"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.componentFromSpecId = exports.componentFromUnitBundle = void 0;
const weakMerge_1 = require("../weakMerge");
const componentClassFromSpecId_1 = require("./componentClassFromSpecId");
function componentFromUnitBundle(system, bundle, subComponentMap = {}) {
    var _a;
    const { unit } = bundle;
    const props = {}; // TODO derive from unit.input
    const Class = (0, componentClassFromSpecId_1.componentClassFromSpecId)(system.components, (0, weakMerge_1.weakMerge)((_a = bundle.specs) !== null && _a !== void 0 ? _a : {}, system.specs), system.classes, unit.id, props, subComponentMap);
    const component = new Class(props, system);
    return component;
}
exports.componentFromUnitBundle = componentFromUnitBundle;
function componentFromSpecId(system, specs, id, props, subComponentMap = {}) {
    const Class = (0, componentClassFromSpecId_1.componentClassFromSpecId)(system.components, specs, system.classes, id, {}, subComponentMap);
    const component = new Class(props, system);
    return component;
}
exports.componentFromSpecId = componentFromSpecId;
//# sourceMappingURL=componentFromSpecId.js.map