import type { HydratedEntry } from "./center";
/**
 * This class provides methods to register, un-register, update, and retrieve state, ensuring components are updated efficiently and consistently.
 */
export declare class StateManager<StateType> {
    /**
     * Initial state of the manager.
     */
    protected _initialValue: StateType;
    /**
     * Options to configure the state manager.
     */
    private _configs;
    protected _value: StateType;
    /**
     * The current state change promise.
     *
     * @protected
     * @type {Promise<any>}
     */
    protected _fulfill: Promise<any> | undefined;
    /**
     * Returns the promise to full fill the current state change.
     *
     * @returns the instance of the state manager for method chaining.
     */
    fulfill(): Promise<this>;
    /**
     * A dictionary of callbacks registered in the state manager.
     * The key is the unique identifier of the callback, and the value is the callback function.
     * The callback function receives the new state whenever it is updated.
     */
    protected _callbacks: Record<string, (newState: StateType) => void | Promise<void>>;
    constructor(
    /**
     * Initial state of the manager.
     */
    _initialValue: StateType, 
    /**
     * Options to configure the state manager.
     */
    _configs?: TypeStateManagerConfigs<StateType>);
    get value(): Readonly<StateType>;
    set value(newState: StateType);
    hydrate(value: StateType): HydratedEntry;
    /**
     * Handles setting a new state value.
     *
     * This method clones the new state (if cloning is not disabled) and assigns it to the internal `_value` property.
     * It then logs the new state using the `center._log` method.
     *
     * After logging, it asynchronously triggers the `onChange` callback if it exists,
     * and iterates over the `_callbacks` object to call each callback with the new state.
     *
     * @param newState - The new state to be set.
     */
    protected _setValueHandler(newState: StateType): void;
    /**
     * Gets the unique identifier (uid) from the configuration.
     *
     * @returns {string} The unique identifier.
     */
    get uid(): string;
    /**
     * Registers a new callback in the state manager.
     */
    register({ uid, callback, }: {
        /**
         * Unique identifier for the callback.
         */
        uid: string;
        /**
         * Callback to be registered.
         */
        callback: (newState: StateType) => void | Promise<void>;
    }): this;
    /**
     * Unregister a callback from the state manger.
     */
    unregister({ uid, }: {
        /**
         * Unique identifier of the callback.
         */
        uid: string;
    }): this;
    /**
     * Returns the unique IDs of the registered callbacks.
     */
    get registeredCallbacks(): string[];
    /**
     * Triggers the state manager to update the components.
     */
    trigger(): void;
    /**
     * Resets the state manager to its initial state.
     */
    reset(): void;
    /**
     * Clones the given state value if cloning is not disabled.
     *
     * @param value - The state value to be cloned.
     * @returns The cloned state value if cloning is enabled; otherwise, returns the original value.
     */
    protected _clone(value: StateType): StateType;
    get initialValue(): StateType;
    /**
     * Updates the current state using the provided updater function (it utilizes immer js).
     *
     * @param updater - A function that takes the previous state and returns the new state.
     * @returns The current instance for method chaining.
     */
    update(updater: (prev: StateType) => StateType): this;
}
export type TypeStateManagerConfigs<StateType> = {
    /**
     * Unique identifier for the state manager.
     */
    uid: string;
    /**
     * A callback that receives the new state whenever it is updated.
     * You can utilize "onChange" callback to modify other state manager instances or variables.
     * With "onChange" callback you do not need to cope with creating a unique id to register a callback with "register" method.
     *
     * Important Notes:
     * It will not be unregistered ever.
     * It will be triggered even in the initialization of the state manager.
     *
     * @param newState
     * @returns void
     */
    onChange?: (newState: StateType) => void;
    /**
     * Disables cloning for the state manager.
     */
    disableCloning?: boolean;
};
