@harbour-enterprises/superdoc 1.0.0-next.9 → 1.0.2

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 (37) hide show
  1. package/dist/chunks/{PdfViewer-C7Wo4VVN.es.js → PdfViewer-C51KNTCu.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-QwjK1Tx6.cjs → PdfViewer-Dk7wI3bm.cjs} +2 -2
  3. package/dist/chunks/{eventemitter3-DQmQUge-.cjs → eventemitter3-DIclNhoR.cjs} +1 -1
  4. package/dist/chunks/{eventemitter3-44XulWQe.es.js → eventemitter3-D_2kqkfV.es.js} +1 -1
  5. package/dist/chunks/{index-DI2R4qz8.cjs → index-Cf7hdzkm.cjs} +20 -15
  6. package/dist/chunks/{index-DNIymDRK-CzsYNHvC.cjs → index-DDZ1ZT8N-DzepXBTN.cjs} +1 -1
  7. package/dist/chunks/{index-DNIymDRK-BMrUTNeb.es.js → index-DDZ1ZT8N-MJzqg0qg.es.js} +1 -1
  8. package/dist/chunks/{index-CfSkb15j.es.js → index-rtbawgUA.es.js} +20 -15
  9. package/dist/chunks/{jszip-VP334ufO.es.js → jszip-B690S4j-.es.js} +1 -1
  10. package/dist/chunks/{jszip-BdEez1WM.cjs → jszip-qHp7FC78.cjs} +1 -1
  11. package/dist/chunks/{super-editor.es-BI8ByUNm.cjs → super-editor.es-BijxiFs9.cjs} +1671 -353
  12. package/dist/chunks/{super-editor.es-B42HV1fg.es.js → super-editor.es-DFXddrgb.es.js} +1671 -353
  13. package/dist/chunks/{vue-BuPTonTJ.es.js → vue-CLFbn_1r.es.js} +209 -185
  14. package/dist/chunks/{vue-jWLMl8Ts.cjs → vue-gvuFr0vx.cjs} +209 -185
  15. package/dist/chunks/xml-js-BXUvL-Mz.es.js +2 -0
  16. package/dist/chunks/xml-js-CCH4ckfW.cjs +3 -0
  17. package/dist/super-editor/ai-writer.es.js +2 -2
  18. package/dist/super-editor/chunks/{converter-a3CAItrf.js → converter-VYPiNbpo.js} +1 -1
  19. package/dist/super-editor/chunks/{docx-zipper-BsmzO0LG.js → docx-zipper-D8Tzq3RX.js} +1 -1
  20. package/dist/super-editor/chunks/{editor-qn0f9LDg.js → editor-mgoEnsBi.js} +1635 -288
  21. package/dist/super-editor/chunks/{index-DNIymDRK.js → index-DDZ1ZT8N.js} +1 -1
  22. package/dist/super-editor/chunks/{toolbar-DW8hTxsF.js → toolbar-DULgxvjl.js} +2 -2
  23. package/dist/super-editor/converter.es.js +1 -1
  24. package/dist/super-editor/docx-zipper.es.js +2 -2
  25. package/dist/super-editor/editor.es.js +3 -3
  26. package/dist/super-editor/file-zipper.es.js +1 -1
  27. package/dist/super-editor/super-editor.es.js +6 -6
  28. package/dist/super-editor/toolbar.es.js +2 -2
  29. package/dist/super-editor.cjs +2 -2
  30. package/dist/super-editor.es.js +2 -2
  31. package/dist/superdoc.cjs +2 -2
  32. package/dist/superdoc.es.js +2 -2
  33. package/dist/superdoc.umd.js +1913 -572
  34. package/dist/superdoc.umd.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunks/xml-js-Dz51sEbr.cjs +0 -3
  37. package/dist/chunks/xml-js-LkEmUa9-.es.js +0 -2
@@ -1,4 +1,4 @@
1
- import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as getCurrentInstance, p as onDeactivated, q as nextTick, s as createVNode, u as withCtx, v as createBlock, x as unref, y as defineComponent, z as normalizeStyle, A as h, B as mergeProps, C as shallowRef, D as markRaw, E as provide, G as createTextVNode, H as toRef, I as cloneVNode, T as Text$2, J as withDirectives, K as watchEffect, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted, Y as resolveDynamicComponent, Z as normalizeProps, _ as guardReactiveProps, $ as useCssVars } from "./vue-BuPTonTJ.es.js";
1
+ import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as getCurrentInstance, p as onDeactivated, q as nextTick, s as createVNode, u as withCtx, v as createBlock, x as unref, y as defineComponent, z as normalizeStyle, A as h, B as mergeProps, C as shallowRef, D as markRaw, E as provide, G as createTextVNode, H as toRef, I as cloneVNode, T as Text$2, J as withDirectives, K as watchEffect, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted, Y as resolveDynamicComponent, Z as normalizeProps, _ as guardReactiveProps, $ as useCssVars } from "./vue-CLFbn_1r.es.js";
2
2
  import * as Y from "yjs";
3
3
  import { UndoManager, Item as Item$2, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
4
4
  var __defProp$2 = Object.defineProperty;
@@ -10,7 +10,7 @@ var __publicField$2 = (obj, key2, value) => __defNormalProp$2(obj, typeof key2 !
10
10
  var __accessCheck$2 = (obj, member, msg2) => member.has(obj) || __typeError$2("Cannot " + msg2);
11
11
  var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
12
12
  var __privateMethod$2 = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
13
- var _a, _b, _DocxExporter_instances, generate_xml_as_list_fn, replaceSpecialCharacters_fn, generateXml_fn, _SuperConverter_instances, generateDocumentHash_fn, exportNumberingFile_fn, prepareCommentsXmlFilesForExport_fn, exportProcessHeadersFooters_fn, exportProcessNewRelationships_fn, exportProcessMediaFiles_fn;
13
+ var _a$1, _b, _DocxExporter_instances, generate_xml_as_list_fn, replaceSpecialCharacters_fn, generateXml_fn, _SuperConverter_instances, generateDocumentHash_fn, exportNumberingFile_fn, prepareCommentsXmlFilesForExport_fn, exportProcessHeadersFooters_fn, exportProcessNewRelationships_fn, exportProcessMediaFiles_fn;
14
14
  var buffer = {};
15
15
  var base64Js = {};
16
16
  base64Js.byteLength = byteLength;
@@ -622,7 +622,7 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
622
622
  return slowToString.apply(this, arguments);
623
623
  };
624
624
  Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
625
- Buffer3.prototype.equals = function equals(b2) {
625
+ Buffer3.prototype.equals = function equals2(b2) {
626
626
  if (!Buffer3.isBuffer(b2)) throw new TypeError("Argument must be a Buffer");
627
627
  if (this === b2) return true;
628
628
  return Buffer3.compare(this, b2) === 0;
@@ -2971,7 +2971,7 @@ function requireDist() {
2971
2971
  return slowToString.apply(this, arguments);
2972
2972
  };
2973
2973
  Buffer4.prototype.toLocaleString = Buffer4.prototype.toString;
2974
- Buffer4.prototype.equals = function equals(b2) {
2974
+ Buffer4.prototype.equals = function equals2(b2) {
2975
2975
  if (!Buffer4.isBuffer(b2)) throw new TypeError("Argument must be a Buffer");
2976
2976
  if (this === b2) return true;
2977
2977
  return Buffer4.compare(this, b2) === 0;
@@ -4428,8 +4428,8 @@ var hasRequiredObject_getPrototypeOf;
4428
4428
  function requireObject_getPrototypeOf() {
4429
4429
  if (hasRequiredObject_getPrototypeOf) return Object_getPrototypeOf;
4430
4430
  hasRequiredObject_getPrototypeOf = 1;
4431
- var $Object = /* @__PURE__ */ requireEsObjectAtoms();
4432
- Object_getPrototypeOf = $Object.getPrototypeOf || null;
4431
+ var $Object2 = /* @__PURE__ */ requireEsObjectAtoms();
4432
+ Object_getPrototypeOf = $Object2.getPrototypeOf || null;
4433
4433
  return Object_getPrototypeOf;
4434
4434
  }
4435
4435
  var implementation;
@@ -4591,12 +4591,12 @@ function requireGet() {
4591
4591
  /** @type {keyof typeof Object.prototype} */
4592
4592
  "__proto__"
4593
4593
  );
4594
- var $Object = Object;
4595
- var $getPrototypeOf = $Object.getPrototypeOf;
4594
+ var $Object2 = Object;
4595
+ var $getPrototypeOf = $Object2.getPrototypeOf;
4596
4596
  get$1 = desc && typeof desc.get === "function" ? callBind2([desc.get]) : typeof $getPrototypeOf === "function" ? (
4597
4597
  /** @type {import('./get')} */
4598
4598
  (function getDunder(value) {
4599
- return $getPrototypeOf(value == null ? value : $Object(value));
4599
+ return $getPrototypeOf(value == null ? value : $Object2(value));
4600
4600
  })
4601
4601
  ) : false;
4602
4602
  return get$1;
@@ -4638,7 +4638,7 @@ function requireGetIntrinsic() {
4638
4638
  if (hasRequiredGetIntrinsic) return getIntrinsic;
4639
4639
  hasRequiredGetIntrinsic = 1;
4640
4640
  var undefined$1;
4641
- var $Object = /* @__PURE__ */ requireEsObjectAtoms();
4641
+ var $Object2 = /* @__PURE__ */ requireEsObjectAtoms();
4642
4642
  var $Error = /* @__PURE__ */ requireEsErrors();
4643
4643
  var $EvalError = /* @__PURE__ */ require_eval();
4644
4644
  var $RangeError = /* @__PURE__ */ requireRange();
@@ -4728,7 +4728,7 @@ function requireGetIntrinsic() {
4728
4728
  "%MapIteratorPrototype%": typeof Map === "undefined" || !hasSymbols2 || !getProto2 ? undefined$1 : getProto2((/* @__PURE__ */ new Map())[Symbol.iterator]()),
4729
4729
  "%Math%": Math,
4730
4730
  "%Number%": Number,
4731
- "%Object%": $Object,
4731
+ "%Object%": $Object2,
4732
4732
  "%Object.getOwnPropertyDescriptor%": $gOPD,
4733
4733
  "%parseFloat%": parseFloat,
4734
4734
  "%parseInt%": parseInt,
@@ -4871,8 +4871,8 @@ function requireGetIntrinsic() {
4871
4871
  throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
4872
4872
  }
4873
4873
  var result = [];
4874
- $replace(string, rePropName2, function(match, number, quote, subString) {
4875
- result[result.length] = quote ? $replace(subString, reEscapeChar2, "$1") : number || match;
4874
+ $replace(string, rePropName2, function(match2, number, quote, subString) {
4875
+ result[result.length] = quote ? $replace(subString, reEscapeChar2, "$1") : number || match2;
4876
4876
  });
4877
4877
  return result;
4878
4878
  };
@@ -10776,9 +10776,9 @@ function requireXml2js() {
10776
10776
  var attributes = {};
10777
10777
  if (instruction.body && (instruction.name.toLowerCase() === "xml" || options.instructionHasAttributes)) {
10778
10778
  var attrsRegExp = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;
10779
- var match;
10780
- while ((match = attrsRegExp.exec(instruction.body)) !== null) {
10781
- attributes[match[1]] = match[2] || match[3] || match[4];
10779
+ var match2;
10780
+ while ((match2 = attrsRegExp.exec(instruction.body)) !== null) {
10781
+ attributes[match2[1]] = match2[2] || match2[3] || match2[4];
10782
10782
  }
10783
10783
  attributes = manipulateAttributes(attributes);
10784
10784
  }
@@ -11763,8 +11763,8 @@ const DOM_SIZE_UNITS = ["px", "rem", "em", "in", "q", "mm", "cm", "pt", "pc", "v
11763
11763
  function parseSizeUnit(val = "0") {
11764
11764
  const length2 = val.toString() || "0";
11765
11765
  const value = Number.parseFloat(length2);
11766
- const match = length2.match(CSS_DIMENSION_REGEX);
11767
- const unit = (match?.[1] ?? "").toLowerCase();
11766
+ const match2 = length2.match(CSS_DIMENSION_REGEX);
11767
+ const unit = (match2?.[1] ?? "").toLowerCase();
11768
11768
  return [value, DOM_SIZE_UNITS.includes(unit) ? unit : null];
11769
11769
  }
11770
11770
  function minMax(value = 0, min2 = 0, max2 = 0) {
@@ -13217,10 +13217,10 @@ let Node$1$1 = class Node2 {
13217
13217
  Get the content match in this node at the given index.
13218
13218
  */
13219
13219
  contentMatchAt(index2) {
13220
- let match = this.type.contentMatch.matchFragment(this.content, 0, index2);
13221
- if (!match)
13220
+ let match2 = this.type.contentMatch.matchFragment(this.content, 0, index2);
13221
+ if (!match2)
13222
13222
  throw new Error("Called contentMatchAt on a node with invalid content");
13223
- return match;
13223
+ return match2;
13224
13224
  }
13225
13225
  /**
13226
13226
  Test whether replacing the range between `from` and `to` (by
@@ -13388,9 +13388,9 @@ class ContentMatch {
13388
13388
  let expr = parseExpr(stream);
13389
13389
  if (stream.next)
13390
13390
  stream.err("Unexpected trailing text");
13391
- let match = dfa(nfa(expr));
13392
- checkForDeadEnds(match, stream);
13393
- return match;
13391
+ let match2 = dfa(nfa(expr));
13392
+ checkForDeadEnds(match2, stream);
13393
+ return match2;
13394
13394
  }
13395
13395
  /**
13396
13396
  Match a node type, returning a match after that node if
@@ -13450,12 +13450,12 @@ class ContentMatch {
13450
13450
  */
13451
13451
  fillBefore(after, toEnd = false, startIndex = 0) {
13452
13452
  let seen = [this];
13453
- function search2(match, types2) {
13454
- let finished = match.matchFragment(after, startIndex);
13453
+ function search2(match2, types2) {
13454
+ let finished = match2.matchFragment(after, startIndex);
13455
13455
  if (finished && (!toEnd || finished.validEnd))
13456
13456
  return Fragment.from(types2.map((tp) => tp.createAndFill()));
13457
- for (let i = 0; i < match.next.length; i++) {
13458
- let { type: type2, next } = match.next[i];
13457
+ for (let i = 0; i < match2.next.length; i++) {
13458
+ let { type: type2, next } = match2.next[i];
13459
13459
  if (!(type2.isText || type2.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
13460
13460
  seen.push(next);
13461
13461
  let found2 = search2(next, types2.concat(type2));
@@ -13487,15 +13487,15 @@ class ContentMatch {
13487
13487
  computeWrapping(target) {
13488
13488
  let seen = /* @__PURE__ */ Object.create(null), active = [{ match: this, type: null, via: null }];
13489
13489
  while (active.length) {
13490
- let current = active.shift(), match = current.match;
13491
- if (match.matchType(target)) {
13490
+ let current = active.shift(), match2 = current.match;
13491
+ if (match2.matchType(target)) {
13492
13492
  let result = [];
13493
13493
  for (let obj = current; obj.type; obj = obj.via)
13494
13494
  result.push(obj.type);
13495
13495
  return result.reverse();
13496
13496
  }
13497
- for (let i = 0; i < match.next.length; i++) {
13498
- let { type: type2, next } = match.next[i];
13497
+ for (let i = 0; i < match2.next.length; i++) {
13498
+ let { type: type2, next } = match2.next[i];
13499
13499
  if (!type2.isLeaf && !type2.hasRequiredAttrs() && !(type2.name in seen) && (!current.type || next.validEnd)) {
13500
13500
  active.push({ match: type2.contentMatch, type: type2, via: current });
13501
13501
  seen[type2.name] = true;
@@ -13756,8 +13756,8 @@ function dfa(nfa2) {
13756
13756
  return state2;
13757
13757
  }
13758
13758
  }
13759
- function checkForDeadEnds(match, stream) {
13760
- for (let i = 0, work = [match]; i < work.length; i++) {
13759
+ function checkForDeadEnds(match2, stream) {
13760
+ for (let i = 0, work = [match2]; i < work.length; i++) {
13761
13761
  let state2 = work[i], dead = !state2.validEnd, nodes = [];
13762
13762
  for (let j2 = 0; j2 < state2.next.length; j2++) {
13763
13763
  let { type: type2, next } = state2.next[j2];
@@ -14102,7 +14102,7 @@ class MarkType {
14102
14102
  return this.excluded.indexOf(other) > -1;
14103
14103
  }
14104
14104
  }
14105
- let Schema$1 = class Schema {
14105
+ let Schema$1$1 = class Schema {
14106
14106
  /**
14107
14107
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
14108
14108
  */
@@ -14383,7 +14383,7 @@ function wsOptionsFor(type2, preserveWhitespace, base2) {
14383
14383
  return type2 && type2.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base2 & ~OPT_OPEN_LEFT;
14384
14384
  }
14385
14385
  class NodeContext {
14386
- constructor(type2, attrs, marks, solid, match, options) {
14386
+ constructor(type2, attrs, marks, solid, match2, options) {
14387
14387
  this.type = type2;
14388
14388
  this.attrs = attrs;
14389
14389
  this.marks = marks;
@@ -14391,7 +14391,7 @@ class NodeContext {
14391
14391
  this.options = options;
14392
14392
  this.content = [];
14393
14393
  this.activeMarks = Mark$1.none;
14394
- this.match = match || (options & OPT_OPEN_LEFT ? null : type2.contentMatch);
14394
+ this.match = match2 || (options & OPT_OPEN_LEFT ? null : type2.contentMatch);
14395
14395
  }
14396
14396
  findWrapping(node) {
14397
14397
  if (!this.match) {
@@ -14790,14 +14790,14 @@ class ParseContext {
14790
14790
  let option = this.options.context;
14791
14791
  let useRoot = !this.isOpen && (!option || option.parent.type == this.nodes[0].type);
14792
14792
  let minDepth = -(option ? option.depth + 1 : 0) + (useRoot ? 0 : 1);
14793
- let match = (i, depth) => {
14793
+ let match2 = (i, depth) => {
14794
14794
  for (; i >= 0; i--) {
14795
14795
  let part = parts[i];
14796
14796
  if (part == "") {
14797
14797
  if (i == parts.length - 1 || i == 0)
14798
14798
  continue;
14799
14799
  for (; depth >= minDepth; depth--)
14800
- if (match(i - 1, depth))
14800
+ if (match2(i - 1, depth))
14801
14801
  return true;
14802
14802
  return false;
14803
14803
  } else {
@@ -14809,7 +14809,7 @@ class ParseContext {
14809
14809
  }
14810
14810
  return true;
14811
14811
  };
14812
- return match(parts.length - 1, this.open);
14812
+ return match2(parts.length - 1, this.open);
14813
14813
  }
14814
14814
  textblockFromContext() {
14815
14815
  let $context = this.options.context;
@@ -14854,10 +14854,10 @@ function markMayApply(markType, nodeType) {
14854
14854
  let parent = nodes[name];
14855
14855
  if (!parent.allowsMarkType(markType))
14856
14856
  continue;
14857
- let seen = [], scan = (match) => {
14858
- seen.push(match);
14859
- for (let i = 0; i < match.edgeCount; i++) {
14860
- let { type: type2, next } = match.edge(i);
14857
+ let seen = [], scan = (match2) => {
14858
+ seen.push(match2);
14859
+ for (let i = 0; i < match2.edgeCount; i++) {
14860
+ let { type: type2, next } = match2.edge(i);
14861
14861
  if (type2 == nodeType)
14862
14862
  return true;
14863
14863
  if (seen.indexOf(next) < 0 && scan(next))
@@ -22930,16 +22930,16 @@ function removeMark(tr, from2, to, mark) {
22930
22930
  });
22931
22931
  matched.forEach((m2) => tr.step(new RemoveMarkStep(m2.from, m2.to, m2.style)));
22932
22932
  }
22933
- function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch, clearNewlines = true) {
22933
+ function clearIncompatible(tr, pos, parentType, match2 = parentType.contentMatch, clearNewlines = true) {
22934
22934
  let node = tr.doc.nodeAt(pos);
22935
22935
  let replSteps = [], cur = pos + 1;
22936
22936
  for (let i = 0; i < node.childCount; i++) {
22937
22937
  let child = node.child(i), end2 = cur + child.nodeSize;
22938
- let allowed = match.matchType(child.type);
22938
+ let allowed = match2.matchType(child.type);
22939
22939
  if (!allowed) {
22940
22940
  replSteps.push(new ReplaceStep(cur, end2, Slice.empty));
22941
22941
  } else {
22942
- match = allowed;
22942
+ match2 = allowed;
22943
22943
  for (let j2 = 0; j2 < child.marks.length; j2++)
22944
22944
  if (!parentType.allowsMarkType(child.marks[j2].type))
22945
22945
  tr.step(new RemoveMarkStep(cur, end2, child.marks[j2]));
@@ -22954,8 +22954,8 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
22954
22954
  }
22955
22955
  cur = end2;
22956
22956
  }
22957
- if (!match.validEnd) {
22958
- let fill = match.fillBefore(Fragment.empty, true);
22957
+ if (!match2.validEnd) {
22958
+ let fill = match2.fillBefore(Fragment.empty, true);
22959
22959
  tr.replace(cur, cur, new Slice(fill, 0, 0));
22960
22960
  }
22961
22961
  for (let i = replSteps.length - 1; i >= 0; i--)
@@ -23009,8 +23009,8 @@ function wrap(tr, range2, wrappers) {
23009
23009
  let content = Fragment.empty;
23010
23010
  for (let i = wrappers.length - 1; i >= 0; i--) {
23011
23011
  if (content.size) {
23012
- let match = wrappers[i].type.contentMatch.matchFragment(content);
23013
- if (!match || !match.validEnd)
23012
+ let match2 = wrappers[i].type.contentMatch.matchFragment(content);
23013
+ if (!match2 || !match2.validEnd)
23014
23014
  throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
23015
23015
  }
23016
23016
  content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
@@ -23118,18 +23118,18 @@ function canJoin(doc2, pos) {
23118
23118
  function canAppendWithSubstitutedLinebreaks(a, b2) {
23119
23119
  if (!b2.content.size)
23120
23120
  a.type.compatibleContent(b2.type);
23121
- let match = a.contentMatchAt(a.childCount);
23121
+ let match2 = a.contentMatchAt(a.childCount);
23122
23122
  let { linebreakReplacement } = a.type.schema;
23123
23123
  for (let i = 0; i < b2.childCount; i++) {
23124
23124
  let child = b2.child(i);
23125
23125
  let type2 = child.type == linebreakReplacement ? a.type.schema.nodes.text : child.type;
23126
- match = match.matchType(type2);
23127
- if (!match)
23126
+ match2 = match2.matchType(type2);
23127
+ if (!match2)
23128
23128
  return false;
23129
23129
  if (!a.type.allowsMarks(child.marks))
23130
23130
  return false;
23131
23131
  }
23132
- return match.validEnd;
23132
+ return match2.validEnd;
23133
23133
  }
23134
23134
  function joinable(a, b2) {
23135
23135
  return !!(a && b2 && !a.isLeaf && canAppendWithSubstitutedLinebreaks(a, b2));
@@ -23311,12 +23311,12 @@ class Fitter {
23311
23311
  }
23312
23312
  let first2 = fragment.firstChild;
23313
23313
  for (let frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {
23314
- let { type: type2, match } = this.frontier[frontierDepth], wrap2, inject2 = null;
23315
- if (pass == 1 && (first2 ? match.matchType(first2.type) || (inject2 = match.fillBefore(Fragment.from(first2), false)) : parent && type2.compatibleContent(parent.type)))
23314
+ let { type: type2, match: match2 } = this.frontier[frontierDepth], wrap2, inject2 = null;
23315
+ if (pass == 1 && (first2 ? match2.matchType(first2.type) || (inject2 = match2.fillBefore(Fragment.from(first2), false)) : parent && type2.compatibleContent(parent.type)))
23316
23316
  return { sliceDepth, frontierDepth, parent, inject: inject2 };
23317
- else if (pass == 2 && first2 && (wrap2 = match.findWrapping(first2.type)))
23317
+ else if (pass == 2 && first2 && (wrap2 = match2.findWrapping(first2.type)))
23318
23318
  return { sliceDepth, frontierDepth, parent, wrap: wrap2 };
23319
- if (parent && match.matchType(parent.type))
23319
+ if (parent && match2.matchType(parent.type))
23320
23320
  break;
23321
23321
  }
23322
23322
  }
@@ -23352,20 +23352,20 @@ class Fitter {
23352
23352
  let slice2 = this.unplaced, fragment = parent ? parent.content : slice2.content;
23353
23353
  let openStart = slice2.openStart - sliceDepth;
23354
23354
  let taken = 0, add = [];
23355
- let { match, type: type2 } = this.frontier[frontierDepth];
23355
+ let { match: match2, type: type2 } = this.frontier[frontierDepth];
23356
23356
  if (inject2) {
23357
23357
  for (let i = 0; i < inject2.childCount; i++)
23358
23358
  add.push(inject2.child(i));
23359
- match = match.matchFragment(inject2);
23359
+ match2 = match2.matchFragment(inject2);
23360
23360
  }
23361
23361
  let openEndCount = fragment.size + sliceDepth - (slice2.content.size - slice2.openEnd);
23362
23362
  while (taken < fragment.childCount) {
23363
- let next = fragment.child(taken), matches2 = match.matchType(next.type);
23363
+ let next = fragment.child(taken), matches2 = match2.matchType(next.type);
23364
23364
  if (!matches2)
23365
23365
  break;
23366
23366
  taken++;
23367
23367
  if (taken > 1 || openStart == 0 || next.content.size) {
23368
- match = matches2;
23368
+ match2 = matches2;
23369
23369
  add.push(closeNodeStart(next.mark(type2.allowedMarks(next.marks)), taken == 1 ? openStart : 0, taken == fragment.childCount ? openEndCount : -1));
23370
23370
  }
23371
23371
  }
@@ -23373,7 +23373,7 @@ class Fitter {
23373
23373
  if (!toEnd)
23374
23374
  openEndCount = -1;
23375
23375
  this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add));
23376
- this.frontier[frontierDepth].match = match;
23376
+ this.frontier[frontierDepth].match = match2;
23377
23377
  if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)
23378
23378
  this.closeFrontierNode();
23379
23379
  for (let i = 0, cur = fragment; i < openEndCount; i++) {
@@ -23396,14 +23396,14 @@ class Fitter {
23396
23396
  }
23397
23397
  findCloseLevel($to) {
23398
23398
  scan: for (let i = Math.min(this.depth, $to.depth); i >= 0; i--) {
23399
- let { match, type: type2 } = this.frontier[i];
23399
+ let { match: match2, type: type2 } = this.frontier[i];
23400
23400
  let dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));
23401
- let fit = contentAfterFits($to, i, type2, match, dropInner);
23401
+ let fit = contentAfterFits($to, i, type2, match2, dropInner);
23402
23402
  if (!fit)
23403
23403
  continue;
23404
23404
  for (let d2 = i - 1; d2 >= 0; d2--) {
23405
- let { match: match2, type: type3 } = this.frontier[d2];
23406
- let matches2 = contentAfterFits($to, d2, type3, match2, true);
23405
+ let { match: match22, type: type3 } = this.frontier[d2];
23406
+ let matches2 = contentAfterFits($to, d2, type3, match22, true);
23407
23407
  if (!matches2 || matches2.childCount)
23408
23408
  continue scan;
23409
23409
  }
@@ -23466,11 +23466,11 @@ function closeNodeStart(node, openStart, openEnd) {
23466
23466
  }
23467
23467
  return node.copy(frag);
23468
23468
  }
23469
- function contentAfterFits($to, depth, type2, match, open) {
23469
+ function contentAfterFits($to, depth, type2, match2, open) {
23470
23470
  let node = $to.node(depth), index2 = open ? $to.indexAfter(depth) : $to.index(depth);
23471
23471
  if (index2 == node.childCount && !type2.compatibleContent(node.type))
23472
23472
  return null;
23473
- let fit = match.fillBefore(node.content, true, index2);
23473
+ let fit = match2.fillBefore(node.content, true, index2);
23474
23474
  return fit && !invalidMarks(type2, node.content, index2) ? fit : null;
23475
23475
  }
23476
23476
  function invalidMarks(type2, fragment, start2) {
@@ -23552,9 +23552,9 @@ function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
23552
23552
  fragment = fragment.replaceChild(0, first2.copy(closeFragment(first2.content, depth + 1, oldOpen, newOpen, first2)));
23553
23553
  }
23554
23554
  if (depth > newOpen) {
23555
- let match = parent.contentMatchAt(0);
23556
- let start2 = match.fillBefore(fragment).append(fragment);
23557
- fragment = start2.append(match.matchFragment(start2).fillBefore(Fragment.empty, true));
23555
+ let match2 = parent.contentMatchAt(0);
23556
+ let start2 = match2.fillBefore(fragment).append(fragment);
23557
+ fragment = start2.append(match2.matchFragment(start2).fillBefore(Fragment.empty, true));
23558
23558
  }
23559
23559
  return fragment;
23560
23560
  }
@@ -23928,8 +23928,8 @@ class Transform {
23928
23928
  an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as
23929
23929
  third argument.
23930
23930
  */
23931
- clearIncompatible(pos, parentType, match) {
23932
- clearIncompatible(this, pos, parentType, match);
23931
+ clearIncompatible(pos, parentType, match2) {
23932
+ clearIncompatible(this, pos, parentType, match2);
23933
23933
  return this;
23934
23934
  }
23935
23935
  }
@@ -25284,7 +25284,7 @@ let isLoggingEnabled$1 = true;
25284
25284
  function loggingEnabled$1(enabled) {
25285
25285
  isLoggingEnabled$1 = enabled;
25286
25286
  }
25287
- let Helper$1 = (_a = class {
25287
+ let Helper$1 = (_a$1 = class {
25288
25288
  static log(message) {
25289
25289
  if (isLoggingEnabled$1) {
25290
25290
  console.log(message);
@@ -25307,7 +25307,7 @@ let Helper$1 = (_a = class {
25307
25307
  }
25308
25308
  return ret;
25309
25309
  }
25310
- }, _a.GDI = {
25310
+ }, _a$1.GDI = {
25311
25311
  FormatSignature: {
25312
25312
  ENHMETA_SIGNATURE: 1179469088,
25313
25313
  EPS_SIGNATURE: 1179865157
@@ -25587,7 +25587,7 @@ let Helper$1 = (_a = class {
25587
25587
  DC_BRUSH: 2147483666,
25588
25588
  DC_PEN: 2147483667
25589
25589
  }
25590
- }, _a._uniqueId = 0, _a);
25590
+ }, _a$1._uniqueId = 0, _a$1);
25591
25591
  let Blob$2 = class Blob2 {
25592
25592
  constructor(blob, offset2) {
25593
25593
  if (blob instanceof Blob2) {
@@ -31296,9 +31296,9 @@ function getMarkType(nameOrType, schema) {
31296
31296
  }
31297
31297
  return nameOrType;
31298
31298
  }
31299
- function defaultBlockAt$1(match) {
31300
- for (let i = 0; i < match.edgeCount; i++) {
31301
- const { type: type2 } = match.edge(i);
31299
+ function defaultBlockAt$1(match2) {
31300
+ for (let i = 0; i < match2.edgeCount; i++) {
31301
+ const { type: type2 } = match2.edge(i);
31302
31302
  if (type2.isTextblock && !type2.hasRequiredAttrs()) return type2;
31303
31303
  }
31304
31304
  return null;
@@ -31975,11 +31975,11 @@ const generateFromCustom = (path, lvlText, customFormat) => {
31975
31975
  if (customFormat.match(/(?:[0]+\d,\s){3}\.{3}/) == null) {
31976
31976
  return generateNumbering(path, lvlText, numberToStringFormatter);
31977
31977
  }
31978
- const match = customFormat.match(/(\d+)/);
31979
- if (!match) {
31978
+ const match2 = customFormat.match(/(\d+)/);
31979
+ if (!match2) {
31980
31980
  throw new Error("Invalid format string: no numeric pattern found");
31981
31981
  }
31982
- const digitCount = match[1].length;
31982
+ const digitCount = match2[1].length;
31983
31983
  return generateNumbering(path, lvlText, (p) => String(p).padStart(digitCount, "0"));
31984
31984
  };
31985
31985
  const numberToStringFormatter = (value) => String(value);
@@ -33891,9 +33891,9 @@ const ListHelpers = {
33891
33891
  };
33892
33892
  const extractListLevelStyles = (cssText, listId, level, numId) => {
33893
33893
  const pattern = new RegExp(`@list\\s+l${listId}:level${level}(?:\\s+lfo${numId})?\\s*\\{([^}]+)\\}`, "i");
33894
- const match = cssText.match(pattern);
33895
- if (!match) return null;
33896
- const rawStyles = match[1].split(";").map((line) => line.trim()).filter(Boolean);
33894
+ const match2 = cssText.match(pattern);
33895
+ if (!match2) return null;
33896
+ const rawStyles = match2[1].split(";").map((line) => line.trim()).filter(Boolean);
33897
33897
  const styleMap = {};
33898
33898
  for (const style2 of rawStyles) {
33899
33899
  const [key2, value] = style2.split(":").map((s2) => s2.trim());
@@ -33903,9 +33903,9 @@ const extractListLevelStyles = (cssText, listId, level, numId) => {
33903
33903
  };
33904
33904
  const extractParagraphStyles = (cssText, selector) => {
33905
33905
  const pattern = new RegExp(`(${selector})\\s*\\{([^}]+)\\}`, "i");
33906
- const match = cssText.match(pattern);
33907
- if (!match) return null;
33908
- const rawStyles = match[2].split(";").map((line) => line.trim()).filter(Boolean);
33906
+ const match2 = cssText.match(pattern);
33907
+ if (!match2) return null;
33908
+ const rawStyles = match2[2].split(";").map((line) => line.trim()).filter(Boolean);
33909
33909
  const styleMap = {};
33910
33910
  for (const style2 of rawStyles) {
33911
33911
  const [key2, value] = style2.split(":").map((s2) => s2.trim());
@@ -33950,16 +33950,16 @@ const numDefByTypeMap = /* @__PURE__ */ new Map([
33950
33950
  ["i", "lowerRoman"]
33951
33951
  ]);
33952
33952
  function getStartNumber(lvlText) {
33953
- const match = lvlText.match(/^(\d+)/);
33954
- if (match) return parseInt(match[1], 10);
33953
+ const match2 = lvlText.match(/^(\d+)/);
33954
+ if (match2) return parseInt(match2[1], 10);
33955
33955
  return null;
33956
33956
  }
33957
- function letterToNumber(letter) {
33958
- return letter.toLowerCase().charCodeAt(0) - "a".charCodeAt(0) + 1;
33957
+ function letterToNumber(letter2) {
33958
+ return letter2.toLowerCase().charCodeAt(0) - "a".charCodeAt(0) + 1;
33959
33959
  }
33960
33960
  function getStartNumberFromAlpha(lvlText) {
33961
- const match = lvlText.match(/^([a-zA-Z])/);
33962
- if (match) return letterToNumber(match[1]);
33961
+ const match2 = lvlText.match(/^([a-zA-Z])/);
33962
+ if (match2) return letterToNumber(match2[1]);
33963
33963
  return null;
33964
33964
  }
33965
33965
  function romanToNumber(roman) {
@@ -33974,8 +33974,8 @@ function romanToNumber(roman) {
33974
33974
  return num;
33975
33975
  }
33976
33976
  function getStartNumberFromRoman(lvlText) {
33977
- const match = lvlText.match(/^([ivxlcdmIVXLCDM]+)/);
33978
- if (match) return romanToNumber(match[1]);
33977
+ const match2 = lvlText.match(/^([ivxlcdmIVXLCDM]+)/);
33978
+ if (match2) return romanToNumber(match2[1]);
33979
33979
  return null;
33980
33980
  }
33981
33981
  const startHelperMap = /* @__PURE__ */ new Map([
@@ -34777,11 +34777,11 @@ class InputRule {
34777
34777
  this.handler = config2.handler;
34778
34778
  }
34779
34779
  }
34780
- const inputRuleMatcherHandler = (text, match) => {
34781
- if (isRegExp$1(match)) {
34782
- return match.exec(text);
34780
+ const inputRuleMatcherHandler = (text, match2) => {
34781
+ if (isRegExp$1(match2)) {
34782
+ return match2.exec(text);
34783
34783
  }
34784
- const inputRuleMatch = match(text);
34784
+ const inputRuleMatch = match2(text);
34785
34785
  if (!inputRuleMatch) {
34786
34786
  return null;
34787
34787
  }
@@ -34813,14 +34813,14 @@ const run = (config2) => {
34813
34813
  if (matched) {
34814
34814
  return;
34815
34815
  }
34816
- const match = inputRuleMatcherHandler(textBefore, rule.match);
34817
- if (!match) {
34816
+ const match2 = inputRuleMatcherHandler(textBefore, rule.match);
34817
+ if (!match2) {
34818
34818
  return;
34819
34819
  }
34820
34820
  const tr = view.state.tr;
34821
34821
  const state2 = chainableEditorState(tr, view.state);
34822
34822
  const range2 = {
34823
- from: from2 - (match[0].length - text.length),
34823
+ from: from2 - (match2[0].length - text.length),
34824
34824
  to
34825
34825
  };
34826
34826
  const { commands: commands2, chain, can } = new CommandService({
@@ -34830,7 +34830,7 @@ const run = (config2) => {
34830
34830
  const handler2 = rule.handler({
34831
34831
  state: state2,
34832
34832
  range: range2,
34833
- match,
34833
+ match: match2,
34834
34834
  commands: commands2,
34835
34835
  chain,
34836
34836
  can
@@ -35749,7 +35749,7 @@ ${e}</tr>
35749
35749
  return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : w(e.text);
35750
35750
  }
35751
35751
  };
35752
- var $ = class {
35752
+ var $$1 = class $ {
35753
35753
  strong({ text: e }) {
35754
35754
  return e;
35755
35755
  }
@@ -35783,7 +35783,7 @@ var b = class l2 {
35783
35783
  __publicField$2(this, "options");
35784
35784
  __publicField$2(this, "renderer");
35785
35785
  __publicField$2(this, "textRenderer");
35786
- this.options = e || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $();
35786
+ this.options = e || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $$1();
35787
35787
  }
35788
35788
  static parse(e, t) {
35789
35789
  return new l2(t).parse(e);
@@ -35956,7 +35956,7 @@ var B = class {
35956
35956
  __publicField$2(this, "parseInline", this.parseMarkdown(false));
35957
35957
  __publicField$2(this, "Parser", b);
35958
35958
  __publicField$2(this, "Renderer", P);
35959
- __publicField$2(this, "TextRenderer", $);
35959
+ __publicField$2(this, "TextRenderer", $$1);
35960
35960
  __publicField$2(this, "Lexer", x);
35961
35961
  __publicField$2(this, "Tokenizer", y);
35962
35962
  __publicField$2(this, "Hooks", S);
@@ -36128,7 +36128,7 @@ k$1.parseInline = _.parseInline;
36128
36128
  k$1.Parser = b;
36129
36129
  k$1.parser = b.parse;
36130
36130
  k$1.Renderer = P;
36131
- k$1.TextRenderer = $;
36131
+ k$1.TextRenderer = $$1;
36132
36132
  k$1.Lexer = x;
36133
36133
  k$1.lexer = x.lex;
36134
36134
  k$1.Tokenizer = y;
@@ -37142,7 +37142,7 @@ function requireHe() {
37142
37142
  if (strict && regexInvalidEntity.test(html)) {
37143
37143
  parseError("malformed character reference");
37144
37144
  }
37145
- return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
37145
+ return html.replace(regexDecode, function($0, $1, $22, $3, $4, $5, $6, $7, $8) {
37146
37146
  var codePoint;
37147
37147
  var semicolon;
37148
37148
  var decDigits;
@@ -37153,8 +37153,8 @@ function requireHe() {
37153
37153
  reference2 = $1;
37154
37154
  return decodeMap[reference2];
37155
37155
  }
37156
- if ($2) {
37157
- reference2 = $2;
37156
+ if ($22) {
37157
+ reference2 = $22;
37158
37158
  next = $3;
37159
37159
  if (next && options.isAttributeValue) {
37160
37160
  if (strict && next == "=") {
@@ -40023,7 +40023,7 @@ const DocxHelpers = {
40023
40023
  insertNewRelationship,
40024
40024
  getNewRelationshipId
40025
40025
  };
40026
- const kebabCase$1 = (str) => str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
40026
+ const kebabCase$1 = (str) => str.replace(/[A-Z]/g, (match2) => `-${match2.toLowerCase()}`);
40027
40027
  const comments_module_events = {
40028
40028
  ADD: "add",
40029
40029
  UPDATE: "update",
@@ -40293,9 +40293,9 @@ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
40293
40293
  };
40294
40294
  const parsedSwitches = {};
40295
40295
  for (const [key2, pattern] of Object.entries(availableSwitches)) {
40296
- const match = instruction.match(pattern);
40297
- if (match) {
40298
- parsedSwitches[key2] = match.groups?.value || true;
40296
+ const match2 = instruction.match(pattern);
40297
+ if (match2) {
40298
+ parsedSwitches[key2] = match2.groups?.value || true;
40299
40299
  }
40300
40300
  }
40301
40301
  if (parsedSwitches.new_window) {
@@ -41869,7 +41869,7 @@ const getCommentDefinition = (comment, commentId, allComments, editor) => {
41869
41869
  const getInitials = (name) => {
41870
41870
  if (!name) return null;
41871
41871
  const preparedText = name.replace("(imported)", "").trim();
41872
- const initials = preparedText.split(" ").map((word) => word[0]).join("");
41872
+ const initials = preparedText.split(" ").map((word2) => word2[0]).join("");
41873
41873
  return initials;
41874
41874
  };
41875
41875
  const toIsoNoFractional = (unixMillis) => {
@@ -42410,7 +42410,7 @@ const _SuperConverter = class _SuperConverter2 {
42410
42410
  static getStoredSuperdocVersion(docx) {
42411
42411
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42412
42412
  }
42413
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-next.9") {
42413
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.2") {
42414
42414
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42415
42415
  }
42416
42416
  /**
@@ -45722,7 +45722,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45722
45722
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45723
45723
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45724
45724
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45725
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
45725
+ var _a, _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, wrapHiddenEditorFocus_fn, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
45726
45726
  var GOOD_LEAF_SIZE = 200;
45727
45727
  var RopeSequence = function RopeSequence2() {
45728
45728
  };
@@ -48855,12 +48855,12 @@ function normalizeSiblings(fragment, $context) {
48855
48855
  return fragment;
48856
48856
  for (let d2 = $context.depth; d2 >= 0; d2--) {
48857
48857
  let parent = $context.node(d2);
48858
- let match = parent.contentMatchAt($context.index(d2));
48858
+ let match2 = parent.contentMatchAt($context.index(d2));
48859
48859
  let lastWrap, result = [];
48860
48860
  fragment.forEach((node) => {
48861
48861
  if (!result)
48862
48862
  return;
48863
- let wrap2 = match.findWrapping(node.type), inLast;
48863
+ let wrap2 = match2.findWrapping(node.type), inLast;
48864
48864
  if (!wrap2)
48865
48865
  return result = null;
48866
48866
  if (inLast = result.length && lastWrap.length && addToSibling(wrap2, lastWrap, node, result[result.length - 1], 0)) {
@@ -48870,7 +48870,7 @@ function normalizeSiblings(fragment, $context) {
48870
48870
  result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length);
48871
48871
  let wrapped = withWrappers(node, wrap2);
48872
48872
  result.push(wrapped);
48873
- match = match.matchType(wrapped.type);
48873
+ match2 = match2.matchType(wrapped.type);
48874
48874
  lastWrap = wrap2;
48875
48875
  }
48876
48876
  });
@@ -48889,8 +48889,8 @@ function addToSibling(wrap2, lastWrap, node, sibling, depth) {
48889
48889
  let inner = addToSibling(wrap2, lastWrap, node, sibling.lastChild, depth + 1);
48890
48890
  if (inner)
48891
48891
  return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));
48892
- let match = sibling.contentMatchAt(sibling.childCount);
48893
- if (match.matchType(depth == wrap2.length - 1 ? node.type : wrap2[depth + 1]))
48892
+ let match2 = sibling.contentMatchAt(sibling.childCount);
48893
+ if (match2.matchType(depth == wrap2.length - 1 ? node.type : wrap2[depth + 1]))
48894
48894
  return sibling.copy(sibling.content.append(Fragment.from(withWrappers(node, wrap2, depth + 1))));
48895
48895
  }
48896
48896
  }
@@ -51447,15 +51447,40 @@ const BIT30 = 1 << 29;
51447
51447
  const BITS6 = 63;
51448
51448
  const BITS7 = 127;
51449
51449
  const BITS31 = 2147483647;
51450
+ const MAX_SAFE_INTEGER$2 = Number.MAX_SAFE_INTEGER;
51451
+ const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
51450
51452
  const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
51451
51453
  const create$2 = () => /* @__PURE__ */ new Set();
51454
+ const every$1 = (arr, f2) => {
51455
+ for (let i = 0; i < arr.length; i++) {
51456
+ if (!f2(arr[i], i, arr)) {
51457
+ return false;
51458
+ }
51459
+ }
51460
+ return true;
51461
+ };
51462
+ const some = (arr, f2) => {
51463
+ for (let i = 0; i < arr.length; i++) {
51464
+ if (f2(arr[i], i, arr)) {
51465
+ return true;
51466
+ }
51467
+ }
51468
+ return false;
51469
+ };
51470
+ const unfold = (len, f2) => {
51471
+ const array = new Array(len);
51472
+ for (let i = 0; i < len; i++) {
51473
+ array[i] = f2(i, array);
51474
+ }
51475
+ return array;
51476
+ };
51452
51477
  const isArray$1 = Array.isArray;
51453
51478
  const fromCharCode = String.fromCharCode;
51454
51479
  const toLowerCase = (s2) => s2.toLowerCase();
51455
51480
  const trimLeftRegex = /^\s*/g;
51456
51481
  const trimLeft = (s2) => s2.replace(trimLeftRegex, "");
51457
51482
  const fromCamelCaseRegex = /([A-Z])/g;
51458
- const fromCamelCase = (s2, separator) => trimLeft(s2.replace(fromCamelCaseRegex, (match) => `${separator}${toLowerCase(match)}`));
51483
+ const fromCamelCase = (s2, separator) => trimLeft(s2.replace(fromCamelCaseRegex, (match2) => `${separator}${toLowerCase(match2)}`));
51459
51484
  const _encodeUtf8Polyfill = (str) => {
51460
51485
  const encodedString = unescape(encodeURIComponent(str));
51461
51486
  const len = encodedString.length;
@@ -51476,6 +51501,7 @@ let utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecode
51476
51501
  if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array()).length === 1) {
51477
51502
  utf8TextDecoder = null;
51478
51503
  }
51504
+ const repeat$1 = (source, n) => unfold(n, () => source).join("");
51479
51505
  class Encoder {
51480
51506
  constructor() {
51481
51507
  this.cpos = 0;
@@ -51672,7 +51698,11 @@ const setIfUndefined = (map22, key2, createT) => {
51672
51698
  }
51673
51699
  return set;
51674
51700
  };
51701
+ const EqualityTraitSymbol = Symbol("Equality");
51702
+ const equals = (a, b2) => a === b2 || a[EqualityTraitSymbol]?.(b2) || false;
51703
+ const isObject$2 = (o) => typeof o === "object";
51675
51704
  const keys$1 = Object.keys;
51705
+ const size$1 = (obj) => keys$1(obj).length;
51676
51706
  const every = (obj, f2) => {
51677
51707
  for (const key2 in obj) {
51678
51708
  if (!f2(obj[key2], key2)) {
@@ -51681,6 +51711,81 @@ const every = (obj, f2) => {
51681
51711
  }
51682
51712
  return true;
51683
51713
  };
51714
+ const hasProperty = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
51715
+ const equalityDeep = (a, b2) => {
51716
+ if (a === b2) {
51717
+ return true;
51718
+ }
51719
+ if (a == null || b2 == null || a.constructor !== b2.constructor && (a.constructor || Object) !== (b2.constructor || Object)) {
51720
+ return false;
51721
+ }
51722
+ if (a[EqualityTraitSymbol] != null) {
51723
+ return a[EqualityTraitSymbol](b2);
51724
+ }
51725
+ switch (a.constructor) {
51726
+ case ArrayBuffer:
51727
+ a = new Uint8Array(a);
51728
+ b2 = new Uint8Array(b2);
51729
+ // eslint-disable-next-line no-fallthrough
51730
+ case Uint8Array: {
51731
+ if (a.byteLength !== b2.byteLength) {
51732
+ return false;
51733
+ }
51734
+ for (let i = 0; i < a.length; i++) {
51735
+ if (a[i] !== b2[i]) {
51736
+ return false;
51737
+ }
51738
+ }
51739
+ break;
51740
+ }
51741
+ case Set: {
51742
+ if (a.size !== b2.size) {
51743
+ return false;
51744
+ }
51745
+ for (const value of a) {
51746
+ if (!b2.has(value)) {
51747
+ return false;
51748
+ }
51749
+ }
51750
+ break;
51751
+ }
51752
+ case Map: {
51753
+ if (a.size !== b2.size) {
51754
+ return false;
51755
+ }
51756
+ for (const key2 of a.keys()) {
51757
+ if (!b2.has(key2) || !equalityDeep(a.get(key2), b2.get(key2))) {
51758
+ return false;
51759
+ }
51760
+ }
51761
+ break;
51762
+ }
51763
+ case void 0:
51764
+ case Object:
51765
+ if (size$1(a) !== size$1(b2)) {
51766
+ return false;
51767
+ }
51768
+ for (const key2 in a) {
51769
+ if (!hasProperty(a, key2) || !equalityDeep(a[key2], b2[key2])) {
51770
+ return false;
51771
+ }
51772
+ }
51773
+ break;
51774
+ case Array:
51775
+ if (a.length !== b2.length) {
51776
+ return false;
51777
+ }
51778
+ for (let i = 0; i < a.length; i++) {
51779
+ if (!equalityDeep(a[i], b2[i])) {
51780
+ return false;
51781
+ }
51782
+ }
51783
+ break;
51784
+ default:
51785
+ return false;
51786
+ }
51787
+ return true;
51788
+ };
51684
51789
  const isOneOf = (value, options) => options.includes(value);
51685
51790
  const createMutex = () => {
51686
51791
  let token = true;
@@ -51721,7 +51826,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
51721
51826
  const yUndoPluginKey = new PluginKey("y-undo");
51722
51827
  const yCursorPluginKey = new PluginKey("yjs-cursor");
51723
51828
  const rand = Math.random;
51724
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
51829
+ const oneOf$1 = (arr) => arr[floor(rand() * arr.length)];
51725
51830
  const undefinedToNull = (v2) => v2 === void 0 ? null : v2;
51726
51831
  class VarStoragePolyfill {
51727
51832
  constructor() {
@@ -51795,15 +51900,771 @@ const computeParams = () => {
51795
51900
  const hasParam = (name) => computeParams().has(name);
51796
51901
  const getVariable = (name) => isNode ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
51797
51902
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
51798
- hasConf("production");
51903
+ const production = hasConf("production");
51799
51904
  const forceColor = isNode && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
51800
51905
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
51801
51906
  !hasConf("no-color") && (!isNode || process$1$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
51907
+ const toBase64Browser = (bytes) => {
51908
+ let s2 = "";
51909
+ for (let i = 0; i < bytes.byteLength; i++) {
51910
+ s2 += fromCharCode(bytes[i]);
51911
+ }
51912
+ return btoa(s2);
51913
+ };
51914
+ const toBase64Node = (bytes) => Buffer2.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
51915
+ const toBase64 = isBrowser$1$1 ? toBase64Browser : toBase64Node;
51916
+ const encodeAny = (data) => encode((encoder) => writeAny(encoder, data));
51917
+ const bool = (gen) => gen.next() >= 0.5;
51918
+ const int53 = (gen, min2, max2) => floor(gen.next() * (max2 + 1 - min2) + min2);
51919
+ const int32 = (gen, min2, max2) => floor(gen.next() * (max2 + 1 - min2) + min2);
51920
+ const int31 = (gen, min2, max2) => int32(gen, min2, max2);
51921
+ const letter = (gen) => fromCharCode(int31(gen, 97, 122));
51922
+ const word = (gen, minLen = 0, maxLen = 20) => {
51923
+ const len = int31(gen, minLen, maxLen);
51924
+ let str = "";
51925
+ for (let i = 0; i < len; i++) {
51926
+ str += letter(gen);
51927
+ }
51928
+ return str;
51929
+ };
51930
+ const oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)];
51931
+ const schemaSymbol = Symbol("0schema");
51932
+ class ValidationError {
51933
+ constructor() {
51934
+ this._rerrs = [];
51935
+ }
51936
+ /**
51937
+ * @param {string?} path
51938
+ * @param {string} expected
51939
+ * @param {string} has
51940
+ * @param {string?} message
51941
+ */
51942
+ extend(path, expected, has, message = null) {
51943
+ this._rerrs.push({ path, expected, has, message });
51944
+ }
51945
+ toString() {
51946
+ const s2 = [];
51947
+ for (let i = this._rerrs.length - 1; i > 0; i--) {
51948
+ const r2 = this._rerrs[i];
51949
+ s2.push(repeat$1(" ", (this._rerrs.length - i) * 2) + `${r2.path != null ? `[${r2.path}] ` : ""}${r2.has} doesn't match ${r2.expected}. ${r2.message}`);
51950
+ }
51951
+ return s2.join("\n");
51952
+ }
51953
+ }
51954
+ const shapeExtends = (a, b2) => {
51955
+ if (a === b2) return true;
51956
+ if (a == null || b2 == null || a.constructor !== b2.constructor) return false;
51957
+ if (a[EqualityTraitSymbol]) return equals(a, b2);
51958
+ if (isArray$1(a)) {
51959
+ return every$1(
51960
+ a,
51961
+ (aitem) => some(b2, (bitem) => shapeExtends(aitem, bitem))
51962
+ );
51963
+ } else if (isObject$2(a)) {
51964
+ return every(
51965
+ a,
51966
+ (aitem, akey) => shapeExtends(aitem, b2[akey])
51967
+ );
51968
+ }
51969
+ return false;
51970
+ };
51971
+ let Schema$1 = (_a = class {
51972
+ /**
51973
+ * @param {Schema<any>} other
51974
+ */
51975
+ extends(other) {
51976
+ let [a, b2] = [
51977
+ /** @type {any} */
51978
+ this.shape,
51979
+ /** @type {any} */
51980
+ other.shape
51981
+ ];
51982
+ if (
51983
+ /** @type {typeof Schema<any>} */
51984
+ this.constructor._dilutes
51985
+ ) [b2, a] = [a, b2];
51986
+ return shapeExtends(a, b2);
51987
+ }
51988
+ /**
51989
+ * Overwrite this when necessary. By default, we only check the `shape` property which every shape
51990
+ * should have.
51991
+ * @param {Schema<any>} other
51992
+ */
51993
+ equals(other) {
51994
+ return this.constructor === other.constructor && equalityDeep(this.shape, other.shape);
51995
+ }
51996
+ [schemaSymbol]() {
51997
+ return true;
51998
+ }
51999
+ /**
52000
+ * @param {object} other
52001
+ */
52002
+ [EqualityTraitSymbol](other) {
52003
+ return this.equals(
52004
+ /** @type {any} */
52005
+ other
52006
+ );
52007
+ }
52008
+ /**
52009
+ * Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of
52010
+ * Schema. Validate will check the structure of the parameter and return true iff the instance
52011
+ * really is an instance of Schema.
52012
+ *
52013
+ * @param {T} o
52014
+ * @return {boolean}
52015
+ */
52016
+ validate(o) {
52017
+ return this.check(o);
52018
+ }
52019
+ /* c8 ignore start */
52020
+ /**
52021
+ * Similar to validate, but this method accepts untyped parameters.
52022
+ *
52023
+ * @param {any} _o
52024
+ * @param {ValidationError} [_err]
52025
+ * @return {_o is T}
52026
+ */
52027
+ check(_o, _err) {
52028
+ methodUnimplemented();
52029
+ }
52030
+ /* c8 ignore stop */
52031
+ /**
52032
+ * @type {Schema<T?>}
52033
+ */
52034
+ get nullable() {
52035
+ return $union(this, $null);
52036
+ }
52037
+ /**
52038
+ * @type {$Optional<Schema<T>>}
52039
+ */
52040
+ get optional() {
52041
+ return new $Optional(
52042
+ /** @type {Schema<T>} */
52043
+ this
52044
+ );
52045
+ }
52046
+ /**
52047
+ * Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise.
52048
+ * Use this if you know that the type is of a specific type and you just want to convince the type
52049
+ * system.
52050
+ *
52051
+ * **Do not rely on these error messages!**
52052
+ * Performs an assertion check only if not in a production environment.
52053
+ *
52054
+ * @template OO
52055
+ * @param {OO} o
52056
+ * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}
52057
+ */
52058
+ cast(o) {
52059
+ assert(o, this);
52060
+ return (
52061
+ /** @type {any} */
52062
+ o
52063
+ );
52064
+ }
52065
+ /**
52066
+ * EXPECTO PATRONUM!! 🪄
52067
+ * This function protects against type errors. Though it may not work in the real world.
52068
+ *
52069
+ * "After all this time?"
52070
+ * "Always." - Snape, talking about type safety
52071
+ *
52072
+ * Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed.
52073
+ * Use this if you know that the type is of a specific type and you just want to convince the type
52074
+ * system.
52075
+ *
52076
+ * Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).expect((n) => n + 1)`
52077
+ *
52078
+ * **Do not rely on these error messages!**
52079
+ * Performs an assertion check if not in a production environment.
52080
+ *
52081
+ * @param {T} o
52082
+ * @return {o extends T ? T : never}
52083
+ */
52084
+ expect(o) {
52085
+ assert(o, this);
52086
+ return o;
52087
+ }
52088
+ }, // this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
52089
+ /**
52090
+ * If true, the more things are added to the shape the more objects this schema will accept (e.g.
52091
+ * union). By default, the more objects are added, the the fewer objects this schema will accept.
52092
+ * @protected
52093
+ */
52094
+ __publicField$1(_a, "_dilutes", false), _a);
52095
+ class $ConstructedBy extends Schema$1 {
52096
+ /**
52097
+ * @param {C} c
52098
+ * @param {((o:Instance<C>)=>boolean)|null} check
52099
+ */
52100
+ constructor(c2, check) {
52101
+ super();
52102
+ this.shape = c2;
52103
+ this._c = check;
52104
+ }
52105
+ /**
52106
+ * @param {any} o
52107
+ * @param {ValidationError} [err]
52108
+ * @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o
52109
+ */
52110
+ check(o, err = void 0) {
52111
+ const c2 = o?.constructor === this.shape && (this._c == null || this._c(o));
52112
+ !c2 && err?.extend(null, this.shape.name, o?.constructor.name, o?.constructor !== this.shape ? "Constructor match failed" : "Check failed");
52113
+ return c2;
52114
+ }
52115
+ }
52116
+ const $constructedBy = (c2, check = null) => new $ConstructedBy(c2, check);
52117
+ $constructedBy($ConstructedBy);
52118
+ class $Custom extends Schema$1 {
52119
+ /**
52120
+ * @param {(o:any) => boolean} check
52121
+ */
52122
+ constructor(check) {
52123
+ super();
52124
+ this.shape = check;
52125
+ }
52126
+ /**
52127
+ * @param {any} o
52128
+ * @param {ValidationError} err
52129
+ * @return {o is any}
52130
+ */
52131
+ check(o, err) {
52132
+ const c2 = this.shape(o);
52133
+ !c2 && err?.extend(null, "custom prop", o?.constructor.name, "failed to check custom prop");
52134
+ return c2;
52135
+ }
52136
+ }
52137
+ const $custom = (check) => new $Custom(check);
52138
+ $constructedBy($Custom);
52139
+ class $Literal extends Schema$1 {
52140
+ /**
52141
+ * @param {Array<T>} literals
52142
+ */
52143
+ constructor(literals) {
52144
+ super();
52145
+ this.shape = literals;
52146
+ }
52147
+ /**
52148
+ *
52149
+ * @param {any} o
52150
+ * @param {ValidationError} [err]
52151
+ * @return {o is T}
52152
+ */
52153
+ check(o, err) {
52154
+ const c2 = this.shape.some((a) => a === o);
52155
+ !c2 && err?.extend(null, this.shape.join(" | "), o.toString());
52156
+ return c2;
52157
+ }
52158
+ }
52159
+ const $literal = (...literals) => new $Literal(literals);
52160
+ const $$literal = $constructedBy($Literal);
52161
+ const _regexEscape = (
52162
+ /** @type {any} */
52163
+ RegExp.escape || /** @type {(str:string) => string} */
52164
+ ((str) => str.replace(/[().|&,$^[\]]/g, (s2) => "\\" + s2))
52165
+ );
52166
+ const _schemaStringTemplateToRegex = (s2) => {
52167
+ if ($string.check(s2)) {
52168
+ return [_regexEscape(s2)];
52169
+ }
52170
+ if ($$literal.check(s2)) {
52171
+ return (
52172
+ /** @type {Array<string|number>} */
52173
+ s2.shape.map((v2) => v2 + "")
52174
+ );
52175
+ }
52176
+ if ($$number.check(s2)) {
52177
+ return ["[+-]?\\d+.?\\d*"];
52178
+ }
52179
+ if ($$string.check(s2)) {
52180
+ return [".*"];
52181
+ }
52182
+ if ($$union.check(s2)) {
52183
+ return s2.shape.map(_schemaStringTemplateToRegex).flat(1);
52184
+ }
52185
+ unexpectedCase();
52186
+ };
52187
+ class $StringTemplate extends Schema$1 {
52188
+ /**
52189
+ * @param {T} shape
52190
+ */
52191
+ constructor(shape) {
52192
+ super();
52193
+ this.shape = shape;
52194
+ this._r = new RegExp("^" + shape.map(_schemaStringTemplateToRegex).map((opts) => `(${opts.join("|")})`).join("") + "$");
52195
+ }
52196
+ /**
52197
+ * @param {any} o
52198
+ * @param {ValidationError} [err]
52199
+ * @return {o is CastStringTemplateArgsToTemplate<T>}
52200
+ */
52201
+ check(o, err) {
52202
+ const c2 = this._r.exec(o) != null;
52203
+ !c2 && err?.extend(null, this._r.toString(), o.toString(), "String doesn't match string template.");
52204
+ return c2;
52205
+ }
52206
+ }
52207
+ $constructedBy($StringTemplate);
52208
+ const isOptionalSymbol = Symbol("optional");
52209
+ class $Optional extends Schema$1 {
52210
+ /**
52211
+ * @param {S} shape
52212
+ */
52213
+ constructor(shape) {
52214
+ super();
52215
+ this.shape = shape;
52216
+ }
52217
+ /**
52218
+ * @param {any} o
52219
+ * @param {ValidationError} [err]
52220
+ * @return {o is (Unwrap<S>|undefined)}
52221
+ */
52222
+ check(o, err) {
52223
+ const c2 = o === void 0 || this.shape.check(o);
52224
+ !c2 && err?.extend(null, "undefined (optional)", "()");
52225
+ return c2;
52226
+ }
52227
+ get [isOptionalSymbol]() {
52228
+ return true;
52229
+ }
52230
+ }
52231
+ const $$optional = $constructedBy($Optional);
52232
+ class $Never extends Schema$1 {
52233
+ /**
52234
+ * @param {any} _o
52235
+ * @param {ValidationError} [err]
52236
+ * @return {_o is never}
52237
+ */
52238
+ check(_o, err) {
52239
+ err?.extend(null, "never", typeof _o);
52240
+ return false;
52241
+ }
52242
+ }
52243
+ $constructedBy($Never);
52244
+ const _$Object = class _$Object2 extends Schema$1 {
52245
+ /**
52246
+ * @param {S} shape
52247
+ * @param {boolean} partial
52248
+ */
52249
+ constructor(shape, partial = false) {
52250
+ super();
52251
+ this.shape = shape;
52252
+ this._isPartial = partial;
52253
+ }
52254
+ /**
52255
+ * @type {Schema<Partial<$ObjectToType<S>>>}
52256
+ */
52257
+ get partial() {
52258
+ return new _$Object2(this.shape, true);
52259
+ }
52260
+ /**
52261
+ * @param {any} o
52262
+ * @param {ValidationError} err
52263
+ * @return {o is $ObjectToType<S>}
52264
+ */
52265
+ check(o, err) {
52266
+ if (o == null) {
52267
+ err?.extend(null, "object", "null");
52268
+ return false;
52269
+ }
52270
+ return every(this.shape, (vv, vk) => {
52271
+ const c2 = this._isPartial && !hasProperty(o, vk) || vv.check(o[vk], err);
52272
+ !c2 && err?.extend(vk.toString(), vv.toString(), typeof o[vk], "Object property does not match");
52273
+ return c2;
52274
+ });
52275
+ }
52276
+ };
52277
+ __publicField$1(_$Object, "_dilutes", true);
52278
+ let $Object = _$Object;
52279
+ const $object = (def) => (
52280
+ /** @type {any} */
52281
+ new $Object(def)
52282
+ );
52283
+ const $$object = $constructedBy($Object);
52284
+ const $objectAny = $custom((o) => o != null && (o.constructor === Object || o.constructor == null));
52285
+ class $Record extends Schema$1 {
52286
+ /**
52287
+ * @param {Keys} keys
52288
+ * @param {Values} values
52289
+ */
52290
+ constructor(keys2, values) {
52291
+ super();
52292
+ this.shape = {
52293
+ keys: keys2,
52294
+ values
52295
+ };
52296
+ }
52297
+ /**
52298
+ * @param {any} o
52299
+ * @param {ValidationError} err
52300
+ * @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }}
52301
+ */
52302
+ check(o, err) {
52303
+ return o != null && every(o, (vv, vk) => {
52304
+ const ck = this.shape.keys.check(vk, err);
52305
+ !ck && err?.extend(vk + "", "Record", typeof o, ck ? "Key doesn't match schema" : "Value doesn't match value");
52306
+ return ck && this.shape.values.check(vv, err);
52307
+ });
52308
+ }
52309
+ }
52310
+ const $record = (keys2, values) => new $Record(keys2, values);
52311
+ const $$record = $constructedBy($Record);
52312
+ class $Tuple extends Schema$1 {
52313
+ /**
52314
+ * @param {S} shape
52315
+ */
52316
+ constructor(shape) {
52317
+ super();
52318
+ this.shape = shape;
52319
+ }
52320
+ /**
52321
+ * @param {any} o
52322
+ * @param {ValidationError} err
52323
+ * @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }}
52324
+ */
52325
+ check(o, err) {
52326
+ return o != null && every(this.shape, (vv, vk) => {
52327
+ const c2 = (
52328
+ /** @type {Schema<any>} */
52329
+ vv.check(o[vk], err)
52330
+ );
52331
+ !c2 && err?.extend(vk.toString(), "Tuple", typeof vv);
52332
+ return c2;
52333
+ });
52334
+ }
52335
+ }
52336
+ const $tuple = (...def) => new $Tuple(def);
52337
+ $constructedBy($Tuple);
52338
+ class $Array extends Schema$1 {
52339
+ /**
52340
+ * @param {Array<S>} v
52341
+ */
52342
+ constructor(v2) {
52343
+ super();
52344
+ this.shape = v2.length === 1 ? v2[0] : new $Union(v2);
52345
+ }
52346
+ /**
52347
+ * @param {any} o
52348
+ * @param {ValidationError} [err]
52349
+ * @return {o is Array<S extends Schema<infer T> ? T : never>} o
52350
+ */
52351
+ check(o, err) {
52352
+ const c2 = isArray$1(o) && every$1(o, (oi) => this.shape.check(oi));
52353
+ !c2 && err?.extend(null, "Array", "");
52354
+ return c2;
52355
+ }
52356
+ }
52357
+ const $array = (...def) => new $Array(def);
52358
+ const $$array = $constructedBy($Array);
52359
+ const $arrayAny = $custom((o) => isArray$1(o));
52360
+ class $InstanceOf extends Schema$1 {
52361
+ /**
52362
+ * @param {new (...args:any) => T} constructor
52363
+ * @param {((o:T) => boolean)|null} check
52364
+ */
52365
+ constructor(constructor, check) {
52366
+ super();
52367
+ this.shape = constructor;
52368
+ this._c = check;
52369
+ }
52370
+ /**
52371
+ * @param {any} o
52372
+ * @param {ValidationError} err
52373
+ * @return {o is T}
52374
+ */
52375
+ check(o, err) {
52376
+ const c2 = o instanceof this.shape && (this._c == null || this._c(o));
52377
+ !c2 && err?.extend(null, this.shape.name, o?.constructor.name);
52378
+ return c2;
52379
+ }
52380
+ }
52381
+ const $instanceOf = (c2, check = null) => new $InstanceOf(c2, check);
52382
+ $constructedBy($InstanceOf);
52383
+ const $$schema = $instanceOf(Schema$1);
52384
+ class $Lambda extends Schema$1 {
52385
+ /**
52386
+ * @param {Args} args
52387
+ */
52388
+ constructor(args) {
52389
+ super();
52390
+ this.len = args.length - 1;
52391
+ this.args = $tuple(...args.slice(-1));
52392
+ this.res = args[this.len];
52393
+ }
52394
+ /**
52395
+ * @param {any} f
52396
+ * @param {ValidationError} err
52397
+ * @return {f is _LArgsToLambdaDef<Args>}
52398
+ */
52399
+ check(f2, err) {
52400
+ const c2 = f2.constructor === Function && f2.length <= this.len;
52401
+ !c2 && err?.extend(null, "function", typeof f2);
52402
+ return c2;
52403
+ }
52404
+ }
52405
+ const $$lambda = $constructedBy($Lambda);
52406
+ const $function = $custom((o) => typeof o === "function");
52407
+ class $Intersection extends Schema$1 {
52408
+ /**
52409
+ * @param {T} v
52410
+ */
52411
+ constructor(v2) {
52412
+ super();
52413
+ this.shape = v2;
52414
+ }
52415
+ /**
52416
+ * @param {any} o
52417
+ * @param {ValidationError} [err]
52418
+ * @return {o is Intersect<UnwrapArray<T>>}
52419
+ */
52420
+ check(o, err) {
52421
+ const c2 = every$1(this.shape, (check) => check.check(o, err));
52422
+ !c2 && err?.extend(null, "Intersectinon", typeof o);
52423
+ return c2;
52424
+ }
52425
+ }
52426
+ $constructedBy($Intersection, (o) => o.shape.length > 0);
52427
+ class $Union extends Schema$1 {
52428
+ /**
52429
+ * @param {Array<Schema<S>>} v
52430
+ */
52431
+ constructor(v2) {
52432
+ super();
52433
+ this.shape = v2;
52434
+ }
52435
+ /**
52436
+ * @param {any} o
52437
+ * @param {ValidationError} [err]
52438
+ * @return {o is S}
52439
+ */
52440
+ check(o, err) {
52441
+ const c2 = some(this.shape, (vv) => vv.check(o, err));
52442
+ err?.extend(null, "Union", typeof o);
52443
+ return c2;
52444
+ }
52445
+ }
52446
+ __publicField$1($Union, "_dilutes", true);
52447
+ const $union = (...schemas) => schemas.findIndex(($s) => $$union.check($s)) >= 0 ? $union(...schemas.map(($s) => $2($s)).map(($s) => $$union.check($s) ? $s.shape : [$s]).flat(1)) : schemas.length === 1 ? schemas[0] : new $Union(schemas);
52448
+ const $$union = (
52449
+ /** @type {Schema<$Union<any>>} */
52450
+ $constructedBy($Union)
52451
+ );
52452
+ const _t = () => true;
52453
+ const $any = $custom(_t);
52454
+ const $$any = (
52455
+ /** @type {Schema<Schema<any>>} */
52456
+ $constructedBy($Custom, (o) => o.shape === _t)
52457
+ );
52458
+ const $bigint = $custom((o) => typeof o === "bigint");
52459
+ const $$bigint = (
52460
+ /** @type {Schema<Schema<BigInt>>} */
52461
+ $custom((o) => o === $bigint)
52462
+ );
52463
+ const $symbol = $custom((o) => typeof o === "symbol");
52464
+ $custom((o) => o === $symbol);
52465
+ const $number = $custom((o) => typeof o === "number");
52466
+ const $$number = (
52467
+ /** @type {Schema<Schema<number>>} */
52468
+ $custom((o) => o === $number)
52469
+ );
52470
+ const $string = $custom((o) => typeof o === "string");
52471
+ const $$string = (
52472
+ /** @type {Schema<Schema<string>>} */
52473
+ $custom((o) => o === $string)
52474
+ );
52475
+ const $boolean = $custom((o) => typeof o === "boolean");
52476
+ const $$boolean = (
52477
+ /** @type {Schema<Schema<Boolean>>} */
52478
+ $custom((o) => o === $boolean)
52479
+ );
52480
+ const $undefined = $literal(void 0);
52481
+ $constructedBy($Literal, (o) => o.shape.length === 1 && o.shape[0] === void 0);
52482
+ $literal(void 0);
52483
+ const $null = $literal(null);
52484
+ const $$null = (
52485
+ /** @type {Schema<Schema<null>>} */
52486
+ $constructedBy($Literal, (o) => o.shape.length === 1 && o.shape[0] === null)
52487
+ );
52488
+ $constructedBy(Uint8Array);
52489
+ $constructedBy($ConstructedBy, (o) => o.shape === Uint8Array);
52490
+ const $primitive = $union($number, $string, $null, $undefined, $bigint, $boolean, $symbol);
52491
+ (() => {
52492
+ const $jsonArr = (
52493
+ /** @type {$Array<$any>} */
52494
+ $array($any)
52495
+ );
52496
+ const $jsonRecord = (
52497
+ /** @type {$Record<$string,$any>} */
52498
+ $record($string, $any)
52499
+ );
52500
+ const $json = $union($number, $string, $null, $boolean, $jsonArr, $jsonRecord);
52501
+ $jsonArr.shape = $json;
52502
+ $jsonRecord.shape.values = $json;
52503
+ return $json;
52504
+ })();
52505
+ const $2 = (o) => {
52506
+ if ($$schema.check(o)) {
52507
+ return (
52508
+ /** @type {any} */
52509
+ o
52510
+ );
52511
+ } else if ($objectAny.check(o)) {
52512
+ const o2 = {};
52513
+ for (const k2 in o) {
52514
+ o2[k2] = $2(o[k2]);
52515
+ }
52516
+ return (
52517
+ /** @type {any} */
52518
+ $object(o2)
52519
+ );
52520
+ } else if ($arrayAny.check(o)) {
52521
+ return (
52522
+ /** @type {any} */
52523
+ $union(...o.map($2))
52524
+ );
52525
+ } else if ($primitive.check(o)) {
52526
+ return (
52527
+ /** @type {any} */
52528
+ $literal(o)
52529
+ );
52530
+ } else if ($function.check(o)) {
52531
+ return (
52532
+ /** @type {any} */
52533
+ $constructedBy(
52534
+ /** @type {any} */
52535
+ o
52536
+ )
52537
+ );
52538
+ }
52539
+ unexpectedCase();
52540
+ };
52541
+ const assert = production ? () => {
52542
+ } : (o, schema) => {
52543
+ const err = new ValidationError();
52544
+ if (!schema.check(o, err)) {
52545
+ throw create$1(`Expected value to be of type ${schema.constructor.name}.
52546
+ ${err.toString()}`);
52547
+ }
52548
+ };
52549
+ class PatternMatcher {
52550
+ /**
52551
+ * @param {Schema<State>} [$state]
52552
+ */
52553
+ constructor($state) {
52554
+ this.patterns = [];
52555
+ this.$state = $state;
52556
+ }
52557
+ /**
52558
+ * @template P
52559
+ * @template R
52560
+ * @param {P} pattern
52561
+ * @param {(o:NoInfer<Unwrap<ReadSchema<P>>>,s:State)=>R} handler
52562
+ * @return {PatternMatcher<State,Patterns|Pattern<Unwrap<ReadSchema<P>>,R>>}
52563
+ */
52564
+ if(pattern, handler2) {
52565
+ this.patterns.push({ if: $2(pattern), h: handler2 });
52566
+ return this;
52567
+ }
52568
+ /**
52569
+ * @template R
52570
+ * @param {(o:any,s:State)=>R} h
52571
+ */
52572
+ else(h2) {
52573
+ return this.if($any, h2);
52574
+ }
52575
+ /**
52576
+ * @return {State extends undefined
52577
+ * ? <In extends Unwrap<Patterns['if']>>(o:In,state?:undefined)=>PatternMatchResult<Patterns,In>
52578
+ * : <In extends Unwrap<Patterns['if']>>(o:In,state:State)=>PatternMatchResult<Patterns,In>}
52579
+ */
52580
+ done() {
52581
+ return (
52582
+ /** @type {any} */
52583
+ ((o, s2) => {
52584
+ for (let i = 0; i < this.patterns.length; i++) {
52585
+ const p = this.patterns[i];
52586
+ if (p.if.check(o)) {
52587
+ return p.h(o, s2);
52588
+ }
52589
+ }
52590
+ throw create$1("Unhandled pattern");
52591
+ })
52592
+ );
52593
+ }
52594
+ }
52595
+ const match = (state2) => new PatternMatcher(
52596
+ /** @type {any} */
52597
+ state2
52598
+ );
52599
+ const _random = (
52600
+ /** @type {any} */
52601
+ match(
52602
+ /** @type {Schema<prng.PRNG>} */
52603
+ $any
52604
+ ).if($$number, (_o, gen) => int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER$2)).if($$string, (_o, gen) => word(gen)).if($$boolean, (_o, gen) => bool(gen)).if($$bigint, (_o, gen) => BigInt(int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER$2))).if($$union, (o, gen) => random(gen, oneOf(gen, o.shape))).if($$object, (o, gen) => {
52605
+ const res = {};
52606
+ for (const k2 in o.shape) {
52607
+ let prop = o.shape[k2];
52608
+ if ($$optional.check(prop)) {
52609
+ if (bool(gen)) {
52610
+ continue;
52611
+ }
52612
+ prop = prop.shape;
52613
+ }
52614
+ res[k2] = _random(prop, gen);
52615
+ }
52616
+ return res;
52617
+ }).if($$array, (o, gen) => {
52618
+ const arr = [];
52619
+ const n = int32(gen, 0, 42);
52620
+ for (let i = 0; i < n; i++) {
52621
+ arr.push(random(gen, o.shape));
52622
+ }
52623
+ return arr;
52624
+ }).if($$literal, (o, gen) => {
52625
+ return oneOf(gen, o.shape);
52626
+ }).if($$null, (o, gen) => {
52627
+ return null;
52628
+ }).if($$lambda, (o, gen) => {
52629
+ const res = random(gen, o.res);
52630
+ return () => res;
52631
+ }).if($$any, (o, gen) => random(gen, oneOf(gen, [
52632
+ $number,
52633
+ $string,
52634
+ $null,
52635
+ $undefined,
52636
+ $bigint,
52637
+ $boolean,
52638
+ $array($number),
52639
+ $record($union("a", "b", "c"), $number)
52640
+ ]))).if($$record, (o, gen) => {
52641
+ const res = {};
52642
+ const keysN = int53(gen, 0, 3);
52643
+ for (let i = 0; i < keysN; i++) {
52644
+ const key2 = random(gen, o.shape.keys);
52645
+ const val = random(gen, o.shape.values);
52646
+ res[key2] = val;
52647
+ }
52648
+ return res;
52649
+ }).done()
52650
+ );
52651
+ const random = (gen, schema) => (
52652
+ /** @type {any} */
52653
+ _random($2(schema), gen)
52654
+ );
51802
52655
  const doc = (
51803
52656
  /** @type {Document} */
51804
52657
  typeof document !== "undefined" ? document : {}
51805
52658
  );
52659
+ $custom((el) => el.nodeType === DOCUMENT_FRAGMENT_NODE);
51806
52660
  typeof DOMParser !== "undefined" ? new DOMParser() : null;
52661
+ $custom((el) => el.nodeType === ELEMENT_NODE);
52662
+ $custom((el) => el.nodeType === TEXT_NODE);
52663
+ const ELEMENT_NODE = doc.ELEMENT_NODE;
52664
+ const TEXT_NODE = doc.TEXT_NODE;
52665
+ const DOCUMENT_NODE = doc.DOCUMENT_NODE;
52666
+ const DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE;
52667
+ $custom((el) => el.nodeType === DOCUMENT_NODE);
51807
52668
  const createTimeoutClass = (clearFunction) => class TT {
51808
52669
  /**
51809
52670
  * @param {number} timeoutId
@@ -51986,16 +52847,6 @@ class Hasher {
51986
52847
  }
51987
52848
  }
51988
52849
  const digest = (data) => new Hasher().digest(data);
51989
- const toBase64Browser = (bytes) => {
51990
- let s2 = "";
51991
- for (let i = 0; i < bytes.byteLength; i++) {
51992
- s2 += fromCharCode(bytes[i]);
51993
- }
51994
- return btoa(s2);
51995
- };
51996
- const toBase64Node = (bytes) => Buffer2.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
51997
- const toBase64 = isBrowser$1$1 ? toBase64Browser : toBase64Node;
51998
- const encodeAny = (data) => encode((encoder) => writeAny(encoder, data));
51999
52850
  const _convolute = (digest2) => {
52000
52851
  const N2 = 6;
52001
52852
  for (let i = N2; i < digest2.length; i++) {
@@ -52018,7 +52869,7 @@ const getUserColor = (colorMapping, colors2, user) => {
52018
52869
  colorMapping.forEach((color) => usedColors.add(color));
52019
52870
  colors2 = colors2.filter((color) => !usedColors.has(color));
52020
52871
  }
52021
- colorMapping.set(user, oneOf(colors2));
52872
+ colorMapping.set(user, oneOf$1(colors2));
52022
52873
  }
52023
52874
  return (
52024
52875
  /** @type {ColorDef} */
@@ -53798,7 +54649,7 @@ const _Schema = class _Schema2 {
53798
54649
  const attributes = Attribute2.getAttributesFromExtensions(extensions);
53799
54650
  const nodes = __privateMethod$1(_a2 = _Schema2, _Schema_static, createNodesSchema_fn).call(_a2, nodeExtensions, attributes, editor);
53800
54651
  const marks = __privateMethod$1(_b2 = _Schema2, _Schema_static, createMarksSchema_fn).call(_b2, markExtensions, attributes, editor);
53801
- return new Schema$1({ topNode, nodes, marks });
54652
+ return new Schema$1$1({ topNode, nodes, marks });
53802
54653
  }
53803
54654
  };
53804
54655
  _Schema_static = /* @__PURE__ */ new WeakSet();
@@ -54299,9 +55150,9 @@ const newlineInCode$1 = (state2, dispatch) => {
54299
55150
  dispatch(state2.tr.insertText("\n").scrollIntoView());
54300
55151
  return true;
54301
55152
  };
54302
- function defaultBlockAt(match) {
54303
- for (let i = 0; i < match.edgeCount; i++) {
54304
- let { type: type2 } = match.edge(i);
55153
+ function defaultBlockAt(match2) {
55154
+ for (let i = 0; i < match2.edgeCount; i++) {
55155
+ let { type: type2 } = match2.edge(i);
54305
55156
  if (type2.isTextblock && !type2.hasRequiredAttrs())
54306
55157
  return type2;
54307
55158
  }
@@ -54428,12 +55279,12 @@ function joinMaybeClear(state2, $pos, dispatch) {
54428
55279
  return true;
54429
55280
  }
54430
55281
  function deleteBarrier(state2, $cut, dispatch, dir) {
54431
- let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match;
55282
+ let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match2;
54432
55283
  let isolated = before.type.spec.isolating || after.type.spec.isolating;
54433
55284
  if (!isolated && joinMaybeClear(state2, $cut, dispatch))
54434
55285
  return true;
54435
55286
  let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
54436
- if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {
55287
+ if (canDelAfter && (conn = (match2 = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match2.matchType(conn[0] || after.type).validEnd) {
54437
55288
  if (dispatch) {
54438
55289
  let end2 = $cut.pos + after.nodeSize, wrap2 = Fragment.empty;
54439
55290
  for (let i = conn.length - 1; i >= 0; i--)
@@ -55045,7 +55896,7 @@ function createNodeFromContent(content, editor, options) {
55045
55896
  if (options.errorOnInvalidContent) {
55046
55897
  let hasInvalidContent = false;
55047
55898
  let invalidContent = "";
55048
- const contentCheckSchema = new Schema$1({
55899
+ const contentCheckSchema = new Schema$1$1({
55049
55900
  topNode: schema.spec.topNode,
55050
55901
  marks: schema.spec.marks,
55051
55902
  // Prosemirror's schemas are executed such that: the last to execute, matches last
@@ -57967,7 +58818,11 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
57967
58818
  const onlyInputTypeMeta = ["inputType", "uiEvent", "paste", "pointer"];
57968
58819
  const notAllowedMeta = ["historyUndo", "historyRedo", "acceptReject"];
57969
58820
  const isProgrammaticInput = tr.getMeta("inputType") === "programmatic";
57970
- if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => onlyInputTypeMeta.includes(meta)) && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
58821
+ const ySyncMeta = tr.getMeta(ySyncPluginKey);
58822
+ const allowedMeta = /* @__PURE__ */ new Set([...onlyInputTypeMeta, ySyncPluginKey.key]);
58823
+ const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta) => !allowedMeta.has(meta));
58824
+ if (ySyncMeta?.isChangeOrigin || // Skip Yjs-origin transactions (remote/rehydration).
58825
+ !tr.steps.length || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
57971
58826
  return tr;
57972
58827
  }
57973
58828
  const newTr = state2.tr;
@@ -59636,7 +60491,7 @@ const isHeadless = (editor) => {
59636
60491
  const shouldSkipNodeView = (editor) => {
59637
60492
  return isHeadless(editor);
59638
60493
  };
59639
- const summaryVersion = "1.0.0-next.9";
60494
+ const summaryVersion = "1.0.2";
59640
60495
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59641
60496
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59642
60497
  function mapAttributes(attrs) {
@@ -60425,7 +61280,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60425
61280
  { default: remarkStringify },
60426
61281
  { default: remarkGfm }
60427
61282
  ] = await Promise.all([
60428
- import("./index-DNIymDRK-BMrUTNeb.es.js"),
61283
+ import("./index-DDZ1ZT8N-MJzqg0qg.es.js"),
60429
61284
  import("./index-DRCvimau-Cw339678.es.js"),
60430
61285
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60431
61286
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60630,7 +61485,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60630
61485
  * Process collaboration migrations
60631
61486
  */
60632
61487
  processCollaborationMigrations() {
60633
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-next.9");
61488
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.2");
60634
61489
  if (!this.options.ydoc) return;
60635
61490
  const metaMap = this.options.ydoc.getMap("meta");
60636
61491
  let docVersion = metaMap.get("version");
@@ -71629,6 +72484,86 @@ const createDomPainter = (options) => {
71629
72484
  }
71630
72485
  };
71631
72486
  };
72487
+ const DEFAULT_CONFIG = {
72488
+ logLevel: "off",
72489
+ hud: false,
72490
+ dumpRects: false,
72491
+ disableRectDedupe: false
72492
+ };
72493
+ const levelOrder = {
72494
+ error: 0,
72495
+ warn: 1,
72496
+ info: 2,
72497
+ verbose: 3
72498
+ };
72499
+ function getSelectionDebugConfig() {
72500
+ var _a2;
72501
+ if (typeof window === "undefined") {
72502
+ return DEFAULT_CONFIG;
72503
+ }
72504
+ window.superdocDebug ?? (window.superdocDebug = {});
72505
+ (_a2 = window.superdocDebug).selection ?? (_a2.selection = {});
72506
+ const cfg = window.superdocDebug.selection;
72507
+ return {
72508
+ logLevel: cfg.logLevel ?? DEFAULT_CONFIG.logLevel,
72509
+ hud: cfg.hud ?? DEFAULT_CONFIG.hud,
72510
+ dumpRects: cfg.dumpRects ?? DEFAULT_CONFIG.dumpRects,
72511
+ disableRectDedupe: cfg.disableRectDedupe ?? DEFAULT_CONFIG.disableRectDedupe
72512
+ };
72513
+ }
72514
+ function debugLog(level, message, data) {
72515
+ const cfg = getSelectionDebugConfig();
72516
+ if (cfg.logLevel === "off") return;
72517
+ if (levelOrder[level] > levelOrder[cfg.logLevel]) return;
72518
+ const prefix2 = "[Selection]";
72519
+ if (data) {
72520
+ console.log(prefix2, message, data);
72521
+ } else {
72522
+ console.log(prefix2, message);
72523
+ }
72524
+ }
72525
+ const HUD_DATA_ATTR = "data-superdoc-selection-debug-hud";
72526
+ function updateSelectionDebugHud(host, state2) {
72527
+ const cfg = getSelectionDebugConfig();
72528
+ const doc2 = host.ownerDocument ?? (typeof document !== "undefined" ? document : null);
72529
+ if (!doc2) return;
72530
+ const existing = host.querySelector(`[${HUD_DATA_ATTR}="true"]`);
72531
+ if (!cfg.hud) {
72532
+ existing?.remove();
72533
+ return;
72534
+ }
72535
+ const hud = existing ?? doc2.createElement("div");
72536
+ hud.setAttribute(HUD_DATA_ATTR, "true");
72537
+ hud.style.position = "absolute";
72538
+ hud.style.top = "8px";
72539
+ hud.style.left = "8px";
72540
+ hud.style.zIndex = "9999";
72541
+ hud.style.maxWidth = "420px";
72542
+ hud.style.padding = "6px 8px";
72543
+ hud.style.borderRadius = "6px";
72544
+ hud.style.background = "rgba(0, 0, 0, 0.72)";
72545
+ hud.style.color = "white";
72546
+ hud.style.fontFamily = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
72547
+ hud.style.fontSize = "12px";
72548
+ hud.style.lineHeight = "1.3";
72549
+ hud.style.pointerEvents = "none";
72550
+ hud.style.whiteSpace = "pre";
72551
+ const behind = Math.max(0, state2.docEpoch - state2.layoutEpoch);
72552
+ const selectionText = state2.selection ? `${state2.selection.from}..${state2.selection.to}` : "null";
72553
+ const pointerText = state2.lastPointer ? `${state2.lastPointer.clientX},${state2.lastPointer.clientY} -> ${Math.round(state2.lastPointer.x)},${Math.round(
72554
+ state2.lastPointer.y
72555
+ )}` : "null";
72556
+ const hitText = state2.lastHit ? `${state2.lastHit.source} pos=${state2.lastHit.pos ?? "null"} epoch=${state2.lastHit.layoutEpoch ?? "null"} mapped=${state2.lastHit.mappedPos ?? "null"}` : "null";
72557
+ hud.textContent = [
72558
+ `docEpoch=${state2.docEpoch} layoutEpoch=${state2.layoutEpoch} behind=${behind}`,
72559
+ `selection=${selectionText}`,
72560
+ `pointer=${pointerText}`,
72561
+ `hit=${hitText}`
72562
+ ].join("\n");
72563
+ if (!existing) {
72564
+ host.appendChild(hud);
72565
+ }
72566
+ }
71632
72567
  class DomPositionIndex {
71633
72568
  constructor() {
71634
72569
  __privateAdd$1(this, _entries, []);
@@ -71685,6 +72620,7 @@ class DomPositionIndex {
71685
72620
  }
71686
72621
  for (const node of pmNodes) {
71687
72622
  if (node.classList.contains(DOM_CLASS_NAMES.INLINE_SDT_WRAPPER)) continue;
72623
+ if (node.closest(".superdoc-page-header, .superdoc-page-footer")) continue;
71688
72624
  if (leafOnly && nonLeaf.has(node)) continue;
71689
72625
  const pmStart = Number(node.dataset.pmStart ?? "NaN");
71690
72626
  const pmEnd = Number(node.dataset.pmEnd ?? "NaN");
@@ -71694,6 +72630,60 @@ class DomPositionIndex {
71694
72630
  }
71695
72631
  entries.sort((a, b2) => a.pmStart - b2.pmStart !== 0 ? a.pmStart - b2.pmStart : a.pmEnd - b2.pmEnd);
71696
72632
  __privateSet(this, _entries, entries);
72633
+ const isVerbose = getSelectionDebugConfig().logLevel === "verbose";
72634
+ if (isVerbose) {
72635
+ const counts = { total: entries.length, body: 0, header: 0, footer: 0 };
72636
+ const bodySamples = [];
72637
+ const headerSamples = [];
72638
+ const footerSamples = [];
72639
+ for (const entry of entries) {
72640
+ const pageEl = entry.el.closest(`.${DOM_CLASS_NAMES.PAGE}`);
72641
+ const pageIndex = pageEl?.dataset.pageIndex ?? null;
72642
+ const section = entry.el.closest(".superdoc-page-header") ? "header" : entry.el.closest(".superdoc-page-footer") ? "footer" : "body";
72643
+ if (section === "header") {
72644
+ counts.header += 1;
72645
+ if (headerSamples.length < 10) {
72646
+ headerSamples.push({
72647
+ pmStart: entry.pmStart,
72648
+ pmEnd: entry.pmEnd,
72649
+ pageIndex,
72650
+ text: (entry.el.textContent ?? "").slice(0, 40)
72651
+ });
72652
+ }
72653
+ continue;
72654
+ }
72655
+ if (section === "footer") {
72656
+ counts.footer += 1;
72657
+ if (footerSamples.length < 10) {
72658
+ footerSamples.push({
72659
+ pmStart: entry.pmStart,
72660
+ pmEnd: entry.pmEnd,
72661
+ pageIndex,
72662
+ text: (entry.el.textContent ?? "").slice(0, 40)
72663
+ });
72664
+ }
72665
+ continue;
72666
+ }
72667
+ counts.body += 1;
72668
+ if (bodySamples.length < 10) {
72669
+ bodySamples.push({
72670
+ pmStart: entry.pmStart,
72671
+ pmEnd: entry.pmEnd,
72672
+ pageIndex,
72673
+ text: (entry.el.textContent ?? "").slice(0, 40)
72674
+ });
72675
+ }
72676
+ }
72677
+ debugLog(
72678
+ "verbose",
72679
+ `DomPositionIndex: rebuild summary ${JSON.stringify({
72680
+ counts,
72681
+ bodySamples,
72682
+ headerSamples,
72683
+ footerSamples
72684
+ })}`
72685
+ );
72686
+ }
71697
72687
  }
71698
72688
  /**
71699
72689
  * Finds the index entry whose position range contains the given position.
@@ -71943,82 +72933,6 @@ _onRebuild = /* @__PURE__ */ new WeakMap();
71943
72933
  _observer = /* @__PURE__ */ new WeakMap();
71944
72934
  _rebuildScheduled = /* @__PURE__ */ new WeakMap();
71945
72935
  _rebuildRafId = /* @__PURE__ */ new WeakMap();
71946
- const DEFAULT_CONFIG = {
71947
- logLevel: "off",
71948
- hud: false
71949
- };
71950
- const levelOrder = {
71951
- error: 0,
71952
- warn: 1,
71953
- info: 2,
71954
- verbose: 3
71955
- };
71956
- function getSelectionDebugConfig() {
71957
- var _a2;
71958
- if (typeof window === "undefined") {
71959
- return DEFAULT_CONFIG;
71960
- }
71961
- window.superdocDebug ?? (window.superdocDebug = {});
71962
- (_a2 = window.superdocDebug).selection ?? (_a2.selection = {});
71963
- const cfg = window.superdocDebug.selection;
71964
- return {
71965
- logLevel: cfg.logLevel ?? DEFAULT_CONFIG.logLevel,
71966
- hud: cfg.hud ?? DEFAULT_CONFIG.hud
71967
- };
71968
- }
71969
- function debugLog(level, message, data) {
71970
- const cfg = getSelectionDebugConfig();
71971
- if (cfg.logLevel === "off") return;
71972
- if (levelOrder[level] > levelOrder[cfg.logLevel]) return;
71973
- const prefix2 = "[Selection]";
71974
- if (data) {
71975
- console.log(prefix2, message, data);
71976
- } else {
71977
- console.log(prefix2, message);
71978
- }
71979
- }
71980
- const HUD_DATA_ATTR = "data-superdoc-selection-debug-hud";
71981
- function updateSelectionDebugHud(host, state2) {
71982
- const cfg = getSelectionDebugConfig();
71983
- const doc2 = host.ownerDocument ?? (typeof document !== "undefined" ? document : null);
71984
- if (!doc2) return;
71985
- const existing = host.querySelector(`[${HUD_DATA_ATTR}="true"]`);
71986
- if (!cfg.hud) {
71987
- existing?.remove();
71988
- return;
71989
- }
71990
- const hud = existing ?? doc2.createElement("div");
71991
- hud.setAttribute(HUD_DATA_ATTR, "true");
71992
- hud.style.position = "absolute";
71993
- hud.style.top = "8px";
71994
- hud.style.left = "8px";
71995
- hud.style.zIndex = "9999";
71996
- hud.style.maxWidth = "420px";
71997
- hud.style.padding = "6px 8px";
71998
- hud.style.borderRadius = "6px";
71999
- hud.style.background = "rgba(0, 0, 0, 0.72)";
72000
- hud.style.color = "white";
72001
- hud.style.fontFamily = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
72002
- hud.style.fontSize = "12px";
72003
- hud.style.lineHeight = "1.3";
72004
- hud.style.pointerEvents = "none";
72005
- hud.style.whiteSpace = "pre";
72006
- const behind = Math.max(0, state2.docEpoch - state2.layoutEpoch);
72007
- const selectionText = state2.selection ? `${state2.selection.from}..${state2.selection.to}` : "null";
72008
- const pointerText = state2.lastPointer ? `${state2.lastPointer.clientX},${state2.lastPointer.clientY} -> ${Math.round(state2.lastPointer.x)},${Math.round(
72009
- state2.lastPointer.y
72010
- )}` : "null";
72011
- const hitText = state2.lastHit ? `${state2.lastHit.source} pos=${state2.lastHit.pos ?? "null"} epoch=${state2.lastHit.layoutEpoch ?? "null"} mapped=${state2.lastHit.mappedPos ?? "null"}` : "null";
72012
- hud.textContent = [
72013
- `docEpoch=${state2.docEpoch} layoutEpoch=${state2.layoutEpoch} behind=${behind}`,
72014
- `selection=${selectionText}`,
72015
- `pointer=${pointerText}`,
72016
- `hit=${hitText}`
72017
- ].join("\n");
72018
- if (!existing) {
72019
- host.appendChild(hud);
72020
- }
72021
- }
72022
72936
  function computeSelectionRectsFromDom(options, from2, to) {
72023
72937
  const painterHost = options.painterHost;
72024
72938
  if (!painterHost) return null;
@@ -72039,6 +72953,34 @@ function computeSelectionRectsFromDom(options, from2, to) {
72039
72953
  );
72040
72954
  const out = [];
72041
72955
  let rebuiltOnce = false;
72956
+ const debugConfig = getSelectionDebugConfig();
72957
+ const isVerbose = debugConfig.logLevel === "verbose";
72958
+ const dumpRects = isVerbose && debugConfig.dumpRects;
72959
+ const disableRectDedupe = debugConfig.disableRectDedupe;
72960
+ const entryDebugInfo = (entry) => {
72961
+ const pageEl = entry.el.closest(`.${DOM_CLASS_NAMES.PAGE}`);
72962
+ const section = entry.el.closest(".superdoc-page-header") ? "header" : entry.el.closest(".superdoc-page-footer") ? "footer" : "body";
72963
+ return {
72964
+ pmStart: entry.pmStart,
72965
+ pmEnd: entry.pmEnd,
72966
+ pageIndex: pageEl?.dataset.pageIndex ?? null,
72967
+ section,
72968
+ connected: entry.el.isConnected,
72969
+ layoutEpoch: entry.el.dataset.layoutEpoch ?? null,
72970
+ pageEpoch: pageEl?.dataset.layoutEpoch ?? null,
72971
+ text: (entry.el.textContent ?? "").slice(0, 80)
72972
+ };
72973
+ };
72974
+ const rectDebugInfo = (rect) => ({
72975
+ x: rect.x,
72976
+ y: rect.y,
72977
+ width: rect.width,
72978
+ height: rect.height,
72979
+ top: rect.top,
72980
+ left: rect.left,
72981
+ right: rect.right,
72982
+ bottom: rect.bottom
72983
+ });
72042
72984
  for (const pageEl of pageEls) {
72043
72985
  const pageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
72044
72986
  if (!Number.isFinite(pageIndex)) continue;
@@ -72062,9 +73004,47 @@ function computeSelectionRectsFromDom(options, from2, to) {
72062
73004
  if (sliceEntries.length === 0) {
72063
73005
  continue;
72064
73006
  }
73007
+ if (isVerbose) {
73008
+ debugLog(
73009
+ "verbose",
73010
+ `DOM selection rects: slice entries ${JSON.stringify({
73011
+ pageIndex,
73012
+ sliceFrom,
73013
+ sliceTo,
73014
+ entriesCount: sliceEntries.length,
73015
+ entriesPreview: sliceEntries.slice(0, 20).map(entryDebugInfo)
73016
+ })}`
73017
+ );
73018
+ }
72065
73019
  let startEntry = options.domPositionIndex.findEntryAtPosition(sliceFrom) ?? sliceEntries[0];
72066
73020
  let endEntry = options.domPositionIndex.findEntryAtPosition(sliceTo) ?? sliceEntries[sliceEntries.length - 1];
72067
- if (!pageEl.contains(startEntry.el) || !pageEl.contains(endEntry.el)) {
73021
+ if (isVerbose) {
73022
+ debugLog(
73023
+ "verbose",
73024
+ `DOM selection rects: boundaries ${JSON.stringify({
73025
+ pageIndex,
73026
+ sliceFrom,
73027
+ sliceTo,
73028
+ start: entryDebugInfo(startEntry),
73029
+ end: entryDebugInfo(endEntry)
73030
+ })}`
73031
+ );
73032
+ }
73033
+ let startContained = pageEl.contains(startEntry.el);
73034
+ let endContained = pageEl.contains(endEntry.el);
73035
+ if (!startContained || !endContained) {
73036
+ if (isVerbose) {
73037
+ debugLog(
73038
+ "verbose",
73039
+ `DOM selection rects: boundary containment ${JSON.stringify({
73040
+ pageIndex,
73041
+ sliceFrom,
73042
+ sliceTo,
73043
+ startContained,
73044
+ endContained
73045
+ })}`
73046
+ );
73047
+ }
72068
73048
  if (!rebuiltOnce) {
72069
73049
  options.rebuildDomPositionIndex();
72070
73050
  rebuiltOnce = true;
@@ -72072,9 +73052,34 @@ function computeSelectionRectsFromDom(options, from2, to) {
72072
73052
  if (sliceEntries.length === 0) continue;
72073
73053
  startEntry = options.domPositionIndex.findEntryAtPosition(sliceFrom) ?? sliceEntries[0];
72074
73054
  endEntry = options.domPositionIndex.findEntryAtPosition(sliceTo) ?? sliceEntries[sliceEntries.length - 1];
73055
+ startContained = pageEl.contains(startEntry.el);
73056
+ endContained = pageEl.contains(endEntry.el);
73057
+ if (isVerbose) {
73058
+ debugLog(
73059
+ "verbose",
73060
+ `DOM selection rects: boundary containment after rebuild ${JSON.stringify({
73061
+ pageIndex,
73062
+ sliceFrom,
73063
+ sliceTo,
73064
+ startContained,
73065
+ endContained,
73066
+ start: entryDebugInfo(startEntry),
73067
+ end: entryDebugInfo(endEntry)
73068
+ })}`
73069
+ );
73070
+ }
72075
73071
  }
72076
- if (!pageEl.contains(startEntry.el) || !pageEl.contains(endEntry.el)) {
72077
- debugLog("warn", "DOM selection rects: stale index after rebuild", { pageIndex, sliceFrom, sliceTo });
73072
+ if (!startContained || !endContained) {
73073
+ debugLog(
73074
+ "warn",
73075
+ `DOM selection rects: stale index after rebuild ${JSON.stringify({
73076
+ pageIndex,
73077
+ sliceFrom,
73078
+ sliceTo,
73079
+ start: entryDebugInfo(startEntry),
73080
+ end: entryDebugInfo(endEntry)
73081
+ })}`
73082
+ );
72078
73083
  return null;
72079
73084
  }
72080
73085
  }
@@ -72089,8 +73094,83 @@ function computeSelectionRectsFromDom(options, from2, to) {
72089
73094
  }
72090
73095
  let clientRects = [];
72091
73096
  try {
72092
- const rawRects = Array.from(range2.getClientRects());
72093
- clientRects = deduplicateOverlappingRects(rawRects);
73097
+ let rawRects = Array.from(range2.getClientRects());
73098
+ if (dumpRects) {
73099
+ debugLog(
73100
+ "verbose",
73101
+ `DOM selection rects: raw rects ${JSON.stringify({
73102
+ pageIndex,
73103
+ sliceFrom,
73104
+ sliceTo,
73105
+ rects: rawRects.map(rectDebugInfo)
73106
+ })}`
73107
+ );
73108
+ }
73109
+ let missingEntries = null;
73110
+ if (typeof range2.intersectsNode === "function") {
73111
+ for (const entry of sliceEntries) {
73112
+ try {
73113
+ if (!range2.intersectsNode(entry.el)) {
73114
+ missingEntries ?? (missingEntries = []);
73115
+ missingEntries.push(entry);
73116
+ }
73117
+ } catch {
73118
+ }
73119
+ }
73120
+ }
73121
+ if (missingEntries && missingEntries.length > 0) {
73122
+ if (isVerbose) {
73123
+ debugLog(
73124
+ "verbose",
73125
+ `DOM selection rects: range missing entries ${JSON.stringify({
73126
+ pageIndex,
73127
+ sliceFrom,
73128
+ sliceTo,
73129
+ missingCount: missingEntries.length,
73130
+ missingPreview: missingEntries.slice(0, 20).map(entryDebugInfo)
73131
+ })}`
73132
+ );
73133
+ }
73134
+ rawRects = collectClientRectsByLine(doc2, sliceEntries, sliceFrom, sliceTo);
73135
+ if (dumpRects) {
73136
+ debugLog(
73137
+ "verbose",
73138
+ `DOM selection rects: fallback raw rects ${JSON.stringify({
73139
+ pageIndex,
73140
+ sliceFrom,
73141
+ sliceTo,
73142
+ rects: rawRects.map(rectDebugInfo)
73143
+ })}`
73144
+ );
73145
+ }
73146
+ }
73147
+ clientRects = disableRectDedupe ? rawRects : deduplicateOverlappingRects(rawRects);
73148
+ if (dumpRects) {
73149
+ debugLog(
73150
+ "verbose",
73151
+ `DOM selection rects: final rects ${JSON.stringify({
73152
+ pageIndex,
73153
+ sliceFrom,
73154
+ sliceTo,
73155
+ dedupeDisabled: disableRectDedupe,
73156
+ rects: clientRects.map(rectDebugInfo)
73157
+ })}`
73158
+ );
73159
+ const nonPositive = clientRects.filter(
73160
+ (rect) => !Number.isFinite(rect.width) || !Number.isFinite(rect.height) || rect.width <= 0 || rect.height <= 0
73161
+ );
73162
+ if (nonPositive.length > 0) {
73163
+ debugLog(
73164
+ "verbose",
73165
+ `DOM selection rects: non-positive rects ${JSON.stringify({
73166
+ pageIndex,
73167
+ sliceFrom,
73168
+ sliceTo,
73169
+ rects: nonPositive.map(rectDebugInfo)
73170
+ })}`
73171
+ );
73172
+ }
73173
+ }
72094
73174
  } catch (error) {
72095
73175
  debugLog("warn", "DOM selection rects: getClientRects failed", { error: String(error) });
72096
73176
  return null;
@@ -72114,6 +73194,57 @@ function computeSelectionRectsFromDom(options, from2, to) {
72114
73194
  }
72115
73195
  return out;
72116
73196
  }
73197
+ function collectClientRectsByLine(doc2, entries, sliceFrom, sliceTo) {
73198
+ const rects = [];
73199
+ const lineMap = /* @__PURE__ */ new Map();
73200
+ const looseEntries = [];
73201
+ for (const entry of entries) {
73202
+ const lineEl = entry.el.closest(".superdoc-line");
73203
+ if (!lineEl) {
73204
+ looseEntries.push(entry);
73205
+ continue;
73206
+ }
73207
+ const list = lineMap.get(lineEl);
73208
+ if (list) {
73209
+ list.push(entry);
73210
+ } else {
73211
+ lineMap.set(lineEl, [entry]);
73212
+ }
73213
+ }
73214
+ for (const [, lineEntries] of lineMap) {
73215
+ lineEntries.sort((a, b2) => a.pmStart - b2.pmStart !== 0 ? a.pmStart - b2.pmStart : a.pmEnd - b2.pmEnd);
73216
+ const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
73217
+ const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
73218
+ if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart) continue;
73219
+ const lineFrom = Math.max(sliceFrom, linePmStart);
73220
+ const lineTo = Math.min(sliceTo, linePmEnd);
73221
+ if (lineFrom >= lineTo) continue;
73222
+ const startEntry = lineEntries.find((entry) => lineFrom >= entry.pmStart && lineFrom <= entry.pmEnd) ?? lineEntries[0];
73223
+ const endEntry = lineEntries.find((entry) => lineTo >= entry.pmStart && lineTo <= entry.pmEnd) ?? lineEntries[lineEntries.length - 1];
73224
+ const range2 = doc2.createRange();
73225
+ try {
73226
+ if (!setDomRangeStart(range2, startEntry, lineFrom)) continue;
73227
+ if (!setDomRangeEnd(range2, endEntry, lineTo)) continue;
73228
+ } catch {
73229
+ continue;
73230
+ }
73231
+ rects.push(...Array.from(range2.getClientRects()));
73232
+ }
73233
+ for (const entry of looseEntries) {
73234
+ const entryFrom = Math.max(sliceFrom, entry.pmStart);
73235
+ const entryTo = Math.min(sliceTo, entry.pmEnd);
73236
+ if (entryFrom >= entryTo) continue;
73237
+ const range2 = doc2.createRange();
73238
+ try {
73239
+ if (!setDomRangeStart(range2, entry, entryFrom)) continue;
73240
+ if (!setDomRangeEnd(range2, entry, entryTo)) continue;
73241
+ } catch {
73242
+ continue;
73243
+ }
73244
+ rects.push(...Array.from(range2.getClientRects()));
73245
+ }
73246
+ return rects;
73247
+ }
72117
73248
  function setDomRangeStart(range2, entry, pos) {
72118
73249
  const el = entry.el;
72119
73250
  const pmStart = entry.pmStart;
@@ -72223,31 +73354,69 @@ function deduplicateOverlappingRects(rects) {
72223
73354
  return a.x - b2.x;
72224
73355
  });
72225
73356
  const result = [];
72226
- let i = 0;
72227
- while (i < sorted.length) {
72228
- const current = sorted[i];
72229
- let best = current;
72230
- let j2 = i + 1;
72231
- while (j2 < sorted.length) {
72232
- const next = sorted[j2];
72233
- const yOverlap = Math.abs(next.y - current.y) < Y_SAME_LINE_THRESHOLD_PX;
72234
- const xOverlapStart = Math.max(current.x, next.x);
72235
- const xOverlapEnd = Math.min(current.x + current.width, next.x + next.width);
72236
- const hasHorizontalOverlap = xOverlapEnd > xOverlapStart;
72237
- const overlapWidth = Math.max(0, xOverlapEnd - xOverlapStart);
72238
- const minWidth = Math.min(current.width, next.width);
72239
- const significantOverlap = minWidth > 0 && overlapWidth / minWidth > HORIZONTAL_OVERLAP_THRESHOLD;
72240
- if (yOverlap && hasHorizontalOverlap && significantOverlap) {
72241
- if (next.height < best.height) {
72242
- best = next;
72243
- }
72244
- j2++;
72245
- } else {
72246
- break;
73357
+ const groups = [];
73358
+ let currentGroup = [];
73359
+ for (const rect of sorted) {
73360
+ if (currentGroup.length === 0) {
73361
+ currentGroup.push(rect);
73362
+ continue;
73363
+ }
73364
+ const groupY = currentGroup[0].y;
73365
+ if (Math.abs(rect.y - groupY) <= Y_SAME_LINE_THRESHOLD_PX) {
73366
+ currentGroup.push(rect);
73367
+ } else {
73368
+ groups.push(currentGroup);
73369
+ currentGroup = [rect];
73370
+ }
73371
+ }
73372
+ if (currentGroup.length > 0) {
73373
+ groups.push(currentGroup);
73374
+ }
73375
+ const SIZE_EPS_PX = 0.5;
73376
+ const X_DUPLICATE_EPS_PX = 1;
73377
+ const hasSignificantOverlap = (a, b2) => {
73378
+ const xOverlapStart = Math.max(a.x, b2.x);
73379
+ const xOverlapEnd = Math.min(a.x + a.width, b2.x + b2.width);
73380
+ const hasHorizontalOverlap = xOverlapEnd > xOverlapStart;
73381
+ if (!hasHorizontalOverlap) return false;
73382
+ const overlapWidth = Math.max(0, xOverlapEnd - xOverlapStart);
73383
+ const minWidth = Math.min(a.width, b2.width);
73384
+ return minWidth > 0 && overlapWidth / minWidth > HORIZONTAL_OVERLAP_THRESHOLD;
73385
+ };
73386
+ const isLargerRect = (a, b2) => {
73387
+ return a.width > b2.width + SIZE_EPS_PX || a.height > b2.height + SIZE_EPS_PX;
73388
+ };
73389
+ for (const group of groups) {
73390
+ const unique2 = [];
73391
+ for (const rect of group) {
73392
+ const isDuplicate = unique2.some((existing) => {
73393
+ const xClose = Math.abs(existing.x - rect.x) <= X_DUPLICATE_EPS_PX;
73394
+ const yClose = Math.abs(existing.y - rect.y) <= Y_SAME_LINE_THRESHOLD_PX;
73395
+ const widthClose = Math.abs(existing.width - rect.width) <= SIZE_EPS_PX;
73396
+ const heightClose = Math.abs(existing.height - rect.height) <= SIZE_EPS_PX;
73397
+ return xClose && yClose && widthClose && heightClose;
73398
+ });
73399
+ if (!isDuplicate) {
73400
+ unique2.push(rect);
72247
73401
  }
72248
73402
  }
72249
- result.push(best);
72250
- i = j2;
73403
+ if (unique2.length <= 1) {
73404
+ result.push(...unique2);
73405
+ continue;
73406
+ }
73407
+ const containers = /* @__PURE__ */ new Set();
73408
+ for (const rect of unique2) {
73409
+ for (const other of unique2) {
73410
+ if (rect === other) continue;
73411
+ if (!hasSignificantOverlap(rect, other)) continue;
73412
+ if (isLargerRect(rect, other)) {
73413
+ containers.add(rect);
73414
+ break;
73415
+ }
73416
+ }
73417
+ }
73418
+ const filtered = unique2.filter((rect) => !containers.has(rect));
73419
+ result.push(...filtered.length > 0 ? filtered : unique2);
72251
73420
  }
72252
73421
  return result;
72253
73422
  }
@@ -72371,10 +73540,11 @@ function safeCleanup(fn2, context) {
72371
73540
  function createHiddenHost(doc2, widthPx) {
72372
73541
  const host = doc2.createElement("div");
72373
73542
  host.className = "presentation-editor__hidden-host";
72374
- host.style.position = "absolute";
73543
+ host.style.position = "fixed";
72375
73544
  host.style.left = "-9999px";
72376
73545
  host.style.top = "0";
72377
73546
  host.style.width = `${widthPx}px`;
73547
+ host.style.setProperty("overflow-anchor", "none");
72378
73548
  host.style.pointerEvents = "none";
72379
73549
  host.style.opacity = "0";
72380
73550
  host.style.zIndex = "-1";
@@ -72848,7 +74018,8 @@ function clickToPositionDom(domContainer, clientX, clientY) {
72848
74018
  });
72849
74019
  let hitChain = [];
72850
74020
  const doc2 = document;
72851
- if (typeof doc2.elementsFromPoint === "function") {
74021
+ const hasElementsFromPoint = typeof doc2.elementsFromPoint === "function";
74022
+ if (hasElementsFromPoint) {
72852
74023
  try {
72853
74024
  hitChain = doc2.elementsFromPoint(viewX, viewY) ?? [];
72854
74025
  } catch {
@@ -72894,11 +74065,14 @@ function clickToPositionDom(domContainer, clientX, clientY) {
72894
74065
  log("All fragments on page:", JSON.stringify(fragmentData, null, 2));
72895
74066
  const fragmentEl = hitChain.find((el) => el.classList?.contains?.(CLASS_NAMES.fragment));
72896
74067
  if (!fragmentEl) {
74068
+ if (hasElementsFromPoint) {
74069
+ return null;
74070
+ }
72897
74071
  const fallbackFragment = pageEl.querySelector(`.${CLASS_NAMES.fragment}`);
72898
74072
  if (!fallbackFragment) {
72899
74073
  return null;
72900
74074
  }
72901
- log("Using fallback fragment:", {
74075
+ log("Using fallback fragment (no elementsFromPoint):", {
72902
74076
  blockId: fallbackFragment.dataset.blockId,
72903
74077
  pmStart: fallbackFragment.dataset.pmStart,
72904
74078
  pmEnd: fallbackFragment.dataset.pmEnd
@@ -80509,9 +81683,9 @@ function getAtomNodeTypes(schema) {
80509
81683
  }
80510
81684
  return types2;
80511
81685
  }
80512
- const isObject$2 = (value) => typeof value === "object" && value !== null;
81686
+ const isObject$3 = (value) => typeof value === "object" && value !== null;
80513
81687
  function buildPositionMapFromPmDoc(pmDoc, jsonDoc) {
80514
- if (!pmDoc || !isObject$2(jsonDoc)) return null;
81688
+ if (!pmDoc || !isObject$3(jsonDoc)) return null;
80515
81689
  const map22 = /* @__PURE__ */ new WeakMap();
80516
81690
  const walk = (pmNode, jsonNode, pos, isDoc) => {
80517
81691
  const jsonType = jsonNode.type;
@@ -80532,7 +81706,7 @@ function buildPositionMapFromPmDoc(pmDoc, jsonDoc) {
80532
81706
  let ok2 = true;
80533
81707
  pmNode.forEach((child, offset2, index2) => {
80534
81708
  const jsonChild = jsonContent[index2];
80535
- if (!isObject$2(jsonChild)) {
81709
+ if (!isObject$3(jsonChild)) {
80536
81710
  ok2 = false;
80537
81711
  return;
80538
81712
  }
@@ -84936,13 +86110,13 @@ const inferBooleanFromParagraphElements = (paragraphProps, elementNames) => {
84936
86110
  (name) => name.startsWith("w:") ? [name, name.slice(2)] : [name, `w:${name}`]
84937
86111
  )
84938
86112
  );
84939
- const match = elements.find((el) => {
86113
+ const match2 = elements.find((el) => {
84940
86114
  if (!el || typeof el !== "object") return false;
84941
86115
  const name = el.name;
84942
86116
  return typeof name === "string" && normalizedTargets.has(name);
84943
86117
  });
84944
- if (!match) return void 0;
84945
- const rawVal = match.attributes?.["w:val"] ?? match.attributes?.val;
86118
+ if (!match2) return void 0;
86119
+ const rawVal = match2.attributes?.["w:val"] ?? match2.attributes?.val;
84946
86120
  if (rawVal == null) return true;
84947
86121
  if (isExplicitFalse(rawVal)) return false;
84948
86122
  if (isTruthy(rawVal)) return true;
@@ -86477,11 +87651,11 @@ const toPxNumber = (value) => {
86477
87651
  if (typeof raw === "number" && Number.isFinite(raw)) return raw;
86478
87652
  if (typeof raw !== "string") return void 0;
86479
87653
  const trimmed = raw.trim();
86480
- const match = trimmed.match(/^(-?\d+(\.\d+)?)([a-z%]*)$/i);
86481
- if (!match) return void 0;
86482
- const numeric = parseFloat(match[1]);
87654
+ const match2 = trimmed.match(/^(-?\d+(\.\d+)?)([a-z%]*)$/i);
87655
+ if (!match2) return void 0;
87656
+ const numeric = parseFloat(match2[1]);
86483
87657
  if (!Number.isFinite(numeric)) return void 0;
86484
- const unit = match[3]?.toLowerCase();
87658
+ const unit = match2[3]?.toLowerCase();
86485
87659
  if (!unit || unit === "px") return numeric;
86486
87660
  if (unit === "pt") return numeric * PT_TO_PX;
86487
87661
  return numeric;
@@ -90589,8 +91763,8 @@ async function measureParagraphBlock(block, maxWidth) {
90589
91763
  }
90590
91764
  }
90591
91765
  for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
90592
- const word = words[wordIndex];
90593
- if (word === "") {
91766
+ const word2 = words[wordIndex];
91767
+ if (word2 === "") {
90594
91768
  const spaceStartChar = charPosInRun;
90595
91769
  const spaceEndChar = charPosInRun + 1;
90596
91770
  const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
@@ -90644,15 +91818,15 @@ async function measureParagraphBlock(block, maxWidth) {
90644
91818
  charPosInRun = spaceEndChar;
90645
91819
  continue;
90646
91820
  }
90647
- const wordOnlyWidth = measureRunWidth(word, font, ctx2, run2);
91821
+ const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2);
90648
91822
  const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
90649
91823
  const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2) : 0;
90650
91824
  const wordCommitWidth = wordOnlyWidth + spaceWidth;
90651
91825
  const wordStartChar = charPosInRun;
90652
- const wordEndNoSpace = charPosInRun + word.length;
91826
+ const wordEndNoSpace = charPosInRun + word2.length;
90653
91827
  const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
90654
91828
  const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
90655
- if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
91829
+ if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
90656
91830
  if (currentLine && currentLine.width > 0 && currentLine.segments && currentLine.segments.length > 0) {
90657
91831
  trimTrailingWrapSpaces(currentLine);
90658
91832
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
@@ -90668,7 +91842,7 @@ async function measureParagraphBlock(block, maxWidth) {
90668
91842
  const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
90669
91843
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
90670
91844
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
90671
- const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
91845
+ const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
90672
91846
  let chunkCharOffset = wordStartChar;
90673
91847
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
90674
91848
  const chunk = chunks[chunkIndex];
@@ -91343,10 +92517,10 @@ const measureRunWidth = (text, font, ctx2, run2) => {
91343
92517
  const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
91344
92518
  return roundValue(width);
91345
92519
  };
91346
- const breakWordIntoChunks = (word, maxWidth, font, ctx2, run2) => {
92520
+ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
91347
92521
  const chunks = [];
91348
92522
  if (maxWidth <= 0) {
91349
- for (const char of word) {
92523
+ for (const char of word2) {
91350
92524
  const charWidth = measureRunWidth(char, font, ctx2, run2);
91351
92525
  chunks.push({ text: char, width: charWidth });
91352
92526
  }
@@ -91354,8 +92528,8 @@ const breakWordIntoChunks = (word, maxWidth, font, ctx2, run2) => {
91354
92528
  }
91355
92529
  let currentChunk = "";
91356
92530
  let currentWidth = 0;
91357
- for (let i = 0; i < word.length; i++) {
91358
- const char = word[i];
92531
+ for (let i = 0; i < word2.length; i++) {
92532
+ const char = word2[i];
91359
92533
  const testChunk = currentChunk + char;
91360
92534
  const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
91361
92535
  if (testWidth > maxWidth && currentChunk.length > 0) {
@@ -91928,6 +93102,25 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
91928
93102
  } else {
91929
93103
  __privateSet(this, _dragExtensionMode, "char");
91930
93104
  }
93105
+ debugLog(
93106
+ "verbose",
93107
+ `Drag selection start ${JSON.stringify({
93108
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: x2, y: y2 },
93109
+ clickDepth,
93110
+ extensionMode: __privateGet$1(this, _dragExtensionMode),
93111
+ anchor: __privateGet$1(this, _dragAnchor),
93112
+ anchorPageIndex: __privateGet$1(this, _dragAnchorPageIndex),
93113
+ rawHit: rawHit ? {
93114
+ pos: rawHit.pos,
93115
+ pageIndex: rawHit.pageIndex,
93116
+ blockId: rawHit.blockId,
93117
+ lineIndex: rawHit.lineIndex,
93118
+ layoutEpoch: rawHit.layoutEpoch
93119
+ } : null,
93120
+ mapped: mapped ? mapped.ok ? { ok: true, pos: mapped.pos, fromEpoch: mapped.fromEpoch, toEpoch: mapped.toEpoch } : { ok: false, reason: mapped.reason, fromEpoch: mapped.fromEpoch, toEpoch: mapped.toEpoch } : null,
93121
+ hit: hit ? { pos: hit.pos, pageIndex: hit.pageIndex, layoutEpoch: hit.layoutEpoch } : null
93122
+ })}`
93123
+ );
91931
93124
  if (typeof __privateGet$1(this, _viewportHost).setPointerCapture === "function") {
91932
93125
  __privateGet$1(this, _viewportHost).setPointerCapture(event.pointerId);
91933
93126
  }
@@ -91964,6 +93157,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
91964
93157
  if (!normalized) return;
91965
93158
  if (__privateGet$1(this, _isDragging) && __privateGet$1(this, _dragAnchor) !== null && event.buttons & 1) {
91966
93159
  __privateSet(this, _pendingMarginClick, null);
93160
+ const prevPointer = __privateGet$1(this, _dragLastPointer);
93161
+ const prevRawHit = __privateGet$1(this, _dragLastRawHit);
91967
93162
  __privateSet(this, _dragLastPointer, { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y });
91968
93163
  const rawHit = clickToPosition(
91969
93164
  __privateGet$1(this, _layoutState).layout,
@@ -91975,7 +93170,17 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
91975
93170
  event.clientY,
91976
93171
  __privateGet$1(this, _pageGeometryHelper) ?? void 0
91977
93172
  );
91978
- if (!rawHit) return;
93173
+ if (!rawHit) {
93174
+ debugLog(
93175
+ "verbose",
93176
+ `Drag selection update (no hit) ${JSON.stringify({
93177
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
93178
+ prevPointer,
93179
+ anchor: __privateGet$1(this, _dragAnchor)
93180
+ })}`
93181
+ );
93182
+ return;
93183
+ }
91979
93184
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
91980
93185
  if (!doc22) return;
91981
93186
  __privateSet(this, _dragLastRawHit, rawHit);
@@ -91988,6 +93193,27 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
91988
93193
  const mappedHead = __privateGet$1(this, _epochMapper).mapPosFromLayoutToCurrentDetailed(rawHit.pos, rawHit.layoutEpoch, 1);
91989
93194
  if (!mappedHead.ok) {
91990
93195
  debugLog("warn", "drag mapping failed", mappedHead);
93196
+ debugLog(
93197
+ "verbose",
93198
+ `Drag selection update (map failed) ${JSON.stringify({
93199
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
93200
+ prevPointer,
93201
+ anchor: __privateGet$1(this, _dragAnchor),
93202
+ rawHit: {
93203
+ pos: rawHit.pos,
93204
+ pageIndex: rawHit.pageIndex,
93205
+ blockId: rawHit.blockId,
93206
+ lineIndex: rawHit.lineIndex,
93207
+ layoutEpoch: rawHit.layoutEpoch
93208
+ },
93209
+ mapped: {
93210
+ ok: false,
93211
+ reason: mappedHead.reason,
93212
+ fromEpoch: mappedHead.fromEpoch,
93213
+ toEpoch: mappedHead.toEpoch
93214
+ }
93215
+ })}`
93216
+ );
91991
93217
  return;
91992
93218
  }
91993
93219
  const hit = {
@@ -92002,6 +93228,41 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
92002
93228
  mappedPos: hit.pos
92003
93229
  });
92004
93230
  __privateMethod$1(this, _PresentationEditor_instances, updateSelectionDebugHud_fn).call(this);
93231
+ const anchor = __privateGet$1(this, _dragAnchor);
93232
+ const head = hit.pos;
93233
+ const { selAnchor, selHead } = __privateMethod$1(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet$1(this, _dragExtensionMode));
93234
+ debugLog(
93235
+ "verbose",
93236
+ `Drag selection update ${JSON.stringify({
93237
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
93238
+ prevPointer,
93239
+ rawHit: {
93240
+ pos: rawHit.pos,
93241
+ pageIndex: rawHit.pageIndex,
93242
+ blockId: rawHit.blockId,
93243
+ lineIndex: rawHit.lineIndex,
93244
+ layoutEpoch: rawHit.layoutEpoch
93245
+ },
93246
+ prevRawHit: prevRawHit ? {
93247
+ pos: prevRawHit.pos,
93248
+ pageIndex: prevRawHit.pageIndex,
93249
+ blockId: prevRawHit.blockId,
93250
+ lineIndex: prevRawHit.lineIndex,
93251
+ layoutEpoch: prevRawHit.layoutEpoch
93252
+ } : null,
93253
+ mappedHead: { pos: mappedHead.pos, fromEpoch: mappedHead.fromEpoch, toEpoch: mappedHead.toEpoch },
93254
+ hit: { pos: hit.pos, pageIndex: hit.pageIndex, layoutEpoch: hit.layoutEpoch },
93255
+ anchor,
93256
+ head,
93257
+ selAnchor,
93258
+ selHead,
93259
+ direction: head >= anchor ? "down" : "up",
93260
+ selectionDirection: selHead >= selAnchor ? "down" : "up",
93261
+ extensionMode: __privateGet$1(this, _dragExtensionMode),
93262
+ hitSource: pageMounted ? "dom" : "geometry",
93263
+ pageMounted
93264
+ })}`
93265
+ );
92005
93266
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
92006
93267
  const shouldUseCellSel = __privateMethod$1(this, _PresentationEditor_instances, shouldUseCellSelection_fn).call(this, currentTableHit);
92007
93268
  if (shouldUseCellSel && __privateGet$1(this, _cellAnchor)) {
@@ -92036,9 +93297,6 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
92036
93297
  return;
92037
93298
  }
92038
93299
  }
92039
- const anchor = __privateGet$1(this, _dragAnchor);
92040
- const head = hit.pos;
92041
- const { selAnchor, selHead } = __privateMethod$1(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet$1(this, _dragExtensionMode));
92042
93300
  try {
92043
93301
  const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, selAnchor, selHead));
92044
93302
  __privateGet$1(this, _editor3).view?.dispatch(tr);
@@ -92433,6 +93691,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
92433
93691
  editorProps: normalizedEditorProps,
92434
93692
  documentMode: __privateGet$1(this, _documentMode)
92435
93693
  }));
93694
+ __privateMethod$1(this, _PresentationEditor_instances, wrapHiddenEditorFocus_fn).call(this);
92436
93695
  __privateGet$1(this, _editor3).presentationEditor = this;
92437
93696
  __privateGet$1(this, _editor3)._presentationEditor = this;
92438
93697
  __privateMethod$1(this, _PresentationEditor_instances, syncHiddenEditorA11yAttributes_fn).call(this);
@@ -93632,6 +94891,65 @@ _scrollTimeout = /* @__PURE__ */ new WeakMap();
93632
94891
  _lastRemoteCursorRenderTime = /* @__PURE__ */ new WeakMap();
93633
94892
  _remoteCursorThrottleTimeout = /* @__PURE__ */ new WeakMap();
93634
94893
  _PresentationEditor_instances = /* @__PURE__ */ new WeakSet();
94894
+ wrapHiddenEditorFocus_fn = function() {
94895
+ const view = __privateGet$1(this, _editor3)?.view;
94896
+ if (!view || !view.dom || typeof view.focus !== "function") {
94897
+ return;
94898
+ }
94899
+ const viewWithFlag = view;
94900
+ if (viewWithFlag.__sdPreventScrollFocus) {
94901
+ return;
94902
+ }
94903
+ const focusFn = view.focus;
94904
+ if (focusFn.mock) {
94905
+ return;
94906
+ }
94907
+ viewWithFlag.__sdPreventScrollFocus = true;
94908
+ const originalFocus = view.focus.bind(view);
94909
+ view.focus = () => {
94910
+ const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView;
94911
+ if (!win) {
94912
+ originalFocus();
94913
+ return;
94914
+ }
94915
+ const beforeX = win.scrollX;
94916
+ const beforeY = win.scrollY;
94917
+ let focused = false;
94918
+ try {
94919
+ view.dom.focus({ preventScroll: true });
94920
+ focused = true;
94921
+ } catch (error) {
94922
+ debugLog("warn", "Hidden editor focus: preventScroll failed", {
94923
+ error: String(error),
94924
+ strategy: "preventScroll"
94925
+ });
94926
+ }
94927
+ if (!focused) {
94928
+ try {
94929
+ view.dom.focus();
94930
+ focused = true;
94931
+ } catch (error) {
94932
+ debugLog("warn", "Hidden editor focus: standard focus failed", {
94933
+ error: String(error),
94934
+ strategy: "standard"
94935
+ });
94936
+ }
94937
+ }
94938
+ if (!focused) {
94939
+ try {
94940
+ originalFocus();
94941
+ } catch (error) {
94942
+ debugLog("error", "Hidden editor focus: all strategies failed", {
94943
+ error: String(error),
94944
+ strategy: "original"
94945
+ });
94946
+ }
94947
+ }
94948
+ if (win.scrollX !== beforeX || win.scrollY !== beforeY) {
94949
+ win.scrollTo(beforeX, beforeY);
94950
+ }
94951
+ };
94952
+ };
93635
94953
  collectCommentPositions_fn = function() {
93636
94954
  return collectCommentPositions(__privateGet$1(this, _editor3)?.state?.doc ?? null, {
93637
94955
  commentMarkName: CommentMarkName,
@@ -95146,8 +96464,8 @@ resolveDescriptorForRegion_fn = function(region) {
95146
96464
  }
95147
96465
  if (region.sectionType) {
95148
96466
  const descriptors2 = __privateGet$1(this, _headerFooterManager).getDescriptors(region.kind);
95149
- const match = descriptors2.find((entry) => entry.variant === region.sectionType);
95150
- if (match) return match;
96467
+ const match2 = descriptors2.find((entry) => entry.variant === region.sectionType);
96468
+ if (match2) return match2;
95151
96469
  }
95152
96470
  const descriptors = __privateGet$1(this, _headerFooterManager).getDescriptors(region.kind);
95153
96471
  if (!descriptors.length) {
@@ -98389,7 +99707,7 @@ const Document = Node$1.create({
98389
99707
  */
98390
99708
  getDocumentStats: () => ({ editor }) => {
98391
99709
  const text = editor.getText();
98392
- const words = text.split(/\s+/).filter((word) => word.length > 0).length;
99710
+ const words = text.split(/\s+/).filter((word2) => word2.length > 0).length;
98393
99711
  const characters = text.length;
98394
99712
  const paragraphs = editor.state.doc.content.childCount;
98395
99713
  return {
@@ -98505,9 +99823,9 @@ const buildWrapTransaction = (state2, ranges, runType) => {
98505
99823
  ranges.forEach(({ from: from2, to }) => {
98506
99824
  state2.doc.nodesBetween(from2, to, (node, pos, parent, index2) => {
98507
99825
  if (!node.isText || !parent || parent.type === runType) return;
98508
- const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
98509
- if (match && !match.matchType(runType)) return;
98510
- if (!match && !parent.type.contentMatch.matchType(runType)) return;
99826
+ const match2 = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
99827
+ if (match2 && !match2.matchType(runType)) return;
99828
+ if (!match2 && !parent.type.contentMatch.matchType(runType)) return;
98511
99829
  const runProperties = decodeRPrFromMarks(node.marks);
98512
99830
  const runNode = runType.create({ runProperties }, node);
98513
99831
  replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
@@ -101204,8 +102522,8 @@ const Table = Node$1.create({
101204
102522
  let resolvedTablePos = tablePos;
101205
102523
  if (typeof resolvedTablePos !== "number" && workingTable) {
101206
102524
  const tables = editor.getNodesOfType("table");
101207
- const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
101208
- resolvedTablePos = match?.pos ?? null;
102525
+ const match2 = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
102526
+ resolvedTablePos = match2?.pos ?? null;
101209
102527
  }
101210
102528
  if (typeof resolvedTablePos !== "number") {
101211
102529
  return false;
@@ -112192,8 +113510,8 @@ class Popover {
112192
113510
  if (from2 < 1) return false;
112193
113511
  const textBefore = this.getMentionText(from2);
112194
113512
  const mentionPattern = /(?:^|\s)@[\w]*$/;
112195
- const match = textBefore.match(mentionPattern);
112196
- return match && this.state.selection.empty;
113513
+ const match2 = textBefore.match(mentionPattern);
113514
+ return match2 && this.state.selection.empty;
112197
113515
  }
112198
113516
  destroy() {
112199
113517
  this.tippyInstance.destroy();
@@ -112271,8 +113589,8 @@ class SearchQuery {
112271
113589
  let $from = state2.doc.resolve(result.from);
112272
113590
  let marks = $from.marksAcross(state2.doc.resolve(result.to));
112273
113591
  let ranges = [];
112274
- let frag = Fragment.empty, pos = result.from, { match } = result;
112275
- let groups = match ? getGroupIndices(match) : [[0, result.to - result.from]];
113592
+ let frag = Fragment.empty, pos = result.from, { match: match2 } = result;
113593
+ let groups = match2 ? getGroupIndices(match2) : [[0, result.to - result.from]];
112276
113594
  let replParts = parseReplacement(this.unquote(this.replace));
112277
113595
  for (let part of replParts) {
112278
113596
  if (typeof part == "string") {
@@ -112350,39 +113668,39 @@ class RegExpQuery {
112350
113668
  return scanTextblocks(state2.doc, from2, to, (node, start2) => {
112351
113669
  let content = textContent(node).slice(0, Math.min(node.content.size, to - start2));
112352
113670
  this.regexp.lastIndex = from2 - start2;
112353
- let match = this.regexp.exec(content);
112354
- if (!match) return null;
112355
- const absoluteIndex = match.index;
113671
+ let match2 = this.regexp.exec(content);
113672
+ if (!match2) return null;
113673
+ const absoluteIndex = match2.index;
112356
113674
  const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
112357
- const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
112358
- return { from: fromPos, to: toPos, match, matchStart: start2 };
113675
+ const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match2[0].length);
113676
+ return { from: fromPos, to: toPos, match: match2, matchStart: start2 };
112359
113677
  });
112360
113678
  }
112361
113679
  findPrev(state2, from2, to) {
112362
113680
  return scanTextblocks(state2.doc, from2, to, (node, start2) => {
112363
113681
  let content = textContent(node).slice(0, Math.min(node.content.size, from2 - start2));
112364
- let match;
113682
+ let match2;
112365
113683
  for (let off2 = 0; ; ) {
112366
113684
  this.regexp.lastIndex = off2;
112367
113685
  let next = this.regexp.exec(content);
112368
113686
  if (!next) break;
112369
- match = next;
113687
+ match2 = next;
112370
113688
  off2 = next.index + 1;
112371
113689
  }
112372
- if (!match) return null;
112373
- const absoluteIndex = match.index;
113690
+ if (!match2) return null;
113691
+ const absoluteIndex = match2.index;
112374
113692
  const fromPos = mapIndexToDocPos(node, start2, absoluteIndex);
112375
- const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match[0].length);
112376
- return { from: fromPos, to: toPos, match, matchStart: start2 };
113693
+ const toPos = mapIndexToDocPos(node, start2, absoluteIndex + match2[0].length);
113694
+ return { from: fromPos, to: toPos, match: match2, matchStart: start2 };
112377
113695
  });
112378
113696
  }
112379
113697
  }
112380
- function getGroupIndices(match) {
112381
- if (match.indices) return match.indices;
112382
- let result = [[0, match[0].length]];
112383
- for (let i = 1, pos = 0; i < match.length; i++) {
112384
- let found2 = match[i] ? match[0].indexOf(match[i], pos) : -1;
112385
- result.push(found2 < 0 ? void 0 : [found2, pos = found2 + match[i].length]);
113698
+ function getGroupIndices(match2) {
113699
+ if (match2.indices) return match2.indices;
113700
+ let result = [[0, match2[0].length]];
113701
+ for (let i = 1, pos = 0; i < match2.length; i++) {
113702
+ let found2 = match2[i] ? match2[0].indexOf(match2[i], pos) : -1;
113703
+ result.push(found2 < 0 ? void 0 : [found2, pos = found2 + match2[i].length]);
112386
113704
  }
112387
113705
  return result;
112388
113706
  }
@@ -112624,8 +113942,8 @@ const Search = Extension.create({
112624
113942
  const matches2 = storage?.searchResults;
112625
113943
  if (!matches2?.length) return null;
112626
113944
  const decorations = matches2.map(
112627
- (match) => Decoration.inline(match.from, match.to, {
112628
- id: `search-match-${match.id}`
113945
+ (match2) => Decoration.inline(match2.from, match2.to, {
113946
+ id: `search-match-${match2.id}`
112629
113947
  })
112630
113948
  );
112631
113949
  return DecorationSet.create(state2.doc, decorations);
@@ -112729,10 +114047,10 @@ const Search = Extension.create({
112729
114047
  * editor.commands.goToSearchResult(searchResults[3])
112730
114048
  * @note Scrolls to match and selects it
112731
114049
  */
112732
- goToSearchResult: (match) => (
114050
+ goToSearchResult: (match2) => (
112733
114051
  /** @returns {boolean} */
112734
114052
  (({ state: state2, dispatch, editor }) => {
112735
- const { from: from2, to } = match;
114053
+ const { from: from2, to } = match2;
112736
114054
  editor.view.focus();
112737
114055
  const tr = state2.tr.setSelection(TextSelection$1.create(state2.doc, from2, to)).scrollIntoView();
112738
114056
  dispatch(tr);
@@ -113472,7 +114790,7 @@ function isMediaOrSupports(selector) {
113472
114790
  }
113473
114791
  const kebabRegex = /[A-Z]/g;
113474
114792
  function kebabCase(pattern) {
113475
- return pattern.replace(kebabRegex, (match) => "-" + match.toLowerCase());
114793
+ return pattern.replace(kebabRegex, (match2) => "-" + match2.toLowerCase());
113476
114794
  }
113477
114795
  function unwrapProperty(prop, indent = " ") {
113478
114796
  if (typeof prop === "object" && prop !== null) {
@@ -113546,16 +114864,16 @@ function loopCNodeListWithCallback(children, options, callback) {
113546
114864
  });
113547
114865
  }
113548
114866
  function traverseCNode(node, selectorPaths, styles, instance, params2) {
113549
- const $2 = node.$;
114867
+ const $3 = node.$;
113550
114868
  let blockSelector = "";
113551
- if (!$2 || typeof $2 === "string") {
113552
- if (isMediaOrSupports($2)) {
113553
- blockSelector = $2;
114869
+ if (!$3 || typeof $3 === "string") {
114870
+ if (isMediaOrSupports($3)) {
114871
+ blockSelector = $3;
113554
114872
  } else {
113555
- selectorPaths.push($2);
114873
+ selectorPaths.push($3);
113556
114874
  }
113557
- } else if (typeof $2 === "function") {
113558
- const selector2 = $2({
114875
+ } else if (typeof $3 === "function") {
114876
+ const selector2 = $3({
113559
114877
  context: instance.context,
113560
114878
  props: params2
113561
114879
  });
@@ -113565,16 +114883,16 @@ function traverseCNode(node, selectorPaths, styles, instance, params2) {
113565
114883
  selectorPaths.push(selector2);
113566
114884
  }
113567
114885
  } else {
113568
- if ($2.before)
113569
- $2.before(instance.context);
113570
- if (!$2.$ || typeof $2.$ === "string") {
113571
- if (isMediaOrSupports($2.$)) {
113572
- blockSelector = $2.$;
114886
+ if ($3.before)
114887
+ $3.before(instance.context);
114888
+ if (!$3.$ || typeof $3.$ === "string") {
114889
+ if (isMediaOrSupports($3.$)) {
114890
+ blockSelector = $3.$;
113573
114891
  } else {
113574
- selectorPaths.push($2.$);
114892
+ selectorPaths.push($3.$);
113575
114893
  }
113576
- } else if ($2.$) {
113577
- const selector2 = $2.$({
114894
+ } else if ($3.$) {
114895
+ const selector2 = $3.$({
113578
114896
  context: instance.context,
113579
114897
  props: params2
113580
114898
  });
@@ -113609,8 +114927,8 @@ function traverseCNode(node, selectorPaths, styles, instance, params2) {
113609
114927
  if (blockSelector) {
113610
114928
  styles.push("}");
113611
114929
  }
113612
- if ($2 && $2.after)
113613
- $2.after(instance.context);
114930
+ if ($3 && $3.after)
114931
+ $3.after(instance.context);
113614
114932
  }
113615
114933
  function render$1(node, instance, props) {
113616
114934
  const styles = [];
@@ -113715,10 +115033,10 @@ function wrappedUnmount(options = {}) {
113715
115033
  const { id, parent } = options;
113716
115034
  unmount(this.instance, this, id, parent);
113717
115035
  }
113718
- const createCNode = function(instance, $2, props, children) {
115036
+ const createCNode = function(instance, $3, props, children) {
113719
115037
  return {
113720
115038
  instance,
113721
- $: $2,
115039
+ $: $3,
113722
115040
  props,
113723
115041
  children,
113724
115042
  els: [],
@@ -113727,15 +115045,15 @@ const createCNode = function(instance, $2, props, children) {
113727
115045
  unmount: wrappedUnmount
113728
115046
  };
113729
115047
  };
113730
- const c$2 = function(instance, $2, props, children) {
113731
- if (Array.isArray($2)) {
113732
- return createCNode(instance, { $: null }, null, $2);
115048
+ const c$2 = function(instance, $3, props, children) {
115049
+ if (Array.isArray($3)) {
115050
+ return createCNode(instance, { $: null }, null, $3);
113733
115051
  } else if (Array.isArray(props)) {
113734
- return createCNode(instance, $2, null, props);
115052
+ return createCNode(instance, $3, null, props);
113735
115053
  } else if (Array.isArray(children)) {
113736
- return createCNode(instance, $2, props, children);
115054
+ return createCNode(instance, $3, props, children);
113737
115055
  } else {
113738
- return createCNode(instance, $2, props, null);
115056
+ return createCNode(instance, $3, props, null);
113739
115057
  }
113740
115058
  };
113741
115059
  function CssRender(config2 = {}) {
@@ -117584,8 +118902,8 @@ var stringToPath = memoizeCapped(function(string) {
117584
118902
  if (string.charCodeAt(0) === 46) {
117585
118903
  result.push("");
117586
118904
  }
117587
- string.replace(rePropName, function(match, number, quote, subString) {
117588
- result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
118905
+ string.replace(rePropName, function(match2, number, quote, subString) {
118906
+ result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match2);
117589
118907
  });
117590
118908
  return result;
117591
118909
  });
@@ -123584,9 +124902,9 @@ async function processStream(stream, onChunk, onDone) {
123584
124902
  function getJsonBetweenFencesFromResponse(buffer2) {
123585
124903
  try {
123586
124904
  const jsonRegex = /```json\s*\n([\s\S]*?)\n\s*```/;
123587
- const match = buffer2.match(jsonRegex);
123588
- if (match && match[1]) {
123589
- const jsonObj = JSON.parse(match[1]);
124905
+ const match2 = buffer2.match(jsonRegex);
124906
+ if (match2 && match2[1]) {
124907
+ const jsonObj = JSON.parse(match2[1]);
123590
124908
  if (jsonObj.custom_prompt && jsonObj.custom_prompt.value !== void 0) {
123591
124909
  return jsonObj.custom_prompt.value || "";
123592
124910
  }
@@ -123678,19 +124996,19 @@ function formatDocument(editor) {
123678
124996
  formatRegistry.rules.forEach((rule) => {
123679
124997
  rule.pattern.lastIndex = 0;
123680
124998
  const matches2 = [];
123681
- let match;
123682
- while ((match = rule.pattern.exec(docText)) !== null) {
124999
+ let match2;
125000
+ while ((match2 = rule.pattern.exec(docText)) !== null) {
123683
125001
  matches2.push({
123684
125002
  rule,
123685
- startPos: match.index,
123686
- endPos: match.index + match[0].length,
123687
- originalText: match[0],
123688
- contentText: match[1]
125003
+ startPos: match2.index,
125004
+ endPos: match2.index + match2[0].length,
125005
+ originalText: match2[0],
125006
+ contentText: match2[1]
123689
125007
  });
123690
125008
  }
123691
125009
  matches2.sort((a, b2) => b2.startPos - a.startPos);
123692
- for (const match2 of matches2) {
123693
- const { startPos, endPos, originalText, contentText } = match2;
125010
+ for (const match22 of matches2) {
125011
+ const { startPos, endPos, originalText, contentText } = match22;
123694
125012
  try {
123695
125013
  let tr = editor.state.tr;
123696
125014
  const replacement = rule.transform(originalText, contentText, editor);