@editora/plugins 1.0.9 → 1.0.10

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 (140) hide show
  1. package/README.md +5 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +40 -40
  11. package/dist/approval-workflow.esm.js +249 -208
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +45 -45
  16. package/dist/blocks-library.esm.js +245 -178
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +37 -37
  21. package/dist/citations.esm.js +512 -439
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +90 -90
  31. package/dist/conditional-content.esm.js +432 -371
  32. package/dist/content-rules.cjs.js +7 -7
  33. package/dist/content-rules.esm.js +159 -105
  34. package/dist/data-binding.cjs.js +46 -46
  35. package/dist/data-binding.esm.js +368 -328
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +29 -29
  38. package/dist/doc-schema.esm.js +308 -240
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -1
  49. package/dist/enterprise.esm.js +56 -54
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +128 -125
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +9 -9
  87. package/dist/mentions.esm.js +286 -238
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +49 -33
  92. package/dist/pii-redaction.cjs.js +19 -19
  93. package/dist/pii-redaction.esm.js +463 -393
  94. package/dist/preview.esm.js +10 -5
  95. package/dist/print.cjs.js +4 -4
  96. package/dist/print.esm.js +20 -17
  97. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  98. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  99. package/dist/slash-commands.cjs.js +3 -3
  100. package/dist/slash-commands.esm.js +212 -176
  101. package/dist/smart-paste.cjs.js +27 -27
  102. package/dist/smart-paste.esm.js +336 -280
  103. package/dist/special-characters.cjs.js +7 -7
  104. package/dist/special-characters.esm.js +69 -61
  105. package/dist/spell-check.cjs.js +5 -5
  106. package/dist/spell-check.esm.js +123 -97
  107. package/dist/strikethrough.cjs.js +1 -1
  108. package/dist/strikethrough.esm.js +19 -14
  109. package/dist/style.css +1 -0
  110. package/dist/table.cjs.js +4 -4
  111. package/dist/table.esm.js +225 -191
  112. package/dist/template.cjs.js +11 -11
  113. package/dist/template.esm.js +153 -124
  114. package/dist/text-alignment.cjs.js +1 -1
  115. package/dist/text-alignment.esm.js +27 -21
  116. package/dist/text-color.cjs.js +3 -3
  117. package/dist/text-color.esm.js +87 -70
  118. package/dist/track-changes.cjs.js +2 -2
  119. package/dist/track-changes.esm.js +162 -100
  120. package/dist/translation-workflow.cjs.js +74 -74
  121. package/dist/translation-workflow.esm.js +678 -602
  122. package/dist/version-diff.cjs.js +14 -14
  123. package/dist/version-diff.esm.js +157 -128
  124. package/package.json +13 -7
  125. package/LICENSE +0 -21
  126. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  127. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  128. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  129. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  130. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  131. package/dist/documentManager-Jf0RbSks.js +0 -17
  132. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  133. package/dist/index-CvJk4DKa.js +0 -221
  134. package/dist/index-D3CycEFU.mjs +0 -16543
  135. package/dist/index-tqLTHcO6.js +0 -1
  136. package/dist/index.es-CE_A4QSm.js +0 -5
  137. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  138. package/dist/jspdf.es.min-BoS80556.js +0 -77
  139. package/dist/plugins.css +0 -1
  140. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -1,4 +1,4 @@
1
- const S = ".rte-content, .editora-content", mt = "rte-citations-styles", b = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Bt = {
1
+ const $ = ".rte-content, .editora-content", gt = "rte-citations-styles", m = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Bt = {
2
2
  panelTitle: "Citations",
3
3
  panelAriaLabel: "Citations panel",
4
4
  styleLabel: "Citation style",
@@ -27,41 +27,42 @@ function g(t) {
27
27
  function Pt(t) {
28
28
  return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
29
29
  }
30
- function ht(t, e) {
31
- const n = e(t);
32
- if (!n) return "";
33
- const i = n.match(/\d{4}/);
34
- return i ? i[0] : n;
30
+ function ht(t, n) {
31
+ const e = n(t);
32
+ if (!e)
33
+ return "";
34
+ const i = e.match(/\d{4}/);
35
+ return i ? i[0] : e;
35
36
  }
36
- function xt(t, e) {
37
- const n = e(t);
38
- return n ? /^https?:\/\//i.test(n) ? n : `https://${n}` : "";
37
+ function xt(t, n) {
38
+ const e = n(t);
39
+ return e ? /^https?:\/\//i.test(e) ? e : `https://${e}` : "";
39
40
  }
40
41
  function F(t) {
41
42
  return t.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
42
43
  }
43
- function yt(t, e) {
44
+ function yt(t, n) {
44
45
  return {
45
- id: F(e.normalizeText(t.id || "")),
46
- author: e.normalizeText(t.author || ""),
47
- year: ht(t.year || "", e.normalizeText) || void 0,
48
- title: e.normalizeText(t.title || ""),
49
- source: e.normalizeText(t.source || "") || void 0,
50
- url: xt(t.url || "", e.normalizeText) || void 0,
51
- note: e.normalizeText(t.note || "") || void 0
46
+ id: F(n.normalizeText(t.id || "")),
47
+ author: n.normalizeText(t.author || ""),
48
+ year: ht(t.year || "", n.normalizeText) || void 0,
49
+ title: n.normalizeText(t.title || ""),
50
+ source: n.normalizeText(t.source || "") || void 0,
51
+ url: xt(t.url || "", n.normalizeText) || void 0,
52
+ note: n.normalizeText(t.note || "") || void 0
52
53
  };
53
54
  }
54
55
  function Z(t = {}) {
55
- const e = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", n = {
56
+ const n = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", e = {
56
57
  ...Bt,
57
58
  ...t.labels || {}
58
59
  };
59
60
  return {
60
- defaultStyle: e,
61
+ defaultStyle: n,
61
62
  enableFootnoteSync: t.enableFootnoteSync !== !1,
62
63
  debounceMs: Math.max(80, Number(t.debounceMs ?? 220)),
63
64
  maxRecentCitations: Math.max(3, Math.min(30, Number(t.maxRecentCitations ?? 8))),
64
- labels: n,
65
+ labels: e,
65
66
  normalizeText: t.normalizeText || Pt,
66
67
  generateCitationId: typeof t.generateCitationId == "function" ? t.generateCitationId : void 0
67
68
  };
@@ -76,72 +77,80 @@ function X(t) {
76
77
  return t ? (t.getAttribute("data-theme") || t.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : t.classList.contains("dark") || t.classList.contains("editora-theme-dark") || t.classList.contains("rte-theme-dark") : !1;
77
78
  }
78
79
  function Dt(t) {
79
- const e = lt(t);
80
- if (X(e)) return !0;
81
- const n = e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
82
- return X(n) ? !0 : X(document.documentElement) || X(document.body);
83
- }
84
- function tt(t, e) {
85
- t.classList.remove("rte-citations-theme-dark"), Dt(e) && t.classList.add("rte-citations-theme-dark");
86
- }
87
- function h(t, e = !0) {
88
- if (t?.contentElement instanceof HTMLElement) return t.contentElement;
89
- if (t?.editorElement instanceof HTMLElement) {
80
+ const n = lt(t);
81
+ if (X(n))
82
+ return !0;
83
+ const e = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
84
+ return X(e) ? !0 : X(document.documentElement) || X(document.body);
85
+ }
86
+ function tt(t, n) {
87
+ t.classList.remove("rte-citations-theme-dark"), Dt(n) && t.classList.add("rte-citations-theme-dark");
88
+ }
89
+ function h(t, n = !0) {
90
+ if ((t == null ? void 0 : t.contentElement) instanceof HTMLElement)
91
+ return t.contentElement;
92
+ if ((t == null ? void 0 : t.editorElement) instanceof HTMLElement) {
90
93
  const o = t.editorElement;
91
- if (o.matches(S)) return o;
92
- const r = o.querySelector(S);
93
- if (r instanceof HTMLElement) return r;
94
+ if (o.matches($))
95
+ return o;
96
+ const r = o.querySelector($);
97
+ if (r instanceof HTMLElement)
98
+ return r;
94
99
  }
95
- const n = window.getSelection();
96
- if (n && n.rangeCount > 0) {
97
- const o = n.getRangeAt(0).startContainer, a = Ct(o)?.closest(S);
98
- if (a) return a;
100
+ const e = window.getSelection();
101
+ if (e && e.rangeCount > 0) {
102
+ const o = e.getRangeAt(0).startContainer, r = Ct(o), a = r == null ? void 0 : r.closest($);
103
+ if (a)
104
+ return a;
99
105
  }
100
106
  const i = document.activeElement;
101
107
  if (i) {
102
- if (i.matches(S)) return i;
103
- const o = i.closest(S);
104
- if (o) return o;
108
+ if (i.matches($))
109
+ return i;
110
+ const o = i.closest($);
111
+ if (o)
112
+ return o;
105
113
  }
106
- return p && p.isConnected ? p : (p && !p.isConnected && (p = null), e ? document.querySelector(S) : null);
114
+ return p && p.isConnected ? p : (p && !p.isConnected && (p = null), n ? document.querySelector($) : null);
107
115
  }
108
- function $(t) {
116
+ function S(t) {
109
117
  return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";
110
118
  }
111
119
  function j(t) {
112
- const e = Ct(t);
113
- return e ? !!(e.closest(W) || e.closest(G)) : !1;
114
- }
115
- function Ht(t, e) {
116
- if (at += 1, e.generateCitationId) {
117
- const n = e.generateCitationId({ editor: t, index: at }), i = F(e.normalizeText(n || ""));
118
- if (i) return i;
120
+ const n = Ct(t);
121
+ return n ? !!(n.closest(W) || n.closest(G)) : !1;
122
+ }
123
+ function Ht(t, n) {
124
+ if (at += 1, n.generateCitationId) {
125
+ const e = n.generateCitationId({ editor: t, index: at }), i = F(n.normalizeText(e || ""));
126
+ if (i)
127
+ return i;
119
128
  }
120
129
  return `cite-${Date.now().toString(36)}-${at.toString(36)}`;
121
130
  }
122
131
  function st(t) {
123
- return t.map((e) => (e || "").trim()).filter(Boolean).join(" ").trim();
132
+ return t.map((n) => (n || "").trim()).filter(Boolean).join(" ").trim();
124
133
  }
125
- function Ft(t, e) {
126
- const n = t.author || "Unknown", i = t.year || "n.d.";
127
- return e === "mla" ? `(${n} ${i})` : e === "chicago" ? `(${n} ${i})` : `(${n}, ${i})`;
134
+ function Ft(t, n) {
135
+ const e = t.author || "Unknown", i = t.year || "n.d.";
136
+ return n === "mla" ? `(${e} ${i})` : n === "chicago" ? `(${e} ${i})` : `(${e}, ${i})`;
128
137
  }
129
- function ut(t, e) {
130
- const n = t.author || "Unknown", i = t.year || "n.d.", o = t.title || "Untitled", r = t.source || "", a = t.url || "";
131
- return st(e === "mla" ? [
132
- `${n}.`,
138
+ function ut(t, n) {
139
+ const e = t.author || "Unknown", i = t.year || "n.d.", o = t.title || "Untitled", r = t.source || "", a = t.url || "";
140
+ return st(n === "mla" ? [
141
+ `${e}.`,
133
142
  `"${o}."`,
134
143
  r ? `${r},` : "",
135
144
  `${i}.`,
136
145
  a
137
- ] : e === "chicago" ? [
138
- `${n}.`,
146
+ ] : n === "chicago" ? [
147
+ `${e}.`,
139
148
  `${o}.`,
140
149
  r ? `${r}.` : "",
141
150
  `(${i}).`,
142
151
  a
143
152
  ] : [
144
- `${n}.`,
153
+ `${e}.`,
145
154
  `(${i}).`,
146
155
  `${o}.`,
147
156
  r ? `${r}.` : "",
@@ -150,45 +159,47 @@ function ut(t, e) {
150
159
  }
151
160
  function R(t) {
152
161
  return Array.from(t.querySelectorAll(ot)).filter(
153
- (e) => !e.closest(W) && !e.closest(G)
162
+ (n) => !n.closest(W) && !n.closest(G)
154
163
  );
155
164
  }
156
- function wt(t, e) {
157
- const n = F(e.normalizeText(t.getAttribute("data-citation-id") || ""));
158
- if (!n) return null;
159
- const i = e.normalizeText(t.getAttribute("data-citation-author") || ""), o = e.normalizeText(t.getAttribute("data-citation-title") || "");
165
+ function wt(t, n) {
166
+ const e = F(n.normalizeText(t.getAttribute("data-citation-id") || ""));
167
+ if (!e)
168
+ return null;
169
+ const i = n.normalizeText(t.getAttribute("data-citation-author") || ""), o = n.normalizeText(t.getAttribute("data-citation-title") || "");
160
170
  return {
161
- id: n,
171
+ id: e,
162
172
  author: i || "Unknown",
163
- year: ht(t.getAttribute("data-citation-year") || "", e.normalizeText) || void 0,
173
+ year: ht(t.getAttribute("data-citation-year") || "", n.normalizeText) || void 0,
164
174
  title: o || "Untitled",
165
- source: e.normalizeText(t.getAttribute("data-citation-source") || "") || void 0,
166
- url: xt(t.getAttribute("data-citation-url") || "", e.normalizeText) || void 0,
167
- note: e.normalizeText(t.getAttribute("data-citation-note") || "") || void 0
175
+ source: n.normalizeText(t.getAttribute("data-citation-source") || "") || void 0,
176
+ url: xt(t.getAttribute("data-citation-url") || "", n.normalizeText) || void 0,
177
+ note: n.normalizeText(t.getAttribute("data-citation-note") || "") || void 0
168
178
  };
169
179
  }
170
- function vt(t, e, n) {
171
- t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", e.id), t.setAttribute("data-citation-author", e.author || ""), t.setAttribute("data-citation-year", e.year || ""), t.setAttribute("data-citation-title", e.title || ""), t.setAttribute("data-citation-source", e.source || ""), t.setAttribute("data-citation-url", e.url || ""), t.setAttribute("data-citation-note", e.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", n), t.textContent = Ft(e, n);
180
+ function vt(t, n, e) {
181
+ t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", n.id), t.setAttribute("data-citation-author", n.author || ""), t.setAttribute("data-citation-year", n.year || ""), t.setAttribute("data-citation-title", n.title || ""), t.setAttribute("data-citation-source", n.source || ""), t.setAttribute("data-citation-url", n.url || ""), t.setAttribute("data-citation-note", n.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", e), t.textContent = Ft(n, e);
172
182
  }
173
- function it(t, e, n) {
183
+ function it(t, n, e) {
174
184
  const i = lt(t);
175
185
  Array.from(
176
186
  i.querySelectorAll(
177
- `.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`
187
+ `.rte-toolbar-button[data-command="${n}"], .editora-toolbar-button[data-command="${n}"]`
178
188
  )
179
189
  ).forEach((r) => {
180
- r.classList.toggle("active", n), r.setAttribute("data-active", n ? "true" : "false"), r.setAttribute("aria-pressed", n ? "true" : "false");
190
+ r.classList.toggle("active", e), r.setAttribute("data-active", e ? "true" : "false"), r.setAttribute("aria-pressed", e ? "true" : "false");
181
191
  });
182
192
  }
183
- function N(t, e) {
184
- const n = T.get(t);
185
- return n && L.includes(n) ? n : e?.defaultStyle || "apa";
193
+ function N(t, n) {
194
+ const e = T.get(t);
195
+ return e && L.includes(e) ? e : (n == null ? void 0 : n.defaultStyle) || "apa";
186
196
  }
187
- function K(t, e) {
188
- const n = R(t), i = /* @__PURE__ */ new Map();
189
- return n.forEach((o) => {
190
- const r = wt(o, e);
191
- if (!r) return;
197
+ function K(t, n) {
198
+ const e = R(t), i = /* @__PURE__ */ new Map();
199
+ return e.forEach((o) => {
200
+ const r = wt(o, n);
201
+ if (!r)
202
+ return;
192
203
  if (!i.has(r.id)) {
193
204
  i.set(r.id, r);
194
205
  return;
@@ -205,137 +216,145 @@ function K(t, e) {
205
216
  });
206
217
  }), Array.from(i.values());
207
218
  }
208
- function _t(t, e, n) {
209
- const i = yt(e, n);
210
- if (!i.id || !i.author || !i.title) return;
219
+ function _t(t, n, e) {
220
+ const i = yt(n, e);
221
+ if (!i.id || !i.author || !i.title)
222
+ return;
211
223
  const r = (D.get(t) || []).filter((a) => a.id !== i.id);
212
- D.set(t, [i, ...r].slice(0, n.maxRecentCitations));
224
+ D.set(t, [i, ...r].slice(0, e.maxRecentCitations));
213
225
  }
214
- function rt(t, e, n) {
226
+ function rt(t, n, e) {
215
227
  const i = D.get(t) || [], o = /* @__PURE__ */ new Map();
216
- e.slice(Math.max(0, e.length - n.maxRecentCitations)).reverse().forEach((a) => {
228
+ n.slice(Math.max(0, n.length - e.maxRecentCitations)).reverse().forEach((a) => {
217
229
  a.id && o.set(a.id, a);
218
230
  }), i.forEach((a) => {
219
231
  !a.id || o.has(a.id) || o.set(a.id, a);
220
232
  });
221
- const r = Array.from(o.values()).slice(0, n.maxRecentCitations);
233
+ const r = Array.from(o.values()).slice(0, e.maxRecentCitations);
222
234
  return D.set(t, r), r;
223
235
  }
224
- function Et(t, e, n, i) {
225
- const o = F(i.normalizeText(e || ""));
226
- return o && rt(t, n, i).find((a) => a.id === o) || null;
236
+ function Et(t, n, e, i) {
237
+ const o = F(i.normalizeText(n || ""));
238
+ return o && rt(t, e, i).find((a) => a.id === o) || null;
227
239
  }
228
- function qt(t, e, n) {
229
- const i = F(n.normalizeText(e || ""));
230
- if (!i) return !1;
240
+ function qt(t, n, e) {
241
+ const i = F(e.normalizeText(n || ""));
242
+ if (!i)
243
+ return !1;
231
244
  const o = D.get(t) || [], r = o.filter((a) => a.id !== i);
232
245
  return r.length === o.length ? !1 : (D.set(t, r), !0);
233
246
  }
234
- function St(t, e, n) {
247
+ function $t(t, n, e) {
235
248
  const i = document.createElement("section");
236
- i.className = t, i.setAttribute("data-type", e), i.setAttribute("contenteditable", "false"), i.setAttribute("aria-label", n), e === "citation-bibliography" ? i.setAttribute("role", "doc-bibliography") : e === "citation-footnotes" && i.setAttribute("role", "doc-endnotes");
249
+ i.className = t, i.setAttribute("data-type", n), i.setAttribute("contenteditable", "false"), i.setAttribute("aria-label", e), n === "citation-bibliography" ? i.setAttribute("role", "doc-bibliography") : n === "citation-footnotes" && i.setAttribute("role", "doc-endnotes");
237
250
  const o = document.createElement("h3");
238
- o.className = "rte-citation-section-title", o.textContent = n;
251
+ o.className = "rte-citation-section-title", o.textContent = e;
239
252
  const r = document.createElement("ol");
240
253
  return r.className = "rte-citation-list", r.setAttribute("role", "list"), i.appendChild(o), i.appendChild(r), i;
241
254
  }
242
- function jt(t, e) {
243
- let n = t.querySelector(W);
244
- n || (n = St("rte-citation-bibliography", "citation-bibliography", e.labels.bibliographyTitle), t.appendChild(n));
245
- const i = n.querySelector(".rte-citation-section-title");
246
- return i && (i.textContent = e.labels.bibliographyTitle), n.setAttribute("aria-label", e.labels.bibliographyTitle), n;
247
- }
248
- function Kt(t, e) {
249
- let n = t.querySelector(G);
250
- n || (n = St("rte-citation-footnotes", "citation-footnotes", e.labels.footnotesTitle), t.appendChild(n));
251
- const i = n.querySelector(".rte-citation-section-title");
252
- return i && (i.textContent = e.labels.footnotesTitle), n.setAttribute("aria-label", e.labels.footnotesTitle), n;
253
- }
254
- function $t(t, e) {
255
- t.querySelector(e)?.remove();
256
- }
257
- function Ut(t, e, n, i) {
258
- if (e.length === 0) {
259
- $t(t, W);
255
+ function jt(t, n) {
256
+ let e = t.querySelector(W);
257
+ e || (e = $t("rte-citation-bibliography", "citation-bibliography", n.labels.bibliographyTitle), t.appendChild(e));
258
+ const i = e.querySelector(".rte-citation-section-title");
259
+ return i && (i.textContent = n.labels.bibliographyTitle), e.setAttribute("aria-label", n.labels.bibliographyTitle), e;
260
+ }
261
+ function Kt(t, n) {
262
+ let e = t.querySelector(G);
263
+ e || (e = $t("rte-citation-footnotes", "citation-footnotes", n.labels.footnotesTitle), t.appendChild(e));
264
+ const i = e.querySelector(".rte-citation-section-title");
265
+ return i && (i.textContent = n.labels.footnotesTitle), e.setAttribute("aria-label", n.labels.footnotesTitle), e;
266
+ }
267
+ function St(t, n) {
268
+ const e = t.querySelector(n);
269
+ e == null || e.remove();
270
+ }
271
+ function Ut(t, n, e, i) {
272
+ if (n.length === 0) {
273
+ St(t, W);
260
274
  return;
261
275
  }
262
- const r = jt(t, n).querySelector(".rte-citation-list");
263
- if (!r) return;
276
+ const r = jt(t, e).querySelector(".rte-citation-list");
277
+ if (!r)
278
+ return;
264
279
  const a = document.createDocumentFragment();
265
- e.forEach((s, u) => {
280
+ n.forEach((s, d) => {
266
281
  const c = document.createElement("li");
267
- c.className = "rte-citation-item", c.id = `rte-citation-entry-${s.id}`, c.setAttribute("data-citation-id", s.id), c.setAttribute("data-citation-number", String(u + 1)), c.textContent = ut(s, i), a.appendChild(c);
282
+ c.className = "rte-citation-item", c.id = `rte-citation-entry-${s.id}`, c.setAttribute("data-citation-id", s.id), c.setAttribute("data-citation-number", String(d + 1)), c.textContent = ut(s, i), a.appendChild(c);
268
283
  }), r.innerHTML = "", r.appendChild(a);
269
284
  }
270
- function Wt(t, e, n, i) {
271
- if (!n.enableFootnoteSync || e.length === 0) {
272
- $t(t, G), R(t).forEach((l) => {
285
+ function Wt(t, n, e, i) {
286
+ if (!e.enableFootnoteSync || n.length === 0) {
287
+ St(t, G), R(t).forEach((l) => {
273
288
  l.removeAttribute("data-footnote-number"), l.removeAttribute("data-footnote-target");
274
289
  });
275
290
  return;
276
291
  }
277
- const r = Kt(t, n).querySelector(".rte-citation-list");
278
- if (!r) return;
292
+ const r = Kt(t, e).querySelector(".rte-citation-list");
293
+ if (!r)
294
+ return;
279
295
  const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
280
- e.forEach((l, d) => {
281
- s.set(l.id, d + 1);
296
+ n.forEach((l, u) => {
297
+ s.set(l.id, u + 1);
282
298
  });
283
- const u = /* @__PURE__ */ new Map();
299
+ const d = /* @__PURE__ */ new Map();
284
300
  R(t).forEach((l) => {
285
- const d = l.getAttribute("data-citation-id") || "";
286
- if (!d || !s.has(d)) return;
287
- const m = (u.get(d) || 0) + 1;
288
- u.set(d, m);
289
- const w = `rte-citation-ref-${d}-${m}`;
301
+ const u = l.getAttribute("data-citation-id") || "";
302
+ if (!u || !s.has(u))
303
+ return;
304
+ const b = (d.get(u) || 0) + 1;
305
+ d.set(u, b);
306
+ const w = `rte-citation-ref-${u}-${b}`;
290
307
  l.id = w;
291
- const A = s.get(d);
292
- l.setAttribute("data-footnote-number", String(A)), l.setAttribute("data-footnote-target", `rte-citation-note-${d}`), a.has(d) || a.set(d, w);
308
+ const A = s.get(u);
309
+ l.setAttribute("data-footnote-number", String(A)), l.setAttribute("data-footnote-target", `rte-citation-note-${u}`), a.has(u) || a.set(u, w);
293
310
  });
294
311
  const c = document.createDocumentFragment();
295
- e.forEach((l, d) => {
296
- const m = document.createElement("li");
297
- m.className = "rte-citation-item rte-citation-footnote-item", m.id = `rte-citation-note-${l.id}`, m.setAttribute("data-citation-id", l.id);
312
+ n.forEach((l, u) => {
313
+ const b = document.createElement("li");
314
+ b.className = "rte-citation-item rte-citation-footnote-item", b.id = `rte-citation-note-${l.id}`, b.setAttribute("data-citation-id", l.id);
298
315
  const w = document.createElement("span");
299
- w.className = "rte-citation-footnote-number", w.textContent = `${d + 1}. `;
316
+ w.className = "rte-citation-footnote-number", w.textContent = `${u + 1}. `;
300
317
  const A = document.createElement("span");
301
318
  A.className = "rte-citation-footnote-text";
302
319
  const It = l.note ? `${l.note}. ` : "";
303
- A.textContent = `${It}${ut(l, i)}`, m.appendChild(w), m.appendChild(A);
304
- const gt = a.get(l.id);
305
- if (gt) {
320
+ A.textContent = `${It}${ut(l, i)}`, b.appendChild(w), b.appendChild(A);
321
+ const mt = a.get(l.id);
322
+ if (mt) {
306
323
  const _ = document.createElement("a");
307
- _.className = "rte-citation-backref", _.href = `#${gt}`, _.setAttribute("aria-label", `Back to citation ${d + 1}`), _.textContent = "Back", m.appendChild(_);
324
+ _.className = "rte-citation-backref", _.href = `#${mt}`, _.setAttribute("aria-label", `Back to citation ${u + 1}`), _.textContent = "Back", b.appendChild(_);
308
325
  }
309
- c.appendChild(m);
326
+ c.appendChild(b);
310
327
  }), r.innerHTML = "", r.appendChild(c);
311
328
  }
312
- function Gt(t, e, n, i) {
313
- const o = ut(e, n);
329
+ function Gt(t, n, e, i) {
330
+ const o = ut(n, e);
314
331
  t.setAttribute("data-citation-number", String(i)), t.setAttribute("aria-label", `Citation ${i}: ${o}`);
315
332
  }
316
- function Vt(t, e, n) {
333
+ function Vt(t, n, e) {
317
334
  const i = R(t);
318
- let o = `${e}:${n ? "1" : "0"}:${i.length}`;
335
+ let o = `${n}:${e ? "1" : "0"}:${i.length}`;
319
336
  return i.forEach((r) => {
320
337
  o += `|${r.getAttribute("data-citation-id") || ""}`, o += `|${r.getAttribute("data-citation-author") || ""}`, o += `|${r.getAttribute("data-citation-year") || ""}`, o += `|${r.getAttribute("data-citation-title") || ""}`, o += `|${r.getAttribute("data-citation-source") || ""}`, o += `|${r.getAttribute("data-citation-url") || ""}`, o += `|${r.getAttribute("data-citation-note") || ""}`;
321
338
  }), o;
322
339
  }
323
340
  function H(t) {
324
- const e = v.get(t);
325
- if (!e) return;
326
- const n = f.get(t) || M;
327
- if (!n) return;
328
- const i = N(t, n), o = K(t, n), r = rt(t, o, n), a = e.querySelector(".rte-citations-status"), s = e.querySelector('[data-action="cycle-style"]'), u = e.querySelector(".rte-citations-recent-list");
341
+ const n = v.get(t);
342
+ if (!n)
343
+ return;
344
+ const e = f.get(t) || M;
345
+ if (!e)
346
+ return;
347
+ const i = N(t, e), o = K(t, e), r = rt(t, o, e), a = n.querySelector(".rte-citations-status"), s = n.querySelector('[data-action="cycle-style"]'), d = n.querySelector(".rte-citations-recent-list");
329
348
  if (a) {
330
349
  const c = o.length;
331
- a.textContent = `${n.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${n.enableFootnoteSync ? "On" : "Off"}`;
350
+ a.textContent = `${e.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${e.enableFootnoteSync ? "On" : "Off"}`;
332
351
  }
333
- if (s && (s.textContent = `${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`, s.setAttribute("aria-label", `${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`)), u) {
352
+ if (s && (s.textContent = `${e.labels.styleButtonPrefix}: ${i.toUpperCase()}`, s.setAttribute("aria-label", `${e.labels.styleButtonPrefix}: ${i.toUpperCase()}`)), d) {
334
353
  if (r.length === 0) {
335
- u.innerHTML = `<li class="rte-citations-empty">${g(n.labels.noCitationsText)}</li>`;
354
+ d.innerHTML = `<li class="rte-citations-empty">${g(e.labels.noCitationsText)}</li>`;
336
355
  return;
337
356
  }
338
- u.innerHTML = r.map(
357
+ d.innerHTML = r.map(
339
358
  (c) => `
340
359
  <li class="rte-citations-recent-item">
341
360
  <div class="rte-citations-recent-row">
@@ -355,191 +374,211 @@ function H(t) {
355
374
  data-action="delete-by-id"
356
375
  data-citation-id="${g(c.id)}"
357
376
  aria-label="Delete citation: ${g(c.title)}"
358
- >${g(n.labels.deleteRecentText)}</button>
377
+ >${g(e.labels.deleteRecentText)}</button>
359
378
  </div>
360
379
  </li>
361
380
  `
362
381
  ).join("");
363
382
  }
364
383
  }
365
- function y(t, e, n = !1) {
366
- const i = N(t, e), o = Vt(t, i, e.enableFootnoteSync);
367
- if (!n && pt.get(t) === o)
368
- return K(t, e);
384
+ function y(t, n, e = !1) {
385
+ const i = N(t, n), o = Vt(t, i, n.enableFootnoteSync);
386
+ if (!e && pt.get(t) === o)
387
+ return K(t, n);
369
388
  const r = R(t), a = /* @__PURE__ */ new Map();
370
389
  r.forEach((c) => {
371
- const l = wt(c, e);
390
+ const l = wt(c, n);
372
391
  l && (a.has(l.id) || a.set(l.id, l));
373
392
  });
374
393
  const s = Array.from(a.values());
375
- rt(t, s, e);
376
- const u = /* @__PURE__ */ new Map();
394
+ rt(t, s, n);
395
+ const d = /* @__PURE__ */ new Map();
377
396
  return s.forEach((c, l) => {
378
- u.set(c.id, l + 1);
397
+ d.set(c.id, l + 1);
379
398
  }), r.forEach((c) => {
380
- const l = c.getAttribute("data-citation-id") || "", d = a.get(l);
381
- if (!d) return;
382
- vt(c, d, i);
383
- const m = u.get(d.id) || 1;
384
- Gt(c, d, i, Math.max(1, m));
385
- }), Ut(t, s, e, i), Wt(t, s, e, i), pt.set(t, o), H(t), t.dispatchEvent(
399
+ const l = c.getAttribute("data-citation-id") || "", u = a.get(l);
400
+ if (!u)
401
+ return;
402
+ vt(c, u, i);
403
+ const b = d.get(u.id) || 1;
404
+ Gt(c, u, i, Math.max(1, b));
405
+ }), Ut(t, s, n, i), Wt(t, s, n, i), pt.set(t, o), H(t), t.dispatchEvent(
386
406
  new CustomEvent("editora:citations-refreshed", {
387
407
  bubbles: !0,
388
408
  detail: {
389
409
  citations: s,
390
410
  style: i,
391
- footnoteSync: e.enableFootnoteSync
411
+ footnoteSync: n.enableFootnoteSync
392
412
  }
393
413
  })
394
414
  ), s;
395
415
  }
396
416
  function At(t) {
397
- const e = Q.get(t);
398
- typeof e == "number" && (window.clearTimeout(e), q.delete(e), Q.delete(t));
417
+ const n = Q.get(t);
418
+ typeof n == "number" && (window.clearTimeout(n), q.delete(n), Q.delete(t));
399
419
  }
400
420
  function kt(t) {
401
- const e = f.get(t) || M;
402
- if (!e) return;
421
+ const n = f.get(t) || M;
422
+ if (!n)
423
+ return;
403
424
  At(t);
404
- const n = window.setTimeout(() => {
405
- q.delete(n), Q.delete(t), y(t, e, !1);
406
- }, e.debounceMs);
407
- q.add(n), Q.set(t, n);
425
+ const e = window.setTimeout(() => {
426
+ q.delete(e), Q.delete(t), y(t, n, !1);
427
+ }, n.debounceMs);
428
+ q.add(e), Q.set(t, e);
408
429
  }
409
430
  function Yt(t) {
410
- const e = window.getSelection();
411
- if (!e) throw new Error("Selection unavailable");
412
- if (e.rangeCount > 0) {
413
- const a = e.getRangeAt(0);
431
+ const n = window.getSelection();
432
+ if (!n)
433
+ throw new Error("Selection unavailable");
434
+ if (n.rangeCount > 0) {
435
+ const a = n.getRangeAt(0);
414
436
  if (t.contains(a.commonAncestorContainer) && !j(a.commonAncestorContainer))
415
437
  return a.cloneRange();
416
438
  }
417
- const n = document.createRange(), i = t.querySelector(W), o = t.querySelector(G), r = i || o;
418
- return r ? (n.setStartBefore(r), n.collapse(!0), n) : (n.selectNodeContents(t), n.collapse(!1), n);
439
+ const e = document.createRange(), i = t.querySelector(W), o = t.querySelector(G), r = i || o;
440
+ return r ? (e.setStartBefore(r), e.collapse(!0), e) : (e.selectNodeContents(t), e.collapse(!1), e);
419
441
  }
420
442
  function dt(t) {
421
443
  t.dispatchEvent(new Event("input", { bubbles: !0 }));
422
444
  }
423
- function ft(t, e) {
424
- if (e === t.innerHTML) return;
425
- const n = window.execEditorCommand || window.executeEditorCommand;
426
- if (typeof n == "function")
445
+ function ft(t, n) {
446
+ if (n === t.innerHTML)
447
+ return;
448
+ const e = window.execEditorCommand || window.executeEditorCommand;
449
+ if (typeof e == "function")
427
450
  try {
428
- n("recordDomTransaction", t, e, t.innerHTML);
451
+ e("recordDomTransaction", t, n, t.innerHTML);
429
452
  } catch {
430
453
  }
431
454
  }
432
- function Tt(t, e) {
433
- const n = window.getSelection();
434
- if (!n) return;
455
+ function Tt(t, n) {
456
+ const e = window.getSelection();
457
+ if (!e)
458
+ return;
435
459
  const i = document.createRange();
436
460
  if (t.nodeType === Node.TEXT_NODE) {
437
- const o = t, r = Math.max(0, Math.min(e, o.length));
461
+ const o = t, r = Math.max(0, Math.min(n, o.length));
438
462
  i.setStart(o, r);
439
463
  } else {
440
- const o = t.childNodes.length, r = Math.max(0, Math.min(e, o));
464
+ const o = t.childNodes.length, r = Math.max(0, Math.min(n, o));
441
465
  i.setStart(t, r);
442
466
  }
443
- i.collapse(!0), n.removeAllRanges(), n.addRange(i);
467
+ i.collapse(!0), e.removeAllRanges(), e.addRange(i);
444
468
  }
445
469
  function Mt(t) {
446
470
  if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
447
471
  return null;
448
- const e = t.startContainer.childNodes[t.startOffset];
449
- return !(e instanceof HTMLElement) || !e.matches(ot) ? null : e;
472
+ const n = t.startContainer.childNodes[t.startOffset];
473
+ return !(n instanceof HTMLElement) || !n.matches(ot) ? null : n;
450
474
  }
451
- function J(t, e, n) {
475
+ function J(t, n, e) {
452
476
  const { startContainer: i, startOffset: o } = t;
453
477
  if (i.nodeType === Node.ELEMENT_NODE) {
454
478
  const a = i;
455
- if (n === "previous") {
456
- if (o > 0) return a.childNodes[o - 1] || null;
479
+ if (e === "previous") {
480
+ if (o > 0)
481
+ return a.childNodes[o - 1] || null;
457
482
  } else if (o < a.childNodes.length)
458
483
  return a.childNodes[o] || null;
459
484
  }
460
- if (i.nodeType === Node.TEXT_NODE && (n === "previous" && o < i.data.length || n === "next" && o > 0))
485
+ if (i.nodeType === Node.TEXT_NODE && (e === "previous" && o < i.data.length || e === "next" && o > 0))
461
486
  return null;
462
487
  let r = i;
463
- for (; r && r !== e; ) {
464
- const a = n === "previous" ? r.previousSibling : r.nextSibling;
465
- if (a) return a;
488
+ for (; r && r !== n; ) {
489
+ const a = e === "previous" ? r.previousSibling : r.nextSibling;
490
+ if (a)
491
+ return a;
466
492
  r = r.parentNode;
467
493
  }
468
494
  return null;
469
495
  }
470
- function Lt(t, e, n) {
471
- if (!t.collapsed) return null;
496
+ function Lt(t, n, e) {
497
+ if (!t.collapsed)
498
+ return null;
472
499
  const i = (a) => a instanceof HTMLElement && a.matches(ot) ? a : null, { startContainer: o, startOffset: r } = t;
473
500
  if (o.nodeType === Node.ELEMENT_NODE) {
474
501
  const a = o;
475
- return n === "Backspace" && r > 0 ? i(a.childNodes[r - 1] || null) : n === "Delete" ? i(a.childNodes[r] || null) : null;
502
+ return e === "Backspace" && r > 0 ? i(a.childNodes[r - 1] || null) : e === "Delete" ? i(a.childNodes[r] || null) : null;
476
503
  }
477
504
  if (o.nodeType === Node.TEXT_NODE) {
478
505
  const a = o;
479
- if (n === "Backspace" && r === 0) {
506
+ if (e === "Backspace" && r === 0) {
480
507
  const s = i(a.previousSibling);
481
- return s || i(J(t, e, "previous"));
508
+ return s || i(J(t, n, "previous"));
482
509
  }
483
- if (n === "Delete" && r === a.data.length) {
510
+ if (e === "Delete" && r === a.data.length) {
484
511
  const s = i(a.nextSibling);
485
- return s || i(J(t, e, "next"));
512
+ return s || i(J(t, n, "next"));
486
513
  }
487
514
  }
488
- return i(n === "Backspace" ? J(t, e, "previous") : J(t, e, "next"));
515
+ return i(e === "Backspace" ? J(t, n, "previous") : J(t, n, "next"));
489
516
  }
490
- function P(t, e, n) {
491
- const i = t.closest(S);
492
- if (!i || j(t)) return !1;
517
+ function P(t, n, e) {
518
+ const i = t.closest($);
519
+ if (!i || j(t))
520
+ return !1;
493
521
  const o = t.parentNode;
494
- if (!o) return !1;
522
+ if (!o)
523
+ return !1;
495
524
  const r = i.innerHTML, a = Array.from(o.childNodes).indexOf(t);
496
- if (a < 0) return !1;
525
+ if (a < 0)
526
+ return !1;
497
527
  const s = t.nextSibling;
498
- return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(o, a), y(i, n, !0), ft(i, r), dt(i), e === "Delete" && i.focus({ preventScroll: !0 }), !0;
528
+ return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(o, a), y(i, e, !0), ft(i, r), dt(i), n === "Delete" && i.focus({ preventScroll: !0 }), !0;
499
529
  }
500
- function Xt(t, e, n) {
501
- if (t.key !== "Backspace" && t.key !== "Delete") return !1;
530
+ function Xt(t, n, e) {
531
+ if (t.key !== "Backspace" && t.key !== "Delete")
532
+ return !1;
502
533
  const i = t.key, o = t.target;
503
- if (o?.matches(ot) && e.contains(o) && !j(o))
504
- return t.preventDefault(), t.stopPropagation(), P(o, i, n);
534
+ if (o != null && o.matches(ot) && n.contains(o) && !j(o))
535
+ return t.preventDefault(), t.stopPropagation(), P(o, i, e);
505
536
  const r = window.getSelection();
506
- if (!r || r.rangeCount === 0) return !1;
537
+ if (!r || r.rangeCount === 0)
538
+ return !1;
507
539
  const a = r.getRangeAt(0);
508
- if (!e.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer)) return !1;
540
+ if (!n.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer))
541
+ return !1;
509
542
  const s = Mt(a);
510
543
  if (s)
511
- return t.preventDefault(), t.stopPropagation(), P(s, i, n);
512
- const u = Lt(a, e, i);
513
- return u ? (t.preventDefault(), t.stopPropagation(), P(u, i, n)) : !1;
544
+ return t.preventDefault(), t.stopPropagation(), P(s, i, e);
545
+ const d = Lt(a, n, i);
546
+ return d ? (t.preventDefault(), t.stopPropagation(), P(d, i, e)) : !1;
514
547
  }
515
- function Rt(t, e, n) {
516
- const i = F(n.normalizeText(e || ""));
517
- if (!i) return !1;
548
+ function Rt(t, n, e) {
549
+ const i = F(e.normalizeText(n || ""));
550
+ if (!i)
551
+ return !1;
518
552
  const o = R(t).filter((a) => a.getAttribute("data-citation-id") === i);
519
- if (o.length === 0) return !1;
553
+ if (o.length === 0)
554
+ return !1;
520
555
  if (o.length === 1)
521
- return P(o[0], "Delete", n);
556
+ return P(o[0], "Delete", e);
522
557
  const r = t.innerHTML;
523
558
  return o.forEach((a) => {
524
559
  const s = a.nextSibling;
525
560
  s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), a.remove();
526
- }), Tt(t, t.childNodes.length), y(t, n, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
561
+ }), Tt(t, t.childNodes.length), y(t, e, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
527
562
  }
528
- function Jt(t, e) {
529
- const n = window.getSelection();
530
- if (!n || n.rangeCount === 0) return !1;
531
- const i = n.getRangeAt(0);
532
- if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer)) return !1;
563
+ function Jt(t, n) {
564
+ const e = window.getSelection();
565
+ if (!e || e.rangeCount === 0)
566
+ return !1;
567
+ const i = e.getRangeAt(0);
568
+ if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer))
569
+ return !1;
533
570
  const o = Mt(i);
534
571
  if (o)
535
- return P(o, "Delete", e);
572
+ return P(o, "Delete", n);
536
573
  const r = Lt(i, t, "Backspace");
537
- return r ? P(r, "Backspace", e) : !1;
574
+ return r ? P(r, "Backspace", n) : !1;
538
575
  }
539
- function et(t, e, n) {
540
- const i = yt(e, n);
541
- if (!i.author || !i.title) return !1;
542
- i.id || (i.id = Ht(t, n));
576
+ function et(t, n, e) {
577
+ var l, u;
578
+ const i = yt(n, e);
579
+ if (!i.author || !i.title)
580
+ return !1;
581
+ i.id || (i.id = Ht(t, e));
543
582
  const o = t.innerHTML;
544
583
  let r;
545
584
  try {
@@ -548,97 +587,104 @@ function et(t, e, n) {
548
587
  return !1;
549
588
  }
550
589
  const a = window.getSelection();
551
- if (!a) return !1;
590
+ if (!a)
591
+ return !1;
552
592
  r.collapsed || r.deleteContents();
553
593
  const s = document.createElement("span");
554
- vt(s, i, N(t, n));
594
+ vt(s, i, N(t, e));
555
595
  try {
556
596
  r.insertNode(s);
557
597
  } catch {
558
598
  return !1;
559
599
  }
560
- const u = document.createTextNode(" ");
561
- s.nextSibling ? s.parentNode?.insertBefore(u, s.nextSibling) : s.parentNode?.appendChild(u);
600
+ const d = document.createTextNode(" ");
601
+ s.nextSibling ? (l = s.parentNode) == null || l.insertBefore(d, s.nextSibling) : (u = s.parentNode) == null || u.appendChild(d);
562
602
  const c = document.createRange();
563
- if (u.parentNode) {
564
- const l = Array.from(u.parentNode.childNodes).indexOf(u) + 1;
565
- c.setStart(u.parentNode, Math.max(0, l));
603
+ if (d.parentNode) {
604
+ const b = Array.from(d.parentNode.childNodes).indexOf(d) + 1;
605
+ c.setStart(d.parentNode, Math.max(0, b));
566
606
  } else
567
607
  c.setStartAfter(s);
568
- return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, n), y(t, n, !0), ft(t, o), dt(t), !0;
608
+ return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, e), y(t, e, !0), ft(t, o), dt(t), !0;
569
609
  }
570
- function Zt(t, e) {
571
- if (!e) return !1;
572
- const n = R(t).find((r) => r.getAttribute("data-citation-id") === e) || null;
573
- if (!n) return !1;
574
- n.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), n.focus({ preventScroll: !0 });
610
+ function Zt(t, n) {
611
+ if (!n)
612
+ return !1;
613
+ const e = R(t).find((r) => r.getAttribute("data-citation-id") === n) || null;
614
+ if (!e)
615
+ return !1;
616
+ e.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 });
575
617
  const i = window.getSelection();
576
- if (!i) return !0;
618
+ if (!i)
619
+ return !0;
577
620
  const o = document.createRange();
578
- return o.selectNode(n), i.removeAllRanges(), i.addRange(o), !0;
621
+ return o.selectNode(e), i.removeAllRanges(), i.addRange(o), !0;
579
622
  }
580
623
  function nt(t) {
581
624
  return V.get(t) === !0;
582
625
  }
583
- function U(t, e = !1) {
584
- const n = v.get(t);
585
- n && (n.classList.remove("show"), V.set(t, !1), it(t, "toggleCitationsPanel", !1), e && t.focus({ preventScroll: !0 }));
626
+ function U(t, n = !1) {
627
+ const e = v.get(t);
628
+ e && (e.classList.remove("show"), V.set(t, !1), it(t, "toggleCitationsPanel", !1), n && t.focus({ preventScroll: !0 }));
586
629
  }
587
630
  function Qt(t) {
588
- v.forEach((e, n) => {
589
- n !== t && U(n, !1);
631
+ v.forEach((n, e) => {
632
+ e !== t && U(e, !1);
590
633
  });
591
634
  }
592
- function ct(t, e) {
593
- if (!e.classList.contains("show")) return;
635
+ function ct(t, n) {
636
+ if (!n.classList.contains("show"))
637
+ return;
594
638
  const i = lt(t).getBoundingClientRect(), o = Math.min(window.innerWidth - 20, 380), r = Math.max(10, window.innerWidth - o - 10), a = Math.min(Math.max(10, i.right - o), r), s = Math.max(10, Math.min(window.innerHeight - 10 - 260, i.top + 10));
595
- e.style.width = `${o}px`, e.style.left = `${a}px`, e.style.top = `${s}px`, e.style.maxHeight = `${Math.max(260, window.innerHeight - 24)}px`;
639
+ n.style.width = `${o}px`, n.style.left = `${a}px`, n.style.top = `${s}px`, n.style.maxHeight = `${Math.max(260, window.innerHeight - 24)}px`;
596
640
  }
597
- function C(t, e) {
598
- return t.querySelector(`[data-field="${e}"]`);
641
+ function C(t, n) {
642
+ return t.querySelector(`[data-field="${n}"]`);
599
643
  }
600
644
  function te(t) {
601
- const e = C(t, "author")?.value || "", n = C(t, "year")?.value || "", i = C(t, "title")?.value || "", o = C(t, "source")?.value || "", r = C(t, "url")?.value || "", a = C(t, "note")?.value || "";
645
+ var s, d, c, l, u, b;
646
+ const n = ((s = C(t, "author")) == null ? void 0 : s.value) || "", e = ((d = C(t, "year")) == null ? void 0 : d.value) || "", i = ((c = C(t, "title")) == null ? void 0 : c.value) || "", o = ((l = C(t, "source")) == null ? void 0 : l.value) || "", r = ((u = C(t, "url")) == null ? void 0 : u.value) || "", a = ((b = C(t, "note")) == null ? void 0 : b.value) || "";
602
647
  return {
603
- author: e,
604
- year: n,
648
+ author: n,
649
+ year: e,
605
650
  title: i,
606
651
  source: o,
607
652
  url: r,
608
653
  note: a
609
654
  };
610
655
  }
611
- function E(t, e) {
612
- const n = t.querySelector(".rte-citations-live");
613
- n && (n.textContent = e);
656
+ function E(t, n) {
657
+ const e = t.querySelector(".rte-citations-live");
658
+ e && (e.textContent = n);
614
659
  }
615
- function ee(t, e, n) {
616
- const i = C(e, "style");
617
- i && (i.value = N(t, n));
660
+ function ee(t, n, e) {
661
+ const i = C(n, "style");
662
+ i && (i.value = N(t, e));
618
663
  }
619
- function Nt(t, e, n) {
620
- const i = L.includes(e) ? e : n.defaultStyle;
621
- return T.set(t, i), y(t, n, !0), i;
664
+ function Nt(t, n, e) {
665
+ const i = L.includes(n) ? n : e.defaultStyle;
666
+ return T.set(t, i), y(t, e, !0), i;
622
667
  }
623
- function bt(t, e) {
624
- const n = N(t, e), i = L.indexOf(n), o = L[(i + 1) % L.length];
625
- return T.set(t, o), y(t, e, !0), o;
668
+ function bt(t, n) {
669
+ const e = N(t, n), i = L.indexOf(e), o = L[(i + 1) % L.length];
670
+ return T.set(t, o), y(t, n, !0), o;
626
671
  }
627
672
  function ne(t) {
628
- const e = v.get(t);
629
- if (e) return e;
630
- const n = f.get(t) || M || Z(), i = `rte-citations-panel-${Ot++}`, o = document.createElement("section");
631
- o.className = b, o.id = i, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", n.labels.panelAriaLabel), o.setAttribute("tabindex", "-1"), o.innerHTML = `
673
+ const n = v.get(t);
674
+ if (n)
675
+ return n;
676
+ const e = f.get(t) || M || Z(), i = `rte-citations-panel-${Ot++}`, o = document.createElement("section");
677
+ o.className = m, o.id = i, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", e.labels.panelAriaLabel), o.setAttribute("tabindex", "-1"), o.innerHTML = `
632
678
  <header class="rte-citations-header">
633
- <h2 class="rte-citations-title">${g(n.labels.panelTitle)}</h2>
634
- <button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(n.labels.closeText)}">✕</button>
679
+ <h2 class="rte-citations-title">${g(e.labels.panelTitle)}</h2>
680
+ <button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(e.labels.closeText)}">✕</button>
635
681
  </header>
636
682
  <div class="rte-citations-body">
637
683
  <p class="rte-citations-status" aria-live="polite"></p>
638
684
 
639
685
  <div class="rte-citations-grid">
640
686
  <label class="rte-citations-label">
641
- ${g(n.labels.styleLabel)}
687
+ ${g(e.labels.styleLabel)}
642
688
  <select data-field="style" class="rte-citations-field">
643
689
  <option value="apa">APA</option>
644
690
  <option value="mla">MLA</option>
@@ -646,39 +692,39 @@ function ne(t) {
646
692
  </select>
647
693
  </label>
648
694
  <label class="rte-citations-label">
649
- ${g(n.labels.authorLabel)}
695
+ ${g(e.labels.authorLabel)}
650
696
  <input type="text" data-field="author" class="rte-citations-field" autocomplete="off" />
651
697
  </label>
652
698
  <label class="rte-citations-label">
653
- ${g(n.labels.yearLabel)}
699
+ ${g(e.labels.yearLabel)}
654
700
  <input type="text" data-field="year" class="rte-citations-field" inputmode="numeric" autocomplete="off" />
655
701
  </label>
656
702
  <label class="rte-citations-label">
657
- ${g(n.labels.titleLabel)}
703
+ ${g(e.labels.titleLabel)}
658
704
  <input type="text" data-field="title" class="rte-citations-field" autocomplete="off" />
659
705
  </label>
660
706
  <label class="rte-citations-label">
661
- ${g(n.labels.sourceLabel)}
707
+ ${g(e.labels.sourceLabel)}
662
708
  <input type="text" data-field="source" class="rte-citations-field" autocomplete="off" />
663
709
  </label>
664
710
  <label class="rte-citations-label">
665
- ${g(n.labels.urlLabel)}
711
+ ${g(e.labels.urlLabel)}
666
712
  <input type="url" data-field="url" class="rte-citations-field" autocomplete="off" />
667
713
  </label>
668
714
  <label class="rte-citations-label rte-citations-label-note">
669
- ${g(n.labels.noteLabel)}
715
+ ${g(e.labels.noteLabel)}
670
716
  <textarea data-field="note" class="rte-citations-field" rows="2"></textarea>
671
717
  </label>
672
718
  </div>
673
719
 
674
720
  <div class="rte-citations-controls" role="toolbar" aria-label="Citation actions">
675
- <button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(n.labels.insertText)}</button>
676
- <button type="button" class="rte-citations-btn" data-action="refresh">${g(n.labels.refreshText)}</button>
721
+ <button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(e.labels.insertText)}</button>
722
+ <button type="button" class="rte-citations-btn" data-action="refresh">${g(e.labels.refreshText)}</button>
677
723
  <button type="button" class="rte-citations-btn" data-action="cycle-style"></button>
678
724
  </div>
679
725
 
680
- <section class="rte-citations-recent" aria-label="${g(n.labels.recentHeading)}">
681
- <h3 class="rte-citations-recent-heading">${g(n.labels.recentHeading)}</h3>
726
+ <section class="rte-citations-recent" aria-label="${g(e.labels.recentHeading)}">
727
+ <h3 class="rte-citations-recent-heading">${g(e.labels.recentHeading)}</h3>
682
728
  <ul class="rte-citations-recent-list" role="list"></ul>
683
729
  </section>
684
730
 
@@ -687,22 +733,25 @@ function ne(t) {
687
733
  </div>
688
734
  `, o.addEventListener("click", (a) => {
689
735
  const s = a.target;
690
- if (!s) return;
691
- const u = s.closest("[data-action]");
692
- if (!u) return;
693
- const c = u.getAttribute("data-action") || "", l = f.get(t) || M || n;
736
+ if (!s)
737
+ return;
738
+ const d = s.closest("[data-action]");
739
+ if (!d)
740
+ return;
741
+ const c = d.getAttribute("data-action") || "", l = f.get(t) || M || e;
694
742
  if (f.set(t, l), c === "close") {
695
743
  U(t, !0);
696
744
  return;
697
745
  }
698
746
  if (c === "insert") {
699
- if ($(t)) return;
700
- const d = te(o);
701
- if (!l.normalizeText(d.author) || !l.normalizeText(d.title)) {
747
+ if (S(t))
748
+ return;
749
+ const u = te(o);
750
+ if (!l.normalizeText(u.author) || !l.normalizeText(u.title)) {
702
751
  E(o, l.labels.invalidMessage);
703
752
  return;
704
753
  }
705
- if (!et(t, d, l)) {
754
+ if (!et(t, u, l)) {
706
755
  E(o, l.labels.invalidMessage);
707
756
  return;
708
757
  }
@@ -712,30 +761,33 @@ function ne(t) {
712
761
  return;
713
762
  }
714
763
  if (c === "refresh") {
715
- const d = y(t, l, !0);
716
- E(o, `Refreshed ${d.length} citation${d.length === 1 ? "" : "s"}.`);
764
+ const u = y(t, l, !0);
765
+ E(o, `Refreshed ${u.length} citation${u.length === 1 ? "" : "s"}.`);
717
766
  return;
718
767
  }
719
768
  if (c === "cycle-style") {
720
- const d = bt(t, l);
721
- ee(t, o, l), E(o, `Style changed to ${d.toUpperCase()}.`);
769
+ const u = bt(t, l);
770
+ ee(t, o, l), E(o, `Style changed to ${u.toUpperCase()}.`);
722
771
  return;
723
772
  }
724
773
  if (c === "insert-from-recent") {
725
- if ($(t)) return;
726
- const d = u.getAttribute("data-citation-id") || "", m = Et(t, d, K(t, l), l);
727
- if (!m) return;
728
- et(t, m, l), E(o, `Inserted citation: ${m.title}.`);
774
+ if (S(t))
775
+ return;
776
+ const u = d.getAttribute("data-citation-id") || "", b = Et(t, u, K(t, l), l);
777
+ if (!b)
778
+ return;
779
+ et(t, b, l), E(o, `Inserted citation: ${b.title}.`);
729
780
  return;
730
781
  }
731
782
  if (c === "delete-by-id") {
732
- if ($(t)) return;
733
- const d = u.getAttribute("data-citation-id") || "";
734
- if (Rt(t, d, l)) {
783
+ if (S(t))
784
+ return;
785
+ const u = d.getAttribute("data-citation-id") || "";
786
+ if (Rt(t, u, l)) {
735
787
  E(o, "Citation deleted.");
736
788
  return;
737
789
  }
738
- qt(t, d, l) && (H(t), E(o, "Removed from recent citations."));
790
+ qt(t, u, l) && (H(t), E(o, "Removed from recent citations."));
739
791
  }
740
792
  }), o.addEventListener("keydown", (a) => {
741
793
  if (a.key === "Escape") {
@@ -743,78 +795,86 @@ function ne(t) {
743
795
  return;
744
796
  }
745
797
  const s = a.target;
746
- if (!s || !s.matches(".rte-citations-recent-btn") || a.key !== "ArrowDown" && a.key !== "ArrowUp") return;
747
- const u = Array.from(o.querySelectorAll(".rte-citations-recent-btn"));
748
- if (u.length === 0) return;
749
- const c = u.indexOf(s);
750
- if (c < 0) return;
798
+ if (!s || !s.matches(".rte-citations-recent-btn") || a.key !== "ArrowDown" && a.key !== "ArrowUp")
799
+ return;
800
+ const d = Array.from(o.querySelectorAll(".rte-citations-recent-btn"));
801
+ if (d.length === 0)
802
+ return;
803
+ const c = d.indexOf(s);
804
+ if (c < 0)
805
+ return;
751
806
  a.preventDefault();
752
- const l = a.key === "ArrowDown" ? 1 : -1, d = (c + l + u.length) % u.length;
753
- u[d].focus();
807
+ const l = a.key === "ArrowDown" ? 1 : -1, u = (c + l + d.length) % d.length;
808
+ d[u].focus();
754
809
  });
755
810
  const r = C(o, "style");
756
- return r?.addEventListener("change", () => {
757
- const a = f.get(t) || M || n, s = r.value;
811
+ return r == null || r.addEventListener("change", () => {
812
+ const a = f.get(t) || M || e, s = r.value;
758
813
  Nt(t, s, a), E(o, `Style changed to ${s.toUpperCase()}.`);
759
814
  }), tt(o, t), document.body.appendChild(o), v.set(t, o), V.set(t, !1), H(t), o;
760
815
  }
761
816
  function z(t) {
762
- const e = ne(t);
763
- Qt(t), e.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(e, t), ct(t, e), H(t), C(e, "author")?.focus();
817
+ const n = ne(t);
818
+ Qt(t), n.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(n, t), ct(t, n), H(t);
819
+ const e = C(n, "author");
820
+ e == null || e.focus();
764
821
  }
765
- function zt(t, e) {
766
- const n = nt(t);
767
- return (typeof e == "boolean" ? e : !n) ? z(t) : U(t, !1), !0;
822
+ function zt(t, n) {
823
+ const e = nt(t);
824
+ return (typeof n == "boolean" ? n : !e) ? z(t) : U(t, !1), !0;
768
825
  }
769
826
  function oe(t) {
770
- const e = t.key.toLowerCase();
771
- return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "c";
827
+ const n = t.key.toLowerCase();
828
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && n === "c";
772
829
  }
773
830
  function ie(t) {
774
- const e = t.key.toLowerCase();
775
- return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "b";
831
+ const n = t.key.toLowerCase();
832
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && n === "b";
776
833
  }
777
834
  function re(t) {
778
- const e = t.key.toLowerCase();
779
- return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "j";
835
+ const n = t.key.toLowerCase();
836
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && n === "j";
780
837
  }
781
838
  function ae(t) {
782
- M = t, I || (I = (e) => {
783
- const i = e.target?.closest(S);
784
- if (!i) return;
839
+ M = t, I || (I = (n) => {
840
+ const e = n.target, i = e == null ? void 0 : e.closest($);
841
+ if (!i)
842
+ return;
785
843
  p = i, f.has(i) || f.set(i, t), T.has(i) || T.set(i, t.defaultStyle);
786
844
  const o = v.get(i);
787
845
  o && (tt(o, i), ct(i, o)), it(i, "toggleCitationsPanel", nt(i));
788
- }, document.addEventListener("focusin", I, !0)), B || (B = (e) => {
789
- const i = e.target?.closest(S);
846
+ }, document.addEventListener("focusin", I, !0)), B || (B = (n) => {
847
+ const e = n.target, i = e == null ? void 0 : e.closest($);
790
848
  i && (p = i, kt(i));
791
- }, document.addEventListener("input", B, !0)), O || (O = (e) => {
792
- if (e.defaultPrevented) return;
793
- const i = !!e.target?.closest(`.${b} input, .${b} textarea, .${b} select`), o = h(void 0, !1);
794
- if (!o || $(o)) return;
849
+ }, document.addEventListener("input", B, !0)), O || (O = (n) => {
850
+ if (n.defaultPrevented)
851
+ return;
852
+ const e = n.target, i = !!(e != null && e.closest(`.${m} input, .${m} textarea, .${m} select`)), o = h(void 0, !1);
853
+ if (!o || S(o))
854
+ return;
795
855
  const r = f.get(o) || M || t;
796
- if (f.set(o, r), p = o, e.key === "Escape" && nt(o)) {
797
- e.preventDefault(), U(o, !0);
856
+ if (f.set(o, r), p = o, n.key === "Escape" && nt(o)) {
857
+ n.preventDefault(), U(o, !0);
798
858
  return;
799
859
  }
800
- if (!i && !Xt(e, o, r)) {
801
- if (oe(e)) {
802
- e.preventDefault(), e.stopPropagation(), zt(o);
860
+ if (!i && !Xt(n, o, r)) {
861
+ if (oe(n)) {
862
+ n.preventDefault(), n.stopPropagation(), zt(o);
803
863
  return;
804
864
  }
805
- if (ie(e)) {
806
- e.preventDefault(), e.stopPropagation(), y(o, r, !0), z(o);
865
+ if (ie(n)) {
866
+ n.preventDefault(), n.stopPropagation(), y(o, r, !0), z(o);
807
867
  return;
808
868
  }
809
- re(e) && (e.preventDefault(), e.stopPropagation(), bt(o, r));
869
+ re(n) && (n.preventDefault(), n.stopPropagation(), bt(o, r));
810
870
  }
811
871
  }, document.addEventListener("keydown", O, !0)), k || (k = () => {
812
- v.forEach((e, n) => {
813
- if (!n.isConnected || !e.isConnected) {
814
- At(n), e.remove(), v.delete(n), V.delete(n);
872
+ v.forEach((n, e) => {
873
+ if (!e.isConnected || !n.isConnected) {
874
+ At(e), n.remove(), v.delete(e), V.delete(e);
815
875
  return;
816
876
  }
817
- tt(e, n), ct(n, e);
877
+ tt(n, e), ct(e, n);
818
878
  });
819
879
  }, window.addEventListener("scroll", k, !0), window.addEventListener("resize", k));
820
880
  }
@@ -822,9 +882,10 @@ function se() {
822
882
  I && (document.removeEventListener("focusin", I, !0), I = null), B && (document.removeEventListener("input", B, !0), B = null), O && (document.removeEventListener("keydown", O, !0), O = null), k && (window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k), k = null), v.forEach((t) => t.remove()), v.clear(), M = null, p = null;
823
883
  }
824
884
  function ce() {
825
- if (typeof document > "u" || document.getElementById(mt)) return;
885
+ if (typeof document > "u" || document.getElementById(gt))
886
+ return;
826
887
  const t = document.createElement("style");
827
- t.id = mt, t.textContent = `
888
+ t.id = gt, t.textContent = `
828
889
  .rte-toolbar-group-items.citations,
829
890
  .editora-toolbar-group-items.citations {
830
891
  display: flex;
@@ -852,7 +913,7 @@ function ce() {
852
913
 
853
914
  ${x} .rte-toolbar-group-items.citations,
854
915
  ${x} .editora-toolbar-group-items.citations,
855
- .${b}.rte-citations-theme-dark {
916
+ .${m}.rte-citations-theme-dark {
856
917
  border-color: #566275;
857
918
  }
858
919
 
@@ -870,7 +931,7 @@ function ce() {
870
931
  ${x} .editora-toolbar-button[data-command="toggleCitationsPanel"].active {
871
932
  background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
872
933
  }
873
- .${b} {
934
+ .${m} {
874
935
  position: fixed;
875
936
  z-index: 1500;
876
937
  right: 16px;
@@ -887,11 +948,11 @@ function ce() {
887
948
  overflow: hidden;
888
949
  }
889
950
 
890
- .${b}.show {
951
+ .${m}.show {
891
952
  display: flex;
892
953
  }
893
954
 
894
- .${b}.rte-citations-theme-dark {
955
+ .${m}.rte-citations-theme-dark {
895
956
  background: #0f172a;
896
957
  color: #e2e8f0;
897
958
  border-color: #334155;
@@ -907,7 +968,7 @@ function ce() {
907
968
  background: #f8fafc;
908
969
  }
909
970
 
910
- .${b}.rte-citations-theme-dark .rte-citations-header {
971
+ .${m}.rte-citations-theme-dark .rte-citations-header {
911
972
  border-bottom-color: #334155;
912
973
  background: #111827;
913
974
  }
@@ -944,14 +1005,14 @@ function ce() {
944
1005
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
945
1006
  }
946
1007
 
947
- .${b}.rte-citations-theme-dark .rte-citations-icon-btn {
1008
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn {
948
1009
  background: #0f172a;
949
1010
  border-color: #475569;
950
1011
  color: #e2e8f0;
951
1012
  }
952
1013
 
953
- .${b}.rte-citations-theme-dark .rte-citations-icon-btn:hover,
954
- .${b}.rte-citations-theme-dark .rte-citations-icon-btn:focus-visible {
1014
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn:hover,
1015
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn:focus-visible {
955
1016
  border-color: #60a5fa;
956
1017
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
957
1018
  }
@@ -970,7 +1031,7 @@ function ce() {
970
1031
  color: #475569;
971
1032
  }
972
1033
 
973
- .${b}.rte-citations-theme-dark .rte-citations-status {
1034
+ .${m}.rte-citations-theme-dark .rte-citations-status {
974
1035
  color: #94a3b8;
975
1036
  }
976
1037
 
@@ -1011,7 +1072,7 @@ function ce() {
1011
1072
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
1012
1073
  }
1013
1074
 
1014
- .${b}.rte-citations-theme-dark .rte-citations-field {
1075
+ .${m}.rte-citations-theme-dark .rte-citations-field {
1015
1076
  border-color: #334155;
1016
1077
  background: #0b1220;
1017
1078
  color: #e2e8f0;
@@ -1053,13 +1114,13 @@ function ce() {
1053
1114
  border-color: #1e40af;
1054
1115
  }
1055
1116
 
1056
- .${b}.rte-citations-theme-dark .rte-citations-btn {
1117
+ .${m}.rte-citations-theme-dark .rte-citations-btn {
1057
1118
  border-color: #334155;
1058
1119
  background: #0b1220;
1059
1120
  color: #e2e8f0;
1060
1121
  }
1061
1122
 
1062
- .${b}.rte-citations-theme-dark .rte-citations-btn-primary {
1123
+ .${m}.rte-citations-theme-dark .rte-citations-btn-primary {
1063
1124
  border-color: #2563eb;
1064
1125
  background: #2563eb;
1065
1126
  color: #ffffff;
@@ -1071,7 +1132,7 @@ function ce() {
1071
1132
  padding: 8px;
1072
1133
  }
1073
1134
 
1074
- .${b}.rte-citations-theme-dark .rte-citations-recent {
1135
+ .${m}.rte-citations-theme-dark .rte-citations-recent {
1075
1136
  border-color: #334155;
1076
1137
  }
1077
1138
 
@@ -1139,13 +1200,13 @@ function ce() {
1139
1200
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
1140
1201
  }
1141
1202
 
1142
- .${b}.rte-citations-theme-dark .rte-citations-recent-btn {
1203
+ .${m}.rte-citations-theme-dark .rte-citations-recent-btn {
1143
1204
  border-color: #334155;
1144
1205
  background: #0b1220;
1145
1206
  color: #e2e8f0;
1146
1207
  }
1147
1208
 
1148
- .${b}.rte-citations-theme-dark .rte-citations-recent-delete {
1209
+ .${m}.rte-citations-theme-dark .rte-citations-recent-delete {
1149
1210
  border-color: #7f1d1d;
1150
1211
  background: #2b1218;
1151
1212
  color: #fca5a5;
@@ -1163,7 +1224,7 @@ function ce() {
1163
1224
  line-height: 1.3;
1164
1225
  }
1165
1226
 
1166
- .${b}.rte-citations-theme-dark .rte-citations-recent-meta {
1227
+ .${m}.rte-citations-theme-dark .rte-citations-recent-meta {
1167
1228
  color: #94a3b8;
1168
1229
  }
1169
1230
 
@@ -1175,7 +1236,7 @@ function ce() {
1175
1236
  color: #64748b;
1176
1237
  }
1177
1238
 
1178
- .${b}.rte-citations-theme-dark .rte-citations-empty {
1239
+ .${m}.rte-citations-theme-dark .rte-citations-empty {
1179
1240
  border-color: #334155;
1180
1241
  color: #94a3b8;
1181
1242
  }
@@ -1186,7 +1247,7 @@ function ce() {
1186
1247
  color: #64748b;
1187
1248
  }
1188
1249
 
1189
- .${b}.rte-citations-theme-dark .rte-citations-shortcut {
1250
+ .${m}.rte-citations-theme-dark .rte-citations-shortcut {
1190
1251
  color: #94a3b8;
1191
1252
  }
1192
1253
 
@@ -1276,7 +1337,7 @@ function ce() {
1276
1337
  }
1277
1338
 
1278
1339
  @media (max-width: 768px) {
1279
- .${b} {
1340
+ .${m} {
1280
1341
  left: 10px !important;
1281
1342
  right: 10px;
1282
1343
  top: 10px !important;
@@ -1295,7 +1356,7 @@ function ce() {
1295
1356
  `, document.head.appendChild(t);
1296
1357
  }
1297
1358
  const le = (t = {}) => {
1298
- const e = Z(t);
1359
+ const n = Z(t);
1299
1360
  return ce(), {
1300
1361
  name: "citations",
1301
1362
  toolbar: [
@@ -1330,53 +1391,60 @@ const le = (t = {}) => {
1330
1391
  }
1331
1392
  ],
1332
1393
  commands: {
1333
- citations: (n, i) => {
1394
+ citations: (e, i) => {
1334
1395
  const o = h(i);
1335
- if (!o || $(o)) return !1;
1336
- const r = f.get(o) || e;
1396
+ if (!o || S(o))
1397
+ return !1;
1398
+ const r = f.get(o) || n;
1337
1399
  return f.set(o, r), T.set(o, N(o, r)), p = o, z(o), y(o, r, !1), !0;
1338
1400
  },
1339
- toggleCitationsPanel: (n, i) => {
1401
+ toggleCitationsPanel: (e, i) => {
1340
1402
  const o = h(i);
1341
- if (!o || $(o)) return !1;
1342
- const r = f.get(o) || e;
1403
+ if (!o || S(o))
1404
+ return !1;
1405
+ const r = f.get(o) || n;
1343
1406
  f.set(o, r), p = o;
1344
- const a = zt(o, typeof n == "boolean" ? n : void 0);
1407
+ const a = zt(o, typeof e == "boolean" ? e : void 0);
1345
1408
  return nt(o) && y(o, r, !1), a;
1346
1409
  },
1347
- insertCitation: (n, i) => {
1410
+ insertCitation: (e, i) => {
1348
1411
  const o = h(i);
1349
- if (!o || $(o) || !n || typeof n != "object") return !1;
1350
- const r = f.get(o) || e;
1412
+ if (!o || S(o) || !e || typeof e != "object")
1413
+ return !1;
1414
+ const r = f.get(o) || n;
1351
1415
  f.set(o, r), p = o;
1352
- const a = et(o, n, r);
1416
+ const a = et(o, e, r);
1353
1417
  return a && z(o), a;
1354
1418
  },
1355
- refreshCitations: (n, i) => {
1419
+ refreshCitations: (e, i) => {
1356
1420
  const o = h(i);
1357
- if (!o) return !1;
1358
- const r = f.get(o) || e;
1421
+ if (!o)
1422
+ return !1;
1423
+ const r = f.get(o) || n;
1359
1424
  return f.set(o, r), p = o, y(o, r, !0), z(o), !0;
1360
1425
  },
1361
- setCitationStyle: (n, i) => {
1426
+ setCitationStyle: (e, i) => {
1362
1427
  const o = h(i);
1363
- if (!o || !n) return !1;
1364
- const r = f.get(o) || e;
1365
- return f.set(o, r), p = o, Nt(o, n, r), !0;
1428
+ if (!o || !e)
1429
+ return !1;
1430
+ const r = f.get(o) || n;
1431
+ return f.set(o, r), p = o, Nt(o, e, r), !0;
1366
1432
  },
1367
- cycleCitationStyle: (n, i) => {
1433
+ cycleCitationStyle: (e, i) => {
1368
1434
  const o = h(i);
1369
- if (!o) return !1;
1370
- const r = f.get(o) || e;
1435
+ if (!o)
1436
+ return !1;
1437
+ const r = f.get(o) || n;
1371
1438
  return f.set(o, r), p = o, bt(o, r), H(o), !0;
1372
1439
  },
1373
- getCitationRecords: (n, i) => {
1440
+ getCitationRecords: (e, i) => {
1374
1441
  const o = h(i);
1375
- if (!o) return !1;
1376
- const r = f.get(o) || e, a = K(o, r);
1377
- if (typeof n == "function")
1442
+ if (!o)
1443
+ return !1;
1444
+ const r = f.get(o) || n, a = K(o, r);
1445
+ if (typeof e == "function")
1378
1446
  try {
1379
- n(a);
1447
+ e(a);
1380
1448
  } catch {
1381
1449
  }
1382
1450
  return o.__citationRecords = a, o.dispatchEvent(
@@ -1389,41 +1457,46 @@ const le = (t = {}) => {
1389
1457
  })
1390
1458
  ), !0;
1391
1459
  },
1392
- setCitationsOptions: (n, i) => {
1460
+ setCitationsOptions: (e, i) => {
1393
1461
  const o = h(i);
1394
- if (!o || !n || typeof n != "object") return !1;
1395
- const r = f.get(o) || e, a = Z({
1462
+ if (!o || !e || typeof e != "object")
1463
+ return !1;
1464
+ const r = f.get(o) || n, a = Z({
1396
1465
  ...r,
1397
- ...n,
1466
+ ...e,
1398
1467
  labels: {
1399
1468
  ...r.labels,
1400
- ...n.labels || {}
1469
+ ...e.labels || {}
1401
1470
  },
1402
- normalizeText: n.normalizeText || r.normalizeText,
1403
- generateCitationId: n.generateCitationId || r.generateCitationId
1471
+ normalizeText: e.normalizeText || r.normalizeText,
1472
+ generateCitationId: e.generateCitationId || r.generateCitationId
1404
1473
  });
1405
- return f.set(o, a), n.defaultStyle && L.includes(n.defaultStyle) && T.set(o, n.defaultStyle), y(o, a, !0), H(o), !0;
1474
+ return f.set(o, a), e.defaultStyle && L.includes(e.defaultStyle) && T.set(o, e.defaultStyle), y(o, a, !0), H(o), !0;
1406
1475
  },
1407
- locateCitation: (n, i) => {
1476
+ locateCitation: (e, i) => {
1408
1477
  const o = h(i);
1409
- return !o || typeof n != "string" ? !1 : Zt(o, n);
1478
+ return !o || typeof e != "string" ? !1 : Zt(o, e);
1410
1479
  },
1411
- deleteCitation: (n, i) => {
1480
+ deleteCitation: (e, i) => {
1412
1481
  const o = h(i);
1413
- if (!o || $(o)) return !1;
1414
- const r = f.get(o) || e;
1415
- return f.set(o, r), typeof n == "string" && n.trim() ? Rt(o, n, r) : Jt(o, r);
1482
+ if (!o || S(o))
1483
+ return !1;
1484
+ const r = f.get(o) || n;
1485
+ return f.set(o, r), typeof e == "string" && e.trim() ? Rt(o, e, r) : Jt(o, r);
1416
1486
  },
1417
- insertRecentCitation: (n, i) => {
1487
+ insertRecentCitation: (e, i) => {
1418
1488
  const o = h(i);
1419
- if (!o || $(o)) return !1;
1420
- const r = f.get(o) || e;
1489
+ if (!o || S(o))
1490
+ return !1;
1491
+ const r = f.get(o) || n;
1421
1492
  f.set(o, r);
1422
1493
  const a = K(o, r), s = rt(o, a, r);
1423
- if (s.length === 0) return !1;
1424
- const u = typeof n == "string" && n.trim() ? Et(o, n, a, r) : s[0];
1425
- if (!u) return !1;
1426
- const c = et(o, u, r);
1494
+ if (s.length === 0)
1495
+ return !1;
1496
+ const d = typeof e == "string" && e.trim() ? Et(o, e, a, r) : s[0];
1497
+ if (!d)
1498
+ return !1;
1499
+ const c = et(o, d, r);
1427
1500
  return c && z(o), c;
1428
1501
  }
1429
1502
  },
@@ -1437,7 +1510,7 @@ const le = (t = {}) => {
1437
1510
  },
1438
1511
  init: function(i) {
1439
1512
  Y += 1;
1440
- const o = this && typeof this.__pluginConfig == "object" ? Z({ ...e, ...this.__pluginConfig }) : e;
1513
+ const o = this && typeof this.__pluginConfig == "object" ? Z({ ...n, ...this.__pluginConfig }) : n;
1441
1514
  ae(o);
1442
1515
  const r = h(
1443
1516
  i && i.editorElement ? { editorElement: i.editorElement } : void 0,
@@ -1446,8 +1519,8 @@ const le = (t = {}) => {
1446
1519
  r && (p = r, f.set(r, o), T.set(r, o.defaultStyle), it(r, "toggleCitationsPanel", !1), kt(r));
1447
1520
  },
1448
1521
  destroy: () => {
1449
- Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((n) => {
1450
- window.clearTimeout(n);
1522
+ Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((e) => {
1523
+ window.clearTimeout(e);
1451
1524
  }), q.clear(), se());
1452
1525
  }
1453
1526
  };