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