import { z } from 'zod';
import { PaykitMetadata } from '../resources/metadata.js';

type Result<T, E = unknown> = {
    ok: true;
    value: T;
    error?: never;
} | {
    ok: false;
    value?: never;
    error: E;
};
declare const OK: <V>(value: V) => Result<V, never>;
declare const ERR: <E>(error: E) => Result<never, E>;
declare const unwrapAsync: <T>(pr: Promise<Result<T, unknown>>) => Promise<T>;
declare function safeParse<Inp, Out>(rawValue: Inp, fn: (value: Inp) => Out, errorMessage: string): Result<Out, Error>;
declare const safeEncode: <T>(value: T) => Result<string, Error>;
declare const safeDecode: <T>(value: string) => Result<T, Error>;
declare function executeWithRetryWithHandler<T>(apiCall: () => Promise<T>, errorHandler: (error: any, attempt: number) => {
    retry: boolean;
    data: unknown;
}, maxRetries?: number, baseDelay?: number, currentAttempt?: number): Promise<T>;
declare function buildError(message: string, cause?: unknown): Error;
declare const validateRequiredKeys: <K extends string>(requiredKeys: readonly K[], source: Record<K, string>, errorMessage: string | ((missingKeys: K[]) => string), errorInstance?: (message: string) => Error) => Record<K, string>;
declare const parseJSON: <T>(str: string, schema: z.ZodSchema<T>) => T | null;
/**
 * Validates that a Zod schema exactly matches a TypeScript interface.
 * Preserves all Zod methods while ensuring type safety.
 *
 * @example
 * export const mySchema = schema<MyInterface>()(z.object({ ... }));
 */
declare const schema: <TInterface>() => <TSchema extends z.ZodType<any>>(schema: TSchema & (z.infer<TSchema> extends TInterface ? TInterface extends z.infer<TSchema> ? unknown : never : never)) => TSchema;
declare const omitInternalMetadata: (metadata: Record<string, any>, internalKeys?: string[]) => PaykitMetadata;
/**
 * Safely converts metadata values to strings for provider storage.
 * Only stringifies non-string values to prevent nested JSON escaping.
 *
 * @example
 * stringifyMetadataValues({ count: 5, name: "John" })
 * // => { count: "5", name: "John" }
 *
 * stringifyMetadataValues({ data: { nested: true } })
 * // => { data: "{\"nested\":true}" }
 */
declare const stringifyMetadataValues: (metadata: Record<string, any>) => Record<string, string>;
declare const getURLFromHeaders: (headers: Record<string, string>) => string;
declare const refundReasonMatcher: (matcher: string) => "duplicate" | "fraudulent" | "requested_by_customer" | "other";

export { ERR, OK, type Result, buildError, executeWithRetryWithHandler, getURLFromHeaders, omitInternalMetadata, parseJSON, refundReasonMatcher, safeDecode, safeEncode, safeParse, schema, stringifyMetadataValues, unwrapAsync, validateRequiredKeys };
