@fluidframework/sequence 2.43.0-343119 → 2.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/api-report/sequence.legacy.alpha.api.md +2 -2
  3. package/dist/intervalCollection.d.ts +4 -9
  4. package/dist/intervalCollection.d.ts.map +1 -1
  5. package/dist/intervalCollection.js +96 -82
  6. package/dist/intervalCollection.js.map +1 -1
  7. package/dist/intervalCollectionMap.d.ts +1 -1
  8. package/dist/intervalCollectionMap.d.ts.map +1 -1
  9. package/dist/intervalCollectionMap.js +2 -2
  10. package/dist/intervalCollectionMap.js.map +1 -1
  11. package/dist/intervalCollectionMapInterfaces.d.ts +13 -6
  12. package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
  13. package/dist/intervalCollectionMapInterfaces.js.map +1 -1
  14. package/dist/intervals/intervalUtils.d.ts +4 -3
  15. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  16. package/dist/intervals/intervalUtils.js +16 -3
  17. package/dist/intervals/intervalUtils.js.map +1 -1
  18. package/dist/intervals/sequenceInterval.d.ts +21 -7
  19. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  20. package/dist/intervals/sequenceInterval.js +88 -16
  21. package/dist/intervals/sequenceInterval.js.map +1 -1
  22. package/dist/packageVersion.d.ts +1 -1
  23. package/dist/packageVersion.d.ts.map +1 -1
  24. package/dist/packageVersion.js +1 -1
  25. package/dist/packageVersion.js.map +1 -1
  26. package/dist/sequence.js +1 -1
  27. package/dist/sequence.js.map +1 -1
  28. package/lib/intervalCollection.d.ts +4 -9
  29. package/lib/intervalCollection.d.ts.map +1 -1
  30. package/lib/intervalCollection.js +98 -82
  31. package/lib/intervalCollection.js.map +1 -1
  32. package/lib/intervalCollectionMap.d.ts +1 -1
  33. package/lib/intervalCollectionMap.d.ts.map +1 -1
  34. package/lib/intervalCollectionMap.js +2 -2
  35. package/lib/intervalCollectionMap.js.map +1 -1
  36. package/lib/intervalCollectionMapInterfaces.d.ts +13 -6
  37. package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
  38. package/lib/intervalCollectionMapInterfaces.js.map +1 -1
  39. package/lib/intervals/intervalUtils.d.ts +4 -3
  40. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  41. package/lib/intervals/intervalUtils.js +15 -3
  42. package/lib/intervals/intervalUtils.js.map +1 -1
  43. package/lib/intervals/sequenceInterval.d.ts +21 -7
  44. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  45. package/lib/intervals/sequenceInterval.js +88 -16
  46. package/lib/intervals/sequenceInterval.js.map +1 -1
  47. package/lib/packageVersion.d.ts +1 -1
  48. package/lib/packageVersion.d.ts.map +1 -1
  49. package/lib/packageVersion.js +1 -1
  50. package/lib/packageVersion.js.map +1 -1
  51. package/lib/sequence.js +1 -1
  52. package/lib/sequence.js.map +1 -1
  53. package/package.json +18 -18
  54. package/src/intervalCollection.ts +122 -142
  55. package/src/intervalCollectionMap.ts +6 -2
  56. package/src/intervalCollectionMapInterfaces.ts +15 -5
  57. package/src/intervals/intervalUtils.ts +31 -3
  58. package/src/intervals/sequenceInterval.ts +135 -72
  59. package/src/packageVersion.ts +1 -1
  60. package/src/sequence.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollection.js","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,+DAAiE;AAEjE,kEAA8E;AAE9E,kEAkB6C;AAC7C,uEAAoF;AACpF,+BAAkC;AASlC,uDAQkC;AAClC,mDAa8B;AAU9B,SAAgB,mBAAmB,CAAC,UAA8B;IACjE,MAAM,SAAS,GAAG,CAAC,UAAU,GAAG,6BAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAI,CAAC,KAAK,CAAC,CAAC,CAAC,eAAI,CAAC,MAAM,CAAC;IAC3F,MAA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G,OAAO,GAAG,CAAC,wBAAa,CAAC,YAAY,CAAC;IAChD,OAAO,GAAG,OAAO,GAAG,wBAAa,CAAC,aAAa,CAAC;IAChD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACxB,CAAC;AAiBD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAC1C,iBAAyC;IAEzC,MAAM,EAAE,QAAQ,EAAE,CAAC,iCAAsB,CAAC,EAAE,mBAAmB,EAAE,GAChE,iBAAiB,CAAC,UAAU,IAAI,EAAE,CAAC;IACpC,OAAO,QAAQ,IAAI,mBAAmB,EAAE,MAAM,KAAK,CAAC;QACnD,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE;QAC7C,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AARD,kEAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tClient,\n\tDetachedReferencePosition,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tgetSlideToSegoff,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n\ttype ISegmentInternal,\n\tcreateLocalReconnectingPerspective,\n\tDoublyLinkedList,\n\ttype ListNode,\n} from \"@fluidframework/merge-tree/internal\";\nimport { LoggingError, UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tIntervalMessageLocalMetadata,\n\tSequenceOptions,\n\ttype IIntervalCollectionTypeOperationValue,\n\ttype IntervalAddLocalMetadata,\n\ttype IntervalChangeLocalMetadata,\n} from \"./intervalCollectionMapInterfaces.js\";\nimport {\n\tcreateIdIntervalIndex,\n\tEndpointIndex,\n\tOverlappingIntervalsIndex,\n\ttype IEndpointIndex,\n\ttype IIdIntervalIndex,\n\ttype ISequenceOverlappingIntervalsIndex,\n\ttype SequenceIntervalIndex,\n} from \"./intervalIndex/index.js\";\nimport {\n\tCompressedSerializedInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tSequenceInterval,\n\tSequenceIntervalClass,\n\tSerializedIntervalDelta,\n\tcreatePositionReferenceFromSegoff,\n\tcreateSequenceInterval,\n\tendReferenceSlidingPreference,\n\tgetSerializedProperties,\n\tstartReferenceSlidingPreference,\n} from \"./intervals/index.js\";\n\nexport type ISerializedIntervalCollectionV1 = ISerializedInterval[];\n\nexport interface ISerializedIntervalCollectionV2 {\n\tlabel: string;\n\tversion: 2;\n\tintervals: CompressedSerializedInterval[];\n}\n\nexport function sidesFromStickiness(stickiness: IntervalStickiness) {\n\tconst startSide = (stickiness & IntervalStickiness.START) !== 0 ? Side.After : Side.Before;\n\tconst endSide = (stickiness & IntervalStickiness.END) !== 0 ? Side.Before : Side.After;\n\n\treturn { startSide, endSide };\n}\n\n/**\n * Decompress an interval after loading a summary from JSON. The exact format\n * of this compression is unspecified and subject to change\n */\nfunction decompressInterval(\n\tinterval: CompressedSerializedInterval,\n\tlabel?: string,\n): ISerializedInterval {\n\tconst stickiness = interval[5] ?? IntervalStickiness.END;\n\tconst { startSide, endSide } = sidesFromStickiness(stickiness);\n\treturn {\n\t\tstart: interval[0],\n\t\tend: interval[1],\n\t\tsequenceNumber: interval[2],\n\t\tintervalType: interval[3],\n\t\tproperties: { ...interval[4], [reservedRangeLabelsKey]: [label] },\n\t\tstickiness,\n\t\tstartSide,\n\t\tendSide,\n\t};\n}\n\n/**\n * Compress an interval prior to serialization as JSON. The exact format of this\n * compression is unspecified and subject to change\n */\nfunction compressInterval(interval: ISerializedInterval): CompressedSerializedInterval {\n\tconst { start, end, sequenceNumber, intervalType, properties } = interval;\n\n\tlet base: CompressedSerializedInterval = [\n\t\tstart,\n\t\tend,\n\t\tsequenceNumber,\n\t\tintervalType,\n\t\t// remove the `referenceRangeLabels` property as it is already stored\n\t\t// in the `label` field of the summary\n\t\t{ ...properties, [reservedRangeLabelsKey]: undefined },\n\t];\n\n\tif (interval.stickiness !== undefined && interval.stickiness !== IntervalStickiness.END) {\n\t\t// reassignment to make it easier for typescript to reason about types\n\t\tbase = [...base, interval.stickiness];\n\t}\n\n\treturn base;\n}\n\nexport function toSequencePlace(\n\tpos: number | \"start\" | \"end\",\n\tside: Side | undefined,\n): SequencePlace {\n\treturn typeof pos === \"number\" && side !== undefined ? { pos, side } : pos;\n}\n\nexport function toOptionalSequencePlace(\n\tpos: number | \"start\" | \"end\" | undefined,\n\tside: Side | undefined,\n): SequencePlace | undefined {\n\treturn typeof pos === \"number\" && side !== undefined ? { pos, side } : pos;\n}\n\nexport function computeStickinessFromSide(\n\tstartPos: number | \"start\" | \"end\" | undefined = -1,\n\tstartSide: Side = Side.Before,\n\tendPos: number | \"start\" | \"end\" | undefined = -1,\n\tendSide: Side = Side.Before,\n): IntervalStickiness {\n\tlet stickiness: IntervalStickiness = IntervalStickiness.NONE;\n\n\tif (startSide === Side.After || startPos === \"start\") {\n\t\tstickiness |= IntervalStickiness.START;\n\t}\n\n\tif (endSide === Side.Before || endPos === \"end\") {\n\t\tstickiness |= IntervalStickiness.END;\n\t}\n\n\treturn stickiness as IntervalStickiness;\n}\n\nexport class LocalIntervalCollection {\n\tpublic readonly overlappingIntervalsIndex: ISequenceOverlappingIntervalsIndex;\n\tpublic readonly idIntervalIndex: IIdIntervalIndex;\n\tpublic readonly endIntervalIndex: IEndpointIndex;\n\tprivate readonly indexes: Set<SequenceIntervalIndex>;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly label: string,\n\t\tprivate readonly options: Partial<SequenceOptions>,\n\t\t/** Callback invoked each time one of the endpoints of an interval slides. */\n\t\tprivate readonly onPositionChange?: (\n\t\t\tinterval: SequenceIntervalClass,\n\t\t\tpreviousInterval: SequenceIntervalClass,\n\t\t) => void,\n\t) {\n\t\tthis.overlappingIntervalsIndex = new OverlappingIntervalsIndex(client);\n\t\tthis.idIntervalIndex = createIdIntervalIndex();\n\t\tthis.endIntervalIndex = new EndpointIndex(client);\n\t\tthis.indexes = new Set([\n\t\t\tthis.overlappingIntervalsIndex,\n\t\t\tthis.idIntervalIndex,\n\t\t\tthis.endIntervalIndex,\n\t\t]);\n\t}\n\n\t/**\n\t * Validates that a serialized interval has the ID property. Creates an ID\n\t * if one does not already exist\n\t *\n\t * @param serializedInterval - The interval to be checked\n\t * @returns The interval's existing or newly created id\n\t */\n\n\tprivate removeIntervalFromIndexes(interval: SequenceIntervalClass) {\n\t\tfor (const index of this.indexes) {\n\t\t\tindex.remove(interval);\n\t\t}\n\t}\n\n\tpublic appendIndex(index: SequenceIntervalIndex) {\n\t\tthis.indexes.add(index);\n\t}\n\n\tpublic removeIndex(index: SequenceIntervalIndex): boolean {\n\t\treturn this.indexes.delete(index);\n\t}\n\n\tpublic removeExistingInterval(interval: SequenceIntervalClass) {\n\t\tthis.removeIntervalFromIndexes(interval);\n\t\tthis.removeIntervalListeners(interval);\n\t}\n\n\tpublic addInterval(\n\t\tid: string,\n\t\tstart: SequencePlace,\n\t\tend: SequencePlace,\n\t\tprops?: PropertySet,\n\t\top?: ISequencedDocumentMessage,\n\t\trollback?: boolean,\n\t) {\n\t\t// This check is intended to prevent scenarios where a random interval is created and then\n\t\t// inserted into a collection. The aim is to ensure that the collection is created first\n\t\t// then the user can create/add intervals based on the collection\n\t\tif (\n\t\t\tprops?.[reservedRangeLabelsKey] !== undefined &&\n\t\t\tprops[reservedRangeLabelsKey][0] !== this.label\n\t\t) {\n\t\t\tthrow new LoggingError(\n\t\t\t\t\"Adding an interval that belongs to another interval collection is not permitted\",\n\t\t\t);\n\t\t}\n\t\tconst interval: SequenceIntervalClass = createSequenceInterval(\n\t\t\tthis.label,\n\t\t\tid,\n\t\t\tstart,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.SlideOnRemove,\n\t\t\top,\n\t\t\tundefined,\n\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t\tprops,\n\t\t\trollback,\n\t\t);\n\n\t\tthis.add(interval);\n\t\treturn interval;\n\t}\n\n\tprivate linkEndpointsToInterval(interval: SequenceIntervalClass): void {\n\t\tinterval.start.addProperties({ interval });\n\t\tinterval.end.addProperties({ interval });\n\t}\n\n\tprivate addIntervalToIndexes(interval: SequenceIntervalClass) {\n\t\tfor (const index of this.indexes) {\n\t\t\tindex.add(interval);\n\t\t}\n\t}\n\n\tpublic add(interval: SequenceIntervalClass): void {\n\t\tthis.linkEndpointsToInterval(interval);\n\t\tthis.addIntervalToIndexes(interval);\n\t\tthis.addIntervalListeners(interval);\n\t}\n\n\tpublic changeInterval(\n\t\tinterval: SequenceIntervalClass,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t) {\n\t\tconst newInterval = interval.modify(\n\t\t\tthis.label,\n\t\t\tstart,\n\t\t\tend,\n\t\t\top,\n\t\t\tlocalSeq,\n\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t);\n\t\tif (newInterval) {\n\t\t\tthis.removeExistingInterval(interval);\n\t\t\tthis.add(newInterval);\n\t\t}\n\t\treturn newInterval;\n\t}\n\n\tpublic serialize(\n\t\tversion: \"1\" | \"2\",\n\t): ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2 {\n\t\tif (version === \"1\") {\n\t\t\treturn Array.from(this.idIntervalIndex, (interval) => interval.serialize());\n\t\t}\n\t\treturn {\n\t\t\tlabel: this.label,\n\t\t\tintervals: Array.from(this.idIntervalIndex, (interval) =>\n\t\t\t\tcompressInterval(interval.serialize()),\n\t\t\t),\n\t\t\tversion: 2,\n\t\t};\n\t}\n\n\tprivate addIntervalListeners(interval: SequenceIntervalClass) {\n\t\tconst cloneRef = (ref: LocalReferencePosition) => {\n\t\t\tconst segment = ref.getSegment();\n\t\t\tif (segment === undefined) {\n\t\t\t\t// Cloning is unnecessary: refs which have slid off the string entirely\n\t\t\t\t// never get slid back on. Creation code for refs doesn't accept undefined segment\n\t\t\t\t// either, so this must be special-cased.\n\t\t\t\treturn ref;\n\t\t\t}\n\n\t\t\treturn this.client.createLocalReferencePosition(\n\t\t\t\tsegment,\n\t\t\t\tref.getOffset(),\n\t\t\t\tReferenceType.Transient,\n\t\t\t\tref.properties,\n\t\t\t\tref.slidingPreference,\n\t\t\t\tref.canSlideToEndpoint,\n\t\t\t);\n\t\t};\n\t\tlet previousInterval: SequenceIntervalClass | undefined;\n\t\tlet pendingChanges = 0;\n\t\tinterval.addPositionChangeListeners(\n\t\t\t() => {\n\t\t\t\tpendingChanges++;\n\t\t\t\t// Note: both start and end can change and invoke beforeSlide on each endpoint before afterSlide.\n\t\t\t\tif (!previousInterval) {\n\t\t\t\t\tpreviousInterval = interval.clone();\n\t\t\t\t\tpreviousInterval.start = cloneRef(previousInterval.start);\n\t\t\t\t\tpreviousInterval.end = cloneRef(previousInterval.end);\n\t\t\t\t\tthis.removeIntervalFromIndexes(interval);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tassert(\n\t\t\t\t\tpreviousInterval !== undefined,\n\t\t\t\t\t0x3fa /* Invalid interleaving of before/after slide */,\n\t\t\t\t);\n\t\t\t\tpendingChanges--;\n\t\t\t\tif (pendingChanges === 0) {\n\t\t\t\t\tthis.addIntervalToIndexes(interval);\n\t\t\t\t\tthis.onPositionChange?.(interval, previousInterval);\n\t\t\t\t\tpreviousInterval = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate removeIntervalListeners(interval: SequenceIntervalClass) {\n\t\tinterval.removePositionChangeListeners();\n\t}\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport type DeserializeCallback = (properties: PropertySet) => void;\n\nclass IntervalCollectionIterator implements Iterator<SequenceIntervalClass> {\n\tprivate readonly results: SequenceIntervalClass[];\n\tprivate index: number;\n\n\tconstructor(\n\t\tcollection: IntervalCollection,\n\t\titeratesForward: boolean = true,\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tthis.results = [];\n\t\tthis.index = 0;\n\n\t\tcollection.gatherIterationResults(this.results, iteratesForward, start, end);\n\t}\n\n\tpublic next(): IteratorResult<SequenceIntervalClass> {\n\t\tif (this.index < this.results.length) {\n\t\t\treturn {\n\t\t\t\tvalue: this.results[this.index++],\n\t\t\t\tdone: false,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tvalue: undefined,\n\t\t\tdone: true,\n\t\t};\n\t}\n}\n\n/**\n * Change events emitted by `IntervalCollection`s\n * @legacy\n * @alpha\n */\nexport interface ISequenceIntervalCollectionEvents extends IEvent {\n\t/**\n\t * This event is invoked whenever the endpoints of an interval may have changed.\n\t * This can happen on:\n\t * - local endpoint modification\n\t * - ack of a remote endpoint modification\n\t * - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)\n\t * The `interval` argument reflects the new values.\n\t * `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original\n\t * endpoints. These references should be used for position information only.\n\t * `local` reflects whether the change originated locally.\n\t * `op` is defined if and only if the server has acked this change.\n\t * `slide` is true if the change is due to sliding on removal of position\n\t */\n\t(\n\t\tevent: \"changeInterval\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tpreviousInterval: SequenceInterval,\n\t\t\tlocal: boolean,\n\t\t\top: ISequencedDocumentMessage | undefined,\n\t\t\tslide: boolean,\n\t\t) => void,\n\t): void;\n\t/**\n\t * This event is invoked whenever an interval is added or removed from the collection.\n\t * `local` reflects whether the change originated locally.\n\t * `op` is defined if and only if the server has acked this change.\n\t */\n\t(\n\t\tevent: \"addInterval\" | \"deleteInterval\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tlocal: boolean,\n\t\t\top: ISequencedDocumentMessage | undefined,\n\t\t) => void,\n\t): void;\n\t/**\n\t * This event is invoked whenever an interval's properties have changed.\n\t * `interval` reflects the state of the updated properties.\n\t * `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose\n\t * values contain all previous values of the property set.\n\t * This object can be used directly in a call to `changeProperties` to revert the property change if desired.\n\t * `local` reflects whether the change originated locally.\n\t * `op` is defined if and only if the server has acked this change.\n\t */\n\t(\n\t\tevent: \"propertyChanged\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tpropertyDeltas: PropertySet,\n\t\t\tlocal: boolean,\n\t\t\top: ISequencedDocumentMessage | undefined,\n\t\t) => void,\n\t): void;\n\t/**\n\t * This event is invoked whenever an interval's endpoints or properties (or both) have changed.\n\t * `interval` reflects the state of the updated endpoints or properties.\n\t * `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose\n\t * values contain all previous values of the property set.\n\t * This object can be used directly in a call to `changeProperties` to revert the property change if desired.\n\t * 'previousInterval' contains transient `ReferencePosition`s at the same location as the interval's original\n\t * endpoints. These references should be used for position information only. In the case of a property change\n\t * only, this argument should be undefined.\n\t * `local` reflects whether the change originated locally.\n\t * `slide` is true if the change is due to sliding on removal of position.\n\t */\n\t(\n\t\tevent: \"changed\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tpropertyDeltas: PropertySet,\n\t\t\tpreviousInterval: SequenceInterval | undefined,\n\t\t\tlocal: boolean,\n\t\t\tslide: boolean,\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Collection of intervals that supports addition, modification, removal, and efficient spatial querying.\n * Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).\n * @legacy\n * @alpha\n */\nexport interface ISequenceIntervalCollection\n\textends TypedEventEmitter<ISequenceIntervalCollectionEvents> {\n\treadonly attached: boolean;\n\t/**\n\t * Attaches an index to this collection.\n\t * All intervals which are part of this collection will be added to the index, and the index will automatically\n\t * be updated when this collection updates due to local or remote changes.\n\t *\n\t * @remarks After attaching an index to an interval collection, applications should typically store this\n\t * index somewhere in their in-memory data model for future reference and querying.\n\t */\n\tattachIndex(index: SequenceIntervalIndex): void;\n\t/**\n\t * Detaches an index from this collection.\n\t * All intervals which are part of this collection will be removed from the index, and updates to this collection\n\t * due to local or remote changes will no longer incur updates to the index.\n\t *\n\t * @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.\n\t */\n\tdetachIndex(index: SequenceIntervalIndex): boolean;\n\t/**\n\t * @returns the interval in this collection that has the provided `id`.\n\t * If no interval in the collection has this `id`, returns `undefined`.\n\t */\n\tgetIntervalById(id: string): SequenceInterval | undefined;\n\t/**\n\t * Creates a new interval and add it to the collection.\n\t * @param start - interval start position (inclusive)\n\t * @param end - interval end position (exclusive)\n\t * @param props - properties of the interval\n\t * @returns - the created interval\n\t * @remarks See documentation on {@link SequenceInterval} for comments on\n\t * interval endpoint semantics: there are subtleties with how the current\n\t * half-open behavior is represented.\n\t *\n\t * Note that intervals may behave unexpectedly if the entire contents\n\t * of the string are deleted. In this case, it is possible for one endpoint\n\t * of the interval to become detached, while the other remains on the string.\n\t *\n\t * By adjusting the `side` and `pos` values of the `start` and `end` parameters,\n\t * it is possible to control whether the interval expands to include content\n\t * inserted at its start or end.\n\t *\n\t *\tSee {@link @fluidframework/merge-tree#SequencePlace} for more details on the model.\n\t *\n\t *\t@example\n\t *\n\t *\tGiven the string \"ABCD\":\n\t *\n\t *```typescript\n\t *\t// Refers to \"BC\". If any content is inserted before B or after C, this\n\t *\t// interval will include that content\n\t *\t//\n\t *\t// Picture:\n\t *\t// \\{start\\} - A[- B - C -]D - \\{end\\}\n\t *\t// \\{start\\} - A - B - C - D - \\{end\\}\n\t *\tcollection.add(\\{ pos: 0, side: Side.After \\}, \\{ pos: 3, side: Side.Before \\}, IntervalType.SlideOnRemove);\n\t *\t// Equivalent to specifying the same positions and Side.Before.\n\t *\t// Refers to \"ABC\". Content inserted after C will be included in the\n\t *\t// interval, but content inserted before A will not.\n\t *\t// \\{start\\} -[A - B - C -]D - \\{end\\}\n\t *\t// \\{start\\} - A - B - C - D - \\{end\\}\n\t *\tcollection.add(0, 3, IntervalType.SlideOnRemove);\n\t *```\n\t *\n\t * In the case of the first example, if text is deleted,\n\t *\n\t * ```typescript\n\t *\t// Delete the character \"B\"\n\t *\tstring.removeRange(1, 2);\n\t * ```\n\t *\n\t * The start point of the interval will slide to the position immediately\n\t * before \"C\", and the same will be true.\n\t *\n\t * ```\n\t * \\{start\\} - A[- C -]D - \\{end\\}\n\t * ```\n\t *\n\t * In this case, text inserted immediately before \"C\" would be included in\n\t * the interval.\n\t *\n\t * ```typescript\n\t * string.insertText(1, \"EFG\");\n\t * ```\n\t *\n\t * With the string now being,\n\t *\n\t * ```\n\t * \\{start\\} - A[- E - F - G - C -]D - \\{end\\}\n\t * ```\n\t *\n\t * @privateRemarks TODO: ADO:5205 the above comment regarding behavior in\n\t * the case that the entire interval has been deleted should be resolved at\n\t * the same time as this ticket\n\t */\n\tadd({\n\t\tstart,\n\t\tend,\n\t\tprops,\n\t}: {\n\t\tstart: SequencePlace;\n\t\tend: SequencePlace;\n\t\tprops?: PropertySet;\n\t}): SequenceInterval;\n\t/**\n\t * Removes an interval from the collection.\n\t * @param id - Id of the interval to remove\n\t * @returns the removed interval\n\t */\n\tremoveIntervalById(id: string): SequenceInterval | undefined;\n\t/**\n\t * Changes the endpoints, properties, or both of an existing interval.\n\t * @param id - Id of the Interval to change\n\t * @returns the interval that was changed, if it existed in the collection.\n\t * Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed\n\t * simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints\n\t * undefined. To only change the endpoints, leave the properties undefined.\n\t */\n\tchange(\n\t\tid: string,\n\t\t{ start, end, props }: { start?: SequencePlace; end?: SequencePlace; props?: PropertySet },\n\t): SequenceInterval | undefined;\n\n\t/**\n\t * @deprecated This api is not meant or necessary for external consumption and will be removed in subsequent release\n\t */\n\tattachDeserializer(onDeserialize: DeserializeCallback): void;\n\t/**\n\t * @returns an iterator over all intervals in this collection.\n\t */\n\t[Symbol.iterator](): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.\n\t */\n\tCreateForwardIteratorWithStartPosition(startPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.\n\t */\n\tCreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.\n\t */\n\tCreateForwardIteratorWithEndPosition(endPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.\n\t */\n\tCreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * Gathers iteration results that optionally match a start/end criteria into the provided array.\n\t * @param results - Array to gather the results into. In lieu of a return value, this array will be populated with\n\t * intervals matching the query upon edit.\n\t * @param iteratesForward - whether or not iteration should be in the forward direction\n\t * @param start - If provided, only match intervals whose start point is equal to `start`.\n\t * @param end - If provided, only match intervals whose end point is equal to `end`.\n\t */\n\tgatherIterationResults(\n\t\tresults: SequenceInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: number,\n\t\tend?: number,\n\t): void;\n\n\t/**\n\t * @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:\n\t *\n\t * ```typescript\n\t * const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);\n\t * collection.attachIndex(overlappingIntervalsIndex)\n\t * const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);\n\t * ```\n\t *\n\t * @returns an array of all intervals in this collection that overlap with the interval\n\t * `[startPosition, endPosition]`.\n\t */\n\tfindOverlappingIntervals(startPosition: number, endPosition: number): SequenceInterval[];\n\n\t/**\n\t * Applies a function to each interval in this collection.\n\t */\n\tmap(fn: (interval: SequenceInterval) => void): void;\n\n\t/**\n\t * @deprecated - due to the forthcoming change where the endpointIndex will no longer be\n\t * automatically added to the collection. Users are advised to independently attach the\n\t * index to the collection and utilize the API accordingly, for instance:\n\t * ```typescript\n\t * const endpointIndex = createEndpointIndex(sharedString);\n\t * collection.attachIndex(endpointIndex);\n\t * const result1 = endpointIndex.previousInterval(pos);\n\t * ```\n\t * If an index is used repeatedly, applications should generally attach it once and store it in memory.\n\t */\n\tpreviousInterval(pos: number): SequenceInterval | undefined;\n\n\t/**\n\t * @deprecated - due to the forthcoming change where the endpointIndex will no longer be\n\t * automatically added to the collection. Users are advised to independently attach the\n\t * index to the collection and utilize the API accordingly, for instance:\n\t * ```typescript\n\t * const endpointIndex = createEndpointIndex(sharedString);\n\t * collection.attachIndex(endpointIndex);\n\t * const result2 = endpointIndex.nextInterval(pos);\n\t * ```\n\t */\n\tnextInterval(pos: number): SequenceInterval | undefined;\n}\n\ntype PendingChanges = Partial<\n\tRecord<\n\t\tstring,\n\t\t{\n\t\t\t/**\n\t\t\t * The local metadatas are stores in order of submission, FIFO.\n\t\t\t * This matches how ops are ordered, and should maintained\n\t\t\t * across, submit, process, resubmit, and rollback.\n\t\t\t */\n\t\t\tlocal: DoublyLinkedList<IntervalMessageLocalMetadata>;\n\t\t\t/**\n\t\t\t * The endpointChanges are unordered, and are used to determine\n\t\t\t * if any local changes also change the endpoints. The nodes of the\n\t\t\t * list are also stored in the individual change op metadatas, and\n\t\t\t * are removed as those metadatas are handled.\n\t\t\t */\n\t\t\tendpointChanges?: DoublyLinkedList<\n\t\t\t\tIntervalAddLocalMetadata | IntervalChangeLocalMetadata\n\t\t\t>;\n\t\t}\n\t>\n>;\n\nfunction removeMetadataFromPendingChanges(\n\tlocalOpMetadataNode: ListNode<IntervalMessageLocalMetadata> | unknown,\n): IntervalMessageLocalMetadata {\n\tconst acked = (localOpMetadataNode as ListNode<IntervalMessageLocalMetadata>)?.remove()\n\t\t?.data;\n\tassert(acked !== undefined, \"local change must exist\");\n\tacked.endpointChangesNode?.remove();\n\treturn acked;\n}\n\nfunction clearEmptyPendingEntry(pendingChanges: PendingChanges, id: string) {\n\tconst pending = pendingChanges[id];\n\tassert(pending !== undefined, \"pending must exist for local process\");\n\tif (pending.local.empty) {\n\t\tassert(\n\t\t\tpending.endpointChanges?.empty !== false,\n\t\t\t\"endpointChanges must be empty if not pending changes\",\n\t\t);\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete pendingChanges[id];\n\t}\n}\n\nfunction hasEndpointChanges(serialized: SerializedIntervalDelta) {\n\treturn serialized.start !== undefined && serialized.end !== undefined;\n}\n\n/**\n * {@inheritdoc IIntervalCollection}\n */\nexport class IntervalCollection\n\textends TypedEventEmitter<ISequenceIntervalCollectionEvents>\n\timplements ISequenceIntervalCollection\n{\n\tprivate savedSerializedIntervals?: ISerializedIntervalCollectionV1;\n\tprivate localCollection: LocalIntervalCollection | undefined;\n\tprivate onDeserialize: DeserializeCallback | undefined;\n\tprivate client: Client | undefined;\n\n\tprivate readonly pending: PendingChanges = {};\n\n\tpublic get attached(): boolean {\n\t\treturn !!this.localCollection;\n\t}\n\n\tprivate readonly submitDelta: (\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tmd: IntervalMessageLocalMetadata,\n\t) => void;\n\n\tconstructor(\n\t\tsubmitDelta: (op: IIntervalCollectionTypeOperationValue, md: unknown) => void,\n\t\tserializedIntervals: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2,\n\t\tprivate readonly options: Partial<SequenceOptions> = {},\n\t) {\n\t\tsuper();\n\n\t\tthis.submitDelta = (op, md) => {\n\t\t\tconst { id } = getSerializedProperties(op.value);\n\t\t\tconst pending = (this.pending[id] ??= {\n\t\t\t\tlocal: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tif (md.type === \"add\" || (md.type === \"change\" && hasEndpointChanges(op.value))) {\n\t\t\t\tconst endpointChanges = (pending.endpointChanges ??= new DoublyLinkedList());\n\t\t\t\tmd.endpointChangesNode = endpointChanges.push(md).last;\n\t\t\t}\n\t\t\tsubmitDelta(op, pending.local.push(md).last);\n\t\t};\n\n\t\tthis.savedSerializedIntervals = Array.isArray(serializedIntervals)\n\t\t\t? serializedIntervals\n\t\t\t: serializedIntervals.intervals.map((i) =>\n\t\t\t\t\tdecompressInterval(i, serializedIntervals.label),\n\t\t\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.attachIndex}\n\t */\n\tpublic attachIndex(index: SequenceIntervalIndex): void {\n\t\tif (!this.attached) {\n\t\t\tthrow new LoggingError(\"The local interval collection must exist\");\n\t\t}\n\t\tfor (const interval of this) {\n\t\t\tindex.add(interval);\n\t\t}\n\n\t\tthis.localCollection?.appendIndex(index);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.detachIndex}\n\t */\n\tpublic detachIndex(index: SequenceIntervalIndex): boolean {\n\t\tif (!this.attached) {\n\t\t\tthrow new LoggingError(\"The local interval collection must exist\");\n\t\t}\n\n\t\t// Avoid removing intervals if the index does not exist\n\t\tif (!this.localCollection?.removeIndex(index)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const interval of this) {\n\t\t\tindex.remove(interval);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic rollback(op: IIntervalCollectionTypeOperationValue, maybeMetadata: unknown) {\n\t\tconst localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);\n\t\tconst { value } = op;\n\t\tconst { id, properties } = getSerializedProperties(value);\n\t\tconst { type } = localOpMetadata;\n\t\tswitch (type) {\n\t\t\tcase \"add\": {\n\t\t\t\tconst interval = this.getIntervalById(id);\n\t\t\t\tif (interval) {\n\t\t\t\t\tthis.deleteExistingInterval({ interval, local: true, rollback: true });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"change\": {\n\t\t\t\tconst { previous } = localOpMetadata;\n\t\t\t\tconst endpointsChanged = hasEndpointChanges(value);\n\t\t\t\tconst start = endpointsChanged\n\t\t\t\t\t? toOptionalSequencePlace(previous.start, previous.startSide)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst end = endpointsChanged\n\t\t\t\t\t? toOptionalSequencePlace(previous.end, previous.endSide)\n\t\t\t\t\t: undefined;\n\t\t\t\tthis.change(id, {\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\tprops: Object.keys(properties).length > 0 ? properties : undefined,\n\t\t\t\t\trollback: true,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tconst { previous } = localOpMetadata;\n\t\t\t\tthis.add({\n\t\t\t\t\tid,\n\t\t\t\t\tstart: toSequencePlace(previous.start, previous.startSide),\n\t\t\t\t\tend: toSequencePlace(previous.end, previous.endSide),\n\t\t\t\t\tprops: Object.keys(properties).length > 0 ? properties : undefined,\n\t\t\t\t\trollback: true,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(type);\n\t\t}\n\n\t\tclearEmptyPendingEntry(this.pending, id);\n\t}\n\n\tpublic process(\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tmaybeMetadata: unknown,\n\t) {\n\t\tconst localOpMetadata = local\n\t\t\t? removeMetadataFromPendingChanges(maybeMetadata)\n\t\t\t: undefined;\n\n\t\tconst { opName, value } = op;\n\t\tassert(\n\t\t\t(local === false && localOpMetadata === undefined) || opName === localOpMetadata?.type,\n\t\t\t\"must be same type\",\n\t\t);\n\t\tswitch (opName) {\n\t\t\tcase \"add\": {\n\t\t\t\tthis.ackAdd(\n\t\t\t\t\tvalue,\n\t\t\t\t\tlocal,\n\t\t\t\t\tmessage,\n\t\t\t\t\t// this cast is safe because of the above assert which\n\t\t\t\t\t// validates the op and metadata types match for local changes\n\t\t\t\t\tlocalOpMetadata as IntervalAddLocalMetadata | undefined,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"delete\": {\n\t\t\t\tthis.ackDelete(value, local, message);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"change\": {\n\t\t\t\tthis.ackChange(value, local, message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(opName);\n\t\t}\n\n\t\tif (local) {\n\t\t\tconst { id } = getSerializedProperties(value);\n\t\t\tclearEmptyPendingEntry(this.pending, id);\n\t\t}\n\t}\n\n\tpublic resubmitMessage(\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tmaybeMetadata: unknown,\n\t): void {\n\t\tconst { opName, value } = op;\n\n\t\tconst localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);\n\n\t\tconst rebasedValue =\n\t\t\tlocalOpMetadata.endpointChangesNode === undefined\n\t\t\t\t? value\n\t\t\t\t: this.rebaseLocalInterval(localOpMetadata);\n\n\t\tif (rebasedValue === undefined) {\n\t\t\tconst { id } = getSerializedProperties(value);\n\t\t\tclearEmptyPendingEntry(this.pending, id);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitDelta({ opName, value: rebasedValue as any }, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp(op: IIntervalCollectionTypeOperationValue): void {\n\t\tconst { opName, value } = op;\n\t\tconst { id, properties } = getSerializedProperties(value);\n\t\tswitch (opName) {\n\t\t\tcase \"add\": {\n\t\t\t\tthis.add({\n\t\t\t\t\tid,\n\t\t\t\t\t// Todo: we should improve typing so we know add ops always have start and end\n\t\t\t\t\tstart: toSequencePlace(value.start, value.startSide),\n\t\t\t\t\tend: toSequencePlace(value.end, value.endSide),\n\t\t\t\t\tprops: properties,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"change\": {\n\t\t\t\tthis.change(id, {\n\t\t\t\t\tstart: toOptionalSequencePlace(value.start, value.startSide),\n\t\t\t\t\tend: toOptionalSequencePlace(value.end, value.endSide),\n\t\t\t\t\tprops: properties,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthis.removeIntervalById(id);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"unknown ops should not be stashed\");\n\t\t}\n\t}\n\n\tprivate rebasePositionWithSegmentSlide(\n\t\tpos: number | \"start\" | \"end\",\n\t\tseqNumberFrom: number,\n\t\tlocalSeq: number,\n\t): number | \"start\" | \"end\" | undefined {\n\t\tif (!this.client) {\n\t\t\tthrow new LoggingError(\"mergeTree client must exist\");\n\t\t}\n\n\t\tif (pos === \"start\" || pos === \"end\") {\n\t\t\treturn pos;\n\t\t}\n\n\t\tconst { clientId } = this.client.getCollabWindow();\n\t\tconst { segment, offset } =\n\t\t\tthis.client.getContainingSegment(\n\t\t\t\tpos,\n\t\t\t\t{\n\t\t\t\t\treferenceSequenceNumber: seqNumberFrom,\n\t\t\t\t\tclientId: this.client.getLongClientId(clientId),\n\t\t\t\t},\n\t\t\t\tlocalSeq,\n\t\t\t) ?? {};\n\n\t\t// if segment is undefined, it slid off the string\n\t\tassert(segment !== undefined && offset !== undefined, 0x54e /* No segment found */);\n\n\t\tconst segoff = getSlideToSegoff(\n\t\t\t{ segment, offset },\n\t\t\tundefined,\n\t\t\tcreateLocalReconnectingPerspective(this.client.getCurrentSeq(), clientId, localSeq),\n\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t);\n\n\t\t// case happens when rebasing op, but concurrently entire string has been deleted\n\t\tif (segoff?.segment === undefined || segoff.offset === undefined) {\n\t\t\treturn DetachedReferencePosition;\n\t\t}\n\n\t\tassert(\n\t\t\toffset !== undefined && 0 <= offset && offset < segment.cachedLength,\n\t\t\t0x54f /* Invalid offset */,\n\t\t);\n\t\treturn this.client.findReconnectionPosition(segoff.segment, localSeq) + segoff.offset;\n\t}\n\n\tprivate computeRebasedPositions(\n\t\tlocalOpMetadata: IntervalAddLocalMetadata | IntervalChangeLocalMetadata,\n\t): ISerializedInterval | SerializedIntervalDelta {\n\t\tassert(\n\t\t\tthis.client !== undefined,\n\t\t\t0x550 /* Client should be defined when computing rebased position */,\n\t\t);\n\t\tconst { localSeq, original } = localOpMetadata;\n\t\tconst rebased = { ...original };\n\t\tconst { start, end, sequenceNumber } = original;\n\t\tif (start !== undefined) {\n\t\t\trebased.start = this.rebasePositionWithSegmentSlide(start, sequenceNumber, localSeq);\n\t\t}\n\t\tif (end !== undefined) {\n\t\t\trebased.end = this.rebasePositionWithSegmentSlide(end, sequenceNumber, localSeq);\n\t\t}\n\t\treturn rebased;\n\t}\n\n\tpublic attachGraph(client: Client, label: string) {\n\t\tif (this.attached) {\n\t\t\tthrow new LoggingError(\"Only supports one Sequence attach\");\n\t\t}\n\n\t\tif (client === undefined) {\n\t\t\tthrow new LoggingError(\"Client required for this collection\");\n\t\t}\n\n\t\t// Instantiate the local interval collection based on the saved intervals\n\t\tthis.client = client;\n\t\tif (client) {\n\t\t\tclient.on(\"normalize\", () => {\n\t\t\t\tfor (const pending of Object.values(this.pending)) {\n\t\t\t\t\tif (pending?.endpointChanges !== undefined) {\n\t\t\t\t\t\tfor (const local of pending.endpointChanges) {\n\t\t\t\t\t\t\tlocal.data.rebased = this.computeRebasedPositions(local.data);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.localCollection = new LocalIntervalCollection(\n\t\t\tclient,\n\t\t\tlabel,\n\t\t\tthis.options,\n\t\t\t(interval, previousInterval) => this.emitChange(interval, previousInterval, true, true),\n\t\t);\n\t\tif (this.savedSerializedIntervals) {\n\t\t\tfor (const serializedInterval of this.savedSerializedIntervals) {\n\t\t\t\tconst { id, properties } = getSerializedProperties(serializedInterval);\n\t\t\t\tconst {\n\t\t\t\t\tstart: startPos,\n\t\t\t\t\tend: endPos,\n\t\t\t\t\tintervalType,\n\t\t\t\t\tstartSide,\n\t\t\t\t\tendSide,\n\t\t\t\t} = serializedInterval;\n\t\t\t\tconst start =\n\t\t\t\t\ttypeof startPos === \"number\" && startSide !== undefined\n\t\t\t\t\t\t? { pos: startPos, side: startSide }\n\t\t\t\t\t\t: startPos;\n\t\t\t\tconst end =\n\t\t\t\t\ttypeof endPos === \"number\" && endSide !== undefined\n\t\t\t\t\t\t? { pos: endPos, side: endSide }\n\t\t\t\t\t\t: endPos;\n\t\t\t\tconst interval = createSequenceInterval(\n\t\t\t\t\tlabel,\n\t\t\t\t\tid,\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\tclient,\n\t\t\t\t\tintervalType,\n\t\t\t\t\tundefined,\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t\t\t\tproperties,\n\t\t\t\t);\n\t\t\t\tthis.localCollection.add(interval);\n\t\t\t}\n\t\t}\n\t\tthis.savedSerializedIntervals = undefined;\n\t}\n\n\t/**\n\t * Gets the next local sequence number, modifying this client's collab window in doing so.\n\t */\n\tprivate getNextLocalSeq(): number {\n\t\tif (this.client) {\n\t\t\treturn ++this.client.getCollabWindow().localSeq;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprivate emitChange(\n\t\tinterval: SequenceIntervalClass,\n\t\tpreviousInterval: SequenceIntervalClass,\n\t\tlocal: boolean,\n\t\tslide: boolean,\n\t\top?: ISequencedDocumentMessage,\n\t): void {\n\t\t// Temporarily make references transient so that positional queries work (non-transient refs\n\t\t// on resolve to DetachedPosition on any segments that don't contain them). The original refType\n\t\t// is restored as single-endpoint changes re-use previous references.\n\n\t\tconst startRefType = previousInterval.start.refType;\n\t\tconst endRefType = previousInterval.end.refType;\n\t\tpreviousInterval.start.refType = ReferenceType.Transient;\n\t\tpreviousInterval.end.refType = ReferenceType.Transient;\n\t\tthis.emit(\"changeInterval\", interval, previousInterval, local, op, slide);\n\t\tthis.emit(\"changed\", interval, undefined, previousInterval ?? undefined, local, slide);\n\t\tpreviousInterval.start.refType = startRefType;\n\t\tpreviousInterval.end.refType = endRefType;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.getIntervalById}\n\t */\n\tpublic getIntervalById(id: string): SequenceIntervalClass | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attach must be called before accessing intervals\");\n\t\t}\n\t\treturn this.localCollection.idIntervalIndex.getIntervalById(id);\n\t}\n\n\tprivate assertStickinessEnabled(start: SequencePlace, end: SequencePlace) {\n\t\tif (\n\t\t\t!(typeof start === \"number\" && typeof end === \"number\") &&\n\t\t\t!this.options.intervalStickinessEnabled\n\t\t) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"attempted to set interval stickiness without enabling `intervalStickinessEnabled` feature flag\",\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.add}\n\t */\n\tpublic add({\n\t\tid,\n\t\tstart,\n\t\tend,\n\t\tprops,\n\t\trollback,\n\t}: {\n\t\tid?: string;\n\t\tstart: SequencePlace;\n\t\tend: SequencePlace;\n\t\tprops?: PropertySet;\n\t\trollback?: boolean;\n\t}): SequenceIntervalClass {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attach must be called prior to adding intervals\");\n\t\t}\n\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\n\t\tassert(\n\t\t\tstartPos !== undefined &&\n\t\t\t\tendPos !== undefined &&\n\t\t\t\tstartSide !== undefined &&\n\t\t\t\tendSide !== undefined,\n\t\t\t0x793 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t\t);\n\n\t\tthis.assertStickinessEnabled(start, end);\n\n\t\tconst intervalId = id ?? uuid();\n\n\t\tconst interval: SequenceIntervalClass = this.localCollection.addInterval(\n\t\t\tintervalId,\n\t\t\ttoSequencePlace(startPos, startSide),\n\t\t\ttoSequencePlace(endPos, endSide),\n\t\t\tprops,\n\t\t\tundefined,\n\t\t\trollback,\n\t\t);\n\n\t\tif (interval) {\n\t\t\tif (!this.isCollaborating) {\n\t\t\t\tsetSlideOnRemove(interval.start);\n\t\t\t\tsetSlideOnRemove(interval.end);\n\t\t\t}\n\t\t\tconst serializedInterval: ISerializedInterval = interval.serialize();\n\t\t\tconst localSeq = this.getNextLocalSeq();\n\t\t\tif (this.isCollaborating && rollback !== true) {\n\t\t\t\tthis.submitDelta(\n\t\t\t\t\t{\n\t\t\t\t\t\topName: \"add\",\n\t\t\t\t\t\tvalue: serializedInterval,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"add\",\n\t\t\t\t\t\tlocalSeq,\n\t\t\t\t\t\toriginal: serializedInterval,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"addInterval\", interval, true, undefined);\n\n\t\treturn interval;\n\t}\n\n\tprivate deleteExistingInterval({\n\t\tinterval,\n\t\tlocal,\n\t\top,\n\t\trollback,\n\t}: {\n\t\tinterval: SequenceIntervalClass;\n\t\tlocal: boolean;\n\t\top?: ISequencedDocumentMessage;\n\t\trollback?: boolean;\n\t}) {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\t\t// The given interval is known to exist in the collection.\n\t\tthis.localCollection.removeExistingInterval(interval);\n\n\t\tif (interval) {\n\t\t\t// Local ops get submitted to the server. Remote ops have the deserializer run.\n\t\t\tif (local && rollback !== true) {\n\t\t\t\tconst value = interval.serialize();\n\t\t\t\tthis.submitDelta(\n\t\t\t\t\t{\n\t\t\t\t\t\topName: \"delete\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"delete\",\n\t\t\t\t\t\tlocalSeq: this.getNextLocalSeq(),\n\t\t\t\t\t\tprevious: value,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (this.onDeserialize) {\n\t\t\t\t\tthis.onDeserialize(interval);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"deleteInterval\", interval, local, op);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.removeIntervalById}\n\t */\n\tpublic removeIntervalById(id: string): SequenceIntervalClass | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\t\tconst interval = this.localCollection.idIntervalIndex.getIntervalById(id);\n\t\tif (interval) {\n\t\t\tthis.deleteExistingInterval({ interval, local: true });\n\t\t}\n\t\treturn interval;\n\t}\n\t/**\n\t * {@inheritdoc IIntervalCollection.change}\n\t */\n\tpublic change(\n\t\tid: string,\n\t\t{\n\t\t\tstart,\n\t\t\tend,\n\t\t\tprops,\n\t\t\trollback,\n\t\t}: { start?: SequencePlace; end?: SequencePlace; props?: PropertySet; rollback?: boolean },\n\t): SequenceIntervalClass | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\n\t\t// Force id to be a string.\n\t\tif (typeof id !== \"string\") {\n\t\t\tthrow new UsageError(\"Change API requires an ID that is a string\");\n\t\t}\n\n\t\t// Ensure that both start and end are defined or both are undefined.\n\t\tif ((start === undefined) !== (end === undefined)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Change API requires both start and end to be defined or undefined\",\n\t\t\t);\n\t\t}\n\n\t\t// prevent the overwriting of an interval label, it should remain unchanged\n\t\t// once it has been inserted into the collection.\n\t\tif (props?.[reservedRangeLabelsKey] !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The label property should not be modified once inserted to the collection\",\n\t\t\t);\n\t\t}\n\n\t\tconst interval = this.getIntervalById(id);\n\t\tif (interval) {\n\t\t\tlet deltaProps: PropertySet | undefined;\n\t\t\tlet newInterval: SequenceIntervalClass | undefined;\n\t\t\tif (props !== undefined) {\n\t\t\t\tdeltaProps = interval.changeProperties(props, undefined, rollback);\n\t\t\t}\n\t\t\tconst changeEndpoints = start !== undefined && end !== undefined;\n\t\t\tif (changeEndpoints) {\n\t\t\t\tnewInterval = this.localCollection.changeInterval(interval, start, end);\n\t\t\t\tif (!this.isCollaborating && newInterval !== undefined) {\n\t\t\t\t\tsetSlideOnRemove(newInterval.start);\n\t\t\t\t\tsetSlideOnRemove(newInterval.end);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.isCollaborating && rollback !== true) {\n\t\t\t\t// Emit a property bag containing the ID and the other (if any) properties changed\n\t\t\t\tconst serializedInterval: SerializedIntervalDelta = (\n\t\t\t\t\tnewInterval ?? interval\n\t\t\t\t).serializeDelta({ props, includeEndpoints: changeEndpoints });\n\t\t\t\tconst localSeq = this.getNextLocalSeq();\n\n\t\t\t\tconst metadata: IntervalChangeLocalMetadata = {\n\t\t\t\t\ttype: \"change\",\n\t\t\t\t\tlocalSeq,\n\t\t\t\t\tprevious: interval.serialize(),\n\t\t\t\t\toriginal: serializedInterval,\n\t\t\t\t};\n\n\t\t\t\tthis.submitDelta(\n\t\t\t\t\t{\n\t\t\t\t\t\topName: \"change\",\n\t\t\t\t\t\tvalue: serializedInterval,\n\t\t\t\t\t},\n\t\t\t\t\tmetadata,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (deltaProps !== undefined) {\n\t\t\t\tthis.emit(\"propertyChanged\", interval, deltaProps, true, undefined);\n\t\t\t\tthis.emit(\n\t\t\t\t\t\"changed\",\n\t\t\t\t\tnewInterval ?? interval,\n\t\t\t\t\tdeltaProps,\n\t\t\t\t\tnewInterval ? interval : undefined,\n\t\t\t\t\ttrue,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (newInterval) {\n\t\t\t\tthis.emitChange(newInterval, interval, true, false);\n\t\t\t\tthis.client?.removeLocalReferencePosition(interval.start);\n\t\t\t\tthis.client?.removeLocalReferencePosition(interval.end);\n\t\t\t}\n\t\t\treturn newInterval;\n\t\t}\n\t\t// No interval to change\n\t\treturn undefined;\n\t}\n\n\tprivate get isCollaborating(): boolean {\n\t\treturn this.client?.getCollabWindow().collaborating ?? false;\n\t}\n\n\tprivate hasPendingEndpointChanges(id: string) {\n\t\treturn this.pending[id]?.endpointChanges?.empty === false;\n\t}\n\n\tpublic ackChange(\n\t\tserializedInterval: SerializedIntervalDelta,\n\t\tlocal: boolean,\n\t\top: ISequencedDocumentMessage,\n\t) {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\n\t\t// Note that the ID is in the property bag only to allow us to find the interval.\n\t\t// This API cannot change the ID, and writing to the ID property will result in an exception. So we\n\t\t// strip it out of the properties here.\n\t\tconst { id, properties } = getSerializedProperties(serializedInterval);\n\t\tassert(id !== undefined, 0x3fe /* id must exist on the interval */);\n\t\tconst interval: SequenceIntervalClass | undefined = this.getIntervalById(id);\n\n\t\tif (!interval) {\n\t\t\t// The interval has been removed locally; no-op.\n\t\t\treturn;\n\t\t}\n\n\t\tif (local) {\n\t\t\tinterval.ackPropertiesChange(properties, op);\n\n\t\t\tthis.ackInterval(interval, op);\n\t\t} else {\n\t\t\t// If there are pending changes with this ID, don't apply the remote start/end change, as the local ack\n\t\t\t// should be the winning change.\n\t\t\tlet start: number | \"start\" | \"end\" | undefined;\n\t\t\tlet end: number | \"start\" | \"end\" | undefined;\n\t\t\t// Track pending start/end independently of one another.\n\t\t\tif (!this.hasPendingEndpointChanges(id)) {\n\t\t\t\tstart = serializedInterval.start;\n\t\t\t\tend = serializedInterval.end;\n\t\t\t}\n\n\t\t\tlet newInterval = interval;\n\t\t\tif (start !== undefined || end !== undefined) {\n\t\t\t\t// If changeInterval gives us a new interval, work with that one. Otherwise keep working with\n\t\t\t\t// the one we originally found in the tree.\n\t\t\t\tnewInterval =\n\t\t\t\t\tthis.localCollection.changeInterval(\n\t\t\t\t\t\tinterval,\n\t\t\t\t\t\ttoOptionalSequencePlace(start, serializedInterval.startSide ?? Side.Before),\n\t\t\t\t\t\ttoOptionalSequencePlace(end, serializedInterval.endSide ?? Side.Before),\n\t\t\t\t\t\top,\n\t\t\t\t\t) ?? interval;\n\t\t\t}\n\t\t\tconst deltaProps = newInterval.changeProperties(properties, op);\n\n\t\t\tif (this.onDeserialize) {\n\t\t\t\tthis.onDeserialize(newInterval);\n\t\t\t}\n\n\t\t\tif (newInterval !== interval) {\n\t\t\t\tthis.emitChange(newInterval, interval, local, false, op);\n\t\t\t}\n\n\t\t\tconst changedProperties = Object.keys(properties).length > 0;\n\t\t\tif (changedProperties) {\n\t\t\t\tthis.emit(\"propertyChanged\", interval, deltaProps, local, op);\n\t\t\t\tthis.emit(\"changed\", interval, deltaProps, undefined, local, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.attachDeserializer}\n\t */\n\tpublic attachDeserializer(onDeserialize: DeserializeCallback): void {\n\t\t// If no deserializer is specified can skip all processing work\n\t\tif (!onDeserialize) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Start by storing the callbacks so that any subsequent modifications make use of them\n\t\tthis.onDeserialize = onDeserialize;\n\n\t\t// Trigger the async prepare work across all values in the collection\n\t\tif (this.attached) {\n\t\t\tthis.map(onDeserialize);\n\t\t}\n\t}\n\n\t/**\n\t * Returns new interval after rebasing. If undefined, the interval was\n\t * deleted as a result of rebasing. This can occur if the interval applies\n\t * to a range that no longer exists, and the interval was unable to slide.\n\t *\n\t */\n\tpublic rebaseLocalInterval(\n\t\tlocalOpMetadata: IntervalAddLocalMetadata | IntervalChangeLocalMetadata,\n\t): SerializedIntervalDelta | undefined {\n\t\tconst original = localOpMetadata.original;\n\t\tif (!this.client) {\n\t\t\t// If there's no associated mergeTree client, the originally submitted op is still correct.\n\t\t\treturn original;\n\t\t}\n\t\tif (!this.attached) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\tconst { localSeq } = localOpMetadata;\n\t\tconst { intervalType, properties, stickiness, startSide, endSide } = original;\n\t\tconst { id } = getSerializedProperties(original);\n\t\tconst { start: startRebased, end: endRebased } = (localOpMetadata.rebased ??=\n\t\t\tthis.computeRebasedPositions(localOpMetadata));\n\n\t\tconst localInterval = this.localCollection?.idIntervalIndex.getIntervalById(id);\n\n\t\tconst rebased: SerializedIntervalDelta = {\n\t\t\tstart: startRebased,\n\t\t\tend: endRebased,\n\t\t\tintervalType,\n\t\t\tsequenceNumber: this.client?.getCurrentSeq() ?? 0,\n\t\t\tproperties,\n\t\t\tstickiness,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t};\n\n\t\t// if the interval slid off the string, rebase the op to be a noop and delete the interval.\n\t\tif (\n\t\t\t!this.options.mergeTreeReferencesCanSlideToEndpoint &&\n\t\t\t(startRebased === DetachedReferencePosition || endRebased === DetachedReferencePosition)\n\t\t) {\n\t\t\tif (localInterval) {\n\t\t\t\tthis.localCollection?.removeExistingInterval(localInterval);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (localInterval !== undefined) {\n\t\t\t// The rebased op may place this interval's endpoints on different segments. Calling `changeInterval` here\n\t\t\t// updates the local client's state to be consistent with the emitted op.\n\t\t\tthis.localCollection?.changeInterval(\n\t\t\t\tlocalInterval,\n\t\t\t\ttoOptionalSequencePlace(startRebased, startSide ?? Side.Before),\n\t\t\t\ttoOptionalSequencePlace(endRebased, endSide ?? Side.Before),\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t);\n\t\t}\n\n\t\treturn rebased;\n\t}\n\n\tprivate getSlideToSegment(\n\t\tlref: LocalReferencePosition,\n\t\tslidingPreference: SlidingPreference,\n\t): { segment: ISegment; offset: number } | undefined {\n\t\tif (!this.client) {\n\t\t\tthrow new LoggingError(\"client does not exist\");\n\t\t}\n\t\tconst segment: ISegmentInternal | undefined = lref.getSegment();\n\t\tif (segment === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst segoff = {\n\t\t\tsegment,\n\t\t\toffset: lref.getOffset(),\n\t\t};\n\t\tif (segoff.segment.localRefs?.has(lref) !== true) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getSlideToSegoff(\n\t\t\tsegoff,\n\t\t\tslidingPreference,\n\t\t\tundefined,\n\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t);\n\t}\n\n\tprivate ackInterval(interval: SequenceIntervalClass, op: ISequencedDocumentMessage): void {\n\t\tif (\n\t\t\t!refTypeIncludesFlag(interval.start, ReferenceType.StayOnRemove) &&\n\t\t\t!refTypeIncludesFlag(interval.end, ReferenceType.StayOnRemove)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStart = this.getSlideToSegment(\n\t\t\tinterval.start,\n\t\t\tstartReferenceSlidingPreference(interval.stickiness),\n\t\t);\n\t\tconst newEnd = this.getSlideToSegment(\n\t\t\tinterval.end,\n\t\t\tendReferenceSlidingPreference(interval.stickiness),\n\t\t);\n\n\t\tconst id = interval.getIntervalId();\n\t\tconst hasPendingChange = this.hasPendingEndpointChanges(id);\n\n\t\tif (!hasPendingChange) {\n\t\t\tsetSlideOnRemove(interval.start);\n\t\t\tsetSlideOnRemove(interval.end);\n\t\t}\n\n\t\tconst needsStartUpdate =\n\t\t\tnewStart?.segment !== interval.start.getSegment() && !hasPendingChange;\n\t\tconst needsEndUpdate = newEnd?.segment !== interval.end.getSegment() && !hasPendingChange;\n\n\t\tif (needsStartUpdate || needsEndUpdate) {\n\t\t\tif (!this.localCollection) {\n\t\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t\t}\n\n\t\t\t// `interval`'s endpoints will get modified in-place, so clone it prior to doing so for event emission.\n\t\t\tconst oldInterval = interval.clone();\n\n\t\t\t// In this case, where we change the start or end of an interval,\n\t\t\t// it is necessary to remove and re-add the interval listeners.\n\t\t\t// This ensures that the correct listeners are added to the LocalReferencePosition.\n\t\t\tthis.localCollection.removeExistingInterval(interval);\n\t\t\tif (!this.client) {\n\t\t\t\tthrow new LoggingError(\"client does not exist\");\n\t\t\t}\n\n\t\t\tif (needsStartUpdate) {\n\t\t\t\tconst props = interval.start.properties;\n\t\t\t\tinterval.start = createPositionReferenceFromSegoff(\n\t\t\t\t\tthis.client,\n\t\t\t\t\tnewStart,\n\t\t\t\t\tinterval.start.refType,\n\t\t\t\t\top,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tstartReferenceSlidingPreference(interval.stickiness),\n\t\t\t\t\tstartReferenceSlidingPreference(interval.stickiness) === SlidingPreference.BACKWARD,\n\t\t\t\t);\n\t\t\t\tif (props) {\n\t\t\t\t\tinterval.start.addProperties(props);\n\t\t\t\t}\n\t\t\t\tconst oldSeg: ISegmentInternal | undefined = oldInterval.start.getSegment();\n\t\t\t\t// remove and rebuild start interval as transient for event\n\t\t\t\tthis.client.removeLocalReferencePosition(oldInterval.start);\n\t\t\t\toldInterval.start.refType = ReferenceType.Transient;\n\t\t\t\toldSeg?.localRefs?.addLocalRef(oldInterval.start, oldInterval.start.getOffset());\n\t\t\t}\n\t\t\tif (needsEndUpdate) {\n\t\t\t\tconst props = interval.end.properties;\n\t\t\t\tinterval.end = createPositionReferenceFromSegoff(\n\t\t\t\t\tthis.client,\n\t\t\t\t\tnewEnd,\n\t\t\t\t\tinterval.end.refType,\n\t\t\t\t\top,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tendReferenceSlidingPreference(interval.stickiness),\n\t\t\t\t\tendReferenceSlidingPreference(interval.stickiness) === SlidingPreference.FORWARD,\n\t\t\t\t);\n\t\t\t\tif (props) {\n\t\t\t\t\tinterval.end.addProperties(props);\n\t\t\t\t}\n\t\t\t\t// remove and rebuild end interval as transient for event\n\t\t\t\tconst oldSeg: ISegmentInternal | undefined = oldInterval.end.getSegment();\n\t\t\t\tthis.client.removeLocalReferencePosition(oldInterval.end);\n\t\t\t\toldInterval.end.refType = ReferenceType.Transient;\n\t\t\t\toldSeg?.localRefs?.addLocalRef(oldInterval.end, oldInterval.end.getOffset());\n\t\t\t}\n\t\t\tthis.localCollection.add(interval);\n\t\t\tthis.emitChange(interval, oldInterval, true, true, op);\n\t\t}\n\t}\n\n\tpublic ackAdd(\n\t\tserializedInterval: ISerializedInterval,\n\t\tlocal: boolean,\n\t\top: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: IntervalAddLocalMetadata | undefined,\n\t) {\n\t\tconst { id, properties } = getSerializedProperties(serializedInterval);\n\n\t\tif (local) {\n\t\t\tassert(\n\t\t\t\tlocalOpMetadata !== undefined,\n\t\t\t\t0x553 /* op metadata should be defined for local op */,\n\t\t\t);\n\t\t\tconst localInterval = this.getIntervalById(id);\n\t\t\tif (localInterval) {\n\t\t\t\tthis.ackInterval(localInterval, op);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\tconst interval: SequenceIntervalClass = this.localCollection.addInterval(\n\t\t\tid,\n\t\t\ttoSequencePlace(serializedInterval.start, serializedInterval.startSide ?? Side.Before),\n\t\t\ttoSequencePlace(serializedInterval.end, serializedInterval.endSide ?? Side.Before),\n\t\t\tproperties,\n\t\t\top,\n\t\t);\n\n\t\tif (interval) {\n\t\t\tif (this.onDeserialize) {\n\t\t\t\tthis.onDeserialize(interval);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"addInterval\", interval, local, op);\n\n\t\treturn interval;\n\t}\n\n\tpublic ackDelete(\n\t\tserializedInterval: SerializedIntervalDelta,\n\t\tlocal: boolean,\n\t\top: ISequencedDocumentMessage,\n\t): void {\n\t\tif (local) {\n\t\t\t// Local ops were applied when the message was created and there's no \"pending delete\"\n\t\t\t// state to book keep: remote operation application takes into account possibility of\n\t\t\t// locally deleted interval whenever a lookup happens.\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attach must be called prior to deleting intervals\");\n\t\t}\n\n\t\tconst { id } = getSerializedProperties(serializedInterval);\n\t\tconst interval = this.localCollection.idIntervalIndex.getIntervalById(id);\n\t\tif (interval) {\n\t\t\tthis.deleteExistingInterval({ interval, local, op });\n\t\t}\n\t}\n\n\tpublic serializeInternal(\n\t\tversion: \"1\" | \"2\",\n\t): ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2 {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.serialize(version);\n\t}\n\n\t/**\n\t * @returns an iterator over all intervals in this collection.\n\t */\n\tpublic [Symbol.iterator](): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithStartPosition}\n\t */\n\tpublic CreateForwardIteratorWithStartPosition(\n\t\tstartPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, true, startPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithStartPosition}\n\t */\n\tpublic CreateBackwardIteratorWithStartPosition(\n\t\tstartPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, false, startPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithEndPosition}\n\t */\n\tpublic CreateForwardIteratorWithEndPosition(\n\t\tendPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, true, undefined, endPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithEndPosition}\n\t */\n\tpublic CreateBackwardIteratorWithEndPosition(\n\t\tendPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, false, undefined, endPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.gatherIterationResults}\n\t */\n\tpublic gatherIterationResults(\n\t\tresults: SequenceIntervalClass[],\n\t\titeratesForward: boolean,\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tif (!this.localCollection) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.localCollection.overlappingIntervalsIndex.gatherIterationResults(\n\t\t\tresults,\n\t\t\titeratesForward,\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.findOverlappingIntervals}\n\t */\n\tpublic findOverlappingIntervals(\n\t\tstartPosition: number,\n\t\tendPosition: number,\n\t): SequenceInterval[] {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.overlappingIntervalsIndex.findOverlappingIntervals(\n\t\t\tstartPosition,\n\t\t\tendPosition,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.map}\n\t */\n\tpublic map(fn: (interval: SequenceIntervalClass) => void) {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\tfor (const interval of this.localCollection.idIntervalIndex) {\n\t\t\tfn(interval);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.previousInterval}\n\t */\n\tpublic previousInterval(pos: number): SequenceInterval | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.endIntervalIndex.previousInterval(pos);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.nextInterval}\n\t */\n\tpublic nextInterval(pos: number): SequenceInterval | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.endIntervalIndex.nextInterval(pos);\n\t}\n}\n\nfunction setSlideOnRemove(lref: LocalReferencePosition) {\n\tlet refType = lref.refType;\n\trefType = refType & ~ReferenceType.StayOnRemove;\n\trefType = refType | ReferenceType.SlideOnRemove;\n\tlref.refType = refType;\n}\n\n/**\n * Information that identifies an interval within a `Sequence`.\n * @internal\n */\nexport interface IntervalLocator {\n\t/**\n\t * Label for the collection the interval is a part of\n\t */\n\tlabel: string;\n\t/**\n\t * Interval within that collection\n\t */\n\tinterval: SequenceIntervalClass;\n}\n\n/**\n * Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.\n * @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created\n * on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this\n * endpoint is a part of.\n * @internal\n */\nexport function intervalLocatorFromEndpoint(\n\tpotentialEndpoint: LocalReferencePosition,\n): IntervalLocator | undefined {\n\tconst { interval, [reservedRangeLabelsKey]: collectionNameArray } =\n\t\tpotentialEndpoint.properties ?? {};\n\treturn interval && collectionNameArray?.length === 1\n\t\t? { label: collectionNameArray[0], interval }\n\t\t: undefined;\n}\n"]}
1
+ {"version":3,"file":"intervalCollection.js","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,+DAAiE;AAEjE,kEAA8E;AAE9E,kEAiB6C;AAC7C,uEAAoF;AACpF,+BAAkC;AASlC,uDAQkC;AAClC,mDAW8B;AAU9B,SAAS,mBAAmB,CAAC,UAA8B;IAC1D,MAAM,SAAS,GAAG,CAAC,UAAU,GAAG,6BAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAI,CAAC,KAAK,CAAC,CAAC,CAAC,eAAI,CAAC,MAAM,CAAC;IAC3F,MAAM,OAAO,GAAG,CAAC,UAAU,GAAG,6BAAkB,CAAC,GAAG,CAAC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AAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC3B,OAAO,GAAG,OAAO,GAAG,CAAC,wBAAa,CAAC,YAAY,CAAC;IAChD,OAAO,GAAG,OAAO,GAAG,wBAAa,CAAC,aAAa,CAAC;IAChD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACxB,CAAC;AAiBD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAC1C,iBAAyC;IAEzC,MAAM,EAAE,QAAQ,EAAE,CAAC,iCAAsB,CAAC,EAAE,mBAAmB,EAAE,GAChE,iBAAiB,CAAC,UAAU,IAAI,EAAE,CAAC;IACpC,OAAO,QAAQ,IAAI,mBAAmB,EAAE,MAAM,KAAK,CAAC;QACnD,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE;QAC7C,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AARD,kEAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tClient,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertySet,\n\tReferenceType,\n\tgetSlideToSegoff,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n\ttype ISegmentInternal,\n\tcreateLocalReconnectingPerspective,\n\tDoublyLinkedList,\n\ttype ListNode,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree/internal\";\nimport { LoggingError, UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tIntervalMessageLocalMetadata,\n\tSequenceOptions,\n\ttype IIntervalCollectionTypeOperationValue,\n\ttype IntervalAddLocalMetadata,\n\ttype IntervalChangeLocalMetadata,\n} from \"./intervalCollectionMapInterfaces.js\";\nimport {\n\tcreateIdIntervalIndex,\n\tEndpointIndex,\n\tOverlappingIntervalsIndex,\n\ttype IEndpointIndex,\n\ttype IIdIntervalIndex,\n\ttype ISequenceOverlappingIntervalsIndex,\n\ttype SequenceIntervalIndex,\n} from \"./intervalIndex/index.js\";\nimport {\n\tCompressedSerializedInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tSequenceInterval,\n\tSequenceIntervalClass,\n\tSerializedIntervalDelta,\n\tcreatePositionReferenceFromSegoff,\n\tcreateSequenceInterval,\n\tgetSerializedProperties,\n} from \"./intervals/index.js\";\n\nexport type ISerializedIntervalCollectionV1 = ISerializedInterval[];\n\nexport interface ISerializedIntervalCollectionV2 {\n\tlabel: string;\n\tversion: 2;\n\tintervals: CompressedSerializedInterval[];\n}\n\nfunction sidesFromStickiness(stickiness: IntervalStickiness) {\n\tconst startSide = (stickiness & IntervalStickiness.START) !== 0 ? Side.After : Side.Before;\n\tconst endSide = (stickiness & IntervalStickiness.END) !== 0 ? Side.Before : Side.After;\n\n\treturn { startSide, endSide };\n}\n\n/**\n * Decompress an interval after loading a summary from JSON. The exact format\n * of this compression is unspecified and subject to change\n */\nfunction decompressInterval(\n\tinterval: CompressedSerializedInterval,\n\tlabel?: string,\n): ISerializedInterval {\n\tconst stickiness = interval[5] ?? IntervalStickiness.END;\n\tconst { startSide, endSide } = sidesFromStickiness(stickiness);\n\treturn {\n\t\tstart: interval[0],\n\t\tend: interval[1],\n\t\tsequenceNumber: interval[2],\n\t\tintervalType: interval[3],\n\t\tproperties: { ...interval[4], [reservedRangeLabelsKey]: [label] },\n\t\tstickiness,\n\t\tstartSide,\n\t\tendSide,\n\t};\n}\n\n/**\n * Compress an interval prior to serialization as JSON. The exact format of this\n * compression is unspecified and subject to change\n */\nfunction compressInterval(interval: ISerializedInterval): CompressedSerializedInterval {\n\tconst { start, end, sequenceNumber, intervalType, properties } = interval;\n\n\tlet base: CompressedSerializedInterval = [\n\t\tstart,\n\t\tend,\n\t\tsequenceNumber,\n\t\tintervalType,\n\t\t// remove the `referenceRangeLabels` property as it is already stored\n\t\t// in the `label` field of the summary\n\t\t{ ...properties, [reservedRangeLabelsKey]: undefined },\n\t];\n\n\tif (interval.stickiness !== undefined && interval.stickiness !== IntervalStickiness.END) {\n\t\t// reassignment to make it easier for typescript to reason about types\n\t\tbase = [...base, interval.stickiness];\n\t}\n\n\treturn base;\n}\n\nexport function toSequencePlace(\n\tpos: number | \"start\" | \"end\",\n\tside: Side | undefined,\n): SequencePlace {\n\treturn typeof pos === \"number\" && side !== undefined ? { pos, side } : pos;\n}\n\nexport function toOptionalSequencePlace(\n\tpos: number | \"start\" | \"end\" | undefined,\n\tside: Side | undefined,\n): SequencePlace | undefined {\n\treturn typeof pos === \"number\" && side !== undefined ? { pos, side } : pos;\n}\n\nexport class LocalIntervalCollection {\n\tpublic readonly overlappingIntervalsIndex: ISequenceOverlappingIntervalsIndex;\n\tpublic readonly idIntervalIndex: IIdIntervalIndex;\n\tpublic readonly endIntervalIndex: IEndpointIndex;\n\tprivate readonly indexes: Set<SequenceIntervalIndex>;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly label: string,\n\t\tprivate readonly options: Partial<SequenceOptions>,\n\t\t/** Callback invoked each time one of the endpoints of an interval slides. */\n\t\tprivate readonly onPositionChange?: (\n\t\t\tinterval: SequenceIntervalClass,\n\t\t\tpreviousInterval: SequenceIntervalClass,\n\t\t) => void,\n\t) {\n\t\tthis.overlappingIntervalsIndex = new OverlappingIntervalsIndex(client);\n\t\tthis.idIntervalIndex = createIdIntervalIndex();\n\t\tthis.endIntervalIndex = new EndpointIndex(client);\n\t\tthis.indexes = new Set([\n\t\t\tthis.overlappingIntervalsIndex,\n\t\t\tthis.idIntervalIndex,\n\t\t\tthis.endIntervalIndex,\n\t\t]);\n\t}\n\n\t/**\n\t * Validates that a serialized interval has the ID property. Creates an ID\n\t * if one does not already exist\n\t *\n\t * @param serializedInterval - The interval to be checked\n\t * @returns The interval's existing or newly created id\n\t */\n\n\tprivate removeIntervalFromIndexes(interval: SequenceIntervalClass) {\n\t\tfor (const index of this.indexes) {\n\t\t\tindex.remove(interval);\n\t\t}\n\t}\n\n\tpublic appendIndex(index: SequenceIntervalIndex) {\n\t\tthis.indexes.add(index);\n\t}\n\n\tpublic removeIndex(index: SequenceIntervalIndex): boolean {\n\t\treturn this.indexes.delete(index);\n\t}\n\n\tpublic removeExistingInterval(interval: SequenceIntervalClass) {\n\t\tthis.removeIntervalFromIndexes(interval);\n\t\tthis.removeIntervalListeners(interval);\n\t}\n\n\tpublic addInterval(\n\t\tid: string,\n\t\tstart: SequencePlace,\n\t\tend: SequencePlace,\n\t\tprops?: PropertySet,\n\t\top?: ISequencedDocumentMessage,\n\t\trollback?: boolean,\n\t) {\n\t\t// This check is intended to prevent scenarios where a random interval is created and then\n\t\t// inserted into a collection. The aim is to ensure that the collection is created first\n\t\t// then the user can create/add intervals based on the collection\n\t\tif (\n\t\t\tprops?.[reservedRangeLabelsKey] !== undefined &&\n\t\t\tprops[reservedRangeLabelsKey][0] !== this.label\n\t\t) {\n\t\t\tthrow new LoggingError(\n\t\t\t\t\"Adding an interval that belongs to another interval collection is not permitted\",\n\t\t\t);\n\t\t}\n\t\tconst interval: SequenceIntervalClass = createSequenceInterval(\n\t\t\tthis.label,\n\t\t\tid,\n\t\t\tstart,\n\t\t\tend,\n\t\t\tthis.client,\n\t\t\tIntervalType.SlideOnRemove,\n\t\t\top,\n\t\t\tundefined,\n\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t\tprops,\n\t\t\trollback,\n\t\t);\n\n\t\tthis.add(interval);\n\t\treturn interval;\n\t}\n\n\tprivate linkEndpointsToInterval(interval: SequenceIntervalClass): void {\n\t\tinterval.start.addProperties({ interval });\n\t\tinterval.end.addProperties({ interval });\n\t}\n\n\tprivate addIntervalToIndexes(interval: SequenceIntervalClass) {\n\t\tfor (const index of this.indexes) {\n\t\t\tindex.add(interval);\n\t\t}\n\t}\n\n\tpublic add(interval: SequenceIntervalClass): void {\n\t\tthis.linkEndpointsToInterval(interval);\n\t\tthis.addIntervalToIndexes(interval);\n\t\tthis.addIntervalListeners(interval);\n\t}\n\n\tpublic changeInterval(\n\t\tinterval: SequenceIntervalClass,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t) {\n\t\tconst newInterval = interval.modify(\n\t\t\tthis.label,\n\t\t\tstart,\n\t\t\tend,\n\t\t\top,\n\t\t\tlocalSeq,\n\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t);\n\t\tif (newInterval) {\n\t\t\tthis.removeExistingInterval(interval);\n\t\t\tthis.add(newInterval);\n\t\t}\n\t\treturn newInterval;\n\t}\n\n\tpublic serialize(\n\t\tversion: \"1\" | \"2\",\n\t): ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2 {\n\t\tif (version === \"1\") {\n\t\t\treturn Array.from(this.idIntervalIndex, (interval) => interval.serialize());\n\t\t}\n\t\treturn {\n\t\t\tlabel: this.label,\n\t\t\tintervals: Array.from(this.idIntervalIndex, (interval) =>\n\t\t\t\tcompressInterval(interval.serialize()),\n\t\t\t),\n\t\t\tversion: 2,\n\t\t};\n\t}\n\n\tprivate addIntervalListeners(interval: SequenceIntervalClass) {\n\t\tconst cloneRef = (ref: LocalReferencePosition) => {\n\t\t\tconst segment = ref.getSegment();\n\t\t\tif (segment === undefined) {\n\t\t\t\t// Cloning is unnecessary: refs which have slid off the string entirely\n\t\t\t\t// never get slid back on. Creation code for refs doesn't accept undefined segment\n\t\t\t\t// either, so this must be special-cased.\n\t\t\t\treturn ref;\n\t\t\t}\n\n\t\t\treturn this.client.createLocalReferencePosition(\n\t\t\t\tsegment,\n\t\t\t\tref.getOffset(),\n\t\t\t\tReferenceType.Transient,\n\t\t\t\tref.properties,\n\t\t\t\tref.slidingPreference,\n\t\t\t\tref.canSlideToEndpoint,\n\t\t\t);\n\t\t};\n\t\tlet previousInterval: SequenceIntervalClass | undefined;\n\t\tlet pendingChanges = 0;\n\t\tinterval.addPositionChangeListeners(\n\t\t\t() => {\n\t\t\t\tpendingChanges++;\n\t\t\t\t// Note: both start and end can change and invoke beforeSlide on each endpoint before afterSlide.\n\t\t\t\tif (!previousInterval) {\n\t\t\t\t\tpreviousInterval = interval.clone();\n\t\t\t\t\tpreviousInterval.start = cloneRef(previousInterval.start);\n\t\t\t\t\tpreviousInterval.end = cloneRef(previousInterval.end);\n\t\t\t\t\tthis.removeIntervalFromIndexes(interval);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tassert(\n\t\t\t\t\tpreviousInterval !== undefined,\n\t\t\t\t\t0x3fa /* Invalid interleaving of before/after slide */,\n\t\t\t\t);\n\t\t\t\tpendingChanges--;\n\t\t\t\tif (pendingChanges === 0) {\n\t\t\t\t\tthis.addIntervalToIndexes(interval);\n\t\t\t\t\tthis.onPositionChange?.(interval, previousInterval);\n\t\t\t\t\tpreviousInterval = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate removeIntervalListeners(interval: SequenceIntervalClass) {\n\t\tinterval.removePositionChangeListeners();\n\t}\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport type DeserializeCallback = (properties: PropertySet) => void;\n\nclass IntervalCollectionIterator implements Iterator<SequenceIntervalClass> {\n\tprivate readonly results: SequenceIntervalClass[];\n\tprivate index: number;\n\n\tconstructor(\n\t\tcollection: IntervalCollection,\n\t\titeratesForward: boolean = true,\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tthis.results = [];\n\t\tthis.index = 0;\n\n\t\tcollection.gatherIterationResults(this.results, iteratesForward, start, end);\n\t}\n\n\tpublic next(): IteratorResult<SequenceIntervalClass> {\n\t\tif (this.index < this.results.length) {\n\t\t\treturn {\n\t\t\t\tvalue: this.results[this.index++],\n\t\t\t\tdone: false,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tvalue: undefined,\n\t\t\tdone: true,\n\t\t};\n\t}\n}\n\n/**\n * Change events emitted by `IntervalCollection`s\n * @legacy\n * @alpha\n */\nexport interface ISequenceIntervalCollectionEvents extends IEvent {\n\t/**\n\t * This event is invoked whenever the endpoints of an interval may have changed.\n\t * This can happen on:\n\t * - local endpoint modification\n\t * - ack of a remote endpoint modification\n\t * - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)\n\t * The `interval` argument reflects the new values.\n\t * `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original\n\t * endpoints. These references should be used for position information only.\n\t * `local` reflects whether the change originated locally.\n\t * `op` is defined if and only if the server has acked this change.\n\t * `slide` is true if the change is due to sliding on removal of position\n\t */\n\t(\n\t\tevent: \"changeInterval\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tpreviousInterval: SequenceInterval,\n\t\t\tlocal: boolean,\n\t\t\top: ISequencedDocumentMessage | undefined,\n\t\t\tslide: boolean,\n\t\t) => void,\n\t): void;\n\t/**\n\t * This event is invoked whenever an interval is added or removed from the collection.\n\t * `local` reflects whether the change originated locally.\n\t * `op` is defined if and only if the server has acked this change.\n\t */\n\t(\n\t\tevent: \"addInterval\" | \"deleteInterval\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tlocal: boolean,\n\t\t\top: ISequencedDocumentMessage | undefined,\n\t\t) => void,\n\t): void;\n\t/**\n\t * This event is invoked whenever an interval's properties have changed.\n\t * `interval` reflects the state of the updated properties.\n\t * `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose\n\t * values contain all previous values of the property set.\n\t * This object can be used directly in a call to `changeProperties` to revert the property change if desired.\n\t * `local` reflects whether the change originated locally.\n\t * `op` is defined if and only if the server has acked this change.\n\t */\n\t(\n\t\tevent: \"propertyChanged\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tpropertyDeltas: PropertySet,\n\t\t\tlocal: boolean,\n\t\t\top: ISequencedDocumentMessage | undefined,\n\t\t) => void,\n\t): void;\n\t/**\n\t * This event is invoked whenever an interval's endpoints or properties (or both) have changed.\n\t * `interval` reflects the state of the updated endpoints or properties.\n\t * `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose\n\t * values contain all previous values of the property set.\n\t * This object can be used directly in a call to `changeProperties` to revert the property change if desired.\n\t * 'previousInterval' contains transient `ReferencePosition`s at the same location as the interval's original\n\t * endpoints. These references should be used for position information only. In the case of a property change\n\t * only, this argument should be undefined.\n\t * `local` reflects whether the change originated locally.\n\t * `slide` is true if the change is due to sliding on removal of position.\n\t */\n\t(\n\t\tevent: \"changed\",\n\t\tlistener: (\n\t\t\tinterval: SequenceInterval,\n\t\t\tpropertyDeltas: PropertySet,\n\t\t\tpreviousInterval: SequenceInterval | undefined,\n\t\t\tlocal: boolean,\n\t\t\tslide: boolean,\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Collection of intervals that supports addition, modification, removal, and efficient spatial querying.\n * Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).\n * @legacy\n * @alpha\n */\nexport interface ISequenceIntervalCollection\n\textends TypedEventEmitter<ISequenceIntervalCollectionEvents> {\n\treadonly attached: boolean;\n\t/**\n\t * Attaches an index to this collection.\n\t * All intervals which are part of this collection will be added to the index, and the index will automatically\n\t * be updated when this collection updates due to local or remote changes.\n\t *\n\t * @remarks After attaching an index to an interval collection, applications should typically store this\n\t * index somewhere in their in-memory data model for future reference and querying.\n\t */\n\tattachIndex(index: SequenceIntervalIndex): void;\n\t/**\n\t * Detaches an index from this collection.\n\t * All intervals which are part of this collection will be removed from the index, and updates to this collection\n\t * due to local or remote changes will no longer incur updates to the index.\n\t *\n\t * @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.\n\t */\n\tdetachIndex(index: SequenceIntervalIndex): boolean;\n\t/**\n\t * @returns the interval in this collection that has the provided `id`.\n\t * If no interval in the collection has this `id`, returns `undefined`.\n\t */\n\tgetIntervalById(id: string): SequenceInterval | undefined;\n\t/**\n\t * Creates a new interval and add it to the collection.\n\t * @param start - interval start position (inclusive)\n\t * @param end - interval end position (exclusive)\n\t * @param props - properties of the interval\n\t * @returns - the created interval\n\t * @remarks See documentation on {@link SequenceInterval} for comments on\n\t * interval endpoint semantics: there are subtleties with how the current\n\t * half-open behavior is represented.\n\t *\n\t * Note that intervals may behave unexpectedly if the entire contents\n\t * of the string are deleted. In this case, it is possible for one endpoint\n\t * of the interval to become detached, while the other remains on the string.\n\t *\n\t * By adjusting the `side` and `pos` values of the `start` and `end` parameters,\n\t * it is possible to control whether the interval expands to include content\n\t * inserted at its start or end.\n\t *\n\t *\tSee {@link @fluidframework/merge-tree#SequencePlace} for more details on the model.\n\t *\n\t *\t@example\n\t *\n\t *\tGiven the string \"ABCD\":\n\t *\n\t *```typescript\n\t *\t// Refers to \"BC\". If any content is inserted before B or after C, this\n\t *\t// interval will include that content\n\t *\t//\n\t *\t// Picture:\n\t *\t// \\{start\\} - A[- B - C -]D - \\{end\\}\n\t *\t// \\{start\\} - A - B - C - D - \\{end\\}\n\t *\tcollection.add(\\{ pos: 0, side: Side.After \\}, \\{ pos: 3, side: Side.Before \\}, IntervalType.SlideOnRemove);\n\t *\t// Equivalent to specifying the same positions and Side.Before.\n\t *\t// Refers to \"ABC\". Content inserted after C will be included in the\n\t *\t// interval, but content inserted before A will not.\n\t *\t// \\{start\\} -[A - B - C -]D - \\{end\\}\n\t *\t// \\{start\\} - A - B - C - D - \\{end\\}\n\t *\tcollection.add(0, 3, IntervalType.SlideOnRemove);\n\t *```\n\t *\n\t * In the case of the first example, if text is deleted,\n\t *\n\t * ```typescript\n\t *\t// Delete the character \"B\"\n\t *\tstring.removeRange(1, 2);\n\t * ```\n\t *\n\t * The start point of the interval will slide to the position immediately\n\t * before \"C\", and the same will be true.\n\t *\n\t * ```\n\t * \\{start\\} - A[- C -]D - \\{end\\}\n\t * ```\n\t *\n\t * In this case, text inserted immediately before \"C\" would be included in\n\t * the interval.\n\t *\n\t * ```typescript\n\t * string.insertText(1, \"EFG\");\n\t * ```\n\t *\n\t * With the string now being,\n\t *\n\t * ```\n\t * \\{start\\} - A[- E - F - G - C -]D - \\{end\\}\n\t * ```\n\t *\n\t * @privateRemarks TODO: ADO:5205 the above comment regarding behavior in\n\t * the case that the entire interval has been deleted should be resolved at\n\t * the same time as this ticket\n\t */\n\tadd({\n\t\tstart,\n\t\tend,\n\t\tprops,\n\t}: {\n\t\tstart: SequencePlace;\n\t\tend: SequencePlace;\n\t\tprops?: PropertySet;\n\t}): SequenceInterval;\n\t/**\n\t * Removes an interval from the collection.\n\t * @param id - Id of the interval to remove\n\t * @returns the removed interval\n\t */\n\tremoveIntervalById(id: string): SequenceInterval | undefined;\n\t/**\n\t * Changes the endpoints, properties, or both of an existing interval.\n\t * @param id - Id of the Interval to change\n\t * @returns the interval that was changed, if it existed in the collection.\n\t * Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed\n\t * simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints\n\t * undefined. To only change the endpoints, leave the properties undefined.\n\t */\n\tchange(\n\t\tid: string,\n\t\t{ start, end, props }: { start?: SequencePlace; end?: SequencePlace; props?: PropertySet },\n\t): SequenceInterval | undefined;\n\n\t/**\n\t * @deprecated This api is not meant or necessary for external consumption and will be removed in subsequent release\n\t */\n\tattachDeserializer(onDeserialize: DeserializeCallback): void;\n\t/**\n\t * @returns an iterator over all intervals in this collection.\n\t */\n\t[Symbol.iterator](): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.\n\t */\n\tCreateForwardIteratorWithStartPosition(startPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.\n\t */\n\tCreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.\n\t */\n\tCreateForwardIteratorWithEndPosition(endPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.\n\t */\n\tCreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<SequenceInterval>;\n\n\t/**\n\t * Gathers iteration results that optionally match a start/end criteria into the provided array.\n\t * @param results - Array to gather the results into. In lieu of a return value, this array will be populated with\n\t * intervals matching the query upon edit.\n\t * @param iteratesForward - whether or not iteration should be in the forward direction\n\t * @param start - If provided, only match intervals whose start point is equal to `start`.\n\t * @param end - If provided, only match intervals whose end point is equal to `end`.\n\t */\n\tgatherIterationResults(\n\t\tresults: SequenceInterval[],\n\t\titeratesForward: boolean,\n\t\tstart?: number,\n\t\tend?: number,\n\t): void;\n\n\t/**\n\t * @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:\n\t *\n\t * ```typescript\n\t * const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);\n\t * collection.attachIndex(overlappingIntervalsIndex)\n\t * const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);\n\t * ```\n\t *\n\t * @returns an array of all intervals in this collection that overlap with the interval\n\t * `[startPosition, endPosition]`.\n\t */\n\tfindOverlappingIntervals(startPosition: number, endPosition: number): SequenceInterval[];\n\n\t/**\n\t * Applies a function to each interval in this collection.\n\t */\n\tmap(fn: (interval: SequenceInterval) => void): void;\n\n\t/**\n\t * @deprecated - due to the forthcoming change where the endpointIndex will no longer be\n\t * automatically added to the collection. Users are advised to independently attach the\n\t * index to the collection and utilize the API accordingly, for instance:\n\t * ```typescript\n\t * const endpointIndex = createEndpointIndex(sharedString);\n\t * collection.attachIndex(endpointIndex);\n\t * const result1 = endpointIndex.previousInterval(pos);\n\t * ```\n\t * If an index is used repeatedly, applications should generally attach it once and store it in memory.\n\t */\n\tpreviousInterval(pos: number): SequenceInterval | undefined;\n\n\t/**\n\t * @deprecated - due to the forthcoming change where the endpointIndex will no longer be\n\t * automatically added to the collection. Users are advised to independently attach the\n\t * index to the collection and utilize the API accordingly, for instance:\n\t * ```typescript\n\t * const endpointIndex = createEndpointIndex(sharedString);\n\t * collection.attachIndex(endpointIndex);\n\t * const result2 = endpointIndex.nextInterval(pos);\n\t * ```\n\t */\n\tnextInterval(pos: number): SequenceInterval | undefined;\n}\n\ntype PendingChanges = Partial<\n\tRecord<\n\t\tstring,\n\t\t{\n\t\t\t/**\n\t\t\t * The local metadatas are stores in order of submission, FIFO.\n\t\t\t * This matches how ops are ordered, and should maintained\n\t\t\t * across, submit, process, resubmit, and rollback.\n\t\t\t */\n\t\t\tlocal: DoublyLinkedList<IntervalMessageLocalMetadata>;\n\t\t\t/**\n\t\t\t * The endpointChanges are unordered, and are used to determine\n\t\t\t * if any local changes also change the endpoints. The nodes of the\n\t\t\t * list are also stored in the individual change op metadatas, and\n\t\t\t * are removed as those metadatas are handled.\n\t\t\t */\n\t\t\tendpointChanges?: DoublyLinkedList<\n\t\t\t\tIntervalAddLocalMetadata | IntervalChangeLocalMetadata\n\t\t\t>;\n\t\t}\n\t>\n>;\n\nfunction removeMetadataFromPendingChanges(\n\tlocalOpMetadataNode: ListNode<IntervalMessageLocalMetadata> | unknown,\n): IntervalMessageLocalMetadata {\n\tconst acked = (localOpMetadataNode as ListNode<IntervalMessageLocalMetadata>)?.remove()\n\t\t?.data;\n\tassert(acked !== undefined, 0xbbe /* local change must exist */);\n\tacked.endpointChangesNode?.remove();\n\treturn acked;\n}\n\nfunction clearEmptyPendingEntry(pendingChanges: PendingChanges, id: string) {\n\tconst pending = pendingChanges[id];\n\tassert(pending !== undefined, 0xbbf /* pending must exist for local process */);\n\tif (pending.local.empty) {\n\t\tassert(\n\t\t\tpending.endpointChanges?.empty !== false,\n\t\t\t0xbc0 /* endpointChanges must be empty if not pending changes */,\n\t\t);\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete pendingChanges[id];\n\t}\n}\n\nfunction hasEndpointChanges(\n\tserialized: SerializedIntervalDelta,\n): serialized is ISerializedInterval {\n\treturn serialized.start !== undefined && serialized.end !== undefined;\n}\n\n/**\n * {@inheritdoc IIntervalCollection}\n */\nexport class IntervalCollection\n\textends TypedEventEmitter<ISequenceIntervalCollectionEvents>\n\timplements ISequenceIntervalCollection\n{\n\tprivate savedSerializedIntervals?: ISerializedIntervalCollectionV1;\n\tprivate localCollection: LocalIntervalCollection | undefined;\n\tprivate onDeserialize: DeserializeCallback | undefined;\n\tprivate client: Client | undefined;\n\n\tprivate readonly pending: PendingChanges = {};\n\n\tpublic get attached(): boolean {\n\t\treturn !!this.localCollection;\n\t}\n\n\tprivate readonly submitDelta: (\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tmd: IntervalMessageLocalMetadata,\n\t) => void;\n\n\tconstructor(\n\t\tsubmitDelta: (op: IIntervalCollectionTypeOperationValue, md: unknown) => void,\n\t\tserializedIntervals: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2,\n\t\tprivate readonly options: Partial<SequenceOptions> = {},\n\t) {\n\t\tsuper();\n\n\t\tthis.submitDelta = (op, md) => {\n\t\t\tconst { id } = getSerializedProperties(op.value);\n\t\t\tconst pending = (this.pending[id] ??= {\n\t\t\t\tlocal: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tif (md.type === \"add\" || (md.type === \"change\" && hasEndpointChanges(op.value))) {\n\t\t\t\tconst endpointChanges = (pending.endpointChanges ??= new DoublyLinkedList());\n\t\t\t\tmd.endpointChangesNode = endpointChanges.push(md).last;\n\t\t\t\tmd.rebased = undefined;\n\t\t\t}\n\t\t\tsubmitDelta(op, pending.local.push(md).last);\n\t\t};\n\n\t\tthis.savedSerializedIntervals = Array.isArray(serializedIntervals)\n\t\t\t? serializedIntervals\n\t\t\t: serializedIntervals.intervals.map((i) =>\n\t\t\t\t\tdecompressInterval(i, serializedIntervals.label),\n\t\t\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.attachIndex}\n\t */\n\tpublic attachIndex(index: SequenceIntervalIndex): void {\n\t\tif (!this.attached) {\n\t\t\tthrow new LoggingError(\"The local interval collection must exist\");\n\t\t}\n\t\tfor (const interval of this) {\n\t\t\tindex.add(interval);\n\t\t}\n\n\t\tthis.localCollection?.appendIndex(index);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.detachIndex}\n\t */\n\tpublic detachIndex(index: SequenceIntervalIndex): boolean {\n\t\tif (!this.attached) {\n\t\t\tthrow new LoggingError(\"The local interval collection must exist\");\n\t\t}\n\n\t\t// Avoid removing intervals if the index does not exist\n\t\tif (!this.localCollection?.removeIndex(index)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const interval of this) {\n\t\t\tindex.remove(interval);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic rollback(op: IIntervalCollectionTypeOperationValue, maybeMetadata: unknown) {\n\t\tconst localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);\n\t\tconst { value } = op;\n\t\tconst { id, properties } = getSerializedProperties(value);\n\t\tconst { type } = localOpMetadata;\n\t\tswitch (type) {\n\t\t\tcase \"add\": {\n\t\t\t\tconst interval = this.getIntervalById(id);\n\t\t\t\tif (interval) {\n\t\t\t\t\tthis.deleteExistingInterval({ interval, local: true, rollback: true });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"change\": {\n\t\t\t\tconst { previous } = localOpMetadata;\n\t\t\t\tconst endpointsChanged = hasEndpointChanges(value);\n\t\t\t\tconst start = endpointsChanged\n\t\t\t\t\t? toOptionalSequencePlace(previous.start, previous.startSide)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst end = endpointsChanged\n\t\t\t\t\t? toOptionalSequencePlace(previous.end, previous.endSide)\n\t\t\t\t\t: undefined;\n\t\t\t\tthis.change(id, {\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\tprops: Object.keys(properties).length > 0 ? properties : undefined,\n\t\t\t\t\trollback: true,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tconst { previous } = localOpMetadata;\n\t\t\t\tthis.add({\n\t\t\t\t\tid,\n\t\t\t\t\tstart: toSequencePlace(previous.start, previous.startSide),\n\t\t\t\t\tend: toSequencePlace(previous.end, previous.endSide),\n\t\t\t\t\tprops: Object.keys(properties).length > 0 ? properties : undefined,\n\t\t\t\t\trollback: true,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(type);\n\t\t}\n\n\t\tclearEmptyPendingEntry(this.pending, id);\n\t}\n\n\tpublic process(\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tmaybeMetadata: unknown,\n\t) {\n\t\tconst localOpMetadata = local\n\t\t\t? removeMetadataFromPendingChanges(maybeMetadata)\n\t\t\t: undefined;\n\n\t\tconst { opName, value } = op;\n\t\tassert(\n\t\t\t(local === false && localOpMetadata === undefined) || opName === localOpMetadata?.type,\n\t\t\t0xbc1 /* must be same type */,\n\t\t);\n\t\tswitch (opName) {\n\t\t\tcase \"add\": {\n\t\t\t\tthis.ackAdd(\n\t\t\t\t\tvalue,\n\t\t\t\t\tlocal,\n\t\t\t\t\tmessage,\n\t\t\t\t\t// this cast is safe because of the above assert which\n\t\t\t\t\t// validates the op and metadata types match for local changes\n\t\t\t\t\tlocalOpMetadata as IntervalAddLocalMetadata | undefined,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"delete\": {\n\t\t\t\tthis.ackDelete(value, local, message);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"change\": {\n\t\t\t\tthis.ackChange(value, local, message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(opName);\n\t\t}\n\n\t\tif (local) {\n\t\t\tconst { id } = getSerializedProperties(value);\n\t\t\tclearEmptyPendingEntry(this.pending, id);\n\t\t}\n\t}\n\n\tpublic resubmitMessage(\n\t\top: IIntervalCollectionTypeOperationValue,\n\t\tmaybeMetadata: unknown,\n\t\tsquash: boolean,\n\t): void {\n\t\tconst { opName, value } = op;\n\n\t\tconst localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);\n\n\t\tconst rebasedValue =\n\t\t\tlocalOpMetadata.endpointChangesNode === undefined\n\t\t\t\t? value\n\t\t\t\t: this.rebaseLocalInterval(value, localOpMetadata, squash);\n\n\t\tif (rebasedValue === undefined) {\n\t\t\tconst { id } = getSerializedProperties(value);\n\t\t\tclearEmptyPendingEntry(this.pending, id);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitDelta({ opName, value: rebasedValue as any }, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp(op: IIntervalCollectionTypeOperationValue): void {\n\t\tconst { opName, value } = op;\n\t\tconst { id, properties } = getSerializedProperties(value);\n\t\tswitch (opName) {\n\t\t\tcase \"add\": {\n\t\t\t\tthis.add({\n\t\t\t\t\tid,\n\t\t\t\t\t// Todo: we should improve typing so we know add ops always have start and end\n\t\t\t\t\tstart: toSequencePlace(value.start, value.startSide),\n\t\t\t\t\tend: toSequencePlace(value.end, value.endSide),\n\t\t\t\t\tprops: properties,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"change\": {\n\t\t\t\tthis.change(id, {\n\t\t\t\t\tstart: toOptionalSequencePlace(value.start, value.startSide),\n\t\t\t\t\tend: toOptionalSequencePlace(value.end, value.endSide),\n\t\t\t\t\tprops: properties,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthis.removeIntervalById(id);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"unknown ops should not be stashed\");\n\t\t}\n\t}\n\n\tprivate rebaseReferenceWithSegmentSlide(\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t\tsquash: boolean,\n\t): { segment: ISegment; offset: number } | undefined {\n\t\tif (!this.client) {\n\t\t\tthrow new LoggingError(\"mergeTree client must exist\");\n\t\t}\n\n\t\tconst { clientId } = this.client.getCollabWindow();\n\t\tconst segment: ISegmentInternal | undefined = ref.getSegment();\n\t\tif (segment?.endpointType) {\n\t\t\treturn { segment, offset: 0 };\n\t\t}\n\t\tconst offset = ref.getOffset();\n\n\t\tconst segoff = getSlideToSegoff(\n\t\t\tsegment === undefined ? undefined : { segment, offset },\n\t\t\tref.slidingPreference,\n\t\t\tcreateLocalReconnectingPerspective(\n\t\t\t\tthis.client.getCurrentSeq(),\n\t\t\t\tclientId,\n\t\t\t\tlocalSeq,\n\t\t\t\tsquash,\n\t\t\t),\n\t\t\tref.canSlideToEndpoint,\n\t\t);\n\n\t\t// case happens when rebasing op, but concurrently entire string has been deleted\n\t\tif (segoff === undefined) {\n\t\t\tif (ref.canSlideToEndpoint !== true) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsegment:\n\t\t\t\t\tref.slidingPreference === SlidingPreference.FORWARD\n\t\t\t\t\t\t? this.client.endOfTree\n\t\t\t\t\t\t: this.client.startOfTree,\n\t\t\t\toffset: 0,\n\t\t\t};\n\t\t}\n\t\treturn segoff;\n\t}\n\n\tprivate computeRebasedPositions(\n\t\tlocalOpMetadata: IntervalAddLocalMetadata | IntervalChangeLocalMetadata,\n\t\tsquash: boolean,\n\t): Record<\"start\" | \"end\", { segment: ISegmentInternal; offset: number }> | \"detached\" {\n\t\tassert(\n\t\t\tthis.client !== undefined,\n\t\t\t0x550 /* Client should be defined when computing rebased position */,\n\t\t);\n\n\t\tconst { localSeq, interval } = localOpMetadata;\n\t\tconst start = this.rebaseReferenceWithSegmentSlide(interval.start, localSeq, squash);\n\t\tif (start === undefined) {\n\t\t\treturn \"detached\";\n\t\t}\n\t\tconst end = this.rebaseReferenceWithSegmentSlide(interval.end, localSeq, squash);\n\t\tif (end === undefined) {\n\t\t\treturn \"detached\";\n\t\t}\n\t\treturn { start, end };\n\t}\n\n\tpublic attachGraph(client: Client, label: string) {\n\t\tif (this.attached) {\n\t\t\tthrow new LoggingError(\"Only supports one Sequence attach\");\n\t\t}\n\n\t\tif (client === undefined) {\n\t\t\tthrow new LoggingError(\"Client required for this collection\");\n\t\t}\n\n\t\t// Instantiate the local interval collection based on the saved intervals\n\t\tthis.client = client;\n\t\tif (client) {\n\t\t\tclient.on(\"normalize\", (squash) => {\n\t\t\t\tfor (const pending of Object.values(this.pending)) {\n\t\t\t\t\tif (pending?.endpointChanges !== undefined) {\n\t\t\t\t\t\tfor (const local of pending.endpointChanges) {\n\t\t\t\t\t\t\tlocal.data.rebased = this.computeRebasedPositions(local.data, squash);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.localCollection = new LocalIntervalCollection(\n\t\t\tclient,\n\t\t\tlabel,\n\t\t\tthis.options,\n\t\t\t(interval, previousInterval) => this.emitChange(interval, previousInterval, true, true),\n\t\t);\n\t\tif (this.savedSerializedIntervals) {\n\t\t\tfor (const serializedInterval of this.savedSerializedIntervals) {\n\t\t\t\tconst { id, properties } = getSerializedProperties(serializedInterval);\n\t\t\t\tconst {\n\t\t\t\t\tstart: startPos,\n\t\t\t\t\tend: endPos,\n\t\t\t\t\tintervalType,\n\t\t\t\t\tstartSide,\n\t\t\t\t\tendSide,\n\t\t\t\t} = serializedInterval;\n\t\t\t\tconst start =\n\t\t\t\t\ttypeof startPos === \"number\" && startSide !== undefined\n\t\t\t\t\t\t? { pos: startPos, side: startSide }\n\t\t\t\t\t\t: startPos;\n\t\t\t\tconst end =\n\t\t\t\t\ttypeof endPos === \"number\" && endSide !== undefined\n\t\t\t\t\t\t? { pos: endPos, side: endSide }\n\t\t\t\t\t\t: endPos;\n\t\t\t\tconst interval = createSequenceInterval(\n\t\t\t\t\tlabel,\n\t\t\t\t\tid,\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\tclient,\n\t\t\t\t\tintervalType,\n\t\t\t\t\tundefined,\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.options.mergeTreeReferencesCanSlideToEndpoint,\n\t\t\t\t\tproperties,\n\t\t\t\t);\n\t\t\t\tthis.localCollection.add(interval);\n\t\t\t}\n\t\t}\n\t\tthis.savedSerializedIntervals = undefined;\n\t}\n\n\t/**\n\t * Gets the next local sequence number, modifying this client's collab window in doing so.\n\t */\n\tprivate getNextLocalSeq(): number {\n\t\tif (this.client) {\n\t\t\treturn ++this.client.getCollabWindow().localSeq;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprivate emitChange(\n\t\tinterval: SequenceIntervalClass,\n\t\tpreviousInterval: SequenceIntervalClass,\n\t\tlocal: boolean,\n\t\tslide: boolean,\n\t\top?: ISequencedDocumentMessage,\n\t): void {\n\t\t// Temporarily make references transient so that positional queries work (non-transient refs\n\t\t// on resolve to DetachedPosition on any segments that don't contain them). The original refType\n\t\t// is restored as single-endpoint changes re-use previous references.\n\n\t\tconst startRefType = previousInterval.start.refType;\n\t\tconst endRefType = previousInterval.end.refType;\n\t\tpreviousInterval.start.refType = ReferenceType.Transient;\n\t\tpreviousInterval.end.refType = ReferenceType.Transient;\n\t\tthis.emit(\"changeInterval\", interval, previousInterval, local, op, slide);\n\t\tthis.emit(\"changed\", interval, undefined, previousInterval ?? undefined, local, slide);\n\t\tpreviousInterval.start.refType = startRefType;\n\t\tpreviousInterval.end.refType = endRefType;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.getIntervalById}\n\t */\n\tpublic getIntervalById(id: string): SequenceIntervalClass | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attach must be called before accessing intervals\");\n\t\t}\n\t\treturn this.localCollection.idIntervalIndex.getIntervalById(id);\n\t}\n\n\tprivate assertStickinessEnabled(start: SequencePlace, end: SequencePlace) {\n\t\tif (\n\t\t\t!(typeof start === \"number\" && typeof end === \"number\") &&\n\t\t\t!this.options.intervalStickinessEnabled\n\t\t) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"attempted to set interval stickiness without enabling `intervalStickinessEnabled` feature flag\",\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.add}\n\t */\n\tpublic add({\n\t\tid,\n\t\tstart,\n\t\tend,\n\t\tprops,\n\t\trollback,\n\t}: {\n\t\tid?: string;\n\t\tstart: SequencePlace;\n\t\tend: SequencePlace;\n\t\tprops?: PropertySet;\n\t\trollback?: boolean;\n\t}): SequenceIntervalClass {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attach must be called prior to adding intervals\");\n\t\t}\n\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\n\t\tassert(\n\t\t\tstartPos !== undefined &&\n\t\t\t\tendPos !== undefined &&\n\t\t\t\tstartSide !== undefined &&\n\t\t\t\tendSide !== undefined,\n\t\t\t0x793 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t\t);\n\n\t\tthis.assertStickinessEnabled(start, end);\n\n\t\tconst intervalId = id ?? uuid();\n\n\t\tconst interval: SequenceIntervalClass = this.localCollection.addInterval(\n\t\t\tintervalId,\n\t\t\ttoSequencePlace(startPos, startSide),\n\t\t\ttoSequencePlace(endPos, endSide),\n\t\t\tprops,\n\t\t\tundefined,\n\t\t\trollback,\n\t\t);\n\n\t\tif (interval) {\n\t\t\tif (!this.isCollaborating) {\n\t\t\t\tsetSlideOnRemove(interval.start);\n\t\t\t\tsetSlideOnRemove(interval.end);\n\t\t\t}\n\t\t\tconst serializedInterval: ISerializedInterval = interval.serialize();\n\t\t\tconst localSeq = this.getNextLocalSeq();\n\t\t\tif (this.isCollaborating && rollback !== true) {\n\t\t\t\tthis.submitDelta(\n\t\t\t\t\t{\n\t\t\t\t\t\topName: \"add\",\n\t\t\t\t\t\tvalue: serializedInterval,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"add\",\n\t\t\t\t\t\tlocalSeq,\n\t\t\t\t\t\tinterval,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"addInterval\", interval, true, undefined);\n\n\t\treturn interval;\n\t}\n\n\tprivate deleteExistingInterval({\n\t\tinterval,\n\t\tlocal,\n\t\top,\n\t\trollback,\n\t}: {\n\t\tinterval: SequenceIntervalClass;\n\t\tlocal: boolean;\n\t\top?: ISequencedDocumentMessage;\n\t\trollback?: boolean;\n\t}) {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\t\t// The given interval is known to exist in the collection.\n\t\tthis.localCollection.removeExistingInterval(interval);\n\n\t\tif (interval) {\n\t\t\t// Local ops get submitted to the server. Remote ops have the deserializer run.\n\t\t\tif (local && rollback !== true) {\n\t\t\t\tconst value = interval.serialize();\n\t\t\t\tthis.submitDelta(\n\t\t\t\t\t{\n\t\t\t\t\t\topName: \"delete\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"delete\",\n\t\t\t\t\t\tlocalSeq: this.getNextLocalSeq(),\n\t\t\t\t\t\tprevious: value,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (this.onDeserialize) {\n\t\t\t\t\tthis.onDeserialize(interval);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"deleteInterval\", interval, local, op);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.removeIntervalById}\n\t */\n\tpublic removeIntervalById(id: string): SequenceIntervalClass | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\t\tconst interval = this.localCollection.idIntervalIndex.getIntervalById(id);\n\t\tif (interval) {\n\t\t\tthis.deleteExistingInterval({ interval, local: true });\n\t\t}\n\t\treturn interval;\n\t}\n\t/**\n\t * {@inheritdoc IIntervalCollection.change}\n\t */\n\tpublic change(\n\t\tid: string,\n\t\t{\n\t\t\tstart,\n\t\t\tend,\n\t\t\tprops,\n\t\t\trollback,\n\t\t}: { start?: SequencePlace; end?: SequencePlace; props?: PropertySet; rollback?: boolean },\n\t): SequenceIntervalClass | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\n\t\t// Force id to be a string.\n\t\tif (typeof id !== \"string\") {\n\t\t\tthrow new UsageError(\"Change API requires an ID that is a string\");\n\t\t}\n\n\t\t// Ensure that both start and end are defined or both are undefined.\n\t\tif ((start === undefined) !== (end === undefined)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Change API requires both start and end to be defined or undefined\",\n\t\t\t);\n\t\t}\n\n\t\t// prevent the overwriting of an interval label, it should remain unchanged\n\t\t// once it has been inserted into the collection.\n\t\tif (props?.[reservedRangeLabelsKey] !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The label property should not be modified once inserted to the collection\",\n\t\t\t);\n\t\t}\n\n\t\tconst interval = this.getIntervalById(id);\n\t\tif (interval) {\n\t\t\tlet deltaProps: PropertySet | undefined;\n\t\t\tlet newInterval: SequenceIntervalClass | undefined;\n\t\t\tif (props !== undefined) {\n\t\t\t\tdeltaProps = interval.changeProperties(props, undefined, rollback);\n\t\t\t}\n\t\t\tconst changeEndpoints = start !== undefined && end !== undefined;\n\t\t\tif (changeEndpoints) {\n\t\t\t\tnewInterval = this.localCollection.changeInterval(interval, start, end);\n\t\t\t\tif (!this.isCollaborating && newInterval !== undefined) {\n\t\t\t\t\tsetSlideOnRemove(newInterval.start);\n\t\t\t\t\tsetSlideOnRemove(newInterval.end);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.isCollaborating && rollback !== true) {\n\t\t\t\t// Emit a property bag containing the ID and the other (if any) properties changed\n\t\t\t\tconst serializedInterval: SerializedIntervalDelta = (\n\t\t\t\t\tnewInterval ?? interval\n\t\t\t\t).serializeDelta({ props, includeEndpoints: changeEndpoints });\n\t\t\t\tconst localSeq = this.getNextLocalSeq();\n\n\t\t\t\tconst metadata: IntervalChangeLocalMetadata = {\n\t\t\t\t\ttype: \"change\",\n\t\t\t\t\tlocalSeq,\n\t\t\t\t\tprevious: interval.serialize(),\n\t\t\t\t\tinterval: newInterval ?? interval,\n\t\t\t\t};\n\n\t\t\t\tthis.submitDelta(\n\t\t\t\t\t{\n\t\t\t\t\t\topName: \"change\",\n\t\t\t\t\t\tvalue: serializedInterval,\n\t\t\t\t\t},\n\t\t\t\t\tmetadata,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (deltaProps !== undefined) {\n\t\t\t\tthis.emit(\"propertyChanged\", interval, deltaProps, true, undefined);\n\t\t\t\tthis.emit(\n\t\t\t\t\t\"changed\",\n\t\t\t\t\tnewInterval ?? interval,\n\t\t\t\t\tdeltaProps,\n\t\t\t\t\tnewInterval ? interval : undefined,\n\t\t\t\t\ttrue,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (newInterval) {\n\t\t\t\tthis.emitChange(newInterval, interval, true, false);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tinterval.start.properties!.interval = undefined;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tinterval.end.properties!.interval = undefined;\n\t\t\t}\n\t\t\treturn newInterval;\n\t\t}\n\t\t// No interval to change\n\t\treturn undefined;\n\t}\n\n\tprivate get isCollaborating(): boolean {\n\t\treturn this.client?.getCollabWindow().collaborating ?? false;\n\t}\n\n\tprivate hasPendingEndpointChanges(id: string) {\n\t\treturn this.pending[id]?.endpointChanges?.empty === false;\n\t}\n\n\tpublic ackChange(\n\t\tserializedInterval: SerializedIntervalDelta,\n\t\tlocal: boolean,\n\t\top: ISequencedDocumentMessage,\n\t) {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t}\n\n\t\t// Note that the ID is in the property bag only to allow us to find the interval.\n\t\t// This API cannot change the ID, and writing to the ID property will result in an exception. So we\n\t\t// strip it out of the properties here.\n\t\tconst { id, properties } = getSerializedProperties(serializedInterval);\n\t\tassert(id !== undefined, 0x3fe /* id must exist on the interval */);\n\t\tconst interval: SequenceIntervalClass | undefined = this.getIntervalById(id);\n\n\t\tif (!interval) {\n\t\t\t// The interval has been removed locally; no-op.\n\t\t\treturn;\n\t\t}\n\n\t\tif (local) {\n\t\t\tinterval.ackPropertiesChange(properties, op);\n\n\t\t\tthis.ackInterval(interval, op);\n\t\t} else {\n\t\t\t// If there are pending changes with this ID, don't apply the remote start/end change, as the local ack\n\t\t\t// should be the winning change.\n\t\t\tlet start: number | \"start\" | \"end\" | undefined;\n\t\t\tlet end: number | \"start\" | \"end\" | undefined;\n\t\t\t// Track pending start/end independently of one another.\n\t\t\tif (!this.hasPendingEndpointChanges(id)) {\n\t\t\t\tstart = serializedInterval.start;\n\t\t\t\tend = serializedInterval.end;\n\t\t\t}\n\n\t\t\tlet newInterval = interval;\n\t\t\tif (start !== undefined || end !== undefined) {\n\t\t\t\t// If changeInterval gives us a new interval, work with that one. Otherwise keep working with\n\t\t\t\t// the one we originally found in the tree.\n\t\t\t\tnewInterval =\n\t\t\t\t\tthis.localCollection.changeInterval(\n\t\t\t\t\t\tinterval,\n\t\t\t\t\t\ttoOptionalSequencePlace(start, serializedInterval.startSide ?? Side.Before),\n\t\t\t\t\t\ttoOptionalSequencePlace(end, serializedInterval.endSide ?? Side.Before),\n\t\t\t\t\t\top,\n\t\t\t\t\t) ?? interval;\n\t\t\t}\n\t\t\tconst deltaProps = newInterval.changeProperties(properties, op);\n\n\t\t\tif (this.onDeserialize) {\n\t\t\t\tthis.onDeserialize(newInterval);\n\t\t\t}\n\n\t\t\tif (newInterval !== interval) {\n\t\t\t\tthis.emitChange(newInterval, interval, local, false, op);\n\t\t\t}\n\n\t\t\tconst changedProperties = Object.keys(properties).length > 0;\n\t\t\tif (changedProperties) {\n\t\t\t\tthis.emit(\"propertyChanged\", interval, deltaProps, local, op);\n\t\t\t\tthis.emit(\"changed\", interval, deltaProps, undefined, local, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.attachDeserializer}\n\t */\n\tpublic attachDeserializer(onDeserialize: DeserializeCallback): void {\n\t\t// If no deserializer is specified can skip all processing work\n\t\tif (!onDeserialize) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Start by storing the callbacks so that any subsequent modifications make use of them\n\t\tthis.onDeserialize = onDeserialize;\n\n\t\t// Trigger the async prepare work across all values in the collection\n\t\tif (this.attached) {\n\t\t\tthis.map(onDeserialize);\n\t\t}\n\t}\n\n\t/**\n\t * Returns new interval after rebasing. If undefined, the interval was\n\t * deleted as a result of rebasing. This can occur if the interval applies\n\t * to a range that no longer exists, and the interval was unable to slide.\n\t *\n\t */\n\tpublic rebaseLocalInterval(\n\t\toriginal: SerializedIntervalDelta,\n\t\tlocalOpMetadata: IntervalAddLocalMetadata | IntervalChangeLocalMetadata,\n\t\tsquash: boolean,\n\t): SerializedIntervalDelta | undefined {\n\t\tif (!this.client || !hasEndpointChanges(original)) {\n\t\t\t// If there's no associated mergeTree client, the originally submitted op is still correct.\n\t\t\treturn original;\n\t\t}\n\t\tif (!this.attached || this.localCollection === undefined) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\tconst { localSeq, interval } = localOpMetadata;\n\t\tconst { id } = getSerializedProperties(original);\n\t\tconst rebasedEndpoint = (localOpMetadata.rebased ??= this.computeRebasedPositions(\n\t\t\tlocalOpMetadata,\n\t\t\tsquash,\n\t\t));\n\t\tconst localInterval = this.localCollection.idIntervalIndex.getIntervalById(id);\n\n\t\t// if the interval slid off the string, rebase the op to be a noop and delete the interval.\n\t\tif (rebasedEndpoint === \"detached\") {\n\t\t\tif (\n\t\t\t\tlocalInterval !== undefined &&\n\t\t\t\t(localInterval === interval || localOpMetadata.type === \"add\")\n\t\t\t) {\n\t\t\t\tthis.localCollection?.removeExistingInterval(localInterval);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { start, end } = rebasedEndpoint;\n\t\tif (\n\t\t\tinterval.start.getSegment() !== start.segment ||\n\t\t\tinterval.start.getOffset() !== start.offset ||\n\t\t\tinterval.end.getSegment() !== end.segment ||\n\t\t\tinterval.end.getOffset() !== end.offset\n\t\t) {\n\t\t\tif (localInterval === interval) {\n\t\t\t\tthis.localCollection.removeExistingInterval(localInterval);\n\t\t\t}\n\t\t\tconst old = interval.clone();\n\t\t\tinterval.moveEndpointReferences(rebasedEndpoint);\n\t\t\tif (localInterval === interval) {\n\t\t\t\tthis.localCollection.add(interval);\n\t\t\t\tthis.emitChange(interval, old, true, true);\n\t\t\t}\n\t\t\tthis.client.removeLocalReferencePosition(old.start);\n\t\t\tthis.client.removeLocalReferencePosition(old.end);\n\t\t}\n\n\t\treturn {\n\t\t\t...original,\n\t\t\tstart:\n\t\t\t\tstart.segment.endpointType ??\n\t\t\t\tthis.client.findReconnectionPosition(start.segment, localSeq) + start.offset,\n\t\t\tend:\n\t\t\t\tend.segment.endpointType ??\n\t\t\t\tthis.client.findReconnectionPosition(end.segment, localSeq) + end.offset,\n\t\t\tsequenceNumber: this.client?.getCurrentSeq() ?? 0,\n\t\t};\n\t}\n\n\tprivate getSlideToSegment(\n\t\tlref: LocalReferencePosition,\n\t): { segment: ISegment; offset: number } | undefined {\n\t\tif (!this.client) {\n\t\t\tthrow new LoggingError(\"client does not exist\");\n\t\t}\n\t\tconst segment: ISegmentInternal | undefined = lref.getSegment();\n\t\tif (segment === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst segoff = {\n\t\t\tsegment,\n\t\t\toffset: lref.getOffset(),\n\t\t};\n\t\tif (segoff.segment.localRefs?.has(lref) !== true) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getSlideToSegoff(\n\t\t\tsegoff,\n\t\t\tlref.slidingPreference,\n\t\t\tundefined,\n\t\t\tlref.canSlideToEndpoint,\n\t\t);\n\t}\n\n\tprivate ackInterval(interval: SequenceIntervalClass, op: ISequencedDocumentMessage): void {\n\t\tif (\n\t\t\t!refTypeIncludesFlag(interval.start, ReferenceType.StayOnRemove) &&\n\t\t\t!refTypeIncludesFlag(interval.end, ReferenceType.StayOnRemove)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStart = this.getSlideToSegment(interval.start);\n\t\tconst newEnd = this.getSlideToSegment(interval.end);\n\n\t\tconst id = interval.getIntervalId();\n\t\tconst hasPendingChange = this.hasPendingEndpointChanges(id);\n\n\t\tif (!hasPendingChange) {\n\t\t\tsetSlideOnRemove(interval.start);\n\t\t\tsetSlideOnRemove(interval.end);\n\t\t}\n\n\t\tconst needsStartUpdate =\n\t\t\tnewStart?.segment !== interval.start.getSegment() && !hasPendingChange;\n\t\tconst needsEndUpdate = newEnd?.segment !== interval.end.getSegment() && !hasPendingChange;\n\n\t\tif (needsStartUpdate || needsEndUpdate) {\n\t\t\tif (!this.localCollection) {\n\t\t\t\tthrow new LoggingError(\"Attach must be called before accessing intervals\");\n\t\t\t}\n\n\t\t\t// `interval`'s endpoints will get modified in-place, so clone it prior to doing so for event emission.\n\t\t\tconst oldInterval = interval.clone();\n\n\t\t\t// In this case, where we change the start or end of an interval,\n\t\t\t// it is necessary to remove and re-add the interval listeners.\n\t\t\t// This ensures that the correct listeners are added to the LocalReferencePosition.\n\t\t\tthis.localCollection.removeExistingInterval(interval);\n\t\t\tif (!this.client) {\n\t\t\t\tthrow new LoggingError(\"client does not exist\");\n\t\t\t}\n\n\t\t\tif (needsStartUpdate) {\n\t\t\t\tconst props = interval.start.properties;\n\t\t\t\tinterval.start = createPositionReferenceFromSegoff({\n\t\t\t\t\tclient: this.client,\n\t\t\t\t\tsegoff: newStart,\n\t\t\t\t\trefType: interval.start.refType,\n\t\t\t\t\top,\n\t\t\t\t\tslidingPreference: interval.start.slidingPreference,\n\t\t\t\t\tcanSlideToEndpoint: interval.start.canSlideToEndpoint,\n\t\t\t\t});\n\t\t\t\tif (props) {\n\t\t\t\t\tinterval.start.addProperties(props);\n\t\t\t\t}\n\t\t\t\tconst oldSeg: ISegmentInternal | undefined = oldInterval.start.getSegment();\n\t\t\t\t// remove and rebuild start interval as transient for event\n\t\t\t\tthis.client.removeLocalReferencePosition(oldInterval.start);\n\t\t\t\toldInterval.start.refType = ReferenceType.Transient;\n\t\t\t\toldSeg?.localRefs?.addLocalRef(oldInterval.start, oldInterval.start.getOffset());\n\t\t\t}\n\t\t\tif (needsEndUpdate) {\n\t\t\t\tconst props = interval.end.properties;\n\t\t\t\tinterval.end = createPositionReferenceFromSegoff({\n\t\t\t\t\tclient: this.client,\n\t\t\t\t\tsegoff: newEnd,\n\t\t\t\t\trefType: interval.end.refType,\n\t\t\t\t\top,\n\t\t\t\t\tslidingPreference: interval.end.slidingPreference,\n\t\t\t\t\tcanSlideToEndpoint: interval.end.canSlideToEndpoint,\n\t\t\t\t});\n\t\t\t\tif (props) {\n\t\t\t\t\tinterval.end.addProperties(props);\n\t\t\t\t}\n\t\t\t\t// remove and rebuild end interval as transient for event\n\t\t\t\tconst oldSeg: ISegmentInternal | undefined = oldInterval.end.getSegment();\n\t\t\t\tthis.client.removeLocalReferencePosition(oldInterval.end);\n\t\t\t\toldInterval.end.refType = ReferenceType.Transient;\n\t\t\t\toldSeg?.localRefs?.addLocalRef(oldInterval.end, oldInterval.end.getOffset());\n\t\t\t}\n\t\t\tthis.localCollection.add(interval);\n\t\t\tthis.emitChange(interval, oldInterval, true, true, op);\n\t\t}\n\t}\n\n\tpublic ackAdd(\n\t\tserializedInterval: ISerializedInterval,\n\t\tlocal: boolean,\n\t\top: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: IntervalAddLocalMetadata | undefined,\n\t) {\n\t\tconst { id, properties } = getSerializedProperties(serializedInterval);\n\n\t\tif (local) {\n\t\t\tassert(\n\t\t\t\tlocalOpMetadata !== undefined,\n\t\t\t\t0x553 /* op metadata should be defined for local op */,\n\t\t\t);\n\t\t\tconst localInterval = this.getIntervalById(id);\n\t\t\tif (localInterval) {\n\t\t\t\tthis.ackInterval(localInterval, op);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\tconst interval: SequenceIntervalClass = this.localCollection.addInterval(\n\t\t\tid,\n\t\t\ttoSequencePlace(serializedInterval.start, serializedInterval.startSide ?? Side.Before),\n\t\t\ttoSequencePlace(serializedInterval.end, serializedInterval.endSide ?? Side.Before),\n\t\t\tproperties,\n\t\t\top,\n\t\t);\n\n\t\tif (interval) {\n\t\t\tif (this.onDeserialize) {\n\t\t\t\tthis.onDeserialize(interval);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"addInterval\", interval, local, op);\n\n\t\treturn interval;\n\t}\n\n\tpublic ackDelete(\n\t\tserializedInterval: SerializedIntervalDelta,\n\t\tlocal: boolean,\n\t\top: ISequencedDocumentMessage,\n\t): void {\n\t\tif (local) {\n\t\t\t// Local ops were applied when the message was created and there's no \"pending delete\"\n\t\t\t// state to book keep: remote operation application takes into account possibility of\n\t\t\t// locally deleted interval whenever a lookup happens.\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attach must be called prior to deleting intervals\");\n\t\t}\n\n\t\tconst { id } = getSerializedProperties(serializedInterval);\n\t\tconst interval = this.localCollection.idIntervalIndex.getIntervalById(id);\n\t\tif (interval) {\n\t\t\tthis.deleteExistingInterval({ interval, local, op });\n\t\t}\n\t}\n\n\tpublic serializeInternal(\n\t\tversion: \"1\" | \"2\",\n\t): ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2 {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.serialize(version);\n\t}\n\n\t/**\n\t * @returns an iterator over all intervals in this collection.\n\t */\n\tpublic [Symbol.iterator](): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithStartPosition}\n\t */\n\tpublic CreateForwardIteratorWithStartPosition(\n\t\tstartPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, true, startPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithStartPosition}\n\t */\n\tpublic CreateBackwardIteratorWithStartPosition(\n\t\tstartPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, false, startPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithEndPosition}\n\t */\n\tpublic CreateForwardIteratorWithEndPosition(\n\t\tendPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, true, undefined, endPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithEndPosition}\n\t */\n\tpublic CreateBackwardIteratorWithEndPosition(\n\t\tendPosition: number,\n\t): IntervalCollectionIterator {\n\t\tconst iterator = new IntervalCollectionIterator(this, false, undefined, endPosition);\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.gatherIterationResults}\n\t */\n\tpublic gatherIterationResults(\n\t\tresults: SequenceIntervalClass[],\n\t\titeratesForward: boolean,\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tif (!this.localCollection) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.localCollection.overlappingIntervalsIndex.gatherIterationResults(\n\t\t\tresults,\n\t\t\titeratesForward,\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.findOverlappingIntervals}\n\t */\n\tpublic findOverlappingIntervals(\n\t\tstartPosition: number,\n\t\tendPosition: number,\n\t): SequenceInterval[] {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.overlappingIntervalsIndex.findOverlappingIntervals(\n\t\t\tstartPosition,\n\t\t\tendPosition,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.map}\n\t */\n\tpublic map(fn: (interval: SequenceIntervalClass) => void) {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\tfor (const interval of this.localCollection.idIntervalIndex) {\n\t\t\tfn(interval);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.previousInterval}\n\t */\n\tpublic previousInterval(pos: number): SequenceInterval | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.endIntervalIndex.previousInterval(pos);\n\t}\n\n\t/**\n\t * {@inheritdoc IIntervalCollection.nextInterval}\n\t */\n\tpublic nextInterval(pos: number): SequenceInterval | undefined {\n\t\tif (!this.localCollection) {\n\t\t\tthrow new LoggingError(\"attachSequence must be called\");\n\t\t}\n\n\t\treturn this.localCollection.endIntervalIndex.nextInterval(pos);\n\t}\n}\n\nfunction setSlideOnRemove(lref: LocalReferencePosition) {\n\tlet refType = lref.refType;\n\trefType = refType & ~ReferenceType.StayOnRemove;\n\trefType = refType | ReferenceType.SlideOnRemove;\n\tlref.refType = refType;\n}\n\n/**\n * Information that identifies an interval within a `Sequence`.\n * @internal\n */\nexport interface IntervalLocator {\n\t/**\n\t * Label for the collection the interval is a part of\n\t */\n\tlabel: string;\n\t/**\n\t * Interval within that collection\n\t */\n\tinterval: SequenceIntervalClass;\n}\n\n/**\n * Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.\n * @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created\n * on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this\n * endpoint is a part of.\n * @internal\n */\nexport function intervalLocatorFromEndpoint(\n\tpotentialEndpoint: LocalReferencePosition,\n): IntervalLocator | undefined {\n\tconst { interval, [reservedRangeLabelsKey]: collectionNameArray } =\n\t\tpotentialEndpoint.properties ?? {};\n\treturn interval && collectionNameArray?.length === 1\n\t\t? { label: collectionNameArray[0], interval }\n\t\t: undefined;\n}\n"]}
@@ -95,7 +95,7 @@ export declare class IntervalCollectionMap {
95
95
  * also sent if we are asked to resubmit the message.
96
96
  * @returns True if the operation was submitted, false otherwise.
97
97
  */
98
- tryResubmitMessage(content: unknown, localOpMetadata: unknown): boolean;
98
+ tryResubmitMessage(content: unknown, localOpMetadata: unknown, squash: boolean): boolean;
99
99
  tryRollback(content: any, localOpMetadata: unknown): boolean;
100
100
  tryApplyStashedOp(content: unknown): boolean;
101
101
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMap.d.ts","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAa,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAG1F,OAAO,EACN,kBAAkB,EAGlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,qCAAqC,EACrC,+BAA+B,EAC/B,e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,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAalD,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAWnD;;;;;;;;;;;;;;OAcG;IACI,iBAAiB,CACvB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,yBAAyB,EAClC,eAAe,EAAE,OAAO,GACtB,OAAO;IAUV;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAyBlB"}
@@ -121,12 +121,12 @@ class IntervalCollectionMap {
121
121
  * also sent if we are asked to resubmit the message.
122
122
  * @returns True if the operation was submitted, false otherwise.
123
123
  */
124
- tryResubmitMessage(content, localOpMetadata) {
124
+ tryResubmitMessage(content, localOpMetadata, squash) {
125
125
  if (isMapOperation(content)) {
126
126
  const { value, key } = content;
127
127
  const localValue = this.data.get(key);
128
128
  (0, internal_1.assert)(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
129
- localValue.resubmitMessage(value, localOpMetadata);
129
+ localValue.resubmitMessage(value, localOpMetadata, squash);
130
130
  return true;
131
131
  }
132
132
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"intervalCollectionMap.js","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAGjE,kEAA6D;AAE7D,0EAA0F;AAE1F,+EAAiE;AACjE,mEAIiC;AAOjC,SAAS,cAAc,CAAC,EAAW;IAClC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,IAAI,IAAI,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC;AACnF,CAAC;AAiCD;;;;;;GAMG;AACH,MAAa,qBAAqB;IACjC;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB,CAAC;IAQD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;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cG;IACI,iBAAiB,CACvB,OAAgB,EAChB,KAAc,EACd,OAAkC,EAClC,eAAwB;QAExB,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;YAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACrE,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;OAIG;IACK,UAAU,CACjB,GAAW,EACX,KAAc,EACd,mBAAuF;QAEvF,MAAM,UAAU,GAAG,IAAI,0CAAkB,CACxC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YACV,CAAC;gBACA,IAAI,CAAC,aAAa,CACjB;oBACC,GAAG;oBACH,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,EAAE;iBACT,EACD,EAAE,CACF,CAAC;YACH,CAAC;QACF,CAAC,EACD,mBAAmB,IAAI,EAAE,EACzB,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;IACnB,CAAC;CACD;AA3ND,sDA2NC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { ValueType, IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\n\nimport { makeSerializable } from \"./IntervalCollectionValues.js\";\nimport {\n\tIntervalCollection,\n\ttype ISerializedIntervalCollectionV1,\n\ttype ISerializedIntervalCollectionV2,\n} from \"./intervalCollection.js\";\nimport {\n\tIIntervalCollectionTypeOperationValue,\n\tISerializableIntervalCollection,\n\tSequenceOptions,\n} from \"./intervalCollectionMapInterfaces.js\";\n\nfunction isMapOperation(op: unknown): op is IMapOperation {\n\treturn typeof op === \"object\" && op !== null && \"type\" in op && op.type === \"act\";\n}\n\n/**\n * Description of a map delta operation\n */\nexport interface IMapOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t */\n\tvalue: IIntervalCollectionTypeOperationValue;\n}\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n\t[key: string]: ISerializableIntervalCollection;\n}\n\nexport interface IntervalCollectionMapEvents extends IEvent {\n\t(event: \"createIntervalCollection\", listener: (key: string, local: boolean) => void): void;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class IntervalCollectionMap {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, IntervalCollection>();\n\n\tprivate readonly eventEmitter = new TypedEventEmitter<IntervalCollectionMapEvents>();\n\tpublic get events(): IEventProvider<IntervalCollectionMapEvents> {\n\t\treturn this.eventEmitter;\n\t}\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (op: IMapOperation, localOpMetadata: unknown) => void,\n\t\tprivate readonly options?: Partial<SequenceOptions>,\n\t) {}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): IntervalCollection {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(\n\t\t\t\tlocalValue,\n\t\t\t\tserializer,\n\t\t\t\tthis.handle,\n\t\t\t\tthis.options?.intervalSerializationFormat ?? \"2\",\n\t\t\t);\n\t\t});\n\t\treturn JSON.stringify(serializableMapData);\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t *\n\t * @param serialized - A JSON string containing serialized map data\n\t */\n\tpublic populate(serialized: string): void {\n\t\tconst parsed = this.serializer.parse(serialized) as IMapDataObjectSerializable;\n\n\t\tfor (const [key, serializable] of Object.entries(parsed)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tassert(\n\t\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t\t);\n\n\t\t\tthis.createCore(normalizedKey, false, serializable.value);\n\t\t}\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param content - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(content: unknown, localOpMetadata: unknown): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst localValue = this.data.get(key);\n\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\t\t\tlocalValue.resubmitMessage(value, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryRollback(content: any, localOpMetadata: unknown) {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst localValue = this.data.get(content.key);\n\n\t\t\tassert(localValue !== undefined, 0xb7e /* Local value expected on rollback */);\n\n\t\t\tlocalValue.rollback(content.value, localOpMetadata);\n\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryApplyStashedOp(content: unknown): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst map = this.get(key);\n\n\t\t\tmap.applyStashedOp(value);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was recognized and thus processed, false otherwise.\n\t *\n\t * @remarks\n\t * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code.\n\t * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op\n\t * and could result in data corruption or data loss as well.\n\t * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption\n\t * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.\n\t */\n\tpublic tryProcessMessage(\n\t\tcontent: unknown,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst localValue = this.data.get(key) ?? this.createCore(key, local);\n\t\t\tlocalValue.process(value, local, message, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t */\n\tprivate createCore(\n\t\tkey: string,\n\t\tlocal: boolean,\n\t\tserializedIntervals?: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2,\n\t): IntervalCollection {\n\t\tconst localValue = new IntervalCollection(\n\t\t\t(op, md) => {\n\t\t\t\t{\n\t\t\t\t\tthis.submitMessage(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\ttype: \"act\",\n\t\t\t\t\t\t\tvalue: op,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmd,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\tserializedIntervals ?? [],\n\t\t\tthis.options,\n\t\t);\n\t\tthis.data.set(key, localValue);\n\t\tthis.eventEmitter.emit(\"createIntervalCollection\", key, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n}\n"]}
1
+ {"version":3,"file":"intervalCollectionMap.js","sourceRoot":"","sources":["../src/intervalCollectionMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAGjE,kEAA6D;AAE7D,0EAA0F;AAE1F,+EAAiE;AACjE,mEAIiC;AAOjC,SAAS,cAAc,CAAC,EAAW;IAClC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,IAAI,IAAI,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC;AACnF,CAAC;AAiCD;;;;;;GAMG;AACH,MAAa,qBAAqB;IACjC;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB,CAAC;IAQD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAAoE,EACpE,OAAkC;QAHlC,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAAuD;QACpE,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AG,EAAE,GAAG,OAAO,CAAC;YAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACrE,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;OAIG;IACK,UAAU,CACjB,GAAW,EACX,KAAc,EACd,mBAAuF;QAEvF,MAAM,UAAU,GAAG,IAAI,0CAAkB,CACxC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YACV,CAAC;gBACA,IAAI,CAAC,aAAa,CACjB;oBACC,GAAG;oBACH,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,EAAE;iBACT,EACD,EAAE,CACF,CAAC;YACH,CAAC;QACF,CAAC,EACD,mBAAmB,IAAI,EAAE,EACzB,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;IACnB,CAAC;CACD;AA/ND,sDA+NC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { ValueType, IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\n\nimport { makeSerializable } from \"./IntervalCollectionValues.js\";\nimport {\n\tIntervalCollection,\n\ttype ISerializedIntervalCollectionV1,\n\ttype ISerializedIntervalCollectionV2,\n} from \"./intervalCollection.js\";\nimport {\n\tIIntervalCollectionTypeOperationValue,\n\tISerializableIntervalCollection,\n\tSequenceOptions,\n} from \"./intervalCollectionMapInterfaces.js\";\n\nfunction isMapOperation(op: unknown): op is IMapOperation {\n\treturn typeof op === \"object\" && op !== null && \"type\" in op && op.type === \"act\";\n}\n\n/**\n * Description of a map delta operation\n */\nexport interface IMapOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t */\n\tvalue: IIntervalCollectionTypeOperationValue;\n}\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n\t[key: string]: ISerializableIntervalCollection;\n}\n\nexport interface IntervalCollectionMapEvents extends IEvent {\n\t(event: \"createIntervalCollection\", listener: (key: string, local: boolean) => void): void;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class IntervalCollectionMap {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, IntervalCollection>();\n\n\tprivate readonly eventEmitter = new TypedEventEmitter<IntervalCollectionMapEvents>();\n\tpublic get events(): IEventProvider<IntervalCollectionMapEvents> {\n\t\treturn this.eventEmitter;\n\t}\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (op: IMapOperation, localOpMetadata: unknown) => void,\n\t\tprivate readonly options?: Partial<SequenceOptions>,\n\t) {}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): IntervalCollection {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(\n\t\t\t\tlocalValue,\n\t\t\t\tserializer,\n\t\t\t\tthis.handle,\n\t\t\t\tthis.options?.intervalSerializationFormat ?? \"2\",\n\t\t\t);\n\t\t});\n\t\treturn JSON.stringify(serializableMapData);\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t *\n\t * @param serialized - A JSON string containing serialized map data\n\t */\n\tpublic populate(serialized: string): void {\n\t\tconst parsed = this.serializer.parse(serialized) as IMapDataObjectSerializable;\n\n\t\tfor (const [key, serializable] of Object.entries(parsed)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tassert(\n\t\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t\t);\n\n\t\t\tthis.createCore(normalizedKey, false, serializable.value);\n\t\t}\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param content - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(\n\t\tcontent: unknown,\n\t\tlocalOpMetadata: unknown,\n\t\tsquash: boolean,\n\t): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst localValue = this.data.get(key);\n\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\t\t\tlocalValue.resubmitMessage(value, localOpMetadata, squash);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryRollback(content: any, localOpMetadata: unknown) {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst localValue = this.data.get(content.key);\n\n\t\t\tassert(localValue !== undefined, 0xb7e /* Local value expected on rollback */);\n\n\t\t\tlocalValue.rollback(content.value, localOpMetadata);\n\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryApplyStashedOp(content: unknown): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst map = this.get(key);\n\n\t\t\tmap.applyStashedOp(value);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was recognized and thus processed, false otherwise.\n\t *\n\t * @remarks\n\t * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code.\n\t * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op\n\t * and could result in data corruption or data loss as well.\n\t * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption\n\t * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.\n\t */\n\tpublic tryProcessMessage(\n\t\tcontent: unknown,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tif (isMapOperation(content)) {\n\t\t\tconst { value, key } = content;\n\t\t\tconst localValue = this.data.get(key) ?? this.createCore(key, local);\n\t\t\tlocalValue.process(value, local, message, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t */\n\tprivate createCore(\n\t\tkey: string,\n\t\tlocal: boolean,\n\t\tserializedIntervals?: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2,\n\t): IntervalCollection {\n\t\tconst localValue = new IntervalCollection(\n\t\t\t(op, md) => {\n\t\t\t\t{\n\t\t\t\t\tthis.submitMessage(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\ttype: \"act\",\n\t\t\t\t\t\t\tvalue: op,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmd,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\tserializedIntervals ?? [],\n\t\t\tthis.options,\n\t\t);\n\t\tthis.data.set(key, localValue);\n\t\tthis.eventEmitter.emit(\"createIntervalCollection\", key, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n}\n"]}