/// <reference types="react" />
import { FormPageState, ReportBI, WixPatternsContainer, ActionsBarConfig } from '@wix/bex-core';
import { FieldValues, UseFormReturn } from 'react-hook-form';
import { EntityPageStateBIReporter } from './EntityPageStateBIReporter';
import { TypedEmitter } from '@wix/bex-core/events';
import { WixPatternsRouterState } from '../WixPatternsRouterState';
type OnSaveParams = {
    widgetsFormData: {
        [key: string]: any;
    };
};
export interface EntityPageStateParams<T, V extends FieldValues = FieldValues> {
    /**
     * A function that fetches the entity data.
     * @returns a promise that resolves to an object containing the entity.
     */
    fetch: () => Promise<{
        entity: T | undefined;
    }>;
    /**
     * A function to handle the save action.
     * @returns promise that resolves to an object that contains a 'updatedEntity' object.
     */
    onSave: (params: OnSaveParams) => Promise<{
        updatedEntity: T;
    }>;
    /**
     * An optional object with an optional message, or it can directly get a string message.
     */
    saveSuccessToast?: {
        message?: string;
    } | string;
    /**
     * An optional function to display an error toast message when a save operation fails.
     * @returns An object with a `message` and an `action` object. Alternatively, it can return an object with an optional `message` and a `tryAgain` flag, or a string message.
     * The previous return types are still supported but are now deprecated.
     */
    saveErrorToast?: (err: unknown, params: {
        retry: () => void;
    }) => {
        message?: string;
        /**
         * @deprecated use `action` instead
         */
        tryAgain?: boolean;
        action?: {
            text: string;
            onClick: () => void;
        };
    } | string;
    /**
     * An optional function to transform the updated entity data before it is passed to the collection page.
     * @param entity the updated entity.
     * @returns an object representing the entity in the collection page.
     */
    transformEntityToCollectionItem?: (entity: T) => any;
    form: UseFormReturn<V>;
    /**
     * An object representing the container, possibly for dependency injection or component management.
     */
    container: WixPatternsContainer;
    /**
     * A string representing the ID of the parent page.
     * Must be passed if not using Patterns Router
     */
    parentPageId?: string;
    /**
     * A string representing the path of the parent page.
     * Must be passed if using Patterns Router
     */
    parentPath?: string;
    /**
     * An object representing the router state
     */
    routerState?: WixPatternsRouterState | null;
    /**
     * An optional object to override the actions bar.
     */
    actionsBarConfig?: ActionsBarConfig;
    /**
     * Entity fqdn.
     */
    fqdn?: string;
}
export interface EntityPageStateInterface {
}
export interface EntityPageWidgetState {
    validate: () => Promise<{
        isValid: boolean;
        values?: any;
    }>;
    isDirty: boolean;
}
export declare class EntityPageState<T, V extends FieldValues = FieldValues> implements EntityPageStateInterface {
    readonly fetch: EntityPageStateParams<T>['fetch'];
    readonly onSave: EntityPageStateParams<T, V>['onSave'];
    readonly saveSuccessToast?: EntityPageStateParams<T>['saveSuccessToast'];
    readonly saveErrorToast?: EntityPageStateParams<T>['saveErrorToast'];
    readonly transformEntityToCollectionItem: (entity: T) => any;
    _entity: T | null;
    private readonly _parentPageId?;
    private readonly _parentPath?;
    actionsBarConfig?: EntityPageStateParams<T>['actionsBarConfig'];
    readonly container: WixPatternsContainer;
    readonly reportBI: ReportBI;
    readonly bi: EntityPageStateBIReporter<T, V>;
    _routerState: WixPatternsRouterState | null;
    readonly formPage: FormPageState<V>;
    readonly events: TypedEmitter<{
        save: () => void;
        saveError: (err: unknown) => void;
    }>;
    constructor(params: EntityPageStateParams<T, V>);
    init(): () => void;
    retryFetch(): void;
    setEntity(newEntity: T | null): void;
    get entity(): T | null;
    get isFetching(): boolean;
    get form(): UseFormReturn<V, any, V>;
    set isSubmitSuccessful(flag: boolean);
    get isFormDirty(): boolean;
    set _isFormDirty(val: boolean);
    get _withinRouter(): boolean;
    onCancel(): void;
    navigateToParent(updatedEntity?: any): void;
    _showErrorToast(err: any, e?: React.BaseSyntheticEvent): void;
    _showSuccessToast(): void;
    handleSubmit(e?: React.BaseSyntheticEvent): Promise<void>;
    get initTask(): import("@wix/bex-core").TaskState<unknown>;
    get submitTask(): import("@wix/bex-core").TaskState<unknown>;
    private _checkPageParams;
}
export {};
//# sourceMappingURL=EntityPageState.d.ts.map