import { FormErrors } from '@page-speed/forms/integration';
import { ReactNode } from 'react';

type PageSpeedFormMethod = "post" | "get" | "put" | "patch";
type PageSpeedFormSubmissionFormat = "json" | "rails";
type PageSpeedFormSubmissionBehavior = "showConfirmation" | "redirect" | "renderCustomComponent";
interface PageSpeedFormSubmissionResult {
    formData: Record<string, any>;
    responseData: unknown;
}
interface PageSpeedFormSubmissionConfig {
    /**
     * Post-submit behavior.
     * @default "showConfirmation"
     */
    behavior?: PageSpeedFormSubmissionBehavior;
    /**
     * Optional callback triggered on successful submission.
     * Always invoked regardless of `behavior`.
     */
    handleFormSubmission?: (result: PageSpeedFormSubmissionResult) => void | Promise<void>;
    /**
     * Redirect destination used when behavior is "redirect".
     */
    redirectUrl?: string;
    /**
     * Custom component that replaces default confirmation when
     * behavior is "renderCustomComponent".
     */
    customComponent?: ReactNode;
    /**
     * Optional action to allow a fresh submission after success.
     */
    newFormSubmissionAction?: {
        /**
         * Defaults to true when `label` is provided, otherwise false.
         */
        enable?: boolean;
        label?: string;
    };
}
interface PageSpeedFormConfig {
    /**
     * API endpoint used for submission (also applied to form action).
     */
    endpoint?: string;
    /**
     * HTTP method for submission.
     * @default "post"
     */
    method?: PageSpeedFormMethod;
    /**
     * Submission format.
     * Defaults to "rails" when apiKey is present, otherwise "json".
     */
    format?: PageSpeedFormSubmissionFormat;
    /**
     * Additional headers for the submission request.
     */
    headers?: Record<string, string>;
    /**
     * Static values merged into the payload (e.g. subject, content).
     */
    values?: Record<string, unknown>;
    /**
     * Rails API key (required for rails format).
     */
    apiKey?: string;
    /**
     * Rails contact category token.
     */
    contactCategoryToken?: string;
    /**
     * Rails location ID.
     */
    locationId?: string;
    /**
     * Rails website ID.
     */
    websiteId?: string;
    /**
     * Rails website form assignment ID.
     */
    websiteFormAssignmentId?: string;
    /**
     * Rails visitor IP address override.
     */
    visitorIpAddress?: string;
    /**
     * Reset form values after a successful submission.
     * @default true
     */
    resetOnSuccess?: boolean;
    /**
     * Optional post-submission behavior configuration.
     */
    submissionConfig?: PageSpeedFormSubmissionConfig;
}
declare class PageSpeedFormSubmissionError extends Error {
    formErrors?: FormErrors;
    status?: number;
    constructor(message: string, options?: {
        formErrors?: FormErrors;
        status?: number;
    });
}
declare function isValidEmail(value: string): boolean;
declare function submitPageSpeedForm(values: Record<string, any>, config?: PageSpeedFormConfig): Promise<unknown>;

export { type PageSpeedFormConfig as P, PageSpeedFormSubmissionError as a, type PageSpeedFormMethod as b, type PageSpeedFormSubmissionFormat as c, isValidEmail as i, submitPageSpeedForm as s };
