import { $, $Events } from '../$';
import { Pin, Pin_M } from '../../Pin';
import { PinOpt } from '../../PinOpt';
import { PinOpts } from '../../PinOpts';
import { Pins } from '../../Pins';
import { System } from '../../system';
import { Spec } from '../../types';
import { Dict } from '../../types/Dict';
import { U, U_EE } from '../../types/interface/U';
import { IO } from '../../types/IO';
import { None } from '../../types/None';
import { UnitBundleSpec } from '../../types/UnitBundleSpec';
import { Unlisten } from '../../types/Unlisten';
import { Memory } from './Memory';
export type PinMap<T> = Dict<Pin<T[keyof T]>>;
export interface ION<I, O> {
    i?: string[];
    o?: string[];
}
export interface Opt {
    input?: PinOpts;
    output?: PinOpts;
}
export declare const DEFAULT_PIN_OPT: PinOpt;
export type PinOf<T> = Pin<T[keyof T]>;
export type UnitEvents<_EE extends Dict<any[]>> = $Events<_EE & U_EE> & U_EE;
export interface U_M {
}
export declare class Unit<I extends Dict<any> = any, O extends Dict<any> = any, _EE extends UnitEvents<_EE> & Dict<any[]> = UnitEvents<U_EE>> extends $<_EE> implements U<I, O> {
    __: string[];
    id: string;
    _parent: Unit | null;
    _input: Pins<I>;
    _output: Pins<O>;
    _data_input: Pins<any>;
    _data_output: Pins<any>;
    _ref_input: Pins<any>;
    _ref_output: Pins<any>;
    protected _i_opt: Dict<PinOpt>;
    protected _o_opt: Dict<PinOpt>;
    protected _i_name_set: Set<string>;
    protected _o_name_set: Set<string>;
    protected _d_i_name: Set<string>;
    protected _d_o_name: Set<string>;
    protected _r_i_name: Set<string>;
    protected _r_o_name: Set<string>;
    protected _o_count: number;
    protected _i_count: number;
    protected _d_i_count: number;
    protected _d_o_count: number;
    protected _r_i_count: number;
    protected _r_o_count: number;
    protected _err: string | null;
    protected _selfInput: Pin;
    protected _selfOutput: Pin<U>;
    ref: any | null;
    _paused: boolean;
    _opt: Opt;
    constructor({ i, o }: ION<I, O>, opt: Opt, system: System, id: string);
    isElement(): boolean;
    isPinIgnored(type: IO, pinId: string): boolean;
    isPinConstant(type: IO, pinId: string): boolean;
    isPinRef(type: IO, pinId: string): boolean;
    setParent(parent: Unit | null): void;
    setPinIgnored(type: IO, pinId: string, ignored: boolean): void;
    setPinConstant(type: IO, pinId: string, constant: boolean): void;
    private _memSetPinOptData;
    private _memSetInputData;
    private _memSetOutputData;
    private _memSetPinRef;
    private _memSetInputRef;
    private _memSetOutputRef;
    setPinRef(type: IO, pinId: string, ref: boolean): void;
    setInputRef(pinId: string, ref: boolean): void;
    setOutputRef(pinId: string, ref: boolean): void;
    setInputIgnored(pinId: string, ignore: boolean): boolean;
    setOutputIgnored(pinId: string, ignore: boolean): boolean;
    setInputs(inputs: Pins<I>, opts?: PinOpts): void;
    setPin(type: IO, pinId: string, pin: Pin<any>, opt?: PinOpt, propagate?: boolean): void;
    setInput<K extends keyof I>(pinId: string, input: Pin<I[K]>, opt?: PinOpt, propagate?: boolean): void;
    _setInput<K extends keyof I>(pinId: K, input: Pin<I[K]>, opt?: PinOpt): void;
    private _memAddDataInput;
    private _memAddRefInput;
    private _validateInputName;
    private _validateOutputName;
    addPin(type: IO, name: string, pin: Pin<any>, opt: PinOpt): void;
    addInput(name: string, input: Pin<any>, opt?: PinOpt): void;
    removeInput(name: string): void;
    private _memRemoveDataInput;
    private _memRemoveRefInput;
    setOutputs(outputs: Pins<O>, opts?: PinOpts): void;
    setOutput<K extends keyof O>(name: K, output: Pin<O[K]>, opt?: PinOpt, propagate?: boolean): void;
    _setOutput<K extends keyof O>(name: K, output: Pin<O[K]>, opt?: PinOpt): void;
    private _memAddRefOutput;
    private _memSetRefOutput;
    private _memAddDataOutput;
    private _memSetDataOutput;
    addOutput(name: string, output: Pin<any>, opt?: PinOpt): void;
    private _memRemoveRefPin;
    private _memRemoveRefOutput;
    private _memRemoveDataOutput;
    removeOutput(name: string): void;
    removePin(type: IO, name: string): void;
    getPin(type: IO, pinId: string): Pin<any>;
    getInputs(): Pins<I>;
    getDataInputs(): Pins<Partial<I>>;
    getRefInputs(): Pins<Partial<I>>;
    getInput(name: string): Pin<any>;
    getOutputs(): Pins<O>;
    getDataOutputs(): Pins<Partial<O>>;
    getRefOutputs(): Pins<Partial<O>>;
    getOutput(name: string): Pin<any>;
    push<K extends keyof I>(name: string, data: any): void;
    pushInput<K extends keyof I>(name: string, data: I[K]): void;
    pushAllInput<K extends keyof I>(data: Dict<I[K]>): void;
    pushOutput<K extends keyof O>(name: string, data: O[K]): void;
    pushAllOutput<K extends keyof O>(data: Dict<O[K]>): void;
    pushAll<K extends keyof I>(data: Dict<I[K]>): void;
    pullInput<K extends keyof I>(name: string): I[K];
    pullOutput<K extends keyof O>(name: string): O[K];
    pullPin<K extends keyof O>(type: IO, name: string): O[K] | I[K];
    takePin<K extends keyof O>(type: IO, name: string): O[K] | I[K];
    takeInput<K extends keyof O>(name: string): O[K];
    takeOutput<K extends keyof O>(name: string): O[K];
    take<K extends keyof O>(name: string): O[K];
    takeAll(): Dict<any>;
    peakInput<K extends keyof I>(name: string): I[K];
    peakOutput<K extends keyof O>(name: string): O[K];
    peak<K extends keyof O>(name: string): O[K];
    peakAllOutput(): Dict<any>;
    peakAll(): Dict<any>;
    hasPinNamed(type: IO, name: string): boolean;
    hasInputNamed(name: string): boolean;
    hasOutputNamed(name: string): boolean;
    hasDataPinNamed(type: IO, name: string): boolean;
    hasDataInputNamed(name: string): boolean;
    hasDataOutputNamed(name: string): boolean;
    hasRefPinNamed(type: IO, name: string): boolean;
    hasRefInputNamed(name: string): boolean;
    renamePin(type: IO, name: string, newName: string): void;
    renameInput(name: keyof I, newName: keyof I, propagate?: boolean): void;
    renameOutput(name: keyof O, newName: keyof O, propagate?: boolean): void;
    getInputOpt(name: string): PinOpt;
    getOutputOpt(name: string): PinOpt;
    hasRefOutputNamed(name: string): boolean;
    getInputCount(): number;
    getOutputCount(): number;
    getInputNames(): string[];
    getOutputNames(): string[];
    setPinData(type: IO, pinId: string, data: any): void;
    removePinData(type: IO, pinId: string): void;
    setInputConstant(pinId: string, constant: boolean): void;
    setOutputConstant(pinId: string, constant: boolean): void;
    getCatchErr(): boolean;
    private _catcherCallback;
    private _catcherDoneCount;
    private _catcherDone;
    protected _catchErr: boolean;
    protected _caughtErr: string | null;
    caughtErr(): string | null;
    catch(callback: (err: string) => void): {
        unlisten: Unlisten;
        done: () => void;
    };
    getConfig(): Opt;
    reset(): void;
    pause(): void;
    play(): void;
    paused(): boolean;
    getSelfPin(): Pin<U>;
    err(err?: string | Error | None): string | null;
    hasErr(): boolean;
    getErr(): string | null;
    takeErr(): string | null;
    takeCaughtErr(): string | null;
    destroy(): void;
    getPinData(type: IO, pinId: string): any;
    getPinsData(): {
        input: Dict<any>;
        output: Dict<any>;
    };
    getInputData(): Partial<I>;
    getRefInputData(): Dict<Unit>;
    getSpec(): Spec;
    getUnitBundleSpec(deep?: boolean): UnitBundleSpec;
    snapshotSelf(): Dict<any>;
    snapshotInput<T extends keyof I>(pinId: T): Pin_M<I[T]>;
    snapshotInputs(): Dict<Pin_M>;
    snapshotOutput<T extends keyof O>(pinId: T): Pin_M<O[T]>;
    snapshotOutputs(): Dict<Pin_M>;
    snapshot(): Memory;
    restoreSelf(state: Dict<any>): void;
    restoreInputs(state: Dict<Pin_M>): void;
    restoreInput(pinId: string, state: Pin_M): void;
    restoreOutputs(state: Dict<Pin_M>): void;
    restoreOutput(pinId: string, state: Pin_M): void;
    restore(state: {
        input?: Dict<any>;
        output?: Dict<any>;
        memory?: Dict<any>;
    }): void;
}
