@superdoc-dev/cli 0.8.0-next.21 → 0.8.0-next.24

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 +1495 -230
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1365,7 +1365,26 @@ More content with **bold** and *italic*.`
1365
1365
  table: { toolName: "superdoc_table", description: "Table structure and cell operations" },
1366
1366
  list: {
1367
1367
  toolName: "superdoc_list",
1368
- description: "Create and manipulate bullet and numbered lists. " + 'To create a list: first create all paragraphs at the SAME location using superdoc_create (chain each using the previous nodeId as the "at" target). ' + 'Then call action "create" with mode:"fromParagraphs", a preset ("disc" for bullet, "decimal" for numbered), and a range target: {from:{kind:"block", nodeType:"paragraph", nodeId:"<first>"}, to:{kind:"block", nodeType:"paragraph", nodeId:"<last>"}}. ' + "The range converts ALL paragraphs between from and to into list items. Make sure no other content exists between them. " + 'Action "set_type" converts between bullet and ordered (target any item in the list, kind:"ordered" or "bullet"). ' + 'Action "insert" adds a new item before/after a target list item. ' + 'Actions "indent" and "outdent" change nesting level; "set_level" jumps to a specific level (0-8). ' + 'Action "detach" converts a list item back to a plain paragraph. ' + "Do NOT target paragraphs with indent/outdent/set_type; these actions require a listItem target.",
1368
+ description: "Create and manipulate bullet and numbered lists. " + 'Most actions require a list-item target: {kind:"block", nodeType:"listItem", nodeId:"<id>"}. ' + 'Exceptions: "create" and "attach" operate on paragraph targets (they turn paragraphs into list items). ' + `Find nodeIds via superdoc_get_content({action:"blocks"}) pick listItem blocks for most actions, paragraph blocks for create/attach.
1369
+ ` + `
1370
+ ` + `CREATE & CONVERT:
1371
+ ` + '• "create" — make a NEW list from paragraphs. Two modes: ' + 'mode:"empty" with at:{kind:"block", nodeType:"paragraph", nodeId} converts a single paragraph; ' + 'mode:"fromParagraphs" with target:{from:{...paragraph block address}, to:{...paragraph block address}} converts a range — ALL paragraphs between from and to become items, so make sure no other content sits between them. ' + 'Pass a preset ("disc"|"circle"|"square"|"dash" for bullets; "decimal"|"decimalParenthesis"|"lowerLetter"|"upperLetter"|"lowerRoman"|"upperRoman" for ordered) or a custom style. ' + `Use "create" to start a fresh list — NOT to extend an existing one (use "attach" for that).
1372
+ ` + `• "attach" — add paragraphs to an EXISTING list, inheriting its numbering definition. Pass target:{paragraph block address} (or {from, to} range of paragraphs) + attachTo:{kind:"block", nodeType:"listItem", nodeId:"<any item in destination list>"} + optional level:0..8. Use this to extend a list or as the second half of a merge workflow (see "join" below).
1373
+ ` + `• "set_type" — convert an existing list between ordered and bullet. Pass target:{listItem} + kind:"ordered" or "bullet". Adjacent compatible sequences are merged automatically to preserve continuous numbering.
1374
+ ` + `• "detach" — convert a list item back to a plain paragraph. Pass target:{listItem}.
1375
+ ` + `
1376
+ ` + `ITEMS & NESTING:
1377
+ ` + `• "insert" — add a new list item adjacent to an existing item in the same list. Pass target:{listItem} + position:"before"|"after" + optional text. Use this (NOT superdoc_create) to add items to an existing list.
1378
+ ` + `• "indent" / "outdent" — bump the target item's nesting level by one (0-8 range). Pass target:{listItem}.
1379
+ ` + `• "set_level" — jump the target item to an explicit level. Pass target:{listItem} + level:0..8.
1380
+ ` + `
1381
+ ` + `NUMBERING (ordered lists):
1382
+ ` + `• "set_value" — restart numbering at the target. Pass target:{listItem} + value:<number> (e.g. value:1 to start over) or value:null to clear a previous override. Mid-sequence targets are atomically split off into their own sequence.
1383
+ ` + `• "continue_previous" — make the target's sequence continue numbering from the nearest compatible previous sequence (same abstract definition). Pass target:{listItem of the sequence you want to renumber}. Fails with NO_COMPATIBLE_PREVIOUS or INCOMPATIBLE_DEFINITIONS if no matching prior sequence exists.
1384
+ ` + `
1385
+ ` + `SEQUENCE SHAPE (merge / split):
1386
+ ` + `• "merge" — merge the target's sequence with an adjacent one into one continuous list. Pass target:{listItem} + direction:"withPrevious" or "withNext". Absorbed items adopt the absorbing sequence's numbering definition, and empty paragraphs between the two sequences are removed so numbering flows continuously.
1387
+ ` + `• "split" — split the target's sequence at the target item into two independent lists. The target and everything after become a new sequence that restarts numbering at 1. Pass target:{listItem}; add restartNumbering:false to keep the count continuing instead of restarting.`,
1369
1388
  inputExamples: [
1370
1389
  {
1371
1390
  action: "create",
@@ -1383,7 +1402,15 @@ More content with **bold** and *italic*.`
1383
1402
  position: "after",
1384
1403
  text: "New list item"
1385
1404
  },
1386
- { action: "indent", target: { kind: "block", nodeType: "listItem", nodeId: "<itemId>" } }
1405
+ { action: "indent", target: { kind: "block", nodeType: "listItem", nodeId: "<itemId>" } },
1406
+ {
1407
+ action: "merge",
1408
+ target: { kind: "block", nodeType: "listItem", nodeId: "<itemId>" },
1409
+ direction: "withPrevious"
1410
+ },
1411
+ { action: "split", target: { kind: "block", nodeType: "listItem", nodeId: "<itemId>" } },
1412
+ { action: "set_value", target: { kind: "block", nodeType: "listItem", nodeId: "<itemId>" }, value: 1 },
1413
+ { action: "continue_previous", target: { kind: "block", nodeType: "listItem", nodeId: "<itemId>" } }
1387
1414
  ]
1388
1415
  },
1389
1416
  comment: {
@@ -2616,7 +2643,9 @@ More content with **bold** and *italic*.`
2616
2643
  throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
2617
2644
  }),
2618
2645
  referenceDocPath: "lists/attach.mdx",
2619
- referenceGroup: "lists"
2646
+ referenceGroup: "lists",
2647
+ intentGroup: "list",
2648
+ intentAction: "attach"
2620
2649
  },
2621
2650
  "lists.detach": {
2622
2651
  memberPath: "lists.detach",
@@ -2716,6 +2745,40 @@ More content with **bold** and *italic*.`
2716
2745
  referenceDocPath: "lists/separate.mdx",
2717
2746
  referenceGroup: "lists"
2718
2747
  },
2748
+ "lists.merge": {
2749
+ memberPath: "lists.merge",
2750
+ description: 'Compound: merge two adjacent list sequences into one. Reassigns numId on the absorbed sequence (no strict abstractNumId check — absorbed items adopt the absorbing definition) and deletes empty paragraphs between the two sequences. Use this instead of lists.join for the user-facing "merge these lists" intent.',
2751
+ expectedResult: "Returns a ListsMergeResult with the merged listId, absorbedCount, and removedEmptyBlocks count.",
2752
+ requiresDocumentContext: true,
2753
+ metadata: mutationOperation({
2754
+ idempotency: "conditional",
2755
+ supportsDryRun: true,
2756
+ supportsTrackedMode: false,
2757
+ possibleFailureCodes: ["INVALID_TARGET", "NO_ADJACENT_SEQUENCE", "NO_OP"],
2758
+ throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
2759
+ }),
2760
+ referenceDocPath: "lists/merge.mdx",
2761
+ referenceGroup: "lists",
2762
+ intentGroup: "list",
2763
+ intentAction: "merge"
2764
+ },
2765
+ "lists.split": {
2766
+ memberPath: "lists.split",
2767
+ description: "Compound: split a list sequence at the target item into two independent sequences. Runs lists.separate then (by default) lists.setValue(1) so the new half starts numbering fresh at 1. Pass restartNumbering:false for raw separate semantics (new half continues the previous count).",
2768
+ expectedResult: "Returns a ListsSplitResult with the new listId, numId, and the restart value applied (or null).",
2769
+ requiresDocumentContext: true,
2770
+ metadata: mutationOperation({
2771
+ idempotency: "conditional",
2772
+ supportsDryRun: true,
2773
+ supportsTrackedMode: false,
2774
+ possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
2775
+ throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
2776
+ }),
2777
+ referenceDocPath: "lists/split.mdx",
2778
+ referenceGroup: "lists",
2779
+ intentGroup: "list",
2780
+ intentAction: "split"
2781
+ },
2719
2782
  "lists.setLevel": {
2720
2783
  memberPath: "lists.setLevel",
2721
2784
  description: "Set the absolute nesting level (0..8) of a list item.",
@@ -2746,7 +2809,9 @@ More content with **bold** and *italic*.`
2746
2809
  throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
2747
2810
  }),
2748
2811
  referenceDocPath: "lists/set-value.mdx",
2749
- referenceGroup: "lists"
2812
+ referenceGroup: "lists",
2813
+ intentGroup: "list",
2814
+ intentAction: "set_value"
2750
2815
  },
2751
2816
  "lists.continuePrevious": {
2752
2817
  memberPath: "lists.continuePrevious",
@@ -2761,7 +2826,9 @@ More content with **bold** and *italic*.`
2761
2826
  throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
2762
2827
  }),
2763
2828
  referenceDocPath: "lists/continue-previous.mdx",
2764
- referenceGroup: "lists"
2829
+ referenceGroup: "lists",
2830
+ intentGroup: "list",
2831
+ intentAction: "continue_previous"
2765
2832
  },
2766
2833
  "lists.canContinuePrevious": {
2767
2834
  memberPath: "lists.canContinuePrevious",
@@ -3245,6 +3312,19 @@ More content with **bold** and *italic*.`
3245
3312
  referenceDocPath: "ranges/resolve.mdx",
3246
3313
  referenceGroup: "ranges"
3247
3314
  },
3315
+ "selection.current": {
3316
+ memberPath: "selection.current",
3317
+ description: "Read the editor's current selection as a portable SelectionInfo with a text-anchored TextTarget. Primitive for building custom comments UIs, floating toolbars, and other selection-driven components without reaching into ProseMirror internals.",
3318
+ expectedResult: "Returns a SelectionInfo with `empty`, `target` (TextTarget or null), `activeMarks`, and optionally `text` when `includeText: true`.",
3319
+ requiresDocumentContext: true,
3320
+ metadata: readOperation({
3321
+ idempotency: "idempotent",
3322
+ throws: ["INVALID_INPUT", "INVALID_CONTEXT"],
3323
+ deterministicTargetResolution: true
3324
+ }),
3325
+ referenceDocPath: "selection/current.mdx",
3326
+ referenceGroup: "selection"
3327
+ },
3248
3328
  "mutations.preview": {
3249
3329
  memberPath: "mutations.preview",
3250
3330
  description: "Dry-run a mutation plan, returning resolved targets without applying changes.",
@@ -9688,7 +9768,25 @@ var init_schemas = __esm(() => {
9688
9768
  description: "Block type: paragraph, heading, listItem, image, tableOfContents."
9689
9769
  },
9690
9770
  text: { type: "string", description: "Full plain text content of the block." },
9691
- headingLevel: { type: "integer", description: "Heading level (1–6). Only present for headings." },
9771
+ textSpans: {
9772
+ type: "array",
9773
+ description: "Block text broken into runs with tracked-change marks preserved per run. Present only when the block contains at least one tracked change. Concatenating span text yields `text`.",
9774
+ items: objectSchema({
9775
+ text: { type: "string", description: "Raw text of the run." },
9776
+ trackedChanges: {
9777
+ type: "array",
9778
+ description: "Tracked-change marks applied to this run.",
9779
+ items: objectSchema({
9780
+ entityId: {
9781
+ type: "string",
9782
+ description: "Tracked change entity ID matching an entry in trackedChanges[]."
9783
+ },
9784
+ type: { type: "string", enum: ["insert", "delete", "format"] }
9785
+ }, ["entityId", "type"])
9786
+ }
9787
+ }, ["text"])
9788
+ },
9789
+ headingLevel: { type: "integer", description: "Heading level (1-6). Only present for headings." },
9692
9790
  tableContext: objectSchema({
9693
9791
  tableOrdinal: {
9694
9792
  type: "integer",
@@ -9735,10 +9833,27 @@ var init_schemas = __esm(() => {
9735
9833
  items: objectSchema({
9736
9834
  entityId: {
9737
9835
  type: "string",
9738
- description: "Tracked change entity ID pass to scrollToElement() for navigation."
9836
+ description: "Tracked change entity ID. Pass to scrollToElement() for navigation."
9837
+ },
9838
+ type: {
9839
+ type: "string",
9840
+ enum: ["insert", "delete", "format"],
9841
+ description: "Aggregate type at the entity level. In paired replacement mode, a delete+insert pair shares one entity and this collapses to 'insert'; per-half type lives on block.textSpans[].trackedChanges[]."
9842
+ },
9843
+ blockIds: {
9844
+ type: "array",
9845
+ description: "Block IDs whose textSpans carry this change.",
9846
+ items: { type: "string" }
9847
+ },
9848
+ wordRevisionIds: objectSchema({
9849
+ insert: { type: "string", description: "Original OOXML w:id from a w:ins mark." },
9850
+ delete: { type: "string", description: "Original OOXML w:id from a w:del mark." },
9851
+ format: { type: "string", description: "Original OOXML w:id from a w:rPrChange mark." }
9852
+ }, []),
9853
+ excerpt: {
9854
+ type: "string",
9855
+ description: "Short text excerpt of the changed content. Omitted for paired replacements; read block.textSpans for the per-half text."
9739
9856
  },
9740
- type: { type: "string", enum: ["insert", "delete", "format"] },
9741
- excerpt: { type: "string", description: "Short text excerpt of the changed content." },
9742
9857
  author: { type: "string", description: "Change author name." },
9743
9858
  date: { type: "string", description: "Change date (ISO string)." }
9744
9859
  }, ["entityId", "type"])
@@ -10690,6 +10805,54 @@ var init_schemas = __esm(() => {
10690
10805
  ]),
10691
10806
  failure: listsFailureSchemaFor("lists.separate")
10692
10807
  },
10808
+ "lists.merge": {
10809
+ input: objectSchema({
10810
+ target: listItemAddressSchema,
10811
+ direction: { enum: ["withPrevious", "withNext"] }
10812
+ }, ["target", "direction"]),
10813
+ output: {
10814
+ oneOf: [
10815
+ objectSchema({
10816
+ success: { const: true },
10817
+ listId: { type: "string" },
10818
+ absorbedCount: { type: "integer" },
10819
+ removedEmptyBlocks: { type: "integer" }
10820
+ }, ["success", "listId", "absorbedCount", "removedEmptyBlocks"]),
10821
+ listsFailureSchemaFor("lists.merge")
10822
+ ]
10823
+ },
10824
+ success: objectSchema({
10825
+ success: { const: true },
10826
+ listId: { type: "string" },
10827
+ absorbedCount: { type: "integer" },
10828
+ removedEmptyBlocks: { type: "integer" }
10829
+ }, ["success", "listId", "absorbedCount", "removedEmptyBlocks"]),
10830
+ failure: listsFailureSchemaFor("lists.merge")
10831
+ },
10832
+ "lists.split": {
10833
+ input: objectSchema({
10834
+ target: listItemAddressSchema,
10835
+ restartNumbering: { type: "boolean" }
10836
+ }, ["target"]),
10837
+ output: {
10838
+ oneOf: [
10839
+ objectSchema({
10840
+ success: { const: true },
10841
+ listId: { type: "string" },
10842
+ numId: { type: "integer" },
10843
+ restartedAt: { type: ["integer", "null"] }
10844
+ }, ["success", "listId", "numId", "restartedAt"]),
10845
+ listsFailureSchemaFor("lists.split")
10846
+ ]
10847
+ },
10848
+ success: objectSchema({
10849
+ success: { const: true },
10850
+ listId: { type: "string" },
10851
+ numId: { type: "integer" },
10852
+ restartedAt: { type: ["integer", "null"] }
10853
+ }, ["success", "listId", "numId", "restartedAt"]),
10854
+ failure: listsFailureSchemaFor("lists.split")
10855
+ },
10693
10856
  "lists.setLevel": {
10694
10857
  input: objectSchema({
10695
10858
  target: listItemAddressSchema,
@@ -11058,8 +11221,8 @@ var init_schemas = __esm(() => {
11058
11221
  input: objectSchema({
11059
11222
  text: { type: "string", description: "Comment text content." },
11060
11223
  target: {
11061
- ...textAddressSchema,
11062
- description: "Text range to anchor the comment: {kind:'text', blockId:'...', range:{start:N, end:N}}."
11224
+ oneOf: [textAddressSchema, textTargetSchema],
11225
+ description: "Text range to anchor the comment. Accepts either a single-block TextAddress {kind:'text', blockId, range} or a multi-segment TextTarget {kind:'text', segments:[{blockId, range}, ...]} for selections that span blocks."
11063
11226
  },
11064
11227
  parentCommentId: {
11065
11228
  type: "string",
@@ -11391,6 +11554,17 @@ var init_schemas = __esm(() => {
11391
11554
  }, ["start", "end"]),
11392
11555
  output: resolveRangeOutputSchema
11393
11556
  },
11557
+ "selection.current": {
11558
+ input: objectSchema({
11559
+ includeText: { type: "boolean" }
11560
+ }, []),
11561
+ output: objectSchema({
11562
+ empty: { type: "boolean" },
11563
+ target: { oneOf: [textTargetSchema, { type: "null" }] },
11564
+ activeMarks: arraySchema({ type: "string" }),
11565
+ text: { type: "string" }
11566
+ }, ["empty", "target", "activeMarks"])
11567
+ },
11394
11568
  "mutations.preview": {
11395
11569
  input: mutationsInputSchema,
11396
11570
  output: objectSchema({
@@ -13260,6 +13434,11 @@ var init_reference_doc_map = __esm(() => {
13260
13434
  description: "Deterministic range construction from explicit document anchors.",
13261
13435
  pagePath: "ranges/index.mdx"
13262
13436
  },
13437
+ selection: {
13438
+ title: "Selection",
13439
+ description: "Read the editor's current selection as a portable, addressable target.",
13440
+ pagePath: "selection/index.mdx"
13441
+ },
13263
13442
  diff: {
13264
13443
  title: "Diff",
13265
13444
  description: "Snapshot-based document comparison and replay.",
@@ -13657,6 +13836,29 @@ var init_ranges = __esm(() => {
13657
13836
  init_resolve();
13658
13837
  init_scroll_into_view();
13659
13838
  });
13839
+
13840
+ // ../../packages/document-api/src/selection/selection.ts
13841
+ function validateSelectionCurrentInput(input) {
13842
+ if (input === undefined)
13843
+ return;
13844
+ if (!isRecord(input)) {
13845
+ throw new DocumentApiValidationError("INVALID_INPUT", "selection.current input must be a non-null object.");
13846
+ }
13847
+ assertNoUnknownFields(input, SELECTION_CURRENT_ALLOWED_KEYS, "selection.current");
13848
+ if (input.includeText !== undefined && typeof input.includeText !== "boolean") {
13849
+ throw new DocumentApiValidationError("INVALID_INPUT", `includeText must be a boolean, got ${typeof input.includeText}.`, { field: "includeText", value: input.includeText });
13850
+ }
13851
+ }
13852
+ function executeSelectionCurrent(adapter, input) {
13853
+ validateSelectionCurrentInput(input);
13854
+ return adapter.current(input ?? {});
13855
+ }
13856
+ var SELECTION_CURRENT_ALLOWED_KEYS;
13857
+ var init_selection = __esm(() => {
13858
+ init_errors2();
13859
+ init_validation_primitives();
13860
+ SELECTION_CURRENT_ALLOWED_KEYS = new Set(["includeText"]);
13861
+ });
13660
13862
  // ../../packages/document-api/src/markdown-to-fragment/markdown-to-fragment.ts
13661
13863
  function executeMarkdownToFragment(adapter, input) {
13662
13864
  return adapter.markdownToFragment(input);
@@ -13694,8 +13896,8 @@ function validateCreateCommentInput(input) {
13694
13896
  field: "target"
13695
13897
  });
13696
13898
  }
13697
- if (!isTextAddress(target)) {
13698
- throw new DocumentApiValidationError("INVALID_TARGET", "target must be a text address object.", {
13899
+ if (!isTextAddress(target) && !isTextTarget(target)) {
13900
+ throw new DocumentApiValidationError("INVALID_TARGET", "target must be a TextAddress or TextTarget object.", {
13699
13901
  field: "target",
13700
13902
  value: target
13701
13903
  });
@@ -15033,6 +15235,16 @@ function executeListsSeparate(adapter, input, options) {
15033
15235
  optionalBoolean(input.copyOverrides, "copyOverrides", "lists.separate");
15034
15236
  return adapter.separate(input, normalizeMutationOptions(options));
15035
15237
  }
15238
+ function executeListsMerge(adapter, input, options) {
15239
+ validateListItemTarget(input, "lists.merge");
15240
+ requireEnum(input.direction, "direction", VALID_JOIN_DIRECTIONS, "lists.merge");
15241
+ return adapter.merge(input, normalizeMutationOptions(options));
15242
+ }
15243
+ function executeListsSplit(adapter, input, options) {
15244
+ validateListItemTarget(input, "lists.split");
15245
+ optionalBoolean(input.restartNumbering, "restartNumbering", "lists.split");
15246
+ return adapter.split(input, normalizeMutationOptions(options));
15247
+ }
15036
15248
  function executeListsSetLevel(adapter, input, options) {
15037
15249
  validateListItemTarget(input, "lists.setLevel");
15038
15250
  requireLevel(input.level, "lists.setLevel");
@@ -15757,6 +15969,8 @@ function buildDispatchTable(api) {
15757
15969
  "lists.join": (input, options) => api.lists.join(input, options),
15758
15970
  "lists.canJoin": (input) => api.lists.canJoin(input),
15759
15971
  "lists.separate": (input, options) => api.lists.separate(input, options),
15972
+ "lists.merge": (input, options) => api.lists.merge(input, options),
15973
+ "lists.split": (input, options) => api.lists.split(input, options),
15760
15974
  "lists.setLevel": (input, options) => api.lists.setLevel(input, options),
15761
15975
  "lists.setValue": (input, options) => api.lists.setValue(input, options),
15762
15976
  "lists.continuePrevious": (input, options) => api.lists.continuePrevious(input, options),
@@ -15810,6 +16024,7 @@ function buildDispatchTable(api) {
15810
16024
  "trackChanges.decide": (input, options) => api.trackChanges.decide(input, options),
15811
16025
  "query.match": (input) => api.query.match(input),
15812
16026
  "ranges.resolve": (input) => api.ranges.resolve(input),
16027
+ "selection.current": (input) => api.selection.current(input),
15813
16028
  "mutations.preview": (input) => api.mutations.preview(input),
15814
16029
  "mutations.apply": (input) => api.mutations.apply(input),
15815
16030
  "capabilities.get": () => api.capabilities(),
@@ -18718,6 +18933,12 @@ function createDocumentApi(adapters) {
18718
18933
  separate(input, options) {
18719
18934
  return executeListsSeparate(adapters.lists, input, options);
18720
18935
  },
18936
+ merge(input, options) {
18937
+ return executeListsMerge(adapters.lists, input, options);
18938
+ },
18939
+ split(input, options) {
18940
+ return executeListsSplit(adapters.lists, input, options);
18941
+ },
18721
18942
  setLevel(input, options) {
18722
18943
  return executeListsSetLevel(adapters.lists, input, options);
18723
18944
  },
@@ -19478,6 +19699,22 @@ function createDocumentApi(adapters) {
19478
19699
  return executeScrollIntoView(adapters.ranges, input);
19479
19700
  }
19480
19701
  },
19702
+ selection: {
19703
+ current(input) {
19704
+ const adapter = adapters.selection;
19705
+ if (!adapter) {
19706
+ throw new DocumentApiValidationError("SELECTION_ADAPTER_UNAVAILABLE", "No selection adapter was registered. Pass `selection` in DocumentApiAdapters to call selection.current().");
19707
+ }
19708
+ return executeSelectionCurrent(adapter, input);
19709
+ },
19710
+ onChange(listener) {
19711
+ const adapter = adapters.selection;
19712
+ if (!adapter) {
19713
+ throw new DocumentApiValidationError("SELECTION_ADAPTER_UNAVAILABLE", "No selection adapter was registered. Pass `selection` in DocumentApiAdapters to call selection.onChange().");
19714
+ }
19715
+ return adapter.onChange(listener);
19716
+ }
19717
+ },
19481
19718
  mutations: {
19482
19719
  preview(input) {
19483
19720
  return adapters.mutations.preview(input);
@@ -19551,6 +19788,7 @@ var ADAPTER_GATED_PREFIXES;
19551
19788
  var init_src = __esm(() => {
19552
19789
  init_errors2();
19553
19790
  init_ranges();
19791
+ init_selection();
19554
19792
  init_comments();
19555
19793
  init_find();
19556
19794
  init_format();
@@ -19563,6 +19801,7 @@ var init_src = __esm(() => {
19563
19801
  init_delete();
19564
19802
  init_resolve();
19565
19803
  init_scroll_into_view();
19804
+ init_selection();
19566
19805
  init_insert();
19567
19806
  init_lists();
19568
19807
  init_replace();
@@ -57307,7 +57546,7 @@ var init_uuid_qzgm05fK_es = __esm(() => {
57307
57546
  v5_default = v35("v5", 80, sha1);
57308
57547
  });
57309
57548
 
57310
- // ../../packages/superdoc/dist/chunks/constants-CGhJRd87.es.js
57549
+ // ../../packages/superdoc/dist/chunks/constants-DrU4EASo.es.js
57311
57550
  function computeCrc32Hex(data) {
57312
57551
  let crc = 4294967295;
57313
57552
  for (let i2 = 0;i2 < data.length; i2++)
@@ -57406,10 +57645,18 @@ function pixelsToEmu(px) {
57406
57645
  px = parseFloat(px);
57407
57646
  return Math.round(px * 9525);
57408
57647
  }
57409
- function eighthPointsToPixels(eighthPoints) {
57648
+ function eighthPointsToPixels(eighthPoints, { clamp = false } = {}) {
57410
57649
  if (eighthPoints == null)
57411
57650
  return;
57412
- return parseFloat(eighthPoints) / 8 * 1.3333;
57651
+ const numeric = parseFloat(eighthPoints);
57652
+ if (!Number.isFinite(numeric))
57653
+ return;
57654
+ if (clamp && numeric <= 0)
57655
+ return 0;
57656
+ const pixels = numeric / EIGHTHS_PER_POINT * (96 / 72);
57657
+ if (!clamp)
57658
+ return pixels;
57659
+ return Math.min(MAX_BORDER_SIZE_PX, Math.max(MIN_BORDER_SIZE_PX, pixels));
57413
57660
  }
57414
57661
  function pointsToTwips(points) {
57415
57662
  if (points == null)
@@ -57543,7 +57790,7 @@ function convertSizeToCSS(value, type) {
57543
57790
  return null;
57544
57791
  }
57545
57792
  }
57546
- var import_lib, CRC32_TABLE, REMOTE_RESOURCE_PATTERN, DATA_URI_PATTERN, getArrayBufferFromUrl = async (input) => {
57793
+ var import_lib, CRC32_TABLE, EIGHTHS_PER_POINT = 8, MIN_BORDER_SIZE_PX = 0.5, MAX_BORDER_SIZE_PX = 100, REMOTE_RESOURCE_PATTERN, DATA_URI_PATTERN, getArrayBufferFromUrl = async (input) => {
57547
57794
  if (input == null)
57548
57795
  return /* @__PURE__ */ new ArrayBuffer(0);
57549
57796
  if (input instanceof ArrayBuffer)
@@ -57704,7 +57951,7 @@ var import_lib, CRC32_TABLE, REMOTE_RESOURCE_PATTERN, DATA_URI_PATTERN, getArray
57704
57951
  return "webp";
57705
57952
  return null;
57706
57953
  }, COMMENT_FILE_BASENAMES, DEFAULT_XML_DECLARATION, COMMENT_RELATIONSHIP_TYPES;
57707
- var init_constants_CGhJRd87_es = __esm(() => {
57954
+ var init_constants_DrU4EASo_es = __esm(() => {
57708
57955
  init_xml_js_CqGKpaft_es();
57709
57956
  import_lib = require_lib();
57710
57957
  CRC32_TABLE = new Uint32Array(256);
@@ -65610,7 +65857,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
65610
65857
  emptyOptions2 = {};
65611
65858
  });
65612
65859
 
65613
- // ../../packages/superdoc/dist/chunks/SuperConverter-2Pu0hMB1.es.js
65860
+ // ../../packages/superdoc/dist/chunks/SuperConverter-lmyr0gmB.es.js
65614
65861
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
65615
65862
  const fieldValue = extension$1.config[field];
65616
65863
  if (typeof fieldValue === "function")
@@ -68320,6 +68567,22 @@ async function executeScrollIntoView2(adapter, input) {
68320
68567
  validateScrollIntoViewInput2(input);
68321
68568
  return adapter.scrollIntoView(input);
68322
68569
  }
68570
+ function validateSelectionCurrentInput2(input) {
68571
+ if (input === undefined)
68572
+ return;
68573
+ if (!isRecord4(input))
68574
+ throw new DocumentApiValidationError2("INVALID_INPUT", "selection.current input must be a non-null object.");
68575
+ assertNoUnknownFields3(input, SELECTION_CURRENT_ALLOWED_KEYS2, "selection.current");
68576
+ if (input.includeText !== undefined && typeof input.includeText !== "boolean")
68577
+ throw new DocumentApiValidationError2("INVALID_INPUT", `includeText must be a boolean, got ${typeof input.includeText}.`, {
68578
+ field: "includeText",
68579
+ value: input.includeText
68580
+ });
68581
+ }
68582
+ function executeSelectionCurrent2(adapter, input) {
68583
+ validateSelectionCurrentInput2(input);
68584
+ return adapter.current(input ?? {});
68585
+ }
68323
68586
  function executeMarkdownToFragment2(adapter, input) {
68324
68587
  return adapter.markdownToFragment(input);
68325
68588
  }
@@ -68347,8 +68610,8 @@ function validateCreateCommentInput2(input) {
68347
68610
  }
68348
68611
  if (!hasTarget)
68349
68612
  throw new DocumentApiValidationError2("INVALID_TARGET", "comments.create requires a target for root comments.", { field: "target" });
68350
- if (!isTextAddress2(target))
68351
- throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a text address object.", {
68613
+ if (!isTextAddress2(target) && !isTextTarget2(target))
68614
+ throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a TextAddress or TextTarget object.", {
68352
68615
  field: "target",
68353
68616
  value: target
68354
68617
  });
@@ -69512,6 +69775,16 @@ function executeListsSeparate2(adapter, input, options) {
69512
69775
  optionalBoolean2(input.copyOverrides, "copyOverrides", "lists.separate");
69513
69776
  return adapter.separate(input, normalizeMutationOptions2(options));
69514
69777
  }
69778
+ function executeListsMerge2(adapter, input, options) {
69779
+ validateListItemTarget2(input, "lists.merge");
69780
+ requireEnum2(input.direction, "direction", VALID_JOIN_DIRECTIONS2, "lists.merge");
69781
+ return adapter.merge(input, normalizeMutationOptions2(options));
69782
+ }
69783
+ function executeListsSplit2(adapter, input, options) {
69784
+ validateListItemTarget2(input, "lists.split");
69785
+ optionalBoolean2(input.restartNumbering, "restartNumbering", "lists.split");
69786
+ return adapter.split(input, normalizeMutationOptions2(options));
69787
+ }
69515
69788
  function executeListsSetLevel2(adapter, input, options) {
69516
69789
  validateListItemTarget2(input, "lists.setLevel");
69517
69790
  requireLevel2(input.level, "lists.setLevel");
@@ -70136,6 +70409,8 @@ function buildDispatchTable2(api) {
70136
70409
  "lists.join": (input, options) => api.lists.join(input, options),
70137
70410
  "lists.canJoin": (input) => api.lists.canJoin(input),
70138
70411
  "lists.separate": (input, options) => api.lists.separate(input, options),
70412
+ "lists.merge": (input, options) => api.lists.merge(input, options),
70413
+ "lists.split": (input, options) => api.lists.split(input, options),
70139
70414
  "lists.setLevel": (input, options) => api.lists.setLevel(input, options),
70140
70415
  "lists.setValue": (input, options) => api.lists.setValue(input, options),
70141
70416
  "lists.continuePrevious": (input, options) => api.lists.continuePrevious(input, options),
@@ -70189,6 +70464,7 @@ function buildDispatchTable2(api) {
70189
70464
  "trackChanges.decide": (input, options) => api.trackChanges.decide(input, options),
70190
70465
  "query.match": (input) => api.query.match(input),
70191
70466
  "ranges.resolve": (input) => api.ranges.resolve(input),
70467
+ "selection.current": (input) => api.selection.current(input),
70192
70468
  "mutations.preview": (input) => api.mutations.preview(input),
70193
70469
  "mutations.apply": (input) => api.mutations.apply(input),
70194
70470
  "capabilities.get": () => api.capabilities(),
@@ -72746,6 +73022,12 @@ function createDocumentApi2(adapters) {
72746
73022
  separate(input, options) {
72747
73023
  return executeListsSeparate2(adapters.lists, input, options);
72748
73024
  },
73025
+ merge(input, options) {
73026
+ return executeListsMerge2(adapters.lists, input, options);
73027
+ },
73028
+ split(input, options) {
73029
+ return executeListsSplit2(adapters.lists, input, options);
73030
+ },
72749
73031
  setLevel(input, options) {
72750
73032
  return executeListsSetLevel2(adapters.lists, input, options);
72751
73033
  },
@@ -73504,6 +73786,20 @@ function createDocumentApi2(adapters) {
73504
73786
  return executeScrollIntoView2(adapters.ranges, input);
73505
73787
  }
73506
73788
  },
73789
+ selection: {
73790
+ current(input) {
73791
+ const adapter = adapters.selection;
73792
+ if (!adapter)
73793
+ throw new DocumentApiValidationError2("SELECTION_ADAPTER_UNAVAILABLE", "No selection adapter was registered. Pass `selection` in DocumentApiAdapters to call selection.current().");
73794
+ return executeSelectionCurrent2(adapter, input);
73795
+ },
73796
+ onChange(listener) {
73797
+ const adapter = adapters.selection;
73798
+ if (!adapter)
73799
+ throw new DocumentApiValidationError2("SELECTION_ADAPTER_UNAVAILABLE", "No selection adapter was registered. Pass `selection` in DocumentApiAdapters to call selection.onChange().");
73800
+ return adapter.onChange(listener);
73801
+ }
73802
+ },
73507
73803
  mutations: {
73508
73804
  preview(input) {
73509
73805
  return adapters.mutations.preview(input);
@@ -77261,15 +77557,15 @@ function getPresetColor(name) {
77261
77557
  function applyModifiersAndAlpha(color2, elements) {
77262
77558
  let alpha = null;
77263
77559
  (elements || []).forEach((mod) => {
77264
- if (mod.name === "a:shade")
77560
+ if (hasLocalName(mod, "shade"))
77265
77561
  color2 = applyColorModifier(color2, "shade", mod.attributes["val"]);
77266
- else if (mod.name === "a:tint")
77562
+ else if (hasLocalName(mod, "tint"))
77267
77563
  color2 = applyColorModifier(color2, "tint", mod.attributes["val"]);
77268
- else if (mod.name === "a:lumMod")
77564
+ else if (hasLocalName(mod, "lumMod"))
77269
77565
  color2 = applyColorModifier(color2, "lumMod", mod.attributes["val"]);
77270
- else if (mod.name === "a:lumOff")
77566
+ else if (hasLocalName(mod, "lumOff"))
77271
77567
  color2 = applyColorModifier(color2, "lumOff", mod.attributes["val"]);
77272
- else if (mod.name === "a:alpha")
77568
+ else if (hasLocalName(mod, "alpha"))
77273
77569
  alpha = parseInt(mod.attributes["val"]) / 1e5;
77274
77570
  });
77275
77571
  return {
@@ -77280,15 +77576,15 @@ function applyModifiersAndAlpha(color2, elements) {
77280
77576
  function extractColorFromElement(element) {
77281
77577
  if (!element?.elements)
77282
77578
  return null;
77283
- const schemeClr = element.elements.find((el) => el.name === "a:schemeClr");
77579
+ const schemeClr = findChildByLocalName(element.elements, "schemeClr");
77284
77580
  if (schemeClr) {
77285
77581
  const themeName = schemeClr.attributes?.["val"];
77286
77582
  return applyModifiersAndAlpha(getThemeColor(themeName), schemeClr.elements);
77287
77583
  }
77288
- const srgbClr = element.elements.find((el) => el.name === "a:srgbClr");
77584
+ const srgbClr = findChildByLocalName(element.elements, "srgbClr");
77289
77585
  if (srgbClr)
77290
77586
  return applyModifiersAndAlpha("#" + srgbClr.attributes?.["val"], srgbClr.elements);
77291
- const prstClr = element.elements.find((el) => el.name === "a:prstClr");
77587
+ const prstClr = findChildByLocalName(element.elements, "prstClr");
77292
77588
  if (prstClr) {
77293
77589
  const presetName = prstClr.attributes?.["val"];
77294
77590
  const baseColor = getPresetColor(presetName);
@@ -77347,7 +77643,7 @@ function applyColorModifier(hexColor, modifier, value) {
77347
77643
  return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;
77348
77644
  }
77349
77645
  function extractStrokeWidth(spPr) {
77350
- const ln = spPr?.elements?.find((el) => el.name === "a:ln");
77646
+ const ln = findChildByLocalName(spPr?.elements, "ln");
77351
77647
  if (!ln)
77352
77648
  return 1;
77353
77649
  const w = ln.attributes?.["w"];
@@ -77359,11 +77655,11 @@ function extractStrokeWidth(spPr) {
77359
77655
  return emu * 72 / 914400;
77360
77656
  }
77361
77657
  function extractLineEnds(spPr) {
77362
- const ln = spPr?.elements?.find((el) => el.name === "a:ln");
77658
+ const ln = findChildByLocalName(spPr?.elements, "ln");
77363
77659
  if (!ln?.elements)
77364
77660
  return null;
77365
- const parseEnd = (name) => {
77366
- const end = ln.elements.find((el) => el.name === name);
77661
+ const parseEnd = (localName) => {
77662
+ const end = findChildByLocalName(ln.elements, localName);
77367
77663
  if (!end?.attributes)
77368
77664
  return null;
77369
77665
  const type = end.attributes?.["type"];
@@ -77375,21 +77671,21 @@ function extractLineEnds(spPr) {
77375
77671
  length: end.attributes?.["len"]
77376
77672
  };
77377
77673
  };
77378
- const head = parseEnd("a:headEnd");
77379
- const tail = parseEnd("a:tailEnd");
77380
- if (!head && !tail)
77674
+ const headConfig = parseEnd("headEnd");
77675
+ const tailConfig = parseEnd("tailEnd");
77676
+ if (!headConfig && !tailConfig)
77381
77677
  return null;
77382
77678
  return {
77383
- head: head ?? undefined,
77384
- tail: tail ?? undefined
77679
+ head: headConfig ?? undefined,
77680
+ tail: tailConfig ?? undefined
77385
77681
  };
77386
77682
  }
77387
77683
  function extractStrokeColor(spPr, style) {
77388
- const ln = spPr?.elements?.find((el) => el.name === "a:ln");
77684
+ const ln = findChildByLocalName(spPr?.elements, "ln");
77389
77685
  if (ln) {
77390
- if (ln.elements?.find((el) => el.name === "a:noFill"))
77686
+ if (findChildByLocalName(ln.elements, "noFill"))
77391
77687
  return null;
77392
- const solidFill = ln.elements?.find((el) => el.name === "a:solidFill");
77688
+ const solidFill = findChildByLocalName(ln.elements, "solidFill");
77393
77689
  if (solidFill) {
77394
77690
  const result = extractColorFromElement(solidFill);
77395
77691
  if (result)
@@ -77398,7 +77694,7 @@ function extractStrokeColor(spPr, style) {
77398
77694
  }
77399
77695
  if (!style)
77400
77696
  return null;
77401
- const lnRef = style.elements?.find((el) => el.name === "a:lnRef");
77697
+ const lnRef = findChildByLocalName(style.elements, "lnRef");
77402
77698
  if (!lnRef)
77403
77699
  return null;
77404
77700
  if (lnRef.attributes?.["idx"] === "0")
@@ -77409,9 +77705,9 @@ function extractStrokeColor(spPr, style) {
77409
77705
  return null;
77410
77706
  }
77411
77707
  function extractFillColor(spPr, style) {
77412
- if (spPr?.elements?.find((el) => el.name === "a:noFill"))
77708
+ if (findChildByLocalName(spPr?.elements, "noFill"))
77413
77709
  return null;
77414
- const solidFill = spPr?.elements?.find((el) => el.name === "a:solidFill");
77710
+ const solidFill = findChildByLocalName(spPr?.elements, "solidFill");
77415
77711
  if (solidFill) {
77416
77712
  const result = extractColorFromElement(solidFill);
77417
77713
  if (result) {
@@ -77424,14 +77720,14 @@ function extractFillColor(spPr, style) {
77424
77720
  return result.color;
77425
77721
  }
77426
77722
  }
77427
- const gradFill = spPr?.elements?.find((el) => el.name === "a:gradFill");
77723
+ const gradFill = findChildByLocalName(spPr?.elements, "gradFill");
77428
77724
  if (gradFill)
77429
77725
  return extractGradientFill(gradFill);
77430
- if (spPr?.elements?.find((el) => el.name === "a:blipFill"))
77726
+ if (findChildByLocalName(spPr?.elements, "blipFill"))
77431
77727
  return "#cccccc";
77432
77728
  if (!style)
77433
77729
  return null;
77434
- const fillRef = style.elements?.find((el) => el.name === "a:fillRef");
77730
+ const fillRef = findChildByLocalName(style.elements, "fillRef");
77435
77731
  if (!fillRef)
77436
77732
  return null;
77437
77733
  if (fillRef.attributes?.["idx"] === "0")
@@ -77449,13 +77745,13 @@ function extractFillColor(spPr, style) {
77449
77745
  return null;
77450
77746
  }
77451
77747
  function extractCustomGeometry(spPr) {
77452
- const custGeom = spPr?.elements?.find((el) => el.name === "a:custGeom");
77748
+ const custGeom = findChildByLocalName(spPr?.elements, "custGeom");
77453
77749
  if (!custGeom)
77454
77750
  return null;
77455
- const pathLst = custGeom.elements?.find((el) => el.name === "a:pathLst");
77751
+ const pathLst = findChildByLocalName(custGeom.elements, "pathLst");
77456
77752
  if (!pathLst?.elements)
77457
77753
  return null;
77458
- const paths = pathLst.elements.filter((el) => el.name === "a:path").map((pathEl) => {
77754
+ const paths = pathLst.elements.filter((el) => hasLocalName(el, "path")).map((pathEl) => {
77459
77755
  const w = parseInt(pathEl.attributes?.["w"] || "0", 10);
77460
77756
  const h = parseInt(pathEl.attributes?.["h"] || "0", 10);
77461
77757
  return {
@@ -77473,32 +77769,32 @@ function convertDrawingMLPathToSvg(pathEl) {
77473
77769
  return "";
77474
77770
  const parts = [];
77475
77771
  for (const cmd of pathEl.elements)
77476
- switch (cmd.name) {
77477
- case "a:moveTo": {
77478
- const pt = cmd.elements?.find((el) => el.name === "a:pt");
77772
+ switch (getLocalName$1(cmd.name)) {
77773
+ case "moveTo": {
77774
+ const pt = findChildByLocalName(cmd.elements, "pt");
77479
77775
  if (pt)
77480
77776
  parts.push(`M ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
77481
77777
  break;
77482
77778
  }
77483
- case "a:lnTo": {
77484
- const pt = cmd.elements?.find((el) => el.name === "a:pt");
77779
+ case "lnTo": {
77780
+ const pt = findChildByLocalName(cmd.elements, "pt");
77485
77781
  if (pt)
77486
77782
  parts.push(`L ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
77487
77783
  break;
77488
77784
  }
77489
- case "a:cubicBezTo": {
77490
- const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
77785
+ case "cubicBezTo": {
77786
+ const pts = filterChildrenByLocalName(cmd.elements, "pt") || [];
77491
77787
  if (pts.length === 3)
77492
77788
  parts.push(`C ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0} ${pts[2].attributes?.["x"] || 0} ${pts[2].attributes?.["y"] || 0}`);
77493
77789
  break;
77494
77790
  }
77495
- case "a:quadBezTo": {
77496
- const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
77791
+ case "quadBezTo": {
77792
+ const pts = filterChildrenByLocalName(cmd.elements, "pt") || [];
77497
77793
  if (pts.length === 2)
77498
77794
  parts.push(`Q ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0}`);
77499
77795
  break;
77500
77796
  }
77501
- case "a:close":
77797
+ case "close":
77502
77798
  parts.push("Z");
77503
77799
  break;
77504
77800
  default:
@@ -77512,16 +77808,16 @@ function extractGradientFill(gradFill) {
77512
77808
  stops: [],
77513
77809
  angle: 0
77514
77810
  };
77515
- const gsLst = gradFill.elements?.find((el) => el.name === "a:gsLst");
77811
+ const gsLst = findChildByLocalName(gradFill.elements, "gsLst");
77516
77812
  if (gsLst)
77517
- gradient.stops = (gsLst.elements?.filter((el) => el.name === "a:gs") || []).map((stop) => {
77813
+ gradient.stops = (filterChildrenByLocalName(gsLst.elements, "gs") || []).map((stop) => {
77518
77814
  const pos = parseInt(stop.attributes?.["pos"] || "0", 10) / 1e5;
77519
- const srgbClr = stop.elements?.find((el) => el.name === "a:srgbClr");
77815
+ const srgbClr = findChildByLocalName(stop.elements, "srgbClr");
77520
77816
  let color2 = "#000000";
77521
77817
  let alpha = 1;
77522
77818
  if (srgbClr) {
77523
77819
  color2 = "#" + srgbClr.attributes?.["val"];
77524
- const alphaEl = srgbClr.elements?.find((el) => el.name === "a:alpha");
77820
+ const alphaEl = findChildByLocalName(srgbClr.elements, "alpha");
77525
77821
  if (alphaEl)
77526
77822
  alpha = parseInt(alphaEl.attributes?.["val"] || "100000", 10) / 1e5;
77527
77823
  }
@@ -77531,10 +77827,10 @@ function extractGradientFill(gradFill) {
77531
77827
  alpha
77532
77828
  };
77533
77829
  });
77534
- const lin = gradFill.elements?.find((el) => el.name === "a:lin");
77830
+ const lin = findChildByLocalName(gradFill.elements, "lin");
77535
77831
  if (lin)
77536
77832
  gradient.angle = parseInt(lin.attributes?.["ang"] || "0", 10) / 60000;
77537
- const path2 = gradFill.elements?.find((el) => el.name === "a:path");
77833
+ const path2 = findChildByLocalName(gradFill.elements, "path");
77538
77834
  if (path2) {
77539
77835
  gradient.gradientType = "radial";
77540
77836
  gradient.path = path2.attributes?.["path"] || "circle";
@@ -78659,7 +78955,7 @@ function handleImageNode(node3, params3, isAnchor) {
78659
78955
  alignH,
78660
78956
  alignV
78661
78957
  };
78662
- const graphicData = node3.elements.find((el) => el.name === "a:graphic")?.elements.find((el) => el.name === "a:graphicData");
78958
+ const graphicData = findChildByLocalName(findChildByLocalName(node3.elements, "graphic")?.elements, "graphicData");
78663
78959
  const { uri } = graphicData?.attributes || {};
78664
78960
  if (!graphicData)
78665
78961
  return null;
@@ -78681,20 +78977,20 @@ function handleImageNode(node3, params3, isAnchor) {
78681
78977
  if (!picture || !picture.elements)
78682
78978
  return null;
78683
78979
  const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
78684
- const blip = blipFill?.elements.find((el) => el.name === "a:blip");
78980
+ const blip = findChildByLocalName(blipFill?.elements, "blip");
78685
78981
  if (!blip)
78686
78982
  return null;
78687
- const hasGrayscale = blip.elements?.some((el) => el.name === "a:grayscl");
78688
- const lumEl = blip.elements?.find((el) => el.name === "a:lum");
78983
+ const hasGrayscale = someChildHasLocalName(blip.elements, "grayscl");
78984
+ const lumEl = findChildByLocalName(blip.elements, "lum");
78689
78985
  const rawBright = Number(lumEl?.attributes?.bright);
78690
78986
  const rawContrast = Number(lumEl?.attributes?.contrast);
78691
78987
  const lum = Number.isFinite(rawBright) || Number.isFinite(rawContrast) ? {
78692
78988
  ...Number.isFinite(rawBright) ? { bright: rawBright } : {},
78693
78989
  ...Number.isFinite(rawContrast) ? { contrast: rawContrast } : {}
78694
78990
  } : undefined;
78695
- const stretch = blipFill?.elements?.find((el) => el.name === "a:stretch");
78696
- const fillRect = stretch?.elements?.find((el) => el.name === "a:fillRect");
78697
- const srcRect = blipFill?.elements?.find((el) => el.name === "a:srcRect");
78991
+ const stretch = findChildByLocalName(blipFill?.elements, "stretch");
78992
+ const fillRect = findChildByLocalName(stretch?.elements, "fillRect");
78993
+ const srcRect = findChildByLocalName(blipFill?.elements, "srcRect");
78698
78994
  const srcRectAttrs = srcRect?.attributes || {};
78699
78995
  const clipPath = buildClipPathFromSrcRect(srcRectAttrs);
78700
78996
  const srcRectHasNegativeValues = [
@@ -78711,7 +79007,7 @@ function handleImageNode(node3, params3, isAnchor) {
78711
79007
  const shouldFillClippedStretch = shouldStretch && !srcRectHasNegativeValues && Boolean(clipPath);
78712
79008
  const spPr = picture.elements.find((el) => el.name === "pic:spPr");
78713
79009
  if (spPr) {
78714
- const xfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
79010
+ const xfrm = findChildByLocalName(spPr.elements, "xfrm");
78715
79011
  if (xfrm?.attributes)
78716
79012
  transformData = {
78717
79013
  ...transformData,
@@ -78721,9 +79017,11 @@ function handleImageNode(node3, params3, isAnchor) {
78721
79017
  };
78722
79018
  }
78723
79019
  const nvPicPr = picture.elements.find((el) => el.name === "pic:nvPicPr");
78724
- const picLocks = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPicPr")?.elements?.find((el) => el.name === "a:picLocks");
79020
+ const cNvPicPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPicPr");
79021
+ const picLocks = findChildByLocalName(cNvPicPr?.elements, "picLocks");
78725
79022
  const lockAspectRatio = picLocks ? picLocks.attributes?.["noChangeAspect"] === "1" || picLocks.attributes?.["noChangeAspect"] === 1 : false;
78726
- const hlinkClick = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr")?.elements?.find((el) => el.name === "a:hlinkClick") || docPr?.elements?.find((el) => el.name === "a:hlinkClick");
79023
+ const cNvPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr");
79024
+ const hlinkClick = findChildByLocalName(cNvPr?.elements, "hlinkClick") || findChildByLocalName(docPr?.elements, "hlinkClick");
78727
79025
  let hyperlink = null;
78728
79026
  if (hlinkClick?.attributes?.["r:id"]) {
78729
79027
  const hlinkRId = hlinkClick.attributes["r:id"];
@@ -78738,12 +79036,12 @@ function handleImageNode(node3, params3, isAnchor) {
78738
79036
  }
78739
79037
  }
78740
79038
  let decorative = false;
78741
- const docPrExtLst = docPr?.elements?.find((el) => el.name === "a:extLst");
79039
+ const docPrExtLst = findChildByLocalName(docPr?.elements, "extLst");
78742
79040
  if (docPrExtLst)
78743
79041
  for (const ext of docPrExtLst.elements || []) {
78744
- if (ext.name !== "a:ext")
79042
+ if (!hasLocalName(ext, "ext"))
78745
79043
  continue;
78746
- const decEl = ext.elements?.find((el) => el.name === "adec:decorative" || el.name === "a16:decorative");
79044
+ const decEl = findChildByLocalName(ext.elements, "decorative");
78747
79045
  if (decEl && (decEl.attributes?.["val"] === "1" || decEl.attributes?.["val"] === 1)) {
78748
79046
  decorative = true;
78749
79047
  break;
@@ -78988,7 +79286,7 @@ function getVectorShape({ params: params3, node: node3, graphicData, size: size2
78988
79286
  const spPr = wsp.elements?.find((el) => el.name === "wps:spPr");
78989
79287
  if (!spPr)
78990
79288
  return null;
78991
- const shapeKind = spPr.elements?.find((el) => el.name === "a:prstGeom")?.attributes?.["prst"];
79289
+ const shapeKind = findChildByLocalName(spPr.elements, "prstGeom")?.attributes?.["prst"];
78992
79290
  schemaAttrs.kind = shapeKind;
78993
79291
  if (customGeometry)
78994
79292
  schemaAttrs.customGeometry = customGeometry;
@@ -78999,7 +79297,7 @@ function getVectorShape({ params: params3, node: node3, graphicData, size: size2
78999
79297
  }
79000
79298
  const width = size2?.width ?? DEFAULT_SHAPE_WIDTH;
79001
79299
  const height = size2?.height ?? DEFAULT_SHAPE_HEIGHT;
79002
- const xfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
79300
+ const xfrm = findChildByLocalName(spPr.elements, "xfrm");
79003
79301
  const rotation = xfrm?.attributes?.["rot"] ? rotToDegrees(xfrm.attributes["rot"]) : 0;
79004
79302
  const flipH = xfrm?.attributes?.["flipH"] === "1";
79005
79303
  const flipV = xfrm?.attributes?.["flipV"] === "1";
@@ -92067,7 +92365,7 @@ function fixZeroDrawingIds(merged, generated) {
92067
92365
  const docPr = merged.find((el) => el?.name === "wp:docPr");
92068
92366
  if (docPr?.attributes && !(Number(docPr.attributes.id) > 0))
92069
92367
  docPr.attributes.id = validId;
92070
- const cNvPr = merged.find((el) => el?.name === "a:graphic")?.elements?.find((el) => el?.name === "a:graphicData")?.elements?.find((el) => el?.name === "pic:pic")?.elements?.find((el) => el?.name === "pic:nvPicPr")?.elements?.find((el) => el?.name === "pic:cNvPr");
92368
+ const cNvPr = findChildByLocalName(findChildByLocalName(merged, "graphic")?.elements, "graphicData")?.elements?.find((el) => el?.name === "pic:pic")?.elements?.find((el) => el?.name === "pic:nvPicPr")?.elements?.find((el) => el?.name === "pic:cNvPr");
92071
92369
  if (cNvPr?.attributes && !(Number(cNvPr.attributes.id) > 0))
92072
92370
  cNvPr.attributes.id = validId;
92073
92371
  }
@@ -95818,7 +96116,8 @@ function createStoryEditor(parentEditor, content$2, options = {}) {
95818
96116
  collaborationProvider: null,
95819
96117
  isCommentsEnabled: false,
95820
96118
  fragment: null,
95821
- ...editorOptions
96119
+ ...editorOptions,
96120
+ telemetry: { enabled: false }
95822
96121
  });
95823
96122
  const inheritedPresentationEditor = parentEditor.presentationEditor ?? parentEditor._presentationEditor ?? null;
95824
96123
  if (inheritedPresentationEditor) {
@@ -96868,6 +97167,57 @@ function resolveSegmentPosition(targetOffset, segmentStart, segmentLength, docFr
96868
97167
  return targetOffset <= segmentStart ? docFrom : docTo;
96869
97168
  return docFrom + (targetOffset - segmentStart);
96870
97169
  }
97170
+ function pmPositionToTextOffset(blockNode, blockPos, pmPos) {
97171
+ const contentStart = blockPos + 1;
97172
+ if (pmPos <= contentStart)
97173
+ return 0;
97174
+ let offset = 0;
97175
+ let done = false;
97176
+ const visit2 = (node3, docPos) => {
97177
+ if (done)
97178
+ return;
97179
+ if (node3.isText) {
97180
+ const text$2 = node3.text ?? "";
97181
+ if (pmPos >= docPos + text$2.length)
97182
+ offset += text$2.length;
97183
+ else {
97184
+ offset += Math.max(0, pmPos - docPos);
97185
+ done = true;
97186
+ }
97187
+ return;
97188
+ }
97189
+ if (node3.isLeaf) {
97190
+ if (pmPos >= docPos + node3.nodeSize)
97191
+ offset += 1;
97192
+ else
97193
+ done = true;
97194
+ return;
97195
+ }
97196
+ visitContent(node3, docPos + 1);
97197
+ };
97198
+ const visitContent = (node3, contentPos) => {
97199
+ let isFirst = true;
97200
+ let childOffset = 0;
97201
+ for (let i$1 = 0;i$1 < node3.childCount; i$1 += 1) {
97202
+ if (done)
97203
+ return;
97204
+ const child = node3.child(i$1);
97205
+ const childPos = contentPos + childOffset;
97206
+ if (child.isBlock && !isFirst)
97207
+ if (pmPos >= childPos + 1)
97208
+ offset += 1;
97209
+ else {
97210
+ done = true;
97211
+ return;
97212
+ }
97213
+ visit2(child, childPos);
97214
+ childOffset += child.nodeSize;
97215
+ isFirst = false;
97216
+ }
97217
+ };
97218
+ visitContent(blockNode, contentStart);
97219
+ return offset;
97220
+ }
96871
97221
  function computeTextContentLength(blockNode) {
96872
97222
  let length3 = 0;
96873
97223
  const walk = (node3) => {
@@ -103431,7 +103781,7 @@ var isRegExp = (value) => {
103431
103781
  tracked: false,
103432
103782
  carrier: runAttributeCarrier2(runPropertyKey ?? key),
103433
103783
  schema
103434
- }), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, PROPERTY_VALIDATOR_MAP2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_STORY2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, T_PROTECTION_READ2, T_PROTECTION_MUTATION2, T_PERM_RANGE_READ2, T_PERM_RANGE_MUTATION2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_DIRECTIONS2, ALIGNMENT_POLICIES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, SET_DIRECTION_KEYS2, CLEAR_DIRECTION_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY2, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, tableAddressSchema2, tableRowAddressSchema2, tableCellAddressSchema2, tableOrCellAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationRangeSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, storyLocatorSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, documentStylesSchema2, documentDefaultsSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, trackChangeWordRevisionIdsSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, nullableTableBorderSpecSchema2, sdFragmentSchema2, placementSchema2, nestingPolicySchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, diffCoverageSchema2, diffSummarySchema2, diffSnapshotSchema2, diffPayloadSchema2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, VALID_ENTITY_TYPES2, SCROLL_INTO_VIEW_ALLOWED_KEYS2, VALID_BLOCK_VALUES2, VALID_BEHAVIOR_VALUES2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, TEXT_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, LIST_KINDS2, LIST_INSERT_POSITIONS2, JOIN_DIRECTIONS2, MUTATION_SCOPES2, LEVEL_ALIGNMENTS2, TRAILING_CHARACTERS2, LIST_PRESET_IDS2, VALID_BLOCK_NODE_TYPES$1, VALID_LIST_KINDS2, VALID_INSERT_POSITIONS2, VALID_JOIN_DIRECTIONS2, VALID_MUTATION_SCOPES2, VALID_LEVEL_ALIGNMENTS2, VALID_TRAILING_CHARACTERS2, VALID_LIST_PRESETS2, VALID_CONTINUITY_VALUES2, VALID_SEQUENCE_MODES2, VALID_LIST_CREATE_MODES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, VALID_HEADING_LEVELS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES3, SNAPSHOT_VERSIONS2, PAYLOAD_VERSIONS2, VALID_STYLE_OPTION_FLAGS2, TABLE_BORDER_COLOR_PATTERN2, VALID_APPLY_TO_VALUES2, VALID_BORDER_EDGE_KEYS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, VALID_TOC_UPDATE_MODES2, EDIT_ENTRY_PATCH_ALLOWED_KEYS2, PATCH_FIELDS2, CONTENT_CONTROL_TYPES2, LOCK_MODES2, CONTENT_CONTROL_APPEARANCES2, VALID_NODE_KINDS2, VALID_LOCK_MODES$1, VALID_CC_TYPES2, VALID_CC_APPEARANCES2, VALID_CONTENT_FORMATS2, VALID_RAW_PATCH_OPS2, VALID_SET_MODES2, VALID_CREATE_LOCATION_KINDS2, DEFAULT_PROTECTION_STATE, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$217) => ({
103784
+ }), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, PROPERTY_VALIDATOR_MAP2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_STORY2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, T_PROTECTION_READ2, T_PROTECTION_MUTATION2, T_PERM_RANGE_READ2, T_PERM_RANGE_MUTATION2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_DIRECTIONS2, ALIGNMENT_POLICIES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, SET_DIRECTION_KEYS2, CLEAR_DIRECTION_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY2, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, tableAddressSchema2, tableRowAddressSchema2, tableCellAddressSchema2, tableOrCellAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationRangeSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, storyLocatorSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, documentStylesSchema2, documentDefaultsSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, trackChangeWordRevisionIdsSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, nullableTableBorderSpecSchema2, sdFragmentSchema2, placementSchema2, nestingPolicySchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, diffCoverageSchema2, diffSummarySchema2, diffSnapshotSchema2, diffPayloadSchema2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, VALID_ENTITY_TYPES2, SCROLL_INTO_VIEW_ALLOWED_KEYS2, VALID_BLOCK_VALUES2, VALID_BEHAVIOR_VALUES2, SELECTION_CURRENT_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, TEXT_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, LIST_KINDS2, LIST_INSERT_POSITIONS2, JOIN_DIRECTIONS2, MUTATION_SCOPES2, LEVEL_ALIGNMENTS2, TRAILING_CHARACTERS2, LIST_PRESET_IDS2, VALID_BLOCK_NODE_TYPES$1, VALID_LIST_KINDS2, VALID_INSERT_POSITIONS2, VALID_JOIN_DIRECTIONS2, VALID_MUTATION_SCOPES2, VALID_LEVEL_ALIGNMENTS2, VALID_TRAILING_CHARACTERS2, VALID_LIST_PRESETS2, VALID_CONTINUITY_VALUES2, VALID_SEQUENCE_MODES2, VALID_LIST_CREATE_MODES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, VALID_HEADING_LEVELS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES3, SNAPSHOT_VERSIONS2, PAYLOAD_VERSIONS2, VALID_STYLE_OPTION_FLAGS2, TABLE_BORDER_COLOR_PATTERN2, VALID_APPLY_TO_VALUES2, VALID_BORDER_EDGE_KEYS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, VALID_TOC_UPDATE_MODES2, EDIT_ENTRY_PATCH_ALLOWED_KEYS2, PATCH_FIELDS2, CONTENT_CONTROL_TYPES2, LOCK_MODES2, CONTENT_CONTROL_APPEARANCES2, VALID_NODE_KINDS2, VALID_LOCK_MODES$1, VALID_CC_TYPES2, VALID_CC_APPEARANCES2, VALID_CONTENT_FORMATS2, VALID_RAW_PATCH_OPS2, VALID_SET_MODES2, VALID_CREATE_LOCATION_KINDS2, DEFAULT_PROTECTION_STATE, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$217) => ({
103435
103785
  handlerName,
103436
103786
  handler: (params3) => {
103437
103787
  const { nodes } = params3;
@@ -105659,6 +106009,27 @@ var isRegExp = (value) => {
105659
106009
  getState(state) {
105660
106010
  return state[this.key];
105661
106011
  }
106012
+ }, getLocalName$1 = (name) => {
106013
+ if (typeof name !== "string")
106014
+ return "";
106015
+ const parts = name.split(":");
106016
+ return parts.length ? parts[parts.length - 1] : name;
106017
+ }, hasLocalName = (node3, localName) => {
106018
+ if (!node3 || typeof node3 !== "object")
106019
+ return false;
106020
+ return getLocalName$1(node3.name) === localName;
106021
+ }, findChildByLocalName = (elements, localName) => {
106022
+ if (!Array.isArray(elements))
106023
+ return;
106024
+ return elements.find((el) => hasLocalName(el, localName));
106025
+ }, filterChildrenByLocalName = (elements, localName) => {
106026
+ if (!Array.isArray(elements))
106027
+ return [];
106028
+ return elements.filter((el) => hasLocalName(el, localName));
106029
+ }, someChildHasLocalName = (elements, localName) => {
106030
+ if (!Array.isArray(elements))
106031
+ return false;
106032
+ return elements.some((el) => hasLocalName(el, localName));
105662
106033
  }, SVGFilters = class {
105663
106034
  flood(filter, resultId, color2, opacity, _settings) {
105664
106035
  const floodElement = document.createElementNS("http://www.w3.org/2000/svg", "feFlood");
@@ -109587,7 +109958,7 @@ var isRegExp = (value) => {
109587
109958
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
109588
109959
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
109589
109960
  const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
109590
- const shapeType = spPr?.elements.find((el) => el.name === "a:prstGeom")?.attributes["prst"];
109961
+ const shapeType = findChildByLocalName(spPr?.elements, "prstGeom")?.attributes["prst"];
109591
109962
  const custGeom = !shapeType ? extractCustomGeometry(spPr) : null;
109592
109963
  if (shapeType || custGeom) {
109593
109964
  const result = getVectorShape({
@@ -109618,13 +109989,13 @@ var isRegExp = (value) => {
109618
109989
  placeholder.attrs.hidden = true;
109619
109990
  return placeholder;
109620
109991
  }
109621
- const xfrm = wgp.elements.find((el) => el.name === "wpg:grpSpPr")?.elements?.find((el) => el.name === "a:xfrm");
109992
+ const xfrm = findChildByLocalName(wgp.elements.find((el) => el.name === "wpg:grpSpPr")?.elements, "xfrm");
109622
109993
  const groupTransform = {};
109623
109994
  if (xfrm) {
109624
- const off = xfrm.elements?.find((el) => el.name === "a:off");
109625
- const ext = xfrm.elements?.find((el) => el.name === "a:ext");
109626
- const chOff = xfrm.elements?.find((el) => el.name === "a:chOff");
109627
- const chExt = xfrm.elements?.find((el) => el.name === "a:chExt");
109995
+ const off = findChildByLocalName(xfrm.elements, "off");
109996
+ const ext = findChildByLocalName(xfrm.elements, "ext");
109997
+ const chOff = findChildByLocalName(xfrm.elements, "chOff");
109998
+ const chExt = findChildByLocalName(xfrm.elements, "chExt");
109628
109999
  if (off) {
109629
110000
  groupTransform.x = emuToPixels(off.attributes?.["x"] || 0);
109630
110001
  groupTransform.y = emuToPixels(off.attributes?.["y"] || 0);
@@ -109650,11 +110021,11 @@ var isRegExp = (value) => {
109650
110021
  const spPr = wsp.elements?.find((el) => el.name === "wps:spPr");
109651
110022
  if (!spPr)
109652
110023
  return null;
109653
- const shapeKind = spPr.elements?.find((el) => el.name === "a:prstGeom")?.attributes?.["prst"];
110024
+ const shapeKind = findChildByLocalName(spPr.elements, "prstGeom")?.attributes?.["prst"];
109654
110025
  const customGeom = !shapeKind ? extractCustomGeometry(spPr) : null;
109655
- const shapeXfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
109656
- const shapeOff = shapeXfrm?.elements?.find((el) => el.name === "a:off");
109657
- const shapeExt = shapeXfrm?.elements?.find((el) => el.name === "a:ext");
110026
+ const shapeXfrm = findChildByLocalName(spPr.elements, "xfrm");
110027
+ const shapeOff = findChildByLocalName(shapeXfrm?.elements, "off");
110028
+ const shapeExt = findChildByLocalName(shapeXfrm?.elements, "ext");
109658
110029
  const rawX = shapeOff?.attributes?.["x"] ? parseFloat(shapeOff.attributes["x"]) : 0;
109659
110030
  const rawY = shapeOff?.attributes?.["y"] ? parseFloat(shapeOff.attributes["y"]) : 0;
109660
110031
  const rawWidth = shapeExt?.attributes?.["cx"] ? parseFloat(shapeExt.attributes["cx"]) : 914400;
@@ -109721,9 +110092,9 @@ var isRegExp = (value) => {
109721
110092
  const spPr = pic.elements?.find((el) => el.name === "pic:spPr");
109722
110093
  if (!spPr)
109723
110094
  return null;
109724
- const xfrm$1 = spPr.elements?.find((el) => el.name === "a:xfrm");
109725
- const off = xfrm$1?.elements?.find((el) => el.name === "a:off");
109726
- const ext = xfrm$1?.elements?.find((el) => el.name === "a:ext");
110095
+ const xfrm$1 = findChildByLocalName(spPr.elements, "xfrm");
110096
+ const off = findChildByLocalName(xfrm$1?.elements, "off");
110097
+ const ext = findChildByLocalName(xfrm$1?.elements, "ext");
109727
110098
  const rawX = off?.attributes?.["x"] ? parseFloat(off.attributes["x"]) : 0;
109728
110099
  const rawY = off?.attributes?.["y"] ? parseFloat(off.attributes["y"]) : 0;
109729
110100
  const rawWidth = ext?.attributes?.["cx"] ? parseFloat(ext.attributes["cx"]) : 914400;
@@ -109744,7 +110115,8 @@ var isRegExp = (value) => {
109744
110115
  width = emuToPixels(rawWidth);
109745
110116
  height = emuToPixels(rawHeight);
109746
110117
  }
109747
- const blip = pic.elements?.find((el) => el.name === "pic:blipFill")?.elements?.find((el) => el.name === "a:blip");
110118
+ const blipFill = pic.elements?.find((el) => el.name === "pic:blipFill");
110119
+ const blip = findChildByLocalName(blipFill?.elements, "blip");
109748
110120
  if (!blip)
109749
110121
  return null;
109750
110122
  const rEmbed = blip.attributes?.["r:embed"];
@@ -117890,12 +118262,12 @@ var isRegExp = (value) => {
117890
118262
  state.kern = kernNode.attributes["w:val"];
117891
118263
  }
117892
118264
  }, SuperConverter;
117893
- var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
118265
+ var init_SuperConverter_lmyr0gmB_es = __esm(() => {
117894
118266
  init_rolldown_runtime_Bg48TavK_es();
117895
118267
  init_jszip_C49i9kUs_es();
117896
118268
  init_xml_js_CqGKpaft_es();
117897
118269
  init_uuid_qzgm05fK_es();
117898
- init_constants_CGhJRd87_es();
118270
+ init_constants_DrU4EASo_es();
117899
118271
  init_dist_B8HfvhaK_es();
117900
118272
  init_unified_Dsuw2be5_es();
117901
118273
  init_lib_CYqLdG4z_es();
@@ -122071,7 +122443,9 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
122071
122443
  throws: [...T_NOT_FOUND_CAPABLE2, "INVALID_TARGET"]
122072
122444
  }),
122073
122445
  referenceDocPath: "lists/attach.mdx",
122074
- referenceGroup: "lists"
122446
+ referenceGroup: "lists",
122447
+ intentGroup: "list",
122448
+ intentAction: "attach"
122075
122449
  },
122076
122450
  "lists.detach": {
122077
122451
  memberPath: "lists.detach",
@@ -122183,6 +122557,44 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
122183
122557
  referenceDocPath: "lists/separate.mdx",
122184
122558
  referenceGroup: "lists"
122185
122559
  },
122560
+ "lists.merge": {
122561
+ memberPath: "lists.merge",
122562
+ description: 'Compound: merge two adjacent list sequences into one. Reassigns numId on the absorbed sequence (no strict abstractNumId check — absorbed items adopt the absorbing definition) and deletes empty paragraphs between the two sequences. Use this instead of lists.join for the user-facing "merge these lists" intent.',
122563
+ expectedResult: "Returns a ListsMergeResult with the merged listId, absorbedCount, and removedEmptyBlocks count.",
122564
+ requiresDocumentContext: true,
122565
+ metadata: mutationOperation2({
122566
+ idempotency: "conditional",
122567
+ supportsDryRun: true,
122568
+ supportsTrackedMode: false,
122569
+ possibleFailureCodes: [
122570
+ "INVALID_TARGET",
122571
+ "NO_ADJACENT_SEQUENCE",
122572
+ "NO_OP"
122573
+ ],
122574
+ throws: [...T_NOT_FOUND_CAPABLE2, "INVALID_TARGET"]
122575
+ }),
122576
+ referenceDocPath: "lists/merge.mdx",
122577
+ referenceGroup: "lists",
122578
+ intentGroup: "list",
122579
+ intentAction: "merge"
122580
+ },
122581
+ "lists.split": {
122582
+ memberPath: "lists.split",
122583
+ description: "Compound: split a list sequence at the target item into two independent sequences. Runs lists.separate then (by default) lists.setValue(1) so the new half starts numbering fresh at 1. Pass restartNumbering:false for raw separate semantics (new half continues the previous count).",
122584
+ expectedResult: "Returns a ListsSplitResult with the new listId, numId, and the restart value applied (or null).",
122585
+ requiresDocumentContext: true,
122586
+ metadata: mutationOperation2({
122587
+ idempotency: "conditional",
122588
+ supportsDryRun: true,
122589
+ supportsTrackedMode: false,
122590
+ possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
122591
+ throws: [...T_NOT_FOUND_CAPABLE2, "INVALID_TARGET"]
122592
+ }),
122593
+ referenceDocPath: "lists/split.mdx",
122594
+ referenceGroup: "lists",
122595
+ intentGroup: "list",
122596
+ intentAction: "split"
122597
+ },
122186
122598
  "lists.setLevel": {
122187
122599
  memberPath: "lists.setLevel",
122188
122600
  description: "Set the absolute nesting level (0..8) of a list item.",
@@ -122217,7 +122629,9 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
122217
122629
  throws: [...T_NOT_FOUND_CAPABLE2, "INVALID_TARGET"]
122218
122630
  }),
122219
122631
  referenceDocPath: "lists/set-value.mdx",
122220
- referenceGroup: "lists"
122632
+ referenceGroup: "lists",
122633
+ intentGroup: "list",
122634
+ intentAction: "set_value"
122221
122635
  },
122222
122636
  "lists.continuePrevious": {
122223
122637
  memberPath: "lists.continuePrevious",
@@ -122236,7 +122650,9 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
122236
122650
  throws: [...T_NOT_FOUND_CAPABLE2, "INVALID_TARGET"]
122237
122651
  }),
122238
122652
  referenceDocPath: "lists/continue-previous.mdx",
122239
- referenceGroup: "lists"
122653
+ referenceGroup: "lists",
122654
+ intentGroup: "list",
122655
+ intentAction: "continue_previous"
122240
122656
  },
122241
122657
  "lists.canContinuePrevious": {
122242
122658
  memberPath: "lists.canContinuePrevious",
@@ -122876,6 +123292,19 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
122876
123292
  referenceDocPath: "ranges/resolve.mdx",
122877
123293
  referenceGroup: "ranges"
122878
123294
  },
123295
+ "selection.current": {
123296
+ memberPath: "selection.current",
123297
+ description: "Read the editor's current selection as a portable SelectionInfo with a text-anchored TextTarget. Primitive for building custom comments UIs, floating toolbars, and other selection-driven components without reaching into ProseMirror internals.",
123298
+ expectedResult: "Returns a SelectionInfo with `empty`, `target` (TextTarget or null), `activeMarks`, and optionally `text` when `includeText: true`.",
123299
+ requiresDocumentContext: true,
123300
+ metadata: readOperation2({
123301
+ idempotency: "idempotent",
123302
+ throws: ["INVALID_INPUT", "INVALID_CONTEXT"],
123303
+ deterministicTargetResolution: true
123304
+ }),
123305
+ referenceDocPath: "selection/current.mdx",
123306
+ referenceGroup: "selection"
123307
+ },
122879
123308
  "mutations.preview": {
122880
123309
  memberPath: "mutations.preview",
122881
123310
  description: "Dry-run a mutation plan, returning resolved targets without applying changes.",
@@ -128948,9 +129377,37 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
128948
129377
  type: "string",
128949
129378
  description: "Full plain text content of the block."
128950
129379
  },
129380
+ textSpans: {
129381
+ type: "array",
129382
+ description: "Block text broken into runs with tracked-change marks preserved per run. Present only when the block contains at least one tracked change. Concatenating span text yields `text`.",
129383
+ items: objectSchema2({
129384
+ text: {
129385
+ type: "string",
129386
+ description: "Raw text of the run."
129387
+ },
129388
+ trackedChanges: {
129389
+ type: "array",
129390
+ description: "Tracked-change marks applied to this run.",
129391
+ items: objectSchema2({
129392
+ entityId: {
129393
+ type: "string",
129394
+ description: "Tracked change entity ID matching an entry in trackedChanges[]."
129395
+ },
129396
+ type: {
129397
+ type: "string",
129398
+ enum: [
129399
+ "insert",
129400
+ "delete",
129401
+ "format"
129402
+ ]
129403
+ }
129404
+ }, ["entityId", "type"])
129405
+ }
129406
+ }, ["text"])
129407
+ },
128951
129408
  headingLevel: {
128952
129409
  type: "integer",
128953
- description: "Heading level (16). Only present for headings."
129410
+ description: "Heading level (1-6). Only present for headings."
128954
129411
  },
128955
129412
  tableContext: objectSchema2({
128956
129413
  tableOrdinal: {
@@ -129032,7 +129489,7 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
129032
129489
  items: objectSchema2({
129033
129490
  entityId: {
129034
129491
  type: "string",
129035
- description: "Tracked change entity ID pass to scrollToElement() for navigation."
129492
+ description: "Tracked change entity ID. Pass to scrollToElement() for navigation."
129036
129493
  },
129037
129494
  type: {
129038
129495
  type: "string",
@@ -129040,11 +129497,31 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
129040
129497
  "insert",
129041
129498
  "delete",
129042
129499
  "format"
129043
- ]
129500
+ ],
129501
+ description: "Aggregate type at the entity level. In paired replacement mode, a delete+insert pair shares one entity and this collapses to 'insert'; per-half type lives on block.textSpans[].trackedChanges[]."
129044
129502
  },
129503
+ blockIds: {
129504
+ type: "array",
129505
+ description: "Block IDs whose textSpans carry this change.",
129506
+ items: { type: "string" }
129507
+ },
129508
+ wordRevisionIds: objectSchema2({
129509
+ insert: {
129510
+ type: "string",
129511
+ description: "Original OOXML w:id from a w:ins mark."
129512
+ },
129513
+ delete: {
129514
+ type: "string",
129515
+ description: "Original OOXML w:id from a w:del mark."
129516
+ },
129517
+ format: {
129518
+ type: "string",
129519
+ description: "Original OOXML w:id from a w:rPrChange mark."
129520
+ }
129521
+ }, []),
129045
129522
  excerpt: {
129046
129523
  type: "string",
129047
- description: "Short text excerpt of the changed content."
129524
+ description: "Short text excerpt of the changed content. Omitted for paired replacements; read block.textSpans for the per-half text."
129048
129525
  },
129049
129526
  author: {
129050
129527
  type: "string",
@@ -129772,6 +130249,52 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
129772
130249
  "listId",
129773
130250
  "numId"
129774
130251
  ]), listsFailureSchemaFor2("lists.separate"), objectSchema2({
130252
+ target: listItemAddressSchema2,
130253
+ direction: { enum: ["withPrevious", "withNext"] }
130254
+ }, ["target", "direction"]), objectSchema2({
130255
+ success: { const: true },
130256
+ listId: { type: "string" },
130257
+ absorbedCount: { type: "integer" },
130258
+ removedEmptyBlocks: { type: "integer" }
130259
+ }, [
130260
+ "success",
130261
+ "listId",
130262
+ "absorbedCount",
130263
+ "removedEmptyBlocks"
130264
+ ]), listsFailureSchemaFor2("lists.merge"), objectSchema2({
130265
+ success: { const: true },
130266
+ listId: { type: "string" },
130267
+ absorbedCount: { type: "integer" },
130268
+ removedEmptyBlocks: { type: "integer" }
130269
+ }, [
130270
+ "success",
130271
+ "listId",
130272
+ "absorbedCount",
130273
+ "removedEmptyBlocks"
130274
+ ]), listsFailureSchemaFor2("lists.merge"), objectSchema2({
130275
+ target: listItemAddressSchema2,
130276
+ restartNumbering: { type: "boolean" }
130277
+ }, ["target"]), objectSchema2({
130278
+ success: { const: true },
130279
+ listId: { type: "string" },
130280
+ numId: { type: "integer" },
130281
+ restartedAt: { type: ["integer", "null"] }
130282
+ }, [
130283
+ "success",
130284
+ "listId",
130285
+ "numId",
130286
+ "restartedAt"
130287
+ ]), listsFailureSchemaFor2("lists.split"), objectSchema2({
130288
+ success: { const: true },
130289
+ listId: { type: "string" },
130290
+ numId: { type: "integer" },
130291
+ restartedAt: { type: ["integer", "null"] }
130292
+ }, [
130293
+ "success",
130294
+ "listId",
130295
+ "numId",
130296
+ "restartedAt"
130297
+ ]), listsFailureSchemaFor2("lists.split"), objectSchema2({
129775
130298
  target: listItemAddressSchema2,
129776
130299
  level: {
129777
130300
  type: "integer",
@@ -130174,8 +130697,8 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
130174
130697
  description: "Comment text content."
130175
130698
  },
130176
130699
  target: {
130177
- ...textAddressSchema2,
130178
- description: "Text range to anchor the comment: {kind:'text', blockId:'...', range:{start:N, end:N}}."
130700
+ oneOf: [textAddressSchema2, textTargetSchema2],
130701
+ description: "Text range to anchor the comment. Accepts either a single-block TextAddress {kind:'text', blockId, range} or a multi-segment TextTarget {kind:'text', segments:[{blockId, range}, ...]} for selections that span blocks."
130179
130702
  },
130180
130703
  parentCommentId: {
130181
130704
  type: "string",
@@ -130623,6 +131146,19 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
130623
131146
  }, ["start", "end"]),
130624
131147
  output: resolveRangeOutputSchema
130625
131148
  },
131149
+ "selection.current": {
131150
+ input: objectSchema2({ includeText: { type: "boolean" } }, []),
131151
+ output: objectSchema2({
131152
+ empty: { type: "boolean" },
131153
+ target: { oneOf: [textTargetSchema2, { type: "null" }] },
131154
+ activeMarks: arraySchema2({ type: "string" }),
131155
+ text: { type: "string" }
131156
+ }, [
131157
+ "empty",
131158
+ "target",
131159
+ "activeMarks"
131160
+ ])
131161
+ },
130626
131162
  "mutations.preview": {
130627
131163
  input: mutationsInputSchema,
130628
131164
  output: objectSchema2({
@@ -132347,6 +132883,11 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
132347
132883
  description: "Deterministic range construction from explicit document anchors.",
132348
132884
  pagePath: "ranges/index.mdx"
132349
132885
  },
132886
+ selection: {
132887
+ title: "Selection",
132888
+ description: "Read the editor's current selection as a portable, addressable target.",
132889
+ pagePath: "selection/index.mdx"
132890
+ },
132350
132891
  diff: {
132351
132892
  title: "Diff",
132352
132893
  description: "Snapshot-based document comparison and replay.",
@@ -132461,6 +133002,7 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
132461
133002
  "nearest"
132462
133003
  ]);
132463
133004
  VALID_BEHAVIOR_VALUES2 = new Set(["auto", "smooth"]);
133005
+ SELECTION_CURRENT_ALLOWED_KEYS2 = new Set(["includeText"]);
132464
133006
  CREATE_COMMENT_ALLOWED_KEYS2 = new Set([
132465
133007
  "target",
132466
133008
  "text",
@@ -155319,7 +155861,7 @@ var init_SuperConverter_2Pu0hMB1_es = __esm(() => {
155319
155861
  };
155320
155862
  });
155321
155863
 
155322
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-sMwtuYL8.es.js
155864
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CVKqElqj.es.js
155323
155865
  function parseSizeUnit(val = "0") {
155324
155866
  const length3 = val.toString() || "0";
155325
155867
  const value = Number.parseFloat(length3);
@@ -157941,9 +158483,9 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
157941
158483
  }
157942
158484
  };
157943
158485
  };
157944
- var init_create_headless_toolbar_sMwtuYL8_es = __esm(() => {
157945
- init_SuperConverter_2Pu0hMB1_es();
157946
- init_constants_CGhJRd87_es();
158486
+ var init_create_headless_toolbar_CVKqElqj_es = __esm(() => {
158487
+ init_SuperConverter_lmyr0gmB_es();
158488
+ init_constants_DrU4EASo_es();
157947
158489
  init_dist_B8HfvhaK_es();
157948
158490
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
157949
158491
  DOM_SIZE_UNITS = [
@@ -159389,7 +159931,7 @@ var init_decrypt_docx_Bs1PbPQR_es = __esm(() => {
159389
159931
  ]);
159390
159932
  });
159391
159933
 
159392
- // ../../packages/superdoc/dist/chunks/DocxZipper-BBjEXAFw.es.js
159934
+ // ../../packages/superdoc/dist/chunks/DocxZipper-CwFyjl1b.es.js
159393
159935
  function sniffEncoding(u8) {
159394
159936
  if (u8.length >= 2) {
159395
159937
  const b0 = u8[0], b1 = u8[1];
@@ -160040,11 +160582,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
160040
160582
  return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
160041
160583
  }
160042
160584
  }, DocxZipper_default;
160043
- var init_DocxZipper_BBjEXAFw_es = __esm(() => {
160585
+ var init_DocxZipper_CwFyjl1b_es = __esm(() => {
160044
160586
  init_rolldown_runtime_Bg48TavK_es();
160045
160587
  init_jszip_C49i9kUs_es();
160046
160588
  init_xml_js_CqGKpaft_es();
160047
- init_constants_CGhJRd87_es();
160589
+ init_constants_DrU4EASo_es();
160048
160590
  init_dist_B8HfvhaK_es();
160049
160591
  MANAGED_PACKAGE_PARTS = [
160050
160592
  {
@@ -206629,7 +207171,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
206629
207171
  init_remark_gfm_BhnWr3yf_es();
206630
207172
  });
206631
207173
 
206632
- // ../../packages/superdoc/dist/chunks/src-BNgFLixt.es.js
207174
+ // ../../packages/superdoc/dist/chunks/src-iqx3UG8T.es.js
206633
207175
  function deleteProps(obj, propOrProps) {
206634
207176
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
206635
207177
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -210852,6 +211394,33 @@ function updateTableWrapper(tableWrapper, table2) {
210852
211394
  borderWidth = Math.ceil(Math.max(borderLeftMax, borderRightMax));
210853
211395
  tableWrapper.style.setProperty("--table-border-width", `${borderWidth || defaultBorderWidth}px`);
210854
211396
  }
211397
+ function cloneBorders(borders, sides) {
211398
+ if (!borders || typeof borders !== "object")
211399
+ return {};
211400
+ const source = borders;
211401
+ const keys$1 = Array.isArray(sides) ? sides : Object.keys(source);
211402
+ const clone = {};
211403
+ for (const side of keys$1) {
211404
+ const borderValue = source[side];
211405
+ if (!borderValue || typeof borderValue !== "object")
211406
+ continue;
211407
+ clone[side] = { ...borderValue };
211408
+ }
211409
+ return clone;
211410
+ }
211411
+ function mapBorderSizes(borders, sizeMapper) {
211412
+ if (!borders || typeof borders !== "object")
211413
+ return;
211414
+ if (typeof sizeMapper !== "function")
211415
+ return;
211416
+ for (const border of Object.values(borders)) {
211417
+ if (!border || typeof border !== "object")
211418
+ continue;
211419
+ const mapped = sizeMapper(border.size);
211420
+ if (typeof mapped === "number" && Number.isFinite(mapped))
211421
+ border.size = mapped;
211422
+ }
211423
+ }
210855
211424
  function resolvePreferredNewTableStyleIdFromEditor(editor) {
210856
211425
  const translatedLinkedStyles = readTranslatedLinkedStyles(editor);
210857
211426
  let settingsDefaultStyleId = null;
@@ -210865,10 +211434,12 @@ function resolvePreferredNewTableStyleIdFromEditor(editor) {
210865
211434
  }
210866
211435
  function normalizeNewTableAttrs(editor) {
210867
211436
  const resolved = resolvePreferredNewTableStyleIdFromEditor(editor);
210868
- if (resolved.source === "none")
211437
+ if (resolved.source === "none") {
211438
+ const fallbackPixelBorders = cloneBorders(TABLE_FALLBACK_BORDERS, TABLE_BORDER_SIDES);
211439
+ mapBorderSizes(fallbackPixelBorders, eighthPointsToPixels);
210869
211440
  return {
210870
211441
  tableStyleId: null,
210871
- borders: { ...TABLE_FALLBACK_BORDERS },
211442
+ borders: fallbackPixelBorders,
210872
211443
  tableProperties: {
210873
211444
  borders: { ...TABLE_FALLBACK_BORDERS },
210874
211445
  cellMargins: {
@@ -210891,6 +211462,7 @@ function normalizeNewTableAttrs(editor) {
210891
211462
  }
210892
211463
  }
210893
211464
  };
211465
+ }
210894
211466
  return {
210895
211467
  tableStyleId: resolved.styleId,
210896
211468
  tableProperties: {
@@ -222017,8 +222589,33 @@ function buildMatchBlocks(editor, textRanges, evaluatedRevision, matchId, storyK
222017
222589
  const to = Math.max(...ranges.map((r$1) => r$1.range.end));
222018
222590
  const sorted = [...ranges].sort((a2, b$1) => a2.range.start - b$1.range.start);
222019
222591
  for (let i4 = 0;i4 < sorted.length - 1; i4++)
222020
- if (sorted[i4].range.end < sorted[i4 + 1].range.start)
222021
- throw planError("INVALID_INPUT", `discontiguous text ranges in block ${blockId}: gap between ${sorted[i4].range.end} and ${sorted[i4 + 1].range.start}`);
222592
+ if (sorted[i4].range.end < sorted[i4 + 1].range.start) {
222593
+ const gapStart = sorted[i4].range.end;
222594
+ const gapEnd = sorted[i4 + 1].range.start;
222595
+ const coveringStart = Math.min(...sorted.map((r$1) => r$1.range.start));
222596
+ const coveringEnd = Math.max(...sorted.map((r$1) => r$1.range.end));
222597
+ throw planError("INVALID_INPUT", `discontiguous text ranges in block ${blockId}: gap between ${gapStart} and ${gapEnd}. Two or more edits target the same block with untouched text between them and cannot be coalesced safely. Fix by: (a) splitting the edits across separate superdoc_mutations batches — preferred, works in both direct and tracked change modes; or (b) combining the edits into a single text.rewrite covering offsets ${coveringStart}..${coveringEnd} — direct mode only, since in tracked mode the untouched middle would be recorded as deleted+reinserted.`, undefined, {
222598
+ blockId,
222599
+ gap: {
222600
+ start: gapStart,
222601
+ end: gapEnd
222602
+ },
222603
+ coveringRange: {
222604
+ start: coveringStart,
222605
+ end: coveringEnd
222606
+ },
222607
+ rangeCount: sorted.length,
222608
+ ranges: sorted.map((r$1) => ({
222609
+ start: r$1.range.start,
222610
+ end: r$1.range.end
222611
+ })),
222612
+ remediation: {
222613
+ preferred: "split-batches",
222614
+ optionA: "Split into separate superdoc_mutations batches (works in direct and tracked modes).",
222615
+ optionB: `Combine into one text.rewrite covering offsets ${coveringStart}..${coveringEnd} (direct mode only — pollutes tracked history).`
222616
+ }
222617
+ });
222618
+ }
222022
222619
  const blockStart = candidate.pos + 1;
222023
222620
  const blockEnd = candidate.end - 1;
222024
222621
  const blockText = doc$12.textBetween(blockStart, blockEnd, `
@@ -228423,6 +229020,26 @@ function toNotFoundError(input2) {
228423
229020
  function isSameTarget(left$1, right$1) {
228424
229021
  return left$1.blockId === right$1.blockId && left$1.range.start === right$1.range.start && left$1.range.end === right$1.range.end;
228425
229022
  }
229023
+ function isTextTargetShape(target) {
229024
+ if (!target || typeof target !== "object")
229025
+ return false;
229026
+ const t = target;
229027
+ if (t.kind !== "text")
229028
+ return false;
229029
+ if (!Array.isArray(t.segments) || t.segments.length === 0)
229030
+ return false;
229031
+ if (typeof t.blockId === "string" || t.range !== undefined && t.range !== null)
229032
+ return false;
229033
+ return true;
229034
+ }
229035
+ function targetToSegments(target) {
229036
+ if (isTextTargetShape(target))
229037
+ return [...target.segments];
229038
+ return [{
229039
+ blockId: target.blockId,
229040
+ range: target.range
229041
+ }];
229042
+ }
228426
229043
  function listCommentAnchorsSafe(editor) {
228427
229044
  try {
228428
229045
  return listCommentAnchors(editor);
@@ -228528,7 +229145,7 @@ function buildAnchoredText(editor, canonical) {
228528
229145
  }
228529
229146
  return parts.length > 0 ? normalizeExcerpt(parts.join(" ")) : undefined;
228530
229147
  }
228531
- function buildTextTarget(canonical) {
229148
+ function buildTextTarget$1(canonical) {
228532
229149
  if (canonical.length === 0)
228533
229150
  return;
228534
229151
  return {
@@ -228554,7 +229171,7 @@ function mergeAnchorData(editor, infosById, anchors) {
228554
229171
  const firstAnchor = sorted[0];
228555
229172
  const status = sorted.every((anchor) => anchor.status === "resolved") ? "resolved" : "open";
228556
229173
  const canonical = canonicalizeAnchors(sorted);
228557
- const target = buildTextTarget(canonical);
229174
+ const target = buildTextTarget$1(canonical);
228558
229175
  const anchoredText = buildAnchoredText(editor, canonical);
228559
229176
  const existing = infosById.get(commentId);
228560
229177
  if (existing) {
@@ -228629,17 +229246,62 @@ function buildCommentInfos(editor) {
228629
229246
  }
228630
229247
  function addCommentHandler(editor, input2, options) {
228631
229248
  requireEditorCommand(editor.commands?.addComment, "comments.create (addComment)");
228632
- if (input2.target.range.start === input2.target.range.end)
229249
+ const target = input2.target;
229250
+ if (!target)
228633
229251
  return {
228634
229252
  success: false,
228635
229253
  failure: {
228636
229254
  code: "INVALID_TARGET",
228637
- message: "Comment target range must be non-collapsed."
229255
+ message: "Comment target is required."
228638
229256
  }
228639
229257
  };
228640
- const resolved = resolveTextTarget(editor, input2.target);
228641
- if (!resolved)
228642
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Comment target could not be resolved.", { target: input2.target });
229258
+ const segments = targetToSegments(target);
229259
+ for (const seg of segments)
229260
+ if (seg.range.start === seg.range.end)
229261
+ return {
229262
+ success: false,
229263
+ failure: {
229264
+ code: "INVALID_TARGET",
229265
+ message: "Comment target range must be non-collapsed.",
229266
+ details: { target }
229267
+ }
229268
+ };
229269
+ const resolvedSegments = segments.map((seg) => resolveTextTarget(editor, {
229270
+ kind: "text",
229271
+ blockId: seg.blockId,
229272
+ range: seg.range
229273
+ }));
229274
+ if (resolvedSegments.some((r$1) => r$1 === null))
229275
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Comment target could not be resolved.", { target });
229276
+ const docForGap = editor.state?.doc;
229277
+ for (let i4 = 1;i4 < resolvedSegments.length; i4 += 1) {
229278
+ const prev = resolvedSegments[i4 - 1];
229279
+ const curr = resolvedSegments[i4];
229280
+ if (prev.to > curr.from)
229281
+ return {
229282
+ success: false,
229283
+ failure: {
229284
+ code: "INVALID_TARGET",
229285
+ message: "Comment target segments must be in document order.",
229286
+ details: { target }
229287
+ }
229288
+ };
229289
+ if ((docForGap ? docForGap.textBetween(prev.to, curr.from, "", () => "\x01") : "").length > 0)
229290
+ return {
229291
+ success: false,
229292
+ failure: {
229293
+ code: "INVALID_TARGET",
229294
+ message: "Comment target segments must be contiguous — non-selected text or atoms between segments is not supported.",
229295
+ details: { target }
229296
+ }
229297
+ };
229298
+ }
229299
+ const firstResolved = resolvedSegments[0];
229300
+ const lastResolved = resolvedSegments[resolvedSegments.length - 1];
229301
+ const resolved = {
229302
+ from: firstResolved.from,
229303
+ to: lastResolved.to
229304
+ };
228643
229305
  if (resolved.from === resolved.to)
228644
229306
  return {
228645
229307
  success: false,
@@ -229421,7 +230083,79 @@ function indexCellsForTable(tableNode) {
229421
230083
  }
229422
230084
  return anchors;
229423
230085
  }
229424
- function buildBlock(node3, pos, nodeType, path2, tableContext) {
230086
+ function readSpanTrackedChanges(node3, canonicalIdByAlias) {
230087
+ const out = [];
230088
+ for (const mark2 of node3.marks) {
230089
+ const type = TRACK_MARK_TYPE_BY_NAME[mark2.type.name];
230090
+ if (!type)
230091
+ continue;
230092
+ const rawId = mark2.attrs?.id;
230093
+ if (typeof rawId !== "string" || rawId.length === 0)
230094
+ continue;
230095
+ const entityId = canonicalIdByAlias.get(rawId);
230096
+ if (!entityId)
230097
+ continue;
230098
+ out.push({
230099
+ entityId,
230100
+ type
230101
+ });
230102
+ }
230103
+ out.sort((a2, b$1) => {
230104
+ if (a2.entityId !== b$1.entityId)
230105
+ return a2.entityId < b$1.entityId ? -1 : 1;
230106
+ return a2.type < b$1.type ? -1 : a2.type > b$1.type ? 1 : 0;
230107
+ });
230108
+ return out;
230109
+ }
230110
+ function spanTrackedChangesEqual(a2, b$1) {
230111
+ if (a2.length !== b$1.length)
230112
+ return false;
230113
+ for (let i4 = 0;i4 < a2.length; i4++)
230114
+ if (a2[i4].entityId !== b$1[i4].entityId || a2[i4].type !== b$1[i4].type)
230115
+ return false;
230116
+ return true;
230117
+ }
230118
+ function recordEntityHit(index2, entityId, type, blockId) {
230119
+ let entry = index2.get(entityId);
230120
+ if (!entry) {
230121
+ entry = {
230122
+ blockIds: /* @__PURE__ */ new Set,
230123
+ types: /* @__PURE__ */ new Set
230124
+ };
230125
+ index2.set(entityId, entry);
230126
+ }
230127
+ entry.blockIds.add(blockId);
230128
+ entry.types.add(type);
230129
+ }
230130
+ function buildTextSpans(node3, blockId, canonicalIdByAlias, entityIndex) {
230131
+ if (canonicalIdByAlias.size === 0)
230132
+ return;
230133
+ const spans = [];
230134
+ let hasAnyTrackedChange = false;
230135
+ node3.descendants((child) => {
230136
+ if (!child.isText || typeof child.text !== "string" || child.text.length === 0)
230137
+ return true;
230138
+ const tracked = readSpanTrackedChanges(child, canonicalIdByAlias);
230139
+ if (tracked.length > 0) {
230140
+ hasAnyTrackedChange = true;
230141
+ for (const tc of tracked)
230142
+ recordEntityHit(entityIndex, tc.entityId, tc.type, blockId);
230143
+ }
230144
+ const last2 = spans.length > 0 ? spans[spans.length - 1] : undefined;
230145
+ const lastTracked = last2?.trackedChanges ?? [];
230146
+ if (last2 && spanTrackedChangesEqual(lastTracked, tracked)) {
230147
+ last2.text += child.text;
230148
+ return true;
230149
+ }
230150
+ const span = { text: child.text };
230151
+ if (tracked.length > 0)
230152
+ span.trackedChanges = tracked;
230153
+ spans.push(span);
230154
+ return true;
230155
+ });
230156
+ return hasAnyTrackedChange ? spans : undefined;
230157
+ }
230158
+ function buildBlock(node3, pos, nodeType, path2, canonicalIdByAlias, entityIndex, tableContext) {
229425
230159
  const nodeId = resolveBlockNodeId(node3, pos, nodeType, path2);
229426
230160
  if (!nodeId)
229427
230161
  return;
@@ -229432,13 +230166,16 @@ function buildBlock(node3, pos, nodeType, path2, tableContext) {
229432
230166
  type: nodeType,
229433
230167
  text: node3.textContent
229434
230168
  };
230169
+ const spans = buildTextSpans(node3, nodeId, canonicalIdByAlias, entityIndex);
230170
+ if (spans)
230171
+ block.textSpans = spans;
229435
230172
  if (headingLevel !== undefined)
229436
230173
  block.headingLevel = headingLevel;
229437
230174
  if (tableContext)
229438
230175
  block.tableContext = tableContext;
229439
230176
  return block;
229440
230177
  }
229441
- function collectContainerBlocks(container, contentStart, containerPath, ordinals, tableContext, nestedParent) {
230178
+ function collectContainerBlocks(container, contentStart, containerPath, ctx$1, tableContext, nestedParent) {
229442
230179
  const blocks2 = [];
229443
230180
  let childOffset = 0;
229444
230181
  for (let i4 = 0;i4 < container.childCount; i4++) {
@@ -229447,27 +230184,27 @@ function collectContainerBlocks(container, contentStart, containerPath, ordinals
229447
230184
  childOffset += child.nodeSize;
229448
230185
  const childPath = [...containerPath, i4];
229449
230186
  if (child.type.name === "table") {
229450
- blocks2.push(...collectTableExtractBlocks(child, childPos, childPath, ordinals, nestedParent));
230187
+ blocks2.push(...collectTableExtractBlocks(child, childPos, childPath, ctx$1, nestedParent));
229451
230188
  continue;
229452
230189
  }
229453
230190
  if (SDT_BLOCK_NODE_NAMES.has(child.type.name)) {
229454
- blocks2.push(...collectContainerBlocks(child, childPos + 1, childPath, ordinals, tableContext, nestedParent));
230191
+ blocks2.push(...collectContainerBlocks(child, childPos + 1, childPath, ctx$1, tableContext, nestedParent));
229455
230192
  continue;
229456
230193
  }
229457
230194
  const childType = mapBlockNodeType(child);
229458
230195
  if (childType && EMITTABLE_BLOCK_TYPES.has(childType)) {
229459
- const block = buildBlock(child, childPos, childType, childPath, tableContext);
230196
+ const block = buildBlock(child, childPos, childType, childPath, ctx$1.canonicalIdByAlias, ctx$1.entityIndex, tableContext);
229460
230197
  if (block)
229461
230198
  blocks2.push(block);
229462
230199
  continue;
229463
230200
  }
229464
230201
  if (!child.isLeaf && child.firstChild?.isBlock === true)
229465
- blocks2.push(...collectContainerBlocks(child, childPos + 1, childPath, ordinals, tableContext, nestedParent));
230202
+ blocks2.push(...collectContainerBlocks(child, childPos + 1, childPath, ctx$1, tableContext, nestedParent));
229466
230203
  }
229467
230204
  return blocks2;
229468
230205
  }
229469
- function collectTableExtractBlocks(tableNode, tablePos, tablePath, ordinals, parent) {
229470
- const tableOrdinal = ordinals.next++;
230206
+ function collectTableExtractBlocks(tableNode, tablePos, tablePath, ctx$1, parent) {
230207
+ const tableOrdinal = ctx$1.ordinals.next++;
229471
230208
  const anchors = indexCellsForTable(tableNode);
229472
230209
  const blocks2 = [];
229473
230210
  for (const anchor of anchors) {
@@ -229489,7 +230226,7 @@ function collectTableExtractBlocks(tableNode, tablePos, tablePath, ordinals, par
229489
230226
  tableContext.parentRowIndex = parent.rowIndex;
229490
230227
  tableContext.parentColumnIndex = parent.columnIndex;
229491
230228
  }
229492
- blocks2.push(...collectContainerBlocks(anchor.cellNode, cellContentStart, cellPath, ordinals, tableContext, {
230229
+ blocks2.push(...collectContainerBlocks(anchor.cellNode, cellContentStart, cellPath, ctx$1, tableContext, {
229493
230230
  tableOrdinal,
229494
230231
  rowIndex: anchor.gridRowIndex,
229495
230232
  columnIndex: anchor.gridColumnIndex
@@ -229498,7 +230235,15 @@ function collectTableExtractBlocks(tableNode, tablePos, tablePath, ordinals, par
229498
230235
  return blocks2;
229499
230236
  }
229500
230237
  function collectBlocks(editor) {
229501
- return collectContainerBlocks(editor.state.doc, 0, [], { next: 0 });
230238
+ const ctx$1 = {
230239
+ ordinals: { next: 0 },
230240
+ canonicalIdByAlias: buildTrackedChangeCanonicalIdMap(editor),
230241
+ entityIndex: /* @__PURE__ */ new Map
230242
+ };
230243
+ return {
230244
+ blocks: collectContainerBlocks(editor.state.doc, 0, [], ctx$1),
230245
+ entityIndex: ctx$1.entityIndex
230246
+ };
229502
230247
  }
229503
230248
  function collectComments(editor) {
229504
230249
  return createCommentsWrapper(editor).list({ includeResolved: true }).items.map((item) => {
@@ -229517,13 +230262,19 @@ function collectComments(editor) {
229517
230262
  return comment2;
229518
230263
  });
229519
230264
  }
229520
- function collectTrackedChanges$1(editor) {
230265
+ function collectTrackedChanges$1(editor, entityIndex) {
229521
230266
  return trackChangesListWrapper(editor).items.map((item) => {
229522
230267
  const tc = {
229523
230268
  entityId: item.address.entityId,
229524
230269
  type: item.type
229525
230270
  };
229526
- if (item.excerpt)
230271
+ const indexEntry = entityIndex.get(item.address.entityId);
230272
+ if (indexEntry && indexEntry.blockIds.size > 0)
230273
+ tc.blockIds = Array.from(indexEntry.blockIds);
230274
+ if (item.wordRevisionIds)
230275
+ tc.wordRevisionIds = item.wordRevisionIds;
230276
+ const isMultiTypeEntity = !!(indexEntry && indexEntry.types.size > 1);
230277
+ if (item.excerpt && !isMultiTypeEntity)
229527
230278
  tc.excerpt = item.excerpt;
229528
230279
  if (item.author)
229529
230280
  tc.author = item.author;
@@ -229533,10 +230284,11 @@ function collectTrackedChanges$1(editor) {
229533
230284
  });
229534
230285
  }
229535
230286
  function extractAdapter(editor, _input) {
230287
+ const { blocks: blocks2, entityIndex } = collectBlocks(editor);
229536
230288
  return {
229537
- blocks: collectBlocks(editor),
230289
+ blocks: blocks2,
229538
230290
  comments: collectComments(editor),
229539
- trackedChanges: collectTrackedChanges$1(editor),
230291
+ trackedChanges: collectTrackedChanges$1(editor, entityIndex),
229540
230292
  revision: getRevision(editor)
229541
230293
  };
229542
230294
  }
@@ -231501,6 +232253,9 @@ function resolveInsertedListItem(editor, sdBlockId) {
231501
232253
  });
231502
232254
  throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Inserted list item with sdBlockId "${sdBlockId}" could not be resolved after insertion.`);
231503
232255
  }
232256
+ function generateRuntimeParaId() {
232257
+ return v4_default().replace(/-/g, "").slice(0, 8).toUpperCase();
232258
+ }
231504
232259
  function withListTarget(editor, input2) {
231505
232260
  return resolveListItem(editor, input2.target);
231506
232261
  }
@@ -231588,6 +232343,7 @@ function listsInsertWrapper(editor, input2, options) {
231588
232343
  }
231589
232344
  };
231590
232345
  const createdId = v4_default();
232346
+ const createdParaId = generateRuntimeParaId();
231591
232347
  let created = null;
231592
232348
  if (executeDomainCommand(editor, () => {
231593
232349
  const didApply = insertListItemAt$1({
@@ -231595,6 +232351,7 @@ function listsInsertWrapper(editor, input2, options) {
231595
232351
  position: input2.position,
231596
232352
  text: input2.text ?? "",
231597
232353
  sdBlockId: createdId,
232354
+ paraId: createdParaId,
231598
232355
  tracked: mode === "tracked"
231599
232356
  });
231600
232357
  if (didApply) {
@@ -231616,11 +232373,11 @@ function listsInsertWrapper(editor, input2, options) {
231616
232373
  item: {
231617
232374
  kind: "block",
231618
232375
  nodeType: "listItem",
231619
- nodeId: createdId
232376
+ nodeId: createdParaId
231620
232377
  },
231621
232378
  insertionPoint: {
231622
232379
  kind: "text",
231623
- blockId: createdId,
232380
+ blockId: createdParaId,
231624
232381
  range: {
231625
232382
  start: 0,
231626
232383
  end: 0
@@ -231971,6 +232728,129 @@ function listsSeparateWrapper(editor, input2, options) {
231971
232728
  numId: newNumId
231972
232729
  };
231973
232730
  }
232731
+ function listsMergeWrapper(editor, input2, options) {
232732
+ rejectTrackedMode("lists.merge", options);
232733
+ const target = resolveListItem(editor, input2.target);
232734
+ if (target.numId == null)
232735
+ return toListsFailure$1("INVALID_TARGET", "Target must have numbering metadata.", { target: input2.target });
232736
+ const adjacent = findAdjacentSequence(editor, target, input2.direction);
232737
+ if (!adjacent)
232738
+ return toListsFailure$1("NO_ADJACENT_SEQUENCE", "No adjacent list sequence found in the given direction.", {
232739
+ target: input2.target,
232740
+ direction: input2.direction
232741
+ });
232742
+ const targetSequence = getContiguousSequence(editor, target);
232743
+ if (adjacent.numId === target.numId)
232744
+ return toListsFailure$1("NO_OP", "Target and adjacent items already belong to the same sequence.", { target: input2.target });
232745
+ let absorbingNumId;
232746
+ let absorbedItems;
232747
+ let anchorNodeId;
232748
+ let gapFromPos;
232749
+ let gapToPos;
232750
+ if (input2.direction === "withPrevious") {
232751
+ absorbingNumId = adjacent.numId;
232752
+ absorbedItems = targetSequence;
232753
+ anchorNodeId = adjacent.sequence[0]?.address.nodeId ?? target.address.nodeId;
232754
+ const lastOfAdjacent = adjacent.sequence[adjacent.sequence.length - 1];
232755
+ const firstOfTarget = targetSequence[0];
232756
+ gapFromPos = lastOfAdjacent.candidate.pos + lastOfAdjacent.candidate.node.nodeSize;
232757
+ gapToPos = firstOfTarget.candidate.pos;
232758
+ } else {
232759
+ absorbingNumId = target.numId;
232760
+ absorbedItems = adjacent.sequence;
232761
+ anchorNodeId = targetSequence[0]?.address.nodeId ?? target.address.nodeId;
232762
+ const lastOfTarget = targetSequence[targetSequence.length - 1];
232763
+ const firstOfAdjacent = adjacent.sequence[0];
232764
+ gapFromPos = lastOfTarget.candidate.pos + lastOfTarget.candidate.node.nodeSize;
232765
+ gapToPos = firstOfAdjacent.candidate.pos;
232766
+ }
232767
+ const gapEmptyParagraphs = [];
232768
+ if (gapFromPos < gapToPos)
232769
+ editor.state.doc.forEach((child, offset$1) => {
232770
+ if (child.type.name !== "paragraph")
232771
+ return;
232772
+ if (offset$1 < gapFromPos)
232773
+ return;
232774
+ if (offset$1 + child.nodeSize > gapToPos)
232775
+ return;
232776
+ if (child.childCount > 0)
232777
+ return;
232778
+ gapEmptyParagraphs.push({
232779
+ pos: offset$1,
232780
+ node: child
232781
+ });
232782
+ });
232783
+ const mergedListId = `${absorbingNumId}:${anchorNodeId}`;
232784
+ if (options?.dryRun)
232785
+ return {
232786
+ success: true,
232787
+ listId: mergedListId,
232788
+ absorbedCount: absorbedItems.length,
232789
+ removedEmptyBlocks: gapEmptyParagraphs.length
232790
+ };
232791
+ if (executeDomainCommand(editor, () => {
232792
+ const { tr } = editor.state;
232793
+ for (const item of absorbedItems) {
232794
+ const currentLevel = item.level ?? 0;
232795
+ updateNumberingProperties({
232796
+ numId: absorbingNumId,
232797
+ ilvl: currentLevel
232798
+ }, item.candidate.node, item.candidate.pos, editor, tr);
232799
+ }
232800
+ const sorted = [...gapEmptyParagraphs].sort((a2, b$1) => b$1.pos - a2.pos);
232801
+ for (const gap of sorted)
232802
+ tr.delete(gap.pos, gap.pos + gap.node.nodeSize);
232803
+ dispatchEditorTransaction$2(editor, tr);
232804
+ clearIndexCache(editor);
232805
+ return true;
232806
+ }, { expectedRevision: options?.expectedRevision }).steps[0]?.effect !== "changed")
232807
+ return toListsFailure$1("INVALID_TARGET", "List merge could not be applied.", {
232808
+ target: input2.target,
232809
+ direction: input2.direction
232810
+ });
232811
+ return {
232812
+ success: true,
232813
+ listId: mergedListId,
232814
+ absorbedCount: absorbedItems.length,
232815
+ removedEmptyBlocks: gapEmptyParagraphs.length
232816
+ };
232817
+ }
232818
+ function listsSplitWrapper(editor, input2, options) {
232819
+ rejectTrackedMode("lists.split", options);
232820
+ const separateResult = listsSeparateWrapper(editor, { target: input2.target }, options);
232821
+ if (!separateResult.success)
232822
+ return separateResult;
232823
+ if (!(input2.restartNumbering !== false))
232824
+ return {
232825
+ success: true,
232826
+ listId: separateResult.listId,
232827
+ numId: separateResult.numId,
232828
+ restartedAt: null
232829
+ };
232830
+ if (options?.dryRun)
232831
+ return {
232832
+ success: true,
232833
+ listId: separateResult.listId,
232834
+ numId: separateResult.numId,
232835
+ restartedAt: 1
232836
+ };
232837
+ const setValueOptions = options ? {
232838
+ ...options,
232839
+ expectedRevision: undefined
232840
+ } : options;
232841
+ const setValueResult = listsSetValueWrapper(editor, {
232842
+ target: input2.target,
232843
+ value: 1
232844
+ }, setValueOptions);
232845
+ if (!setValueResult.success)
232846
+ return setValueResult;
232847
+ return {
232848
+ success: true,
232849
+ listId: separateResult.listId,
232850
+ numId: separateResult.numId,
232851
+ restartedAt: 1
232852
+ };
232853
+ }
231974
232854
  function listsSetLevelWrapper(editor, input2, options) {
231975
232855
  rejectTrackedMode("lists.setLevel", options);
231976
232856
  return executeSetLevel(editor, resolveListItem(editor, input2.target), input2.level, options);
@@ -233277,6 +234157,151 @@ async function scrollRangeIntoView(editor, input2) {
233277
234157
  return { success: false };
233278
234158
  }
233279
234159
  }
234160
+ function resolveCurrentSelectionInfo(editor, input2) {
234161
+ const state = editor.state;
234162
+ if (!state)
234163
+ return {
234164
+ empty: true,
234165
+ target: null,
234166
+ activeMarks: []
234167
+ };
234168
+ const { from: from$1, to, empty: empty$1 } = state.selection;
234169
+ const segments = collectTextSegments(state.doc, from$1, to);
234170
+ const info = {
234171
+ empty: empty$1,
234172
+ target: segments && segments.length > 0 ? buildTextTarget(segments) : null,
234173
+ activeMarks: collectActiveMarks(state, from$1, to)
234174
+ };
234175
+ if (input2.includeText && !empty$1)
234176
+ info.text = state.doc.textBetween(from$1, to, " ");
234177
+ return info;
234178
+ }
234179
+ function buildTextTarget(segments) {
234180
+ return {
234181
+ kind: "text",
234182
+ segments
234183
+ };
234184
+ }
234185
+ function collectTextSegments(doc$12, from$1, to) {
234186
+ const segments = [];
234187
+ let abort = false;
234188
+ doc$12.nodesBetween(from$1, to, (node3, pos) => {
234189
+ if (abort)
234190
+ return false;
234191
+ if (!node3.isTextblock)
234192
+ return true;
234193
+ const blockId = readBlockId(node3);
234194
+ if (!blockId) {
234195
+ abort = true;
234196
+ return false;
234197
+ }
234198
+ const blockStart = pos + 1;
234199
+ const blockEnd = pos + node3.nodeSize - 1;
234200
+ const selStart = Math.max(from$1, blockStart);
234201
+ const selEnd = Math.min(to, blockEnd);
234202
+ const start$1 = pmPositionToTextOffset(node3, pos, selStart);
234203
+ const end$1 = Math.max(start$1, pmPositionToTextOffset(node3, pos, selEnd));
234204
+ segments.push({
234205
+ blockId,
234206
+ range: {
234207
+ start: start$1,
234208
+ end: end$1
234209
+ }
234210
+ });
234211
+ return false;
234212
+ });
234213
+ if (abort)
234214
+ return null;
234215
+ return segments;
234216
+ }
234217
+ function readBlockId(node3) {
234218
+ const attrs = node3.attrs ?? {};
234219
+ const id2 = attrs.sdBlockId ?? attrs.id ?? attrs.blockId;
234220
+ return typeof id2 === "string" && id2.length > 0 ? id2 : null;
234221
+ }
234222
+ function collectActiveMarks(state, from$1, to) {
234223
+ const names = /* @__PURE__ */ new Set;
234224
+ const stored = state.storedMarks;
234225
+ if (stored)
234226
+ for (const mark2 of stored)
234227
+ names.add(mark2.type.name);
234228
+ if (from$1 === to) {
234229
+ const marks = state.doc.resolve(from$1).marks();
234230
+ for (const mark2 of marks)
234231
+ names.add(mark2.type.name);
234232
+ } else {
234233
+ const common = markTypesPresentEverywhere(state.doc, from$1, to);
234234
+ for (const name of common)
234235
+ names.add(name);
234236
+ }
234237
+ return Array.from(names);
234238
+ }
234239
+ function subscribeToSelection(editor, listener) {
234240
+ let scheduled = false;
234241
+ let cancelled = false;
234242
+ let lastEmittedKey = null;
234243
+ const flush = () => {
234244
+ scheduled = false;
234245
+ if (cancelled)
234246
+ return;
234247
+ const info = resolveCurrentSelectionInfo(editor, {});
234248
+ const key2 = selectionInfoKey(info);
234249
+ if (key2 === lastEmittedKey)
234250
+ return;
234251
+ lastEmittedKey = key2;
234252
+ listener(info);
234253
+ };
234254
+ const schedule = () => {
234255
+ if (scheduled || cancelled)
234256
+ return;
234257
+ scheduled = true;
234258
+ queueMicrotask(flush);
234259
+ };
234260
+ editor.on("selectionUpdate", schedule);
234261
+ editor.on("transaction", schedule);
234262
+ return () => {
234263
+ cancelled = true;
234264
+ editor.off?.("selectionUpdate", schedule);
234265
+ editor.off?.("transaction", schedule);
234266
+ };
234267
+ }
234268
+ function selectionInfoKey(info) {
234269
+ const target = info.target;
234270
+ let targetKey;
234271
+ if (!target)
234272
+ targetKey = "null";
234273
+ else
234274
+ targetKey = target.segments.map((s2) => `${s2.blockId}:${s2.range.start}-${s2.range.end}`).join("|");
234275
+ const marks = [...info.activeMarks].sort().join(",");
234276
+ return `${info.empty ? "1" : "0"}:${targetKey}:${marks}`;
234277
+ }
234278
+ function markTypesPresentEverywhere(doc$12, from$1, to) {
234279
+ let common = null;
234280
+ let aborted = false;
234281
+ doc$12.nodesBetween(from$1, to, (node3, pos) => {
234282
+ if (aborted)
234283
+ return false;
234284
+ if (!node3.isText)
234285
+ return true;
234286
+ const start$1 = Math.max(pos, from$1);
234287
+ if (Math.min(pos + node3.nodeSize, to) <= start$1)
234288
+ return false;
234289
+ const names = /* @__PURE__ */ new Set;
234290
+ for (const m$1 of node3.marks)
234291
+ names.add(m$1.type.name);
234292
+ if (common === null)
234293
+ common = names;
234294
+ else {
234295
+ for (const name of common)
234296
+ if (!names.has(name))
234297
+ common.delete(name);
234298
+ if (common.size === 0)
234299
+ aborted = true;
234300
+ }
234301
+ return false;
234302
+ });
234303
+ return common ?? /* @__PURE__ */ new Set;
234304
+ }
233280
234305
  function resolveLocatorToCandidate(editor, locator, operationName) {
233281
234306
  const hasTarget = locator.target != null;
233282
234307
  const hasNodeId = locator.nodeId != null;
@@ -233508,7 +234533,7 @@ function syncExtractedTableAttrs(tp) {
233508
234533
  extracted.tableStyleId = tp.tableStyleId ?? null;
233509
234534
  extracted.justification = tp.justification ?? null;
233510
234535
  extracted.tableLayout = tp.tableLayout ?? null;
233511
- extracted.borders = tp.borders ?? null;
234536
+ extracted.borders = convertTableBordersToPixelUnits(tp.borders) ?? tp.borders ?? null;
233512
234537
  const indent2 = tp.tableIndent;
233513
234538
  if (indent2?.value != null)
233514
234539
  extracted.tableIndent = {
@@ -233552,6 +234577,13 @@ function syncExtractedTableAttrs(tp) {
233552
234577
  extracted.tableWidth = null;
233553
234578
  return extracted;
233554
234579
  }
234580
+ function convertTableBordersToPixelUnits(value) {
234581
+ const clone = cloneBorders(value);
234582
+ if (!clone || Object.keys(clone).length === 0)
234583
+ return;
234584
+ mapBorderSizes(clone, eighthPointsToPixels);
234585
+ return Object.keys(clone).length > 0 ? clone : undefined;
234586
+ }
233555
234587
  function normalizeGridWidth(width) {
233556
234588
  if (typeof width === "number" && Number.isFinite(width))
233557
234589
  return { col: Math.round(width) };
@@ -245856,6 +246888,8 @@ function assembleDocumentApiAdapters(editor) {
245856
246888
  join: (input2, options) => listsJoinWrapper(editor, input2, options),
245857
246889
  canJoin: (input2) => listsCanJoinWrapper(editor, input2),
245858
246890
  separate: (input2, options) => listsSeparateWrapper(editor, input2, options),
246891
+ merge: (input2, options) => listsMergeWrapper(editor, input2, options),
246892
+ split: (input2, options) => listsSplitWrapper(editor, input2, options),
245859
246893
  setLevel: (input2, options) => listsSetLevelWrapper(editor, input2, options),
245860
246894
  setValue: (input2, options) => listsSetValueWrapper(editor, input2, options),
245861
246895
  continuePrevious: (input2, options) => listsContinuePreviousWrapper(editor, input2, options),
@@ -246107,6 +247141,10 @@ function assembleDocumentApiAdapters(editor) {
246107
247141
  resolve: (input2) => resolveRange(editor, input2),
246108
247142
  scrollIntoView: (input2) => scrollRangeIntoView(editor, input2)
246109
247143
  },
247144
+ selection: {
247145
+ current: (input2) => resolveCurrentSelectionInfo(editor, input2),
247146
+ onChange: (listener) => subscribeToSelection(editor, listener)
247147
+ },
246110
247148
  query: { match: (input2) => queryMatchAdapter(editor, input2) },
246111
247149
  mutations: {
246112
247150
  preview: (input2) => previewPlan(editor, input2),
@@ -249509,7 +250547,7 @@ function getStableParagraphId(node3) {
249509
250547
  return null;
249510
250548
  return String(id2);
249511
250549
  }
249512
- function convertBorderSpec(ooxmlBorder) {
250550
+ function convertBorderSpec(ooxmlBorder, options) {
249513
250551
  if (!ooxmlBorder || typeof ooxmlBorder !== "object" || ooxmlBorder === null)
249514
250552
  return;
249515
250553
  const border = ooxmlBorder;
@@ -249529,17 +250567,25 @@ function convertBorderSpec(ooxmlBorder) {
249529
250567
  style: "none",
249530
250568
  width: 0
249531
250569
  };
249532
- const width = borderSizeToPx(sizeNumber);
249533
- if (width == null)
250570
+ if (!isFiniteNumber(sizeNumber))
249534
250571
  return;
250572
+ const numericSize = sizeNumber;
250573
+ if (numericSize <= 0)
250574
+ return {
250575
+ style: "none",
250576
+ width: 0
250577
+ };
249535
250578
  const normalizedColor = normalizeColorWithDefault(colorString);
250579
+ const width = resolveBorderWidth(numericSize, options?.unit ?? "px");
250580
+ if (width == null)
250581
+ return;
249536
250582
  return {
249537
250583
  style: val || "single",
249538
250584
  width,
249539
250585
  color: normalizedColor
249540
250586
  };
249541
250587
  }
249542
- function convertTableBorderValue(ooxmlBorder) {
250588
+ function convertTableBorderValue(ooxmlBorder, options) {
249543
250589
  if (!ooxmlBorder || typeof ooxmlBorder !== "object")
249544
250590
  return;
249545
250591
  const border = ooxmlBorder;
@@ -249548,10 +250594,15 @@ function convertTableBorderValue(ooxmlBorder) {
249548
250594
  const { val, size: size$1, color: color2 } = border;
249549
250595
  if (val === "nil" || val === "none" || size$1 === 0)
249550
250596
  return { none: true };
249551
- const width = borderSizeToPx(size$1);
249552
- if (width == null)
250597
+ if (!isFiniteNumber(size$1))
249553
250598
  return;
250599
+ const numericSize = size$1;
250600
+ if (numericSize <= 0)
250601
+ return { none: true };
249554
250602
  const normalizedColor = normalizeColorWithDefault(color2);
250603
+ const width = resolveBorderWidth(numericSize, options?.unit ?? "px");
250604
+ if (width == null)
250605
+ return;
249555
250606
  return {
249556
250607
  style: val || "single",
249557
250608
  width,
@@ -249573,7 +250624,7 @@ function isTableBorderValue(value) {
249573
250624
  return false;
249574
250625
  return (("style" in obj) || ("width" in obj) || ("color" in obj) || ("space" in obj)) && (!("style" in obj) || obj.style == null || isBorderStyle(obj.style));
249575
250626
  }
249576
- function extractTableBorders(bordersInput) {
250627
+ function extractTableBorders(bordersInput, options) {
249577
250628
  if (!bordersInput || typeof bordersInput !== "object")
249578
250629
  return;
249579
250630
  const sides = [
@@ -249592,7 +250643,7 @@ function extractTableBorders(bordersInput) {
249592
250643
  if (isTableBorderValue(raw))
249593
250644
  borders[side] = raw;
249594
250645
  else {
249595
- const converted = convertTableBorderValue(raw);
250646
+ const converted = convertTableBorderValue(raw, options);
249596
250647
  if (converted !== undefined)
249597
250648
  borders[side] = converted;
249598
250649
  }
@@ -251370,11 +252421,18 @@ function tableNodeToBlock(node3, { nextBlockId, positions, storyKey, trackedChan
251370
252421
  const tableAttrs = {};
251371
252422
  const getBorderSource = () => {
251372
252423
  if (node3.attrs?.borders && typeof node3.attrs.borders === "object" && node3.attrs.borders !== null && Object.keys(node3.attrs.borders).length > 0)
251373
- return node3.attrs.borders;
252424
+ return {
252425
+ borders: node3.attrs.borders,
252426
+ unit: "px"
252427
+ };
251374
252428
  if (hydratedTableStyle?.borders && typeof hydratedTableStyle.borders === "object" && hydratedTableStyle.borders !== null)
251375
- return hydratedTableStyle.borders;
252429
+ return {
252430
+ borders: hydratedTableStyle.borders,
252431
+ unit: "eighthPoints"
252432
+ };
251376
252433
  };
251377
- const tableBorders = extractTableBorders(getBorderSource());
252434
+ const borderSource = getBorderSource();
252435
+ const tableBorders = borderSource ? extractTableBorders(borderSource.borders, { unit: borderSource.unit }) : undefined;
251378
252436
  if (tableBorders)
251379
252437
  tableAttrs.borders = tableBorders;
251380
252438
  if (node3.attrs?.borderCollapse)
@@ -254202,7 +255260,11 @@ function computePhysicalAnchorY(block, fragmentHeight, pageHeight) {
254202
255260
  return offsetV;
254203
255261
  }
254204
255262
  function computeFooterBandOrigin(constraints) {
254205
- return (constraints.pageHeight ?? 0) - (constraints.margins?.bottom ?? 0);
255263
+ const pageHeight = constraints.pageHeight ?? 0;
255264
+ const footerDistance = constraints.margins?.footer;
255265
+ if (typeof footerDistance === "number" && Number.isFinite(footerDistance))
255266
+ return Math.max(0, pageHeight - Math.max(0, footerDistance));
255267
+ return Math.max(0, pageHeight - (constraints.margins?.bottom ?? 0));
254206
255268
  }
254207
255269
  function isAnchoredFragment(fragment2) {
254208
255270
  return (fragment2.kind === "image" || fragment2.kind === "drawing") && fragment2.isAnchored === true;
@@ -257048,15 +258110,15 @@ function measureRunSliceWidth(run2, fromChar, toChar) {
257048
258110
  context.font = fontString(run2);
257049
258111
  return context.measureText(text5).width;
257050
258112
  }
257051
- function lineHeightForRuns(runs2, fromRun, toRun) {
258113
+ function lineHeightForRuns(runs2, fromRun, toRun, fallbackFontSize = 16) {
257052
258114
  let maxSize$1 = 0;
257053
258115
  for (let i4 = fromRun;i4 <= toRun; i4 += 1) {
257054
258116
  const run2 = runs2[i4];
257055
- const size$1 = (run2 && isTextRun$3(run2) ? run2 : null)?.fontSize ?? 16;
258117
+ const size$1 = (run2 && isTextRun$3(run2) ? run2 : null)?.fontSize ?? 0;
257056
258118
  if (size$1 > maxSize$1)
257057
258119
  maxSize$1 = size$1;
257058
258120
  }
257059
- return maxSize$1 * 1.2;
258121
+ return (maxSize$1 > 0 ? maxSize$1 : fallbackFontSize) * 1.2;
257060
258122
  }
257061
258123
  function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
257062
258124
  if (!Number.isFinite(maxWidth) || maxWidth <= 0)
@@ -257101,6 +258163,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
257101
258163
  const decimalSeparator = sanitizeDecimalSeparator$1(attrs?.decimalSeparator);
257102
258164
  let currentRun = 0;
257103
258165
  let currentChar = 0;
258166
+ let lastMeasuredFontSize = runs2.find((run2) => isTextRun$3(run2) && typeof run2.fontSize === "number")?.fontSize ?? 16;
257104
258167
  while (currentRun < runs2.length) {
257105
258168
  const isFirstLine = lines.length === 0;
257106
258169
  const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
@@ -257115,10 +258178,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
257115
258178
  let endChar = currentChar;
257116
258179
  let tabStopCursor = 0;
257117
258180
  let didBreakInThisLine = false;
258181
+ let explicitLineBreakRun = -1;
257118
258182
  let resumeRun = -1;
257119
258183
  let resumeChar = 0;
258184
+ let lineMaxTextFontSize = 0;
257120
258185
  for (let r$1 = currentRun;r$1 < runs2.length; r$1 += 1) {
257121
258186
  const run2 = runs2[r$1];
258187
+ if (isLineBreakRun$1(run2)) {
258188
+ explicitLineBreakRun = r$1;
258189
+ if (startRun === r$1 && startChar === 0 && width === 0) {
258190
+ endRun = r$1;
258191
+ endChar = 0;
258192
+ }
258193
+ didBreakInThisLine = true;
258194
+ break;
258195
+ }
257122
258196
  if (run2.kind === "tab") {
257123
258197
  const absCurrentX = width + effectiveIndent;
257124
258198
  const { target, nextIndex, stop } = getNextTabStopPx$1(absCurrentX, tabStops, tabStopCursor);
@@ -257170,6 +258244,8 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
257170
258244
  const start$1 = r$1 === currentRun ? currentChar : r$1 === resumeRun ? resumeChar : 0;
257171
258245
  if (r$1 === resumeRun)
257172
258246
  resumeRun = -1;
258247
+ if (text5.length > 0 && isTextRun$3(run2))
258248
+ lineMaxTextFontSize = Math.max(lineMaxTextFontSize, run2.fontSize ?? 16);
257173
258249
  for (let c = start$1;c < text5.length; c += 1) {
257174
258250
  const ch = text5[c];
257175
258251
  if (ch === "\t") {
@@ -257254,7 +258330,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
257254
258330
  if (didBreakInThisLine)
257255
258331
  break;
257256
258332
  }
257257
- if (startRun === endRun && startChar === endChar) {
258333
+ if (explicitLineBreakRun < 0 && startRun === endRun && startChar === endChar) {
257258
258334
  endRun = startRun;
257259
258335
  endChar = startChar + 1;
257260
258336
  }
@@ -257266,15 +258342,29 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
257266
258342
  width,
257267
258343
  ascent: 0,
257268
258344
  descent: 0,
257269
- lineHeight: lineHeightForRuns(runs2, startRun, endRun),
258345
+ lineHeight: lineHeightForRuns(runs2, startRun, endRun, lastMeasuredFontSize),
257270
258346
  maxWidth: effectiveMaxWidth
257271
258347
  };
257272
258348
  lines.push(line);
257273
- currentRun = endRun;
257274
- currentChar = endChar;
258349
+ if (lineMaxTextFontSize > 0)
258350
+ lastMeasuredFontSize = lineMaxTextFontSize;
258351
+ if (explicitLineBreakRun >= 0) {
258352
+ if (startRun === explicitLineBreakRun && startChar === 0 && endRun === explicitLineBreakRun && endChar === 0)
258353
+ currentRun = explicitLineBreakRun + 1;
258354
+ else {
258355
+ let nextNonBreakRun = explicitLineBreakRun + 1;
258356
+ while (nextNonBreakRun < runs2.length && isLineBreakRun$1(runs2[nextNonBreakRun]))
258357
+ nextNonBreakRun += 1;
258358
+ currentRun = nextNonBreakRun >= runs2.length ? explicitLineBreakRun : explicitLineBreakRun + 1;
258359
+ }
258360
+ currentChar = 0;
258361
+ } else {
258362
+ currentRun = endRun;
258363
+ currentChar = endChar;
258364
+ }
257275
258365
  if (currentRun >= runs2.length)
257276
258366
  break;
257277
- if (currentChar >= runText(runs2[currentRun]).length) {
258367
+ if (!isLineBreakRun$1(runs2[currentRun]) && currentChar >= runText(runs2[currentRun]).length) {
257278
258368
  currentRun += 1;
257279
258369
  currentChar = 0;
257280
258370
  }
@@ -257374,6 +258464,8 @@ function computeConstraintsHash(constraints) {
257374
258464
  parts.push(`mb:${margins.bottom}`);
257375
258465
  if (margins.header !== undefined)
257376
258466
  parts.push(`mh:${margins.header}`);
258467
+ if (margins.footer !== undefined)
258468
+ parts.push(`mf:${margins.footer}`);
257377
258469
  }
257378
258470
  return parts.join("|");
257379
258471
  }
@@ -260239,9 +261331,13 @@ function getFirstTextPosition(doc$12) {
260239
261331
  if (!doc$12 || !doc$12.content)
260240
261332
  return 1;
260241
261333
  let validPos = 1;
261334
+ let found2 = false;
260242
261335
  doc$12.nodesBetween(0, doc$12.content.size, (node3, pos) => {
261336
+ if (found2)
261337
+ return false;
260243
261338
  if (node3.isTextblock) {
260244
261339
  validPos = pos + 1;
261340
+ found2 = true;
260245
261341
  return false;
260246
261342
  }
260247
261343
  return true;
@@ -260915,6 +262011,13 @@ function clickToPositionDom(domContainer, clientX, clientY) {
260915
262011
  log2("Using hit-chain line directly");
260916
262012
  return resolveLineAtX(hitChainLine, clientX);
260917
262013
  }
262014
+ if (fragmentEl.classList.contains(CLASS.tableFragment)) {
262015
+ const scopedContainer = findScopedLineContainer(hitChain, fragmentEl);
262016
+ if (scopedContainer) {
262017
+ log2("Resolving table click from scoped line container");
262018
+ return resolveFromLines(getLinesInPageFragment(scopedContainer, pageEl, fragmentEl), clientX, clientY);
262019
+ }
262020
+ }
260918
262021
  if (fragmentEl.classList.contains(CLASS.tableFragment)) {
260919
262022
  log2("Table fragment without line in hit chain — deferring to geometry");
260920
262023
  return null;
@@ -260963,7 +262066,9 @@ function readLayoutEpochFromDom(domContainer, clientX, clientY) {
260963
262066
  return latestEpoch;
260964
262067
  }
260965
262068
  function resolveFragment(fragmentEl, viewX, viewY) {
260966
- const lineEls = Array.from(fragmentEl.querySelectorAll(`.${CLASS.line}`));
262069
+ return resolveFromLines(Array.from(fragmentEl.querySelectorAll(`.${CLASS.line}`)), viewX, viewY);
262070
+ }
262071
+ function resolveFromLines(lineEls, viewX, viewY) {
260967
262072
  if (lineEls.length === 0) {
260968
262073
  log2("No lines in fragment");
260969
262074
  return null;
@@ -260984,6 +262089,13 @@ function resolveTextBoundaryWithinFragmentDom(fragmentEl, clientX, clientY) {
260984
262089
  return null;
260985
262090
  return resolveLineTextBoundaryAtX(lineEl, clientX);
260986
262091
  }
262092
+ function getLinesInPageFragment(containerEl, pageEl, fragmentEl) {
262093
+ return Array.from(containerEl.querySelectorAll(`.${CLASS.line}`)).filter((lineEl) => {
262094
+ if (lineEl.dataset.pmStart === undefined || lineEl.dataset.pmEnd === undefined)
262095
+ return false;
262096
+ return lineEl.closest(`.${CLASS.page}`) === pageEl && lineEl.closest(`.${CLASS.tableFragment}`) === fragmentEl;
262097
+ });
262098
+ }
260987
262099
  function resolveLineAtX(lineEl, viewX) {
260988
262100
  const { start: lineStart, end: lineEnd } = readPmRange(lineEl);
260989
262101
  if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
@@ -261087,12 +262199,19 @@ function resolveRightCaretBoundary(spanEls, targetIndex, spanStart, spanEnd) {
261087
262199
  function findLineAtY(lineEls, viewY) {
261088
262200
  if (lineEls.length === 0)
261089
262201
  return null;
262202
+ let nearest = lineEls[0];
262203
+ let minDistance = Infinity;
261090
262204
  for (const lineEl of lineEls) {
261091
262205
  const r$1 = lineEl.getBoundingClientRect();
261092
262206
  if (viewY >= r$1.top && viewY <= r$1.bottom)
261093
262207
  return lineEl;
262208
+ const distance2 = viewY < r$1.top ? r$1.top - viewY : Math.max(0, viewY - r$1.bottom);
262209
+ if (distance2 < minDistance) {
262210
+ minDistance = distance2;
262211
+ nearest = lineEl;
262212
+ }
261094
262213
  }
261095
- return lineEls[lineEls.length - 1];
262214
+ return nearest;
261096
262215
  }
261097
262216
  function findSpanAtX(spanEls, viewX) {
261098
262217
  if (spanEls.length === 0)
@@ -261113,6 +262232,19 @@ function findSpanAtX(spanEls, viewX) {
261113
262232
  }
261114
262233
  return nearest;
261115
262234
  }
262235
+ function findScopedLineContainer(hitChain, fragmentEl) {
262236
+ for (const el of hitChain) {
262237
+ if (!(el instanceof HTMLElement))
262238
+ continue;
262239
+ if (el === fragmentEl)
262240
+ break;
262241
+ if (!fragmentEl.contains(el))
262242
+ continue;
262243
+ if (el.querySelector(`.${CLASS.line}`))
262244
+ return el;
262245
+ }
262246
+ return null;
262247
+ }
261116
262248
  function mapCharIndexToPm(spanStart, spanEnd, rightCaretBoundary, textLength, charIndex) {
261117
262249
  if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
261118
262250
  return spanStart;
@@ -261922,6 +263054,29 @@ function isSameRenderedNoteTarget(left$1, right$1) {
261922
263054
  return false;
261923
263055
  return left$1.storyType === right$1.storyType && left$1.noteId === right$1.noteId;
261924
263056
  }
263057
+ function isOutsidePageBodyContent(layout, x, pageIndex, pageLocalY) {
263058
+ if (!Number.isFinite(x) || !Number.isFinite(pageIndex) || !Number.isFinite(pageLocalY))
263059
+ return false;
263060
+ const page = layout.pages[pageIndex];
263061
+ if (!page)
263062
+ return false;
263063
+ const pageWidth = page.size?.w ?? layout.pageSize.w;
263064
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
263065
+ if (!Number.isFinite(pageWidth) || pageWidth <= 0 || !Number.isFinite(pageHeight) || pageHeight <= 0)
263066
+ return false;
263067
+ const margins = page.margins ?? null;
263068
+ const marginLeft = Number.isFinite(margins?.left) ? margins.left : DEFAULT_PAGE_MARGIN_PX;
263069
+ const marginRight = Number.isFinite(margins?.right) ? margins.right : DEFAULT_PAGE_MARGIN_PX;
263070
+ const marginTop = Number.isFinite(margins?.top) ? margins.top : DEFAULT_PAGE_MARGIN_PX;
263071
+ const marginBottom = Number.isFinite(margins?.bottom) ? margins.bottom : DEFAULT_PAGE_MARGIN_PX;
263072
+ const bodyLeft = Math.max(0, marginLeft);
263073
+ const bodyRight = Math.min(pageWidth, pageWidth - Math.max(0, marginRight));
263074
+ const bodyTop = Math.max(0, marginTop);
263075
+ const bodyBottom = Math.min(pageHeight, pageHeight - Math.max(0, marginBottom));
263076
+ if (bodyLeft >= bodyRight || bodyTop >= bodyBottom)
263077
+ return false;
263078
+ return x < bodyLeft || x > bodyRight || pageLocalY < bodyTop || pageLocalY > bodyBottom;
263079
+ }
261925
263080
  function getCommentHighlightThreadIds(target) {
261926
263081
  if (!(target instanceof Element))
261927
263082
  return [];
@@ -261936,7 +263091,7 @@ function isDirectSingleCommentHighlightHit(target) {
261936
263091
  function isDirectTrackedChangeHit(target) {
261937
263092
  if (!(target instanceof Element))
261938
263093
  return false;
261939
- return target.closest(TRACK_CHANGE_SELECTOR) != null;
263094
+ return target.closest(`${TRACK_CHANGE_SELECTOR}, ${PM_TRACK_CHANGE_SELECTOR}`) != null;
261940
263095
  }
261941
263096
  function resolveTrackChangeThreadId(target) {
261942
263097
  if (!(target instanceof Element))
@@ -264044,7 +265199,8 @@ async function measureParagraphBlock(block, maxWidth) {
264044
265199
  maxFontInfo: lineBreakFontInfo,
264045
265200
  maxWidth: nextLineMaxWidth,
264046
265201
  segments: [],
264047
- spaceCount: 0
265202
+ spaceCount: 0,
265203
+ isLineBreakPlaceholder: true
264048
265204
  };
264049
265205
  tabStopCursor = 0;
264050
265206
  pendingTabAlignment = null;
@@ -264053,6 +265209,11 @@ async function measureParagraphBlock(block, maxWidth) {
264053
265209
  pendingRunSpacing = 0;
264054
265210
  continue;
264055
265211
  }
265212
+ if (currentLine?.isLineBreakPlaceholder) {
265213
+ currentLine.fromRun = runIndex;
265214
+ currentLine.toRun = runIndex;
265215
+ currentLine.isLineBreakPlaceholder = false;
265216
+ }
264056
265217
  if (isTabRun(run2)) {
264057
265218
  activeTabGroup = null;
264058
265219
  pendingLeader = null;
@@ -270073,7 +271234,7 @@ var Node$13 = class Node$14 {
270073
271234
  if (handled && dispatch)
270074
271235
  dispatch(tr);
270075
271236
  return handled;
270076
- }, insertListItemAt = ({ pos, position: position4, text: text5 = "", sdBlockId, tracked }) => ({ state, dispatch }) => {
271237
+ }, insertListItemAt = ({ pos, position: position4, text: text5 = "", sdBlockId, paraId, tracked }) => ({ state, dispatch }) => {
270077
271238
  if (!Number.isInteger(pos) || pos < 0 || pos > state.doc.content.size)
270078
271239
  return false;
270079
271240
  if (position4 !== "before" && position4 !== "after")
@@ -270096,7 +271257,7 @@ var Node$13 = class Node$14 {
270096
271257
  const attrs = {
270097
271258
  ...targetNode.attrs ?? {},
270098
271259
  sdBlockId: sdBlockId ?? null,
270099
- paraId: null,
271260
+ paraId: paraId ?? null,
270100
271261
  textId: null,
270101
271262
  listRendering: null,
270102
271263
  paragraphProperties: newParagraphProperties,
@@ -272019,7 +273180,7 @@ var Node$13 = class Node$14 {
272019
273180
  return false;
272020
273181
  editor.commands.deleteTable();
272021
273182
  return true;
272022
- }, createTableBorders = (borderSpec = {}) => {
273183
+ }, TABLE_BORDER_SIDES, createTableBorders = (borderSpec = {}) => {
272023
273184
  borderSpec = {
272024
273185
  size: 0.66665,
272025
273186
  color: "#000000",
@@ -278051,7 +279212,7 @@ var Node$13 = class Node$14 {
278051
279212
  debugGlobal.__SD_DEBUG_STORY_INPUT_LOG__ = existingLog;
278052
279213
  }, isStorySurfaceEditor = (editor) => {
278053
279214
  const documentId = editor?.options?.documentId ?? "";
278054
- return documentId.startsWith("hf:") || documentId.startsWith("fn:") || documentId.startsWith("en:");
279215
+ return documentId.startsWith("hf:") || documentId.startsWith("fn:") || documentId.startsWith("en:") || editor?.options?.isHeaderOrFooter === true || editor?.options?.headerFooterType === "header" || editor?.options?.headerFooterType === "footer";
278055
279216
  }, recordStoryInputDebug = (view, event, editor, phase, extra = {}) => {
278056
279217
  if (!isStorySurfaceEditor(editor))
278057
279218
  return;
@@ -278094,6 +279255,12 @@ var Node$13 = class Node$14 {
278094
279255
  return false;
278095
279256
  }
278096
279257
  const tr = view.state.tr.insertText(event.data, selection.from, selection.to);
279258
+ const insertedTo = Math.max(0, Math.min(selection.from + event.data.length, tr.doc.content.size));
279259
+ try {
279260
+ tr.setSelection(TextSelection.create(tr.doc, insertedTo));
279261
+ } catch {
279262
+ tr.setSelection(Selection.near(tr.doc.resolve(insertedTo), 1));
279263
+ }
278097
279264
  tr.setMeta("inputType", "insertText");
278098
279265
  view.dispatch(tr);
278099
279266
  event.preventDefault();
@@ -279272,7 +280439,7 @@ var Node$13 = class Node$14 {
279272
280439
  listener(snapshot2);
279273
280440
  } catch {}
279274
280441
  }
279275
- }, EMITTABLE_BLOCK_TYPES, SDT_BLOCK_NODE_NAMES, REQUIRED_COMMANDS, VALID_CAPABILITY_REASON_CODES, REQUIRED_HELPERS, SCHEMA_NODE_GATES, schemaGatedIds, SUPPORTED_NON_UNIFORM_STRATEGIES, SUPPORTED_SET_MARKS, REGEX_MAX_PATTERN_LENGTH = 1024, STYLES_PART = "word/styles.xml", PROPERTIES_KEY_BY_CHANNEL, XML_PATH_BY_CHANNEL2, UNDERLINE_API_TO_STORAGE, UNDERLINE_STORAGE_TO_API, HEX_SUBKEYS_BY_PROPERTY, SUPPORTED_DELETE_NODE_TYPES3, REJECTED_DELETE_NODE_TYPES3, TEXT_PREVIEW_MAX_LENGTH = 80, RANGE_DELETE_SAFE_NODE_TYPES, HEADING_PATTERN, OOXML_DEFAULT_FONT_SIZE_PT = 10, INDENT_PER_LEVEL_TWIPS = 720, HANGING_INDENT_TWIPS = 360, SYMBOL_FONT_NAMES, RFONTS_FAMILY_ATTRS, ORDERED_PRESET_CONFIG, BULLET_PRESET_CONFIG, PRESET_TEMPLATES, LevelFormattingHelpers, PRESET_KIND_MAP, NUMBERING_PART = "word/numbering.xml", DEFAULT_PRESET_FOR_KIND, _setValueDelegate, PREVIEW_TEXT_MAX_LENGTH = 2000, BLOCK_PREVIEW_MAX_LENGTH = 200, EDGE_NODE_TYPES$1, POINTS_TO_PIXELS, POINTS_TO_TWIPS = 20, PIXELS_TO_TWIPS, DEFAULT_TABLE_GRID_WIDTH_TWIPS = 1500, SETTINGS_PART$1 = "word/settings.xml", WORD_DEFAULT_TBL_LOOK, FLAG_TO_OOXML_KEY, INVERTED_FLAGS, XML_KEY_TO_STYLE_OPTION, CLEARED_BORDER_OOXML, TABLE_MARGIN_KEY_GROUPS, TABLE_ADAPTER_DISPATCH, ROW_TARGETED_TABLE_OPS, registered = false, STYLES_PART_ID = "word/styles.xml", stylesPartDescriptor, settingsPartDescriptor, RELS_PART_ID2 = "word/_rels/document.xml.rels", RELS_XMLNS2 = "http://schemas.openxmlformats.org/package/2006/relationships", HEADER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", relsPartDescriptor, BatchHistoryAdapter = class {
280442
+ }, TRACK_MARK_TYPE_BY_NAME, EMITTABLE_BLOCK_TYPES, SDT_BLOCK_NODE_NAMES, REQUIRED_COMMANDS, VALID_CAPABILITY_REASON_CODES, REQUIRED_HELPERS, SCHEMA_NODE_GATES, schemaGatedIds, SUPPORTED_NON_UNIFORM_STRATEGIES, SUPPORTED_SET_MARKS, REGEX_MAX_PATTERN_LENGTH = 1024, STYLES_PART = "word/styles.xml", PROPERTIES_KEY_BY_CHANNEL, XML_PATH_BY_CHANNEL2, UNDERLINE_API_TO_STORAGE, UNDERLINE_STORAGE_TO_API, HEX_SUBKEYS_BY_PROPERTY, SUPPORTED_DELETE_NODE_TYPES3, REJECTED_DELETE_NODE_TYPES3, TEXT_PREVIEW_MAX_LENGTH = 80, RANGE_DELETE_SAFE_NODE_TYPES, HEADING_PATTERN, OOXML_DEFAULT_FONT_SIZE_PT = 10, INDENT_PER_LEVEL_TWIPS = 720, HANGING_INDENT_TWIPS = 360, SYMBOL_FONT_NAMES, RFONTS_FAMILY_ATTRS, ORDERED_PRESET_CONFIG, BULLET_PRESET_CONFIG, PRESET_TEMPLATES, LevelFormattingHelpers, PRESET_KIND_MAP, NUMBERING_PART = "word/numbering.xml", DEFAULT_PRESET_FOR_KIND, _setValueDelegate, PREVIEW_TEXT_MAX_LENGTH = 2000, BLOCK_PREVIEW_MAX_LENGTH = 200, EDGE_NODE_TYPES$1, POINTS_TO_PIXELS, POINTS_TO_TWIPS = 20, PIXELS_TO_TWIPS, DEFAULT_TABLE_GRID_WIDTH_TWIPS = 1500, SETTINGS_PART$1 = "word/settings.xml", WORD_DEFAULT_TBL_LOOK, FLAG_TO_OOXML_KEY, INVERTED_FLAGS, XML_KEY_TO_STYLE_OPTION, CLEARED_BORDER_OOXML, TABLE_MARGIN_KEY_GROUPS, TABLE_ADAPTER_DISPATCH, ROW_TARGETED_TABLE_OPS, registered = false, STYLES_PART_ID = "word/styles.xml", stylesPartDescriptor, settingsPartDescriptor, RELS_PART_ID2 = "word/_rels/document.xml.rels", RELS_XMLNS2 = "http://schemas.openxmlformats.org/package/2006/relationships", HEADER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", relsPartDescriptor, BatchHistoryAdapter = class {
279276
280443
  #done = [];
279277
280444
  #redone = [];
279278
280445
  #listeners = /* @__PURE__ */ new Set;
@@ -283994,13 +285161,10 @@ menclose::after {
283994
285161
  misses: this.#misses
283995
285162
  };
283996
285163
  }
283997
- }, EIGHTHS_PER_POINT = 8, MIN_BORDER_SIZE_PX = 0.5, MAX_BORDER_SIZE_PX = 100, borderSizeToPx = (size$1) => {
283998
- if (!isFiniteNumber(size$1))
283999
- return;
284000
- if (size$1 <= 0)
284001
- return 0;
284002
- const pixelValue = size$1 / EIGHTHS_PER_POINT * PX_PER_PT$12;
284003
- return Math.min(MAX_BORDER_SIZE_PX, Math.max(MIN_BORDER_SIZE_PX, pixelValue));
285164
+ }, MIN_BORDER_SIZE_PX2 = 0.5, MAX_BORDER_SIZE_PX2 = 100, borderSizeToPx = (size$1) => eighthPointsToPixels(size$1, { clamp: true }), clampPixelBorderWidth = (width) => Math.min(MAX_BORDER_SIZE_PX2, Math.max(MIN_BORDER_SIZE_PX2, width)), resolveBorderWidth = (size$1, unit) => {
285165
+ if (unit === "eighthPoints")
285166
+ return borderSizeToPx(size$1);
285167
+ return clampPixelBorderWidth(size$1);
284004
285168
  }, normalizeColorWithDefault = (color2) => {
284005
285169
  if (!color2 || color2 === "auto")
284006
285170
  return "#000000";
@@ -285498,7 +286662,7 @@ menclose::after {
285498
286662
  if (padding)
285499
286663
  inlinePadding = normalizeCellPaddingTopBottom(padding);
285500
286664
  if (tableProps.borders && typeof tableProps.borders === "object")
285501
- inlineBorders = clonePlainObject(tableProps.borders);
286665
+ inlineBorders = normalizeTableBorders(tableProps.borders);
285502
286666
  if (typeof tableProps.justification === "string")
285503
286667
  hydration.justification = tableProps.justification;
285504
286668
  const tableWidth = normalizeTableWidth(tableProps.tableWidth);
@@ -285509,11 +286673,11 @@ menclose::after {
285509
286673
  if (styleId && context?.translatedLinkedStyles) {
285510
286674
  const resolved = resolveTableProperties(styleId, context.translatedLinkedStyles);
285511
286675
  if (resolved.borders) {
285512
- const styleBorders = clonePlainObject(resolved.borders);
285513
- hydration.borders = inlineBorders ? {
286676
+ const styleBorders = normalizeTableBorders(resolved.borders);
286677
+ hydration.borders = inlineBorders && styleBorders ? {
285514
286678
  ...styleBorders,
285515
286679
  ...inlineBorders
285516
- } : styleBorders;
286680
+ } : inlineBorders ?? styleBorders;
285517
286681
  } else if (inlineBorders)
285518
286682
  hydration.borders = inlineBorders;
285519
286683
  if (resolved.cellMargins) {
@@ -285544,7 +286708,34 @@ menclose::after {
285544
286708
  hydration.cellPadding = inlinePadding;
285545
286709
  }
285546
286710
  return Object.keys(hydration).length > 0 ? hydration : null;
285547
- }, clonePlainObject = (value) => ({ ...value }), convertCellMarginsToPx = (margins) => {
286711
+ }, normalizeTableBorders = (value) => {
286712
+ if (!value)
286713
+ return;
286714
+ const sides = [
286715
+ "top",
286716
+ "bottom",
286717
+ "left",
286718
+ "right",
286719
+ "insideH",
286720
+ "insideV"
286721
+ ];
286722
+ const result = {};
286723
+ for (const side of sides) {
286724
+ const border = value[side];
286725
+ if (!border || typeof border !== "object")
286726
+ continue;
286727
+ const converted = convertTableBorderValue(adjustBorderSize(border));
286728
+ if (converted)
286729
+ result[side] = converted;
286730
+ }
286731
+ return Object.keys(result).length > 0 ? result : undefined;
286732
+ }, adjustBorderSize = (border) => {
286733
+ const size$1 = typeof border.size === "number" ? borderSizeToPx(border.size) : undefined;
286734
+ return size$1 != null ? {
286735
+ ...border,
286736
+ size: size$1
286737
+ } : border;
286738
+ }, convertCellMarginsToPx = (margins) => {
285548
286739
  if (!margins || typeof margins !== "object")
285549
286740
  return;
285550
286741
  const spacing = {};
@@ -285602,7 +286793,16 @@ menclose::after {
285602
286793
  width: raw,
285603
286794
  type: measurement.type
285604
286795
  };
285605
- }, isTableRowNode = (node3) => node3.type === "tableRow" || node3.type === "table_row", isTableCellNode = (node3) => node3.type === "tableCell" || node3.type === "table_cell" || node3.type === "tableHeader" || node3.type === "table_header", normalizeRowHeight = (rowProps) => {
286796
+ }, isTableRowNode = (node3) => node3.type === "tableRow" || node3.type === "table_row", isTableCellNode = (node3) => node3.type === "tableCell" || node3.type === "table_cell" || node3.type === "tableHeader" || node3.type === "table_header", convertResolvedCellBorder = (value) => {
286797
+ if (!value || typeof value !== "object")
286798
+ return;
286799
+ const border = value;
286800
+ const size$1 = typeof border.size === "number" ? borderSizeToPx(border.size) : undefined;
286801
+ return convertBorderSpec(size$1 != null ? {
286802
+ ...border,
286803
+ size: size$1
286804
+ } : border);
286805
+ }, normalizeRowHeight = (rowProps) => {
285606
286806
  if (!rowProps || typeof rowProps !== "object")
285607
286807
  return;
285608
286808
  const rawRowHeight = rowProps.rowHeight;
@@ -285798,7 +286998,7 @@ menclose::after {
285798
286998
  "bottom",
285799
286999
  "left"
285800
287000
  ]) {
285801
- const spec = convertBorderSpec(resolvedTcProps.borders[side]);
287001
+ const spec = convertResolvedCellBorder(resolvedTcProps.borders[side]);
285802
287002
  if (spec)
285803
287003
  resolvedBorders[side] = spec;
285804
287004
  }
@@ -288563,6 +289763,7 @@ menclose::after {
288563
289763
  return m$1.height;
288564
289764
  return 0;
288565
289765
  };
289766
+ let nearestParagraphHit = null;
288566
289767
  for (let i4 = 0;i4 < cellBlocks.length && i4 < cellBlockMeasures.length; i4++) {
288567
289768
  const cellBlock = cellBlocks[i4];
288568
289769
  const cellBlockMeasure = cellBlockMeasures[i4];
@@ -288582,9 +289783,7 @@ menclose::after {
288582
289783
  const cellLocalY = localY - rowY - (padding.top ?? 0);
288583
289784
  const paragraphBlock = cellBlock;
288584
289785
  const paragraphMeasure = cellBlockMeasure;
288585
- const isWithinBlock = cellLocalY >= blockStartY && cellLocalY < blockEndY;
288586
- const isLastParagraph = i4 === Math.min(cellBlocks.length, cellBlockMeasures.length) - 1;
288587
- if (isWithinBlock || isLastParagraph) {
289786
+ if (cellLocalY >= blockStartY && cellLocalY < blockEndY) {
288588
289787
  const unclampedLocalY = cellLocalY - blockStartY;
288589
289788
  const localYWithinBlock = Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0)));
288590
289789
  return {
@@ -288601,9 +289800,35 @@ menclose::after {
288601
289800
  blockStartGlobal: blockStartGlobalLines
288602
289801
  };
288603
289802
  }
289803
+ const distanceToBlock = cellLocalY < blockStartY ? blockStartY - cellLocalY : Math.max(0, cellLocalY - blockEndY);
289804
+ if (!nearestParagraphHit || distanceToBlock < nearestParagraphHit.distance) {
289805
+ const unclampedLocalY = cellLocalY - blockStartY;
289806
+ nearestParagraphHit = {
289807
+ cellBlock: paragraphBlock,
289808
+ cellMeasure: paragraphMeasure,
289809
+ localX: Math.max(0, cellLocalX),
289810
+ localY: Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0))),
289811
+ blockStartGlobal: blockStartGlobalLines,
289812
+ distance: distanceToBlock
289813
+ };
289814
+ }
288604
289815
  blockStartY = blockEndY;
288605
289816
  blockStartGlobalLines += paragraphMeasure.lines.length;
288606
289817
  }
289818
+ if (nearestParagraphHit)
289819
+ return {
289820
+ fragment: tableFragment,
289821
+ block: tableBlock,
289822
+ measure: tableMeasure,
289823
+ pageIndex: pageHit.pageIndex,
289824
+ cellRowIndex: rowIndex,
289825
+ cellColIndex: colIndex,
289826
+ cellBlock: nearestParagraphHit.cellBlock,
289827
+ cellMeasure: nearestParagraphHit.cellMeasure,
289828
+ localX: nearestParagraphHit.localX,
289829
+ localY: nearestParagraphHit.localY,
289830
+ blockStartGlobal: nearestParagraphHit.blockStartGlobal
289831
+ };
288607
289832
  }
288608
289833
  return null;
288609
289834
  }, logSelectionMapDebug = (payload) => {}, rangesOverlap = (startA, endA, startB, endB) => {
@@ -290351,7 +291576,7 @@ menclose::after {
290351
291576
  this.#onCursorsUpdate = null;
290352
291577
  this.#isSetup = false;
290353
291578
  }
290354
- }, SEMANTIC_FOOTNOTES_HEADING_BLOCK_ID = "__sd_semantic_footnotes_heading", SEMANTIC_FOOTNOTE_BLOCK_ID_PREFIX = "__sd_semantic_footnote", MULTI_CLICK_TIME_THRESHOLD_MS = 400, MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5, AUTO_SCROLL_EDGE_PX = 32, AUTO_SCROLL_MAX_SPEED_PX = 24, SCROLL_DETECTION_TOLERANCE_PX = 1, COMMENT_HIGHLIGHT_SELECTOR = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR = "[data-track-change-id]", PM_TRACK_CHANGE_SELECTOR = ".track-insert[data-id], .track-delete[data-id], .track-format[data-id]", VISIBLE_HEADER_FOOTER_SELECTOR = ".superdoc-page-header, .superdoc-page-footer", VISIBLE_BODY_CONTENT_SELECTOR = ".superdoc-line, .superdoc-fragment, [data-block-id]", COMMENT_THREAD_HIT_TOLERANCE_PX = 3, COMMENT_THREAD_HIT_SAMPLE_OFFSETS, clamp = (value, min$2, max$2) => Math.max(min$2, Math.min(max$2, value)), EditorInputManager = class {
291579
+ }, SEMANTIC_FOOTNOTES_HEADING_BLOCK_ID = "__sd_semantic_footnotes_heading", SEMANTIC_FOOTNOTE_BLOCK_ID_PREFIX = "__sd_semantic_footnote", MULTI_CLICK_TIME_THRESHOLD_MS = 400, MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5, AUTO_SCROLL_EDGE_PX = 32, AUTO_SCROLL_MAX_SPEED_PX = 24, SCROLL_DETECTION_TOLERANCE_PX = 1, DEFAULT_PAGE_MARGIN_PX = 72, COMMENT_HIGHLIGHT_SELECTOR = ".superdoc-comment-highlight", TRACK_CHANGE_SELECTOR = "[data-track-change-id]", PM_TRACK_CHANGE_SELECTOR = ".track-insert[data-id], .track-delete[data-id], .track-format[data-id]", VISIBLE_HEADER_FOOTER_SELECTOR = ".superdoc-page-header, .superdoc-page-footer", VISIBLE_BODY_CONTENT_SELECTOR = ".superdoc-line, .superdoc-fragment, [data-block-id]", COMMENT_THREAD_HIT_TOLERANCE_PX = 3, COMMENT_THREAD_HIT_SAMPLE_OFFSETS, clamp = (value, min$2, max$2) => Math.max(min$2, Math.min(max$2, value)), EditorInputManager = class {
290355
291580
  #deps = null;
290356
291581
  #callbacks = {};
290357
291582
  #isDragging = false;
@@ -290983,6 +292208,11 @@ menclose::after {
290983
292208
  return;
290984
292209
  }
290985
292210
  }
292211
+ if (!useActiveSurfaceHitTest && isOutsidePageBodyContent(layoutState.layout, x, normalizedPoint.pageIndex, normalizedPoint.pageLocalY)) {
292212
+ event.preventDefault();
292213
+ this.#focusEditor();
292214
+ return;
292215
+ }
290986
292216
  const { rawHit, hit } = this.#resolveSelectionPointerHit({
290987
292217
  layoutState,
290988
292218
  normalized: {
@@ -291038,10 +292268,10 @@ menclose::after {
291038
292268
  }
291039
292269
  }
291040
292270
  if (!rawHit) {
291041
- this.#focusEditorAtFirstPosition();
292271
+ this.#focusEditor();
291042
292272
  return;
291043
292273
  }
291044
- if (isNoteEditing && activeNoteTarget && parseRenderedNoteTarget$1(rawHit.blockId)?.noteId !== activeNoteTarget.noteId) {
292274
+ if (isNoteEditing && activeNoteTarget && !isSameRenderedNoteTarget(parseRenderedNoteTarget$1(rawHit.blockId), activeNoteTarget)) {
291045
292275
  this.#callbacks.exitActiveStorySession?.();
291046
292276
  this.#focusEditor();
291047
292277
  return;
@@ -291388,16 +292618,20 @@ menclose::after {
291388
292618
  #findStructuredContentBlockAtPos(doc$12, pos) {
291389
292619
  if (!Number.isFinite(pos))
291390
292620
  return null;
291391
- const $pos = doc$12.resolve(pos);
291392
- for (let depth = $pos.depth;depth > 0; depth--) {
291393
- const node3 = $pos.node(depth);
291394
- if (node3.type?.name === "structuredContentBlock")
291395
- return {
291396
- node: node3,
291397
- pos: $pos.before(depth),
291398
- start: $pos.start(depth),
291399
- end: $pos.end(depth)
291400
- };
292621
+ try {
292622
+ const $pos = doc$12.resolve(pos);
292623
+ for (let depth = $pos.depth;depth > 0; depth--) {
292624
+ const node3 = $pos.node(depth);
292625
+ if (node3.type?.name === "structuredContentBlock")
292626
+ return {
292627
+ node: node3,
292628
+ pos: $pos.before(depth),
292629
+ start: $pos.start(depth),
292630
+ end: $pos.end(depth)
292631
+ };
292632
+ }
292633
+ } catch {
292634
+ return null;
291401
292635
  }
291402
292636
  return null;
291403
292637
  }
@@ -291445,16 +292679,20 @@ menclose::after {
291445
292679
  #findStructuredContentInlineAtPos(doc$12, pos) {
291446
292680
  if (!Number.isFinite(pos))
291447
292681
  return null;
291448
- const $pos = doc$12.resolve(pos);
291449
- for (let depth = $pos.depth;depth > 0; depth--) {
291450
- const node3 = $pos.node(depth);
291451
- if (node3.type?.name === "structuredContent")
291452
- return {
291453
- node: node3,
291454
- pos: $pos.before(depth),
291455
- start: $pos.start(depth),
291456
- end: $pos.end(depth)
291457
- };
292682
+ try {
292683
+ const $pos = doc$12.resolve(pos);
292684
+ for (let depth = $pos.depth;depth > 0; depth--) {
292685
+ const node3 = $pos.node(depth);
292686
+ if (node3.type?.name === "structuredContent")
292687
+ return {
292688
+ node: node3,
292689
+ pos: $pos.before(depth),
292690
+ start: $pos.start(depth),
292691
+ end: $pos.end(depth)
292692
+ };
292693
+ }
292694
+ } catch {
292695
+ return null;
291458
292696
  }
291459
292697
  return null;
291460
292698
  }
@@ -291951,8 +293189,10 @@ menclose::after {
291951
293189
  if (!editorDom)
291952
293190
  return;
291953
293191
  const active = document.activeElement;
291954
- if (active === editorDom || !!active && editorDom.contains?.(active))
293192
+ if (active === editorDom || !!active && editorDom.contains?.(active)) {
293193
+ this.#focusEditorView(view);
291955
293194
  return;
293195
+ }
291956
293196
  if (active instanceof HTMLElement)
291957
293197
  active.blur();
291958
293198
  editorDom.focus();
@@ -294896,18 +296136,18 @@ menclose::after {
294896
296136
  return;
294897
296137
  console.log(...args$1);
294898
296138
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
294899
- var init_src_BNgFLixt_es = __esm(() => {
296139
+ var init_src_iqx3UG8T_es = __esm(() => {
294900
296140
  init_rolldown_runtime_Bg48TavK_es();
294901
- init_SuperConverter_2Pu0hMB1_es();
296141
+ init_SuperConverter_lmyr0gmB_es();
294902
296142
  init_jszip_C49i9kUs_es();
294903
296143
  init_uuid_qzgm05fK_es();
294904
- init_create_headless_toolbar_sMwtuYL8_es();
294905
- init_constants_CGhJRd87_es();
296144
+ init_create_headless_toolbar_CVKqElqj_es();
296145
+ init_constants_DrU4EASo_es();
294906
296146
  init_dist_B8HfvhaK_es();
294907
296147
  init_unified_Dsuw2be5_es();
294908
296148
  init_remark_gfm_BhnWr3yf_es();
294909
296149
  init_remark_stringify_6MMJfY0k_es();
294910
- init_DocxZipper_BBjEXAFw_es();
296150
+ init_DocxZipper_CwFyjl1b_es();
294911
296151
  init__plugin_vue_export_helper_HmhZBO0u_es();
294912
296152
  init_eventemitter3_BdNugZrm_es();
294913
296153
  init_errors_CtyzHiH4_es();
@@ -298846,6 +300086,14 @@ ${err.toString()}`);
298846
300086
  } };
298847
300087
  }
298848
300088
  });
300089
+ TABLE_BORDER_SIDES = [
300090
+ "top",
300091
+ "bottom",
300092
+ "left",
300093
+ "right",
300094
+ "insideH",
300095
+ "insideV"
300096
+ ];
298849
300097
  TABLE_CELL_ROLES = new Set(["cell", "header_cell"]);
298850
300098
  TableBoundaryNavigationPluginKey = new PluginKey("tableBoundaryNavigation");
298851
300099
  Table = Node$13.create({
@@ -317548,6 +318796,11 @@ function print() { __p += __j.call(arguments, '') }
317548
318796
  "image"
317549
318797
  ]);
317550
318798
  indexByHost = /* @__PURE__ */ new WeakMap;
318799
+ TRACK_MARK_TYPE_BY_NAME = {
318800
+ [TrackInsertMarkName]: "insert",
318801
+ [TrackDeleteMarkName]: "delete",
318802
+ [TrackFormatMarkName]: "format"
318803
+ };
317551
318804
  EMITTABLE_BLOCK_TYPES = new Set([
317552
318805
  "paragraph",
317553
318806
  "heading",
@@ -318707,7 +319960,7 @@ function print() { __p += __j.call(arguments, '') }
318707
319960
  const { telemetry: telemetryConfig, licenseKey } = this.options;
318708
319961
  if (typeof process$12 !== "undefined" && (process$12.env?.VITEST || process$12.env.NODE_ENV === "test"))
318709
319962
  return;
318710
- if (this.options.mode === "text" || this.options.isHeaderOrFooter)
319963
+ if (this.options.mode === "text" || this.options.isHeaderOrFooter || this.options.isChildEditor)
318711
319964
  return;
318712
319965
  if (!telemetryConfig?.enabled)
318713
319966
  return;
@@ -322207,13 +323460,17 @@ function print() { __p += __j.call(arguments, '') }
322207
323460
  getDecorationAnchorPageOriginY(pageEl, page, kind, effectiveOffset, resolvedPage) {
322208
323461
  if (kind === "header")
322209
323462
  return effectiveOffset;
322210
- const bottomMargin = (resolvedPage?.margins ?? page.margins)?.bottom;
323463
+ const pageMargins = resolvedPage?.margins ?? page.margins;
323464
+ const styledPageHeight = Number.parseFloat(pageEl.style.height || "");
323465
+ const pageHeight = page.size?.h ?? this.currentLayout?.pageSize?.h ?? (Number.isFinite(styledPageHeight) ? styledPageHeight : pageEl.clientHeight);
323466
+ const footerDistance = pageMargins?.footer;
323467
+ if (typeof footerDistance === "number" && Number.isFinite(footerDistance))
323468
+ return Math.max(0, pageHeight - Math.max(0, footerDistance));
323469
+ const bottomMargin = pageMargins?.bottom;
322211
323470
  if (bottomMargin == null)
322212
323471
  return effectiveOffset;
322213
323472
  const footnoteReserve = resolvedPage?.footnoteReserved ?? page.footnoteReserved ?? 0;
322214
323473
  const adjustedBottomMargin = Math.max(0, bottomMargin - footnoteReserve);
322215
- const styledPageHeight = Number.parseFloat(pageEl.style.height || "");
322216
- const pageHeight = page.size?.h ?? this.currentLayout?.pageSize?.h ?? (Number.isFinite(styledPageHeight) ? styledPageHeight : pageEl.clientHeight);
322217
323474
  return Math.max(0, pageHeight - adjustedBottomMargin);
322218
323475
  }
322219
323476
  renderDecorationSection(pageEl, page, pageIndex, kind, resolvedPage) {
@@ -324730,6 +325987,7 @@ function print() { __p += __j.call(arguments, '') }
324730
325987
  geoSdtWrapper.style.top = "0px";
324731
325988
  geoSdtWrapper.style.height = `${line.lineHeight}px`;
324732
325989
  }
325990
+ this.syncInlineSdtWrapperTypography(geoSdtWrapper, runForSdt);
324733
325991
  elem.style.left = `${elemLeftPx - geoSdtWrapperLeft}px`;
324734
325992
  geoSdtMaxRight = Math.max(geoSdtMaxRight, elemLeftPx + elemWidthPx);
324735
325993
  this.expandSdtWrapperPmRange(geoSdtWrapper, runForSdt.pmStart, runForSdt.pmEnd);
@@ -324917,6 +326175,7 @@ function print() { __p += __j.call(arguments, '') }
324917
326175
  if (resolved && this.doc) {
324918
326176
  if (!currentInlineSdtWrapper) {
324919
326177
  currentInlineSdtWrapper = this.createInlineSdtWrapper(resolved.sdt);
326178
+ this.syncInlineSdtWrapperTypography(currentInlineSdtWrapper, run2);
324920
326179
  currentInlineSdtId = runSdtId;
324921
326180
  }
324922
326181
  this.expandSdtWrapperPmRange(currentInlineSdtWrapper, run2.pmStart, run2.pmEnd);
@@ -325138,6 +326397,11 @@ function print() { __p += __j.call(arguments, '') }
325138
326397
  wrapper.appendChild(labelEl);
325139
326398
  return wrapper;
325140
326399
  }
326400
+ syncInlineSdtWrapperTypography(wrapper, runForSizing) {
326401
+ const runFontSize = runForSizing && "fontSize" in runForSizing && typeof runForSizing.fontSize === "number" ? `${runForSizing.fontSize}px` : BROWSER_DEFAULT_FONT_SIZE;
326402
+ wrapper.style.fontSize = runFontSize;
326403
+ wrapper.style.lineHeight = "normal";
326404
+ }
325141
326405
  expandSdtWrapperPmRange(wrapper, pmStart, pmEnd) {
325142
326406
  if (pmStart != null) {
325143
326407
  const cur = wrapper.dataset.pmStart;
@@ -330148,7 +331412,8 @@ function print() { __p += __j.call(arguments, '') }
330148
331412
  right: marginRight,
330149
331413
  top: marginTop,
330150
331414
  bottom: marginBottom,
330151
- header: headerMargin
331415
+ header: headerMargin,
331416
+ ...margins.footer != null ? { footer: footerMargin } : {}
330152
331417
  },
330153
331418
  overflowBaseHeight
330154
331419
  };
@@ -331774,15 +333039,15 @@ var init_zipper_DbkgrypV_es = __esm(() => {
331774
333039
 
331775
333040
  // ../../packages/superdoc/dist/super-editor.es.js
331776
333041
  var init_super_editor_es = __esm(() => {
331777
- init_src_BNgFLixt_es();
331778
- init_SuperConverter_2Pu0hMB1_es();
333042
+ init_src_iqx3UG8T_es();
333043
+ init_SuperConverter_lmyr0gmB_es();
331779
333044
  init_jszip_C49i9kUs_es();
331780
333045
  init_xml_js_CqGKpaft_es();
331781
- init_create_headless_toolbar_sMwtuYL8_es();
331782
- init_constants_CGhJRd87_es();
333046
+ init_create_headless_toolbar_CVKqElqj_es();
333047
+ init_constants_DrU4EASo_es();
331783
333048
  init_dist_B8HfvhaK_es();
331784
333049
  init_unified_Dsuw2be5_es();
331785
- init_DocxZipper_BBjEXAFw_es();
333050
+ init_DocxZipper_CwFyjl1b_es();
331786
333051
  init_eventemitter3_BdNugZrm_es();
331787
333052
  init_errors_CtyzHiH4_es();
331788
333053
  init_zipper_DbkgrypV_es();