import { destructor } from '@synnaxlabs/x';
import { z } from 'zod';
import { base } from './base';
import { Result } from './result';
import { RetrieveMountListenersParams, RetrieveParams } from './retrieve';
import { UpdateParams } from './update';
import { Form } from '../form';
export interface FormUpdateParams<Schema extends z.ZodType<base.Shape>, ScopedStore extends base.Store = {}> extends Omit<UpdateParams<z.infer<Schema>, ScopedStore>, "data" | "onChange">, Omit<Form.UseReturn<Schema>, "setStatus"> {
}
export interface FormRetrieveParams<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store = {}> extends Form.UseReturn<Schema>, RetrieveParams<Query, Store> {
}
export interface CreateFormParams<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> {
    name: string;
    schema: Schema;
    initialValues: z.infer<Schema>;
    update: (args: FormUpdateParams<Schema, Store>) => Promise<void>;
    retrieve: (args: FormRetrieveParams<Query, Schema, Store>) => Promise<void>;
    mountListeners?: (args: FormMountListenersParams<Query, Schema, Store>) => destructor.Destructor | destructor.Destructor[];
}
export type UseFormReturn<Schema extends z.ZodType<base.Shape>> = Omit<Result<z.infer<Schema>>, "data"> & {
    form: Form.UseReturn<Schema>;
    save: (opts?: base.FetchOptions) => void;
};
export interface FormBeforeSaveParams<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> extends Form.UseReturn<Schema>, RetrieveParams<Query, Store> {
}
interface FormMountListenersParams<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> extends Form.UseReturn<Schema>, Omit<RetrieveMountListenersParams<Query, base.Shape, Store>, "onChange"> {
}
export interface AfterSaveParams<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> extends FormBeforeSaveParams<Query, Schema, Store> {
}
export interface BeforeValidateArgs<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> extends FormBeforeSaveParams<Query, Schema, Store> {
}
export interface UseFormArgs<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> extends Pick<Form.UseArgs<Schema>, "sync" | "onHasTouched" | "mode"> {
    initialValues?: z.infer<Schema>;
    autoSave?: boolean;
    query: Query;
    beforeValidate?: (args: BeforeValidateArgs<Query, Schema, Store>) => boolean | void;
    beforeSave?: (args: FormBeforeSaveParams<Query, Schema, Store>) => Promise<boolean>;
    afterSave?: (args: AfterSaveParams<Query, Schema, Store>) => void;
    scope?: string;
}
export interface UseForm<Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store> {
    (args: UseFormArgs<Query, Schema, Store>): UseFormReturn<Schema>;
}
export declare const createForm: <Query extends base.Shape, Schema extends z.ZodType<base.Shape>, Store extends base.Store = {}>({ name, schema, retrieve, mountListeners, update, initialValues: baseInitialValues, }: CreateFormParams<Query, Schema, Store>) => UseForm<Query, Schema, Store>;
export {};
//# sourceMappingURL=form.d.ts.map