@editora/core 1.0.15 → 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 (68) 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-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  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-D1YHQ2NN.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/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-B1_vtXRz.mjs +3910 -0
  48. package/dist/index-C6BoNR2t.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2039 -473
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2208 -641
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
@@ -1,4 +1,5 @@
1
- class _ {
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
  }
@@ -84,7 +85,7 @@ class _ {
84
85
  }
85
86
  // Clone the model
86
87
  clone() {
87
- const e = new _();
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 _ {
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
  }
@@ -508,8 +509,8 @@ class Q {
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 c = Math.max(0, t - i), g = (s = a[c]) != null ? s : l.length;
512
- return { node: o, offset: g };
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;
@@ -573,15 +574,15 @@ class Q {
573
574
  const h = (l = (o = n.textContent) == null ? void 0 : o.length) != null ? l : 0, c = document.createRange();
574
575
  if (s < h) {
575
576
  c.setStart(n, s), c.setEnd(n, Math.min(h, s + 1));
576
- const g = this.getUsableRangeRect(c);
577
- if (g)
578
- return g;
577
+ const d = this.getUsableRangeRect(c);
578
+ if (d)
579
+ return d;
579
580
  }
580
581
  if (s > 0) {
581
582
  c.setStart(n, s - 1), c.setEnd(n, s);
582
- const g = this.getUsableRangeRect(c);
583
- if (g)
584
- return g;
583
+ const d = this.getUsableRangeRect(c);
584
+ if (d)
585
+ return d;
585
586
  }
586
587
  }
587
588
  const r = n instanceof Element ? n : (a = n == null ? void 0 : n.parentElement) != null ? a : null;
@@ -822,10 +823,10 @@ class Q {
822
823
  this.contentElement.__lceFoldPlaceholderSources = e;
823
824
  }
824
825
  }
825
- let Y = 0;
826
- const L = class L {
826
+ let X = 0;
827
+ const w = class w {
827
828
  constructor(e, t = {}) {
828
- 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 = ++Y, 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
+ 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: "",
830
831
  theme: "default",
831
832
  readOnly: !1,
@@ -833,7 +834,7 @@ const L = class L {
833
834
  lineWrapping: !1,
834
835
  lineNumbers: !0,
835
836
  ...t
836
- }, this.textModel = new _(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 L = class L {
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
  }
@@ -874,13 +877,17 @@ const L = class L {
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();
@@ -924,20 +931,21 @@ const L = class L {
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 n of i)
928
- if (n.onKeyDown && n.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
  }
@@ -1115,33 +1123,33 @@ const L = class L {
1115
1123
  } catch (f) {
1116
1124
  return [];
1117
1125
  }
1118
- let g;
1119
- for (; (g = c.exec(r)) !== null; ) {
1120
- const f = (h = g[0]) != null ? h : "";
1126
+ let d;
1127
+ for (; (d = c.exec(r)) !== null; ) {
1128
+ const f = (h = d[0]) != null ? h : "";
1121
1129
  if (f.length === 0) {
1122
- c.lastIndex = g.index + 1;
1130
+ c.lastIndex = d.index + 1;
1123
1131
  continue;
1124
1132
  }
1125
- const d = g.index, u = g.index + f.length;
1126
- i.wholeWord && !this.isWholeWordBoundary(r, d, u) || this.pushSearchResultFromOffsets(
1133
+ const u = d.index, g = d.index + f.length;
1134
+ i.wholeWord && !this.isWholeWordBoundary(r, u, g) || this.pushSearchResultFromOffsets(
1127
1135
  n,
1128
- d,
1129
1136
  u,
1137
+ g,
1130
1138
  r,
1131
1139
  o
1132
1140
  );
1133
1141
  }
1134
1142
  } else {
1135
- let c = 0, g = l.indexOf(a, c);
1136
- for (; g !== -1; ) {
1137
- const f = g + a.length;
1138
- !i.wholeWord || this.isWholeWordBoundary(r, g, f) ? (this.pushSearchResultFromOffsets(
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(
1139
1147
  n,
1140
- g,
1148
+ d,
1141
1149
  f,
1142
1150
  r,
1143
1151
  o
1144
- ), c = f) : c = g + 1, g = l.indexOf(a, c);
1152
+ ), c = f) : c = d + 1, d = l.indexOf(a, c);
1145
1153
  }
1146
1154
  }
1147
1155
  return n;
@@ -1166,7 +1174,7 @@ const L = class L {
1166
1174
  let n = 0;
1167
1175
  for (let s = 0; s < e.length; s++) {
1168
1176
  const r = e[s];
1169
- r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), n += 1, i[n] = s + 1);
1177
+ r === "​" || r === w.CURSOR_SENTINEL || (t.push(r), n += 1, i[n] = s + 1);
1170
1178
  }
1171
1179
  return i[n] = e.length, {
1172
1180
  normalizedText: t.join(""),
@@ -1181,10 +1189,12 @@ const L = class L {
1181
1189
  }
1182
1190
  replaceAll(e, t, i = {}) {
1183
1191
  const n = this.search(e, i);
1184
- let s = 0;
1192
+ if (n.length === 0) return 0;
1193
+ this.suppressHistory || this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));
1194
+ const s = [];
1185
1195
  for (let r = n.length - 1; r >= 0; r--)
1186
- this.replace(n[r].range, t), s++;
1187
- return s;
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) {
@@ -1228,10 +1238,10 @@ const L = class L {
1228
1238
  if (i && typeof i.highlightHTML == "function")
1229
1239
  try {
1230
1240
  if (typeof this.view.setHighlightHTML == "function") {
1231
- const u = this.view.getContentElement();
1232
- (u.querySelector(
1241
+ const g = this.view.getContentElement();
1242
+ (g.querySelector(
1233
1243
  "[data-lce-fold-placeholder]"
1234
- ) || u.textContent !== e) && this.view.setText(e);
1244
+ ) || g.textContent !== e) && this.view.setText(e);
1235
1245
  const m = typeof i.highlight == "function" ? i.highlight(e) : i.highlightHTML(e);
1236
1246
  this.view.setHighlightHTML(m), this.view.syncTrailingNewlineMarkerForText(e), this.scheduleDecorationRender();
1237
1247
  return;
@@ -1240,21 +1250,21 @@ const L = class L {
1240
1250
  let r, o, l, a;
1241
1251
  const h = this.view.getSelectionState(), c = h.isInEditor && !!h.cursor;
1242
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)));
1243
- const g = c && (t || s) && !r && o !== void 0 && this.hasCollapsedSelectionInEditor(), f = g ? this.insertSentinelAtOffset(e, o) : e, d = typeof i.highlight == "function" ? i.highlight(f) : i.highlightHTML(f);
1244
- typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(d) : this.view.setHTML(d), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && c && requestAnimationFrame(() => {
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
- if (g && this.restoreCursorFromSentinel()) {
1256
+ if (d && this.restoreCursorFromSentinel()) {
1247
1257
  this.view.ensureCaretVisible();
1248
1258
  return;
1249
1259
  }
1250
1260
  if (r && (l !== void 0 || a !== void 0)) {
1251
- const u = l !== void 0 ? l : o, p = a !== void 0 ? a : o, m = Math.min(u, p), x = Math.max(u, p), v = this.textModel.offsetToPosition(m), T = this.textModel.offsetToPosition(x);
1252
- this.view.setSelectionRange({ start: v, end: T });
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 });
1253
1263
  } else if (o !== void 0) {
1254
- const u = this.textModel.offsetToPosition(o);
1255
- this.view.setCursorPosition(u);
1264
+ const g = this.textModel.offsetToPosition(o);
1265
+ this.view.setCursorPosition(g);
1256
1266
  }
1257
- } catch (u) {
1267
+ } catch (g) {
1258
1268
  }
1259
1269
  }), this.scheduleDecorationRender();
1260
1270
  return;
@@ -1281,19 +1291,19 @@ const L = class L {
1281
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(L.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) + L.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
1303
  let n = i.nextNode(), s = null, r = 0;
1294
1304
  for (; n; ) {
1295
- const l = (o = n.textContent) != null ? o : "", a = l.indexOf(L.CURSOR_SENTINEL);
1296
- a !== -1 && (s || (s = n, r = a), n.textContent = l.split(L.CURSOR_SENTINEL).join("")), n = i.nextNode();
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
1308
  if (!s || !t) return !1;
1299
1309
  try {
@@ -1339,20 +1349,63 @@ const L = class L {
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);
1402
+ }
1403
+ deleteForward(e = "char") {
1404
+ this.config.readOnly || this.deleteUsingDirection("forward", e);
1353
1405
  }
1354
- deleteForward() {
1355
- this.config.readOnly || this.deleteUsingDirection("forward");
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;
@@ -1544,19 +1597,97 @@ const L = class L {
1544
1597
  endOffset: i
1545
1598
  };
1546
1599
  }
1547
- deleteUsingDirection(e) {
1548
- const t = this.textModel.getText(), { startOffset: i, endOffset: n } = this.getActiveSelectionOffsets(t), s = Math.min(i, n), r = Math.max(i, n);
1549
- if (s !== r) {
1550
- this.replaceOffsetsWithText(s, 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 (s === 0)
1607
+ if (r === 0)
1555
1608
  return;
1556
- this.replaceOffsetsWithText(s - 1, s, "");
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
1693
  var f;
@@ -1570,8 +1701,8 @@ const L = class L {
1570
1701
  n
1571
1702
  );
1572
1703
  this.pendingInputSnapshot = void 0, this.suppressHistory || this.pushUndoSnapshot(r);
1573
- const g = a + n.length;
1574
- return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.textModel.getText(), !1), this.setCursor(this.textModel.offsetToPosition(g)), 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
1707
  }, 20), this.emit("change", [c]), c;
1577
1708
  }
@@ -1768,9 +1899,9 @@ const L = class L {
1768
1899
  };
1769
1900
  }
1770
1901
  };
1771
- L.CURSOR_SENTINEL = "";
1772
- let V = L;
1773
- class X {
1902
+ w.CURSOR_SENTINEL = "";
1903
+ let V = w;
1904
+ class J {
1774
1905
  constructor(e) {
1775
1906
  this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
1776
1907
  }
@@ -1787,8 +1918,8 @@ class X {
1787
1918
  const { key: t, ctrlKey: i, altKey: n, shiftKey: s, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
1788
1919
  if (!l) return null;
1789
1920
  for (const a of l) {
1790
- const h = a.ctrlKey === void 0 || a.ctrlKey === i, c = a.altKey === void 0 || a.altKey === n, g = a.shiftKey === void 0 || a.shiftKey === s, f = a.metaKey === void 0 || a.metaKey === r;
1791
- if (h && c && g && f)
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)
1792
1923
  return a;
1793
1924
  }
1794
1925
  return null;
@@ -1799,7 +1930,7 @@ class X {
1799
1930
  }
1800
1931
  getDefaultKeymap() {
1801
1932
  const e = {};
1802
- 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;
1803
1934
  }
1804
1935
  addBinding(e, t, i, n) {
1805
1936
  const s = t.toLowerCase();
@@ -1844,7 +1975,7 @@ class X {
1844
1975
  this.keymap = {}, this.editor = null;
1845
1976
  }
1846
1977
  }
1847
- const D = class D {
1978
+ const A = class A {
1848
1979
  constructor() {
1849
1980
  this.name = "transaction", this.transactions = [];
1850
1981
  }
@@ -1856,9 +1987,9 @@ const D = class D {
1856
1987
  effects: [],
1857
1988
  annotations: []
1858
1989
  };
1859
- this.transactions.push(i), this.transactions.length > D.MAX_TRANSACTIONS && this.transactions.splice(
1990
+ this.transactions.push(i), this.transactions.length > A.MAX_TRANSACTIONS && this.transactions.splice(
1860
1991
  0,
1861
- this.transactions.length - D.MAX_TRANSACTIONS
1992
+ this.transactions.length - A.MAX_TRANSACTIONS
1862
1993
  );
1863
1994
  });
1864
1995
  }
@@ -1869,9 +2000,9 @@ const D = class D {
1869
2000
  this.transactions = [];
1870
2001
  }
1871
2002
  };
1872
- D.MAX_TRANSACTIONS = 200;
1873
- let W = D;
1874
- class J {
2003
+ A.MAX_TRANSACTIONS = 200;
2004
+ let W = A;
2005
+ class ee {
1875
2006
  constructor() {
1876
2007
  this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
1877
2008
  }
@@ -1900,7 +2031,7 @@ class J {
1900
2031
  this.lineNumbersElement = null, this.editor = null;
1901
2032
  }
1902
2033
  }
1903
- class ee {
2034
+ class te {
1904
2035
  constructor() {
1905
2036
  this.name = "theme", this.editor = null, this.currentTheme = "dark";
1906
2037
  }
@@ -1925,7 +2056,7 @@ class ee {
1925
2056
  this.editor = null;
1926
2057
  }
1927
2058
  }
1928
- class te {
2059
+ class ie {
1929
2060
  constructor() {
1930
2061
  this.name = "read-only", this.editor = null, this.isReadOnly = !1;
1931
2062
  }
@@ -1952,14 +2083,14 @@ class te {
1952
2083
  this.editor = null;
1953
2084
  }
1954
2085
  }
1955
- let ie = 0;
1956
- const y = class y {
2086
+ let ne = 0;
2087
+ const x = class x {
1957
2088
  constructor(e = {}) {
1958
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 = {
1959
2090
  caseSensitive: !1,
1960
2091
  wholeWord: !1,
1961
2092
  regex: !1
1962
- }, this.trailingMarkerAttr = "data-lce-trailing-newline-marker", this.editorContainerSelector = '[data-lce-editor-container="true"]', this.highlightId = ++ie, this.highlightMatchName = `editora-search-match-${this.highlightId}`, this.highlightActiveName = `editora-search-active-${this.highlightId}`, this.highlightStyleId = `editora-search-highlight-style-${this.highlightId}`, this.maxCustomHighlightRanges = 2e3, this.virtualMarkerRegex = /[\u200B\uE000]/, this.hasCustomHighlightSupport = !1, this.config = {
2093
+ }, this.trailingMarkerAttr = "data-lce-trailing-newline-marker", this.editorContainerSelector = '[data-lce-editor-container="true"]', this.highlightId = ++ne, this.highlightMatchName = `editora-search-match-${this.highlightId}`, this.highlightActiveName = `editora-search-active-${this.highlightId}`, this.highlightStyleId = `editora-search-highlight-style-${this.highlightId}`, this.maxCustomHighlightRanges = 2e3, this.virtualMarkerRegex = /[\u200B\uE000]/, this.hasCustomHighlightSupport = !1, this.config = {
1963
2094
  replaceAndFindNext: !0,
1964
2095
  ...e
1965
2096
  };
@@ -1994,67 +2125,67 @@ const y = class y {
1994
2125
  this.editorContainerSelector
1995
2126
  ), i = t == null ? void 0 : t.parentElement, n = e.closest(".rte-source-editor-modal") || i || t || e.parentElement;
1996
2127
  if (!n) return;
1997
- window.getComputedStyle(n).position === "static" && (n.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = y.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
1998
- <div class="${y.css.row}">
1999
- <input type="text" class="${y.css.findInput} ${y.css.inputBase}" placeholder="Find..." />
2000
- <button class="${y.css.prevButton} ${y.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
2001
- <button class="${y.css.nextButton} ${y.css.buttonBase}" type="button" aria-label="Next match">↓</button>
2002
- <button class="${y.css.closeButton} ${y.css.buttonBase}" type="button" aria-label="Close search">×</button>
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>
2003
2134
  </div>
2004
- <div class="${y.css.options}">
2005
- <label class="${y.css.optionLabel}" title="Case sensitive">
2006
- <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}" />
2007
2138
  <span>Aa</span>
2008
2139
  </label>
2009
- <label class="${y.css.optionLabel}" title="Whole word">
2010
- <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}" />
2011
2142
  <span>Whole</span>
2012
2143
  </label>
2013
- <label class="${y.css.optionLabel}" title="Regular expression">
2014
- <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}" />
2015
2146
  <span>.*</span>
2016
2147
  </label>
2017
2148
  </div>
2018
- <div class="${y.css.meta}">
2019
- <div class="${y.css.status} ${y.css.statusLayout}"></div>
2020
- <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>
2021
2152
  </div>
2022
- <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..." />
2023
2154
  `;
2024
2155
  const s = this.searchUI.querySelector(
2025
- `.${y.css.findInput}`
2156
+ `.${x.css.findInput}`
2026
2157
  ), r = this.searchUI.querySelector(
2027
- `.${y.css.replaceInput}`
2158
+ `.${x.css.replaceInput}`
2028
2159
  ), o = this.searchUI.querySelector(
2029
- `.${y.css.prevButton}`
2160
+ `.${x.css.prevButton}`
2030
2161
  ), l = this.searchUI.querySelector(
2031
- `.${y.css.nextButton}`
2162
+ `.${x.css.nextButton}`
2032
2163
  ), a = this.searchUI.querySelector(
2033
- `.${y.css.closeButton}`
2164
+ `.${x.css.closeButton}`
2034
2165
  ), h = this.searchUI.querySelector(
2035
- `.${y.css.status}`
2166
+ `.${x.css.status}`
2036
2167
  ), c = this.searchUI.querySelector(
2037
- `.${y.css.mode}`
2038
- ), g = this.searchUI.querySelector(
2039
- `.${y.css.caseSensitive}`
2040
- ), f = this.searchUI.querySelector(
2041
- `.${y.css.wholeWord}`
2168
+ `.${x.css.mode}`
2042
2169
  ), d = this.searchUI.querySelector(
2043
- `.${y.css.regex}`
2170
+ `.${x.css.caseSensitive}`
2171
+ ), f = this.searchUI.querySelector(
2172
+ `.${x.css.wholeWord}`
2173
+ ), u = this.searchUI.querySelector(
2174
+ `.${x.css.regex}`
2044
2175
  );
2045
- this.findInput = s, this.replaceInputEl = r, this.statusDiv = h, this.modeDiv = c, this.caseSensitiveInput = g, this.wholeWordInput = f, this.regexInput = d, g.checked = !!this.searchOptions.caseSensitive, f.checked = !!this.searchOptions.wholeWord, d.checked = !!this.searchOptions.regex, s.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", () => {
2046
2177
  this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
2047
2178
  const p = s.value;
2048
2179
  this.searchDebounceTimer = setTimeout(() => {
2049
2180
  this.performSearch(p, !1, !1);
2050
2181
  }, 120);
2051
2182
  });
2052
- const u = () => {
2053
- this.searchOptions.caseSensitive = g.checked, this.searchOptions.wholeWord = f.checked, this.searchOptions.regex = d.checked;
2183
+ const g = () => {
2184
+ this.searchOptions.caseSensitive = d.checked, this.searchOptions.wholeWord = f.checked, this.searchOptions.regex = u.checked;
2054
2185
  const p = s.value;
2055
2186
  p.trim() ? this.performSearch(p, !1, !1) : this.performSearch("", !1, !1);
2056
2187
  };
2057
- g.addEventListener("change", u), f.addEventListener("change", u), d.addEventListener("change", u), s.addEventListener("keydown", (p) => {
2188
+ d.addEventListener("change", g), f.addEventListener("change", g), u.addEventListener("change", g), s.addEventListener("keydown", (p) => {
2058
2189
  p.key === "Enter" ? (p.preventDefault(), p.shiftKey ? this.findPrev() : this.findNext()) : p.key === "Escape" && (p.preventDefault(), this.hideSearch());
2059
2190
  }), r.addEventListener("keydown", (p) => {
2060
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());
@@ -2154,12 +2285,12 @@ const y = class y {
2154
2285
  if (!l) return;
2155
2286
  const a = l.startContainer.nodeType === Node.TEXT_NODE ? l.startContainer.parentElement : l.startContainer, h = this.resolveScrollContainer(i);
2156
2287
  if (h) {
2157
- const c = l.getClientRects()[0] || l.getBoundingClientRect(), g = h.getBoundingClientRect(), d = h.scrollTop + (c.top - g.top) - g.height / 2 + c.height / 2, u = 18;
2158
- let p = t ? d : h.scrollTop, m = h.scrollLeft;
2159
- const x = h.scrollLeft + (c.left - g.left), v = x + c.width;
2160
- c.right > g.right - u ? m = v - g.width + u : c.left < g.left + u && (m = Math.max(0, x - u));
2161
- const T = Math.max(0, h.scrollHeight - h.clientHeight), S = Math.max(0, h.scrollWidth - h.clientWidth);
2162
- if (p = Math.min(T, Math.max(0, p)), m = Math.min(S, Math.max(0, m)), T === 0 && S === 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) {
2163
2294
  a == null || a.scrollIntoView({
2164
2295
  block: t ? "center" : "nearest",
2165
2296
  inline: "nearest",
@@ -2306,13 +2437,13 @@ const y = class y {
2306
2437
  let l = null;
2307
2438
  const a = Math.min(this.currentResults.length, this.maxCustomHighlightRanges);
2308
2439
  for (let h = 0; h < a; h++) {
2309
- const c = this.currentResults[h], g = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
2440
+ const c = this.currentResults[h], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
2310
2441
  c.range,
2311
2442
  i,
2312
2443
  n,
2313
2444
  s,
2314
2445
  r,
2315
- g
2446
+ d
2316
2447
  );
2317
2448
  f && (o.push(f), h === this.currentIndex && (l = f));
2318
2449
  }
@@ -2358,12 +2489,12 @@ const y = class y {
2358
2489
  var s, r, o, l, a, h;
2359
2490
  const i = Math.max(0, e);
2360
2491
  for (let c = 0; c < t.length; c++) {
2361
- const g = t[c];
2362
- if (i <= g.end) {
2363
- const f = Math.max(0, i - g.start), d = (o = (r = g.visibleToDom[f]) != null ? r : (s = g.node.textContent) == null ? void 0 : s.length) != null ? o : 0;
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: g.node,
2366
- offset: d
2496
+ node: d.node,
2497
+ offset: u
2367
2498
  };
2368
2499
  }
2369
2500
  }
@@ -2377,22 +2508,22 @@ const y = class y {
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
2510
  if (s && r) {
2380
- const d = r, u = s.slice(a, h);
2381
- if (u.length === d.length && u.toLowerCase() !== d.toLowerCase()) {
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
2514
  s,
2384
- d,
2515
+ u,
2385
2516
  a
2386
2517
  );
2387
- p !== -1 && (a = p, h = p + d.length);
2518
+ p !== -1 && (a = p, h = p + u.length);
2388
2519
  }
2389
2520
  }
2390
- const c = this.resolveDomPoint(a, n), g = this.resolveDomPoint(h, n);
2391
- if (!c || !g) return null;
2521
+ const c = this.resolveDomPoint(a, n), d = this.resolveDomPoint(h, n);
2522
+ if (!c || !d) return null;
2392
2523
  const f = document.createRange();
2393
2524
  try {
2394
- return f.setStart(c.node, c.offset), f.setEnd(g.node, g.offset), f;
2395
- } catch (d) {
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
  }
@@ -2503,7 +2634,7 @@ const y = class y {
2503
2634
  e != null && e.parentNode && e.parentNode.removeChild(e), this.editor = null;
2504
2635
  }
2505
2636
  };
2506
- y.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 @@ y.css = {
2526
2657
  mode: "search-mode",
2527
2658
  modeLayout: "lce-search-mode"
2528
2659
  };
2529
- let U = y, ne = 0;
2530
- class se {
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 se {
2539
2670
  "]": "[",
2540
2671
  "}": "{",
2541
2672
  ">": "<"
2542
- }, this.highlightId = ++ne, 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 = () => {
@@ -2697,7 +2828,7 @@ class se {
2697
2828
  this.cursorHandler = null, this.changeHandler = null, this.editor = null;
2698
2829
  }
2699
2830
  }
2700
- class re {
2831
+ class oe {
2701
2832
  constructor() {
2702
2833
  this.name = "code-folding", this.lineHeight = 21, this.voidMarkupTags = /* @__PURE__ */ new Set([
2703
2834
  "area",
@@ -2830,19 +2961,19 @@ class re {
2830
2961
  i.push({ char: c, line: l, column: h });
2831
2962
  continue;
2832
2963
  }
2833
- const g = r[c];
2834
- if (!g) continue;
2964
+ const d = r[c];
2965
+ if (!d) continue;
2835
2966
  let f = -1;
2836
2967
  for (let m = i.length - 1; m >= 0; m--)
2837
- if (i[m].char === g) {
2968
+ if (i[m].char === d) {
2838
2969
  f = m;
2839
2970
  break;
2840
2971
  }
2841
2972
  if (f === -1) continue;
2842
- const d = i.splice(f, 1)[0];
2843
- if (d.line >= l) continue;
2844
- const u = ((o = t[d.line]) == null ? void 0 : o.length) || 0, p = {
2845
- start: { line: d.line, column: u },
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
2979
  level: f
@@ -2933,16 +3064,16 @@ class re {
2933
3064
  return null;
2934
3065
  let h = null;
2935
3066
  for (; o < e.length; ) {
2936
- const u = e[o];
3067
+ const g = e[o];
2937
3068
  if (h) {
2938
- u === h && (h = null), o += 1;
3069
+ g === h && (h = null), o += 1;
2939
3070
  continue;
2940
3071
  }
2941
- if (u === '"' || u === "'") {
2942
- h = u, o += 1;
3072
+ if (g === '"' || g === "'") {
3073
+ h = g, o += 1;
2943
3074
  continue;
2944
3075
  }
2945
- if (u === ">")
3076
+ if (g === ">")
2946
3077
  break;
2947
3078
  o += 1;
2948
3079
  }
@@ -2951,13 +3082,13 @@ class re {
2951
3082
  const c = e.slice(l, a).toLowerCase();
2952
3083
  if (!c)
2953
3084
  return null;
2954
- const g = e.slice(t, o + 1), f = this.offsetToLine(t, i, n), d = this.offsetToLine(o, i, n);
3085
+ const d = e.slice(t, o + 1), f = this.offsetToLine(t, i, n), u = this.offsetToLine(o, i, n);
2955
3086
  return {
2956
3087
  name: c,
2957
3088
  isClosing: r,
2958
- isSelfClosing: !r && /\/\s*>$/.test(g),
3089
+ isSelfClosing: !r && /\/\s*>$/.test(d),
2959
3090
  startLine: f,
2960
- endLine: d,
3091
+ endLine: u,
2961
3092
  endOffset: o + 1
2962
3093
  };
2963
3094
  }
@@ -3103,13 +3234,13 @@ class re {
3103
3234
  const o = [];
3104
3235
  let l = 0;
3105
3236
  for (const h of s) {
3106
- const c = this.positionToOffset(h.start, i, n), g = this.positionToOffset(h.end, i, n), f = e.slice(l, c), d = this.getFoldPlaceholder(h), u = e.slice(c, g);
3107
- r += f, r += d, f && o.push({ type: "text", text: f }), o.push({
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: d,
3240
+ text: u,
3110
3241
  fold: h,
3111
- hiddenText: u
3112
- }), l = g;
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 };
@@ -3197,28 +3328,28 @@ class re {
3197
3328
  }
3198
3329
  findReplacementFold(e, t, i, n, s) {
3199
3330
  const r = this.getFoldKey(e), o = this.foldRegions.find(
3200
- (d) => this.getFoldKey(d) === 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, n, s), c = this.foldRegions.filter((d) => !i.has(this.getFoldKey(d))).map((d) => {
3205
- const u = this.createFoldSnapshot(d, n, s), p = a && (u == null ? void 0 : u.startLineText) === a.startLineText ? 1 : 0, m = a && (u == null ? void 0 : u.endLineText) === a.endLineText ? 1 : 0, x = 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: d,
3208
- overlaps: this.lineRangeOverlap(e, d),
3209
- lineDistance: Math.abs(d.start.line - e.start.line) + Math.abs(d.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
- d.end.line - d.start.line - l
3342
+ u.end.line - u.start.line - l
3212
3343
  ),
3213
- columnDistance: Math.abs(d.start.column - e.start.column) + Math.abs(d.end.column - e.end.column),
3214
- hiddenTextMatch: a && (u == null ? void 0 : u.hiddenText) === a.hiddenText ? 1 : 0,
3215
- boundaryMatchScore: p + m + x
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((d, u) => d.hiddenTextMatch !== u.hiddenTextMatch ? u.hiddenTextMatch - d.hiddenTextMatch : d.boundaryMatchScore !== u.boundaryMatchScore ? u.boundaryMatchScore - d.boundaryMatchScore : d.overlaps !== u.overlaps ? u.overlaps - d.overlaps : d.lineDistance !== u.lineDistance ? d.lineDistance - u.lineDistance : d.spanDistance !== u.spanDistance ? d.spanDistance - u.spanDistance : d.columnDistance - u.columnDistance)[0];
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];
3218
3349
  if (!c)
3219
3350
  return null;
3220
- const g = c.lineDistance <= 2 && c.spanDistance <= 1;
3221
- return !(c.hiddenTextMatch === 1 || c.boundaryMatchScore >= 2) && !g ? null : c.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
3355
  const i = Math.max(e.start.line, t.start.line), n = Math.min(e.end.line, t.end.line);
@@ -3365,7 +3496,7 @@ class re {
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 oe {
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
  }
@@ -3570,55 +3701,55 @@ class oe {
3570
3701
  return s >= 2 ? n : null;
3571
3702
  }
3572
3703
  _highlightHTML(e, t) {
3573
- const i = t, n = (g) => this.escapeHTML(g), s = [], r = this.createTokenStore(s), o = [], l = (g) => {
3704
+ const i = t, n = (d) => this.escapeHTML(d), s = [], r = this.createTokenStore(s), o = [], l = (d) => {
3574
3705
  const f = o.length;
3575
- return o.push(g), `ht${f}`;
3706
+ return o.push(d), `ht${f}`;
3576
3707
  };
3577
3708
  let a = n(e);
3578
3709
  a = a.replace(
3579
3710
  /&lt;\/?(?:(?!&gt;)[^\n\r<])*?(?=$|[\n\r])/g,
3580
- (g) => l(g)
3711
+ (d) => l(d)
3581
3712
  );
3582
3713
  const h = [];
3583
3714
  try {
3584
- e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (g, f, d) => (h.push({ attrs: String(f || ""), inner: String(d || "") }), g));
3585
- } catch (g) {
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
3718
  let c = 0;
3588
- return a = a.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (g, f, d, u, p) => {
3589
- var v, T, S;
3590
- const m = (T = (v = h[c++]) == null ? void 0 : v.inner) != null ? T : this.unescapeEntitiesRepeated(u || "");
3591
- (((S = h[c - 1]) == null ? void 0 : S.attrs) || d || "").toLowerCase();
3592
- const x = this._highlightJS(m, i);
3593
- return `${f}${x}${p}`;
3594
- }), a = a.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (g, f, d, u) => {
3595
- const p = this._highlightCSS(this.unescapeEntitiesRepeated(d), i);
3596
- return `${f}${p}${u}`;
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
- (g) => r(`<span style="color: ${i.comment};">${g}</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
- (g) => r(`<span style="color: ${i.doctype};">${g}</span>`)
3603
- ), a = a.replace(/(&lt;\/?\s*)([^\s&>\/]+)([^<]*?)(\/?&gt;)/g, (g, f, d, u, p) => {
3604
- const m = `<span style="color: ${i.tag};">${d}</span>`;
3605
- let x = u;
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, S, w) => {
3609
- const O = String(T).toLowerCase(), $ = `<span style="color: ${i.attrName};">${T}</span>`;
3610
- let I = w, C = "";
3611
- w.startsWith("&quot;") && w.endsWith("&quot;") ? (I = w.slice(6, -6), C = "&quot;") : w.startsWith("&#39;") && w.endsWith("&#39;") && (I = w.slice(5, -5), C = "&#39;");
3612
- let M = w;
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;
3613
3744
  if (O === "style") {
3614
- const N = I.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (A, R, P, H) => `<span style="color: ${i.styleProp};">${R}</span>:<span style="color: ${i.styleVal};">${P}</span>${H}`);
3615
- C ? M = `${C}${N}${C}` : M = N, M = `<span style="color: ${i.attrValue};">${M}</span>`;
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}${I}${C}`), M = `<span style="color: ${i.attrValue};">${M}</span>`;
3618
- return `${$}${S}${M}`;
3748
+ M && (E = `${M}${I}${M}`), E = `<span style="color: ${i.attrValue};">${E}</span>`;
3749
+ return `${$}${v}${E}`;
3619
3750
  }
3620
- ), `${f}${m}${x}${p}`;
3621
- }), a = a.replace(/\u0002ht(\d+)\u0002/g, (g, f) => o[Number(f)] || ""), this.restoreHighlightTokens(a, s);
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
3755
  const i = this.unescapeEntitiesRepeated(e), n = [], s = this.createTokenStore(n), r = /(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
@@ -3633,7 +3764,7 @@ class oe {
3633
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, c, g) => `${s(`<span style="color: ${t.styleProp};">${c}</span>`)}${g}`
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
3770
  (h) => s(`<span style="color: ${t.number};">${h}</span>`)
@@ -3652,8 +3783,8 @@ class oe {
3652
3783
  s < o.index && (r += this.escapeHTML(i.slice(s, o.index)));
3653
3784
  const l = o[0], a = o[1], h = o[2] || "", c = o[3];
3654
3785
  if (a) {
3655
- const g = h ? t.attrName : t.string;
3656
- r += `<span style="color: ${g};">${this.escapeHTML(a)}</span>${this.escapeHTML(h)}`;
3786
+ const d = h ? t.attrName : t.string;
3787
+ r += `<span style="color: ${d};">${this.escapeHTML(a)}</span>${this.escapeHTML(h)}`;
3657
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>`;
3658
3789
  s = n.lastIndex;
3659
3790
  }
@@ -3665,57 +3796,57 @@ class oe {
3665
3796
  `);
3666
3797
  let s = !1, r = "", o = "", l = ((a = n[0]) == null ? void 0 : a.trim()) === "---";
3667
3798
  return n.map((h, c) => {
3668
- const g = [], f = this.createTokenStore(g);
3799
+ const d = [], f = this.createTokenStore(d);
3669
3800
  if (l) {
3670
- const p = h.trim() === "---", x = `<span style="color: ${p ? t.keyword : t.attrName};">${this.escapeHTML(h)}</span>`;
3671
- return c > 0 && p && (l = !1), x;
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 d = h.match(/^(\s*)(`{3,}|~{3,})(.*)$/);
3674
- if (d) {
3675
- const p = d[2];
3676
- return s = !(s && p[0] === r[0]), r = s ? p : "", o = s ? this.extractMarkdownFenceLanguage(d[3] || "") : "", [
3677
- this.escapeHTML(d[1]),
3804
+ const u = h.match(/^(\s*)(`{3,}|~{3,})(.*)$/);
3805
+ if (u) {
3806
+ const p = u[2];
3807
+ return s = !(s && p[0] === r[0]), r = s ? p : "", o = s ? this.extractMarkdownFenceLanguage(u[3] || "") : "", [
3808
+ this.escapeHTML(u[1]),
3678
3809
  `<span style="color: ${t.keyword}; font-weight: 700;">${this.escapeHTML(p)}</span>`,
3679
- `<span style="color: ${t.string};">${this.escapeHTML(d[3] || "")}</span>`
3810
+ `<span style="color: ${t.string};">${this.escapeHTML(u[3] || "")}</span>`
3680
3811
  ].join("");
3681
3812
  }
3682
3813
  if (s)
3683
3814
  return this.highlightMarkdownFenceLine(h, o, t);
3684
- let u = this.escapeHTML(h).replace(
3815
+ let g = this.escapeHTML(h).replace(
3685
3816
  /(`[^`]+`)/g,
3686
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
- (p, m, x) => f(`<span style="color: ${t.attrName};">${m}</span><span style="color: ${t.attrValue};">${x}</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
- (p, m, x) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${x}</span><span style="color: ${t.keyword};">${m}</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
- (p, m, x) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.comment}; text-decoration: line-through;">${x}</span><span style="color: ${t.keyword};">${m}</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
- (p, m, x) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.styleVal}; font-style: italic;">${x}</span><span style="color: ${t.keyword};">${m}</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
- return u = u.replace(
3831
+ return g = g.replace(
3701
3832
  /^(\s{0,3}#{1,6})(\s+.*)?$/,
3702
- (p, m, x = "") => `<span style="color: ${t.keyword}; font-weight: 700;">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${x}</span>`
3703
- ), u = u.replace(
3833
+ (p, m, y = "") => `<span style="color: ${t.keyword}; font-weight: 700;">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${y}</span>`
3834
+ ), g = g.replace(
3704
3835
  /^(\s{0,3})((?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,
3705
- (p, m, x) => `${m}<span style="color: ${t.comment};">${x}</span>`
3706
- ), u = u.replace(
3836
+ (p, m, y) => `${m}<span style="color: ${t.comment};">${y}</span>`
3837
+ ), g = g.replace(
3707
3838
  /^(\s{0,3}&gt;)(.*)$/,
3708
- (p, m, x) => `<span style="color: ${t.comment};">${m}</span>${x}`
3709
- ), u = u.replace(
3839
+ (p, m, y) => `<span style="color: ${t.comment};">${m}</span>${y}`
3840
+ ), g = g.replace(
3710
3841
  /^(\s*)([-*+])(\s+\[[ xX]\])(\s+)/,
3711
- (p, m, x, v, T) => `${m}<span style="color: ${t.keyword};">${x}</span><span style="color: ${t.attrName};">${v}</span>${T}`
3712
- ), u = u.replace(
3842
+ (p, m, y, T, S) => `${m}<span style="color: ${t.keyword};">${y}</span><span style="color: ${t.attrName};">${T}</span>${S}`
3843
+ ), g = g.replace(
3713
3844
  /^(\s*)([-*+]|\d+\.)(\s+)/,
3714
- (p, m, x, v) => `${m}<span style="color: ${t.keyword};">${x}</span>${v}`
3715
- ), u = u.replace(
3845
+ (p, m, y, T) => `${m}<span style="color: ${t.keyword};">${y}</span>${T}`
3846
+ ), g = g.replace(
3716
3847
  /^(\s*\|.*\|\s*)$/,
3717
3848
  (p) => p.replace(/\|/g, (m) => `<span style="color: ${t.keyword};">${m}</span>`)
3718
- ), this.restoreHighlightTokens(u, g);
3849
+ ), this.restoreHighlightTokens(g, d);
3719
3850
  }).join(`
3720
3851
  `);
3721
3852
  }
@@ -3738,13 +3869,13 @@ class oe {
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, c, g) => `${c}${s(`<span style="color: ${t.attrName};">${g}</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
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, c, g) => `${c}${s(`<span style="color: ${t.tag};">${g}</span>`)}`
3878
+ (h, c, d) => `${c}${s(`<span style="color: ${t.tag};">${d}</span>`)}`
3748
3879
  ), this.restoreHighlightTokens(l, n);
3749
3880
  }
3750
3881
  getLanguageKeywords(e) {
@@ -3769,19 +3900,19 @@ class oe {
3769
3900
  let a = 0, h = "", c;
3770
3901
  for (; c = l.exec(n); ) {
3771
3902
  a < c.index && (h += this.escapeHTML(n.slice(a, c.index)));
3772
- const f = c[0], d = f.startsWith("//") || f.startsWith("/*") || f.startsWith("#") || f.startsWith("--") ? t.comment : t.string;
3773
- h += r(`<span style="color: ${d};">${this.escapeHTML(f)}</span>`), a = l.lastIndex;
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
3906
  a < n.length && (h += this.escapeHTML(n.slice(a)));
3776
- const g = Array.from(new Set(this.getLanguageKeywords(i)));
3777
- if (g.length > 0) {
3907
+ const d = Array.from(new Set(this.getLanguageKeywords(i)));
3908
+ if (d.length > 0) {
3778
3909
  const f = new RegExp(
3779
- `\\b(${g.map((d) => d.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`,
3910
+ `\\b(${d.map((u) => u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`,
3780
3911
  i === "sql" ? "gi" : "g"
3781
3912
  );
3782
3913
  h = h.replace(
3783
3914
  f,
3784
- (d) => r(`<span style="color: ${t.keyword};">${d}</span>`)
3915
+ (u) => r(`<span style="color: ${t.keyword};">${u}</span>`)
3785
3916
  );
3786
3917
  }
3787
3918
  return h = h.replace(
@@ -3824,12 +3955,12 @@ class oe {
3824
3955
  (s) => {
3825
3956
  const r = i.length, o = this.escapeHTML(s).replace(
3826
3957
  /(&lt;\/?)([A-Za-z][\w.:-]*)([\s\S]*?)(\/?&gt;)/,
3827
- (l, a, h, c, g) => {
3958
+ (l, a, h, c, d) => {
3828
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>${f}${g}`;
3963
+ return `${a}<span style="color: ${t.tag};">${h}</span>${f}${d}`;
3833
3964
  }
3834
3965
  );
3835
3966
  return i.push(o), `jsx${r}`;
@@ -3865,14 +3996,14 @@ class oe {
3865
3996
  const i = this.unescapeEntitiesRepeated(e);
3866
3997
  this.escapeHTML(i);
3867
3998
  const n = [], s = (f) => {
3868
- let d = "", u = f;
3999
+ let u = "", g = f;
3869
4000
  do
3870
- d = String.fromCharCode(97 + u % 26) + d, u = Math.floor(u / 26) - 1;
3871
- while (u >= 0);
3872
- return d || "a";
4001
+ u = String.fromCharCode(97 + g % 26) + u, g = Math.floor(g / 26) - 1;
4002
+ while (g >= 0);
4003
+ return u || "a";
3873
4004
  }, r = (f) => `\0${s(f)}\0`, o = (f) => {
3874
- const d = n.length;
3875
- return n.push(f), r(d);
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;
@@ -3880,60 +4011,60 @@ class oe {
3880
4011
  for (; l = a.exec(i); ) {
3881
4012
  const f = l.index;
3882
4013
  h < f && (c += this.escapeHTML(i.slice(h, f)));
3883
- const d = l[0];
3884
- /^\/\*/.test(d) || /^\/\//.test(d) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(d)}</span>`), h = a.lastIndex;
4014
+ const u = l[0];
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 && (c += this.escapeHTML(i.slice(h))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (f, d, u) => {
3887
- const p = c[u - 1] || "", m = c[u + f.length] || "";
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] || "";
3888
4019
  return p === "&" || p === "#" || m === ";" || m === "#" ? f : `<span style="color: ${t.number};">${f}</span>`;
3889
- }), 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, d) => {
3890
- let u = 0;
3891
- for (let p = 0; p < d.length; p++)
3892
- u = u * 26 + (d.charCodeAt(p) - 97 + 1);
3893
- return u = u - 1, n[u] || "";
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) => {
4021
+ let g = 0;
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
4029
  let n = this.escapeHTML(i);
3899
- const s = [], r = (d) => {
3900
- let u = "", p = d;
4030
+ const s = [], r = (u) => {
4031
+ let g = "", p = u;
3901
4032
  do
3902
- u = String.fromCharCode(97 + p % 26) + u, 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 u || "a";
3905
- }, o = (d) => {
3906
- const u = s.length;
3907
- return s.push(d), `\0${r(u)}\0`;
3908
- }, l = (d, u) => {
3909
- const p = n.indexOf(d);
3910
- return p === -1 ? !1 : (n = n.slice(0, p) + u + n.slice(p + d.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, c = /\/\/[^\n\r]*/g, g = /\#([^\n\r]*)/g, f = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/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 d = a[0];
3916
- l(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
4046
+ const u = a[0];
4047
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
3917
4048
  }
3918
4049
  for (; a = c.exec(i); ) {
3919
- const d = a[0];
3920
- l(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
4050
+ const u = a[0];
4051
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
3921
4052
  }
3922
- for (; a = g.exec(i); ) {
3923
- const d = a[0];
3924
- l(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
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
4057
  for (; a = f.exec(i); ) {
3927
- const d = a[0];
3928
- l(this.escapeHTML(d), o(`<span style="color: ${t.string};">${this.escapeHTML(d)}</span>`));
4058
+ const u = a[0];
4059
+ l(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
3929
4060
  }
3930
4061
  return n = n.replace(
3931
4062
  /(&lt;\?(?:php\b|=)?|\?&gt;)/gi,
3932
- (d) => o(`<span style="color: ${t.keyword};">${d}</span>`)
3933
- ), 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, (d, u) => {
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 < u.length; m++)
3936
- p = p * 26 + (u.charCodeAt(m) - 97 + 1);
4066
+ for (let m = 0; m < g.length; m++)
4067
+ p = p * 26 + (g.charCodeAt(m) - 97 + 1);
3937
4068
  return p = p - 1, s[p] || "";
3938
4069
  }), n;
3939
4070
  }
@@ -3945,11 +4076,11 @@ class oe {
3945
4076
  this.editor = null, this.modes.clear();
3946
4077
  }
3947
4078
  }
3948
- function le(E, e) {
4079
+ function ae(R, e) {
3949
4080
  const t = { ...e };
3950
- return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new X(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new W()), new V(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 z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* 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 z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4326
4457
  flex: 1;
4327
4458
  text-align: center;
4328
4459
  }
4329
- }`, he = () => ({
4460
+ }`, de = () => ({
4330
4461
  name: "code",
4331
4462
  // Toolbar button configuration
4332
4463
  toolbar: [
@@ -4394,12 +4525,13 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* 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, c = !1, g = !1;
4399
- const f = !!e.closest(z) || document.body.matches(z) || document.documentElement.matches(z), d = document.createElement("div");
4400
- d.className = "rte-source-editor-overlay", f && d.classList.add("rte-theme-dark");
4401
- const u = document.createElement("div");
4402
- u.className = "rte-source-editor-modal", u.setAttribute("role", "dialog"), u.setAttribute("aria-modal", "true"), u.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 z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* 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);
4578
+ T.className = "rte-source-editor-warning", T.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
4449
4579
  const S = document.createElement("div");
4450
- if (S.className = "rte-source-editor-footer", S.innerHTML = `
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,11 +4587,11 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* 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
- `, u.appendChild(p), u.appendChild(m), u.appendChild(S), d.appendChild(u), !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 = ae, document.head.appendChild(b);
4592
+ b.id = "rte-source-editor-styles", b.textContent = he, document.head.appendChild(b);
4461
4593
  }
4462
- const w = p.querySelector(
4594
+ const C = p.querySelector(
4463
4595
  ".theme-toggle-btn"
4464
4596
  ), O = p.querySelector(
4465
4597
  ".readonly-toggle-btn"
@@ -4467,28 +4599,28 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4467
4599
  ".rte-source-editor-fullscreen-btn"
4468
4600
  ), I = p.querySelector(
4469
4601
  ".rte-source-editor-close-btn"
4470
- ), C = S.querySelector(
4602
+ ), M = v.querySelector(
4471
4603
  ".rte-source-editor-btn-cancel"
4472
- ), M = S.querySelector(
4604
+ ), E = v.querySelector(
4473
4605
  ".rte-source-editor-btn-save"
4474
- ), N = S.querySelector(
4606
+ ), N = v.querySelector(
4475
4607
  ".unsaved-changes"
4476
- ), A = [], R = (b, k, B, F) => {
4477
- b.addEventListener(k, B, F), A.push(
4478
- () => b.removeEventListener(k, B, F)
4608
+ ), F = [], k = (b, L, B, D) => {
4609
+ b.addEventListener(L, B, D), F.push(
4610
+ () => b.removeEventListener(L, B, D)
4479
4611
  );
4480
4612
  }, P = (b) => {
4481
4613
  c !== b && (c = b, N && (N.style.display = c ? "inline" : "none"));
4482
4614
  }, H = () => {
4483
- if (!g) {
4484
- for (g = !0; A.length; ) {
4485
- const b = A.pop();
4615
+ if (!d) {
4616
+ for (d = !0; F.length; ) {
4617
+ const b = F.pop();
4486
4618
  b == null || b();
4487
4619
  }
4488
- o && (o.destroy(), o = null), d.isConnected && d.remove();
4620
+ o && (o.destroy(), o = null), u.isConnected && u.remove();
4489
4621
  }
4490
- }, K = () => {
4491
- l = l === "dark" ? "light" : "dark", o == null || o.setTheme(l), w && (w.innerHTML = l === "light" ? `
4622
+ }, _ = () => {
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>
@@ -4519,7 +4651,7 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4519
4651
  </svg>
4520
4652
  `);
4521
4653
  }, q = () => {
4522
- h = !h, d.classList.toggle("fullscreen", h), T.style.height = h ? "calc(100vh - 200px)" : "400px", $ && ($.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>
@@ -4532,10 +4664,10 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4532
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()) || "", k = document.createElement("div");
4536
- k.innerHTML = b, k.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((F) => F.remove()), e.innerHTML = k.innerHTML;
4670
+ ).forEach((D) => D.remove()), e.innerHTML = L.innerHTML;
4539
4671
  try {
4540
4672
  e.dispatchEvent(
4541
4673
  new InputEvent("input", {
@@ -4544,7 +4676,7 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4544
4676
  inputType: "insertReplacementText"
4545
4677
  })
4546
4678
  );
4547
- } catch (F) {
4679
+ } catch (D) {
4548
4680
  e.dispatchEvent(
4549
4681
  new Event("input", { bubbles: !0 })
4550
4682
  );
@@ -4556,26 +4688,26 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4556
4688
  alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", b);
4557
4689
  }
4558
4690
  };
4559
- w && R(w, "click", K), O && R(O, "click", j), $ && R($, "click", q), I && R(I, "click", H), C && R(C, "click", G), M && R(M, "click", Z), R(d, "click", (b) => {
4560
- b.target === d && H();
4561
- }), R(document, "keydown", (b) => {
4562
- const k = b;
4563
- k.key === "Escape" && (k.preventDefault(), H());
4564
- }), document.body.appendChild(d), requestAnimationFrame(() => {
4565
- if (!(g || !d.isConnected))
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();
4693
+ }), k(document, "keydown", (b) => {
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 = le(T, {
4699
+ o = ae(S, {
4568
4700
  value: r,
4569
4701
  theme: "dark",
4570
4702
  readOnly: !1,
4571
4703
  extensions: [
4572
- new J(),
4573
4704
  new ee(),
4574
4705
  new te(),
4575
- new se(),
4576
- new U(),
4706
+ new ie(),
4577
4707
  new re(),
4578
- new oe()
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()) || "";
@@ -4595,6 +4727,6 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
4595
4727
  }
4596
4728
  });
4597
4729
  export {
4598
- he as CodePlugin
4730
+ de as CodePlugin
4599
4731
  };
4600
- //# sourceMappingURL=CodePlugin.native-knhM8NNo.mjs.map
4732
+ //# sourceMappingURL=CodePlugin.native-BH-K4xmW.mjs.map