import { FetchRequest, FetchMethod } from "../../http/fetch_request";
import { FetchResponse } from "../../http/fetch_response";
export interface FormSubmissionDelegate {
    formSubmissionStarted(formSubmission: FormSubmission): void;
    formSubmissionSucceededWithResponse(formSubmission: FormSubmission, fetchResponse: FetchResponse): void;
    formSubmissionFailedWithResponse(formSubmission: FormSubmission, fetchResponse: FetchResponse): void;
    formSubmissionErrored(formSubmission: FormSubmission, error: Error): void;
    formSubmissionFinished(formSubmission: FormSubmission): void;
}
export type FormSubmissionResult = {
    success: boolean;
    fetchResponse: FetchResponse;
} | {
    success: false;
    error: Error;
};
export declare enum FormSubmissionState {
    initialized = 0,
    requesting = 1,
    waiting = 2,
    receiving = 3,
    stopping = 4,
    stopped = 5
}
declare enum FormEnctype {
    urlEncoded = "application/x-www-form-urlencoded",
    multipart = "multipart/form-data",
    plain = "text/plain"
}
export type TurboSubmitStartEvent = CustomEvent<{
    formSubmission: FormSubmission;
}>;
export type TurboSubmitEndEvent = CustomEvent<{
    formSubmission: FormSubmission;
} & {
    [K in keyof FormSubmissionResult]?: FormSubmissionResult[K];
}>;
export declare class FormSubmission {
    readonly delegate: FormSubmissionDelegate;
    readonly formElement: HTMLFormElement;
    readonly submitter?: HTMLElement;
    readonly formData: FormData;
    readonly location: URL;
    readonly fetchRequest: FetchRequest;
    readonly mustRedirect: boolean;
    state: FormSubmissionState;
    result?: FormSubmissionResult;
    originalSubmitText?: string;
    static confirmMethod(message: string, _element: HTMLFormElement, _submitter: HTMLElement | undefined): Promise<boolean>;
    constructor(delegate: FormSubmissionDelegate, formElement: HTMLFormElement, submitter?: HTMLElement, mustRedirect?: boolean);
    get method(): FetchMethod;
    get action(): string;
    get body(): FormData;
    get enctype(): FormEnctype;
    get isSafe(): boolean;
    get stringFormData(): [string, string][];
    start(): Promise<void | FetchResponse>;
    stop(): true | undefined;
    prepareRequest(request: FetchRequest): void;
    requestStarted(_request: FetchRequest): void;
    requestPreventedHandlingResponse(request: FetchRequest, response: FetchResponse): void;
    requestSucceededWithResponse(request: FetchRequest, response: FetchResponse): void;
    requestFailedWithResponse(request: FetchRequest, response: FetchResponse): void;
    requestErrored(request: FetchRequest, error: Error): void;
    requestFinished(_request: FetchRequest): void;
    setSubmitsWith(): void;
    resetSubmitterText(): void;
    requestMustRedirect(request: FetchRequest): boolean;
    requestAcceptsTurboStreamResponse(request: FetchRequest): boolean;
    get submitsWith(): string | null | undefined;
}
export {};
