"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectNodeTree = exports.ObjectTree = void 0;
const entity_name_1 = require("./entity-name");
class ObjectTree {
    constructor(treeNode) {
        this.treeNode = treeNode;
        this.children = [];
        this.entityName = entity_name_1.EntityName.objectTree;
    }
    get childrenByObjectTypeId() {
        const result = {};
        for (const child of this.children) {
            if (!(child.treeNode.objectTypeId in result)) {
                result[child.treeNode.objectTypeId] = [];
            }
            result[child.treeNode.objectTypeId].push(child);
        }
        return result;
    }
    async init(allNodes) {
        /* await contentEntityService.addTransientContent(
          objectTypes[this.treeNode.objectTypeId]?.contentType,
          this.treeNode,
        );*/
        for (const otherNode of allNodes) {
            if (otherNode.parentNodeId === this.treeNode.id) {
                this.children.push(await new ObjectTree(otherNode).init(allNodes));
            }
        }
        this.id = this.treeNode.id;
        return this;
    }
}
exports.ObjectTree = ObjectTree;
class ObjectNodeTree extends ObjectTree {
}
exports.ObjectNodeTree = ObjectNodeTree;
//# sourceMappingURL=object-tree.model.js.map