ryugi-artifacts 1.7.4 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.cjs CHANGED
@@ -95,13 +95,13 @@ var require_CSSStyleRule = __commonJS({
95
95
  CSSOM.CSSStyleRule.prototype.type = 1;
96
96
  Object.defineProperty(CSSOM.CSSStyleRule.prototype, "cssText", {
97
97
  get: function() {
98
- var text;
98
+ var text2;
99
99
  if (this.selectorText) {
100
- text = this.selectorText + " {" + this.style.cssText + "}";
100
+ text2 = this.selectorText + " {" + this.style.cssText + "}";
101
101
  } else {
102
- text = "";
102
+ text2 = "";
103
103
  }
104
- return text;
104
+ return text2;
105
105
  },
106
106
  set: function(cssText) {
107
107
  var rule = CSSOM.CSSStyleRule.parse(cssText);
@@ -659,9 +659,9 @@ var require_CSSValue = __commonJS({
659
659
  CSSOM.CSSValue.prototype = {
660
660
  constructor: CSSOM.CSSValue,
661
661
  // @see: http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSValue
662
- set cssText(text) {
662
+ set cssText(text2) {
663
663
  var name = this._getConstructorName();
664
- throw new Error('DOMException: property "cssText" of "' + name + '" is readonly and can not be replaced with "' + text + '"!');
664
+ throw new Error('DOMException: property "cssText" of "' + name + '" is readonly and can not be replaced with "' + text2 + '"!');
665
665
  },
666
666
  get cssText() {
667
667
  var name = this._getConstructorName();
@@ -755,7 +755,7 @@ var require_CSSValueExpression = __commonJS({
755
755
  return ret;
756
756
  };
757
757
  CSSOM.CSSValueExpression.prototype._parseJSComment = function(token, idx) {
758
- var nextChar = token.charAt(idx + 1), text;
758
+ var nextChar = token.charAt(idx + 1), text2;
759
759
  if (nextChar === "/" || nextChar === "*") {
760
760
  var startIdx = idx, endIdx, commentEndChar;
761
761
  if (nextChar === "/") {
@@ -766,10 +766,10 @@ var require_CSSValueExpression = __commonJS({
766
766
  endIdx = token.indexOf(commentEndChar, startIdx + 1 + 1);
767
767
  if (endIdx !== -1) {
768
768
  endIdx = endIdx + commentEndChar.length - 1;
769
- text = token.substring(idx, endIdx + 1);
769
+ text2 = token.substring(idx, endIdx + 1);
770
770
  return {
771
771
  idx: endIdx,
772
- text
772
+ text: text2
773
773
  };
774
774
  } else {
775
775
  var error = "css expression error: unfinished comment in expression!";
@@ -782,14 +782,14 @@ var require_CSSValueExpression = __commonJS({
782
782
  }
783
783
  };
784
784
  CSSOM.CSSValueExpression.prototype._parseJSString = function(token, idx, sep) {
785
- var endIdx = this._findMatchedIdx(token, idx, sep), text;
785
+ var endIdx = this._findMatchedIdx(token, idx, sep), text2;
786
786
  if (endIdx === -1) {
787
787
  return false;
788
788
  } else {
789
- text = token.substring(idx, endIdx + sep.length);
789
+ text2 = token.substring(idx, endIdx + sep.length);
790
790
  return {
791
791
  idx: endIdx,
792
- text
792
+ text: text2
793
793
  };
794
794
  }
795
795
  };
@@ -839,7 +839,7 @@ var require_CSSValueExpression = __commonJS({
839
839
  endIdx = NOT_FOUND;
840
840
  break;
841
841
  } else {
842
- var text = token.substring(idx + 1, endIdx), matched = text.match(/\\+$/);
842
+ var text2 = token.substring(idx + 1, endIdx), matched = text2.match(/\\+$/);
843
843
  if (!matched || matched[0] % 2 === 0) {
844
844
  break;
845
845
  } else {
@@ -1424,7 +1424,7 @@ var require_CSSStyleDeclaration = __commonJS({
1424
1424
  }
1425
1425
  return properties.join(" ");
1426
1426
  },
1427
- set cssText(text) {
1427
+ set cssText(text2) {
1428
1428
  var i6, name;
1429
1429
  for (i6 = this.length; i6--; ) {
1430
1430
  name = this[i6];
@@ -1432,7 +1432,7 @@ var require_CSSStyleDeclaration = __commonJS({
1432
1432
  }
1433
1433
  Array.prototype.splice.call(this, 0, this.length);
1434
1434
  this._importants = {};
1435
- var dummyRule = CSSOM.parse("#bogus{" + text + "}").cssRules[0].style;
1435
+ var dummyRule = CSSOM.parse("#bogus{" + text2 + "}").cssRules[0].style;
1436
1436
  var length = dummyRule.length;
1437
1437
  for (i6 = 0; i6 < length; ++i6) {
1438
1438
  name = dummyRule[i6];
@@ -1563,14 +1563,14 @@ var require_canvas = __commonJS({
1563
1563
 
1564
1564
  // src/server/main.ts
1565
1565
  var import_node_child_process = require("node:child_process");
1566
- var import_node_fs17 = __toESM(require("node:fs"), 1);
1566
+ var import_node_fs18 = __toESM(require("node:fs"), 1);
1567
1567
  var import_node_os = __toESM(require("node:os"), 1);
1568
- var import_node_path16 = __toESM(require("node:path"), 1);
1568
+ var import_node_path17 = __toESM(require("node:path"), 1);
1569
1569
 
1570
1570
  // src/server/app.ts
1571
- var import_node_fs15 = __toESM(require("node:fs"), 1);
1571
+ var import_node_fs16 = __toESM(require("node:fs"), 1);
1572
1572
  var import_node_http = __toESM(require("node:http"), 1);
1573
- var import_node_path15 = __toESM(require("node:path"), 1);
1573
+ var import_node_path16 = __toESM(require("node:path"), 1);
1574
1574
 
1575
1575
  // src/shared/types.ts
1576
1576
  var ARTIFACT_TYPES = ["artboard", "document", "html"];
@@ -1744,8 +1744,8 @@ function nanoid(size = 21) {
1744
1744
  // src/shared/comments.ts
1745
1745
  var emptyComments = () => ({ version: 1, threads: [] });
1746
1746
  var isObject = (value) => typeof value === "object" && value !== null;
1747
- function parseComments(text) {
1748
- const raw = JSON.parse(text);
1747
+ function parseComments(text2) {
1748
+ const raw = JSON.parse(text2);
1749
1749
  if (!isObject(raw)) throw new Error("comments.json must be an object");
1750
1750
  if (!Array.isArray(raw.threads)) throw new Error("threads must be an array");
1751
1751
  raw.threads.forEach((thread, i6) => {
@@ -1874,13 +1874,13 @@ var STICKY_FONT_SIZE = 18;
1874
1874
  var STICKY_LINE_H = 27;
1875
1875
  var STICKY_PAD = 16;
1876
1876
  var isWide = (code) => code >= 11904;
1877
- function textWidth(text, fontSize) {
1877
+ function textWidth(text2, fontSize) {
1878
1878
  let width = 0;
1879
- for (const char of text) width += fontSize * (isWide(char.codePointAt(0)) ? 1 : 0.56);
1879
+ for (const char of text2) width += fontSize * (isWide(char.codePointAt(0)) ? 1 : 0.56);
1880
1880
  return width;
1881
1881
  }
1882
- function wrappedLines(text, fontSize, maxWidth) {
1883
- return text.split("\n").reduce((lines, paragraph) => lines + Math.max(1, Math.ceil(textWidth(paragraph, fontSize) / maxWidth)), 0);
1882
+ function wrappedLines(text2, fontSize, maxWidth) {
1883
+ return text2.split("\n").reduce((lines, paragraph) => lines + Math.max(1, Math.ceil(textWidth(paragraph, fontSize) / maxWidth)), 0);
1884
1884
  }
1885
1885
  function groupFrame(group, boards) {
1886
1886
  const members = group.boards.map((id2) => boards[id2]).filter((b6) => Boolean(b6));
@@ -2108,14 +2108,14 @@ var resolveHtmlFile = (artifactDir, relative) => resolveFileWithin(artifactDir,
2108
2108
 
2109
2109
  // src/server/state.ts
2110
2110
  function readRaw(boardDir) {
2111
- let text;
2111
+ let text2;
2112
2112
  try {
2113
- text = import_node_fs5.default.readFileSync(import_node_path5.default.join(boardDir, "canvas.json"), "utf8");
2113
+ text2 = import_node_fs5.default.readFileSync(import_node_path5.default.join(boardDir, "canvas.json"), "utf8");
2114
2114
  } catch {
2115
2115
  return { warning: "canvas.json not found" };
2116
2116
  }
2117
2117
  try {
2118
- return { raw: JSON.parse(text) };
2118
+ return { raw: JSON.parse(text2) };
2119
2119
  } catch (err) {
2120
2120
  return { warning: `canvas.json is not valid JSON: ${err.message}` };
2121
2121
  }
@@ -2217,20 +2217,20 @@ function createCommentStore(file, now = () => (/* @__PURE__ */ new Date()).toISO
2217
2217
  lastSeen = import_node_fs6.default.readFileSync(file, "utf8");
2218
2218
  };
2219
2219
  const sync = () => {
2220
- let text;
2220
+ let text2;
2221
2221
  try {
2222
- text = import_node_fs6.default.readFileSync(file, "utf8");
2222
+ text2 = import_node_fs6.default.readFileSync(file, "utf8");
2223
2223
  } catch {
2224
2224
  return false;
2225
2225
  }
2226
- if (text === lastSeen) return false;
2227
- lastSeen = text;
2226
+ if (text2 === lastSeen) return false;
2227
+ lastSeen = text2;
2228
2228
  try {
2229
- const merged = mergeComments(current, parseComments(text), "agent", now(), newId);
2229
+ const merged = mergeComments(current, parseComments(text2), "agent", now(), newId);
2230
2230
  current = merged.file;
2231
2231
  warnings = merged.warnings;
2232
2232
  if (`${JSON.stringify(current, null, 2)}
2233
- ` !== text) write();
2233
+ ` !== text2) write();
2234
2234
  } catch (err) {
2235
2235
  warnings = [`comments.json is not valid: ${err.message} (left as written; fix it)`];
2236
2236
  }
@@ -2749,8 +2749,8 @@ function $createDecoratorBoundaryAnchor() {
2749
2749
  const img = $getDocument().createElement("img");
2750
2750
  img.setAttribute("data-lexical-decorator-boundary", "true");
2751
2751
  img.alt = "";
2752
- for (const [property, value] of [["position", "absolute"], ["width", "0px"], ["height", "0px"], ["border", "0px"], ["margin", "0px"], ["padding", "0px"]]) {
2753
- img.style.setProperty(property, value, "important");
2752
+ for (const [property2, value] of [["position", "absolute"], ["width", "0px"], ["height", "0px"], ["border", "0px"], ["margin", "0px"], ["padding", "0px"]]) {
2753
+ img.style.setProperty(property2, value, "important");
2754
2754
  }
2755
2755
  return img;
2756
2756
  }
@@ -3114,19 +3114,19 @@ var ElementDOMSlot = class _ElementDOMSlot extends DOMSlot {
3114
3114
  }
3115
3115
  };
3116
3116
  function indexPath(root, child) {
3117
- const path17 = [];
3117
+ const path18 = [];
3118
3118
  let node = child;
3119
3119
  for (; node !== root && node !== null; node = node.parentNode) {
3120
3120
  let i6 = 0;
3121
3121
  for (let sibling = node.previousSibling; sibling !== null; sibling = sibling.previousSibling) {
3122
3122
  i6++;
3123
3123
  }
3124
- path17.push(i6);
3124
+ path18.push(i6);
3125
3125
  }
3126
3126
  if (!(node === root)) {
3127
3127
  formatDevErrorMessage(`indexPath: root is not a parent of child`);
3128
3128
  }
3129
- return path17.reverse();
3129
+ return path18.reverse();
3130
3130
  }
3131
3131
  // @__NO_SIDE_EFFECTS__
3132
3132
  function readLexicalVersion() {
@@ -3526,9 +3526,9 @@ function $handleTextMutation(target, node, editor) {
3526
3526
  anchorOffset = domSelectionPoints.anchorOffset;
3527
3527
  focusOffset = domSelectionPoints.focusOffset;
3528
3528
  }
3529
- const text = target.nodeValue;
3530
- if (text !== null) {
3531
- $updateTextNodeFromDOMContent(node, text, anchorOffset, focusOffset, false);
3529
+ const text2 = target.nodeValue;
3530
+ if (text2 !== null) {
3531
+ $updateTextNodeFromDOMContent(node, text2, anchorOffset, focusOffset, false);
3532
3532
  }
3533
3533
  }
3534
3534
  function shouldUpdateTextNodeFromMutation(selection, targetDOM, targetNode) {
@@ -5470,7 +5470,7 @@ function $createNode(key2, slot) {
5470
5470
  $reconcileDecoratorBoundaryAnchors(node, dom);
5471
5471
  }
5472
5472
  } else {
5473
- const text = node.getTextContent();
5473
+ const text2 = node.getTextContent();
5474
5474
  if ($isDecoratorNode(node)) {
5475
5475
  const decorator = node.decorate(activeEditor$1, activeEditorConfig);
5476
5476
  if (decorator !== null) {
@@ -5482,7 +5482,7 @@ function $createNode(key2, slot) {
5482
5482
  $mountSlotChildren(node, dom, slots);
5483
5483
  }
5484
5484
  }
5485
- subTreeTextContent += text;
5485
+ subTreeTextContent += text2;
5486
5486
  }
5487
5487
  if (slot !== null) {
5488
5488
  slot.insertChild(dom);
@@ -5761,18 +5761,18 @@ function $tryReconcileSuffixWithSizeDelta(prevElement, nextElement, slot, cacheD
5761
5761
  if (node === void 0) {
5762
5762
  return false;
5763
5763
  }
5764
- let text;
5764
+ let text2;
5765
5765
  if ($isElementNode(node)) {
5766
5766
  const childKeyedDom = activeEditor$1._keyToDOMMap.get(nextSuffixKeys[i6]);
5767
5767
  const cached = childKeyedDom && childKeyedDom.__lexicalTextContent;
5768
5768
  if (!(typeof cached === "string")) {
5769
5769
  formatDevErrorMessage(`tryReconcileSuffixWithSizeDelta: missing __lexicalTextContent on child of type ${node.getType()} after suffix reconcile`);
5770
5770
  }
5771
- text = cached;
5771
+ text2 = cached;
5772
5772
  } else {
5773
- text = node.getTextContent();
5773
+ text2 = node.getTextContent();
5774
5774
  }
5775
- newSuffix += text;
5775
+ newSuffix += text2;
5776
5776
  if (i6 < k5 - 1 && $isElementNode(node) && !node.isInline()) {
5777
5777
  newSuffix += DOUBLE_LINE_BREAK;
5778
5778
  }
@@ -5878,18 +5878,18 @@ function $reconcileChildren(prevElement, nextElement, slot) {
5878
5878
  if (node === void 0) {
5879
5879
  break;
5880
5880
  }
5881
- let text;
5881
+ let text2;
5882
5882
  if ($isElementNode(node)) {
5883
5883
  const childKeyedDom = activeEditor$1._keyToDOMMap.get(cur);
5884
5884
  const cached = childKeyedDom && childKeyedDom.__lexicalTextContent;
5885
5885
  if (!(typeof cached === "string")) {
5886
5886
  formatDevErrorMessage(`reconcileChildren same-size suffix: missing __lexicalTextContent on child of type ${node.getType()} after reconcile`);
5887
5887
  }
5888
- text = cached;
5888
+ text2 = cached;
5889
5889
  } else {
5890
- text = node.getTextContent();
5890
+ text2 = node.getTextContent();
5891
5891
  }
5892
- newSuffix += text;
5892
+ newSuffix += text2;
5893
5893
  if (i6 < k5 - 1 && $isElementNode(node) && !node.isInline()) {
5894
5894
  newSuffix += DOUBLE_LINE_BREAK;
5895
5895
  }
@@ -5928,7 +5928,7 @@ function $reconcileChildren(prevElement, nextElement, slot) {
5928
5928
  if (isDirty) {
5929
5929
  $reconcileNode(nodeKey, dom);
5930
5930
  } else {
5931
- let text;
5931
+ let text2;
5932
5932
  let childKeyedDom;
5933
5933
  if ($isElementNode(node)) {
5934
5934
  childKeyedDom = activePrevKeyToDOMMap.get(nodeKey);
@@ -5936,11 +5936,11 @@ function $reconcileChildren(prevElement, nextElement, slot) {
5936
5936
  if (!(typeof cached === "string")) {
5937
5937
  formatDevErrorMessage(`reconcileChildren structurally-clean walk: missing __lexicalTextContent on non-dirty child of type ${node.getType()}`);
5938
5938
  }
5939
- text = cached;
5939
+ text2 = cached;
5940
5940
  } else {
5941
- text = node.getTextContent();
5941
+ text2 = node.getTextContent();
5942
5942
  }
5943
- subTreeTextContent += text;
5943
+ subTreeTextContent += text2;
5944
5944
  if (childKeyedDom !== void 0) {
5945
5945
  $bubbleChildFirstText(childKeyedDom);
5946
5946
  }
@@ -6040,18 +6040,18 @@ function $reconcileNode(key2, parentDOM) {
6040
6040
  const isDirty = treatAllNodesAsDirty || activeDirtyLeaves.has(key2) || activeDirtyElements.has(key2);
6041
6041
  const dom = getElementByKeyOrThrow(activeEditor$1, key2);
6042
6042
  if (prevNode === nextNode && !isDirty) {
6043
- let text;
6043
+ let text2;
6044
6044
  if ($isElementNode(prevNode)) {
6045
6045
  const previousSubTreeTextContent = dom.__lexicalTextContent;
6046
6046
  if (!(typeof previousSubTreeTextContent === "string")) {
6047
6047
  formatDevErrorMessage(`reconcileNode: missing __lexicalTextContent on non-dirty element of type ${prevNode.getType()}`);
6048
6048
  }
6049
- text = previousSubTreeTextContent;
6049
+ text2 = previousSubTreeTextContent;
6050
6050
  $bubbleChildFirstText(dom);
6051
6051
  } else {
6052
- text = prevNode.getTextContent();
6052
+ text2 = prevNode.getTextContent();
6053
6053
  }
6054
- subTreeTextContent += text;
6054
+ subTreeTextContent += text2;
6055
6055
  return dom;
6056
6056
  }
6057
6057
  if (prevNode !== nextNode && isDirty) {
@@ -6123,7 +6123,7 @@ function $reconcileNode(key2, parentDOM) {
6123
6123
  }
6124
6124
  }
6125
6125
  } else {
6126
- const text = nextNode.getTextContent();
6126
+ const text2 = nextNode.getTextContent();
6127
6127
  if ($isDecoratorNode(nextNode)) {
6128
6128
  const decorator = nextNode.decorate(activeEditor$1, activeEditorConfig);
6129
6129
  if (decorator !== null) {
@@ -6133,7 +6133,7 @@ function $reconcileNode(key2, parentDOM) {
6133
6133
  $reconcileSlotChildren(prevNode, nextNode, dom);
6134
6134
  }
6135
6135
  }
6136
- subTreeTextContent += text;
6136
+ subTreeTextContent += text2;
6137
6137
  }
6138
6138
  if (!activeEditorStateReadOnly && $isRootNode(nextNode)) {
6139
6139
  const latestRoot = nextNode.getLatest();
@@ -6544,7 +6544,7 @@ var documentSelectionChange = /* @__PURE__ */ createRefCountedRegistry((doc) =>
6544
6544
  doc.addEventListener("selectionchange", onDocumentSelectionChange);
6545
6545
  return () => doc.removeEventListener("selectionchange", onDocumentSelectionChange);
6546
6546
  });
6547
- function $shouldPreventDefaultAndInsertText(selection, domTargetRange, text, timeStamp, isBeforeInput, cachedDOMSelectionPoints) {
6547
+ function $shouldPreventDefaultAndInsertText(selection, domTargetRange, text2, timeStamp, isBeforeInput, cachedDOMSelectionPoints) {
6548
6548
  const anchor = selection.anchor;
6549
6549
  const focus = selection.focus;
6550
6550
  const anchorNode = anchor.getNode();
@@ -6559,7 +6559,7 @@ function $shouldPreventDefaultAndInsertText(selection, domTargetRange, text, tim
6559
6559
  const domAnchorNode = domSelectionPoints !== null ? domSelectionPoints.anchorNode : null;
6560
6560
  const anchorKey = anchor.key;
6561
6561
  const backingAnchorElement = editor.getElementByKey(anchorKey);
6562
- const textLength = text.length;
6562
+ const textLength = text2.length;
6563
6563
  return anchorKey !== focus.key || // If we're working with a non-text node.
6564
6564
  !$isTextNode(anchorNode) || // If we are replacing a range with a single character or grapheme, and not composing.
6565
6565
  (!isBeforeInput && (!CAN_USE_BEFORE_INPUT || // We check to see if there has been
@@ -6568,7 +6568,7 @@ function $shouldPreventDefaultAndInsertText(selection, domTargetRange, text, tim
6568
6568
  // a dangling `input` event caused by execCommand('insertText').
6569
6569
  editor._inputState.lastBeforeInputInsertTextTimeStamp < timeStamp + 50) || anchorNode.isDirty() && textLength < 2 || // TODO consider if there are other scenarios when multiple code units
6570
6570
  // should be addressed here
6571
- doesContainSurrogatePair(text)) && anchor.offset !== focus.offset && !anchorNode.isComposing() || // Any non standard text node.
6571
+ doesContainSurrogatePair(text2)) && anchor.offset !== focus.offset && !anchorNode.isComposing() || // Any non standard text node.
6572
6572
  $isTokenOrSegmented(anchorNode) || // If the text length is more than a single character and we're either
6573
6573
  // dealing with this in "beforeinput" or where the node has already recently
6574
6574
  // been changed (thus is dirty).
@@ -6987,9 +6987,9 @@ function $handleBeforeInput(event) {
6987
6987
  event.preventDefault();
6988
6988
  dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND);
6989
6989
  } else if (data == null && event.dataTransfer) {
6990
- const text = event.dataTransfer.getData("text/plain");
6990
+ const text2 = event.dataTransfer.getData("text/plain");
6991
6991
  event.preventDefault();
6992
- selection.insertRawText(text);
6992
+ selection.insertRawText(text2);
6993
6993
  } else if (data != null && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, true)) {
6994
6994
  event.preventDefault();
6995
6995
  dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data);
@@ -8228,11 +8228,11 @@ var LexicalNode = class {
8228
8228
  *
8229
8229
  * @param object - the node to perform the equality comparison on.
8230
8230
  */
8231
- is(object) {
8232
- if (object == null) {
8231
+ is(object2) {
8232
+ if (object2 == null) {
8233
8233
  return false;
8234
8234
  }
8235
- return this.__key === object.__key;
8235
+ return this.__key === object2.__key;
8236
8236
  }
8237
8237
  /**
8238
8238
  * Returns true if this node logically precedes the target node in the
@@ -9067,9 +9067,9 @@ var GENERATED_TEXT = (fields) => {
9067
9067
  if (style !== void 0 && style !== "") {
9068
9068
  json.style = style;
9069
9069
  }
9070
- const text = node.__text;
9071
- if (text !== void 0 && text !== "") {
9072
- json.text = text;
9070
+ const text2 = node.__text;
9071
+ if (text2 !== void 0 && text2 !== "") {
9072
+ json.text = text2;
9073
9073
  }
9074
9074
  return json;
9075
9075
  }
@@ -9082,8 +9082,8 @@ var GENERATED_TEXT = (fields) => {
9082
9082
  node.__mode = typeof mode === "string" && mode in TEXT_MODE_SETTER ? TEXT_MODE_SETTER[mode] : TEXT_MODE_SETTER_DEFAULT;
9083
9083
  const style = json.style;
9084
9084
  node.__style = typeof style === "string" ? style : "";
9085
- const text = json.text;
9086
- node.__text = typeof text === "string" ? text : "";
9085
+ const text2 = json.text;
9086
+ node.__text = typeof text2 === "string" ? text2 : "";
9087
9087
  return node;
9088
9088
  }
9089
9089
  return {
@@ -9308,10 +9308,10 @@ function getStyleObjectFromCSS(css) {
9308
9308
  }
9309
9309
  chunkStart = -1;
9310
9310
  }
9311
- const property2 = currentProperty.trim();
9311
+ const property3 = currentProperty.trim();
9312
9312
  const value2 = currentValue.trim();
9313
- if (property2 !== "" && value2 !== "") {
9314
- styles[property2] = value2;
9313
+ if (property3 !== "" && value2 !== "") {
9314
+ styles[property3] = value2;
9315
9315
  }
9316
9316
  currentProperty = "";
9317
9317
  currentValue = "";
@@ -9329,30 +9329,30 @@ function getStyleObjectFromCSS(css) {
9329
9329
  currentProperty += css.slice(chunkStart, length);
9330
9330
  }
9331
9331
  }
9332
- const property = currentProperty.trim();
9332
+ const property2 = currentProperty.trim();
9333
9333
  const value = currentValue.trim();
9334
- if (property !== "" && value !== "") {
9335
- styles[property] = value;
9334
+ if (property2 !== "" && value !== "") {
9335
+ styles[property2] = value;
9336
9336
  }
9337
9337
  return styles;
9338
9338
  }
9339
- function setDOMStyleProperty(domStyle, property, value) {
9339
+ function setDOMStyleProperty(domStyle, property2, value) {
9340
9340
  const trimmedValue = value.trimEnd();
9341
9341
  const flagStart = trimmedValue.length - IMPORTANT_FLAG.length;
9342
9342
  const hasImportant = flagStart >= 0 && trimmedValue.slice(flagStart).toLowerCase() === IMPORTANT_FLAG;
9343
9343
  if (hasImportant) {
9344
- domStyle.setProperty(property, trimmedValue.slice(0, flagStart).trim(), "important");
9344
+ domStyle.setProperty(property2, trimmedValue.slice(0, flagStart).trim(), "important");
9345
9345
  } else {
9346
- domStyle.setProperty(property, value, "");
9346
+ domStyle.setProperty(property2, value, "");
9347
9347
  }
9348
9348
  }
9349
9349
  function setDOMStyleObject(domStyle, styleObject) {
9350
- for (const property in styleObject) {
9351
- const value = styleObject[property];
9350
+ for (const property2 in styleObject) {
9351
+ const value = styleObject[property2];
9352
9352
  if (value == null) {
9353
- domStyle.removeProperty(property);
9353
+ domStyle.removeProperty(property2);
9354
9354
  } else {
9355
- setDOMStyleProperty(domStyle, property, value);
9355
+ setDOMStyleProperty(domStyle, property2, value);
9356
9356
  }
9357
9357
  }
9358
9358
  }
@@ -9362,12 +9362,12 @@ function setDOMStyleFromCSS(domStyle, cssText, prevCSSText = "") {
9362
9362
  }
9363
9363
  const prevCSS = getStyleObjectFromCSS(prevCSSText);
9364
9364
  const nextCSS = getStyleObjectFromCSS(cssText);
9365
- for (const property in nextCSS) {
9366
- delete prevCSS[property];
9367
- setDOMStyleProperty(domStyle, property, nextCSS[property]);
9365
+ for (const property2 in nextCSS) {
9366
+ delete prevCSS[property2];
9367
+ setDOMStyleProperty(domStyle, property2, nextCSS[property2]);
9368
9368
  }
9369
- for (const property in prevCSS) {
9370
- domStyle.removeProperty(property);
9369
+ for (const property2 in prevCSS) {
9370
+ domStyle.removeProperty(property2);
9371
9371
  }
9372
9372
  }
9373
9373
  var textNodeSchema = /* @__PURE__ */ (/* @__PURE__ */ nodeSchema())({
@@ -9481,31 +9481,31 @@ function diffComposedText(a5, b6) {
9481
9481
  function $setTextContent(nextText, dom, node) {
9482
9482
  const isComposing = node.isComposing();
9483
9483
  const suffix = isComposing ? COMPOSITION_SUFFIX : "";
9484
- const text = nextText + suffix;
9484
+ const text2 = nextText + suffix;
9485
9485
  const editor = $getEditor();
9486
9486
  const slot = $getEditorDOMRenderConfig(editor).$getDOMSlot(node, dom, editor);
9487
9487
  const firstChild = slot.getFirstChild();
9488
9488
  if (firstChild === null || firstChild.nodeType !== Node.TEXT_NODE) {
9489
- slot.insertChild($getDocument().createTextNode(text));
9489
+ slot.insertChild($getDocument().createTextNode(text2));
9490
9490
  return;
9491
9491
  }
9492
9492
  const textChild = firstChild;
9493
9493
  const nodeValue = textChild.nodeValue;
9494
- if (nodeValue === text) {
9494
+ if (nodeValue === text2) {
9495
9495
  return;
9496
9496
  }
9497
9497
  if (isComposing || IS_FIREFOX) {
9498
- const [index, remove2, insert2] = diffComposedText(nodeValue, text);
9498
+ const [index, remove2, insert2] = diffComposedText(nodeValue, text2);
9499
9499
  if (remove2 !== 0) {
9500
9500
  textChild.deleteData(index, remove2);
9501
9501
  }
9502
9502
  textChild.insertData(index, insert2);
9503
9503
  } else {
9504
- textChild.nodeValue = text;
9504
+ textChild.nodeValue = text2;
9505
9505
  }
9506
9506
  }
9507
- function $createTextInnerDOM(innerDOM, node, innerTag, format, text, config) {
9508
- $setTextContent(text, innerDOM, node);
9507
+ function $createTextInnerDOM(innerDOM, node, innerTag, format, text2, config) {
9508
+ $setTextContent(text2, innerDOM, node);
9509
9509
  const theme = config.theme;
9510
9510
  const textClassNames = theme.text;
9511
9511
  if (textClassNames !== void 0) {
@@ -9592,9 +9592,9 @@ var TextNode = class extends LexicalNode {
9592
9592
  json: textNodeSchema
9593
9593
  });
9594
9594
  }
9595
- constructor(text = "", key2) {
9595
+ constructor(text2 = "", key2) {
9596
9596
  super(key2);
9597
- this.__text = text;
9597
+ this.__text = text2;
9598
9598
  this.__format = 0;
9599
9599
  this.__style = "";
9600
9600
  this.__mode = 0;
@@ -9755,8 +9755,8 @@ var TextNode = class extends LexicalNode {
9755
9755
  innerDOM = $getDocument().createElement(innerTag);
9756
9756
  dom.appendChild(innerDOM);
9757
9757
  }
9758
- const text = this.__text;
9759
- $createTextInnerDOM(innerDOM, this, innerTag, format, text, config);
9758
+ const text2 = this.__text;
9759
+ $createTextInnerDOM(innerDOM, this, innerTag, format, text2, config);
9760
9760
  const style = this.__style;
9761
9761
  if (style !== "") {
9762
9762
  setDOMStyleFromCSS(dom.style, style);
@@ -9956,12 +9956,12 @@ var TextNode = class extends LexicalNode {
9956
9956
  *
9957
9957
  * @returns this TextNode.
9958
9958
  */
9959
- setTextContent(text) {
9960
- if (this.getLatest().__text === text) {
9959
+ setTextContent(text2) {
9960
+ if (this.getLatest().__text === text2) {
9961
9961
  return this;
9962
9962
  }
9963
9963
  const self2 = this.getWritable();
9964
- self2.__text = text;
9964
+ self2.__text = text2;
9965
9965
  return self2;
9966
9966
  }
9967
9967
  /**
@@ -9977,10 +9977,10 @@ var TextNode = class extends LexicalNode {
9977
9977
  let anchorOffset = _anchorOffset;
9978
9978
  let focusOffset = _focusOffset;
9979
9979
  const selection = $getSelection();
9980
- const text = this.getTextContent();
9980
+ const text2 = this.getTextContent();
9981
9981
  const key2 = this.__key;
9982
- if (typeof text === "string") {
9983
- const lastOffset = text.length;
9982
+ if (typeof text2 === "string") {
9983
+ const lastOffset = text2.length;
9984
9984
  if (anchorOffset === void 0) {
9985
9985
  anchorOffset = lastOffset;
9986
9986
  }
@@ -10022,7 +10022,7 @@ var TextNode = class extends LexicalNode {
10022
10022
  */
10023
10023
  spliceText(offset, delCount, newText, moveSelection) {
10024
10024
  const writableSelf = this.getWritable();
10025
- const text = writableSelf.__text;
10025
+ const text2 = writableSelf.__text;
10026
10026
  const handledTextLength = newText.length;
10027
10027
  let index = offset;
10028
10028
  if (index < 0) {
@@ -10036,7 +10036,7 @@ var TextNode = class extends LexicalNode {
10036
10036
  const newOffset = offset + handledTextLength;
10037
10037
  selection.setTextNodeRange(writableSelf, newOffset, writableSelf, newOffset);
10038
10038
  }
10039
- const updatedText = text.slice(0, index) + newText + text.slice(index + delCount);
10039
+ const updatedText = text2.slice(0, index) + newText + text2.slice(index + delCount);
10040
10040
  writableSelf.__text = updatedText;
10041
10041
  return writableSelf;
10042
10042
  }
@@ -10188,8 +10188,8 @@ var TextNode = class extends LexicalNode {
10188
10188
  }
10189
10189
  const key2 = this.__key;
10190
10190
  const targetKey = target.__key;
10191
- const text = this.__text;
10192
- const textLength = text.length;
10191
+ const text2 = this.__text;
10192
+ const textLength = text2.length;
10193
10193
  const compositionKey = $getCompositionKey();
10194
10194
  if (compositionKey === targetKey) {
10195
10195
  $setCompositionKey(key2);
@@ -10206,7 +10206,7 @@ var TextNode = class extends LexicalNode {
10206
10206
  }
10207
10207
  }
10208
10208
  const targetText = target.__text;
10209
- const newText = isBefore ? targetText + text : text + targetText;
10209
+ const newText = isBefore ? targetText + text2 : text2 + targetText;
10210
10210
  this.setTextContent(newText);
10211
10211
  const writableSelf = this.getWritable();
10212
10212
  target.remove();
@@ -10321,8 +10321,8 @@ function $convertTextDOMNode(domNode) {
10321
10321
  node: $createTextNode(textContent3)
10322
10322
  };
10323
10323
  }
10324
- function findTextInLine(text, forward) {
10325
- let node = text;
10324
+ function findTextInLine(text2, forward) {
10325
+ let node = text2;
10326
10326
  while (true) {
10327
10327
  let sibling;
10328
10328
  while ((sibling = forward ? node.nextSibling : node.previousSibling) === null) {
@@ -10373,8 +10373,8 @@ function convertTextFormatElement(domNode) {
10373
10373
  node: null
10374
10374
  };
10375
10375
  }
10376
- function $createTextNode(text = "") {
10377
- return $applyNodeReplacement(new TextNode(text));
10376
+ function $createTextNode(text2 = "") {
10377
+ return $applyNodeReplacement(new TextNode(text2));
10378
10378
  }
10379
10379
  function $isTextNode(node) {
10380
10380
  return node instanceof TextNode;
@@ -10645,13 +10645,13 @@ function $transferStartingElementPointToTextPoint(start, end, format, style) {
10645
10645
  }
10646
10646
  start.set(textNode.__key, 0, "text");
10647
10647
  }
10648
- function $insertTextAtPoint(selection, text, format, style) {
10648
+ function $insertTextAtPoint(selection, text2, format, style) {
10649
10649
  const anchorNode = selection.anchor.getNode();
10650
10650
  if (!$isTextNode(anchorNode)) {
10651
10651
  formatDevErrorMessage(`insertText: anchor is not a text node`);
10652
10652
  }
10653
10653
  const offset = selection.anchor.offset;
10654
- const textNode = $createTextNode(text);
10654
+ const textNode = $createTextNode(text2);
10655
10655
  textNode.setFormat(format);
10656
10656
  textNode.setStyle(style);
10657
10657
  const parent = anchorNode.getParentOrThrow();
@@ -10676,7 +10676,7 @@ function $insertTextAtPoint(selection, text, format, style) {
10676
10676
  }
10677
10677
  textNode.selectEnd();
10678
10678
  if (textNode.isComposing() && selection.anchor.type === "text") {
10679
- selection.anchor.set(selection.anchor.key, selection.anchor.offset - text.length, selection.anchor.type);
10679
+ selection.anchor.set(selection.anchor.key, selection.anchor.offset - text2.length, selection.anchor.type);
10680
10680
  }
10681
10681
  }
10682
10682
  var NodeSelection = class _NodeSelection {
@@ -10735,7 +10735,7 @@ var NodeSelection = class _NodeSelection {
10735
10735
  extract() {
10736
10736
  return this.getNodes();
10737
10737
  }
10738
- insertRawText(text) {
10738
+ insertRawText(text2) {
10739
10739
  }
10740
10740
  insertText() {
10741
10741
  }
@@ -10765,8 +10765,8 @@ var NodeSelection = class _NodeSelection {
10765
10765
  }
10766
10766
  const objects = this._nodes;
10767
10767
  const nodes = [];
10768
- for (const object of objects) {
10769
- const node = $getNodeByKey(object);
10768
+ for (const object2 of objects) {
10769
+ const node = $getNodeByKey(object2);
10770
10770
  if (node !== null) {
10771
10771
  nodes.push(node);
10772
10772
  }
@@ -10961,19 +10961,19 @@ var RangeSelection = class _RangeSelection {
10961
10961
  } else {
10962
10962
  prevWasElement = false;
10963
10963
  if ($isTextNode(node)) {
10964
- let text = node.getTextContent();
10964
+ let text2 = node.getTextContent();
10965
10965
  if (node === firstNode) {
10966
10966
  if (node === lastNode) {
10967
10967
  if (anchor.type !== "element" || focus.type !== "element" || focus.offset === anchor.offset) {
10968
- text = anchorOffset < focusOffset ? text.slice(anchorOffset, focusOffset) : text.slice(focusOffset, anchorOffset);
10968
+ text2 = anchorOffset < focusOffset ? text2.slice(anchorOffset, focusOffset) : text2.slice(focusOffset, anchorOffset);
10969
10969
  }
10970
10970
  } else {
10971
- text = isBefore ? text.slice(anchorOffset) : text.slice(focusOffset);
10971
+ text2 = isBefore ? text2.slice(anchorOffset) : text2.slice(focusOffset);
10972
10972
  }
10973
10973
  } else if (node === lastNode) {
10974
- text = isBefore ? text.slice(0, focusOffset) : text.slice(0, anchorOffset);
10974
+ text2 = isBefore ? text2.slice(0, focusOffset) : text2.slice(0, anchorOffset);
10975
10975
  }
10976
- textContent3 += text;
10976
+ textContent3 += text2;
10977
10977
  } else if (($isDecoratorNode(node) || $isLineBreakNode(node)) && (node !== lastNode || !this.isCollapsed())) {
10978
10978
  textContent3 += node.getTextContent();
10979
10979
  }
@@ -11058,15 +11058,15 @@ var RangeSelection = class _RangeSelection {
11058
11058
  *
11059
11059
  * @param text the text to insert into the Selection
11060
11060
  */
11061
- insertRawText(text) {
11062
- this.insertNodes($generateNodesFromRawText(text));
11061
+ insertRawText(text2) {
11062
+ this.insertNodes($generateNodesFromRawText(text2));
11063
11063
  }
11064
11064
  /**
11065
11065
  * Insert the provided text into the EditorState at the current Selection.
11066
11066
  *
11067
11067
  * @param text the text to insert into the Selection
11068
11068
  */
11069
- insertText(text) {
11069
+ insertText(text2) {
11070
11070
  let format = this.format;
11071
11071
  let style = this.style;
11072
11072
  if (!this.isCollapsed()) {
@@ -11079,14 +11079,14 @@ var RangeSelection = class _RangeSelection {
11079
11079
  this.removeText();
11080
11080
  this.format = format;
11081
11081
  this.style = style;
11082
- if (text === "") {
11082
+ if (text2 === "") {
11083
11083
  return;
11084
11084
  }
11085
11085
  if ($getCompositionKey() === null) {
11086
11086
  if (this.anchor.type === "element") {
11087
11087
  $transferStartingElementPointToTextPoint(this.anchor, this.focus, format, style);
11088
11088
  }
11089
- $insertTextAtPoint(this, text, format, style);
11089
+ $insertTextAtPoint(this, text2, format, style);
11090
11090
  return;
11091
11091
  }
11092
11092
  }
@@ -11116,12 +11116,12 @@ var RangeSelection = class _RangeSelection {
11116
11116
  $setSelection(this);
11117
11117
  }
11118
11118
  }
11119
- if (text !== "") {
11120
- this.insertText(text);
11119
+ if (text2 !== "") {
11120
+ this.insertText(text2);
11121
11121
  }
11122
11122
  return;
11123
11123
  }
11124
- if (text === "") {
11124
+ if (text2 === "") {
11125
11125
  return;
11126
11126
  }
11127
11127
  if (offset === 0) {
@@ -11139,7 +11139,7 @@ var RangeSelection = class _RangeSelection {
11139
11139
  }
11140
11140
  newNode2.select();
11141
11141
  }
11142
- this.insertText(text);
11142
+ this.insertText(text2);
11143
11143
  return;
11144
11144
  } else if (offset === anchorSize) {
11145
11145
  const next = anchorNode.getNextSibling();
@@ -11156,17 +11156,17 @@ var RangeSelection = class _RangeSelection {
11156
11156
  }
11157
11157
  newNode2.select(0, 0);
11158
11158
  }
11159
- this.insertText(text);
11159
+ this.insertText(text2);
11160
11160
  return;
11161
11161
  }
11162
- const newNode = $createTextNode(text);
11162
+ const newNode = $createTextNode(text2);
11163
11163
  newNode.setFormat(format);
11164
11164
  newNode.setStyle(style);
11165
11165
  anchorNode.replace(newNode);
11166
11166
  newNode.select();
11167
11167
  return;
11168
11168
  }
11169
- if (text === "") {
11169
+ if (text2 === "") {
11170
11170
  return;
11171
11171
  }
11172
11172
  const atStartOfInline = anchorParent.isInline() && offset === 0 && !anchorNode.__prev;
@@ -11177,13 +11177,13 @@ var RangeSelection = class _RangeSelection {
11177
11177
  anchorNode.setFormat(format);
11178
11178
  anchorNode.setStyle(style);
11179
11179
  } else {
11180
- $insertTextAtPoint(this, text, format, style);
11180
+ $insertTextAtPoint(this, text2, format, style);
11181
11181
  return;
11182
11182
  }
11183
11183
  }
11184
- anchorNode.spliceText(offset, 0, text, true);
11184
+ anchorNode.spliceText(offset, 0, text2, true);
11185
11185
  if (anchorNode.isComposing() && this.anchor.type === "text") {
11186
- this.anchor.set(this.anchor.key, this.anchor.offset - text.length, this.anchor.type);
11186
+ this.anchor.set(this.anchor.key, this.anchor.offset - text2.length, this.anchor.type);
11187
11187
  }
11188
11188
  }
11189
11189
  /**
@@ -12112,8 +12112,8 @@ function $updateCaretSelectionForUnicodeCharacter(selection, isBackward) {
12112
12112
  const endOffset = isBefore ? focusOffset : anchorOffset;
12113
12113
  const characterOffset = endOffset - 1;
12114
12114
  if (startOffset !== characterOffset) {
12115
- const text = anchorNode.getTextContent().slice(startOffset, endOffset);
12116
- if (shouldDeleteExactlyOneCodeUnit(text)) {
12115
+ const text2 = anchorNode.getTextContent().slice(startOffset, endOffset);
12116
+ if (shouldDeleteExactlyOneCodeUnit(text2)) {
12117
12117
  if (isBackward) {
12118
12118
  focus.set(focus.key, characterOffset, focus.type);
12119
12119
  } else {
@@ -12123,13 +12123,13 @@ function $updateCaretSelectionForUnicodeCharacter(selection, isBackward) {
12123
12123
  }
12124
12124
  }
12125
12125
  }
12126
- function shouldDeleteExactlyOneCodeUnit(text) {
12126
+ function shouldDeleteExactlyOneCodeUnit(text2) {
12127
12127
  {
12128
- if (!(text.length > 1)) {
12128
+ if (!(text2.length > 1)) {
12129
12129
  formatDevErrorMessage(`shouldDeleteExactlyOneCodeUnit: expecting to be called only with sequences of two or more code units`);
12130
12130
  }
12131
12131
  }
12132
- return !(doesContainSurrogatePair(text) || doesContainEmoji(text));
12132
+ return !(doesContainSurrogatePair(text2) || doesContainEmoji(text2));
12133
12133
  }
12134
12134
  // @__NO_SIDE_EFFECTS__
12135
12135
  function createEmojiTest() {
@@ -12157,10 +12157,10 @@ function $removeSegment(node, isBackward, offset) {
12157
12157
  let segmentOffset = 0;
12158
12158
  let restoreOffset = 0;
12159
12159
  for (let i6 = 0; i6 < splitLength; i6++) {
12160
- const text = split[i6];
12160
+ const text2 = split[i6];
12161
12161
  const isLast = i6 === splitLength - 1;
12162
12162
  restoreOffset = segmentOffset;
12163
- segmentOffset += text.length;
12163
+ segmentOffset += text2.length;
12164
12164
  if (isBackward && segmentOffset === offset || segmentOffset > offset || isLast) {
12165
12165
  split.splice(i6, 1);
12166
12166
  if (isLast) {
@@ -12844,8 +12844,8 @@ function $insertNodes(nodes) {
12844
12844
  }
12845
12845
  selection.insertNodes(nodes);
12846
12846
  }
12847
- function tokenizeRawText(text, visitor) {
12848
- for (const part of text.split(/(\r?\n|\t)/)) {
12847
+ function tokenizeRawText(text2, visitor) {
12848
+ for (const part of text2.split(/(\r?\n|\t)/)) {
12849
12849
  if (part === "\n" || part === "\r\n") {
12850
12850
  visitor.linebreak();
12851
12851
  } else if (part === " ") {
@@ -12855,9 +12855,9 @@ function tokenizeRawText(text, visitor) {
12855
12855
  }
12856
12856
  }
12857
12857
  }
12858
- function $generateNodesFromRawText(text) {
12858
+ function $generateNodesFromRawText(text2) {
12859
12859
  const nodes = [];
12860
- tokenizeRawText(text, {
12860
+ tokenizeRawText(text2, {
12861
12861
  linebreak: () => nodes.push($createLineBreakNode()),
12862
12862
  tab: () => nodes.push($createTabNode()),
12863
12863
  text: (part) => nodes.push($createTextNode(part))
@@ -16640,11 +16640,11 @@ function getNearestEditorFromDOMNode(node) {
16640
16640
  function getEditorPropertyFromDOMNode(node) {
16641
16641
  return node ? node.__lexicalEditor : null;
16642
16642
  }
16643
- function getTextDirection(text) {
16644
- if (RTL_REGEX.test(text)) {
16643
+ function getTextDirection(text2) {
16644
+ if (RTL_REGEX.test(text2)) {
16645
16645
  return "rtl";
16646
16646
  }
16647
- if (LTR_REGEX.test(text)) {
16647
+ if (LTR_REGEX.test(text2)) {
16648
16648
  return "ltr";
16649
16649
  }
16650
16650
  return null;
@@ -17906,9 +17906,9 @@ function getActiveElementDeep(root) {
17906
17906
  function getComposedEventTarget(event) {
17907
17907
  const target = event.target;
17908
17908
  if (target !== null && isHTMLElement(target) && target.shadowRoot !== null && typeof event.composedPath === "function") {
17909
- const path17 = event.composedPath();
17910
- if (path17.length > 0) {
17911
- return path17[0];
17909
+ const path18 = event.composedPath();
17910
+ if (path18.length > 0) {
17911
+ return path18[0];
17912
17912
  }
17913
17913
  }
17914
17914
  return target;
@@ -19548,8 +19548,8 @@ var TextPointCaretSliceImpl = class {
19548
19548
  }
19549
19549
  } = this;
19550
19550
  const [indexStart, indexEnd] = this.getSliceIndices();
19551
- const text = origin.getTextContent();
19552
- return $getTextPointCaret(origin.setTextContent(text.slice(0, indexStart) + text.slice(indexEnd)), direction, indexStart);
19551
+ const text2 = origin.getTextContent();
19552
+ return $getTextPointCaret(origin.setTextContent(text2.slice(0, indexStart) + text2.slice(indexEnd)), direction, indexStart);
19553
19553
  }
19554
19554
  };
19555
19555
  function $getSliceFromTextPointCaret(caret, anchorOrFocus) {
@@ -28004,10 +28004,10 @@ function _loadWasmModule(sync, filepath, src, imports2) {
28004
28004
  var buf = null;
28005
28005
  var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
28006
28006
  if (filepath && isNode2) {
28007
- var fs20 = null;
28008
- var path17 = null;
28007
+ var fs21 = null;
28008
+ var path18 = null;
28009
28009
  return new Promise((resolve, reject) => {
28010
- fs20.readFile(path17.resolve(__dirname, filepath), (error, buffer) => {
28010
+ fs21.readFile(path18.resolve(__dirname, filepath), (error, buffer) => {
28011
28011
  if (error != null) {
28012
28012
  reject(error);
28013
28013
  } else {
@@ -28072,8 +28072,8 @@ function stateBinary(bytes) {
28072
28072
  function stateIndex(array, index, value) {
28073
28073
  Object.defineProperty(array, index, { value, enumerable: true, writable: true, configurable: true });
28074
28074
  }
28075
- function stateSet(object, key2, value) {
28076
- Object.defineProperty(object, key2, { value, enumerable: true, writable: true, configurable: true });
28075
+ function stateSet(object2, key2, value) {
28076
+ Object.defineProperty(object2, key2, { value, enumerable: true, writable: true, configurable: true });
28077
28077
  }
28078
28078
  var wasm;
28079
28079
  function __wbg_set_wasm(val) {
@@ -29310,10 +29310,10 @@ var LoroDoc = class _LoroDoc {
29310
29310
  * @param {string} path
29311
29311
  * @returns {Value | Container | undefined}
29312
29312
  */
29313
- getByPath(path17) {
29313
+ getByPath(path18) {
29314
29314
  try {
29315
29315
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
29316
- const ptr0 = passStringToWasm0(path17, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
29316
+ const ptr0 = passStringToWasm0(path18, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
29317
29317
  const len0 = WASM_VECTOR_LEN;
29318
29318
  wasm.lorodoc_getByPath(retptr, this.__wbg_ptr, ptr0, len0);
29319
29319
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -33572,10 +33572,10 @@ var LoroText = class _LoroText {
33572
33572
  * @param {string} text
33573
33573
  * @param {any} options
33574
33574
  */
33575
- updateByLine(text, options) {
33575
+ updateByLine(text2, options) {
33576
33576
  try {
33577
33577
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
33578
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
33578
+ const ptr0 = passStringToWasm0(text2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
33579
33579
  const len0 = WASM_VECTOR_LEN;
33580
33580
  wasm.lorotext_updateByLine(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options));
33581
33581
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -34011,10 +34011,10 @@ var LoroText = class _LoroText {
34011
34011
  * @param {string} text
34012
34012
  * @param {any} options
34013
34013
  */
34014
- update(text, options) {
34014
+ update(text2, options) {
34015
34015
  try {
34016
34016
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
34017
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
34017
+ const ptr0 = passStringToWasm0(text2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
34018
34018
  const len0 = WASM_VECTOR_LEN;
34019
34019
  wasm.lorotext_update(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options));
34020
34020
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -36665,9 +36665,9 @@ function createLoroBinding(editor, doc, options = {}) {
36665
36665
  synced.set(node.getKey(), props);
36666
36666
  if (wrote) readBaseline.set(treeNode.id, stable(storedProps(treeNode)));
36667
36667
  if ($isTextNode2(node)) {
36668
- const text = data.getOrCreateContainer(TEXT_KEY, new LoroText());
36668
+ const text2 = data.getOrCreateContainer(TEXT_KEY, new LoroText());
36669
36669
  const next = node.getTextContent();
36670
- if (text.toString() !== next) text.update(next);
36670
+ if (text2.toString() !== next) text2.update(next);
36671
36671
  }
36672
36672
  };
36673
36673
  const writeChildren = (parent, parentId, visited) => {
@@ -36713,14 +36713,14 @@ function createLoroBinding(editor, doc, options = {}) {
36713
36713
  node.setTextContent(next);
36714
36714
  points.forEach((point, index) => point.set(node.getKey(), offsets[index], "text"));
36715
36715
  };
36716
- const readNode = (treeNode) => {
36716
+ const readNode2 = (treeNode) => {
36717
36717
  const node = readNodeUnsynced(treeNode);
36718
36718
  synced.set(node.getKey(), nodeProps(node));
36719
36719
  return node;
36720
36720
  };
36721
36721
  const readNodeUnsynced = (treeNode) => {
36722
36722
  const props = storedProps(treeNode);
36723
- const text = $isTextLike(props) ? String(treeNode.data.get(TEXT_KEY) ?? "") : void 0;
36723
+ const text2 = $isTextLike(props) ? String(treeNode.data.get(TEXT_KEY) ?? "") : void 0;
36724
36724
  const key2 = idToKey.get(treeNode.id);
36725
36725
  const existing = key2 === void 0 ? null : $getNodeByKey2(key2);
36726
36726
  if (existing && existing.getType() === props.type) {
@@ -36729,7 +36729,7 @@ function createLoroBinding(editor, doc, options = {}) {
36729
36729
  ...props,
36730
36730
  text: existing.getTextContent()
36731
36731
  });
36732
- applyText(existing, text ?? "");
36732
+ applyText(existing, text2 ?? "");
36733
36733
  return existing;
36734
36734
  }
36735
36735
  const storedKey = stable(props);
@@ -36752,7 +36752,7 @@ function createLoroBinding(editor, doc, options = {}) {
36752
36752
  }
36753
36753
  const created = $parseSerializedNode2({
36754
36754
  ...props,
36755
- ...text === void 0 ? {} : { text },
36755
+ ...text2 === void 0 ? {} : { text: text2 },
36756
36756
  children: []
36757
36757
  });
36758
36758
  readBaseline.set(treeNode.id, stable(props));
@@ -36761,7 +36761,7 @@ function createLoroBinding(editor, doc, options = {}) {
36761
36761
  };
36762
36762
  const readChildren = (parent, treeNode, visited) => {
36763
36763
  (treeNode.children() ?? []).forEach((child, index) => {
36764
- const node = readNode(child);
36764
+ const node = readNode2(child);
36765
36765
  visited.add(node.getKey());
36766
36766
  const current = parent.getChildAtIndex(index);
36767
36767
  if (!current || !current.is(node)) {
@@ -36824,14 +36824,14 @@ function sliceRuns(runs, start, end) {
36824
36824
  const out = [];
36825
36825
  let offset = 0;
36826
36826
  for (const run2 of runs) {
36827
- const text = run2.text ?? "";
36827
+ const text2 = run2.text ?? "";
36828
36828
  const from = Math.max(start, offset);
36829
- const to3 = Math.min(end, offset + text.length);
36829
+ const to3 = Math.min(end, offset + text2.length);
36830
36830
  if (to3 > from) out.push({
36831
36831
  ...run2,
36832
- text: text.slice(from - offset, to3 - offset)
36832
+ text: text2.slice(from - offset, to3 - offset)
36833
36833
  });
36834
- offset += text.length;
36834
+ offset += text2.length;
36835
36835
  }
36836
36836
  return out;
36837
36837
  }
@@ -36937,10 +36937,10 @@ function $locate(focus) {
36937
36937
  };
36938
36938
  let remaining = focus.offset;
36939
36939
  const texts = block.getChildren().filter($isTextNode2);
36940
- for (const text of texts) {
36941
- const size = text.getTextContentSize();
36940
+ for (const text2 of texts) {
36941
+ const size = text2.getTextContentSize();
36942
36942
  if (remaining <= size) return {
36943
- key: text.getKey(),
36943
+ key: text2.getKey(),
36944
36944
  offset: remaining
36945
36945
  };
36946
36946
  remaining -= size;
@@ -37742,12 +37742,12 @@ function $sliceSelectedTextNodeContent(selection, textNode, mutates = "self") {
37742
37742
  startOffset = 0;
37743
37743
  endOffset = offset;
37744
37744
  }
37745
- const text = textNode.__text.slice(startOffset, endOffset);
37746
- if (text !== textNode.__text) {
37745
+ const text2 = textNode.__text.slice(startOffset, endOffset);
37746
+ if (text2 !== textNode.__text) {
37747
37747
  if (mutates === "clone") {
37748
37748
  textNode = $cloneWithPropertiesEphemeral2(textNode);
37749
37749
  }
37750
- textNode.__text = text;
37750
+ textNode.__text = text2;
37751
37751
  }
37752
37752
  }
37753
37753
  }
@@ -37797,11 +37797,11 @@ function $trimTextContentFromAnchor(editor, anchor, delCount) {
37797
37797
  nextNode = parentSibling;
37798
37798
  }
37799
37799
  }
37800
- let text = currentNode.getTextContent();
37801
- if (text === "" && $isElementNode2(currentNode) && !currentNode.isInline()) {
37802
- text = "\n\n";
37800
+ let text2 = currentNode.getTextContent();
37801
+ if (text2 === "" && $isElementNode2(currentNode) && !currentNode.isInline()) {
37802
+ text2 = "\n\n";
37803
37803
  }
37804
- const currentNodeSize = text.length;
37804
+ const currentNodeSize = text2.length;
37805
37805
  if (!$isTextNode2(currentNode) || remaining >= currentNodeSize) {
37806
37806
  const parent = currentNode.getParent();
37807
37807
  currentNode.remove();
@@ -37820,8 +37820,8 @@ function $trimTextContentFromAnchor(editor, anchor, delCount) {
37820
37820
  return null;
37821
37821
  });
37822
37822
  const offset = currentNodeSize - remaining;
37823
- const slicedText = text.slice(0, offset);
37824
- if (prevTextContent !== null && prevTextContent !== text) {
37823
+ const slicedText = text2.slice(0, offset);
37824
+ if (prevTextContent !== null && prevTextContent !== text2) {
37825
37825
  const prevSelection = $getPreviousSelection2();
37826
37826
  let target = currentNode;
37827
37827
  if (!currentNode.isSimpleText()) {
@@ -39523,11 +39523,11 @@ function $wrapNodeInElement(node, createElementNode) {
39523
39523
  elementNode.append(node);
39524
39524
  return elementNode;
39525
39525
  }
39526
- function objectKlassEquals(object, objectClass) {
39527
- if (object == null) {
39526
+ function objectKlassEquals(object2, objectClass) {
39527
+ if (object2 == null) {
39528
39528
  return false;
39529
39529
  }
39530
- const prototype2 = Object.getPrototypeOf(object);
39530
+ const prototype2 = Object.getPrototypeOf(object2);
39531
39531
  if (prototype2 == null || prototype2.constructor == null) {
39532
39532
  return false;
39533
39533
  }
@@ -43285,8 +43285,8 @@ function isInsidePreserveWhitespace(node, wsConfig) {
43285
43285
  }
43286
43286
  return false;
43287
43287
  }
43288
- function findAdjacentTextOnLine(text, forward, wsConfig) {
43289
- let node = text;
43288
+ function findAdjacentTextOnLine(text2, forward, wsConfig) {
43289
+ let node = text2;
43290
43290
  while (true) {
43291
43291
  let sibling = null;
43292
43292
  while ((sibling = forward ? node.nextSibling : node.previousSibling) === null) {
@@ -43389,10 +43389,10 @@ var TextRule = {
43389
43389
  if (collapsed === "") {
43390
43390
  return [];
43391
43391
  }
43392
- const text = $createTextNode2(collapsed);
43393
- $applyFormat(text, format);
43394
- $applyTextStyle(text, style);
43395
- return [text];
43392
+ const text2 = $createTextNode2(collapsed);
43393
+ $applyFormat(text2, format);
43394
+ $applyTextStyle(text2, style);
43395
+ return [text2];
43396
43396
  },
43397
43397
  match: /* @__PURE__ */ sel$1.text(),
43398
43398
  name: "@lexical/html/#text"
@@ -43496,23 +43496,23 @@ function compileImportRules(rules) {
43496
43496
  wildcardIndices.push(i6);
43497
43497
  } else {
43498
43498
  for (const tag of sel3.tags) {
43499
- let list = byTag.get(tag);
43500
- if (!list) {
43501
- list = [];
43502
- byTag.set(tag, list);
43499
+ let list2 = byTag.get(tag);
43500
+ if (!list2) {
43501
+ list2 = [];
43502
+ byTag.set(tag, list2);
43503
43503
  }
43504
- list.push(i6);
43504
+ list2.push(i6);
43505
43505
  }
43506
43506
  }
43507
43507
  });
43508
43508
  const finalByTag = /* @__PURE__ */ new Map();
43509
43509
  if (wildcardIndices.length === 0) {
43510
- for (const [tag, list] of byTag) {
43511
- finalByTag.set(tag, list);
43510
+ for (const [tag, list2] of byTag) {
43511
+ finalByTag.set(tag, list2);
43512
43512
  }
43513
43513
  } else {
43514
- for (const [tag, list] of byTag) {
43515
- finalByTag.set(tag, mergeSortedAsc(list, wildcardIndices));
43514
+ for (const [tag, list2] of byTag) {
43515
+ finalByTag.set(tag, mergeSortedAsc(list2, wildcardIndices));
43516
43516
  }
43517
43517
  }
43518
43518
  return {
@@ -45507,9 +45507,9 @@ function $getLexicalContent(editor, selection = $getSelection2()) {
45507
45507
  return JSON.stringify($generateJSONFromSelectedNodes(editor, selection));
45508
45508
  }
45509
45509
  function $insertDataTransferForPlainText(dataTransfer, selection) {
45510
- const text = dataTransfer.getData("text/plain") || dataTransfer.getData("text/uri-list");
45511
- if (text != null) {
45512
- selection.insertRawText(text);
45510
+ const text2 = dataTransfer.getData("text/plain") || dataTransfer.getData("text/uri-list");
45511
+ if (text2 != null) {
45512
+ selection.insertRawText(text2);
45513
45513
  }
45514
45514
  }
45515
45515
  function $insertDataTransferForRichText(dataTransfer, selection, _editor) {
@@ -48264,11 +48264,11 @@ var TableSelection = class _TableSelection {
48264
48264
  extract() {
48265
48265
  return this.getNodes();
48266
48266
  }
48267
- insertRawText(text) {
48268
- if (text === "") {
48267
+ insertRawText(text2) {
48268
+ if (text2 === "") {
48269
48269
  return;
48270
48270
  }
48271
- const trimmed = text.endsWith("\n") ? text.slice(0, -1) : text;
48271
+ const trimmed = text2.endsWith("\n") ? text2.slice(0, -1) : text2;
48272
48272
  const tsvGrid = trimmed.split("\n").map((line) => line.split(" "));
48273
48273
  const tableNode = $createTableNode();
48274
48274
  for (const row2 of tsvGrid) {
@@ -51301,17 +51301,17 @@ function $tableSelectionInsertClipboardNodesCommand(selectionPayload, hasNestedT
51301
51301
  const hasTables = nodes.some((n7) => $isTableNode(n7) || $dfs2(n7).some((d9) => $isTableNode(d9.node)));
51302
51302
  if (!hasTables) {
51303
51303
  if ($isTableSelection(selection)) {
51304
- let text = "";
51304
+ let text2 = "";
51305
51305
  let lastWasBlock = false;
51306
51306
  for (const node of nodes) {
51307
51307
  const isBlock = $isElementNode2(node) && !node.isInline();
51308
- if (text.length > 0 && (isBlock || lastWasBlock)) {
51309
- text += "\n";
51308
+ if (text2.length > 0 && (isBlock || lastWasBlock)) {
51309
+ text2 += "\n";
51310
51310
  }
51311
- text += node.getTextContent();
51311
+ text2 += node.getTextContent();
51312
51312
  lastWasBlock = isBlock;
51313
51313
  }
51314
- selection.insertRawText(text);
51314
+ selection.insertRawText(text2);
51315
51315
  return true;
51316
51316
  }
51317
51317
  return false;
@@ -54380,9 +54380,9 @@ function $getEndOfCodeInLine(anchor) {
54380
54380
  }
54381
54381
  return lastNode;
54382
54382
  }
54383
- function $plainifyCodeContent(text) {
54383
+ function $plainifyCodeContent(text2) {
54384
54384
  const out = [];
54385
- tokenizeRawText2(text, {
54385
+ tokenizeRawText2(text2, {
54386
54386
  linebreak: () => out.push($createLineBreakNode2()),
54387
54387
  tab: () => out.push($createTabNode2()),
54388
54388
  text: (part) => out.push($createCodeHighlightNode(part))
@@ -54393,8 +54393,8 @@ function $outdentLeadingSpaces(node, tabSize, selection) {
54393
54393
  if (!Number.isInteger(tabSize) || tabSize <= 0) {
54394
54394
  return false;
54395
54395
  }
54396
- const text = node.getTextContent();
54397
- const leading = /^ +/.exec(text);
54396
+ const text2 = node.getTextContent();
54397
+ const leading = /^ +/.exec(text2);
54398
54398
  if (!leading) {
54399
54399
  return false;
54400
54400
  }
@@ -54553,9 +54553,9 @@ var GENERATED_CODEHIGHLIGHT = (fields) => {
54553
54553
  if (style !== void 0 && style !== "") {
54554
54554
  json.style = style;
54555
54555
  }
54556
- const text = node.__text;
54557
- if (text !== void 0 && text !== "") {
54558
- json.text = text;
54556
+ const text2 = node.__text;
54557
+ if (text2 !== void 0 && text2 !== "") {
54558
+ json.text = text2;
54559
54559
  }
54560
54560
  return json;
54561
54561
  }
@@ -54568,8 +54568,8 @@ var GENERATED_CODEHIGHLIGHT = (fields) => {
54568
54568
  node.__mode = typeof mode === "string" && mode in CODEHIGHLIGHT_MODE_SETTER ? CODEHIGHLIGHT_MODE_SETTER[mode] : CODEHIGHLIGHT_MODE_SETTER_DEFAULT;
54569
54569
  const style = json.style;
54570
54570
  node.__style = typeof style === "string" ? style : "";
54571
- const text = json.text;
54572
- node.__text = typeof text === "string" ? text : "";
54571
+ const text2 = json.text;
54572
+ node.__text = typeof text2 === "string" ? text2 : "";
54573
54573
  const highlightType = json.highlightType;
54574
54574
  node.setHighlightType(highlightType == null ? highlightType : typeof highlightType === "string" ? highlightType : "");
54575
54575
  return node;
@@ -54810,9 +54810,9 @@ var CodeNode = class extends ElementNode2 {
54810
54810
  node = node.getNextSibling();
54811
54811
  } else if ($isCodeHighlightNode(node)) {
54812
54812
  let spaces = 0;
54813
- const text = node.getTextContent();
54813
+ const text2 = node.getTextContent();
54814
54814
  const textSize = node.getTextContentSize();
54815
- while (spaces < textSize && text[spaces] === " ") {
54815
+ while (spaces < textSize && text2[spaces] === " ") {
54816
54816
  spaces++;
54817
54817
  }
54818
54818
  if (spaces !== 0) {
@@ -54974,8 +54974,8 @@ var codeHighlightNodeSchema = /* @__PURE__ */ nodeSchema2()({
54974
54974
  var CodeHighlightNode = class extends TextNode2 {
54975
54975
  /** @internal */
54976
54976
  __highlightType;
54977
- constructor(text = "", highlightType, key2) {
54978
- super(text, key2);
54977
+ constructor(text2 = "", highlightType, key2) {
54978
+ super(text2, key2);
54979
54979
  this.__highlightType = highlightType;
54980
54980
  }
54981
54981
  $config() {
@@ -55031,8 +55031,8 @@ var CodeHighlightNode = class extends TextNode2 {
55031
55031
  function getHighlightThemeClass(theme, highlightType) {
55032
55032
  return highlightType && theme && theme.codeHighlight && theme.codeHighlight[highlightType];
55033
55033
  }
55034
- function $createCodeHighlightNode(text = "", highlightType) {
55035
- return $applyNodeReplacement2(new CodeHighlightNode(text, highlightType));
55034
+ function $createCodeHighlightNode(text2 = "", highlightType) {
55035
+ return $applyNodeReplacement2(new CodeHighlightNode(text2, highlightType));
55036
55036
  }
55037
55037
  function $isCodeHighlightNode(node) {
55038
55038
  return node instanceof CodeHighlightNode;
@@ -55064,8 +55064,8 @@ var PreRule = {
55064
55064
  };
55065
55065
  var MultilineCodeRule = {
55066
55066
  $import: (ctx, el2, $next) => {
55067
- const text = el2.textContent || "";
55068
- const isMultiLine = /\r?\n/.test(text) || el2.querySelector("br") !== null;
55067
+ const text2 = el2.textContent || "";
55068
+ const isMultiLine = /\r?\n/.test(text2) || el2.querySelector("br") !== null;
55069
55069
  if (!isMultiLine) {
55070
55070
  return $next();
55071
55071
  }
@@ -56626,8 +56626,8 @@ var AriaLiveRegionExtension = {
56626
56626
  const message = state.getInitResult();
56627
56627
  return {
56628
56628
  ...namedSignals2(config),
56629
- announce(text) {
56630
- message.value = text === message.peek() ? text + "\u200B" : text;
56629
+ announce(text2) {
56630
+ message.value = text2 === message.peek() ? text2 + "\u200B" : text2;
56631
56631
  }
56632
56632
  };
56633
56633
  },
@@ -56682,10 +56682,10 @@ var AriaLiveRegionExtension = {
56682
56682
  // region would make the screen reader re-announce it on every editor
56683
56683
  // remount with no user action.
56684
56684
  effect(() => {
56685
- const text = message.value;
56685
+ const text2 = message.value;
56686
56686
  const el2 = region.peek();
56687
56687
  if (el2) {
56688
- el2.textContent = text;
56688
+ el2.textContent = text2;
56689
56689
  }
56690
56690
  })
56691
56691
  );
@@ -57968,9 +57968,9 @@ var ClickableLinkExtension = {
57968
57968
  }
57969
57969
  };
57970
57970
  // @__NO_SIDE_EFFECTS__
57971
- function createLinkMatcherWithRegExp(regExp, urlTransformer = (text) => text) {
57972
- return (text) => {
57973
- const match = regExp.exec(text);
57971
+ function createLinkMatcherWithRegExp(regExp, urlTransformer = (text2) => text2) {
57972
+ return (text2) => {
57973
+ const match = regExp.exec(text2);
57974
57974
  if (match === null) {
57975
57975
  return null;
57976
57976
  }
@@ -57984,8 +57984,8 @@ function createLinkMatcherWithRegExp(regExp, urlTransformer = (text) => text) {
57984
57984
  }
57985
57985
  var URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-\p{L}\p{N}@:%._+~#=]{1,256}\.[\p{L}\p{N}]{1,6}(?:[-\p{L}\p{N}()@:%_+.~#?&//=]*[\p{L}\p{N}()@_~#?&//=])?/u;
57986
57986
  var EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]{1,64}(\.[^<>()[\]\\.,;:\s@"]{1,64}){0,63})|(".{1,255}"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]{1,63}\.){1,127}[a-zA-Z]{2,63}))/;
57987
- var autoLinkUrlMatcher = (text) => {
57988
- const match = URL_REGEX.exec(text);
57987
+ var autoLinkUrlMatcher = (text2) => {
57988
+ const match = URL_REGEX.exec(text2);
57989
57989
  if (match === null) {
57990
57990
  return null;
57991
57991
  }
@@ -58009,10 +58009,10 @@ var autoLinkUrlMatcher = (text) => {
58009
58009
  url: matched.startsWith("http") ? matched : `https://${matched}`
58010
58010
  };
58011
58011
  };
58012
- var autoLinkEmailMatcher = /* @__PURE__ */ createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => `mailto:${text}`);
58013
- function findFirstMatch(text, matchers) {
58012
+ var autoLinkEmailMatcher = /* @__PURE__ */ createLinkMatcherWithRegExp(EMAIL_REGEX, (text2) => `mailto:${text2}`);
58013
+ function findFirstMatch(text2, matchers) {
58014
58014
  for (let i6 = 0; i6 < matchers.length; i6++) {
58015
- const match = matchers[i6](text);
58015
+ const match = matchers[i6](text2);
58016
58016
  if (match) {
58017
58017
  return match;
58018
58018
  }
@@ -58050,12 +58050,12 @@ function isNextNodeValid(node, separatorRegex) {
58050
58050
  }
58051
58051
  return nextNode === null || $isLineBreakNode2(nextNode) || $isTextNode2(nextNode) && startsWithSeparator(nextNode.getTextContent(), separatorRegex);
58052
58052
  }
58053
- function isContentAroundIsValid(matchStart, matchEnd, separatorRegex, text, nodes) {
58054
- const contentBeforeIsValid = matchStart > 0 ? isSeparator(text[matchStart - 1], separatorRegex) : isPreviousNodeValid(nodes[0], separatorRegex);
58053
+ function isContentAroundIsValid(matchStart, matchEnd, separatorRegex, text2, nodes) {
58054
+ const contentBeforeIsValid = matchStart > 0 ? isSeparator(text2[matchStart - 1], separatorRegex) : isPreviousNodeValid(nodes[0], separatorRegex);
58055
58055
  if (!contentBeforeIsValid) {
58056
58056
  return false;
58057
58057
  }
58058
- const contentAfterIsValid = matchEnd < text.length ? isSeparator(text[matchEnd], separatorRegex) : isNextNodeValid(nodes[nodes.length - 1], separatorRegex);
58058
+ const contentAfterIsValid = matchEnd < text2.length ? isSeparator(text2[matchEnd], separatorRegex) : isNextNodeValid(nodes[nodes.length - 1], separatorRegex);
58059
58059
  return contentAfterIsValid;
58060
58060
  }
58061
58061
  function extractMatchingNodes(nodes, startIndex, endIndex) {
@@ -58157,10 +58157,10 @@ function $handleLinkCreation(nodes, matchers, onChange, separatorRegex) {
58157
58157
  }
58158
58158
  let currentNodes = [...nodes];
58159
58159
  const initialText = currentNodes.map((node) => node.getTextContent()).join("");
58160
- let text = initialText;
58160
+ let text2 = initialText;
58161
58161
  let match;
58162
58162
  let invalidMatchEnd = 0;
58163
- while ((match = findFirstMatch(text, matchers)) && match !== null) {
58163
+ while ((match = findFirstMatch(text2, matchers)) && match !== null) {
58164
58164
  const matchStart = match.index;
58165
58165
  const matchLength = match.length;
58166
58166
  const matchEnd = matchStart + matchLength;
@@ -58177,7 +58177,7 @@ function $handleLinkCreation(nodes, matchers, onChange, separatorRegex) {
58177
58177
  }
58178
58178
  if (alreadyLinked) {
58179
58179
  invalidMatchEnd += matchEnd;
58180
- text = text.substring(matchEnd);
58180
+ text2 = text2.substring(matchEnd);
58181
58181
  continue;
58182
58182
  }
58183
58183
  const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset;
@@ -58189,7 +58189,7 @@ function $handleLinkCreation(nodes, matchers, onChange, separatorRegex) {
58189
58189
  } else {
58190
58190
  invalidMatchEnd += matchEnd;
58191
58191
  }
58192
- text = text.substring(matchEnd);
58192
+ text2 = text2.substring(matchEnd);
58193
58193
  }
58194
58194
  }
58195
58195
  function handleLinkEdit(linkNode, matchers, onChange, separatorRegex) {
@@ -58203,9 +58203,9 @@ function handleLinkEdit(linkNode, matchers, onChange, separatorRegex) {
58203
58203
  return;
58204
58204
  }
58205
58205
  }
58206
- const text = linkNode.getTextContent();
58207
- const match = findFirstMatch(text, matchers);
58208
- if (match === null || match.text !== text) {
58206
+ const text2 = linkNode.getTextContent();
58207
+ const match = findFirstMatch(text2, matchers);
58208
+ if (match === null || match.text !== text2) {
58209
58209
  replaceWithChildren(linkNode);
58210
58210
  onChange(null, linkNode.getURL());
58211
58211
  return;
@@ -58236,19 +58236,19 @@ function handleBadNeighbors(textNode, matchers, onChange, separatorRegex) {
58236
58236
  const parent = textNode.getParent();
58237
58237
  const previousSibling2 = textNode.getPreviousSibling();
58238
58238
  const nextSibling2 = textNode.getNextSibling();
58239
- const text = textNode.getTextContent();
58239
+ const text2 = textNode.getTextContent();
58240
58240
  if ($isAutoLinkNode(parent) && !parent.getIsUnlinked()) {
58241
58241
  return;
58242
58242
  }
58243
58243
  if ($isAutoLinkNode(previousSibling2) && !previousSibling2.getIsUnlinked()) {
58244
58244
  if (previousSibling2.is(textNode.getPreviousSibling()) && textNode.getParent() === previousSibling2.getParent()) {
58245
- if (!startsWithSeparator(text, separatorRegex)) {
58245
+ if (!startsWithSeparator(text2, separatorRegex)) {
58246
58246
  replaceWithChildren(previousSibling2);
58247
58247
  onChange(null, previousSibling2.getURL());
58248
58248
  return;
58249
58249
  }
58250
- if (startsWithTLD(text, previousSibling2.isEmailURI())) {
58251
- const combinedText = previousSibling2.getTextContent() + text;
58250
+ if (startsWithTLD(text2, previousSibling2.isEmailURI())) {
58251
+ const combinedText = previousSibling2.getTextContent() + text2;
58252
58252
  const match = findFirstMatch(combinedText, matchers);
58253
58253
  if (match !== null && match.text === combinedText) {
58254
58254
  previousSibling2.append(textNode);
@@ -58258,7 +58258,7 @@ function handleBadNeighbors(textNode, matchers, onChange, separatorRegex) {
58258
58258
  }
58259
58259
  }
58260
58260
  }
58261
- if ($isAutoLinkNode(nextSibling2) && !nextSibling2.getIsUnlinked() && !endsWithSeparator(text, separatorRegex)) {
58261
+ if ($isAutoLinkNode(nextSibling2) && !nextSibling2.getIsUnlinked() && !endsWithSeparator(text2, separatorRegex)) {
58262
58262
  if (nextSibling2.is(textNode.getNextSibling()) && textNode.getParent() === nextSibling2.getParent()) {
58263
58263
  replaceWithChildren(nextSibling2);
58264
58264
  onChange(null, nextSibling2.getURL());
@@ -59133,15 +59133,15 @@ function $getTopListNode(listItem) {
59133
59133
  formatDevErrorMessage12(`A ListItemNode must have a ListNode for a parent.`);
59134
59134
  }
59135
59135
  }
59136
- let list = parentList;
59136
+ let list2 = parentList;
59137
59137
  let parent = parentList;
59138
59138
  while (parent !== null) {
59139
59139
  parent = parent.getParent();
59140
59140
  if ($isListNode(parent)) {
59141
- list = parent;
59141
+ list2 = parent;
59142
59142
  }
59143
59143
  }
59144
- return list;
59144
+ return list2;
59145
59145
  }
59146
59146
  function $getAllListItems(node) {
59147
59147
  let listItemNodes = [];
@@ -59171,14 +59171,14 @@ function $removeHighestEmptyListParent(sublist) {
59171
59171
  }
59172
59172
  emptyListPtr.remove();
59173
59173
  }
59174
- function $getNewListStart(list, listItem) {
59174
+ function $getNewListStart(list2, listItem) {
59175
59175
  return listItem.getValue();
59176
59176
  }
59177
59177
  function $isSelectingEmptyListItem(anchorNode, nodes) {
59178
59178
  return $isListItemNode(anchorNode) && (nodes.length === 0 || nodes.length === 1 && anchorNode.is(nodes[0]) && anchorNode.getChildrenSize() === 0);
59179
59179
  }
59180
- function $newListFrom(list, listType) {
59181
- return $isListNode(list) ? $copyNode2(list).setListType(listType) : $createListNode(listType);
59180
+ function $newListFrom(list2, listType) {
59181
+ return $isListNode(list2) ? $copyNode2(list2).setListType(listType) : $createListNode(listType);
59182
59182
  }
59183
59183
  function $insertList(listType) {
59184
59184
  const selection = $getSelection2();
@@ -59199,20 +59199,20 @@ function $insertList(listType) {
59199
59199
  }
59200
59200
  } else if ($isSelectingEmptyListItem(anchorNode, nodes)) {
59201
59201
  if ($isRootOrShadowRoot2(anchorNodeParent)) {
59202
- const list = $createListNode(listType);
59203
- anchorNode.replace(list);
59202
+ const list2 = $createListNode(listType);
59203
+ anchorNode.replace(list2);
59204
59204
  const listItem = $createListItemNode();
59205
59205
  if ($isElementNode2(anchorNode)) {
59206
59206
  listItem.setFormat(anchorNode.getFormatType());
59207
59207
  listItem.setIndent(anchorNode.getIndent());
59208
59208
  }
59209
- list.append(listItem);
59209
+ list2.append(listItem);
59210
59210
  } else if ($isListItemNode(anchorNode)) {
59211
59211
  const parent = anchorNode.getParentOrThrow();
59212
59212
  if ($getSlotHost2(parent) === null) {
59213
- const list = $newListFrom(parent, listType);
59214
- append(list, parent.getChildren());
59215
- parent.replace(list);
59213
+ const list2 = $newListFrom(parent, listType);
59214
+ append(list2, parent.getChildren());
59215
+ parent.replace(list2);
59216
59216
  }
59217
59217
  }
59218
59218
  return;
@@ -59275,10 +59275,10 @@ function $createListOrMerge(node, listType) {
59275
59275
  nextSibling2.getFirstChildOrThrow().insertBefore(listItem);
59276
59276
  targetList = nextSibling2;
59277
59277
  } else {
59278
- const list = $createListNode(listType);
59279
- list.append(listItem);
59280
- node.replace(list);
59281
- targetList = list;
59278
+ const list2 = $createListNode(listType);
59279
+ list2.append(listItem);
59280
+ node.replace(list2);
59281
+ targetList = list2;
59282
59282
  }
59283
59283
  listItem.setFormat(node.getFormatType());
59284
59284
  listItem.setIndent(node.getIndent());
@@ -59352,10 +59352,10 @@ function $removeList() {
59352
59352
  }
59353
59353
  }
59354
59354
  }
59355
- function updateChildrenListItemValue(list) {
59356
- const isNotChecklist = list.getListType() !== "check";
59357
- let value = list.getStart();
59358
- for (const child of list.getChildren()) {
59355
+ function updateChildrenListItemValue(list2) {
59356
+ const isNotChecklist = list2.getListType() !== "check";
59357
+ let value = list2.getStart();
59358
+ for (const child of list2.getChildren()) {
59359
59359
  if ($isListItemNode(child)) {
59360
59360
  if (child.getValue() !== value) {
59361
59361
  child.setValue(value);
@@ -59369,10 +59369,10 @@ function updateChildrenListItemValue(list) {
59369
59369
  }
59370
59370
  }
59371
59371
  }
59372
- function mergeNextSiblingListIfSameType(list) {
59373
- const nextSibling2 = list.getNextSibling();
59374
- if ($isListNode(nextSibling2) && list.getListType() === nextSibling2.getListType()) {
59375
- mergeLists(list, nextSibling2);
59372
+ function mergeNextSiblingListIfSameType(list2) {
59373
+ const nextSibling2 = list2.getNextSibling();
59374
+ if ($isListNode(nextSibling2) && list2.getListType() === nextSibling2.getListType()) {
59375
+ mergeLists(list2, nextSibling2);
59376
59376
  }
59377
59377
  }
59378
59378
  function $handleIndent(listItemNode) {
@@ -59874,23 +59874,23 @@ var ListItemNode = class extends ElementNode2 {
59874
59874
  return super.replace(replaceWithNode);
59875
59875
  }
59876
59876
  this.setIndent(0);
59877
- const list = this.getParentOrThrow();
59878
- if (!$isListNode(list)) {
59877
+ const list2 = this.getParentOrThrow();
59878
+ if (!$isListNode(list2)) {
59879
59879
  return replaceWithNode;
59880
59880
  }
59881
- if (list.__first === this.getKey()) {
59882
- list.insertBefore(replaceWithNode);
59883
- } else if (list.__last === this.getKey()) {
59884
- list.insertAfter(replaceWithNode);
59881
+ if (list2.__first === this.getKey()) {
59882
+ list2.insertBefore(replaceWithNode);
59883
+ } else if (list2.__last === this.getKey()) {
59884
+ list2.insertAfter(replaceWithNode);
59885
59885
  } else {
59886
- const newList = $copyNode2(list);
59886
+ const newList = $copyNode2(list2);
59887
59887
  let nextSibling2 = this.getNextSibling();
59888
59888
  while (nextSibling2) {
59889
59889
  const nodeToAppend = nextSibling2;
59890
59890
  nextSibling2 = nextSibling2.getNextSibling();
59891
59891
  newList.append(nodeToAppend);
59892
59892
  }
59893
- list.insertAfter(replaceWithNode);
59893
+ list2.insertAfter(replaceWithNode);
59894
59894
  replaceWithNode.insertAfter(newList);
59895
59895
  }
59896
59896
  const toReplaceKey = this.__key;
@@ -59913,8 +59913,8 @@ var ListItemNode = class extends ElementNode2 {
59913
59913
  }
59914
59914
  }
59915
59915
  this.remove();
59916
- if (list.getChildrenSize() === 0) {
59917
- list.remove();
59916
+ if (list2.getChildrenSize() === 0) {
59917
+ list2.remove();
59918
59918
  }
59919
59919
  return replaceWithNode;
59920
59920
  }
@@ -62409,8 +62409,8 @@ function handleMessage(event) {
62409
62409
  if (payload && payload.functionId === "makeChanges") {
62410
62410
  const args = payload.args;
62411
62411
  if (Array.isArray(args)) {
62412
- const [elementStart, elementLength, text, selStart, selLength, formatCommand] = args;
62413
- if (![elementStart, elementLength, selStart, selLength].every(Number.isFinite) || typeof text !== "string" && text !== -1) {
62412
+ const [elementStart, elementLength, text2, selStart, selLength, formatCommand] = args;
62413
+ if (![elementStart, elementLength, selStart, selLength].every(Number.isFinite) || typeof text2 !== "string" && text2 !== -1) {
62414
62414
  return;
62415
62415
  }
62416
62416
  editor.update(() => {
@@ -62427,8 +62427,8 @@ function handleMessage(event) {
62427
62427
  selection.setTextNodeRange(anchorNode, setSelStart, anchorNode, setSelEnd);
62428
62428
  }
62429
62429
  }
62430
- if (typeof text === "string" && (setSelStart !== setSelEnd || text !== "")) {
62431
- selection.insertRawText(text);
62430
+ if (typeof text2 === "string" && (setSelStart !== setSelEnd || text2 !== "")) {
62431
+ selection.insertRawText(text2);
62432
62432
  anchorNode = anchor.getNode();
62433
62433
  }
62434
62434
  if ($isTextNode2(anchorNode)) {
@@ -64994,9 +64994,9 @@ var quoteShadowRootState2 = mod27.quoteShadowRootState;
64994
64994
  var registerRichText2 = mod27.registerRichText;
64995
64995
 
64996
64996
  // node_modules/.pnpm/@lexical+markdown@0.52.0_typescript@5.9.3/node_modules/@lexical/markdown/dist/LexicalMarkdown.dev.js
64997
- function indexBy(list, callback) {
64997
+ function indexBy(list2, callback) {
64998
64998
  const index = {};
64999
- for (const item of list) {
64999
+ for (const item of list2) {
65000
65000
  const key2 = callback(item);
65001
65001
  if (!key2) {
65002
65002
  continue;
@@ -65136,8 +65136,8 @@ function $extractMarkdownHardLineBreakMarker(previousNode) {
65136
65136
  const lastText = lastChild.getTextContent();
65137
65137
  const hardLineBreak = parseMarkdownHardLineBreak(lastText);
65138
65138
  if (hardLineBreak !== null) {
65139
- const [text, marker] = hardLineBreak;
65140
- lastChild.setTextContent(text);
65139
+ const [text2, marker] = hardLineBreak;
65140
+ lastChild.setTextContent(text2);
65141
65141
  return marker;
65142
65142
  }
65143
65143
  if (/^ {2,}$/.test(lastText) && hasNonWhitespaceContentOnLine(children, lastChildIndex)) {
@@ -65281,9 +65281,9 @@ var listReplace = /* @__NO_SIDE_EFFECTS__ */ (listType) => {
65281
65281
  precedingBlock.append(listItem);
65282
65282
  parentNode.remove();
65283
65283
  } else {
65284
- const list = $createListNode2(listType, listType === "number" ? Number(match[2]) : void 0);
65285
- list.append(listItem);
65286
- parentNode.replace(list);
65284
+ const list2 = $createListNode2(listType, listType === "number" ? Number(match[2]) : void 0);
65285
+ list2.append(listItem);
65286
+ parentNode.replace(list2);
65287
65287
  }
65288
65288
  listItem.append(...children);
65289
65289
  if (!isImport) {
@@ -66110,20 +66110,20 @@ function findOutermostTextFormatTransformer(textNode, textFormatTransformersInde
66110
66110
  transformer: resultTransformer
66111
66111
  };
66112
66112
  }
66113
- function scanCodeSpans(text) {
66113
+ function scanCodeSpans(text2) {
66114
66114
  const isEscaped = (index) => {
66115
66115
  let count = 0;
66116
- for (let i7 = index - 1; i7 >= 0 && text[i7] === "\\"; i7--) {
66116
+ for (let i7 = index - 1; i7 >= 0 && text2[i7] === "\\"; i7--) {
66117
66117
  count++;
66118
66118
  }
66119
66119
  return count % 2 === 1;
66120
66120
  };
66121
66121
  const runs = [];
66122
66122
  let i6 = 0;
66123
- while (i6 < text.length) {
66124
- if (text[i6] === "`") {
66123
+ while (i6 < text2.length) {
66124
+ if (text2[i6] === "`") {
66125
66125
  let length = 1;
66126
- while (i6 + length < text.length && text[i6 + length] === "`") {
66126
+ while (i6 + length < text2.length && text2[i6 + length] === "`") {
66127
66127
  length++;
66128
66128
  }
66129
66129
  runs.push({
@@ -66155,7 +66155,7 @@ function scanCodeSpans(text) {
66155
66155
  continue;
66156
66156
  }
66157
66157
  const closer = runs[closeIdx];
66158
- let content = text.slice(opener.index + opener.length, closer.index);
66158
+ let content = text2.slice(opener.index + opener.length, closer.index);
66159
66159
  if (content.length >= 2 && content.startsWith(" ") && content.endsWith(" ") && /[^ ]/.test(content)) {
66160
66160
  content = content.slice(1, -1);
66161
66161
  }
@@ -66168,12 +66168,12 @@ function scanCodeSpans(text) {
66168
66168
  }
66169
66169
  return spans;
66170
66170
  }
66171
- function scanDelimiters(text, transformersIndex, excludeRanges = []) {
66171
+ function scanDelimiters(text2, transformersIndex, excludeRanges = []) {
66172
66172
  const delimiters = [];
66173
66173
  const delimiterChars = new Set(Object.keys(transformersIndex.transformersByTag).filter((tag) => tag[0] !== "`").map((tag) => tag[0]));
66174
66174
  const isEscaped = (index) => {
66175
66175
  let count = 0;
66176
- for (let i7 = index - 1; i7 >= 0 && text[i7] === "\\"; i7--) {
66176
+ for (let i7 = index - 1; i7 >= 0 && text2[i7] === "\\"; i7--) {
66177
66177
  count++;
66178
66178
  }
66179
66179
  return count % 2 === 1;
@@ -66182,18 +66182,18 @@ function scanDelimiters(text, transformersIndex, excludeRanges = []) {
66182
66182
  return excludeRanges.some((range) => index >= range.start && index < range.end);
66183
66183
  };
66184
66184
  let i6 = 0;
66185
- while (i6 < text.length) {
66186
- const char = text[i6];
66185
+ while (i6 < text2.length) {
66186
+ const char = text2[i6];
66187
66187
  if (!delimiterChars.has(char) || isEscaped(i6) || isInExcludedRange(i6)) {
66188
66188
  i6++;
66189
66189
  continue;
66190
66190
  }
66191
66191
  let len = 1;
66192
- while (i6 + len < text.length && text[i6 + len] === char) {
66192
+ while (i6 + len < text2.length && text2[i6 + len] === char) {
66193
66193
  len++;
66194
66194
  }
66195
- const canOpen = canEmphasis(char, text, i6, len, true);
66196
- const canClose = canEmphasis(char, text, i6, len, false);
66195
+ const canOpen = canEmphasis(char, text2, i6, len, true);
66196
+ const canClose = canEmphasis(char, text2, i6, len, false);
66197
66197
  if (canOpen || canClose) {
66198
66198
  delimiters.push({
66199
66199
  active: true,
@@ -66208,7 +66208,7 @@ function scanDelimiters(text, transformersIndex, excludeRanges = []) {
66208
66208
  }
66209
66209
  return delimiters;
66210
66210
  }
66211
- function processEmphasis(text, delimiters, transformersIndex) {
66211
+ function processEmphasis(text2, delimiters, transformersIndex) {
66212
66212
  const openersBottom = {};
66213
66213
  let currentPos = 0;
66214
66214
  let result = null;
@@ -66240,7 +66240,7 @@ function processEmphasis(text, delimiters, transformersIndex) {
66240
66240
  foundOpener = true;
66241
66241
  const matchLen = matchedTag.length;
66242
66242
  const match = {
66243
- content: text.slice(opener.index + opener.length, closer.index),
66243
+ content: text2.slice(opener.index + opener.length, closer.index),
66244
66244
  endIndex: closer.index + matchLen,
66245
66245
  startIndex: opener.index + (opener.length - matchLen),
66246
66246
  tag: matchedTag
@@ -66272,25 +66272,25 @@ function processEmphasis(text, delimiters, transformersIndex) {
66272
66272
  }
66273
66273
  return result;
66274
66274
  }
66275
- function canEmphasis(char, text, index, length, isOpen) {
66276
- if (!isFlanking(text, index, length, isOpen)) {
66275
+ function canEmphasis(char, text2, index, length, isOpen) {
66276
+ if (!isFlanking(text2, index, length, isOpen)) {
66277
66277
  return false;
66278
66278
  }
66279
66279
  if (char === "*") {
66280
66280
  return true;
66281
66281
  }
66282
66282
  if (char === "_") {
66283
- if (!isFlanking(text, index, length, !isOpen)) {
66283
+ if (!isFlanking(text2, index, length, !isOpen)) {
66284
66284
  return true;
66285
66285
  }
66286
- const adjacentChar = isOpen ? text[index - 1] : text[index + length];
66286
+ const adjacentChar = isOpen ? text2[index - 1] : text2[index + length];
66287
66287
  return adjacentChar !== void 0 && PUNCTUATION.test(adjacentChar);
66288
66288
  }
66289
66289
  return true;
66290
66290
  }
66291
- function isFlanking(text, index, length, isLeft) {
66292
- const charBefore = text[index - 1];
66293
- const charAfter = text[index + length];
66291
+ function isFlanking(text2, index, length, isLeft) {
66292
+ const charBefore = text2[index - 1];
66293
+ const charAfter = text2[index + length];
66294
66294
  const [primary, secondary] = isLeft ? [charAfter, charBefore] : [charBefore, charAfter];
66295
66295
  if (primary === void 0 || WHITESPACE.test(primary)) {
66296
66296
  return false;
@@ -66510,11 +66510,11 @@ function $importMultiline(lines, startLineIndex, multilineElementTransformers, r
66510
66510
  } else {
66511
66511
  for (let i6 = startLineIndex; i6 <= endLineIndex; i6++) {
66512
66512
  if (i6 === startLineIndex) {
66513
- const text = lines[i6].slice(startMatch[0].length);
66514
- linesInBetween.push(text);
66513
+ const text2 = lines[i6].slice(startMatch[0].length);
66514
+ linesInBetween.push(text2);
66515
66515
  } else if (i6 === endLineIndex && endMatch) {
66516
- const text = lines[i6].slice(0, -endMatch[0].length);
66517
- linesInBetween.push(text);
66516
+ const text2 = lines[i6].slice(0, -endMatch[0].length);
66517
+ linesInBetween.push(text2);
66518
66518
  } else {
66519
66519
  linesInBetween.push(lines[i6]);
66520
66520
  }
@@ -66570,23 +66570,23 @@ function $normalizeMarkdownTextNode(textNode) {
66570
66570
  if ($isTabNode2(textNode)) {
66571
66571
  return;
66572
66572
  }
66573
- const text = textNode.getTextContent();
66574
- if (!text.includes(" ")) {
66573
+ const text2 = textNode.getTextContent();
66574
+ if (!text2.includes(" ")) {
66575
66575
  return;
66576
66576
  }
66577
66577
  const format = textNode.getFormat();
66578
66578
  const style = textNode.getStyle();
66579
66579
  const nodes = [];
66580
66580
  let start = 0;
66581
- for (let index = text.indexOf(" "); index !== -1; index = text.indexOf(" ", index + 1)) {
66581
+ for (let index = text2.indexOf(" "); index !== -1; index = text2.indexOf(" ", index + 1)) {
66582
66582
  if (index > start) {
66583
- nodes.push($createTextNode2(text.slice(start, index)).setFormat(format).setStyle(style));
66583
+ nodes.push($createTextNode2(text2.slice(start, index)).setFormat(format).setStyle(style));
66584
66584
  }
66585
66585
  nodes.push($createTabNode2());
66586
66586
  start = index + 1;
66587
66587
  }
66588
- if (start < text.length) {
66589
- nodes.push($createTextNode2(text.slice(start)).setFormat(format).setStyle(style));
66588
+ if (start < text2.length) {
66589
+ nodes.push($createTextNode2(text2.slice(start)).setFormat(format).setStyle(style));
66590
66590
  }
66591
66591
  textNode.getParentOrThrow().splice(textNode.getIndexWithinParent(), 1, nodes);
66592
66592
  }
@@ -66810,9 +66810,9 @@ function $runTextFormatTransformers(anchorNode, anchorOffset, textFormatTransfor
66810
66810
  }
66811
66811
  function $isInsideUnclosedCodeSpan(node, offset) {
66812
66812
  let backtickCount = 0;
66813
- const text = node.getTextContent();
66813
+ const text2 = node.getTextContent();
66814
66814
  for (let i6 = 0; i6 < offset; i6++) {
66815
- if (text[i6] === "`") {
66815
+ if (text2[i6] === "`") {
66816
66816
  backtickCount++;
66817
66817
  }
66818
66818
  }
@@ -68120,10 +68120,10 @@ var LEGACY_CODE_NODE_TRANSFORMER = {
68120
68120
  export: (node) => {
68121
68121
  if (node.getType() !== "code") return null;
68122
68122
  const lang = node.getLanguage?.() ?? "";
68123
- const text = node.getTextContent();
68124
- const f6 = fence(text);
68123
+ const text2 = node.getTextContent();
68124
+ const f6 = fence(text2);
68125
68125
  return `${f6}${lang}
68126
- ${text}
68126
+ ${text2}
68127
68127
  ${f6}`;
68128
68128
  },
68129
68129
  regExp: NEVER,
@@ -72347,10 +72347,10 @@ function registerCustomWriters(registry2) {
72347
72347
  registry2.registerWriter("footnote-section", (node) => {
72348
72348
  const n7 = node;
72349
72349
  const defs = n7.definitions ?? {};
72350
- const children = Object.entries(defs).map(([ref, text]) => ({
72350
+ const children = Object.entries(defs).map(([ref, text2]) => ({
72351
72351
  tag: "def",
72352
72352
  attrs: { ref },
72353
- children: [text]
72353
+ children: [text2]
72354
72354
  }));
72355
72355
  return {
72356
72356
  tag: "footnote-section",
@@ -72486,8 +72486,8 @@ var FORMAT_TAG_TO_BIT = {
72486
72486
  sup: 64,
72487
72487
  mark: 128
72488
72488
  };
72489
- function wrapWithFormatTags(text, format) {
72490
- return wrapContentWithFormatTags([text], format);
72489
+ function wrapWithFormatTags(text2, format) {
72490
+ return wrapContentWithFormatTags([text2], format);
72491
72491
  }
72492
72492
  function wrapContentWithFormatTags(content, format) {
72493
72493
  if (format === 0) return content;
@@ -72513,8 +72513,8 @@ var ESCAPE_MAP = {
72513
72513
  '"': "&quot;",
72514
72514
  "'": "&apos;"
72515
72515
  };
72516
- function escapeXml(text) {
72517
- return text.replaceAll(/["&'<>]/g, (ch) => ESCAPE_MAP[ch]);
72516
+ function escapeXml(text2) {
72517
+ return text2.replaceAll(/["&'<>]/g, (ch) => ESCAPE_MAP[ch]);
72518
72518
  }
72519
72519
  function buildAttrs(attrs) {
72520
72520
  return Object.entries(attrs).filter(([, v6]) => v6 !== void 0 && v6 !== "").map(([k5, v6]) => ` ${k5}="${escapeXml(v6)}"`).join("");
@@ -72774,10 +72774,10 @@ function parseFallbackNode(element) {
72774
72774
  version: 1
72775
72775
  };
72776
72776
  }
72777
- function makeTextNode(text, format) {
72777
+ function makeTextNode(text2, format) {
72778
72778
  return {
72779
72779
  type: "text",
72780
- text,
72780
+ text: text2,
72781
72781
  format,
72782
72782
  detail: 0,
72783
72783
  mode: "normal",
@@ -74955,11 +74955,11 @@ var DomHandler = class {
74955
74955
  this.lastNode = null;
74956
74956
  }
74957
74957
  oncdatastart() {
74958
- const text = new Text2("");
74959
- const node = new CDATA2([text]);
74958
+ const text2 = new Text2("");
74959
+ const node = new CDATA2([text2]);
74960
74960
  this.addNode(node);
74961
- text.parent = node;
74962
- this.lastNode = text;
74961
+ text2.parent = node;
74962
+ this.lastNode = text2;
74963
74963
  }
74964
74964
  oncdataend() {
74965
74965
  this.lastNode = null;
@@ -76640,11 +76640,11 @@ var parseFromString = (document2, isHTML, markupLanguage) => {
76640
76640
  oncomment(data) {
76641
76641
  append3(node, document2.createComment(data), active);
76642
76642
  },
76643
- ontext(text) {
76643
+ ontext(text2) {
76644
76644
  if (parsingCData) {
76645
- append3(node, document2.createCDATASection(text), active);
76645
+ append3(node, document2.createCDATASection(text2), active);
76646
76646
  } else {
76647
- append3(node, document2.createTextNode(text), active);
76647
+ append3(node, document2.createTextNode(text2), active);
76648
76648
  }
76649
76649
  },
76650
76650
  // #cdata
@@ -78558,10 +78558,10 @@ function getOneElement2(tagName19, node) {
78558
78558
  function fetch3(tagName19, where, recurse = false) {
78559
78559
  return textContent2(getElementsByTagName2(tagName19, where, recurse, 1)).trim();
78560
78560
  }
78561
- function addConditionally2(object, property, tagName19, where, recurse = false) {
78561
+ function addConditionally2(object2, property2, tagName19, where, recurse = false) {
78562
78562
  const value = fetch3(tagName19, where, recurse);
78563
78563
  if (value)
78564
- object[property] = value;
78564
+ object2[property2] = value;
78565
78565
  }
78566
78566
  function isValidFeed2(value) {
78567
78567
  return value === "rss" || value === "feed" || value === "rdf:RDF";
@@ -79260,12 +79260,12 @@ function compileNth(reverse, ofType) {
79260
79260
  };
79261
79261
  }
79262
79262
  var filters = {
79263
- contains(next, text, options) {
79263
+ contains(next, text2, options) {
79264
79264
  const { getText: getText4 } = options.adapter;
79265
- return cacheParentResults(next, options, (element) => getText4(element).includes(text));
79265
+ return cacheParentResults(next, options, (element) => getText4(element).includes(text2));
79266
79266
  },
79267
- icontains(next, text, options) {
79268
- const itext = text.toLowerCase();
79267
+ icontains(next, text2, options) {
79268
+ const itext = text2.toLowerCase();
79269
79269
  const { getText: getText4 } = options.adapter;
79270
79270
  return cacheParentResults(next, options, (element) => getText4(element).toLowerCase().includes(itext));
79271
79271
  },
@@ -79929,24 +79929,24 @@ var Text4 = class _Text extends CharacterData {
79929
79929
  super(ownerDocument, "#text", TEXT_NODE, data);
79930
79930
  }
79931
79931
  get wholeText() {
79932
- const text = [];
79932
+ const text2 = [];
79933
79933
  let { previousSibling: previousSibling2, nextSibling: nextSibling2 } = this;
79934
79934
  while (previousSibling2) {
79935
79935
  if (previousSibling2.nodeType === TEXT_NODE)
79936
- text.unshift(previousSibling2[VALUE]);
79936
+ text2.unshift(previousSibling2[VALUE]);
79937
79937
  else
79938
79938
  break;
79939
79939
  previousSibling2 = previousSibling2.previousSibling;
79940
79940
  }
79941
- text.push(this[VALUE]);
79941
+ text2.push(this[VALUE]);
79942
79942
  while (nextSibling2) {
79943
79943
  if (nextSibling2.nodeType === TEXT_NODE)
79944
- text.push(nextSibling2[VALUE]);
79944
+ text2.push(nextSibling2[VALUE]);
79945
79945
  else
79946
79946
  break;
79947
79947
  nextSibling2 = nextSibling2.nextSibling;
79948
79948
  }
79949
- return text.join("");
79949
+ return text2.join("");
79950
79950
  }
79951
79951
  cloneNode() {
79952
79952
  const { ownerDocument, [VALUE]: data } = this;
@@ -80745,36 +80745,36 @@ var Element2 = class extends ParentNode {
80745
80745
  // </specialGetters>
80746
80746
  // <contentRelated>
80747
80747
  get innerText() {
80748
- const text = [];
80748
+ const text2 = [];
80749
80749
  let { [NEXT]: next, [END]: end } = this;
80750
80750
  while (next !== end) {
80751
80751
  if (next.nodeType === TEXT_NODE) {
80752
- text.push(next.textContent.replace(/\s+/g, " "));
80753
- } else if (text.length && next[NEXT] != end && BLOCK_ELEMENTS.has(next.tagName)) {
80754
- text.push("\n");
80752
+ text2.push(next.textContent.replace(/\s+/g, " "));
80753
+ } else if (text2.length && next[NEXT] != end && BLOCK_ELEMENTS.has(next.tagName)) {
80754
+ text2.push("\n");
80755
80755
  }
80756
80756
  next = next[NEXT];
80757
80757
  }
80758
- return text.join("");
80758
+ return text2.join("");
80759
80759
  }
80760
80760
  /**
80761
80761
  * @returns {String}
80762
80762
  */
80763
80763
  get textContent() {
80764
- const text = [];
80764
+ const text2 = [];
80765
80765
  let { [NEXT]: next, [END]: end } = this;
80766
80766
  while (next !== end) {
80767
80767
  const nodeType = next.nodeType;
80768
80768
  if (nodeType === TEXT_NODE || nodeType === CDATA_SECTION_NODE)
80769
- text.push(next.textContent);
80769
+ text2.push(next.textContent);
80770
80770
  next = next[NEXT];
80771
80771
  }
80772
- return text.join("");
80772
+ return text2.join("");
80773
80773
  }
80774
- set textContent(text) {
80774
+ set textContent(text2) {
80775
80775
  this.replaceChildren();
80776
- if (text != null && text !== "")
80777
- this.appendChild(new Text4(this.ownerDocument, text));
80776
+ if (text2 != null && text2 !== "")
80777
+ this.appendChild(new Text4(this.ownerDocument, text2));
80778
80778
  }
80779
80779
  get innerHTML() {
80780
80780
  return getInnerHtml(this);
@@ -80954,8 +80954,8 @@ var Element2 = class extends ParentNode {
80954
80954
  insertAdjacentHTML(position, html) {
80955
80955
  this.insertAdjacentElement(position, htmlToFragment(this.ownerDocument, html));
80956
80956
  }
80957
- insertAdjacentText(position, text) {
80958
- const node = this.ownerDocument.createTextNode(text);
80957
+ insertAdjacentText(position, text2) {
80958
+ const node = this.ownerDocument.createTextNode(text2);
80959
80959
  this.insertAdjacentElement(position, node);
80960
80960
  }
80961
80961
  // </insertAdjacent>
@@ -83646,8 +83646,8 @@ function blockStats(before2, after2) {
83646
83646
  const changed = Math.min(added, removed);
83647
83647
  return `+${added - changed} ~${changed} -${removed - changed} blocks`;
83648
83648
  }
83649
- function closestBase(written, text, fallback) {
83650
- const wanted = new Set(text.split("\n").map((line) => line.trim()));
83649
+ function closestBase(written, text2, fallback) {
83650
+ const wanted = new Set(text2.split("\n").map((line) => line.trim()));
83651
83651
  let best = fallback;
83652
83652
  let bestScore = -1;
83653
83653
  for (const candidate of written.keys()) {
@@ -83694,9 +83694,9 @@ async function createDocumentSession(options) {
83694
83694
  const binding = createLoroBinding(editor, loro);
83695
83695
  loro.subscribeLocalUpdates((bytes) => emit({ type: "update", bytes }));
83696
83696
  const written = /* @__PURE__ */ new Map();
83697
- const remember = (text, frontiers = loro.frontiers()) => {
83698
- written.delete(text);
83699
- written.set(text, frontiers);
83697
+ const remember = (text2, frontiers = loro.frontiers()) => {
83698
+ written.delete(text2);
83699
+ written.set(text2, frontiers);
83700
83700
  if (written.size > WRITTEN_LIMIT) written.delete(written.keys().next().value);
83701
83701
  };
83702
83702
  let outcome = { kind: "idle" };
@@ -83722,7 +83722,7 @@ async function createDocumentSession(options) {
83722
83722
  let snapshotDirty = true;
83723
83723
  let writing = Promise.resolve();
83724
83724
  let playing = Promise.resolve();
83725
- const prepareAgentEdit = (baseText, text, target) => {
83725
+ const prepareAgentEdit = (baseText, text2, target) => {
83726
83726
  const baseState = parseDocument2(baseText);
83727
83727
  const stats = blockStats(baseState, target);
83728
83728
  const { frontiers, steps } = streamAtVersion(
@@ -83733,7 +83733,7 @@ async function createDocumentSession(options) {
83733
83733
  target,
83734
83734
  `agent: ${stats}`
83735
83735
  );
83736
- remember(text, frontiers);
83736
+ remember(text2, frontiers);
83737
83737
  return { stats, steps };
83738
83738
  };
83739
83739
  const applyStep = (step) => {
@@ -83744,24 +83744,24 @@ async function createDocumentSession(options) {
83744
83744
  emit({ type: "cursor", cursor: step.cursor });
83745
83745
  }
83746
83746
  };
83747
- const onFileText = (text) => {
83748
- if (text === lastFileText) return;
83749
- lastFileText = text;
83747
+ const onFileText = (text2) => {
83748
+ if (text2 === lastFileText) return;
83749
+ lastFileText = text2;
83750
83750
  let target;
83751
83751
  try {
83752
- target = parseDocument2(text);
83752
+ target = parseDocument2(text2);
83753
83753
  } catch (err) {
83754
83754
  log(`agent edit rejected: ${messageOf(err)}`);
83755
83755
  setOutcome({ kind: "rejected", message: messageOf(err) });
83756
83756
  return;
83757
83757
  }
83758
- const baseText = closestBase(written, text, lastGoodText ?? serializeDocument(editor.getEditorState().toJSON()));
83759
- lastGoodText = text;
83758
+ const baseText = closestBase(written, text2, lastGoodText ?? serializeDocument(editor.getEditorState().toJSON()));
83759
+ lastGoodText = text2;
83760
83760
  streaming += 1;
83761
83761
  emit({ type: "status", outcome, streaming: true });
83762
83762
  playing = playing.then(async () => {
83763
83763
  try {
83764
- const { stats, steps } = prepareAgentEdit(baseText, text, target);
83764
+ const { stats, steps } = prepareAgentEdit(baseText, text2, target);
83765
83765
  for (const step of steps) {
83766
83766
  applyStep(step);
83767
83767
  if (stepDelayMs > 0) await new Promise((resolve) => setTimeout(resolve, stepDelayMs * (0.6 + Math.random() * 0.8)));
@@ -83799,17 +83799,17 @@ async function createDocumentSession(options) {
83799
83799
  if (stamped !== current && JSON.stringify(stamped) !== JSON.stringify(current)) {
83800
83800
  editor.update(() => $reconcileRoot2(stamped.root), { discrete: true });
83801
83801
  }
83802
- const text = serializeDocument(editor.getEditorState().toJSON());
83803
- if (text !== lastFileText) {
83802
+ const text2 = serializeDocument(editor.getEditorState().toJSON());
83803
+ if (text2 !== lastFileText) {
83804
83804
  const beforeRename = await readText(file);
83805
83805
  if (beforeRename !== null && beforeRename !== lastFileText) {
83806
83806
  onFileText(beforeRename);
83807
83807
  return;
83808
83808
  }
83809
- await writeAtomic(file, text);
83810
- lastFileText = text;
83811
- lastGoodText = text;
83812
- remember(text);
83809
+ await writeAtomic(file, text2);
83810
+ lastFileText = text2;
83811
+ lastGoodText = text2;
83812
+ remember(text2);
83813
83813
  }
83814
83814
  snapshotDirty = true;
83815
83815
  await saveSnapshot();
@@ -83928,8 +83928,8 @@ function createDocumentRegistry(options) {
83928
83928
  const known = sessions.has(id2);
83929
83929
  void open(id2).then((session) => {
83930
83930
  if (!session || !known) return;
83931
- import_node_fs7.default.readFile(docFile(id2), "utf8", (err, text) => {
83932
- if (!err) session.onFileText(text);
83931
+ import_node_fs7.default.readFile(docFile(id2), "utf8", (err, text2) => {
83932
+ if (!err) session.onFileText(text2);
83933
83933
  });
83934
83934
  });
83935
83935
  },
@@ -83972,10 +83972,14 @@ function installInspector(win, properties) {
83972
83972
  let hovered = null;
83973
83973
  let selectedRect = null;
83974
83974
  let hoverRect = null;
83975
+ let hoverId = null;
83975
83976
  let dragging = null;
83976
83977
  let marquee = null;
83977
83978
  let suppressClick = false;
83978
83979
  const tracked = /* @__PURE__ */ new Map();
83980
+ const cursor = doc.createElement("style");
83981
+ cursor.setAttribute("data-ryugi-inspector", "");
83982
+ cursor.textContent = "*{cursor:default!important}";
83979
83983
  const post = (type, data) => win.parent.postMessage({ type: `ryugi:inspect:${type}`, session, connection, ...data }, "*");
83980
83984
  const idOf = (el2) => {
83981
83985
  let id2 = ids.get(el2);
@@ -83988,6 +83992,21 @@ function installInspector(win, properties) {
83988
83992
  };
83989
83993
  const label = (el2) => (el2.getAttribute("data-layer-name") || el2.getAttribute("aria-label") || el2.id || (!el2.childElementCount ? el2.textContent?.trim() : "") || "").slice(0, 100);
83990
83994
  const selector = (el2) => (el2.id ? `#${el2.id}` : el2.tagName.toLowerCase() + Array.from(el2.classList).slice(0, 2).map((name) => `.${name}`).join("")).slice(0, 200);
83995
+ const pathOf = (el2) => {
83996
+ const segments = [];
83997
+ for (let node = el2; node && node !== doc.documentElement; node = node.parentElement) {
83998
+ const tag = node.tagName.toLowerCase();
83999
+ const parent = node.parentElement;
84000
+ const same = parent && node !== doc.body ? Array.from(parent.children).filter((child) => child.tagName === node.tagName) : [];
84001
+ segments.unshift(node.id && node.id.length <= 64 && /^[A-Za-z][\w-]*$/.test(node.id) ? `${tag}#${node.id}` : same.length > 1 ? `${tag}:nth-of-type(${same.indexOf(node) + 1})` : tag);
84002
+ if (node === doc.body) break;
84003
+ }
84004
+ return segments.join(" > ").slice(0, 4e3);
84005
+ };
84006
+ const treeId = (el2) => {
84007
+ const id2 = ids.get(el2);
84008
+ return id2 !== void 0 && elements.get(id2) === el2 ? id2 : null;
84009
+ };
83991
84010
  const kind = (el2, style) => {
83992
84011
  if (/^H[1-6]$/.test(el2.tagName)) return "Title";
83993
84012
  if (["IMG", "SVG", "CANVAS", "VIDEO"].includes(el2.tagName.toUpperCase())) return "Image";
@@ -84015,7 +84034,7 @@ function installInspector(win, properties) {
84015
84034
  tag: el2.tagName.toLowerCase(),
84016
84035
  selector: selector(el2),
84017
84036
  rect: selectedRect = rectOf(el2),
84018
- css: Object.fromEntries(properties.map((property) => [property, style.getPropertyValue(property)])),
84037
+ css: Object.fromEntries(properties.map((property2) => [property2, style.getPropertyValue(property2)])),
84019
84038
  html: el2.outerHTML.slice(0, 2e4),
84020
84039
  widthMode: inline?.width === "100%" ? "fill" : inline?.width === "max-content" ? "hug" : "fixed",
84021
84040
  heightMode: inline?.height && inline.height !== "auto" ? "fixed" : "hug"
@@ -84023,15 +84042,15 @@ function installInspector(win, properties) {
84023
84042
  post("selection", { selection: info, reason, toggle });
84024
84043
  };
84025
84044
  const tweaks = () => {
84026
- const list = [];
84045
+ const list2 = [];
84027
84046
  for (const [el2, changes] of originals) {
84028
84047
  if (!el2.isConnected) {
84029
84048
  originals.delete(el2);
84030
84049
  continue;
84031
84050
  }
84032
- for (const [property, saved] of changes) list.push({ id: idOf(el2), name: label(el2) || selector(el2), property, value: saved.applied });
84051
+ for (const [property2, saved] of changes) list2.push({ id: idOf(el2), name: label(el2) || selector(el2), property: property2, from: saved.from, value: saved.applied });
84033
84052
  }
84034
- post("tweaks", { tweaks: list });
84053
+ post("tweaks", { tweaks: list2 });
84035
84054
  };
84036
84055
  const tree = () => {
84037
84056
  if (!enabled || !doc.body) return;
@@ -84045,7 +84064,7 @@ function installInspector(win, properties) {
84045
84064
  return null;
84046
84065
  }
84047
84066
  const id2 = idOf(el2);
84048
- const node = { id: id2, parentId, name: label(el2), tag: el2.tagName.toLowerCase(), selector: selector(el2), kind: kind(el2, win.getComputedStyle(el2)), children: [] };
84067
+ const node = { id: id2, parentId, name: label(el2), tag: el2.tagName.toLowerCase(), selector: selector(el2), path: pathOf(el2), kind: kind(el2, win.getComputedStyle(el2)), children: [] };
84049
84068
  nodes.push(node);
84050
84069
  for (const child of el2.children) {
84051
84070
  if (nodes.length >= 2500) {
@@ -84095,13 +84114,16 @@ function installInspector(win, properties) {
84095
84114
  }
84096
84115
  if (hovered?.isConnected) {
84097
84116
  const rect = rectOf(hovered);
84098
- if (!sameRect(hoverRect, rect)) {
84117
+ const id2 = treeId(hovered);
84118
+ if (!sameRect(hoverRect, rect) || id2 !== hoverId) {
84099
84119
  hoverRect = rect;
84100
- post("hover", { rect });
84120
+ hoverId = id2;
84121
+ post("hover", { rect, id: id2 });
84101
84122
  }
84102
84123
  } else if (hoverRect) {
84103
84124
  hoverRect = null;
84104
- post("hover", { rect: null });
84125
+ hoverId = null;
84126
+ post("hover", { rect: null, id: null });
84105
84127
  }
84106
84128
  geometryFrame = win.requestAnimationFrame(geometry);
84107
84129
  };
@@ -84161,7 +84183,8 @@ function installInspector(win, properties) {
84161
84183
  const leave = () => {
84162
84184
  hovered = null;
84163
84185
  hoverRect = null;
84164
- if (enabled) post("hover", { rect: null });
84186
+ hoverId = null;
84187
+ if (enabled) post("hover", { rect: null, id: null });
84165
84188
  };
84166
84189
  const wheel = (event) => {
84167
84190
  if (!enabled) return;
@@ -84184,13 +84207,15 @@ function installInspector(win, properties) {
84184
84207
  endDrag(new win.Event("pointercancel"));
84185
84208
  enabled = false;
84186
84209
  observer.disconnect();
84210
+ cursor.remove();
84187
84211
  win.clearTimeout(treeTimer);
84188
84212
  win.cancelAnimationFrame(geometryFrame);
84189
84213
  treeTimer = 0;
84190
84214
  geometryFrame = 0;
84191
84215
  hovered = null;
84192
84216
  hoverRect = null;
84193
- post("hover", { rect: null });
84217
+ hoverId = null;
84218
+ post("hover", { rect: null, id: null });
84194
84219
  };
84195
84220
  const onMessage = (event) => {
84196
84221
  if (event.source !== win.parent || event.data?.type !== "ryugi:inspect") return;
@@ -84199,6 +84224,7 @@ function installInspector(win, properties) {
84199
84224
  if (typeof data.connection !== "string" || !data.connection || data.connection.length > 128) return;
84200
84225
  connection = data.connection;
84201
84226
  enabled = true;
84227
+ if (!cursor.isConnected) (doc.head || doc.documentElement).append(cursor);
84202
84228
  observer.observe(doc.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });
84203
84229
  win.cancelAnimationFrame(geometryFrame);
84204
84230
  geometryFrame = win.requestAnimationFrame(geometry);
@@ -84230,44 +84256,52 @@ function installInspector(win, properties) {
84230
84256
  const el2 = elements.get(id2);
84231
84257
  if (el2?.isConnected) tracked.set(id2, rectOf(el2));
84232
84258
  }
84233
- } else if (data.action === "marquee" && Number.isSafeInteger(data.request) && data.request > 0) {
84234
- const r7 = data.rect;
84235
- if (!r7 || !["x", "y", "width", "height"].every((key3) => typeof r7[key3] === "number" && Number.isFinite(r7[key3]) && Math.abs(r7[key3]) <= 1e8) || r7.width < 0 || r7.height < 0) return;
84236
- const contained = /* @__PURE__ */ new Set();
84259
+ } else if (data.action === "leaves" && Number.isSafeInteger(data.request) && data.request > 0) {
84260
+ const inTree = (el2) => treeId(el2) !== null;
84261
+ const content = (el2) => el2.tagName.toLowerCase() === "svg" || Array.from(el2.childNodes).some((child) => child.nodeType === 3 && child.textContent.trim()) || !Array.from(el2.children).some(inTree);
84262
+ const picked = /* @__PURE__ */ new Set();
84237
84263
  const targets = [];
84238
84264
  for (const [id2, el2] of elements) {
84239
- if (el2 === doc.body || !el2.isConnected) continue;
84240
- const rect = rectOf(el2);
84241
- if (rect.width <= 0 || rect.height <= 0 || rect.x < r7.x || rect.y < r7.y || rect.x + rect.width > r7.x + r7.width || rect.y + rect.height > r7.y + r7.height) continue;
84265
+ if (el2 === doc.body || !el2.isConnected || el2.parentElement?.closest("svg") || !content(el2)) continue;
84242
84266
  let parent = el2.parentElement;
84243
- while (parent && !contained.has(parent)) parent = parent.parentElement;
84267
+ while (parent && !picked.has(parent)) parent = parent.parentElement;
84244
84268
  if (parent) continue;
84245
- contained.add(el2);
84269
+ const rect = rectOf(el2);
84270
+ if (rect.width <= 0 || rect.height <= 0) continue;
84271
+ picked.add(el2);
84246
84272
  targets.push({ id: id2, name: label(el2) || selector(el2), rect });
84247
84273
  }
84248
84274
  post("targets", { request: data.request, targets });
84275
+ } else if (data.action === "describe" && Number.isSafeInteger(data.request) && data.request > 0 && Array.isArray(data.ids) && data.ids.length <= 2500) {
84276
+ const nodes = [];
84277
+ for (const id2 of data.ids) {
84278
+ const el2 = Number.isSafeInteger(id2) ? elements.get(id2) : void 0;
84279
+ if (el2?.isConnected) nodes.push({ id: id2, text: (el2.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 200), html: el2.outerHTML.slice(0, 2e3) });
84280
+ }
84281
+ post("details", { request: data.request, nodes });
84249
84282
  } else if (data.action === "hover") {
84250
84283
  const el2 = elements.get(data.id);
84251
84284
  hovered = el2?.isConnected ? el2 : null;
84252
84285
  hoverRect = hovered ? rectOf(hovered) : null;
84253
- post("hover", { rect: hoverRect });
84286
+ hoverId = hovered ? treeId(hovered) : null;
84287
+ post("hover", { rect: hoverRect, id: hoverId });
84254
84288
  } else if (data.action === "style" && data.session === session && selected && ids.get(selected) === data.id && properties.includes(data.property) && typeof data.value === "string" && data.value.length <= 300) {
84255
84289
  const el2 = selected;
84256
84290
  if (!el2.style || !el2.isConnected) return;
84257
- const property = data.property;
84291
+ const property2 = data.property;
84258
84292
  const probe = doc.createElement("div").style;
84259
- probe.setProperty(property, data.value);
84260
- const value = probe.getPropertyValue(property);
84293
+ probe.setProperty(property2, data.value);
84294
+ const value = probe.getPropertyValue(property2);
84261
84295
  if (!value) return;
84262
84296
  if (!originals.has(el2)) originals.set(el2, /* @__PURE__ */ new Map());
84263
84297
  const changes = originals.get(el2);
84264
- if (!changes.has(property)) {
84298
+ if (!changes.has(property2)) {
84265
84299
  const affected = /* @__PURE__ */ new Set([...Array.from(probe), ...Array.from(el2.style).filter((name) => probe.getPropertyValue(name))]);
84266
- changes.set(property, { applied: "", declarations: new Map(Array.from(affected, (name) => [name, { value: el2.style.getPropertyValue(name), priority: el2.style.getPropertyPriority(name), applied: "" }])) });
84300
+ changes.set(property2, { from: win.getComputedStyle(el2).getPropertyValue(property2).slice(0, 2e3), applied: "", declarations: new Map(Array.from(affected, (name) => [name, { value: el2.style.getPropertyValue(name), priority: el2.style.getPropertyPriority(name), applied: "" }])) });
84267
84301
  }
84268
- el2.style.setProperty(property, value);
84269
- const saved = changes.get(property);
84270
- saved.applied = el2.style.getPropertyValue(property);
84302
+ el2.style.setProperty(property2, value);
84303
+ const saved = changes.get(property2);
84304
+ saved.applied = el2.style.getPropertyValue(property2);
84271
84305
  for (const [name, declaration] of saved.declarations) declaration.applied = el2.style.getPropertyValue(name);
84272
84306
  selection("update");
84273
84307
  tweaks();
@@ -84607,10 +84641,110 @@ function createDynamicBlocks(limits) {
84607
84641
  };
84608
84642
  }
84609
84643
 
84610
- // src/server/config.ts
84644
+ // src/server/selection.ts
84611
84645
  var import_node_fs10 = __toESM(require("node:fs"), 1);
84612
84646
  var import_node_path10 = __toESM(require("node:path"), 1);
84613
84647
 
84648
+ // src/shared/selection.ts
84649
+ var SELECTION_FULL_NODES = 20;
84650
+ var SELECTION_MAX_NODES = 25e3;
84651
+ var SELECTION_MAX_BYTES = 4 * 1024 * 1024;
84652
+ var SELECTION_LIMITS = { id: 200, board: 100, file: 500, tag: 80, path: 4e3, name: 100, text: 200, html: 2e3, from: 2e3, value: 300 };
84653
+
84654
+ // src/server/selection.ts
84655
+ var object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
84656
+ var text = (value, max) => typeof value === "string" && value.length <= max;
84657
+ var list = (value, max) => Array.isArray(value) && value.length <= max;
84658
+ var property = (value) => INSPECTOR_PROPERTIES.some((item) => item === value);
84659
+ function readNode(value) {
84660
+ if (!object(value) || !text(value.id, SELECTION_LIMITS.id) || !text(value.board, SELECTION_LIMITS.board) || !text(value.file, SELECTION_LIMITS.file) || !text(value.tag, SELECTION_LIMITS.tag) || !text(value.path, SELECTION_LIMITS.path) || !text(value.name, SELECTION_LIMITS.name)) return null;
84661
+ return { id: value.id, board: value.board, file: value.file, tag: value.tag, path: value.path, name: value.name };
84662
+ }
84663
+ function readChange(value) {
84664
+ if (!object(value) || !property(value.property) || !text(value.from, SELECTION_LIMITS.from) || !text(value.value, SELECTION_LIMITS.value)) return null;
84665
+ return { property: value.property, from: value.from, value: value.value };
84666
+ }
84667
+ function readAll(values, read) {
84668
+ const out = [];
84669
+ for (const value of values) {
84670
+ const item = read(value);
84671
+ if (!item) return null;
84672
+ out.push(item);
84673
+ }
84674
+ return out;
84675
+ }
84676
+ function readSelectionMessage(value) {
84677
+ if (!object(value) || value.type !== "selection" || !text(value.artifact, 200) || !text(value.tab, 64) || !value.tab || typeof value.human !== "boolean") return null;
84678
+ const id2 = value.artifact.startsWith("artboard/") ? value.artifact.slice("artboard/".length) : "";
84679
+ if (!isArtifactId(id2) || !Number.isSafeInteger(value.more) || value.more < 0) return null;
84680
+ if (!list(value.selected, SELECTION_FULL_NODES) || !list(value.tweaks, SELECTION_MAX_NODES) || !list(value.nodes, SELECTION_MAX_NODES)) return null;
84681
+ const selected = readAll(value.selected, (item) => {
84682
+ const node = readNode(item);
84683
+ if (!node || !object(item) || !text(item.text, SELECTION_LIMITS.text) || !text(item.html, SELECTION_LIMITS.html) || !list(item.tweaks, INSPECTOR_PROPERTIES.length)) return null;
84684
+ const tweaks2 = readAll(item.tweaks, readChange);
84685
+ return tweaks2 && { ...node, text: item.text, html: item.html, tweaks: tweaks2 };
84686
+ });
84687
+ const tweaks = readAll(value.tweaks, (item) => {
84688
+ const node = readNode(item);
84689
+ const change = readChange(item);
84690
+ return node && change && { ...node, ...change };
84691
+ });
84692
+ const nodes = readAll(value.nodes, readNode);
84693
+ if (!selected || !tweaks || !nodes) return null;
84694
+ return { id: id2, tab: value.tab, human: value.human, state: { selected, more: value.more, tweaks, nodes } };
84695
+ }
84696
+ function createSelectionStore(stateDir, exists) {
84697
+ const tabs = /* @__PURE__ */ new Map();
84698
+ let clock = 0;
84699
+ const fileOf = (id2) => import_node_path10.default.join(stateDir, "artboard", id2, "selection.json");
84700
+ const write = (id2) => {
84701
+ let winner;
84702
+ for (const tab of tabs.values()) {
84703
+ if (tab.id !== id2) continue;
84704
+ if (!winner || tab.humanAt > winner.humanAt || tab.humanAt === winner.humanAt && tab.seenAt > winner.seenAt) winner = tab;
84705
+ }
84706
+ if (!winner) import_node_fs10.default.rmSync(fileOf(id2), { force: true });
84707
+ else writeJsonAtomic(fileOf(id2), { artifact: `artboard/${id2}`, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), ...winner.state });
84708
+ };
84709
+ return {
84710
+ accept(socket, value) {
84711
+ const message = readSelectionMessage(value);
84712
+ const previous = tabs.get(socket);
84713
+ if (!message || !exists(message.id)) {
84714
+ if (previous) {
84715
+ tabs.delete(socket);
84716
+ write(previous.id);
84717
+ }
84718
+ return;
84719
+ }
84720
+ const humanAt = message.human ? ++clock : previous?.id === message.id ? previous.humanAt : 0;
84721
+ tabs.set(socket, { id: message.id, state: message.state, humanAt, seenAt: ++clock });
84722
+ if (previous && previous.id !== message.id) write(previous.id);
84723
+ write(message.id);
84724
+ },
84725
+ drop(socket) {
84726
+ const tab = tabs.get(socket);
84727
+ if (!tab) return;
84728
+ tabs.delete(socket);
84729
+ write(tab.id);
84730
+ },
84731
+ clearAll() {
84732
+ tabs.clear();
84733
+ let ids = [];
84734
+ try {
84735
+ ids = import_node_fs10.default.readdirSync(import_node_path10.default.join(stateDir, "artboard"));
84736
+ } catch {
84737
+ return;
84738
+ }
84739
+ for (const id2 of ids) import_node_fs10.default.rmSync(fileOf(id2), { force: true });
84740
+ }
84741
+ };
84742
+ }
84743
+
84744
+ // src/server/config.ts
84745
+ var import_node_fs11 = __toESM(require("node:fs"), 1);
84746
+ var import_node_path11 = __toESM(require("node:path"), 1);
84747
+
84614
84748
  // src/shared/cloud.ts
84615
84749
  var isVisibility = (value) => value === "private" || value === "public";
84616
84750
 
@@ -84638,35 +84772,35 @@ function normalize(raw) {
84638
84772
  return config;
84639
84773
  }
84640
84774
  function readConfig(file) {
84641
- let text;
84775
+ let text2;
84642
84776
  try {
84643
- text = import_node_fs10.default.readFileSync(file, "utf8");
84777
+ text2 = import_node_fs11.default.readFileSync(file, "utf8");
84644
84778
  } catch {
84645
84779
  return { config: defaults() };
84646
84780
  }
84647
84781
  try {
84648
- return { config: normalize(JSON.parse(text)) };
84782
+ return { config: normalize(JSON.parse(text2)) };
84649
84783
  } catch (err) {
84650
84784
  return { config: defaults(), warning: `config.json is not valid JSON: ${err.message}` };
84651
84785
  }
84652
84786
  }
84653
84787
  function ensureGitignore(dir) {
84654
- const file = import_node_path10.default.join(dir, ".gitignore");
84788
+ const file = import_node_path11.default.join(dir, ".gitignore");
84655
84789
  let current = "";
84656
84790
  try {
84657
- current = import_node_fs10.default.readFileSync(file, "utf8");
84791
+ current = import_node_fs11.default.readFileSync(file, "utf8");
84658
84792
  } catch {
84659
- import_node_fs10.default.writeFileSync(file, "config.json\n");
84793
+ import_node_fs11.default.writeFileSync(file, "config.json\n");
84660
84794
  return;
84661
84795
  }
84662
84796
  if (current.split(/\r?\n/).some((line) => line.trim() === "config.json")) return;
84663
- import_node_fs10.default.writeFileSync(file, `${current}${current === "" || current.endsWith("\n") ? "" : "\n"}config.json
84797
+ import_node_fs11.default.writeFileSync(file, `${current}${current === "" || current.endsWith("\n") ? "" : "\n"}config.json
84664
84798
  `);
84665
84799
  }
84666
84800
  function ensureConfig(file) {
84667
- import_node_fs10.default.mkdirSync(import_node_path10.default.dirname(file), { recursive: true });
84668
- ensureGitignore(import_node_path10.default.dirname(file));
84669
- if (!import_node_fs10.default.existsSync(file)) writeJsonAtomic(file, defaults());
84801
+ import_node_fs11.default.mkdirSync(import_node_path11.default.dirname(file), { recursive: true });
84802
+ ensureGitignore(import_node_path11.default.dirname(file));
84803
+ if (!import_node_fs11.default.existsSync(file)) writeJsonAtomic(file, defaults());
84670
84804
  }
84671
84805
  function updateArtifactConfig(file, key2, patch) {
84672
84806
  const { config, warning } = readConfig(file);
@@ -84791,16 +84925,16 @@ function callbackPage(result) {
84791
84925
  }
84792
84926
 
84793
84927
  // src/server/credentials.ts
84794
- var import_node_fs11 = __toESM(require("node:fs"), 1);
84795
- var import_node_path11 = __toESM(require("node:path"), 1);
84928
+ var import_node_fs12 = __toESM(require("node:fs"), 1);
84929
+ var import_node_path12 = __toESM(require("node:path"), 1);
84796
84930
  function credentialsFile(env, platform, home) {
84797
- if (platform === "win32" && env.APPDATA) return import_node_path11.default.join(env.APPDATA, "ryugi", "credentials.json");
84798
- return import_node_path11.default.join(env.XDG_CONFIG_HOME || import_node_path11.default.join(home, ".config"), "ryugi", "credentials.json");
84931
+ if (platform === "win32" && env.APPDATA) return import_node_path12.default.join(env.APPDATA, "ryugi", "credentials.json");
84932
+ return import_node_path12.default.join(env.XDG_CONFIG_HOME || import_node_path12.default.join(home, ".config"), "ryugi", "credentials.json");
84799
84933
  }
84800
84934
  function readCredentials(file, origin) {
84801
84935
  let raw;
84802
84936
  try {
84803
- raw = JSON.parse(import_node_fs11.default.readFileSync(file, "utf8"));
84937
+ raw = JSON.parse(import_node_fs12.default.readFileSync(file, "utf8"));
84804
84938
  } catch {
84805
84939
  return null;
84806
84940
  }
@@ -84811,16 +84945,16 @@ function readCredentials(file, origin) {
84811
84945
  return { origin: savedOrigin, token, login };
84812
84946
  }
84813
84947
  function writeCredentials(file, credentials) {
84814
- import_node_fs11.default.mkdirSync(import_node_path11.default.dirname(file), { recursive: true, mode: 448 });
84948
+ import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(file), { recursive: true, mode: 448 });
84815
84949
  writeJsonAtomic(file, credentials);
84816
84950
  }
84817
84951
  function clearCredentials(file) {
84818
- import_node_fs11.default.rmSync(file, { force: true });
84952
+ import_node_fs12.default.rmSync(file, { force: true });
84819
84953
  }
84820
84954
 
84821
84955
  // src/server/pack.ts
84822
- var import_node_fs12 = __toESM(require("node:fs"), 1);
84823
- var import_node_path12 = __toESM(require("node:path"), 1);
84956
+ var import_node_fs13 = __toESM(require("node:fs"), 1);
84957
+ var import_node_path13 = __toESM(require("node:path"), 1);
84824
84958
  var MAX_ARTIFACT_BYTES = 20 * 1024 * 1024;
84825
84959
  function formatBytes(bytes) {
84826
84960
  if (bytes < 1024) return `${bytes} B`;
@@ -84829,22 +84963,22 @@ function formatBytes(bytes) {
84829
84963
  }
84830
84964
  var excluded = (type, relative) => type === "document" && relative === "comments.json";
84831
84965
  function packArtifact(dir, type, { maxBytes = MAX_ARTIFACT_BYTES } = {}) {
84832
- const rootReal = import_node_fs12.default.realpathSync(dir);
84966
+ const rootReal = import_node_fs13.default.realpathSync(dir);
84833
84967
  const found = [];
84834
84968
  const visited = /* @__PURE__ */ new Set([rootReal]);
84835
84969
  let total = 0;
84836
84970
  const walk = (current) => {
84837
- for (const entry of import_node_fs12.default.readdirSync(current, { withFileTypes: true })) {
84971
+ for (const entry of import_node_fs13.default.readdirSync(current, { withFileTypes: true })) {
84838
84972
  if (entry.name.startsWith(".")) continue;
84839
- const full = import_node_path12.default.join(current, entry.name);
84973
+ const full = import_node_path13.default.join(current, entry.name);
84840
84974
  let real;
84841
84975
  try {
84842
- real = import_node_fs12.default.realpathSync(full);
84976
+ real = import_node_fs13.default.realpathSync(full);
84843
84977
  } catch {
84844
84978
  continue;
84845
84979
  }
84846
- if (!real.startsWith(rootReal + import_node_path12.default.sep)) continue;
84847
- const stat = import_node_fs12.default.statSync(real);
84980
+ if (!real.startsWith(rootReal + import_node_path13.default.sep)) continue;
84981
+ const stat = import_node_fs13.default.statSync(real);
84848
84982
  if (stat.isDirectory()) {
84849
84983
  if (visited.has(real)) continue;
84850
84984
  visited.add(real);
@@ -84852,7 +84986,7 @@ function packArtifact(dir, type, { maxBytes = MAX_ARTIFACT_BYTES } = {}) {
84852
84986
  continue;
84853
84987
  }
84854
84988
  if (!stat.isFile()) continue;
84855
- const relative = import_node_path12.default.relative(dir, full).split(import_node_path12.default.sep).join("/");
84989
+ const relative = import_node_path13.default.relative(dir, full).split(import_node_path13.default.sep).join("/");
84856
84990
  if (excluded(type, relative)) continue;
84857
84991
  total += stat.size;
84858
84992
  found.push({ path: relative, real });
@@ -84862,19 +84996,19 @@ function packArtifact(dir, type, { maxBytes = MAX_ARTIFACT_BYTES } = {}) {
84862
84996
  if (total > maxBytes) {
84863
84997
  throw new Error(`artifact is ${formatBytes(total)}; the limit is ${formatBytes(maxBytes)}`);
84864
84998
  }
84865
- return found.map((file) => ({ path: file.path, data: import_node_fs12.default.readFileSync(file.real) }));
84999
+ return found.map((file) => ({ path: file.path, data: import_node_fs13.default.readFileSync(file.real) }));
84866
85000
  }
84867
85001
 
84868
85002
  // src/server/publish-payload.ts
84869
- var import_node_fs13 = __toESM(require("node:fs"), 1);
84870
- var import_node_path13 = __toESM(require("node:path"), 1);
85003
+ var import_node_fs14 = __toESM(require("node:fs"), 1);
85004
+ var import_node_path14 = __toESM(require("node:path"), 1);
84871
85005
  var CLOUD_RUNTIME_URL = "/_ryugi/runtime/ryugi-ui.js";
84872
85006
  function publishPayload(ref, dir, title, payload) {
84873
85007
  if (ref.type === "artboard") {
84874
85008
  const { canvas, layout, versions } = payload;
84875
85009
  return { canvas, layout, versions };
84876
85010
  }
84877
- if (ref.type === "document") return { title, state: parseDocument2(import_node_fs13.default.readFileSync(import_node_path13.default.join(dir, "doc.xml"), "utf8")) };
85011
+ if (ref.type === "document") return { title, state: parseDocument2(import_node_fs14.default.readFileSync(import_node_path14.default.join(dir, "doc.xml"), "utf8")) };
84878
85012
  return { title };
84879
85013
  }
84880
85014
  var isPage = (type, file) => type === "html" ? file === "index.html" : (type === "document" || type === "artboard") && file.endsWith(".html");
@@ -84914,12 +85048,12 @@ async function readJsonBody(req) {
84914
85048
  }
84915
85049
  }
84916
85050
  async function errorMessage(res) {
84917
- const text = await res.text().catch(() => "");
85051
+ const text2 = await res.text().catch(() => "");
84918
85052
  try {
84919
- const parsed = JSON.parse(text);
84920
- return typeof parsed.error === "string" ? parsed.error : text;
85053
+ const parsed = JSON.parse(text2);
85054
+ return typeof parsed.error === "string" ? parsed.error : text2;
84921
85055
  } catch {
84922
- return text || res.statusText;
85056
+ return text2 || res.statusText;
84923
85057
  }
84924
85058
  }
84925
85059
  function createCloudRoutes(options) {
@@ -84934,7 +85068,7 @@ function createCloudRoutes(options) {
84934
85068
  const challenge = import_node_crypto3.default.createHash("sha256").update(verifier).digest("base64url");
84935
85069
  return `${origin}/auth/cli?port=${options.port()}&state=${state}&challenge=${challenge}`;
84936
85070
  };
84937
- const cloudFetch = async (method, path17, body) => {
85071
+ const cloudFetch = async (method, path18, body) => {
84938
85072
  const credentials = readCredentials(credentialsFile2, origin);
84939
85073
  if (!credentials) throw new SignedOut();
84940
85074
  const headers = { Authorization: `Bearer ${credentials.token}` };
@@ -84948,7 +85082,7 @@ function createCloudRoutes(options) {
84948
85082
  }
84949
85083
  let res;
84950
85084
  try {
84951
- res = await fetch(`${origin}${path17}`, { method, headers, body: payload });
85085
+ res = await fetch(`${origin}${path18}`, { method, headers, body: payload });
84952
85086
  } catch (err) {
84953
85087
  throw new CloudRefused(502, `could not reach ${origin}: ${err.message}`);
84954
85088
  }
@@ -84974,7 +85108,7 @@ function createCloudRoutes(options) {
84974
85108
  const entry = artifactEntry(key2);
84975
85109
  const hashed = files.map((file) => ({ ...file, hash: import_node_crypto3.default.createHash("sha256").update(file.data).digest("hex") }));
84976
85110
  const byHash = new Map(hashed.map((file) => [file.hash, file.data]));
84977
- const manifest = hashed.map(({ path: path17, hash }) => ({ path: path17, hash }));
85111
+ const manifest = hashed.map(({ path: path18, hash }) => ({ path: path18, hash }));
84978
85112
  const version = (visibility) => ({ title: inspected.title, payload: inspected.payload, files: manifest, ...visibility ? { visibility } : {} });
84979
85113
  const create3 = async () => {
84980
85114
  const res2 = await cloudFetch("POST", "/api/artifacts", { type: ref.type, visibility: requested ?? entry.visibility ?? "private" });
@@ -85171,25 +85305,25 @@ function viewerPage(template, page) {
85171
85305
  }
85172
85306
 
85173
85307
  // src/server/watch.ts
85174
- var import_node_fs14 = __toESM(require("node:fs"), 1);
85175
- var import_node_path14 = __toESM(require("node:path"), 1);
85176
- var toPosix = (file) => file.split(import_node_path14.default.sep).join("/");
85308
+ var import_node_fs15 = __toESM(require("node:fs"), 1);
85309
+ var import_node_path15 = __toESM(require("node:path"), 1);
85310
+ var toPosix = (file) => file.split(import_node_path15.default.sep).join("/");
85177
85311
  var ignored = (file) => file === ".state" || file.startsWith(".state/");
85178
85312
  function snapshot(root, dir = root, out = /* @__PURE__ */ new Map()) {
85179
85313
  let entries2;
85180
85314
  try {
85181
- entries2 = import_node_fs14.default.readdirSync(dir, { withFileTypes: true });
85315
+ entries2 = import_node_fs15.default.readdirSync(dir, { withFileTypes: true });
85182
85316
  } catch {
85183
85317
  return out;
85184
85318
  }
85185
85319
  for (const entry of entries2) {
85186
- const full = import_node_path14.default.join(dir, entry.name);
85187
- const rel = toPosix(import_node_path14.default.relative(root, full));
85320
+ const full = import_node_path15.default.join(dir, entry.name);
85321
+ const rel = toPosix(import_node_path15.default.relative(root, full));
85188
85322
  if (ignored(rel)) continue;
85189
85323
  if (entry.isDirectory()) snapshot(root, full, out);
85190
85324
  else {
85191
85325
  try {
85192
- out.set(rel, import_node_fs14.default.statSync(full).mtimeMs);
85326
+ out.set(rel, import_node_fs15.default.statSync(full).mtimeMs);
85193
85327
  } catch {
85194
85328
  }
85195
85329
  }
@@ -85222,7 +85356,7 @@ function watchTree(root, onChange, debounceMs = 120, backupPollMs = 1e3) {
85222
85356
  }, debounceMs);
85223
85357
  };
85224
85358
  try {
85225
- const watcher = import_node_fs14.default.watch(root, { recursive: true }, (_event, filename) => {
85359
+ const watcher = import_node_fs15.default.watch(root, { recursive: true }, (_event, filename) => {
85226
85360
  if (filename) queue([toPosix(filename.toString())]);
85227
85361
  });
85228
85362
  watcher.on("error", () => {
@@ -85253,6 +85387,7 @@ var OPCODE_TEXT = 1;
85253
85387
  var OPCODE_CLOSE = 8;
85254
85388
  var OPCODE_PING = 9;
85255
85389
  var OPCODE_PONG = 10;
85390
+ var MAX_CLIENT_FRAME = 8 * 1024 * 1024;
85256
85391
  function acceptKey(clientKey) {
85257
85392
  return import_node_crypto4.default.createHash("sha1").update(clientKey + WS_MAGIC).digest("base64");
85258
85393
  }
@@ -85274,7 +85409,7 @@ function encodeFrame(opcode, payload) {
85274
85409
  }
85275
85410
  return Buffer.concat([header, payload]);
85276
85411
  }
85277
- var textFrame = (text) => encodeFrame(OPCODE_TEXT, Buffer.from(text));
85412
+ var textFrame = (text2) => encodeFrame(OPCODE_TEXT, Buffer.from(text2));
85278
85413
  function completeHandshake(socket, clientKey) {
85279
85414
  socket.write(
85280
85415
  `HTTP/1.1 101 Switching Protocols\r
@@ -85306,8 +85441,14 @@ function handleClientFrames(socket, onText) {
85306
85441
  len = buffer.readUInt16BE(2);
85307
85442
  offset = 4;
85308
85443
  } else if (len === 127) {
85309
- socket.destroy();
85310
- return;
85444
+ if (buffer.length < 10) return;
85445
+ const big = buffer.readBigUInt64BE(2);
85446
+ if (big > BigInt(MAX_CLIENT_FRAME)) {
85447
+ socket.destroy();
85448
+ return;
85449
+ }
85450
+ len = Number(big);
85451
+ offset = 10;
85311
85452
  }
85312
85453
  const total = offset + 4 + len;
85313
85454
  if (buffer.length < total) return;
@@ -85366,17 +85507,17 @@ function titleOf(payload, ref) {
85366
85507
  return payload.canvas?.title || ref.id;
85367
85508
  }
85368
85509
  async function startArtifactsServer(options) {
85369
- const root = import_node_path15.default.resolve(options.root);
85370
- const viewerDir = import_node_path15.default.resolve(options.viewerDir);
85371
- const runtimeDir = options.runtimeDir ? import_node_path15.default.resolve(options.runtimeDir) : null;
85372
- const stateDir = import_node_path15.default.join(root, ".state");
85373
- import_node_fs15.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
85374
- import_node_fs15.default.writeFileSync(import_node_path15.default.join(stateDir, ".gitignore"), "*\n");
85510
+ const root = import_node_path16.default.resolve(options.root);
85511
+ const viewerDir = import_node_path16.default.resolve(options.viewerDir);
85512
+ const runtimeDir = options.runtimeDir ? import_node_path16.default.resolve(options.runtimeDir) : null;
85513
+ const stateDir = import_node_path16.default.join(root, ".state");
85514
+ import_node_fs16.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
85515
+ import_node_fs16.default.writeFileSync(import_node_path16.default.join(stateDir, ".gitignore"), "*\n");
85375
85516
  if (options.configFile) ensureConfig(options.configFile);
85376
- const portFile = import_node_path15.default.join(stateDir, ".last-port");
85377
- const tokenFile = import_node_path15.default.join(stateDir, ".last-token");
85517
+ const portFile = import_node_path16.default.join(stateDir, ".last-port");
85518
+ const tokenFile = import_node_path16.default.join(stateDir, ".last-token");
85378
85519
  const token = readPersisted(tokenFile) || randomToken();
85379
- import_node_fs15.default.writeFileSync(tokenFile, `${token}
85520
+ import_node_fs16.default.writeFileSync(tokenFile, `${token}
85380
85521
  `, { mode: 384 });
85381
85522
  const contentToken = randomToken();
85382
85523
  const runtimeWarnings = /* @__PURE__ */ new Map();
@@ -85385,6 +85526,8 @@ async function startArtifactsServer(options) {
85385
85526
  const runtimeOf = (ref, dir) => ref.type === "document" ? [...documents.warnings(ref.id), ...dynamicBlocks.state(ref.id, dir).warnings] : runtimeWarnings.get(`${ref.type}/${ref.id}`) ?? [];
85386
85527
  const contentPrefix = `/c/${contentToken}/`;
85387
85528
  const clients = /* @__PURE__ */ new Set();
85529
+ const selections = createSelectionStore(stateDir, (id2) => resolveArtifactDir(root, "artboard", id2) !== null);
85530
+ selections.clearAll();
85388
85531
  const changeListeners = [];
85389
85532
  const activityListeners = [];
85390
85533
  const touch = () => activityListeners.forEach((listener) => listener());
@@ -85541,7 +85684,7 @@ async function startArtifactsServer(options) {
85541
85684
  sendFile(res, target, headers);
85542
85685
  return;
85543
85686
  }
85544
- import_node_fs15.default.readFile(target, "utf8", (err, source) => {
85687
+ import_node_fs16.default.readFile(target, "utf8", (err, source) => {
85545
85688
  if (err) send(res, 404, "Not found");
85546
85689
  else {
85547
85690
  const uiRuntimeUrl = runtimeDir ? `${contentPrefix}runtime/ryugi-ui.js` : void 0;
@@ -85566,16 +85709,20 @@ async function startArtifactsServer(options) {
85566
85709
  title: titleOf(readArtifact(entry.dir, entry), entry),
85567
85710
  updatedAt: latestMtime(entry.dir)
85568
85711
  }));
85569
- sendJson(res, 200, { project: import_node_path15.default.basename(import_node_path15.default.dirname(import_node_path15.default.dirname(root))), artifacts: summaries, warnings });
85712
+ sendJson(res, 200, { project: import_node_path16.default.basename(import_node_path16.default.dirname(import_node_path16.default.dirname(root))), artifacts: summaries, warnings });
85570
85713
  };
85571
- function onClientText(text) {
85714
+ function onClientText(socket, text2) {
85572
85715
  let message;
85573
85716
  try {
85574
- message = JSON.parse(text);
85717
+ message = JSON.parse(text2);
85575
85718
  } catch {
85576
85719
  return;
85577
85720
  }
85578
85721
  if (typeof message !== "object" || message === null) return;
85722
+ if (message.type === "selection") {
85723
+ selections.accept(socket, message);
85724
+ return;
85725
+ }
85579
85726
  const { type, artifact, message: detail, version, file } = message;
85580
85727
  if (typeof artifact !== "string") return;
85581
85728
  const ref = artifactKeyOf(artifact);
@@ -85603,12 +85750,12 @@ async function startArtifactsServer(options) {
85603
85750
  }
85604
85751
  if (type !== "runtime-error" || typeof detail !== "string") return;
85605
85752
  if (detail.length === 0 || detail.length > MAX_RUNTIME_MESSAGE) return;
85606
- const list = runtimeWarnings.get(artifact) ?? [];
85607
- if (list.includes(detail) || list.length >= MAX_RUNTIME_WARNINGS) return;
85608
- runtimeWarnings.set(artifact, [...list, detail]);
85753
+ const list2 = runtimeWarnings.get(artifact) ?? [];
85754
+ if (list2.includes(detail) || list2.length >= MAX_RUNTIME_WARNINGS) return;
85755
+ runtimeWarnings.set(artifact, [...list2, detail]);
85609
85756
  writeState(ref, dir);
85610
85757
  const frame = textFrame(JSON.stringify({ type: "change", artifact, files: [] }));
85611
- for (const socket of clients) socket.write(frame);
85758
+ for (const socket2 of clients) socket2.write(frame);
85612
85759
  }
85613
85760
  const handleRequest = (req, res) => {
85614
85761
  touch();
@@ -85622,7 +85769,7 @@ async function startArtifactsServer(options) {
85622
85769
  return;
85623
85770
  }
85624
85771
  if (pathname === "/robots.txt") {
85625
- sendFile(res, import_node_path15.default.join(viewerDir, "robots.txt"));
85772
+ sendFile(res, import_node_path16.default.join(viewerDir, "robots.txt"));
85626
85773
  return;
85627
85774
  }
85628
85775
  if (pathname.startsWith("/c/")) {
@@ -85687,7 +85834,7 @@ async function startArtifactsServer(options) {
85687
85834
  if (SHELL_ROUTE.test(pathname) || PREVIEW_ROUTE.test(pathname) || pathname === "/index.html") {
85688
85835
  const ref = artifactKeyOf(pathname.replace(/^\/(?:preview\/)?/, "").replace(/\/$/, ""));
85689
85836
  const dir = ref && resolveArtifactDir(root, ref.type, ref.id);
85690
- const project = import_node_path15.default.basename(import_node_path15.default.dirname(import_node_path15.default.dirname(root)));
85837
+ const project = import_node_path16.default.basename(import_node_path16.default.dirname(import_node_path16.default.dirname(root)));
85691
85838
  const title = ref ? dir ? titleOf(readArtifact(dir, ref), ref) : ref.id : `${project} \xB7 Artifacts`;
85692
85839
  const description = ref ? `\u5728 ${project} \u9879\u76EE\u4E2D\u67E5\u770B ${title}\uFF0C\u8FD9\u662F\u4E00\u4E2A ${ref.type === "artboard" ? "Artboard" : ref.type === "document" ? "Document" : "HTML"} Artifact\u3002` : `\u6D4F\u89C8 ${project} \u9879\u76EE\u7684\u5168\u90E8 Artboard\u3001Document \u548C HTML Artifact\uFF0C\u9884\u89C8\u771F\u5B9E\u5185\u5BB9\uFF0C\u6309\u7C7B\u578B\u3001\u540D\u79F0\u548C\u66F4\u65B0\u65F6\u95F4\u67E5\u627E\u4F5C\u54C1\u3002`;
85693
85840
  const canonical = `http://${urlHostForHttp(options.urlHost)}:${port}/${ref ? `${ref.type}/${ref.id}` : ""}`;
@@ -85696,7 +85843,7 @@ async function startArtifactsServer(options) {
85696
85843
  "Content-Security-Policy": PREVIEW_ROUTE.test(pathname) ? VIEWER_CSP.replace("frame-ancestors 'none'", "frame-ancestors 'self'") : VIEWER_CSP
85697
85844
  };
85698
85845
  if (key2 !== null) headers["Set-Cookie"] = `${cookieName}=${token}; HttpOnly; SameSite=Strict; Path=/`;
85699
- void import_node_fs15.default.promises.readFile(import_node_path15.default.join(viewerDir, "index.html"), "utf8").then((template) => send(res, 200, viewerPage(template, { title, description, url: canonical }), headers)).catch((err) => send(res, err.code === "ENOENT" ? 404 : 500, "Viewer unavailable"));
85846
+ void import_node_fs16.default.promises.readFile(import_node_path16.default.join(viewerDir, "index.html"), "utf8").then((template) => send(res, 200, viewerPage(template, { title, description, url: canonical }), headers)).catch((err) => send(res, err.code === "ENOENT" ? 404 : 500, "Viewer unavailable"));
85700
85847
  return;
85701
85848
  }
85702
85849
  const target = resolveInside(viewerDir, pathname.slice(1));
@@ -85723,9 +85870,17 @@ async function startArtifactsServer(options) {
85723
85870
  }
85724
85871
  completeHandshake(socket, clientKey);
85725
85872
  clients.add(socket);
85726
- handleClientFrames(socket, onClientText);
85727
- socket.on("close", () => clients.delete(socket));
85728
- socket.on("error", () => clients.delete(socket));
85873
+ handleClientFrames(socket, (text2) => onClientText(socket, text2));
85874
+ const forget = () => {
85875
+ clients.delete(socket);
85876
+ selections.drop(socket);
85877
+ };
85878
+ socket.on("end", () => {
85879
+ forget();
85880
+ socket.end();
85881
+ });
85882
+ socket.on("close", forget);
85883
+ socket.on("error", forget);
85729
85884
  touch();
85730
85885
  });
85731
85886
  const previousPort = Number(readPersisted(portFile));
@@ -85735,7 +85890,7 @@ async function startArtifactsServer(options) {
85735
85890
  port = await listen(server, options.host, 0);
85736
85891
  }
85737
85892
  cookieName = `ryugi_artifacts_${port}`;
85738
- import_node_fs15.default.writeFileSync(portFile, `${port}
85893
+ import_node_fs16.default.writeFileSync(portFile, `${port}
85739
85894
  `, { mode: 384 });
85740
85895
  const origin = `http://${urlHostForHttp(options.urlHost)}:${port}`;
85741
85896
  const url = `${origin}/?key=${token}`;
@@ -85761,7 +85916,7 @@ async function startArtifactsServer(options) {
85761
85916
  initialChanges.push({ ref: entry, payload, files: [] });
85762
85917
  if (entry.type === "document") void documents.open(entry.id);
85763
85918
  }
85764
- writeJsonAtomic(import_node_path15.default.join(stateDir, "server-info"), { type: "server-started", url, port, root });
85919
+ writeJsonAtomic(import_node_path16.default.join(stateDir, "server-info"), { type: "server-started", url, port, root });
85765
85920
  const watcher = watchTree(
85766
85921
  root,
85767
85922
  (files) => {
@@ -85810,6 +85965,7 @@ async function startArtifactsServer(options) {
85810
85965
  onActivity: (listener) => activityListeners.push(listener),
85811
85966
  close: () => new Promise((resolve) => {
85812
85967
  watcher.close();
85968
+ selections.clearAll();
85813
85969
  for (const socket of clients) socket.destroy();
85814
85970
  server.close(() => resolve());
85815
85971
  server.closeAllConnections();
@@ -85818,7 +85974,7 @@ async function startArtifactsServer(options) {
85818
85974
  }
85819
85975
 
85820
85976
  // src/server/lifecycle.ts
85821
- var import_node_fs16 = __toESM(require("node:fs"), 1);
85977
+ var import_node_fs17 = __toESM(require("node:fs"), 1);
85822
85978
  var DEFAULT_IDLE_TIMEOUT_MS = 4 * 60 * 60 * 1e3;
85823
85979
  var DEFAULT_LIFECYCLE_CHECK_MS = 60 * 1e3;
85824
85980
  var SERVER_ID_ARG = "--artifacts-server-id=";
@@ -85848,13 +86004,13 @@ function parseEnv(env, argv = []) {
85848
86004
  };
85849
86005
  }
85850
86006
  function readOwners(file) {
85851
- let text;
86007
+ let text2;
85852
86008
  try {
85853
- text = import_node_fs16.default.readFileSync(file, "utf8");
86009
+ text2 = import_node_fs17.default.readFileSync(file, "utf8");
85854
86010
  } catch {
85855
86011
  return [];
85856
86012
  }
85857
- const pids = text.split("\n").map((line) => Number(line.trim())).filter((pid) => Number.isInteger(pid) && pid > 1);
86013
+ const pids = text2.split("\n").map((line) => Number(line.trim())).filter((pid) => Number.isInteger(pid) && pid > 1);
85858
86014
  return [...new Set(pids)];
85859
86015
  }
85860
86016
  var liveOwners = (pids, alive) => pids.filter(alive);
@@ -85914,15 +86070,15 @@ function openReady(payload) {
85914
86070
  // src/server/main.ts
85915
86071
  async function main() {
85916
86072
  const config = parseEnv(process.env, process.argv.slice(2));
85917
- const root = import_node_path16.default.resolve(config.root);
85918
- const stateDir = import_node_path16.default.join(root, ".state");
86073
+ const root = import_node_path17.default.resolve(config.root);
86074
+ const stateDir = import_node_path17.default.join(root, ".state");
85919
86075
  const server = await startArtifactsServer({
85920
86076
  root,
85921
- viewerDir: import_node_path16.default.join(__dirname, "viewer"),
85922
- runtimeDir: import_node_path16.default.join(__dirname, "runtime"),
86077
+ viewerDir: import_node_path17.default.join(__dirname, "viewer"),
86078
+ runtimeDir: import_node_path17.default.join(__dirname, "runtime"),
85923
86079
  host: config.host,
85924
86080
  urlHost: config.urlHost,
85925
- configFile: import_node_path16.default.join(import_node_path16.default.dirname(root), "config.json"),
86081
+ configFile: import_node_path17.default.join(import_node_path17.default.dirname(root), "config.json"),
85926
86082
  cloud: { origin: config.cloudOrigin, credentialsFile: credentialsFile(process.env, process.platform, import_node_os.default.homedir()) }
85927
86083
  });
85928
86084
  let lastActivity = Date.now();
@@ -85951,12 +86107,12 @@ async function main() {
85951
86107
  if (stopping) return;
85952
86108
  stopping = true;
85953
86109
  console.log(JSON.stringify({ type: "server-stopped", reason }));
85954
- import_node_fs17.default.rmSync(import_node_path16.default.join(stateDir, "server-info"), { force: true });
85955
- writeJsonAtomic(import_node_path16.default.join(stateDir, "server-stopped"), { reason, timestamp: Date.now() });
86110
+ import_node_fs18.default.rmSync(import_node_path17.default.join(stateDir, "server-info"), { force: true });
86111
+ writeJsonAtomic(import_node_path17.default.join(stateDir, "server-stopped"), { reason, timestamp: Date.now() });
85956
86112
  await server.close();
85957
86113
  process.exit(0);
85958
86114
  };
85959
- const ownersFile = import_node_path16.default.join(stateDir, "owners");
86115
+ const ownersFile = import_node_path17.default.join(stateDir, "owners");
85960
86116
  const timer = setInterval(() => {
85961
86117
  const owners = readOwners(ownersFile);
85962
86118
  const reason = shutdownReason({
@@ -85970,7 +86126,7 @@ async function main() {
85970
86126
  timer.unref();
85971
86127
  process.on("SIGTERM", () => void shutdown("SIGTERM"));
85972
86128
  process.on("SIGINT", () => void shutdown("SIGINT"));
85973
- import_node_fs17.default.rmSync(import_node_path16.default.join(stateDir, "server-stopped"), { force: true });
86129
+ import_node_fs18.default.rmSync(import_node_path17.default.join(stateDir, "server-stopped"), { force: true });
85974
86130
  console.log(JSON.stringify({ type: "server-started", url: server.url, port: server.port, root }));
85975
86131
  }
85976
86132
  main().catch((err) => {