"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.treeSchema = exports.fieldSchema = exports.emptyMap = exports.emptySet = void 0;
const util_1 = require("../../util");
/**
 * APIs to help build schema.
 *
 * See typedSchema.ts for a wrapper for these APIs that captures the types as TypeScript types
 * in addition to runtime data.
 */
/**
 * Empty readonly set.
 */
exports.emptySet = new Set();
/**
 * Empty readonly map.
 */
exports.emptyMap = new Map();
/**
 * Helper for building {@link FieldStoredSchema}.
 * @public
 */
function fieldSchema(kind, types) {
    return {
        kind,
        types: types === undefined ? undefined : new Set(types),
    };
}
exports.fieldSchema = fieldSchema;
/**
 * Helper for building {@link TreeStoredSchema}.
 */
function treeSchema(data) {
    const structFields = new Map();
    const fields = data.structFields ?? {};
    // eslint-disable-next-line no-restricted-syntax
    for (const key in fields) {
        if (Object.prototype.hasOwnProperty.call(fields, key)) {
            structFields.set((0, util_1.brand)(key), fields[key]);
        }
    }
    return {
        structFields,
        mapFields: data.mapFields,
        leafValue: data.leafValue,
    };
}
exports.treeSchema = treeSchema;
//# sourceMappingURL=builders.js.map