import { AdaptableState } from '../AdaptableState/AdaptableState';
/**
 * Options related to Adaptable State hydration / dehydration; allows users to intercept state persistence and loading with custom functionality
 */
export interface StateOptions {
    /**
     * Allows customization of Adaptable State loading
     */
    loadState?: AdaptableLoadStateFunction;
    /**
     * Allows hooking into Adaptable State hydration
     */
    applyState?: (state: any) => any;
    /**
     * Allows customization of Adaptable State about to be persisted
     */
    saveState?: AdaptableSaveStateFunction;
    /**
     * Allows customization of Adaptable State persistence
     */
    persistState?: AdaptablePersistStateFunction;
    /**
     * Allows clearing of remote Adaptable State
     *
     * @defaultValue undefined
     */
    clearState?: AdaptableClearStateFunction;
    /**
     * Delay (in ms) to debounce `saveState` / `persistState` calls enabling grouping multiple sequential calls in single one (e.g. elevator doors)
     *
     * **Defaults to: 400**. Also, the wait will be max 1000ms, at which point the save/persist calls will happen anyway.
     *
     * @defaultValue 400
     */
    debounceStateDelay?: number;
    /**
     * Automatically migrate State from previous AdapTable version to current one
     *
     * @defaultValue true
     */
    autoMigrateState?: boolean;
}
/**
 * State Function Config object passed into all State Options functions (except 'applyState')
 */
export interface AdaptableStateFunctionConfig {
    /**
     * Id of current Adaptable instance
     */
    adaptableId: string;
    /**
     * State Key being used
     */
    adaptableStateKey: string;
    /**
     * current Adaptable user
     */
    userName: string;
}
/**
 * Allows customization of state persistence - used `persistState` function in StateOptions
 *
 * @example
 * ```
 * persistState = (state, stateFunctionConfig) => {
 *  localStorage.setItem(stateFunctionConfig.adaptableStateKey, JSON.stringify(state))
 * }
 * ```
 */
export interface AdaptablePersistStateFunction {
    (state: any, adaptableStateFunctionConfig: AdaptableStateFunctionConfig): Promise<any>;
}
/**
 * Allows clearing state when a custom persistState is used.
 * Only called by StateApi.reloadInitialState
 */
export interface AdaptableClearStateFunction {
    (adaptableStateFunctionConfig: AdaptableStateFunctionConfig): Promise<any>;
}
/**
 * Allows the customization state persistence - used by `saveState` function in StateOptions
 */
export interface AdaptableSaveStateFunction {
    (state: AdaptableState, adaptablestatefunctionconfig: AdaptableStateFunctionConfig): any;
}
/**
 * Allows customization of state loading - used by `loadState` function in StateOptions
 */
export interface AdaptableLoadStateFunction {
    (config: AdaptableStateFunctionConfig): Promise<any>;
}
