@superdoc/mcp 1.3.0-next.3 → 1.3.0-next.5

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 (2) hide show
  1. package/dist/index.js +747 -137
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31316,7 +31316,7 @@ var init_host = __esm(() => {
31316
31316
  });
31317
31317
 
31318
31318
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31319
- var SDK_VERSION = "2.16.0-next.3";
31319
+ var SDK_VERSION = "2.16.0-next.5";
31320
31320
 
31321
31321
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31322
31322
  import { chmodSync, existsSync } from "node:fs";
@@ -135122,7 +135122,8 @@ function validateRunContents(xml, options) {
135122
135122
  if (xml === "")
135123
135123
  return { ok: true };
135124
135124
  const replayXml = stripAllowedNoteReferences(xml, options);
135125
- const withoutBookmarks = replayXml !== null && /<(?:[\w.-]+:)?bookmark(?:Start|End)\b/.test(replayXml) ? preservedBookmarkRunTokens(replayXml)?.strippedXml ?? null : replayXml;
135125
+ const withoutCarriers = replayXml !== null && options.baseRunXml ? stripRetainedCarrier(replayXml, options.baseRunXml, options.allowNamespaceDeclarationDifference === true) : replayXml;
135126
+ const withoutBookmarks = withoutCarriers !== null && /<(?:[\w.-]+:)?bookmark(?:Start|End)\b/.test(withoutCarriers) ? preservedBookmarkRunTokens(withoutCarriers)?.strippedXml ?? null : withoutCarriers;
135126
135127
  if (withoutBookmarks === null || UNSUPPORTED_XML.test(withoutBookmarks) || RELATIONSHIP_REFERENCE.test(withoutBookmarks)) {
135127
135128
  return { ok: false, reason: "target runs require unsupported structural or relationship replay" };
135128
135129
  }
@@ -135134,6 +135135,17 @@ function validateRunContents(xml, options) {
135134
135135
  }
135135
135136
  return { ok: true };
135136
135137
  }
135138
+ function stripRetainedCarrier(target, base2, allowNamespaceDeclarationDifference) {
135139
+ if (!target.includes("<w:drawing") && !target.includes("<w:fldSimple"))
135140
+ return target;
135141
+ const carrier = /<w:r\b[^>]*><w:drawing\b[^>]*>[\s\S]*?<\/w:drawing><\/w:r>|<w:fldSimple\b[^>]*>[\s\S]*?<\/w:fldSimple>/g;
135142
+ const targetCarriers = [...target.matchAll(carrier)];
135143
+ const baseCarriers = [...base2.matchAll(carrier)];
135144
+ const normalized = (xml) => allowNamespaceDeclarationDifference ? xml.replace(/\s+xmlns(?::[\w.-]+)?=(?:"[^"]*"|'[^']*')/g, "") : xml;
135145
+ if (targetCarriers.length !== 1 || baseCarriers.length !== 1 || normalized(targetCarriers[0][0]) !== normalized(baseCarriers[0][0]))
135146
+ return null;
135147
+ return target.replace(targetCarriers[0][0], "");
135148
+ }
135137
135149
  function validateCompareReplayPayload(payload, options = {}) {
135138
135150
  if (payload.targetParagraphPropertiesXml !== undefined && !isWellFormedReplayXmlFragment(payload.targetParagraphPropertiesXml)) {
135139
135151
  return { ok: false, reason: "target paragraph properties are not well-formed XML" };
@@ -136792,7 +136804,7 @@ function validateRetainedNoteReplay(value, problems, existingNoteReferenceProofs
136792
136804
  }
136793
136805
  }
136794
136806
  }
136795
- function validateCompareApplyPlan(value) {
136807
+ function validateCompareApplyPlan(value, baseBody = []) {
136796
136808
  const problems = [];
136797
136809
  if (!isRecord9(value))
136798
136810
  return ["apply plan: not an object"];
@@ -136819,8 +136831,10 @@ function validateCompareApplyPlan(value) {
136819
136831
  const dispositions = validatePlanDispositions(value, value.steps, problems);
136820
136832
  const allowedNoteReferences = noteReferenceCandidates.filter(({ family }) => dispositions.get(family) === "supported");
136821
136833
  if (Array.isArray(value.bodyOperations)) {
136834
+ const baseRunByBlockId = new Map(baseBody.map((entry) => [entry.blockId, entry.runXml]));
136822
136835
  value.bodyOperations.forEach((operation, index) => {
136823
- validateBodyOperation(operation, `bodyOperations[${index}]`, problems, { allowedNoteReferences });
136836
+ const baseRunXml = isRecord9(operation) && isNonEmptyString2(operation.blockId) ? baseRunByBlockId.get(operation.blockId) : undefined;
136837
+ validateBodyOperation(operation, `bodyOperations[${index}]`, problems, { allowedNoteReferences, baseRunXml });
136824
136838
  });
136825
136839
  }
136826
136840
  validateBodyNoteReplay(value, problems, allowedNoteReferences);
@@ -138929,14 +138943,18 @@ function attachExactTargetRevisionReplayToStories(groups, base2, target, matchRe
138929
138943
  });
138930
138944
  return { groups: replayGroups, coveredBaseAnnotations, coveredTargetAnnotations, changedTrackedXmlReplayed };
138931
138945
  }
138932
- function firstUnsafeReplayReason(operations, noteLifecycle = [], targetStories = []) {
138946
+ function firstUnsafeReplayReason(operations, noteLifecycle = [], targetStories = [], baseBody = []) {
138933
138947
  const createdNoteReferences = noteLifecycle.filter((operation) => operation.kind === "create-note-definition" || operation.kind === "create-note-story").map((operation) => ({ family: operation.family, noteId: operation.noteId }));
138934
138948
  const retainedNoteReferences = targetStories.flatMap((story) => (story.family === "footnotes" || story.family === "endnotes") && story.noteId ? [{ family: story.family, noteId: story.noteId }] : []);
138935
138949
  const allowedNoteReferences = [...createdNoteReferences, ...retainedNoteReferences];
138950
+ const baseRunByBlockId = new Map(baseBody.map((entry) => [entry.blockId, entry.runXml]));
138936
138951
  for (const operation of operations) {
138937
138952
  if (operation.kind === "delete")
138938
138953
  continue;
138939
- const result = validateCompareReplayPayload(operation, { allowedNoteReferences });
138954
+ const result = validateCompareReplayPayload(operation, {
138955
+ allowedNoteReferences,
138956
+ ...operation.kind === "edit" || operation.kind === "formatEdit" ? { baseRunXml: baseRunByBlockId.get(operation.blockId) } : {}
138957
+ });
138940
138958
  if (!result.ok)
138941
138959
  return result.reason;
138942
138960
  }
@@ -139111,7 +139129,7 @@ function planCompare(base2, target) {
139111
139129
  semanticAnalysis = markFamilyLossy(semanticAnalysis, hazard.family, hazard.reason);
139112
139130
  }
139113
139131
  const storyPackageOperations = buildStoryPackageOperations(base2, target, semanticAnalysis, bodyOperations);
139114
- const unsafeBodyReason = firstUnsafeReplayReason(bodyOperations, storyPackageOperations, target.stories);
139132
+ const unsafeBodyReason = firstUnsafeReplayReason(bodyOperations, storyPackageOperations, target.stories, base2.body);
139115
139133
  if (unsafeBodyReason) {
139116
139134
  semanticAnalysis = markFamilyLossy(semanticAnalysis, "body", `body target structure cannot be replayed safely: ${unsafeBodyReason}`);
139117
139135
  const bodyDependentNoteFamilies = new Set(storyPackageOperations.filter((operation) => operation.bodyReplayOwnsReference).map((operation) => operation.family));
@@ -211007,7 +211025,7 @@ function isCaretSlotAtomic(piece, input) {
211007
211025
  return input.space === "tracked" || !piece.containerStack.some((scope) => scope.deleted);
211008
211026
  }
211009
211027
  function planCut(pieces, levelStart, input, rootPieces, chain = []) {
211010
- const { offset, space } = input;
211028
+ const { offset } = input;
211011
211029
  const strict = pieces.find((piece) => pieceStart(piece, input, rootPieces) < offset && offset < pieceEnd(piece, input, rootPieces));
211012
211030
  if (strict) {
211013
211031
  if (strict.kind === "text") {
@@ -211061,7 +211079,7 @@ function planCut(pieces, levelStart, input, rootPieces, chain = []) {
211061
211079
  const start = pieceStart(piece, input, rootPieces);
211062
211080
  const end = pieceEnd(piece, input, rootPieces);
211063
211081
  const width = end - start;
211064
- const toHead = width > 0 ? end <= offset : end < offset || end === offset && !zeroWidthPrefersTail(piece, space);
211082
+ const toHead = width > 0 ? end <= offset : end < offset || end === offset && !zeroWidthPrefersTail(piece, input);
211065
211083
  if (!toHead)
211066
211084
  break;
211067
211085
  boundaryChar = piece.charEnd;
@@ -211080,9 +211098,12 @@ function planCut(pieces, levelStart, input, rootPieces, chain = []) {
211080
211098
  }
211081
211099
  return { kind: "boundary", boundaryChar, chain };
211082
211100
  }
211083
- function zeroWidthPrefersTail(piece, space) {
211101
+ function zeroWidthPrefersTail(piece, input) {
211084
211102
  if (piece.kind === "tracked")
211085
- return piece.removesVisible && space === "visible";
211103
+ return piece.removesVisible && input.space === "visible";
211104
+ if (input.fieldBeginToTail && piece.kind === "container" && piece.containerKind === "complexField") {
211105
+ return /\bfldCharType\s*=\s*["']begin["']/.test(piece.rawXml);
211106
+ }
211086
211107
  if (piece.kind === "marker") {
211087
211108
  return piece.role === "range-start" || piece.markerKind === "fieldBegin";
211088
211109
  }
@@ -214749,7 +214770,7 @@ function isImmediatelyWrappedInsertedSuccessor(bytes, currentEnd, successor) {
214749
214770
  return close.test(TD52.decode(bytes.subarray(successor.byteEnd)));
214750
214771
  }
214751
214772
  function runParagraphRangeCollapseCommit(input) {
214752
- const op = input.op;
214773
+ let op = input.op;
214753
214774
  const { state } = input;
214754
214775
  if (input.options.expectedPackageRevision && input.options.expectedPackageRevision !== state.packageRevision) {
214755
214776
  return rejected8(input.txId, "base-revision-drift");
@@ -214769,13 +214790,17 @@ function runParagraphRangeCollapseCommit(input) {
214769
214790
  return rejected8(input.txId, "text-range-cross-paragraph-tracked-coordinate-unsupported");
214770
214791
  }
214771
214792
  const deleteFullBlocks = changeMode === "direct" && op.deleteFinalParagraphMark === true;
214772
- if (op.on.startBlockId === op.on.endBlockId && !deleteFullBlocks)
214793
+ const sameBlockRequested = op.on.startBlockId === op.on.endBlockId;
214794
+ if (sameBlockRequested && !deleteFullBlocks && (changeMode !== "direct" || op.replacementText !== undefined)) {
214773
214795
  return rejected8(input.txId, "invalid-range");
214796
+ }
214774
214797
  const index = paragraphIndexForStory(state, op.on.storyId);
214775
- const start = index?.byParaId(op.on.startBlockId) ?? null;
214776
- const end = index?.byParaId(op.on.endBlockId) ?? null;
214777
- if (!index || !start || !end)
214798
+ const initialStart = index?.byParaId(op.on.startBlockId) ?? null;
214799
+ const initialEnd = index?.byParaId(op.on.endBlockId) ?? null;
214800
+ if (!index || !initialStart || !initialEnd)
214778
214801
  return rejected8(input.txId, "paragraph-target-not-found");
214802
+ let start = initialStart;
214803
+ let end = initialEnd;
214779
214804
  if (start.ordinal > end.ordinal || start.partUri !== end.partUri || start.storyId !== end.storyId) {
214780
214805
  return rejected8(input.txId, "invalid-range");
214781
214806
  }
@@ -214816,7 +214841,7 @@ function runParagraphRangeCollapseCommit(input) {
214816
214841
  return rejected8(input.txId, fullBlockFailure);
214817
214842
  }
214818
214843
  const residentFieldCatalog = peekFieldCatalogForStory(state, op.on.storyId);
214819
- const fieldCatalog = residentFieldCatalog ?? (() => {
214844
+ let fieldCatalog = residentFieldCatalog ?? (() => {
214820
214845
  const fieldCatalogBytes = bytes.subarray(0, end.byteEnd);
214821
214846
  recordSDTxPerf("rangeIntegrityFieldCatalogBytes", fieldCatalogBytes.byteLength);
214822
214847
  return buildFieldCatalog({
@@ -214827,7 +214852,10 @@ function runParagraphRangeCollapseCommit(input) {
214827
214852
  })();
214828
214853
  if (residentFieldCatalog)
214829
214854
  recordSDTxPerf("rangeIntegrityFieldCatalogBytes", 0);
214830
- const rangeIntegrity = validateParagraphRangeIntegrity({
214855
+ if (sameBlockRequested && !deleteFullBlocks && !fieldCatalog.fields.some((field) => field.byteStart < op.on.endByte && (!field.complete || field.byteEnd > op.on.startByte)))
214856
+ return rejected8(input.txId, "invalid-range");
214857
+ let fieldDeletionExpanded = false;
214858
+ let rangeIntegrity = validateParagraphRangeIntegrity({
214831
214859
  bytes,
214832
214860
  index,
214833
214861
  fieldCatalog,
@@ -214837,6 +214865,30 @@ function runParagraphRangeCollapseCommit(input) {
214837
214865
  endOffset: op.on.endOffset,
214838
214866
  ...deleteFullBlocks ? { removedByteRange: { startByte: start.byteStart, endByte: end.byteEnd } } : {}
214839
214867
  });
214868
+ if (changeMode === "direct" && !deleteFullBlocks && op.replacementText === undefined && !op.startObjectBoundary && !op.endObjectBoundary && !rangeIntegrity.ok && (rangeIntegrity.reason === "partial-field" || rangeIntegrity.reason === "incomplete-field")) {
214869
+ if (rangeIntegrity.reason === "incomplete-field" && !residentFieldCatalog) {
214870
+ fieldCatalog = buildFieldCatalog({ bytes, storyId: op.on.storyId, partUri: start.partUri });
214871
+ }
214872
+ const expanded = expandDirectFieldDeletionRange(bytes, index.entries, op, fieldCatalog.fields);
214873
+ if (expanded) {
214874
+ fieldDeletionExpanded = true;
214875
+ op = expanded.op;
214876
+ start = expanded.start;
214877
+ end = expanded.end;
214878
+ const expandedStructure = validateRangeCollapseStructure(bytes, index.entries, start, end, changeMode, undefined, undefined, { allowSectionBoundary: true });
214879
+ if (expandedStructure)
214880
+ return rejected8(input.txId, expandedStructure);
214881
+ rangeIntegrity = validateParagraphRangeIntegrity({
214882
+ bytes,
214883
+ index,
214884
+ fieldCatalog,
214885
+ startBlockId: op.on.startBlockId,
214886
+ startOffset: op.on.startOffset,
214887
+ endBlockId: op.on.endBlockId,
214888
+ endOffset: op.on.endOffset
214889
+ });
214890
+ }
214891
+ }
214840
214892
  if (!rangeIntegrity.ok) {
214841
214893
  if (rangeIntegrity.reason === "partial-bookmark")
214842
214894
  return rejected8(input.txId, "text-range-in-bookmark");
@@ -214862,6 +214914,7 @@ function runParagraphRangeCollapseCommit(input) {
214862
214914
  startObjectBoundary: op.startObjectBoundary,
214863
214915
  endObjectBoundary: op.endObjectBoundary,
214864
214916
  removedBookmarkNames: rangeIntegrity.removedBookmarkNames,
214917
+ fieldBeginToTail: fieldDeletionExpanded,
214865
214918
  allocateWId: () => allocateRevisionWId(state),
214866
214919
  collapseSectionBoundaries: op.replacementText === undefined && !deleteFullBlocks,
214867
214920
  ...deleteFullBlocks ? {
@@ -214903,6 +214956,70 @@ function runParagraphRangeCollapseCommit(input) {
214903
214956
  rebuildSections: contribution.rebuildSections
214904
214957
  });
214905
214958
  }
214959
+ function expandDirectFieldDeletionRange(bytes, entries, op, fields) {
214960
+ const startEntry = entries.find((entry) => entry.blockId === op.on.startBlockId);
214961
+ const endEntry = entries.find((entry) => entry.blockId === op.on.endBlockId);
214962
+ if (!startEntry || !endEntry)
214963
+ return null;
214964
+ const pointAtByte = (byte) => {
214965
+ const entry = entries.find((candidate2) => byte >= candidate2.byteStart && byte <= candidate2.byteEnd);
214966
+ if (!entry)
214967
+ return null;
214968
+ const model = parseParagraphInlineMap(decodeByteRange(bytes, entry.byteStart, entry.byteEnd));
214969
+ return { entry, offset: resolveParagraphVisibleOffsetAtByte(model, byte - entry.byteStart) };
214970
+ };
214971
+ const compare = (a, b) => a.entry.ordinal - b.entry.ordinal || a.offset - b.offset;
214972
+ let first = { entry: startEntry, offset: op.on.startOffset };
214973
+ let last = { entry: endEntry, offset: op.on.endOffset };
214974
+ let changed = false;
214975
+ for (let pass2 = 0;pass2 < fields.length; pass2++) {
214976
+ let widened = false;
214977
+ for (const field of fields) {
214978
+ if (!field.complete)
214979
+ continue;
214980
+ const fieldStart = pointAtByte(field.byteStart);
214981
+ const fieldEnd = pointAtByte(field.byteEnd);
214982
+ if (!fieldStart || !fieldEnd)
214983
+ return null;
214984
+ const touches = compare(fieldStart, last) < 0 && compare(first, fieldEnd) < 0;
214985
+ if (!touches)
214986
+ continue;
214987
+ if (compare(fieldStart, first) < 0) {
214988
+ first = fieldStart;
214989
+ widened = true;
214990
+ }
214991
+ if (compare(last, fieldEnd) < 0) {
214992
+ last = fieldEnd;
214993
+ widened = true;
214994
+ }
214995
+ }
214996
+ if (!widened)
214997
+ break;
214998
+ changed = true;
214999
+ }
215000
+ if (!changed)
215001
+ return null;
215002
+ const startByte = buildParagraphOffsetMap(bytes, first.entry.byteStart, first.entry.byteEnd).charToByte(first.offset);
215003
+ const endByte = buildParagraphOffsetMap(bytes, last.entry.byteStart, last.entry.byteEnd).charToByte(last.offset);
215004
+ if (startByte == null || endByte == null)
215005
+ return null;
215006
+ return {
215007
+ op: {
215008
+ ...op,
215009
+ on: {
215010
+ ...op.on,
215011
+ startBlockId: first.entry.blockId,
215012
+ startOffset: first.offset,
215013
+ startByte,
215014
+ endBlockId: last.entry.blockId,
215015
+ endOffset: last.offset,
215016
+ endByte
215017
+ }
215018
+ },
215019
+ start: first.entry,
215020
+ end: last.entry
215021
+ };
215022
+ }
214906
215023
  function planDirectParagraphRangeRewrite(input) {
214907
215024
  const { state, storyId, indexEntries, start, end, startOffset, endOffset } = input;
214908
215025
  const bytes = state.packageBytes.get(start.partUri);
@@ -214929,7 +215046,8 @@ function planDirectParagraphRangeRewrite(input) {
214929
215046
  offset: startSliceOffset,
214930
215047
  space: "visible",
214931
215048
  allocateWId: input.allocateWId,
214932
- atomicObjectsAsCaretSlots: input.startObjectBoundary != null
215049
+ atomicObjectsAsCaretSlots: input.startObjectBoundary != null,
215050
+ fieldBeginToTail: input.fieldBeginToTail
214933
215051
  });
214934
215052
  if (!startSlice.ok)
214935
215053
  return startSlice;
@@ -214979,7 +215097,7 @@ function planDirectParagraphRangeRewrite(input) {
214979
215097
  }
214980
215098
  }
214981
215099
  const coveredEntries = indexEntries.filter((entry) => entry.ordinal >= start.ordinal && entry.ordinal <= end.ordinal);
214982
- const removedVisibleChars = coveredEntries.reduce((sum, entry) => {
215100
+ const removedVisibleChars = start.ordinal === end.ordinal ? endOffset - startOffset : coveredEntries.reduce((sum, entry) => {
214983
215101
  if (entry.ordinal === start.ordinal)
214984
215102
  return sum + (entry.textLength - startOffset);
214985
215103
  if (entry.ordinal === end.ordinal)
@@ -221499,7 +221617,7 @@ function runCompareApplyCommit(input) {
221499
221617
  for (const group of rawGroups) {
221500
221618
  const bodySteps = [];
221501
221619
  for (const step2 of group.bodySteps) {
221502
- const normalized = normalizeCompareBodyStep(step2, rawSectionReplaySteps, rawReferenceReplaySteps, storyPartUriFromStoryId2(group.storyId) === DOCUMENT_PART_URI4 ? allowedNoteReferences : []);
221620
+ const normalized = normalizeCompareBodyStep(step2, rawSectionReplaySteps, rawReferenceReplaySteps, storyPartUriFromStoryId2(group.storyId) === DOCUMENT_PART_URI4 ? allowedNoteReferences : [], state, group.storyId);
221503
221621
  if (!normalized)
221504
221622
  return rejected14(txId, "unsupported-context");
221505
221623
  bodySteps.push(normalized.operationId ? normalized : { ...normalized, operationId: `compare:${encodeURIComponent(group.storyId)}:${executableOperationOrdinal}` });
@@ -222231,14 +222349,15 @@ function isBodyReplayNoteReferenceRemoval(state, storyId, step2, operations) {
222231
222349
  return liveBodyNoteReferences(state, storyId, operation.family, noteIds)?.some((reference) => reference.blockId === step2.blockId && bodyStepRemovesNoteReference(step2, reference.family, reference.noteId)) === true;
222232
222350
  });
222233
222351
  }
222234
- function normalizeCompareBodyStep(step2, sectionSteps, referenceSteps, allowedNoteReferences) {
222352
+ function normalizeCompareBodyStep(step2, sectionSteps, referenceSteps, allowedNoteReferences, state, storyId) {
222235
222353
  if (step2.kind === "delete") {
222236
222354
  return step2.targetRevisionReplay === undefined || step2.targetRevisionReplay.structuralAction === "delete" ? step2 : null;
222237
222355
  }
222238
- if (!validateCompareBodyReplayPayload(step2, sectionSteps, referenceSteps, allowedNoteReferences, step2.text))
222356
+ const baseRunXml = step2.kind === "edit" || step2.kind === "formatEdit" ? liveCompareBodyRunXml(state, storyId, step2.blockId) : undefined;
222357
+ if (!validateCompareBodyReplayPayload(step2, sectionSteps, referenceSteps, allowedNoteReferences, step2.text, baseRunXml))
222239
222358
  return null;
222240
222359
  const targetParagraphPropertiesXml = step2.targetParagraphPropertiesXml === undefined ? undefined : canonicalizeCompareBodyParagraphPropertiesXml(step2.targetParagraphPropertiesXml, sectionSteps);
222241
- const targetRunXml = step2.targetRunXml === undefined ? undefined : canonicalizeCompareBodyRunXml(step2.targetRunXml, referenceSteps);
222360
+ const targetRunXml = step2.targetRunXml === undefined ? undefined : (step2.targetRunXml.includes("<w:drawing") || step2.targetRunXml.includes("<w:fldSimple")) && baseRunXml && referenceSteps.length === 0 ? step2.targetRunXml : canonicalizeCompareBodyRunXml(step2.targetRunXml, referenceSteps);
222242
222361
  if (targetParagraphPropertiesXml === null || targetRunXml === null)
222243
222362
  return null;
222244
222363
  const normalized = {
@@ -222251,7 +222370,12 @@ function normalizeCompareBodyStep(step2, sectionSteps, referenceSteps, allowedNo
222251
222370
  targetRunXml,
222252
222371
  replayDependencies: "replayDependencies" in step2 ? step2.replayDependencies : undefined,
222253
222372
  targetRevisionReplay: "targetRevisionReplay" in step2 ? step2.targetRevisionReplay : undefined
222254
- }, sectionSteps, referenceSteps, allowedNoteReferences, step2.text) ? normalized : null;
222373
+ }, sectionSteps, referenceSteps, allowedNoteReferences, step2.text, baseRunXml) ? normalized : null;
222374
+ }
222375
+ function liveCompareBodyRunXml(state, storyId, blockId) {
222376
+ const entry = getStoryParagraphIndexFromState(state, storyId)?.byParaId(blockId);
222377
+ const bytes = state.packageBytes.get(storyPartUriFromStoryId2(storyId));
222378
+ return entry && bytes ? extractCompareParagraphRunXml(TD59.decode(bytes.subarray(entry.byteStart, entry.byteEnd))) : undefined;
222255
222379
  }
222256
222380
  function noteRemovalsBindLiveReferences(state, groups, operations) {
222257
222381
  const mainStoryId = state.mainStoryId;
@@ -222379,7 +222503,7 @@ function sourceProofBindsReference(proof, family) {
222379
222503
  const childXml = wrappedSource.slice(child.start, child.end);
222380
222504
  return isValidNoteReferenceReplayRunXml(childXml, family, proof.noteId, child.namespaceBindings) && replayCarrierXmlEquals(childXml, proof.referenceRunXml);
222381
222505
  }
222382
- function validateCompareBodyReplayPayload(payload, sectionSteps, referenceSteps, allowedNoteReferences, expectedCurrentText) {
222506
+ function validateCompareBodyReplayPayload(payload, sectionSteps, referenceSteps, allowedNoteReferences, expectedCurrentText, baseRunXml) {
222383
222507
  if (payload.targetRunXml !== undefined && expectedCurrentText !== undefined && projectCompareReplayCurrentText(payload.targetRunXml) !== expectedCurrentText.replace(/\uFFFC/g, "")) {
222384
222508
  return false;
222385
222509
  }
@@ -222387,7 +222511,7 @@ function validateCompareBodyReplayPayload(payload, sectionSteps, referenceSteps,
222387
222511
  if (targetParagraphPropertiesXml === null)
222388
222512
  return false;
222389
222513
  const targetRunXml = payload.targetRunXml === undefined ? undefined : stripProtectedReferenceTokens(payload.targetRunXml, referenceSteps);
222390
- return targetRunXml !== null && validateCompareReplayPayload({ ...payload, targetParagraphPropertiesXml, targetRunXml }, { allowedNoteReferences }).ok;
222514
+ return targetRunXml !== null && validateCompareReplayPayload({ ...payload, targetParagraphPropertiesXml, targetRunXml }, { allowedNoteReferences, baseRunXml, allowNamespaceDeclarationDifference: baseRunXml !== undefined }).ok;
222391
222515
  }
222392
222516
  function stripProtectedSectionTokens(xml, sectionSteps) {
222393
222517
  const tokens = collectProtectedSectionTokens(xml, sectionSteps);
@@ -223405,7 +223529,10 @@ function runCompareBodyEditCommit(input, storyId, step2, changeMode, options, pu
223405
223529
  }
223406
223530
  const oldRunsDel = oldRunsRaw.replace(/<((?:[\w.-]+:)?)t(\b[^>]*)>/g, "<$1delText$2>").replace(/<\/((?:[\w.-]+:)?)t>/g, "</$1delText>");
223407
223531
  const hunkStamps = makeCompareHunkStampSource(stamps, input);
223408
- const protectedRuns = renderTrackedRunsWithProtectedReferences(oldRunsRaw, newRuns, protectedReferenceSteps, hunkStamps.next, paragraphWrapper.wordprocessingPrefix);
223532
+ const retainedCarrier = newRuns.includes("<w:drawing") || newRuns.includes("<w:fldSimple") && protectedReferenceSteps.length === 0;
223533
+ const protectedRuns = retainedCarrier ? protectedReferenceSteps.length === 0 ? renderTrackedRunsWithRetainedCarrier(oldRunsRaw, newRuns, hunkStamps.next, paragraphWrapper.wordprocessingPrefix, bytes, entry.byteStart, entry.byteEnd) : null : renderTrackedRunsWithProtectedReferences(oldRunsRaw, newRuns, protectedReferenceSteps, hunkStamps.next, paragraphWrapper.wordprocessingPrefix);
223534
+ if (retainedCarrier && !protectedRuns)
223535
+ return rejected14(txId, "unsupported-context");
223409
223536
  if (!protectedRuns && stableBookmarkSteps?.length)
223410
223537
  return rejected14(txId, "unsupported-context");
223411
223538
  let delXml;
@@ -223456,6 +223583,51 @@ function runCompareBodyEditCommit(input, storyId, step2, changeMode, options, pu
223456
223583
  targetBlockIds: [step2.blockId]
223457
223584
  });
223458
223585
  }
223586
+ function renderTrackedRunsWithRetainedCarrier(oldRuns, targetRuns, getStamp, prefix, documentBytes, paragraphStartByte, paragraphEndByte) {
223587
+ const carrier = /<w:r\b[^>]*><w:drawing\b[^>]*>[\s\S]*?<\/w:drawing><\/w:r>|<w:fldSimple\b[^>]*>[\s\S]*?<\/w:fldSimple>/g;
223588
+ const oldMatches = [...oldRuns.matchAll(carrier)];
223589
+ const targetMatches = [...targetRuns.matchAll(carrier)];
223590
+ const withoutNamespaceDeclarations = (xml) => xml.replace(/\s+xmlns(?::[\w.-]+)?=(?:"[^"]*"|'[^']*')/g, "");
223591
+ if (oldMatches.length !== 1 || targetMatches.length !== 1 || withoutNamespaceDeclarations(oldMatches[0][0]) !== withoutNamespaceDeclarations(targetMatches[0][0]))
223592
+ return null;
223593
+ if (!sameTrackedCarrierNamespaceBindings(documentBytes, paragraphStartByte, paragraphEndByte, targetRuns))
223594
+ return null;
223595
+ const oldIndex = oldMatches[0].index;
223596
+ const targetIndex = targetMatches[0].index;
223597
+ const oldSegments = [oldRuns.slice(0, oldIndex), oldRuns.slice(oldIndex + oldMatches[0][0].length)];
223598
+ const targetSegments = [targetRuns.slice(0, targetIndex), targetRuns.slice(targetIndex + targetMatches[0][0].length)];
223599
+ const simpleRuns = (xml) => xml.replace(/\s*<w:r(?:\s[^>]*)?><w:t(?:\s[^>]*)?>[^<]*<\/w:t><\/w:r>\s*/g, "").trim() === "";
223600
+ if (![...oldSegments, ...targetSegments].every(simpleRuns))
223601
+ return null;
223602
+ const trackedSegment = (oldXml, targetXml) => {
223603
+ if (withoutNamespaceDeclarations(oldXml) === withoutNamespaceDeclarations(targetXml))
223604
+ return oldXml;
223605
+ const wordLevel = renderWordLevelTrackedRunSegment(oldXml, targetXml, getStamp, prefix);
223606
+ if (wordLevel)
223607
+ return wordLevel.xml;
223608
+ const deleted = oldXml.replace(/<w:t(\b[^>]*)>/g, "<w:delText$1>").replace(/<\/w:t>/g, "</w:delText>");
223609
+ const pair = getStamp();
223610
+ return (deleted ? wrapTracked("del", deleted, pair.del, "rsidDel", prefix) : "") + (targetXml ? wrapTracked("ins", targetXml, pair.ins, "rsidR", prefix) : "");
223611
+ };
223612
+ return { xml: trackedSegment(oldSegments[0], targetSegments[0]) + oldMatches[0][0] + trackedSegment(oldSegments[1], targetSegments[1]) };
223613
+ }
223614
+ function sameTrackedCarrierNamespaceBindings(documentBytes, paragraphStartByte, paragraphEndByte, targetRuns) {
223615
+ const documentXml = TD59.decode(documentBytes);
223616
+ const paragraphStart = TD59.decode(documentBytes.subarray(0, paragraphStartByte)).length;
223617
+ const paragraphEnd = paragraphStart + TD59.decode(documentBytes.subarray(paragraphStartByte, paragraphEndByte)).length;
223618
+ const current = collectXmlElementRanges(documentXml);
223619
+ const target = collectXmlElementRanges(targetRuns, { fragment: true });
223620
+ if (current.errors.length > 0 || target.errors.length > 0)
223621
+ return false;
223622
+ const carrierName = targetRuns.includes("<w:drawing") ? "drawing" : "fldSimple";
223623
+ const currentCarriers = current.ranges.filter((range) => range.tag.namespaceUri === NS_W && range.tag.localName === carrierName && range.start >= paragraphStart && range.end <= paragraphEnd);
223624
+ const targetCarriers = target.ranges.filter((range) => range.tag.namespaceUri === NS_W && range.tag.localName === carrierName);
223625
+ if (currentCarriers.length !== 1 || targetCarriers.length !== 1)
223626
+ return false;
223627
+ const targetFragment = targetRuns.slice(targetCarriers[0].start, targetCarriers[0].end);
223628
+ const prefixes = new Set([...targetFragment.matchAll(/(?:<\/?|\s)([A-Za-z_][\w.-]*):[A-Za-z_][\w.-]*(?=[\s=/>])/g)].map((match) => match[1]));
223629
+ return [...prefixes].every((usedPrefix) => currentCarriers[0].namespaceBindings[usedPrefix] === targetCarriers[0].namespaceBindings[usedPrefix]);
223630
+ }
223459
223631
  function renderTrackedRunsWithProtectedReferences(oldRuns, targetRuns, referenceSteps, getStamp, prefix) {
223460
223632
  const oldTokens = collectProtectedReferenceTokens(oldRuns, referenceSteps);
223461
223633
  const targetTokens = collectProtectedReferenceTokens(targetRuns, referenceSteps);
@@ -224711,7 +224883,7 @@ function availableNamespacePrefix(namespaceBindings, preferred) {
224711
224883
  }
224712
224884
  function runPackageRewriteStep(input, op, options, pushHistory, affectedStoryIds = [], headerFooterRewriteKinds = new Map) {
224713
224885
  const { state, txId } = input;
224714
- if (op.family !== "comments" && op.family !== "styles" && op.family !== "numbering" && op.family !== "header-footer-slots" && op.family !== "header-footer-parts" && op.family !== "tables" && op.family !== "package-graph") {
224886
+ if (op.family !== "comments" && op.family !== "styles" && op.family !== "numbering" && op.family !== "settings" && op.family !== "header-footer-slots" && op.family !== "header-footer-parts" && op.family !== "tables" && op.family !== "package-graph") {
224715
224887
  return rejected14(txId, "unsupported-context");
224716
224888
  }
224717
224889
  if (op.family === "comments" && ![
@@ -224737,6 +224909,8 @@ function runPackageRewriteStep(input, op, options, pushHistory, affectedStoryIds
224737
224909
  if ((op.family === "header-footer-slots" || op.family === "tables") && op.partUri !== DOCUMENT_PART_URI4) {
224738
224910
  return rejected14(txId, "unsupported-context");
224739
224911
  }
224912
+ if (op.family === "settings" && op.partUri !== "/word/settings.xml")
224913
+ return rejected14(txId, "unsupported-context");
224740
224914
  const currentBytes = state.packageBytes.get(op.partUri);
224741
224915
  if (op.kind === "create" && (currentBytes || !op.nextBytes || !op.contentType))
224742
224916
  return rejected14(txId, "unsupported-context");
@@ -226440,12 +226614,14 @@ function validatePackageRewritePreconditions(state, rewrites, headerFooterRewrit
226440
226614
  if (!validateMetadataPackageRewrites(state, rewrites, changeMode))
226441
226615
  return "unsupported-context";
226442
226616
  for (const rewrite of rewrites) {
226443
- if (rewrite.family !== "comments" && rewrite.family !== "styles" && rewrite.family !== "numbering" && rewrite.family !== "header-footer-slots" && rewrite.family !== "header-footer-parts" && rewrite.family !== "tables" && rewrite.family !== "package-graph") {
226617
+ if (rewrite.family !== "comments" && rewrite.family !== "styles" && rewrite.family !== "numbering" && rewrite.family !== "settings" && rewrite.family !== "header-footer-slots" && rewrite.family !== "header-footer-parts" && rewrite.family !== "tables" && rewrite.family !== "package-graph") {
226444
226618
  return "unsupported-context";
226445
226619
  }
226446
226620
  if ((rewrite.family === "header-footer-slots" || rewrite.family === "tables") && rewrite.partUri !== DOCUMENT_PART_URI4) {
226447
226621
  return "unsupported-context";
226448
226622
  }
226623
+ if (rewrite.family === "settings" && rewrite.partUri !== "/word/settings.xml")
226624
+ return "unsupported-context";
226449
226625
  if (rewrite.family === "comments" && ![
226450
226626
  "/word/comments.xml",
226451
226627
  "/word/commentsExtended.xml",
@@ -226558,6 +226734,10 @@ function validateRelationshipBackedBodyRewrites(state, changeMode, rewrites, pac
226558
226734
  if (!currentDocument || !currentContentTypes || !nextContentTypes || !currentEmbedIds || !nextEmbedIds || currentRelationshipsBytes && !currentRelationships || !nextRelationships || currentContentTypes.rootSignature !== nextContentTypes.rootSignature || currentRelationships && currentRelationships.rootSignature !== nextRelationships.rootSignature) {
226559
226735
  return false;
226560
226736
  }
226737
+ if (byUri.size === 3 && relationships.kind === "modify" && currentRelationshipsBytes && bytesEqual11(currentRelationshipsBytes, relationships.nextBytes) && bytesEqual11(packageBytesAfterHeaderFooterRewrites(state, CONTENT_TYPES_PART_URI7, packageRewrites), contentTypes.nextBytes) && currentEmbedIds.join(`
226738
+ `) === nextEmbedIds.join(`
226739
+ `) && sameRetainedBodyMarkup(currentDocument, document2.nextBytes))
226740
+ return true;
226561
226741
  const currentRelationshipRecords = currentRelationships?.records ?? new Map;
226562
226742
  const addedEmbeds = addedEmbeddedImageRelationshipIds({
226563
226743
  currentEmbedIds,
@@ -226639,6 +226819,81 @@ function validateRelationshipBackedBodyRewrites(state, changeMode, rewrites, pac
226639
226819
  }
226640
226820
  return true;
226641
226821
  }
226822
+ function sameRetainedBodyMarkup(currentBytes, nextBytes) {
226823
+ const currentXml3 = TD59.decode(currentBytes);
226824
+ const nextXml = TD59.decode(nextBytes);
226825
+ const outsideBody = (xml) => {
226826
+ const parsed = collectXmlElementRanges(xml);
226827
+ if (parsed.errors.length > 0)
226828
+ return null;
226829
+ const bodies = parsed.ranges.filter((range) => range.tag.namespaceUri === NS_W && range.tag.localName === "body");
226830
+ if (bodies.length !== 1)
226831
+ return null;
226832
+ return [xml.slice(0, bodies[0].openEnd), xml.slice(bodies[0].closeStart)];
226833
+ };
226834
+ const currentOutside = outsideBody(currentXml3);
226835
+ const nextOutside = outsideBody(nextXml);
226836
+ if (!currentOutside || !nextOutside || currentOutside[0] !== nextOutside[0] || currentOutside[1] !== nextOutside[1])
226837
+ return false;
226838
+ const protectedNames = new Set([
226839
+ "drawing",
226840
+ "pict",
226841
+ "object",
226842
+ "fldSimple",
226843
+ "fldChar",
226844
+ "instrText",
226845
+ "commentReference",
226846
+ "commentRangeStart",
226847
+ "commentRangeEnd",
226848
+ "permStart",
226849
+ "permEnd",
226850
+ "sdt",
226851
+ "customXml",
226852
+ "oMath",
226853
+ "oMathPara",
226854
+ "footnoteReference",
226855
+ "endnoteReference",
226856
+ "ins",
226857
+ "del",
226858
+ "moveFrom",
226859
+ "moveTo",
226860
+ "sectPr",
226861
+ "hyperlink",
226862
+ "bookmarkStart",
226863
+ "bookmarkEnd"
226864
+ ]);
226865
+ const signature = (bytes) => {
226866
+ const xml = TD59.decode(bytes);
226867
+ const parsed = collectXmlElementRanges(xml);
226868
+ if (parsed.errors.length > 0)
226869
+ return null;
226870
+ if (parsed.ranges.some((range) => range.tag.namespaceUri === NS_W && (range.tag.localName === "altChunk" || range.tag.localName === "subDoc")))
226871
+ return null;
226872
+ let drawings = 0;
226873
+ let carriers = 0;
226874
+ const fragments = [];
226875
+ const refs = [];
226876
+ for (const range of parsed.ranges) {
226877
+ if (range.tag.namespaceUri === NS_W && protectedNames.has(range.tag.localName)) {
226878
+ const fragment2 = xml.slice(range.start, range.end);
226879
+ const prefixes = [...new Set([...fragment2.matchAll(/(?:<\/?|\s)([A-Za-z_][\w.-]*):[A-Za-z_][\w.-]*(?=[\s=/>])/g)].map((match) => match[1]))].sort();
226880
+ fragments.push(JSON.stringify([fragment2, prefixes.map((prefix) => [prefix, range.namespaceBindings[prefix]])]));
226881
+ if (range.tag.localName === "drawing")
226882
+ drawings += 1;
226883
+ if (range.tag.localName !== "sectPr")
226884
+ carriers += 1;
226885
+ }
226886
+ for (const attribute of range.tag.attributes) {
226887
+ if (isRelationshipNamespace(attribute.namespaceUri))
226888
+ refs.push(`${attribute.localName}:${attribute.value}`);
226889
+ }
226890
+ }
226891
+ return { fragments, refs, drawings, carriers };
226892
+ };
226893
+ const current = signature(currentBytes);
226894
+ const next = signature(nextBytes);
226895
+ return current !== null && next !== null && current.carriers > 0 && current.drawings === next.drawings && JSON.stringify(current.fragments) === JSON.stringify(next.fragments) && JSON.stringify(current.refs) === JSON.stringify(next.refs);
226896
+ }
226642
226897
  function packageBytesAfterHeaderFooterRewrites(state, partUri, rewrites) {
226643
226898
  let bytes = state.packageBytes.get(partUri) ?? null;
226644
226899
  for (const rewrite of rewrites) {
@@ -291591,6 +291846,9 @@ function preflightSelectionRangeCollapse(deps, plan) {
291591
291846
  endOffset: plan.endOffset
291592
291847
  });
291593
291848
  if (!rangeIntegrity.ok) {
291849
+ if (deps.allowAtomicFieldDelete && deps.changeMode === "direct" && (rangeIntegrity.reason === "partial-field" || rangeIntegrity.reason === "incomplete-field")) {
291850
+ return null;
291851
+ }
291594
291852
  if (rangeIntegrity.reason === "partial-bookmark") {
291595
291853
  return failure3("INVALID_CONTEXT", "text-range-in-bookmark: selection must preserve both bookmark markers.");
291596
291854
  }
@@ -294439,7 +294697,7 @@ class V2SelectionMutationAdapter {
294439
294697
  const offsetSpace = selectionOffsetSpace(options);
294440
294698
  switch (request.kind) {
294441
294699
  case "replace":
294442
- return this.executeReplace(request, options, offsetSpace, rewriteIntent);
294700
+ return this.executeReplace(request, options, offsetSpace, rewriteIntent, request.target !== undefined && request.text === "");
294443
294701
  case "insert":
294444
294702
  return this.executeReplace({
294445
294703
  kind: "replace",
@@ -294455,15 +294713,15 @@ class V2SelectionMutationAdapter {
294455
294713
  ref: request.ref,
294456
294714
  text: "",
294457
294715
  in: request.in
294458
- }, options, offsetSpace, false);
294716
+ }, options, offsetSpace, false, true);
294459
294717
  case "format":
294460
294718
  return this.executeFormat(request, options, offsetSpace);
294461
294719
  }
294462
294720
  }
294463
- executeReplace(request, options, offsetSpace, isRewrite = false) {
294721
+ executeReplace(request, options, offsetSpace, isRewrite = false, atomicFieldDelete = false) {
294464
294722
  const startedAt = nowMs6();
294465
294723
  if (request.ref !== undefined && request.target === undefined) {
294466
- return this.executeRefBasedReplace(request, options, isRewrite);
294724
+ return this.executeRefBasedReplace(request, options, isRewrite, atomicFieldDelete);
294467
294725
  }
294468
294726
  const target = request.target;
294469
294727
  if (!target) {
@@ -294489,7 +294747,7 @@ class V2SelectionMutationAdapter {
294489
294747
  if (policyFailure)
294490
294748
  return failureWithoutResolution(policyFailure.code, policyFailure.message);
294491
294749
  if (!options?.dryRun && initialStory.materialization?.sourcePartUri) {
294492
- const preflight = this.executeReplace(request, { ...options, dryRun: true }, offsetSpace, isRewrite);
294750
+ const preflight = this.executeReplace(request, { ...options, dryRun: true }, offsetSpace, isRewrite, atomicFieldDelete);
294493
294751
  if (!preflight.success)
294494
294752
  return preflight;
294495
294753
  }
@@ -294594,7 +294852,8 @@ class V2SelectionMutationAdapter {
294594
294852
  startedAt,
294595
294853
  storyResolveMs,
294596
294854
  offsetSpace,
294597
- options
294855
+ options,
294856
+ atomicFieldDelete
294598
294857
  });
294599
294858
  }
294600
294859
  const resolveSelectionTargetStartedAt = nowMs6();
@@ -294637,6 +294896,47 @@ class V2SelectionMutationAdapter {
294637
294896
  resolved
294638
294897
  });
294639
294898
  const buildResolutionMs = nowMs6() - buildResolutionStartedAt;
294899
+ if (atomicFieldDelete && (options?.changeMode ?? "direct") === "direct" && selectedText.length > 0) {
294900
+ const touchedFields = listCanonicalFieldEntries(this.context).filter((entry) => entry.storyId === resolved.storyId && entry.blockId === resolved.startBlockId && entry.descriptor.complete && resolved.startByte < entry.descriptor.resultByteEnd && resolved.endByte > entry.descriptor.resultByteStart && (offsetSpace === "selection" || instructionKeyword(entry.descriptor.instructionText) === "REF"));
294901
+ if (touchedFields.length > 0) {
294902
+ if (options?.dryRun)
294903
+ return { success: true, resolution };
294904
+ const plan = {
294905
+ kind: "cross-paragraph",
294906
+ startBlockId: resolved.startBlockId,
294907
+ endBlockId: resolved.endBlockId,
294908
+ startOffset: resolved.startOffset,
294909
+ endOffset: resolved.endOffset,
294910
+ startTextLength: index.byParaId(resolved.startBlockId)?.textLength ?? 0,
294911
+ normalizedTarget: target,
294912
+ resolved
294913
+ };
294914
+ const outcome = executeSelectionRangePaste({
294915
+ context: this.context,
294916
+ index,
294917
+ historyLabel: "selection.delete.field",
294918
+ changeMode: "direct",
294919
+ preflightValidated: true
294920
+ }, plan, effectiveStory);
294921
+ if (!outcome.success) {
294922
+ return {
294923
+ success: false,
294924
+ failure: { code: outcome.failure.code, message: outcome.failure.message },
294925
+ resolution
294926
+ };
294927
+ }
294928
+ return {
294929
+ success: true,
294930
+ resolution,
294931
+ ...outcome.meta ? {
294932
+ txId: outcome.meta.txId,
294933
+ invalidatedRefs: outcome.meta.invalidatedRefs,
294934
+ affectedStories: outcome.meta.affectedStories,
294935
+ textRangeShifts: outcome.meta.textRangeShifts
294936
+ } : {}
294937
+ };
294938
+ }
294939
+ }
294640
294940
  let replacements = resolved.coordinateSpace !== "tracked" && resolved.startOffset < resolved.endOffset && selectedText.length === resolved.endOffset - resolved.startOffset && isPlannableTextPayload(request.text) ? planTrackedRewriteReplacement(selectedText, request.text) : [{ start: 0, end: resolved.endOffset - resolved.startOffset, text: request.text }];
294641
294941
  let structuralRewrite = false;
294642
294942
  if (options?.changeMode === "tracked" && replacements.length > 1) {
@@ -294818,7 +295118,7 @@ class V2SelectionMutationAdapter {
294818
295118
  });
294819
295119
  }
294820
295120
  executeCrossParagraphReplace(input) {
294821
- const { target, index, story, storyLocator, text, startedAt, storyResolveMs, offsetSpace, options } = input;
295121
+ const { target, index, story, storyLocator, text, startedAt, storyResolveMs, offsetSpace, options, atomicFieldDelete } = input;
294822
295122
  if (target.coordinateSpace === "tracked") {
294823
295123
  return failureWithoutResolution("CAPABILITY_UNAVAILABLE", "text-range-cross-paragraph-tracked-coordinate-unsupported");
294824
295124
  }
@@ -294862,7 +295162,8 @@ class V2SelectionMutationAdapter {
294862
295162
  context: this.context,
294863
295163
  index,
294864
295164
  changeMode,
294865
- diagnostics: preflightDiagnostics
295165
+ diagnostics: preflightDiagnostics,
295166
+ allowAtomicFieldDelete: atomicFieldDelete && changeMode === "direct"
294866
295167
  }, plan);
294867
295168
  const containmentMs = nowMs6() - containmentStartedAt;
294868
295169
  if (preflightFailure) {
@@ -295141,7 +295442,7 @@ class V2SelectionMutationAdapter {
295141
295442
  ...remappedRefs ? { remappedRefs } : {}
295142
295443
  };
295143
295444
  }
295144
- executeRefBasedReplace(request, options, isRewrite = false) {
295445
+ executeRefBasedReplace(request, options, isRewrite = false, atomicFieldDelete = false) {
295145
295446
  const ref5 = request.ref;
295146
295447
  if (isV2RangeRef(ref5)) {
295147
295448
  const resolvedRange = this.resolveRangeRefSelectionTarget(ref5, request.in);
@@ -295155,7 +295456,7 @@ class V2SelectionMutationAdapter {
295155
295456
  target: resolvedRange.target,
295156
295457
  text: request.text,
295157
295458
  in: resolvedRange.story
295158
- }, options, "kernel", isRewrite);
295459
+ }, options, "kernel", isRewrite, atomicFieldDelete);
295159
295460
  }
295160
295461
  if (!isV2SearchRef(ref5)) {
295161
295462
  const raw = resolveRawBlockRefTarget(this.context, ref5, request.in);
@@ -295167,7 +295468,7 @@ class V2SelectionMutationAdapter {
295167
295468
  target: raw.target,
295168
295469
  text: request.text,
295169
295470
  in: request.in
295170
- }, options, "kernel", isRewrite);
295471
+ }, options, "kernel", isRewrite, atomicFieldDelete);
295171
295472
  }
295172
295473
  const outcome = resolveV2SearchRef({
295173
295474
  ref: ref5,
@@ -295204,7 +295505,7 @@ class V2SelectionMutationAdapter {
295204
295505
  if (fieldDelete)
295205
295506
  return fieldDelete;
295206
295507
  }
295207
- return this.executeReplace({ kind: "replace", target: outcome.selectionTarget, text: request.text, in: outcome.storyLocator }, options, "kernel", isRewrite);
295508
+ return this.executeReplace({ kind: "replace", target: outcome.selectionTarget, text: request.text, in: outcome.storyLocator }, options, "kernel", isRewrite, atomicFieldDelete);
295208
295509
  }
295209
295510
  trackedTextMove(input, options) {
295210
295511
  const destination = input.destination;
@@ -299936,7 +300237,7 @@ class V2TablesAdapter {
299936
300237
  const index = story.storyKind === "main" ? getSDDocumentSessionInternalParagraphIndex(session) : getSDDocumentSessionInternalStoryParagraphIndex(session, story.storyId);
299937
300238
  if (!index)
299938
300239
  return EMPTY_TABLE_CONTEXT_AT_SELECTION;
299939
- if (story.storyKind === "main" || story.storyKind === "header" || story.storyKind === "footer") {
300240
+ if (!input.selectionTextBounds && (story.storyKind === "main" || story.storyKind === "header" || story.storyKind === "footer")) {
299940
300241
  const proved = readTableContextFromTopology(readTopLevelTableTopologyForSession(session, story.storyId), index, input.blockIds);
299941
300242
  if (proved)
299942
300243
  return proved;
@@ -299965,8 +300266,15 @@ class V2TablesAdapter {
299965
300266
  return EMPTY_TABLE_CONTEXT_AT_SELECTION;
299966
300267
  const uniqueCellIds = new Set(matches.map((match) => match.cell.cellNodeId));
299967
300268
  const paragraphNodeIds = index.entries.filter((entry) => entry.byteStart >= primary.cell.bodyByteStart && entry.byteEnd <= primary.cell.bodyByteEnd).map((entry) => entry.blockId);
300269
+ const firstCell = primary.table.rows[0]?.cells[0];
300270
+ const lastRow = primary.table.rows[primary.table.rows.length - 1];
300271
+ const lastCell = lastRow?.cells[lastRow.cells.length - 1];
300272
+ const firstTableParagraph = firstCell ? index.entries.find((entry) => entry.byteStart >= firstCell.bodyByteStart && entry.byteEnd <= firstCell.bodyByteEnd) : null;
300273
+ const lastTableParagraph = lastCell ? index.entries.filter((entry) => entry.byteStart >= lastCell.bodyByteStart && entry.byteEnd <= lastCell.bodyByteEnd).at(-1) : null;
300274
+ const coversWholeTableText = input.selectionTextBounds ? Boolean(firstTableParagraph && lastTableParagraph && input.blockIds[0] === firstTableParagraph.blockId && input.blockIds[input.blockIds.length - 1] === lastTableParagraph.blockId && input.selectionTextBounds.startOffset === 0 && input.selectionTextBounds.endOffset === lastTableParagraph.textLength) : undefined;
299968
300275
  return {
299969
300276
  inTable: true,
300277
+ ...coversWholeTableText === undefined ? {} : { coversWholeTableText },
299970
300278
  table: {
299971
300279
  nodeId: primary.table.tableNodeId,
299972
300280
  rows: primary.table.rows.length,
@@ -357585,6 +357893,9 @@ function normalizeSettingsXml(xml) {
357585
357893
  });
357586
357894
  return normalized;
357587
357895
  }
357896
+ function settingsContentSignatureFromXml(xml) {
357897
+ return digest2(normalizeSettingsXml(xml));
357898
+ }
357588
357899
  function projectSettings(context) {
357589
357900
  const bytes = getSDDocumentSessionInternalPartBytes(context.session, SETTINGS_PART_URI4);
357590
357901
  if (!bytes)
@@ -357593,7 +357904,7 @@ function projectSettings(context) {
357593
357904
  key: "settings",
357594
357905
  stableKey: "settings",
357595
357906
  semanticKey: null,
357596
- contentSignature: digest2(normalizeSettingsXml(TD100.decode(bytes))),
357907
+ contentSignature: settingsContentSignatureFromXml(TD100.decode(bytes)),
357597
357908
  ordinal: 0,
357598
357909
  label: "settings.xml"
357599
357910
  }];
@@ -364412,13 +364723,86 @@ var init_numbering_replay = __esm(() => {
364412
364723
  TE63 = new TextEncoder;
364413
364724
  });
364414
364725
 
364726
+ // ../../../v2/document-api-v2-adapter/dist/diff/settings-replay.js
364727
+ function projectDiffSettingsSource(context) {
364728
+ const bytes = getSDDocumentSessionInternalPartBytes(context.session, SETTINGS_PART_URI5);
364729
+ return { xml: bytes ? TD108.decode(bytes) : null };
364730
+ }
364731
+ function buildSettingsApplyPlan(base3, target) {
364732
+ if (base3.xml === null && target.xml === null)
364733
+ return { steps: [], unsafeReasons: [] };
364734
+ if (base3.xml === null)
364735
+ return { steps: [], unsafeReasons: ["creating a settings part requires package graph replay"] };
364736
+ if (target.xml === null)
364737
+ return { steps: [], unsafeReasons: ["removing a settings part requires package graph replay"] };
364738
+ if (settingsContentSignatureFromXml(base3.xml) === settingsContentSignatureFromXml(target.xml)) {
364739
+ return { steps: [], unsafeReasons: [] };
364740
+ }
364741
+ return {
364742
+ steps: [{ partUri: SETTINGS_PART_URI5, nextXml: target.xml }],
364743
+ unsafeReasons: []
364744
+ };
364745
+ }
364746
+ function validateSettingsSourceAgainstSnapshot(source, snapshot2, label) {
364747
+ const problems = [];
364748
+ const entry = snapshot2.definitions?.find((definition2) => definition2.family === "settings")?.entries[0];
364749
+ const inventoryPart = snapshot2.sourceInventory?.parts.find((part) => part.partUri === SETTINGS_PART_URI5);
364750
+ if (source.xml === null) {
364751
+ if (entry || inventoryPart)
364752
+ problems.push(`${label}: snapshot has a settings part but the captured source does not`);
364753
+ return problems;
364754
+ }
364755
+ if (!hasSettingsRoot(source.xml))
364756
+ problems.push(`${label}: settings XML is malformed or has the wrong root`);
364757
+ if (!entry)
364758
+ problems.push(`${label}: captured settings source is absent from the snapshot definitions`);
364759
+ if (entry && settingsContentSignatureFromXml(source.xml) !== entry.contentSignature) {
364760
+ problems.push(`${label}: captured settings source does not match the snapshot definition`);
364761
+ }
364762
+ if (!inventoryPart?.contentFingerprint) {
364763
+ problems.push(`${label}: snapshot lacks an exact settings inventory fingerprint`);
364764
+ } else if (comparePartXmlFingerprint(SETTINGS_PART_URI5, source.xml) !== inventoryPart.contentFingerprint) {
364765
+ problems.push(`${label}: captured settings bytes do not match the snapshot inventory`);
364766
+ }
364767
+ return problems;
364768
+ }
364769
+ function hasSettingsRoot(xml) {
364770
+ let valid = true;
364771
+ let rootCount = 0;
364772
+ const parser = createXmlSaxParser({ namespaceAware: true });
364773
+ parser.on("error", () => {
364774
+ valid = false;
364775
+ });
364776
+ parser.on("opentag", (tag) => {
364777
+ if (rootCount === 0) {
364778
+ if (tag.namespaceUri !== W_NS7 && tag.namespaceUri !== STRICT_W_NS || tag.localName !== "settings")
364779
+ valid = false;
364780
+ rootCount++;
364781
+ }
364782
+ });
364783
+ try {
364784
+ parser.write(xml);
364785
+ parser.close();
364786
+ } catch {
364787
+ valid = false;
364788
+ }
364789
+ return valid && rootCount === 1;
364790
+ }
364791
+ var SETTINGS_PART_URI5 = "/word/settings.xml", W_NS7 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", STRICT_W_NS = "http://purl.oclc.org/ooxml/wordprocessingml/main", TD108;
364792
+ var init_settings_replay = __esm(() => {
364793
+ init_sd_document_session_internal();
364794
+ init_definitions();
364795
+ init_part_fingerprint();
364796
+ TD108 = new TextDecoder("utf-8", { fatal: false, ignoreBOM: true });
364797
+ });
364798
+
364415
364799
  // ../../../v2/document-api-v2-adapter/dist/diff/main-document-source.js
364416
364800
  function projectDiffMainDocumentSource(context) {
364417
364801
  const bytes = getSDDocumentSessionInternalPartBytes(context.session, MAIN_DOCUMENT_PART_URI);
364418
364802
  if (!bytes) {
364419
364803
  throw new Error(`missing required main document part: ${MAIN_DOCUMENT_PART_URI}`);
364420
364804
  }
364421
- const xml = TD108.decode(bytes);
364805
+ const xml = TD109.decode(bytes);
364422
364806
  return {
364423
364807
  xml,
364424
364808
  fingerprint: capturedMainDocumentFingerprint(xml),
@@ -364518,7 +364902,7 @@ function projectMainDocumentBodyEntries(source, options = {}) {
364518
364902
  });
364519
364903
  const scopes = mapBodyParagraphStructuralScopes(tableCatalog, paragraphIndex.entries);
364520
364904
  const namespaceBindingsByByteStart = scanParagraphNamespaceBindingsByByteStart(source.xml);
364521
- const rawXmls = paragraphIndex.entries.map((entry) => TD108.decode(bytes.subarray(entry.byteStart, entry.byteEnd)));
364905
+ const rawXmls = paragraphIndex.entries.map((entry) => TD109.decode(bytes.subarray(entry.byteStart, entry.byteEnd)));
364522
364906
  const runXmls = paragraphIndex.entries.map((entry, index2) => {
364523
364907
  const namespaceBindings = namespaceBindingsByByteStart.get(entry.byteStart) ?? {};
364524
364908
  return extractParagraphRunXml(rawXmls[index2], namespaceBindings);
@@ -364552,13 +364936,13 @@ function paragraphStyleOutlineLevelMap(record3) {
364552
364936
  function capturedMainDocumentFingerprint(xml) {
364553
364937
  return comparePartXmlFingerprint(MAIN_DOCUMENT_PART_URI, xml);
364554
364938
  }
364555
- var TD108, TE64, MAIN_DOCUMENT_PART_URI = "/word/document.xml", MAIN_DOCUMENT_STORY_ID = "body:/word/document.xml", SNAPSHOT_REVISION = "snapshot";
364939
+ var TD109, TE64, MAIN_DOCUMENT_PART_URI = "/word/document.xml", MAIN_DOCUMENT_STORY_ID = "body:/word/document.xml", SNAPSHOT_REVISION = "snapshot";
364556
364940
  var init_main_document_source = __esm(() => {
364557
364941
  init_sd_document_session_internal();
364558
364942
  init_document_reader();
364559
364943
  init_run_signature2();
364560
364944
  init_part_fingerprint();
364561
- TD108 = new TextDecoder("utf-8", { fatal: false });
364945
+ TD109 = new TextDecoder("utf-8", { fatal: false });
364562
364946
  TE64 = new TextEncoder;
364563
364947
  });
364564
364948
 
@@ -364649,6 +365033,11 @@ function validateStylesSourceShape(value2, label) {
364649
365033
  }
364650
365034
  return problems;
364651
365035
  }
365036
+ function validateSettingsSourceShape(value2, label) {
365037
+ if (!isRecord14(value2) || !("xml" in value2))
365038
+ return [`${label}: must be an object with an "xml" field`];
365039
+ return value2.xml === null || typeof value2.xml === "string" ? [] : [`${label}.xml: must be a string or null`];
365040
+ }
364652
365041
  function isLegacyBodySnapshotPayload(payload) {
364653
365042
  if (!isRecord14(payload))
364654
365043
  return false;
@@ -364689,6 +365078,9 @@ function validateFullDiffSnapshotPayload(payload) {
364689
365078
  problems.push(...validateCommentSourceShape(payload.commentSource, "payload.commentSource"));
364690
365079
  }
364691
365080
  problems.push(...validateStylesSourceShape(payload.styles, "payload.styles"));
365081
+ if (payload.settings !== undefined) {
365082
+ problems.push(...validateSettingsSourceShape(payload.settings, "payload.settings"));
365083
+ }
364692
365084
  if (!isRecord14(payload.numbering) || !("xml" in payload.numbering)) {
364693
365085
  problems.push('payload.numbering: must be an object with an "xml" field');
364694
365086
  } else {
@@ -364783,8 +365175,10 @@ function validateFullDiffPayload(payload) {
364783
365175
  }
364784
365176
  for (const problem of validateCompareAnalysisResult(payload.analysis))
364785
365177
  problems.push(`payload.analysis.${problem}`);
364786
- for (const problem of validateCompareApplyPlan(payload.applyPlan))
365178
+ const baseBody = isRecord14(payload.base) && Array.isArray(payload.base.body) ? payload.base.body.filter((entry) => isRecord14(entry) && typeof entry.blockId === "string" && typeof entry.runXml === "string").map(({ blockId, runXml }) => ({ blockId, runXml })) : [];
365179
+ for (const problem of validateCompareApplyPlan(payload.applyPlan, baseBody)) {
364787
365180
  problems.push(`payload.applyPlan.${problem}`);
365181
+ }
364788
365182
  if (!Array.isArray(payload.familyPolicy)) {
364789
365183
  problems.push("payload.familyPolicy: must be an array");
364790
365184
  }
@@ -364818,6 +365212,19 @@ function validateFullDiffPayload(payload) {
364818
365212
  if (!Array.isArray(styles.unsafeReasons))
364819
365213
  problems.push("payload.styles.unsafeReasons: must be an array");
364820
365214
  }
365215
+ const settings = payload.settings;
365216
+ if (settings !== undefined) {
365217
+ if (!isRecord14(settings)) {
365218
+ problems.push("payload.settings: must be an object");
365219
+ } else {
365220
+ problems.push(...validateSettingsSourceShape(settings.base, "payload.settings.base"));
365221
+ problems.push(...validateSettingsSourceShape(settings.target, "payload.settings.target"));
365222
+ if (!Array.isArray(settings.steps))
365223
+ problems.push("payload.settings.steps: must be an array");
365224
+ if (!Array.isArray(settings.unsafeReasons))
365225
+ problems.push("payload.settings.unsafeReasons: must be an array");
365226
+ }
365227
+ }
364821
365228
  const numbering = payload.numbering;
364822
365229
  if (!isRecord14(numbering)) {
364823
365230
  problems.push("payload.numbering: must be an object");
@@ -364931,7 +365338,7 @@ function buildFamilyPolicy(analysis, plan, semanticAnalysis, additionalDetectedF
364931
365338
  disposition = "analysis-only";
364932
365339
  }
364933
365340
  }
364934
- const reason = step3?.reason ?? res?.blockedReason ?? res?.excludedDecision;
365341
+ const reason = adapterApplySupportedFamilies?.has(family) && changed ? undefined : step3?.reason ?? res?.blockedReason ?? res?.excludedDecision;
364935
365342
  return {
364936
365343
  family,
364937
365344
  disposition,
@@ -365357,6 +365764,9 @@ function buildRelationshipBackedBodyPlan(input) {
365357
365764
  if (!targetEmbedIds || !baseEmbedIdList) {
365358
365765
  return { rewrites: [], unsafeReasons: ["main document XML cannot be parsed safely"] };
365359
365766
  }
365767
+ const retainedMarkupPlan = buildRetainedMarkupBodyPlan(input, composedBaseMainDocumentXml);
365768
+ if (retainedMarkupPlan)
365769
+ return retainedMarkupPlan;
365360
365770
  const baseVisibleText = visibleText2(composedBaseMainDocumentXml);
365361
365771
  const targetVisibleText = visibleText2(input.targetMainDocument.xml);
365362
365772
  if (baseVisibleText === null || targetVisibleText === null) {
@@ -365476,6 +365886,98 @@ function buildRelationshipBackedBodyPlan(input) {
365476
365886
  ];
365477
365887
  return { rewrites, unsafeReasons: [] };
365478
365888
  }
365889
+ function buildRetainedMarkupBodyPlan(input, baseDocumentXml) {
365890
+ if ((input.priorPackageRewrites?.length ?? 0) > 0 || (input.coveredChangedPartUris?.size ?? 0) > 0)
365891
+ return null;
365892
+ if (!sameOutsideMainBody(baseDocumentXml, input.targetMainDocument.xml))
365893
+ return null;
365894
+ if (!sameRetainedMarkup(baseDocumentXml, input.targetMainDocument.xml))
365895
+ return null;
365896
+ if (JSON.stringify(embedIds(baseDocumentXml)) !== JSON.stringify(embedIds(input.targetMainDocument.xml)))
365897
+ return null;
365898
+ if (!input.base.documentRelationships || !input.target.documentRelationships || input.base.documentRelationships.fingerprint !== input.target.documentRelationships.fingerprint || input.base.contentTypes.fingerprint !== input.target.contentTypes.fingerprint)
365899
+ return null;
365900
+ const baseParts = new Map(input.baseSnapshot.sourceInventory?.parts.map((part) => [part.partUri, part]) ?? []);
365901
+ const targetParts = new Map(input.targetSnapshot.sourceInventory?.parts.map((part) => [part.partUri, part]) ?? []);
365902
+ if (baseParts.size === 0 || baseParts.size !== targetParts.size)
365903
+ return null;
365904
+ const changedParts = [...baseParts.keys()].filter((partUri) => baseParts.get(partUri)?.contentFingerprint !== targetParts.get(partUri)?.contentFingerprint || baseParts.get(partUri)?.contentType !== targetParts.get(partUri)?.contentType);
365905
+ if (changedParts.length !== 1 || changedParts[0] !== DOCUMENT_URI)
365906
+ return null;
365907
+ const relationships = decodePartBytes(input.target.documentRelationships);
365908
+ const contentTypes = decodePartBytes(input.target.contentTypes);
365909
+ if (!relationships || !contentTypes)
365910
+ return null;
365911
+ return {
365912
+ rewrites: [
365913
+ { partUri: DOCUMENT_URI, kind: "modify", nextBytes: new TextEncoder().encode(input.targetMainDocument.xml) },
365914
+ { partUri: DOCUMENT_RELS_URI3, kind: "modify", nextBytes: relationships },
365915
+ { partUri: CONTENT_TYPES_URI3, kind: "modify", nextBytes: contentTypes }
365916
+ ],
365917
+ unsafeReasons: []
365918
+ };
365919
+ }
365920
+ function sameOutsideMainBody(baseXml, targetXml) {
365921
+ const outside = (xml) => {
365922
+ const parsed = collectXmlElementRanges(xml);
365923
+ if (parsed.errors.length > 0)
365924
+ return null;
365925
+ const bodies = parsed.ranges.filter((range) => range.tag.namespaceUri === WORDPROCESSINGML_NS5 && range.tag.localName === "body");
365926
+ if (bodies.length !== 1)
365927
+ return null;
365928
+ const body = bodies[0];
365929
+ return [xml.slice(0, body.openEnd), xml.slice(body.closeStart)];
365930
+ };
365931
+ const base3 = outside(baseXml);
365932
+ const target = outside(targetXml);
365933
+ return base3 !== null && target !== null && base3[0] === target[0] && base3[1] === target[1];
365934
+ }
365935
+ function sameRetainedMarkup(baseXml, targetXml) {
365936
+ const fragments = (xml) => [...xml.matchAll(/<w:drawing\b[^>]*>[\s\S]*?<\/w:drawing>/g)].map((match) => match[0]);
365937
+ const baseFragments = fragments(baseXml);
365938
+ const targetFragments = fragments(targetXml);
365939
+ if (JSON.stringify(baseFragments) !== JSON.stringify(targetFragments))
365940
+ return false;
365941
+ const inspect = (xml) => {
365942
+ let drawings = 0;
365943
+ const references = [];
365944
+ const valid = parseXml(xml, {
365945
+ onOpenTag: (tag) => {
365946
+ if (tag.namespaceUri === WORDPROCESSINGML_NS5 && tag.localName === "drawing")
365947
+ drawings += 1;
365948
+ for (const attribute2 of tag.attributes) {
365949
+ if (OFFICE_DOCUMENT_RELATIONSHIP_NAMESPACES.has(attribute2.namespaceUri)) {
365950
+ references.push(`${attribute2.localName}:${attribute2.value}`);
365951
+ }
365952
+ }
365953
+ }
365954
+ });
365955
+ return valid ? { drawings, references } : null;
365956
+ };
365957
+ const base3 = inspect(baseXml);
365958
+ const target = inspect(targetXml);
365959
+ return base3 !== null && target !== null && base3.drawings === baseFragments.length && target.drawings === targetFragments.length && JSON.stringify(base3.references) === JSON.stringify(target.references) && sameProtectedBodyMarkup(baseXml, targetXml);
365960
+ }
365961
+ function sameProtectedBodyMarkup(baseXml, targetXml) {
365962
+ const signature = (xml) => {
365963
+ const parsed = collectXmlElementRanges(xml);
365964
+ if (parsed.errors.length > 0)
365965
+ return null;
365966
+ if (parsed.ranges.some((range) => range.tag.namespaceUri === WORDPROCESSINGML_NS5 && (range.tag.localName === "altChunk" || range.tag.localName === "subDoc")))
365967
+ return null;
365968
+ const protectedRanges = parsed.ranges.filter((range) => range.tag.namespaceUri === WORDPROCESSINGML_NS5 && PROTECTED_BODY_ELEMENTS.has(range.tag.localName));
365969
+ if (!protectedRanges.some((range) => range.tag.localName !== "sectPr"))
365970
+ return null;
365971
+ return protectedRanges.map((range) => {
365972
+ const fragment3 = xml.slice(range.start, range.end);
365973
+ const prefixes = [...new Set([...fragment3.matchAll(/(?:<\/?|\s)([A-Za-z_][\w.-]*):[A-Za-z_][\w.-]*(?=[\s=/>])/g)].map((match) => match[1]))].sort();
365974
+ return JSON.stringify([fragment3, prefixes.map((prefix) => [prefix, range.namespaceBindings[prefix]])]);
365975
+ });
365976
+ };
365977
+ const base3 = signature(baseXml);
365978
+ const target = signature(targetXml);
365979
+ return base3 !== null && target !== null && JSON.stringify(base3) === JSON.stringify(target);
365980
+ }
365479
365981
  function partSourceAfterPriorRewrites(base3, partUri, rewrites) {
365480
365982
  const bytes = partBytesAfterPriorRewrites(base3 ? decodePartBytes(base3) : null, partUri, rewrites);
365481
365983
  if (!bytes)
@@ -365640,7 +366142,7 @@ function relationshipRecords2(source) {
365640
366142
  let depth = 0;
365641
366143
  let rootSeen = false;
365642
366144
  let invalid4 = false;
365643
- const parsed = parseXml(TD109.decode(decodePartBytes(source)), {
366145
+ const parsed = parseXml(TD110.decode(decodePartBytes(source)), {
365644
366146
  onOpenTag: (tag) => {
365645
366147
  if (depth === 0) {
365646
366148
  if (rootSeen || tag.localName !== "Relationships" || tag.namespaceUri !== PACKAGE_RELATIONSHIPS_NS3) {
@@ -365689,7 +366191,7 @@ function saveNoiseProfile(partUri, bytes) {
365689
366191
  const tokens = [];
365690
366192
  const stack = [];
365691
366193
  let invalid4 = false;
365692
- const parsed = parseXml(TD109.decode(bytes), {
366194
+ const parsed = parseXml(TD110.decode(bytes), {
365693
366195
  onOpenTag: (tag) => {
365694
366196
  const parent = stack.at(-1);
365695
366197
  const ignored = parent?.ignored === true || partUri === "/word/settings.xml" && tag.namespaceUri === WORDPROCESSINGML_NS5 && tag.localName === "rsids";
@@ -365745,7 +366247,7 @@ function contentTypeRecords(source) {
365745
366247
  let depth = 0;
365746
366248
  let rootSeen = false;
365747
366249
  let invalid4 = false;
365748
- const parsed = parseXml(TD109.decode(decodePartBytes(source)), {
366250
+ const parsed = parseXml(TD110.decode(decodePartBytes(source)), {
365749
366251
  onOpenTag: (tag) => {
365750
366252
  if (depth === 0) {
365751
366253
  if (rootSeen || tag.localName !== "Types" || tag.namespaceUri !== CONTENT_TYPES_NS6)
@@ -365805,7 +366307,7 @@ function decodePartBytes(source) {
365805
366307
  const length = base64DecodedLength(source.bytesBase64);
365806
366308
  return length === null ? null : base64ToBytes(source.bytesBase64, length);
365807
366309
  }
365808
- var DOCUMENT_RELS_URI3 = "/word/_rels/document.xml.rels", DOCUMENT_URI = "/word/document.xml", CONTENT_TYPES_URI3 = "/[Content_Types].xml", SAVE_NOISE_PART_URIS, IMAGE_REL_TYPES, OFFICE_DOCUMENT_RELATIONSHIP_NAMESPACES, PACKAGE_RELATIONSHIPS_NS3 = "http://schemas.openxmlformats.org/package/2006/relationships", CONTENT_TYPES_NS6 = "http://schemas.openxmlformats.org/package/2006/content-types", DRAWINGML_NS2 = "http://schemas.openxmlformats.org/drawingml/2006/main", WORDPROCESSINGML_NS5 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", CORE_PROPERTIES_NS3 = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", DCTERMS_NS3 = "http://purl.org/dc/terms/", EXTENDED_PROPERTIES_NS2 = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties", TD109;
366310
+ var DOCUMENT_RELS_URI3 = "/word/_rels/document.xml.rels", DOCUMENT_URI = "/word/document.xml", CONTENT_TYPES_URI3 = "/[Content_Types].xml", SAVE_NOISE_PART_URIS, IMAGE_REL_TYPES, OFFICE_DOCUMENT_RELATIONSHIP_NAMESPACES, PACKAGE_RELATIONSHIPS_NS3 = "http://schemas.openxmlformats.org/package/2006/relationships", CONTENT_TYPES_NS6 = "http://schemas.openxmlformats.org/package/2006/content-types", DRAWINGML_NS2 = "http://schemas.openxmlformats.org/drawingml/2006/main", WORDPROCESSINGML_NS5 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", CORE_PROPERTIES_NS3 = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", DCTERMS_NS3 = "http://purl.org/dc/terms/", EXTENDED_PROPERTIES_NS2 = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties", TD110, PROTECTED_BODY_ELEMENTS;
365809
366311
  var init_relationship_backed_body_replay = __esm(() => {
365810
366312
  init_sd_document_session_internal();
365811
366313
  init_part_fingerprint();
@@ -365818,7 +366320,34 @@ var init_relationship_backed_body_replay = __esm(() => {
365818
366320
  "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
365819
366321
  "http://purl.oclc.org/ooxml/officeDocument/relationships"
365820
366322
  ]);
365821
- TD109 = new TextDecoder;
366323
+ TD110 = new TextDecoder;
366324
+ PROTECTED_BODY_ELEMENTS = new Set([
366325
+ "drawing",
366326
+ "pict",
366327
+ "object",
366328
+ "fldSimple",
366329
+ "fldChar",
366330
+ "instrText",
366331
+ "commentReference",
366332
+ "commentRangeStart",
366333
+ "commentRangeEnd",
366334
+ "permStart",
366335
+ "permEnd",
366336
+ "sdt",
366337
+ "customXml",
366338
+ "oMath",
366339
+ "oMathPara",
366340
+ "footnoteReference",
366341
+ "endnoteReference",
366342
+ "ins",
366343
+ "del",
366344
+ "moveFrom",
366345
+ "moveTo",
366346
+ "sectPr",
366347
+ "hyperlink",
366348
+ "bookmarkStart",
366349
+ "bookmarkEnd"
366350
+ ]);
365822
366351
  });
365823
366352
 
365824
366353
  // ../../../v2/document-api-v2-adapter/dist/diff/sections-references-replay.js
@@ -366610,6 +367139,7 @@ class V2DiffAdapter {
366610
367139
  comments: projectDiffComments(this.context),
366611
367140
  commentSource: projectDiffCommentSource(this.context, compareSnapshot),
366612
367141
  styles: projectDiffStylesSource(this.context),
367142
+ settings: projectDiffSettingsSource(this.context),
366613
367143
  numbering: projectDiffNumberingSource(this.context),
366614
367144
  mainDocument: projectDiffMainDocumentSource(this.context),
366615
367145
  relationshipBackedBody: projectRelationshipBackedBodySource(this.context),
@@ -366700,8 +367230,14 @@ class V2DiffAdapter {
366700
367230
  const baseNumbering = projectDiffNumberingSource(this.context);
366701
367231
  const targetNumbering = targetPayload.numbering ?? { xml: null };
366702
367232
  const numberingPlan = buildNumberingApplyPlan(baseNumbering, targetNumbering);
367233
+ const baseSettings = projectDiffSettingsSource(this.context);
367234
+ const targetSettings = targetPayload.settings ?? { xml: null };
367235
+ const settingsPlan = buildSettingsApplyPlan(baseSettings, targetSettings);
366703
367236
  const sectionsReferencesPlan = buildSectionsReferencesReplayPlan(baseMainDocument, targetMainDocument);
366704
367237
  const adapterApplySupportedFamilies = new Set;
367238
+ if (settingsPlan.unsafeReasons.length === 0 && settingsPlan.steps.length > 0) {
367239
+ adapterApplySupportedFamilies.add("settings");
367240
+ }
366705
367241
  if (sectionsReferencesPlan.unsafeReasons.length === 0) {
366706
367242
  if (sectionsReferencesPlan.sectionSteps.length > 0)
366707
367243
  adapterApplySupportedFamilies.add("sections");
@@ -366737,6 +367273,12 @@ class V2DiffAdapter {
366737
367273
  steps: numberingPlan.steps,
366738
367274
  unsafeReasons: numberingPlan.unsafeReasons
366739
367275
  },
367276
+ settings: {
367277
+ base: baseSettings,
367278
+ target: targetSettings,
367279
+ steps: settingsPlan.steps,
367280
+ unsafeReasons: settingsPlan.unsafeReasons
367281
+ },
366740
367282
  mainDocument: {
366741
367283
  base: baseMainDocument,
366742
367284
  target: targetMainDocument
@@ -366760,6 +367302,7 @@ class V2DiffAdapter {
366760
367302
  commentPlan,
366761
367303
  stylePlan,
366762
367304
  numberingPlan,
367305
+ settingsPlan,
366763
367306
  sectionsReferencesPlan,
366764
367307
  physicalPlan
366765
367308
  }),
@@ -366853,7 +367396,7 @@ class V2DiffAdapter {
366853
367396
  if (commentsChanged && !payload.comments.targetSource) {
366854
367397
  throw diffValidationError("INVALID_INPUT", "diff.apply: exact target comment source is required when comments changed. No mutation was performed.");
366855
367398
  }
366856
- const relationshipBackedFamiliesChanged = changedPolicies.some((policy) => policy.family === "body") && changedPolicies.some((policy) => policy.family === "media");
367399
+ const relationshipBackedFamiliesChanged = changedPolicies.some((policy) => policy.family === "body") && (changedPolicies.some((policy) => policy.family === "media") || bodyOperationsTouchRetainedMarkup(payload));
366857
367400
  const relationshipBackedSource = payload.relationshipBackedBody;
366858
367401
  const relationshipBackedSourceProblems = relationshipBackedFamiliesChanged && !reviewMarkup && relationshipBackedSource ? [
366859
367402
  ...validateRelationshipBackedBodySource(relationshipBackedSource.target, payload.target, "target")
@@ -366874,11 +367417,15 @@ class V2DiffAdapter {
366874
367417
  const liveBaseNumbering = projectDiffNumberingSource(this.context);
366875
367418
  const numberingPlan = numberingChanged ? buildNumberingApplyPlan(liveBaseNumbering, payload.numbering.target) : { steps: [], unsafeReasons: [] };
366876
367419
  const hasNumberingWork = numberingPlan.steps.length > 0 || numberingPlan.unsafeReasons.length > 0;
367420
+ const settingsChanged2 = changedPolicies.some((p) => p.family === "settings");
367421
+ const liveBaseSettings = projectDiffSettingsSource(this.context);
367422
+ const settingsPlan = settingsChanged2 ? buildSettingsApplyPlan(liveBaseSettings, payload.settings?.target ?? { xml: null }) : { steps: [], unsafeReasons: [] };
367423
+ const hasSettingsWork = settingsPlan.steps.length > 0 || settingsPlan.unsafeReasons.length > 0;
366877
367424
  const slotsChanged = physicalPlan.hasReferenceIdChanges || changedPolicies.some((p) => p.family === "header-footer-slots");
366878
367425
  const slotPlan = slotsChanged ? buildHeaderFooterSlotPackageRewrite(this.context, payload.base.slots ?? [], payload.target.slots ?? [], physicalPlan.refByPart) : { rewrites: [], unsafeReasons: [], operationCount: 0 };
366879
367426
  const hasSlotWork = slotPlan.rewrites.length > 0 || slotPlan.unsafeReasons.length > 0;
366880
367427
  const operationCounts = buildApplyOperationCounts(payload.applyPlan);
366881
- const hasChanges = expectedSummary.hasChanges || payload.analysis.hasChanges || changedPolicies.length > 0 || hasCommentWork || hasStyleWork || hasNumberingWork || hasSlotWork || physicalPlan.operationCount > 0;
367428
+ const hasChanges = expectedSummary.hasChanges || payload.analysis.hasChanges || changedPolicies.length > 0 || hasCommentWork || hasStyleWork || hasNumberingWork || hasSettingsWork || hasSlotWork || physicalPlan.operationCount > 0;
366882
367429
  if (physicalPlan.unsafeReasons.length > 0) {
366883
367430
  throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: header/footer physical lifecycle is unsafe — [${physicalPlan.unsafeReasons.join("; ")}]. No mutation was performed.`, { changedFamilies: ["header-footer-parts"], unsupportedReason: "header-footer-physical-lifecycle-unsafe" });
366884
367431
  }
@@ -366926,6 +367473,15 @@ class V2DiffAdapter {
366926
367473
  throw diffValidationError("INVALID_INPUT", `diff.apply: numbering source does not match its snapshots — ${numberingSourceProblems.join("; ")}.`);
366927
367474
  }
366928
367475
  }
367476
+ if (settingsChanged2) {
367477
+ const settingsSourceProblems = [
367478
+ ...validateSettingsSourceAgainstSnapshot(payload.settings?.target ?? { xml: null }, payload.target, "payload.settings.target"),
367479
+ ...validateSettingsSourceAgainstSnapshot(liveBaseSettings, payload.base, "live base settings")
367480
+ ];
367481
+ if (settingsSourceProblems.length > 0) {
367482
+ throw diffValidationError("INVALID_INPUT", `diff.apply: settings source does not match its snapshots — ${settingsSourceProblems.join("; ")}.`);
367483
+ }
367484
+ }
366929
367485
  if (commentPlan.unsafeReasons.length > 0) {
366930
367486
  throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: comment replay is unsafe — [${commentPlan.unsafeReasons.join("; ")}]. ` + "No mutation was performed (full payloads are never partially applied).", { changedFamilies: ["comments"], unsupportedReason: "comment-replay-unsafe" });
366931
367487
  }
@@ -366944,12 +367500,18 @@ class V2DiffAdapter {
366944
367500
  throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: numbering replay is unsafe — [${numberingPlan.unsafeReasons.join("; ")}]. ` + "No mutation was performed (full payloads are never partially applied).", { changedFamilies: ["numbering"], unsupportedReason: "numbering-replay-unsafe" });
366945
367501
  }
366946
367502
  const numberingHandled = numberingPlan.steps.length > 0;
366947
- if (reviewMarkup && (stylesHandled || numberingHandled)) {
367503
+ if (settingsPlan.unsafeReasons.length > 0) {
367504
+ throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: settings replay is unsafe — [${settingsPlan.unsafeReasons.join("; ")}]. No mutation was performed.`, { changedFamilies: ["settings"], unsupportedReason: "settings-replay-unsafe" });
367505
+ }
367506
+ const settingsHandled = settingsPlan.steps.length > 0;
367507
+ if (reviewMarkup && (stylesHandled || numberingHandled || settingsHandled)) {
366948
367508
  const changedFamilies3 = [];
366949
367509
  if (stylesHandled)
366950
367510
  changedFamilies3.push("styles");
366951
367511
  if (numberingHandled)
366952
367512
  changedFamilies3.push("numbering");
367513
+ if (settingsHandled)
367514
+ changedFamilies3.push("settings");
366953
367515
  throw diffValidationError("CAPABILITY_UNSUPPORTED", "diff.apply: tracked shared definition replacement is not supported. No mutation was performed.", { changedFamilies: changedFamilies3, unsupportedReason: "definition-replay-tracked-unsupported" });
366954
367516
  }
366955
367517
  if (slotPlan.unsafeReasons.length > 0) {
@@ -367076,7 +367638,7 @@ class V2DiffAdapter {
367076
367638
  const tablesHandled = mainDocumentPlan.steps.length > 0 || trackedTableRowsHandled;
367077
367639
  const mainStoryId = listSDDocumentSessionInternalStories(this.context.session).find((story) => story.storyKind === "main")?.storyId;
367078
367640
  const mainRevisionChangesHandled = mainDocumentPlan.steps.length > 0 && mainStoryId !== undefined && mainDocumentReplacementCoversRevisionChanges(payload.base, payload.target, mainStoryId);
367079
- const definitionPackageRewrites = buildKernelPackageRewrites(stylePlan.steps, numberingPlan.steps);
367641
+ const definitionPackageRewrites = buildKernelPackageRewrites(stylePlan.steps, numberingPlan.steps, settingsPlan.steps);
367080
367642
  const runtimeApplyPlanBase = buildHeaderFooterRuntimeApplyPlan(payload, slotPlan, physicalPlan, reviewMarkup);
367081
367643
  if (runtimeApplyPlanBase.fatalUnsafeReasons.length > 0) {
367082
367644
  throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: header/footer story replay is unsafe — [${runtimeApplyPlanBase.fatalUnsafeReasons.join("; ")}]. ` + "No mutation was performed (full payloads are never partially applied).", { changedFamilies: ["header-footer-parts"], unsupportedReason: "header-footer-story-replay-unsafe" });
@@ -367133,6 +367695,8 @@ class V2DiffAdapter {
367133
367695
  handledFamilies.add("styles");
367134
367696
  if (numberingHandled)
367135
367697
  handledFamilies.add("numbering");
367698
+ if (settingsHandled)
367699
+ handledFamilies.add("settings");
367136
367700
  if (slotsHandled)
367137
367701
  handledFamilies.add("header-footer-slots");
367138
367702
  if (tablesHandled) {
@@ -367181,6 +367745,9 @@ class V2DiffAdapter {
367181
367745
  const changedFamilies3 = unsupportedChanged.length > 0 ? unsupportedChanged.map((p) => p.family) : changedPolicies.map((p) => p.family);
367182
367746
  throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: cannot apply the complete diff because changed families ` + `[${detail.join("; ") || "detected (non-attributed)"}] in this build. ` + "No mutation was performed (full payloads are never partially applied).", { changedFamilies: changedFamilies3, unsupportedReason: "family-apply-lane-unavailable" });
367183
367747
  }
367748
+ if (relationshipBackedFamiliesChanged && !reviewMarkup && relationshipBackedBodyPlan.unsafeReasons.length > 0) {
367749
+ throw diffValidationError("CAPABILITY_UNSUPPORTED", `diff.apply: relationship-backed body replay is unsafe — [${relationshipBackedBodyPlan.unsafeReasons.join("; ")}]. ` + "No mutation was performed (full payloads are never partially applied).", { changedFamilies: ["body"], unsupportedReason: "relationship-backed-body-replay-unsafe" });
367750
+ }
367184
367751
  if (commentsHandled) {
367185
367752
  const stepProblems = validateCommentStepsResolvable(this.context, commentPlan.steps);
367186
367753
  if (stepProblems.length > 0) {
@@ -367318,6 +367885,9 @@ function buildCompareApplyEligibility(context, payload, plans) {
367318
367885
  if (plans.numberingPlan.unsafeReasons.length === 0 && plans.numberingPlan.steps.length > 0) {
367319
367886
  direct.add("numbering");
367320
367887
  }
367888
+ if (plans.settingsPlan.unsafeReasons.length === 0 && plans.settingsPlan.steps.length > 0) {
367889
+ direct.add("settings");
367890
+ }
367321
367891
  if (plans.sectionsReferencesPlan.unsafeReasons.length === 0) {
367322
367892
  if (plans.sectionsReferencesPlan.sectionSteps.length > 0) {
367323
367893
  direct.add("sections");
@@ -367349,13 +367919,13 @@ function buildCompareApplyEligibility(context, payload, plans) {
367349
367919
  const slotPlan = slotsChanged ? buildHeaderFooterSlotPackageRewrite(context, payload.base.slots ?? [], payload.target.slots ?? [], plans.physicalPlan.refByPart) : { rewrites: [], unsafeReasons: [], operationCount: 0 };
367350
367920
  if (slotPlan.unsafeReasons.length === 0 && slotPlan.rewrites.length > 0)
367351
367921
  direct.add("header-footer-slots");
367352
- const relationshipBackedFamiliesChanged = payload.familyPolicy.some((policy) => policy.family === "body" && policy.applyRequired) && payload.familyPolicy.some((policy) => policy.family === "media" && policy.applyRequired);
367922
+ const relationshipBackedFamiliesChanged = payload.familyPolicy.some((policy) => policy.family === "body" && policy.applyRequired) && (payload.familyPolicy.some((policy) => policy.family === "media" && policy.applyRequired) || bodyOperationsTouchRetainedMarkup(payload));
367353
367923
  const relationshipBackedBodyUnsafeReasons = [];
367354
367924
  if (relationshipBackedFamiliesChanged && payload.relationshipBackedBody) {
367355
367925
  const baseRelationshipBackedBody = projectRelationshipBackedBodySource(context);
367356
367926
  relationshipBackedBodyUnsafeReasons.push(...validateRelationshipBackedBodySource(baseRelationshipBackedBody, payload.base, "base"), ...validateRelationshipBackedBodySource(payload.relationshipBackedBody.target, payload.target, "target"));
367357
367927
  if (relationshipBackedBodyUnsafeReasons.length === 0) {
367358
- const definitionPackageRewrites = buildKernelPackageRewrites(plans.stylePlan.steps, plans.numberingPlan.steps);
367928
+ const definitionPackageRewrites = buildKernelPackageRewrites(plans.stylePlan.steps, plans.numberingPlan.steps, plans.settingsPlan.steps);
367359
367929
  const directRuntimePlan = buildHeaderFooterRuntimeApplyPlan(payload, slotPlan, plans.physicalPlan, false);
367360
367930
  relationshipBackedBodyUnsafeReasons.push(...directRuntimePlan.fatalUnsafeReasons);
367361
367931
  const plannedHeaderFooterStoryIds = new Set((directRuntimePlan.applyPlan.storyOperations ?? []).filter((group) => group.family === "header-footer-parts").map((group) => group.storyId));
@@ -367466,6 +368036,7 @@ function buildCompareApplyEligibility(context, payload, plans) {
367466
368036
  }
367467
368037
  addPlanHazards(hazards, plans.stylePlan.unsafeReasons, "styles-replay-unsafe", ["styles"], "Styles replay");
367468
368038
  addPlanHazards(hazards, plans.numberingPlan.unsafeReasons, "numbering-replay-unsafe", ["numbering"], "Numbering replay");
368039
+ addPlanHazards(hazards, plans.settingsPlan.unsafeReasons, "family-apply-lane-unavailable", ["settings"], "Settings replay");
367469
368040
  const trackedDefinitionFamilies = [];
367470
368041
  if (plans.stylePlan.unsafeReasons.length === 0 && plans.stylePlan.steps.length > 0) {
367471
368042
  trackedDefinitionFamilies.push("styles");
@@ -367480,6 +368051,13 @@ function buildCompareApplyEligibility(context, payload, plans) {
367480
368051
  families: trackedDefinitionFamilies
367481
368052
  });
367482
368053
  }
368054
+ if (plans.settingsPlan.unsafeReasons.length === 0 && plans.settingsPlan.steps.length > 0) {
368055
+ hazards.tracked.push({
368056
+ code: "definition-replay-tracked-unsupported",
368057
+ message: "Tracked settings replacement requires document-level review.",
368058
+ families: ["settings"]
368059
+ });
368060
+ }
367483
368061
  const sectionReferenceFamilies = payload.familyPolicy.filter((policy) => policy.applyRequired && (policy.family === "sections" || policy.family === "fields-references")).map((policy) => policy.family);
367484
368062
  addPlanHazards(hazards, plans.sectionsReferencesPlan.unsafeReasons, "section-reference-replay-unsafe", sectionReferenceFamilies, "Section/reference replay");
367485
368063
  if (hasUntrackableFieldReplayStep(plans.sectionsReferencesPlan.referenceSteps)) {
@@ -367611,7 +368189,7 @@ function buildKernelCommentSteps(context, steps) {
367611
368189
  };
367612
368190
  });
367613
368191
  }
367614
- function buildKernelPackageRewrites(styleSteps, numberingSteps) {
368192
+ function buildKernelPackageRewrites(styleSteps, numberingSteps, settingsSteps) {
367615
368193
  const rewrites = [];
367616
368194
  for (const step3 of styleSteps) {
367617
368195
  if (step3.kind !== "replace-styles-part")
@@ -367633,12 +368211,40 @@ function buildKernelPackageRewrites(styleSteps, numberingSteps) {
367633
368211
  nextBytes: TE65.encode(step3.nextXml)
367634
368212
  });
367635
368213
  }
368214
+ for (const step3 of settingsSteps) {
368215
+ rewrites.push({
368216
+ family: "settings",
368217
+ partUri: step3.partUri,
368218
+ kind: "modify",
368219
+ nextBytes: TE65.encode(step3.nextXml)
368220
+ });
368221
+ }
367636
368222
  return rewrites;
367637
368223
  }
367638
368224
  function commentAnchorReplayPreservesMarkerSemantics(commentPlan, base3, target) {
367639
368225
  const commentAnchorMovesOnly = commentPlan.steps.length > 0 && commentPlan.steps.every((step3) => step3.kind === "move-anchor");
367640
368226
  return !commentAnchorMovesOnly || compareBodySemanticsEqual(base3, target);
367641
368227
  }
368228
+ function bodyOperationsTouchRetainedMarkup(payload) {
368229
+ const drawingBlockIds = new Set([
368230
+ ...payload.base.body.filter((entry) => entry.runXml?.includes("<w:drawing")).map((entry) => entry.blockId),
368231
+ ...payload.target.body.filter((entry) => entry.runXml?.includes("<w:drawing")).map((entry) => entry.blockId)
368232
+ ]);
368233
+ if (payload.applyPlan.bodyOperations.some((operation) => drawingBlockIds.has(operation.blockId)))
368234
+ return true;
368235
+ if (payload.applyPlan.bodyOperations.length > 0 || payload.familyPolicy.some((policy) => policy.applyRequired && policy.family !== "body"))
368236
+ return false;
368237
+ const retainedMarkup = /<w:(?:fldSimple|hyperlink|sdt)\b/;
368238
+ const baseById = new Map(payload.base.body.map((entry) => [entry.blockId, entry]));
368239
+ const targetById = new Map(payload.target.body.map((entry) => [entry.blockId, entry]));
368240
+ return [...new Set([...baseById.keys(), ...targetById.keys()])].some((blockId) => {
368241
+ const base3 = baseById.get(blockId);
368242
+ const target = targetById.get(blockId);
368243
+ if (!retainedMarkup.test(base3?.runXml ?? "") && !retainedMarkup.test(target?.runXml ?? ""))
368244
+ return false;
368245
+ return !base3 || !target || base3.runXml !== target.runXml || base3.text !== target.text;
368246
+ });
368247
+ }
367642
368248
  function compareBodySemanticsEqual(base3, target) {
367643
368249
  if (base3.length !== target.length)
367644
368250
  return false;
@@ -367760,7 +368366,7 @@ function packageGraphDeltaIsCoveredByWholeNoteLifecycle(payload) {
367760
368366
  const relationshipBytes = source.headerFooterPhysical?.documentRelationshipsBytes;
367761
368367
  if (!relationshipBytes)
367762
368368
  return false;
367763
- const relationship = parseOpcRelationshipsXml(TD110.decode(Uint8Array.from(relationshipBytes)))?.elements.find((candidate2) => candidate2.id === relationshipId);
368369
+ const relationship = parseOpcRelationshipsXml(TD111.decode(Uint8Array.from(relationshipBytes)))?.elements.find((candidate2) => candidate2.id === relationshipId);
367764
368370
  return relationship?.type.endsWith(relationshipType) === true && relationship.targetMode !== "External" && resolveDocumentRelationshipTarget(relationship.target) === partUri;
367765
368371
  }));
367766
368372
  }
@@ -368347,7 +368953,7 @@ function findStructurallyUnsupportedOperationFamilies(context, runtimeApplyPlan,
368347
368953
  if (op.kind === "edit") {
368348
368954
  if (op.targetRevisionReplay !== undefined)
368349
368955
  return false;
368350
- return bodyStructuralIds.editDelete.has(op.blockId.toUpperCase()) && !localizedReferenceEditIsProtected(op.targetRunXml, referenceSteps);
368956
+ return bodyStructuralIds.editDelete.has(op.blockId.toUpperCase()) && !localizedReferenceEditIsProtected(op.targetRunXml, referenceSteps) && !(referenceSteps.length === 0 && localizedRetainedFieldEditIsProtected(op.targetRunXml));
368351
368957
  }
368352
368958
  if (op.kind === "delete") {
368353
368959
  if (op.targetRevisionReplay?.structuralAction === "delete")
@@ -368424,6 +369030,9 @@ function localizedReferenceEditIsProtected(runXml, referenceSteps) {
368424
369030
  }
368425
369031
  return removed && containsStructuralParagraphTag(remaining, "edit-delete") === false;
368426
369032
  }
369033
+ function localizedRetainedFieldEditIsProtected(runXml) {
369034
+ return runXml !== undefined && [...runXml.matchAll(/<w:fldSimple\b/g)].length === 1 && [...runXml.matchAll(/<\/w:fldSimple>/g)].length === 1;
369035
+ }
368427
369036
  function containsStructuralParagraphTag(xml, blockKind) {
368428
369037
  let found = false;
368429
369038
  const fragment3 = [
@@ -368469,7 +369078,7 @@ function stripRootReplayNamespaceDeclarations(xml) {
368469
369078
  const openEnd = xml.indexOf(">") + 1;
368470
369079
  return stripReplayNamespaceDeclarations(xml.slice(0, openEnd)) + xml.slice(openEnd);
368471
369080
  }
368472
- var FULL_DIFF_APPLY_SUPPORTED_FAMILIES, TE65, TD110, DOCUMENT_PART_URI6 = "/word/document.xml", NUMBERING_PART_URI4 = "/word/numbering.xml", EMPTY_MAIN_DOCUMENT_SOURCE, WORDPROCESSINGML_NS7 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NS2 = "http://schemas.microsoft.com/office/word/2010/wordml", WORDPROCESSING_MATH_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math", MARKUP_COMPATIBILITY_NS3 = "http://schemas.openxmlformats.org/markup-compatibility/2006", VML_NS = "urn:schemas-microsoft-com:vml", STRUCTURAL_PARA_EDIT_DELETE_WML_NAMES, STRUCTURAL_PARA_EDIT_DELETE_MATH_NAMES, STRUCTURAL_PARA_FORMAT_EDIT_WML_NAMES;
369081
+ var FULL_DIFF_APPLY_SUPPORTED_FAMILIES, TE65, TD111, DOCUMENT_PART_URI6 = "/word/document.xml", NUMBERING_PART_URI4 = "/word/numbering.xml", EMPTY_MAIN_DOCUMENT_SOURCE, WORDPROCESSINGML_NS7 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NS2 = "http://schemas.microsoft.com/office/word/2010/wordml", WORDPROCESSING_MATH_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math", MARKUP_COMPATIBILITY_NS3 = "http://schemas.openxmlformats.org/markup-compatibility/2006", VML_NS = "urn:schemas-microsoft-com:vml", STRUCTURAL_PARA_EDIT_DELETE_WML_NAMES, STRUCTURAL_PARA_EDIT_DELETE_MATH_NAMES, STRUCTURAL_PARA_FORMAT_EDIT_WML_NAMES;
368473
369082
  var init_adapter24 = __esm(() => {
368474
369083
  init_tracked_table_property_replay();
368475
369084
  init_src2();
@@ -368484,6 +369093,7 @@ var init_adapter24 = __esm(() => {
368484
369093
  init_comments_replay();
368485
369094
  init_styles_replay();
368486
369095
  init_numbering_replay();
369096
+ init_settings_replay();
368487
369097
  init_main_document_source();
368488
369098
  init_legacy_body();
368489
369099
  init_xml_rewrite();
@@ -368506,7 +369116,7 @@ var init_adapter24 = __esm(() => {
368506
369116
  "tracked-changes"
368507
369117
  ]);
368508
369118
  TE65 = new TextEncoder;
368509
- TD110 = new TextDecoder;
369119
+ TD111 = new TextDecoder;
368510
369120
  EMPTY_MAIN_DOCUMENT_SOURCE = { xml: "" };
368511
369121
  STRUCTURAL_PARA_EDIT_DELETE_WML_NAMES = new Set([
368512
369122
  "fldChar",
@@ -369329,7 +369939,7 @@ function deleteListSequence(input) {
369329
369939
  const author = input.context.readAuthor();
369330
369940
  if (!author?.name)
369331
369941
  return { ok: false, code: "PRECONDITION_FAILED", message: "Tracked list deletion requires an author." };
369332
- const parsed = collectXmlElementRanges(TD111.decode(runtime.value.partBytes));
369942
+ const parsed = collectXmlElementRanges(TD112.decode(runtime.value.partBytes));
369333
369943
  if (parsed.errors.length)
369334
369944
  return { ok: false, code: "PRECONDITION_FAILED", message: "List part XML is malformed." };
369335
369945
  const date6 = new Date().toISOString();
@@ -369710,7 +370320,7 @@ function numberingInstanceIsOwnedByRun(runtime, run) {
369710
370320
  const bytes = getSDDocumentSessionInternalPartBytes(runtime.context.session, partUri);
369711
370321
  if (!bytes)
369712
370322
  return false;
369713
- const xml = TD111.decode(bytes);
370323
+ const xml = TD112.decode(bytes);
369714
370324
  if (!xml.includes("numId"))
369715
370325
  continue;
369716
370326
  const parsed = collectXmlElementRanges(xml);
@@ -370261,7 +370871,7 @@ function commitTrackedDefinitionMutation(runtime, abstractNumId, txIdPrefix, mut
370261
370871
  const bytes = getSDDocumentSessionInternalPartBytes(runtime.context.session, partUri);
370262
370872
  if (!bytes)
370263
370873
  return { ok: false, code: "PRECONDITION_FAILED", message: `Cannot inspect numbering ownership in ${partUri}.` };
370264
- const xml = TD111.decode(bytes);
370874
+ const xml = TD112.decode(bytes);
370265
370875
  if (!xml.includes("numId"))
370266
370876
  continue;
370267
370877
  const parsed = collectXmlElementRanges(xml);
@@ -370317,7 +370927,7 @@ function commitTrackedDefinitionMutation(runtime, abstractNumId, txIdPrefix, mut
370317
370927
  ...[...byPart.values()].map((group) => ({
370318
370928
  partUri: group.runtime.partUri,
370319
370929
  currentBytes: group.runtime.partBytes,
370320
- nextXml: TD111.decode(applyParagraphEdits(group.runtime.partBytes, group.paragraphs, group.edits)),
370930
+ nextXml: TD112.decode(applyParagraphEdits(group.runtime.partBytes, group.paragraphs, group.edits)),
370321
370931
  affectsStoryIndex: true
370322
370932
  })),
370323
370933
  { partUri: NUMBERING_PART_URI5, nextXml: serializeNumberingDocument(mutate(versionedNumbering, version2.value.abstractNumId)), affectsStoryIndex: false }
@@ -370406,7 +371016,7 @@ function loadTargetListRunRuntime(context, storyId, paraId) {
370406
371016
  styleId: null,
370407
371017
  numId: state.numId,
370408
371018
  ilvl: state.ilvl,
370409
- rawXml: TD111.decode(partBytes.subarray(entry.byteStart, entry.byteEnd)),
371019
+ rawXml: TD112.decode(partBytes.subarray(entry.byteStart, entry.byteEnd)),
370410
371020
  ilvlValue: state.ilvl,
370411
371021
  definitionNumId: state.definitionNumId,
370412
371022
  effectiveAbstractNumId: state.abstractNumId,
@@ -370627,7 +371237,7 @@ function commitRuntimeMutation(input) {
370627
371237
  const nextBytes = applyParagraphEdits(input.runtime.partBytes, input.runtime.paragraphs, input.documentEdits);
370628
371238
  rewrites.push({
370629
371239
  partUri: input.runtime.partUri,
370630
- nextXml: TD111.decode(nextBytes),
371240
+ nextXml: TD112.decode(nextBytes),
370631
371241
  currentBytes: input.runtime.partBytes,
370632
371242
  affectsStoryIndex: true
370633
371243
  });
@@ -371340,7 +371950,7 @@ function escapeForRegex2(value2) {
371340
371950
  function createEmptyLevelXml(level, prefix = "w") {
371341
371951
  return `<${prefix}:lvl w:ilvl="${level}"></${prefix}:lvl>`;
371342
371952
  }
371343
- var NUMBERING_PART_URI5 = "/word/numbering.xml", WORDPROCESSINGML_NAMESPACE8 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", TE66, TD111;
371953
+ var NUMBERING_PART_URI5 = "/word/numbering.xml", WORDPROCESSINGML_NAMESPACE8 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", TE66, TD112;
371344
371954
  var init_runtime3 = __esm(() => {
371345
371955
  init_src3();
371346
371956
  init_sd_document_session_internal();
@@ -371351,7 +371961,7 @@ var init_runtime3 = __esm(() => {
371351
371961
  init_xml_rewrite();
371352
371962
  init_tracked_sequence_edits();
371353
371963
  TE66 = new TextEncoder;
371354
- TD111 = new TextDecoder;
371964
+ TD112 = new TextDecoder;
371355
371965
  });
371356
371966
 
371357
371967
  // ../../../v2/document-api-v2-adapter/dist/lists/adapter.js
@@ -374135,16 +374745,16 @@ class V2GetTextAdapter {
374135
374745
  if (!bytes)
374136
374746
  return "";
374137
374747
  const scopedBytes = resolved.descriptor.storyByteRange ? bytes.subarray(resolved.descriptor.storyByteRange[0], resolved.descriptor.storyByteRange[1]) : bytes;
374138
- return extractVisibleTextFromXml4(TD112.decode(scopedBytes));
374748
+ return extractVisibleTextFromXml4(TD113.decode(scopedBytes));
374139
374749
  }
374140
374750
  }
374141
- var TD112, extractVisibleTextFromXml4;
374751
+ var TD113, extractVisibleTextFromXml4;
374142
374752
  var init_adapter28 = __esm(() => {
374143
374753
  init_sd_document_session_internal();
374144
374754
  init_story_identity();
374145
374755
  init_story_surface();
374146
374756
  init_visible_text();
374147
- TD112 = new TextDecoder;
374757
+ TD113 = new TextDecoder;
374148
374758
  extractVisibleTextFromXml4 = extractVisibleTextFromXml2;
374149
374759
  });
374150
374760
 
@@ -374240,7 +374850,7 @@ function collectRunNodes(context, resolved, story) {
374240
374850
  continue;
374241
374851
  if (entry.byteEnd > bytes.length || entry.byteStart < 0 || entry.byteEnd <= entry.byteStart)
374242
374852
  continue;
374243
- const paragraphXml = stripPendingDeletions(TD113.decode(bytes.subarray(entry.byteStart, entry.byteEnd)));
374853
+ const paragraphXml = stripPendingDeletions(TD114.decode(bytes.subarray(entry.byteStart, entry.byteEnd)));
374244
374854
  let offset = 0;
374245
374855
  for (const runXml of scanRunSpans(paragraphXml)) {
374246
374856
  const text4 = extractVisibleTextFromXml4(runXml);
@@ -374414,7 +375024,7 @@ function readCellText(context, storyId, bodyStart, bodyEnd) {
374414
375024
  return "";
374415
375025
  if (bodyEnd > bytes.length || bodyStart < 0 || bodyEnd <= bodyStart)
374416
375026
  return "";
374417
- return extractVisibleTextFromXml4(TD113.decode(bytes.subarray(bodyStart, bodyEnd)));
375027
+ return extractVisibleTextFromXml4(TD114.decode(bytes.subarray(bodyStart, bodyEnd)));
374418
375028
  }
374419
375029
  function addressStory(locator, resolved) {
374420
375030
  if (resolved.storyKind === "main")
@@ -374442,7 +375052,7 @@ function storyPartUriFromId6(storyId) {
374442
375052
  const uri = storyId.slice(colonIdx + 1);
374443
375053
  return uri.startsWith("/") ? uri : `/${uri}`;
374444
375054
  }
374445
- var TD113, STORY_PART_URI_MAIN = "/word/document.xml";
375055
+ var TD114, STORY_PART_URI_MAIN = "/word/document.xml";
374446
375056
  var init_node_discovery = __esm(() => {
374447
375057
  init_sd_document_session_internal();
374448
375058
  init_document_reader();
@@ -374451,7 +375061,7 @@ var init_node_discovery = __esm(() => {
374451
375061
  init_note_story();
374452
375062
  init_textbox_story();
374453
375063
  init_within();
374454
- TD113 = new TextDecoder;
375064
+ TD114 = new TextDecoder;
374455
375065
  });
374456
375066
 
374457
375067
  // ../../../v2/document-api-v2-adapter/dist/search/query-adapter.js
@@ -375387,7 +375997,7 @@ function splicePartBytes(bytes, start, end, replacementXml) {
375387
375997
  next.set(bytes.subarray(0, start), 0);
375388
375998
  next.set(replacement, start);
375389
375999
  next.set(bytes.subarray(end), start + replacement.length);
375390
- return TD114.decode(next);
376000
+ return TD115.decode(next);
375391
376001
  }
375392
376002
  function readExplicitParagraphStyleId(paragraphXml) {
375393
376003
  const pPrMatch = /<w:pPr\b[\s\S]*?<\/w:pPr>/.exec(paragraphXml);
@@ -375485,7 +376095,7 @@ function txIdPrefixToOperation(prefix) {
375485
376095
  return prefix;
375486
376096
  }
375487
376097
  }
375488
- var TD114, TE67;
376098
+ var TD115, TE67;
375489
376099
  var init_adapter29 = __esm(() => {
375490
376100
  init_sd_document_session_internal();
375491
376101
  init_src6();
@@ -375498,7 +376108,7 @@ var init_adapter29 = __esm(() => {
375498
376108
  init_receipt_entities();
375499
376109
  init_part();
375500
376110
  init_paragraph();
375501
- TD114 = new TextDecoder;
376111
+ TD115 = new TextDecoder;
375502
376112
  TE67 = new TextEncoder;
375503
376113
  });
375504
376114
 
@@ -375944,7 +376554,7 @@ async function compileOrderedTextProgram(context, sourceSteps, story, evaluatedR
375944
376554
  const paragraphBytes = getSDDocumentSessionInternalPartRange(context.session, paragraph4.seedRange.partUri, paragraph4.seedRange.paragraphByteStart ?? paragraph4.seedRange.startByte, paragraph4.seedRange.paragraphByteEnd ?? paragraph4.seedRange.endByte);
375945
376555
  if (paragraphBytes) {
375946
376556
  spans = planTrackedRewriteReplacement(match.text, replacement, {
375947
- paragraphXml: TD115.decode(paragraphBytes),
376557
+ paragraphXml: TD116.decode(paragraphBytes),
375948
376558
  startOffset: match.from
375949
376559
  });
375950
376560
  }
@@ -377207,7 +377817,7 @@ function readResolvedText2(context, index2, resolved, cache) {
377207
377817
  const cacheKey = `${entry.partUri}:${entry.byteStart}:${entry.byteEnd}:${resolved.coordinateSpace ?? "visible"}`;
377208
377818
  let paragraphText3 = cache?.paragraphTexts.get(cacheKey);
377209
377819
  if (paragraphText3 === undefined) {
377210
- const paragraphXml = TD115.decode(residentBytes ? bytes.subarray(entry.byteStart, entry.byteEnd) : bytes);
377820
+ const paragraphXml = TD116.decode(residentBytes ? bytes.subarray(entry.byteStart, entry.byteEnd) : bytes);
377211
377821
  paragraphText3 = resolved.coordinateSpace === "tracked" ? readTrackedParagraphText(paragraphXml) : readVisibleParagraphText(paragraphXml);
377212
377822
  cache?.paragraphTexts.set(cacheKey, paragraphText3);
377213
377823
  }
@@ -377268,7 +377878,7 @@ function rangesOverlap10(start, end, otherStart, otherEnd) {
377268
377878
  function elapsed(startedAt) {
377269
377879
  return Math.max(0, performance.now() - startedAt);
377270
377880
  }
377271
- var TD115, BODY_STORY_LOCATOR2, MAX_APPLY_TRACKED_CHANGE_DETAILS = 100, MAX_APPLY_MUTATION_METADATA_DETAILS = 100, DEFAULT_PREVIEW_DETAIL_LIMIT = 100, MAX_PREVIEW_DETAIL_LIMIT = 1000, MAX_LEGACY_NON_REPLACEMENT_TARGETS = 500;
377881
+ var TD116, BODY_STORY_LOCATOR2, MAX_APPLY_TRACKED_CHANGE_DETAILS = 100, MAX_APPLY_MUTATION_METADATA_DETAILS = 100, DEFAULT_PREVIEW_DETAIL_LIMIT = 100, MAX_PREVIEW_DETAIL_LIMIT = 1000, MAX_LEGACY_NON_REPLACEMENT_TARGETS = 500;
377272
377882
  var init_engine3 = __esm(() => {
377273
377883
  init_src3();
377274
377884
  init_sd_document_session_internal();
@@ -377289,7 +377899,7 @@ var init_engine3 = __esm(() => {
377289
377899
  init_stories();
377290
377900
  init_text_range_shifts();
377291
377901
  init_support_contract();
377292
- TD115 = new TextDecoder;
377902
+ TD116 = new TextDecoder;
377293
377903
  BODY_STORY_LOCATOR2 = { kind: "story", storyType: "body" };
377294
377904
  });
377295
377905
 
@@ -377956,7 +378566,7 @@ function resolveParagraphEnd(context, entry) {
377956
378566
  function resolveTrailingZeroWidthParagraphTailByte(bytes, entry, visibleEndByte) {
377957
378567
  if (visibleEndByte < entry.byteStart || visibleEndByte > entry.byteEnd)
377958
378568
  return visibleEndByte;
377959
- const paragraphXml = TD116.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
378569
+ const paragraphXml = TD117.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
377960
378570
  const closeMatch = paragraphXml.match(/<\/[\w.-]+:p>\s*$/);
377961
378571
  if (!closeMatch || closeMatch.index == null)
377962
378572
  return visibleEndByte;
@@ -377975,7 +378585,7 @@ function containsOnlyZeroWidthReferenceTail(xml) {
377975
378585
  const normalized = stripped.replace(/<[\w.-]+:r\b[^>]*>\s*<\/[\w.-]+:r>/g, "").replace(/<\/[\w.-]+:r>/g, "").replace(/<[\w.-]+:r\b[^>]*>/g, "").replace(/\s+/g, "");
377976
378586
  return normalized.length === 0;
377977
378587
  }
377978
- var TD116;
378588
+ var TD117;
377979
378589
  var init_adapter32 = __esm(() => {
377980
378590
  init_sd_document_session_internal();
377981
378591
  init_materialize_slot();
@@ -377990,7 +378600,7 @@ var init_adapter32 = __esm(() => {
377990
378600
  init_xml();
377991
378601
  init_xml3();
377992
378602
  init_rich_fragment_apply();
377993
- TD116 = new TextDecoder;
378603
+ TD117 = new TextDecoder;
377994
378604
  });
377995
378605
 
377996
378606
  // ../../../v2/document-api-v2-adapter/dist/search/find-adapter.js
@@ -379478,11 +380088,11 @@ function provePlainBlockHasNoHyperlink(context, query3) {
379478
380088
  const bytes = getSDDocumentSessionInternalPartBytes(context.session, paragraph4.partUri);
379479
380089
  if (!bytes || paragraph4.byteStart < 0 || paragraph4.byteEnd > bytes.byteLength)
379480
380090
  return null;
379481
- const paragraphXml = TD117.decode(bytes.subarray(paragraph4.byteStart, paragraph4.byteEnd));
380091
+ const paragraphXml = TD118.decode(bytes.subarray(paragraph4.byteStart, paragraph4.byteEnd));
379482
380092
  if (/<(?:[\w.-]+:)?(?:hyperlink|fldSimple|fldChar|instrText|delInstrText)\b/i.test(paragraphXml)) {
379483
380093
  return null;
379484
380094
  }
379485
- const prefixXml = TD117.decode(bytes.subarray(0, paragraph4.byteStart));
380095
+ const prefixXml = TD118.decode(bytes.subarray(0, paragraph4.byteStart));
379486
380096
  if (hasOpenHyperlinkOrFieldAtEnd(prefixXml))
379487
380097
  return null;
379488
380098
  return { storyId: body.storyId, partUri: body.partUri };
@@ -379743,7 +380353,7 @@ function predictInsertedHyperlinkNodeId(context, input) {
379743
380353
  const bytes = getSDDocumentSessionInternalPartBytes(context.session, entry.partUri);
379744
380354
  if (!bytes)
379745
380355
  return null;
379746
- const prefix = TD117.decode(bytes.subarray(0, entry.byteStart));
380356
+ const prefix = TD118.decode(bytes.subarray(0, entry.byteStart));
379747
380357
  const ordinal = countHyperlinkOpenTags(prefix);
379748
380358
  return `hl:${input.paraId}:${ordinal}`;
379749
380359
  }
@@ -379871,7 +380481,7 @@ function escapeRegex15(value2) {
379871
380481
  function defaultRelationshipsXml3() {
379872
380482
  return '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
379873
380483
  }
379874
- var HYPERLINK_REL_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", TD117, TE68;
380484
+ var HYPERLINK_REL_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", TD118, TE68;
379875
380485
  var init_adapter34 = __esm(() => {
379876
380486
  init_sd_document_session_internal();
379877
380487
  init_inline();
@@ -379881,7 +380491,7 @@ var init_adapter34 = __esm(() => {
379881
380491
  init_document_reader();
379882
380492
  init_stories();
379883
380493
  init_registry3();
379884
- TD117 = new TextDecoder;
380494
+ TD118 = new TextDecoder;
379885
380495
  TE68 = new TextEncoder;
379886
380496
  });
379887
380497
 
@@ -380145,7 +380755,7 @@ function prepareTargetPart(context, target, additionalTargets = [], allocatePara
380145
380755
  part: {
380146
380756
  refId: materialized.refId,
380147
380757
  partUri: materialized.partUri,
380148
- partXml: TD118.decode(materialized.partBytes),
380758
+ partXml: TD119.decode(materialized.partBytes),
380149
380759
  contentType: materialized.contentType,
380150
380760
  perPart: { ...materialized.perPart },
380151
380761
  created: true
@@ -380161,7 +380771,7 @@ function preparePicturePlan(context, part, input, shapeId, contentTypesXml) {
380161
380771
  return { ok: false, message: "Header relationships path could not be resolved." };
380162
380772
  const preparedRels = part.perPart[relsUri];
380163
380773
  const existingRelsBytes = resultingWholePartBytes(context, relsUri, preparedRels);
380164
- const relsXml = existingRelsBytes ? TD118.decode(existingRelsBytes) : EMPTY_RELATIONSHIPS_XML4;
380774
+ const relsXml = existingRelsBytes ? TD119.decode(existingRelsBytes) : EMPTY_RELATIONSHIPS_XML4;
380165
380775
  const imageRefId = allocateRId2(relsXml);
380166
380776
  const mediaPartUri = allocateMediaPartUri(context, decoded.format);
380167
380777
  const mediaTarget = relativeTarget3(part.partUri, mediaPartUri);
@@ -380193,7 +380803,7 @@ function removePictureResources(context, entry, perPart, contentTypesXml) {
380193
380803
  if (!relsUri || !entry.imageRefId || !entry.mediaPartUri)
380194
380804
  return { contentTypesXml };
380195
380805
  const relsBytes = readPartBytes2(context, relsUri);
380196
- const relsXml = relsBytes ? TD118.decode(relsBytes) : EMPTY_RELATIONSHIPS_XML4;
380806
+ const relsXml = relsBytes ? TD119.decode(relsBytes) : EMPTY_RELATIONSHIPS_XML4;
380197
380807
  const remainingPartXml = replaceExactlyOnce4(entry.partXml, entry.pictXml, "");
380198
380808
  if (remainingPartXml && [...remainingPartXml.matchAll(/<[A-Za-z_][^>]*>/g)].some((match) => ["r:id", "r:embed", "r:link"].some((attribute2) => xmlAttribute3(match[0], attribute2) === entry.imageRefId))) {
380199
380809
  return { contentTypesXml };
@@ -380313,7 +380923,7 @@ function contentTypesXmlForPrepared(context, part) {
380313
380923
  if (current) {
380314
380924
  const replacement = entry.patches.find((patch) => patch.kind === "replaceBytes" && patch.startByte === 0 && patch.endByte === current.length);
380315
380925
  if (replacement?.kind === "replaceBytes")
380316
- return TD118.decode(replacement.bytes);
380926
+ return TD119.decode(replacement.bytes);
380317
380927
  }
380318
380928
  }
380319
380929
  return readPartXml(context, CONTENT_TYPES_PART_URI14) ?? "";
@@ -380487,7 +381097,7 @@ function readAspectLock(pictXml) {
380487
381097
  return /^(?:t|true|1)$/.test(instanceLock[1] ?? instanceLock[2] ?? "");
380488
381098
  return /<o:lock\b[^>]*\baspectratio=["'](?:t|true|1)["']/.test(pictXml);
380489
381099
  }
380490
- var IMAGE_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", RELATIONSHIPS_CT2 = "application/vnd.openxmlformats-package.relationships+xml", EMPTY_RELATIONSHIPS_XML4, TD118;
381100
+ var IMAGE_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", RELATIONSHIPS_CT2 = "application/vnd.openxmlformats-package.relationships+xml", EMPTY_RELATIONSHIPS_XML4, TD119;
380491
381101
  var init_parts = __esm(() => {
380492
381102
  init_sd_document_session_internal();
380493
381103
  init_adapter3();
@@ -380498,7 +381108,7 @@ var init_parts = __esm(() => {
380498
381108
  init_xml3();
380499
381109
  init_serialization();
380500
381110
  EMPTY_RELATIONSHIPS_XML4 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
380501
- TD118 = new TextDecoder;
381111
+ TD119 = new TextDecoder;
380502
381112
  });
380503
381113
 
380504
381114
  // ../../../v2/document-api-v2-adapter/dist/watermarks/scoped-apply.js
@@ -429649,8 +430259,8 @@ function readSessionStoryPayloads(context) {
429649
430259
  };
429650
430260
  const payloads = [...context.index.entries].sort((left, right) => left.byteStart - right.byteStart).map((entry) => {
429651
430261
  const refs = context.tableRefsByBlockId.get(entry.blockId);
429652
- const leadingXml = TD119.decode(context.bytes.slice(cursor, entry.byteStart));
429653
- const xml = TD119.decode(context.bytes.slice(entry.byteStart, entry.byteEnd));
430262
+ const leadingXml = TD120.decode(context.bytes.slice(cursor, entry.byteStart));
430263
+ const xml = TD120.decode(context.bytes.slice(entry.byteStart, entry.byteEnd));
429654
430264
  const namespaceBindings = context.resolveNamespaceBindings({ xml, byteStart: entry.byteStart });
429655
430265
  advanceTrackedWrapperIdentityState(leadingXml, namespaceBindings, trackedWrapperIdentityState);
429656
430266
  const trackedWrapperOccurrenceStart = trackedWrapperIdentityState.occurrence;
@@ -429678,7 +430288,7 @@ function readSessionStoryPayloads(context) {
429678
430288
  });
429679
430289
  return {
429680
430290
  payloads,
429681
- trailingXml: TD119.decode(context.bytes.slice(cursor, contentWindow.byteEnd))
430291
+ trailingXml: TD120.decode(context.bytes.slice(cursor, contentWindow.byteEnd))
429682
430292
  };
429683
430293
  }
429684
430294
  function readSessionBlockPayload(context, blockId) {
@@ -429687,7 +430297,7 @@ function readSessionBlockPayload(context, blockId) {
429687
430297
  throw new Error(`story-surface session sync could not resolve paragraph ${blockId} in ${context.storyId}`);
429688
430298
  }
429689
430299
  const refs = context.tableRefsByBlockId.get(entry.blockId);
429690
- const xml = TD119.decode(context.bytes.slice(entry.byteStart, entry.byteEnd));
430300
+ const xml = TD120.decode(context.bytes.slice(entry.byteStart, entry.byteEnd));
429691
430301
  return {
429692
430302
  storyId: entry.storyId,
429693
430303
  storyRevision: String(entry.storyRevision),
@@ -429833,7 +430443,7 @@ function writeParagraphMembershipTableOverlaysFromSession(session, prepared, sto
429833
430443
  ...tableBlockIds,
429834
430444
  ...affectedBlockIds.filter((blockId) => knownTableBlockIds.has(blockId))
429835
430445
  ])];
429836
- const tableXml = TD119.decode(bytes.slice(table.tableByteStart, table.tableByteEnd));
430446
+ const tableXml = TD120.decode(bytes.slice(table.tableByteStart, table.tableByteEnd));
429837
430447
  const sourceXmlStart = byteOffsetToCharOffset(bytes, table.tableByteStart);
429838
430448
  const sourceXmlEnd = sourceXmlStart + tableXml.length;
429839
430449
  writeTableOverlayState({
@@ -429885,7 +430495,7 @@ function reconcileTableOverlaysFromSession(session, prepared, storyId, doc2, opt
429885
430495
  return;
429886
430496
  for (const table of currentCatalog.tables) {
429887
430497
  const affectedBlockIds = currentIndex.entries.filter((entry) => entry.byteStart >= table.tableByteStart && entry.byteEnd <= table.tableByteEnd).map((entry) => entry.blockId);
429888
- const tableXml = TD119.decode(bytes.slice(table.tableByteStart, table.tableByteEnd));
430498
+ const tableXml = TD120.decode(bytes.slice(table.tableByteStart, table.tableByteEnd));
429889
430499
  const sourceXmlStart = byteOffsetToCharOffset(bytes, table.tableByteStart);
429890
430500
  const createdTableIdentity = createdTableIdentityBlockId(table.tableNodeId);
429891
430501
  writeTableOverlayState({
@@ -429938,7 +430548,7 @@ function projectionAnchorForCreatedTable(input) {
429938
430548
  return owningTable?.tableNodeId ?? entry.blockId;
429939
430549
  }
429940
430550
  function writeCreatedTableOverlayFromSession(input) {
429941
- const tableXml = TD119.decode(input.context.bytes.slice(input.table.tableByteStart, input.table.tableByteEnd));
430551
+ const tableXml = TD120.decode(input.context.bytes.slice(input.table.tableByteStart, input.table.tableByteEnd));
429942
430552
  const sourceXmlStart = byteOffsetToCharOffset(input.context.bytes, input.table.tableByteStart);
429943
430553
  const tableMap = getStoryTablesMap(input.doc);
429944
430554
  writeTableOverlayState({
@@ -430060,7 +430670,7 @@ function syncTrackedDecisionTableOverlaysFromSession(session, prepared, storyId,
430060
430670
  const overlayTableNodeId = resolveTrackedDecisionTableOverlayOwner(tableMap, table.tableNodeId, affectedBlockIds);
430061
430671
  const currentOverlay = tableMap.get(overlayTableNodeId);
430062
430672
  const existingOverlay = hasTableOverlaySourceCoordinates(currentOverlay);
430063
- const tableXml = TD119.decode(bytes.slice(table.tableByteStart, table.tableByteEnd));
430673
+ const tableXml = TD120.decode(bytes.slice(table.tableByteStart, table.tableByteEnd));
430064
430674
  const tableCoordinatesChanged = currentOverlay instanceof YMap && (currentOverlay.get("sourceByteStart") !== table.tableByteStart || currentOverlay.get("sourceByteEnd") !== table.tableByteEnd);
430065
430675
  const tableXmlChanged = currentOverlay instanceof YMap && currentOverlay.get("xml") !== tableXml;
430066
430676
  if (!shouldSyncTable(table.tableNodeId) && !tableCoordinatesChanged && !tableXmlChanged)
@@ -430165,7 +430775,7 @@ function writeTableOverlayState(input) {
430165
430775
  }
430166
430776
  function reconcileTableStructuralProperties(tableState, table, tableXml) {
430167
430777
  const tableBytes = TE72.encode(tableXml);
430168
- const xmlForRange = (start, end) => TD119.decode(tableBytes.slice(start - table.tableByteStart, end - table.tableByteStart));
430778
+ const xmlForRange = (start, end) => TD120.decode(tableBytes.slice(start - table.tableByteStart, end - table.tableByteStart));
430169
430779
  for (const row of table.rows) {
430170
430780
  reconcileTableStructuralProperty(tableState, `rowProperties:${row.rowNodeId}`, readDirectChildPropertyXml3(xmlForRange(row.rowByteStart, row.rowByteEnd), "tr", "trPr"));
430171
430781
  for (const cell of row.cells) {
@@ -430204,7 +430814,7 @@ function readDirectChildPropertyXml3(xml, rootLocalName, propertyLocalName) {
430204
430814
  function byteOffsetToCharOffset(bytes, byteOffset) {
430205
430815
  if (byteOffset <= 0)
430206
430816
  return 0;
430207
- return TD119.decode(bytes.slice(0, byteOffset)).length;
430817
+ return TD120.decode(bytes.slice(0, byteOffset)).length;
430208
430818
  }
430209
430819
  function writeStringArray2(map5, key2, values2) {
430210
430820
  let arrayValue = map5.get(key2);
@@ -430438,7 +431048,7 @@ function inferStoryKindFromStoryId(storyId) {
430438
431048
  return storyId.split(":", 1)[0] ?? "preserved";
430439
431049
  }
430440
431050
  function resolveStoryContentWindow(bytes, storyKind, entries2) {
430441
- const xml = TD119.decode(bytes);
431051
+ const xml = TD120.decode(bytes);
430442
431052
  const root = extractRootEnvelope(xml);
430443
431053
  if (!root) {
430444
431054
  return deriveContentWindowFromEntrySpans(bytes, entries2);
@@ -430516,7 +431126,7 @@ function utf8ByteLength8(xml, codeUnitIndex) {
430516
431126
  return TE72.encode(xml).length;
430517
431127
  return TE72.encode(xml.slice(0, codeUnitIndex)).length;
430518
431128
  }
430519
- var TD119, TE72;
431129
+ var TD120, TE72;
430520
431130
  var init_story_surface_session_sync = __esm(() => {
430521
431131
  init_yjs();
430522
431132
  init_scope3();
@@ -430534,7 +431144,7 @@ var init_story_surface_session_sync = __esm(() => {
430534
431144
  init_story_surface_origin();
430535
431145
  init_paragraph_inline_sync();
430536
431146
  init_story_surface_origin();
430537
- TD119 = new TextDecoder;
431147
+ TD120 = new TextDecoder;
430538
431148
  TE72 = new TextEncoder;
430539
431149
  });
430540
431150
 
@@ -435675,7 +436285,7 @@ function createHeadlessCollabRoomCoordinator(options) {
435675
436285
  if (storyPartUris.has(String(partUri)))
435676
436286
  continue;
435677
436287
  const shardKind = shardKindForPackagePartUri(String(partUri));
435678
- const shardOwner = shardKind === SHARD_KIND.relationships ? ownerPartUriForRels2(String(partUri)) : shardKind === SHARD_KIND.settings ? SETTINGS_PART_URI5 : String(partUri);
436288
+ const shardOwner = shardKind === SHARD_KIND.relationships ? ownerPartUriForRels2(String(partUri)) : shardKind === SHARD_KIND.settings ? SETTINGS_PART_URI6 : String(partUri);
435679
436289
  const shardId = packageShardId(options.rootId, shardKind, shardOwner);
435680
436290
  if (seen.has(shardId))
435681
436291
  continue;
@@ -435696,7 +436306,7 @@ function createHeadlessCollabRoomCoordinator(options) {
435696
436306
  function syncSessionPackagePart(prepared, partUri) {
435697
436307
  const entry = prepared.localApplyBundle.perPart[partUri];
435698
436308
  if (entry?.kind === "remove") {
435699
- if (partUri === SETTINGS_PART_URI5 || partUri === WEB_SETTINGS_PART_URI) {
436309
+ if (partUri === SETTINGS_PART_URI6 || partUri === WEB_SETTINGS_PART_URI) {
435700
436310
  syncSettingsParts(prepared);
435701
436311
  return;
435702
436312
  }
@@ -435732,7 +436342,7 @@ function createHeadlessCollabRoomCoordinator(options) {
435732
436342
  syncNumberingPart(bytes);
435733
436343
  return;
435734
436344
  }
435735
- if (partUri === SETTINGS_PART_URI5 || partUri === WEB_SETTINGS_PART_URI) {
436345
+ if (partUri === SETTINGS_PART_URI6 || partUri === WEB_SETTINGS_PART_URI) {
435736
436346
  syncSettingsParts(prepared);
435737
436347
  return;
435738
436348
  }
@@ -435970,15 +436580,15 @@ function createHeadlessCollabRoomCoordinator(options) {
435970
436580
  });
435971
436581
  }
435972
436582
  function syncSettingsParts(prepared) {
435973
- const settingsBytes = readPartBytesForSync(prepared, SETTINGS_PART_URI5);
436583
+ const settingsBytes = readPartBytesForSync(prepared, SETTINGS_PART_URI6);
435974
436584
  const webSettingsBytes = readPartBytesForSync(prepared, WEB_SETTINGS_PART_URI);
435975
436585
  const handle = ensureSettingsShard();
435976
436586
  resetPackagePartPayload(collabUnitTargetOrDoc(handle));
435977
436587
  writeSettingsSnapshot(collabUnitTargetOrDoc(handle), settingsBytes, webSettingsBytes);
435978
436588
  if (settingsBytes) {
435979
436589
  recordManifestPart({
435980
- partKey: encodeLogicalOwnerKey(SETTINGS_PART_URI5),
435981
- partUri: SETTINGS_PART_URI5,
436590
+ partKey: encodeLogicalOwnerKey(SETTINGS_PART_URI6),
436591
+ partUri: SETTINGS_PART_URI6,
435982
436592
  partKind: "settings",
435983
436593
  contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",
435984
436594
  binary: false,
@@ -436491,7 +437101,7 @@ function createHeadlessCollabRoomCoordinator(options) {
436491
437101
  return [packageShardId(options.rootId, SHARD_KIND.numbering, descriptor.partUri)];
436492
437102
  }
436493
437103
  if (descriptor.partKind === "settings" || descriptor.partKind === "webSettings") {
436494
- return [packageShardId(options.rootId, SHARD_KIND.settings, SETTINGS_PART_URI5)];
437104
+ return [packageShardId(options.rootId, SHARD_KIND.settings, SETTINGS_PART_URI6)];
436495
437105
  }
436496
437106
  if (isCommentsFamilyPartKind(descriptor.partKind)) {
436497
437107
  return [packageShardId(options.rootId, SHARD_KIND.comments, COMMENTS_PART_URI5)];
@@ -436577,7 +437187,7 @@ function createHeadlessCollabRoomCoordinator(options) {
436577
437187
  }
436578
437188
  if (descriptor.partKind === "settings" || descriptor.partKind === "webSettings") {
436579
437189
  connectPackageHandleIfNeeded({
436580
- shardId: packageShardId(options.rootId, SHARD_KIND.settings, SETTINGS_PART_URI5),
437190
+ shardId: packageShardId(options.rootId, SHARD_KIND.settings, SETTINGS_PART_URI6),
436581
437191
  shardKind: SHARD_KIND.settings,
436582
437192
  required: true
436583
437193
  });
@@ -437725,7 +438335,7 @@ function createHeadlessCollabRoomCoordinator(options) {
437725
438335
  return handle;
437726
438336
  }
437727
438337
  function ensureSettingsShard() {
437728
- const shardId = packageShardId(options.rootId, SHARD_KIND.settings, SETTINGS_PART_URI5);
438338
+ const shardId = packageShardId(options.rootId, SHARD_KIND.settings, SETTINGS_PART_URI6);
437729
438339
  const existing = options.graph.projectionHandles.get(shardId);
437730
438340
  if (existing)
437731
438341
  return existing;
@@ -437734,9 +438344,9 @@ function createHeadlessCollabRoomCoordinator(options) {
437734
438344
  seedSettingsShard({
437735
438345
  doc: unit,
437736
438346
  shardId,
437737
- ownerPartKey: encodeLogicalOwnerKey(SETTINGS_PART_URI5),
437738
- ownerPartUri: SETTINGS_PART_URI5,
437739
- pairedPartKeys: [encodeLogicalOwnerKey(SETTINGS_PART_URI5), encodeLogicalOwnerKey(WEB_SETTINGS_PART_URI)],
438347
+ ownerPartKey: encodeLogicalOwnerKey(SETTINGS_PART_URI6),
438348
+ ownerPartUri: SETTINGS_PART_URI6,
438349
+ pairedPartKeys: [encodeLogicalOwnerKey(SETTINGS_PART_URI6), encodeLogicalOwnerKey(WEB_SETTINGS_PART_URI)],
437740
438350
  settings: { fields: {}, webFields: {}, opaqueXml: null, webOpaqueXml: null }
437741
438351
  });
437742
438352
  } catch {}
@@ -438104,7 +438714,7 @@ function createHeadlessCollabRoomCoordinator(options) {
438104
438714
  function retirePackagePart(partUri) {
438105
438715
  const partKey = encodeLogicalOwnerKey(partUri);
438106
438716
  const shardKind = shardKindForPackagePartUri(partUri);
438107
- const shardOwner = shardKind === SHARD_KIND.settings ? SETTINGS_PART_URI5 : partUri;
438717
+ const shardOwner = shardKind === SHARD_KIND.settings ? SETTINGS_PART_URI6 : partUri;
438108
438718
  const shardId = packageShardId(options.rootId, shardKind, shardOwner);
438109
438719
  options.rootDoc.transact(() => {
438110
438720
  getPackagePartsMap(options.rootDoc).delete(partKey);
@@ -438258,7 +438868,7 @@ function partKindForPackagePartUri(partUri) {
438258
438868
  return "styles";
438259
438869
  if (partUri === NUMBERING_PART_URI6)
438260
438870
  return "numbering";
438261
- if (partUri === SETTINGS_PART_URI5)
438871
+ if (partUri === SETTINGS_PART_URI6)
438262
438872
  return "settings";
438263
438873
  if (partUri === WEB_SETTINGS_PART_URI)
438264
438874
  return "webSettings";
@@ -438305,7 +438915,7 @@ function shardKindForPackagePartUri(partUri) {
438305
438915
  return SHARD_KIND.styles;
438306
438916
  if (partUri === NUMBERING_PART_URI6)
438307
438917
  return SHARD_KIND.numbering;
438308
- if (partUri === SETTINGS_PART_URI5 || partUri === WEB_SETTINGS_PART_URI)
438918
+ if (partUri === SETTINGS_PART_URI6 || partUri === WEB_SETTINGS_PART_URI)
438309
438919
  return SHARD_KIND.settings;
438310
438920
  if (isCommentsFamilyPartUri(partUri))
438311
438921
  return SHARD_KIND.comments;
@@ -438369,7 +438979,7 @@ function contentTypeForPackagePart(partUri) {
438369
438979
  if (partUri === "/word/styles.xml") {
438370
438980
  return "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
438371
438981
  }
438372
- if (partUri === SETTINGS_PART_URI5) {
438982
+ if (partUri === SETTINGS_PART_URI6) {
438373
438983
  return "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
438374
438984
  }
438375
438985
  if (partUri === WEB_SETTINGS_PART_URI) {
@@ -438994,7 +439604,7 @@ function listManifestPartUris(rootDoc, partKinds) {
438994
439604
  }
438995
439605
  return out;
438996
439606
  }
438997
- var TEXT_DECODER10, CONTENT_TYPES_PART_URI17 = "/[Content_Types].xml", NUMBERING_PART_URI6 = "/word/numbering.xml", SETTINGS_PART_URI5 = "/word/settings.xml", WEB_SETTINGS_PART_URI = "/word/webSettings.xml", MAIN_DOCUMENT_PART_URI2 = "/word/document.xml", MAIN_DOCUMENT_RELS_PART_URI = "/word/_rels/document.xml.rels", ROOT_RELS_PART_URI = "/_rels/.rels", COMMENTS_PART_URI5 = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI5 = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI5 = "/word/commentsIds.xml", PEOPLE_PART_URI = "/word/people.xml", NOTES_FOOTNOTES_URI = "/word/footnotes.xml", NOTES_ENDNOTES_URI = "/word/endnotes.xml", MEDIA_OWNER_URI = "/word/media", REL_CONTENT_TYPE = "application/vnd.openxmlformats-package.relationships+xml", COMMENTS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml", COMMENTS_EXTENDED_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", COMMENTS_IDS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml", PEOPLE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml", NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", IMAGE_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", HYPERLINK_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", FIRST_LIST_LEVEL_OPAQUE_XML = '<w:lvlJc w:val="left"/><w:pPr><w:ind w:left="720" w:hanging="360"/></w:pPr>';
439607
+ var TEXT_DECODER10, CONTENT_TYPES_PART_URI17 = "/[Content_Types].xml", NUMBERING_PART_URI6 = "/word/numbering.xml", SETTINGS_PART_URI6 = "/word/settings.xml", WEB_SETTINGS_PART_URI = "/word/webSettings.xml", MAIN_DOCUMENT_PART_URI2 = "/word/document.xml", MAIN_DOCUMENT_RELS_PART_URI = "/word/_rels/document.xml.rels", ROOT_RELS_PART_URI = "/_rels/.rels", COMMENTS_PART_URI5 = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI5 = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI5 = "/word/commentsIds.xml", PEOPLE_PART_URI = "/word/people.xml", NOTES_FOOTNOTES_URI = "/word/footnotes.xml", NOTES_ENDNOTES_URI = "/word/endnotes.xml", MEDIA_OWNER_URI = "/word/media", REL_CONTENT_TYPE = "application/vnd.openxmlformats-package.relationships+xml", COMMENTS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml", COMMENTS_EXTENDED_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", COMMENTS_IDS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml", PEOPLE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml", NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", IMAGE_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", HYPERLINK_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", FIRST_LIST_LEVEL_OPAQUE_XML = '<w:lvlJc w:val="left"/><w:pPr><w:ind w:left="720" w:hanging="360"/></w:pPr>';
438998
439608
  var init_collaboration_v2_room_coordinator = __esm(() => {
438999
439609
  init_yjs();
439000
439610
  init_dist9();
@@ -439973,7 +440583,7 @@ async function buildCanonicalShardGraph(input) {
439973
440583
  input.trace?.mark("canonical:core-package-parts");
439974
440584
  const settingsFamily = buildSettingsFamily(roomInventory);
439975
440585
  if (settingsFamily) {
439976
- const shardId = packageShardId2(input.runtime.rootId, SHARD_KIND.settings, SETTINGS_PART_URI6);
440586
+ const shardId = packageShardId2(input.runtime.rootId, SHARD_KIND.settings, SETTINGS_PART_URI7);
439977
440587
  projectionHandles.set(shardId, await connectSettingsShard(rootDoc, shardId, settingsFamily.settings, settingsFamily.webSettings));
439978
440588
  requiredShardIds.add(shardId);
439979
440589
  }
@@ -440090,7 +440700,7 @@ function readCompletePartBytes(session, sourceOpen, partUri) {
440090
440700
  return null;
440091
440701
  }
440092
440702
  function buildSettingsFamily(inventory) {
440093
- const settings = inventory.get(SETTINGS_PART_URI6) ?? null;
440703
+ const settings = inventory.get(SETTINGS_PART_URI7) ?? null;
440094
440704
  const webSettings = inventory.get(WEB_SETTINGS_PART_URI2) ?? null;
440095
440705
  if (!settings && !webSettings)
440096
440706
  return null;
@@ -440248,8 +440858,8 @@ async function connectSettingsShard(rootDoc, shardId, settingsPart, webSettingsP
440248
440858
  seedSettingsShard({
440249
440859
  doc: unit,
440250
440860
  shardId,
440251
- ownerPartKey: settingsPart?.partKey ?? encodeLogicalOwnerKey(SETTINGS_PART_URI6),
440252
- ownerPartUri: settingsPart?.partUri ?? SETTINGS_PART_URI6,
440861
+ ownerPartKey: settingsPart?.partKey ?? encodeLogicalOwnerKey(SETTINGS_PART_URI7),
440862
+ ownerPartUri: settingsPart?.partUri ?? SETTINGS_PART_URI7,
440253
440863
  pairedPartKeys: [settingsPart?.partKey, webSettingsPart?.partKey].filter(Boolean),
440254
440864
  settings: {
440255
440865
  fields: {},
@@ -440721,7 +441331,7 @@ function formatLateJoinValidationFailure(validation) {
440721
441331
  const diagnostics = validation.diagnostics.length > 0 ? validation.diagnostics.map((diagnostic2) => `${diagnostic2.code}: ${diagnostic2.message}`).join("; ") : "no diagnostics reported";
440722
441332
  return `v2 collaboration late-join validation failed (${validation.classification.classification}, ${readiness}): ${diagnostics}`;
440723
441333
  }
440724
- var TEXT_DECODER11, DEFAULT_CLAIMER_ID = "headless-open", REPLACEMENT_REQUEST_KEY_PREFIX = "replaceFile:", REPLACEMENT_HEARTBEAT_INTERVAL_MS = 5000, REPLACEMENT_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_HEARTBEAT_INTERVAL_MS = 5000, BOOTSTRAP_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_LEASE_KEY_PREFIX = "bootstrapSeed:", SETTINGS_PART_URI6 = "/word/settings.xml", WEB_SETTINGS_PART_URI2 = "/word/webSettings.xml", COMMENTS_PART_URI6 = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI6 = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI6 = "/word/commentsIds.xml", PEOPLE_PART_URI2 = "/word/people.xml", MEDIA_OWNER_URI2 = "/word/media", INLINE_BINARY_FAMILIES, OPAQUE_PART_FAMILIES, DEFAULT_OPEN_INTENT, POST_SYNC_SETTLE_MAX_MS = 1000, POST_SYNC_QUIET_WINDOW_MS = 20, replacementSequence = 0, replacementHeartbeatObservations;
441334
+ var TEXT_DECODER11, DEFAULT_CLAIMER_ID = "headless-open", REPLACEMENT_REQUEST_KEY_PREFIX = "replaceFile:", REPLACEMENT_HEARTBEAT_INTERVAL_MS = 5000, REPLACEMENT_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_HEARTBEAT_INTERVAL_MS = 5000, BOOTSTRAP_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_LEASE_KEY_PREFIX = "bootstrapSeed:", SETTINGS_PART_URI7 = "/word/settings.xml", WEB_SETTINGS_PART_URI2 = "/word/webSettings.xml", COMMENTS_PART_URI6 = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI6 = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI6 = "/word/commentsIds.xml", PEOPLE_PART_URI2 = "/word/people.xml", MEDIA_OWNER_URI2 = "/word/media", INLINE_BINARY_FAMILIES, OPAQUE_PART_FAMILIES, DEFAULT_OPEN_INTENT, POST_SYNC_SETTLE_MAX_MS = 1000, POST_SYNC_QUIET_WINDOW_MS = 20, replacementSequence = 0, replacementHeartbeatObservations;
440725
441335
  var init_collaboration_v2_open = __esm(() => {
440726
441336
  init_dist9();
440727
441337
  init_setup();