@editora/core 1.0.14 → 1.0.16

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 (73) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-veDC_kx5.mjs → CodePlugin.native-BH-K4xmW.mjs} +1049 -917
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/{documentManager-vQ1VkbUY.mjs → documentManager-BcBIv5P-.mjs} +3 -3
  44. package/dist/editora.min.js +26 -24
  45. package/dist/editora.umd.js +26 -24
  46. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  47. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  48. package/dist/index-B1_vtXRz.mjs +3910 -0
  49. package/dist/index-C6BoNR2t.js +12 -0
  50. package/dist/{index-BslAFzmv.mjs → index-CavM-mEM.mjs} +6391 -6203
  51. package/dist/index.cjs.js +3 -3
  52. package/dist/{index.es-BYD2KEo6.mjs → index.es-BK-4TPv8.mjs} +1562 -1546
  53. package/dist/index.esm.js +17 -14
  54. package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-BsnKYYHL.mjs} +4 -3
  55. package/dist/plugin-loader.js +53 -52
  56. package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-DhWKBjsL.mjs} +3 -3
  57. package/dist/webcomponent-core.js +2039 -473
  58. package/dist/webcomponent-core.min.css +1 -1
  59. package/dist/webcomponent-core.min.js +100 -70
  60. package/dist/webcomponent.cjs.js +1 -1
  61. package/dist/webcomponent.esm.js +1 -1
  62. package/dist/webcomponent.js +2208 -641
  63. package/dist/webcomponent.min.css +1 -1
  64. package/dist/webcomponent.min.js +1575 -1209
  65. package/index.d.ts +32 -0
  66. package/package.json +10 -3
  67. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  68. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  69. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  70. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  71. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  72. package/dist/index-B9MPiUAR.mjs +0 -2341
  73. package/dist/index-BLm1MtzH.js +0 -10
@@ -1,4 +1,5 @@
1
- class V {
1
+ import { i as Q } from "./dialogHelpers-DBf7WqYH.mjs";
2
+ class K {
2
3
  constructor(e = "") {
3
4
  this._lines = [], this._version = 0, this.setText(e);
4
5
  }
@@ -37,8 +38,8 @@ class V {
37
38
  }
38
39
  // Replace text in range
39
40
  replaceRange(e, t) {
40
- const i = this.normalizeRange(e), s = this.getTextInRange(i), n = this.getText(), r = this.positionToOffset(i.start), o = this.positionToOffset(i.end), l = n.slice(0, r) + t + n.slice(o);
41
- return this.setText(l), { range: i, text: t, oldText: s };
41
+ const i = this.normalizeRange(e), n = this.getTextInRange(i), s = this.getText(), r = this.positionToOffset(i.start), o = this.positionToOffset(i.end), l = s.slice(0, r) + t + s.slice(o);
42
+ return this.setText(l), { range: i, text: t, oldText: n };
42
43
  }
43
44
  // Insert text at position
44
45
  insertText(e, t) {
@@ -60,10 +61,10 @@ class V {
60
61
  offsetToPosition(e) {
61
62
  let t = e;
62
63
  for (let i = 0; i < this.getLineCount(); i++) {
63
- const s = this.getLine(i).length;
64
- if (t <= s)
64
+ const n = this.getLine(i).length;
65
+ if (t <= n)
65
66
  return { line: i, column: t };
66
- t -= s + 1;
67
+ t -= n + 1;
67
68
  }
68
69
  return {
69
70
  line: this.getLineCount() - 1,
@@ -84,7 +85,7 @@ class V {
84
85
  }
85
86
  // Clone the model
86
87
  clone() {
87
- const e = new V();
88
+ const e = new K();
88
89
  return e._lines = [...this._lines], e._version = this._version, e;
89
90
  }
90
91
  normalizeRange(e) {
@@ -97,7 +98,7 @@ class V {
97
98
  return e.line !== t.line ? e.line - t.line : e.column - t.column;
98
99
  }
99
100
  }
100
- class Q {
101
+ class Y {
101
102
  constructor(e) {
102
103
  this.gutterWidth = 50, this.gutterFoldColumnWidth = 20, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
103
104
  }
@@ -207,14 +208,14 @@ class Q {
207
208
  if (this.updateGutterWidth(e), e === this.lastLineCount)
208
209
  return;
209
210
  this.lastLineCount = e;
210
- const t = Math.max(e, 1), i = Array.from({ length: t }, (s, n) => n + 1);
211
- this.lineNumbersContentElement.innerHTML = i.map((s) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${s}</div>`).join("");
211
+ const t = Math.max(e, 1), i = Array.from({ length: t }, (n, s) => s + 1);
212
+ this.lineNumbersContentElement.innerHTML = i.map((n) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${n}</div>`).join("");
212
213
  }
213
214
  updateGutterWidth(e) {
214
- const t = String(Math.max(e, 1)).length * this.gutterDigitWidth + this.gutterLineNumberPaddingLeft + this.gutterLineNumberPaddingRight, i = Math.ceil(
215
- t + this.gutterFoldColumnGap + this.gutterFoldColumnWidth
215
+ const i = String(Math.max(e, 1)).length * this.gutterDigitWidth + this.gutterLineNumberPaddingLeft + this.gutterLineNumberPaddingRight, n = Math.ceil(
216
+ i + this.gutterFoldColumnGap + this.gutterFoldColumnWidth
216
217
  );
217
- i !== this.gutterWidth && (this.gutterWidth = i, this.lineNumbersElement.style.display !== "none" && (this.lineNumbersElement.style.width = `${this.gutterWidth}px`, this.lineNumbersElement.style.minWidth = `${this.gutterWidth}px`));
218
+ n !== this.gutterWidth && (this.gutterWidth = n, this.lineNumbersElement.style.display !== "none" && (this.lineNumbersElement.style.width = `${this.gutterWidth}px`, this.lineNumbersElement.style.minWidth = `${this.gutterWidth}px`));
218
219
  }
219
220
  setDecorations(e, t) {
220
221
  this.renderLineDecorations(e), this.renderGutterDecorations(t);
@@ -245,17 +246,17 @@ class Q {
245
246
  // Set inner HTML (used for syntax highlighted content)
246
247
  setHTML(e) {
247
248
  this.clearHighlightOverlay(), this.setFoldPlaceholderSources(/* @__PURE__ */ new Map());
248
- const t = /\n$/.test(e), i = /&lt;|&gt;/.test(e), s = /<span\b/i.test(e), n = /<[^>]+>/.test(e);
249
- i && s ? this.contentElement.innerHTML = e : n && !i ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
250
- const r = (this.contentElement.textContent || "").split(`
249
+ const t = /\n$/.test(e), i = /&lt;|&gt;/.test(e), n = /<span\b/i.test(e), s = /<[^>]+>/.test(e);
250
+ i && n ? this.contentElement.innerHTML = e : s && !i ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
251
+ const o = (this.contentElement.textContent || "").split(`
251
252
  `).length;
252
- this.updateLineNumbers(r);
253
+ this.updateLineNumbers(o);
253
254
  }
254
255
  setHighlightHTML(e) {
255
256
  e !== this.lastHighlightHTML && (this.highlightElement.innerHTML = e, this.lastHighlightHTML = e), this.highlightElement.style.visibility = "visible", this.highlightOverlayActive = !0, this.contentElement.style.color = "transparent", this.contentElement.style.WebkitTextFillColor = "transparent";
256
- const t = (this.contentElement.textContent || "").split(`
257
+ const i = (this.contentElement.textContent || "").split(`
257
258
  `).length;
258
- this.updateLineNumbers(t);
259
+ this.updateLineNumbers(i);
259
260
  }
260
261
  setLineWrapping(e) {
261
262
  this.contentElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.contentElement.style.overflow = "visible", this.contentElement.style.minWidth = e ? "100%" : "max-content", this.contentSurface.style.minWidth = e ? "100%" : "max-content", this.contentElement.style.wordBreak = "normal", this.contentElement.style.overflowWrap = e ? "anywhere" : "normal", this.highlightElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.highlightElement.style.wordBreak = "normal", this.highlightElement.style.overflowWrap = e ? "anywhere" : "normal";
@@ -280,10 +281,10 @@ class Q {
280
281
  }
281
282
  // Set cursor position
282
283
  setCursorPosition(e) {
283
- const t = this.getText(), i = this.positionToTextOffset(e, t), s = window.getSelection(), n = this.createDomRangeFromOffsets(i);
284
- if (n)
284
+ const t = this.getText(), i = this.positionToTextOffset(e, t), n = window.getSelection(), s = this.createDomRangeFromOffsets(i);
285
+ if (s)
285
286
  try {
286
- s == null || s.removeAllRanges(), s == null || s.addRange(n), this.ensureCaretVisible();
287
+ n == null || n.removeAllRanges(), n == null || n.addRange(s), this.ensureCaretVisible();
287
288
  } catch (r) {
288
289
  console.warn("Could not set cursor position:", r);
289
290
  }
@@ -292,7 +293,7 @@ class Q {
292
293
  `[${this.trailingNewlineMarkerAttr}]`
293
294
  ), o = document.createRange();
294
295
  try {
295
- r && r.parentNode === this.contentElement ? o.setStartBefore(r) : (o.selectNodeContents(this.contentElement), o.collapse(!1)), o.collapse(!0), s == null || s.removeAllRanges(), s == null || s.addRange(o), this.ensureCaretVisible();
296
+ r && r.parentNode === this.contentElement ? o.setStartBefore(r) : (o.selectNodeContents(this.contentElement), o.collapse(!1)), o.collapse(!0), n == null || n.removeAllRanges(), n == null || n.addRange(o), this.ensureCaretVisible();
296
297
  } catch (l) {
297
298
  console.warn("Could not set fallback cursor position:", l);
298
299
  }
@@ -322,7 +323,7 @@ class Q {
322
323
  const i = e.anchorNode && this.isNodeInsideContent(e.anchorNode) ? this.sourceOffsetFromBoundary(
323
324
  e.anchorNode,
324
325
  e.anchorOffset
325
- ) : void 0, s = e.focusNode && this.isNodeInsideContent(e.focusNode) ? this.sourceOffsetFromBoundary(
326
+ ) : void 0, n = e.focusNode && this.isNodeInsideContent(e.focusNode) ? this.sourceOffsetFromBoundary(
326
327
  e.focusNode,
327
328
  e.focusOffset
328
329
  ) : void 0;
@@ -338,7 +339,7 @@ class Q {
338
339
  t.endOffset
339
340
  ),
340
341
  anchorOffset: i,
341
- focusOffset: s
342
+ focusOffset: n
342
343
  };
343
344
  }
344
345
  getSelectionState() {
@@ -354,10 +355,10 @@ class Q {
354
355
  isInEditor: !1,
355
356
  isCollapsed: e.isCollapsed
356
357
  };
357
- const i = this.getText(), s = this.sourceOffsetFromBoundary(t.startContainer, t.startOffset), n = this.sourceOffsetFromBoundary(t.endContainer, t.endOffset), r = e.focusNode && this.isNodeInsideContent(e.focusNode) ? this.sourceOffsetFromBoundary(
358
+ const i = this.getText(), n = this.sourceOffsetFromBoundary(t.startContainer, t.startOffset), s = this.sourceOffsetFromBoundary(t.endContainer, t.endOffset), r = e.focusNode && this.isNodeInsideContent(e.focusNode) ? this.sourceOffsetFromBoundary(
358
359
  e.focusNode,
359
360
  e.focusOffset
360
- ) : n, o = this.offsetToPositionInText(s, i), l = this.offsetToPositionInText(n, i), a = this.offsetToPositionInText(r, i);
361
+ ) : s, o = this.offsetToPositionInText(n, i), l = this.offsetToPositionInText(s, i), a = this.offsetToPositionInText(r, i);
361
362
  return {
362
363
  isInEditor: !0,
363
364
  isCollapsed: e.isCollapsed,
@@ -377,12 +378,12 @@ class Q {
377
378
  }
378
379
  }
379
380
  createDomRangeFromOffsets(e, t = e) {
380
- const [i, s] = e <= t ? [e, t] : [t, e], n = this.resolveOffsetToDomPoint(i), r = this.resolveOffsetToDomPoint(s);
381
- if (!n || !r)
381
+ const [i, n] = e <= t ? [e, t] : [t, e], s = this.resolveOffsetToDomPoint(i), r = this.resolveOffsetToDomPoint(n);
382
+ if (!s || !r)
382
383
  return null;
383
384
  const o = document.createRange();
384
385
  try {
385
- return o.setStart(n.node, n.offset), o.setEnd(r.node, r.offset), o;
386
+ return o.setStart(s.node, s.offset), o.setEnd(r.node, r.offset), o;
386
387
  } catch (l) {
387
388
  return null;
388
389
  }
@@ -398,43 +399,43 @@ class Q {
398
399
  const i = this.getDomRangeFromClientPoint(e, t);
399
400
  if (!i || !this.isNodeInsideContent(i.startContainer))
400
401
  return null;
401
- const s = this.sourceOffsetFromBoundary(
402
+ const n = this.sourceOffsetFromBoundary(
402
403
  i.startContainer,
403
404
  i.startOffset
404
405
  );
405
- return this.offsetToPositionInText(s, this.getText());
406
+ return this.offsetToPositionInText(n, this.getText());
406
407
  }
407
408
  setSelectionOffsets(e, t = e) {
408
409
  const i = this.createDomRangeFromOffsets(e, t);
409
410
  if (i)
410
411
  try {
411
- const s = window.getSelection();
412
- s == null || s.removeAllRanges(), s == null || s.addRange(i), this.ensureCaretVisible();
413
- } catch (s) {
414
- console.warn("Could not set selection offsets:", s);
412
+ const n = window.getSelection();
413
+ n == null || n.removeAllRanges(), n == null || n.addRange(i), this.ensureCaretVisible();
414
+ } catch (n) {
415
+ console.warn("Could not set selection offsets:", n);
415
416
  }
416
417
  }
417
418
  setSelectionBoundaryOffsets(e, t) {
418
- const i = this.resolveOffsetToDomPoint(e), s = this.resolveOffsetToDomPoint(t), n = window.getSelection();
419
- if (!i || !s || !n) {
419
+ const i = this.resolveOffsetToDomPoint(e), n = this.resolveOffsetToDomPoint(t), s = window.getSelection();
420
+ if (!i || !n || !s) {
420
421
  this.setSelectionOffsets(e, t);
421
422
  return;
422
423
  }
423
424
  try {
424
- if (n.removeAllRanges(), e === t) {
425
+ if (s.removeAllRanges(), e === t) {
425
426
  const o = document.createRange();
426
- o.setStart(i.node, i.offset), o.collapse(!0), n.addRange(o), this.ensureCaretVisible();
427
+ o.setStart(i.node, i.offset), o.collapse(!0), s.addRange(o), this.ensureCaretVisible();
427
428
  return;
428
429
  }
429
- if (typeof n.extend == "function") {
430
+ if (typeof s.extend == "function") {
430
431
  const o = document.createRange();
431
- o.setStart(i.node, i.offset), o.collapse(!0), n.addRange(o), n.extend(s.node, s.offset), this.ensureCaretVisible();
432
+ o.setStart(i.node, i.offset), o.collapse(!0), s.addRange(o), s.extend(n.node, n.offset), this.ensureCaretVisible();
432
433
  return;
433
434
  }
434
435
  const r = this.createDomRangeFromOffsets(e, t);
435
436
  if (!r)
436
437
  return;
437
- n.addRange(r), this.ensureCaretVisible();
438
+ s.addRange(r), this.ensureCaretVisible();
438
439
  } catch (r) {
439
440
  console.warn("Could not set selection boundary offsets:", r), this.setSelectionOffsets(e, t);
440
441
  }
@@ -459,8 +460,8 @@ class Q {
459
460
  }
460
461
  // Scroll to position
461
462
  scrollToPosition(e) {
462
- const t = Math.max(0, Math.floor(e.line) || 0) * this.lineHeight - this.editorContainer.clientHeight / 2 + this.lineHeight / 2;
463
- this.editorContainer.scrollTop = Math.max(0, t);
463
+ const n = Math.max(0, Math.floor(e.line) || 0) * this.lineHeight - this.editorContainer.clientHeight / 2 + this.lineHeight / 2;
464
+ this.editorContainer.scrollTop = Math.max(0, n);
464
465
  }
465
466
  // Get scroll position
466
467
  getScrollTop() {
@@ -491,39 +492,39 @@ class Q {
491
492
  if (!e || e.rangeCount === 0) return;
492
493
  const t = this.getCaretClientRect(e);
493
494
  if (!t) return;
494
- const i = this.editorContainer.getBoundingClientRect(), s = 12;
495
- t.bottom > i.bottom - s ? this.editorContainer.scrollTop += t.bottom - (i.bottom - s) : t.top < i.top + s && (this.editorContainer.scrollTop -= i.top + s - t.top), t.right > i.right - s ? this.editorContainer.scrollLeft += t.right - (i.right - s) : t.left < i.left + s && (this.editorContainer.scrollLeft -= i.left + s - t.left);
495
+ const i = this.editorContainer.getBoundingClientRect(), n = 12;
496
+ t.bottom > i.bottom - n ? this.editorContainer.scrollTop += t.bottom - (i.bottom - n) : t.top < i.top + n && (this.editorContainer.scrollTop -= i.top + n - t.top), t.right > i.right - n ? this.editorContainer.scrollLeft += t.right - (i.right - n) : t.left < i.left + n && (this.editorContainer.scrollLeft -= i.left + n - t.left);
496
497
  }
497
498
  // Destroy the view
498
499
  destroy() {
499
500
  this.clearDecorations(), this.container && (this.container.innerHTML = ""), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
500
501
  }
501
502
  resolveOffsetToDomPoint(e) {
502
- var n;
503
+ var s;
503
504
  const t = Math.max(0, e);
504
505
  let i = 0;
505
- const s = Array.from(this.contentElement.childNodes);
506
- for (let r = 0; r < s.length; r++) {
507
- const o = s[r];
506
+ const n = Array.from(this.contentElement.childNodes);
507
+ for (let r = 0; r < n.length; r++) {
508
+ const o = n[r];
508
509
  if (o instanceof Text) {
509
510
  const l = o.textContent || "", a = this.buildVisibleToDomMap(l), h = Math.max(0, a.length - 1);
510
511
  if (i + h >= t) {
511
- const d = Math.max(0, t - i), c = (n = a[d]) != null ? n : l.length;
512
- return { node: o, offset: c };
512
+ const c = Math.max(0, t - i), d = (s = a[c]) != null ? s : l.length;
513
+ return { node: o, offset: d };
513
514
  }
514
515
  i += h;
515
516
  continue;
516
517
  }
517
518
  if (o instanceof HTMLElement && !o.hasAttribute(this.trailingNewlineMarkerAttr) && o.hasAttribute(this.foldPlaceholderAttr)) {
518
- const l = this.getFoldPlaceholderSource(o).length;
519
- if (i + l >= t) {
520
- const a = t - i;
519
+ const a = this.getFoldPlaceholderSource(o).length;
520
+ if (i + a >= t) {
521
+ const h = t - i;
521
522
  return {
522
523
  node: this.contentElement,
523
- offset: a <= l / 2 ? r : r + 1
524
+ offset: h <= a / 2 ? r : r + 1
524
525
  };
525
526
  }
526
- i += l;
527
+ i += a;
527
528
  }
528
529
  }
529
530
  return {
@@ -534,14 +535,14 @@ class Q {
534
535
  getDomRangeFromClientPoint(e, t) {
535
536
  const i = document;
536
537
  if (typeof i.caretPositionFromPoint == "function") {
537
- const s = i.caretPositionFromPoint(
538
+ const n = i.caretPositionFromPoint(
538
539
  e,
539
540
  t
540
541
  );
541
- if (s != null && s.offsetNode) {
542
- const n = document.createRange();
542
+ if (n != null && n.offsetNode) {
543
+ const s = document.createRange();
543
544
  try {
544
- return n.setStart(s.offsetNode, s.offset), n.collapse(!0), n;
545
+ return s.setStart(n.offsetNode, n.offset), s.collapse(!0), s;
545
546
  } catch (r) {
546
547
  return null;
547
548
  }
@@ -552,9 +553,9 @@ class Q {
552
553
  buildVisibleToDomMap(e) {
553
554
  const t = [0];
554
555
  let i = 0;
555
- for (let s = 0; s < e.length; s++) {
556
- const n = e[s];
557
- this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
556
+ for (let n = 0; n < e.length; n++) {
557
+ const s = e[n];
558
+ this.virtualMarkerRegex.test(s) || (i += 1, t[i] = n + 1);
558
559
  }
559
560
  return t;
560
561
  }
@@ -568,23 +569,23 @@ class Q {
568
569
  const i = this.getUsableRangeRect(t);
569
570
  if (i)
570
571
  return i;
571
- const s = e.focusNode, n = e.focusOffset;
572
- if (s instanceof Text) {
573
- const h = (l = (o = s.textContent) == null ? void 0 : o.length) != null ? l : 0, d = document.createRange();
574
- if (n < h) {
575
- d.setStart(s, n), d.setEnd(s, Math.min(h, n + 1));
576
- const c = this.getUsableRangeRect(d);
577
- if (c)
578
- return c;
572
+ const n = e.focusNode, s = e.focusOffset;
573
+ if (n instanceof Text) {
574
+ const h = (l = (o = n.textContent) == null ? void 0 : o.length) != null ? l : 0, c = document.createRange();
575
+ if (s < h) {
576
+ c.setStart(n, s), c.setEnd(n, Math.min(h, s + 1));
577
+ const d = this.getUsableRangeRect(c);
578
+ if (d)
579
+ return d;
579
580
  }
580
- if (n > 0) {
581
- d.setStart(s, n - 1), d.setEnd(s, n);
582
- const c = this.getUsableRangeRect(d);
583
- if (c)
584
- return c;
581
+ if (s > 0) {
582
+ c.setStart(n, s - 1), c.setEnd(n, s);
583
+ const d = this.getUsableRangeRect(c);
584
+ if (d)
585
+ return d;
585
586
  }
586
587
  }
587
- const r = s instanceof Element ? s : (a = s == null ? void 0 : s.parentElement) != null ? a : null;
588
+ const r = n instanceof Element ? n : (a = n == null ? void 0 : n.parentElement) != null ? a : null;
588
589
  if (r && r !== this.contentElement && r !== this.editorContainer && this.contentElement.contains(r)) {
589
590
  const h = r.getBoundingClientRect();
590
591
  if (this.isUsableRect(h))
@@ -594,9 +595,9 @@ class Q {
594
595
  }
595
596
  getUsableRangeRect(e) {
596
597
  const t = Array.from(e.getClientRects());
597
- for (let s = 0; s < t.length; s++)
598
- if (this.isUsableRect(t[s]))
599
- return t[s];
598
+ for (let n = 0; n < t.length; n++)
599
+ if (this.isUsableRect(t[n]))
600
+ return t[n];
600
601
  const i = e.getBoundingClientRect();
601
602
  return this.isUsableRect(i) ? i : null;
602
603
  }
@@ -629,14 +630,14 @@ class Q {
629
630
  }
630
631
  sourceOffsetFromBoundary(e, t) {
631
632
  let i = 0;
632
- const s = Array.from(this.contentElement.childNodes);
633
+ const n = Array.from(this.contentElement.childNodes);
633
634
  if (e === this.contentElement) {
634
- for (let n = 0; n < Math.min(t, s.length); n++)
635
- i += this.getSourceLength(s[n]);
635
+ for (let s = 0; s < Math.min(t, n.length); s++)
636
+ i += this.getSourceLength(n[s]);
636
637
  return i;
637
638
  }
638
- for (let n = 0; n < s.length; n++) {
639
- const r = s[n];
639
+ for (let s = 0; s < n.length; s++) {
640
+ const r = n[s];
640
641
  if (r === e) {
641
642
  if (r instanceof Text)
642
643
  return i + this.stripVirtualMarkers((r.textContent || "").slice(0, t)).length;
@@ -664,40 +665,40 @@ class Q {
664
665
  return i;
665
666
  }
666
667
  sourceOffsetWithinNode(e, t, i) {
667
- let s = 0;
668
- const n = Array.from(e.childNodes);
668
+ let n = 0;
669
+ const s = Array.from(e.childNodes);
669
670
  if (t === e) {
670
- for (let r = 0; r < Math.min(i, n.length); r++)
671
- s += this.getSourceLength(n[r]);
672
- return s;
671
+ for (let r = 0; r < Math.min(i, s.length); r++)
672
+ n += this.getSourceLength(s[r]);
673
+ return n;
673
674
  }
674
- for (let r = 0; r < n.length; r++) {
675
- const o = n[r];
675
+ for (let r = 0; r < s.length; r++) {
676
+ const o = s[r];
676
677
  if (o === t) {
677
678
  if (o instanceof Text)
678
- return s + this.stripVirtualMarkers((o.textContent || "").slice(0, i)).length;
679
+ return n + this.stripVirtualMarkers((o.textContent || "").slice(0, i)).length;
679
680
  if (o instanceof HTMLElement) {
680
681
  if (o.hasAttribute(this.foldPlaceholderAttr))
681
- return s + this.getFoldPlaceholderBoundaryOffset(
682
+ return n + this.getFoldPlaceholderBoundaryOffset(
682
683
  o,
683
684
  o,
684
685
  i
685
686
  );
686
687
  const l = Array.from(o.childNodes);
687
688
  for (let a = 0; a < Math.min(i, l.length); a++)
688
- s += this.getSourceLength(l[a]);
689
- return s;
689
+ n += this.getSourceLength(l[a]);
690
+ return n;
690
691
  }
691
692
  }
692
693
  if (o instanceof HTMLElement && o.contains(t))
693
- return o.hasAttribute(this.foldPlaceholderAttr) ? s + this.getFoldPlaceholderBoundaryOffset(
694
+ return o.hasAttribute(this.foldPlaceholderAttr) ? n + this.getFoldPlaceholderBoundaryOffset(
694
695
  o,
695
696
  t,
696
697
  i
697
- ) : s + this.sourceOffsetWithinNode(o, t, i);
698
- s += this.getSourceLength(o);
698
+ ) : n + this.sourceOffsetWithinNode(o, t, i);
699
+ n += this.getSourceLength(o);
699
700
  }
700
- return s;
701
+ return n;
701
702
  }
702
703
  getSourceLength(e) {
703
704
  if (e instanceof Text)
@@ -712,44 +713,44 @@ class Q {
712
713
  }), t;
713
714
  }
714
715
  renderLineDecorations(e) {
715
- const t = [...e].filter((n) => Number.isFinite(n.line) && n.line >= 0).sort((n, r) => n.line - r.line || n.id.localeCompare(r.id)), i = t.map(
716
- (n) => `${n.id}:${n.line}:${n.className || ""}:${this.serializeStyleObject(n.style)}`
716
+ const t = [...e].filter((s) => Number.isFinite(s.line) && s.line >= 0).sort((s, r) => s.line - r.line || s.id.localeCompare(r.id)), i = t.map(
717
+ (s) => `${s.id}:${s.line}:${s.className || ""}:${this.serializeStyleObject(s.style)}`
717
718
  ).join("|");
718
719
  if (i === this.lastLineDecorationSnapshot || (this.lineDecorationsElement.innerHTML = "", this.lastLineDecorationSnapshot = i, t.length === 0))
719
720
  return;
720
- const s = document.createDocumentFragment();
721
- for (const n of t) {
721
+ const n = document.createDocumentFragment();
722
+ for (const s of t) {
722
723
  const r = document.createElement("div");
723
724
  r.className = this.joinClassNames(
724
725
  "lce-decoration lce-decoration-line",
725
- n.className
726
- ), r.setAttribute("data-decoration-id", n.id), r.setAttribute("data-decoration-line", String(n.line)), r.style.cssText = this.joinStyleFragments([
726
+ s.className
727
+ ), r.setAttribute("data-decoration-id", s.id), r.setAttribute("data-decoration-line", String(s.line)), r.style.cssText = this.joinStyleFragments([
727
728
  "position: absolute",
728
- `top: ${n.line * this.lineHeight}px`,
729
+ `top: ${s.line * this.lineHeight}px`,
729
730
  `height: ${this.lineHeight}px`,
730
731
  "left: 12px",
731
732
  "right: 12px",
732
733
  "border-radius: 3px",
733
- this.serializeStyleObject(n.style)
734
- ]), s.appendChild(r);
734
+ this.serializeStyleObject(s.style)
735
+ ]), n.appendChild(r);
735
736
  }
736
- this.lineDecorationsElement.appendChild(s);
737
+ this.lineDecorationsElement.appendChild(n);
737
738
  }
738
739
  renderGutterDecorations(e) {
739
- const t = [...e].filter((n) => Number.isFinite(n.line) && n.line >= 0).sort((n, r) => n.line - r.line || n.id.localeCompare(r.id)), i = t.map(
740
- (n) => `${n.id}:${n.line}:${n.label || ""}:${n.title || ""}:${n.className || ""}:${this.serializeStyleObject(n.style)}`
740
+ const t = [...e].filter((s) => Number.isFinite(s.line) && s.line >= 0).sort((s, r) => s.line - r.line || s.id.localeCompare(r.id)), i = t.map(
741
+ (s) => `${s.id}:${s.line}:${s.label || ""}:${s.title || ""}:${s.className || ""}:${this.serializeStyleObject(s.style)}`
741
742
  ).join("|");
742
743
  if (i === this.lastGutterDecorationSnapshot || (this.gutterDecorationsElement.innerHTML = "", this.lastGutterDecorationSnapshot = i, t.length === 0))
743
744
  return;
744
- const s = document.createDocumentFragment();
745
- for (const n of t) {
745
+ const n = document.createDocumentFragment();
746
+ for (const s of t) {
746
747
  const r = document.createElement("div");
747
748
  r.className = this.joinClassNames(
748
749
  "lce-decoration lce-decoration-gutter",
749
- n.className
750
- ), r.setAttribute("data-decoration-id", n.id), r.setAttribute("data-decoration-line", String(n.line)), r.style.cssText = this.joinStyleFragments([
750
+ s.className
751
+ ), r.setAttribute("data-decoration-id", s.id), r.setAttribute("data-decoration-line", String(s.line)), r.style.cssText = this.joinStyleFragments([
751
752
  "position: absolute",
752
- `top: ${n.line * this.lineHeight}px`,
753
+ `top: ${s.line * this.lineHeight}px`,
753
754
  `height: ${this.lineHeight}px`,
754
755
  "left: 0",
755
756
  "right: 0",
@@ -758,10 +759,10 @@ class Q {
758
759
  "justify-content: flex-end",
759
760
  "padding-right: 4px",
760
761
  "box-sizing: border-box",
761
- this.serializeStyleObject(n.style)
762
- ]), n.title && (r.title = n.title), r.textContent = n.label || "", s.appendChild(r);
762
+ this.serializeStyleObject(s.style)
763
+ ]), s.title && (r.title = s.title), r.textContent = s.label || "", n.appendChild(r);
763
764
  }
764
- this.gutterDecorationsElement.appendChild(s);
765
+ this.gutterDecorationsElement.appendChild(n);
765
766
  }
766
767
  joinClassNames(...e) {
767
768
  return e.filter(Boolean).join(" ").trim();
@@ -789,14 +790,14 @@ class Q {
789
790
  positionToTextOffset(e, t) {
790
791
  var o;
791
792
  const i = t.split(`
792
- `), s = Math.max(0, Math.min(e.line, i.length - 1)), n = Math.max(
793
+ `), n = Math.max(0, Math.min(e.line, i.length - 1)), s = Math.max(
793
794
  0,
794
- Math.min(e.column, ((o = i[s]) == null ? void 0 : o.length) || 0)
795
+ Math.min(e.column, ((o = i[n]) == null ? void 0 : o.length) || 0)
795
796
  );
796
797
  let r = 0;
797
- for (let l = 0; l < s; l++)
798
+ for (let l = 0; l < n; l++)
798
799
  r += i[l].length + 1;
799
- return r + n;
800
+ return r + s;
800
801
  }
801
802
  getFoldPlaceholderSource(e) {
802
803
  const t = e.getAttribute(this.foldPlaceholderAttr), i = this.getFoldPlaceholderSources();
@@ -806,24 +807,24 @@ class Q {
806
807
  return this.contentElement.__lceFoldPlaceholderSources || /* @__PURE__ */ new Map();
807
808
  }
808
809
  getFoldPlaceholderBoundaryOffset(e, t, i) {
809
- const s = this.getFoldPlaceholderSource(e).length, n = this.stripVirtualMarkers(e.textContent || "").length;
810
- if (s === 0 || n === 0)
810
+ const n = this.getFoldPlaceholderSource(e).length, s = this.stripVirtualMarkers(e.textContent || "").length;
811
+ if (n === 0 || s === 0)
811
812
  return 0;
812
813
  const r = document.createRange();
813
814
  r.selectNodeContents(e);
814
815
  try {
815
816
  r.setEnd(t, i);
816
- } catch (o) {
817
+ } catch (l) {
817
818
  return 0;
818
819
  }
819
- return this.stripVirtualMarkers(r.toString()).length <= n / 2 ? 0 : s;
820
+ return this.stripVirtualMarkers(r.toString()).length <= s / 2 ? 0 : n;
820
821
  }
821
822
  setFoldPlaceholderSources(e) {
822
823
  this.contentElement.__lceFoldPlaceholderSources = e;
823
824
  }
824
825
  }
825
826
  let X = 0;
826
- const W = class O {
827
+ const w = class w {
827
828
  constructor(e, t = {}) {
828
829
  this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.lastKnownCursor = { line: 0, column: 0 }, this.editorInstanceId = ++X, this.decorationHighlightStyleId = `editora-decoration-style-${this.editorInstanceId}`, this.decorationHighlightLimit = 1e3, this.decorationLayers = /* @__PURE__ */ new Map(), this.inlineDecorationHighlightNames = /* @__PURE__ */ new Set(), this.decorationRenderRaf = null, this.decorationMutationObserver = null, this.hasCustomDecorationHighlightSupport = !1, this.lastProgrammaticClipboardInsertAt = 0, this.config = {
829
830
  value: "",
@@ -833,7 +834,7 @@ const W = class O {
833
834
  lineWrapping: !1,
834
835
  lineNumbers: !0,
835
836
  ...t
836
- }, this.textModel = new V(this.config.value), this.view = new Q(e), this.view.setTabSize(this.config.tabSize || 2), this.view.setLineWrapping(!!this.config.lineWrapping), this.view.setLineNumbersVisible(this.config.lineNumbers !== !1), this.hasCustomDecorationHighlightSupport = this.detectCustomHighlightSupport(), this.observeDecorationRelevantMutations(), 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();
837
+ }, this.textModel = new K(this.config.value), this.view = new Y(e), this.view.setTabSize(this.config.tabSize || 2), this.view.setLineWrapping(!!this.config.lineWrapping), this.view.setLineNumbersVisible(this.config.lineNumbers !== !1), this.hasCustomDecorationHighlightSupport = this.detectCustomHighlightSupport(), this.observeDecorationRelevantMutations(), 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();
837
838
  }
838
839
  // Public accessors for extensions
839
840
  getTextModel() {
@@ -847,7 +848,9 @@ const W = class O {
847
848
  }
848
849
  // Register built-in editor commands like undo/redo/insertTab
849
850
  registerBuiltInCommands() {
850
- this.registerCommand("undo", () => this.undo()), this.registerCommand("redo", () => this.redo()), this.registerCommand("insertTab", () => this.insertTab()), this.registerCommand("save", () => {
851
+ this.registerCommand("undo", () => this.undo()), this.registerCommand("redo", () => this.redo()), this.registerCommand("insertTab", () => this.insertTab()), this.registerCommand("outdent", () => {
852
+ this.shiftSelectedLines(!0);
853
+ }), this.registerCommand("save", () => {
851
854
  this.emit("save");
852
855
  });
853
856
  }
@@ -864,23 +867,27 @@ const W = class O {
864
867
  return;
865
868
  }
866
869
  if (t.inputType === "insertFromPaste" || t.inputType === "insertFromPasteAsQuotation" || t.inputType === "insertFromDrop") {
867
- const i = t.dataTransfer, s = this.getPlainTextFromDataTransfer(i);
868
- if (s.length === 0 || (t.preventDefault(), this.pendingInputSnapshot = void 0, Date.now() - this.lastProgrammaticClipboardInsertAt < 80))
870
+ const i = t.dataTransfer, n = this.getPlainTextFromDataTransfer(i);
871
+ if (n.length === 0 || (t.preventDefault(), this.pendingInputSnapshot = void 0, Date.now() - this.lastProgrammaticClipboardInsertAt < 80))
869
872
  return;
870
- this.insertClipboardText(s);
873
+ this.insertClipboardText(n);
871
874
  return;
872
875
  }
873
876
  if (t.inputType === "insertParagraph" || t.inputType === "insertLineBreak") {
874
877
  t.preventDefault(), this.pendingInputSnapshot = void 0, this.insertNewLine();
875
878
  return;
876
879
  }
877
- if (t.inputType === "deleteContentBackward" || t.inputType === "deleteWordBackward") {
878
- t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteBackward();
879
- return;
880
- }
881
- if (t.inputType === "deleteContentForward" || t.inputType === "deleteWordForward") {
882
- t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteForward();
883
- return;
880
+ if (!t.isComposing) {
881
+ const i = w.deletionUnit(t.inputType, "Backward");
882
+ if (i) {
883
+ t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteBackward(i);
884
+ return;
885
+ }
886
+ const n = w.deletionUnit(t.inputType, "Forward");
887
+ if (n) {
888
+ t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteForward(n);
889
+ return;
890
+ }
884
891
  }
885
892
  if (t.inputType === "deleteByCut") {
886
893
  t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteSelection();
@@ -903,41 +910,42 @@ const W = class O {
903
910
  const i = this.getPlainTextFromDataTransfer(t.clipboardData);
904
911
  i.length !== 0 && (t.preventDefault(), this.insertClipboardText(i));
905
912
  }), e.addEventListener("input", () => {
906
- var s;
913
+ var n;
907
914
  const t = this.view.getText(), i = this.textModel.getText();
908
915
  t !== i ? (this.suppressHistory || this.pushUndoSnapshot(
909
- (s = this.pendingInputSnapshot) != null ? s : this.captureHistorySnapshot(i)
916
+ (n = this.pendingInputSnapshot) != null ? n : this.captureHistorySnapshot(i)
910
917
  ), this.pendingInputSnapshot = void 0, this.textModel.setText(t), this.view.syncTrailingNewlineMarkerForText(t), this.hasRenderedFoldPlaceholders() ? this.clearPendingHighlightRender() : (this.clearPendingHighlightRender(), this.highlightTimeout = setTimeout(() => {
911
- const n = this.view.getText();
912
- n !== this.textModel.getText() && this.textModel.setText(n), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
918
+ const s = this.view.getText();
919
+ s !== this.textModel.getText() && this.textModel.setText(s), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
913
920
  }, 300)), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: i }])) : this.pendingInputSnapshot = void 0;
914
921
  }), this.documentSelectionChangeHandler = () => {
915
- var s, n, r;
922
+ var n, s, r;
916
923
  const t = this.syncSelectionCacheFromView();
917
924
  if (!t.isInEditor)
918
925
  return;
919
- const i = (s = t.cursor) != null ? s : this.lastKnownCursor;
926
+ const i = (n = t.cursor) != null ? n : this.lastKnownCursor;
920
927
  this.emit("cursor", {
921
928
  position: i,
922
- anchor: (r = (n = t.range) == null ? void 0 : n.start) != null ? r : i
929
+ anchor: (r = (s = t.range) == null ? void 0 : s.start) != null ? r : i
923
930
  }), this.emit("selection", t.isCollapsed ? void 0 : t.range);
924
931
  }, document.addEventListener("selectionchange", this.documentSelectionChangeHandler), e.addEventListener("keydown", (t) => {
925
932
  this.emit("keydown", t);
926
933
  const i = Array.from(this.extensions.values()).reverse();
927
- for (const s of i)
928
- if (s.onKeyDown && s.onKeyDown(t) === !1) {
934
+ for (const r of i)
935
+ if (r.onKeyDown && r.onKeyDown(t) === !1) {
929
936
  t.preventDefault(), t.stopPropagation();
930
937
  return;
931
938
  }
932
939
  if (t.key === "Tab" && !this.config.readOnly) {
933
- this.insertTab(), t.preventDefault(), t.stopPropagation();
940
+ t.shiftKey ? this.shiftSelectedLines(!0) : this.insertTab(), t.preventDefault(), t.stopPropagation();
934
941
  return;
935
942
  }
936
- if (t.key === "Backspace" && !this.config.readOnly) {
943
+ const n = t.altKey || t.ctrlKey || t.metaKey, s = t.isComposing || t.keyCode === 229;
944
+ if (t.key === "Backspace" && !this.config.readOnly && !n && !s) {
937
945
  this.deleteBackward(), t.preventDefault(), t.stopPropagation();
938
946
  return;
939
947
  }
940
- if (t.key === "Delete" && !this.config.readOnly) {
948
+ if (t.key === "Delete" && !this.config.readOnly && !n && !s) {
941
949
  this.deleteForward(), t.preventDefault(), t.stopPropagation();
942
950
  return;
943
951
  }
@@ -948,16 +956,16 @@ const W = class O {
948
956
  }), e.addEventListener("mousedown", (t) => {
949
957
  this.emit("mousedown", t);
950
958
  const i = Array.from(this.extensions.values()).reverse();
951
- for (const s of i)
952
- if (s.onMouseDown && s.onMouseDown(t) === !1) {
959
+ for (const n of i)
960
+ if (n.onMouseDown && n.onMouseDown(t) === !1) {
953
961
  t.preventDefault(), t.stopPropagation();
954
962
  return;
955
963
  }
956
964
  }), e.addEventListener("contextmenu", (t) => {
957
965
  this.emit("contextmenu", t);
958
966
  const i = Array.from(this.extensions.values()).reverse();
959
- for (const s of i)
960
- if (s.onContextMenu && s.onContextMenu(t) === !1) {
967
+ for (const n of i)
968
+ if (n.onContextMenu && n.onContextMenu(t) === !1) {
961
969
  t.preventDefault(), t.stopPropagation();
962
970
  return;
963
971
  }
@@ -985,7 +993,7 @@ const W = class O {
985
993
  // Emit events to listeners
986
994
  emit(e, ...t) {
987
995
  const i = this.eventListeners.get(e);
988
- i && i.forEach((s) => s(...t));
996
+ i && i.forEach((n) => n(...t));
989
997
  }
990
998
  // State management
991
999
  getValue() {
@@ -1006,16 +1014,16 @@ const W = class O {
1006
1014
  }
1007
1015
  // Cursor & Selection
1008
1016
  getCursor() {
1009
- var i, s, n;
1017
+ var i, n, s;
1010
1018
  const e = this.syncSelectionCacheFromView(), t = (i = e.cursor) != null ? i : this.lastKnownCursor;
1011
1019
  return {
1012
1020
  position: t,
1013
- anchor: (n = (s = e.range) == null ? void 0 : s.start) != null ? n : t
1021
+ anchor: (s = (n = e.range) == null ? void 0 : n.start) != null ? s : t
1014
1022
  };
1015
1023
  }
1016
1024
  setCursor(e) {
1017
- const t = this.textModel.getText(), i = this.clampPositionToText(e, t), s = this.positionToOffsetInText(i, t);
1018
- this.lastKnownCursor = i, this.lastKnownSelection = void 0, this.view.setSelectionOffsets(s), this.emit("cursor", this.getCursor());
1025
+ const t = this.textModel.getText(), i = this.clampPositionToText(e, t), n = this.positionToOffsetInText(i, t);
1026
+ this.lastKnownCursor = i, this.lastKnownSelection = void 0, this.view.setSelectionOffsets(n), this.emit("cursor", this.getCursor());
1019
1027
  }
1020
1028
  getSelection() {
1021
1029
  const e = this.syncSelectionCacheFromView();
@@ -1026,8 +1034,8 @@ const W = class O {
1026
1034
  const t = this.textModel.getText(), i = this.normalizeRange({
1027
1035
  start: this.clampPositionToText(e.start, t),
1028
1036
  end: this.clampPositionToText(e.end, t)
1029
- }), s = this.positionToOffsetInText(i.start, t), n = this.positionToOffsetInText(i.end, t);
1030
- this.lastKnownSelection = i, this.lastKnownCursor = i.end, this.view.setSelectionOffsets(s, n), this.emit("selection", i);
1037
+ }), n = this.positionToOffsetInText(i.start, t), s = this.positionToOffsetInText(i.end, t);
1038
+ this.lastKnownSelection = i, this.lastKnownCursor = i.end, this.view.setSelectionOffsets(n, s), this.emit("selection", i);
1031
1039
  }
1032
1040
  // Configuration
1033
1041
  setTheme(e) {
@@ -1044,8 +1052,8 @@ const W = class O {
1044
1052
  if (i && typeof i.setTheme == "function")
1045
1053
  try {
1046
1054
  i.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
1047
- } catch (s) {
1048
- console.warn("Error applying theme to syntax-highlighting extension", s);
1055
+ } catch (n) {
1056
+ console.warn("Error applying theme to syntax-highlighting extension", n);
1049
1057
  }
1050
1058
  }
1051
1059
  setReadOnly(e) {
@@ -1079,7 +1087,7 @@ const W = class O {
1079
1087
  }
1080
1088
  this.decorationLayers.set(
1081
1089
  i,
1082
- t.map((s) => this.cloneDecoration(s))
1090
+ t.map((n) => this.cloneDecoration(n))
1083
1091
  ), this.scheduleDecorationRender();
1084
1092
  }
1085
1093
  clearDecorations(e) {
@@ -1093,7 +1101,7 @@ const W = class O {
1093
1101
  const t = [];
1094
1102
  for (const i of this.decorationLayers.values())
1095
1103
  t.push(
1096
- ...i.map((s) => this.cloneDecoration(s))
1104
+ ...i.map((n) => this.cloneDecoration(n))
1097
1105
  );
1098
1106
  return t;
1099
1107
  }
@@ -1107,68 +1115,68 @@ const W = class O {
1107
1115
  wholeWord: !1,
1108
1116
  regex: !1,
1109
1117
  ...t
1110
- }, s = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(n), l = i.caseSensitive ? r : r.toLowerCase(), a = i.caseSensitive ? e : e.toLowerCase();
1118
+ }, n = [], s = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(s), l = i.caseSensitive ? r : r.toLowerCase(), a = i.caseSensitive ? e : e.toLowerCase();
1111
1119
  if (i.regex) {
1112
- let d;
1120
+ let c;
1113
1121
  try {
1114
- d = new RegExp(e, i.caseSensitive ? "g" : "gi");
1115
- } catch (u) {
1122
+ c = new RegExp(e, i.caseSensitive ? "g" : "gi");
1123
+ } catch (f) {
1116
1124
  return [];
1117
1125
  }
1118
- let c;
1119
- for (; (c = d.exec(r)) !== null; ) {
1120
- const u = (h = c[0]) != null ? h : "";
1121
- if (u.length === 0) {
1122
- d.lastIndex = c.index + 1;
1126
+ let d;
1127
+ for (; (d = c.exec(r)) !== null; ) {
1128
+ const f = (h = d[0]) != null ? h : "";
1129
+ if (f.length === 0) {
1130
+ c.lastIndex = d.index + 1;
1123
1131
  continue;
1124
1132
  }
1125
- const g = c.index, f = c.index + u.length;
1126
- i.wholeWord && !this.isWholeWordBoundary(r, g, f) || this.pushSearchResultFromOffsets(
1127
- s,
1133
+ const u = d.index, g = d.index + f.length;
1134
+ i.wholeWord && !this.isWholeWordBoundary(r, u, g) || this.pushSearchResultFromOffsets(
1135
+ n,
1136
+ u,
1128
1137
  g,
1129
- f,
1130
1138
  r,
1131
1139
  o
1132
1140
  );
1133
1141
  }
1134
1142
  } else {
1135
- let d = 0, c = l.indexOf(a, d);
1136
- for (; c !== -1; ) {
1137
- const u = c + a.length;
1138
- !i.wholeWord || this.isWholeWordBoundary(r, c, u) ? (this.pushSearchResultFromOffsets(
1139
- s,
1140
- c,
1141
- u,
1143
+ let c = 0, d = l.indexOf(a, c);
1144
+ for (; d !== -1; ) {
1145
+ const f = d + a.length;
1146
+ !i.wholeWord || this.isWholeWordBoundary(r, d, f) ? (this.pushSearchResultFromOffsets(
1147
+ n,
1148
+ d,
1149
+ f,
1142
1150
  r,
1143
1151
  o
1144
- ), d = u) : d = c + 1, c = l.indexOf(a, d);
1152
+ ), c = f) : c = d + 1, d = l.indexOf(a, c);
1145
1153
  }
1146
1154
  }
1147
- return s;
1155
+ return n;
1148
1156
  }
1149
- pushSearchResultFromOffsets(e, t, i, s, n) {
1150
- var h, d;
1151
- const r = (h = n[t]) != null ? h : t, o = (d = n[i]) != null ? d : r, l = this.textModel.offsetToPosition(r), a = this.textModel.offsetToPosition(o);
1157
+ pushSearchResultFromOffsets(e, t, i, n, s) {
1158
+ var h, c;
1159
+ const r = (h = s[t]) != null ? h : t, o = (c = s[i]) != null ? c : r, l = this.textModel.offsetToPosition(r), a = this.textModel.offsetToPosition(o);
1152
1160
  e.push({
1153
1161
  range: { start: l, end: a },
1154
- match: s.substring(t, i)
1162
+ match: n.substring(t, i)
1155
1163
  });
1156
1164
  }
1157
1165
  isWholeWordBoundary(e, t, i) {
1158
- const s = t > 0 ? e[t - 1] : "", n = i < e.length ? e[i] : "";
1159
- return !this.isWordChar(s) && !this.isWordChar(n);
1166
+ const n = t > 0 ? e[t - 1] : "", s = i < e.length ? e[i] : "";
1167
+ return !this.isWordChar(n) && !this.isWordChar(s);
1160
1168
  }
1161
1169
  isWordChar(e) {
1162
1170
  return /^[A-Za-z0-9_]$/.test(e);
1163
1171
  }
1164
1172
  buildSearchTextAndOffsetMap(e) {
1165
1173
  const t = [], i = [0];
1166
- let s = 0;
1167
- for (let n = 0; n < e.length; n++) {
1168
- const r = e[n];
1169
- r === "​" || r === O.CURSOR_SENTINEL || (t.push(r), s += 1, i[s] = n + 1);
1174
+ let n = 0;
1175
+ for (let s = 0; s < e.length; s++) {
1176
+ const r = e[s];
1177
+ r === "​" || r === w.CURSOR_SENTINEL || (t.push(r), n += 1, i[n] = s + 1);
1170
1178
  }
1171
- return i[s] = e.length, {
1179
+ return i[n] = e.length, {
1172
1180
  normalizedText: t.join(""),
1173
1181
  normalizedToRawOffsets: i
1174
1182
  };
@@ -1176,15 +1184,17 @@ const W = class O {
1176
1184
  replace(e, t) {
1177
1185
  const i = this.getValue();
1178
1186
  this.suppressHistory || this.pushUndoSnapshot(this.captureHistorySnapshot(i));
1179
- const s = this.textModel.replaceRange(e, t);
1180
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [s]);
1187
+ const n = this.textModel.replaceRange(e, t);
1188
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [n]);
1181
1189
  }
1182
1190
  replaceAll(e, t, i = {}) {
1183
- const s = this.search(e, i);
1184
- let n = 0;
1185
- for (let r = s.length - 1; r >= 0; r--)
1186
- this.replace(s[r].range, t), n++;
1187
- return n;
1191
+ const n = this.search(e, i);
1192
+ if (n.length === 0) return 0;
1193
+ this.suppressHistory || this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));
1194
+ const s = [];
1195
+ for (let r = n.length - 1; r >= 0; r--)
1196
+ s.push(this.textModel.replaceRange(n[r].range, t));
1197
+ return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", s), n.length;
1188
1198
  }
1189
1199
  // Folding (basic implementation)
1190
1200
  fold(e) {
@@ -1193,14 +1203,14 @@ const W = class O {
1193
1203
  if (t.start.line === t.end.line && t.start.column === t.end.column)
1194
1204
  return;
1195
1205
  const i = this.folds.findIndex(
1196
- (n) => this.isSameFoldRange(n, t)
1197
- ), s = {
1206
+ (s) => this.isSameFoldRange(s, t)
1207
+ ), n = {
1198
1208
  start: t.start,
1199
1209
  end: t.end,
1200
1210
  collapsed: !0,
1201
1211
  level: 0
1202
1212
  };
1203
- i !== -1 ? this.folds[i] = s : (this.folds.push(s), this.folds.sort((n, r) => this.comparePositions(n.start, r.start)));
1213
+ i !== -1 ? this.folds[i] = n : (this.folds.push(n), this.folds.sort((s, r) => this.comparePositions(s.start, r.start)));
1204
1214
  }
1205
1215
  unfold(e) {
1206
1216
  this.clearPendingHighlightRender();
@@ -1232,34 +1242,34 @@ const W = class O {
1232
1242
  (g.querySelector(
1233
1243
  "[data-lce-fold-placeholder]"
1234
1244
  ) || g.textContent !== e) && this.view.setText(e);
1235
- const f = typeof i.highlight == "function" ? i.highlight(e) : i.highlightHTML(e);
1236
- this.view.setHighlightHTML(f), this.view.syncTrailingNewlineMarkerForText(e), this.scheduleDecorationRender();
1245
+ const m = typeof i.highlight == "function" ? i.highlight(e) : i.highlightHTML(e);
1246
+ this.view.setHighlightHTML(m), this.view.syncTrailingNewlineMarkerForText(e), this.scheduleDecorationRender();
1237
1247
  return;
1238
1248
  }
1239
1249
  const s = !t && !this.expectingProgrammaticCursor;
1240
- let n, r, o, l;
1241
- const a = this.view.getSelectionState(), h = a.isInEditor && !!a.cursor;
1242
- (t || s) && h && (n = a.isCollapsed ? void 0 : a.range, r = this.textModel.positionToOffset(a.cursor), n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end)));
1243
- const d = h && (t || s) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), c = d ? this.insertSentinelAtOffset(e, r) : e, u = typeof i.highlight == "function" ? i.highlight(c) : i.highlightHTML(c);
1244
- typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(u) : this.view.setHTML(u), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && h && requestAnimationFrame(() => {
1250
+ let r, o, l, a;
1251
+ const h = this.view.getSelectionState(), c = h.isInEditor && !!h.cursor;
1252
+ (t || s) && c && (r = h.isCollapsed ? void 0 : h.range, o = this.textModel.positionToOffset(h.cursor), r && (l = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)));
1253
+ const d = c && (t || s) && !r && o !== void 0 && this.hasCollapsedSelectionInEditor(), f = d ? this.insertSentinelAtOffset(e, o) : e, u = typeof i.highlight == "function" ? i.highlight(f) : i.highlightHTML(f);
1254
+ typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(u) : this.view.setHTML(u), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && c && requestAnimationFrame(() => {
1245
1255
  try {
1246
1256
  if (d && this.restoreCursorFromSentinel()) {
1247
1257
  this.view.ensureCaretVisible();
1248
1258
  return;
1249
1259
  }
1250
- if (n && (o !== void 0 || l !== void 0)) {
1251
- const g = o !== void 0 ? o : r, f = l !== void 0 ? l : r, p = Math.min(g, f), m = Math.max(g, f), x = this.textModel.offsetToPosition(p), v = this.textModel.offsetToPosition(m);
1252
- this.view.setSelectionRange({ start: x, end: v });
1253
- } else if (r !== void 0) {
1254
- const g = this.textModel.offsetToPosition(r);
1260
+ if (r && (l !== void 0 || a !== void 0)) {
1261
+ const g = l !== void 0 ? l : o, p = a !== void 0 ? a : o, m = Math.min(g, p), y = Math.max(g, p), T = this.textModel.offsetToPosition(m), S = this.textModel.offsetToPosition(y);
1262
+ this.view.setSelectionRange({ start: T, end: S });
1263
+ } else if (o !== void 0) {
1264
+ const g = this.textModel.offsetToPosition(o);
1255
1265
  this.view.setCursorPosition(g);
1256
1266
  }
1257
1267
  } catch (g) {
1258
1268
  }
1259
1269
  }), this.scheduleDecorationRender();
1260
1270
  return;
1261
- } catch (s) {
1262
- console.warn("Syntax highlighting failed, falling back to plain text", s);
1271
+ } catch (n) {
1272
+ console.warn("Syntax highlighting failed, falling back to plain text", n);
1263
1273
  }
1264
1274
  this.view.setText(e), this.scheduleDecorationRender();
1265
1275
  }
@@ -1277,28 +1287,28 @@ const W = class O {
1277
1287
  const t = e.getRangeAt(0), i = this.view.getContentElement();
1278
1288
  if (!i.contains(t.commonAncestorContainer))
1279
1289
  return;
1280
- const s = t.cloneRange();
1281
- return s.selectNodeContents(i), s.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(s.toString()).length;
1290
+ const n = t.cloneRange();
1291
+ return n.selectNodeContents(i), n.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(n.toString()).length;
1282
1292
  }
1283
1293
  stripVirtualMarkers(e) {
1284
- return e.replace(/\u200B/g, "").split(O.CURSOR_SENTINEL).join("");
1294
+ return e.replace(/\u200B/g, "").split(w.CURSOR_SENTINEL).join("");
1285
1295
  }
1286
1296
  insertSentinelAtOffset(e, t) {
1287
1297
  const i = Math.max(0, Math.min(t, e.length));
1288
- return e.slice(0, i) + O.CURSOR_SENTINEL + e.slice(i);
1298
+ return e.slice(0, i) + w.CURSOR_SENTINEL + e.slice(i);
1289
1299
  }
1290
1300
  restoreCursorFromSentinel() {
1291
1301
  var o;
1292
1302
  const e = this.view.getContentElement(), t = window.getSelection(), i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
1293
- let s = i.nextNode(), n = null, r = 0;
1294
- for (; s; ) {
1295
- const l = (o = s.textContent) != null ? o : "", a = l.indexOf(O.CURSOR_SENTINEL);
1296
- a !== -1 && (n || (n = s, r = a), s.textContent = l.split(O.CURSOR_SENTINEL).join("")), s = i.nextNode();
1303
+ let n = i.nextNode(), s = null, r = 0;
1304
+ for (; n; ) {
1305
+ const l = (o = n.textContent) != null ? o : "", a = l.indexOf(w.CURSOR_SENTINEL);
1306
+ a !== -1 && (s || (s = n, r = a), n.textContent = l.split(w.CURSOR_SENTINEL).join("")), n = i.nextNode();
1297
1307
  }
1298
- if (!n || !t) return !1;
1308
+ if (!s || !t) return !1;
1299
1309
  try {
1300
1310
  const l = document.createRange();
1301
- return l.setStart(n, r), l.collapse(!0), t.removeAllRanges(), t.addRange(l), !0;
1311
+ return l.setStart(s, r), l.collapse(!0), t.removeAllRanges(), t.addRange(l), !0;
1302
1312
  } catch (l) {
1303
1313
  return !1;
1304
1314
  }
@@ -1339,25 +1349,68 @@ const W = class O {
1339
1349
  }
1340
1350
  // Insert a tab character or spaces at current cursor
1341
1351
  insertTab() {
1342
- if (this.config.readOnly) return;
1352
+ if (this.config.readOnly || this.shiftSelectedLines(!1)) return;
1343
1353
  const e = " ".repeat(this.config.tabSize || 2);
1344
1354
  this.replaceSelectionWithText(e);
1345
1355
  }
1356
+ /**
1357
+ * Tab / Shift+Tab over whole lines. Tab only applies when the selection spans lines (a caret
1358
+ * or single-line selection keeps the plain "insert a tab" behaviour); Shift+Tab always
1359
+ * outdents the line(s) it touches. Returns false when the caller should fall back to inserting.
1360
+ * The edit is one replace, so it is one undo step, and the selection is kept on the same text.
1361
+ */
1362
+ shiftSelectedLines(e) {
1363
+ if (this.config.readOnly) return !1;
1364
+ const t = this.textModel.getText(), { startOffset: i, endOffset: n } = this.getActiveSelectionOffsets(t), s = Math.min(i, n), r = Math.max(i, n);
1365
+ if (!e && !t.slice(s, r).includes(`
1366
+ `)) return !1;
1367
+ const o = " ".repeat(this.config.tabSize || 2), l = t.lastIndexOf(`
1368
+ `, s - 1) + 1, a = r > s && t[r - 1] === `
1369
+ ` ? r - 1 : r, h = t.indexOf(`
1370
+ `, a), c = h === -1 ? t.length : h, d = t.slice(l, c).split(`
1371
+ `);
1372
+ let f = 0, u = 0;
1373
+ const g = d.map((y, T) => {
1374
+ let S = y;
1375
+ if (!e)
1376
+ S = y.length === 0 ? y : o + y;
1377
+ else if (y.startsWith(" "))
1378
+ S = y.slice(1);
1379
+ else {
1380
+ const C = /^ */.exec(y)[0].length;
1381
+ S = y.slice(Math.min(C, o.length));
1382
+ }
1383
+ const v = S.length - y.length;
1384
+ return T === 0 && (f = v), u += v, S;
1385
+ });
1386
+ if (u === 0) return !0;
1387
+ this.replaceOffsetsWithText(l, c, g.join(`
1388
+ `));
1389
+ const p = Math.max(l, s + f), m = Math.max(p, r + u);
1390
+ return s === r ? this.setCursor(this.textModel.offsetToPosition(p)) : this.setSelection({
1391
+ start: this.textModel.offsetToPosition(p),
1392
+ end: this.textModel.offsetToPosition(m)
1393
+ }), !0;
1394
+ }
1346
1395
  // Insert a newline at current cursor position
1347
1396
  insertNewLine() {
1348
1397
  this.config.readOnly || this.replaceSelectionWithText(`
1349
1398
  `);
1350
1399
  }
1351
- deleteBackward() {
1352
- this.config.readOnly || this.deleteUsingDirection("backward");
1400
+ deleteBackward(e = "char") {
1401
+ this.config.readOnly || this.deleteUsingDirection("backward", e);
1353
1402
  }
1354
- deleteForward() {
1355
- this.config.readOnly || this.deleteUsingDirection("forward");
1403
+ deleteForward(e = "char") {
1404
+ this.config.readOnly || this.deleteUsingDirection("forward", e);
1405
+ }
1406
+ /** Map an InputEvent.inputType to the unit it deletes, or null when it isn't a delete in that direction. */
1407
+ static deletionUnit(e, t) {
1408
+ return e === `deleteContent${t}` ? "char" : e === `deleteWord${t}` ? "word" : e === `deleteSoftLine${t}` || e === `deleteHardLine${t}` ? "line" : null;
1356
1409
  }
1357
1410
  deleteSelection() {
1358
1411
  if (this.config.readOnly) return;
1359
- const e = this.textModel.getText(), { startOffset: t, endOffset: i } = this.getActiveSelectionOffsets(e), s = Math.min(t, i), n = Math.max(t, i);
1360
- s !== n && this.replaceOffsetsWithText(s, n, "");
1412
+ const e = this.textModel.getText(), { startOffset: t, endOffset: i } = this.getActiveSelectionOffsets(e), n = Math.min(t, i), s = Math.max(t, i);
1413
+ n !== s && this.replaceOffsetsWithText(n, s, "");
1361
1414
  }
1362
1415
  // Events
1363
1416
  on(e, t) {
@@ -1367,8 +1420,8 @@ const W = class O {
1367
1420
  if (!this.eventListeners.has(e)) return;
1368
1421
  const i = this.eventListeners.get(e);
1369
1422
  if (t) {
1370
- const s = i.indexOf(t);
1371
- s !== -1 && i.splice(s, 1);
1423
+ const n = i.indexOf(t);
1424
+ n !== -1 && i.splice(n, 1);
1372
1425
  } else
1373
1426
  i.length = 0;
1374
1427
  }
@@ -1379,12 +1432,12 @@ const W = class O {
1379
1432
  return e.line !== t.line ? e.line - t.line : e.column - t.column;
1380
1433
  }
1381
1434
  captureHistorySnapshot(e = this.textModel.getText()) {
1382
- const t = this.view.getSelectionState(), i = t.isInEditor && !t.isCollapsed ? t.range : void 0, s = t.isInEditor && t.cursor ? t.cursor : void 0, n = i != null ? i : this.lastKnownSelection, r = s != null ? s : this.lastKnownCursor, o = this.clampPositionToText(r, e), l = {
1435
+ const t = this.view.getSelectionState(), i = t.isInEditor && !t.isCollapsed ? t.range : void 0, n = t.isInEditor && t.cursor ? t.cursor : void 0, s = i != null ? i : this.lastKnownSelection, r = n != null ? n : this.lastKnownCursor, o = this.clampPositionToText(r, e), l = {
1383
1436
  text: e,
1384
1437
  cursorOffset: this.positionToOffsetInText(o, e)
1385
1438
  };
1386
- if (n) {
1387
- const a = this.clampPositionToText(n.start, e), h = this.clampPositionToText(n.end, e);
1439
+ if (s) {
1440
+ const a = this.clampPositionToText(s.start, e), h = this.clampPositionToText(s.end, e);
1388
1441
  l.anchorOffset = this.positionToOffsetInText(a, e), l.focusOffset = this.positionToOffsetInText(h, e);
1389
1442
  }
1390
1443
  return l;
@@ -1393,10 +1446,10 @@ const W = class O {
1393
1446
  this.setValue(e.text), requestAnimationFrame(() => {
1394
1447
  try {
1395
1448
  if (e.anchorOffset !== void 0 && e.focusOffset !== void 0 && e.anchorOffset !== e.focusOffset) {
1396
- const t = Math.min(e.anchorOffset, e.focusOffset), i = Math.max(e.anchorOffset, e.focusOffset);
1449
+ const i = Math.min(e.anchorOffset, e.focusOffset), n = Math.max(e.anchorOffset, e.focusOffset);
1397
1450
  this.setSelection({
1398
- start: this.textModel.offsetToPosition(t),
1399
- end: this.textModel.offsetToPosition(i)
1451
+ start: this.textModel.offsetToPosition(i),
1452
+ end: this.textModel.offsetToPosition(n)
1400
1453
  });
1401
1454
  return;
1402
1455
  }
@@ -1414,23 +1467,23 @@ const W = class O {
1414
1467
  clampPositionToText(e, t) {
1415
1468
  var r, o;
1416
1469
  const i = t.split(`
1417
- `), s = Math.max(0, Math.min(e.line, i.length - 1)), n = Math.max(
1470
+ `), n = Math.max(0, Math.min(e.line, i.length - 1)), s = Math.max(
1418
1471
  0,
1419
- Math.min(e.column, (o = (r = i[s]) == null ? void 0 : r.length) != null ? o : 0)
1472
+ Math.min(e.column, (o = (r = i[n]) == null ? void 0 : r.length) != null ? o : 0)
1420
1473
  );
1421
1474
  return {
1422
- line: s,
1423
- column: n
1475
+ line: n,
1476
+ column: s
1424
1477
  };
1425
1478
  }
1426
1479
  positionToOffsetInText(e, t) {
1427
1480
  var r, o;
1428
1481
  const i = t.split(`
1429
- `), s = this.clampPositionToText(e, t);
1430
- let n = 0;
1431
- for (let l = 0; l < s.line; l++)
1432
- n += ((o = (r = i[l]) == null ? void 0 : r.length) != null ? o : 0) + 1;
1433
- return n + s.column;
1482
+ `), n = this.clampPositionToText(e, t);
1483
+ let s = 0;
1484
+ for (let l = 0; l < n.line; l++)
1485
+ s += ((o = (r = i[l]) == null ? void 0 : r.length) != null ? o : 0) + 1;
1486
+ return s + n.column;
1434
1487
  }
1435
1488
  clearPendingHighlightRender() {
1436
1489
  this.highlightTimeout && (clearTimeout(this.highlightTimeout), this.highlightTimeout = null);
@@ -1440,7 +1493,7 @@ const W = class O {
1440
1493
  }
1441
1494
  replaceSelectionWithText(e) {
1442
1495
  const t = e.replace(/\r\n?/g, `
1443
- `), i = this.textModel.getText(), { startOffset: s, endOffset: n } = this.getActiveSelectionOffsets(i), r = Math.max(0, Math.min(s, n)), o = Math.max(0, Math.max(s, n));
1496
+ `), i = this.textModel.getText(), { startOffset: n, endOffset: s } = this.getActiveSelectionOffsets(i), r = Math.max(0, Math.min(n, s)), o = Math.max(0, Math.max(n, s));
1444
1497
  return this.replaceOffsetsWithText(r, o, t);
1445
1498
  }
1446
1499
  insertClipboardText(e) {
@@ -1493,7 +1546,7 @@ const W = class O {
1493
1546
  "TABLE",
1494
1547
  "TR",
1495
1548
  "UL"
1496
- ]), s = (o) => {
1549
+ ]), n = (o) => {
1497
1550
  var l;
1498
1551
  for (let a = o.length - 1; a >= 0; a--) {
1499
1552
  const h = (l = o[a]) != null ? l : "";
@@ -1502,13 +1555,13 @@ const W = class O {
1502
1555
  `);
1503
1556
  }
1504
1557
  return !1;
1505
- }, n = (o, l) => {
1558
+ }, s = (o, l) => {
1506
1559
  if (o instanceof Text) {
1507
1560
  l.push(o.data);
1508
1561
  return;
1509
1562
  }
1510
1563
  if (!(o instanceof HTMLElement)) {
1511
- o.childNodes.forEach((h) => n(h, l));
1564
+ o.childNodes.forEach((h) => s(h, l));
1512
1565
  return;
1513
1566
  }
1514
1567
  if (o.tagName === "BR") {
@@ -1517,11 +1570,11 @@ const W = class O {
1517
1570
  return;
1518
1571
  }
1519
1572
  const a = i.has(o.tagName);
1520
- a && l.length > 0 && !s(l) && l.push(`
1521
- `), o.childNodes.forEach((h) => n(h, l)), a && !s(l) && l.push(`
1573
+ a && l.length > 0 && !n(l) && l.push(`
1574
+ `), o.childNodes.forEach((h) => s(h, l)), a && !n(l) && l.push(`
1522
1575
  `);
1523
1576
  }, r = [];
1524
- return t.body.childNodes.forEach((o) => n(o, r)), r.join("").replace(/\n{3,}/g, `
1577
+ return t.body.childNodes.forEach((o) => s(o, r)), r.join("").replace(/\n{3,}/g, `
1525
1578
 
1526
1579
  `).replace(/[ \t]+\n/g, `
1527
1580
  `).trimEnd();
@@ -1544,36 +1597,114 @@ const W = class O {
1544
1597
  endOffset: i
1545
1598
  };
1546
1599
  }
1547
- deleteUsingDirection(e) {
1548
- const t = this.textModel.getText(), { startOffset: i, endOffset: s } = this.getActiveSelectionOffsets(t), n = Math.min(i, s), r = Math.max(i, s);
1549
- if (n !== r) {
1550
- this.replaceOffsetsWithText(n, r, "");
1600
+ deleteUsingDirection(e, t = "char") {
1601
+ const i = this.textModel.getText(), { startOffset: n, endOffset: s } = this.getActiveSelectionOffsets(i), r = Math.min(n, s), o = Math.max(n, s);
1602
+ if (r !== o) {
1603
+ this.replaceOffsetsWithText(r, o, "");
1551
1604
  return;
1552
1605
  }
1553
1606
  if (e === "backward") {
1554
- if (n === 0)
1607
+ if (r === 0)
1555
1608
  return;
1556
- this.replaceOffsetsWithText(n - 1, n, "");
1609
+ const a = w.deletionBoundary(i, r, "backward", t);
1610
+ this.replaceOffsetsWithText(a, r, "");
1557
1611
  return;
1558
1612
  }
1559
- r >= t.length || this.replaceOffsetsWithText(r, r + 1, "");
1613
+ if (o >= i.length)
1614
+ return;
1615
+ const l = w.deletionBoundary(i, o, "forward", t);
1616
+ this.replaceOffsetsWithText(o, l, "");
1617
+ }
1618
+ static getGraphemeSegmenter() {
1619
+ if (w.graphemeSegmenter === void 0) {
1620
+ const e = Intl.Segmenter;
1621
+ w.graphemeSegmenter = e ? new e(void 0, { granularity: "grapheme" }) : null;
1622
+ }
1623
+ return w.graphemeSegmenter;
1624
+ }
1625
+ /**
1626
+ * Where a deletion of `unit` starting at `offset` ends. Characters are whole grapheme
1627
+ * clusters (an emoji is two UTF-16 units, a flag or ZWJ sequence several), so Backspace
1628
+ * never leaves half a surrogate pair behind - that used to turn "a😀b" into "a\uD83Db",
1629
+ * which is invalid text once saved.
1630
+ */
1631
+ static deletionBoundary(e, t, i, n) {
1632
+ const s = (d) => /[A-Za-z0-9_]/.test(d), r = (d) => d === " " || d === " ";
1633
+ if (n === "line") {
1634
+ if (i === "backward") {
1635
+ const u = e.lastIndexOf(`
1636
+ `, t - 1) + 1;
1637
+ return u === t ? t - 1 : u;
1638
+ }
1639
+ const d = e.indexOf(`
1640
+ `, t), f = d === -1 ? e.length : d;
1641
+ return f === t ? Math.min(e.length, t + 1) : f;
1642
+ }
1643
+ if (n === "word") {
1644
+ let d = t;
1645
+ if (i === "backward") {
1646
+ if (e[d - 1] === `
1647
+ `) return d - 1;
1648
+ for (; d > 0 && r(e[d - 1]); ) d--;
1649
+ if (d > 0 && e[d - 1] !== `
1650
+ `) {
1651
+ const f = s(e[d - 1]);
1652
+ for (; d > 0 && e[d - 1] !== `
1653
+ ` && !r(e[d - 1]) && s(e[d - 1]) === f; ) d--;
1654
+ }
1655
+ return d;
1656
+ }
1657
+ if (e[d] === `
1658
+ `) return d + 1;
1659
+ for (; d < e.length && r(e[d]); ) d++;
1660
+ if (d < e.length && e[d] !== `
1661
+ `) {
1662
+ const f = s(e[d]);
1663
+ for (; d < e.length && e[d] !== `
1664
+ ` && !r(e[d]) && s(e[d]) === f; ) d++;
1665
+ }
1666
+ return d;
1667
+ }
1668
+ if (i === "backward") {
1669
+ const d = e.lastIndexOf(`
1670
+ `, t - 1) + 1;
1671
+ if (d === t) return t - 1;
1672
+ const f = w.getGraphemeSegmenter();
1673
+ if (f) {
1674
+ let p = 1;
1675
+ for (const { segment: m } of f.segment(e.slice(d, t))) p = m.length;
1676
+ return t - p;
1677
+ }
1678
+ const u = e.charCodeAt(t - 1), g = t >= 2 ? e.charCodeAt(t - 2) : 0;
1679
+ return u >= 56320 && u <= 57343 && g >= 55296 && g <= 56319 ? t - 2 : t - 1;
1680
+ }
1681
+ if (e[t] === `
1682
+ `) return t + 1;
1683
+ const o = e.indexOf(`
1684
+ `, t), l = o === -1 ? e.length : o, a = w.getGraphemeSegmenter();
1685
+ if (a) {
1686
+ for (const { segment: d } of a.segment(e.slice(t, l))) return t + d.length;
1687
+ return t + 1;
1688
+ }
1689
+ const h = e.charCodeAt(t), c = t + 1 < e.length ? e.charCodeAt(t + 1) : 0;
1690
+ return h >= 55296 && h <= 56319 && c >= 56320 && c <= 57343 ? t + 2 : t + 1;
1560
1691
  }
1561
1692
  replaceOffsetsWithText(e, t, i) {
1562
- var u;
1693
+ var f;
1563
1694
  this.ensureEditableSurfaceIsUnfolded();
1564
- const s = i.replace(/\r\n?/g, `
1565
- `), n = this.textModel.getText(), r = (u = this.pendingInputSnapshot) != null ? u : this.captureHistorySnapshot(n), o = Math.max(0, Math.min(e, n.length)), l = Math.max(0, Math.min(t, n.length)), a = Math.min(o, l), h = Math.max(o, l), d = this.textModel.replaceRange(
1695
+ const n = i.replace(/\r\n?/g, `
1696
+ `), s = this.textModel.getText(), r = (f = this.pendingInputSnapshot) != null ? f : this.captureHistorySnapshot(s), o = Math.max(0, Math.min(e, s.length)), l = Math.max(0, Math.min(t, s.length)), a = Math.min(o, l), h = Math.max(o, l), c = this.textModel.replaceRange(
1566
1697
  {
1567
1698
  start: this.textModel.offsetToPosition(a),
1568
1699
  end: this.textModel.offsetToPosition(h)
1569
1700
  },
1570
- s
1701
+ n
1571
1702
  );
1572
1703
  this.pendingInputSnapshot = void 0, this.suppressHistory || this.pushUndoSnapshot(r);
1573
- const c = a + s.length;
1574
- return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.textModel.getText(), !1), this.setCursor(this.textModel.offsetToPosition(c)), setTimeout(() => {
1704
+ const d = a + n.length;
1705
+ return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.textModel.getText(), !1), this.setCursor(this.textModel.offsetToPosition(d)), setTimeout(() => {
1575
1706
  this.expectingProgrammaticCursor = !1;
1576
- }, 20), this.emit("change", [d]), d;
1707
+ }, 20), this.emit("change", [c]), c;
1577
1708
  }
1578
1709
  ensureEditableSurfaceIsUnfolded() {
1579
1710
  !this.hasRenderedFoldPlaceholders() && this.folds.length === 0 || (this.clearPendingHighlightRender(), this.folds = [], this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.textModel.getText(), !1), setTimeout(() => {
@@ -1606,9 +1737,9 @@ const W = class O {
1606
1737
  return;
1607
1738
  }
1608
1739
  const e = [], t = [], i = [];
1609
- for (const [s, n] of this.decorationLayers.entries())
1610
- for (const r of n) {
1611
- const o = `${s}::${r.id}`;
1740
+ for (const [n, s] of this.decorationLayers.entries())
1741
+ for (const r of s) {
1742
+ const o = `${n}::${r.id}`;
1612
1743
  if (r.type === "line") {
1613
1744
  e.push({
1614
1745
  ...r,
@@ -1661,28 +1792,28 @@ const W = class O {
1661
1792
  }
1662
1793
  if (this.clearInlineDecorationHighlights(), e.length === 0)
1663
1794
  return;
1664
- const s = this.textModel.getText(), n = [];
1795
+ const n = this.textModel.getText(), s = [];
1665
1796
  let r = 0;
1666
1797
  for (const l of e) {
1667
1798
  if (r >= this.decorationHighlightLimit)
1668
1799
  break;
1669
- const a = this.normalizeInlineDecoration(l, s);
1800
+ const a = this.normalizeInlineDecoration(l, n);
1670
1801
  if (!a)
1671
1802
  continue;
1672
1803
  const h = this.view.createDomRangeFromRange(a.range);
1673
1804
  if (!h)
1674
1805
  continue;
1675
- const d = this.buildInlineDecorationHighlightName(
1806
+ const c = this.buildInlineDecorationHighlightName(
1676
1807
  a.id
1677
1808
  );
1678
- t.highlights.set(d, new i(h)), this.inlineDecorationHighlightNames.add(d), n.push(`
1679
- ::highlight(${d}) {
1809
+ t.highlights.set(c, new i(h)), this.inlineDecorationHighlightNames.add(c), s.push(`
1810
+ ::highlight(${c}) {
1680
1811
  ${this.serializeInlineDecorationStyle(a.style)}
1681
1812
  }
1682
1813
  `), r += 1;
1683
1814
  }
1684
1815
  const o = this.ensureDecorationHighlightStyleNode();
1685
- o.textContent = n.join(`
1816
+ o.textContent = s.join(`
1686
1817
  `);
1687
1818
  }
1688
1819
  normalizeInlineDecoration(e, t) {
@@ -1700,11 +1831,11 @@ const W = class O {
1700
1831
  try {
1701
1832
  const i = CSS;
1702
1833
  if (i.highlights)
1703
- for (const s of this.inlineDecorationHighlightNames)
1704
- i.highlights.delete(s);
1834
+ for (const n of this.inlineDecorationHighlightNames)
1835
+ i.highlights.delete(n);
1705
1836
  } catch (i) {
1706
1837
  }
1707
- if (this.inlineDecorationHighlightNames.clear(), typeof document > "u")
1838
+ if (this.inlineDecorationHighlightNames.clear(), typeof document == "undefined")
1708
1839
  return;
1709
1840
  const t = document.getElementById(this.decorationHighlightStyleId);
1710
1841
  if (e) {
@@ -1720,7 +1851,7 @@ const W = class O {
1720
1851
  return e || (e = document.createElement("style"), e.id = this.decorationHighlightStyleId, document.head.appendChild(e), e);
1721
1852
  }
1722
1853
  observeDecorationRelevantMutations() {
1723
- typeof MutationObserver > "u" || (this.decorationMutationObserver = new MutationObserver(() => {
1854
+ typeof MutationObserver != "undefined" && (this.decorationMutationObserver = new MutationObserver(() => {
1724
1855
  this.decorationLayers.size !== 0 && this.scheduleDecorationRender();
1725
1856
  }), this.decorationMutationObserver.observe(this.view.getContentElement(), {
1726
1857
  childList: !0,
@@ -1730,7 +1861,7 @@ const W = class O {
1730
1861
  }
1731
1862
  detectCustomHighlightSupport() {
1732
1863
  try {
1733
- if (typeof CSS > "u" || typeof window > "u")
1864
+ if (typeof CSS == "undefined" || typeof window == "undefined")
1734
1865
  return !1;
1735
1866
  const e = CSS, t = window.Highlight;
1736
1867
  return !!e.highlights && !!t;
@@ -1745,7 +1876,8 @@ const W = class O {
1745
1876
  return e.toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
1746
1877
  }
1747
1878
  serializeInlineDecorationStyle(e) {
1748
- return this.serializeStyleObject(e) || "background-color: var(--lce-inline-decoration-bg, rgba(86, 156, 214, 0.18)); border-radius: 2px;";
1879
+ const t = this.serializeStyleObject(e);
1880
+ return t || "background-color: var(--lce-inline-decoration-bg, rgba(86, 156, 214, 0.18)); border-radius: 2px;";
1749
1881
  }
1750
1882
  serializeStyleObject(e) {
1751
1883
  return e ? Object.entries(e).filter(([, t]) => typeof t == "string" && t.length > 0).map(([t, i]) => `${this.toKebabCase(t)}: ${i};`).join(" ") : "";
@@ -1767,8 +1899,8 @@ const W = class O {
1767
1899
  };
1768
1900
  }
1769
1901
  };
1770
- W.CURSOR_SENTINEL = "";
1771
- let Y = W;
1902
+ w.CURSOR_SENTINEL = "";
1903
+ let V = w;
1772
1904
  class J {
1773
1905
  constructor(e) {
1774
1906
  this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
@@ -1783,11 +1915,11 @@ class J {
1783
1915
  return this.editor.executeCommand(t.command), e.preventDefault(), e.stopPropagation(), !1;
1784
1916
  }
1785
1917
  findMatchingBinding(e) {
1786
- const { key: t, ctrlKey: i, altKey: s, shiftKey: n, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
1918
+ const { key: t, ctrlKey: i, altKey: n, shiftKey: s, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
1787
1919
  if (!l) return null;
1788
1920
  for (const a of l) {
1789
- const h = a.ctrlKey === void 0 || a.ctrlKey === i, d = a.altKey === void 0 || a.altKey === s, c = a.shiftKey === void 0 || a.shiftKey === n, u = a.metaKey === void 0 || a.metaKey === r;
1790
- if (h && d && c && u)
1921
+ const h = a.ctrlKey === void 0 || a.ctrlKey === i, c = a.altKey === void 0 || a.altKey === n, d = a.shiftKey === void 0 || a.shiftKey === s, f = a.metaKey === void 0 || a.metaKey === r;
1922
+ if (h && c && d && f)
1791
1923
  return a;
1792
1924
  }
1793
1925
  return null;
@@ -1798,13 +1930,13 @@ class J {
1798
1930
  }
1799
1931
  getDefaultKeymap() {
1800
1932
  const e = {};
1801
- 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"), this.addBinding(e, "f", { altKey: !0, shiftKey: !0 }, "formatDocument"), e;
1933
+ 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", { shiftKey: !0 }, "outdent"), this.addBinding(e, "tab", { shiftKey: !1, ctrlKey: !1, altKey: !1, metaKey: !1 }, "insertTab"), this.addBinding(e, "t", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "toggleTheme"), this.addBinding(e, "f", { altKey: !0, shiftKey: !0 }, "formatDocument"), e;
1802
1934
  }
1803
- addBinding(e, t, i, s) {
1804
- const n = t.toLowerCase();
1805
- e[n] || (e[n] = []), e[n].push({
1806
- key: n,
1807
- command: s,
1935
+ addBinding(e, t, i, n) {
1936
+ const s = t.toLowerCase();
1937
+ e[s] || (e[s] = []), e[s].push({
1938
+ key: s,
1939
+ command: n,
1808
1940
  ...i
1809
1941
  });
1810
1942
  }
@@ -1821,7 +1953,7 @@ class J {
1821
1953
  }
1822
1954
  removeKeyBinding(e, t) {
1823
1955
  const i = e.toLowerCase();
1824
- 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];
1956
+ t ? this.keymap[i] && (this.keymap[i] = this.keymap[i].filter((n) => n.command !== t), this.keymap[i].length === 0 && delete this.keymap[i]) : delete this.keymap[i];
1825
1957
  }
1826
1958
  getKeymap() {
1827
1959
  return { ...this.keymap };
@@ -1829,8 +1961,8 @@ class J {
1829
1961
  getBindingsForCommand(e) {
1830
1962
  const t = [];
1831
1963
  for (const i in this.keymap)
1832
- for (const s of this.keymap[i])
1833
- s.command === e && t.push({ ...s });
1964
+ for (const n of this.keymap[i])
1965
+ n.command === e && t.push({ ...n });
1834
1966
  return t;
1835
1967
  }
1836
1968
  getPlatformInfo() {
@@ -1843,7 +1975,7 @@ class J {
1843
1975
  this.keymap = {}, this.editor = null;
1844
1976
  }
1845
1977
  }
1846
- const U = class z {
1978
+ const A = class A {
1847
1979
  constructor() {
1848
1980
  this.name = "transaction", this.transactions = [];
1849
1981
  }
@@ -1855,9 +1987,9 @@ const U = class z {
1855
1987
  effects: [],
1856
1988
  annotations: []
1857
1989
  };
1858
- this.transactions.push(i), this.transactions.length > z.MAX_TRANSACTIONS && this.transactions.splice(
1990
+ this.transactions.push(i), this.transactions.length > A.MAX_TRANSACTIONS && this.transactions.splice(
1859
1991
  0,
1860
- this.transactions.length - z.MAX_TRANSACTIONS
1992
+ this.transactions.length - A.MAX_TRANSACTIONS
1861
1993
  );
1862
1994
  });
1863
1995
  }
@@ -1868,9 +2000,9 @@ const U = class z {
1868
2000
  this.transactions = [];
1869
2001
  }
1870
2002
  };
1871
- U.MAX_TRANSACTIONS = 200;
1872
- let ee = U;
1873
- class te {
2003
+ A.MAX_TRANSACTIONS = 200;
2004
+ let W = A;
2005
+ class ee {
1874
2006
  constructor() {
1875
2007
  this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
1876
2008
  }
@@ -1899,7 +2031,7 @@ class te {
1899
2031
  this.lineNumbersElement = null, this.editor = null;
1900
2032
  }
1901
2033
  }
1902
- class ie {
2034
+ class te {
1903
2035
  constructor() {
1904
2036
  this.name = "theme", this.editor = null, this.currentTheme = "dark";
1905
2037
  }
@@ -1924,7 +2056,7 @@ class ie {
1924
2056
  this.editor = null;
1925
2057
  }
1926
2058
  }
1927
- class se {
2059
+ class ie {
1928
2060
  constructor() {
1929
2061
  this.name = "read-only", this.editor = null, this.isReadOnly = !1;
1930
2062
  }
@@ -1952,7 +2084,7 @@ class se {
1952
2084
  }
1953
2085
  }
1954
2086
  let ne = 0;
1955
- const K = class y {
2087
+ const x = class x {
1956
2088
  constructor(e = {}) {
1957
2089
  this.name = "search", this.editor = null, this.searchUI = null, this.isVisible = !1, this.currentResults = [], this.currentIndex = -1, this.searchDebounceTimer = null, this.liveRefreshTimer = null, this.statusResetTimer = null, this.statusFreezeUntil = 0, this.findInput = null, this.replaceInputEl = null, this.statusDiv = null, this.modeDiv = null, this.caseSensitiveInput = null, this.wholeWordInput = null, this.regexInput = null, this.currentQuery = "", this.savedCursor = null, this.editorChangeHandler = null, this.searchOptions = {
1958
2090
  caseSensitive: !1,
@@ -1991,73 +2123,73 @@ const K = class y {
1991
2123
  if (!this.editor) return;
1992
2124
  const e = this.editor.getView().getContentElement(), t = e.closest(
1993
2125
  this.editorContainerSelector
1994
- ), i = t == null ? void 0 : t.parentElement, s = e.closest(".rte-source-editor-modal") || i || t || e.parentElement;
1995
- if (!s) return;
1996
- window.getComputedStyle(s).position === "static" && (s.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = y.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
1997
- <div class="${y.css.row}">
1998
- <input type="text" class="${y.css.findInput} ${y.css.inputBase}" placeholder="Find..." />
1999
- <button class="${y.css.prevButton} ${y.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
2000
- <button class="${y.css.nextButton} ${y.css.buttonBase}" type="button" aria-label="Next match">↓</button>
2001
- <button class="${y.css.closeButton} ${y.css.buttonBase}" type="button" aria-label="Close search">×</button>
2126
+ ), i = t == null ? void 0 : t.parentElement, n = e.closest(".rte-source-editor-modal") || i || t || e.parentElement;
2127
+ if (!n) return;
2128
+ window.getComputedStyle(n).position === "static" && (n.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = x.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
2129
+ <div class="${x.css.row}">
2130
+ <input type="text" class="${x.css.findInput} ${x.css.inputBase}" placeholder="Find..." />
2131
+ <button class="${x.css.prevButton} ${x.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
2132
+ <button class="${x.css.nextButton} ${x.css.buttonBase}" type="button" aria-label="Next match">↓</button>
2133
+ <button class="${x.css.closeButton} ${x.css.buttonBase}" type="button" aria-label="Close search">×</button>
2002
2134
  </div>
2003
- <div class="${y.css.options}">
2004
- <label class="${y.css.optionLabel}" title="Case sensitive">
2005
- <input type="checkbox" class="${y.css.optionInput} ${y.css.caseSensitive}" />
2135
+ <div class="${x.css.options}">
2136
+ <label class="${x.css.optionLabel}" title="Case sensitive">
2137
+ <input type="checkbox" class="${x.css.optionInput} ${x.css.caseSensitive}" />
2006
2138
  <span>Aa</span>
2007
2139
  </label>
2008
- <label class="${y.css.optionLabel}" title="Whole word">
2009
- <input type="checkbox" class="${y.css.optionInput} ${y.css.wholeWord}" />
2140
+ <label class="${x.css.optionLabel}" title="Whole word">
2141
+ <input type="checkbox" class="${x.css.optionInput} ${x.css.wholeWord}" />
2010
2142
  <span>Whole</span>
2011
2143
  </label>
2012
- <label class="${y.css.optionLabel}" title="Regular expression">
2013
- <input type="checkbox" class="${y.css.optionInput} ${y.css.regex}" />
2144
+ <label class="${x.css.optionLabel}" title="Regular expression">
2145
+ <input type="checkbox" class="${x.css.optionInput} ${x.css.regex}" />
2014
2146
  <span>.*</span>
2015
2147
  </label>
2016
2148
  </div>
2017
- <div class="${y.css.meta}">
2018
- <div class="${y.css.status} ${y.css.statusLayout}"></div>
2019
- <div class="${y.css.mode} ${y.css.modeLayout}" aria-live="polite"></div>
2149
+ <div class="${x.css.meta}">
2150
+ <div class="${x.css.status} ${x.css.statusLayout}"></div>
2151
+ <div class="${x.css.mode} ${x.css.modeLayout}" aria-live="polite"></div>
2020
2152
  </div>
2021
- <input type="text" class="${y.css.replaceInput} ${y.css.inputBase} ${y.css.replaceInputLayout}" placeholder="Replace with..." />
2153
+ <input type="text" class="${x.css.replaceInput} ${x.css.inputBase} ${x.css.replaceInputLayout}" placeholder="Replace with..." />
2022
2154
  `;
2023
- const n = this.searchUI.querySelector(
2024
- `.${y.css.findInput}`
2155
+ const s = this.searchUI.querySelector(
2156
+ `.${x.css.findInput}`
2025
2157
  ), r = this.searchUI.querySelector(
2026
- `.${y.css.replaceInput}`
2158
+ `.${x.css.replaceInput}`
2027
2159
  ), o = this.searchUI.querySelector(
2028
- `.${y.css.prevButton}`
2160
+ `.${x.css.prevButton}`
2029
2161
  ), l = this.searchUI.querySelector(
2030
- `.${y.css.nextButton}`
2162
+ `.${x.css.nextButton}`
2031
2163
  ), a = this.searchUI.querySelector(
2032
- `.${y.css.closeButton}`
2164
+ `.${x.css.closeButton}`
2033
2165
  ), h = this.searchUI.querySelector(
2034
- `.${y.css.status}`
2035
- ), d = this.searchUI.querySelector(
2036
- `.${y.css.mode}`
2166
+ `.${x.css.status}`
2037
2167
  ), c = this.searchUI.querySelector(
2038
- `.${y.css.caseSensitive}`
2168
+ `.${x.css.mode}`
2169
+ ), d = this.searchUI.querySelector(
2170
+ `.${x.css.caseSensitive}`
2171
+ ), f = this.searchUI.querySelector(
2172
+ `.${x.css.wholeWord}`
2039
2173
  ), u = this.searchUI.querySelector(
2040
- `.${y.css.wholeWord}`
2041
- ), g = this.searchUI.querySelector(
2042
- `.${y.css.regex}`
2174
+ `.${x.css.regex}`
2043
2175
  );
2044
- this.findInput = n, this.replaceInputEl = r, this.statusDiv = h, this.modeDiv = d, this.caseSensitiveInput = c, this.wholeWordInput = u, this.regexInput = g, c.checked = !!this.searchOptions.caseSensitive, u.checked = !!this.searchOptions.wholeWord, g.checked = !!this.searchOptions.regex, n.addEventListener("input", () => {
2176
+ this.findInput = s, this.replaceInputEl = r, this.statusDiv = h, this.modeDiv = c, this.caseSensitiveInput = d, this.wholeWordInput = f, this.regexInput = u, d.checked = !!this.searchOptions.caseSensitive, f.checked = !!this.searchOptions.wholeWord, u.checked = !!this.searchOptions.regex, s.addEventListener("input", () => {
2045
2177
  this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
2046
- const p = n.value;
2178
+ const p = s.value;
2047
2179
  this.searchDebounceTimer = setTimeout(() => {
2048
2180
  this.performSearch(p, !1, !1);
2049
2181
  }, 120);
2050
2182
  });
2051
- const f = () => {
2052
- this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = u.checked, this.searchOptions.regex = g.checked;
2053
- const p = n.value;
2183
+ const g = () => {
2184
+ this.searchOptions.caseSensitive = d.checked, this.searchOptions.wholeWord = f.checked, this.searchOptions.regex = u.checked;
2185
+ const p = s.value;
2054
2186
  p.trim() ? this.performSearch(p, !1, !1) : this.performSearch("", !1, !1);
2055
2187
  };
2056
- c.addEventListener("change", f), u.addEventListener("change", f), g.addEventListener("change", f), n.addEventListener("keydown", (p) => {
2188
+ d.addEventListener("change", g), f.addEventListener("change", g), u.addEventListener("change", g), s.addEventListener("keydown", (p) => {
2057
2189
  p.key === "Enter" ? (p.preventDefault(), p.shiftKey ? this.findPrev() : this.findNext()) : p.key === "Escape" && (p.preventDefault(), this.hideSearch());
2058
2190
  }), r.addEventListener("keydown", (p) => {
2059
- p.key === "Enter" ? (p.preventDefault(), p.shiftKey ? this.replaceAll(n.value, r.value) : this.replaceCurrent(n.value, r.value)) : p.key === "Escape" && (p.preventDefault(), this.hideSearch());
2060
- }), o.addEventListener("click", () => this.findPrev()), l.addEventListener("click", () => this.findNext()), a.addEventListener("click", () => this.hideSearch()), s.appendChild(this.searchUI);
2191
+ p.key === "Enter" ? (p.preventDefault(), p.shiftKey ? this.replaceAll(s.value, r.value) : this.replaceCurrent(s.value, r.value)) : p.key === "Escape" && (p.preventDefault(), this.hideSearch());
2192
+ }), o.addEventListener("click", () => this.findPrev()), l.addEventListener("click", () => this.findNext()), a.addEventListener("click", () => this.hideSearch()), n.appendChild(this.searchUI);
2061
2193
  }
2062
2194
  updateModeHint(e) {
2063
2195
  this.modeDiv && (this.modeDiv.textContent = e ? `Replace: move next ${this.config.replaceAndFindNext ? "ON" : "OFF"}` : "Find mode");
@@ -2072,12 +2204,12 @@ const K = class y {
2072
2204
  return;
2073
2205
  }
2074
2206
  this.currentQuery = e;
2075
- const s = this.currentIndex, n = this.editor.search(e, this.searchOptions);
2076
- if (this.currentResults = n, n.length === 0) {
2207
+ const n = this.currentIndex, s = this.editor.search(e, this.searchOptions);
2208
+ if (this.currentResults = s, s.length === 0) {
2077
2209
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("No matches");
2078
2210
  return;
2079
2211
  }
2080
- t && s >= 0 ? this.currentIndex = Math.min(s, n.length - 1) : this.currentIndex = 0, this.updateHighlights(i);
2212
+ t && n >= 0 ? this.currentIndex = Math.min(n, s.length - 1) : this.currentIndex = 0, this.updateHighlights(i);
2081
2213
  }
2082
2214
  findNext() {
2083
2215
  if (this.currentResults.length === 0) {
@@ -2097,17 +2229,17 @@ const K = class y {
2097
2229
  if (!this.editor || !e.trim() || ((this.currentQuery !== e || this.currentResults.length === 0) && this.performSearch(e, !1, !0), this.currentIndex < 0 || this.currentResults.length === 0)) return;
2098
2230
  const i = this.currentResults[this.currentIndex];
2099
2231
  if (!i) return;
2100
- const s = this.computeReplacementRange(i.range.start, t);
2232
+ const n = this.computeReplacementRange(i.range.start, t);
2101
2233
  if (this.editor.replace(i.range, t), this.config.replaceAndFindNext) {
2102
2234
  this.currentQuery = e;
2103
- const n = this.editor.search(e, this.searchOptions);
2104
- if (this.currentResults = n, n.length === 0) {
2235
+ const s = this.editor.search(e, this.searchOptions);
2236
+ if (this.currentResults = s, s.length === 0) {
2105
2237
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("Replaced current occurrence"), this.restoreReplaceInputFocus();
2106
2238
  return;
2107
2239
  }
2108
- this.currentIndex = this.findNextResultIndexAfter(s.end, n), this.updateHighlights(!0);
2240
+ this.currentIndex = this.findNextResultIndexAfter(n.end, s), this.updateHighlights(!0);
2109
2241
  } else
2110
- this.scrollLogicalRangeIntoView(s, !0), this.performSearch(e, !0, !1);
2242
+ this.scrollLogicalRangeIntoView(n, !0), this.performSearch(e, !0, !1);
2111
2243
  this.currentResults.length > 0 || this.showTransientStatus("Replaced current occurrence"), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
2112
2244
  }
2113
2245
  replaceAll(e, t) {
@@ -2126,10 +2258,10 @@ const K = class y {
2126
2258
  }
2127
2259
  navigateToResult(e, t) {
2128
2260
  if (!this.editor) return;
2129
- const i = document.activeElement, s = !!i && (i === this.findInput || i === this.replaceInputEl);
2261
+ const i = document.activeElement, n = !!i && (i === this.findInput || i === this.replaceInputEl);
2130
2262
  t ? (this.editor.setSelection(e.range), this.centerCurrentSelectionInView()) : this.scrollResultIntoView(e);
2131
- const n = this.editor.getView();
2132
- t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && s && i && requestAnimationFrame(() => {
2263
+ const s = this.editor.getView();
2264
+ t && typeof s.ensureCaretVisible == "function" && s.ensureCaretVisible(), t && n && i && requestAnimationFrame(() => {
2133
2265
  this.focusWithoutScrolling(i);
2134
2266
  });
2135
2267
  }
@@ -2147,18 +2279,18 @@ const K = class y {
2147
2279
  }
2148
2280
  scrollLogicalRangeIntoView(e, t) {
2149
2281
  if (!this.editor) return;
2150
- const i = this.editor.getView().getContentElement(), s = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(s), o = this.buildTextNodeIndex(i);
2282
+ const i = this.editor.getView().getContentElement(), n = this.editor.getValue(), { lineStarts: s, lines: r } = this.buildLineStarts(n), o = this.buildTextNodeIndex(i);
2151
2283
  if (o.length === 0) return;
2152
- const l = this.toDomRange(e, n, r, o);
2284
+ const l = this.toDomRange(e, s, r, o);
2153
2285
  if (!l) return;
2154
2286
  const a = l.startContainer.nodeType === Node.TEXT_NODE ? l.startContainer.parentElement : l.startContainer, h = this.resolveScrollContainer(i);
2155
2287
  if (h) {
2156
- const d = l.getClientRects()[0] || l.getBoundingClientRect(), c = h.getBoundingClientRect(), u = h.scrollTop + (d.top - c.top) - c.height / 2 + d.height / 2, g = 18;
2157
- let f = t ? u : h.scrollTop, p = h.scrollLeft;
2158
- const m = h.scrollLeft + (d.left - c.left), x = m + d.width;
2159
- d.right > c.right - g ? p = x - c.width + g : d.left < c.left + g && (p = Math.max(0, m - g));
2160
- const v = Math.max(0, h.scrollHeight - h.clientHeight), T = Math.max(0, h.scrollWidth - h.clientWidth);
2161
- if (f = Math.min(v, Math.max(0, f)), p = Math.min(T, Math.max(0, p)), v === 0 && T === 0) {
2288
+ const c = l.getClientRects()[0] || l.getBoundingClientRect(), d = h.getBoundingClientRect(), u = h.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, g = 18;
2289
+ let p = t ? u : h.scrollTop, m = h.scrollLeft;
2290
+ const y = h.scrollLeft + (c.left - d.left), T = y + c.width;
2291
+ c.right > d.right - g ? m = T - d.width + g : c.left < d.left + g && (m = Math.max(0, y - g));
2292
+ const S = Math.max(0, h.scrollHeight - h.clientHeight), v = Math.max(0, h.scrollWidth - h.clientWidth);
2293
+ if (p = Math.min(S, Math.max(0, p)), m = Math.min(v, Math.max(0, m)), S === 0 && v === 0) {
2162
2294
  a == null || a.scrollIntoView({
2163
2295
  block: t ? "center" : "nearest",
2164
2296
  inline: "nearest",
@@ -2166,9 +2298,9 @@ const K = class y {
2166
2298
  });
2167
2299
  return;
2168
2300
  }
2169
- (f !== h.scrollTop || p !== h.scrollLeft) && h.scrollTo({
2170
- top: f,
2171
- left: p,
2301
+ (p !== h.scrollTop || m !== h.scrollLeft) && h.scrollTo({
2302
+ top: p,
2303
+ left: m,
2172
2304
  behavior: "smooth"
2173
2305
  });
2174
2306
  return;
@@ -2196,32 +2328,32 @@ const K = class y {
2196
2328
  if (!t) return;
2197
2329
  const i = window.getSelection();
2198
2330
  if (!i || i.rangeCount === 0) return;
2199
- const s = i.getRangeAt(0).cloneRange(), n = s.getClientRects()[0] || s.getBoundingClientRect();
2200
- if (!n) return;
2201
- 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), a = Math.min(l, Math.max(0, o));
2202
- a !== t.scrollTop && t.scrollTo({
2203
- top: a,
2331
+ const n = i.getRangeAt(0).cloneRange(), s = n.getClientRects()[0] || n.getBoundingClientRect();
2332
+ if (!s) return;
2333
+ const r = t.getBoundingClientRect(), l = t.scrollTop + (s.top - r.top) - r.height / 2 + s.height / 2, a = Math.max(0, t.scrollHeight - t.clientHeight), h = Math.min(a, Math.max(0, l));
2334
+ h !== t.scrollTop && t.scrollTo({
2335
+ top: h,
2204
2336
  behavior: "smooth"
2205
2337
  });
2206
2338
  }
2207
2339
  computeReplacementRange(e, t) {
2208
2340
  const i = t.replace(/\r\n?/g, `
2209
- `), s = i.split(`
2341
+ `), n = i.split(`
2210
2342
  `);
2211
- let n;
2212
- return s.length <= 1 ? (n = {
2343
+ let s;
2344
+ return n.length <= 1 ? (s = {
2213
2345
  start: e,
2214
2346
  end: {
2215
2347
  line: e.line,
2216
2348
  column: e.column + i.length
2217
2349
  }
2218
- }, this.clampRangeToDocument(n)) : (n = {
2350
+ }, this.clampRangeToDocument(s)) : (s = {
2219
2351
  start: e,
2220
2352
  end: {
2221
- line: e.line + s.length - 1,
2222
- column: s[s.length - 1].length
2353
+ line: e.line + n.length - 1,
2354
+ column: n[n.length - 1].length
2223
2355
  }
2224
- }, this.clampRangeToDocument(n));
2356
+ }, this.clampRangeToDocument(s));
2225
2357
  }
2226
2358
  findNextResultIndexAfter(e, t) {
2227
2359
  for (let i = 0; i < t.length; i++)
@@ -2237,15 +2369,15 @@ const K = class y {
2237
2369
  const t = this.editor;
2238
2370
  if (!t) return e;
2239
2371
  const i = t.getValue().split(`
2240
- `), s = Math.max(0, i.length - 1), n = Math.max(0, Math.min(e.start.line, s)), r = Math.max(0, Math.min(e.end.line, s)), o = Math.max(
2372
+ `), n = Math.max(0, i.length - 1), s = Math.max(0, Math.min(e.start.line, n)), r = Math.max(0, Math.min(e.end.line, n)), o = Math.max(
2241
2373
  0,
2242
- Math.min(e.start.column, ((a = i[n]) == null ? void 0 : a.length) || 0)
2374
+ Math.min(e.start.column, ((a = i[s]) == null ? void 0 : a.length) || 0)
2243
2375
  ), l = Math.max(
2244
2376
  0,
2245
2377
  Math.min(e.end.column, ((h = i[r]) == null ? void 0 : h.length) || 0)
2246
2378
  );
2247
2379
  return {
2248
- start: { line: n, column: o },
2380
+ start: { line: s, column: o },
2249
2381
  end: { line: r, column: l }
2250
2382
  };
2251
2383
  }
@@ -2256,36 +2388,36 @@ const K = class y {
2256
2388
  });
2257
2389
  } catch (t) {
2258
2390
  const i = [];
2259
- let s = e.parentElement;
2260
- for (; s; )
2261
- this.canScroll(s) && i.push({
2262
- el: s,
2263
- top: s.scrollTop,
2264
- left: s.scrollLeft
2265
- }), s = s.parentElement;
2266
- const n = window.scrollX, r = window.scrollY;
2391
+ let n = e.parentElement;
2392
+ for (; n; )
2393
+ this.canScroll(n) && i.push({
2394
+ el: n,
2395
+ top: n.scrollTop,
2396
+ left: n.scrollLeft
2397
+ }), n = n.parentElement;
2398
+ const s = window.scrollX, r = window.scrollY;
2267
2399
  e.focus();
2268
2400
  for (let o = 0; o < i.length; o++) {
2269
2401
  const l = i[o];
2270
2402
  l.el.scrollTop = l.top, l.el.scrollLeft = l.left;
2271
2403
  }
2272
- window.scrollTo(n, r);
2404
+ window.scrollTo(s, r);
2273
2405
  }
2274
2406
  }
2275
2407
  findScrollContainer(e) {
2276
2408
  let t = e;
2277
2409
  for (; t; ) {
2278
- const i = window.getComputedStyle(t).overflowY;
2279
- if ((i === "auto" || i === "scroll") && t.scrollHeight > t.clientHeight)
2410
+ const n = window.getComputedStyle(t).overflowY;
2411
+ if ((n === "auto" || n === "scroll") && t.scrollHeight > t.clientHeight)
2280
2412
  return t;
2281
2413
  t = t.parentElement;
2282
2414
  }
2283
2415
  return null;
2284
2416
  }
2285
2417
  resolveScrollContainer(e) {
2286
- var i, s, n;
2287
- const t = ((n = (s = (i = this.editor) == null ? void 0 : i.getView()) == null ? void 0 : s.getScrollElement) == null ? void 0 : n.call(s)) || null;
2288
- return t && this.canScroll(t) ? t : this.findScrollContainer(e);
2418
+ var n, s;
2419
+ const t = (n = this.editor) == null ? void 0 : n.getView(), i = ((s = t == null ? void 0 : t.getScrollElement) == null ? void 0 : s.call(t)) || null;
2420
+ return i && this.canScroll(i) ? i : this.findScrollContainer(e);
2289
2421
  }
2290
2422
  canScroll(e) {
2291
2423
  return e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth;
@@ -2299,123 +2431,122 @@ const K = class y {
2299
2431
  applyCustomHighlights() {
2300
2432
  if (!this.editor || !this.hasCustomHighlightSupport || this.currentResults.length === 0)
2301
2433
  return;
2302
- const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: i, lines: s } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
2303
- if (n.length === 0) return;
2304
- const r = this.buildVisibleDocumentText(n), o = [];
2434
+ const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: i, lines: n } = this.buildLineStarts(t), s = this.buildTextNodeIndex(e);
2435
+ if (s.length === 0) return;
2436
+ const r = this.buildVisibleDocumentText(s), o = [];
2305
2437
  let l = null;
2306
2438
  const a = Math.min(this.currentResults.length, this.maxCustomHighlightRanges);
2307
2439
  for (let h = 0; h < a; h++) {
2308
- const d = this.currentResults[h], c = this.searchOptions.regex ? d.match || this.currentQuery : this.currentQuery || d.match, u = this.toDomRange(
2309
- d.range,
2440
+ const c = this.currentResults[h], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
2441
+ c.range,
2310
2442
  i,
2311
- s,
2312
2443
  n,
2444
+ s,
2313
2445
  r,
2314
- c
2446
+ d
2315
2447
  );
2316
- u && (o.push(u), h === this.currentIndex && (l = u));
2448
+ f && (o.push(f), h === this.currentIndex && (l = f));
2317
2449
  }
2318
2450
  if (o.length !== 0)
2319
2451
  try {
2320
- const h = CSS, d = window.Highlight;
2321
- if (!h.highlights || !d) return;
2322
- h.highlights.set(this.highlightMatchName, new d(...o)), l && h.highlights.set(this.highlightActiveName, new d(l));
2452
+ const h = CSS, c = window.Highlight;
2453
+ if (!h.highlights || !c) return;
2454
+ h.highlights.set(this.highlightMatchName, new c(...o)), l && h.highlights.set(this.highlightActiveName, new c(l));
2323
2455
  } catch (h) {
2324
2456
  }
2325
2457
  }
2326
2458
  buildLineStarts(e) {
2327
2459
  const t = e.split(`
2328
2460
  `), i = new Array(t.length);
2329
- let s = 0;
2330
- for (let n = 0; n < t.length; n++)
2331
- i[n] = s, s += t[n].length + 1;
2461
+ let n = 0;
2462
+ for (let s = 0; s < t.length; s++)
2463
+ i[s] = n, n += t[s].length + 1;
2332
2464
  return { lineStarts: i, lines: t };
2333
2465
  }
2334
2466
  positionToOffset(e, t, i) {
2335
2467
  var r;
2336
- const s = Math.max(0, Math.min(e.line, i.length - 1)), n = Math.max(0, Math.min(e.column, ((r = i[s]) == null ? void 0 : r.length) || 0));
2337
- return t[s] + n;
2468
+ const n = Math.max(0, Math.min(e.line, i.length - 1)), s = Math.max(0, Math.min(e.column, ((r = i[n]) == null ? void 0 : r.length) || 0));
2469
+ return t[n] + s;
2338
2470
  }
2339
2471
  buildTextNodeIndex(e) {
2340
- var r;
2341
2472
  const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), i = [];
2342
- let s = 0, n;
2343
- for (; n = t.nextNode(); ) {
2344
- const o = n;
2345
- if ((r = o.parentElement) != null && r.hasAttribute(this.trailingMarkerAttr))
2473
+ let n = 0, s;
2474
+ for (; s = t.nextNode(); ) {
2475
+ const r = s, o = r.parentElement;
2476
+ if (o != null && o.hasAttribute(this.trailingMarkerAttr))
2346
2477
  continue;
2347
- const l = o.textContent || "", a = this.buildVisibleToDomMap(l), h = Math.max(0, a.length - 1);
2478
+ const l = r.textContent || "", a = this.buildVisibleToDomMap(l), h = Math.max(0, a.length - 1);
2348
2479
  h === 0 && l.length === 0 || (i.push({
2349
- node: o,
2350
- start: s,
2351
- end: s + h,
2480
+ node: r,
2481
+ start: n,
2482
+ end: n + h,
2352
2483
  visibleToDom: a
2353
- }), s += h);
2484
+ }), n += h);
2354
2485
  }
2355
2486
  return i;
2356
2487
  }
2357
2488
  resolveDomPoint(e, t) {
2358
- var n, r, o, l, a, h;
2489
+ var s, r, o, l, a, h;
2359
2490
  const i = Math.max(0, e);
2360
- for (let d = 0; d < t.length; d++) {
2361
- const c = t[d];
2362
- if (i <= c.end) {
2363
- const u = Math.max(0, i - c.start), g = (o = (r = c.visibleToDom[u]) != null ? r : (n = c.node.textContent) == null ? void 0 : n.length) != null ? o : 0;
2491
+ for (let c = 0; c < t.length; c++) {
2492
+ const d = t[c];
2493
+ if (i <= d.end) {
2494
+ const f = Math.max(0, i - d.start), u = (o = (r = d.visibleToDom[f]) != null ? r : (s = d.node.textContent) == null ? void 0 : s.length) != null ? o : 0;
2364
2495
  return {
2365
- node: c.node,
2366
- offset: g
2496
+ node: d.node,
2497
+ offset: u
2367
2498
  };
2368
2499
  }
2369
2500
  }
2370
- const s = t[t.length - 1];
2371
- return s ? {
2372
- node: s.node,
2373
- offset: (h = (a = s.visibleToDom[s.visibleToDom.length - 1]) != null ? a : (l = s.node.textContent) == null ? void 0 : l.length) != null ? h : 0
2501
+ const n = t[t.length - 1];
2502
+ return n ? {
2503
+ node: n.node,
2504
+ offset: (h = (a = n.visibleToDom[n.visibleToDom.length - 1]) != null ? a : (l = n.node.textContent) == null ? void 0 : l.length) != null ? h : 0
2374
2505
  } : null;
2375
2506
  }
2376
- toDomRange(e, t, i, s, n, r) {
2507
+ toDomRange(e, t, i, n, s, r) {
2377
2508
  const o = this.positionToOffset(e.start, t, i), l = this.positionToOffset(e.end, t, i);
2378
2509
  let a = Math.min(o, l), h = Math.max(o, l);
2379
- if (n && r) {
2380
- const g = r, f = n.slice(a, h);
2381
- if (f.length === g.length && f.toLowerCase() !== g.toLowerCase()) {
2510
+ if (s && r) {
2511
+ const u = r, g = s.slice(a, h);
2512
+ if (g.length === u.length && g.toLowerCase() !== u.toLowerCase()) {
2382
2513
  const p = this.findNearestMatchOffset(
2383
- n,
2384
- g,
2514
+ s,
2515
+ u,
2385
2516
  a
2386
2517
  );
2387
- p !== -1 && (a = p, h = p + g.length);
2518
+ p !== -1 && (a = p, h = p + u.length);
2388
2519
  }
2389
2520
  }
2390
- const d = this.resolveDomPoint(a, s), c = this.resolveDomPoint(h, s);
2391
- if (!d || !c) return null;
2392
- const u = document.createRange();
2521
+ const c = this.resolveDomPoint(a, n), d = this.resolveDomPoint(h, n);
2522
+ if (!c || !d) return null;
2523
+ const f = document.createRange();
2393
2524
  try {
2394
- return u.setStart(d.node, d.offset), u.setEnd(c.node, c.offset), u;
2395
- } catch (g) {
2525
+ return f.setStart(c.node, c.offset), f.setEnd(d.node, d.offset), f;
2526
+ } catch (u) {
2396
2527
  return null;
2397
2528
  }
2398
2529
  }
2399
2530
  buildVisibleDocumentText(e) {
2400
2531
  let t = "";
2401
2532
  for (let i = 0; i < e.length; i++) {
2402
- const s = e[i].node.textContent || "";
2403
- for (let n = 0; n < s.length; n++) {
2404
- const r = s[n];
2533
+ const n = e[i].node.textContent || "";
2534
+ for (let s = 0; s < n.length; s++) {
2535
+ const r = n[s];
2405
2536
  this.virtualMarkerRegex.test(r) || (t += r);
2406
2537
  }
2407
2538
  }
2408
2539
  return t;
2409
2540
  }
2410
2541
  findNearestMatchOffset(e, t, i) {
2411
- const s = t.toLowerCase();
2412
- let n = e.toLowerCase().indexOf(s);
2413
- if (n === -1) return -1;
2414
- let r = n, o = Math.abs(n - i);
2415
- for (; n !== -1; ) {
2416
- const l = Math.abs(n - i);
2417
- if (l < o && (o = l, r = n), l === 0) return n;
2418
- n = e.toLowerCase().indexOf(s, n + 1);
2542
+ const n = t.toLowerCase();
2543
+ let s = e.toLowerCase().indexOf(n);
2544
+ if (s === -1) return -1;
2545
+ let r = s, o = Math.abs(s - i);
2546
+ for (; s !== -1; ) {
2547
+ const l = Math.abs(s - i);
2548
+ if (l < o && (o = l, r = s), l === 0) return s;
2549
+ s = e.toLowerCase().indexOf(n, s + 1);
2419
2550
  }
2420
2551
  return r;
2421
2552
  }
@@ -2477,9 +2608,9 @@ const K = class y {
2477
2608
  buildVisibleToDomMap(e) {
2478
2609
  const t = [0];
2479
2610
  let i = 0;
2480
- for (let s = 0; s < e.length; s++) {
2481
- const n = e[s];
2482
- this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
2611
+ for (let n = 0; n < e.length; n++) {
2612
+ const s = e[n];
2613
+ this.virtualMarkerRegex.test(s) || (i += 1, t[i] = n + 1);
2483
2614
  }
2484
2615
  return t;
2485
2616
  }
@@ -2503,7 +2634,7 @@ const K = class y {
2503
2634
  e != null && e.parentNode && e.parentNode.removeChild(e), this.editor = null;
2504
2635
  }
2505
2636
  };
2506
- K.css = {
2637
+ x.css = {
2507
2638
  root: "lce-search-ui",
2508
2639
  row: "lce-search-row",
2509
2640
  options: "lce-search-options",
@@ -2526,8 +2657,8 @@ K.css = {
2526
2657
  mode: "search-mode",
2527
2658
  modeLayout: "lce-search-mode"
2528
2659
  };
2529
- let re = K, oe = 0;
2530
- class le {
2660
+ let U = x, se = 0;
2661
+ class re {
2531
2662
  constructor() {
2532
2663
  this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
2533
2664
  "(": ")",
@@ -2539,7 +2670,7 @@ class le {
2539
2670
  "]": "[",
2540
2671
  "}": "{",
2541
2672
  ">": "<"
2542
- }, this.highlightId = ++oe, this.highlightName = `editora-bracket-match-${this.highlightId}`, this.highlightStyleId = `editora-bracket-match-style-${this.highlightId}`, this.currentMatch = null, this.hasCustomHighlightSupport = !1, this.observer = null, this.pendingUpdateRaf = null, this.updateRequestVersion = 0, this.cursorHandler = null, this.changeHandler = null;
2673
+ }, this.highlightId = ++se, this.highlightName = `editora-bracket-match-${this.highlightId}`, this.highlightStyleId = `editora-bracket-match-style-${this.highlightId}`, this.currentMatch = null, this.hasCustomHighlightSupport = !1, this.observer = null, this.pendingUpdateRaf = null, this.updateRequestVersion = 0, this.cursorHandler = null, this.changeHandler = null;
2543
2674
  }
2544
2675
  setup(e) {
2545
2676
  this.editor = e, this.hasCustomHighlightSupport = this.detectCustomHighlightSupport(), this.hasCustomHighlightSupport && (this.ensureHighlightStyles(), this.observeContentMutations()), this.cursorHandler = () => {
@@ -2569,17 +2700,17 @@ class le {
2569
2700
  this.clearBracketHighlighting();
2570
2701
  const i = this.getBracketNearPosition(t, e.position);
2571
2702
  if (!i) return;
2572
- const s = this.findMatchingBracket(t, i);
2573
- s && (this.currentMatch = s, this.highlightBrackets(s));
2703
+ const n = this.findMatchingBracket(t, i);
2704
+ n && (this.currentMatch = n, this.highlightBrackets(n));
2574
2705
  }
2575
2706
  getBracketNearPosition(e, t) {
2576
2707
  const i = e.split(`
2577
2708
  `);
2578
2709
  if (t.line < 0 || t.line >= i.length) return null;
2579
- const s = [{ line: t.line, column: t.column }];
2580
- t.column > 0 && s.push({ line: t.line, column: t.column - 1 });
2581
- for (const n of s) {
2582
- const r = this.getBracketAtPosition(i, n);
2710
+ const n = [{ line: t.line, column: t.column }];
2711
+ t.column > 0 && n.push({ line: t.line, column: t.column - 1 });
2712
+ for (const s of n) {
2713
+ const r = this.getBracketAtPosition(i, s);
2583
2714
  if (r)
2584
2715
  return r;
2585
2716
  }
@@ -2589,47 +2720,47 @@ class le {
2589
2720
  if (t.line < 0 || t.line >= e.length) return null;
2590
2721
  const i = e[t.line];
2591
2722
  if (t.column < 0 || t.column >= i.length) return null;
2592
- const s = i[t.column];
2593
- return this.bracketPairs[s] || this.reverseBracketPairs[s] ? { char: s, position: t } : null;
2723
+ const n = i[t.column];
2724
+ return this.bracketPairs[n] || this.reverseBracketPairs[n] ? { char: n, position: t } : null;
2594
2725
  }
2595
2726
  findMatchingBracket(e, t) {
2596
2727
  const i = e.split(`
2597
- `), s = t.position.line, n = t.position.column, r = t.char;
2598
- return this.bracketPairs[r] ? this.findClosingBracket(i, s, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(i, s, n, r) : null;
2728
+ `), n = t.position.line, s = t.position.column, r = t.char;
2729
+ return this.bracketPairs[r] ? this.findClosingBracket(i, n, s, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(i, n, s, r) : null;
2599
2730
  }
2600
- findClosingBracket(e, t, i, s) {
2601
- const n = this.bracketPairs[s];
2731
+ findClosingBracket(e, t, i, n) {
2732
+ const s = this.bracketPairs[n];
2602
2733
  let r = 0;
2603
2734
  for (let o = t; o < e.length; o++) {
2604
2735
  const l = e[o], a = o === t ? i : 0;
2605
2736
  for (let h = a; h < l.length; h++) {
2606
- const d = l[h];
2607
- if (d === s)
2737
+ const c = l[h];
2738
+ if (c === n)
2608
2739
  r++;
2609
- else if (d === n && (r--, r === 0))
2740
+ else if (c === s && (r--, r === 0))
2610
2741
  return {
2611
2742
  open: { start: { line: t, column: i }, end: { line: t, column: i + 1 } },
2612
2743
  close: { start: { line: o, column: h }, end: { line: o, column: h + 1 } },
2613
- type: s
2744
+ type: n
2614
2745
  };
2615
2746
  }
2616
2747
  }
2617
2748
  return null;
2618
2749
  }
2619
- findOpeningBracket(e, t, i, s) {
2620
- const n = this.reverseBracketPairs[s];
2750
+ findOpeningBracket(e, t, i, n) {
2751
+ const s = this.reverseBracketPairs[n];
2621
2752
  let r = 0;
2622
2753
  for (let o = t; o >= 0; o--) {
2623
2754
  const l = e[o], a = o === t ? i : l.length - 1;
2624
2755
  for (let h = a; h >= 0; h--) {
2625
- const d = l[h];
2626
- if (d === s)
2756
+ const c = l[h];
2757
+ if (c === n)
2627
2758
  r++;
2628
- else if (d === n && (r--, r === 0))
2759
+ else if (c === s && (r--, r === 0))
2629
2760
  return {
2630
2761
  open: { start: { line: o, column: h }, end: { line: o, column: h + 1 } },
2631
2762
  close: { start: { line: t, column: i }, end: { line: t, column: i + 1 } },
2632
- type: n
2763
+ type: s
2633
2764
  };
2634
2765
  }
2635
2766
  }
@@ -2637,13 +2768,13 @@ class le {
2637
2768
  }
2638
2769
  highlightBrackets(e) {
2639
2770
  if (!this.editor || !this.hasCustomHighlightSupport) return;
2640
- const t = this.editor.getView(), i = t.createDomRangeFromRange(e.open), s = t.createDomRangeFromRange(e.close);
2641
- if (!(!i || !s))
2771
+ const t = this.editor.getView(), i = t.createDomRangeFromRange(e.open), n = t.createDomRangeFromRange(e.close);
2772
+ if (!(!i || !n))
2642
2773
  try {
2643
- const n = CSS, r = window.Highlight;
2644
- if (!n.highlights || !r) return;
2645
- n.highlights.set(this.highlightName, new r(i, s));
2646
- } catch (n) {
2774
+ const s = CSS, r = window.Highlight;
2775
+ if (!s.highlights || !r) return;
2776
+ s.highlights.set(this.highlightName, new r(i, n));
2777
+ } catch (s) {
2647
2778
  }
2648
2779
  }
2649
2780
  clearBracketHighlighting() {
@@ -2655,7 +2786,7 @@ class le {
2655
2786
  }
2656
2787
  }
2657
2788
  observeContentMutations() {
2658
- if (!this.editor || typeof MutationObserver > "u") return;
2789
+ if (!this.editor || typeof MutationObserver == "undefined") return;
2659
2790
  const e = this.editor.getView().getContentElement();
2660
2791
  this.observer = new MutationObserver(() => {
2661
2792
  this.clearBracketHighlighting(), this.scheduleBracketUpdate();
@@ -2667,7 +2798,7 @@ class le {
2667
2798
  }
2668
2799
  detectCustomHighlightSupport() {
2669
2800
  try {
2670
- if (typeof CSS > "u" || typeof window > "u")
2801
+ if (typeof CSS == "undefined" || typeof window == "undefined")
2671
2802
  return !1;
2672
2803
  const e = CSS, t = window.Highlight;
2673
2804
  return !!e.highlights && !!t;
@@ -2676,7 +2807,7 @@ class le {
2676
2807
  }
2677
2808
  }
2678
2809
  ensureHighlightStyles() {
2679
- if (typeof document > "u" || document.getElementById(this.highlightStyleId)) return;
2810
+ if (typeof document == "undefined" || document.getElementById(this.highlightStyleId)) return;
2680
2811
  const e = document.createElement("style");
2681
2812
  e.id = this.highlightStyleId, e.textContent = `
2682
2813
  ::highlight(${this.highlightName}) {
@@ -2690,14 +2821,14 @@ class le {
2690
2821
  }
2691
2822
  destroy() {
2692
2823
  var e;
2693
- if (this.pendingUpdateRaf !== null && typeof cancelAnimationFrame == "function" && (cancelAnimationFrame(this.pendingUpdateRaf), this.pendingUpdateRaf = null), this.clearBracketHighlighting(), (e = this.observer) == null || e.disconnect(), this.observer = null, this.editor && this.cursorHandler && this.editor.off("cursor", this.cursorHandler), this.editor && this.changeHandler && this.editor.off("change", this.changeHandler), typeof document < "u") {
2824
+ if (this.pendingUpdateRaf !== null && typeof cancelAnimationFrame == "function" && (cancelAnimationFrame(this.pendingUpdateRaf), this.pendingUpdateRaf = null), this.clearBracketHighlighting(), (e = this.observer) == null || e.disconnect(), this.observer = null, this.editor && this.cursorHandler && this.editor.off("cursor", this.cursorHandler), this.editor && this.changeHandler && this.editor.off("change", this.changeHandler), typeof document != "undefined") {
2694
2825
  const t = document.getElementById(this.highlightStyleId);
2695
2826
  t != null && t.parentNode && t.parentNode.removeChild(t);
2696
2827
  }
2697
2828
  this.cursorHandler = null, this.changeHandler = null, this.editor = null;
2698
2829
  }
2699
2830
  }
2700
- class ae {
2831
+ class oe {
2701
2832
  constructor() {
2702
2833
  this.name = "code-folding", this.lineHeight = 21, this.voidMarkupTags = /* @__PURE__ */ new Set([
2703
2834
  "area",
@@ -2797,14 +2928,14 @@ class ae {
2797
2928
  const e = this.editor.getValue(), t = this.getActiveFolds().map((r) => this.getFoldKey(r)).join("|"), i = `${e}::${t}`;
2798
2929
  if (i === this.lastSnapshot) return;
2799
2930
  this.lastSnapshot = i, this.foldingUI.innerHTML = "";
2800
- const s = this.getRenderableActiveFolds(), n = document.createDocumentFragment();
2931
+ const n = this.getRenderableActiveFolds(), s = document.createDocumentFragment();
2801
2932
  for (const r of this.foldRegions) {
2802
- const o = this.toDisplayLine(r, s);
2933
+ const o = this.toDisplayLine(r, n);
2803
2934
  if (o === null) continue;
2804
2935
  const l = this.isFoldActive(r), a = this.createFoldIndicator(r, o, l);
2805
- n.appendChild(a);
2936
+ s.appendChild(a);
2806
2937
  }
2807
- this.foldingUI.appendChild(n);
2938
+ this.foldingUI.appendChild(s);
2808
2939
  }
2809
2940
  buildFoldRegions(e) {
2810
2941
  const t = this.buildBracketFoldRegions(e), i = this.shouldIncludeMarkupFolds(e) ? this.buildMarkupFoldRegions(e) : [];
@@ -2813,7 +2944,7 @@ class ae {
2813
2944
  buildBracketFoldRegions(e) {
2814
2945
  var o;
2815
2946
  const t = e.split(`
2816
- `), i = [], s = [], n = {
2947
+ `), i = [], n = [], s = {
2817
2948
  "{": "}",
2818
2949
  "[": "]",
2819
2950
  "(": ")"
@@ -2825,38 +2956,38 @@ class ae {
2825
2956
  for (let l = 0; l < t.length; l++) {
2826
2957
  const a = t[l];
2827
2958
  for (let h = 0; h < a.length; h++) {
2828
- const d = a[h];
2829
- if (n[d]) {
2830
- i.push({ char: d, line: l, column: h });
2959
+ const c = a[h];
2960
+ if (s[c]) {
2961
+ i.push({ char: c, line: l, column: h });
2831
2962
  continue;
2832
2963
  }
2833
- const c = r[d];
2834
- if (!c) continue;
2835
- let u = -1;
2964
+ const d = r[c];
2965
+ if (!d) continue;
2966
+ let f = -1;
2836
2967
  for (let m = i.length - 1; m >= 0; m--)
2837
- if (i[m].char === c) {
2838
- u = m;
2968
+ if (i[m].char === d) {
2969
+ f = m;
2839
2970
  break;
2840
2971
  }
2841
- if (u === -1) continue;
2842
- const g = i.splice(u, 1)[0];
2843
- if (g.line >= l) continue;
2844
- const f = ((o = t[g.line]) == null ? void 0 : o.length) || 0, p = {
2845
- start: { line: g.line, column: f },
2972
+ if (f === -1) continue;
2973
+ const u = i.splice(f, 1)[0];
2974
+ if (u.line >= l) continue;
2975
+ const g = ((o = t[u.line]) == null ? void 0 : o.length) || 0, p = {
2976
+ start: { line: u.line, column: g },
2846
2977
  end: { line: l, column: 0 },
2847
2978
  collapsed: !1,
2848
- level: u
2979
+ level: f
2849
2980
  };
2850
- this.isValidFoldRegion(p) && s.push(p);
2981
+ this.isValidFoldRegion(p) && n.push(p);
2851
2982
  }
2852
2983
  }
2853
- return s.sort((l, a) => l.start.line !== a.start.line ? l.start.line - a.start.line : l.end.line !== a.end.line ? l.end.line - a.end.line : l.start.column - a.start.column), s;
2984
+ return n.sort((l, a) => l.start.line !== a.start.line ? l.start.line - a.start.line : l.end.line !== a.end.line ? l.end.line - a.end.line : l.start.column - a.start.column), n;
2854
2985
  }
2855
2986
  shouldIncludeMarkupFolds(e) {
2856
2987
  return /<!DOCTYPE\b/i.test(e) || /<[A-Za-z][\w:-]*(?:\s|>)/.test(e) && /<\/[A-Za-z][\w:-]*\s*>/.test(e);
2857
2988
  }
2858
2989
  buildMarkupFoldRegions(e) {
2859
- const { lineStarts: t, lines: i } = this.buildLineStarts(e), s = [], n = [];
2990
+ const { lineStarts: t, lines: i } = this.buildLineStarts(e), n = [], s = [];
2860
2991
  let r = 0;
2861
2992
  for (; r < e.length; ) {
2862
2993
  if (e[r] !== "<") {
@@ -2879,15 +3010,15 @@ class ae {
2879
3010
  continue;
2880
3011
  }
2881
3012
  if (r = o.endOffset, o.isClosing) {
2882
- const l = n.findIndex((d) => d.name === o.name);
3013
+ const l = s.findIndex((c) => c.name === o.name);
2883
3014
  if (l === -1)
2884
3015
  continue;
2885
- const a = n.splice(l, 1)[0], h = this.createMarkupFoldRegion(
3016
+ const a = s.splice(l, 1)[0], h = this.createMarkupFoldRegion(
2886
3017
  a.openEndLine,
2887
3018
  o.startLine,
2888
3019
  i
2889
3020
  );
2890
- h && s.push(h);
3021
+ h && n.push(h);
2891
3022
  continue;
2892
3023
  }
2893
3024
  if (!(o.isSelfClosing || this.voidMarkupTags.has(o.name))) {
@@ -2905,25 +3036,25 @@ class ae {
2905
3036
  l.startLine,
2906
3037
  i
2907
3038
  );
2908
- a && s.push(a), r = l.endOffset;
3039
+ a && n.push(a), r = l.endOffset;
2909
3040
  }
2910
3041
  continue;
2911
3042
  }
2912
- this.nonFoldableInlineMarkupTags.has(o.name) || n.unshift({
3043
+ this.nonFoldableInlineMarkupTags.has(o.name) || s.unshift({
2913
3044
  name: o.name,
2914
3045
  openEndLine: o.endLine
2915
3046
  });
2916
3047
  }
2917
3048
  }
2918
- return s;
3049
+ return n;
2919
3050
  }
2920
- parseMarkupTag(e, t, i, s) {
3051
+ parseMarkupTag(e, t, i, n) {
2921
3052
  if (e[t] !== "<")
2922
3053
  return null;
2923
- const n = e[t + 1];
2924
- if (!n || n !== "/" && !/[A-Za-z]/.test(n))
3054
+ const s = e[t + 1];
3055
+ if (!s || s !== "/" && !/[A-Za-z]/.test(s))
2925
3056
  return null;
2926
- const r = n === "/";
3057
+ const r = s === "/";
2927
3058
  let o = t + (r ? 2 : 1);
2928
3059
  const l = o;
2929
3060
  for (; o < e.length && /[A-Za-z0-9:-]/.test(e[o]); )
@@ -2933,39 +3064,39 @@ class ae {
2933
3064
  return null;
2934
3065
  let h = null;
2935
3066
  for (; o < e.length; ) {
2936
- const f = e[o];
3067
+ const g = e[o];
2937
3068
  if (h) {
2938
- f === h && (h = null), o += 1;
3069
+ g === h && (h = null), o += 1;
2939
3070
  continue;
2940
3071
  }
2941
- if (f === '"' || f === "'") {
2942
- h = f, o += 1;
3072
+ if (g === '"' || g === "'") {
3073
+ h = g, o += 1;
2943
3074
  continue;
2944
3075
  }
2945
- if (f === ">")
3076
+ if (g === ">")
2946
3077
  break;
2947
3078
  o += 1;
2948
3079
  }
2949
3080
  if (o >= e.length || e[o] !== ">")
2950
3081
  return null;
2951
- const d = e.slice(l, a).toLowerCase();
2952
- if (!d)
3082
+ const c = e.slice(l, a).toLowerCase();
3083
+ if (!c)
2953
3084
  return null;
2954
- const c = e.slice(t, o + 1), u = this.offsetToLine(t, i, s), g = this.offsetToLine(o, i, s);
3085
+ const d = e.slice(t, o + 1), f = this.offsetToLine(t, i, n), u = this.offsetToLine(o, i, n);
2955
3086
  return {
2956
- name: d,
3087
+ name: c,
2957
3088
  isClosing: r,
2958
- isSelfClosing: !r && /\/\s*>$/.test(c),
2959
- startLine: u,
2960
- endLine: g,
3089
+ isSelfClosing: !r && /\/\s*>$/.test(d),
3090
+ startLine: f,
3091
+ endLine: u,
2961
3092
  endOffset: o + 1
2962
3093
  };
2963
3094
  }
2964
- findClosingMarkupTag(e, t, i, s, n) {
3095
+ findClosingMarkupTag(e, t, i, n, s) {
2965
3096
  const r = `</${i}`, o = e.toLowerCase();
2966
3097
  let l = o.indexOf(r, t);
2967
3098
  for (; l !== -1; ) {
2968
- const a = this.parseMarkupTag(e, l, s, n);
3099
+ const a = this.parseMarkupTag(e, l, n, s);
2969
3100
  if (a && a.isClosing && a.name === i)
2970
3101
  return {
2971
3102
  startLine: a.startLine,
@@ -2979,13 +3110,13 @@ class ae {
2979
3110
  var o;
2980
3111
  if (e >= t)
2981
3112
  return null;
2982
- const s = Math.max(0, Math.min(e, i.length - 1)), n = Math.max(0, Math.min(t, i.length - 1)), r = {
3113
+ const n = Math.max(0, Math.min(e, i.length - 1)), s = Math.max(0, Math.min(t, i.length - 1)), r = {
2983
3114
  start: {
2984
- line: s,
2985
- column: ((o = i[s]) == null ? void 0 : o.length) || 0
3115
+ line: n,
3116
+ column: ((o = i[n]) == null ? void 0 : o.length) || 0
2986
3117
  },
2987
3118
  end: {
2988
- line: n,
3119
+ line: s,
2989
3120
  column: 0
2990
3121
  },
2991
3122
  collapsed: !1,
@@ -2997,11 +3128,11 @@ class ae {
2997
3128
  const t = /* @__PURE__ */ new Map();
2998
3129
  for (const i of e)
2999
3130
  this.isValidFoldRegion(i) && t.set(this.getFoldKey(i), i);
3000
- return [...t.values()].sort((i, s) => i.start.line !== s.start.line ? i.start.line - s.start.line : i.end.line !== s.end.line ? i.end.line - s.end.line : i.start.column - s.start.column);
3131
+ return [...t.values()].sort((i, n) => i.start.line !== n.start.line ? i.start.line - n.start.line : i.end.line !== n.end.line ? i.end.line - n.end.line : i.start.column - n.start.column);
3001
3132
  }
3002
3133
  createFoldIndicator(e, t, i) {
3003
- const s = document.createElement("button");
3004
- return s.type = "button", s.style.cssText = `
3134
+ const n = document.createElement("button");
3135
+ return n.type = "button", n.style.cssText = `
3005
3136
  position: absolute;
3006
3137
  left: 0;
3007
3138
  top: ${t * this.lineHeight}px;
@@ -3018,11 +3149,11 @@ class ae {
3018
3149
  padding: 0;
3019
3150
  font-size: 10px;
3020
3151
  user-select: none;
3021
- `, s.textContent = i ? "▶" : "▼", s.title = i ? "Expand folded region" : "Collapse region", s.setAttribute("aria-label", s.title), s.addEventListener("mousedown", (n) => {
3022
- n.preventDefault();
3023
- }), s.addEventListener("click", (n) => {
3024
- n.preventDefault(), n.stopPropagation(), this.toggleFold(e);
3025
- }), s;
3152
+ `, n.textContent = i ? "▶" : "▼", n.title = i ? "Expand folded region" : "Collapse region", n.setAttribute("aria-label", n.title), n.addEventListener("mousedown", (s) => {
3153
+ s.preventDefault();
3154
+ }), n.addEventListener("click", (s) => {
3155
+ s.preventDefault(), s.stopPropagation(), this.toggleFold(e);
3156
+ }), n;
3026
3157
  }
3027
3158
  toggleFold(e) {
3028
3159
  this.editor && (this.isFoldActive(e) ? this.editor.unfold(e) : this.editor.fold(e), this.syncFoldingStatePreservingScroll());
@@ -3057,14 +3188,14 @@ class ae {
3057
3188
  });
3058
3189
  }
3059
3190
  withPreservedScroll(e) {
3060
- var n;
3061
- const t = (n = this.editor) == null ? void 0 : n.getView().getScrollElement();
3191
+ var s;
3192
+ const t = (s = this.editor) == null ? void 0 : s.getView().getScrollElement();
3062
3193
  if (!t) {
3063
3194
  e();
3064
3195
  return;
3065
3196
  }
3066
- const i = t.scrollLeft, s = t.scrollTop;
3067
- e(), this.restoreScrollPosition(t, i, s);
3197
+ const i = t.scrollLeft, n = t.scrollTop;
3198
+ e(), this.restoreScrollPosition(t, i, n);
3068
3199
  }
3069
3200
  restoreScrollPosition(e, t, i) {
3070
3201
  e.scrollLeft = t, e.scrollTop = i, requestAnimationFrame(() => {
@@ -3098,39 +3229,39 @@ class ae {
3098
3229
  this.editor.getView().setText(e);
3099
3230
  }
3100
3231
  buildFoldedProjection(e, t) {
3101
- const { lineStarts: i, lines: s } = this.buildLineStarts(e), n = [...t].sort((h, d) => this.comparePositions(h.start, d.start));
3232
+ const { lineStarts: i, lines: n } = this.buildLineStarts(e), s = [...t].sort((h, c) => this.comparePositions(h.start, c.start));
3102
3233
  let r = "";
3103
3234
  const o = [];
3104
3235
  let l = 0;
3105
- for (const h of n) {
3106
- const d = this.positionToOffset(h.start, i, s), c = this.positionToOffset(h.end, i, s), u = e.slice(l, d), g = this.getFoldPlaceholder(h), f = e.slice(d, c);
3107
- r += u, r += g, u && o.push({ type: "text", text: u }), o.push({
3236
+ for (const h of s) {
3237
+ const c = this.positionToOffset(h.start, i, n), d = this.positionToOffset(h.end, i, n), f = e.slice(l, c), u = this.getFoldPlaceholder(h), g = e.slice(c, d);
3238
+ r += f, r += u, f && o.push({ type: "text", text: f }), o.push({
3108
3239
  type: "placeholder",
3109
- text: g,
3240
+ text: u,
3110
3241
  fold: h,
3111
- hiddenText: f
3112
- }), l = c;
3242
+ hiddenText: g
3243
+ }), l = d;
3113
3244
  }
3114
3245
  const a = e.slice(l);
3115
3246
  return r += a, a && o.push({ type: "text", text: a }), { text: r, segments: o };
3116
3247
  }
3117
3248
  renderFoldPlaceholders(e) {
3118
3249
  if (!this.editor) return;
3119
- const t = this.editor.getView().getContentElement(), i = /* @__PURE__ */ new Map(), s = document.createDocumentFragment();
3120
- for (const n of e.segments) {
3121
- if (n.type === "text") {
3122
- s.appendChild(document.createTextNode(n.text));
3250
+ const t = this.editor.getView().getContentElement(), i = /* @__PURE__ */ new Map(), n = document.createDocumentFragment();
3251
+ for (const s of e.segments) {
3252
+ if (s.type === "text") {
3253
+ n.appendChild(document.createTextNode(s.text));
3123
3254
  continue;
3124
3255
  }
3125
- const r = document.createElement("span"), o = this.getFoldKey(n.fold);
3126
- r.setAttribute("data-lce-fold-placeholder", o), r.setAttribute("aria-label", "Folded region"), r.contentEditable = "false", i.set(o, n.hiddenText), r.style.cssText = `
3256
+ const r = document.createElement("span"), o = this.getFoldKey(s.fold);
3257
+ r.setAttribute("data-lce-fold-placeholder", o), r.setAttribute("aria-label", "Folded region"), r.contentEditable = "false", i.set(o, s.hiddenText), r.style.cssText = `
3127
3258
  cursor: text;
3128
3259
  user-select: text;
3129
3260
  pointer-events: auto;
3130
3261
  white-space: pre;
3131
- `, r.textContent = n.text, s.appendChild(r);
3262
+ `, r.textContent = s.text, n.appendChild(r);
3132
3263
  }
3133
- t.replaceChildren(s), t.__lceFoldPlaceholderSources = i, this.editor.getView().syncTrailingNewlineMarkerForText(e.text);
3264
+ t.replaceChildren(n), t.__lceFoldPlaceholderSources = i, this.editor.getView().syncTrailingNewlineMarkerForText(e.text);
3134
3265
  }
3135
3266
  getFoldPlaceholder(e) {
3136
3267
  const t = Math.max(1, e.end.line - e.start.line);
@@ -3138,7 +3269,7 @@ class ae {
3138
3269
  }
3139
3270
  pruneInvalidFolds(e, t) {
3140
3271
  if (!this.editor) return;
3141
- const i = this.editor.getFolds().filter((a) => a.collapsed !== !1), s = new Set(i.map((a) => this.getFoldKey(a))), n = [], r = /* @__PURE__ */ new Set(), o = this.getLineInfo(e);
3272
+ const i = this.editor.getFolds().filter((a) => a.collapsed !== !1), n = new Set(i.map((a) => this.getFoldKey(a))), s = [], r = /* @__PURE__ */ new Set(), o = this.getLineInfo(e);
3142
3273
  for (const a of i) {
3143
3274
  const h = this.findReplacementFold(
3144
3275
  a,
@@ -3149,14 +3280,14 @@ class ae {
3149
3280
  );
3150
3281
  if (!h)
3151
3282
  continue;
3152
- const d = this.getFoldKey(h);
3153
- n.push(h), r.add(d);
3283
+ const c = this.getFoldKey(h);
3284
+ s.push(h), r.add(c);
3154
3285
  }
3155
- const l = new Set(n.map((a) => this.getFoldKey(a)));
3286
+ const l = new Set(s.map((a) => this.getFoldKey(a)));
3156
3287
  for (const a of i)
3157
3288
  l.has(this.getFoldKey(a)) || this.editor.unfold(a);
3158
- for (const a of n)
3159
- s.has(this.getFoldKey(a)) || this.editor.fold(a);
3289
+ for (const a of s)
3290
+ n.has(this.getFoldKey(a)) || this.editor.fold(a);
3160
3291
  }
3161
3292
  getActiveFolds() {
3162
3293
  return this.editor ? this.editor.getFolds().filter((e) => e.collapsed !== !1) : [];
@@ -3168,80 +3299,80 @@ class ae {
3168
3299
  return this.getTopLevelFoldRegions(this.getActiveFolds());
3169
3300
  }
3170
3301
  getTopLevelFoldRegions(e) {
3171
- const t = [...e].sort((s, n) => this.comparePositions(s.start, n.start)), i = [];
3172
- for (const s of t) {
3173
- const n = i[i.length - 1];
3174
- n && this.containsRange(n, s) || i.push(s);
3302
+ const t = [...e].sort((n, s) => this.comparePositions(n.start, s.start)), i = [];
3303
+ for (const n of t) {
3304
+ const s = i[i.length - 1];
3305
+ s && this.containsRange(s, n) || i.push(n);
3175
3306
  }
3176
3307
  return i;
3177
3308
  }
3178
3309
  toDisplayLine(e, t) {
3179
3310
  let i = 0;
3180
- for (const s of t) {
3181
- if (this.isSameRange(s, e))
3311
+ for (const n of t) {
3312
+ if (this.isSameRange(n, e))
3182
3313
  break;
3183
- if (this.containsRange(s, e))
3314
+ if (this.containsRange(n, e))
3184
3315
  return null;
3185
- s.end.line <= e.start.line && (i += s.end.line - s.start.line);
3316
+ n.end.line <= e.start.line && (i += n.end.line - n.start.line);
3186
3317
  }
3187
3318
  return e.start.line - i;
3188
3319
  }
3189
3320
  findBestRegionForLine(e, t) {
3190
- const i = (t ? this.getActiveFolds() : this.foldRegions).filter(
3321
+ const n = (t ? this.getActiveFolds() : this.foldRegions).filter(
3191
3322
  (s) => s.start.line <= e && s.end.line >= e
3192
3323
  );
3193
- return i.length === 0 ? null : (i.sort((s, n) => {
3194
- const r = s.end.line - s.start.line, o = n.end.line - n.start.line;
3195
- return r !== o ? r - o : this.comparePositions(s.start, n.start);
3196
- }), i[0]);
3324
+ return n.length === 0 ? null : (n.sort((s, r) => {
3325
+ const o = s.end.line - s.start.line, l = r.end.line - r.start.line;
3326
+ return o !== l ? o - l : this.comparePositions(s.start, r.start);
3327
+ }), n[0]);
3197
3328
  }
3198
- findReplacementFold(e, t, i, s, n) {
3329
+ findReplacementFold(e, t, i, n, s) {
3199
3330
  const r = this.getFoldKey(e), o = this.foldRegions.find(
3200
- (c) => this.getFoldKey(c) === r && !i.has(r)
3331
+ (u) => this.getFoldKey(u) === r && !i.has(r)
3201
3332
  );
3202
3333
  if (o)
3203
3334
  return o;
3204
- const l = e.end.line - e.start.line, a = t != null ? t : this.createFoldSnapshot(e, s, n), h = this.foldRegions.filter((c) => !i.has(this.getFoldKey(c))).map((c) => {
3205
- const u = this.createFoldSnapshot(c, s, n), g = a && (u == null ? void 0 : u.startLineText) === a.startLineText ? 1 : 0, f = a && (u == null ? void 0 : u.endLineText) === a.endLineText ? 1 : 0, p = a && (u == null ? void 0 : u.lineSpan) === a.lineSpan ? 1 : 0;
3335
+ const l = e.end.line - e.start.line, a = t != null ? t : this.createFoldSnapshot(e, n, s), c = this.foldRegions.filter((u) => !i.has(this.getFoldKey(u))).map((u) => {
3336
+ const g = this.createFoldSnapshot(u, n, s), p = a && (g == null ? void 0 : g.startLineText) === a.startLineText ? 1 : 0, m = a && (g == null ? void 0 : g.endLineText) === a.endLineText ? 1 : 0, y = a && (g == null ? void 0 : g.lineSpan) === a.lineSpan ? 1 : 0;
3206
3337
  return {
3207
- region: c,
3208
- overlaps: this.lineRangeOverlap(e, c),
3209
- lineDistance: Math.abs(c.start.line - e.start.line) + Math.abs(c.end.line - e.end.line),
3338
+ region: u,
3339
+ overlaps: this.lineRangeOverlap(e, u),
3340
+ lineDistance: Math.abs(u.start.line - e.start.line) + Math.abs(u.end.line - e.end.line),
3210
3341
  spanDistance: Math.abs(
3211
- c.end.line - c.start.line - l
3342
+ u.end.line - u.start.line - l
3212
3343
  ),
3213
- columnDistance: Math.abs(c.start.column - e.start.column) + Math.abs(c.end.column - e.end.column),
3214
- hiddenTextMatch: a && (u == null ? void 0 : u.hiddenText) === a.hiddenText ? 1 : 0,
3215
- boundaryMatchScore: g + f + p
3344
+ columnDistance: Math.abs(u.start.column - e.start.column) + Math.abs(u.end.column - e.end.column),
3345
+ hiddenTextMatch: a && (g == null ? void 0 : g.hiddenText) === a.hiddenText ? 1 : 0,
3346
+ boundaryMatchScore: p + m + y
3216
3347
  };
3217
- }).sort((c, u) => c.hiddenTextMatch !== u.hiddenTextMatch ? u.hiddenTextMatch - c.hiddenTextMatch : c.boundaryMatchScore !== u.boundaryMatchScore ? u.boundaryMatchScore - c.boundaryMatchScore : c.overlaps !== u.overlaps ? u.overlaps - c.overlaps : c.lineDistance !== u.lineDistance ? c.lineDistance - u.lineDistance : c.spanDistance !== u.spanDistance ? c.spanDistance - u.spanDistance : c.columnDistance - u.columnDistance)[0];
3218
- if (!h)
3348
+ }).sort((u, g) => u.hiddenTextMatch !== g.hiddenTextMatch ? g.hiddenTextMatch - u.hiddenTextMatch : u.boundaryMatchScore !== g.boundaryMatchScore ? g.boundaryMatchScore - u.boundaryMatchScore : u.overlaps !== g.overlaps ? g.overlaps - u.overlaps : u.lineDistance !== g.lineDistance ? u.lineDistance - g.lineDistance : u.spanDistance !== g.spanDistance ? u.spanDistance - g.spanDistance : u.columnDistance - g.columnDistance)[0];
3349
+ if (!c)
3219
3350
  return null;
3220
- const d = h.lineDistance <= 2 && h.spanDistance <= 1;
3221
- return !(h.hiddenTextMatch === 1 || h.boundaryMatchScore >= 2) && !d ? null : h.region;
3351
+ const d = c.lineDistance <= 2 && c.spanDistance <= 1;
3352
+ return !(c.hiddenTextMatch === 1 || c.boundaryMatchScore >= 2) && !d ? null : c.region;
3222
3353
  }
3223
3354
  lineRangeOverlap(e, t) {
3224
- const i = Math.max(e.start.line, t.start.line), s = Math.min(e.end.line, t.end.line);
3225
- return Math.max(0, s - i);
3355
+ const i = Math.max(e.start.line, t.start.line), n = Math.min(e.end.line, t.end.line);
3356
+ return Math.max(0, n - i);
3226
3357
  }
3227
3358
  rememberActiveFoldSnapshots(e) {
3228
3359
  const t = /* @__PURE__ */ new Map(), i = this.getLineInfo(e);
3229
- for (const s of this.getActiveFolds()) {
3230
- const n = this.createFoldSnapshot(s, e, i);
3231
- n && t.set(this.getFoldKey(s), n);
3360
+ for (const n of this.getActiveFolds()) {
3361
+ const s = this.createFoldSnapshot(n, e, i);
3362
+ s && t.set(this.getFoldKey(n), s);
3232
3363
  }
3233
3364
  this.foldSnapshots = t;
3234
3365
  }
3235
3366
  createFoldSnapshot(e, t, i = this.getLineInfo(t)) {
3236
- var h, d;
3237
- const { lineStarts: s, lines: n } = i;
3238
- if (n.length === 0)
3367
+ var h, c;
3368
+ const { lineStarts: n, lines: s } = i;
3369
+ if (s.length === 0)
3239
3370
  return null;
3240
- const r = this.positionToOffset(e.start, s, n), o = this.positionToOffset(e.end, s, n), l = Math.max(0, Math.min(e.start.line, n.length - 1)), a = Math.max(0, Math.min(e.end.line, n.length - 1));
3371
+ const r = this.positionToOffset(e.start, n, s), o = this.positionToOffset(e.end, n, s), l = Math.max(0, Math.min(e.start.line, s.length - 1)), a = Math.max(0, Math.min(e.end.line, s.length - 1));
3241
3372
  return {
3242
3373
  hiddenText: t.slice(r, o),
3243
- startLineText: (h = n[l]) != null ? h : "",
3244
- endLineText: (d = n[a]) != null ? d : "",
3374
+ startLineText: (h = s[l]) != null ? h : "",
3375
+ endLineText: (c = s[a]) != null ? c : "",
3245
3376
  lineSpan: e.end.line - e.start.line
3246
3377
  };
3247
3378
  }
@@ -3251,22 +3382,22 @@ class ae {
3251
3382
  e();
3252
3383
  return;
3253
3384
  }
3254
- const t = this.editor.getView(), i = t.getContentElement(), s = document.activeElement === i, n = t.getSelectionOffsets(), r = n.isInEditor;
3385
+ const t = this.editor.getView(), i = t.getContentElement(), n = document.activeElement === i, s = t.getSelectionOffsets(), r = s.isInEditor;
3255
3386
  if (e(), !r)
3256
3387
  return;
3257
3388
  const o = this.remapSelectionOffsetsForVisibleDisplay(
3258
- (l = n.anchorOffset) != null ? l : n.startOffset,
3259
- (a = n.focusOffset) != null ? a : n.endOffset
3389
+ (l = s.anchorOffset) != null ? l : s.startOffset,
3390
+ (a = s.focusOffset) != null ? a : s.endOffset
3260
3391
  );
3261
3392
  t.setSelectionBoundaryOffsets(
3262
3393
  o.startOffset,
3263
3394
  o.endOffset
3264
- ), (s || n.isInEditor) && this.editor.focus();
3395
+ ), (n || s.isInEditor) && this.editor.focus();
3265
3396
  }
3266
3397
  remapSelectionOffsetsForVisibleDisplay(e, t) {
3267
3398
  if (!this.editor)
3268
3399
  return { startOffset: e, endOffset: t };
3269
- const i = this.editor.getValue(), { lineStarts: s, lines: n } = this.getLineInfo(i), r = this.getRenderableActiveFolds();
3400
+ const i = this.editor.getValue(), { lineStarts: n, lines: s } = this.getLineInfo(i), r = this.getRenderableActiveFolds();
3270
3401
  if (r.length === 0) {
3271
3402
  const o = i.length;
3272
3403
  return {
@@ -3278,36 +3409,36 @@ class ae {
3278
3409
  startOffset: this.remapOffsetToVisibleBoundary(
3279
3410
  e,
3280
3411
  r,
3281
- s,
3282
3412
  n,
3413
+ s,
3283
3414
  i.length
3284
3415
  ),
3285
3416
  endOffset: this.remapOffsetToVisibleBoundary(
3286
3417
  t,
3287
3418
  r,
3288
- s,
3289
3419
  n,
3420
+ s,
3290
3421
  i.length
3291
3422
  )
3292
3423
  };
3293
3424
  }
3294
- remapOffsetToVisibleBoundary(e, t, i, s, n) {
3295
- const r = Math.max(0, Math.min(e, n));
3425
+ remapOffsetToVisibleBoundary(e, t, i, n, s) {
3426
+ const r = Math.max(0, Math.min(e, s));
3296
3427
  for (const o of t) {
3297
- const l = this.positionToOffset(o.start, i, s), a = this.positionToOffset(o.end, i, s);
3428
+ const l = this.positionToOffset(o.start, i, n), a = this.positionToOffset(o.end, i, n);
3298
3429
  if (r <= l || r >= a)
3299
3430
  continue;
3300
- const h = r - l, d = a - r;
3301
- return h <= d ? l : a;
3431
+ const h = r - l, c = a - r;
3432
+ return h <= c ? l : a;
3302
3433
  }
3303
3434
  return r;
3304
3435
  }
3305
3436
  buildLineStarts(e) {
3306
3437
  const t = e.split(`
3307
3438
  `), i = new Array(t.length);
3308
- let s = 0;
3309
- for (let n = 0; n < t.length; n++)
3310
- i[n] = s, s += t[n].length + 1;
3439
+ let n = 0;
3440
+ for (let s = 0; s < t.length; s++)
3441
+ i[s] = n, n += t[s].length + 1;
3311
3442
  return { lineStarts: i, lines: t };
3312
3443
  }
3313
3444
  getLineInfo(e) {
@@ -3322,15 +3453,15 @@ class ae {
3322
3453
  }
3323
3454
  offsetToLine(e, t, i) {
3324
3455
  var l;
3325
- const s = t.length > 0 ? t[t.length - 1] + (((l = i[i.length - 1]) == null ? void 0 : l.length) || 0) : 0, n = Math.max(0, Math.min(e, s));
3456
+ const n = t.length > 0 ? t[t.length - 1] + (((l = i[i.length - 1]) == null ? void 0 : l.length) || 0) : 0, s = Math.max(0, Math.min(e, n));
3326
3457
  let r = 0, o = t.length - 1;
3327
3458
  for (; r <= o; ) {
3328
- const a = Math.floor((r + o) / 2), h = t[a], d = a + 1 < t.length ? t[a + 1] : Number.POSITIVE_INFINITY;
3329
- if (n < h) {
3459
+ const a = Math.floor((r + o) / 2), h = t[a], c = a + 1 < t.length ? t[a + 1] : Number.POSITIVE_INFINITY;
3460
+ if (s < h) {
3330
3461
  o = a - 1;
3331
3462
  continue;
3332
3463
  }
3333
- if (n >= d) {
3464
+ if (s >= c) {
3334
3465
  r = a + 1;
3335
3466
  continue;
3336
3467
  }
@@ -3340,8 +3471,8 @@ class ae {
3340
3471
  }
3341
3472
  positionToOffset(e, t, i) {
3342
3473
  var r;
3343
- const s = Math.max(0, Math.min(e.line, i.length - 1)), n = Math.max(0, Math.min(e.column, ((r = i[s]) == null ? void 0 : r.length) || 0));
3344
- return t[s] + n;
3474
+ const n = Math.max(0, Math.min(e.line, i.length - 1)), s = Math.max(0, Math.min(e.column, ((r = i[n]) == null ? void 0 : r.length) || 0));
3475
+ return t[n] + s;
3345
3476
  }
3346
3477
  comparePositions(e, t) {
3347
3478
  return e.line !== t.line ? e.line - t.line : e.column - t.column;
@@ -3365,7 +3496,7 @@ class ae {
3365
3496
  this.pendingUpdateRaf !== null && (cancelAnimationFrame(this.pendingUpdateRaf), this.pendingUpdateRaf = null), this.editor && this.changeHandler && this.editor.off("change", this.changeHandler), this.foldingUI && this.foldingUI.parentNode && this.foldingUI.parentNode.removeChild(this.foldingUI), this.restoreFullDisplay(), this.changeHandler = null, this.lastSnapshot = "", this.lastParsedText = null, this.foldingUI = null, this.foldRegions = [], this.cachedLineInfo = null, this.editor = null;
3366
3497
  }
3367
3498
  }
3368
- class he {
3499
+ class le {
3369
3500
  constructor() {
3370
3501
  this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
3371
3502
  }
@@ -3432,10 +3563,10 @@ class he {
3432
3563
  }
3433
3564
  // Public API: highlight a source string using the chosen mode (or detect html)
3434
3565
  highlight(e, t) {
3435
- const i = this.getSyntaxColors(), s = this.normalizeLanguageId(
3566
+ const i = this.getSyntaxColors(), n = this.normalizeLanguageId(
3436
3567
  t || this.currentLanguage || this.detectLanguage(e) || "html"
3437
3568
  );
3438
- return (this.modes.get(s) || this.modes.get("html")).highlight(e, i);
3569
+ return (this.modes.get(n) || this.modes.get("html")).highlight(e, i);
3439
3570
  }
3440
3571
  // Backwards-compatible method
3441
3572
  highlightHTML(e) {
@@ -3481,24 +3612,24 @@ class he {
3481
3612
  }[t] || t || "html";
3482
3613
  }
3483
3614
  restoreHighlightTokens(e, t) {
3484
- return e.replace(/\u0000([a-z]+)\u0000/g, (i, s) => {
3485
- let n = 0;
3486
- for (let r = 0; r < s.length; r++)
3487
- n = n * 26 + (s.charCodeAt(r) - 97 + 1);
3488
- return n = n - 1, t[n] || "";
3615
+ return e.replace(/\u0000([a-z]+)\u0000/g, (i, n) => {
3616
+ let s = 0;
3617
+ for (let r = 0; r < n.length; r++)
3618
+ s = s * 26 + (n.charCodeAt(r) - 97 + 1);
3619
+ return s = s - 1, t[s] || "";
3489
3620
  });
3490
3621
  }
3491
3622
  createTokenStore(e) {
3492
3623
  const t = (i) => {
3493
- let s = "", n = i;
3624
+ let n = "", s = i;
3494
3625
  do
3495
- s = String.fromCharCode(97 + n % 26) + s, n = Math.floor(n / 26) - 1;
3496
- while (n >= 0);
3497
- return s || "a";
3626
+ n = String.fromCharCode(97 + s % 26) + n, s = Math.floor(s / 26) - 1;
3627
+ while (s >= 0);
3628
+ return n || "a";
3498
3629
  };
3499
3630
  return (i) => {
3500
- const s = e.length;
3501
- return e.push(i), `\0${t(s)}\0`;
3631
+ const n = e.length;
3632
+ return e.push(i), `\0${t(n)}\0`;
3502
3633
  };
3503
3634
  }
3504
3635
  refreshEditorHighlight() {
@@ -3509,8 +3640,8 @@ class he {
3509
3640
  unescapeEntitiesRepeated(e) {
3510
3641
  let t = e || "";
3511
3642
  for (let i = 0; i < 5; i++) {
3512
- const s = t;
3513
- if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === s) break;
3643
+ const n = t;
3644
+ if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === n) break;
3514
3645
  }
3515
3646
  return t;
3516
3647
  }
@@ -3523,9 +3654,9 @@ class he {
3523
3654
  if (/^[\[{]/.test(t) && /[\]}]$/.test(t) || /"[^"]+"\s*:/.test(t))
3524
3655
  try {
3525
3656
  return JSON.parse(t), "json";
3526
- } catch (o) {
3657
+ } catch (a) {
3527
3658
  }
3528
- const i = /<\/?[A-Za-z][\w:-]*(?:\s|>|\/>)/.test(t), s = /^<!DOCTYPE\s+html\b/i.test(t) || /<\/?(html|head|body|meta|title|style|script)\b/i.test(t);
3659
+ const i = /<\/?[A-Za-z][\w:-]*(?:\s|>|\/>)/.test(t), n = /^<!DOCTYPE\s+html\b/i.test(t) || /<\/?(html|head|body|meta|title|style|script)\b/i.test(t);
3529
3660
  if ([
3530
3661
  /^---\s*\n[\s\S]*?\n---\s*(?:\n|$)/.test(t),
3531
3662
  /^#{1,6}\s+\S/m.test(t),
@@ -3540,13 +3671,13 @@ class he {
3540
3671
  /(^|\s)(?:\*\*|__)[^*_]+(?:\*\*|__)(?=\s|$|[.,;:!?])/m.test(t)
3541
3672
  ].filter(Boolean).length >= (i ? 2 : 1))
3542
3673
  return "markdown";
3543
- if (s)
3544
- return "html";
3545
- const n = this.detectProgrammingLanguage(t);
3546
3674
  if (n)
3547
- return n;
3548
- const r = /[{][\s\S]*[}]/.test(t) && /[A-Za-z_-][\w-]*\s*:\s*[^;{}]+;?/.test(t) && !/\b(function|const|let|var|return|class|interface|type)\b/.test(t);
3549
- return !i && r ? "css" : null;
3675
+ return "html";
3676
+ const o = this.detectProgrammingLanguage(t);
3677
+ if (o)
3678
+ return o;
3679
+ const l = /[{][\s\S]*[}]/.test(t) && /[A-Za-z_-][\w-]*\s*:\s*[^;{}]+;?/.test(t) && !/\b(function|const|let|var|return|class|interface|type)\b/.test(t);
3680
+ return !i && l ? "css" : null;
3550
3681
  }
3551
3682
  detectProgrammingLanguage(e) {
3552
3683
  const t = {
@@ -3566,155 +3697,155 @@ class he {
3566
3697
  o.test(e) && (t[r] += l);
3567
3698
  };
3568
3699
  i("python", /^\s*(from\s+\w+\s+import|import\s+\w+|def\s+\w+\s*\(|class\s+\w+|for\s+\w+\s+in\s+.+:|if\s+.+:|while\s+.+:|print\s*\()/m, 2), i("python", /^\s*[A-Za-z_]\w*\s*=\s*(?:\[|\{|\(|["']|\d)/m), i("python", /\b(True|False|None|self|elif|lambda|yield)\b/), i("go", /^\s*package\s+\w+/m, 3), i("go", /\bfunc\s+\w+\s*\(/, 2), i("go", /\b(import|defer|goroutine|chan|struct|interface)\b/), i("cpp", /^\s*#include\s*<[^>]+>/m, 2), i("cpp", /\b(std::|template\s*<|namespace\s+\w+|cout\s*<<|cin\s*>>)\b/, 2), i("cpp", /\b(class|public|private|protected|virtual|typename)\b/), i("c", /^\s*#include\s*[<"][^>"]+[>"]/m), i("c", /\b(int|char|float|double|void)\s+\w+\s*\(/), i("c", /\bprintf\s*\(/), i("java", /^\s*(package|import)\s+[\w.]+;/m, 2), i("java", /\b(public|private|protected)\s+(class|interface|enum)\s+\w+/, 2), i("java", /\bSystem\.out\.println\s*\(/), i("csharp", /^\s*using\s+[\w.]+;/m, 2), i("csharp", /\b(namespace|record|var|string|Console\.WriteLine)\b/), i("csharp", /\b(public|private|protected)\s+(class|interface|struct)\s+\w+/), i("rust", /\bfn\s+\w+\s*\(/, 2), i("rust", /\b(let\s+mut|impl\s+\w+|use\s+[\w:]+|println!\s*\()/), i("rust", /\b(crate|trait|enum|match|Some|None|Ok|Err)\b/), i("ruby", /^\s*(def|class|module)\s+\w+/m, 2), i("ruby", /\b(puts|require|attr_reader|elsif|end)\b/), i("sql", /^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)\b/im, 3), i("sql", /\bFROM\s+\w+|\bWHERE\s+/i), i("yaml", /^---\s*$/m), i("yaml", /^\s*[A-Za-z0-9_.-]+\s*:\s+\S/m, 2), i("yaml", /^\s*-\s+[A-Za-z0-9_.-]+\s*:/m), i("dockerfile", /^\s*FROM\s+\S+/im, 3), i("dockerfile", /^\s*(RUN|COPY|ADD|CMD|ENTRYPOINT|WORKDIR|ENV|ARG)\b/im, 2), i("php", /^<\?(?:php\b|=)/i, 3), i("php", /^\?php\b/i, 3), i("php", /\$[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*\s*=/, 2), i("php", /\b(echo|foreach|function|namespace|use|PHP_EOL)\b/, 2);
3569
- const [s, n] = Object.entries(t).sort((r, o) => o[1] - r[1])[0] || ["", 0];
3570
- return n >= 2 ? s : null;
3700
+ const [n, s] = Object.entries(t).sort((r, o) => o[1] - r[1])[0] || ["", 0];
3701
+ return s >= 2 ? n : null;
3571
3702
  }
3572
3703
  _highlightHTML(e, t) {
3573
- const i = t, s = (c) => this.escapeHTML(c), n = [], r = this.createTokenStore(n), o = [], l = (c) => {
3574
- const u = o.length;
3575
- return o.push(c), `ht${u}`;
3704
+ const i = t, n = (d) => this.escapeHTML(d), s = [], r = this.createTokenStore(s), o = [], l = (d) => {
3705
+ const f = o.length;
3706
+ return o.push(d), `ht${f}`;
3576
3707
  };
3577
- let a = s(e);
3708
+ let a = n(e);
3578
3709
  a = a.replace(
3579
3710
  /&lt;\/?(?:(?!&gt;)[^\n\r<])*?(?=$|[\n\r])/g,
3580
- (c) => l(c)
3711
+ (d) => l(d)
3581
3712
  );
3582
3713
  const h = [];
3583
3714
  try {
3584
- e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (c, u, g) => (h.push({ attrs: String(u || ""), inner: String(g || "") }), c));
3585
- } catch (c) {
3715
+ e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (d, f, u) => (h.push({ attrs: String(f || ""), inner: String(u || "") }), d));
3716
+ } catch (d) {
3586
3717
  }
3587
- let d = 0;
3588
- return a = a.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (c, u, g, f, p) => {
3589
- var v, T, w;
3590
- const m = (T = (v = h[d++]) == null ? void 0 : v.inner) != null ? T : this.unescapeEntitiesRepeated(f || "");
3591
- (((w = h[d - 1]) == null ? void 0 : w.attrs) || g || "").toLowerCase();
3592
- const x = this._highlightJS(m, i);
3593
- return `${u}${x}${p}`;
3594
- }), a = a.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (c, u, g, f) => {
3595
- const p = this._highlightCSS(this.unescapeEntitiesRepeated(g), i);
3596
- return `${u}${p}${f}`;
3718
+ let c = 0;
3719
+ return a = a.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (d, f, u, g, p) => {
3720
+ var T, S, v;
3721
+ const m = (S = (T = h[c++]) == null ? void 0 : T.inner) != null ? S : this.unescapeEntitiesRepeated(g || "");
3722
+ (((v = h[c - 1]) == null ? void 0 : v.attrs) || u || "").toLowerCase();
3723
+ const y = this._highlightJS(m, i);
3724
+ return `${f}${y}${p}`;
3725
+ }), a = a.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (d, f, u, g) => {
3726
+ const p = this._highlightCSS(this.unescapeEntitiesRepeated(u), i);
3727
+ return `${f}${p}${g}`;
3597
3728
  }), a = a.replace(
3598
3729
  /(&lt;!--[\s\S]*?--&gt;)/g,
3599
- (c) => r(`<span style="color: ${i.comment};">${c}</span>`)
3730
+ (d) => r(`<span style="color: ${i.comment};">${d}</span>`)
3600
3731
  ), a = a.replace(
3601
3732
  /(&lt;!DOCTYPE[\s\S]*?&gt;)/i,
3602
- (c) => r(`<span style="color: ${i.doctype};">${c}</span>`)
3603
- ), a = a.replace(/(&lt;\/?\s*)([^\s&>\/]+)([^<]*?)(\/?&gt;)/g, (c, u, g, f, p) => {
3604
- const m = `<span style="color: ${i.tag};">${g}</span>`;
3605
- let x = f;
3606
- return x = x.replace(
3733
+ (d) => r(`<span style="color: ${i.doctype};">${d}</span>`)
3734
+ ), a = a.replace(/(&lt;\/?\s*)([^\s&>\/]+)([^<]*?)(\/?&gt;)/g, (d, f, u, g, p) => {
3735
+ const m = `<span style="color: ${i.tag};">${u}</span>`;
3736
+ let y = g;
3737
+ return y = y.replace(
3607
3738
  /([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,
3608
- (v, T, w, S) => {
3609
- const L = String(T).toLowerCase(), I = `<span style="color: ${i.attrName};">${T}</span>`;
3610
- let $ = S, C = "";
3611
- S.startsWith("&quot;") && S.endsWith("&quot;") ? ($ = S.slice(6, -6), C = "&quot;") : S.startsWith("&#39;") && S.endsWith("&#39;") && ($ = S.slice(5, -5), C = "&#39;");
3612
- let M = S;
3613
- if (L === "style") {
3614
- const D = $.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (F, k, A, H) => `<span style="color: ${i.styleProp};">${k}</span>:<span style="color: ${i.styleVal};">${A}</span>${H}`);
3615
- C ? M = `${C}${D}${C}` : M = D, M = `<span style="color: ${i.attrValue};">${M}</span>`;
3739
+ (T, S, v, C) => {
3740
+ const O = String(S).toLowerCase(), $ = `<span style="color: ${i.attrName};">${S}</span>`;
3741
+ let I = C, M = "";
3742
+ C.startsWith("&quot;") && C.endsWith("&quot;") ? (I = C.slice(6, -6), M = "&quot;") : C.startsWith("&#39;") && C.endsWith("&#39;") && (I = C.slice(5, -5), M = "&#39;");
3743
+ let E = C;
3744
+ if (O === "style") {
3745
+ const N = I.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (F, k, P, H) => `<span style="color: ${i.styleProp};">${k}</span>:<span style="color: ${i.styleVal};">${P}</span>${H}`);
3746
+ M ? E = `${M}${N}${M}` : E = N, E = `<span style="color: ${i.attrValue};">${E}</span>`;
3616
3747
  } else
3617
- C && (M = `${C}${$}${C}`), M = `<span style="color: ${i.attrValue};">${M}</span>`;
3618
- return `${I}${w}${M}`;
3748
+ M && (E = `${M}${I}${M}`), E = `<span style="color: ${i.attrValue};">${E}</span>`;
3749
+ return `${$}${v}${E}`;
3619
3750
  }
3620
- ), `${u}${m}${x}${p}`;
3621
- }), a = a.replace(/\u0002ht(\d+)\u0002/g, (c, u) => o[Number(u)] || ""), this.restoreHighlightTokens(a, n);
3751
+ ), `${f}${m}${y}${p}`;
3752
+ }), a = a.replace(/\u0002ht(\d+)\u0002/g, (d, f) => o[Number(f)] || ""), this.restoreHighlightTokens(a, s);
3622
3753
  }
3623
3754
  _highlightCSS(e, t) {
3624
- const i = this.unescapeEntitiesRepeated(e), s = [], n = this.createTokenStore(s), r = /(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
3755
+ const i = this.unescapeEntitiesRepeated(e), n = [], s = this.createTokenStore(n), r = /(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
3625
3756
  let o = 0, l = "", a;
3626
3757
  for (; a = r.exec(i); ) {
3627
3758
  o < a.index && (l += this.escapeHTML(i.slice(o, a.index)));
3628
- const h = a[0], d = h.startsWith("/*") ? t.comment : t.string;
3629
- l += n(`<span style="color: ${d};">${this.escapeHTML(h)}</span>`), o = r.lastIndex;
3759
+ const h = a[0], c = h.startsWith("/*") ? t.comment : t.string;
3760
+ l += s(`<span style="color: ${c};">${this.escapeHTML(h)}</span>`), o = r.lastIndex;
3630
3761
  }
3631
3762
  return o < i.length && (l += this.escapeHTML(i.slice(o))), l = l.replace(
3632
3763
  /(@[\w-]+)/g,
3633
- (h) => n(`<span style="color: ${t.keyword};">${h}</span>`)
3764
+ (h) => s(`<span style="color: ${t.keyword};">${h}</span>`)
3634
3765
  ), l = l.replace(
3635
3766
  /([A-Za-z_-][\w-]*)(\s*:)/g,
3636
- (h, d, c) => `${n(`<span style="color: ${t.styleProp};">${d}</span>`)}${c}`
3767
+ (h, c, d) => `${s(`<span style="color: ${t.styleProp};">${c}</span>`)}${d}`
3637
3768
  ), l = l.replace(
3638
3769
  /(#(?:[0-9a-fA-F]{3,8})\b)/g,
3639
- (h) => n(`<span style="color: ${t.number};">${h}</span>`)
3770
+ (h) => s(`<span style="color: ${t.number};">${h}</span>`)
3640
3771
  ), l = l.replace(
3641
3772
  /\b(-?\d*\.?\d+(?:px|em|rem|vh|vw|vmin|vmax|%|s|ms|deg|turn|fr)?)\b/g,
3642
- (h) => n(`<span style="color: ${t.number};">${h}</span>`)
3773
+ (h) => s(`<span style="color: ${t.number};">${h}</span>`)
3643
3774
  ), l = l.replace(
3644
3775
  /\b(important|inherit|initial|unset|revert|auto|none|block|inline|flex|grid|absolute|relative|fixed|sticky)\b/g,
3645
- (h) => n(`<span style="color: ${t.styleVal};">${h}</span>`)
3646
- ), this.restoreHighlightTokens(l, s);
3776
+ (h) => s(`<span style="color: ${t.styleVal};">${h}</span>`)
3777
+ ), this.restoreHighlightTokens(l, n);
3647
3778
  }
3648
3779
  _highlightJSON(e, t) {
3649
- const i = this.unescapeEntitiesRepeated(e), s = /("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|[{}\[\],:]/g;
3650
- let n = 0, r = "", o;
3651
- for (; o = s.exec(i); ) {
3652
- n < o.index && (r += this.escapeHTML(i.slice(n, o.index)));
3653
- const l = o[0], a = o[1], h = o[2] || "", d = o[3];
3780
+ const i = this.unescapeEntitiesRepeated(e), n = /("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|[{}\[\],:]/g;
3781
+ let s = 0, r = "", o;
3782
+ for (; o = n.exec(i); ) {
3783
+ s < o.index && (r += this.escapeHTML(i.slice(s, o.index)));
3784
+ const l = o[0], a = o[1], h = o[2] || "", c = o[3];
3654
3785
  if (a) {
3655
- const c = h ? t.attrName : t.string;
3656
- r += `<span style="color: ${c};">${this.escapeHTML(a)}</span>${this.escapeHTML(h)}`;
3657
- } else d ? r += `<span style="color: ${t.keyword};">${l}</span>` : /^-?\d/.test(l) ? r += `<span style="color: ${t.number};">${l}</span>` : r += `<span style="color: ${t.tag};">${this.escapeHTML(l)}</span>`;
3658
- n = s.lastIndex;
3786
+ const d = h ? t.attrName : t.string;
3787
+ r += `<span style="color: ${d};">${this.escapeHTML(a)}</span>${this.escapeHTML(h)}`;
3788
+ } else c ? r += `<span style="color: ${t.keyword};">${l}</span>` : /^-?\d/.test(l) ? r += `<span style="color: ${t.number};">${l}</span>` : r += `<span style="color: ${t.tag};">${this.escapeHTML(l)}</span>`;
3789
+ s = n.lastIndex;
3659
3790
  }
3660
- return n < i.length && (r += this.escapeHTML(i.slice(n))), r;
3791
+ return s < i.length && (r += this.escapeHTML(i.slice(s))), r;
3661
3792
  }
3662
3793
  _highlightMarkdown(e, t) {
3663
- var l;
3664
- const i = this.unescapeEntitiesRepeated(e).split(`
3794
+ var a;
3795
+ const n = this.unescapeEntitiesRepeated(e).split(`
3665
3796
  `);
3666
- let s = !1, n = "", r = "", o = ((l = i[0]) == null ? void 0 : l.trim()) === "---";
3667
- return i.map((a, h) => {
3668
- const d = [], c = this.createTokenStore(d);
3669
- if (o) {
3670
- const f = a.trim() === "---", p = `<span style="color: ${f ? t.keyword : t.attrName};">${this.escapeHTML(a)}</span>`;
3671
- return h > 0 && f && (o = !1), p;
3797
+ let s = !1, r = "", o = "", l = ((a = n[0]) == null ? void 0 : a.trim()) === "---";
3798
+ return n.map((h, c) => {
3799
+ const d = [], f = this.createTokenStore(d);
3800
+ if (l) {
3801
+ const p = h.trim() === "---", y = `<span style="color: ${p ? t.keyword : t.attrName};">${this.escapeHTML(h)}</span>`;
3802
+ return c > 0 && p && (l = !1), y;
3672
3803
  }
3673
- const u = a.match(/^(\s*)(`{3,}|~{3,})(.*)$/);
3804
+ const u = h.match(/^(\s*)(`{3,}|~{3,})(.*)$/);
3674
3805
  if (u) {
3675
- const f = u[2];
3676
- return s = !(s && f[0] === n[0]), n = s ? f : "", r = s ? this.extractMarkdownFenceLanguage(u[3] || "") : "", [
3806
+ const p = u[2];
3807
+ return s = !(s && p[0] === r[0]), r = s ? p : "", o = s ? this.extractMarkdownFenceLanguage(u[3] || "") : "", [
3677
3808
  this.escapeHTML(u[1]),
3678
- `<span style="color: ${t.keyword}; font-weight: 700;">${this.escapeHTML(f)}</span>`,
3809
+ `<span style="color: ${t.keyword}; font-weight: 700;">${this.escapeHTML(p)}</span>`,
3679
3810
  `<span style="color: ${t.string};">${this.escapeHTML(u[3] || "")}</span>`
3680
3811
  ].join("");
3681
3812
  }
3682
3813
  if (s)
3683
- return this.highlightMarkdownFenceLine(a, r, t);
3684
- let g = this.escapeHTML(a).replace(
3814
+ return this.highlightMarkdownFenceLine(h, o, t);
3815
+ let g = this.escapeHTML(h).replace(
3685
3816
  /(`[^`]+`)/g,
3686
- (f) => c(`<span style="color: ${t.string}; background: rgba(148, 163, 184, 0.16); border-radius: 3px;">${f}</span>`)
3817
+ (p) => f(`<span style="color: ${t.string}; background: rgba(148, 163, 184, 0.16); border-radius: 3px;">${p}</span>`)
3687
3818
  ).replace(
3688
3819
  /(!?\[[^\]\n]*\])(\([^)]+\))/g,
3689
- (f, p, m) => c(`<span style="color: ${t.attrName};">${p}</span><span style="color: ${t.attrValue};">${m}</span>`)
3820
+ (p, m, y) => f(`<span style="color: ${t.attrName};">${m}</span><span style="color: ${t.attrValue};">${y}</span>`)
3690
3821
  ).replace(
3691
3822
  /(\*\*|__)(.+?)\1/g,
3692
- (f, p, m) => c(`<span style="color: ${t.keyword};">${p}</span><span style="color: ${t.tag}; font-weight: 700;">${m}</span><span style="color: ${t.keyword};">${p}</span>`)
3823
+ (p, m, y) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${y}</span><span style="color: ${t.keyword};">${m}</span>`)
3693
3824
  ).replace(
3694
3825
  /(~~)(.+?)\1/g,
3695
- (f, p, m) => c(`<span style="color: ${t.keyword};">${p}</span><span style="color: ${t.comment}; text-decoration: line-through;">${m}</span><span style="color: ${t.keyword};">${p}</span>`)
3826
+ (p, m, y) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.comment}; text-decoration: line-through;">${y}</span><span style="color: ${t.keyword};">${m}</span>`)
3696
3827
  ).replace(
3697
3828
  /(\*|_)([^*_]+?)\1/g,
3698
- (f, p, m) => c(`<span style="color: ${t.keyword};">${p}</span><span style="color: ${t.styleVal}; font-style: italic;">${m}</span><span style="color: ${t.keyword};">${p}</span>`)
3829
+ (p, m, y) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.styleVal}; font-style: italic;">${y}</span><span style="color: ${t.keyword};">${m}</span>`)
3699
3830
  );
3700
3831
  return g = g.replace(
3701
3832
  /^(\s{0,3}#{1,6})(\s+.*)?$/,
3702
- (f, p, m = "") => `<span style="color: ${t.keyword}; font-weight: 700;">${p}</span><span style="color: ${t.tag}; font-weight: 700;">${m}</span>`
3833
+ (p, m, y = "") => `<span style="color: ${t.keyword}; font-weight: 700;">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${y}</span>`
3703
3834
  ), g = g.replace(
3704
3835
  /^(\s{0,3})((?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,
3705
- (f, p, m) => `${p}<span style="color: ${t.comment};">${m}</span>`
3836
+ (p, m, y) => `${m}<span style="color: ${t.comment};">${y}</span>`
3706
3837
  ), g = g.replace(
3707
3838
  /^(\s{0,3}&gt;)(.*)$/,
3708
- (f, p, m) => `<span style="color: ${t.comment};">${p}</span>${m}`
3839
+ (p, m, y) => `<span style="color: ${t.comment};">${m}</span>${y}`
3709
3840
  ), g = g.replace(
3710
3841
  /^(\s*)([-*+])(\s+\[[ xX]\])(\s+)/,
3711
- (f, p, m, x, v) => `${p}<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.attrName};">${x}</span>${v}`
3842
+ (p, m, y, T, S) => `${m}<span style="color: ${t.keyword};">${y}</span><span style="color: ${t.attrName};">${T}</span>${S}`
3712
3843
  ), g = g.replace(
3713
3844
  /^(\s*)([-*+]|\d+\.)(\s+)/,
3714
- (f, p, m, x) => `${p}<span style="color: ${t.keyword};">${m}</span>${x}`
3845
+ (p, m, y, T) => `${m}<span style="color: ${t.keyword};">${y}</span>${T}`
3715
3846
  ), g = g.replace(
3716
3847
  /^(\s*\|.*\|\s*)$/,
3717
- (f) => f.replace(/\|/g, (p) => `<span style="color: ${t.keyword};">${p}</span>`)
3848
+ (p) => p.replace(/\|/g, (m) => `<span style="color: ${t.keyword};">${m}</span>`)
3718
3849
  ), this.restoreHighlightTokens(g, d);
3719
3850
  }).join(`
3720
3851
  `);
@@ -3725,27 +3856,27 @@ class he {
3725
3856
  return t ? this.normalizeLanguageId(t) : "";
3726
3857
  }
3727
3858
  highlightMarkdownFenceLine(e, t, i) {
3728
- const s = t ? this.modes.get(t) : void 0;
3729
- return !s || s.name === "markdown" ? `<span style="color: ${i.text};">${this.escapeHTML(e)}</span>` : s.highlight(e, i);
3859
+ const n = t ? this.modes.get(t) : void 0;
3860
+ return !n || n.name === "markdown" ? `<span style="color: ${i.text};">${this.escapeHTML(e)}</span>` : n.highlight(e, i);
3730
3861
  }
3731
3862
  _highlightShell(e, t) {
3732
- const i = this.unescapeEntitiesRepeated(e), s = [], n = this.createTokenStore(s), r = /(#[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|(\$\{?[A-Za-z_][\w]*\}?|\$[0-9@#?$*!])/g;
3863
+ const i = this.unescapeEntitiesRepeated(e), n = [], s = this.createTokenStore(n), r = /(#[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|(\$\{?[A-Za-z_][\w]*\}?|\$[0-9@#?$*!])/g;
3733
3864
  let o = 0, l = "", a;
3734
3865
  for (; a = r.exec(i); ) {
3735
3866
  o < a.index && (l += this.escapeHTML(i.slice(o, a.index)));
3736
- const h = a[0], d = h.startsWith("#") ? t.comment : h.startsWith("$") ? t.variable : t.string;
3737
- l += n(`<span style="color: ${d};">${this.escapeHTML(h)}</span>`), o = r.lastIndex;
3867
+ const h = a[0], c = h.startsWith("#") ? t.comment : h.startsWith("$") ? t.variable : t.string;
3868
+ l += s(`<span style="color: ${c};">${this.escapeHTML(h)}</span>`), o = r.lastIndex;
3738
3869
  }
3739
3870
  return o < i.length && (l += this.escapeHTML(i.slice(o))), l = l.replace(
3740
3871
  /(^|\s)(--?[A-Za-z0-9][\w-]*)(?=\s|=|$)/g,
3741
- (h, d, c) => `${d}${n(`<span style="color: ${t.attrName};">${c}</span>`)}`
3872
+ (h, c, d) => `${c}${s(`<span style="color: ${t.attrName};">${d}</span>`)}`
3742
3873
  ), l = l.replace(
3743
3874
  /\b(if|then|else|elif|fi|for|while|until|do|done|case|esac|function|export|unset|alias|source|return|in)\b/g,
3744
- (h) => n(`<span style="color: ${t.keyword};">${h}</span>`)
3875
+ (h) => s(`<span style="color: ${t.keyword};">${h}</span>`)
3745
3876
  ), l = l.replace(
3746
3877
  /(^|\s)(npm|npx|pnpm|yarn|bun|node|git|cd|mkdir|touch|cp|mv|rm|cat|grep|rg|find|curl|wget|echo|printf|sudo|chmod|chown|docker|kubectl)(?=\s|$)/g,
3747
- (h, d, c) => `${d}${n(`<span style="color: ${t.tag};">${c}</span>`)}`
3748
- ), this.restoreHighlightTokens(l, s);
3878
+ (h, c, d) => `${c}${s(`<span style="color: ${t.tag};">${d}</span>`)}`
3879
+ ), this.restoreHighlightTokens(l, n);
3749
3880
  }
3750
3881
  getLanguageKeywords(e) {
3751
3882
  const t = ["true", "false", "null", "nil", "none"];
@@ -3762,101 +3893,101 @@ class he {
3762
3893
  }[e] || [], ...t];
3763
3894
  }
3764
3895
  _highlightGenericCode(e, t, i) {
3765
- const s = this.unescapeEntitiesRepeated(e), n = [], r = this.createTokenStore(n), o = i === "python" || i === "ruby" || i === "sql" ? "#[^\\n\\r]*|--[^\\n\\r]*" : "\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\n\\r]*", l = new RegExp(
3896
+ const n = this.unescapeEntitiesRepeated(e), s = [], r = this.createTokenStore(s), o = i === "python" || i === "ruby" || i === "sql" ? "#[^\\n\\r]*|--[^\\n\\r]*" : "\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\n\\r]*", l = new RegExp(
3766
3897
  `(${o})|("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`)`,
3767
3898
  "g"
3768
3899
  );
3769
- let a = 0, h = "", d;
3770
- for (; d = l.exec(s); ) {
3771
- a < d.index && (h += this.escapeHTML(s.slice(a, d.index)));
3772
- const u = d[0], g = u.startsWith("//") || u.startsWith("/*") || u.startsWith("#") || u.startsWith("--") ? t.comment : t.string;
3773
- h += r(`<span style="color: ${g};">${this.escapeHTML(u)}</span>`), a = l.lastIndex;
3900
+ let a = 0, h = "", c;
3901
+ for (; c = l.exec(n); ) {
3902
+ a < c.index && (h += this.escapeHTML(n.slice(a, c.index)));
3903
+ const f = c[0], u = f.startsWith("//") || f.startsWith("/*") || f.startsWith("#") || f.startsWith("--") ? t.comment : t.string;
3904
+ h += r(`<span style="color: ${u};">${this.escapeHTML(f)}</span>`), a = l.lastIndex;
3774
3905
  }
3775
- a < s.length && (h += this.escapeHTML(s.slice(a)));
3776
- const c = Array.from(new Set(this.getLanguageKeywords(i)));
3777
- if (c.length > 0) {
3778
- const u = new RegExp(
3779
- `\\b(${c.map((g) => g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`,
3906
+ a < n.length && (h += this.escapeHTML(n.slice(a)));
3907
+ const d = Array.from(new Set(this.getLanguageKeywords(i)));
3908
+ if (d.length > 0) {
3909
+ const f = new RegExp(
3910
+ `\\b(${d.map((u) => u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`,
3780
3911
  i === "sql" ? "gi" : "g"
3781
3912
  );
3782
3913
  h = h.replace(
3783
- u,
3784
- (g) => r(`<span style="color: ${t.keyword};">${g}</span>`)
3914
+ f,
3915
+ (u) => r(`<span style="color: ${t.keyword};">${u}</span>`)
3785
3916
  );
3786
3917
  }
3787
3918
  return h = h.replace(
3788
3919
  /\b([A-Z][A-Za-z0-9_]*|[A-Za-z_][\w]*(?=\s*\())\b/g,
3789
- (u) => r(`<span style="color: ${t.tag};">${u}</span>`)
3920
+ (f) => r(`<span style="color: ${t.tag};">${f}</span>`)
3790
3921
  ), h = h.replace(
3791
3922
  /\b(-?0x[0-9a-fA-F]+|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)(?:[uUlLfFdD]*)\b/g,
3792
- (u) => r(`<span style="color: ${t.number};">${u}</span>`)
3923
+ (f) => r(`<span style="color: ${t.number};">${f}</span>`)
3793
3924
  ), h = h.replace(
3794
3925
  /(@[A-Za-z_][\w]*|#[A-Za-z_][\w]*|::[A-Za-z_][\w]*)/g,
3795
- (u) => r(`<span style="color: ${t.attrName};">${u}</span>`)
3796
- ), this.restoreHighlightTokens(h, n);
3926
+ (f) => r(`<span style="color: ${t.attrName};">${f}</span>`)
3927
+ ), this.restoreHighlightTokens(h, s);
3797
3928
  }
3798
3929
  _highlightYAML(e, t) {
3799
- const i = this.unescapeEntitiesRepeated(e), s = [], n = this.createTokenStore(s);
3930
+ const i = this.unescapeEntitiesRepeated(e), n = [], s = this.createTokenStore(n);
3800
3931
  let r = this.escapeHTML(i).replace(
3801
3932
  /(#.*)$/gm,
3802
- (o) => n(`<span style="color: ${t.comment};">${o}</span>`)
3933
+ (o) => s(`<span style="color: ${t.comment};">${o}</span>`)
3803
3934
  ).replace(
3804
3935
  /^(\s*[-?]?\s*)([A-Za-z0-9_.-]+)(\s*:)/gm,
3805
- (o, l, a, h) => `${l}${n(`<span style="color: ${t.attrName};">${a}</span>`)}${h}`
3936
+ (o, l, a, h) => `${l}${s(`<span style="color: ${t.attrName};">${a}</span>`)}${h}`
3806
3937
  ).replace(
3807
3938
  /\b(true|false|null|yes|no|on|off)\b/gi,
3808
- (o) => n(`<span style="color: ${t.keyword};">${o}</span>`)
3939
+ (o) => s(`<span style="color: ${t.keyword};">${o}</span>`)
3809
3940
  ).replace(
3810
3941
  /\b(-?\d+(?:\.\d+)?)\b/g,
3811
- (o) => n(`<span style="color: ${t.number};">${o}</span>`)
3942
+ (o) => s(`<span style="color: ${t.number};">${o}</span>`)
3812
3943
  );
3813
3944
  return r = r.replace(
3814
3945
  /(&quot;[^&]*?&quot;|&#39;[^&]*?&#39;)/g,
3815
- (o) => n(`<span style="color: ${t.string};">${o}</span>`)
3816
- ), this.restoreHighlightTokens(r, s);
3946
+ (o) => s(`<span style="color: ${t.string};">${o}</span>`)
3947
+ ), this.restoreHighlightTokens(r, n);
3817
3948
  }
3818
3949
  _highlightXML(e, t) {
3819
3950
  return this._highlightHTML(e, t);
3820
3951
  }
3821
3952
  _highlightJSX(e, t) {
3822
- const i = [], s = e.replace(
3953
+ const i = [], n = e.replace(
3823
3954
  /<\/?[A-Za-z][\w.:-]*(?:\s+[^<>]*?)?\/?>/g,
3824
- (n) => {
3825
- const r = i.length, o = this.escapeHTML(n).replace(
3955
+ (s) => {
3956
+ const r = i.length, o = this.escapeHTML(s).replace(
3826
3957
  /(&lt;\/?)([A-Za-z][\w.:-]*)([\s\S]*?)(\/?&gt;)/,
3827
- (l, a, h, d, c) => {
3828
- const u = String(d || "").replace(
3958
+ (l, a, h, c, d) => {
3959
+ const f = String(c || "").replace(
3829
3960
  /([A-Za-z_:][\w:.-]*)(\s*=\s*)/g,
3830
3961
  `<span style="color: ${t.attrName};">$1</span>$2`
3831
3962
  );
3832
- return `${a}<span style="color: ${t.tag};">${h}</span>${u}${c}`;
3963
+ return `${a}<span style="color: ${t.tag};">${h}</span>${f}${d}`;
3833
3964
  }
3834
3965
  );
3835
3966
  return i.push(o), `jsx${r}`;
3836
3967
  }
3837
3968
  );
3838
- return this._highlightJS(s, t).replace(
3969
+ return this._highlightJS(n, t).replace(
3839
3970
  /\u0004jsx(\d+)\u0004/g,
3840
- (n, r) => i[Number(r)] || ""
3971
+ (s, r) => i[Number(r)] || ""
3841
3972
  );
3842
3973
  }
3843
3974
  _highlightEJS(e, t) {
3844
- const i = [], s = e.replace(/<%[\s\S]*?%>/g, (n) => {
3975
+ const i = [], n = e.replace(/<%[\s\S]*?%>/g, (s) => {
3845
3976
  const r = i.length;
3846
- return i.push(`<span style="color: ${t.keyword};">${this.escapeHTML(n)}</span>`), `ejs${r}`;
3977
+ return i.push(`<span style="color: ${t.keyword};">${this.escapeHTML(s)}</span>`), `ejs${r}`;
3847
3978
  });
3848
- return this._highlightHTML(s, t).replace(
3979
+ return this._highlightHTML(n, t).replace(
3849
3980
  /\u0003ejs(\d+)\u0003/g,
3850
- (n, r) => i[Number(r)] || ""
3981
+ (s, r) => i[Number(r)] || ""
3851
3982
  );
3852
3983
  }
3853
3984
  _highlightDockerfile(e, t) {
3854
3985
  return this.unescapeEntitiesRepeated(e).split(`
3855
- `).map((i) => {
3856
- const s = this.escapeHTML(i);
3857
- return /^\s*#/.test(i) ? `<span style="color: ${t.comment};">${s}</span>` : s.replace(
3986
+ `).map((n) => {
3987
+ const s = this.escapeHTML(n);
3988
+ return /^\s*#/.test(n) ? `<span style="color: ${t.comment};">${s}</span>` : s.replace(
3858
3989
  /^(\s*)(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)(\b)/i,
3859
- (n, r, o, l) => `${r}<span style="color: ${t.keyword};">${o}</span>${l}`
3990
+ (r, o, l, a) => `${o}<span style="color: ${t.keyword};">${l}</span>${a}`
3860
3991
  );
3861
3992
  }).join(`
3862
3993
  `);
@@ -3864,78 +3995,78 @@ class he {
3864
3995
  _highlightJS(e, t) {
3865
3996
  const i = this.unescapeEntitiesRepeated(e);
3866
3997
  this.escapeHTML(i);
3867
- const s = [], n = (c) => {
3868
- let u = "", g = c;
3998
+ const n = [], s = (f) => {
3999
+ let u = "", g = f;
3869
4000
  do
3870
4001
  u = String.fromCharCode(97 + g % 26) + u, g = Math.floor(g / 26) - 1;
3871
4002
  while (g >= 0);
3872
4003
  return u || "a";
3873
- }, r = (c) => `\0${n(c)}\0`, o = (c) => {
3874
- const u = s.length;
3875
- return s.push(c), r(u);
4004
+ }, r = (f) => `\0${s(f)}\0`, o = (f) => {
4005
+ const u = n.length;
4006
+ return n.push(f), r(u);
3876
4007
  };
3877
4008
  let l;
3878
4009
  const a = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
3879
- let h = 0, d = "";
4010
+ let h = 0, c = "";
3880
4011
  for (; l = a.exec(i); ) {
3881
- const c = l.index;
3882
- h < c && (d += this.escapeHTML(i.slice(h, c)));
4012
+ const f = l.index;
4013
+ h < f && (c += this.escapeHTML(i.slice(h, f)));
3883
4014
  const u = l[0];
3884
- /^\/\*/.test(u) || /^\/\//.test(u) ? d += o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`) : d += o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`), h = a.lastIndex;
4015
+ /^\/\*/.test(u) || /^\/\//.test(u) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`), h = a.lastIndex;
3885
4016
  }
3886
- return h < i.length && (d += this.escapeHTML(i.slice(h))), d = d.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (c, u, g) => {
3887
- const f = d[g - 1] || "", p = d[g + c.length] || "";
3888
- return f === "&" || f === "#" || p === ";" || p === "#" ? c : `<span style="color: ${t.number};">${c}</span>`;
3889
- }), d = d.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>`), d.replace(/\u0000([a-z]+)\u0000/g, (c, u) => {
4017
+ return h < i.length && (c += this.escapeHTML(i.slice(h))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (f, u, g) => {
4018
+ const p = c[g - 1] || "", m = c[g + f.length] || "";
4019
+ return p === "&" || p === "#" || m === ";" || m === "#" ? f : `<span style="color: ${t.number};">${f}</span>`;
4020
+ }), 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, (f, u) => {
3890
4021
  let g = 0;
3891
- for (let f = 0; f < u.length; f++)
3892
- g = g * 26 + (u.charCodeAt(f) - 97 + 1);
3893
- return g = g - 1, s[g] || "";
4022
+ for (let p = 0; p < u.length; p++)
4023
+ g = g * 26 + (u.charCodeAt(p) - 97 + 1);
4024
+ return g = g - 1, n[g] || "";
3894
4025
  });
3895
4026
  }
3896
4027
  _highlightPHP(e, t) {
3897
4028
  const i = this.unescapeEntitiesRepeated(e);
3898
- let s = this.escapeHTML(i);
3899
- const n = [], r = (g) => {
3900
- let f = "", p = g;
4029
+ let n = this.escapeHTML(i);
4030
+ const s = [], r = (u) => {
4031
+ let g = "", p = u;
3901
4032
  do
3902
- f = String.fromCharCode(97 + p % 26) + f, p = Math.floor(p / 26) - 1;
4033
+ g = String.fromCharCode(97 + p % 26) + g, p = Math.floor(p / 26) - 1;
3903
4034
  while (p >= 0);
3904
- return f || "a";
3905
- }, o = (g) => {
3906
- const f = n.length;
3907
- return n.push(g), `\0${r(f)}\0`;
3908
- }, l = (g, f) => {
3909
- const p = s.indexOf(g);
3910
- return p === -1 ? !1 : (s = s.slice(0, p) + f + s.slice(p + g.length), !0);
4035
+ return g || "a";
4036
+ }, o = (u) => {
4037
+ const g = s.length;
4038
+ return s.push(u), `\0${r(g)}\0`;
4039
+ }, l = (u, g) => {
4040
+ const p = n.indexOf(u);
4041
+ return p === -1 ? !1 : (n = n.slice(0, p) + g + n.slice(p + u.length), !0);
3911
4042
  };
3912
4043
  let a;
3913
- const h = /\/\*[\s\S]*?\*\//g, d = /\/\/[^\n\r]*/g, c = /\#([^\n\r]*)/g, u = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
4044
+ const h = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, f = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
3914
4045
  for (; a = h.exec(i); ) {
3915
- const g = a[0];
3916
- l(this.escapeHTML(g), o(`<span style="color: ${t.comment};">${this.escapeHTML(g)}</span>`));
3917
- }
3918
- for (; a = d.exec(i); ) {
3919
- const g = a[0];
3920
- l(this.escapeHTML(g), o(`<span style="color: ${t.comment};">${this.escapeHTML(g)}</span>`));
4046
+ const u = a[0];
4047
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
3921
4048
  }
3922
4049
  for (; a = c.exec(i); ) {
3923
- const g = a[0];
3924
- l(this.escapeHTML(g), o(`<span style="color: ${t.comment};">${this.escapeHTML(g)}</span>`));
4050
+ const u = a[0];
4051
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
4052
+ }
4053
+ for (; a = d.exec(i); ) {
4054
+ const u = a[0];
4055
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
3925
4056
  }
3926
- for (; a = u.exec(i); ) {
3927
- const g = a[0];
3928
- l(this.escapeHTML(g), o(`<span style="color: ${t.string};">${this.escapeHTML(g)}</span>`));
4057
+ for (; a = f.exec(i); ) {
4058
+ const u = a[0];
4059
+ l(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
3929
4060
  }
3930
- return s = s.replace(
4061
+ return n = n.replace(
3931
4062
  /(&lt;\?(?:php\b|=)?|\?&gt;)/gi,
3932
- (g) => o(`<span style="color: ${t.keyword};">${g}</span>`)
3933
- ), 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, (g, f) => {
4063
+ (u) => o(`<span style="color: ${t.keyword};">${u}</span>`)
4064
+ ), n = n.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), n = n.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>`), n = n.replace(/\u0000([a-z]+)\u0000/g, (u, g) => {
3934
4065
  let p = 0;
3935
- for (let m = 0; m < f.length; m++)
3936
- p = p * 26 + (f.charCodeAt(m) - 97 + 1);
3937
- return p = p - 1, n[p] || "";
3938
- }), s;
4066
+ for (let m = 0; m < g.length; m++)
4067
+ p = p * 26 + (g.charCodeAt(m) - 97 + 1);
4068
+ return p = p - 1, s[p] || "";
4069
+ }), n;
3939
4070
  }
3940
4071
  // Method to check if content contains syntax that should be highlighted
3941
4072
  shouldHighlight(e) {
@@ -3945,11 +4076,11 @@ class he {
3945
4076
  this.editor = null, this.modes.clear();
3946
4077
  }
3947
4078
  }
3948
- function ce(E, e) {
4079
+ function ae(R, e) {
3949
4080
  const t = { ...e };
3950
- 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 ee()), new Y(E, t);
4081
+ 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 W()), new V(R, t);
3951
4082
  }
3952
- const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Editor Dialog Styles */
4083
+ const z = '[data-theme="dark"], .dark, .editora-theme-dark', he = `/* Source Editor Dialog Styles */
3953
4084
  .rte-source-editor-overlay {
3954
4085
  position: fixed !important;
3955
4086
  top: 0 !important;
@@ -4326,7 +4457,7 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4326
4457
  flex: 1;
4327
4458
  text-align: center;
4328
4459
  }
4329
- }`, ue = () => ({
4460
+ }`, de = () => ({
4330
4461
  name: "code",
4331
4462
  // Toolbar button configuration
4332
4463
  toolbar: [
@@ -4347,9 +4478,9 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4347
4478
  toggleSourceView: () => {
4348
4479
  const e = (() => {
4349
4480
  var o, l, a;
4350
- const n = window.getSelection();
4351
- if (n && n.anchorNode) {
4352
- let h = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
4481
+ const s = window.getSelection();
4482
+ if (s && s.anchorNode) {
4483
+ let h = s.anchorNode instanceof HTMLElement ? s.anchorNode : s.anchorNode.parentElement;
4353
4484
  for (; h; ) {
4354
4485
  if ((o = h.classList) != null && o.contains("rte-content"))
4355
4486
  return h;
@@ -4363,10 +4494,10 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4363
4494
  for (; h && h !== document.body; ) {
4364
4495
  if ((a = h.classList) != null && a.contains("rte-content"))
4365
4496
  return h;
4366
- const d = h.querySelector(
4497
+ const c = h.querySelector(
4367
4498
  ".rte-content"
4368
4499
  );
4369
- if (d) return d;
4500
+ if (c) return c;
4370
4501
  h = h.parentElement;
4371
4502
  }
4372
4503
  }
@@ -4383,9 +4514,9 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4383
4514
  return console.error("[CodePlugin] Editor content area not found"), alert(
4384
4515
  "Editor content area not found. Please click inside the editor first."
4385
4516
  ), !1;
4386
- const t = e.innerHTML, i = (n) => {
4517
+ const t = e.innerHTML, i = (s) => {
4387
4518
  let r = "", o = 0;
4388
- const l = 2, a = n.split(/(<\/?[a-zA-Z][^>]*>)/);
4519
+ const l = 2, a = s.split(/(<\/?[a-zA-Z][^>]*>)/);
4389
4520
  for (const h of a)
4390
4521
  h.trim() && (h.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), r += `
4391
4522
  ` + " ".repeat(o * l) + h) : h.match(/^<[a-zA-Z]/) && !h.match(/\/>$/) ? (r += `
@@ -4394,12 +4525,13 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4394
4525
  return r.trim();
4395
4526
  };
4396
4527
  return (() => {
4528
+ document.querySelectorAll(".rte-source-editor-overlay").forEach((b) => b.remove());
4397
4529
  const r = i(t);
4398
- let o = null, l = "dark", a = !1, h = !1, d = !1, c = !1;
4399
- const u = !!e.closest(B) || document.body.matches(B) || document.documentElement.matches(B), g = document.createElement("div");
4400
- g.className = "rte-source-editor-overlay", u && g.classList.add("rte-theme-dark");
4401
- const f = document.createElement("div");
4402
- f.className = "rte-source-editor-modal", f.setAttribute("role", "dialog"), f.setAttribute("aria-modal", "true"), f.setAttribute("aria-labelledby", "source-editor-title");
4530
+ let o = null, l = "dark", a = !1, h = !1, c = !1, d = !1;
4531
+ const f = !!e.closest(z) || document.body.matches(z) || document.documentElement.matches(z), u = document.createElement("div");
4532
+ Q(u), u.className = "rte-source-editor-overlay", f && u.classList.add("rte-theme-dark");
4533
+ const g = document.createElement("div");
4534
+ g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
4403
4535
  const p = document.createElement("div");
4404
4536
  p.className = "rte-source-editor-header", p.innerHTML = `
4405
4537
  <h2 id="source-editor-title">Source Editor</h2>
@@ -4440,14 +4572,14 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4440
4572
  `;
4441
4573
  const m = document.createElement("div");
4442
4574
  m.className = "rte-source-editor-body";
4443
- const x = document.createElement("div");
4444
- x.className = "rte-source-editor-content";
4445
- const v = document.createElement("div");
4446
- v.className = "rte-source-editor-warning", v.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
4575
+ const y = document.createElement("div");
4576
+ y.className = "rte-source-editor-content";
4447
4577
  const T = document.createElement("div");
4448
- T.className = "rte-source-editor-light-editor", T.style.height = "400px", x.appendChild(v), x.appendChild(T), m.appendChild(x);
4449
- const w = document.createElement("div");
4450
- if (w.className = "rte-source-editor-footer", w.innerHTML = `
4578
+ T.className = "rte-source-editor-warning", T.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
4579
+ const S = document.createElement("div");
4580
+ S.className = "rte-source-editor-light-editor", S.style.height = "400px", y.appendChild(T), y.appendChild(S), m.appendChild(y);
4581
+ const v = document.createElement("div");
4582
+ if (v.className = "rte-source-editor-footer", v.innerHTML = `
4451
4583
  <div class="rte-source-editor-footer-info">
4452
4584
  <span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
4453
4585
  </div>
@@ -4455,40 +4587,40 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4455
4587
  <button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
4456
4588
  <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
4457
4589
  </div>
4458
- `, f.appendChild(p), f.appendChild(m), f.appendChild(w), g.appendChild(f), !document.getElementById("rte-source-editor-styles")) {
4590
+ `, g.appendChild(p), g.appendChild(m), g.appendChild(v), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
4459
4591
  const b = document.createElement("style");
4460
- b.id = "rte-source-editor-styles", b.textContent = de, document.head.appendChild(b);
4592
+ b.id = "rte-source-editor-styles", b.textContent = he, document.head.appendChild(b);
4461
4593
  }
4462
- const S = p.querySelector(
4594
+ const C = p.querySelector(
4463
4595
  ".theme-toggle-btn"
4464
- ), L = p.querySelector(
4596
+ ), O = p.querySelector(
4465
4597
  ".readonly-toggle-btn"
4466
- ), I = p.querySelector(
4467
- ".rte-source-editor-fullscreen-btn"
4468
4598
  ), $ = p.querySelector(
4599
+ ".rte-source-editor-fullscreen-btn"
4600
+ ), I = p.querySelector(
4469
4601
  ".rte-source-editor-close-btn"
4470
- ), C = w.querySelector(
4602
+ ), M = v.querySelector(
4471
4603
  ".rte-source-editor-btn-cancel"
4472
- ), M = w.querySelector(
4604
+ ), E = v.querySelector(
4473
4605
  ".rte-source-editor-btn-save"
4474
- ), D = w.querySelector(
4606
+ ), N = v.querySelector(
4475
4607
  ".unsaved-changes"
4476
- ), F = [], k = (b, R, P, N) => {
4477
- b.addEventListener(R, P, N), F.push(
4478
- () => b.removeEventListener(R, P, N)
4608
+ ), F = [], k = (b, L, B, D) => {
4609
+ b.addEventListener(L, B, D), F.push(
4610
+ () => b.removeEventListener(L, B, D)
4479
4611
  );
4480
- }, A = (b) => {
4481
- d !== b && (d = b, D && (D.style.display = d ? "inline" : "none"));
4612
+ }, P = (b) => {
4613
+ c !== b && (c = b, N && (N.style.display = c ? "inline" : "none"));
4482
4614
  }, H = () => {
4483
- if (!c) {
4484
- for (c = !0; F.length; ) {
4615
+ if (!d) {
4616
+ for (d = !0; F.length; ) {
4485
4617
  const b = F.pop();
4486
4618
  b == null || b();
4487
4619
  }
4488
- o && (o.destroy(), o = null), g.isConnected && g.remove();
4620
+ o && (o.destroy(), o = null), u.isConnected && u.remove();
4489
4621
  }
4490
4622
  }, _ = () => {
4491
- l = l === "dark" ? "light" : "dark", o == null || o.setTheme(l), S && (S.innerHTML = l === "light" ? `
4623
+ l = l === "dark" ? "light" : "dark", o == null || o.setTheme(l), C && (C.innerHTML = l === "light" ? `
4492
4624
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4493
4625
  <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
4494
4626
  </svg>
@@ -4506,7 +4638,7 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4506
4638
  </svg>
4507
4639
  `);
4508
4640
  }, j = () => {
4509
- a = !a, o == null || o.setReadOnly(a), L && (L.classList.toggle("active", a), L.innerHTML = a ? `
4641
+ a = !a, o == null || o.setReadOnly(a), O && (O.classList.toggle("active", a), O.innerHTML = a ? `
4510
4642
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4511
4643
  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
4512
4644
  <circle cx="12" cy="16" r="1"/>
@@ -4519,7 +4651,7 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4519
4651
  </svg>
4520
4652
  `);
4521
4653
  }, q = () => {
4522
- h = !h, g.classList.toggle("fullscreen", h), T.style.height = h ? "calc(100vh - 200px)" : "400px", I && (I.innerHTML = h ? `
4654
+ h = !h, u.classList.toggle("fullscreen", h), S.style.height = h ? "calc(100vh - 200px)" : "400px", $ && ($.innerHTML = h ? `
4523
4655
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4524
4656
  <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"/>
4525
4657
  </svg>
@@ -4529,13 +4661,13 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4529
4661
  </svg>
4530
4662
  `);
4531
4663
  }, G = () => {
4532
- d && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
4664
+ c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
4533
4665
  }, Z = () => {
4534
4666
  try {
4535
- const b = (o == null ? void 0 : o.getValue()) || "", R = document.createElement("div");
4536
- R.innerHTML = b, R.querySelectorAll(
4667
+ const b = (o == null ? void 0 : o.getValue()) || "", L = document.createElement("div");
4668
+ L.innerHTML = b, L.querySelectorAll(
4537
4669
  'script, iframe[src^="javascript:"], object, embed'
4538
- ).forEach((N) => N.remove()), e.innerHTML = R.innerHTML;
4670
+ ).forEach((D) => D.remove()), e.innerHTML = L.innerHTML;
4539
4671
  try {
4540
4672
  e.dispatchEvent(
4541
4673
  new InputEvent("input", {
@@ -4544,42 +4676,42 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4544
4676
  inputType: "insertReplacementText"
4545
4677
  })
4546
4678
  );
4547
- } catch (N) {
4679
+ } catch (D) {
4548
4680
  e.dispatchEvent(
4549
4681
  new Event("input", { bubbles: !0 })
4550
4682
  );
4551
4683
  }
4552
4684
  e.dispatchEvent(
4553
4685
  new Event("change", { bubbles: !0 })
4554
- ), A(!1), H();
4686
+ ), P(!1), H();
4555
4687
  } catch (b) {
4556
4688
  alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", b);
4557
4689
  }
4558
4690
  };
4559
- S && k(S, "click", _), L && k(L, "click", j), I && k(I, "click", q), $ && k($, "click", H), C && k(C, "click", G), M && k(M, "click", Z), k(g, "click", (b) => {
4560
- b.target === g && H();
4691
+ C && k(C, "click", _), O && k(O, "click", j), $ && k($, "click", q), I && k(I, "click", H), M && k(M, "click", G), E && k(E, "click", Z), k(u, "click", (b) => {
4692
+ b.target === u && H();
4561
4693
  }), k(document, "keydown", (b) => {
4562
- const R = b;
4563
- R.key === "Escape" && (R.preventDefault(), H());
4564
- }), document.body.appendChild(g), requestAnimationFrame(() => {
4565
- if (!(c || !g.isConnected))
4694
+ const L = b;
4695
+ L.key === "Escape" && (L.preventDefault(), H());
4696
+ }), document.body.appendChild(u), requestAnimationFrame(() => {
4697
+ if (!(d || !u.isConnected))
4566
4698
  try {
4567
- o = ce(T, {
4699
+ o = ae(S, {
4568
4700
  value: r,
4569
4701
  theme: "dark",
4570
4702
  readOnly: !1,
4571
4703
  extensions: [
4704
+ new ee(),
4572
4705
  new te(),
4573
4706
  new ie(),
4574
- new se(),
4575
- new le(),
4576
4707
  new re(),
4577
- new ae(),
4578
- new he()
4708
+ new U(),
4709
+ new oe(),
4710
+ new le()
4579
4711
  ]
4580
4712
  }), o.on("change", () => {
4581
4713
  const b = (o == null ? void 0 : o.getValue()) || "";
4582
- A(b !== r);
4714
+ P(b !== r);
4583
4715
  }), requestAnimationFrame(() => o == null ? void 0 : o.focus());
4584
4716
  } catch (b) {
4585
4717
  console.error("Failed to initialize code editor:", b);
@@ -4595,6 +4727,6 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
4595
4727
  }
4596
4728
  });
4597
4729
  export {
4598
- ue as CodePlugin
4730
+ de as CodePlugin
4599
4731
  };
4600
- //# sourceMappingURL=CodePlugin.native-veDC_kx5.mjs.map
4732
+ //# sourceMappingURL=CodePlugin.native-BH-K4xmW.mjs.map