"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.schemaStatics = exports.schemaStaticsStable = void 0;
const fieldSchema_js_1 = require("../fieldSchema.js");
const leafNodeSchema_js_1 = require("../leafNodeSchema.js");
const defaultOptionalProvider = (0, fieldSchema_js_1.getDefaultProvider)(() => []);
function optional(t, props) {
    return (0, fieldSchema_js_1.createFieldSchema)(fieldSchema_js_1.FieldKind.Optional, t, {
        defaultProvider: defaultOptionalProvider,
        ...props,
    });
}
function required(t, props) {
    return (0, fieldSchema_js_1.createFieldSchema)(fieldSchema_js_1.FieldKind.Required, t, props);
}
// #endregion
/**
 * Implementation of {@link SchemaStatics}.
 * @remarks
 * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.
 * Additional non-public members are in {@link schemaStatics}.
 */
exports.schemaStaticsStable = {
    string: leafNodeSchema_js_1.stringSchema,
    number: leafNodeSchema_js_1.numberSchema,
    boolean: leafNodeSchema_js_1.booleanSchema,
    null: leafNodeSchema_js_1.nullSchema,
    handle: leafNodeSchema_js_1.handleSchema,
    leaves: [leafNodeSchema_js_1.stringSchema, leafNodeSchema_js_1.numberSchema, leafNodeSchema_js_1.booleanSchema, leafNodeSchema_js_1.nullSchema, leafNodeSchema_js_1.handleSchema],
    optional,
    required,
    optionalRecursive: (t, props) => {
        return createFieldSchemaUnsafe(fieldSchema_js_1.FieldKind.Optional, t, {
            defaultProvider: defaultOptionalProvider,
            ...props,
        });
    },
    requiredRecursive: (t, props) => {
        return createFieldSchemaUnsafe(fieldSchema_js_1.FieldKind.Required, t, props);
    },
};
/**
 * Unstable extensions to {@link schemaStaticsStable}.
 */
exports.schemaStatics = {
    ...exports.schemaStaticsStable,
    identifier: (props) => {
        return (0, fieldSchema_js_1.createFieldSchema)(fieldSchema_js_1.FieldKind.Identifier, leafNodeSchema_js_1.stringSchema, props);
    },
};
function createFieldSchemaUnsafe(kind, allowedTypes, props) {
    // At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe
    return (0, fieldSchema_js_1.createFieldSchema)(kind, allowedTypes, props);
}
//# sourceMappingURL=schemaStatics.js.map