import { Pin } from '../../Pin';
import { Primitive } from '../../Primitive';
import { State } from '../../State';
import { System } from '../../system';
import { GraphComponentSpec, GraphMergeSpec, GraphMergesSpec, GraphPinSpec, GraphPinsSpec, GraphSpec, GraphSubPinSpec, GraphUnitOuterSpec, GraphUnitSpec, GraphUnitsSpec } from '../../types';
import { BundleSpec } from '../../types/BundleSpec';
import { Dict } from '../../types/Dict';
import { GraphState } from '../../types/GraphState';
import { C, C_EE } from '../../types/interface/C';
import { Component_ } from '../../types/interface/Component';
import { G, G_EE } from '../../types/interface/G';
import { U } from '../../types/interface/U';
import { IO } from '../../types/IO';
import { IOOf, _IOOf } from '../../types/IOOf';
import { UnitBundle } from '../../types/UnitBundle';
import { UnitBundleSpec } from '../../types/UnitBundleSpec';
import Merge from '../Merge';
import { Stateful_EE } from '../Stateful';
import { Unit, UnitEvents } from '../Unit';
export declare type Graph_EE = G_EE & C_EE & Stateful_EE;
export declare type GraphEvents = UnitEvents<Graph_EE> & Graph_EE;
export declare class Graph<I = any, O = any> extends Primitive<I, O, GraphEvents> implements G, C, U {
    __: string[];
    private _element;
    private _spec;
    private _unit;
    private _merge;
    private _pipedFrom;
    private _pipedTo;
    private _errUnitIds;
    private _pin;
    private _unitPins;
    private _exposedPin;
    private _exposedMerge;
    private _exposedEmptySubPin;
    private _mergeToSelfUnit;
    private _selfUniToMerge;
    private _pinToMerge;
    private _branch;
    private _mergePinCount;
    private _unitToMerge;
    private _unitToMergeCount;
    private _children;
    private _waitAll;
    constructor(spec: GraphSpec, branch: Dict<true>, system: System, id?: string);
    private _getExposedSubPinNodeId;
    private _setBranch;
    private _memSetBranch;
    private _simSetBranch;
    private _memRemoveBranch;
    private _simRemoveBranch;
    private _removeBranch;
    private _ensureMergePin;
    private _memEnsureMergePin;
    private _removeMergeOutput;
    private _memRemoveMergeOutput;
    private _simRemoveMergeOutput;
    private _plugPinToMerge;
    private _memPlugPinToMerge;
    private _simPlugPinToMerge;
    private _simUnplugPinFromMerge;
    private _simUnplugPinFromUnitPin;
    private _plugPinToUnitPin;
    private _memPlugPinToUnitPin;
    private _simPlugPinToUnitPin;
    private setExposedSubPin;
    private _setExposedSubPin;
    private _memSetExposedSubPin;
    private _simSetExposedSubPin;
    private _simRemoveExposedSubPin;
    private _takeErr;
    private _nextErr;
    private _destroy;
    private _reset;
    private _play;
    private _pause;
    private _removeErrUnit;
    private _validateMergeId;
    private _validateUnitId;
    isElement(): boolean;
    setElement(): void;
    setNotElement(): void;
    getSpec: () => GraphSpec;
    getComponentSpec: () => GraphComponentSpec;
    getBundleSpec(deep?: boolean): BundleSpec;
    getUnitBundleSpec(): UnitBundleSpec;
    snapshotSelf(): Dict<any>;
    restoreSelf(state: Dict<any>): void;
    getGraphUnitSpec(id: string): GraphUnitSpec;
    refUnits: () => Dict<Unit>;
    refMergePin: (mergeId: string, type: IO) => Pin;
    exposeOutputSets: (outputs: GraphPinsSpec) => void;
    private _exposeOutputSets;
    exposeOutputSet: (input: GraphPinSpec, pinId: string) => void;
    private _exposeOutputSet;
    exposeOutput: (subPinId: string, pinSpec: GraphSubPinSpec, id: string) => void;
    coverOutputSet: (id: string) => void;
    coverOutput: (subPinId: string, id: string) => void;
    plugOutput: (subPinId: string, subPin: GraphSubPinSpec, id: string) => void;
    unplugOutput: (subPinId: string, id: string) => void;
    _unplugOutput: (subPinId: string, id: string) => void;
    isExposedOutput(pin: GraphSubPinSpec): boolean;
    getExposedOutput(pin: GraphSubPinSpec): string;
    exposeInputSets: (inputs: GraphPinsSpec) => void;
    private _exposeInputSets;
    private _initInputSets;
    private _initOutputSets;
    exposeInputSet: (input: GraphPinSpec, pinId: string) => void;
    private _exposeInputSet;
    exposePinSet: (type: IO, pinId: string, pinSpec: GraphPinSpec, emit?: boolean, exposedPin?: Pin, exposedMerge?: Merge, propagate?: boolean) => void;
    _exposePinSet: (type: IO, pinId: string, pinSpec: GraphPinSpec, exposedPin?: Pin<any>, exposedMerge?: Merge<any>, propagate?: boolean) => void;
    _initPinSet: (type: IO, pinId: string, pinSpec: GraphPinSpec, exposedPin?: Pin<any>, exposedMerge?: Merge<any>, propagate?: boolean) => void;
    _specExposePinSet: (type: IO, pinId: string, pinSpec: GraphPinSpec, exposedPin?: Pin<any>, exposedMerge?: Merge<any>, propagate?: boolean) => void;
    memExposePinSet: (type: IO, pinId: string, pinSpec: GraphPinSpec, exposedPin: Pin, exposedMerge: Merge) => void;
    private _memExposePinSet;
    private _simExposePinSet;
    setPinSetFunctional(type: IO, name: string, functional: boolean): void;
    setPinSetId(type: IO, pinId: string, nextPinId: string): void;
    _setPinSetId(type: IO, pinId: string, nextPinId: string): void;
    exposePin: (type: IO, pinId: string, subPinId: string, subPinSpec: GraphSubPinSpec, emit?: boolean) => void;
    private _exposePin;
    private _specExposePin;
    private _memExposePin;
    private _simExposePin;
    exposeInput: (subPinId: string, pinSpec: GraphSubPinSpec, pinId: string, emit?: boolean) => void;
    coverInputSet: (id: string) => void;
    coverInput: (subPinId: string, id: string) => void;
    coverPinSet: (type: IO, id: string, emit?: boolean) => void;
    _coverPinSet: (type: IO, id: string) => void;
    private _memCoverPinSet;
    private _specCoverPinSet;
    private _simCoverPinSet;
    private _specSetPinRef;
    private _memPlugPin;
    private _specPlugPin;
    plugPin: (type: IO, pinId: string, subPinId: string, subPinSpec: GraphSubPinSpec) => void;
    private _plugPin;
    private _simPlugPin;
    plugInput: (subPinId: string, subPin: GraphSubPinSpec, id: string) => void;
    unplugInput: (subPinId: string, id: string) => void;
    _unplugInput: (subPinId: string, id: string) => void;
    coverPin: (type: IO, pinId: string, subPinId: string, emit?: boolean) => void;
    private _coverPin;
    private _specCoverPin;
    private _memCoverPin;
    private _simCoverPin;
    getSubPinSpec: (type: IO, pinId: string, subPinId: string) => GraphSubPinSpec;
    unplugPin: (type: IO, pinId: string, subPinId: string) => void;
    private _unplugPin;
    private _specUnplugPin;
    private _memUnplugPin;
    private _memPlugEmptyPin;
    private _simUnplugPin;
    private __simUnplugPin;
    private _simPlugEmptyPin;
    private _memUnplugInput;
    private _memUnplugOutput;
    private _simUnplugInput;
    private _simUnplugOutput;
    isExposedInput(pin: GraphSubPinSpec): boolean;
    getExposedInputPin: (id: string) => Pin<I[keyof I]>;
    getExposedOutputPin: (id: string) => Pin<O[keyof O]>;
    getExposedPinSpec(type: IO, pinId: string): GraphPinSpec;
    isExposedInputPinId(pinId: string): boolean;
    isExposedOutputPinId(pinId: string): boolean;
    getExposedInputSpec(pinId: string): GraphPinSpec;
    getExposedInputSpecs(): GraphPinsSpec;
    getExposedOutputSpec(pinId: string): GraphPinSpec;
    getExposedOutputSpecs(): GraphPinsSpec;
    hasUnit(id: string): boolean;
    hasMerge(id: string): boolean;
    hasPlug(type: IO, pinId: string, subPinId: string): boolean;
    refUnit(id: string): Unit<any, any>;
    refGraph(id: string): Graph;
    removeUnitGhost(unitId: string, nextUnitId: string, spec: GraphSpec, emit?: boolean): {
        specId: string;
        bundle: UnitBundleSpec;
    };
    addUnitGhost(unitId: string, nextUnitId: string, nextUnitBundle: UnitBundleSpec, nextUnitPinMap: IOOf<Dict<string>>, emit?: boolean): void;
    getUnitOuterSpec: (unitId: string) => GraphUnitOuterSpec;
    private _addUnitGhost;
    private _removeUnitGhost;
    swapUnitGhost(unitId: string, nextUnitId: string, nextUnitBundle: UnitBundleSpec): {
        spec_id: string;
        state: {
            input: Dict<any>;
            output: Dict<any>;
            memory: Dict<any>;
        };
    };
    getUnitByPath(path: string[]): Unit<any, any>;
    read(): State;
    write(state: State): void;
    setGraphState(state: State): Promise<void>;
    getUnitState(unitId: string): State;
    getGraphState(): GraphState;
    getGraphChildren(): Dict<any>;
    getUnitPin(id: string, type: IO, pinId: string): Pin;
    getUnitPinData(id: string, type: IO, pinId: string): {
        input: Dict<any>;
        output: Dict<any>;
    };
    getUnitInput(id: string, pinId: string): Pin;
    getUnitOutput(id: string, pinId: string): Pin;
    setUnitErr(unitId: string, err: string): void;
    takeUnitErr(unitId: string): string | null;
    getGraphPinData: () => object;
    getGraphMergeInputData: () => Dict<any>;
    getGraphErr: () => Dict<string | null>;
    getUnitInputData: (unitId: string) => Dict<any>;
    refMerges(): {
        [id: string]: Merge;
    };
    refPlugs(): IOOf<Dict<Dict<Pin>>>;
    refMerge(mergeId: string): Merge;
    refExposedMerges(): Dict<Merge>;
    getUnitCount(): number;
    getMergeCount(): number;
    findMergeExposedSubPin(type: IO, mergeId: string): {
        pinId: string;
        subPinId: string;
    } | null;
    getUnitsSpec(): GraphUnitsSpec;
    getMergesSpec(): GraphMergesSpec;
    getMergeSpec(mergeId: string): GraphMergeSpec;
    getMergeUnitCount(mergeId: string): number;
    getMergePinCount(mergeId: string): number;
    getPinPlugCount(type: IO, pinId: string): number;
    addUnit: (unitId: string, unit: Unit, emit?: boolean) => void;
    private _fork;
    private _initAddUnit;
    private _initAddUnits;
    private _addUnit;
    addUnitSpecs: (units: GraphUnitsSpec) => void;
    private _addUnitSpecs;
    private injectSubComponent;
    private _simInjectSubComponent;
    private _injectSubComponent;
    private _specInjectSubComponent;
    private componentAppend;
    private _specAppendRoot;
    private componentRemove;
    private _specComponentRemoveChild;
    removeSubComponent: (unitId: string) => void;
    private _specRemoveSubComponent;
    private _getSubComponentParentId;
    private _appendSubComponentChild;
    private _simRemoveSubComponentFromParent;
    private _specRemoveSubComponentChild;
    private _specRemoveSubComponentFromParent;
    private _simSubComponentRemoveChild;
    private _specSubComponentAppendChild;
    private _simSubComponentAppendChild;
    private _unitUnlisten;
    addUnitSpec(unitId: string, unitSpec: UnitBundleSpec, emit?: boolean): Unit;
    addUnitBundle: (unitId: string, unitBundle: UnitBundle) => void;
    _addUnitBundle: (unitId: string, unitBundle: UnitBundle) => void;
    _addUnitBundleSpec(unitId: string, unitBundle: UnitBundleSpec): Unit;
    private _initAddUnitBundleSpecs;
    private _initAddUnitBundleSpec;
    private _onUnitErr;
    private _specAddUnit;
    private _memAddUnit;
    private _simAddUnit;
    private _on_unit_element;
    private _on_unit_not_element;
    removeUnit(unitId: string, emit?: boolean): Unit;
    cloneUnit(unitId: string, newUnitId: string): Unit;
    private _cloneUnit;
    private _moveUnit;
    moveUnit(id: string, unitId: string, inputId: string): void;
    private removeUnitFromMerge;
    private _removeUnitFromMerges;
    private _memRemoveUnitFromMerges;
    private _simRemoveUnitFromMerges;
    private _removeUnitFromMerge;
    private _memRemoveUnitFromMerge;
    private _simRemoveUnitFromMerge;
    private _specRemoveUnitFromMerge;
    private _forEachUnitPinOnMerge;
    private _removeUnit;
    private _specRemoveUnit;
    private _memRemoveUnit;
    private _simRemoveUnit;
    private _specUnplugUnit;
    private _simUnplugUnit;
    addMerges: (merges: GraphMergesSpec) => void;
    private _addMerges;
    private _initMerges;
    private _initMerge;
    addMerge: (mergeSpec: GraphMergeSpec, mergeId: string, emit?: boolean, propagate?: boolean, merge?: Merge) => void;
    private _memUnplugUnit;
    private _createMerge;
    private _addMerge;
    private _specAddMerge;
    private _memAddMerge;
    private _simAddMerge;
    private _simAddPinToMerge;
    private _specAddPinToMerge;
    private _memAddPinToMerge;
    private _memRemoveMerge;
    private _specRemoveMerge;
    private _memRemoveAllMergePlug;
    private _specRemoveAllMergePlug;
    private _memRemoveAllMergeRef;
    private _specRemoveAllMergeRef;
    private _memRemoveAllMergePin;
    private _specRemoveAllMergePin;
    private _memPostRemoveMerge;
    memIsUnitRefPin(unitId: string, type: IO, pinId: string): boolean;
    private _getUnitSpec;
    private getUnitSpecId;
    isUnitRefPin(unitId: string, type: IO, pinId: string): boolean;
    isUnitRefInput(unitId: string, name: string): boolean;
    addPinToMerge: (mergeId: string, unitId: string, type: IO, pinId: string) => void;
    private _addPinToMerge;
    removeMerge(mergeId: string, emit?: boolean, take?: boolean): void;
    _removeMerge(mergeId: string, take: boolean): Merge;
    private _simRemoveMerge;
    private _simRemoveAllPlugsFromMerge;
    private __simRemoveAllPlugsFromMerge;
    private _forEachSpecPinPlug;
    private _forEachSpecPinOfType;
    private _simRemoveAllPinsFromMerge;
    private _simPostRemoveMerge;
    removePinFromMerge(mergeId: string, unitId: string, type: IO, pinId: string): void;
    _removePinFromMerge(mergeId: string, unitId: string, type: IO, pinId: string, propagate?: boolean): void;
    private _memRemovePinFromMerge;
    private _specRemovePinFromMerge;
    private _simRemovePinFromMerge;
    mergeMerges(mergeIds: string[]): void;
    private _mergeMerges;
    isPinMergedTo(mergeId: string, unitId: string, type: IO, pinId: string): boolean;
    setUnitPinConstant(unitId: string, type: IO, pinId: string, constant: boolean, emit?: boolean): void;
    private _setUnitPinConstant;
    setUnitInputConstant(unitId: string, pinId: string, constant: boolean): void;
    setUnitOutputConstant(unitId: string, pinId: string, constant: boolean): void;
    setUnitInputIgnored(unitId: string, pinId: string, ignored: boolean): void;
    setUnitOutputIgnored(unitId: string, pinId: string, ignored: boolean): void;
    setUnitPinIgnored(unitId: string, type: IO, pinId: string, ignored: boolean): void;
    setUnitName(unitId: string, newUnitId: string, name: string): void;
    _setUnitName(unitId: string, newUnitId: string, name: string): void;
    setUnitPinData(unitId: string, type: IO, pinId: string, data: any): void;
    setUnitInputData(unitId: string, pinId: string, data: any): void;
    setUnitOutputData(unitId: string, pinId: string, data: any): void;
    setMetadata(path: string[], data: any): void;
    appendParentRoot(subComponentId: string, childId: string, slotName: string): void;
    appendParentRootChildren(subComponentId: string, children: string[], slotMap: Dict<string>): void;
    appendRoot(subComponentId: string): void;
    private _appendRoot;
    removeRoot(subComponentId: string): void;
    private _removeRoot;
    private _specRemoveRoot;
    private _simRemoveRoot;
    moveSubgraphInto(graphId: string, nodeIds: {
        merge: string[];
        link: {
            unitId: string;
            type: IO;
            pinId: string;
        }[];
        unit: string[];
        plug: {
            type: IO;
            pinId: string;
            subPinId: string;
        }[];
    }, nextIdMap: {
        merge: Dict<string>;
        link: Dict<IOOf<Dict<{
            mergeId: string;
            oppositePinId: string;
        }>>>;
        plug: _IOOf<Dict<Dict<{
            mergeId: string;
            type: IO;
        }>>>;
        unit: Dict<string>;
    }, nextPinIdMap: Dict<{
        input: Dict<{
            pinId: string;
            subPinId: string;
        }>;
        output: Dict<{
            pinId: string;
            subPinId: string;
        }>;
    }>, nextMergePinId: Dict<{
        input: {
            mergeId: string;
            pinId: string;
            subPinSpec: GraphSubPinSpec;
        };
        output: {
            mergeId: string;
            pinId: string;
            subPinSpec: GraphSubPinSpec;
        };
    }>, nextPlugSpec: {
        input: Dict<Dict<GraphSubPinSpec>>;
        output: Dict<Dict<GraphSubPinSpec>>;
    }, nextSubComponentParentMap: Dict<string | null>, nextSubComponentChildrenMap: Dict<string[]>): void;
    private _moveSubgraphInto;
    private _moveSubgraphInto__template;
    private _moveSubgraphInto__remove;
    private _moveSubgraphInto__inject;
    private _moveSubgraphInto__recconect;
    injectGraph(graph: Graph<any, any>): void;
    removeSubgraph(spec: GraphSpec): void;
    private _removeSubgraph;
    movePlugInto(graphId: string, type: IO, pinId: string, subPinId: string, subPinSpec: GraphSubPinSpec, graph?: Graph<any, any> | null): void;
    private _movePlugInto;
    private _movePlugInto__remove;
    private _newMergeId;
    private _movePlugInto__inject;
    private _movePlugInto__reconnect;
    private _simMovePlugInto;
    moveUnitInto(graphId: string, unitId: string, nextUnitId: string, ignoredPin: {
        input: Set<string>;
        output: Set<string>;
    }, ignoredMerge: Set<string>, nextPinMap: {
        input: Dict<{
            pinId: string;
            subPinId: string;
        }>;
        output: Dict<{
            pinId: string;
            subPinId: string;
        }>;
    }, nextUnitSubComponentParent: string | null, nextSubComponentChildren: string[], graph?: Graph<any, any> | null): void;
    getUnitMergesSpec(unitId: string): GraphMergesSpec;
    private _moveUnitInto;
    private _moveUnitInto__remove;
    private _moveUnitInto__reconnect;
    private _moveUnitInto__inject;
    moveLinkPinInto(graphId: string, unitId: string, type: IO, pinId: string, mergeId?: string | null, oppositePinId?: string | null, emit?: boolean, graph?: Graph): void;
    private _getMergeUnitPinCount;
    private _moveLinkPinInto;
    private _moveLinkPinInto__remove;
    private _moveLinkPinInto__inject;
    private _moveLinkPinInto__reconnect;
    moveMergeInto(graphId: string, mergeId: string, nextInputMergeId: {
        mergeId: string;
        pinId: string;
        subPinSpec: GraphSubPinSpec;
    }, nextOutputMergeId: {
        mergeId: string;
        pinId: string;
        subPinSpec: GraphSubPinSpec;
    }, graph?: Graph): void;
    private _moveMergeInto;
    private _moveMergeInto__remove;
    private _moveMergeInto__inject;
    private _moveMergeInto__reconnect;
    private _isUnitComponent;
    explodeUnit(graphId: string, mapUnitId: Dict<string>, mapMergeId: Dict<string>, ignorePins?: boolean): void;
    _explodeUnit(graphId: string, mapUnitId: Dict<string>, mapMergeId: Dict<string>, ignorePins?: boolean): void;
    private _removeSubComponentFromParent;
    moveSubComponent(parentId: string, childId: string, slotName: string): void;
    private _moveSubComponent;
    private _initSetComponent;
    private _specSetComponent;
    private _initAddSubComponent;
    private _specAddSubComponent;
    private _root;
    private _parent_root;
    private _parent_children;
    private _slot;
    appendParentChild(component: Component_, slotName: string): void;
    removeParentChild(component: Component_): void;
    registerRoot(component: Component_): void;
    unregisterRoot(component: Component_): void;
    registerParentRoot(component: Component_, slotName: string): void;
    unregisterParentRoot(component: Component_): void;
    insertChild(Bundle: UnitBundle<Component_>, at: number): void;
    appendChild(Bundle: UnitBundle): number;
    pushChild(Bundle: UnitBundle): number;
    pullChild(at: number): Component_;
    hasChild(at: number): boolean;
    removeChild(at: number): Component_;
    refChild(at: number): Component_;
    refChildren(): Component_[];
    refSlot(slotName: string): Component_;
}
