"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Element_1 = require("../../../../../Class/Element");
const spec_1 = require("../../../../../client/spec");
const fromSpec_1 = require("../../../../../spec/fromSpec");
const _ids_1 = require("../../../../_ids");
class Editor extends Element_1.Element_ {
    constructor(system) {
        super({
            i: ['graph', 'style', 'disabled', 'fullwindow', 'frame', 'zoom'],
            o: ['graph'],
        }, {
            input: {
                graph: {
                    ref: true,
                },
                frame: {
                    ref: true,
                },
            },
            output: {
                graph: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_EDITOR);
        this.__ = ['U', 'C', 'V', 'J', 'G'];
        const { specs } = system;
        const spec = system.newSpec((0, spec_1.emptySpec)({ id: (0, spec_1.newSpecId)(specs) }));
        const Class = (0, fromSpec_1.fromSpec)(spec, specs, {});
        const fallback_graph = new Class(system);
        this._fallback_graph = fallback_graph;
        this._input.graph.push(this._fallback_graph);
        this._output.graph.push(this._fallback_graph);
        this._fallback_graph.play();
    }
    onRefInputInvalid(name) {
        // console.log('Editor', 'onRefInputInvalid', name)
        if (name === 'graph') {
            //
        }
    }
    onRefInputData(name, data) {
        // console.log('Editor', 'onRefInputData', name, data)
        if (name === 'graph') {
            const graph = data;
            this._graph = graph;
            this._output.graph.push(graph);
        }
    }
    onRefInputDrop(name) {
        // console.log('Editor', 'onRefInputDrop', name)
        if (name === 'graph') {
            this._input.graph.push(this._fallback_graph);
            this._output.graph.push(this._fallback_graph);
        }
    }
    onRefOutputData(name, data) {
        // console.log('Editor', 'onRefOutputData', name, data)
    }
    snapshotSelf() {
        return Object.assign(Object.assign({}, super.snapshotSelf()), { 
            // TODO
            _fallback_graph: null });
    }
    restoreSelf(state) {
        const { _fallback_graph } = state, rest = __rest(state, ["_fallback_graph"]);
        super.restoreSelf(rest);
        // this._fallback_graph = _fallback_graph
    }
}
exports.default = Editor;
//# sourceMappingURL=index.js.map