@editora/plugins 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  2. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  3. package/dist/a11y-checker.cjs.js +12 -12
  4. package/dist/a11y-checker.esm.js +80 -98
  5. package/dist/anchor.cjs.js +12 -12
  6. package/dist/anchor.esm.js +115 -128
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +40 -40
  10. package/dist/approval-workflow.esm.js +208 -249
  11. package/dist/background-color.cjs.js +2 -2
  12. package/dist/background-color.esm.js +55 -68
  13. package/dist/blockquote.esm.js +1 -2
  14. package/dist/blocks-library.cjs.js +45 -45
  15. package/dist/blocks-library.esm.js +178 -245
  16. package/dist/capitalization.esm.js +1 -2
  17. package/dist/checklist.cjs.js +1 -1
  18. package/dist/checklist.esm.js +58 -82
  19. package/dist/citations.cjs.js +37 -37
  20. package/dist/citations.esm.js +439 -512
  21. package/dist/clear-formatting.cjs.js +1 -1
  22. package/dist/clear-formatting.esm.js +27 -33
  23. package/dist/code-sample.cjs.js +14 -14
  24. package/dist/code-sample.esm.js +82 -93
  25. package/dist/code.cjs.js +32 -32
  26. package/dist/code.esm.js +501 -506
  27. package/dist/comments.cjs.js +6 -6
  28. package/dist/comments.esm.js +116 -158
  29. package/dist/conditional-content.cjs.js +90 -90
  30. package/dist/conditional-content.esm.js +371 -432
  31. package/dist/content-rules.cjs.js +7 -7
  32. package/dist/content-rules.esm.js +105 -159
  33. package/dist/data-binding.cjs.js +46 -46
  34. package/dist/data-binding.esm.js +328 -368
  35. package/dist/direction.esm.js +9 -18
  36. package/dist/doc-schema.cjs.js +29 -29
  37. package/dist/doc-schema.esm.js +240 -308
  38. package/dist/document-manager.cjs.js +1 -1
  39. package/dist/document-manager.esm.js +4 -5
  40. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  41. package/dist/documentManager-Jf0RbSks.js +17 -0
  42. package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
  43. package/dist/embed-iframe.cjs.js +4 -4
  44. package/dist/embed-iframe.esm.js +73 -81
  45. package/dist/emojis.cjs.js +8 -8
  46. package/dist/emojis.esm.js +65 -77
  47. package/dist/enterprise.cjs.js +1 -1
  48. package/dist/enterprise.esm.js +54 -56
  49. package/dist/font-family.cjs.js +1 -1
  50. package/dist/font-family.esm.js +39 -47
  51. package/dist/font-size.cjs.js +1 -1
  52. package/dist/font-size.esm.js +37 -53
  53. package/dist/footnote.cjs.js +2 -2
  54. package/dist/footnote.esm.js +76 -117
  55. package/dist/history.cjs.js +1 -1
  56. package/dist/history.esm.js +70 -92
  57. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  58. package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
  59. package/dist/indent.cjs.js +1 -1
  60. package/dist/indent.esm.js +12 -24
  61. package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
  62. package/dist/index-CvJk4DKa.js +221 -0
  63. package/dist/index-D3CycEFU.mjs +16543 -0
  64. package/dist/index-tqLTHcO6.js +1 -0
  65. package/dist/index.cjs.js +1 -1
  66. package/dist/index.es-CE_A4QSm.js +5 -0
  67. package/dist/index.es-DQ78mYYo.mjs +6665 -0
  68. package/dist/index.esm.js +125 -128
  69. package/dist/italic.cjs.js +1 -1
  70. package/dist/italic.esm.js +8 -9
  71. package/dist/jspdf.es.min-BoS80556.js +77 -0
  72. package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
  73. package/dist/line-height.cjs.js +1 -1
  74. package/dist/line-height.esm.js +11 -24
  75. package/dist/link.cjs.js +5 -5
  76. package/dist/link.esm.js +24 -30
  77. package/dist/list.cjs.js +1 -1
  78. package/dist/list.esm.js +20 -25
  79. package/dist/lite.cjs.js +1 -1
  80. package/dist/lite.esm.js +59 -61
  81. package/dist/math.cjs.js +21 -21
  82. package/dist/math.esm.js +139 -146
  83. package/dist/media-manager.cjs.js +31 -31
  84. package/dist/media-manager.esm.js +285 -300
  85. package/dist/mentions.cjs.js +9 -9
  86. package/dist/mentions.esm.js +238 -286
  87. package/dist/merge-tag.cjs.js +2 -2
  88. package/dist/merge-tag.esm.js +177 -216
  89. package/dist/page-break.cjs.js +2 -2
  90. package/dist/page-break.esm.js +33 -49
  91. package/dist/pii-redaction.cjs.js +19 -19
  92. package/dist/pii-redaction.esm.js +393 -463
  93. package/dist/plugins.css +1 -0
  94. package/dist/preview.esm.js +5 -10
  95. package/dist/print.cjs.js +4 -4
  96. package/dist/print.esm.js +17 -20
  97. package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
  98. package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
  99. package/dist/slash-commands.cjs.js +2 -2
  100. package/dist/slash-commands.esm.js +39 -75
  101. package/dist/smart-paste.cjs.js +27 -27
  102. package/dist/smart-paste.esm.js +280 -336
  103. package/dist/special-characters.cjs.js +7 -7
  104. package/dist/special-characters.esm.js +61 -69
  105. package/dist/spell-check.cjs.js +5 -5
  106. package/dist/spell-check.esm.js +97 -123
  107. package/dist/strikethrough.cjs.js +1 -1
  108. package/dist/strikethrough.esm.js +14 -19
  109. package/dist/table.cjs.js +4 -4
  110. package/dist/table.esm.js +191 -225
  111. package/dist/template.cjs.js +21 -20
  112. package/dist/template.esm.js +715 -196
  113. package/dist/text-alignment.cjs.js +1 -1
  114. package/dist/text-alignment.esm.js +21 -27
  115. package/dist/text-color.cjs.js +3 -3
  116. package/dist/text-color.esm.js +70 -87
  117. package/dist/track-changes.cjs.js +2 -2
  118. package/dist/track-changes.esm.js +100 -162
  119. package/dist/translation-workflow.cjs.js +74 -74
  120. package/dist/translation-workflow.esm.js +602 -678
  121. package/dist/version-diff.cjs.js +14 -14
  122. package/dist/version-diff.esm.js +128 -157
  123. package/package.json +1 -1
  124. package/dist/_commonjsHelpers-6763f629.js +0 -1
  125. package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
  126. package/dist/anchoredPopover-33f1358d.mjs +0 -109
  127. package/dist/anchoredPopover-8151d535.js +0 -1
  128. package/dist/documentManager-25b6203c.mjs +0 -9122
  129. package/dist/documentManager-b69e7054.js +0 -17
  130. package/dist/html2canvas.esm-09133e29.js +0 -22
  131. package/dist/index-656d224b.js +0 -231
  132. package/dist/index-6a8c48bb.js +0 -1
  133. package/dist/index-d027b7e2.mjs +0 -16859
  134. package/dist/index.es-730f2d98.mjs +0 -5775
  135. package/dist/index.es-dd40173b.js +0 -18
  136. package/dist/jspdf.es.min-90db2c97.js +0 -243
  137. package/dist/style.css +0 -1
  138. /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
package/dist/code.esm.js CHANGED
@@ -30,28 +30,28 @@ class D {
30
30
  return this.getLine(e.start.line).substring(e.start.column, e.end.column);
31
31
  const t = [];
32
32
  t.push(this.getLine(e.start.line).substring(e.start.column));
33
- for (let i = e.start.line + 1; i < e.end.line; i++)
34
- t.push(this.getLine(i));
33
+ for (let s = e.start.line + 1; s < e.end.line; s++)
34
+ t.push(this.getLine(s));
35
35
  return e.end.line < this.getLineCount() && t.push(this.getLine(e.end.line).substring(0, e.end.column)), t.join(`
36
36
  `);
37
37
  }
38
38
  // Replace text in range
39
39
  replaceRange(e, t) {
40
- const i = this.getTextInRange(e);
40
+ const s = this.getTextInRange(e);
41
41
  if (e.start.line === e.end.line) {
42
- const s = this.getLine(e.start.line), n = s.substring(0, e.start.column) + t + s.substring(e.end.column);
42
+ const i = this.getLine(e.start.line), n = i.substring(0, e.start.column) + t + i.substring(e.end.column);
43
43
  this._lines[e.start.line] = n;
44
44
  } else {
45
- const s = this.getLine(e.start.line), n = this.getLine(e.end.line), r = s.substring(0, e.start.column) + t, o = n.substring(e.end.column), a = t.split(`
45
+ const i = this.getLine(e.start.line), n = this.getLine(e.end.line), r = i.substring(0, e.start.column) + t, o = n.substring(e.end.column), l = t.split(`
46
46
  `);
47
- a[0] = r + a[0], a[a.length - 1] = a[a.length - 1] + o, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...a);
47
+ l[0] = r + l[0], l[l.length - 1] = l[l.length - 1] + o, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...l);
48
48
  }
49
- return this._version++, { range: e, text: t, oldText: i };
49
+ return this._version++, { range: e, text: t, oldText: s };
50
50
  }
51
51
  // Insert text at position
52
52
  insertText(e, t) {
53
- const i = { start: e, end: e };
54
- return this.replaceRange(i, t);
53
+ const s = { start: e, end: e };
54
+ return this.replaceRange(s, t);
55
55
  }
56
56
  // Delete text in range
57
57
  deleteRange(e) {
@@ -60,18 +60,18 @@ class D {
60
60
  // Convert position to offset
61
61
  positionToOffset(e) {
62
62
  let t = 0;
63
- for (let i = 0; i < e.line; i++)
64
- t += this.getLine(i).length + 1;
63
+ for (let s = 0; s < e.line; s++)
64
+ t += this.getLine(s).length + 1;
65
65
  return t += e.column, t;
66
66
  }
67
67
  // Convert offset to position
68
68
  offsetToPosition(e) {
69
69
  let t = e;
70
- for (let i = 0; i < this.getLineCount(); i++) {
71
- const s = this.getLine(i).length;
72
- if (t <= s)
73
- return { line: i, column: t };
74
- t -= s + 1;
70
+ for (let s = 0; s < this.getLineCount(); s++) {
71
+ const i = this.getLine(s).length;
72
+ if (t <= i)
73
+ return { line: s, column: t };
74
+ t -= i + 1;
75
75
  }
76
76
  return {
77
77
  line: this.getLineCount() - 1,
@@ -149,8 +149,8 @@ class Z {
149
149
  }
150
150
  // Update line numbers
151
151
  updateLineNumbers(e) {
152
- const t = Math.max(e, 20), i = Array.from({ length: t }, (s, n) => n + 1);
153
- this.lineNumbersElement.innerHTML = i.map((s) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${s}</div>`).join("");
152
+ const t = Math.max(e, 20), s = Array.from({ length: t }, (i, n) => n + 1);
153
+ this.lineNumbersElement.innerHTML = s.map((i) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${i}</div>`).join("");
154
154
  }
155
155
  // Get content element
156
156
  getContentElement() {
@@ -175,8 +175,8 @@ class Z {
175
175
  }
176
176
  // Set inner HTML (used for syntax highlighted content)
177
177
  setHTML(e) {
178
- const t = /\n$/.test(e), i = /&lt;|&gt;/.test(e), s = /<span\b/i.test(e), n = /<[^>]+>/.test(e);
179
- i && s ? this.contentElement.innerHTML = e : n && !i ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
178
+ const t = /\n$/.test(e), s = /&lt;|&gt;/.test(e), i = /<span\b/i.test(e), n = /<[^>]+>/.test(e);
179
+ s && i ? this.contentElement.innerHTML = e : n && !s ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
180
180
  const r = (this.contentElement.textContent || "").split(`
181
181
  `).length;
182
182
  this.updateLineNumbers(r);
@@ -192,37 +192,37 @@ class Z {
192
192
  const e = window.getSelection();
193
193
  if (!e || e.rangeCount === 0)
194
194
  return { line: 0, column: 0 };
195
- const t = e.getRangeAt(0), i = t.cloneRange();
196
- i.selectNodeContents(this.contentElement), i.setEnd(t.endContainer, t.endOffset);
197
- const s = i.toString().replace(/\u200B/g, "").split(`
195
+ const t = e.getRangeAt(0), s = t.cloneRange();
196
+ s.selectNodeContents(this.contentElement), s.setEnd(t.endContainer, t.endOffset);
197
+ const i = s.toString().replace(/\u200B/g, "").split(`
198
198
  `);
199
199
  return {
200
- line: s.length - 1,
201
- column: s[s.length - 1].length
200
+ line: i.length - 1,
201
+ column: i[i.length - 1].length
202
202
  };
203
203
  }
204
204
  // Set cursor position
205
205
  setCursorPosition(e) {
206
206
  var t;
207
- const i = this.getText().split(`
208
- `), s = Math.min(e.line, i.length - 1), n = Math.min(e.column, ((t = i[s]) == null ? void 0 : t.length) || 0);
207
+ const s = this.getText().split(`
208
+ `), i = Math.min(e.line, s.length - 1), n = Math.min(e.column, ((t = s[i]) == null ? void 0 : t.length) || 0);
209
209
  let r = 0;
210
- for (let l = 0; l < s; l++)
211
- r += i[l].length + 1;
210
+ for (let a = 0; a < i; a++)
211
+ r += s[a].length + 1;
212
212
  r += n;
213
- const o = document.createRange(), a = window.getSelection(), h = this.resolveOffsetToDomPoint(r);
213
+ const o = document.createRange(), l = window.getSelection(), h = this.resolveOffsetToDomPoint(r);
214
214
  if (h)
215
215
  try {
216
- o.setStart(h.node, h.offset), o.setEnd(h.node, h.offset), a == null || a.removeAllRanges(), a == null || a.addRange(o), this.ensureCaretVisible();
217
- } catch (l) {
218
- console.warn("Could not set cursor position:", l);
216
+ o.setStart(h.node, h.offset), o.setEnd(h.node, h.offset), l?.removeAllRanges(), l?.addRange(o), this.ensureCaretVisible();
217
+ } catch (a) {
218
+ console.warn("Could not set cursor position:", a);
219
219
  }
220
220
  else {
221
- const l = this.contentElement.querySelector(
221
+ const a = this.contentElement.querySelector(
222
222
  `[${this.trailingNewlineMarkerAttr}]`
223
223
  );
224
224
  try {
225
- l && l.parentNode === this.contentElement ? o.setStartBefore(l) : (o.selectNodeContents(this.contentElement), o.collapse(!1)), o.collapse(!0), a == null || a.removeAllRanges(), a == null || a.addRange(o), this.ensureCaretVisible();
225
+ a && a.parentNode === this.contentElement ? o.setStartBefore(a) : (o.selectNodeContents(this.contentElement), o.collapse(!1)), o.collapse(!0), l?.removeAllRanges(), l?.addRange(o), this.ensureCaretVisible();
226
226
  } catch (c) {
227
227
  console.warn("Could not set fallback cursor position:", c);
228
228
  }
@@ -233,17 +233,17 @@ class Z {
233
233
  const e = window.getSelection();
234
234
  if (!e || e.rangeCount === 0 || e.isCollapsed)
235
235
  return;
236
- const t = e.getRangeAt(0), i = t.cloneRange();
237
- i.selectNodeContents(this.contentElement), i.setEnd(t.startContainer, t.startOffset);
238
- const s = i.toString().replace(/\u200B/g, "").split(`
236
+ const t = e.getRangeAt(0), s = t.cloneRange();
237
+ s.selectNodeContents(this.contentElement), s.setEnd(t.startContainer, t.startOffset);
238
+ const i = s.toString().replace(/\u200B/g, "").split(`
239
239
  `), n = t.cloneRange();
240
240
  n.selectNodeContents(this.contentElement), n.setEnd(t.endContainer, t.endOffset);
241
241
  const r = n.toString().replace(/\u200B/g, "").split(`
242
242
  `);
243
243
  return {
244
244
  start: {
245
- line: s.length - 1,
246
- column: s[s.length - 1].length
245
+ line: i.length - 1,
246
+ column: i[i.length - 1].length
247
247
  },
248
248
  end: {
249
249
  line: r.length - 1,
@@ -254,23 +254,23 @@ class Z {
254
254
  // Set selection range
255
255
  setSelectionRange(e) {
256
256
  const t = this.getText().split(`
257
- `), i = (c) => {
258
- const d = Math.max(0, Math.min(c.line, t.length - 1)), p = Math.max(
257
+ `), s = (c) => {
258
+ const d = Math.max(0, Math.min(c.line, t.length - 1)), f = Math.max(
259
259
  0,
260
260
  Math.min(c.column, t[d] ? t[d].length : 0)
261
261
  );
262
262
  let u = 0;
263
263
  for (let g = 0; g < d; g++)
264
264
  u += t[g].length + 1;
265
- return u + p;
266
- }, s = i(e.start), n = i(e.end), [r, o] = s <= n ? [s, n] : [n, s], a = this.resolveOffsetToDomPoint(r), h = this.resolveOffsetToDomPoint(o);
267
- if (!a || !h)
265
+ return u + f;
266
+ }, i = s(e.start), n = s(e.end), [r, o] = i <= n ? [i, n] : [n, i], l = this.resolveOffsetToDomPoint(r), h = this.resolveOffsetToDomPoint(o);
267
+ if (!l || !h)
268
268
  return;
269
- const l = document.createRange();
269
+ const a = document.createRange();
270
270
  try {
271
- l.setStart(a.node, a.offset), l.setEnd(h.node, h.offset);
271
+ a.setStart(l.node, l.offset), a.setEnd(h.node, h.offset);
272
272
  const c = window.getSelection();
273
- c == null || c.removeAllRanges(), c == null || c.addRange(l), this.ensureCaretVisible();
273
+ c?.removeAllRanges(), c?.addRange(a), this.ensureCaretVisible();
274
274
  } catch (c) {
275
275
  console.warn("Could not set selection range:", c);
276
276
  }
@@ -289,8 +289,8 @@ class Z {
289
289
  }
290
290
  // Apply theme
291
291
  applyTheme(e) {
292
- Object.entries(e).forEach(([t, i]) => {
293
- this.container.style.setProperty(`--${t}`, i);
292
+ Object.entries(e).forEach(([t, s]) => {
293
+ this.container.style.setProperty(`--${t}`, s);
294
294
  });
295
295
  }
296
296
  // Scroll to position
@@ -311,7 +311,7 @@ class Z {
311
311
  this.editorContainer.scrollTop = e;
312
312
  }
313
313
  syncTrailingNewlineMarker(e) {
314
- if (this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach((i) => i.remove()), !e)
314
+ if (this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach((s) => s.remove()), !e)
315
315
  return;
316
316
  const t = document.createElement("span");
317
317
  t.setAttribute(this.trailingNewlineMarkerAttr, "true"), t.setAttribute("aria-hidden", "true"), t.contentEditable = "false", t.style.cssText = `
@@ -328,13 +328,13 @@ class Z {
328
328
  const t = window.getSelection();
329
329
  if (!t || t.rangeCount === 0)
330
330
  return;
331
- const i = t.getRangeAt(0).cloneRange();
332
- i.collapse(!1);
333
- let s = i.getClientRects()[0] || i.getBoundingClientRect();
334
- if ((!s || s.width === 0 && s.height === 0) && t.focusNode instanceof Element ? s = t.focusNode.getBoundingClientRect() : (!s || s.width === 0 && s.height === 0) && (e = t.focusNode) != null && e.parentElement && (s = t.focusNode.parentElement.getBoundingClientRect()), !s)
331
+ const s = t.getRangeAt(0).cloneRange();
332
+ s.collapse(!1);
333
+ let i = s.getClientRects()[0] || s.getBoundingClientRect();
334
+ if ((!i || i.width === 0 && i.height === 0) && t.focusNode instanceof Element ? i = t.focusNode.getBoundingClientRect() : (!i || i.width === 0 && i.height === 0) && (e = t.focusNode) != null && e.parentElement && (i = t.focusNode.parentElement.getBoundingClientRect()), !i)
335
335
  return;
336
336
  const n = this.editorContainer.getBoundingClientRect(), r = 12;
337
- s.bottom > n.bottom - r ? this.editorContainer.scrollTop += s.bottom - (n.bottom - r) : s.top < n.top + r && (this.editorContainer.scrollTop -= n.top + r - s.top);
337
+ i.bottom > n.bottom - r ? this.editorContainer.scrollTop += i.bottom - (n.bottom - r) : i.top < n.top + r && (this.editorContainer.scrollTop -= n.top + r - i.top);
338
338
  }
339
339
  // Destroy the view
340
340
  destroy() {
@@ -342,8 +342,8 @@ class Z {
342
342
  }
343
343
  resolveOffsetToDomPoint(e) {
344
344
  var t;
345
- const i = Math.max(0, e);
346
- let s = 0;
345
+ const s = Math.max(0, e);
346
+ let i = 0;
347
347
  const n = document.createTreeWalker(
348
348
  this.contentElement,
349
349
  NodeFilter.SHOW_TEXT,
@@ -351,32 +351,32 @@ class Z {
351
351
  );
352
352
  let r = null, o;
353
353
  for (; o = n.nextNode(); ) {
354
- const a = o.parentElement;
355
- if (a != null && a.hasAttribute(this.trailingNewlineMarkerAttr))
354
+ const l = o.parentElement;
355
+ if (l != null && l.hasAttribute(this.trailingNewlineMarkerAttr))
356
356
  continue;
357
357
  r = o;
358
- const h = o.textContent || "", l = this.buildVisibleToDomMap(h), c = Math.max(0, l.length - 1);
359
- if (s + c >= i) {
360
- const d = Math.max(0, i - s), p = l[d] ?? h.length;
358
+ const h = o.textContent || "", a = this.buildVisibleToDomMap(h), c = Math.max(0, a.length - 1);
359
+ if (i + c >= s) {
360
+ const d = Math.max(0, s - i), f = a[d] ?? h.length;
361
361
  return {
362
362
  node: o,
363
- offset: p
363
+ offset: f
364
364
  };
365
365
  }
366
- s += c;
366
+ i += c;
367
367
  }
368
368
  if (r) {
369
- const a = ((t = r.textContent) == null ? void 0 : t.length) || 0;
370
- return { node: r, offset: a };
369
+ const l = ((t = r.textContent) == null ? void 0 : t.length) || 0;
370
+ return { node: r, offset: l };
371
371
  }
372
372
  return null;
373
373
  }
374
374
  buildVisibleToDomMap(e) {
375
375
  const t = [0];
376
- let i = 0;
377
- for (let s = 0; s < e.length; s++) {
378
- const n = e[s];
379
- this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
376
+ let s = 0;
377
+ for (let i = 0; i < e.length; i++) {
378
+ const n = e[i];
379
+ this.virtualMarkerRegex.test(n) || (s += 1, t[s] = i + 1);
380
380
  }
381
381
  return t;
382
382
  }
@@ -391,7 +391,7 @@ const F = class L {
391
391
  lineWrapping: !1,
392
392
  lineNumbers: !0,
393
393
  ...t
394
- }, this.textModel = new D(this.config.value), this.view = new Z(e), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((i) => this.addExtension(i)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
394
+ }, this.textModel = new D(this.config.value), this.view = new Z(e), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((s) => this.addExtension(s)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
395
395
  }
396
396
  // Public accessors for extensions
397
397
  getTextModel() {
@@ -417,21 +417,21 @@ const F = class L {
417
417
  setupEventHandlers() {
418
418
  const e = this.view.getContentElement();
419
419
  e.addEventListener("input", () => {
420
- const t = this.view.getText(), i = this.textModel.getText();
421
- if (t !== i) {
420
+ const t = this.view.getText(), s = this.textModel.getText();
421
+ if (t !== s) {
422
422
  if (!this.suppressHistory) {
423
- const s = this.getCursor().position, n = this.textModel.positionToOffset(s), r = this.getSelection();
424
- let o, a;
425
- r && (o = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: i, cursorOffset: n, anchorOffset: o, focusOffset: a }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
423
+ const i = this.getCursor().position, n = this.textModel.positionToOffset(i), r = this.getSelection();
424
+ let o, l;
425
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: s, cursorOffset: n, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
426
426
  }
427
427
  this.textModel.setText(t), this.view.syncTrailingNewlineMarkerForText(t), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
428
- const s = this.view.getText();
429
- s !== this.textModel.getText() && this.textModel.setText(s), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
430
- }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: i }]);
428
+ const i = this.view.getText();
429
+ i !== this.textModel.getText() && this.textModel.setText(i), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
430
+ }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: s }]);
431
431
  }
432
432
  }), e.addEventListener("selectionchange", () => {
433
- const t = this.getCursor(), i = this.getSelection();
434
- this.emit("cursor", t), i && this.emit("selection", i);
433
+ const t = this.getCursor(), s = this.getSelection();
434
+ this.emit("cursor", t), s && this.emit("selection", s);
435
435
  }), e.addEventListener("keydown", (t) => {
436
436
  if (this.emit("keydown", t), t.key === "Tab") {
437
437
  this.config.readOnly || this.insertTab(), t.preventDefault(), t.stopPropagation();
@@ -439,33 +439,33 @@ const F = class L {
439
439
  }
440
440
  if (t.key === "Enter") {
441
441
  if (!this.config.readOnly) {
442
- const i = window.getSelection();
443
- if (i && i.rangeCount > 0) {
444
- const s = this.getCursor().position, n = this.textModel.positionToOffset(s), r = this.getSelection();
445
- let o, a;
446
- r && (o = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end));
447
- const h = r && o !== void 0 && a !== void 0 ? Math.min(o, a) : n;
448
- this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: n, anchorOffset: o, focusOffset: a }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
449
- const l = i.getRangeAt(0);
450
- l.deleteContents();
442
+ const s = window.getSelection();
443
+ if (s && s.rangeCount > 0) {
444
+ const i = this.getCursor().position, n = this.textModel.positionToOffset(i), r = this.getSelection();
445
+ let o, l;
446
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end));
447
+ const h = r && o !== void 0 && l !== void 0 ? Math.min(o, l) : n;
448
+ this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: n, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
449
+ const a = s.getRangeAt(0);
450
+ a.deleteContents();
451
451
  const c = document.createTextNode(`
452
452
  `);
453
- l.insertNode(c), l.setStartAfter(c), l.collapse(!0), i.removeAllRanges(), i.addRange(l), this.view.ensureCaretVisible();
453
+ a.insertNode(c), a.setStartAfter(c), a.collapse(!0), s.removeAllRanges(), s.addRange(a), this.view.ensureCaretVisible();
454
454
  const d = this.view.getText();
455
455
  this.textModel.setText(d), this.view.syncTrailingNewlineMarkerForText(d);
456
- const p = Math.min(
456
+ const f = Math.min(
457
457
  h + 1,
458
458
  this.textModel.getText().length
459
459
  );
460
460
  try {
461
- const u = this.textModel.offsetToPosition(p);
461
+ const u = this.textModel.offsetToPosition(f);
462
462
  this.setCursor(u), this.view.ensureCaretVisible();
463
463
  } catch {
464
464
  }
465
465
  this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
466
466
  this.renderTextWithHighlight(this.textModel.getText(), !1), requestAnimationFrame(() => {
467
467
  try {
468
- const u = this.textModel.offsetToPosition(p);
468
+ const u = this.textModel.offsetToPosition(f);
469
469
  this.setCursor(u), this.view.ensureCaretVisible();
470
470
  } catch {
471
471
  }
@@ -476,15 +476,15 @@ const F = class L {
476
476
  t.preventDefault(), t.stopPropagation();
477
477
  return;
478
478
  }
479
- for (const i of this.extensions.values())
480
- if (i.onKeyDown && i.onKeyDown(t) === !1) {
479
+ for (const s of this.extensions.values())
480
+ if (s.onKeyDown && s.onKeyDown(t) === !1) {
481
481
  t.preventDefault(), t.stopPropagation();
482
482
  return;
483
483
  }
484
484
  }), e.addEventListener("mousedown", (t) => {
485
485
  this.emit("mousedown", t);
486
- for (const i of this.extensions.values())
487
- if (i.onMouseDown && i.onMouseDown(t) === !1) {
486
+ for (const s of this.extensions.values())
487
+ if (s.onMouseDown && s.onMouseDown(t) === !1) {
488
488
  t.preventDefault(), t.stopPropagation();
489
489
  return;
490
490
  }
@@ -511,8 +511,8 @@ const F = class L {
511
511
  }
512
512
  // Emit events to listeners
513
513
  emit(e, ...t) {
514
- const i = this.eventListeners.get(e);
515
- i && i.forEach((s) => s(...t));
514
+ const s = this.eventListeners.get(e);
515
+ s && s.forEach((i) => i(...t));
516
516
  }
517
517
  // State management
518
518
  getValue() {
@@ -560,12 +560,12 @@ const F = class L {
560
560
  "editor-gutter-border": e === "dark" ? "#3e3e42" : "#e1e5e9"
561
561
  };
562
562
  this.view.applyTheme(t);
563
- const i = this.extensions.get("syntax-highlighting");
564
- if (i && typeof i.setTheme == "function")
563
+ const s = this.extensions.get("syntax-highlighting");
564
+ if (s && typeof s.setTheme == "function")
565
565
  try {
566
- i.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
567
- } catch (s) {
568
- console.warn("Error applying theme to syntax-highlighting extension", s);
566
+ s.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
567
+ } catch (i) {
568
+ console.warn("Error applying theme to syntax-highlighting extension", i);
569
569
  }
570
570
  }
571
571
  setReadOnly(e) {
@@ -582,8 +582,8 @@ const F = class L {
582
582
  t && t.destroy && t.destroy(), this.extensions.delete(e);
583
583
  }
584
584
  executeCommand(e, ...t) {
585
- const i = this.commands.get(e);
586
- i ? i(this, ...t) : console.warn(`Command '${e}' not found`);
585
+ const s = this.commands.get(e);
586
+ s ? s(this, ...t) : console.warn(`Command '${e}' not found`);
587
587
  }
588
588
  // Register a command
589
589
  registerCommand(e, t) {
@@ -593,92 +593,92 @@ const F = class L {
593
593
  search(e, t = {}) {
594
594
  if (!e)
595
595
  return [];
596
- const i = {
596
+ const s = {
597
597
  query: e,
598
598
  caseSensitive: !1,
599
599
  wholeWord: !1,
600
600
  regex: !1,
601
601
  ...t
602
- }, s = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(n), a = i.caseSensitive ? r : r.toLowerCase(), h = i.caseSensitive ? e : e.toLowerCase();
603
- if (i.regex) {
604
- let l;
602
+ }, i = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(n), l = s.caseSensitive ? r : r.toLowerCase(), h = s.caseSensitive ? e : e.toLowerCase();
603
+ if (s.regex) {
604
+ let a;
605
605
  try {
606
- l = new RegExp(e, i.caseSensitive ? "g" : "gi");
606
+ a = new RegExp(e, s.caseSensitive ? "g" : "gi");
607
607
  } catch {
608
608
  return [];
609
609
  }
610
610
  let c;
611
- for (; (c = l.exec(r)) !== null; ) {
611
+ for (; (c = a.exec(r)) !== null; ) {
612
612
  const d = c[0] ?? "";
613
613
  if (d.length === 0) {
614
- l.lastIndex = c.index + 1;
614
+ a.lastIndex = c.index + 1;
615
615
  continue;
616
616
  }
617
- const p = c.index, u = c.index + d.length;
618
- i.wholeWord && !this.isWholeWordBoundary(r, p, u) || this.pushSearchResultFromOffsets(
619
- s,
620
- p,
617
+ const f = c.index, u = c.index + d.length;
618
+ s.wholeWord && !this.isWholeWordBoundary(r, f, u) || this.pushSearchResultFromOffsets(
619
+ i,
620
+ f,
621
621
  u,
622
622
  r,
623
623
  o
624
624
  );
625
625
  }
626
626
  } else {
627
- let l = 0, c = a.indexOf(h, l);
627
+ let a = 0, c = l.indexOf(h, a);
628
628
  for (; c !== -1; ) {
629
629
  const d = c + h.length;
630
- !i.wholeWord || this.isWholeWordBoundary(r, c, d) ? (this.pushSearchResultFromOffsets(
631
- s,
630
+ !s.wholeWord || this.isWholeWordBoundary(r, c, d) ? (this.pushSearchResultFromOffsets(
631
+ i,
632
632
  c,
633
633
  d,
634
634
  r,
635
635
  o
636
- ), l = d) : l = c + 1, c = a.indexOf(h, l);
636
+ ), a = d) : a = c + 1, c = l.indexOf(h, a);
637
637
  }
638
638
  }
639
- return s;
639
+ return i;
640
640
  }
641
- pushSearchResultFromOffsets(e, t, i, s, n) {
642
- const r = n[t] ?? t, o = n[i] ?? r, a = this.textModel.offsetToPosition(r), h = this.textModel.offsetToPosition(o);
641
+ pushSearchResultFromOffsets(e, t, s, i, n) {
642
+ const r = n[t] ?? t, o = n[s] ?? r, l = this.textModel.offsetToPosition(r), h = this.textModel.offsetToPosition(o);
643
643
  e.push({
644
- range: { start: a, end: h },
645
- match: s.substring(t, i)
644
+ range: { start: l, end: h },
645
+ match: i.substring(t, s)
646
646
  });
647
647
  }
648
- isWholeWordBoundary(e, t, i) {
649
- const s = t > 0 ? e[t - 1] : "", n = i < e.length ? e[i] : "";
650
- return !this.isWordChar(s) && !this.isWordChar(n);
648
+ isWholeWordBoundary(e, t, s) {
649
+ const i = t > 0 ? e[t - 1] : "", n = s < e.length ? e[s] : "";
650
+ return !this.isWordChar(i) && !this.isWordChar(n);
651
651
  }
652
652
  isWordChar(e) {
653
653
  return /^[A-Za-z0-9_]$/.test(e);
654
654
  }
655
655
  buildSearchTextAndOffsetMap(e) {
656
- const t = [], i = [0];
657
- let s = 0;
656
+ const t = [], s = [0];
657
+ let i = 0;
658
658
  for (let n = 0; n < e.length; n++) {
659
659
  const r = e[n];
660
- r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), s += 1, i[s] = n + 1);
660
+ r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), i += 1, s[i] = n + 1);
661
661
  }
662
- return i[s] = e.length, {
662
+ return s[i] = e.length, {
663
663
  normalizedText: t.join(""),
664
- normalizedToRawOffsets: i
664
+ normalizedToRawOffsets: s
665
665
  };
666
666
  }
667
667
  replace(e, t) {
668
- const i = this.getValue();
668
+ const s = this.getValue();
669
669
  if (!this.suppressHistory) {
670
670
  const n = this.getCursor().position, r = this.textModel.positionToOffset(n), o = this.getSelection();
671
- let a, h;
672
- o && (a = this.textModel.positionToOffset(o.start), h = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: i, cursorOffset: r, anchorOffset: a, focusOffset: h }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
671
+ let l, h;
672
+ o && (l = this.textModel.positionToOffset(o.start), h = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: s, cursorOffset: r, anchorOffset: l, focusOffset: h }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
673
673
  }
674
- const s = this.textModel.replaceRange(e, t);
675
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [s]);
674
+ const i = this.textModel.replaceRange(e, t);
675
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [i]);
676
676
  }
677
- replaceAll(e, t, i = {}) {
678
- const s = this.search(e, i);
677
+ replaceAll(e, t, s = {}) {
678
+ const i = this.search(e, s);
679
679
  let n = 0;
680
- for (let r = s.length - 1; r >= 0; r--)
681
- this.replace(s[r].range, t), n++;
680
+ for (let r = i.length - 1; r >= 0; r--)
681
+ this.replace(i[r].range, t), n++;
682
682
  return n;
683
683
  }
684
684
  // Folding (basic implementation)
@@ -711,32 +711,32 @@ const F = class L {
711
711
  // and restores it after updating the DOM. Callers that will explicitly set the caret
712
712
  // should pass `false` to avoid stomping programmatic cursor changes.
713
713
  renderTextWithHighlight(e, t = !0) {
714
- const i = this.extensions.get("syntax-highlighting");
715
- if (i && typeof i.highlightHTML == "function")
714
+ const s = this.extensions.get("syntax-highlighting");
715
+ if (s && typeof s.highlightHTML == "function")
716
716
  try {
717
- const s = !t && !this.expectingProgrammaticCursor;
718
- let n, r, o, a;
719
- if (t || s) {
717
+ const i = !t && !this.expectingProgrammaticCursor;
718
+ let n, r, o, l;
719
+ if (t || i) {
720
720
  n = this.getSelection();
721
721
  const d = this.getCollapsedSelectionOffsetInEditor();
722
722
  if (d !== void 0)
723
723
  r = d;
724
724
  else {
725
- const p = this.getCursor().position;
726
- r = this.textModel.positionToOffset(p);
725
+ const f = this.getCursor().position;
726
+ r = this.textModel.positionToOffset(f);
727
727
  }
728
- n && (o = this.textModel.positionToOffset(n.start), a = this.textModel.positionToOffset(n.end));
728
+ n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end));
729
729
  }
730
- const h = (t || s) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), l = h ? this.insertSentinelAtOffset(e, r) : e, c = i.highlightHTML(l);
731
- typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && requestAnimationFrame(() => {
730
+ const h = (t || i) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), a = h ? this.insertSentinelAtOffset(e, r) : e, c = s.highlightHTML(a);
731
+ typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), this.view.syncTrailingNewlineMarkerForText(e), (t || i) && requestAnimationFrame(() => {
732
732
  try {
733
733
  if (h && this.restoreCursorFromSentinel()) {
734
734
  this.view.ensureCaretVisible();
735
735
  return;
736
736
  }
737
- if (n && (o !== void 0 || a !== void 0)) {
738
- const d = o !== void 0 ? o : r, p = a !== void 0 ? a : r, u = Math.min(d, p), g = Math.max(d, p), f = this.textModel.offsetToPosition(u), y = this.textModel.offsetToPosition(g);
739
- this.view.setSelectionRange({ start: f, end: y });
737
+ if (n && (o !== void 0 || l !== void 0)) {
738
+ const d = o !== void 0 ? o : r, f = l !== void 0 ? l : r, u = Math.min(d, f), g = Math.max(d, f), p = this.textModel.offsetToPosition(u), y = this.textModel.offsetToPosition(g);
739
+ this.view.setSelectionRange({ start: p, end: y });
740
740
  } else if (r !== void 0) {
741
741
  const d = this.textModel.offsetToPosition(r);
742
742
  this.view.setCursorPosition(d);
@@ -745,8 +745,8 @@ const F = class L {
745
745
  }
746
746
  });
747
747
  return;
748
- } catch (s) {
749
- console.warn("Syntax highlighting failed, falling back to plain text", s);
748
+ } catch (i) {
749
+ console.warn("Syntax highlighting failed, falling back to plain text", i);
750
750
  }
751
751
  this.view.setText(e);
752
752
  }
@@ -761,25 +761,25 @@ const F = class L {
761
761
  const e = window.getSelection();
762
762
  if (!e || e.rangeCount === 0 || !e.isCollapsed)
763
763
  return;
764
- const t = e.getRangeAt(0), i = this.view.getContentElement();
765
- if (!i.contains(t.commonAncestorContainer))
764
+ const t = e.getRangeAt(0), s = this.view.getContentElement();
765
+ if (!s.contains(t.commonAncestorContainer))
766
766
  return;
767
- const s = t.cloneRange();
768
- return s.selectNodeContents(i), s.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(s.toString()).length;
767
+ const i = t.cloneRange();
768
+ return i.selectNodeContents(s), i.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(i.toString()).length;
769
769
  }
770
770
  stripVirtualMarkers(e) {
771
771
  return e.replace(/\u200B/g, "").split(L.CURSOR_SENTINEL).join("");
772
772
  }
773
773
  insertSentinelAtOffset(e, t) {
774
- const i = Math.max(0, Math.min(t, e.length));
775
- return e.slice(0, i) + L.CURSOR_SENTINEL + e.slice(i);
774
+ const s = Math.max(0, Math.min(t, e.length));
775
+ return e.slice(0, s) + L.CURSOR_SENTINEL + e.slice(s);
776
776
  }
777
777
  restoreCursorFromSentinel() {
778
- const e = this.view.getContentElement(), t = window.getSelection(), i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
779
- let s = i.nextNode(), n = null, r = 0;
780
- for (; s; ) {
781
- const o = s.textContent ?? "", a = o.indexOf(L.CURSOR_SENTINEL);
782
- a !== -1 && (n || (n = s, r = a), s.textContent = o.split(L.CURSOR_SENTINEL).join("")), s = i.nextNode();
778
+ const e = this.view.getContentElement(), t = window.getSelection(), s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
779
+ let i = s.nextNode(), n = null, r = 0;
780
+ for (; i; ) {
781
+ const o = i.textContent ?? "", l = o.indexOf(L.CURSOR_SENTINEL);
782
+ l !== -1 && (n || (n = i, r = l), i.textContent = o.split(L.CURSOR_SENTINEL).join("")), i = s.nextNode();
783
783
  }
784
784
  if (!n || !t)
785
785
  return !1;
@@ -806,15 +806,15 @@ const F = class L {
806
806
  this.redoStack.push(t);
807
807
  try {
808
808
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
809
- let i, s;
810
- typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
809
+ let s, i;
810
+ typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
811
811
  try {
812
- if (s != null)
812
+ if (i != null)
813
813
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
814
- const n = e.anchorOffset !== void 0 ? e.anchorOffset : s, r = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(n, r), a = Math.max(n, r), h = this.textModel.offsetToPosition(o), l = this.textModel.offsetToPosition(a);
815
- this.setSelection({ start: h, end: l });
814
+ const n = e.anchorOffset !== void 0 ? e.anchorOffset : i, r = e.focusOffset !== void 0 ? e.focusOffset : i, o = Math.min(n, r), l = Math.max(n, r), h = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
815
+ this.setSelection({ start: h, end: a });
816
816
  } else {
817
- const n = this.textModel.offsetToPosition(s);
817
+ const n = this.textModel.offsetToPosition(i);
818
818
  this.setCursor(n);
819
819
  }
820
820
  } catch {
@@ -833,15 +833,15 @@ const F = class L {
833
833
  this.undoStack.push(t);
834
834
  try {
835
835
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
836
- let i, s;
837
- typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
836
+ let s, i;
837
+ typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
838
838
  try {
839
- if (s != null)
839
+ if (i != null)
840
840
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
841
- const n = e.anchorOffset !== void 0 ? e.anchorOffset : s, r = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(n, r), a = Math.max(n, r), h = this.textModel.offsetToPosition(o), l = this.textModel.offsetToPosition(a);
842
- this.setSelection({ start: h, end: l });
841
+ const n = e.anchorOffset !== void 0 ? e.anchorOffset : i, r = e.focusOffset !== void 0 ? e.focusOffset : i, o = Math.min(n, r), l = Math.max(n, r), h = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
842
+ this.setSelection({ start: h, end: a });
843
843
  } else {
844
- const n = this.textModel.offsetToPosition(s);
844
+ const n = this.textModel.offsetToPosition(i);
845
845
  this.setCursor(n);
846
846
  }
847
847
  } catch {
@@ -857,30 +857,30 @@ const F = class L {
857
857
  insertTab() {
858
858
  if (this.config.readOnly)
859
859
  return;
860
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = " ".repeat(this.config.tabSize || 2), s = this.textModel.insertText(e, i), n = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + i.length);
860
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = " ".repeat(this.config.tabSize || 2), i = this.textModel.insertText(e, s), n = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + s.length);
861
861
  if (!this.suppressHistory) {
862
862
  const r = this.getSelection();
863
- let o, a;
864
- r && (o = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: a }), this.redoStack.length = 0;
863
+ let o, l;
864
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: l }), this.redoStack.length = 0;
865
865
  }
866
866
  this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(n), setTimeout(() => {
867
867
  this.expectingProgrammaticCursor = !1;
868
- }, 20), this.emit("change", [s]);
868
+ }, 20), this.emit("change", [i]);
869
869
  }
870
870
  // Insert a newline at current cursor position
871
871
  insertNewLine() {
872
872
  if (this.config.readOnly)
873
873
  return;
874
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = this.textModel.insertText(e, `
875
- `), s = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
874
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = this.textModel.insertText(e, `
875
+ `), i = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
876
876
  if (!this.suppressHistory) {
877
877
  const n = this.getSelection();
878
878
  let r, o;
879
879
  n && (r = this.textModel.positionToOffset(n.start), o = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: r, focusOffset: o }), this.redoStack.length = 0;
880
880
  }
881
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(s), setTimeout(() => {
881
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(i), setTimeout(() => {
882
882
  this.expectingProgrammaticCursor = !1;
883
- }, 20), this.emit("change", [i]);
883
+ }, 20), this.emit("change", [s]);
884
884
  }
885
885
  // Events
886
886
  on(e, t) {
@@ -889,12 +889,12 @@ const F = class L {
889
889
  off(e, t) {
890
890
  if (!this.eventListeners.has(e))
891
891
  return;
892
- const i = this.eventListeners.get(e);
892
+ const s = this.eventListeners.get(e);
893
893
  if (t) {
894
- const s = i.indexOf(t);
895
- s !== -1 && i.splice(s, 1);
894
+ const i = s.indexOf(t);
895
+ i !== -1 && s.splice(i, 1);
896
896
  } else
897
- i.length = 0;
897
+ s.length = 0;
898
898
  }
899
899
  };
900
900
  F.CURSOR_SENTINEL = "";
@@ -914,12 +914,12 @@ class J {
914
914
  return this.editor.executeCommand(t.command), e.preventDefault(), e.stopPropagation(), !1;
915
915
  }
916
916
  findMatchingBinding(e) {
917
- const { key: t, ctrlKey: i, altKey: s, shiftKey: n, metaKey: r } = e, o = String(t).toLowerCase(), a = this.keymap[o];
918
- if (!a)
917
+ const { key: t, ctrlKey: s, altKey: i, shiftKey: n, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
918
+ if (!l)
919
919
  return null;
920
- for (const h of a) {
921
- const l = h.ctrlKey === void 0 || h.ctrlKey === i, c = h.altKey === void 0 || h.altKey === s, d = h.shiftKey === void 0 || h.shiftKey === n, p = h.metaKey === void 0 || h.metaKey === r;
922
- if (l && c && d && p)
920
+ for (const h of l) {
921
+ const a = h.ctrlKey === void 0 || h.ctrlKey === s, c = h.altKey === void 0 || h.altKey === i, d = h.shiftKey === void 0 || h.shiftKey === n, f = h.metaKey === void 0 || h.metaKey === r;
922
+ if (a && c && d && f)
923
923
  return h;
924
924
  }
925
925
  return null;
@@ -932,12 +932,12 @@ class J {
932
932
  const e = {};
933
933
  return this.addBinding(e, "f", { ctrlKey: !this.isMac, metaKey: this.isMac }, "find"), this.addBinding(e, "h", { ctrlKey: !this.isMac, metaKey: this.isMac }, "replace"), this.addBinding(e, "f3", {}, "findNext"), this.addBinding(e, "f3", { shiftKey: !0 }, "findPrev"), this.addBinding(e, "g", { ctrlKey: !this.isMac, metaKey: this.isMac }, "findNext"), this.addBinding(e, "[", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "fold"), this.addBinding(e, "]", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "unfold"), this.addBinding(e, "s", { ctrlKey: !0 }, "save"), this.addBinding(e, "s", { metaKey: !0 }, "save"), this.addBinding(e, "z", { ctrlKey: !0 }, "undo"), this.addBinding(e, "z", { metaKey: !0 }, "undo"), this.addBinding(e, "y", { ctrlKey: !0 }, "redo"), this.addBinding(e, "y", { metaKey: !0 }, "redo"), this.addBinding(e, "z", { ctrlKey: !0, shiftKey: !0 }, "redo"), this.addBinding(e, "z", { metaKey: !0, shiftKey: !0 }, "redo"), this.addBinding(e, "tab", {}, "insertTab"), this.addBinding(e, "t", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "toggleTheme"), e;
934
934
  }
935
- addBinding(e, t, i, s) {
935
+ addBinding(e, t, s, i) {
936
936
  const n = t.toLowerCase();
937
937
  e[n] || (e[n] = []), e[n].push({
938
938
  key: n,
939
- command: s,
940
- ...i
939
+ command: i,
940
+ ...s
941
941
  });
942
942
  }
943
943
  // Public API for customizing keymap
@@ -946,23 +946,23 @@ class J {
946
946
  }
947
947
  addKeyBinding(e) {
948
948
  const t = e.key.toLowerCase();
949
- this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((i) => i.command !== e.command), this.keymap[t].push({
949
+ this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((s) => s.command !== e.command), this.keymap[t].push({
950
950
  ...e,
951
951
  key: t
952
952
  });
953
953
  }
954
954
  removeKeyBinding(e, t) {
955
- const i = e.toLowerCase();
956
- t ? this.keymap[i] && (this.keymap[i] = this.keymap[i].filter((s) => s.command !== t), this.keymap[i].length === 0 && delete this.keymap[i]) : delete this.keymap[i];
955
+ const s = e.toLowerCase();
956
+ t ? this.keymap[s] && (this.keymap[s] = this.keymap[s].filter((i) => i.command !== t), this.keymap[s].length === 0 && delete this.keymap[s]) : delete this.keymap[s];
957
957
  }
958
958
  getKeymap() {
959
959
  return { ...this.keymap };
960
960
  }
961
961
  getBindingsForCommand(e) {
962
962
  const t = [];
963
- for (const i in this.keymap)
964
- for (const s of this.keymap[i])
965
- s.command === e && t.push({ ...s });
963
+ for (const s in this.keymap)
964
+ for (const i of this.keymap[s])
965
+ i.command === e && t.push({ ...i });
966
966
  return t;
967
967
  }
968
968
  getPlatformInfo() {
@@ -981,13 +981,13 @@ class Y {
981
981
  }
982
982
  setup(e) {
983
983
  e.on("change", (t) => {
984
- const i = {
984
+ const s = {
985
985
  changes: t,
986
986
  selection: e.getSelection(),
987
987
  effects: [],
988
988
  annotations: []
989
989
  };
990
- this.transactions.push(i);
990
+ this.transactions.push(s);
991
991
  });
992
992
  }
993
993
  getTransactions() {
@@ -1018,8 +1018,8 @@ class G {
1018
1018
  if (!this.lineNumbersElement || !this.editor || !this.isEnabled)
1019
1019
  return;
1020
1020
  const e = this.editor.getValue().split(`
1021
- `).length, t = Array.from({ length: Math.max(e, 20) }, (i, s) => s + 1);
1022
- this.lineNumbersElement.innerHTML = t.map((i) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${i}</div>`).join("");
1021
+ `).length, t = Array.from({ length: Math.max(e, 20) }, (s, i) => i + 1);
1022
+ this.lineNumbersElement.innerHTML = t.map((s) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("");
1023
1023
  }
1024
1024
  toggle() {
1025
1025
  if (!this.editor)
@@ -1105,8 +1105,8 @@ const W = class m {
1105
1105
  this.findPrev();
1106
1106
  }), e.registerCommand("replace", () => {
1107
1107
  this.showReplace();
1108
- }), e.registerCommand("replaceAll", (t, i) => {
1109
- this.replaceAll(t, i);
1108
+ }), e.registerCommand("replaceAll", (t, s) => {
1109
+ this.replaceAll(t, s);
1110
1110
  }), this.editorChangeHandler = () => {
1111
1111
  !this.isVisible || !this.currentQuery || this.scheduleLiveRefresh(!0);
1112
1112
  }, e.on("change", this.editorChangeHandler);
@@ -1125,10 +1125,10 @@ const W = class m {
1125
1125
  return;
1126
1126
  const e = this.editor.getView().getContentElement(), t = e.closest(
1127
1127
  this.editorContainerSelector
1128
- ), i = e.closest(".rte-source-editor-modal") || t || e.parentElement;
1129
- if (!i)
1128
+ ), s = e.closest(".rte-source-editor-modal") || t || e.parentElement;
1129
+ if (!s)
1130
1130
  return;
1131
- window.getComputedStyle(i).position === "static" && (i.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = m.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
1131
+ window.getComputedStyle(s).position === "static" && (s.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = m.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
1132
1132
  <div class="${m.css.row}">
1133
1133
  <input type="text" class="${m.css.findInput} ${m.css.inputBase}" placeholder="Find..." />
1134
1134
  <button class="${m.css.prevButton} ${m.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
@@ -1155,7 +1155,7 @@ const W = class m {
1155
1155
  </div>
1156
1156
  <input type="text" class="${m.css.replaceInput} ${m.css.inputBase} ${m.css.replaceInputLayout}" placeholder="Replace with..." />
1157
1157
  `;
1158
- const s = this.searchUI.querySelector(
1158
+ const i = this.searchUI.querySelector(
1159
1159
  `.${m.css.findInput}`
1160
1160
  ), n = this.searchUI.querySelector(
1161
1161
  `.${m.css.replaceInput}`
@@ -1163,41 +1163,41 @@ const W = class m {
1163
1163
  `.${m.css.prevButton}`
1164
1164
  ), o = this.searchUI.querySelector(
1165
1165
  `.${m.css.nextButton}`
1166
- ), a = this.searchUI.querySelector(
1166
+ ), l = this.searchUI.querySelector(
1167
1167
  `.${m.css.closeButton}`
1168
1168
  ), h = this.searchUI.querySelector(
1169
1169
  `.${m.css.status}`
1170
- ), l = this.searchUI.querySelector(
1170
+ ), a = this.searchUI.querySelector(
1171
1171
  `.${m.css.mode}`
1172
1172
  ), c = this.searchUI.querySelector(
1173
1173
  `.${m.css.caseSensitive}`
1174
1174
  ), d = this.searchUI.querySelector(
1175
1175
  `.${m.css.wholeWord}`
1176
- ), p = this.searchUI.querySelector(
1176
+ ), f = this.searchUI.querySelector(
1177
1177
  `.${m.css.regex}`
1178
1178
  );
1179
- this.findInput = s, this.replaceInputEl = n, this.statusDiv = h, this.modeDiv = l, this.caseSensitiveInput = c, this.wholeWordInput = d, this.regexInput = p, c.checked = !!this.searchOptions.caseSensitive, d.checked = !!this.searchOptions.wholeWord, p.checked = !!this.searchOptions.regex, s.addEventListener("input", () => {
1179
+ this.findInput = i, this.replaceInputEl = n, this.statusDiv = h, this.modeDiv = a, this.caseSensitiveInput = c, this.wholeWordInput = d, this.regexInput = f, c.checked = !!this.searchOptions.caseSensitive, d.checked = !!this.searchOptions.wholeWord, f.checked = !!this.searchOptions.regex, i.addEventListener("input", () => {
1180
1180
  this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
1181
- const g = s.value;
1181
+ const g = i.value;
1182
1182
  this.searchDebounceTimer = setTimeout(() => {
1183
1183
  this.performSearch(g, !1, !1);
1184
1184
  }, 120);
1185
1185
  });
1186
1186
  const u = () => {
1187
- this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = d.checked, this.searchOptions.regex = p.checked;
1188
- const g = s.value;
1187
+ this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = d.checked, this.searchOptions.regex = f.checked;
1188
+ const g = i.value;
1189
1189
  g.trim() ? this.performSearch(g, !1, !1) : this.performSearch("", !1, !1);
1190
1190
  };
1191
- c.addEventListener("change", u), d.addEventListener("change", u), p.addEventListener("change", u), s.addEventListener("keydown", (g) => {
1191
+ c.addEventListener("change", u), d.addEventListener("change", u), f.addEventListener("change", u), i.addEventListener("keydown", (g) => {
1192
1192
  g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.findPrev() : this.findNext()) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1193
1193
  }), n.addEventListener("keydown", (g) => {
1194
- g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.replaceAll(s.value, n.value) : this.replaceCurrent(s.value, n.value)) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1195
- }), r.addEventListener("click", () => this.findPrev()), o.addEventListener("click", () => this.findNext()), a.addEventListener("click", () => this.hideSearch()), i.appendChild(this.searchUI);
1194
+ g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.replaceAll(i.value, n.value) : this.replaceCurrent(i.value, n.value)) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1195
+ }), r.addEventListener("click", () => this.findPrev()), o.addEventListener("click", () => this.findNext()), l.addEventListener("click", () => this.hideSearch()), s.appendChild(this.searchUI);
1196
1196
  }
1197
1197
  updateModeHint(e) {
1198
1198
  this.modeDiv && (this.modeDiv.textContent = e ? `Replace: move next ${this.config.replaceAndFindNext ? "ON" : "OFF"}` : "Find mode");
1199
1199
  }
1200
- performSearch(e, t, i) {
1200
+ performSearch(e, t, s) {
1201
1201
  if (!this.editor || !e.trim()) {
1202
1202
  this.currentQuery = "", this.currentResults = [], this.currentIndex = -1, this.clearHighlights(), this.updateStatus("");
1203
1203
  return;
@@ -1207,12 +1207,12 @@ const W = class m {
1207
1207
  return;
1208
1208
  }
1209
1209
  this.currentQuery = e;
1210
- const s = this.currentIndex, n = this.editor.search(e, this.searchOptions);
1210
+ const i = this.currentIndex, n = this.editor.search(e, this.searchOptions);
1211
1211
  if (this.currentResults = n, n.length === 0) {
1212
1212
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("No matches");
1213
1213
  return;
1214
1214
  }
1215
- t && s >= 0 ? this.currentIndex = Math.min(s, n.length - 1) : this.currentIndex = 0, this.updateHighlights(i);
1215
+ t && i >= 0 ? this.currentIndex = Math.min(i, n.length - 1) : this.currentIndex = 0, this.updateHighlights(s);
1216
1216
  }
1217
1217
  findNext() {
1218
1218
  if (this.currentResults.length === 0) {
@@ -1231,27 +1231,27 @@ const W = class m {
1231
1231
  replaceCurrent(e, t) {
1232
1232
  if (!this.editor || !e.trim() || ((this.currentQuery !== e || this.currentResults.length === 0) && this.performSearch(e, !1, !0), this.currentIndex < 0 || this.currentResults.length === 0))
1233
1233
  return;
1234
- const i = this.currentResults[this.currentIndex];
1235
- if (!i)
1234
+ const s = this.currentResults[this.currentIndex];
1235
+ if (!s)
1236
1236
  return;
1237
- const s = this.computeReplacementRange(i.range.start, t);
1238
- if (this.editor.replace(i.range, t), this.config.replaceAndFindNext) {
1237
+ const i = this.computeReplacementRange(s.range.start, t);
1238
+ if (this.editor.replace(s.range, t), this.config.replaceAndFindNext) {
1239
1239
  this.currentQuery = e;
1240
1240
  const n = this.editor.search(e, this.searchOptions);
1241
1241
  if (this.currentResults = n, n.length === 0) {
1242
1242
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("Replaced current occurrence"), this.restoreReplaceInputFocus();
1243
1243
  return;
1244
1244
  }
1245
- this.currentIndex = this.findNextResultIndexAfter(s.end, n), this.updateHighlights(!0);
1245
+ this.currentIndex = this.findNextResultIndexAfter(i.end, n), this.updateHighlights(!0);
1246
1246
  } else
1247
- this.scrollLogicalRangeIntoView(s, !0), this.performSearch(e, !0, !1);
1247
+ this.scrollLogicalRangeIntoView(i, !0), this.performSearch(e, !0, !1);
1248
1248
  this.currentResults.length > 0 || this.showTransientStatus("Replaced current occurrence"), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1249
1249
  }
1250
1250
  replaceAll(e, t) {
1251
1251
  if (!this.editor || !e.trim())
1252
1252
  return;
1253
- const i = this.editor.replaceAll(e, t, this.searchOptions);
1254
- this.performSearch(e, !1, !1), this.showTransientStatus(`Replaced ${i} occurrence${i === 1 ? "" : "s"}`), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1253
+ const s = this.editor.replaceAll(e, t, this.searchOptions);
1254
+ this.performSearch(e, !1, !1), this.showTransientStatus(`Replaced ${s} occurrence${s === 1 ? "" : "s"}`), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1255
1255
  }
1256
1256
  updateHighlights(e) {
1257
1257
  if (this.clearHighlights(), this.currentResults.length === 0 || this.currentIndex === -1 || !this.editor)
@@ -1265,19 +1265,19 @@ const W = class m {
1265
1265
  navigateToResult(e, t) {
1266
1266
  if (!this.editor)
1267
1267
  return;
1268
- const i = document.activeElement, s = !!i && (i === this.findInput || i === this.replaceInputEl);
1268
+ const s = document.activeElement, i = !!s && (s === this.findInput || s === this.replaceInputEl);
1269
1269
  t ? (this.editor.setSelection(e.range), this.centerCurrentSelectionInView()) : this.scrollResultIntoView(e);
1270
1270
  const n = this.editor.getView();
1271
- t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && s && i && requestAnimationFrame(() => {
1272
- this.focusWithoutScrolling(i);
1271
+ t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && i && s && requestAnimationFrame(() => {
1272
+ this.focusWithoutScrolling(s);
1273
1273
  });
1274
1274
  }
1275
1275
  clearHighlights() {
1276
1276
  var e, t;
1277
1277
  if (this.hasCustomHighlightSupport)
1278
1278
  try {
1279
- const i = CSS;
1280
- (e = i.highlights) == null || e.delete(this.highlightMatchName), (t = i.highlights) == null || t.delete(this.highlightActiveName);
1279
+ const s = CSS;
1280
+ (e = s.highlights) == null || e.delete(this.highlightMatchName), (t = s.highlights) == null || t.delete(this.highlightActiveName);
1281
1281
  } catch {
1282
1282
  }
1283
1283
  }
@@ -1287,35 +1287,35 @@ const W = class m {
1287
1287
  scrollLogicalRangeIntoView(e, t) {
1288
1288
  if (!this.editor)
1289
1289
  return;
1290
- const i = this.editor.getView().getContentElement(), s = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(s), o = this.buildTextNodeIndex(i);
1290
+ const s = this.editor.getView().getContentElement(), i = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(i), o = this.buildTextNodeIndex(s);
1291
1291
  if (o.length === 0)
1292
1292
  return;
1293
- const a = this.toDomRange(e, n, r, o);
1294
- if (!a)
1293
+ const l = this.toDomRange(e, n, r, o);
1294
+ if (!l)
1295
1295
  return;
1296
- const h = a.startContainer.nodeType === Node.TEXT_NODE ? a.startContainer.parentElement : a.startContainer, l = this.resolveScrollContainer(i);
1297
- if (l) {
1298
- const c = a.getClientRects()[0] || a.getBoundingClientRect(), d = l.getBoundingClientRect(), p = l.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, u = 18;
1299
- let g = t ? p : l.scrollTop, f = l.scrollLeft;
1300
- const y = l.scrollLeft + (c.left - d.left), k = y + c.width;
1301
- c.right > d.right - u ? f = k - d.width + u : c.left < d.left + u && (f = Math.max(0, y - u));
1302
- const v = Math.max(0, l.scrollHeight - l.clientHeight), C = Math.max(0, l.scrollWidth - l.clientWidth);
1303
- if (g = Math.min(v, Math.max(0, g)), f = Math.min(C, Math.max(0, f)), v === 0 && C === 0) {
1304
- h == null || h.scrollIntoView({
1296
+ const h = l.startContainer.nodeType === Node.TEXT_NODE ? l.startContainer.parentElement : l.startContainer, a = this.resolveScrollContainer(s);
1297
+ if (a) {
1298
+ const c = l.getClientRects()[0] || l.getBoundingClientRect(), d = a.getBoundingClientRect(), f = a.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, u = 18;
1299
+ let g = t ? f : a.scrollTop, p = a.scrollLeft;
1300
+ const y = a.scrollLeft + (c.left - d.left), k = y + c.width;
1301
+ c.right > d.right - u ? p = k - d.width + u : c.left < d.left + u && (p = Math.max(0, y - u));
1302
+ const v = Math.max(0, a.scrollHeight - a.clientHeight), C = Math.max(0, a.scrollWidth - a.clientWidth);
1303
+ if (g = Math.min(v, Math.max(0, g)), p = Math.min(C, Math.max(0, p)), v === 0 && C === 0) {
1304
+ h?.scrollIntoView({
1305
1305
  block: t ? "center" : "nearest",
1306
1306
  inline: "nearest",
1307
1307
  behavior: "smooth"
1308
1308
  });
1309
1309
  return;
1310
1310
  }
1311
- (g !== l.scrollTop || f !== l.scrollLeft) && l.scrollTo({
1311
+ (g !== a.scrollTop || p !== a.scrollLeft) && a.scrollTo({
1312
1312
  top: g,
1313
- left: f,
1313
+ left: p,
1314
1314
  behavior: "smooth"
1315
1315
  });
1316
1316
  return;
1317
1317
  }
1318
- h == null || h.scrollIntoView({
1318
+ h?.scrollIntoView({
1319
1319
  block: t ? "center" : "nearest",
1320
1320
  inline: "nearest",
1321
1321
  behavior: "smooth"
@@ -1338,62 +1338,62 @@ const W = class m {
1338
1338
  const e = this.editor.getView().getContentElement(), t = this.resolveScrollContainer(e);
1339
1339
  if (!t)
1340
1340
  return;
1341
- const i = window.getSelection();
1342
- if (!i || i.rangeCount === 0)
1341
+ const s = window.getSelection();
1342
+ if (!s || s.rangeCount === 0)
1343
1343
  return;
1344
- const s = i.getRangeAt(0).cloneRange(), n = s.getClientRects()[0] || s.getBoundingClientRect();
1344
+ const i = s.getRangeAt(0).cloneRange(), n = i.getClientRects()[0] || i.getBoundingClientRect();
1345
1345
  if (!n)
1346
1346
  return;
1347
- const r = t.getBoundingClientRect(), o = t.scrollTop + (n.top - r.top) - r.height / 2 + n.height / 2, a = Math.max(0, t.scrollHeight - t.clientHeight), h = Math.min(a, Math.max(0, o));
1347
+ const r = t.getBoundingClientRect(), o = t.scrollTop + (n.top - r.top) - r.height / 2 + n.height / 2, l = Math.max(0, t.scrollHeight - t.clientHeight), h = Math.min(l, Math.max(0, o));
1348
1348
  h !== t.scrollTop && t.scrollTo({
1349
1349
  top: h,
1350
1350
  behavior: "smooth"
1351
1351
  });
1352
1352
  }
1353
1353
  computeReplacementRange(e, t) {
1354
- const i = t.replace(/\r\n?/g, `
1355
- `), s = i.split(`
1354
+ const s = t.replace(/\r\n?/g, `
1355
+ `), i = s.split(`
1356
1356
  `);
1357
1357
  let n;
1358
- return s.length <= 1 ? (n = {
1358
+ return i.length <= 1 ? (n = {
1359
1359
  start: e,
1360
1360
  end: {
1361
1361
  line: e.line,
1362
- column: e.column + i.length
1362
+ column: e.column + s.length
1363
1363
  }
1364
1364
  }, this.clampRangeToDocument(n)) : (n = {
1365
1365
  start: e,
1366
1366
  end: {
1367
- line: e.line + s.length - 1,
1368
- column: s[s.length - 1].length
1367
+ line: e.line + i.length - 1,
1368
+ column: i[i.length - 1].length
1369
1369
  }
1370
1370
  }, this.clampRangeToDocument(n));
1371
1371
  }
1372
1372
  findNextResultIndexAfter(e, t) {
1373
- for (let i = 0; i < t.length; i++)
1374
- if (this.comparePositions(t[i].range.start, e) >= 0)
1375
- return i;
1373
+ for (let s = 0; s < t.length; s++)
1374
+ if (this.comparePositions(t[s].range.start, e) >= 0)
1375
+ return s;
1376
1376
  return 0;
1377
1377
  }
1378
1378
  comparePositions(e, t) {
1379
1379
  return e.line !== t.line ? e.line - t.line : e.column - t.column;
1380
1380
  }
1381
1381
  clampRangeToDocument(e) {
1382
- var t, i;
1383
- const s = this.editor;
1384
- if (!s)
1382
+ var t, s;
1383
+ const i = this.editor;
1384
+ if (!i)
1385
1385
  return e;
1386
- const n = s.getValue().split(`
1387
- `), r = Math.max(0, n.length - 1), o = Math.max(0, Math.min(e.start.line, r)), a = Math.max(0, Math.min(e.end.line, r)), h = Math.max(
1386
+ const n = i.getValue().split(`
1387
+ `), r = Math.max(0, n.length - 1), o = Math.max(0, Math.min(e.start.line, r)), l = Math.max(0, Math.min(e.end.line, r)), h = Math.max(
1388
1388
  0,
1389
1389
  Math.min(e.start.column, ((t = n[o]) == null ? void 0 : t.length) || 0)
1390
- ), l = Math.max(
1390
+ ), a = Math.max(
1391
1391
  0,
1392
- Math.min(e.end.column, ((i = n[a]) == null ? void 0 : i.length) || 0)
1392
+ Math.min(e.end.column, ((s = n[l]) == null ? void 0 : s.length) || 0)
1393
1393
  );
1394
1394
  return {
1395
1395
  start: { line: o, column: h },
1396
- end: { line: a, column: l }
1396
+ end: { line: l, column: a }
1397
1397
  };
1398
1398
  }
1399
1399
  focusWithoutScrolling(e) {
@@ -1403,35 +1403,35 @@ const W = class m {
1403
1403
  });
1404
1404
  } catch {
1405
1405
  const t = [];
1406
- let i = e.parentElement;
1407
- for (; i; )
1408
- this.canScroll(i) && t.push({
1409
- el: i,
1410
- top: i.scrollTop,
1411
- left: i.scrollLeft
1412
- }), i = i.parentElement;
1413
- const s = window.scrollX, n = window.scrollY;
1406
+ let s = e.parentElement;
1407
+ for (; s; )
1408
+ this.canScroll(s) && t.push({
1409
+ el: s,
1410
+ top: s.scrollTop,
1411
+ left: s.scrollLeft
1412
+ }), s = s.parentElement;
1413
+ const i = window.scrollX, n = window.scrollY;
1414
1414
  e.focus();
1415
1415
  for (let r = 0; r < t.length; r++) {
1416
1416
  const o = t[r];
1417
1417
  o.el.scrollTop = o.top, o.el.scrollLeft = o.left;
1418
1418
  }
1419
- window.scrollTo(s, n);
1419
+ window.scrollTo(i, n);
1420
1420
  }
1421
1421
  }
1422
1422
  findScrollContainer(e) {
1423
1423
  let t = e;
1424
1424
  for (; t; ) {
1425
- const i = window.getComputedStyle(t).overflowY;
1426
- if ((i === "auto" || i === "scroll") && t.scrollHeight > t.clientHeight)
1425
+ const s = window.getComputedStyle(t).overflowY;
1426
+ if ((s === "auto" || s === "scroll") && t.scrollHeight > t.clientHeight)
1427
1427
  return t;
1428
1428
  t = t.parentElement;
1429
1429
  }
1430
1430
  return null;
1431
1431
  }
1432
1432
  resolveScrollContainer(e) {
1433
- var t, i;
1434
- const s = (t = this.editor) == null ? void 0 : t.getView(), n = ((i = s == null ? void 0 : s.getScrollElement) == null ? void 0 : i.call(s)) || null;
1433
+ var t, s;
1434
+ const i = (t = this.editor) == null ? void 0 : t.getView(), n = ((s = i?.getScrollElement) == null ? void 0 : s.call(i)) || null;
1435
1435
  return n && this.canScroll(n) ? n : this.findScrollContainer(e);
1436
1436
  }
1437
1437
  canScroll(e) {
@@ -1446,127 +1446,127 @@ const W = class m {
1446
1446
  applyCustomHighlights() {
1447
1447
  if (!this.editor || !this.hasCustomHighlightSupport || this.currentResults.length === 0)
1448
1448
  return;
1449
- const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: i, lines: s } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
1449
+ const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: s, lines: i } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
1450
1450
  if (n.length === 0)
1451
1451
  return;
1452
1452
  const r = this.buildVisibleDocumentText(n), o = [];
1453
- let a = null;
1453
+ let l = null;
1454
1454
  const h = Math.min(this.currentResults.length, this.maxCustomHighlightRanges);
1455
- for (let l = 0; l < h; l++) {
1456
- const c = this.currentResults[l], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, p = this.toDomRange(
1455
+ for (let a = 0; a < h; a++) {
1456
+ const c = this.currentResults[a], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
1457
1457
  c.range,
1458
- i,
1459
1458
  s,
1459
+ i,
1460
1460
  n,
1461
1461
  r,
1462
1462
  d
1463
1463
  );
1464
- p && (o.push(p), l === this.currentIndex && (a = p));
1464
+ f && (o.push(f), a === this.currentIndex && (l = f));
1465
1465
  }
1466
1466
  if (o.length !== 0)
1467
1467
  try {
1468
- const l = CSS, c = window.Highlight;
1469
- if (!l.highlights || !c)
1468
+ const a = CSS, c = window.Highlight;
1469
+ if (!a.highlights || !c)
1470
1470
  return;
1471
- l.highlights.set(this.highlightMatchName, new c(...o)), a && l.highlights.set(this.highlightActiveName, new c(a));
1471
+ a.highlights.set(this.highlightMatchName, new c(...o)), l && a.highlights.set(this.highlightActiveName, new c(l));
1472
1472
  } catch {
1473
1473
  }
1474
1474
  }
1475
1475
  buildLineStarts(e) {
1476
1476
  const t = e.split(`
1477
- `), i = new Array(t.length);
1478
- let s = 0;
1477
+ `), s = new Array(t.length);
1478
+ let i = 0;
1479
1479
  for (let n = 0; n < t.length; n++)
1480
- i[n] = s, s += t[n].length + 1;
1481
- return { lineStarts: i, lines: t };
1480
+ s[n] = i, i += t[n].length + 1;
1481
+ return { lineStarts: s, lines: t };
1482
1482
  }
1483
- positionToOffset(e, t, i) {
1484
- var s;
1485
- const n = Math.max(0, Math.min(e.line, i.length - 1)), r = Math.max(0, Math.min(e.column, ((s = i[n]) == null ? void 0 : s.length) || 0));
1483
+ positionToOffset(e, t, s) {
1484
+ var i;
1485
+ const n = Math.max(0, Math.min(e.line, s.length - 1)), r = Math.max(0, Math.min(e.column, ((i = s[n]) == null ? void 0 : i.length) || 0));
1486
1486
  return t[n] + r;
1487
1487
  }
1488
1488
  buildTextNodeIndex(e) {
1489
- const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), i = [];
1490
- let s = 0, n;
1489
+ const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), s = [];
1490
+ let i = 0, n;
1491
1491
  for (; n = t.nextNode(); ) {
1492
1492
  const r = n, o = r.parentElement;
1493
1493
  if (o != null && o.hasAttribute(this.trailingMarkerAttr))
1494
1494
  continue;
1495
- const a = r.textContent || "", h = this.buildVisibleToDomMap(a), l = Math.max(0, h.length - 1);
1496
- l === 0 && a.length === 0 || (i.push({
1495
+ const l = r.textContent || "", h = this.buildVisibleToDomMap(l), a = Math.max(0, h.length - 1);
1496
+ a === 0 && l.length === 0 || (s.push({
1497
1497
  node: r,
1498
- start: s,
1499
- end: s + l,
1498
+ start: i,
1499
+ end: i + a,
1500
1500
  visibleToDom: h
1501
- }), s += l);
1501
+ }), i += a);
1502
1502
  }
1503
- return i;
1503
+ return s;
1504
1504
  }
1505
1505
  resolveDomPoint(e, t) {
1506
- var i, s;
1506
+ var s, i;
1507
1507
  const n = Math.max(0, e);
1508
1508
  for (let o = 0; o < t.length; o++) {
1509
- const a = t[o];
1510
- if (n <= a.end) {
1511
- const h = Math.max(0, n - a.start), l = a.visibleToDom[h] ?? ((i = a.node.textContent) == null ? void 0 : i.length) ?? 0;
1509
+ const l = t[o];
1510
+ if (n <= l.end) {
1511
+ const h = Math.max(0, n - l.start), a = l.visibleToDom[h] ?? ((s = l.node.textContent) == null ? void 0 : s.length) ?? 0;
1512
1512
  return {
1513
- node: a.node,
1514
- offset: l
1513
+ node: l.node,
1514
+ offset: a
1515
1515
  };
1516
1516
  }
1517
1517
  }
1518
1518
  const r = t[t.length - 1];
1519
1519
  return r ? {
1520
1520
  node: r.node,
1521
- offset: r.visibleToDom[r.visibleToDom.length - 1] ?? ((s = r.node.textContent) == null ? void 0 : s.length) ?? 0
1521
+ offset: r.visibleToDom[r.visibleToDom.length - 1] ?? ((i = r.node.textContent) == null ? void 0 : i.length) ?? 0
1522
1522
  } : null;
1523
1523
  }
1524
- toDomRange(e, t, i, s, n, r) {
1525
- const o = this.positionToOffset(e.start, t, i), a = this.positionToOffset(e.end, t, i);
1526
- let h = Math.min(o, a), l = Math.max(o, a);
1524
+ toDomRange(e, t, s, i, n, r) {
1525
+ const o = this.positionToOffset(e.start, t, s), l = this.positionToOffset(e.end, t, s);
1526
+ let h = Math.min(o, l), a = Math.max(o, l);
1527
1527
  if (n && r) {
1528
- const u = r, g = n.slice(h, l);
1528
+ const u = r, g = n.slice(h, a);
1529
1529
  if (g.length === u.length && g.toLowerCase() !== u.toLowerCase()) {
1530
- const f = this.findNearestMatchOffset(
1530
+ const p = this.findNearestMatchOffset(
1531
1531
  n,
1532
1532
  u,
1533
1533
  h
1534
1534
  );
1535
- f !== -1 && (h = f, l = f + u.length);
1535
+ p !== -1 && (h = p, a = p + u.length);
1536
1536
  }
1537
1537
  }
1538
- const c = this.resolveDomPoint(h, s), d = this.resolveDomPoint(l, s);
1538
+ const c = this.resolveDomPoint(h, i), d = this.resolveDomPoint(a, i);
1539
1539
  if (!c || !d)
1540
1540
  return null;
1541
- const p = document.createRange();
1541
+ const f = document.createRange();
1542
1542
  try {
1543
- return p.setStart(c.node, c.offset), p.setEnd(d.node, d.offset), p;
1543
+ return f.setStart(c.node, c.offset), f.setEnd(d.node, d.offset), f;
1544
1544
  } catch {
1545
1545
  return null;
1546
1546
  }
1547
1547
  }
1548
1548
  buildVisibleDocumentText(e) {
1549
1549
  let t = "";
1550
- for (let i = 0; i < e.length; i++) {
1551
- const s = e[i].node.textContent || "";
1552
- for (let n = 0; n < s.length; n++) {
1553
- const r = s[n];
1550
+ for (let s = 0; s < e.length; s++) {
1551
+ const i = e[s].node.textContent || "";
1552
+ for (let n = 0; n < i.length; n++) {
1553
+ const r = i[n];
1554
1554
  this.virtualMarkerRegex.test(r) || (t += r);
1555
1555
  }
1556
1556
  }
1557
1557
  return t;
1558
1558
  }
1559
- findNearestMatchOffset(e, t, i) {
1560
- const s = t.toLowerCase();
1561
- let n = e.toLowerCase().indexOf(s);
1559
+ findNearestMatchOffset(e, t, s) {
1560
+ const i = t.toLowerCase();
1561
+ let n = e.toLowerCase().indexOf(i);
1562
1562
  if (n === -1)
1563
1563
  return -1;
1564
- let r = n, o = Math.abs(n - i);
1564
+ let r = n, o = Math.abs(n - s);
1565
1565
  for (; n !== -1; ) {
1566
- const a = Math.abs(n - i);
1567
- if (a < o && (o = a, r = n), a === 0)
1566
+ const l = Math.abs(n - s);
1567
+ if (l < o && (o = l, r = n), l === 0)
1568
1568
  return n;
1569
- n = e.toLowerCase().indexOf(s, n + 1);
1569
+ n = e.toLowerCase().indexOf(i, n + 1);
1570
1570
  }
1571
1571
  return r;
1572
1572
  }
@@ -1627,10 +1627,10 @@ const W = class m {
1627
1627
  }
1628
1628
  buildVisibleToDomMap(e) {
1629
1629
  const t = [0];
1630
- let i = 0;
1631
- for (let s = 0; s < e.length; s++) {
1632
- const n = e[s];
1633
- this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
1630
+ let s = 0;
1631
+ for (let i = 0; i < e.length; i++) {
1632
+ const n = e[i];
1633
+ this.virtualMarkerRegex.test(n) || (s += 1, t[s] = i + 1);
1634
1634
  }
1635
1635
  return t;
1636
1636
  }
@@ -1678,8 +1678,8 @@ W.css = {
1678
1678
  mode: "search-mode",
1679
1679
  modeLayout: "lce-search-mode"
1680
1680
  };
1681
- let ie = W;
1682
- class se {
1681
+ let se = W;
1682
+ class ie {
1683
1683
  constructor() {
1684
1684
  this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
1685
1685
  "(": ")",
@@ -1705,60 +1705,60 @@ class se {
1705
1705
  return;
1706
1706
  const e = this.editor.getCursor(), t = this.editor.getValue();
1707
1707
  this.clearBracketHighlighting();
1708
- const i = this.getBracketAtPosition(t, e.position);
1709
- if (!i)
1708
+ const s = this.getBracketAtPosition(t, e.position);
1709
+ if (!s)
1710
1710
  return;
1711
- const s = this.findMatchingBracket(t, i);
1712
- s && (this.currentMatch = s, this.highlightBrackets(s));
1711
+ const i = this.findMatchingBracket(t, s);
1712
+ i && (this.currentMatch = i, this.highlightBrackets(i));
1713
1713
  }
1714
1714
  getBracketAtPosition(e, t) {
1715
- const i = e.split(`
1715
+ const s = e.split(`
1716
1716
  `);
1717
- if (t.line >= i.length)
1717
+ if (t.line >= s.length)
1718
1718
  return null;
1719
- const s = i[t.line];
1720
- if (t.column >= s.length)
1719
+ const i = s[t.line];
1720
+ if (t.column >= i.length)
1721
1721
  return null;
1722
- const n = s[t.column];
1722
+ const n = i[t.column];
1723
1723
  return this.bracketPairs[n] || this.reverseBracketPairs[n] ? { char: n, position: t } : null;
1724
1724
  }
1725
1725
  findMatchingBracket(e, t) {
1726
- const i = e.split(`
1727
- `), s = t.position.line, n = t.position.column, r = t.char;
1728
- return this.bracketPairs[r] ? this.findClosingBracket(e, i, s, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(e, i, s, n, r) : null;
1726
+ const s = e.split(`
1727
+ `), i = t.position.line, n = t.position.column, r = t.char;
1728
+ return this.bracketPairs[r] ? this.findClosingBracket(e, s, i, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(e, s, i, n, r) : null;
1729
1729
  }
1730
- findClosingBracket(e, t, i, s, n) {
1730
+ findClosingBracket(e, t, s, i, n) {
1731
1731
  const r = this.bracketPairs[n];
1732
1732
  let o = 0;
1733
- for (let a = i; a < t.length; a++) {
1734
- const h = t[a], l = a === i ? s : 0;
1735
- for (let c = l; c < h.length; c++) {
1733
+ for (let l = s; l < t.length; l++) {
1734
+ const h = t[l], a = l === s ? i : 0;
1735
+ for (let c = a; c < h.length; c++) {
1736
1736
  const d = h[c];
1737
1737
  if (d === n)
1738
1738
  o++;
1739
1739
  else if (d === r && (o--, o === 0))
1740
1740
  return {
1741
- open: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1742
- close: { start: { line: a, column: c }, end: { line: a, column: c + 1 } },
1741
+ open: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1742
+ close: { start: { line: l, column: c }, end: { line: l, column: c + 1 } },
1743
1743
  type: n
1744
1744
  };
1745
1745
  }
1746
1746
  }
1747
1747
  return null;
1748
1748
  }
1749
- findOpeningBracket(e, t, i, s, n) {
1749
+ findOpeningBracket(e, t, s, i, n) {
1750
1750
  const r = this.reverseBracketPairs[n];
1751
1751
  let o = 0;
1752
- for (let a = i; a >= 0; a--) {
1753
- const h = t[a], l = a === i ? s : h.length - 1;
1754
- for (let c = l; c >= 0; c--) {
1752
+ for (let l = s; l >= 0; l--) {
1753
+ const h = t[l], a = l === s ? i : h.length - 1;
1754
+ for (let c = a; c >= 0; c--) {
1755
1755
  const d = h[c];
1756
1756
  if (d === n)
1757
1757
  o++;
1758
1758
  else if (d === r && (o--, o === 0))
1759
1759
  return {
1760
- open: { start: { line: a, column: c }, end: { line: a, column: c + 1 } },
1761
- close: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1760
+ open: { start: { line: l, column: c }, end: { line: l, column: c + 1 } },
1761
+ close: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1762
1762
  type: r
1763
1763
  };
1764
1764
  }
@@ -1821,17 +1821,17 @@ class ne {
1821
1821
  return;
1822
1822
  this.lastSnapshot = e, this.foldingUI.innerHTML = "", this.foldIndicators = [];
1823
1823
  const t = e.split(`
1824
- `), i = this.findFoldableLines(t), s = document.createDocumentFragment();
1825
- i.forEach((n) => {
1824
+ `), s = this.findFoldableLines(t), i = document.createDocumentFragment();
1825
+ s.forEach((n) => {
1826
1826
  const r = this.createFoldIndicator(n);
1827
- s.appendChild(r), this.foldIndicators.push(r);
1828
- }), this.foldingUI.appendChild(s);
1827
+ i.appendChild(r), this.foldIndicators.push(r);
1828
+ }), this.foldingUI.appendChild(i);
1829
1829
  }
1830
1830
  findFoldableLines(e) {
1831
1831
  const t = [];
1832
- for (let i = 0; i < e.length; i++) {
1833
- const s = e[i].trim();
1834
- (s.startsWith("{") || s.startsWith("function") || s.startsWith("class") || s.startsWith("if") || s.includes("=>") || s.startsWith("for") || s.startsWith("while") || s.startsWith("try")) && t.push(i);
1832
+ for (let s = 0; s < e.length; s++) {
1833
+ const i = e[s].trim();
1834
+ (i.startsWith("{") || i.startsWith("function") || i.startsWith("class") || i.startsWith("if") || i.includes("=>") || i.startsWith("for") || i.startsWith("while") || i.startsWith("try")) && t.push(s);
1835
1835
  }
1836
1836
  return t;
1837
1837
  }
@@ -1871,7 +1871,7 @@ class re {
1871
1871
  this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
1872
1872
  }
1873
1873
  setup(e) {
1874
- this.editor = e, this.registerMode("html", { name: "html", highlight: (t, i) => this._highlightHTML(t, i) }), this.registerMode("javascript", { name: "javascript", highlight: (t, i) => this._highlightJS(t, i) }), this.registerMode("typescript", { name: "typescript", highlight: (t, i) => this._highlightJS(t, i) }), this.registerMode("php", { name: "php", highlight: (t, i) => this._highlightPHP(t, i) });
1874
+ this.editor = e, this.registerMode("html", { name: "html", highlight: (t, s) => this._highlightHTML(t, s) }), this.registerMode("javascript", { name: "javascript", highlight: (t, s) => this._highlightJS(t, s) }), this.registerMode("typescript", { name: "typescript", highlight: (t, s) => this._highlightJS(t, s) }), this.registerMode("php", { name: "php", highlight: (t, s) => this._highlightPHP(t, s) });
1875
1875
  }
1876
1876
  // Extension provides methods that can be called by the editor
1877
1877
  setTheme(e) {
@@ -1931,8 +1931,8 @@ class re {
1931
1931
  }
1932
1932
  // Public API: highlight a source string using the chosen mode (or detect html)
1933
1933
  highlight(e, t) {
1934
- const i = this.getSyntaxColors(), s = (t || this.currentLanguage || "html").toLowerCase();
1935
- return (this.modes.get(s) || this.modes.get("html")).highlight(e, i);
1934
+ const s = this.getSyntaxColors(), i = (t || this.currentLanguage || "html").toLowerCase();
1935
+ return (this.modes.get(i) || this.modes.get("html")).highlight(e, s);
1936
1936
  }
1937
1937
  // Backwards-compatible method
1938
1938
  highlightHTML(e) {
@@ -1945,129 +1945,129 @@ class re {
1945
1945
  // Robustly unescape common HTML entities, repeating a few times to handle nested encoding like &amp;amp;...
1946
1946
  unescapeEntitiesRepeated(e) {
1947
1947
  let t = e || "";
1948
- for (let i = 0; i < 5; i++) {
1949
- const s = t;
1950
- if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === s)
1948
+ for (let s = 0; s < 5; s++) {
1949
+ const i = t;
1950
+ if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === i)
1951
1951
  break;
1952
1952
  }
1953
1953
  return t;
1954
1954
  }
1955
1955
  _highlightHTML(e, t) {
1956
- const i = t, s = (h) => this.escapeHTML(h);
1957
- let n = s(e);
1956
+ const s = t, i = (h) => this.escapeHTML(h);
1957
+ let n = i(e);
1958
1958
  const r = (h) => {
1959
- let l = h.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1960
- return l = l.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${i.comment};">$1</span>`), l = l.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (c, d, p, u, g) => {
1961
- const f = String(u).trim(), y = s(f);
1962
- return `<span style="color: ${i.styleProp};">${d}</span>${p}<span style="color: ${i.styleVal};">${y}</span>${g}`;
1963
- }), l;
1959
+ let a = h.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1960
+ return a = a.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${s.comment};">$1</span>`), a = a.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (c, d, f, u, g) => {
1961
+ const p = String(u).trim(), y = i(p);
1962
+ return `<span style="color: ${s.styleProp};">${d}</span>${f}<span style="color: ${s.styleVal};">${y}</span>${g}`;
1963
+ }), a;
1964
1964
  }, o = [];
1965
1965
  try {
1966
- e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (h, l, c) => (o.push({ attrs: String(l || ""), inner: String(c || "") }), h));
1966
+ e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (h, a, c) => (o.push({ attrs: String(a || ""), inner: String(c || "") }), h));
1967
1967
  } catch {
1968
1968
  }
1969
- let a = 0;
1970
- return n = n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (h, l, c, d, p) => {
1969
+ let l = 0;
1970
+ return n = n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (h, a, c, d, f) => {
1971
1971
  var u, g;
1972
- const f = ((u = o[a++]) == null ? void 0 : u.inner) ?? this.unescapeEntitiesRepeated(d || "");
1973
- (((g = o[a - 1]) == null ? void 0 : g.attrs) || c || "").toLowerCase();
1974
- const y = this._highlightJS(f, i);
1975
- return `${l}${y}${p}`;
1976
- }), n = n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (h, l, c, d) => {
1977
- const p = r(c);
1978
- return `${l}${p}${d}`;
1979
- }), n = n.replace(/(&lt;!--[\s\S]*?--&gt;)/g, `<span style="color: ${i.comment};">$1</span>`), n = n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i, `<span style="color: ${i.doctype};">$1</span>`), n = n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g, (h, l, c, d, p) => {
1980
- const u = `<span style="color: ${i.tag};">${c}</span>`;
1972
+ const p = ((u = o[l++]) == null ? void 0 : u.inner) ?? this.unescapeEntitiesRepeated(d || "");
1973
+ (((g = o[l - 1]) == null ? void 0 : g.attrs) || c || "").toLowerCase();
1974
+ const y = this._highlightJS(p, s);
1975
+ return `${a}${y}${f}`;
1976
+ }), n = n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (h, a, c, d) => {
1977
+ const f = r(c);
1978
+ return `${a}${f}${d}`;
1979
+ }), n = n.replace(/(&lt;!--[\s\S]*?--&gt;)/g, `<span style="color: ${s.comment};">$1</span>`), n = n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i, `<span style="color: ${s.doctype};">$1</span>`), n = n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g, (h, a, c, d, f) => {
1980
+ const u = `<span style="color: ${s.tag};">${c}</span>`;
1981
1981
  let g = d;
1982
1982
  return g = g.replace(
1983
1983
  /([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,
1984
- (f, y, k, v) => {
1985
- const C = String(y).toLowerCase(), E = `<span style="color: ${i.attrName};">${y}</span>`;
1984
+ (p, y, k, v) => {
1985
+ const C = String(y).toLowerCase(), E = `<span style="color: ${s.attrName};">${y}</span>`;
1986
1986
  let S = v, b = "";
1987
1987
  v.startsWith("&quot;") && v.endsWith("&quot;") ? (S = v.slice(6, -6), b = "&quot;") : v.startsWith("&#39;") && v.endsWith("&#39;") && (S = v.slice(5, -5), b = "&#39;");
1988
1988
  let T = v;
1989
1989
  if (C === "style") {
1990
- const I = S.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (B, N, $, O) => `<span style="color: ${i.styleProp};">${N}</span>:<span style="color: ${i.styleVal};">${$.trim()}</span>${O}`);
1991
- b ? T = `${b}${I}${b}` : T = I, T = `<span style="color: ${i.attrValue};">${T}</span>`;
1990
+ const I = S.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (B, N, $, O) => `<span style="color: ${s.styleProp};">${N}</span>:<span style="color: ${s.styleVal};">${$.trim()}</span>${O}`);
1991
+ b ? T = `${b}${I}${b}` : T = I, T = `<span style="color: ${s.attrValue};">${T}</span>`;
1992
1992
  } else
1993
- b && (T = `${b}${S}${b}`), T = `<span style="color: ${i.attrValue};">${T}</span>`;
1993
+ b && (T = `${b}${S}${b}`), T = `<span style="color: ${s.attrValue};">${T}</span>`;
1994
1994
  return `${E}${k}${T}`;
1995
1995
  }
1996
- ), `${l}${u}${g}${p}`;
1996
+ ), `${a}${u}${g}${f}`;
1997
1997
  }), n;
1998
1998
  }
1999
1999
  _highlightJS(e, t) {
2000
- const i = this.unescapeEntitiesRepeated(e);
2001
- this.escapeHTML(i);
2002
- const s = [], n = (d) => {
2003
- let p = "", u = d;
2000
+ const s = this.unescapeEntitiesRepeated(e);
2001
+ this.escapeHTML(s);
2002
+ const i = [], n = (d) => {
2003
+ let f = "", u = d;
2004
2004
  do
2005
- p = String.fromCharCode(97 + u % 26) + p, u = Math.floor(u / 26) - 1;
2005
+ f = String.fromCharCode(97 + u % 26) + f, u = Math.floor(u / 26) - 1;
2006
2006
  while (u >= 0);
2007
- return p || "a";
2007
+ return f || "a";
2008
2008
  }, r = (d) => `\0${n(d)}\0`, o = (d) => {
2009
- const p = s.length;
2010
- return s.push(d), r(p);
2009
+ const f = i.length;
2010
+ return i.push(d), r(f);
2011
2011
  };
2012
- let a;
2012
+ let l;
2013
2013
  const h = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
2014
- let l = 0, c = "";
2015
- for (; a = h.exec(i); ) {
2016
- const d = a.index;
2017
- l < d && (c += this.escapeHTML(i.slice(l, d)));
2018
- const p = a[0];
2019
- /^\/\*/.test(p) || /^\/\//.test(p) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(p)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(p)}</span>`), l = h.lastIndex;
2014
+ let a = 0, c = "";
2015
+ for (; l = h.exec(s); ) {
2016
+ const d = l.index;
2017
+ a < d && (c += this.escapeHTML(s.slice(a, d)));
2018
+ const f = l[0];
2019
+ /^\/\*/.test(f) || /^\/\//.test(f) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(f)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(f)}</span>`), a = h.lastIndex;
2020
2020
  }
2021
- return l < i.length && (c += this.escapeHTML(i.slice(l))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, p, u) => {
2022
- const g = c[u - 1] || "", f = c[u + d.length] || "";
2023
- return g === "&" || g === "#" || f === ";" || f === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
2024
- }), c = c.replace(/\b(const|let|var|function|class|if|else|return|for|while|switch|case|break|import|from|export|extends|new|try|catch|finally|throw|await|async|interface|type)\b/g, `<span style="color: ${t.keyword};">$1</span>`), c.replace(/\u0000([a-z]+)\u0000/g, (d, p) => {
2021
+ return a < s.length && (c += this.escapeHTML(s.slice(a))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, f, u) => {
2022
+ const g = c[u - 1] || "", p = c[u + d.length] || "";
2023
+ return g === "&" || g === "#" || p === ";" || p === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
2024
+ }), c = c.replace(/\b(const|let|var|function|class|if|else|return|for|while|switch|case|break|import|from|export|extends|new|try|catch|finally|throw|await|async|interface|type)\b/g, `<span style="color: ${t.keyword};">$1</span>`), c.replace(/\u0000([a-z]+)\u0000/g, (d, f) => {
2025
2025
  let u = 0;
2026
- for (let g = 0; g < p.length; g++)
2027
- u = u * 26 + (p.charCodeAt(g) - 97 + 1);
2028
- return u = u - 1, s[u] || "";
2026
+ for (let g = 0; g < f.length; g++)
2027
+ u = u * 26 + (f.charCodeAt(g) - 97 + 1);
2028
+ return u = u - 1, i[u] || "";
2029
2029
  });
2030
2030
  }
2031
2031
  _highlightPHP(e, t) {
2032
- const i = this.unescapeEntitiesRepeated(e);
2033
- let s = this.escapeHTML(i);
2032
+ const s = this.unescapeEntitiesRepeated(e);
2033
+ let i = this.escapeHTML(s);
2034
2034
  const n = [], r = (u) => {
2035
- let g = "", f = u;
2035
+ let g = "", p = u;
2036
2036
  do
2037
- g = String.fromCharCode(97 + f % 26) + g, f = Math.floor(f / 26) - 1;
2038
- while (f >= 0);
2037
+ g = String.fromCharCode(97 + p % 26) + g, p = Math.floor(p / 26) - 1;
2038
+ while (p >= 0);
2039
2039
  return g || "a";
2040
2040
  }, o = (u) => {
2041
2041
  const g = n.length;
2042
2042
  return n.push(u), `\0${r(g)}\0`;
2043
- }, a = (u, g) => {
2044
- const f = s.indexOf(u);
2045
- return f === -1 ? !1 : (s = s.slice(0, f) + g + s.slice(f + u.length), !0);
2043
+ }, l = (u, g) => {
2044
+ const p = i.indexOf(u);
2045
+ return p === -1 ? !1 : (i = i.slice(0, p) + g + i.slice(p + u.length), !0);
2046
2046
  };
2047
2047
  let h;
2048
- const l = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, p = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
2049
- for (; h = l.exec(i); ) {
2048
+ const a = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, f = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
2049
+ for (; h = a.exec(s); ) {
2050
2050
  const u = h[0];
2051
- a(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2051
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2052
2052
  }
2053
- for (; h = c.exec(i); ) {
2053
+ for (; h = c.exec(s); ) {
2054
2054
  const u = h[0];
2055
- a(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2055
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2056
2056
  }
2057
- for (; h = d.exec(i); ) {
2057
+ for (; h = d.exec(s); ) {
2058
2058
  const u = h[0];
2059
- a(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2059
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2060
2060
  }
2061
- for (; h = p.exec(i); ) {
2061
+ for (; h = f.exec(s); ) {
2062
2062
  const u = h[0];
2063
- a(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
2063
+ l(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
2064
2064
  }
2065
- return s = s.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), s = s.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g, `<span style="color: ${t.keyword};">$1</span>`), s = s.replace(/\u0000([a-z]+)\u0000/g, (u, g) => {
2066
- let f = 0;
2065
+ return i = i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), i = i.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g, `<span style="color: ${t.keyword};">$1</span>`), i = i.replace(/\u0000([a-z]+)\u0000/g, (u, g) => {
2066
+ let p = 0;
2067
2067
  for (let y = 0; y < g.length; y++)
2068
- f = f * 26 + (g.charCodeAt(y) - 97 + 1);
2069
- return f = f - 1, n[f] || "";
2070
- }), s;
2068
+ p = p * 26 + (g.charCodeAt(y) - 97 + 1);
2069
+ return p = p - 1, n[p] || "";
2070
+ }), i;
2071
2071
  }
2072
2072
  // Method to check if content contains syntax that should be highlighted
2073
2073
  shouldHighlight(e) {
@@ -2079,7 +2079,7 @@ class re {
2079
2079
  }
2080
2080
  function oe(w, e) {
2081
2081
  const t = { ...e };
2082
- return t.extensions || (t.extensions = []), t.extensions.some((i) => i.name === "keymap") || t.extensions.unshift(new J(t.keymap)), t.extensions.some((i) => i.name === "transaction") || t.extensions.unshift(new Y()), new X(w, t);
2082
+ return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new J(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new Y()), new X(w, t);
2083
2083
  }
2084
2084
  const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Editor Dialog Styles */
2085
2085
  .rte-source-editor-overlay {
@@ -2478,38 +2478,35 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2478
2478
  */
2479
2479
  toggleSourceView: () => {
2480
2480
  const e = (() => {
2481
- var o, a, h;
2482
2481
  const n = window.getSelection();
2483
2482
  if (n && n.anchorNode) {
2484
- let l = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
2485
- for (; l; ) {
2486
- if ((o = l.classList) != null && o.contains("rte-content"))
2487
- return l;
2488
- l = l.parentElement;
2483
+ let o = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
2484
+ for (; o; ) {
2485
+ if (o.classList?.contains("rte-content"))
2486
+ return o;
2487
+ o = o.parentElement;
2489
2488
  }
2490
2489
  }
2491
2490
  if (document.activeElement) {
2492
- let l = document.activeElement;
2493
- if ((a = l.classList) != null && a.contains("rte-content"))
2494
- return l;
2495
- for (; l && l !== document.body; ) {
2496
- if ((h = l.classList) != null && h.contains("rte-content"))
2497
- return l;
2498
- const c = l.querySelector(
2491
+ let o = document.activeElement;
2492
+ if (o.classList?.contains("rte-content"))
2493
+ return o;
2494
+ for (; o && o !== document.body; ) {
2495
+ if (o.classList?.contains("rte-content"))
2496
+ return o;
2497
+ const l = o.querySelector(
2499
2498
  ".rte-content"
2500
2499
  );
2501
- if (c)
2502
- return c;
2503
- l = l.parentElement;
2500
+ if (l) return l;
2501
+ o = o.parentElement;
2504
2502
  }
2505
2503
  }
2506
2504
  const r = document.querySelector("[data-editora-editor]");
2507
2505
  if (r) {
2508
- const l = r.querySelector(
2506
+ const o = r.querySelector(
2509
2507
  ".rte-content"
2510
2508
  );
2511
- if (l)
2512
- return l;
2509
+ if (o) return o;
2513
2510
  }
2514
2511
  return document.querySelector(".rte-content");
2515
2512
  })();
@@ -2517,25 +2514,25 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2517
2514
  return console.error("[CodePlugin] Editor content area not found"), alert(
2518
2515
  "Editor content area not found. Please click inside the editor first."
2519
2516
  ), !1;
2520
- const t = e.innerHTML, i = (n) => {
2517
+ const t = e.innerHTML, s = (n) => {
2521
2518
  let r = "", o = 0;
2522
- const a = 2, h = n.split(/(<\/?[a-zA-Z][^>]*>)/);
2523
- for (const l of h)
2524
- l.trim() && (l.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), r += `
2525
- ` + " ".repeat(o * a) + l) : l.match(/^<[a-zA-Z]/) && !l.match(/\/>$/) ? (r += `
2526
- ` + " ".repeat(o * a) + l, o++) : l.match(/^<[a-zA-Z].*\/>$/) ? r += `
2527
- ` + " ".repeat(o * a) + l : r += l.trim());
2519
+ const l = 2, h = n.split(/(<\/?[a-zA-Z][^>]*>)/);
2520
+ for (const a of h)
2521
+ a.trim() && (a.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), r += `
2522
+ ` + " ".repeat(o * l) + a) : a.match(/^<[a-zA-Z]/) && !a.match(/\/>$/) ? (r += `
2523
+ ` + " ".repeat(o * l) + a, o++) : a.match(/^<[a-zA-Z].*\/>$/) ? r += `
2524
+ ` + " ".repeat(o * l) + a : r += a.trim());
2528
2525
  return r.trim();
2529
2526
  };
2530
2527
  return (() => {
2531
- const r = i(t);
2532
- let o = null, a = "dark", h = !1, l = !1, c = !1, d = !1;
2533
- const p = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), u = document.createElement("div");
2534
- u.className = "rte-source-editor-overlay", p && u.classList.add("rte-theme-dark");
2528
+ const r = s(t);
2529
+ let o = null, l = "dark", h = !1, a = !1, c = !1, d = !1;
2530
+ const f = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), u = document.createElement("div");
2531
+ u.className = "rte-source-editor-overlay", f && u.classList.add("rte-theme-dark");
2535
2532
  const g = document.createElement("div");
2536
2533
  g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
2537
- const f = document.createElement("div");
2538
- f.className = "rte-source-editor-header", f.innerHTML = `
2534
+ const p = document.createElement("div");
2535
+ p.className = "rte-source-editor-header", p.innerHTML = `
2539
2536
  <h2 id="source-editor-title">Source Editor</h2>
2540
2537
  <div class="rte-source-editor-header-toolbar">
2541
2538
  <button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
@@ -2589,17 +2586,17 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2589
2586
  <button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
2590
2587
  <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
2591
2588
  </div>
2592
- `, g.appendChild(f), g.appendChild(y), g.appendChild(E), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
2589
+ `, g.appendChild(p), g.appendChild(y), g.appendChild(E), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
2593
2590
  const x = document.createElement("style");
2594
2591
  x.id = "rte-source-editor-styles", x.textContent = le, document.head.appendChild(x);
2595
2592
  }
2596
- const S = f.querySelector(
2593
+ const S = p.querySelector(
2597
2594
  ".theme-toggle-btn"
2598
- ), b = f.querySelector(
2595
+ ), b = p.querySelector(
2599
2596
  ".readonly-toggle-btn"
2600
- ), T = f.querySelector(
2597
+ ), T = p.querySelector(
2601
2598
  ".rte-source-editor-fullscreen-btn"
2602
- ), I = f.querySelector(
2599
+ ), I = p.querySelector(
2603
2600
  ".rte-source-editor-close-btn"
2604
2601
  ), B = E.querySelector(
2605
2602
  ".rte-source-editor-btn-cancel"
@@ -2615,14 +2612,12 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2615
2612
  c !== x && (c = x, $ && ($.style.display = c ? "inline" : "none"));
2616
2613
  }, H = () => {
2617
2614
  if (!d) {
2618
- for (d = !0; O.length; ) {
2619
- const x = O.pop();
2620
- x == null || x();
2621
- }
2615
+ for (d = !0; O.length; )
2616
+ O.pop()?.();
2622
2617
  o && (o.destroy(), o = null), u.isConnected && u.remove();
2623
2618
  }
2624
2619
  }, K = () => {
2625
- a = a === "dark" ? "light" : "dark", o == null || o.setTheme(a), S && (S.innerHTML = a === "light" ? `
2620
+ l = l === "dark" ? "light" : "dark", o?.setTheme(l), S && (S.innerHTML = l === "light" ? `
2626
2621
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2627
2622
  <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
2628
2623
  </svg>
@@ -2640,7 +2635,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2640
2635
  </svg>
2641
2636
  `);
2642
2637
  }, z = () => {
2643
- h = !h, o == null || o.setReadOnly(h), b && (b.classList.toggle("active", h), b.innerHTML = h ? `
2638
+ h = !h, o?.setReadOnly(h), b && (b.classList.toggle("active", h), b.innerHTML = h ? `
2644
2639
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2645
2640
  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
2646
2641
  <circle cx="12" cy="16" r="1"/>
@@ -2653,7 +2648,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2653
2648
  </svg>
2654
2649
  `);
2655
2650
  }, q = () => {
2656
- l = !l, u.classList.toggle("fullscreen", l), C.style.height = l ? "calc(100vh - 200px)" : "400px", T && (T.innerHTML = l ? `
2651
+ a = !a, u.classList.toggle("fullscreen", a), C.style.height = a ? "calc(100vh - 200px)" : "400px", T && (T.innerHTML = a ? `
2657
2652
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2658
2653
  <path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3"/>
2659
2654
  </svg>
@@ -2666,7 +2661,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2666
2661
  c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
2667
2662
  }, j = () => {
2668
2663
  try {
2669
- const x = (o == null ? void 0 : o.getValue()) || "", M = document.createElement("div");
2664
+ const x = o?.getValue() || "", M = document.createElement("div");
2670
2665
  M.innerHTML = x, M.querySelectorAll(
2671
2666
  'script, iframe[src^="javascript:"], object, embed'
2672
2667
  ).forEach((A) => A.remove()), e.innerHTML = M.innerHTML;
@@ -2706,15 +2701,15 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2706
2701
  new G(),
2707
2702
  new _(),
2708
2703
  new ee(),
2709
- new se(),
2710
2704
  new ie(),
2705
+ new se(),
2711
2706
  new ne(),
2712
2707
  new re()
2713
2708
  ]
2714
2709
  }), o.on("change", () => {
2715
- const x = (o == null ? void 0 : o.getValue()) || "";
2710
+ const x = o?.getValue() || "";
2716
2711
  U(x !== r);
2717
- }), requestAnimationFrame(() => o == null ? void 0 : o.focus());
2712
+ }), requestAnimationFrame(() => o?.focus());
2718
2713
  } catch (x) {
2719
2714
  console.error("Failed to initialize code editor:", x);
2720
2715
  }