import { EventBus } from 'pullable-event-bus';
import { HandlerMsg, HandlerObject } from './handler';
import { InterfaceHelpers } from './interface';
import { InputHelpers } from './input';
import { Module } from './module';
export interface Component<S extends State> {
    state?: S;
    inputs?: Inputs<S>;
    actions?: Actions<S>;
    interfaces: Interfaces;
    groups?: {
        [name: string]: Group;
    };
}
export interface State {
    [prop: string]: any;
    _nest?: Components<any>;
    _compNames?: string[];
    _compUpdated?: boolean;
}
export interface Components<S> {
    [name: string]: Component<S>;
}
export interface Interfaces {
    [name: string]: Interface<any, any>;
}
export declare type Group = any;
export interface Inputs<S> {
    (s?: S, F?: InputHelpers<S>): InputIndex;
}
export interface InputIndex {
    onInit?: Input;
    onDestroy?: Input;
    onRouteActive?: Input;
    onRouteInactive?: Input;
    [name: string]: Input;
}
export interface Input {
    (data?: any): void;
}
export interface Action<S> {
    (data?: any): Update<S> | Promise<Update<S>>;
}
export interface Actions<S> {
    [name: string]: Action<S>;
}
export interface EventOptions {
    default?: boolean;
    listenPrevented?: boolean;
    selfPropagated?: boolean;
}
export interface InputData extends Array<any> {
    0: string;
    1: string;
    2?: any;
    3?: any;
    4?: EventOptions;
}
export interface EventData extends Array<any> {
    0: string;
    1: string;
    2?: any;
}
export interface Update<S> {
    (state: S): Promise<void | S> | void | S;
}
export interface Interface<Type, S> {
    (state: S, F: InterfaceHelpers<S>): Promise<Type>;
}
export interface InterfaceIndex {
    [name: string]: Interface<any, any>;
}
export interface Task extends Array<any> {
    0: string;
    1?: HandlerMsg;
}
export interface Context<S> {
    id: string;
    name: string;
    state: S;
    inputs: InputIndex;
    actions: Actions<any>;
    interfaces: InterfaceIndex;
    interfaceHelpers: InterfaceHelpers<S>;
    interfaceValues: {
        [name: string]: any;
    };
    groups: {
        [name: string]: Group;
    };
    components: ContextIndex<S>;
    groupHandlers: {
        [name: string]: HandlerObject;
    };
    taskHandlers: {
        [name: string]: HandlerObject;
    };
    interfaceHandlers: {
        [name: string]: HandlerObject;
    };
    global: {
        record: boolean;
        records: ActionRecord[];
        log: boolean;
        render: boolean;
        moduleRender: boolean;
        hotSwap: boolean;
        rootCtx: Context<S>;
        active: boolean;
    };
    eventBus: EventBus;
    beforeInput?(ctxIn: Context<S>, inputName: string, data: any): void;
    afterInput?(ctxIn: Context<S>, inputName: string, data: any): void;
    warn: {
        (source: string, description: string): void;
    };
    error: {
        (source: string, description: string): void;
    };
}
export interface ActionRecord {
    id: string;
    actionName: string;
    value: any;
}
export interface ContextIndex<S> {
    [id: string]: Context<S>;
}
export interface RunModule {
    (root: Component<any>, DEV: boolean, options?: any, viewCb?: any): Promise<Module>;
}
