## API Report File for "@fluidframework/merge-tree"

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

```ts

import { AttributionKey } from '@fluidframework/runtime-definitions';
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IFluidHandle } from '@fluidframework/core-interfaces';
import { IFluidSerializer } from '@fluidframework/shared-object-base';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
import { TypedEventEmitter } from '@fluid-internal/client-utils';

// @internal @deprecated (undocumented)
export function addProperties(oldProps: PropertySet | undefined, newProps: PropertySet, op?: ICombiningOp, seq?: number): PropertySet;

// @internal (undocumented)
export function appendToMergeTreeDeltaRevertibles(deltaArgs: IMergeTreeDeltaCallbackArgs, revertibles: MergeTreeDeltaRevertible[]): void;

// @internal @sealed
export interface AttributionPolicy {
    attach: (client: Client) => void;
    detach: () => void;
    // (undocumented)
    isAttached: boolean;
    serializer: IAttributionCollectionSerializer;
}

// @alpha (undocumented)
export abstract class BaseSegment extends MergeNode implements ISegment {
    // @deprecated (undocumented)
    ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
    // (undocumented)
    addProperties(newProps: PropertySet, op?: ICombiningOp, seq?: number, collabWindow?: CollaborationWindow, rollback?: PropertiesRollback): PropertySet | undefined;
    // (undocumented)
    protected addSerializedProps(jseg: IJSONSegment): void;
    // (undocumented)
    append(other: ISegment): void;
    // (undocumented)
    attribution?: IAttributionCollection<AttributionKey>;
    // (undocumented)
    canAppend(segment: ISegment): boolean;
    // (undocumented)
    clientId: number;
    // (undocumented)
    abstract clone(): ISegment;
    // (undocumented)
    protected cloneInto(b: ISegment): void;
    // (undocumented)
    protected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;
    // (undocumented)
    hasProperty(key: string): boolean;
    // (undocumented)
    isLeaf(): boolean;
    // (undocumented)
    localRefs?: LocalReferenceCollection;
    // (undocumented)
    localRemovedSeq?: number;
    // (undocumented)
    localSeq?: number;
    // (undocumented)
    properties?: PropertySet;
    // (undocumented)
    propertyManager?: PropertiesManager;
    // (undocumented)
    removedClientIds?: number[];
    // (undocumented)
    removedSeq?: number;
    // (undocumented)
    readonly segmentGroups: SegmentGroupCollection;
    // (undocumented)
    seq: number;
    // (undocumented)
    splitAt(pos: number): ISegment | undefined;
    // (undocumented)
    abstract toJSONObject(): any;
    // (undocumented)
    readonly trackingCollection: TrackingGroupCollection;
    // (undocumented)
    abstract readonly type: string;
}

// @alpha @deprecated (undocumented)
export class Client extends TypedEventEmitter<IClientEvents> {
    constructor(specToSegment: (spec: IJSONSegment) => ISegment, logger: ITelemetryLoggerExt, options?: PropertySet);
    // (undocumented)
    addLongClientId(longClientId: string): void;
    annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): IMergeTreeAnnotateMsg | undefined;
    // @deprecated
    annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, consensusCallback: (m: Marker) => void): IMergeTreeAnnotateMsg | undefined;
    annotateRangeLocal(start: number, end: number, props: PropertySet, combiningOp: ICombiningOp | undefined): IMergeTreeAnnotateMsg | undefined;
    // (undocumented)
    applyMsg(msg: ISequencedDocumentMessage, local?: boolean): void;
    // (undocumented)
    applyStashedOp(op: IMergeTreeDeltaOp): SegmentGroup;
    // (undocumented)
    applyStashedOp(op: IMergeTreeGroupMsg): SegmentGroup[];
    // (undocumented)
    applyStashedOp(op: IMergeTreeOp): SegmentGroup | SegmentGroup[];
    // (undocumented)
    cloneFromSegments(): Client;
    createLocalReferencePosition(segment: ISegment | "start" | "end", offset: number | undefined, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
    // (undocumented)
    createTextHelper(): IMergeTreeTextHelper;
    findReconnectionPosition(segment: ISegment, localSeq: number): number;
    // @deprecated (undocumented)
    findTile(startPos: number, tileLabel: string, preceding?: boolean): {
        tile: ReferencePosition;
        pos: number;
    } | undefined;
    // (undocumented)
    getClientId(): number;
    // (undocumented)
    getCollabWindow(): CollaborationWindow;
    // (undocumented)
    getContainingSegment<T extends ISegment>(pos: number, sequenceArgs?: Pick<ISequencedDocumentMessage, "referenceSequenceNumber" | "clientId">, localSeq?: number): {
        segment: T | undefined;
        offset: number | undefined;
    };
    // (undocumented)
    getCurrentSeq(): number;
    // (undocumented)
    getLength(): number;
    // (undocumented)
    getLongClientId(shortClientId: number): string;
    // (undocumented)
    getMarkerFromId(id: string): ISegment | undefined;
    // (undocumented)
    getOrAddShortClientId(longClientId: string): number;
    getPosition(segment: ISegment | undefined, localSeq?: number): number;
    // (undocumented)
    getPropertiesAtPosition(pos: number): PropertySet | undefined;
    // (undocumented)
    getRangeExtentsOfPosition(pos: number): {
        posStart: number | undefined;
        posAfterEnd: number | undefined;
    };
    // (undocumented)
    getShortClientId(longClientId: string): number;
    // @deprecated (undocumented)
    getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
    // (undocumented)
    insertAtReferencePositionLocal(refPos: ReferencePosition, segment: ISegment): IMergeTreeInsertMsg | undefined;
    // (undocumented)
    insertSegmentLocal(pos: number, segment: ISegment): IMergeTreeInsertMsg | undefined;
    // (undocumented)
    load(runtime: IFluidDataStoreRuntime, storage: IChannelStorageService, serializer: IFluidSerializer): Promise<{
        catchupOpsP: Promise<ISequencedDocumentMessage[]>;
    }>;
    localReferencePositionToPosition(lref: ReferencePosition): number;
    // (undocumented)
    localTransaction(groupOp: IMergeTreeGroupMsg): void;
    // (undocumented)
    readonly logger: ITelemetryLoggerExt;
    // (undocumented)
    longClientId: string | undefined;
    peekPendingSegmentGroups(): SegmentGroup | undefined;
    // (undocumented)
    peekPendingSegmentGroups(count: number): SegmentGroup | SegmentGroup[] | undefined;
    posFromRelativePos(relativePos: IRelativePosition): number;
    regeneratePendingOp(resetOp: IMergeTreeOp, segmentGroup: SegmentGroup | SegmentGroup[]): IMergeTreeOp;
    removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
    removeRangeLocal(start: number, end: number): IMergeTreeRemoveMsg;
    resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
    rollback?(op: any, localOpMetadata: unknown): void;
    searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
    serializeGCData(handle: IFluidHandle, handleCollectingSerializer: IFluidSerializer): void;
    // (undocumented)
    readonly specToSegment: (spec: IJSONSegment) => ISegment;
    // (undocumented)
    startOrUpdateCollaboration(longClientId: string | undefined, minSeq?: number, currentSeq?: number): void;
    // (undocumented)
    summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer, catchUpMsgs: ISequencedDocumentMessage[]): ISummaryTreeWithStats;
    // (undocumented)
    updateConsensusProperty(op: IMergeTreeAnnotateMsg, msg: ISequencedDocumentMessage): void;
    // (undocumented)
    updateMinSeq(minSeq: number): void;
    // (undocumented)
    updateSeqNumbers(min: number, seq: number): void;
    // (undocumented)
    protected walkAllSegments<TClientData>(action: (segment: ISegment, accum?: TClientData) => boolean, accum?: TClientData): boolean;
    // (undocumented)
    walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start: number | undefined, end: number | undefined, accum: TClientData, splitRange?: boolean): void;
    // (undocumented)
    walkSegments<undefined>(handler: ISegmentAction<undefined>, start?: number, end?: number, accum?: undefined, splitRange?: boolean): void;
}

// @internal @deprecated (undocumented)
export function clone<T>(extension: MapLike<T> | undefined): MapLike<T> | undefined;

// @alpha @deprecated (undocumented)
export class CollaborationWindow {
    // (undocumented)
    clientId: number;
    // (undocumented)
    collaborating: boolean;
    currentSeq: number;
    // (undocumented)
    loadFrom(a: CollaborationWindow): void;
    localSeq: number;
    minSeq: number;
}

// @internal @deprecated (undocumented)
export function combine(combiningInfo: ICombiningOp, currentValue: any, newValue: any, seq?: number): any;

// @internal @deprecated (undocumented)
export const compareNumbers: (a: number, b: number) => number;

// @internal (undocumented)
export function compareReferencePositions(a: ReferencePosition, b: ReferencePosition): number;

// @internal @deprecated (undocumented)
export const compareStrings: (a: string, b: string) => number;

// @internal (undocumented)
export type ConflictAction<TKey, TData> = (key: TKey, currentKey: TKey, data: TData, currentData: TData) => QProperty<TKey, TData>;

// @internal @deprecated
export function createAnnotateMarkerOp(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): IMergeTreeAnnotateMsg | undefined;

// @internal @deprecated
export function createAnnotateRangeOp(start: number, end: number, props: PropertySet, combiningOp: ICombiningOp | undefined): IMergeTreeAnnotateMsg;

// @internal (undocumented)
export function createDetachedLocalReferencePosition(refType?: ReferenceType): LocalReferencePosition;

// @internal @deprecated (undocumented)
export function createGroupOp(...ops: IMergeTreeDeltaOp[]): IMergeTreeGroupMsg;

// @internal (undocumented)
export function createInsertOnlyAttributionPolicy(): AttributionPolicy;

// @internal @deprecated (undocumented)
export function createInsertOp(pos: number, segSpec: any): IMergeTreeInsertMsg;

// @internal @deprecated (undocumented)
export function createInsertSegmentOp(pos: number, segment: ISegment): IMergeTreeInsertMsg;

// @internal @deprecated (undocumented)
export function createMap<T>(): MapLike<T>;

// @internal @deprecated
export function createRemoveRangeOp(start: number, end: number): IMergeTreeRemoveMsg;

// @internal (undocumented)
export function debugMarkerToString(marker: Marker): string;

// @internal (undocumented)
export const DetachedReferencePosition = -1;

// @internal (undocumented)
export interface Dictionary<TKey, TData> {
    // (undocumented)
    get(key: TKey): Property<TKey, TData> | undefined;
    // (undocumented)
    map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;
    // (undocumented)
    put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;
    // (undocumented)
    remove(key: TKey): void;
}

// @internal (undocumented)
export function discardMergeTreeDeltaRevertible(revertibles: MergeTreeDeltaRevertible[]): void;

// @internal @deprecated (undocumented)
export function extend<T>(base: MapLike<T>, extension: MapLike<T> | undefined, combiningOp?: ICombiningOp, seq?: number): MapLike<T>;

// @internal @deprecated (undocumented)
export function extendIfUndefined<T>(base: MapLike<T>, extension: MapLike<T> | undefined): MapLike<T>;

// @internal
export function getSlideToSegoff(segoff: {
    segment: ISegment | undefined;
    offset: number | undefined;
}, slidingPreference?: SlidingPreference, useNewSlidingBehavior?: boolean): {
    segment: ISegment | undefined;
    offset: number | undefined;
};

// @alpha (undocumented)
export interface IAttributionCollection<T> {
    // (undocumented)
    append(other: IAttributionCollection<T>): void;
    // (undocumented)
    readonly channelNames: Iterable<string>;
    // (undocumented)
    clone(): IAttributionCollection<T>;
    getAll(): IAttributionCollectionSpec<T>;
    getAtOffset(offset: number, channel?: string): AttributionKey | undefined;
    readonly length: number;
    // (undocumented)
    splitAt(pos: number): IAttributionCollection<T>;
    update(name: string | undefined, channel: IAttributionCollection<T>): any;
}

// @internal @sealed (undocumented)
export interface IAttributionCollectionSerializer {
    populateAttributionCollections(segments: Iterable<ISegment>, summary: SerializedAttributionCollection): void;
    // (undocumented)
    serializeAttributionCollections(segments: Iterable<{
        attribution?: IAttributionCollection<AttributionKey>;
        cachedLength: number;
    }>): SerializedAttributionCollection;
}

// @alpha (undocumented)
export interface IAttributionCollectionSpec<T> {
    // (undocumented)
    channels?: {
        [name: string]: Iterable<{
            offset: number;
            key: T | null;
        }>;
    };
    // (undocumented)
    length: number;
    // (undocumented)
    root: Iterable<{
        offset: number;
        key: T | null;
    }>;
}

// @alpha
export interface IClientEvents {
    // (undocumented)
    (event: "normalize", listener: (target: IEventThisPlaceHolder) => void): any;
    // (undocumented)
    (event: "delta", listener: (opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, target: IEventThisPlaceHolder) => void): any;
    // (undocumented)
    (event: "maintenance", listener: (args: IMergeTreeMaintenanceCallbackArgs, deltaArgs: IMergeTreeDeltaOpArgs | undefined, target: IEventThisPlaceHolder) => void): any;
}

// @alpha @deprecated (undocumented)
export interface ICombiningOp {
    // (undocumented)
    defaultValue?: any;
    // (undocumented)
    maxValue?: any;
    // (undocumented)
    minValue?: any;
    // (undocumented)
    name: string;
}

// @internal @deprecated (undocumented)
export interface IConsensusInfo {
    // (undocumented)
    callback: (m: Marker) => void;
    // (undocumented)
    marker: Marker;
}

// @internal @deprecated (undocumented)
export interface IConsensusValue {
    // (undocumented)
    seq: number;
    // (undocumented)
    value: any;
}

// @internal @deprecated
export interface IIntegerRange {
    // (undocumented)
    end: number;
    // (undocumented)
    start: number;
}

// @alpha (undocumented)
export interface IJSONMarkerSegment extends IJSONSegment {
    // (undocumented)
    marker: IMarkerDef;
}

// @alpha (undocumented)
export interface IJSONSegment {
    // (undocumented)
    props?: Record<string, any>;
}

// @internal (undocumented)
export interface IJSONTextSegment extends IJSONSegment {
    // (undocumented)
    text: string;
}

// @alpha (undocumented)
export interface IMarkerDef {
    // (undocumented)
    refType?: ReferenceType;
}

// @internal @deprecated (undocumented)
export interface IMarkerModifiedAction {
    // (undocumented)
    (marker: Marker): void;
}

// @alpha
export interface IMergeNodeCommon {
    index: number;
    // (undocumented)
    isLeaf(): this is ISegment;
    ordinal: string;
}

// @alpha (undocumented)
export interface IMergeTreeAnnotateMsg extends IMergeTreeDelta {
    // @deprecated (undocumented)
    combiningOp?: ICombiningOp;
    // (undocumented)
    pos1?: number;
    // (undocumented)
    pos2?: number;
    // (undocumented)
    props: Record<string, any>;
    // (undocumented)
    relativePos1?: IRelativePosition;
    // (undocumented)
    relativePos2?: IRelativePosition;
    // (undocumented)
    type: typeof MergeTreeDeltaType.ANNOTATE;
}

// @internal (undocumented)
export interface IMergeTreeAttributionOptions {
    policyFactory?: () => AttributionPolicy;
    track?: boolean;
}

// @internal (undocumented)
export interface IMergeTreeClientSequenceArgs {
    // (undocumented)
    readonly clientId: number;
    // (undocumented)
    readonly referenceSequenceNumber: number;
    // (undocumented)
    readonly sequenceNumber: number;
}

// @alpha (undocumented)
export interface IMergeTreeDelta {
    type: MergeTreeDeltaType;
}

// @alpha (undocumented)
export interface IMergeTreeDeltaCallbackArgs<TOperationType extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationType> {
    // (undocumented)
    readonly deltaSegments: IMergeTreeSegmentDelta[];
    // (undocumented)
    readonly operation: TOperationType;
}

// @alpha (undocumented)
export type IMergeTreeDeltaOp = IMergeTreeInsertMsg | IMergeTreeRemoveMsg | IMergeTreeAnnotateMsg;

// @alpha (undocumented)
export interface IMergeTreeDeltaOpArgs {
    readonly groupOp?: IMergeTreeGroupMsg;
    readonly op: IMergeTreeOp;
    readonly sequencedMessage?: ISequencedDocumentMessage;
    readonly stashed?: boolean;
}

// @alpha @deprecated (undocumented)
export interface IMergeTreeGroupMsg extends IMergeTreeDelta {
    // (undocumented)
    ops: IMergeTreeDeltaOp[];
    // (undocumented)
    type: typeof MergeTreeDeltaType.GROUP;
}

// @alpha (undocumented)
export interface IMergeTreeInsertMsg extends IMergeTreeDelta {
    // (undocumented)
    pos1?: number;
    // (undocumented)
    pos2?: number;
    // (undocumented)
    relativePos1?: IRelativePosition;
    // (undocumented)
    relativePos2?: IRelativePosition;
    // (undocumented)
    seg?: any;
    // (undocumented)
    type: typeof MergeTreeDeltaType.INSERT;
}

// @alpha (undocumented)
export interface IMergeTreeMaintenanceCallbackArgs extends IMergeTreeDeltaCallbackArgs<MergeTreeMaintenanceType> {
}

// @alpha (undocumented)
export type IMergeTreeOp = IMergeTreeDeltaOp | IMergeTreeGroupMsg;

// @internal (undocumented)
export interface IMergeTreeOptions {
    attribution?: IMergeTreeAttributionOptions;
    // (undocumented)
    catchUpBlobName?: string;
    mergeTreeReferencesCanSlideToEndpoint?: boolean;
    // (undocumented)
    mergeTreeSnapshotChunkSize?: number;
    newMergeTreeSnapshotFormat?: boolean;
}

// @alpha (undocumented)
export interface IMergeTreeRemoveMsg extends IMergeTreeDelta {
    // (undocumented)
    pos1?: number;
    // (undocumented)
    pos2?: number;
    // (undocumented)
    relativePos1?: IRelativePosition;
    // (undocumented)
    relativePos2?: IRelativePosition;
    // (undocumented)
    type: typeof MergeTreeDeltaType.REMOVE;
}

// @alpha (undocumented)
export interface IMergeTreeSegmentDelta {
    // (undocumented)
    propertyDeltas?: PropertySet;
    // (undocumented)
    segment: ISegment;
}

// @alpha @deprecated (undocumented)
export interface IMergeTreeTextHelper {
    // (undocumented)
    getText(refSeq: number, clientId: number, placeholder: string, start?: number, end?: number): string;
}

// @internal @deprecated (undocumented)
export function internedSpaces(n: number): string;

// @internal (undocumented)
export interface IRBAugmentation<TKey, TData> {
    // (undocumented)
    update(node: RBNode<TKey, TData>): void;
}

// @internal (undocumented)
export interface IRBMatcher<TKey, TData> {
    // (undocumented)
    continueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;
    // (undocumented)
    matchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;
}

// @alpha
export interface IRelativePosition {
    before?: boolean;
    id?: string;
    offset?: number;
}

// @alpha
export interface IRemovalInfo {
    localRemovedSeq?: number;
    removedClientIds: number[];
    removedSeq: number;
}

// @alpha
export interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo> {
    // @deprecated
    ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
    // (undocumented)
    addProperties(newProps: PropertySet, op?: ICombiningOp, seq?: number, collabWindow?: CollaborationWindow, rollback?: PropertiesRollback): PropertySet | undefined;
    // (undocumented)
    append(segment: ISegment): void;
    attribution?: IAttributionCollection<AttributionKey>;
    cachedLength: number;
    // (undocumented)
    canAppend(segment: ISegment): boolean;
    clientId: number;
    // (undocumented)
    clone(): ISegment;
    readonly endpointType?: "start" | "end";
    localRefs?: LocalReferenceCollection;
    localRemovedSeq?: number;
    localSeq?: number;
    properties?: PropertySet;
    propertyManager?: PropertiesManager;
    // (undocumented)
    readonly segmentGroups: SegmentGroupCollection;
    seq?: number;
    // (undocumented)
    splitAt(pos: number): ISegment | undefined;
    // (undocumented)
    toJSONObject(): any;
    // (undocumented)
    readonly trackingCollection: TrackingGroupCollection;
    // (undocumented)
    readonly type: string;
}

// @alpha (undocumented)
export interface ISegmentAction<TClientData> {
    // (undocumented)
    (segment: ISegment, pos: number, refSeq: number, clientId: number, start: number, end: number, accum: TClientData): boolean;
}

// @internal
export function isMergeTreeDeltaRevertible(x: unknown): x is MergeTreeDeltaRevertible;

// @alpha (undocumented)
export interface ITrackingGroup {
    // (undocumented)
    has(trackable: Trackable): boolean;
    // (undocumented)
    link(trackable: Trackable): void;
    // (undocumented)
    size: number;
    // (undocumented)
    tracked: readonly Trackable[];
    // (undocumented)
    unlink(trackable: Trackable): boolean;
}

// @internal (undocumented)
export interface KeyComparer<TKey> {
    // (undocumented)
    (a: TKey, b: TKey): number;
}

// @internal @deprecated (undocumented)
export const LocalClientId = -1;

// @alpha
export class LocalReferenceCollection {
    // (undocumented)
    [Symbol.iterator](): {
        next(): IteratorResult<LocalReferencePosition>;
        [Symbol.iterator](): any;
    };
    constructor(
    segment: ISegment, initialRefsByfOffset?: (IRefsAtOffset | undefined)[]);
    // (undocumented)
    addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
    // (undocumented)
    addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
    // (undocumented)
    addLocalRef(lref: LocalReferencePosition, offset: number): void;
    // (undocumented)
    static append(seg1: ISegment, seg2: ISegment): void;
    append(other: LocalReferenceCollection): void;
    // (undocumented)
    clear(): void;
    // (undocumented)
    createLocalRef(offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
    // (undocumented)
    get empty(): boolean;
    has(lref: ReferencePosition): boolean;
    // (undocumented)
    hierRefCount: number;
    // (undocumented)
    isAfterTombstone(lref: LocalReferencePosition): boolean;
    // (undocumented)
    removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined;
    split(offset: number, splitSeg: ISegment): void;
    // (undocumented)
    walkReferences(visitor: (lref: LocalReferencePosition) => boolean | void | undefined, start?: LocalReferencePosition, forward?: boolean): boolean;
}

// @alpha @sealed (undocumented)
export interface LocalReferencePosition extends ReferencePosition {
    // (undocumented)
    callbacks?: Partial<Record<"beforeSlide" | "afterSlide", (ref: LocalReferencePosition) => void>>;
    readonly canSlideToEndpoint?: boolean;
    // (undocumented)
    readonly trackingCollection: TrackingGroupCollection;
}

// @alpha (undocumented)
export interface MapLike<T> {
    // (undocumented)
    [index: string]: T;
}

// @alpha (undocumented)
export class Marker extends BaseSegment implements ReferencePosition {
    constructor(refType: ReferenceType);
    // (undocumented)
    append(): void;
    // (undocumented)
    canAppend(segment: ISegment): boolean;
    // (undocumented)
    clone(): Marker;
    // (undocumented)
    protected createSplitSegmentAt(pos: number): undefined;
    // (undocumented)
    static fromJSONObject(spec: any): Marker | undefined;
    // (undocumented)
    getId(): string | undefined;
    // (undocumented)
    getOffset(): number;
    // (undocumented)
    getProperties(): PropertySet | undefined;
    // (undocumented)
    getSegment(): this;
    // (undocumented)
    hasSimpleType(simpleTypeName: string): boolean;
    // (undocumented)
    static is(segment: ISegment): segment is Marker;
    // (undocumented)
    static make(refType: ReferenceType, props?: PropertySet): Marker;
    // (undocumented)
    refType: ReferenceType;
    // (undocumented)
    toJSONObject(): IJSONMarkerSegment;
    // (undocumented)
    toString(): string;
    // (undocumented)
    static readonly type = "Marker";
    // (undocumented)
    readonly type = "Marker";
}

// @internal @deprecated (undocumented)
export function matchProperties(a: PropertySet | undefined, b: PropertySet | undefined): boolean;

// @internal (undocumented)
export function maxReferencePosition<T extends ReferencePosition>(a: T, b: T): T;

// @alpha (undocumented)
export class MergeNode implements IMergeNodeCommon {
    // (undocumented)
    cachedLength: number;
    // (undocumented)
    index: number;
    // (undocumented)
    isLeaf(): this is ISegment;
    // (undocumented)
    ordinal: string;
}

// @internal @deprecated (undocumented)
export type MergeTreeDeltaCallback = (opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs) => void;

// @alpha (undocumented)
export type MergeTreeDeltaOperationType = typeof MergeTreeDeltaType.ANNOTATE | typeof MergeTreeDeltaType.INSERT | typeof MergeTreeDeltaType.REMOVE;

// @alpha (undocumented)
export type MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationType | MergeTreeMaintenanceType;

// @internal (undocumented)
export type MergeTreeDeltaRevertible = {
    operation: typeof MergeTreeDeltaType.INSERT;
    trackingGroup: ITrackingGroup;
} | {
    operation: typeof MergeTreeDeltaType.REMOVE;
    trackingGroup: ITrackingGroup;
} | {
    operation: typeof MergeTreeDeltaType.ANNOTATE;
    trackingGroup: ITrackingGroup;
    propertyDeltas: PropertySet;
};

// @alpha (undocumented)
export const MergeTreeDeltaType: {
    readonly INSERT: 0;
    readonly REMOVE: 1;
    readonly ANNOTATE: 2;
    readonly GROUP: 3;
};

// @alpha (undocumented)
export type MergeTreeDeltaType = (typeof MergeTreeDeltaType)[keyof typeof MergeTreeDeltaType];

// @internal @deprecated (undocumented)
export type MergeTreeMaintenanceCallback = (MaintenanceArgs: IMergeTreeMaintenanceCallbackArgs, opArgs: IMergeTreeDeltaOpArgs | undefined) => void;

// @alpha
export const MergeTreeMaintenanceType: {
    readonly APPEND: -1;
    readonly SPLIT: -2;
    readonly UNLINK: -3;
    readonly ACKNOWLEDGED: -4;
};

// @alpha (undocumented)
export type MergeTreeMaintenanceType = (typeof MergeTreeMaintenanceType)[keyof typeof MergeTreeMaintenanceType];

// @alpha (undocumented)
export interface MergeTreeRevertibleDriver {
    // (undocumented)
    annotateRange(start: number, end: number, props: PropertySet): any;
    // (undocumented)
    insertFromSpec(pos: number, spec: IJSONSegment): any;
    // (undocumented)
    removeRange(start: number, end: number): any;
}

// @internal (undocumented)
export function minReferencePosition<T extends ReferencePosition>(a: T, b: T): T;

// @internal @deprecated (undocumented)
export const NonCollabClient = -2;

// @alpha (undocumented)
export class PropertiesManager {
    constructor();
    // (undocumented)
    ackPendingProperties(annotateOp: IMergeTreeAnnotateMsg): void;
    // (undocumented)
    addProperties(oldProps: PropertySet, newProps: PropertySet, op?: ICombiningOp, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet | undefined;
    // (undocumented)
    copyTo(oldProps: PropertySet, newProps: PropertySet | undefined, newManager: PropertiesManager): PropertySet | undefined;
    // (undocumented)
    hasPendingProperties(): boolean;
    // (undocumented)
    hasPendingProperty(key: string): boolean;
}

// @alpha (undocumented)
export enum PropertiesRollback {
    None = 0,
    // @deprecated
    Rewrite = 2,
    Rollback = 1
}

// @internal (undocumented)
export interface Property<TKey, TData> {
    // (undocumented)
    data: TData;
    // (undocumented)
    key: TKey;
}

// @internal (undocumented)
export interface PropertyAction<TKey, TData> {
    // (undocumented)
    <TAccum>(p: Property<TKey, TData>, accum?: TAccum): boolean;
}

// @alpha (undocumented)
export type PropertySet = MapLike<any>;

// @internal (undocumented)
export interface QProperty<TKey, TData> {
    // (undocumented)
    data?: TData;
    // (undocumented)
    key?: TKey;
}

// @alpha @deprecated (undocumented)
export type RangeStackMap = MapLike<Stack<ReferencePosition>>;

// @internal (undocumented)
export const RBColor: {
    readonly RED: 0;
    readonly BLACK: 1;
};

// @internal (undocumented)
export type RBColor = (typeof RBColor)[keyof typeof RBColor];

// @internal (undocumented)
export interface RBNode<TKey, TData> {
    // (undocumented)
    color: RBColor;
    // (undocumented)
    data: TData;
    // (undocumented)
    key: TKey;
    // (undocumented)
    left: RBNode<TKey, TData> | undefined;
    // (undocumented)
    right: RBNode<TKey, TData> | undefined;
    // (undocumented)
    size: number;
}

// @internal (undocumented)
export interface RBNodeActions<TKey, TData> {
    // (undocumented)
    infix?(node: RBNode<TKey, TData>): boolean;
    // (undocumented)
    post?(node: RBNode<TKey, TData>): boolean;
    // (undocumented)
    pre?(node: RBNode<TKey, TData>): boolean;
    // (undocumented)
    showStructure?: boolean;
}

// @internal (undocumented)
export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {
    constructor(compareKeys: KeyComparer<TKey>, aug?: IRBAugmentation<TKey, TData> | undefined);
    // (undocumented)
    ceil(key: TKey): RBNode<TKey, TData> | undefined;
    // (undocumented)
    floor(key: TKey): RBNode<TKey, TData> | undefined;
    // (undocumented)
    gather(key: TKey, matcher: IRBMatcher<TKey, TData>): RBNode<TKey, TData>[];
    // (undocumented)
    get(key: TKey): RBNode<TKey, TData> | undefined;
    // (undocumented)
    isEmpty(): boolean;
    // (undocumented)
    keys(): TKey[];
    // (undocumented)
    map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;
    // (undocumented)
    mapRange<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum, start?: TKey, end?: TKey): void;
    // (undocumented)
    max(): RBNode<TKey, TData> | undefined;
    // (undocumented)
    min(): RBNode<TKey, TData> | undefined;
    // (undocumented)
    put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;
    // (undocumented)
    remove(key: TKey): void;
    // (undocumented)
    removeExisting(key: TKey): void;
    // (undocumented)
    size(): number;
    walk(actions: RBNodeActions<TKey, TData>): void;
    // (undocumented)
    walkBackward(actions: RBNodeActions<TKey, TData>): void;
    // (undocumented)
    walkExactMatchesBackward(compareFn: (node: RBNode<TKey, TData>) => number, actionFn: (node: RBNode<TKey, TData>) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void;
    // (undocumented)
    walkExactMatchesForward(compareFn: (node: RBNode<TKey, TData>) => number, actionFn: (node: RBNode<TKey, TData>) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void;
}

// @alpha
export interface ReferencePosition {
    // (undocumented)
    addProperties(newProps: PropertySet, op?: ICombiningOp): void;
    getOffset(): number;
    getSegment(): ISegment | undefined;
    // (undocumented)
    isLeaf(): this is ISegment;
    // (undocumented)
    properties?: PropertySet;
    // (undocumented)
    refType: ReferenceType;
    slidingPreference?: SlidingPreference;
}

// @alpha
export enum ReferenceType {
    // @deprecated (undocumented)
    NestBegin = 2,
    // @deprecated (undocumented)
    NestEnd = 4,
    // (undocumented)
    RangeBegin = 16,
    // (undocumented)
    RangeEnd = 32,
    // (undocumented)
    Simple = 0,
    SlideOnRemove = 64,
    StayOnRemove = 128,
    Tile = 1,
    Transient = 256
}

// @internal @deprecated (undocumented)
export const refGetRangeLabels: (refPos: ReferencePosition) => string[] | undefined;

// @internal (undocumented)
export const refGetTileLabels: (refPos: ReferencePosition) => string[] | undefined;

// @internal @deprecated (undocumented)
export function refHasRangeLabel(refPos: ReferencePosition, label: string): boolean;

// @internal @deprecated (undocumented)
export function refHasRangeLabels(refPos: ReferencePosition): boolean;

// @internal (undocumented)
export function refHasTileLabel(refPos: ReferencePosition, label: string): boolean;

// @internal (undocumented)
export function refHasTileLabels(refPos: ReferencePosition): boolean;

// @internal (undocumented)
export function refTypeIncludesFlag(refPosOrType: ReferencePosition | ReferenceType, flags: ReferenceType): boolean;

// @internal (undocumented)
export const reservedMarkerIdKey = "markerId";

// @internal (undocumented)
export const reservedMarkerSimpleTypeKey = "markerSimpleType";

// @internal (undocumented)
export const reservedRangeLabelsKey = "referenceRangeLabels";

// @internal (undocumented)
export const reservedTileLabelsKey = "referenceTileLabels";

// @internal (undocumented)
export function revertMergeTreeDeltaRevertibles(driver: MergeTreeRevertibleDriver, revertibles: MergeTreeDeltaRevertible[]): void;

// @internal @deprecated (undocumented)
export interface SegmentAccumulator {
    // (undocumented)
    segments: ISegment[];
}

// @alpha @deprecated (undocumented)
export interface SegmentGroup {
    // (undocumented)
    localSeq: number;
    // (undocumented)
    previousProps?: PropertySet[];
    // (undocumented)
    refSeq: number;
    // (undocumented)
    segments: ISegment[];
}

// @alpha (undocumented)
export class SegmentGroupCollection {
    constructor(segment: ISegment);
    // (undocumented)
    copyTo(segment: ISegment): void;
    // @deprecated (undocumented)
    dequeue(): SegmentGroup | undefined;
    // (undocumented)
    get empty(): boolean;
    // @deprecated (undocumented)
    enqueue(segmentGroup: SegmentGroup): void;
    // @deprecated (undocumented)
    pop?(): SegmentGroup | undefined;
    // (undocumented)
    remove?(segmentGroup: SegmentGroup): boolean;
    // (undocumented)
    get size(): number;
}

// @internal (undocumented)
export interface SequenceOffsets {
    // (undocumented)
    posBreakpoints: number[];
    seqs: (number | AttributionKey | null)[];
}

// @internal (undocumented)
export interface SerializedAttributionCollection extends SequenceOffsets {
    // (undocumented)
    channels?: {
        [name: string]: SequenceOffsets;
    };
    // (undocumented)
    length: number;
}

// @alpha
export const SlidingPreference: {
    readonly BACKWARD: 0;
    readonly FORWARD: 1;
};

// @alpha
export type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];

// @internal (undocumented)
export interface SortedDictionary<TKey, TData> extends Dictionary<TKey, TData> {
    // (undocumented)
    mapRange<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum, start?: TKey, end?: TKey): void;
    // (undocumented)
    max(): Property<TKey, TData> | undefined;
    // (undocumented)
    min(): Property<TKey, TData> | undefined;
}

// @internal @deprecated
export class SortedSegmentSet<T extends SortedSegmentSetItem = ISegment> extends SortedSet<T, string> {
    // (undocumented)
    protected findItemPosition(item: T): {
        exists: boolean;
        index: number;
    };
    // (undocumented)
    protected getKey(item: T): string;
}

// @internal @deprecated (undocumented)
export type SortedSegmentSetItem = ISegment | LocalReferencePosition | {
    readonly segment: ISegment;
};

// @internal @deprecated (undocumented)
export abstract class SortedSet<T, U extends string | number> {
    // (undocumented)
    addOrUpdate(newItem: T, update?: (existingItem: T, newItem: T) => void): void;
    // (undocumented)
    protected findItemPosition(item: T): {
        exists: boolean;
        index: number;
    };
    // (undocumented)
    protected abstract getKey(t: T): U;
    // (undocumented)
    has(item: T): boolean;
    // (undocumented)
    get items(): readonly T[];
    // (undocumented)
    protected readonly keySortedItems: T[];
    // (undocumented)
    remove(item: T): boolean;
    // (undocumented)
    get size(): number;
}

// @alpha @deprecated (undocumented)
export class Stack<T> {
    // (undocumented)
    empty(): boolean;
    // (undocumented)
    items: T[];
    // (undocumented)
    pop(): T | undefined;
    // (undocumented)
    push(val: T): void;
    // (undocumented)
    top(): T | undefined;
}

// @alpha (undocumented)
export class TextSegment extends BaseSegment {
    constructor(text: string);
    // (undocumented)
    append(segment: ISegment): void;
    // (undocumented)
    canAppend(segment: ISegment): boolean;
    // (undocumented)
    clone(start?: number, end?: number): TextSegment;
    // (undocumented)
    protected createSplitSegmentAt(pos: number): TextSegment | undefined;
    // (undocumented)
    static fromJSONObject(spec: any): TextSegment | undefined;
    // (undocumented)
    static is(segment: ISegment): segment is TextSegment;
    // (undocumented)
    static make(text: string, props?: PropertySet): TextSegment;
    // (undocumented)
    removeRange(start: number, end: number): boolean;
    // (undocumented)
    text: string;
    // (undocumented)
    toJSONObject(): string | {
        text: string;
        props: PropertySet;
    };
    // (undocumented)
    toString(): string;
    // (undocumented)
    static readonly type = "TextSegment";
    // (undocumented)
    readonly type = "TextSegment";
}

// @internal @deprecated (undocumented)
export function toRemovalInfo(maybe: Partial<IRemovalInfo> | undefined): IRemovalInfo | undefined;

// @alpha (undocumented)
export type Trackable = ISegment | LocalReferencePosition;

// @alpha (undocumented)
export class TrackingGroup implements ITrackingGroup {
    constructor();
    // (undocumented)
    has(trackable: Trackable): boolean;
    // (undocumented)
    link(trackable: Trackable): void;
    // (undocumented)
    get size(): number;
    // (undocumented)
    get tracked(): readonly Trackable[];
    // (undocumented)
    unlink(trackable: Trackable): boolean;
}

// @alpha (undocumented)
export class TrackingGroupCollection {
    constructor(trackable: Trackable);
    // (undocumented)
    copyTo(trackable: Trackable): void;
    // (undocumented)
    get empty(): boolean;
    // (undocumented)
    link(trackingGroup: ITrackingGroup): void;
    // (undocumented)
    matches(trackingCollection: TrackingGroupCollection): boolean;
    // (undocumented)
    get trackingGroups(): Set<TrackingGroup>;
    // (undocumented)
    unlink(trackingGroup: ITrackingGroup): boolean;
}

// @internal @deprecated (undocumented)
export const TreeMaintenanceSequenceNumber = -2;

// @internal @deprecated (undocumented)
export const UnassignedSequenceNumber = -1;

// @internal @deprecated
export const UniversalSequenceNumber = 0;

// (No @packageDocumentation comment for this package)

```
