## API Report File for "@fluid-experimental/tree2"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { IChannel } from '@fluidframework/datastore-definitions';
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
import { IChannelFactory } from '@fluidframework/datastore-definitions';
import { IChannelServices } from '@fluidframework/datastore-definitions';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IFluidHandle } from '@fluidframework/core-interfaces';
import { ISharedObject } from '@fluidframework/shared-object-base';
import { SessionSpaceCompressedId } from '@fluidframework/runtime-definitions';
import { StableId } from '@fluidframework/runtime-definitions';
import type { Static } from '@sinclair/typebox';
import type { TSchema } from '@sinclair/typebox';

// @alpha
export interface Adapters {
    // (undocumented)
    readonly tree?: readonly TreeAdapter[];
}

// @alpha
export type AllowedTypes = readonly [Any] | readonly LazyItem<TreeNodeSchema>[];

// @alpha
export type AllowedTypeSet = Any | ReadonlySet<TreeNodeSchema>;

// @alpha
type AllowedTypesToTypedTrees<Mode extends ApiMode, T extends AllowedTypes> = [
T extends InternalTypedSchemaTypes.FlexList<TreeNodeSchema> ? InternalTypedSchemaTypes.ArrayToUnion<TypeArrayToTypedTreeArray<Mode, Assume<InternalTypedSchemaTypes.ConstantFlexListToNonLazyArray<T>, readonly TreeNodeSchema[]>>> : UntypedApi<Mode>
][_InlineTrick];

// @alpha
export enum AllowedUpdateType {
    None = 0,
    SchemaCompatible = 1
}

// @alpha
type AllowOptional<T> = [FlattenKeys<RequiredFields<T> & OptionalFields<T>>][_InlineTrick];

// @alpha
type AllowOptionalNotFlattened<T> = [RequiredFields<T> & OptionalFields<T>][_InlineTrick];

// @alpha
export type Anchor = Brand<number, "rebaser.Anchor">;

// @alpha
export interface AnchorEvents {
    afterChange(anchor: AnchorNode): void;
    afterDestroy(anchor: AnchorNode): void;
    beforeChange(anchor: AnchorNode): void;
    childrenChanged(anchor: AnchorNode): void;
    childrenChanging(anchor: AnchorNode): void;
    subtreeChanging(anchor: AnchorNode): PathVisitor | void;
    valueChanging(anchor: AnchorNode, value: Value): void;
}

// @alpha
export interface AnchorLocator {
    locate(anchor: Anchor): AnchorNode | undefined;
}

// @alpha
export interface AnchorNode extends UpPath<AnchorNode>, ISubscribable<AnchorEvents> {
    child(key: FieldKey, index: number): UpPath<AnchorNode>;
    getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];
    readonly slots: BrandedMapSubset<AnchorSlot<any>>;
}

// @alpha @sealed
export class AnchorSet implements ISubscribable<AnchorSetRootEvents>, AnchorLocator {
    constructor();
    acquireVisitor(): AnnouncedVisitor & DeltaVisitor;
    // (undocumented)
    forget(anchor: Anchor): void;
    generationNumber: number;
    internalizePath(originalPath: UpPath): UpPath;
    isEmpty(): boolean;
    // (undocumented)
    locate(anchor: Anchor): AnchorNode | undefined;
    // (undocumented)
    on<K extends keyof AnchorSetRootEvents>(eventName: K, listener: AnchorSetRootEvents[K]): () => void;
    track(path: UpPath | null): Anchor;
}

// @alpha
export interface AnchorSetRootEvents {
    childrenChanging(anchors: AnchorSet): void;
    treeChanging(anchors: AnchorSet): void;
}

// @alpha
export type AnchorSlot<TContent> = BrandedKey<Opaque<Brand<number, "AnchorSlot">>, TContent>;

// @alpha
export function anchorSlot<TContent>(): AnchorSlot<TContent>;

// @alpha
export interface AnnouncedVisitor {
    // (undocumented)
    afterAttach(source: FieldKey, destination: Range_2): void;
    afterCreate(content: Delta.ProtoNodes, destination: FieldKey): void;
    // (undocumented)
    afterDetach(source: PlaceIndex, count: number, destination: FieldKey): void;
    // (undocumented)
    afterReplace(newContentSource: FieldKey, newContent: Range_2, oldContent: FieldKey): void;
    // (undocumented)
    beforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void;
    // (undocumented)
    beforeDestroy(field: FieldKey, count: number): void;
    // (undocumented)
    beforeDetach(source: Range_2, destination: FieldKey): void;
    // (undocumented)
    beforeReplace(newContent: FieldKey, oldContent: Range_2, oldContentDestination: FieldKey): void;
}

// @alpha
export const Any: "Any";

// @alpha
export type Any = typeof Any;

// @alpha
const enum ApiMode {
    Flexible = 0,
    Simple = 1
}

// @alpha
type ApplyMultiplicity<TMultiplicity extends Multiplicity, TypedChild, _Mode extends ApiMode> = {
    [Multiplicity.Forbidden]: undefined;
    [Multiplicity.Optional]: undefined | TypedChild;
    [Multiplicity.Sequence]: TypedChild[];
    [Multiplicity.Single]: TypedChild;
}[TMultiplicity];

// @alpha
type ArrayHasFixedLength<List extends readonly unknown[]> = number extends List["length"] ? false : true;

// @alpha
export interface ArrayLikeMut<TGet, TSet extends TGet = TGet> extends ArrayLike<TGet> {
    // (undocumented)
    [n: number]: TSet;
}

// @alpha
type ArrayToUnion<T extends readonly unknown[]> = T extends readonly (infer TValue)[] ? TValue : never;

// @alpha
export type AssignableFieldKinds = typeof FieldKinds.optional | typeof FieldKinds.required;

// @alpha
type Assume<TInput, TAssumeToBe> = [TInput] extends [TAssumeToBe] ? TInput : TAssumeToBe;

// @alpha
export type Brand<ValueType, Name extends string> = ValueType & BrandedType<ValueType, Name>;

// @alpha
export function brand<T extends Brand<any, string>>(value: T extends BrandedType<infer ValueType, string> ? ValueType : never): T;

// @alpha
export type BrandedKey<TKey, TContent> = TKey & Invariant<TContent>;

// @alpha (undocumented)
type BrandedKeyContent<TKey extends BrandedKey<unknown, any>> = TKey extends BrandedKey<unknown, infer TContent> ? TContent : never;

// @alpha
export interface BrandedMapSubset<K extends BrandedKey<unknown, any>> {
    // (undocumented)
    delete(key: K): boolean;
    // (undocumented)
    get<K2 extends K>(key: K2): BrandedKeyContent<K2> | undefined;
    // (undocumented)
    has(key: K): boolean;
    // (undocumented)
    set<K2 extends K>(key: K2, value: BrandedKeyContent<K2>): this;
}

// @alpha @sealed
abstract class BrandedType<out ValueType, Name extends string> {
    protected abstract brand(dummy: never): Name;
    // (undocumented)
    protected _typeCheck?: Covariant<ValueType>;
}

// @alpha
export function brandOpaque<T extends BrandedType<any, string>>(value: isAny<ValueFromBranded<T>> extends true ? never : ValueFromBranded<T>): BrandedType<ValueFromBranded<T>, NameFromBranded<T>>;

// @alpha
export function buildTreeConfiguration<T extends TreeFieldSchema>(config: InitializeAndSchematizeConfiguration<T>): InitializeAndSchematizeConfiguration<T>;

// @alpha
export type ChangesetLocalId = Brand<number, "ChangesetLocalId">;

// @alpha
export interface CheckoutEvents {
    afterBatch(): void;
    revertible(revertible: Revertible): void;
}

// @alpha
export type CheckTypesOverlap<T, TCheck> = [Extract<T, TCheck> extends never ? never : T][0];

// @alpha
export type ChildCollection = FieldKey | RootField;

// @alpha
export interface ChildLocation {
    // (undocumented)
    readonly container: ChildCollection;
    // (undocumented)
    readonly index: number;
}

// @alpha
type CollectOptions<Mode extends ApiMode, TTypedFields, TValueSchema extends ValueSchema | undefined, TName> = {
    [ApiMode.Flexible]: EmptyObject extends TTypedFields ? TypedValueOrUndefined<TValueSchema> | FlexibleObject<TValueSchema, TName> : FlexibleObject<TValueSchema, TName> & TTypedFields;
    [ApiMode.Simple]: EmptyObject extends TTypedFields ? TypedValueOrUndefined<TValueSchema> : FlexibleObject<TValueSchema, TName> & TTypedFields;
}[Mode];

// @alpha
export function compareLocalNodeKeys(a: LocalNodeKey, b: LocalNodeKey): -1 | 0 | 1;

// @alpha
type ConstantFlexListToNonLazyArray<List extends FlexList> = List extends readonly [
infer Head,
...infer Tail
] ? [ExtractItemType<Head>, ...ConstantFlexListToNonLazyArray<Tail>] : [];

// @alpha
export type ContextuallyTypedFieldData = ContextuallyTypedNodeData | undefined;

// @alpha
export type ContextuallyTypedNodeData = ContextuallyTypedNodeDataObject | PrimitiveValue | readonly ContextuallyTypedNodeData[] | MarkedArrayLike<ContextuallyTypedNodeData>;

// @alpha
export interface ContextuallyTypedNodeDataObject {
    readonly [typeNameSymbol]?: string;
    readonly [valueSymbol]?: Value;
    [key: FieldKey]: ContextuallyTypedFieldData;
    [key: string]: ContextuallyTypedFieldData;
}

// @alpha
interface Contravariant<in T> {
    // (undocumented)
    _removeCovariance?: (_: T) => void;
}

// @alpha
interface Covariant<out T> {
    // (undocumented)
    _removeContravariance?: T;
}

// @alpha
export function createEmitter<E extends Events<E>>(noListeners?: NoListenersCallback<E>): ISubscribable<E> & IEmitter<E> & HasListeners<E>;

// @alpha
export interface CursorAdapter<TNode> {
    // (undocumented)
    getFieldFromNode(node: TNode, key: FieldKey): readonly TNode[];
    // (undocumented)
    keysFromNode(node: TNode): readonly FieldKey[];
    // (undocumented)
    type(node: TNode): TreeType;
    // (undocumented)
    value(node: TNode): Value;
}

// @alpha
export function cursorForTypedTreeData<T extends TreeNodeSchema>(context: TreeDataContext, schema: T, data: TypedNode_2<T, ApiMode.Simple>): ITreeCursorSynchronous;

// @alpha
export function cursorFromContextualData(context: TreeDataContext, typeSet: TreeTypeSet, data: ContextuallyTypedNodeData): ITreeCursorSynchronous;

// @alpha (undocumented)
export const enum CursorLocationType {
    Fields = 1,
    Nodes = 0
}

// @alpha
export function cursorToJsonObject(reader: ITreeCursor): JsonCompatible;

// @alpha
export interface CursorWithNode<TNode> extends ITreeCursorSynchronous {
    fork(): CursorWithNode<TNode>;
    getNode(): TNode;
}

// @alpha
export const defaultSchemaPolicy: FullSchemaPolicy;

declare namespace Delta {
    export {
        Root,
        ProtoNode,
        ProtoNodes,
        Mark,
        DetachedNodeId,
        FieldMap,
        DetachedNodeChanges,
        DetachedNodeBuild,
        DetachedNodeDestruction,
        DetachedNodeRename,
        FieldChanges
    }
}
export { Delta }

// @alpha
export interface DeltaVisitor {
    attach(source: FieldKey, count: number, destination: PlaceIndex): void;
    create(content: Delta.ProtoNodes, destination: FieldKey): void;
    destroy(detachedField: FieldKey, count: number): void;
    detach(source: Range_2, destination: FieldKey): void;
    enterField(key: FieldKey): void;
    enterNode(index: NodeIndex): void;
    exitField(key: FieldKey): void;
    exitNode(index: NodeIndex): void;
    free(): void;
    replace(newContentSource: FieldKey, range: Range_2, oldContentDestination: FieldKey): void;
}

// @alpha
export interface Dependee extends NamedComputation {
    registerDependent(dependent: Dependent): boolean;
    removeDependent(dependent: Dependent): void;
}

// @alpha
export interface Dependent extends NamedComputation {
    markInvalid(token?: InvalidationToken): void;
}

// @alpha
export interface DetachedField extends Opaque<Brand<string, "tree.DetachedField">> {
}

// @alpha
interface DetachedNodeBuild<TTree = ProtoNode> {
    // (undocumented)
    readonly id: DetachedNodeId;
    // (undocumented)
    readonly trees: readonly TTree[];
}

// @alpha
interface DetachedNodeChanges<TTree = ProtoNode> {
    // (undocumented)
    readonly fields: FieldMap<TTree>;
    // (undocumented)
    readonly id: DetachedNodeId;
}

// @alpha
interface DetachedNodeDestruction {
    // (undocumented)
    readonly count: number;
    // (undocumented)
    readonly id: DetachedNodeId;
}

// @alpha
interface DetachedNodeId {
    // (undocumented)
    readonly major?: string | number;
    // (undocumented)
    readonly minor: number;
}

// @alpha
interface DetachedNodeRename {
    // (undocumented)
    readonly count: number;
    // (undocumented)
    readonly newId: DetachedNodeId;
    // (undocumented)
    readonly oldId: DetachedNodeId;
}

// @alpha
export type DetachedPlaceUpPath = Brand<Omit<PlaceUpPath, "parent">, "DetachedRangeUpPath">;

// @alpha
export type DetachedRangeUpPath = Brand<Omit<RangeUpPath, "parent">, "DetachedRangeUpPath">;

// @alpha
export enum DiscardResult {
    Failure = 1,
    Success = 0
}

// @alpha
export const disposeSymbol: unique symbol;

// @alpha
export interface EditableTreeEvents {
    afterChange(event: TreeEvent): void;
    beforeChange(event: TreeEvent): void;
    changing(upPath: UpPath): void;
    subtreeChanging(upPath: UpPath): PathVisitor | void;
}

// @alpha
export const EmptyKey: FieldKey;

// @alpha
type EmptyObject = {};

// @alpha
export function encodeTreeSchema(schema: TreeStoredSchema): JsonCompatible;

// @alpha
export type Events<E> = {
    [P in (string | symbol) & keyof E as IsEvent<E[P]> extends true ? P : never]: E[P];
};

// @alpha
type ExtractFromOpaque<TOpaque extends BrandedType<any, string>> = TOpaque extends BrandedType<infer ValueType, infer Name> ? isAny<ValueType> extends true ? unknown : Brand<ValueType, Name> : never;

// @alpha
export function extractFromOpaque<TOpaque extends BrandedType<any, string>>(value: TOpaque): ExtractFromOpaque<TOpaque>;

// @alpha (undocumented)
type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ? Result : Item;

// @alpha (undocumented)
type ExtractListItemType<List extends FlexList> = List extends FlexList<infer Item> ? Item : unknown;

// @alpha
type FactoryObjectNodeSchema<TScope extends string, Name extends number | string, T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>> = FactoryTreeSchema<ObjectNodeSchema<`${TScope}.${Name}`, {
    [key in keyof T]: NormalizeField<T[key], Required_2>;
}>>;

// @alpha
type FactoryObjectNodeSchemaRecursive<TScope extends string, Name extends number | string, T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>> = FactoryTreeSchema<ObjectNodeSchema<`${TScope}.${Name}`, T>>;

// @alpha
export type FactoryTreeSchema<TSchema extends TreeNodeSchemaBase> = TSchema & TreeObjectFactory<TSchema>;

// @alpha (undocumented)
export function fail(message: string): never;

// @alpha
export interface FieldAnchor {
    // (undocumented)
    fieldKey: FieldKey;
    parent: Anchor | undefined;
}

// @alpha
interface FieldChanges<TTree = ProtoNode> {
    readonly build?: readonly DetachedNodeBuild<TTree>[];
    readonly destroy?: readonly DetachedNodeDestruction[];
    readonly global?: readonly DetachedNodeChanges<TTree>[];
    readonly local?: readonly Mark<TTree>[];
    readonly rename?: readonly DetachedNodeRename[];
}

// @alpha
export type FieldGenerator = () => MapTree[];

// @alpha
export type FieldKey = Brand<string, "tree.FieldKey">;

// @alpha @sealed
export abstract class FieldKind<TName extends string = string, TMultiplicity extends Multiplicity = Multiplicity> implements FieldKindSpecifier {
    protected constructor(identifier: TName & FieldKindIdentifier, multiplicity: TMultiplicity);
    // (undocumented)
    readonly identifier: TName & FieldKindIdentifier;
    // (undocumented)
    readonly multiplicity: TMultiplicity;
}

// @alpha
export type FieldKindIdentifier = Brand<string, "tree.FieldKindIdentifier">;

// @alpha
export const FieldKinds: {
    readonly required: Required_2;
    readonly optional: Optional;
    readonly sequence: Sequence;
    readonly nodeKey: NodeKeyFieldKind;
    readonly forbidden: Forbidden;
};

// @alpha
export interface FieldKindSpecifier<T = FieldKindIdentifier> {
    // (undocumented)
    identifier: T;
}

// @alpha
export interface FieldLocation {
    // (undocumented)
    readonly key: FieldKey;
    // (undocumented)
    readonly parent: ForestLocation;
}

// @alpha (undocumented)
type FieldMap<TTree = ProtoNode> = ReadonlyMap<FieldKey, FieldChanges<TTree>>;

// @alpha
export interface FieldMapObject<TChild> {
    // (undocumented)
    [key: string]: TChild[];
}

// @alpha
export class FieldNodeSchema<Name extends string = string, Specification extends Unenforced<TreeFieldSchema> = TreeFieldSchema> extends TreeNodeSchemaBase<Name, Specification> {
    // (undocumented)
    static create<const Name extends string, const Specification extends TreeFieldSchema>(builder: Named<string>, name: TreeNodeSchemaIdentifier<Name>, specification: Specification): FieldNodeSchema<Name, Specification>;
    // (undocumented)
    getFieldSchema(field: FieldKey): TreeFieldSchema;
    // (undocumented)
    readonly leafValue: undefined;
    // (undocumented)
    readonly mapFields: undefined;
    // (undocumented)
    readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldSchema>;
    // (undocumented)
    protected _typeCheck2?: MakeNominal;
}

// @alpha (undocumented)
interface Fields {
    // (undocumented)
    readonly [key: string]: TreeFieldSchema;
}

// @alpha
export interface FieldUpPath<TUpPath extends UpPath = UpPath> {
    readonly field: FieldKey;
    readonly parent: TUpPath | undefined;
}

// @alpha
type FixedSizeTypeArrayToTypedFlexTree<T extends readonly TreeNodeSchema[]> = [
T extends readonly [infer Head, ...infer Tail] ? [
FlexTreeTypedNode<Assume<Head, TreeNodeSchema>>,
...FixedSizeTypeArrayToTypedFlexTree<Assume<Tail, readonly TreeNodeSchema[]>>
] : []
][_InlineTrick];

// @alpha
type FlattenKeys<T> = [{
    [Property in keyof T]: T[Property];
}][_InlineTrick];

// @alpha
export type FlexibleFieldContent<TSchema extends TreeFieldSchema> = SchemaAware.TypedField<TSchema, SchemaAware.ApiMode.Flexible> | ITreeCursorSynchronous;

// @alpha
export type FlexibleNodeContent<TTypes extends AllowedTypes> = SchemaAware.AllowedTypesToTypedTrees<SchemaAware.ApiMode.Flexible, TTypes> | ITreeCursorSynchronous;

// @alpha
type FlexibleNodeSubSequence<TTypes extends AllowedTypes> = Iterable<SchemaAware.AllowedTypesToTypedTrees<SchemaAware.ApiMode.Flexible, TTypes>> | ITreeCursorSynchronous;

// @alpha
type FlexibleObject<TValueSchema extends ValueSchema | undefined, TName> = [
FlattenKeys<{
    [typeNameSymbol]?: UnbrandedName<TName>;
} & ValuePropertyFromSchema<TValueSchema>>
][_InlineTrick];

// @alpha
type FlexList<Item = unknown> = readonly LazyItem<Item>[];

// @alpha
type FlexListToNonLazyArray<List extends FlexList> = ArrayHasFixedLength<List> extends true ? ConstantFlexListToNonLazyArray<List> : NormalizedFlexList<ExtractListItemType<List>>;

// @alpha
export interface FlexTreeEntity<out TSchema = unknown> {
    [boxedIterator](): IterableIterator<FlexTreeEntity>;
    readonly context: TreeContext;
    readonly schema: TSchema;
    treeStatus(): TreeStatus;
}

// @alpha
export interface FlexTreeField extends FlexTreeEntity<TreeFieldSchema> {
    // (undocumented)
    [boxedIterator](): IterableIterator<FlexTreeNode>;
    is<TSchema extends TreeFieldSchema>(schema: TSchema): this is FlexTreeTypedField<TSchema>;
    isSameAs(other: FlexTreeField): boolean;
    readonly key: FieldKey;
    readonly parent?: FlexTreeNode;
}

// @alpha
export interface FlexTreeFieldNode<in out TSchema extends FieldNodeSchema> extends FlexTreeNode {
    readonly boxedContent: FlexTreeTypedField<TSchema["info"]>;
    readonly content: FlexTreeUnboxField<TSchema["info"]>;
    // (undocumented)
    readonly schema: TSchema;
}

// @alpha
export interface FlexTreeLeafNode<in out TSchema extends LeafNodeSchema> extends FlexTreeNode {
    // (undocumented)
    readonly schema: TSchema;
    readonly value: TreeValue<TSchema["info"]>;
}

// @alpha
export interface FlexTreeMapNode<in out TSchema extends MapNodeSchema> extends FlexTreeNode {
    [boxedIterator](): IterableIterator<FlexTreeTypedField<TSchema["info"]>>;
    // (undocumented)
    [Symbol.iterator](): IterableIterator<[
    FieldKey,
    FlexTreeUnboxField<TSchema["info"], "notEmpty">
    ]>;
    readonly asObject: {
        readonly [P in FieldKey]?: FlexTreeUnboxField<TSchema["info"], "notEmpty">;
    };
    delete(key: string): void;
    entries(): IterableIterator<[FieldKey, FlexTreeUnboxField<TSchema["info"], "notEmpty">]>;
    forEach(callbackFn: (value: FlexTreeUnboxField<TSchema["info"], "notEmpty">, key: FieldKey, map: FlexTreeMapNode<TSchema>) => void, thisArg?: any): void;
    get(key: string): FlexTreeUnboxField<TSchema["info"]>;
    getBoxed(key: string): FlexTreeTypedField<TSchema["info"]>;
    has(key: string): boolean;
    keys(): IterableIterator<FieldKey>;
    // (undocumented)
    readonly schema: TSchema;
    set(key: string, value: FlexibleFieldContent<TSchema["info"]>): void;
    readonly size: number;
    values(): IterableIterator<FlexTreeUnboxField<TSchema["info"], "notEmpty">>;
}

// @alpha
export interface FlexTreeNode extends FlexTreeEntity<TreeNodeSchema> {
    // (undocumented)
    [boxedIterator](): IterableIterator<FlexTreeField>;
    [onNextChange](fn: (node: FlexTreeNode) => void): () => void;
    is<TSchema extends TreeNodeSchema>(schema: TSchema): this is FlexTreeTypedNode<TSchema>;
    // (undocumented)
    on<K extends keyof EditableTreeEvents>(eventName: K, listener: EditableTreeEvents[K]): () => void;
    readonly parentField: {
        readonly parent: FlexTreeField;
        readonly index: number;
    };
    tryGetField(key: FieldKey): undefined | FlexTreeField;
    readonly type: TreeNodeSchemaIdentifier;
    readonly value?: TreeValue;
}

// @alpha
interface FlexTreeNodeKeyField extends FlexTreeField {
    // (undocumented)
    readonly localNodeKey: LocalNodeKey;
    // (undocumented)
    readonly stableNodeKey: StableNodeKey;
}

// @alpha
export interface FlexTreeObjectNode extends FlexTreeNode {
    readonly localNodeKey?: LocalNodeKey;
    // (undocumented)
    readonly schema: ObjectNodeSchema;
}

// @alpha
type FlexTreeObjectNodeFields<TFields extends Fields> = FlattenKeys<{
    readonly [key in keyof TFields as `boxed${Capitalize<key & string>}`]: FlexTreeTypedField<TFields[key]>;
} & {
    readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? never : key]: FlexTreeUnboxField<TFields[key]>;
} & {
    -readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? key : never]: FlexTreeUnboxField<TFields[key]>;
} & {
    readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? `set${Capitalize<key & string>}` : never]: (content: FlexibleFieldContent<TFields[key]>) => void;
}>;

// @alpha
export type FlexTreeObjectNodeTyped<TSchema extends ObjectNodeSchema> = ObjectNodeSchema extends TSchema ? FlexTreeObjectNode : FlexTreeObjectNode & FlexTreeObjectNodeFields<TSchema["info"]>;

// @alpha
export interface FlexTreeOptionalField<in out TTypes extends AllowedTypes> extends FlexTreeField {
    // (undocumented)
    readonly boxedContent?: FlexTreeTypedNodeUnion<TTypes>;
    // (undocumented)
    get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined;
    set content(newContent: FlexibleNodeContent<TTypes> | undefined);
}

// @alpha
export interface FlexTreeRequiredField<in out TTypes extends AllowedTypes> extends FlexTreeField {
    // (undocumented)
    readonly boxedContent: FlexTreeTypedNodeUnion<TTypes>;
    // (undocumented)
    get content(): FlexTreeUnboxNodeUnion<TTypes>;
    set content(content: FlexibleNodeContent<TTypes>);
}

// @alpha
export interface FlexTreeSequenceField<in out TTypes extends AllowedTypes> extends FlexTreeField {
    // (undocumented)
    [boxedIterator](): IterableIterator<FlexTreeTypedNodeUnion<TTypes>>;
    // (undocumented)
    [Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>>;
    readonly asArray: readonly FlexTreeUnboxNodeUnion<TTypes>[];
    at(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined;
    boxedAt(index: number): FlexTreeTypedNodeUnion<TTypes>;
    insertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void;
    insertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void;
    insertAtStart(value: FlexibleNodeSubSequence<TTypes>): void;
    // (undocumented)
    readonly length: number;
    map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[];
    mapBoxed<U>(callbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U): U[];
    moveRangeToEnd(sourceStart: number, sourceEnd: number): void;
    moveRangeToEnd(sourceStart: number, sourceEnd: number, source: FlexTreeSequenceField<AllowedTypes>): void;
    moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;
    moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number, source: FlexTreeSequenceField<AllowedTypes>): void;
    moveRangeToStart(sourceStart: number, sourceEnd: number): void;
    moveRangeToStart(sourceStart: number, sourceEnd: number, source: FlexTreeSequenceField<AllowedTypes>): void;
    moveToEnd(sourceIndex: number): void;
    moveToEnd(sourceIndex: number, source: FlexTreeSequenceField<AllowedTypes>): void;
    moveToIndex(index: number, sourceIndex: number): void;
    moveToIndex(index: number, sourceIndex: number, source: FlexTreeSequenceField<AllowedTypes>): void;
    moveToStart(sourceIndex: number): void;
    moveToStart(sourceIndex: number, source: FlexTreeSequenceField<AllowedTypes>): void;
    removeAt(index: number): void;
    removeRange(start?: number, end?: number): void;
}

// @alpha
export type FlexTreeTyped<TSchema extends TreeFieldSchema | TreeNodeSchema> = TSchema extends TreeNodeSchema ? FlexTreeTypedNode<TSchema> : FlexTreeTypedField<Assume<TSchema, TreeFieldSchema>>;

// @alpha
export type FlexTreeTypedField<TSchema extends TreeFieldSchema> = FlexTreeTypedFieldInner<TSchema["kind"], TSchema["allowedTypes"]>;

// @alpha
type FlexTreeTypedFieldInner<Kind extends FieldKind, Types extends AllowedTypes> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<Types> : Kind extends typeof FieldKinds.required ? FlexTreeRequiredField<Types> : Kind extends typeof FieldKinds.optional ? FlexTreeOptionalField<Types> : Kind extends typeof FieldKinds.nodeKey ? FlexTreeNodeKeyField : FlexTreeField;

// @alpha
export type FlexTreeTypedNode<TSchema extends TreeNodeSchema> = TSchema extends LeafNodeSchema ? FlexTreeLeafNode<TSchema> : TSchema extends MapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FieldNodeSchema ? FlexTreeFieldNode<TSchema> : TSchema extends ObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeNode;

// @alpha
export type FlexTreeTypedNodeUnion<TTypes extends AllowedTypes> = TTypes extends InternalTypedSchemaTypes.FlexList<TreeNodeSchema> ? FlexTreeTypedNodeUnionHelper<TTypes> : FlexTreeNode;

// @alpha
type FlexTreeTypedNodeUnionHelper<TTypes extends InternalTypedSchemaTypes.FlexList<TreeNodeSchema>> = InternalTypedSchemaTypes.ArrayToUnion<TypeArrayToTypedFlexTreeArray<Assume<InternalTypedSchemaTypes.FlexListToNonLazyArray<TTypes>, readonly TreeNodeSchema[]>>>;

// @alpha
type FlexTreeUnboxField<TSchema extends TreeFieldSchema, Emptiness extends "maybeEmpty" | "notEmpty" = "maybeEmpty"> = FlexTreeUnboxFieldInner<TSchema["kind"], TSchema["allowedTypes"], Emptiness>;

// @alpha
type FlexTreeUnboxFieldInner<Kind extends FieldKind, TTypes extends AllowedTypes, Emptiness extends "maybeEmpty" | "notEmpty"> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<TTypes> : Kind extends typeof FieldKinds.required ? FlexTreeUnboxNodeUnion<TTypes> : Kind extends typeof FieldKinds.optional ? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends "notEmpty" ? never : undefined) : Kind extends typeof FieldKinds.nodeKey ? FlexTreeNodeKeyField : unknown;

// @alpha
type FlexTreeUnboxNode<TSchema extends TreeNodeSchema> = TSchema extends LeafNodeSchema ? TreeValue<TSchema["info"]> : TSchema extends MapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FieldNodeSchema ? FlexTreeFieldNode<TSchema> : TSchema extends ObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeUnknownUnboxed;

// @alpha
type FlexTreeUnboxNodeUnion<TTypes extends AllowedTypes> = TTypes extends readonly [
InternalTypedSchemaTypes.LazyItem<infer InnerType>
] ? InnerType extends TreeNodeSchema ? FlexTreeUnboxNode<InnerType> : InnerType extends Any ? FlexTreeNode : unknown : boolean extends IsArrayOfOne<TTypes> ? FlexTreeUnknownUnboxed : FlexTreeTypedNodeUnion<TTypes>;

// @alpha
type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;

// @alpha
export interface FlexTreeView<in out TRoot extends TreeFieldSchema> extends IDisposable {
    readonly checkout: ITreeCheckout;
    readonly context: TreeContext;
    readonly editableTree: FlexTreeTypedField<TRoot>;
    fork(): ITreeViewFork<TRoot>;
}

// @alpha (undocumented)
interface Forbidden extends FieldKind<typeof forbiddenFieldKindIdentifier, Multiplicity.Forbidden> {
}

// @alpha
export const forbiddenFieldKindIdentifier = "Forbidden";

// @alpha
export interface ForestEvents {
    afterChange(): void;
    beforeChange(): void;
}

// @alpha
export type ForestLocation = ITreeSubscriptionCursor | Anchor;

// @alpha
export enum ForestType {
    Optimized = 1,
    Reference = 0
}

// @alpha
export interface FullSchemaPolicy {
    readonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKind>;
}

// @alpha
export interface GenericFieldsNode<TChild> {
    // (undocumented)
    fields?: FieldMapObject<TChild>;
}

// @alpha
export interface GenericTreeNode<TChild> extends GenericFieldsNode<TChild>, NodeData {
}

// @alpha (undocumented)
export function getPrimaryField(schema: TreeNodeStoredSchema): {
    key: FieldKey;
    schema: TreeFieldStoredSchema;
} | undefined;

// @alpha (undocumented)
export interface HasListeners<E extends Events<E>> {
    hasListeners(eventName?: keyof Events<E>): boolean;
}

// @alpha
export interface ICodecOptions {
    readonly jsonValidator: JsonValidator;
}

// @alpha
export interface IdAllocator<TId = number> {
    allocate: (count?: number) => TId;
    // (undocumented)
    getNextId: () => TId;
}

// @alpha
export interface IDefaultEditBuilder {
    // (undocumented)
    addNodeExistsConstraint(path: UpPath): void;
    move(sourceField: FieldUpPath, sourceIndex: number, count: number, destinationField: FieldUpPath, destinationIndex: number): void;
    // (undocumented)
    optionalField(field: FieldUpPath): OptionalFieldEditBuilder;
    // (undocumented)
    sequenceField(field: FieldUpPath): SequenceFieldEditBuilder;
    // (undocumented)
    valueField(field: FieldUpPath): ValueFieldEditBuilder;
}

// @alpha
export interface IDisposable {
    [disposeSymbol](): void;
}

// @alpha
export interface IEditableForest extends IForestSubscription {
    acquireVisitor(): DeltaVisitor;
}

// @alpha
export interface IEmitter<E extends Events<E>> {
    emit<K extends keyof Events<E>>(eventName: K, ...args: Parameters<E[K]>): void;
    emitAndCollect<K extends keyof Events<E>>(eventName: K, ...args: Parameters<E[K]>): ReturnType<E[K]>[];
}

// @alpha
export interface IForestSubscription extends Dependee, ISubscribable<ForestEvents> {
    allocateCursor(): ITreeSubscriptionCursor;
    readonly anchors: AnchorSet;
    clone(schema: StoredSchemaRepository, anchors: AnchorSet): IEditableForest;
    forgetAnchor(anchor: Anchor): void;
    getCursorAboveDetachedFields(): ITreeCursorSynchronous;
    readonly isEmpty: boolean;
    moveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void;
    tryMoveCursorToField(destination: FieldAnchor, cursorToMove: ITreeSubscriptionCursor): TreeNavigationResult;
    tryMoveCursorToNode(destination: Anchor, cursorToMove: ITreeSubscriptionCursor): TreeNavigationResult;
}

// @alpha
export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema | Any;

// @alpha
export type ImplicitFieldSchema = TreeFieldSchema | ImplicitAllowedTypes;

// @alpha
export interface InitializeAndSchematizeConfiguration<TRoot extends TreeFieldSchema = TreeFieldSchema> extends TreeContent<TRoot>, SchematizeConfiguration<TRoot> {
}

// @alpha
type _InlineTrick = 0;

declare namespace InternalEditableTreeTypes {
    export {
        FlexTreeTypedFieldInner,
        FlexTreeUnboxFieldInner,
        TypeArrayToTypedFlexTreeArray,
        FlexTreeObjectNodeFields,
        FlexTreeUnboxField,
        FlexTreeUnboxNode,
        FlexTreeUnboxNodeUnion,
        FlexTreeNodeKeyField,
        IsArrayOfOne,
        FlexTreeUnknownUnboxed,
        FixedSizeTypeArrayToTypedFlexTree,
        FlexTreeTypedNodeUnionHelper,
        FlexibleNodeSubSequence,
        NodeKeys
    }
}
export { InternalEditableTreeTypes }

declare namespace InternalTypedSchemaTypes {
    export {
        ObjectToMap,
        WithDefault,
        Unbrand,
        UnbrandList,
        ArrayToUnion,
        NormalizeObjectNodeFields,
        NormalizeField_2 as NormalizeField,
        Fields,
        MapFieldSchema,
        FlexList,
        FlexListToNonLazyArray,
        ConstantFlexListToNonLazyArray,
        LazyItem,
        NormalizedFlexList,
        ExtractItemType,
        ArrayHasFixedLength,
        ExtractListItemType
    }
}
export { InternalTypedSchemaTypes }

declare namespace InternalTypes {
    export {
        MakeNominal,
        Invariant,
        Contravariant,
        Covariant,
        BrandedType,
        ExtractFromOpaque,
        Assume,
        AllowOptional,
        RequiredFields,
        OptionalFields,
        _InlineTrick,
        _RecursiveTrick,
        FlattenKeys,
        AllowOptionalNotFlattened,
        isAny,
        RestrictiveReadonlyRecord,
        BrandedKeyContent,
        NormalizeField,
        NormalizeAllowedTypes,
        Required_2 as Required,
        Optional,
        NodeKeyFieldKind,
        Forbidden,
        Sequence,
        FactoryObjectNodeSchema,
        FactoryObjectNodeSchemaRecursive,
        testRecursiveDomain
    }
}
export { InternalTypes }

declare namespace InternalTypes_2 {
    export {
        AllowedTypesToTypedTrees,
        CollectOptions,
        TypedFields,
        ApplyMultiplicity,
        ValuePropertyFromSchema,
        FlexibleObject,
        TypedField,
        UnbrandedName,
        TypeArrayToTypedTreeArray,
        UntypedApi,
        EmptyObject,
        ValuesOf,
        TypedValueOrUndefined
    }
}

// @alpha
export class InvalidationToken {
    constructor(description: string, isSecondaryInvalidation?: boolean);
    // (undocumented)
    readonly description: string;
    // (undocumented)
    readonly isSecondaryInvalidation: boolean;
    // (undocumented)
    protected readonly _typeCheck: MakeNominal;
}

// @alpha
interface Invariant<in out T> extends Contravariant<T>, Covariant<T> {
}

// @alpha
type isAny<T> = boolean extends (T extends never ? true : false) ? true : false;

// @alpha
type IsArrayOfOne<T extends readonly unknown[]> = T["length"] extends 1 ? true : 1 extends T["length"] ? boolean : false;

// @alpha
export function isContextuallyTypedNodeDataObject(data: ContextuallyTypedNodeData | undefined): data is ContextuallyTypedNodeDataObject;

// @alpha
export type IsEvent<Event> = Event extends (...args: any[]) => any ? true : false;

// @alpha
export interface ISharedTree extends ISharedObject, ITree {
    contentSnapshot(): SharedTreeContentSnapshot;
    requireSchema<TRoot extends TreeFieldSchema>(schema: TreeSchema<TRoot>, onSchemaIncompatible: () => void): FlexTreeView<TRoot> | undefined;
    schematizeInternal<TRoot extends TreeFieldSchema>(config: InitializeAndSchematizeConfiguration<TRoot>): FlexTreeView<TRoot>;
}

// @alpha (undocumented)
export function isNeverField(policy: FullSchemaPolicy, originalData: TreeStoredSchema, field: TreeFieldStoredSchema): boolean;

// @alpha
export interface ISubscribable<E extends Events<E>> {
    on<K extends keyof Events<E>>(eventName: K, listener: E[K]): () => void;
}

// @alpha
export interface ITransaction {
    abort(): TransactionResult.Abort;
    commit(): TransactionResult.Commit;
    inProgress(): boolean;
    start(): void;
}

// @alpha
export interface ITree extends IChannel {
    schematize<TRoot extends TreeFieldSchema>(config: InitializeAndSchematizeConfiguration<TRoot>): TreeView<TreeField<TRoot>>;
}

// @alpha
export interface ITreeCheckout extends AnchorLocator {
    readonly editor: IDefaultEditBuilder;
    readonly events: ISubscribable<CheckoutEvents>;
    readonly forest: IForestSubscription;
    fork(): ITreeCheckoutFork;
    merge(view: ITreeCheckoutFork): void;
    merge(view: ITreeCheckoutFork, disposeView: boolean): void;
    rebase(view: ITreeCheckoutFork): void;
    readonly rootEvents: ISubscribable<AnchorSetRootEvents>;
    readonly storedSchema: StoredSchemaRepository;
    readonly transaction: ITransaction;
}

// @alpha
export interface ITreeCheckoutFork extends ITreeCheckout {
    rebaseOnto(view: ITreeCheckout): void;
}

// @alpha
export interface ITreeCursor {
    readonly [CursorMarker]: true;
    readonly chunkLength: number;
    readonly chunkStart: number;
    enterField(key: FieldKey): void;
    enterNode(childIndex: number): void;
    exitField(): void;
    exitNode(): void;
    readonly fieldIndex: number;
    firstField(): boolean;
    firstNode(): boolean;
    getFieldKey(): FieldKey;
    // (undocumented)
    getFieldLength(): number;
    getFieldPath(prefix?: PathRootPrefix): FieldUpPath;
    getPath(prefix?: PathRootPrefix): UpPath | undefined;
    readonly mode: CursorLocationType;
    nextField(): boolean;
    nextNode(): boolean;
    // (undocumented)
    readonly pending: boolean;
    seekNodes(offset: number): boolean;
    skipPendingFields(): boolean;
    readonly type: TreeType;
    readonly value: Value;
}

// @alpha
export interface ITreeCursorSynchronous extends ITreeCursor {
    // (undocumented)
    readonly pending: false;
}

// @alpha
export interface ITreeSubscriptionCursor extends ITreeCursor {
    buildAnchor(): Anchor;
    buildFieldAnchor(): FieldAnchor;
    clear(): void;
    // (undocumented)
    fork(): ITreeSubscriptionCursor;
    free(): void;
    readonly state: ITreeSubscriptionCursorState;
}

// @alpha (undocumented)
export enum ITreeSubscriptionCursorState {
    Cleared = 1,
    Current = 0,
    Freed = 2
}

// @alpha
export interface ITreeViewFork<in out TRoot extends TreeFieldSchema> extends FlexTreeView<TRoot> {
    // (undocumented)
    readonly checkout: ITreeCheckoutFork;
}

// @alpha
export interface JsonableTree extends GenericTreeNode<JsonableTree> {
}

// @alpha
export function jsonableTreeFromCursor(cursor: ITreeCursor): JsonableTree;

// @alpha (undocumented)
export const jsonArray: FieldNodeSchema<"com.fluidframework.json.array", TreeFieldSchema<Sequence, readonly [() => MapNodeSchema<"com.fluidframework.json.object", TreeFieldSchema<Optional, readonly [any, () => FieldNodeSchema<"com.fluidframework.json.array", TreeFieldSchema<Sequence, readonly [any, any, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, () => FieldNodeSchema<"com.fluidframework.json.array", TreeFieldSchema<Sequence, readonly [() => MapNodeSchema<"com.fluidframework.json.object", TreeFieldSchema<Optional, readonly [any, any, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, any, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>;

// @alpha
export type JsonCompatible = string | number | boolean | null | JsonCompatible[] | JsonCompatibleObject;

// @alpha
export type JsonCompatibleObject = {
    [P in string]?: JsonCompatible;
};

// @alpha
export type JsonCompatibleReadOnly = string | number | boolean | null | readonly JsonCompatibleReadOnly[] | {
    readonly [P in string]?: JsonCompatibleReadOnly;
};

// @alpha (undocumented)
export const jsonObject: MapNodeSchema<"com.fluidframework.json.object", TreeFieldSchema<Optional, readonly [() => MapNodeSchema<"com.fluidframework.json.object", TreeFieldSchema<Optional, readonly [any, () => FieldNodeSchema<"com.fluidframework.json.array", TreeFieldSchema<Sequence, readonly [any, any, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, () => FieldNodeSchema<"com.fluidframework.json.array", TreeFieldSchema<Sequence, readonly [() => MapNodeSchema<"com.fluidframework.json.object", TreeFieldSchema<Optional, readonly [any, any, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, any, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>]>>;

// @alpha (undocumented)
export const jsonSchema: SchemaLibrary;

// @alpha
export interface JsonValidator {
    compile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;
}

// @alpha
type LazyItem<Item = unknown> = Item | (() => Item);

// @alpha
export type LazyTreeNodeSchema = TreeNodeSchema | (() => TreeNodeSchema);

// @alpha
export const leaf: {
    number: LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>;
    boolean: LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>;
    string: LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>;
    handle: LeafNodeSchema<"com.fluidframework.leaf.handle", ValueSchema.FluidHandle>;
    null: LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>;
    primitives: readonly [LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>];
    all: readonly [LeafNodeSchema<"com.fluidframework.leaf.handle", ValueSchema.FluidHandle>, LeafNodeSchema<"com.fluidframework.leaf.null", ValueSchema.Null>, LeafNodeSchema<"com.fluidframework.leaf.number", ValueSchema.Number>, LeafNodeSchema<"com.fluidframework.leaf.boolean", ValueSchema.Boolean>, LeafNodeSchema<"com.fluidframework.leaf.string", ValueSchema.String>];
    library: SchemaLibrary;
};

// @alpha (undocumented)
export class LeafNodeSchema<const out Name extends string = string, const out Specification extends Unenforced<ValueSchema> = ValueSchema> extends TreeNodeSchemaBase<Name, Specification> {
    // (undocumented)
    static create<const Name extends string, const Specification extends ValueSchema>(builder: Named<string>, name: TreeNodeSchemaIdentifier<Name>, specification: Specification): LeafNodeSchema<Name, Specification>;
    // (undocumented)
    getFieldSchema(field: FieldKey): TreeFieldSchema;
    // (undocumented)
    get leafValue(): ValueSchema;
    // (undocumented)
    readonly mapFields: undefined;
    // (undocumented)
    readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldSchema>;
    // (undocumented)
    protected _typeCheck2?: MakeNominal;
}

// @alpha (undocumented)
const library: SchemaLibrary;

// @alpha
export interface LocalNodeKey extends Opaque<Brand<SessionSpaceCompressedId, "Local Node Key">> {
}

// @alpha
interface MakeNominal {
}

// @alpha
type MapFieldSchema = TreeFieldSchema<typeof FieldKinds.optional | typeof FieldKinds.sequence>;

// @alpha (undocumented)
export class MapNodeSchema<const out Name extends string = string, const out Specification extends Unenforced<MapFieldSchema> = MapFieldSchema> extends TreeNodeSchemaBase<Name, Specification> {
    // (undocumented)
    static create<const Name extends string, const Specification extends MapFieldSchema>(builder: Named<string>, name: TreeNodeSchemaIdentifier<Name>, specification: Specification): MapNodeSchema<Name, Specification>;
    // (undocumented)
    getFieldSchema(field: FieldKey): MapFieldSchema;
    // (undocumented)
    readonly leafValue: undefined;
    // (undocumented)
    get mapFields(): MapFieldSchema;
    // (undocumented)
    readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldSchema>;
    // (undocumented)
    protected _typeCheck2?: MakeNominal;
}

// @alpha
export interface MapTree extends NodeData {
    // (undocumented)
    fields: Map<FieldKey, MapTree[]>;
}

// @alpha
interface Mark<TTree = ProtoNode> {
    readonly attach?: DetachedNodeId;
    readonly count: number;
    readonly detach?: DetachedNodeId;
    readonly fields?: FieldMap<TTree>;
}

// @alpha
export interface MarkedArrayLike<TGet, TSet extends TGet = TGet> extends ArrayLikeMut<TGet, TSet> {
    // (undocumented)
    readonly [arrayLikeMarkerSymbol]: true;
    // (undocumented)
    [Symbol.iterator](): IterableIterator<TGet>;
}

// @alpha
export enum Multiplicity {
    Forbidden = 3,
    Optional = 1,
    Sequence = 2,
    Single = 0
}

// @alpha
export interface Named<TName> {
    // (undocumented)
    readonly name: TName;
}

// @alpha
export interface NamedComputation {
    readonly computationName: string;
    listDependees?(): Iterable<Dependee>;
    listDependents?(): Iterable<Dependent>;
}

// @alpha
export type NameFromBranded<T extends BrandedType<any, string>> = T extends BrandedType<any, infer Name> ? Name : never;

// @alpha
export type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;

// @alpha
export type NewFieldContent = ITreeCursorSynchronous | readonly ITreeCursorSynchronous[] | ContextuallyTypedFieldData;

// @alpha
export interface NodeData {
    readonly type: TreeNodeSchemaIdentifier;
    value?: TreeValue;
}

// @alpha (undocumented)
export interface NodeExistsConstraint {
    // (undocumented)
    violated: boolean;
}

// @alpha
export type NodeIndex = number;

// @alpha
export const nodeKeyField: {
    __n_id__: TreeFieldSchema<NodeKeyFieldKind, readonly [LeafNodeSchema<"com.fluidframework.nodeKey.NodeKey", ValueSchema.String>]>;
};

// @alpha
export const nodeKeyFieldKey = "__n_id__";

// @alpha (undocumented)
interface NodeKeyFieldKind extends FieldKind<"NodeKey", Multiplicity.Single> {
}

// @alpha
interface NodeKeys {
    generate(): LocalNodeKey;
    localize(key: StableNodeKey): LocalNodeKey;
    readonly map: ReadonlyMap<LocalNodeKey, FlexTreeObjectNode>;
    stabilize(key: LocalNodeKey): StableNodeKey;
}

// @alpha
export const nodeKeySchema: SchemaLibrary;

// @alpha
export type NoListenersCallback<E extends Events<E>> = (eventName: keyof Events<E>) => void;

// @alpha
export const noopValidator: JsonValidator;

// @alpha
type NormalizeAllowedTypes<TSchema extends ImplicitAllowedTypes> = TSchema extends TreeNodeSchema ? readonly [TSchema] : TSchema extends Any ? readonly [Any] : TSchema;

// @alpha (undocumented)
type NormalizedFlexList<Item> = readonly Item[];

// @alpha
type NormalizeField<TSchema extends ImplicitFieldSchema, TDefault extends FieldKind> = TSchema extends TreeFieldSchema ? TSchema : TreeFieldSchema<TDefault, NormalizeAllowedTypes<Assume<TSchema, ImplicitAllowedTypes>>>;

// @alpha
type NormalizeField_2<T extends TreeFieldSchema | undefined> = T extends TreeFieldSchema ? T : TreeFieldSchema<typeof FieldKinds.forbidden, []>;

// @alpha (undocumented)
type NormalizeObjectNodeFields<T extends Fields> = {
    readonly [Property in keyof T]: NormalizeField_2<T[Property]>;
};

// @alpha (undocumented)
export class ObjectNodeSchema<const out Name extends string = string, const out Specification extends Unenforced<Fields> = Fields> extends TreeNodeSchemaBase<Name, Specification> {
    // (undocumented)
    static create<const Name extends string, const Specification extends Fields>(builder: Named<string>, name: TreeNodeSchemaIdentifier<Name>, specification: Specification): ObjectNodeSchema<Name, Specification>;
    // (undocumented)
    getFieldSchema(field: FieldKey): TreeFieldSchema;
    // (undocumented)
    readonly leafValue: undefined;
    // (undocumented)
    readonly mapFields: undefined;
    // (undocumented)
    readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldSchema>;
    // (undocumented)
    readonly objectNodeFieldsObject: NormalizeObjectNodeFields<Assume<Specification, Fields>>;
    // (undocumented)
    protected _typeCheck2?: MakeNominal;
}

// @alpha
type ObjectToMap<ObjectMap, MapKey extends number | string, MapValue> = ReadonlyMap<MapKey, MapValue> & {
    get<TKey extends keyof ObjectMap>(key: TKey): ObjectMap[TKey];
};

// @alpha
export interface ObservingDependent extends Dependent {
    // @override
    listDependees(): Iterable<Dependee>;
    registerDependee(dependee: Dependee): void;
}

// @alpha
export function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined;

// @alpha
export type Opaque<T extends Brand<any, string>> = T extends Brand<infer ValueType, infer Name> ? BrandedType<ValueType, Name> : never;

// @alpha (undocumented)
interface Optional extends FieldKind<"Optional", Multiplicity.Optional> {
}

// @alpha (undocumented)
export interface OptionalFieldEditBuilder {
    set(newContent: ITreeCursor | undefined, wasEmpty: boolean): void;
}

// @alpha
type OptionalFields<T> = [
    {
    [P in keyof T as undefined extends T[P] ? T[P] extends undefined ? never : P : never]?: T[P];
}
][_InlineTrick];

// @alpha
export interface PathRootPrefix {
    indexOffset?: number;
    parent?: UpPath | undefined;
    rootFieldOverride?: FieldKey;
}

// @alpha
export interface PathVisitor {
    afterAttach(source: DetachedPlaceUpPath, destination: RangeUpPath): void;
    afterCreate(content: DetachedRangeUpPath): void;
    afterDetach(source: PlaceUpPath, destination: DetachedRangeUpPath): void;
    afterReplace(newContentSource: DetachedPlaceUpPath, newContent: RangeUpPath, oldContent: DetachedRangeUpPath): void;
    beforeAttach(source: DetachedRangeUpPath, destination: PlaceUpPath): void;
    beforeDestroy(content: DetachedRangeUpPath): void;
    beforeDetach(source: RangeUpPath, destination: DetachedPlaceUpPath): void;
    beforeReplace(newContent: DetachedRangeUpPath, oldContent: RangeUpPath, oldContentDestination: DetachedPlaceUpPath): void;
    // @deprecated
    onDelete(path: UpPath, count: number): void;
    // @deprecated (undocumented)
    onInsert(path: UpPath, content: Delta.ProtoNodes): void;
}

// @alpha
export type PlaceIndex = number;

// @alpha
export interface PlaceUpPath<TUpPath extends UpPath = UpPath> extends FieldUpPath<TUpPath> {
    readonly index: PlaceIndex;
}

// @alpha
export function prefixFieldPath(prefix: PathRootPrefix | undefined, path: FieldUpPath): FieldUpPath;

// @alpha
export function prefixPath(prefix: PathRootPrefix | undefined, path: UpPath | undefined): UpPath | undefined;

// @alpha (undocumented)
export type PrimitiveValue = string | boolean | number;

// @alpha
type ProtoNode = ITreeCursorSynchronous;

// @alpha
type ProtoNodes = readonly ProtoNode[];

// @alpha
interface Range_2 {
    readonly end: PlaceIndex;
    readonly start: PlaceIndex;
}
export { Range_2 as Range }

// @alpha
export interface RangeQueryResult<T> {
    length: number;
    value: T | undefined;
}

// @alpha
export interface RangeUpPath<TUpPath extends UpPath = UpPath> extends FieldUpPath<TUpPath>, Range_2 {
}

// @alpha
export function recordDependency(dependent: ObservingDependent | undefined, dependee: Dependee): void;

// @alpha (undocumented)
const recursiveObject: FactoryObjectNodeSchemaRecursive<"Test Recursive Domain", "object", {
readonly recursive: TreeFieldSchema<Optional, readonly [() => FactoryObjectNodeSchemaRecursive<"Test Recursive Domain", "object", any>]>;
readonly number: LeafNodeSchema<"com.fluidframework.leaf.number", import("..").ValueSchema.Number>;
}>;

// @alpha (undocumented)
const recursiveObject2: FactoryObjectNodeSchema<"Test Recursive Domain", "object2", {
readonly recursive: TreeFieldSchema<Optional, readonly [() => FactoryObjectNodeSchema<"Test Recursive Domain", "object2", any>]>;
readonly number: LeafNodeSchema<"com.fluidframework.leaf.number", import("..").ValueSchema.Number>;
}>;

// @alpha
type _RecursiveTrick = never;

// @alpha (undocumented)
interface Required_2 extends FieldKind<"Value", Multiplicity.Single> {
}

// @alpha
type RequiredFields<T> = [
    {
    [P in keyof T as undefined extends T[P] ? never : P]: T[P];
}
][_InlineTrick];

// @alpha
type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
    readonly [P in symbol | string]: P extends K ? T : never;
};

// @alpha
export interface Revertible {
    discard(): DiscardResult;
    readonly kind: RevertibleKind;
    // (undocumented)
    readonly origin: {
        readonly isLocal: boolean;
    };
    revert(): RevertResult;
}

// @alpha
export enum RevertibleKind {
    Default = 0,
    Rebase = 3,
    Redo = 2,
    Undo = 1
}

// @alpha
export enum RevertResult {
    Failure = 1,
    Success = 0
}

// @alpha
type Root<TTree = ProtoNode> = FieldMap<TTree>;

// @alpha
export interface RootField {
    // (undocumented)
    readonly key: DetachedField;
}

// @alpha (undocumented)
export const rootField: DetachedField;

// @alpha
export const rootFieldKey: FieldKey;

// @alpha
export function runSynchronous(view: ITreeCheckout, transaction: (view: ITreeCheckout) => TransactionResult | void): TransactionResult;

declare namespace SchemaAware {
    export {
        ApiMode,
        TypedNode_2 as TypedNode,
        TypedField,
        AllowedTypesToTypedTrees,
        InternalTypes_2 as InternalTypes
    }
}
export { SchemaAware }

// @alpha @sealed
export class SchemaBuilder<TScope extends string = string, TName extends string | number = string> extends SchemaBuilderBase<TScope, typeof FieldKinds.required, TName> {
    constructor(options: SchemaBuilderOptions<TScope>);
    // (undocumented)
    readonly boolean: LeafNodeSchema<"com.fluidframework.leaf.boolean", import("..").ValueSchema.Boolean>;
    fixRecursiveReference<T extends AllowedTypes>(...types: T): void;
    // (undocumented)
    readonly handle: LeafNodeSchema<"com.fluidframework.leaf.handle", import("..").ValueSchema.FluidHandle>;
    list<const T extends TreeNodeSchema | Any | readonly TreeNodeSchema[]>(allowedTypes: T): FieldNodeSchema<`${TScope}.List<${string}>`, TreeFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>>;
    list<Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): FieldNodeSchema<`${TScope}.${Name}`, TreeFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>>;
    map<const T extends TreeNodeSchema | Any | readonly TreeNodeSchema[]>(allowedTypes: T): MapNodeSchema<`${TScope}.Map<${string}>`, NormalizeField<T, typeof FieldKinds.optional>>;
    map<Name extends TName, const T extends MapFieldSchema | ImplicitAllowedTypes>(name: Name, fieldSchema: T): MapNodeSchema<`${TScope}.${Name}`, NormalizeField<T, typeof FieldKinds.optional>>;
    // (undocumented)
    readonly null: LeafNodeSchema<"com.fluidframework.leaf.null", import("..").ValueSchema.Null>;
    // (undocumented)
    readonly number: LeafNodeSchema<"com.fluidframework.leaf.number", import("..").ValueSchema.Number>;
    // (undocumented)
    object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, t: T): FactoryObjectNodeSchema<TScope, Name, T>;
    // (undocumented)
    objectRecursive<const Name extends TName, const T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>>(name: Name, t: T): FactoryObjectNodeSchemaRecursive<TScope, Name, T>;
    static optional: <const T extends ImplicitAllowedTypes>(allowedTypes: T) => TreeFieldSchema<Optional, NormalizeAllowedTypes<T>>;
    readonly optional: <const T extends ImplicitAllowedTypes>(allowedTypes: T) => TreeFieldSchema<Optional, NormalizeAllowedTypes<T>>;
    static required: <const T extends ImplicitAllowedTypes>(allowedTypes: T) => TreeFieldSchema<Required_2, NormalizeAllowedTypes<T>>;
    readonly required: <const T extends ImplicitAllowedTypes>(allowedTypes: T) => TreeFieldSchema<Required_2, NormalizeAllowedTypes<T>>;
    static sequence: <const T extends ImplicitAllowedTypes>(allowedTypes: T) => TreeFieldSchema<Sequence, NormalizeAllowedTypes<T>>;
    readonly sequence: <const T extends ImplicitAllowedTypes>(allowedTypes: T) => TreeFieldSchema<Sequence, NormalizeAllowedTypes<T>>;
    // (undocumented)
    readonly string: LeafNodeSchema<"com.fluidframework.leaf.string", import("..").ValueSchema.String>;
}

// @alpha
export class SchemaBuilderBase<TScope extends string, TDefaultKind extends FieldKind, TName extends number | string = string> {
    constructor(defaultKind: TDefaultKind, options: SchemaBuilderOptions<TScope>);
    // (undocumented)
    protected addNodeSchema<T extends TreeNodeSchema>(schema: T): void;
    static field<Kind extends FieldKind, T extends ImplicitAllowedTypes>(kind: Kind, allowedTypes: T): TreeFieldSchema<Kind, NormalizeAllowedTypes<T>>;
    fieldNode<Name extends TName, const T extends ImplicitFieldSchema>(name: Name, fieldSchema: T): FieldNodeSchema<`${TScope}.${Name}`, NormalizeField<T, TDefaultKind>>;
    fieldNodeRecursive<Name extends TName, const T extends Unenforced<ImplicitFieldSchema>>(name: Name, t: T): FieldNodeSchema<`${TScope}.${Name}`, T>;
    static fieldRecursive<Kind extends FieldKind, T extends FlexList<Unenforced<TreeNodeSchema>>>(kind: Kind, ...allowedTypes: T): TreeFieldSchema<Kind, T>;
    intoLibrary(): SchemaLibrary;
    intoSchema<const TSchema extends ImplicitFieldSchema>(root: TSchema): TreeSchema<NormalizeField<TSchema, TDefaultKind>>;
    map<Name extends TName, const T extends MapFieldSchema>(name: Name, fieldSchema: T): MapNodeSchema<`${TScope}.${Name}`, T>;
    mapRecursive<Name extends TName, const T extends Unenforced<MapFieldSchema>>(name: Name, t: T): MapNodeSchema<`${TScope}.${Name}`, T>;
    readonly name: string;
    protected normalizeField<TSchema extends ImplicitFieldSchema>(schema: TSchema): NormalizeField<TSchema, TDefaultKind>;
    object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, t: T): ObjectNodeSchema<`${TScope}.${Name}`, {
        [key in keyof T]: NormalizeField<T[key], TDefaultKind>;
    }>;
    objectRecursive<const Name extends TName, const T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>>(name: Name, t: T): ObjectNodeSchema<`${TScope}.${Name}`, T>;
    readonly scope: TScope;
    // (undocumented)
    protected scoped<Name extends TName>(name: Name): TreeNodeSchemaIdentifier<`${TScope}.${Name}`>;
}

// @alpha
export interface SchemaBuilderOptions<TScope extends string = string> {
    libraries?: SchemaLibrary[];
    lint?: Partial<SchemaLintConfiguration>;
    name?: string;
    scope: TScope;
}

// @alpha
export interface SchemaCollection extends StoredSchemaCollection {
    readonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>;
}

// @alpha
export interface SchemaConfiguration<TRoot extends TreeFieldSchema = TreeFieldSchema> {
    readonly schema: TreeSchema<TRoot>;
}

// @alpha
export interface SchemaEvents {
    afterSchemaChange(newSchema: TreeStoredSchema): void;
    beforeSchemaChange(newSchema: TreeStoredSchema): void;
}

// @alpha
export function schemaIsFieldNode(schema: TreeNodeSchema): schema is FieldNodeSchema;

// @alpha
export function schemaIsLeaf(schema: TreeNodeSchema): schema is LeafNodeSchema;

// @alpha
export function schemaIsMap(schema: TreeNodeSchema): schema is MapNodeSchema;

// @alpha
export function schemaIsObjectNode(schema: TreeNodeSchema): schema is ObjectNodeSchema;

// @alpha
export interface SchemaLibrary extends SchemaCollection {
    readonly libraries: ReadonlySet<SchemaLibraryData>;
}

// @alpha
export interface SchemaLibraryData extends SchemaCollection {
    // (undocumented)
    readonly adapters: Adapters;
    // (undocumented)
    readonly name: string;
}

// @alpha
export interface SchemaLintConfiguration {
    // (undocumented)
    readonly rejectEmpty: boolean;
    // (undocumented)
    readonly rejectForbidden: boolean;
}

// @alpha
export interface SchematizeConfiguration<TRoot extends TreeFieldSchema = TreeFieldSchema> extends SchemaConfiguration<TRoot> {
    readonly allowedSchemaModifications: AllowedUpdateType;
}

// @alpha
export interface SchemaValidationFunction<Schema extends TSchema> {
    // (undocumented)
    check(data: unknown): data is Static<Schema>;
}

// @alpha (undocumented)
interface Sequence extends FieldKind<"Sequence", Multiplicity.Sequence> {
}

// @alpha (undocumented)
export interface SequenceFieldEditBuilder {
    delete(index: number, count: number): void;
    insert(index: number, newContent: ITreeCursor | readonly ITreeCursor[]): void;
    move(sourceIndex: number, count: number, destIndex: number): void;
}

// @alpha
export interface SharedTreeContentSnapshot {
    readonly schema: TreeStoredSchema;
    readonly tree: JsonableTree[];
}

// @alpha
export class SharedTreeFactory implements IChannelFactory {
    constructor(options?: SharedTreeOptions);
    // (undocumented)
    readonly attributes: IChannelAttributes;
    // (undocumented)
    create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree;
    // (undocumented)
    load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<ISharedTree>;
    // (undocumented)
    readonly type: string;
}

// @alpha (undocumented)
export interface SharedTreeOptions extends Partial<ICodecOptions> {
    forest?: ForestType;
    // (undocumented)
    summaryEncodeType?: TreeCompressionStrategy;
}

// @alpha
export class SimpleDependee implements Dependee {
    constructor(computationName?: string);
    // (undocumented)
    readonly computationName: string;
    invalidateDependents(token?: InvalidationToken): void;
    // @sealed (undocumented)
    listDependents(): Set<Dependent>;
    // (undocumented)
    registerDependent(dependent: Dependent): boolean;
    // (undocumented)
    removeDependent(dependent: Dependent): void;
}

// @alpha
export function singleJsonCursor(root: JsonCompatible): ITreeCursorSynchronous;

// @alpha
export function singleTextCursor(root: JsonableTree): ITreeCursorSynchronous;

// @alpha
export type StableNodeKey = Brand<StableId, "Stable Node Key">;

// @alpha
export function stackTreeFieldCursor<TNode>(adapter: CursorAdapter<TNode>, root: TNode, detachedField?: DetachedField): CursorWithNode<TNode>;

// @alpha
export function stackTreeNodeCursor<TNode>(adapter: CursorAdapter<TNode>, root: TNode): CursorWithNode<TNode>;

// @alpha
export interface StoredSchemaCollection {
    readonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;
}

// @alpha
export interface StoredSchemaRepository extends Dependee, ISubscribable<SchemaEvents>, TreeStoredSchema {
    update(newSchema: TreeStoredSchema): void;
}

declare namespace testRecursiveDomain {
    export {
        recursiveObject,
        recursiveObject2,
        library
    }
}

// @alpha
export enum TransactionResult {
    Abort = 0,
    Commit = 1
}

// @alpha
export const Tree: TreeApi;

// @alpha (undocumented)
export interface TreeAdapter {
    // (undocumented)
    readonly input: TreeNodeSchemaIdentifier;
    // (undocumented)
    readonly output: TreeNodeSchemaIdentifier;
}

// @alpha
export interface TreeApi {
    readonly is: <TSchema extends TreeNodeSchema>(value: unknown, schema: TSchema) => value is TypedNode<TSchema>;
    readonly key: (node: TreeNode) => string | number;
    readonly on: <K extends keyof EditableTreeEvents>(node: TreeNode, eventName: K, listener: EditableTreeEvents[K]) => () => void;
    readonly parent: (node: TreeNode) => TreeNode | undefined;
    readonly schema: (node: TreeNode) => TreeNodeSchema;
    readonly status: (node: TreeNode) => TreeStatus;
}

// @alpha
export enum TreeCompressionStrategy {
    Compressed = 0,
    Uncompressed = 1
}

// @alpha
export interface TreeContent<TRoot extends TreeFieldSchema = TreeFieldSchema> extends SchemaConfiguration<TRoot> {
    readonly initialTree: SchemaAware.TypedField<TRoot, SchemaAware.ApiMode.Flexible> | readonly ITreeCursorSynchronous[] | ITreeCursorSynchronous;
}

// @alpha
export interface TreeContext extends ISubscribable<ForestEvents> {
    // (undocumented)
    readonly nodeKeys: NodeKeys;
    get root(): FlexTreeField;
    readonly schema: TreeSchema;
}

// @alpha
export interface TreeDataContext {
    fieldSource?(key: FieldKey, schema: TreeFieldStoredSchema): undefined | FieldGenerator;
    readonly schema: TreeStoredSchema;
}

// @alpha
export interface TreeEvent {
    readonly target: FlexTreeNode;
}

// @alpha
export type TreeField<TSchema extends TreeFieldSchema = TreeFieldSchema, API extends "javaScript" | "sharedTree" = "sharedTree", Emptiness extends "maybeEmpty" | "notEmpty" = "maybeEmpty"> = TreeFieldInner<TSchema["kind"], TSchema["allowedTypes"], API, Emptiness>;

// @alpha
export type TreeFieldInner<Kind extends FieldKind, TTypes extends AllowedTypes, API extends "javaScript" | "sharedTree", Emptiness extends "maybeEmpty" | "notEmpty"> = Kind extends typeof FieldKinds.sequence ? never : Kind extends typeof FieldKinds.required ? TreeNodeUnion<TTypes, API> : Kind extends typeof FieldKinds.optional ? TreeNodeUnion<TTypes, API> | (Emptiness extends "notEmpty" ? never : undefined) : unknown;

// @alpha @sealed
export class TreeFieldSchema<out TKind extends FieldKind = FieldKind, const out TTypes extends Unenforced<AllowedTypes> = AllowedTypes> implements TreeFieldStoredSchema {
    // (undocumented)
    readonly allowedTypes: TTypes;
    get allowedTypeSet(): AllowedTypeSet;
    static create<TKind extends FieldKind, const Types extends AllowedTypes>(kind: TKind, allowedTypes: Types): TreeFieldSchema<TKind, Types>;
    static createUnsafe<TKind extends FieldKind, const Types extends Unenforced<AllowedTypes>>(kind: TKind, allowedTypes: Types): TreeFieldSchema<TKind, Types>;
    static readonly empty: TreeFieldSchema<Forbidden, readonly []>;
    equals(other: TreeFieldSchema): boolean;
    // (undocumented)
    readonly kind: TKind;
    get monomorphicChildType(): TreeNodeSchema | undefined;
    // (undocumented)
    protected _typeCheck?: MakeNominal;
    get types(): TreeTypeSet;
}

// @alpha (undocumented)
export interface TreeFieldStoredSchema {
    // (undocumented)
    readonly kind: FieldKindSpecifier;
    readonly types?: TreeTypeSet;
}

// @alpha
export interface TreeListNode<TTypes extends AllowedTypes, API extends "javaScript" | "sharedTree" = "sharedTree"> extends ReadonlyArray<TreeNodeUnion<TTypes, API>> {
    insertAt(index: number, value: Iterable<TreeNodeUnion<TTypes, "javaScript">>): void;
    insertAtEnd(value: Iterable<TreeNodeUnion<TTypes, "javaScript">>): void;
    insertAtStart(value: Iterable<TreeNodeUnion<TTypes, "javaScript">>): void;
    moveRangeToEnd(sourceStart: number, sourceEnd: number): void;
    moveRangeToEnd(sourceStart: number, sourceEnd: number, source: TreeListNode<AllowedTypes>): void;
    moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;
    moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number, source: TreeListNode<AllowedTypes>): void;
    moveRangeToStart(sourceStart: number, sourceEnd: number): void;
    moveRangeToStart(sourceStart: number, sourceEnd: number, source: TreeListNode<AllowedTypes>): void;
    moveToEnd(sourceIndex: number): void;
    moveToEnd(sourceIndex: number, source: TreeListNode<AllowedTypes>): void;
    moveToIndex(index: number, sourceIndex: number): void;
    moveToIndex(index: number, sourceIndex: number, source: TreeListNode<AllowedTypes>): void;
    moveToStart(sourceIndex: number): void;
    moveToStart(sourceIndex: number, source: TreeListNode<AllowedTypes>): void;
    removeAt(index: number): void;
    removeRange(start?: number, end?: number): void;
}

// @alpha (undocumented)
export interface TreeLocation {
    // (undocumented)
    readonly index: number;
    // (undocumented)
    readonly range: FieldLocation | DetachedField;
}

// @alpha
export interface TreeMapNode<TSchema extends MapNodeSchema> extends ReadonlyMap<string, TreeField<TSchema["info"], "sharedTree", "notEmpty">> {
    delete(key: string): void;
    set(key: string, value: TreeField<TSchema["info"], "sharedTree", "notEmpty"> | undefined): void;
}

// @alpha (undocumented)
export const enum TreeNavigationResult {
    NotFound = -1,
    Ok = 1,
    Pending = 0
}

// @alpha
export type TreeNode = TreeListNode<AllowedTypes> | TreeObjectNode<ObjectNodeSchema> | TreeMapNode<MapNodeSchema>;

// @alpha (undocumented)
export type TreeNodeSchema = TreeNodeSchemaBase;

// @alpha
export abstract class TreeNodeSchemaBase<const out Name extends string = string, const out Specification = unknown> implements TreeNodeStoredSchema {
    protected constructor(builder: Named<string>, name: TreeNodeSchemaIdentifier<Name>, info: Specification);
    // (undocumented)
    readonly builder: Named<string>;
    // (undocumented)
    abstract getFieldSchema(field: FieldKey): TreeFieldSchema;
    // (undocumented)
    readonly info: Specification;
    // (undocumented)
    abstract readonly leafValue?: ValueSchema | undefined;
    // (undocumented)
    abstract readonly mapFields?: TreeFieldStoredSchema | undefined;
    // (undocumented)
    readonly name: TreeNodeSchemaIdentifier<Name>;
    // (undocumented)
    abstract readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldSchema>;
    // (undocumented)
    protected _typeCheck?: MakeNominal;
}

// @alpha
export type TreeNodeSchemaIdentifier<TName extends string = string> = Brand<TName, "tree.TreeNodeSchemaIdentifier">;

// @alpha (undocumented)
export interface TreeNodeStoredSchema {
    readonly leafValue?: ValueSchema;
    readonly mapFields?: TreeFieldStoredSchema;
    readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>;
}

// @alpha
export type TreeNodeUnion<TTypes extends AllowedTypes, API extends "javaScript" | "sharedTree" = "sharedTree"> = TTypes extends readonly [Any] ? unknown : {
    [Index in keyof TTypes]: TTypes[Index] extends InternalTypedSchemaTypes.LazyItem<infer InnerType> ? InnerType extends TreeNodeSchema ? TypedNode<InnerType, API> : never : never;
}[number];

// @alpha
export interface TreeObjectFactory<TSchema extends TreeNodeSchemaBase> {
    create(content: TypedNode<Assume<TSchema, ObjectNodeSchema>, "javaScript">): TreeObjectNode<Assume<TSchema, ObjectNodeSchema>>;
}

// @alpha
export type TreeObjectNode<TSchema extends ObjectNodeSchema, API extends "javaScript" | "sharedTree" = "sharedTree"> = TreeObjectNodeFields<TSchema["objectNodeFieldsObject"], API>;

// @alpha
export type TreeObjectNodeFields<TFields extends RestrictiveReadonlyRecord<string, TreeFieldSchema>, API extends "javaScript" | "sharedTree" = "sharedTree"> = {
    -readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? TFields[key]["kind"] extends typeof FieldKinds.optional ? key : never : never]?: TreeField<TFields[key], API>;
} & {
    -readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? TFields[key]["kind"] extends typeof FieldKinds.optional ? never : key : never]-?: TreeField<TFields[key], API>;
} & {
    readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? never : TFields[key]["kind"] extends typeof FieldKinds.optional ? key : never]?: TreeField<TFields[key], API>;
} & {
    readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? never : TFields[key]["kind"] extends typeof FieldKinds.optional ? never : key]-?: TreeField<TFields[key], API>;
};

// @alpha
export interface TreeSchema<out T extends TreeFieldSchema = TreeFieldSchema> extends SchemaCollection {
    readonly adapters: Adapters;
    readonly policy: FullSchemaPolicy;
    readonly rootFieldSchema: T;
}

// @alpha
export function treeSchemaFromStoredSchema(schema: TreeStoredSchema): TreeSchema;

// @alpha
export enum TreeStatus {
    Deleted = 2,
    InDocument = 0,
    Removed = 1
}

// @alpha
export interface TreeStoredSchema extends StoredSchemaCollection {
    readonly rootFieldSchema: TreeFieldStoredSchema;
}

// @alpha (undocumented)
export type TreeType = TreeNodeSchemaIdentifier;

// @alpha
export type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier> | undefined;

// @alpha
export type TreeValue<TSchema extends ValueSchema = ValueSchema> = [
    {
    [ValueSchema.Number]: number;
    [ValueSchema.String]: string;
    [ValueSchema.Boolean]: boolean;
    [ValueSchema.FluidHandle]: IFluidHandle;
    [ValueSchema.Null]: null;
}[TSchema]
][_InlineTrick];

// @alpha
export interface TreeView<in out TRoot> extends IDisposable {
    readonly events: ISubscribable<CheckoutEvents>;
    readonly root: TRoot;
}

// @alpha
type TypeArrayToTypedFlexTreeArray<T extends readonly TreeNodeSchema[]> = [
ArrayHasFixedLength<T> extends false ? T extends readonly (infer InnerT)[] ? [FlexTreeTypedNode<Assume<InnerT, TreeNodeSchema>>] : never : FixedSizeTypeArrayToTypedFlexTree<T>
][_InlineTrick];

// @alpha
type TypeArrayToTypedTreeArray<Mode extends ApiMode, T extends readonly TreeNodeSchema[]> = [
T extends readonly [infer Head, ...infer Tail] ? [
TypedNode_2<Assume<Head, TreeNodeSchema>, Mode>,
...TypeArrayToTypedTreeArray<Mode, Assume<Tail, readonly TreeNodeSchema[]>>
] : []
][_InlineTrick];

// @alpha
export const typeboxValidator: JsonValidator;

// @alpha
type TypedField<TField extends TreeFieldSchema, Mode extends ApiMode> = [
ApplyMultiplicity<TField["kind"]["multiplicity"], AllowedTypesToTypedTrees<Mode, TField["allowedTypes"]>, Mode>
][_InlineTrick];

// @alpha
type TypedFields<Mode extends ApiMode, TFields extends undefined | {
    readonly [key: string]: TreeFieldSchema;
}> = [
TFields extends {
    [key: string]: TreeFieldSchema;
} ? {
    -readonly [key in keyof TFields]: TypedField<TFields[key], Mode>;
} : EmptyObject
][_InlineTrick];

// @alpha
export type TypedNode<TSchema extends TreeNodeSchema, API extends "javaScript" | "sharedTree" = "sharedTree"> = TSchema extends LeafNodeSchema ? TreeValue<TSchema["info"]> : TSchema extends MapNodeSchema ? API extends "sharedTree" ? TreeMapNode<TSchema> : ReadonlyMap<string, TreeField<TSchema["info"], API>> : TSchema extends FieldNodeSchema ? API extends "sharedTree" ? TreeListNode<TSchema["info"]["allowedTypes"], API> : readonly TreeNodeUnion<TSchema["info"]["allowedTypes"], API>[] : TSchema extends ObjectNodeSchema ? TreeObjectNode<TSchema, API> : unknown;

// @alpha
type TypedNode_2<TSchema extends TreeNodeSchema, Mode extends ApiMode> = FlattenKeys<CollectOptions<Mode, TSchema extends ObjectNodeSchema<string, infer TFields extends Fields> ? TypedFields<Mode, TFields> : TSchema extends FieldNodeSchema<string, infer TField extends TreeFieldSchema> ? TypedFields<Mode, {
    "": TField;
}> : EmptyObject, TSchema extends LeafNodeSchema<string, infer TValueSchema> ? TValueSchema : undefined, TSchema["name"]>>;

// @alpha
export class TypedTreeFactory implements IChannelFactory {
    constructor(options: TypedTreeOptions);
    // (undocumented)
    readonly attributes: IChannelAttributes;
    // (undocumented)
    create(runtime: IFluidDataStoreRuntime, id: string): ITree;
    // (undocumented)
    load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<ITree>;
    // (undocumented)
    readonly type: string;
}

// @alpha
export interface TypedTreeOptions extends SharedTreeOptions {
    readonly subtype: string;
}

// @alpha
type TypedValueOrUndefined<TValue extends ValueSchema | undefined> = TValue extends ValueSchema ? TreeValue<TValue> : undefined;

// @alpha
export const typeNameSymbol: unique symbol;

// @alpha
type Unbrand<T, B> = T extends infer S & B ? S : T;

// @alpha
type UnbrandedName<TName> = [
TName extends TreeNodeSchemaIdentifier<infer S> ? S : string
][_InlineTrick];

// @alpha
type UnbrandList<T extends unknown[], B> = T extends [infer Head, ...infer Tail] ? [Unbrand<Head, B>, ...UnbrandList<Tail, B>] : [];

// @alpha
export type Unenforced<_DesiredExtendsConstraint> = unknown;

// @alpha
type UntypedApi<Mode extends ApiMode> = {
    [ApiMode.Flexible]: ContextuallyTypedNodeData;
    [ApiMode.Simple]: ContextuallyTypedNodeData;
}[Mode];

// @alpha
export interface UpPath<TParent = UpPathDefault> {
    readonly parent: TParent | undefined;
    readonly parentField: FieldKey;
    readonly parentIndex: NodeIndex;
}

// @alpha
export type UpPathDefault = UpPath;

// @alpha
export type Value = undefined | TreeValue;

// @alpha (undocumented)
export interface ValueFieldEditBuilder {
    set(newContent: ITreeCursor): void;
}

// @alpha
export type ValueFromBranded<T extends BrandedType<any, string>> = T extends BrandedType<infer ValueType, string> ? ValueType : never;

// @alpha (undocumented)
type ValuePropertyFromSchema<TSchema extends ValueSchema | undefined> = TSchema extends ValueSchema ? {
    [valueSymbol]: TreeValue<TSchema>;
} : EmptyObject;

// @alpha
export enum ValueSchema {
    // (undocumented)
    Boolean = 2,
    // (undocumented)
    FluidHandle = 3,
    // (undocumented)
    Null = 4,
    // (undocumented)
    Number = 0,
    // (undocumented)
    String = 1
}

// @alpha (undocumented)
type ValuesOf<T> = T[keyof T];

// @alpha
export const valueSymbol: unique symbol;

// @alpha
type WithDefault<T, Default> = T extends undefined ? Default : unknown extends T ? Default : T;

// (No @packageDocumentation comment for this package)

```
