"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapSystem = exports._newSystem = void 0;
const boot_1 = require("../boot");
const _1 = require("../Class/$");
const fromBundle_1 = require("../spec/fromBundle");
function _newSystem(system, _system) {
    const new_system = system.boot({});
    const _new_system = wrapSystem(new_system, _system);
    return [
        _new_system,
        () => {
            (0, boot_1.destroy)(system);
        },
    ];
}
exports._newSystem = _newSystem;
function wrapSystem(system, _system) {
    return new (class System extends _1.$ {
        fromBundle(bundleSpec) {
            return (0, fromBundle_1.fromBundle)(bundleSpec, _system.specs, _system.classes);
        }
        newGraph(bundle) {
            return system.newGraph(bundle);
        }
        newSystem(opt) {
            return _newSystem(system, _system);
        }
    })(_system);
}
exports.wrapSystem = wrapSystem;
//# sourceMappingURL=System.js.map