## 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 { Heap } from '@fluidframework/core-utils';
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): PropertySet;

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

// @alpha @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 {
    // (undocumented)
    ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
    // (undocumented)
    addProperties(newProps: PropertySet, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet;
    // (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(): this is ISegment;
    // (undocumented)
    localMovedSeq?: number;
    // (undocumented)
    localRefs?: LocalReferenceCollection;
    // (undocumented)
    localRemovedSeq?: number;
    // (undocumented)
    localSeq?: number;
    // (undocumented)
    movedClientIds?: number[];
    // (undocumented)
    movedSeq?: number;
    // (undocumented)
    movedSeqs?: 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;
    // (undocumented)
    wasMovedOnInsert?: boolean | undefined;
}

// @alpha @deprecated (undocumented)
export class Client extends TypedEventEmitter<IClientEvents> {
    constructor(specToSegment: (spec: IJSONSegment) => ISegment, logger: ITelemetryLoggerExt, options?: IMergeTreeOptions & PropertySet);
    // (undocumented)
    addLongClientId(longClientId: string): void;
    annotateMarker(marker: Marker, props: PropertySet): IMergeTreeAnnotateMsg | undefined;
    annotateRangeLocal(start: number, end: number, props: PropertySet): 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[];
    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)
    protected getShortClientId(longClientId: string): number;
    // (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;
    obliterateRangeLocal(start: number, end: number): IMergeTreeObliterateMsg;
    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)
    updateMinSeq(minSeq: 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;
}

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

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

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

// @internal
export function createAnnotateRangeOp(start: number, end: number, props: PropertySet): 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 (undocumented)
export function createInsertOp(pos: number, segSpec: any): IMergeTreeInsertMsg;

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

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

// @internal
export function createObliterateRangeOp(start: number, end: number): IMergeTreeObliterateMsg;

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

// @internal
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
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>): void;
}

// @alpha @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): void;
    // (undocumented)
    (event: "delta", listener: (opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, target: IEventThisPlaceHolder) => void): void;
    // (undocumented)
    (event: "maintenance", listener: (args: IMergeTreeMaintenanceCallbackArgs, deltaArgs: IMergeTreeDeltaOpArgs | undefined, target: IEventThisPlaceHolder) => void): void;
}

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

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

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

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

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

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

// @alpha (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 | IMergeTreeObliterateMsg;

// @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 @deprecated (undocumented)
export interface IMergeTreeObliterateMsg extends IMergeTreeDelta {
    // (undocumented)
    pos1?: number;
    // (undocumented)
    pos2?: number;
    relativePos1?: never;
    relativePos2?: never;
    // (undocumented)
    type: typeof MergeTreeDeltaType.OBLITERATE;
}

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

// @alpha (undocumented)
export interface IMergeTreeOptions {
    attribution?: IMergeTreeAttributionOptions;
    // (undocumented)
    catchUpBlobName?: string;
    mergeTreeEnableObliterate?: boolean;
    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;
}

// @alpha
export interface IMoveInfo {
    localMovedSeq?: number;
    movedClientIds: number[];
    movedSeq: number;
    movedSeqs: number[];
    moveDst?: ReferencePosition;
    wasMovedOnInsert: boolean;
}

// @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>, Partial<IMoveInfo> {
    ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
    addProperties(newProps: PropertySet, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet;
    // (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;
}

// @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)
    createLocalRef(offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
    // (undocumented)
    get empty(): boolean;
    has(lref: ReferencePosition): boolean;
    // (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
export interface MapLike<T> {
    // (undocumented)
    [index: string]: T;
}

// @alpha
export class Marker extends BaseSegment implements ReferencePosition, ISegment {
    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)
    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 (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;
}

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

// @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;
    readonly OBLITERATE: 4;
};

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

// @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): void;
    // (undocumented)
    insertFromSpec(pos: number, spec: IJSONSegment): void;
    // (undocumented)
    removeRange(start: number, end: number): void;
}

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

// @alpha (undocumented)
export class PropertiesManager {
    // (undocumented)
    ackPendingProperties(annotateOp: IMergeTreeAnnotateMsg): void;
    // (undocumented)
    addProperties(oldProps: PropertySet, newProps: PropertySet, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet;
    // (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,
    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
export type PropertySet = MapLike<any>;

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

// @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): void;
    getOffset(): number;
    getSegment(): ISegment | undefined;
    // (undocumented)
    isLeaf(): this is ISegment;
    properties?: PropertySet;
    // (undocumented)
    refType: ReferenceType;
    slidingPreference?: SlidingPreference;
}

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

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

// @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
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;

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

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

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

// @alpha (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 (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)
    text: string;
    // (undocumented)
    toJSONObject(): IJSONTextSegment | string;
    // (undocumented)
    toString(): string;
    // (undocumented)
    static readonly type = "TextSegment";
    // (undocumented)
    readonly type = "TextSegment";
}

// @internal (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
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
export const UnassignedSequenceNumber = -1;

// @internal
export const UniversalSequenceNumber = 0;

// (No @packageDocumentation comment for this package)

```
