@editora/plugins 1.0.8 → 1.0.9

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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/dist/approval-workflow.cjs.js +447 -0
  4. package/dist/approval-workflow.esm.js +1070 -0
  5. package/dist/blocks-library.cjs.js +442 -0
  6. package/dist/blocks-library.esm.js +1317 -0
  7. package/dist/citations.cjs.js +548 -0
  8. package/dist/citations.esm.js +1457 -0
  9. package/dist/conditional-content.cjs.js +626 -0
  10. package/dist/conditional-content.esm.js +1360 -0
  11. package/dist/content-rules.cjs.js +408 -0
  12. package/dist/content-rules.esm.js +1093 -0
  13. package/dist/data-binding.cjs.js +321 -0
  14. package/dist/data-binding.esm.js +913 -0
  15. package/dist/doc-schema.cjs.js +398 -0
  16. package/dist/doc-schema.esm.js +1310 -0
  17. package/dist/enterprise.cjs.js +1 -0
  18. package/dist/enterprise.esm.js +56 -0
  19. package/dist/index.cjs.js +1 -1
  20. package/dist/index.esm.js +109 -81
  21. package/dist/mentions.cjs.js +105 -0
  22. package/dist/mentions.esm.js +726 -0
  23. package/dist/page-break.cjs.js +2 -2
  24. package/dist/page-break.esm.js +32 -32
  25. package/dist/pii-redaction.cjs.js +436 -0
  26. package/dist/pii-redaction.esm.js +1377 -0
  27. package/dist/preview.cjs.js +3 -3
  28. package/dist/preview.esm.js +29 -29
  29. package/dist/slash-commands.cjs.js +90 -0
  30. package/dist/slash-commands.esm.js +752 -0
  31. package/dist/smart-paste.cjs.js +398 -0
  32. package/dist/smart-paste.esm.js +1388 -0
  33. package/dist/track-changes.cjs.js +77 -0
  34. package/dist/track-changes.esm.js +755 -0
  35. package/dist/translation-workflow.cjs.js +626 -0
  36. package/dist/translation-workflow.esm.js +1718 -0
  37. package/dist/version-diff.cjs.js +362 -0
  38. package/dist/version-diff.esm.js +768 -0
  39. package/index.d.ts +798 -0
  40. package/package.json +104 -5
@@ -0,0 +1,1360 @@
1
+ const L = ".rte-content, .editora-content", H = '.rte-conditional-block[data-conditional-content="true"]', b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', f = ':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)', p = ":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)", h = ":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)", Ce = "rte-conditional-content-styles", c = "rte-conditional-dialog-overlay", u = "rte-conditional-floating-toolbar", w = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map();
2
+ let le = null, se = 0, G = null, U = null, Y = null, J = null, X = null, Q = null, N = null, g = null, ee = null;
3
+ const Pe = {
4
+ dialogTitleInsert: "Insert Conditional Content",
5
+ dialogTitleEdit: "Edit Conditional Content",
6
+ conditionLabel: "Condition",
7
+ conditionPlaceholder: 'user.role == "admin"',
8
+ audienceLabel: "Audience (comma separated)",
9
+ audiencePlaceholder: "all",
10
+ localeLabel: "Locale (comma separated)",
11
+ localePlaceholder: "all",
12
+ elseLabel: "Enable Else Block",
13
+ saveText: "Save",
14
+ cancelText: "Cancel",
15
+ blockIfLabel: "IF",
16
+ blockElseLabel: "ELSE",
17
+ allAudiencesText: "all audiences",
18
+ allLocalesText: "all locales"
19
+ };
20
+ function y(e) {
21
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
22
+ }
23
+ function O(e) {
24
+ return e ? e.split(",").map((t) => t.trim()).filter(Boolean) : [];
25
+ }
26
+ function Le(e) {
27
+ return !e || e.length === 0 ? "" : e.join(", ");
28
+ }
29
+ function te(e) {
30
+ return e ? e.map((t) => t.trim()).filter(Boolean) : [];
31
+ }
32
+ function Re(e) {
33
+ return {
34
+ ...Pe,
35
+ ...e || {}
36
+ };
37
+ }
38
+ function k(e) {
39
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
40
+ }
41
+ function ce(e) {
42
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
43
+ }
44
+ function ue(e) {
45
+ if (!e) return !1;
46
+ const t = e.getAttribute("data-theme") || e.getAttribute("theme");
47
+ return t && t.toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark");
48
+ }
49
+ function qe(e) {
50
+ const t = ce(e);
51
+ if (ue(t)) return !0;
52
+ const o = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
53
+ return ue(o) ? !0 : ue(document.documentElement) || ue(document.body);
54
+ }
55
+ function fe(e) {
56
+ if (!e) return !1;
57
+ const t = e.getAttribute("data-theme") || e.getAttribute("theme");
58
+ return t && t.toLowerCase() === "acme" ? !0 : e.classList.contains("editora-theme-acme") || e.classList.contains("rte-theme-acme");
59
+ }
60
+ function Ke(e) {
61
+ const t = ce(e);
62
+ if (fe(t)) return !0;
63
+ const o = t.closest("[data-theme], [theme], .editora-theme-acme, .rte-theme-acme");
64
+ return fe(o) ? !0 : fe(document.documentElement) || fe(document.body);
65
+ }
66
+ function Ie(e) {
67
+ return qe(e) ? "dark" : Ke(e) ? "acme" : "light";
68
+ }
69
+ function he(e, t) {
70
+ const o = Ie(t);
71
+ e.classList.remove("rte-conditional-theme-dark", "rte-conditional-theme-acme"), o === "dark" ? e.classList.add("rte-conditional-theme-dark") : o === "acme" && e.classList.add("rte-conditional-theme-acme");
72
+ }
73
+ function A(e, t = !0) {
74
+ if (e?.contentElement instanceof HTMLElement) return e.contentElement;
75
+ if (e?.editorElement instanceof HTMLElement) {
76
+ const n = e.editorElement;
77
+ if (n.matches(L)) return n;
78
+ const a = n.querySelector(L);
79
+ if (a instanceof HTMLElement) return a;
80
+ }
81
+ const o = window.getSelection();
82
+ if (o && o.rangeCount > 0) {
83
+ const n = o.getRangeAt(0).startContainer, r = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(L);
84
+ if (r) return r;
85
+ }
86
+ const i = document.activeElement;
87
+ if (i) {
88
+ if (i.matches(L)) return i;
89
+ const n = i.closest(L);
90
+ if (n) return n;
91
+ }
92
+ return g && g.isConnected ? g : t ? document.querySelector(L) : null;
93
+ }
94
+ function ke(e) {
95
+ const t = window.getSelection();
96
+ if (!t || t.rangeCount === 0) return null;
97
+ const o = t.getRangeAt(0);
98
+ return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
99
+ }
100
+ function xe(e, t) {
101
+ const o = window.getSelection();
102
+ o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
103
+ }
104
+ function Se(e) {
105
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
106
+ }
107
+ function Te(e, t) {
108
+ if (t === e.innerHTML) return;
109
+ const o = window.execEditorCommand || window.executeEditorCommand;
110
+ if (typeof o == "function")
111
+ try {
112
+ o("recordDomTransaction", e, t, e.innerHTML);
113
+ } catch {
114
+ }
115
+ }
116
+ function pe(e, t) {
117
+ const o = document.createRange();
118
+ o.selectNodeContents(t), o.collapse(!1), xe(e, o);
119
+ }
120
+ function ye(e, t) {
121
+ if (t)
122
+ return t.split(".").filter(Boolean).reduce((o, i) => {
123
+ if (o != null && typeof o == "object")
124
+ return o[i];
125
+ }, e);
126
+ }
127
+ function _e(e) {
128
+ const t = e.trim();
129
+ if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'"))
130
+ return t.slice(1, -1);
131
+ if (t === "true") return !0;
132
+ if (t === "false") return !1;
133
+ if (t === "null") return null;
134
+ const o = Number(t);
135
+ if (!Number.isNaN(o) && t !== "") return o;
136
+ if (t.startsWith("[") && t.endsWith("]") || t.startsWith("{") && t.endsWith("}"))
137
+ try {
138
+ return JSON.parse(t);
139
+ } catch {
140
+ return t;
141
+ }
142
+ return t;
143
+ }
144
+ function ze(e, t) {
145
+ const o = e.trim();
146
+ if (!o) return !0;
147
+ if (o.startsWith("!")) {
148
+ const E = o.slice(1).trim();
149
+ return !ye(t, E);
150
+ }
151
+ const i = o.match(/^([a-zA-Z_$][\w.$]*)\s*(==|!=|>=|<=|>|<|in|contains|~=)\s*(.+)$/);
152
+ if (!i)
153
+ return !!ye(t, o);
154
+ const [, n, a, r] = i, l = ye(t, n), d = _e(r);
155
+ switch (a) {
156
+ case "==":
157
+ return l == d;
158
+ case "!=":
159
+ return l != d;
160
+ case ">":
161
+ return Number(l) > Number(d);
162
+ case "<":
163
+ return Number(l) < Number(d);
164
+ case ">=":
165
+ return Number(l) >= Number(d);
166
+ case "<=":
167
+ return Number(l) <= Number(d);
168
+ case "in":
169
+ return Array.isArray(d) ? d.some((E) => E == l) : typeof d == "string" ? d.split(",").map((E) => E.trim()).includes(String(l)) : !1;
170
+ case "contains":
171
+ case "~=":
172
+ return Array.isArray(l) ? l.some((E) => String(E).toLowerCase() === String(d).toLowerCase()) : typeof l == "string" ? l.toLowerCase().includes(String(d).toLowerCase()) : !1;
173
+ default:
174
+ return !1;
175
+ }
176
+ }
177
+ function Fe() {
178
+ if (typeof document > "u" || document.getElementById(Ce)) return;
179
+ const e = document.createElement("style");
180
+ e.id = Ce, e.textContent = `
181
+ .rte-conditional-block {
182
+ border: 1px solid #dbe3ec;
183
+ border-radius: 8px;
184
+ margin: 10px 0;
185
+ background: #f8fafc;
186
+ overflow: hidden;
187
+ }
188
+
189
+ .rte-conditional-header,
190
+ .rte-conditional-else-label {
191
+ display: flex;
192
+ align-items: center;
193
+ gap: 8px;
194
+ background: #eef2f7;
195
+ border-bottom: 1px solid #dbe3ec;
196
+ padding: 8px 10px;
197
+ user-select: none;
198
+ }
199
+
200
+ .rte-conditional-else-label {
201
+ border-top: 1px solid #dbe3ec;
202
+ border-bottom: 1px solid #dbe3ec;
203
+ }
204
+
205
+ .rte-conditional-chip {
206
+ display: inline-flex;
207
+ align-items: center;
208
+ justify-content: center;
209
+ min-width: 34px;
210
+ height: 20px;
211
+ border-radius: 999px;
212
+ border: 1px solid #bfdbfe;
213
+ background: #dbeafe;
214
+ color: #1e3a8a;
215
+ font-size: 11px;
216
+ font-weight: 700;
217
+ letter-spacing: 0.03em;
218
+ text-transform: uppercase;
219
+ padding: 0 7px;
220
+ flex: 0 0 auto;
221
+ }
222
+
223
+ .rte-conditional-chip-else {
224
+ border-color: #fecaca;
225
+ background: #fee2e2;
226
+ color: #991b1b;
227
+ }
228
+
229
+ .rte-conditional-summary {
230
+ font-size: 12px;
231
+ color: #0f172a;
232
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
233
+ overflow: hidden;
234
+ text-overflow: ellipsis;
235
+ white-space: nowrap;
236
+ flex: 1;
237
+ }
238
+
239
+ .rte-conditional-meta {
240
+ font-size: 11px;
241
+ color: #64748b;
242
+ white-space: nowrap;
243
+ flex: 0 0 auto;
244
+ }
245
+
246
+ .rte-conditional-body {
247
+ padding: 10px;
248
+ background: #ffffff;
249
+ min-height: 44px;
250
+ }
251
+
252
+ .rte-conditional-hidden {
253
+ display: none !important;
254
+ }
255
+
256
+ .rte-toolbar-group-items.conditional-content,
257
+ .editora-toolbar-group-items.conditional-content {
258
+ display: flex;
259
+ border: 1px solid #cbd5e1;
260
+ border-radius: 6px;
261
+ background: #ffffff;
262
+ }
263
+
264
+ .rte-toolbar-group-items.conditional-content .rte-toolbar-item,
265
+ .editora-toolbar-group-items.conditional-content .editora-toolbar-item {
266
+ display: flex;
267
+ }
268
+
269
+ .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
270
+ .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
271
+ border: none;
272
+ border-right: 1px solid #cbd5e1;
273
+ border-radius: 0;
274
+ }
275
+
276
+ .rte-toolbar-group-items.conditional-content .rte-toolbar-item:last-child .rte-toolbar-button,
277
+ .editora-toolbar-group-items.conditional-content .editora-toolbar-item:last-child .editora-toolbar-button {
278
+ border-right: none;
279
+ }
280
+
281
+ .rte-toolbar-button[data-command="toggleConditionalPreview"].active,
282
+ .editora-toolbar-button[data-command="toggleConditionalPreview"].active {
283
+ background: #ccc;
284
+ }
285
+
286
+ .rte-conditional-block.rte-conditional-preview {
287
+ border-style: dashed;
288
+ }
289
+
290
+ .rte-conditional-block.rte-conditional-preview .rte-conditional-body[contenteditable="false"] {
291
+ cursor: default;
292
+ }
293
+
294
+ .${c} {
295
+ position: fixed;
296
+ inset: 0;
297
+ background: rgba(15, 23, 42, 0.5);
298
+ z-index: 2147483646;
299
+ display: flex;
300
+ align-items: center;
301
+ justify-content: center;
302
+ padding: 20px;
303
+ }
304
+
305
+ .rte-conditional-dialog {
306
+ width: min(560px, 96vw);
307
+ max-height: min(88vh, 760px);
308
+ border: 1px solid #dbe3ec;
309
+ border-radius: 8px;
310
+ background: #ffffff;
311
+ box-shadow: 0 24px 50px rgba(15, 23, 42, 0.25);
312
+ display: flex;
313
+ flex-direction: column;
314
+ overflow: hidden;
315
+ }
316
+
317
+ .rte-conditional-dialog-header,
318
+ .rte-conditional-dialog-footer {
319
+ padding: 12px 14px;
320
+ border-bottom: 1px solid #e2e8f0;
321
+ background: #f8fafc;
322
+ display: flex;
323
+ align-items: center;
324
+ justify-content: space-between;
325
+ gap: 10px;
326
+ }
327
+
328
+ .rte-conditional-dialog-footer {
329
+ border-top: 1px solid #e2e8f0;
330
+ border-bottom: none;
331
+ justify-content: flex-end;
332
+ }
333
+
334
+ .rte-conditional-dialog-title {
335
+ margin: 0;
336
+ font-size: 16px;
337
+ font-weight: 700;
338
+ color: #0f172a;
339
+ }
340
+
341
+ .rte-conditional-dialog-body {
342
+ padding: 14px;
343
+ overflow: auto;
344
+ display: grid;
345
+ grid-template-columns: 1fr;
346
+ gap: 12px;
347
+ }
348
+
349
+ .rte-conditional-field {
350
+ display: grid;
351
+ gap: 6px;
352
+ }
353
+
354
+ .rte-conditional-field label {
355
+ font-size: 12px;
356
+ font-weight: 600;
357
+ color: #334155;
358
+ }
359
+
360
+ .rte-conditional-field input[type="text"] {
361
+ width: 100%;
362
+ min-height: 36px;
363
+ border: 1px solid #cbd5e1;
364
+ border-radius: 6px;
365
+ padding: 8px 10px;
366
+ font-size: 13px;
367
+ line-height: 1.4;
368
+ box-sizing: border-box;
369
+ color: #0f172a;
370
+ background: #ffffff;
371
+ }
372
+
373
+ .rte-conditional-field input[type="text"]:focus-visible,
374
+ .rte-conditional-btn:focus-visible {
375
+ outline: none;
376
+ border-color: #3b82f6;
377
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
378
+ }
379
+
380
+ .rte-conditional-checkbox {
381
+ display: inline-flex;
382
+ align-items: center;
383
+ gap: 8px;
384
+ font-size: 13px;
385
+ color: #334155;
386
+ min-height: 36px;
387
+ }
388
+
389
+ .rte-conditional-help {
390
+ margin: 0;
391
+ font-size: 12px;
392
+ color: #64748b;
393
+ }
394
+
395
+ .rte-conditional-btn {
396
+ border: 1px solid #cbd5e1;
397
+ border-radius: 6px;
398
+ min-height: 34px;
399
+ padding: 6px 12px;
400
+ background: #ffffff;
401
+ color: #0f172a;
402
+ font-size: 13px;
403
+ cursor: pointer;
404
+ }
405
+
406
+ .rte-conditional-btn-primary {
407
+ border-color: #2563eb;
408
+ background: #2563eb;
409
+ color: #ffffff;
410
+ }
411
+
412
+ .rte-conditional-btn-primary:hover {
413
+ background: #1d4ed8;
414
+ }
415
+
416
+ .${u} {
417
+ position: fixed;
418
+ z-index: 2147483645;
419
+ display: none;
420
+ align-items: center;
421
+ gap: 6px;
422
+ padding: 6px;
423
+ border-radius: 8px;
424
+ border: 1px solid #cbd5e1;
425
+ background: rgba(255, 255, 255, 0.98);
426
+ box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
427
+ backdrop-filter: blur(6px);
428
+ }
429
+
430
+ .${u}.show {
431
+ display: inline-flex;
432
+ }
433
+
434
+ .${u} .rte-conditional-float-btn {
435
+ border: 1px solid #cbd5e1;
436
+ border-radius: 6px;
437
+ min-height: 30px;
438
+ min-width: 30px;
439
+ padding: 0 8px;
440
+ display: inline-flex;
441
+ align-items: center;
442
+ justify-content: center;
443
+ gap: 6px;
444
+ background: #ffffff;
445
+ color: #0f172a;
446
+ cursor: pointer;
447
+ font-size: 12px;
448
+ line-height: 1;
449
+ }
450
+
451
+ .${u} .rte-conditional-float-btn:hover {
452
+ background: #f8fafc;
453
+ }
454
+
455
+ .${u} .rte-conditional-float-btn[data-action="delete"] {
456
+ border-color: #fecaca;
457
+ color: #991b1b;
458
+ background: #fff5f5;
459
+ }
460
+
461
+ .rte-conditional-preview-on ${H} {
462
+ border-width: 2px;
463
+ }
464
+
465
+ .rte-conditional-preview-on ${H} .rte-conditional-header {
466
+ background: #ecfeff;
467
+ border-color: #bae6fd;
468
+ }
469
+
470
+ ${b} .rte-conditional-block,
471
+ ${p} .rte-conditional-block,
472
+ .${c}.rte-conditional-theme-dark .rte-conditional-block {
473
+ background: #111827;
474
+ border-color: #334155;
475
+ }
476
+
477
+ ${b} .rte-conditional-header,
478
+ ${b} .rte-conditional-else-label,
479
+ ${p} .rte-conditional-header,
480
+ ${p} .rte-conditional-else-label,
481
+ .${c}.rte-conditional-theme-dark .rte-conditional-header,
482
+ .${c}.rte-conditional-theme-dark .rte-conditional-else-label {
483
+ background: #0f172a;
484
+ border-color: #334155;
485
+ }
486
+
487
+ ${b} .rte-conditional-summary,
488
+ ${p} .rte-conditional-summary,
489
+ .${c}.rte-conditional-theme-dark .rte-conditional-summary {
490
+ color: #e2e8f0;
491
+ }
492
+
493
+ ${b} .rte-conditional-meta,
494
+ ${p} .rte-conditional-meta,
495
+ .${c}.rte-conditional-theme-dark .rte-conditional-meta {
496
+ color: #94a3b8;
497
+ }
498
+
499
+ ${b} .rte-conditional-chip,
500
+ ${p} .rte-conditional-chip,
501
+ .${c}.rte-conditional-theme-dark .rte-conditional-chip {
502
+ background: #1e3a8a;
503
+ border-color: #3b82f6;
504
+ color: #dbeafe;
505
+ }
506
+
507
+ ${b} .rte-conditional-chip-else,
508
+ ${p} .rte-conditional-chip-else,
509
+ .${c}.rte-conditional-theme-dark .rte-conditional-chip-else {
510
+ background: #7f1d1d;
511
+ border-color: #ef4444;
512
+ color: #fee2e2;
513
+ }
514
+
515
+ ${b} .rte-conditional-body,
516
+ ${p} .rte-conditional-body,
517
+ .${c}.rte-conditional-theme-dark .rte-conditional-body {
518
+ background: #1f2937;
519
+ color: #e2e8f0;
520
+ }
521
+
522
+ ${b} .rte-conditional-dialog,
523
+ ${p} .rte-conditional-dialog,
524
+ .${c}.rte-conditional-theme-dark .rte-conditional-dialog {
525
+ background: #1f2937;
526
+ border-color: #334155;
527
+ }
528
+
529
+ ${b} .rte-conditional-dialog-header,
530
+ ${b} .rte-conditional-dialog-footer,
531
+ ${p} .rte-conditional-dialog-header,
532
+ ${p} .rte-conditional-dialog-footer,
533
+ .${c}.rte-conditional-theme-dark .rte-conditional-dialog-header,
534
+ .${c}.rte-conditional-theme-dark .rte-conditional-dialog-footer {
535
+ background: #111827;
536
+ border-color: #334155;
537
+ }
538
+
539
+ ${b} .rte-conditional-dialog-title,
540
+ ${b} .rte-conditional-field label,
541
+ ${b} .rte-conditional-checkbox,
542
+ ${p} .rte-conditional-dialog-title,
543
+ ${p} .rte-conditional-field label,
544
+ ${p} .rte-conditional-checkbox,
545
+ .${c}.rte-conditional-theme-dark .rte-conditional-dialog-title,
546
+ .${c}.rte-conditional-theme-dark .rte-conditional-field label,
547
+ .${c}.rte-conditional-theme-dark .rte-conditional-checkbox {
548
+ color: #e2e8f0;
549
+ }
550
+
551
+ ${b} .rte-conditional-help,
552
+ ${p} .rte-conditional-help,
553
+ .${c}.rte-conditional-theme-dark .rte-conditional-help {
554
+ color: #94a3b8;
555
+ }
556
+
557
+ ${b} .rte-conditional-field input[type="text"],
558
+ ${b} .rte-conditional-btn,
559
+ ${p} .rte-conditional-field input[type="text"],
560
+ ${p} .rte-conditional-btn,
561
+ .${c}.rte-conditional-theme-dark .rte-conditional-field input[type="text"],
562
+ .${c}.rte-conditional-theme-dark .rte-conditional-btn {
563
+ background: #0f172a;
564
+ border-color: #475569;
565
+ color: #e2e8f0;
566
+ }
567
+
568
+ ${b} .rte-conditional-btn-primary,
569
+ ${p} .rte-conditional-btn-primary,
570
+ .${c}.rte-conditional-theme-dark .rte-conditional-btn-primary {
571
+ border-color: #3b82f6;
572
+ background: #2563eb;
573
+ color: #ffffff;
574
+ }
575
+
576
+ ${b} .rte-toolbar-group-items.conditional-content,
577
+ .${c}.rte-conditional-theme-dark .rte-toolbar-group-items.conditional-content,
578
+ ${p} .rte-toolbar-group-items.conditional-content,
579
+ ${b} .editora-toolbar-group-items.conditional-content {
580
+ border-color: #566275;
581
+ }
582
+
583
+ ${b} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
584
+ ${p} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
585
+ ${b} .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
586
+ border-right-color: #566275;
587
+ }
588
+
589
+ ${b} .${u},
590
+ .${c}.rte-conditional-theme-dark .${u},
591
+ .${u}.rte-conditional-theme-dark {
592
+ background: rgba(17, 24, 39, 0.98);
593
+ border-color: #334155;
594
+ box-shadow: 0 14px 30px rgba(2, 6, 23, 0.5);
595
+ }
596
+
597
+ ${b} .${u} .rte-conditional-float-btn,
598
+ .${c}.rte-conditional-theme-dark .${u} .rte-conditional-float-btn,
599
+ .${u}.rte-conditional-theme-dark .rte-conditional-float-btn {
600
+ background: #0f172a;
601
+ border-color: #475569;
602
+ color: #e2e8f0;
603
+ }
604
+
605
+ ${b} .${u} .rte-conditional-float-btn[data-action="delete"],
606
+ .${c}.rte-conditional-theme-dark .${u} .rte-conditional-float-btn[data-action="delete"],
607
+ .${u}.rte-conditional-theme-dark .rte-conditional-float-btn[data-action="delete"] {
608
+ border-color: #ef4444;
609
+ color: #fecaca;
610
+ background: rgba(127, 29, 29, 0.45);
611
+ }
612
+
613
+ ${f} .rte-conditional-block,
614
+ ${h} .rte-conditional-block,
615
+ .${c}.rte-conditional-theme-acme .rte-conditional-block {
616
+ background: #f8fbff;
617
+ border-color: #cbd8e8;
618
+ }
619
+
620
+ ${f} .rte-conditional-header,
621
+ ${f} .rte-conditional-else-label,
622
+ ${h} .rte-conditional-header,
623
+ ${h} .rte-conditional-else-label,
624
+ .${c}.rte-conditional-theme-acme .rte-conditional-header,
625
+ .${c}.rte-conditional-theme-acme .rte-conditional-else-label {
626
+ background: linear-gradient(180deg, #eef4fb 0%, #e6eef8 100%);
627
+ border-color: #cbd8e8;
628
+ }
629
+
630
+ ${f} .rte-conditional-summary,
631
+ ${h} .rte-conditional-summary,
632
+ .${c}.rte-conditional-theme-acme .rte-conditional-summary {
633
+ color: #0f172a;
634
+ }
635
+
636
+ ${f} .rte-conditional-meta,
637
+ ${h} .rte-conditional-meta,
638
+ .${c}.rte-conditional-theme-acme .rte-conditional-meta {
639
+ color: #587089;
640
+ }
641
+
642
+ ${f} .rte-conditional-chip,
643
+ ${h} .rte-conditional-chip,
644
+ .${c}.rte-conditional-theme-acme .rte-conditional-chip {
645
+ background: #d9f5ee;
646
+ border-color: #66c6b3;
647
+ color: #0f4f4a;
648
+ }
649
+
650
+ ${f} .rte-conditional-chip-else,
651
+ ${h} .rte-conditional-chip-else,
652
+ .${c}.rte-conditional-theme-acme .rte-conditional-chip-else {
653
+ background: #fde8ea;
654
+ border-color: #f1a7b2;
655
+ color: #8b1f2f;
656
+ }
657
+
658
+ ${f} .rte-conditional-body,
659
+ ${h} .rte-conditional-body,
660
+ .${c}.rte-conditional-theme-acme .rte-conditional-body {
661
+ background: #fcfeff;
662
+ color: #0f172a;
663
+ }
664
+
665
+ ${f} .rte-conditional-dialog,
666
+ ${h} .rte-conditional-dialog,
667
+ .${c}.rte-conditional-theme-acme .rte-conditional-dialog {
668
+ background: #ffffff;
669
+ border-color: #cbd8e8;
670
+ box-shadow: 0 20px 44px rgba(15, 23, 42, 0.18);
671
+ }
672
+
673
+ ${f} .rte-conditional-dialog-header,
674
+ ${f} .rte-conditional-dialog-footer,
675
+ ${h} .rte-conditional-dialog-header,
676
+ ${h} .rte-conditional-dialog-footer,
677
+ .${c}.rte-conditional-theme-acme .rte-conditional-dialog-header,
678
+ .${c}.rte-conditional-theme-acme .rte-conditional-dialog-footer {
679
+ background: #f3f8fd;
680
+ border-color: #d8e4f1;
681
+ }
682
+
683
+ ${f} .rte-conditional-dialog-title,
684
+ ${f} .rte-conditional-field label,
685
+ ${f} .rte-conditional-checkbox,
686
+ ${h} .rte-conditional-dialog-title,
687
+ ${h} .rte-conditional-field label,
688
+ ${h} .rte-conditional-checkbox,
689
+ .${c}.rte-conditional-theme-acme .rte-conditional-dialog-title,
690
+ .${c}.rte-conditional-theme-acme .rte-conditional-field label,
691
+ .${c}.rte-conditional-theme-acme .rte-conditional-checkbox {
692
+ color: #1f334a;
693
+ }
694
+
695
+ ${f} .rte-conditional-help,
696
+ ${h} .rte-conditional-help,
697
+ .${c}.rte-conditional-theme-acme .rte-conditional-help {
698
+ color: #5f738d;
699
+ }
700
+
701
+ ${f} .rte-conditional-field input[type="text"],
702
+ ${f} .rte-conditional-btn,
703
+ ${h} .rte-conditional-field input[type="text"],
704
+ ${h} .rte-conditional-btn,
705
+ .${c}.rte-conditional-theme-acme .rte-conditional-field input[type="text"],
706
+ .${c}.rte-conditional-theme-acme .rte-conditional-btn {
707
+ background: #ffffff;
708
+ border-color: #bfd0e2;
709
+ color: #0f172a;
710
+ }
711
+
712
+ ${f} .rte-conditional-btn-primary,
713
+ ${h} .rte-conditional-btn-primary,
714
+ .${c}.rte-conditional-theme-acme .rte-conditional-btn-primary {
715
+ border-color: #0f766e;
716
+ background: #0f766e;
717
+ color: #ffffff;
718
+ }
719
+
720
+ ${f} .rte-toolbar-group-items.conditional-content,
721
+ .${c}.rte-conditional-theme-acme .rte-toolbar-group-items.conditional-content,
722
+ ${h} .rte-toolbar-group-items.conditional-content,
723
+ ${f} .editora-toolbar-group-items.conditional-content {
724
+ border-color: #bfd0e2;
725
+ }
726
+
727
+ ${f} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
728
+ ${h} .rte-toolbar-group-items.conditional-content .rte-toolbar-button,
729
+ ${f} .editora-toolbar-group-items.conditional-content .editora-toolbar-button {
730
+ border-right-color: #bfd0e2;
731
+ }
732
+
733
+ ${f} .${u},
734
+ .${c}.rte-conditional-theme-acme .${u},
735
+ .${u}.rte-conditional-theme-acme {
736
+ background: rgba(255, 255, 255, 0.98);
737
+ border-color: #bfd0e2;
738
+ box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
739
+ }
740
+
741
+ ${f} .${u} .rte-conditional-float-btn,
742
+ .${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn,
743
+ .${u}.rte-conditional-theme-acme .rte-conditional-float-btn {
744
+ background: #ffffff;
745
+ border-color: #bfd0e2;
746
+ color: #1f334a;
747
+ }
748
+
749
+ ${f} .${u} .rte-conditional-float-btn:hover,
750
+ .${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn:hover,
751
+ .${u}.rte-conditional-theme-acme .rte-conditional-float-btn:hover {
752
+ background: #eef7f5;
753
+ color: #0f4f4a;
754
+ }
755
+
756
+ ${f} .${u} .rte-conditional-float-btn[data-action="delete"],
757
+ .${c}.rte-conditional-theme-acme .${u} .rte-conditional-float-btn[data-action="delete"],
758
+ .${u}.rte-conditional-theme-acme .rte-conditional-float-btn[data-action="delete"] {
759
+ border-color: #f1a7b2;
760
+ color: #8b1f2f;
761
+ background: #fff4f6;
762
+ }
763
+ `, document.head.appendChild(e);
764
+ }
765
+ function je(e) {
766
+ return {
767
+ defaultCondition: e.defaultCondition || "",
768
+ defaultAudience: te(e.defaultAudience || []),
769
+ defaultLocale: te(e.defaultLocale || []),
770
+ enableElseByDefault: e.enableElseByDefault === !0,
771
+ labels: Re(e.labels),
772
+ context: e.context,
773
+ getContext: e.getContext,
774
+ currentAudience: e.currentAudience,
775
+ currentLocale: e.currentLocale,
776
+ evaluateCondition: e.evaluateCondition || ze
777
+ };
778
+ }
779
+ function Be() {
780
+ le && (le.cleanup(), le = null);
781
+ }
782
+ function Ve(e) {
783
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
784
+ }
785
+ function oe(e, t) {
786
+ e.setAttribute("contenteditable", "false"), e.setAttribute("spellcheck", "false");
787
+ const o = e.querySelector(".rte-conditional-header");
788
+ o && (o.setAttribute("contenteditable", "false"), o.setAttribute("tabindex", "0"), o.setAttribute("role", "button"), o.setAttribute("aria-label", "Edit conditional rule"));
789
+ const i = e.querySelector(".rte-conditional-else-label");
790
+ i && i.setAttribute("contenteditable", "false"), Ge(e, !t);
791
+ }
792
+ function We(e) {
793
+ const t = e.querySelector('.rte-conditional-body[data-slot="if"]');
794
+ if (!t) return;
795
+ const o = /* @__PURE__ */ new Set(), i = e.querySelector(".rte-conditional-header"), n = e.querySelector(".rte-conditional-else-label"), a = e.querySelector('.rte-conditional-body[data-slot="else"]');
796
+ i && o.add(i), o.add(t), n && o.add(n), a && o.add(a), Array.from(e.childNodes).forEach((l) => {
797
+ if (!(l instanceof HTMLElement && o.has(l))) {
798
+ if (l.nodeType === Node.TEXT_NODE && !(l.textContent || "").trim()) {
799
+ l.remove();
800
+ return;
801
+ }
802
+ t.appendChild(l);
803
+ }
804
+ });
805
+ }
806
+ function W(e) {
807
+ const t = window.getSelection();
808
+ if (t && t.rangeCount > 0) {
809
+ const n = t.getRangeAt(0).startContainer, r = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(H);
810
+ if (r && e.contains(r)) return r;
811
+ }
812
+ const i = document.activeElement?.closest(H);
813
+ return i && e.contains(i) ? i : null;
814
+ }
815
+ function Ee(e, t) {
816
+ let o = e.querySelector(".rte-conditional-else-label"), i = e.querySelector('.rte-conditional-body[data-slot="else"]');
817
+ o || (o = document.createElement("div"), o.className = "rte-conditional-else-label", o.setAttribute("contenteditable", "false"), o.innerHTML = `
818
+ <span class="rte-conditional-chip rte-conditional-chip-else">${y(t.blockElseLabel)}</span>
819
+ <span class="rte-conditional-summary">Else branch</span>
820
+ `, e.appendChild(o)), i || (i = document.createElement("div"), i.className = "rte-conditional-body rte-conditional-else-body", i.setAttribute("data-slot", "else"), i.innerHTML = "<p><br></p>", e.appendChild(i));
821
+ }
822
+ function Ze(e, t) {
823
+ e.setAttribute("data-has-else", t ? "true" : "false");
824
+ const o = e.querySelector(".rte-conditional-else-label"), i = e.querySelector('.rte-conditional-body[data-slot="else"]');
825
+ o && o.classList.toggle("rte-conditional-hidden", !t), i && i.classList.toggle("rte-conditional-hidden", !t);
826
+ }
827
+ function Ge(e, t) {
828
+ Array.from(e.querySelectorAll(".rte-conditional-body")).forEach((i) => {
829
+ i.setAttribute("contenteditable", t ? "true" : "false");
830
+ }), e.setAttribute("contenteditable", "false");
831
+ }
832
+ function ve(e, t) {
833
+ const o = e.getAttribute("data-condition") || "", i = O(e.getAttribute("data-audience")), n = O(e.getAttribute("data-locale"));
834
+ let a = e.querySelector(".rte-conditional-header");
835
+ a || (a = document.createElement("div"), a.className = "rte-conditional-header", e.prepend(a)), a.setAttribute("contenteditable", "false"), a.setAttribute("tabindex", "0"), a.setAttribute("role", "button"), a.setAttribute("aria-label", "Edit conditional rule");
836
+ const r = o || "(always true)", l = i.length > 0 ? i.join(", ") : t.allAudiencesText, d = n.length > 0 ? n.join(", ") : t.allLocalesText;
837
+ if (a.innerHTML = `
838
+ <span class="rte-conditional-chip">${y(t.blockIfLabel)}</span>
839
+ <span class="rte-conditional-summary">${y(r)}</span>
840
+ <span class="rte-conditional-meta">${y(l)} · ${y(d)}</span>
841
+ `, !e.querySelector('.rte-conditional-body[data-slot="if"]')) {
842
+ const v = document.createElement("div");
843
+ v.className = "rte-conditional-body", v.setAttribute("data-slot", "if"), v.innerHTML = "<p><br></p>", e.insertBefore(v, e.children[1] || null);
844
+ }
845
+ const m = e.getAttribute("data-has-else") === "true";
846
+ m && Ee(e, t), We(e), Ze(e, m);
847
+ }
848
+ function Me(e, t) {
849
+ const o = document.createElement("section");
850
+ o.className = "rte-conditional-block", o.setAttribute("data-conditional-content", "true"), o.setAttribute("data-condition", (e.condition || "").trim()), o.setAttribute("data-audience", te(e.audience).join(",")), o.setAttribute("data-locale", te(e.locale).join(",")), o.setAttribute("data-has-else", e.hasElse ? "true" : "false"), o.setAttribute("role", "group"), o.setAttribute("aria-label", "Conditional content block"), o.setAttribute("contenteditable", "false"), o.setAttribute("spellcheck", "false");
851
+ const i = document.createElement("div");
852
+ i.className = "rte-conditional-header", i.setAttribute("contenteditable", "false");
853
+ const n = document.createElement("div");
854
+ return n.className = "rte-conditional-body", n.setAttribute("data-slot", "if"), n.innerHTML = "<p><br></p>", o.appendChild(i), o.appendChild(n), e.hasElse && Ee(o, t), ve(o, t), oe(o, !1), o;
855
+ }
856
+ function Ue(e, t) {
857
+ if (t)
858
+ try {
859
+ if (!e.isConnected) return;
860
+ const o = e.contains(t.startContainer), i = e.contains(t.endContainer);
861
+ if (!o || !i) return;
862
+ xe(e, t);
863
+ } catch {
864
+ }
865
+ }
866
+ function Ye(e) {
867
+ return (e.textContent || "").replace(/\u200B/g, "").trim().length > 0 ? !0 : e.querySelector("img, video, table, iframe, hr, pre, blockquote, ul, ol") !== null;
868
+ }
869
+ function Ne(e, t, o) {
870
+ let i = null;
871
+ i || (i = ke(e)), i || (i = document.createRange(), i.selectNodeContents(e), i.collapse(!1));
872
+ let n = null;
873
+ i.collapsed || (n = i.extractContents()), i.insertNode(t);
874
+ const a = t.querySelector('.rte-conditional-body[data-slot="if"]');
875
+ a && n && Ye(n) && (a.innerHTML = "", a.appendChild(n)), a ? pe(e, a) : pe(e, t), e.normalize();
876
+ }
877
+ function Je(e) {
878
+ return {
879
+ condition: e.getAttribute("data-condition") || "",
880
+ audience: O(e.getAttribute("data-audience")),
881
+ locale: O(e.getAttribute("data-locale")),
882
+ hasElse: e.getAttribute("data-has-else") === "true"
883
+ };
884
+ }
885
+ function Xe(e, t, o) {
886
+ e.setAttribute("data-condition", (t.condition || "").trim()), e.setAttribute("data-audience", te(t.audience).join(",")), e.setAttribute("data-locale", te(t.locale).join(",")), e.setAttribute("data-has-else", t.hasElse ? "true" : "false"), t.hasElse && Ee(e, o), ve(e, o), oe(e, e.classList.contains("rte-conditional-preview"));
887
+ }
888
+ function ne(e, t) {
889
+ he(e, e);
890
+ const o = Array.from(e.querySelectorAll(H)), i = w.get(e) === !0;
891
+ return o.forEach((n) => {
892
+ n.classList.add("rte-conditional-block"), n.setAttribute("data-conditional-content", "true"), n.hasAttribute("data-condition") || n.setAttribute("data-condition", ""), n.hasAttribute("data-audience") || n.setAttribute("data-audience", ""), n.hasAttribute("data-locale") || n.setAttribute("data-locale", ""), n.hasAttribute("data-has-else") || n.setAttribute("data-has-else", "false"), n.setAttribute("role", "group"), n.setAttribute("aria-label", "Conditional content block"), n.setAttribute("contenteditable", "false"), n.setAttribute("spellcheck", "false"), ve(n, t), oe(n, i);
893
+ }), o;
894
+ }
895
+ async function Qe(e, t) {
896
+ const o = $e.get(e);
897
+ if (o)
898
+ return o;
899
+ if (typeof t.getContext == "function")
900
+ try {
901
+ const i = ce(e), n = await Promise.resolve(t.getContext({ editor: e, editorRoot: i }));
902
+ if (n && typeof n == "object")
903
+ return n;
904
+ } catch {
905
+ return {};
906
+ }
907
+ if (typeof t.context == "function")
908
+ try {
909
+ const i = t.context();
910
+ if (i && typeof i == "object")
911
+ return i;
912
+ } catch {
913
+ return {};
914
+ }
915
+ return t.context && typeof t.context == "object" ? t.context : {};
916
+ }
917
+ function be(e) {
918
+ return Array.isArray(e) ? e.map((t) => t.trim().toLowerCase()).filter(Boolean) : typeof e == "string" ? e.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean) : [];
919
+ }
920
+ function Ae(e, t) {
921
+ return e.length === 0 || e.includes("all") ? !0 : t.length === 0 ? !1 : e.some((o) => t.includes(o));
922
+ }
923
+ async function Z(e, t, o) {
924
+ const i = t.labels, n = ne(e, i);
925
+ if (w.set(e, o), De(e, o), ce(e).classList.toggle("rte-conditional-preview-on", o), !o) {
926
+ n.forEach(($) => {
927
+ $.classList.remove("rte-conditional-preview"), oe($, !1);
928
+ const P = $.querySelector('.rte-conditional-body[data-slot="if"]'), T = $.querySelector('.rte-conditional-body[data-slot="else"]'), F = $.querySelector(".rte-conditional-else-label"), B = $.getAttribute("data-has-else") === "true";
929
+ P && (P.classList.remove("rte-conditional-hidden"), P.removeAttribute("aria-hidden")), T && (T.classList.toggle("rte-conditional-hidden", !B), T.setAttribute("aria-hidden", B ? "false" : "true")), F && F.classList.toggle("rte-conditional-hidden", !B);
930
+ });
931
+ return;
932
+ }
933
+ const r = await Qe(e, t), l = be(t.currentAudience), d = be(t.currentLocale), E = be(
934
+ r.audience ?? r.user?.audience
935
+ ), m = be(
936
+ r.locale ?? r.user?.locale
937
+ ), v = l.length > 0 ? l : E, S = d.length > 0 ? d : m;
938
+ n.forEach(($) => {
939
+ const P = $.getAttribute("data-condition") || "", T = O($.getAttribute("data-audience")).map((s) => s.toLowerCase()), F = O($.getAttribute("data-locale")).map((s) => s.toLowerCase()), B = $.getAttribute("data-has-else") === "true", ge = t.evaluateCondition(P, r), M = Ae(T, v), de = Ae(F, S), R = ge && M && de, ie = $.querySelector('.rte-conditional-body[data-slot="if"]'), j = $.querySelector('.rte-conditional-body[data-slot="else"]'), ae = $.querySelector(".rte-conditional-else-label");
940
+ if ($.classList.add("rte-conditional-preview"), oe($, !0), ie && (ie.classList.toggle("rte-conditional-hidden", !R), ie.setAttribute("aria-hidden", R ? "false" : "true")), j) {
941
+ const s = B && !R;
942
+ j.classList.toggle("rte-conditional-hidden", !s), j.setAttribute("aria-hidden", s ? "false" : "true");
943
+ }
944
+ if (ae) {
945
+ const s = B && !R;
946
+ ae.classList.toggle("rte-conditional-hidden", !s);
947
+ }
948
+ });
949
+ }
950
+ function De(e, t) {
951
+ const o = ce(e);
952
+ Array.from(
953
+ o.querySelectorAll('[data-command="toggleConditionalPreview"], [data-command="conditionalPreview"]')
954
+ ).forEach((n) => {
955
+ n.setAttribute("data-active", t ? "true" : "false"), n.classList.toggle("active", t), n.setAttribute("aria-pressed", t ? "true" : "false");
956
+ });
957
+ }
958
+ function et(e) {
959
+ const t = _.get(e);
960
+ if (t && t.isConnected) return t;
961
+ const o = document.createElement("div");
962
+ return o.className = u, o.setAttribute("role", "toolbar"), o.setAttribute("aria-label", "Conditional block actions"), o.innerHTML = `
963
+ <button type="button" class="rte-conditional-float-btn" data-action="edit" title="Edit Condition" aria-label="Edit Condition">
964
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 17.3V20h2.7l9.7-9.7-2.7-2.7L4 17.3Zm14.7-9.4a1 1 0 0 0 0-1.4l-1.2-1.2a1 1 0 0 0-1.4 0l-1.1 1.1 2.7 2.7 1-1.2Z" fill="currentColor"></path></svg>
965
+ </button>
966
+ <button type="button" class="rte-conditional-float-btn" data-action="delete" title="Delete Block" aria-label="Delete Block">
967
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 4h8l1 2h4v2H3V6h4l1-2Zm1 6h2v8H9v-8Zm4 0h2v8h-2v-8Z" fill="currentColor"></path></svg>
968
+ </button>
969
+ `, o.addEventListener("mousedown", (i) => {
970
+ i.preventDefault();
971
+ }), o.addEventListener("click", (i) => {
972
+ const a = i.target?.closest("[data-action]")?.getAttribute("data-action");
973
+ if (!a) return;
974
+ const r = x.get(e) || ee;
975
+ if (!r) return;
976
+ const l = z.get(e);
977
+ if (!(!l || !e.contains(l))) {
978
+ if (a === "edit") {
979
+ C(e, r, "edit", void 0, l);
980
+ return;
981
+ }
982
+ a === "delete" && (Oe(e, l), z.set(e, null), I(e));
983
+ }
984
+ }), document.body.appendChild(o), _.set(e, o), o;
985
+ }
986
+ function I(e) {
987
+ const t = _.get(e);
988
+ t && t.classList.remove("show");
989
+ }
990
+ function He(e, t) {
991
+ const o = t.getBoundingClientRect();
992
+ e.style.left = "0px", e.style.top = "0px", e.classList.add("show");
993
+ const i = e.getBoundingClientRect(), n = 8, a = window.innerWidth, r = window.innerHeight;
994
+ let l = o.top - i.height - n;
995
+ l < n && (l = o.bottom + n), l = Math.min(l, r - i.height - n);
996
+ let d = o.right - i.width;
997
+ d = Math.max(n, Math.min(d, a - i.width - n)), e.style.left = `${d}px`, e.style.top = `${l}px`;
998
+ }
999
+ function me(e, t) {
1000
+ const o = et(e);
1001
+ he(o, e), z.set(e, t), He(o, t);
1002
+ }
1003
+ function D(e) {
1004
+ const t = x.get(e) || ee;
1005
+ if (!t) return;
1006
+ const o = W(e);
1007
+ if (!o || !e.contains(o) || k(e)) {
1008
+ z.set(e, null), I(e);
1009
+ return;
1010
+ }
1011
+ ne(e, t.labels), me(e, o);
1012
+ }
1013
+ function tt() {
1014
+ _.forEach((e, t) => {
1015
+ if (!t.isConnected || !e.isConnected) {
1016
+ e.remove(), _.delete(t), z.delete(t);
1017
+ return;
1018
+ }
1019
+ if (!e.classList.contains("show")) return;
1020
+ he(e, t);
1021
+ const o = z.get(t);
1022
+ if (!o || !t.contains(o)) {
1023
+ I(t);
1024
+ return;
1025
+ }
1026
+ He(e, o);
1027
+ });
1028
+ }
1029
+ function Oe(e, t) {
1030
+ if (!e.contains(t)) return !1;
1031
+ const o = e.innerHTML, i = t.parentNode, n = t.nextSibling;
1032
+ t.remove(), i === e && e.innerHTML.trim() === "" && (e.innerHTML = "<p><br></p>");
1033
+ const a = document.createRange();
1034
+ return n && e.contains(n) ? a.setStartBefore(n) : (a.selectNodeContents(e), a.collapse(!1)), a.collapse(!0), xe(e, a), Se(e), Te(e, o), !0;
1035
+ }
1036
+ function we(e, t, o) {
1037
+ const i = e.cloneRange(), n = document.createRange();
1038
+ return n.selectNodeContents(t), n.collapse(o === "start"), i.startContainer === n.startContainer && i.startOffset === n.startOffset && i.endContainer === n.endContainer && i.endOffset === n.endOffset;
1039
+ }
1040
+ function C(e, t, o, i, n) {
1041
+ Be();
1042
+ const a = t.labels, r = o === "insert" ? ke(e) : null, l = document.createElement("div");
1043
+ l.className = c, he(l, e);
1044
+ const d = document.createElement("section");
1045
+ d.className = "rte-conditional-dialog", d.setAttribute("role", "dialog"), d.setAttribute("aria-modal", "true"), d.setAttribute("aria-labelledby", "rte-conditional-dialog-title");
1046
+ const E = n ? Je(n) : void 0, m = i || E || {}, v = m.condition ?? t.defaultCondition, S = m.audience ?? t.defaultAudience, $ = m.locale ?? t.defaultLocale, P = m.hasElse ?? t.enableElseByDefault;
1047
+ d.innerHTML = `
1048
+ <header class="rte-conditional-dialog-header">
1049
+ <h2 id="rte-conditional-dialog-title" class="rte-conditional-dialog-title">${y(
1050
+ o === "edit" ? a.dialogTitleEdit : a.dialogTitleInsert
1051
+ )}</h2>
1052
+ <button type="button" class="rte-conditional-btn" data-action="cancel" aria-label="${y(a.cancelText)}">✕</button>
1053
+ </header>
1054
+ <div class="rte-conditional-dialog-body">
1055
+ <div class="rte-conditional-field">
1056
+ <label for="rte-conditional-condition">${y(a.conditionLabel)}</label>
1057
+ <input id="rte-conditional-condition" class="rte-conditional-input-condition" type="text" value="${y(
1058
+ v || ""
1059
+ )}" placeholder="${y(a.conditionPlaceholder)}" />
1060
+ </div>
1061
+ <div class="rte-conditional-field">
1062
+ <label for="rte-conditional-audience">${y(a.audienceLabel)}</label>
1063
+ <input id="rte-conditional-audience" class="rte-conditional-input-audience" type="text" value="${y(
1064
+ Le(S)
1065
+ )}" placeholder="${y(a.audiencePlaceholder)}" />
1066
+ </div>
1067
+ <div class="rte-conditional-field">
1068
+ <label for="rte-conditional-locale">${y(a.localeLabel)}</label>
1069
+ <input id="rte-conditional-locale" class="rte-conditional-input-locale" type="text" value="${y(
1070
+ Le($)
1071
+ )}" placeholder="${y(a.localePlaceholder)}" />
1072
+ </div>
1073
+ <label class="rte-conditional-checkbox">
1074
+ <input class="rte-conditional-input-else" type="checkbox" ${P ? "checked" : ""} />
1075
+ <span>${y(a.elseLabel)}</span>
1076
+ </label>
1077
+ <p class="rte-conditional-help">Example condition: <code>user.role == "admin"</code>, <code>locale == "en-US"</code>, <code>!feature.beta</code></p>
1078
+ </div>
1079
+ <footer class="rte-conditional-dialog-footer">
1080
+ <button type="button" class="rte-conditional-btn" data-action="cancel">${y(a.cancelText)}</button>
1081
+ <button type="button" class="rte-conditional-btn rte-conditional-btn-primary" data-action="save">${y(a.saveText)}</button>
1082
+ </footer>
1083
+ `, l.appendChild(d), document.body.appendChild(l);
1084
+ const T = d.querySelector(".rte-conditional-input-condition"), F = d.querySelector(".rte-conditional-input-audience"), B = d.querySelector(".rte-conditional-input-locale"), ge = d.querySelector(".rte-conditional-input-else"), M = () => {
1085
+ l.removeEventListener("click", R), l.removeEventListener("keydown", ae, !0), document.removeEventListener("keydown", de, !0), l.parentNode && l.parentNode.removeChild(l), le = null, e.focus({ preventScroll: !0 }), D(e);
1086
+ }, de = (s) => {
1087
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), M());
1088
+ }, R = (s) => {
1089
+ s.target === l && M();
1090
+ }, ie = (s) => {
1091
+ if (s.key !== "Tab") return;
1092
+ const q = Array.from(
1093
+ d.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')
1094
+ );
1095
+ if (q.length === 0) return;
1096
+ const V = q[0], K = q[q.length - 1], re = document.activeElement;
1097
+ if (s.shiftKey && re === V) {
1098
+ s.preventDefault(), K.focus();
1099
+ return;
1100
+ }
1101
+ !s.shiftKey && re === K && (s.preventDefault(), V.focus());
1102
+ }, j = async () => {
1103
+ const s = {
1104
+ condition: T?.value?.trim() || "",
1105
+ audience: O(F?.value),
1106
+ locale: O(B?.value),
1107
+ hasElse: ge?.checked || !1
1108
+ }, q = e.innerHTML;
1109
+ if (n)
1110
+ Xe(n, s, a), oe(n, w.get(e) === !0);
1111
+ else {
1112
+ Ue(e, r);
1113
+ const K = Me(s, a);
1114
+ try {
1115
+ Ne(e, K);
1116
+ } catch {
1117
+ e.appendChild(K);
1118
+ const re = K.querySelector('.rte-conditional-body[data-slot="if"]');
1119
+ re ? pe(e, re) : pe(e, K);
1120
+ }
1121
+ }
1122
+ w.get(e) === !0 && await Z(e, t, !0), Se(e), Te(e, q), D(e), M();
1123
+ }, ae = (s) => {
1124
+ if (s.key === "Escape") {
1125
+ s.preventDefault(), M();
1126
+ return;
1127
+ }
1128
+ ie(s), s.key === "Enter" && !s.shiftKey && s.target instanceof HTMLInputElement && (s.preventDefault(), j());
1129
+ };
1130
+ d.addEventListener("click", (s) => {
1131
+ const V = s.target.getAttribute("data-action");
1132
+ if (V === "cancel") {
1133
+ M();
1134
+ return;
1135
+ }
1136
+ V === "save" && j();
1137
+ }), l.addEventListener("click", R), l.addEventListener("keydown", ae, !0), document.addEventListener("keydown", de, !0), le = { cleanup: M }, T?.focus();
1138
+ }
1139
+ function ot(e) {
1140
+ const t = e.metaKey || e.ctrlKey, i = (typeof e.key == "string" ? e.key : "").toLowerCase(), n = typeof e.code == "string" ? e.code.toLowerCase() : "", a = t && e.altKey && e.shiftKey && (i === "c" || n === "keyc"), r = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && (i === "f9" || n === "f9");
1141
+ return a || r;
1142
+ }
1143
+ function nt(e) {
1144
+ const t = e.metaKey || e.ctrlKey, i = (typeof e.key == "string" ? e.key : "").toLowerCase(), n = typeof e.code == "string" ? e.code.toLowerCase() : "", a = t && e.altKey && e.shiftKey && (i === "p" || n === "keyp"), r = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && (i === "f10" || n === "f10");
1145
+ return a || r;
1146
+ }
1147
+ function it(e) {
1148
+ ee = e, U || (U = (t) => {
1149
+ const i = t.target?.closest(L);
1150
+ if (!i) return;
1151
+ g = i, x.has(i) || x.set(i, e);
1152
+ const n = x.get(i) || e;
1153
+ ne(i, n.labels), De(i, w.get(i) === !0), D(i);
1154
+ }, document.addEventListener("focusin", U, !0)), G || (G = (t) => {
1155
+ if (document.querySelector(`.${c}`)) return;
1156
+ const i = t.target;
1157
+ if (!!i?.closest("input, textarea, select")) return;
1158
+ const r = i?.closest(L) || A(void 0, !1) || g;
1159
+ if (!r || k(r)) return;
1160
+ const l = x.get(r) || ee || e, d = document.activeElement, E = i?.closest(".rte-conditional-header") || d?.closest(".rte-conditional-header");
1161
+ if (E && (t.key === "Enter" || t.key === " ")) {
1162
+ const m = E.closest(H);
1163
+ if (m && r.contains(m)) {
1164
+ t.preventDefault(), t.stopPropagation(), C(r, l, "edit", void 0, m);
1165
+ return;
1166
+ }
1167
+ }
1168
+ if (ot(t)) {
1169
+ t.preventDefault(), t.stopPropagation();
1170
+ const m = W(r);
1171
+ m ? C(r, l, "edit", void 0, m) : C(r, l, "insert");
1172
+ return;
1173
+ }
1174
+ if (nt(t)) {
1175
+ t.preventDefault(), t.stopPropagation();
1176
+ const m = w.get(r) !== !0;
1177
+ Z(r, l, m), D(r);
1178
+ return;
1179
+ }
1180
+ if ((t.key === "Backspace" || t.key === "Delete") && !t.altKey && !t.ctrlKey && !t.metaKey) {
1181
+ const m = window.getSelection();
1182
+ if (!m || m.rangeCount === 0) return;
1183
+ const v = m.getRangeAt(0);
1184
+ if (!v.collapsed || !r.contains(v.commonAncestorContainer)) return;
1185
+ const S = Ve(v.startContainer)?.closest(".rte-conditional-body");
1186
+ if (!S || !r.contains(S)) return;
1187
+ if (t.key === "Backspace" && we(v, S, "start")) {
1188
+ t.preventDefault();
1189
+ return;
1190
+ }
1191
+ if (t.key === "Delete" && we(v, S, "end")) {
1192
+ t.preventDefault();
1193
+ return;
1194
+ }
1195
+ }
1196
+ }, document.addEventListener("keydown", G, !0)), J || (J = (t) => {
1197
+ const o = t.target;
1198
+ if (!o || o.closest(`.${u}`)) return;
1199
+ const i = o.closest(L);
1200
+ if (!i) {
1201
+ g && I(g);
1202
+ return;
1203
+ }
1204
+ if (k(i)) return;
1205
+ g = i, x.has(i) || x.set(i, e);
1206
+ const n = o.closest(H);
1207
+ if (!n) {
1208
+ I(i);
1209
+ return;
1210
+ }
1211
+ requestAnimationFrame(() => {
1212
+ !i.isConnected || !i.contains(n) || me(i, n);
1213
+ });
1214
+ }, document.addEventListener("mousedown", J, !0)), Y || (Y = (t) => {
1215
+ const o = t.target;
1216
+ if (!o || o.closest(`.${u}`)) return;
1217
+ const i = o.closest(L);
1218
+ if (!i) {
1219
+ g && I(g);
1220
+ return;
1221
+ }
1222
+ if (k(i)) return;
1223
+ g = i, x.has(i) || x.set(i, e);
1224
+ const n = x.get(i) || e, a = o.closest(H), r = !!o.closest(".rte-conditional-header, .rte-conditional-summary, .rte-conditional-meta, .rte-conditional-else-label");
1225
+ if (a && r) {
1226
+ t.preventDefault(), t.stopPropagation(), C(i, n, "edit", void 0, a), me(i, a);
1227
+ return;
1228
+ }
1229
+ a ? me(i, a) : I(i);
1230
+ }, document.addEventListener("click", Y, !0)), X || (X = () => {
1231
+ const t = A(void 0, !1) || g;
1232
+ t && t.isConnected && D(t);
1233
+ }, document.addEventListener("selectionchange", X)), Q || (Q = (t) => {
1234
+ const i = t.target?.closest(L);
1235
+ if (!i) return;
1236
+ const n = x.get(i) || ee || e;
1237
+ ne(i, n.labels), D(i);
1238
+ }, document.addEventListener("input", Q, !0)), N || (N = () => {
1239
+ tt();
1240
+ }, window.addEventListener("scroll", N, !0), window.addEventListener("resize", N));
1241
+ }
1242
+ function at() {
1243
+ U && (document.removeEventListener("focusin", U, !0), U = null), G && (document.removeEventListener("keydown", G, !0), G = null), Y && (document.removeEventListener("click", Y, !0), Y = null), J && (document.removeEventListener("mousedown", J, !0), J = null), X && (document.removeEventListener("selectionchange", X), X = null), Q && (document.removeEventListener("input", Q, !0), Q = null), N && (window.removeEventListener("scroll", N, !0), window.removeEventListener("resize", N), N = null), _.forEach((e) => {
1244
+ e.remove();
1245
+ }), _.clear(), z.clear(), ee = null, g = null;
1246
+ }
1247
+ const rt = (e = {}) => {
1248
+ const t = je(e);
1249
+ return Fe(), {
1250
+ name: "conditionalContent",
1251
+ toolbar: [
1252
+ {
1253
+ id: "conditionalContentGroup",
1254
+ label: "Conditional Content",
1255
+ type: "group",
1256
+ command: "conditionalContent",
1257
+ items: [
1258
+ {
1259
+ id: "conditionalContent",
1260
+ label: "Conditional Rule",
1261
+ command: "openConditionalDialog",
1262
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12a1 1 0 0 1 1 1v3h-2V7H7v3H5V6a1 1 0 0 1 1-1Zm-1 9h2v3h10v-3h2v4a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-4Zm3-2a1 1 0 0 1 1-1h2.6l1.8-2.4a1 1 0 1 1 1.6 1.2L13.8 11H15a1 1 0 1 1 0 2h-2.7l-1.9 2.5a1 1 0 1 1-1.6-1.2L10.1 13H9a1 1 0 0 1-1-1Z" fill="currentColor"></path></svg>',
1263
+ shortcut: "Mod-Alt-Shift-c"
1264
+ },
1265
+ {
1266
+ id: "conditionalPreview",
1267
+ label: "Conditional Preview",
1268
+ command: "toggleConditionalPreview",
1269
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6h16a1 1 0 0 1 1 1v3h-2V8H5v8h14v-2h2v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm5 3h2v2H9V9Zm0 4h2v2H9v-2Zm4-4h6v2h-6V9Zm0 4h6v2h-6v-2Z" fill="currentColor"></path></svg>',
1270
+ shortcut: "Mod-Alt-Shift-p"
1271
+ }
1272
+ ]
1273
+ }
1274
+ ],
1275
+ commands: {
1276
+ conditionalContent: (o, i) => {
1277
+ const n = A(i);
1278
+ if (!n || k(n)) return !1;
1279
+ g = n, x.set(n, t), ne(n, t.labels);
1280
+ const a = o?.target;
1281
+ if (a === "insert")
1282
+ return C(n, t, "insert", o), !0;
1283
+ const r = W(n);
1284
+ return a === "edit" || r ? !r && a === "edit" ? !1 : (C(n, t, "edit", o, r || void 0), !0) : (C(n, t, "insert", o), !0);
1285
+ },
1286
+ openConditionalDialog: (o, i) => {
1287
+ const n = A(i);
1288
+ if (!n || k(n)) return !1;
1289
+ g = n, x.set(n, t), ne(n, t.labels);
1290
+ const a = o?.target;
1291
+ if (a === "insert")
1292
+ return C(n, t, "insert", o), !0;
1293
+ const r = W(n);
1294
+ return a === "edit" || r ? !r && a === "edit" ? !1 : (C(n, t, "edit", o, r || void 0), !0) : (C(n, t, "insert", o), !0);
1295
+ },
1296
+ conditionalPreview: async (o, i) => {
1297
+ const n = A(i);
1298
+ if (!n) return !1;
1299
+ g = n, x.set(n, t);
1300
+ const a = typeof o == "boolean" ? o : w.get(n) !== !0;
1301
+ return await Z(n, t, a), D(n), !0;
1302
+ },
1303
+ editConditionalBlock: (o, i) => {
1304
+ const n = A(i);
1305
+ if (!n || k(n)) return !1;
1306
+ g = n, x.set(n, t);
1307
+ const a = W(n);
1308
+ return a ? (C(n, t, "edit", o, a), !0) : !1;
1309
+ },
1310
+ deleteConditionalBlock: (o, i) => {
1311
+ const n = A(i);
1312
+ if (!n || k(n)) return !1;
1313
+ const a = W(n);
1314
+ if (!a) return !1;
1315
+ const r = Oe(n, a);
1316
+ return r && D(n), r;
1317
+ },
1318
+ insertConditionalBlock: (o, i) => {
1319
+ const n = A(i);
1320
+ if (!n || k(n)) return !1;
1321
+ g = n, x.set(n, t);
1322
+ const a = {
1323
+ condition: o?.condition ?? t.defaultCondition,
1324
+ audience: o?.audience ?? t.defaultAudience,
1325
+ locale: o?.locale ?? t.defaultLocale,
1326
+ hasElse: o?.hasElse ?? t.enableElseByDefault
1327
+ }, r = Me(a, t.labels);
1328
+ return Ne(n, r), w.get(n) === !0 && Z(n, t, !0), !0;
1329
+ },
1330
+ toggleConditionalPreview: async (o, i) => {
1331
+ const n = A(i);
1332
+ if (!n) return !1;
1333
+ g = n, x.set(n, t);
1334
+ const a = typeof o == "boolean" ? o : w.get(n) !== !0;
1335
+ return await Z(n, t, a), !0;
1336
+ },
1337
+ setConditionalContext: (o, i) => {
1338
+ const n = A(i);
1339
+ return n ? (g = n, !o || typeof o != "object" ? $e.delete(n) : $e.set(n, o), w.get(n) === !0 && Z(n, t, !0), !0) : !1;
1340
+ }
1341
+ },
1342
+ keymap: {
1343
+ "Mod-Alt-Shift-c": "openConditionalDialog",
1344
+ "Mod-Alt-Shift-C": "openConditionalDialog",
1345
+ "Mod-Alt-Shift-p": "toggleConditionalPreview",
1346
+ "Mod-Alt-Shift-P": "toggleConditionalPreview",
1347
+ F9: "openConditionalDialog",
1348
+ F10: "toggleConditionalPreview"
1349
+ },
1350
+ init: () => {
1351
+ se += 1, it(t);
1352
+ },
1353
+ destroy: () => {
1354
+ se = Math.max(0, se - 1), se === 0 && (Be(), at());
1355
+ }
1356
+ };
1357
+ };
1358
+ export {
1359
+ rt as ConditionalContentPlugin
1360
+ };