/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { UsageError } from "@fluidframework/telemetry-utils/internal";
import { normalizeFieldSchema, } from "./fieldSchema.js";
import { walkFieldSchema } from "./walkFieldSchema.js";
export function createTreeSchema(rootSchema) {
    const root = normalizeFieldSchema(rootSchema);
    const definitions = new Map();
    walkFieldSchema(root, {
        node: (schema) => {
            if (definitions.has(schema.identifier)) {
                throw new 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 };
}
//# sourceMappingURL=treeSchema.js.map