"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneUnit = cloneUnit;
exports.cloneUnitClass = cloneUnitClass;
const _clone_1 = require("../util/$clone");
const fromUnitBundle_1 = require("./fromUnitBundle");
function cloneUnit(unit, deep = false) {
    const { __system } = unit;
    const [NewBundle, bundle] = cloneUnitClass(unit, deep);
    const newUnit = new NewBundle(__system);
    return [newUnit, bundle];
}
function cloneUnitClass(unit, deep = false) {
    const { __system } = unit;
    const { specs } = __system;
    const bundle_ = unit.getUnitBundleSpec(deep);
    const bundle = (0, _clone_1.$clone)(bundle_);
    const NewBundle = (0, fromUnitBundle_1.fromUnitBundle)(bundle, specs, __system.classes);
    return [NewBundle, bundle];
}
//# sourceMappingURL=cloneUnit.js.map