"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const globalUrl_1 = require("../../../../../spec/globalUrl");
const _ids_1 = require("../../../../_ids");
class Detach extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['component', 'host', 'opt'],
            i: ['done'],
            fo: [],
            o: [],
        }, {
            input: {
                component: {
                    ref: true,
                },
                host: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_DETACH);
        this._attach = () => {
            this._i.component.emit('call', {
                method: 'attach',
                data: [this._i.opt],
            });
        };
    }
    f({ component, host, opt }, done) {
        component.emit('call', { method: 'register', data: [] });
        host.emit('call', { method: 'register', data: [] });
        const hostUrl = (0, globalUrl_1.globalUrl)(host.__global_id);
        component.emit('call', { method: 'detach', data: [hostUrl, opt] });
    }
    d() {
        this._attach();
    }
    onIterDataInputData(name, data) {
        switch (name) {
            case 'done':
                if (this._functional._active_i_count === 3) {
                    this._attach();
                    this._done();
                }
                this._backward('done');
                break;
        }
    }
}
exports.default = Detach;
//# sourceMappingURL=index.js.map