"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveDataRef = resolveDataRef;
const deepSet_1 = require("../deepSet");
const object_1 = require("../util/object");
const weakMerge_1 = require("../weakMerge");
const fromUnitBundle_1 = require("./fromUnitBundle");
function resolveDataRef(dataRef, specs, classes) {
    for (const path of dataRef.ref ?? []) {
        const bundle = (0, object_1.deepGet)(dataRef.data, path);
        const Class = (0, fromUnitBundle_1.fromUnitBundle)(bundle, (0, weakMerge_1.weakMerge)(specs, bundle.specs ?? {}), classes);
        if (path.length === 0) {
            return Class;
        }
        else {
            (0, deepSet_1.deepSet_)(dataRef.data, path, Class);
        }
    }
    return dataRef.data;
}
//# sourceMappingURL=resolveDataValue.js.map