"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeNodeSchemaDataFormat = exports.TreeNodeSchemaUnionFormat = exports.FieldSchemaFormat = exports.PersistedMetadataFormat = void 0;
const typebox_1 = require("@sinclair/typebox");
const index_js_1 = require("../../codec/index.js");
const index_js_2 = require("../../util/index.js");
const formatV1_js_1 = require("./formatV1.js");
exports.PersistedMetadataFormat = typebox_1.Type.Optional(typebox_1.Type.Unsafe(typebox_1.Type.Record(typebox_1.Type.String(), index_js_2.JsonCompatibleReadOnlySchema)));
const FieldSchemaFormatBase = typebox_1.Type.Object({
    kind: formatV1_js_1.FieldKindIdentifierSchema,
    types: typebox_1.Type.Array(formatV1_js_1.TreeNodeSchemaIdentifierSchema),
    metadata: exports.PersistedMetadataFormat,
});
const noAdditionalProps = { additionalProperties: false };
exports.FieldSchemaFormat = typebox_1.Type.Composite([FieldSchemaFormatBase], noAdditionalProps);
/**
 * Format for the content of a {@link TreeNodeStoredSchema}.
 *
 * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.
 */
exports.TreeNodeSchemaUnionFormat = typebox_1.Type.Object({
    /**
     * Object node union member.
     */
    object: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), exports.FieldSchemaFormat)),
    /**
     * Map node union member.
     */
    map: typebox_1.Type.Optional(exports.FieldSchemaFormat),
    /**
     * Leaf node union member.
     */
    leaf: typebox_1.Type.Optional(typebox_1.Type.Enum(formatV1_js_1.PersistedValueSchema)),
}, index_js_1.unionOptions);
exports.TreeNodeSchemaDataFormat = typebox_1.Type.Object({
    /**
     * Node kind specific data.
     */
    kind: exports.TreeNodeSchemaUnionFormat,
    // Data in common for all TreeNode schemas:
    /**
     * Persisted subset of metadata for this node schema.
     */
    metadata: exports.PersistedMetadataFormat,
}, noAdditionalProps);
//# sourceMappingURL=formatV2.js.map