import { BlueBaseModuleRegistry, BlueBaseModuleRegistryInputItem, BlueBaseModuleRegistryItem } from './BlueBaseModuleRegistry';
import { MaybeArray, MaybeBlueBaseModule, MaybeThunk, Omit } from '../utils';
import { BlueBase } from '../BlueBase';
import { ItemCollection } from './Registry';
/**
 * Default priority for a hook.
 */
export declare const DEFAULT_HOOK_PRIORITY = 10;
/**
 * The handler function of a hook object. This is the function that is
 * called for each hook, during execution.
 *
 * This may or may not be an async function.
 *
 * @param value The input value
 * @param args Any arguments passed on to the listener by the caller
 * @param BB The BlueBase context
 *
 * @returns Original or mutated version of input value. May be a promise that resolves the value.
 */
export declare type HookHandlerFn<T = any> = (value: T, args: {
    [key: string]: any;
}, BB: BlueBase) => T | Promise<T>;
/**
 * Properties of a Hook item.
 */
export interface HookRegistryItemProps {
    /**
     * Priority of exeuction.
     *
     * @default 10
     */
    priority: number;
    /**
     * ID of event to subscribe to
     */
    event: string;
    [key: string]: any;
}
export declare type HookRegistryItem = BlueBaseModuleRegistryItem<HookHandlerFn> & HookRegistryItemProps;
export interface HookRegistryInputItem extends BlueBaseModuleRegistryInputItem<HookHandlerFn> {
    /**
     * ID of event to subscribe to
     */
    event: string;
}
declare type ItemType = HookRegistryItem;
declare type ItemInputType = HookRegistryInputItem;
/**
 * Hook Type.
 */
export declare type Hook = HookRegistryItemProps & {
    value: HookHandlerFn;
};
/**
 * HookInput.
 */
export declare type HookInput = HookRegistryInputItem;
export declare type HookInputCollection = ItemCollection<HookInput>;
/**
 * A nested hook collection.
 */
export declare type HookNestedCollection<T = Omit<HookInput, 'event'> | HookHandlerFn> = MaybeThunk<{
    [event: string]: MaybeArray<MaybeBlueBaseModule<T>>;
}>;
/**
 * 🎣 HookRegistry
 */
export declare class HookRegistry extends BlueBaseModuleRegistry<ItemType, ItemInputType> {
    /**
     * Registers a nested hook collection.
     *
     * @param collections
     */
    registerNestedCollection(collections?: HookNestedCollection): Promise<void>;
    /**
     * Get all hooks for a specific event
     * @param event
     */
    findAllByEvent(event: string): {
        [key: string]: HookRegistryItem;
    };
    /**
     * Run all hook listeners in a waterfall.
     * Each listener function gets 3 arguments:
     * 	- value
     * 	- args
     * 	- context
     *
     * Each listener function is expected to return a value.
     *
     * Example Usage: BB.Hooks.run('hook-name', val, args);
     *
     * @param eventName Name of the hook
     * @param value Initial value to send to the hook
     * @param args Any extra arguments to pass to the hook
     */
    run<T = any>(eventName: string, initialValue: T, args?: {
        [key: string]: any;
    }): Promise<T>;
    /**
     * Typeguard to check a given object is an input value
     * @param value
     */
    protected isInputValue(value: any): value is ItemInputType['value'];
    /**
     * Typeguard to check a given object is a input item
     * @param item
     */
    protected isInputItem(item: any): item is ItemInputType;
    /**
     * Convert any input value to an item. This is where you transform inputs and add defualts
     * @param key
     * @param partial
     */
    protected createItem(key: string, partial: any): HookRegistryItem;
}
export {};
