import { Destructor } from '@synnaxlabs/x';
import { z } from 'zod';
import { core } from './core';
import { Result } from './result';
import { RetrieveMountListenersParams, RetrieveParams } from './retrieve';
import { UpdateParams } from './update';
import { Form } from '../form';
export interface FormUpdateParams<Schema extends z.ZodType<core.Shape>, ScopedStore extends core.Store = {}> extends Omit<UpdateParams<z.infer<Schema>, ScopedStore>, "data" | "onChange">, Omit<Form.UseReturn<Schema>, "setStatus"> {
}
export interface FormRetrieveParams<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store = {}> extends Form.UseReturn<Schema>, RetrieveParams<Query, Store> {
}
export interface CreateFormParams<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.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[];
}
export type UseFormReturn<Schema extends z.ZodType<core.Shape>> = Omit<Result<z.infer<Schema>>, "data"> & {
    form: Form.UseReturn<Schema>;
    save: (opts?: core.FetchOptions) => void;
};
export interface FormBeforeSaveParams<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store> extends Form.UseReturn<Schema>, RetrieveParams<Query, Store> {
}
interface FormMountListenersParams<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store> extends Form.UseReturn<Schema>, Omit<RetrieveMountListenersParams<Query, core.Shape, Store>, "onChange"> {
}
export interface AfterSaveParams<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store> extends FormBeforeSaveParams<Query, Schema, Store> {
}
export interface BeforeValidateArgs<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store> extends FormBeforeSaveParams<Query, Schema, Store> {
}
export interface UseFormArgs<Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.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 core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store> {
    (args: UseFormArgs<Query, Schema, Store>): UseFormReturn<Schema>;
}
export declare const createForm: <Query extends core.Shape, Schema extends z.ZodType<core.Shape>, Store extends core.Store = {}>({ name, schema, retrieve, mountListeners, update, initialValues: baseInitialValues, }: CreateFormParams<Query, Schema, Store>) => UseForm<Query, Schema, Store>;
export {};
//# sourceMappingURL=form.d.ts.map