"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTreeSchema = void 0;
const internal_1 = require("@fluidframework/telemetry-utils/internal");
const fieldSchema_js_1 = require("./fieldSchema.js");
const walkFieldSchema_js_1 = require("./walkFieldSchema.js");
function createTreeSchema(rootSchema) {
    const root = (0, fieldSchema_js_1.normalizeFieldSchema)(rootSchema);
    const definitions = new Map();
    (0, walkFieldSchema_js_1.walkFieldSchema)(root, {
        node: (schema) => {
            if (definitions.has(schema.identifier)) {
                throw new internal_1.UsageError(`Multiple schema encountered with the identifier ${JSON.stringify(schema.identifier)}. Remove or rename them to avoid the collision.`);
            }
            definitions.set(schema.identifier, schema);
        },
    });
    return { root, definitions };
}
exports.createTreeSchema = createTreeSchema;
//# sourceMappingURL=treeSchema.js.map