@editora/core 1.0.6 → 1.0.8

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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  3. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  4. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  5. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  6. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  7. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  8. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  9. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  10. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  11. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  12. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  13. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  14. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  15. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  16. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  17. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  18. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  19. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  20. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  21. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  22. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +86 -77
  23. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  24. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  25. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  26. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  27. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  28. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  29. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  30. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  31. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  32. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  33. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  34. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  35. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  36. package/dist/editora.min.js +13 -13
  37. package/dist/editora.umd.js +13 -13
  38. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  39. package/dist/index-BslAFzmv.mjs +16544 -0
  40. package/dist/index-D1LOqg5C.js +10 -0
  41. package/dist/{index-OwnkG39N.mjs → index-DqC57IEH.mjs} +438 -328
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  44. package/dist/index.esm.js +2 -2
  45. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  46. package/dist/plugin-loader.js +77 -40
  47. package/dist/webcomponent-core.js +456 -346
  48. package/dist/webcomponent-core.min.css +1 -1
  49. package/dist/webcomponent-core.min.js +87 -107
  50. package/dist/webcomponent.cjs.js +1 -1
  51. package/dist/webcomponent.esm.js +1 -1
  52. package/dist/webcomponent.js +503 -356
  53. package/dist/webcomponent.min.css +1 -1
  54. package/dist/webcomponent.min.js +6003 -658
  55. package/package.json +2 -2
  56. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  57. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  58. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  59. package/dist/documentManager-irzj9n3V.mjs +0 -37627
  60. package/dist/index-CqWQFb3D.js +0 -10
@@ -0,0 +1,1396 @@
1
+ const x = ".rte-content, .editora-content", ae = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", we = "__editoraCommandEditorRoot", Ee = "rte-pii-redaction-styles", u = "rte-pii-redaction-panel", k = "pii-redaction", v = "piiRedaction", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pe = typeof NodeFilter != "undefined" ? NodeFilter.SHOW_TEXT : 4, Oe = [
2
+ "email",
3
+ "phone",
4
+ "ssn",
5
+ "credit-card",
6
+ "ipv4",
7
+ "api-key",
8
+ "jwt"
9
+ ], ze = {
10
+ panelTitle: "PII Redaction",
11
+ panelAriaLabel: "PII redaction panel",
12
+ scanText: "Scan PII",
13
+ redactAllText: "Redact All",
14
+ redactText: "Redact",
15
+ locateText: "Locate",
16
+ realtimeOnText: "Realtime On",
17
+ realtimeOffText: "Realtime Off",
18
+ closeText: "Close",
19
+ noFindingsText: "No PII detected in the document.",
20
+ summaryPrefix: "Findings",
21
+ shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",
22
+ readonlyRedactionText: "Editor is read-only. Reopen editable mode to redact.",
23
+ matchLabel: "Detected",
24
+ maskedLabel: "Masked",
25
+ excerptLabel: "Context"
26
+ }, Fe = {
27
+ email: {
28
+ label: "Email",
29
+ severity: "medium",
30
+ pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi
31
+ },
32
+ phone: {
33
+ label: "Phone",
34
+ severity: "medium",
35
+ pattern: /\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g
36
+ },
37
+ ssn: {
38
+ label: "SSN",
39
+ severity: "high",
40
+ pattern: /\b\d{3}-\d{2}-\d{4}\b/g
41
+ },
42
+ "credit-card": {
43
+ label: "Credit Card",
44
+ severity: "high",
45
+ pattern: /\b(?:\d[ -]*?){13,19}\b/g,
46
+ validator: (e) => We(e)
47
+ },
48
+ ipv4: {
49
+ label: "IPv4",
50
+ severity: "low",
51
+ pattern: /\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g
52
+ },
53
+ "api-key": {
54
+ label: "API Key",
55
+ severity: "high",
56
+ pattern: /\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g
57
+ },
58
+ jwt: {
59
+ label: "JWT",
60
+ severity: "high",
61
+ pattern: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g
62
+ }
63
+ }, f = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set();
64
+ let G = 0, He = 0, ve = 0, M = null, g = null, L = null, D = null, _ = null, R = null, N = null;
65
+ function b(e) {
66
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
67
+ }
68
+ function Be(e) {
69
+ return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
70
+ }
71
+ function Y(e) {
72
+ const t = e.flags.includes("g") ? e.flags : `${e.flags}g`;
73
+ return new RegExp(e.source, t);
74
+ }
75
+ function be(e) {
76
+ return new RegExp(e.source, e.flags);
77
+ }
78
+ function X(e, t, n) {
79
+ return Math.max(t, Math.min(n, e));
80
+ }
81
+ function Ke(e, t) {
82
+ return e === "high" || e === "medium" || e === "low" ? e : t;
83
+ }
84
+ function qe(e) {
85
+ const t = (e || "*").slice(0, 1) || "*";
86
+ return /[A-Za-z0-9._%+\-\s]/.test(t) ? "*" : t;
87
+ }
88
+ function $e(e) {
89
+ let t = 2166136261;
90
+ for (let n = 0; n < e.length; n += 1)
91
+ t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
92
+ return t >>> 0;
93
+ }
94
+ function We(e) {
95
+ const t = e.replace(/\D/g, "");
96
+ if (t.length < 13 || t.length > 19) return !1;
97
+ let n = 0, i = !1;
98
+ for (let o = t.length - 1; o >= 0; o -= 1) {
99
+ let r = Number(t[o]);
100
+ i && (r *= 2, r > 9 && (r -= 9)), n += r, i = !i;
101
+ }
102
+ return n % 10 === 0;
103
+ }
104
+ function je(e, t) {
105
+ const n = Fe[e];
106
+ if (typeof t == "boolean")
107
+ return {
108
+ type: e,
109
+ label: n.label,
110
+ severity: n.severity,
111
+ enabled: t,
112
+ pattern: Y(n.pattern),
113
+ validator: n.validator
114
+ };
115
+ if (!t)
116
+ return {
117
+ type: e,
118
+ label: n.label,
119
+ severity: n.severity,
120
+ enabled: !0,
121
+ pattern: Y(n.pattern),
122
+ validator: n.validator
123
+ };
124
+ const i = t.pattern instanceof RegExp ? Y(t.pattern) : Y(n.pattern);
125
+ return {
126
+ type: e,
127
+ label: n.label,
128
+ severity: Ke(t.severity, n.severity),
129
+ enabled: t.enabled !== !1,
130
+ pattern: i,
131
+ validator: n.validator
132
+ };
133
+ }
134
+ function ee(e = {}) {
135
+ var i, o, r, a;
136
+ const t = Oe.map((l) => {
137
+ var c;
138
+ return je(l, (c = e.detectors) == null ? void 0 : c[l]);
139
+ }), n = t.map((l) => `${l.type}:${l.enabled ? "1" : "0"}:${l.severity}:${l.pattern.source}:${l.pattern.flags}`).join("|");
140
+ return {
141
+ enableRealtime: e.enableRealtime !== !1,
142
+ debounceMs: X(Number((i = e.debounceMs) != null ? i : 220), 60, 3e3),
143
+ maxFindings: X(Number((o = e.maxFindings) != null ? o : 140), 1, 500),
144
+ maskChar: qe(e.maskChar),
145
+ revealStart: X(Number((r = e.revealStart) != null ? r : 2), 0, 12),
146
+ revealEnd: X(Number((a = e.revealEnd) != null ? a : 2), 0, 12),
147
+ redactionMode: e.redactionMode === "mask" ? "mask" : "token",
148
+ redactionToken: (e.redactionToken || "REDACTED").trim() || "REDACTED",
149
+ skipInCodeBlocks: e.skipInCodeBlocks !== !1,
150
+ labels: {
151
+ ...ze,
152
+ ...e.labels || {}
153
+ },
154
+ normalizeText: e.normalizeText || Be,
155
+ detectors: t,
156
+ detectorSignature: n
157
+ };
158
+ }
159
+ function ce(e) {
160
+ const t = {};
161
+ return e.detectors.forEach((n) => {
162
+ t[n.type] = {
163
+ enabled: n.enabled,
164
+ severity: n.severity,
165
+ pattern: n.pattern
166
+ };
167
+ }), {
168
+ enableRealtime: e.enableRealtime,
169
+ debounceMs: e.debounceMs,
170
+ maxFindings: e.maxFindings,
171
+ maskChar: e.maskChar,
172
+ revealStart: e.revealStart,
173
+ revealEnd: e.revealEnd,
174
+ redactionMode: e.redactionMode,
175
+ redactionToken: e.redactionToken,
176
+ skipInCodeBlocks: e.skipInCodeBlocks,
177
+ labels: { ...e.labels },
178
+ normalizeText: e.normalizeText,
179
+ detectors: t
180
+ };
181
+ }
182
+ function ge(e) {
183
+ return e.closest(ae) || e;
184
+ }
185
+ function Ze(e) {
186
+ const t = e.closest("[data-editora-editor]");
187
+ if (t && z(t) === e)
188
+ return t;
189
+ let n = e;
190
+ for (; n; ) {
191
+ if (n.matches(ae) && (n === e || z(n) === e))
192
+ return n;
193
+ n = n.parentElement;
194
+ }
195
+ return ge(e);
196
+ }
197
+ function z(e) {
198
+ if (!e) return null;
199
+ if (e.matches(x)) return e;
200
+ const t = e.querySelector(x);
201
+ return t instanceof HTMLElement ? t : null;
202
+ }
203
+ function Ve() {
204
+ if (typeof window == "undefined") return null;
205
+ const e = window[we];
206
+ if (!(e instanceof HTMLElement)) return null;
207
+ window[we] = null;
208
+ const t = z(e);
209
+ if (t) return t;
210
+ const n = e.closest(ae);
211
+ if (n) {
212
+ const o = z(n);
213
+ if (o) return o;
214
+ }
215
+ const i = e.closest(x);
216
+ return i instanceof HTMLElement ? i : null;
217
+ }
218
+ function J(e) {
219
+ return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
220
+ }
221
+ function Ue(e) {
222
+ const t = ge(e);
223
+ if (J(t)) return !0;
224
+ const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
225
+ return J(n) ? !0 : J(document.documentElement) || J(document.body);
226
+ }
227
+ function ne(e, t) {
228
+ e.classList.remove("rte-pii-redaction-theme-dark"), Ue(t) && e.classList.add("rte-pii-redaction-theme-dark");
229
+ }
230
+ function re(e) {
231
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
232
+ }
233
+ function me(e) {
234
+ const t = te.get(e);
235
+ typeof t == "number" && (window.clearTimeout(t), j.delete(t), te.delete(e));
236
+ }
237
+ function U(e) {
238
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
239
+ }
240
+ function le(e = 0) {
241
+ return {
242
+ total: 0,
243
+ high: 0,
244
+ medium: 0,
245
+ low: 0,
246
+ redactedCount: e,
247
+ byType: {
248
+ email: 0,
249
+ phone: 0,
250
+ ssn: 0,
251
+ "credit-card": 0,
252
+ ipv4: 0,
253
+ "api-key": 0,
254
+ jwt: 0
255
+ }
256
+ };
257
+ }
258
+ function q() {
259
+ Array.from(W).forEach((t) => {
260
+ t.isConnected || Te(t);
261
+ });
262
+ }
263
+ function Ge(e) {
264
+ var t, n, i, o;
265
+ for (let r = 0; r < e.length; r += 1) {
266
+ const a = e[r];
267
+ if (!(a.type !== "childList" || a.removedNodes.length === 0))
268
+ for (let l = 0; l < a.removedNodes.length; l += 1) {
269
+ const c = a.removedNodes[l];
270
+ if (c.nodeType !== Node.ELEMENT_NODE) continue;
271
+ const d = c;
272
+ if ((t = d.matches) != null && t.call(d, x) || (n = d.matches) != null && n.call(d, `.${u}`) || (i = d.querySelector) != null && i.call(d, x) || (o = d.querySelector) != null && o.call(d, `.${u}`))
273
+ return !0;
274
+ }
275
+ }
276
+ return !1;
277
+ }
278
+ function T(e, t = !0) {
279
+ if (q(), (e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
280
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
281
+ const r = e.editorElement, a = z(r);
282
+ if (a) return a;
283
+ }
284
+ const n = Ve();
285
+ if (n) return n;
286
+ const i = window.getSelection();
287
+ if (i && i.rangeCount > 0) {
288
+ const r = re(i.getRangeAt(0).startContainer), a = r == null ? void 0 : r.closest(x);
289
+ if (a) return a;
290
+ }
291
+ const o = document.activeElement;
292
+ if (o) {
293
+ if (o.matches(x)) return o;
294
+ const r = o.closest(x);
295
+ if (r) return r;
296
+ }
297
+ return g && g.isConnected ? g : (g && !g.isConnected && (g = null), t ? document.querySelector(x) : null);
298
+ }
299
+ function Te(e) {
300
+ var t;
301
+ me(e), (t = m.get(e)) == null || t.remove(), m.delete(e), V.delete(e), f.delete(e), I.delete(e), E.delete(e), S.delete(e), de.delete(e), Q.delete(e), W.delete(e), g === e && (g = null);
302
+ }
303
+ function C(e, t, n) {
304
+ const i = Ze(e);
305
+ Array.from(
306
+ i.querySelectorAll(
307
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
308
+ )
309
+ ).forEach((r) => {
310
+ r.classList.toggle("active", n), r.setAttribute("data-active", n ? "true" : "false"), r.setAttribute("aria-pressed", n ? "true" : "false");
311
+ });
312
+ }
313
+ function w(e, t) {
314
+ f.has(e) || f.set(e, t), I.has(e) || I.set(e, []), E.has(e) || E.set(e, le(0)), S.has(e) || S.set(e, t.enableRealtime), W.add(e);
315
+ }
316
+ function ie(e) {
317
+ return V.get(e) === !0;
318
+ }
319
+ function Ie(e, t, n, i) {
320
+ if (!e) return e;
321
+ if (e.length <= n + i)
322
+ return t.repeat(e.length);
323
+ const o = e.slice(0, n), r = i > 0 ? e.slice(e.length - i) : "";
324
+ return `${o}${t.repeat(Math.max(1, e.length - n - i))}${r}`;
325
+ }
326
+ function se(e, t, n) {
327
+ const i = e.replace(/\D/g, "");
328
+ if (i.length === 0) return e;
329
+ let o = 0;
330
+ const r = Math.max(0, i.length - n);
331
+ return e.split("").map((a) => /\d/.test(a) ? (o += 1, o <= r ? t : a) : a).join("");
332
+ }
333
+ function Ye(e, t) {
334
+ const n = e.indexOf("@");
335
+ if (n <= 0) return e;
336
+ const i = e.slice(0, n), o = e.slice(n + 1);
337
+ return i.length <= 2 ? `${i[0] || ""}${t}[at]${o}` : `${i[0]}${t.repeat(Math.max(1, i.length - 2))}${i[i.length - 1]}[at]${o}`;
338
+ }
339
+ function Xe(e, t) {
340
+ const n = e.split(".");
341
+ return n.length !== 4 ? e : `${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1, n[3].length))}`;
342
+ }
343
+ function Ce(e, t, n) {
344
+ return e && (t === "email" ? Ye(e, n.maskChar) : t === "phone" || t === "ssn" || t === "credit-card" ? se(e, n.maskChar, 4) : t === "ipv4" ? Xe(e, n.maskChar) : t === "api-key" || t === "jwt" ? Ie(e, n.maskChar, 0, 0) : Ie(e, n.maskChar, n.revealStart, n.revealEnd));
345
+ }
346
+ function Re(e, t, n) {
347
+ return n.redactionMode === "mask" ? Ce(e, t, n) : `[${n.redactionToken}:${t.toUpperCase()}]`;
348
+ }
349
+ function Je(e) {
350
+ return ve += 1, `pii-${e}-${Date.now().toString(36)}-${ve.toString(36)}`;
351
+ }
352
+ function he(e, t) {
353
+ var n;
354
+ return t.skipInCodeBlocks ? !!((n = e.parentElement) != null && n.closest("code, pre, kbd, samp")) : !1;
355
+ }
356
+ function Qe(e, t) {
357
+ return t.some((n) => e.start < n.end && n.start < e.end);
358
+ }
359
+ function et(e, t, n) {
360
+ const i = [];
361
+ t.filter((a) => a.enabled).forEach((a) => {
362
+ const l = be(a.pattern);
363
+ let c = l.exec(e);
364
+ for (; c && i.length < n * 5; ) {
365
+ const d = c[0] || "", s = c.index, p = s + d.length;
366
+ d && p > s && (!a.validator || a.validator(d)) && i.push({
367
+ type: a.type,
368
+ severity: a.severity,
369
+ value: d,
370
+ start: s,
371
+ end: p
372
+ }), l.lastIndex === c.index && (l.lastIndex += 1), c = l.exec(e);
373
+ }
374
+ }), i.sort((a, l) => a.start !== l.start ? a.start - l.start : l.end - a.end);
375
+ const r = [];
376
+ for (let a = 0; a < i.length && !(r.length >= n); a += 1) {
377
+ const l = i[a];
378
+ Qe({ start: l.start, end: l.end }, r) || r.push(l);
379
+ }
380
+ return r;
381
+ }
382
+ function ue(e, t = 120) {
383
+ return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
384
+ }
385
+ function tt(e, t, n) {
386
+ const i = Math.max(0, t - 28), o = Math.min(e.length, n + 28);
387
+ return ue(e.slice(i, o).trim(), 180);
388
+ }
389
+ function nt(e, t) {
390
+ const n = le(t);
391
+ return n.total = e.length, e.forEach((i) => {
392
+ n.byType[i.type] += 1, i.severity === "high" ? n.high += 1 : i.severity === "medium" ? n.medium += 1 : n.low += 1;
393
+ }), n;
394
+ }
395
+ function oe(e, t) {
396
+ const n = e.querySelector(".rte-pii-redaction-live");
397
+ n && (n.textContent = t);
398
+ }
399
+ function F(e, t, n) {
400
+ const i = t.querySelector('[data-action="toggle-realtime"]');
401
+ if (!i) return;
402
+ const o = H(e, n);
403
+ i.textContent = o ? n.labels.realtimeOnText : n.labels.realtimeOffText, i.setAttribute("aria-pressed", o ? "true" : "false"), C(e, "togglePIIRealtime", o);
404
+ }
405
+ function rt(e, t) {
406
+ e.setAttribute("aria-label", t.labels.panelAriaLabel);
407
+ const n = e.querySelector(".rte-pii-redaction-title");
408
+ n && (n.textContent = t.labels.panelTitle);
409
+ const i = e.querySelector('[data-action="close"]');
410
+ i && i.setAttribute("aria-label", t.labels.closeText);
411
+ const o = e.querySelector('[data-action="run-scan"]');
412
+ o && (o.textContent = t.labels.scanText);
413
+ const r = e.querySelector('[data-action="redact-all"]');
414
+ r && (r.textContent = t.labels.redactAllText);
415
+ const a = e.querySelector(".rte-pii-redaction-shortcut");
416
+ a && (a.textContent = t.labels.shortcutText);
417
+ }
418
+ function B(e) {
419
+ const t = m.get(e);
420
+ if (!t) return;
421
+ const n = f.get(e) || M;
422
+ if (!n) return;
423
+ const i = I.get(e) || [], o = E.get(e) || le(0), r = U(e), a = t.querySelector(".rte-pii-redaction-count"), l = t.querySelector(".rte-pii-redaction-summary"), c = t.querySelector(".rte-pii-redaction-list"), d = t.querySelector('[data-action="redact-all"]');
424
+ if (!(!a || !l || !c || !d)) {
425
+ if (a.textContent = String(o.total), l.textContent = `${n.labels.summaryPrefix}: ${o.total} | High ${o.high} | Medium ${o.medium} | Low ${o.low} | Redacted ${o.redactedCount}`, d.disabled = r || i.length === 0, r ? oe(t, n.labels.readonlyRedactionText) : oe(t, `${o.total} PII findings detected.`), F(e, t, n), i.length === 0) {
426
+ c.innerHTML = `<li class="rte-pii-redaction-empty">${b(n.labels.noFindingsText)}</li>`;
427
+ return;
428
+ }
429
+ c.innerHTML = i.map((s) => {
430
+ const p = s.type.toUpperCase(), A = s.suggestion || "Redact this finding before export/share.", P = `${n.labels.locateText}: ${s.match}`, K = `${n.labels.redactText}: ${s.match}`, y = r ? 'disabled aria-disabled="true"' : "";
431
+ return `
432
+ <li class="rte-pii-redaction-item rte-pii-redaction-item-${s.severity}">
433
+ <button
434
+ type="button"
435
+ class="rte-pii-redaction-item-btn"
436
+ data-action="locate-finding"
437
+ data-finding-id="${b(s.id)}"
438
+ data-role="finding-button"
439
+ aria-label="${b(P)}"
440
+ >
441
+ <span class="rte-pii-redaction-badge">${b(s.severity.toUpperCase())}</span>
442
+ <span class="rte-pii-redaction-type">${b(p)}</span>
443
+ </button>
444
+ <p class="rte-pii-redaction-line"><strong>${b(n.labels.matchLabel)}:</strong> ${b(ue(s.match, 80))}</p>
445
+ <p class="rte-pii-redaction-line"><strong>${b(n.labels.maskedLabel)}:</strong> ${b(ue(s.masked, 80))}</p>
446
+ ${s.excerpt ? `<p class="rte-pii-redaction-line"><strong>${b(n.labels.excerptLabel)}:</strong> ${b(s.excerpt)}</p>` : ""}
447
+ <p class="rte-pii-redaction-help">${b(A)}</p>
448
+ <div class="rte-pii-redaction-item-actions">
449
+ <button type="button" class="rte-pii-redaction-btn" data-action="redact-finding" data-finding-id="${b(
450
+ s.id
451
+ )}" aria-label="${b(K)}" ${y}>${b(n.labels.redactText)}</button>
452
+ </div>
453
+ </li>
454
+ `;
455
+ }).join("");
456
+ }
457
+ }
458
+ function fe(e, t) {
459
+ if (!t.classList.contains("show")) return;
460
+ const i = ge(e).getBoundingClientRect(), o = Math.min(window.innerWidth - 20, 390), r = Math.max(10, window.innerWidth - o - 10), a = Math.min(Math.max(10, i.right - o), r), l = Math.max(10, Math.min(window.innerHeight - 10 - 280, i.top + 10));
461
+ t.style.width = `${o}px`, t.style.left = `${a}px`, t.style.top = `${l}px`, t.style.maxHeight = `${Math.max(260, window.innerHeight - 20)}px`;
462
+ }
463
+ function H(e, t) {
464
+ const n = S.get(e);
465
+ return typeof n == "boolean" ? n : t ? t.enableRealtime : !0;
466
+ }
467
+ function Se(e, t) {
468
+ if (t === e.innerHTML) return;
469
+ const n = window.execEditorCommand || window.executeEditorCommand;
470
+ if (typeof n == "function")
471
+ try {
472
+ n("recordDomTransaction", e, t, e.innerHTML);
473
+ } catch (i) {
474
+ }
475
+ }
476
+ function Ae(e) {
477
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
478
+ }
479
+ function Me(e, t) {
480
+ e.dispatchEvent(
481
+ new CustomEvent("editora:pii-redacted", {
482
+ bubbles: !0,
483
+ detail: {
484
+ redactedCount: t
485
+ }
486
+ })
487
+ );
488
+ }
489
+ function Pe(e, t) {
490
+ return (I.get(e) || []).find((i) => i.id === t);
491
+ }
492
+ function it(e) {
493
+ const t = m.get(e);
494
+ if (t) return t;
495
+ const n = f.get(e) || M || ee(), i = `rte-pii-redaction-panel-${He++}`, o = document.createElement("section");
496
+ return o.className = u, o.id = i, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", n.labels.panelAriaLabel), o.innerHTML = `
497
+ <header class="rte-pii-redaction-header">
498
+ <h2 class="rte-pii-redaction-title">${b(n.labels.panelTitle)}</h2>
499
+ <button type="button" class="rte-pii-redaction-icon-btn" data-action="close" aria-label="${b(
500
+ n.labels.closeText
501
+ )}">✕</button>
502
+ </header>
503
+ <div class="rte-pii-redaction-body">
504
+ <div class="rte-pii-redaction-topline">
505
+ <p class="rte-pii-redaction-summary" aria-live="polite"></p>
506
+ <span class="rte-pii-redaction-count" aria-hidden="true">0</span>
507
+ </div>
508
+ <div class="rte-pii-redaction-controls" role="toolbar" aria-label="PII redaction controls">
509
+ <button type="button" class="rte-pii-redaction-btn rte-pii-redaction-btn-primary" data-action="run-scan">${b(
510
+ n.labels.scanText
511
+ )}</button>
512
+ <button type="button" class="rte-pii-redaction-btn" data-action="redact-all">${b(
513
+ n.labels.redactAllText
514
+ )}</button>
515
+ <button type="button" class="rte-pii-redaction-btn" data-action="toggle-realtime" aria-pressed="false"></button>
516
+ </div>
517
+ <ul class="rte-pii-redaction-list" role="list" aria-label="Detected PII findings"></ul>
518
+ <p class="rte-pii-redaction-shortcut">${b(n.labels.shortcutText)}</p>
519
+ <span class="rte-pii-redaction-live" aria-live="polite"></span>
520
+ </div>
521
+ `, o.addEventListener("click", (r) => {
522
+ const a = r.target, l = a == null ? void 0 : a.closest("[data-action]");
523
+ if (!l) return;
524
+ const c = l.getAttribute("data-action") || "", d = f.get(e) || M || n;
525
+ if (f.set(e, d), w(e, d), c === "close") {
526
+ Z(e, !0);
527
+ return;
528
+ }
529
+ if (c === "run-scan") {
530
+ h(e, d, !0);
531
+ return;
532
+ }
533
+ if (c === "toggle-realtime") {
534
+ const s = !H(e, d);
535
+ S.set(e, s), F(e, o, d), s && h(e, d, !0);
536
+ return;
537
+ }
538
+ if (c === "redact-all") {
539
+ xe(e, d);
540
+ return;
541
+ }
542
+ if (c === "locate-finding") {
543
+ const s = l.getAttribute("data-finding-id") || "", p = Pe(e, s);
544
+ if (!p) return;
545
+ lt(e, p, d);
546
+ return;
547
+ }
548
+ if (c === "redact-finding") {
549
+ const s = l.getAttribute("data-finding-id") || "";
550
+ _e(e, s, d);
551
+ }
552
+ }), o.addEventListener("keydown", (r) => {
553
+ if (r.key === "Escape") {
554
+ r.preventDefault(), Z(e, !0);
555
+ return;
556
+ }
557
+ if (r.key !== "ArrowDown" && r.key !== "ArrowUp") return;
558
+ const a = Array.from(o.querySelectorAll('[data-role="finding-button"]'));
559
+ if (a.length === 0) return;
560
+ const l = document.activeElement, c = a.findIndex((p) => p === l);
561
+ if (c === -1) return;
562
+ r.preventDefault();
563
+ const d = r.key === "ArrowDown" ? 1 : -1, s = (c + d + a.length) % a.length;
564
+ a[s].focus();
565
+ }), ne(o, e), document.body.appendChild(o), m.set(e, o), V.set(e, !1), B(e), o;
566
+ }
567
+ function Z(e, t = !1) {
568
+ const n = m.get(e);
569
+ n && (n.classList.remove("show"), V.set(e, !1), C(e, "togglePIIRedactionPanel", !1), t && e.focus({ preventScroll: !0 }));
570
+ }
571
+ function O(e) {
572
+ q();
573
+ const t = it(e);
574
+ m.forEach((i, o) => {
575
+ o !== e && Z(o, !1);
576
+ }), t.classList.add("show"), V.set(e, !0), C(e, "togglePIIRedactionPanel", !0), ne(t, e), fe(e, t), B(e);
577
+ const n = t.querySelector('[data-action="run-scan"]');
578
+ n == null || n.focus();
579
+ }
580
+ function Le(e, t) {
581
+ const n = ie(e);
582
+ return (typeof t == "boolean" ? t : !n) ? O(e) : Z(e), !0;
583
+ }
584
+ function ot(e, t) {
585
+ const n = t.normalizeText(e.innerText || e.textContent || ""), i = e.innerHTML;
586
+ return `${n.length}:${$e(n)}:${i.length}:${$e(i)}:${t.detectorSignature}`;
587
+ }
588
+ function at(e, t) {
589
+ const n = [], i = be(e.pattern);
590
+ let o = i.exec(t);
591
+ for (; o; ) {
592
+ const r = o[0] || "", a = o.index, l = a + r.length;
593
+ r && l > a && (!e.validator || e.validator(r)) && n.push({ value: r, start: a, end: l }), i.lastIndex === o.index && (i.lastIndex += 1), o = i.exec(t);
594
+ }
595
+ return n;
596
+ }
597
+ function De(e, t, n) {
598
+ const i = n.detectors.find((c) => c.type === t.type && c.enabled);
599
+ if (!i) return null;
600
+ const o = t.match.toLowerCase();
601
+ let r = 0;
602
+ const a = document.createTreeWalker(e, pe, null);
603
+ let l = a.nextNode();
604
+ for (; l; ) {
605
+ if (!he(l, n)) {
606
+ const c = at(i, l.data);
607
+ for (let d = 0; d < c.length; d += 1) {
608
+ const s = c[d];
609
+ if (s.value.toLowerCase() === o && (r += 1, r === t.occurrence)) {
610
+ const p = document.createRange();
611
+ return p.setStart(l, s.start), p.setEnd(l, s.end), p;
612
+ }
613
+ }
614
+ }
615
+ l = a.nextNode();
616
+ }
617
+ return null;
618
+ }
619
+ function lt(e, t, n) {
620
+ const i = De(e, t, n);
621
+ if (!i) return !1;
622
+ const o = window.getSelection();
623
+ if (!o) return !1;
624
+ o.removeAllRanges(), o.addRange(i);
625
+ const r = re(i.startContainer);
626
+ return r == null || r.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 }), !0;
627
+ }
628
+ async function h(e, t, n = !1) {
629
+ var p;
630
+ w(e, t);
631
+ const i = ot(e, t);
632
+ if (!n && de.get(e) === i)
633
+ return I.get(e) || [];
634
+ const o = (Q.get(e) || 0) + 1;
635
+ Q.set(e, o);
636
+ const r = [], a = /* @__PURE__ */ new Map(), l = document.createTreeWalker(e, pe, null);
637
+ let c = l.nextNode();
638
+ for (; c && r.length < t.maxFindings; ) {
639
+ const A = c.data || "";
640
+ if (A.trim() && !he(c, t)) {
641
+ const P = et(A, t.detectors, t.maxFindings - r.length);
642
+ for (let K = 0; K < P.length && !(r.length >= t.maxFindings); K += 1) {
643
+ const y = P[K], ye = `${y.type}:${y.value.toLowerCase()}`, ke = (a.get(ye) || 0) + 1;
644
+ a.set(ye, ke), r.push({
645
+ id: Je(y.type),
646
+ type: y.type,
647
+ severity: y.severity,
648
+ match: y.value,
649
+ masked: Ce(y.value, y.type, t),
650
+ occurrence: ke,
651
+ excerpt: tt(A, y.start, y.end),
652
+ suggestion: "Review and redact this value before external sharing."
653
+ });
654
+ }
655
+ }
656
+ c = l.nextNode();
657
+ }
658
+ if (Q.get(e) !== o)
659
+ return I.get(e) || [];
660
+ const d = ((p = E.get(e)) == null ? void 0 : p.redactedCount) || 0, s = nt(r, d);
661
+ return de.set(e, i), I.set(e, r), E.set(e, s), B(e), e.dispatchEvent(
662
+ new CustomEvent("editora:pii-scan", {
663
+ bubbles: !0,
664
+ detail: {
665
+ findings: r,
666
+ stats: s
667
+ }
668
+ })
669
+ ), r;
670
+ }
671
+ function ct(e, t) {
672
+ let n = e, i = 0;
673
+ return t.detectors.filter((r) => r.enabled).forEach((r) => {
674
+ const a = be(r.pattern);
675
+ n = n.replace(a, (l) => r.validator && !r.validator(l) ? l : (i += 1, Re(l, r.type, t)));
676
+ }), { nextValue: n, count: i };
677
+ }
678
+ async function _e(e, t, n) {
679
+ var d;
680
+ if (U(e)) {
681
+ const s = m.get(e);
682
+ return s && oe(s, n.labels.readonlyRedactionText), !1;
683
+ }
684
+ const i = Pe(e, t);
685
+ if (!i) return !1;
686
+ const o = De(e, i, n);
687
+ if (!o) return !1;
688
+ const r = e.innerHTML, a = Re(i.match, i.type, n);
689
+ if (o.startContainer === o.endContainer && o.startContainer.nodeType === Node.TEXT_NODE) {
690
+ const s = o.startContainer, p = s.data, A = o.startOffset, P = o.endOffset;
691
+ s.data = `${p.slice(0, A)}${a}${p.slice(P)}`;
692
+ } else
693
+ o.deleteContents(), o.insertNode(document.createTextNode(a));
694
+ Ae(e), Se(e, r);
695
+ const l = ((d = E.get(e)) == null ? void 0 : d.redactedCount) || 0;
696
+ await h(e, n, !0);
697
+ const c = E.get(e);
698
+ return c && (c.redactedCount = l + 1, B(e)), Me(e, 1), !0;
699
+ }
700
+ async function xe(e, t) {
701
+ var d;
702
+ if (U(e)) {
703
+ const s = m.get(e);
704
+ return s && oe(s, t.labels.readonlyRedactionText), 0;
705
+ }
706
+ (I.get(e) || []).length === 0 && await h(e, t, !0);
707
+ const i = e.innerHTML;
708
+ let o = 0;
709
+ const r = document.createTreeWalker(e, pe, null);
710
+ let a = r.nextNode();
711
+ for (; a; ) {
712
+ if (he(a, t)) {
713
+ a = r.nextNode();
714
+ continue;
715
+ }
716
+ const s = a.data || "";
717
+ if (!s) {
718
+ a = r.nextNode();
719
+ continue;
720
+ }
721
+ const p = ct(s, t);
722
+ p.count > 0 && p.nextValue !== s && (a.data = p.nextValue, o += p.count), a = r.nextNode();
723
+ }
724
+ if (o === 0) return 0;
725
+ Ae(e), Se(e, i);
726
+ const l = ((d = E.get(e)) == null ? void 0 : d.redactedCount) || 0;
727
+ await h(e, t, !0);
728
+ const c = E.get(e);
729
+ return c && (c.redactedCount = l + o, B(e)), Me(e, o), o;
730
+ }
731
+ function Ne(e) {
732
+ const t = f.get(e) || M;
733
+ if (!t || !H(e, t) || U(e)) return;
734
+ me(e);
735
+ const n = window.setTimeout(() => {
736
+ j.delete(n), te.delete(e), h(e, t, !1);
737
+ }, t.debounceMs);
738
+ j.add(n), te.set(e, n);
739
+ }
740
+ function st(e) {
741
+ const t = e.key.toLowerCase();
742
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "i";
743
+ }
744
+ function dt(e) {
745
+ const t = e.key.toLowerCase();
746
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "u";
747
+ }
748
+ function ut(e) {
749
+ const t = e.key.toLowerCase();
750
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "m";
751
+ }
752
+ function ft(e) {
753
+ const t = e.key.toLowerCase();
754
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "y";
755
+ }
756
+ function pt(e) {
757
+ var i;
758
+ const t = re(e.target);
759
+ if (t) {
760
+ const o = t.closest(x);
761
+ if (o) return o;
762
+ const r = t.closest(ae);
763
+ if (r) {
764
+ const l = z(r);
765
+ if (l) return l;
766
+ }
767
+ const a = t.closest(`.${u}`);
768
+ if (a) {
769
+ const l = Array.from(m.entries()).find(([, c]) => c === a);
770
+ if (l) return l[0];
771
+ }
772
+ }
773
+ const n = window.getSelection();
774
+ if (n && n.rangeCount > 0) {
775
+ const o = (i = re(n.getRangeAt(0).startContainer)) == null ? void 0 : i.closest(
776
+ x
777
+ );
778
+ if (o) return o;
779
+ }
780
+ return null;
781
+ }
782
+ function bt() {
783
+ if (typeof document == "undefined" || document.getElementById(Ee)) return;
784
+ const e = document.createElement("style");
785
+ e.id = Ee, e.textContent = `
786
+ .rte-toolbar-group-items.${k},
787
+ .editora-toolbar-group-items.${k},
788
+ .rte-toolbar-group-items.${v},
789
+ .editora-toolbar-group-items.${v} {
790
+ display: flex;
791
+ border: 1px solid #ccc;
792
+ border-radius: 3px;
793
+ background: #fff;
794
+ }
795
+
796
+ .rte-toolbar-group-items.${k} .rte-toolbar-button,
797
+ .editora-toolbar-group-items.${k} .editora-toolbar-button,
798
+ .rte-toolbar-group-items.${v} .rte-toolbar-button,
799
+ .editora-toolbar-group-items.${v} .editora-toolbar-button {
800
+ border: none;
801
+ border-radius: 0;
802
+ border-right: 1px solid #ccc;
803
+ }
804
+
805
+ .rte-toolbar-group-items.${k} .rte-toolbar-item:last-child .rte-toolbar-button,
806
+ .editora-toolbar-group-items.${k} .editora-toolbar-item:last-child .editora-toolbar-button,
807
+ .rte-toolbar-group-items.${v} .rte-toolbar-item:last-child .rte-toolbar-button,
808
+ .editora-toolbar-group-items.${v} .editora-toolbar-item:last-child .editora-toolbar-button {
809
+ border-right: none;
810
+ }
811
+
812
+ .rte-toolbar-button[data-command="togglePIIRealtime"].active,
813
+ .editora-toolbar-button[data-command="togglePIIRealtime"].active {
814
+ background-color: #ccc;
815
+ }
816
+
817
+ ${$} .rte-toolbar-group-items.${k},
818
+ ${$} .editora-toolbar-group-items.${k},
819
+ ${$} .rte-toolbar-group-items.${v},
820
+ ${$} .editora-toolbar-group-items.${v},
821
+ .${u}.rte-pii-redaction-theme-dark {
822
+ border-color: #566275;
823
+ }
824
+ ${$} .rte-toolbar-group-items.${k} .rte-toolbar-button svg,
825
+ ${$} .editora-toolbar-group-items.${k} .editora-toolbar-button svg,
826
+ ${$} .rte-toolbar-group-items.${v} .rte-toolbar-button svg,
827
+ ${$} .editora-toolbar-group-items.${v} .editora-toolbar-button svg
828
+ {
829
+ fill: none;
830
+ }
831
+ ${$} .rte-toolbar-group-items.${k} .rte-toolbar-button,
832
+ ${$} .editora-toolbar-group-items.${k} .editora-toolbar-button
833
+ {
834
+ border-color: #566275;
835
+ }
836
+ .${u} {
837
+ position: fixed;
838
+ z-index: 12000;
839
+ display: none;
840
+ width: min(390px, calc(100vw - 20px));
841
+ max-height: calc(100vh - 20px);
842
+ border: 1px solid #d1d5db;
843
+ border-radius: 14px;
844
+ background: #ffffff;
845
+ color: #111827;
846
+ box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
847
+ overflow: hidden;
848
+ }
849
+
850
+ .${u}.show {
851
+ display: flex;
852
+ flex-direction: column;
853
+ }
854
+
855
+ .${u}.rte-pii-redaction-theme-dark {
856
+ border-color: #334155;
857
+ background: #0f172a;
858
+ color: #e2e8f0;
859
+ box-shadow: 0 20px 46px rgba(2, 6, 23, 0.68);
860
+ }
861
+
862
+ .rte-pii-redaction-header {
863
+ display: flex;
864
+ align-items: center;
865
+ justify-content: space-between;
866
+ gap: 8px;
867
+ padding: 12px 14px;
868
+ border-bottom: 1px solid #e5e7eb;
869
+ background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
870
+ }
871
+
872
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-header {
873
+ border-color: #1e293b;
874
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
875
+ }
876
+
877
+ .rte-pii-redaction-title {
878
+ margin: 0;
879
+ font-size: 15px;
880
+ line-height: 1.2;
881
+ font-weight: 700;
882
+ }
883
+
884
+ .rte-pii-redaction-icon-btn {
885
+ width: 34px;
886
+ height: 34px;
887
+ border: 1px solid #cbd5e1;
888
+ border-radius: 6px;
889
+ background: #ffffff;
890
+ color: #0f172a;
891
+ font-size: 16px;
892
+ line-height: 1;
893
+ font-weight: 600;
894
+ padding: 0;
895
+ display: inline-flex;
896
+ align-items: center;
897
+ justify-content: center;
898
+ cursor: pointer;
899
+ }
900
+
901
+ .rte-pii-redaction-icon-btn:hover,
902
+ .rte-pii-redaction-icon-btn:focus-visible {
903
+ outline: none;
904
+ border-color: #3b82f6;
905
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
906
+ }
907
+
908
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-icon-btn {
909
+ background: #0f172a;
910
+ border-color: #475569;
911
+ color: #e2e8f0;
912
+ }
913
+
914
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-icon-btn:hover,
915
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-icon-btn:focus-visible {
916
+ border-color: #60a5fa;
917
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
918
+ }
919
+
920
+ .rte-pii-redaction-body {
921
+ display: flex;
922
+ flex-direction: column;
923
+ gap: 10px;
924
+ padding: 12px;
925
+ overflow: auto;
926
+ }
927
+
928
+ .rte-pii-redaction-topline {
929
+ display: flex;
930
+ align-items: center;
931
+ justify-content: space-between;
932
+ gap: 8px;
933
+ }
934
+
935
+ .rte-pii-redaction-summary {
936
+ margin: 0;
937
+ font-size: 12px;
938
+ line-height: 1.35;
939
+ color: #475569;
940
+ flex: 1;
941
+ }
942
+
943
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-summary {
944
+ color: #94a3b8;
945
+ }
946
+
947
+ .rte-pii-redaction-count {
948
+ min-width: 32px;
949
+ height: 32px;
950
+ border-radius: 999px;
951
+ display: inline-flex;
952
+ align-items: center;
953
+ justify-content: center;
954
+ font-weight: 700;
955
+ font-size: 13px;
956
+ border: 1px solid #cbd5e1;
957
+ background: #f8fafc;
958
+ }
959
+
960
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-count {
961
+ border-color: #334155;
962
+ background: #111827;
963
+ color: #cbd5e1;
964
+ }
965
+
966
+ .rte-pii-redaction-controls {
967
+ display: flex;
968
+ gap: 8px;
969
+ flex-wrap: wrap;
970
+ }
971
+
972
+ .rte-pii-redaction-btn {
973
+ border: 1px solid #cbd5e1;
974
+ border-radius: 8px;
975
+ height: 34px;
976
+ padding: 0 10px;
977
+ background: #ffffff;
978
+ color: inherit;
979
+ font-size: 12px;
980
+ font-weight: 600;
981
+ cursor: pointer;
982
+ }
983
+
984
+ .rte-pii-redaction-btn:hover,
985
+ .rte-pii-redaction-btn:focus-visible {
986
+ border-color: #94a3b8;
987
+ background: #f8fafc;
988
+ outline: none;
989
+ }
990
+
991
+ .rte-pii-redaction-btn:disabled {
992
+ opacity: 0.56;
993
+ cursor: not-allowed;
994
+ }
995
+
996
+ .rte-pii-redaction-btn-primary {
997
+ border-color: #0284c7;
998
+ background: #0ea5e9;
999
+ color: #f8fafc;
1000
+ }
1001
+
1002
+ .rte-pii-redaction-btn-primary:hover,
1003
+ .rte-pii-redaction-btn-primary:focus-visible {
1004
+ border-color: #0369a1;
1005
+ background: #0284c7;
1006
+ color: #ffffff;
1007
+ }
1008
+
1009
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-btn {
1010
+ border-color: #334155;
1011
+ background: #111827;
1012
+ color: #e2e8f0;
1013
+ }
1014
+
1015
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-btn:hover,
1016
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-btn:focus-visible {
1017
+ border-color: #475569;
1018
+ background: #1e293b;
1019
+ }
1020
+
1021
+ .rte-pii-redaction-list {
1022
+ list-style: none;
1023
+ margin: 0;
1024
+ padding: 0;
1025
+ display: flex;
1026
+ flex-direction: column;
1027
+ gap: 8px;
1028
+ max-height: min(55vh, 420px);
1029
+ overflow: auto;
1030
+ }
1031
+
1032
+ .rte-pii-redaction-item {
1033
+ border: 1px solid #e2e8f0;
1034
+ border-radius: 10px;
1035
+ padding: 8px;
1036
+ background: #ffffff;
1037
+ display: grid;
1038
+ gap: 6px;
1039
+ }
1040
+
1041
+ .rte-pii-redaction-item-high {
1042
+ border-color: #fca5a5;
1043
+ background: #fef2f2;
1044
+ }
1045
+
1046
+ .rte-pii-redaction-item-medium {
1047
+ border-color: #fcd34d;
1048
+ background: #fffbeb;
1049
+ }
1050
+
1051
+ .rte-pii-redaction-item-low {
1052
+ border-color: #93c5fd;
1053
+ background: #eff6ff;
1054
+ }
1055
+
1056
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item {
1057
+ border-color: #334155;
1058
+ background: #0b1220;
1059
+ }
1060
+
1061
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item-high {
1062
+ border-color: #7f1d1d;
1063
+ background: #2b0b11;
1064
+ }
1065
+
1066
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item-medium {
1067
+ border-color: #78350f;
1068
+ background: #2b1907;
1069
+ }
1070
+
1071
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item-low {
1072
+ border-color: #1d4ed8;
1073
+ background: #0a162f;
1074
+ }
1075
+
1076
+ .rte-pii-redaction-item-btn {
1077
+ border: none;
1078
+ background: transparent;
1079
+ width: 100%;
1080
+ display: flex;
1081
+ align-items: center;
1082
+ gap: 8px;
1083
+ text-align: left;
1084
+ padding: 0;
1085
+ color: inherit;
1086
+ cursor: pointer;
1087
+ }
1088
+
1089
+ .rte-pii-redaction-item-btn:focus-visible {
1090
+ outline: 2px solid #0284c7;
1091
+ outline-offset: 3px;
1092
+ border-radius: 6px;
1093
+ }
1094
+
1095
+ .rte-pii-redaction-badge {
1096
+ border-radius: 999px;
1097
+ border: 1px solid currentColor;
1098
+ padding: 1px 8px;
1099
+ font-size: 10px;
1100
+ font-weight: 700;
1101
+ line-height: 1.3;
1102
+ text-transform: uppercase;
1103
+ opacity: 0.86;
1104
+ }
1105
+
1106
+ .rte-pii-redaction-type {
1107
+ font-size: 12px;
1108
+ font-weight: 700;
1109
+ letter-spacing: 0.03em;
1110
+ }
1111
+
1112
+ .rte-pii-redaction-line,
1113
+ .rte-pii-redaction-help {
1114
+ margin: 0;
1115
+ font-size: 12px;
1116
+ line-height: 1.35;
1117
+ color: #334155;
1118
+ word-break: break-word;
1119
+ }
1120
+
1121
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-line,
1122
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-help {
1123
+ color: #94a3b8;
1124
+ }
1125
+
1126
+ .rte-pii-redaction-item-actions {
1127
+ display: flex;
1128
+ justify-content: flex-end;
1129
+ }
1130
+
1131
+ .rte-pii-redaction-empty {
1132
+ border: 1px dashed #cbd5e1;
1133
+ border-radius: 10px;
1134
+ padding: 10px;
1135
+ font-size: 13px;
1136
+ color: #475569;
1137
+ background: #f8fafc;
1138
+ }
1139
+
1140
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-empty {
1141
+ border-color: #334155;
1142
+ background: #0b1220;
1143
+ color: #94a3b8;
1144
+ }
1145
+
1146
+ .rte-pii-redaction-shortcut {
1147
+ margin: 2px 0 0;
1148
+ font-size: 11px;
1149
+ color: #64748b;
1150
+ }
1151
+
1152
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-shortcut {
1153
+ color: #94a3b8;
1154
+ }
1155
+
1156
+ .rte-pii-redaction-live {
1157
+ position: absolute;
1158
+ width: 1px;
1159
+ height: 1px;
1160
+ margin: -1px;
1161
+ padding: 0;
1162
+ overflow: hidden;
1163
+ clip: rect(0 0 0 0);
1164
+ border: 0;
1165
+ }
1166
+
1167
+ @media (max-width: 768px) {
1168
+ .${u} {
1169
+ left: 10px !important;
1170
+ right: 10px;
1171
+ top: 10px !important;
1172
+ width: auto !important;
1173
+ max-height: calc(100vh - 20px);
1174
+ }
1175
+
1176
+ .rte-pii-redaction-list {
1177
+ max-height: 45vh;
1178
+ }
1179
+ }
1180
+ `, document.head.appendChild(e);
1181
+ }
1182
+ function gt(e) {
1183
+ M = e, L || (L = (t) => {
1184
+ q();
1185
+ const n = t.target, i = n == null ? void 0 : n.closest(x);
1186
+ if (!i) return;
1187
+ g = i;
1188
+ const o = f.get(i) || e;
1189
+ w(i, o), f.set(i, o), C(i, "togglePIIRedactionPanel", ie(i)), C(i, "togglePIIRealtime", H(i, o));
1190
+ const r = m.get(i);
1191
+ r && (ne(r, i), fe(i, r), F(i, r, o));
1192
+ }, document.addEventListener("focusin", L, !0)), D || (D = (t) => {
1193
+ const n = t.target, i = n == null ? void 0 : n.closest(x);
1194
+ i && (g = i, Ne(i));
1195
+ }, document.addEventListener("input", D, !0)), _ || (_ = (t) => {
1196
+ if (t.defaultPrevented) return;
1197
+ const n = t.target;
1198
+ if (n != null && n.closest(`.${u} input, .${u} textarea, .${u} select`)) return;
1199
+ const i = pt(t);
1200
+ if (!i) return;
1201
+ const o = f.get(i) || M || e;
1202
+ if (w(i, o), f.set(i, o), g = i, t.key === "Escape" && ie(i)) {
1203
+ t.preventDefault(), Z(i, !0);
1204
+ return;
1205
+ }
1206
+ if (st(t)) {
1207
+ t.preventDefault(), t.stopPropagation(), Le(i);
1208
+ return;
1209
+ }
1210
+ if (dt(t)) {
1211
+ t.preventDefault(), t.stopPropagation(), h(i, o, !0), O(i);
1212
+ return;
1213
+ }
1214
+ if (ut(t)) {
1215
+ t.preventDefault(), t.stopPropagation(), U(i) || (xe(i, o), O(i));
1216
+ return;
1217
+ }
1218
+ if (ft(t)) {
1219
+ t.preventDefault(), t.stopPropagation();
1220
+ const r = !H(i, o);
1221
+ S.set(i, r);
1222
+ const a = m.get(i);
1223
+ a && F(i, a, o), C(i, "togglePIIRealtime", r), r && h(i, o, !0);
1224
+ }
1225
+ }, document.addEventListener("keydown", _, !0)), R || (R = () => {
1226
+ q(), m.forEach((t, n) => {
1227
+ !n.isConnected || !t.isConnected || (ne(t, n), fe(n, t));
1228
+ });
1229
+ }, window.addEventListener("scroll", R, !0), window.addEventListener("resize", R)), !N && typeof MutationObserver != "undefined" && document.body && (N = new MutationObserver((t) => {
1230
+ Ge(t) && q();
1231
+ }), N.observe(document.body, {
1232
+ childList: !0,
1233
+ subtree: !0
1234
+ }));
1235
+ }
1236
+ function mt() {
1237
+ L && (document.removeEventListener("focusin", L, !0), L = null), D && (document.removeEventListener("input", D, !0), D = null), _ && (document.removeEventListener("keydown", _, !0), _ = null), R && (window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R), R = null), N && (N.disconnect(), N = null), m.forEach((e) => e.remove()), m.clear(), W.forEach((e) => me(e)), W.clear(), M = null, g = null;
1238
+ }
1239
+ const ht = (e = {}) => {
1240
+ const t = ee(e), n = /* @__PURE__ */ new Set();
1241
+ return bt(), {
1242
+ name: "piiRedaction",
1243
+ toolbar: [
1244
+ {
1245
+ id: "piiRedactionGroup",
1246
+ label: "PII Redaction",
1247
+ type: "group",
1248
+ command: "piiRedaction",
1249
+ items: [
1250
+ {
1251
+ id: "piiRedaction",
1252
+ label: "PII Redaction",
1253
+ command: "togglePIIRedactionPanel",
1254
+ shortcut: "Mod-Alt-Shift-i",
1255
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'
1256
+ },
1257
+ {
1258
+ id: "piiScan",
1259
+ label: "Scan PII",
1260
+ command: "runPIIScan",
1261
+ shortcut: "Mod-Alt-Shift-u",
1262
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'
1263
+ },
1264
+ {
1265
+ id: "piiRedactAll",
1266
+ label: "Redact All PII",
1267
+ command: "redactAllPII",
1268
+ shortcut: "Mod-Alt-Shift-m",
1269
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'
1270
+ },
1271
+ {
1272
+ id: "piiRealtime",
1273
+ label: "Toggle Realtime PII Scan",
1274
+ command: "togglePIIRealtime",
1275
+ shortcut: "Mod-Alt-Shift-y",
1276
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'
1277
+ }
1278
+ ]
1279
+ }
1280
+ ],
1281
+ commands: {
1282
+ piiRedaction: (i, o) => {
1283
+ const r = T(o);
1284
+ if (!r) return !1;
1285
+ const a = f.get(r) || t;
1286
+ return w(r, a), f.set(r, a), g = r, O(r), h(r, a, !1), !0;
1287
+ },
1288
+ togglePIIRedactionPanel: (i, o) => {
1289
+ const r = T(o);
1290
+ if (!r) return !1;
1291
+ const a = f.get(r) || t;
1292
+ w(r, a), f.set(r, a), g = r;
1293
+ const l = Le(r, typeof i == "boolean" ? i : void 0);
1294
+ return ie(r) && h(r, a, !1), l;
1295
+ },
1296
+ runPIIScan: async (i, o) => {
1297
+ const r = T(o);
1298
+ if (!r) return !1;
1299
+ const a = f.get(r) || t;
1300
+ return w(r, a), f.set(r, a), g = r, await h(r, a, !0), O(r), !0;
1301
+ },
1302
+ redactAllPII: async (i, o) => {
1303
+ const r = T(o);
1304
+ if (!r) return !1;
1305
+ const a = f.get(r) || t;
1306
+ w(r, a), f.set(r, a), g = r;
1307
+ const l = await xe(r, a);
1308
+ return l > 0 && O(r), l > 0;
1309
+ },
1310
+ redactPIIFinding: async (i, o) => {
1311
+ const r = T(o);
1312
+ if (!r || typeof i != "string" || !i) return !1;
1313
+ const a = f.get(r) || t;
1314
+ return w(r, a), f.set(r, a), g = r, _e(r, i, a);
1315
+ },
1316
+ togglePIIRealtime: (i, o) => {
1317
+ const r = T(o);
1318
+ if (!r) return !1;
1319
+ const a = f.get(r) || t;
1320
+ w(r, a), f.set(r, a);
1321
+ const l = typeof i == "boolean" ? i : !H(r, a);
1322
+ S.set(r, l);
1323
+ const c = m.get(r);
1324
+ return c && F(r, c, a), C(r, "togglePIIRealtime", l), l && h(r, a, !0), !0;
1325
+ },
1326
+ getPIIRedactionFindings: (i, o) => {
1327
+ const r = T(o);
1328
+ if (!r) return !1;
1329
+ const a = I.get(r) || [], l = E.get(r) || le(0), c = a.map((s) => ({ ...s })), d = {
1330
+ ...l,
1331
+ byType: { ...l.byType }
1332
+ };
1333
+ if (typeof i == "function")
1334
+ try {
1335
+ i(c, d);
1336
+ } catch (s) {
1337
+ }
1338
+ return r.__piiRedactionFindings = c, r.dispatchEvent(
1339
+ new CustomEvent("editora:pii-findings", {
1340
+ bubbles: !0,
1341
+ detail: { findings: c, stats: d }
1342
+ })
1343
+ ), !0;
1344
+ },
1345
+ setPIIRedactionOptions: (i, o) => {
1346
+ const r = T(o);
1347
+ if (!r || !i || typeof i != "object") return !1;
1348
+ const a = f.get(r) || t, l = ee({
1349
+ ...ce(a),
1350
+ ...i,
1351
+ labels: {
1352
+ ...a.labels,
1353
+ ...i.labels || {}
1354
+ },
1355
+ detectors: {
1356
+ ...ce(a).detectors || {},
1357
+ ...i.detectors || {}
1358
+ },
1359
+ normalizeText: i.normalizeText || a.normalizeText
1360
+ });
1361
+ f.set(r, l), typeof i.enableRealtime == "boolean" && S.set(r, i.enableRealtime);
1362
+ const c = m.get(r);
1363
+ return c && (rt(c, l), B(r), F(r, c, l)), h(r, l, !0), !0;
1364
+ }
1365
+ },
1366
+ keymap: {
1367
+ "Mod-Alt-Shift-i": "togglePIIRedactionPanel",
1368
+ "Mod-Alt-Shift-I": "togglePIIRedactionPanel",
1369
+ "Mod-Alt-Shift-u": "runPIIScan",
1370
+ "Mod-Alt-Shift-U": "runPIIScan",
1371
+ "Mod-Alt-Shift-m": "redactAllPII",
1372
+ "Mod-Alt-Shift-M": "redactAllPII",
1373
+ "Mod-Alt-Shift-y": "togglePIIRealtime",
1374
+ "Mod-Alt-Shift-Y": "togglePIIRealtime"
1375
+ },
1376
+ init: function(o) {
1377
+ G += 1;
1378
+ const r = this && typeof this.__pluginConfig == "object" ? ee({ ...ce(t), ...this.__pluginConfig }) : t;
1379
+ gt(r);
1380
+ const a = T(
1381
+ o != null && o.editorElement ? { editorElement: o.editorElement } : void 0,
1382
+ !1
1383
+ );
1384
+ a && (g = a, n.add(a), w(a, r), f.set(a, r), C(a, "togglePIIRedactionPanel", !1), C(a, "togglePIIRealtime", r.enableRealtime), r.enableRealtime && Ne(a));
1385
+ },
1386
+ destroy: () => {
1387
+ n.forEach((i) => Te(i)), n.clear(), G = Math.max(0, G - 1), !(G > 0) && (j.forEach((i) => {
1388
+ window.clearTimeout(i);
1389
+ }), j.clear(), mt());
1390
+ }
1391
+ };
1392
+ };
1393
+ export {
1394
+ ht as PIIRedactionPlugin
1395
+ };
1396
+ //# sourceMappingURL=PIIRedactionPlugin.native-DcsjmtV1.mjs.map