"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../Class/Functional");
const fromBundle_1 = require("../../../../spec/fromBundle");
const Async_1 = require("../../../../types/interface/async/Async");
const _ids_1 = require("../../../_ids");
class RemoveUnit extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['id', 'graph'],
            o: [],
        }, {
            input: {
                graph: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_REMOVE_UNIT);
    }
    f({ id, graph }, done, fail) {
        graph = (0, Async_1.Async)(graph, ['G'], this.__system.async);
        let Class;
        try {
            const unit = graph.$refUnit({ unitId: id, __: ['U'] });
            unit.$getUnitBundleSpec({}, (bundle) => {
                graph.$removeUnit({ unitId: id });
                Class = (0, fromBundle_1.fromBundle)(bundle, this.__system.specs, this.__system.classes);
            });
        }
        catch (err) {
            fail(err.message);
            return;
        }
        done({
            class: Class,
        });
    }
}
exports.default = RemoveUnit;
//# sourceMappingURL=index.js.map