"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bundleClass = bundleClass;
const bundle_1 = require("../bundle");
const remapBundle_1 = require("./remapBundle");
function bundleClass(Class, bundle, specs) {
    const { unit } = bundle;
    const { id, memory } = unit;
    if (!bundle.specs) {
        bundle = (0, bundle_1.unitBundleSpec)(unit, specs);
    }
    // @ts-ignore
    class Bundle extends Class {
        constructor(system) {
            if (bundle.specs) {
                const map = system.injectSpecs(bundle.specs);
                (0, remapBundle_1.remapSpecs)(bundle, map);
            }
            super(system, id);
            if (memory) {
                this.restore(memory);
            }
        }
    }
    Bundle.__bundle = bundle;
    // @ts-ignore
    return Bundle;
}
//# sourceMappingURL=bundleClass.js.map