/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import * as Type from "@sinclair/typebox";
import { unionOptions } from "../../../../codec/index.js";
import { ShapeIndex } from "./formatGeneric.js";
import { EncodedFieldShape, EncodedValueShape } from "./formatV1.js";
import { shapesV2 } from "./formatV2.js";
export const EncodedSpecializedNodeShape = Type.Object({
    /**
     * Index into the enclosing batch's shapes array of the shape this specializes.
     * Must resolve to either an {@link EncodedNodeShape} or another
     * `EncodedSpecializedNodeShape`; chains are followed transitively until a node shape
     * is reached. This restriction is enforced at runtime, not by the schema.
     */
    base: ShapeIndex,
    /**
     * Field-level overrides applied to the resolved base's `fields`. Entries whose key
     * matches a base field replace that field's shape index in place; entries with new
     * keys are appended after all base fields, in the order given here. Base field order
     * is preserved — this is the stream consumption order at decode time, so encoders
     * must serialize per-field tokens in the resulting field order, not in this list's order.
     */
    fields: Type.Optional(Type.Array(EncodedFieldShape)),
    /**
     * If absent, inherits the resolved base's value shape. If `null`, the resulting shape
     * has no value shape (explicit clear). Any other value replaces the base's.
     */
    value: Type.Optional(Type.Union([EncodedValueShape, Type.Null()])),
    /**
     * If absent, inherits the resolved base's extraFields shape. If `null`, the resulting
     * shape has no extraFields (explicit clear). Any other value replaces the base's.
     */
    extraFields: Type.Optional(Type.Union([ShapeIndex, Type.Null()])),
}, { additionalProperties: false });
export const EncodedChunkShapeVTextExperimental = Type.Object({
    ...shapesV2,
    f: Type.Optional(EncodedSpecializedNodeShape),
}, unionOptions);
//# sourceMappingURL=formatVText.js.map