@notectl/core 0.0.2 → 0.0.5

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.
@@ -1,4 +1,4 @@
1
- class Xe {
1
+ class Ze {
2
2
  constructor(t) {
3
3
  this.nodes = new Map(t.nodes.map((e) => [e.type, e])), this.marks = new Map(t.marks.map((e) => [e.type, e])), this.topNode = t.topNode || "paragraph";
4
4
  }
@@ -20,21 +20,21 @@ class Xe {
20
20
  validateNode(t) {
21
21
  const e = [];
22
22
  if ("text" in t) {
23
- const i = t;
24
- if (typeof i.text != "string" && e.push("Text node must have a string text property"), i.marks)
25
- for (const o of i.marks)
23
+ const n = t;
24
+ if (typeof n.text != "string" && e.push("Text node must have a string text property"), n.marks)
25
+ for (const o of n.marks)
26
26
  this.marks.has(o.type) || e.push(`Unknown mark type: ${o.type}`);
27
27
  } else {
28
- const i = t, o = this.nodes.get(i.type);
28
+ const n = t, o = this.nodes.get(n.type);
29
29
  if (!o)
30
- return e.push(`Unknown node type: ${i.type}`), { valid: !1, errors: e };
30
+ return e.push(`Unknown node type: ${n.type}`), { valid: !1, errors: e };
31
31
  if (o.attrs)
32
- for (const [a, u] of Object.entries(o.attrs))
33
- u.required && (!i.attrs || !(a in i.attrs)) && e.push(`Required attribute missing: ${a}`), i.attrs?.[a] && u.validate && (u.validate(i.attrs[a]) || e.push(`Invalid attribute value: ${a}`));
34
- if (i.children)
35
- for (const a of i.children) {
36
- const u = this.validateNode(a);
37
- e.push(...u.errors);
32
+ for (const [s, l] of Object.entries(o.attrs))
33
+ l.required && (!n.attrs || !(s in n.attrs)) && e.push(`Required attribute missing: ${s}`), n.attrs?.[s] && l.validate && (l.validate(n.attrs[s]) || e.push(`Invalid attribute value: ${s}`));
34
+ if (n.children)
35
+ for (const s of n.children) {
36
+ const l = this.validateNode(s);
37
+ e.push(...l.errors);
38
38
  }
39
39
  }
40
40
  return {
@@ -46,19 +46,19 @@ class Xe {
46
46
  * Check if a mark is allowed on a node
47
47
  */
48
48
  markAllowedOn(t, e) {
49
- const i = this.nodes.get(e);
50
- return !i || !i.marks ? !1 : i.marks === "_" ? !0 : i.marks.split(" ").includes(t);
49
+ const n = this.nodes.get(e);
50
+ return !n || !n.marks ? !1 : n.marks === "_" ? !0 : n.marks.split(" ").includes(t);
51
51
  }
52
52
  /**
53
53
  * Check if two marks can coexist
54
54
  */
55
55
  marksCompatible(t, e) {
56
- const i = this.marks.get(t), o = this.marks.get(e);
57
- return !(i?.excludes && i.excludes.split(" ").includes(e) || o?.excludes && o.excludes.split(" ").includes(t));
56
+ const n = this.marks.get(t), o = this.marks.get(e);
57
+ return !(n?.excludes && n.excludes.split(" ").includes(e) || o?.excludes && o.excludes.split(" ").includes(t));
58
58
  }
59
59
  }
60
60
  function be() {
61
- return new Xe({
61
+ return new Ze({
62
62
  nodes: [
63
63
  {
64
64
  type: "paragraph",
@@ -141,13 +141,13 @@ function be() {
141
141
  topNode: "paragraph"
142
142
  });
143
143
  }
144
- function O() {
144
+ function w() {
145
145
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
146
146
  const t = Math.random() * 16 | 0;
147
147
  return (r === "x" ? t : t & 3 | 8).toString(16);
148
148
  });
149
149
  }
150
- class qe {
150
+ class Je {
151
151
  constructor(t) {
152
152
  this.schema = t;
153
153
  }
@@ -166,7 +166,7 @@ class qe {
166
166
  */
167
167
  paragraph(t, e) {
168
168
  return {
169
- id: O(),
169
+ id: w(),
170
170
  type: "paragraph",
171
171
  attrs: e,
172
172
  children: t || []
@@ -175,11 +175,11 @@ class qe {
175
175
  /**
176
176
  * Create a heading node
177
177
  */
178
- heading(t, e, i) {
178
+ heading(t, e, n) {
179
179
  return {
180
- id: O(),
180
+ id: w(),
181
181
  type: "heading",
182
- attrs: { ...i, level: t },
182
+ attrs: { ...n, level: t },
183
183
  children: e || []
184
184
  };
185
185
  }
@@ -188,7 +188,7 @@ class qe {
188
188
  */
189
189
  list(t, e) {
190
190
  return {
191
- id: O(),
191
+ id: w(),
192
192
  type: "list",
193
193
  attrs: e,
194
194
  children: t
@@ -199,7 +199,7 @@ class qe {
199
199
  */
200
200
  listItem(t, e) {
201
201
  return {
202
- id: O(),
202
+ id: w(),
203
203
  type: "list_item",
204
204
  attrs: e,
205
205
  children: t
@@ -210,7 +210,7 @@ class qe {
210
210
  */
211
211
  table(t, e) {
212
212
  return {
213
- id: O(),
213
+ id: w(),
214
214
  type: "table",
215
215
  attrs: e,
216
216
  children: t
@@ -221,7 +221,7 @@ class qe {
221
221
  */
222
222
  tableRow(t, e) {
223
223
  return {
224
- id: O(),
224
+ id: w(),
225
225
  type: "table_row",
226
226
  attrs: e,
227
227
  children: t
@@ -232,7 +232,7 @@ class qe {
232
232
  */
233
233
  tableCell(t, e) {
234
234
  return {
235
- id: O(),
235
+ id: w(),
236
236
  type: "table_cell",
237
237
  attrs: e,
238
238
  children: t
@@ -241,11 +241,11 @@ class qe {
241
241
  /**
242
242
  * Create an image node
243
243
  */
244
- image(t, e, i) {
244
+ image(t, e, n) {
245
245
  return {
246
- id: O(),
246
+ id: w(),
247
247
  type: "image",
248
- attrs: { src: t, alt: e || "", decorative: !e, ...i },
248
+ attrs: { src: t, alt: e || "", decorative: !e, ...n },
249
249
  children: []
250
250
  };
251
251
  }
@@ -254,7 +254,7 @@ class qe {
254
254
  */
255
255
  codeBlock(t, e) {
256
256
  return {
257
- id: O(),
257
+ id: w(),
258
258
  type: "code_block",
259
259
  attrs: e,
260
260
  children: [this.text(t)]
@@ -263,14 +263,14 @@ class qe {
263
263
  /**
264
264
  * Create a generic block node
265
265
  */
266
- block(t, e, i) {
266
+ block(t, e, n) {
267
267
  if (!this.schema.node(t))
268
268
  throw new Error(`Unknown node type: ${t}`);
269
269
  return {
270
- id: O(),
270
+ id: w(),
271
271
  type: t,
272
272
  attrs: e,
273
- children: i
273
+ children: n
274
274
  };
275
275
  }
276
276
  /**
@@ -290,18 +290,18 @@ class qe {
290
290
  cloneNode(t, e) {
291
291
  return {
292
292
  ...t,
293
- id: O(),
293
+ id: w(),
294
294
  // Generate new ID for cloned node
295
295
  children: e !== void 0 ? e : t.children
296
296
  };
297
297
  }
298
298
  }
299
- function Ze(r) {
300
- return new qe(r);
299
+ function Qe(r) {
300
+ return new Je(r);
301
301
  }
302
- class it {
303
- constructor(t, e, i) {
304
- this.selection = null, this.history = [], this.historyIndex = -1, this.schema = e || be(), this.nodeFactory = Ze(this.schema), this.maxHistoryDepth = i?.maxHistoryDepth || 100, this.document = t || {
302
+ class ot {
303
+ constructor(t, e, n) {
304
+ this.selection = null, this.history = [], this.historyIndex = -1, this.schema = e || be(), this.nodeFactory = Qe(this.schema), this.maxHistoryDepth = n?.maxHistoryDepth || 100, this.document = t || {
305
305
  version: 0,
306
306
  schemaVersion: "1.0.0",
307
307
  children: [this.nodeFactory.paragraph()]
@@ -339,9 +339,9 @@ class it {
339
339
  throw new Error(
340
340
  `Delta version mismatch: expected ${this.document.version}, got ${t.baseVersion}`
341
341
  );
342
- t.ops.some((i) => i.op !== "update_selection") && this.addToHistory(t);
343
- for (const i of t.ops)
344
- this.applyOperation(i);
342
+ t.ops.some((n) => n.op !== "update_selection") && this.addToHistory(t);
343
+ for (const n of t.ops)
344
+ this.applyOperation(n);
345
345
  this.document.version++;
346
346
  }
347
347
  /**
@@ -387,10 +387,10 @@ class it {
387
387
  applyInsertText(t) {
388
388
  const e = this.findBlock(t.target.blockId);
389
389
  if (!e || !e.children) return;
390
- const i = e.children.find((o) => "text" in o);
391
- if (i) {
392
- const o = i.text.slice(0, t.target.offset), a = i.text.slice(t.target.offset);
393
- i.text = o + t.text + a, t.marks && t.marks.length > 0 && (i.marks = t.marks);
390
+ const n = e.children.find((o) => "text" in o);
391
+ if (n) {
392
+ const o = n.text.slice(0, t.target.offset), s = n.text.slice(t.target.offset);
393
+ n.text = o + t.text + s, t.marks && t.marks.length > 0 && (n.marks = t.marks);
394
394
  }
395
395
  }
396
396
  /**
@@ -399,10 +399,10 @@ class it {
399
399
  applyDeleteRange(t) {
400
400
  const e = this.findBlock(t.range.start.blockId);
401
401
  if (!e || !e.children) return;
402
- const i = e.children.find((o) => "text" in o);
403
- if (i) {
404
- const o = i.text.slice(0, t.range.start.offset), a = i.text.slice(t.range.end.offset);
405
- i.text = o + a;
402
+ const n = e.children.find((o) => "text" in o);
403
+ if (n) {
404
+ const o = n.text.slice(0, t.range.start.offset), s = n.text.slice(t.range.end.offset);
405
+ n.text = o + s;
406
406
  }
407
407
  }
408
408
  /**
@@ -411,28 +411,28 @@ class it {
411
411
  applyMark(t) {
412
412
  const e = this.findBlock(t.range.start.blockId);
413
413
  if (!e || !e.children) return;
414
- const i = e.children.find((o) => "text" in o);
415
- i && (t.add ? (i.marks = i.marks || [], i.marks.some((o) => o.type === t.mark.type) || i.marks.push(t.mark)) : i.marks = i.marks?.filter((o) => o.type !== t.mark.type));
414
+ const n = e.children.find((o) => "text" in o);
415
+ n && (t.add ? (n.marks = n.marks || [], n.marks.some((o) => o.type === t.mark.type) || n.marks.push(t.mark)) : n.marks = n.marks?.filter((o) => o.type !== t.mark.type));
416
416
  }
417
417
  /**
418
418
  * Apply insert block after operation
419
419
  */
420
420
  applyInsertBlockAfter(t) {
421
- const e = this.document.children.findIndex((i) => i.id === t.after);
421
+ const e = this.document.children.findIndex((n) => n.id === t.after);
422
422
  e !== -1 && this.document.children.splice(e + 1, 0, t.block);
423
423
  }
424
424
  /**
425
425
  * Apply insert block before operation
426
426
  */
427
427
  applyInsertBlockBefore(t) {
428
- const e = this.document.children.findIndex((i) => i.id === t.before);
428
+ const e = this.document.children.findIndex((n) => n.id === t.before);
429
429
  e !== -1 && this.document.children.splice(e, 0, t.block);
430
430
  }
431
431
  /**
432
432
  * Apply delete block operation
433
433
  */
434
434
  applyDeleteBlock(t) {
435
- const e = this.document.children.findIndex((i) => i.id === t.target.blockId);
435
+ const e = this.document.children.findIndex((n) => n.id === t.target.blockId);
436
436
  e !== -1 && this.document.children.splice(e, 1);
437
437
  }
438
438
  /**
@@ -446,13 +446,13 @@ class it {
446
446
  * Find a block by ID
447
447
  */
448
448
  findBlock(t) {
449
- const e = (i) => {
450
- for (const o of i) {
449
+ const e = (n) => {
450
+ for (const o of n) {
451
451
  if (o.id === t)
452
452
  return o;
453
453
  if (o.children) {
454
- const a = o.children.filter((h) => "id" in h), u = e(a);
455
- if (u) return u;
454
+ const s = o.children.filter((h) => "id" in h), l = e(s);
455
+ if (l) return l;
456
456
  }
457
457
  }
458
458
  };
@@ -506,37 +506,205 @@ class it {
506
506
  * Create state from JSON
507
507
  */
508
508
  static fromJSON(t, e) {
509
- return new it(t, e);
509
+ return new ot(t, e);
510
510
  }
511
511
  }
512
- class Je {
512
+ const Un = 100, Fn = 100, Hn = 100, Gn = 200, R = {
513
+ // Plugin-related errors
514
+ PLUGIN_ALREADY_REGISTERED: "PLUGIN_ALREADY_REGISTERED",
515
+ PLUGIN_NOT_FOUND: "PLUGIN_NOT_FOUND",
516
+ PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
517
+ PLUGIN_INVALID_CONFIG: "PLUGIN_INVALID_CONFIG",
518
+ PLUGIN_INIT_FAILED: "PLUGIN_INIT_FAILED",
519
+ PLUGIN_DESTROY_FAILED: "PLUGIN_DESTROY_FAILED",
520
+ PLUGIN_DEPENDENCY_CONFLICT: "PLUGIN_DEPENDENCY_CONFLICT",
521
+ // Editor state errors
522
+ EDITOR_NOT_MOUNTED: "EDITOR_NOT_MOUNTED",
523
+ EDITOR_NOT_INITIALIZED: "EDITOR_NOT_INITIALIZED",
524
+ EDITOR_DESTROYED: "EDITOR_DESTROYED",
525
+ // Command errors
526
+ COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND",
527
+ COMMAND_ALREADY_REGISTERED: "COMMAND_ALREADY_REGISTERED",
528
+ COMMAND_EXECUTION_FAILED: "COMMAND_EXECUTION_FAILED",
529
+ COMMAND_INVALID_ARGS: "COMMAND_INVALID_ARGS",
530
+ // Content errors
531
+ INVALID_CONTENT: "INVALID_CONTENT",
532
+ INVALID_DELTA: "INVALID_DELTA",
533
+ INVALID_DOCUMENT: "INVALID_DOCUMENT",
534
+ SANITIZATION_FAILED: "SANITIZATION_FAILED",
535
+ // Security errors
536
+ XSS_DETECTED: "XSS_DETECTED",
537
+ UNSAFE_OPERATION: "UNSAFE_OPERATION",
538
+ // General errors
539
+ INVALID_OPERATION: "INVALID_OPERATION",
540
+ INTERNAL_ERROR: "INTERNAL_ERROR"
541
+ };
542
+ class O extends Error {
543
+ constructor(t, e, n) {
544
+ super(e), this.code = t, this.details = n, this.name = "NotectlError", Error.captureStackTrace && Error.captureStackTrace(this, O);
545
+ }
546
+ /**
547
+ * Convert to JSON-serializable format
548
+ */
549
+ toJSON() {
550
+ return {
551
+ error: {
552
+ code: this.code,
553
+ message: this.message,
554
+ details: this.details
555
+ }
556
+ };
557
+ }
558
+ }
559
+ const Bn = {
560
+ NO_DANGLING_REFS: "noDanglingRefs",
561
+ TABLE_GRID_CONSISTENT: "tableGridConsistent",
562
+ ALT_OR_DECORATIVE: "altOrDecorative",
563
+ RTL_INTEGRITY: "rtlIntegrity"
564
+ };
565
+ class tn {
513
566
  constructor() {
514
567
  this.plugins = /* @__PURE__ */ new Map(), this.initializationOrder = [];
515
568
  }
516
569
  /**
517
570
  * Register a plugin
571
+ *
572
+ * @param plugin - The plugin to register
573
+ * @param context - Plugin context with editor APIs
574
+ * @throws {NotectlError} If plugin validation fails or initialization errors occur
575
+ *
576
+ * @example
577
+ * ```typescript
578
+ * const toolbarPlugin = new ToolbarPlugin();
579
+ * await pluginManager.register(toolbarPlugin, context);
580
+ * ```
518
581
  */
519
582
  async register(t, e) {
520
- if (this.plugins.has(t.id))
521
- throw new Error(`Plugin ${t.id} is already registered`);
522
- if (t.dependencies) {
523
- for (const i of t.dependencies)
524
- if (!this.plugins.has(i))
525
- throw new Error(`Plugin ${t.id} depends on ${i} which is not registered`);
583
+ if (!t)
584
+ throw new O(
585
+ R.PLUGIN_INVALID_CONFIG,
586
+ "Cannot register null or undefined plugin"
587
+ );
588
+ if (!t.id || typeof t.id != "string")
589
+ throw new O(
590
+ R.PLUGIN_INVALID_CONFIG,
591
+ 'Plugin must have a valid string "id" property',
592
+ { plugin: t }
593
+ );
594
+ if (!t.name || typeof t.name != "string")
595
+ throw new O(
596
+ R.PLUGIN_INVALID_CONFIG,
597
+ `Plugin "${t.id}" must have a valid string "name" property`,
598
+ { pluginId: t.id }
599
+ );
600
+ if (!t.version || typeof t.version != "string")
601
+ throw new O(
602
+ R.PLUGIN_INVALID_CONFIG,
603
+ `Plugin "${t.id}" must have a valid string "version" property`,
604
+ { pluginId: t.id, pluginName: t.name }
605
+ );
606
+ if (typeof t.init != "function")
607
+ throw new O(
608
+ R.PLUGIN_INVALID_CONFIG,
609
+ `Plugin "${t.id}" must have an "init" method`,
610
+ { pluginId: t.id, pluginName: t.name }
611
+ );
612
+ if (this.plugins.has(t.id)) {
613
+ const n = this.plugins.get(t.id);
614
+ throw new O(
615
+ R.PLUGIN_ALREADY_REGISTERED,
616
+ `Plugin "${t.id}" is already registered (version: ${n.version})`,
617
+ { pluginId: t.id, existingVersion: n.version, newVersion: t.version }
618
+ );
619
+ }
620
+ if (t.dependencies && t.dependencies.length > 0) {
621
+ const n = [];
622
+ for (const o of t.dependencies)
623
+ this.plugins.has(o) || n.push(o);
624
+ if (n.length > 0)
625
+ throw new O(
626
+ R.PLUGIN_MISSING_DEPENDENCY,
627
+ `Plugin "${t.id}" (${t.name}) cannot be registered because the following dependencies are missing: ${n.join(", ")}. Please register these plugins first.`,
628
+ {
629
+ pluginId: t.id,
630
+ pluginName: t.name,
631
+ missingDependencies: n,
632
+ registeredPlugins: Array.from(this.plugins.keys())
633
+ }
634
+ );
635
+ }
636
+ try {
637
+ await t.init(e);
638
+ } catch (n) {
639
+ throw new O(
640
+ R.PLUGIN_INIT_FAILED,
641
+ `Failed to initialize plugin "${t.id}" (${t.name}): ${n instanceof Error ? n.message : String(n)}`,
642
+ {
643
+ pluginId: t.id,
644
+ pluginName: t.name,
645
+ originalError: n
646
+ }
647
+ );
526
648
  }
527
- await t.init(e), this.plugins.set(t.id, t), this.initializationOrder.push(t.id), e.emit("plugin-registered", { pluginId: t.id, plugin: t });
649
+ this.plugins.set(t.id, t), this.initializationOrder.push(t.id), e.emit("plugin-registered", { pluginId: t.id, plugin: t });
528
650
  }
529
651
  /**
530
652
  * Unregister a plugin
653
+ *
654
+ * @param pluginId - ID of the plugin to unregister
655
+ * @param context - Plugin context for event emission
656
+ * @throws {NotectlError} If plugin is not found or has dependents
657
+ *
658
+ * @example
659
+ * ```typescript
660
+ * await pluginManager.unregister('toolbar-plugin', context);
661
+ * ```
531
662
  */
532
663
  async unregister(t, e) {
533
- const i = this.plugins.get(t);
534
- if (!i)
535
- throw new Error(`Plugin ${t} is not registered`);
536
- for (const [o, a] of this.plugins.entries())
537
- if (a.dependencies?.includes(t))
538
- throw new Error(`Cannot unregister ${t}: plugin ${o} depends on it`);
539
- i.destroy && await i.destroy(), this.plugins.delete(t), this.initializationOrder = this.initializationOrder.filter((o) => o !== t), e.emit("plugin-unregistered", { pluginId: t });
664
+ if (!t || typeof t != "string")
665
+ throw new O(
666
+ R.PLUGIN_NOT_FOUND,
667
+ "Plugin ID must be a non-empty string",
668
+ { pluginId: t }
669
+ );
670
+ const n = this.plugins.get(t);
671
+ if (!n)
672
+ throw new O(
673
+ R.PLUGIN_NOT_FOUND,
674
+ `Plugin "${t}" is not registered and cannot be unregistered`,
675
+ {
676
+ pluginId: t,
677
+ registeredPlugins: Array.from(this.plugins.keys())
678
+ }
679
+ );
680
+ const o = [];
681
+ for (const [s, l] of this.plugins.entries())
682
+ l.dependencies?.includes(t) && o.push(`${s} (${l.name})`);
683
+ if (o.length > 0)
684
+ throw new O(
685
+ R.PLUGIN_DEPENDENCY_CONFLICT,
686
+ `Cannot unregister plugin "${t}" (${n.name}) because the following plugins depend on it: ${o.join(", ")}. Please unregister dependent plugins first.`,
687
+ {
688
+ pluginId: t,
689
+ pluginName: n.name,
690
+ dependentPlugins: o
691
+ }
692
+ );
693
+ if (n.destroy)
694
+ try {
695
+ await n.destroy();
696
+ } catch (s) {
697
+ throw new O(
698
+ R.PLUGIN_DESTROY_FAILED,
699
+ `Failed to destroy plugin "${t}" (${n.name}): ${s instanceof Error ? s.message : String(s)}`,
700
+ {
701
+ pluginId: t,
702
+ pluginName: n.name,
703
+ originalError: s
704
+ }
705
+ );
706
+ }
707
+ this.plugins.delete(t), this.initializationOrder = this.initializationOrder.filter((s) => s !== t), e.emit("plugin-unregistered", { pluginId: t });
540
708
  }
541
709
  /**
542
710
  * Get a plugin by ID
@@ -560,13 +728,13 @@ class Je {
560
728
  * Notify plugins of state update
561
729
  */
562
730
  notifyStateUpdate(t, e) {
563
- for (const i of this.initializationOrder) {
564
- const o = this.plugins.get(i);
731
+ for (const n of this.initializationOrder) {
732
+ const o = this.plugins.get(n);
565
733
  if (o?.onStateUpdate)
566
734
  try {
567
735
  o.onStateUpdate(t, e);
568
- } catch (a) {
569
- console.error(`Error in plugin ${i} onStateUpdate:`, a);
736
+ } catch (s) {
737
+ console.error(`Error in plugin ${n} onStateUpdate:`, s);
570
738
  }
571
739
  }
572
740
  }
@@ -575,10 +743,10 @@ class Je {
575
743
  */
576
744
  notifyDeltaApplied(t) {
577
745
  for (const e of this.initializationOrder) {
578
- const i = this.plugins.get(e);
579
- if (i?.onDeltaApplied)
746
+ const n = this.plugins.get(e);
747
+ if (n?.onDeltaApplied)
580
748
  try {
581
- i.onDeltaApplied(t);
749
+ n.onDeltaApplied(t);
582
750
  } catch (o) {
583
751
  console.error(`Error in plugin ${e} onDeltaApplied:`, o);
584
752
  }
@@ -590,10 +758,10 @@ class Je {
590
758
  async destroyAll() {
591
759
  const t = [...this.initializationOrder].reverse();
592
760
  for (const e of t) {
593
- const i = this.plugins.get(e);
594
- if (i?.destroy)
761
+ const n = this.plugins.get(e);
762
+ if (n?.destroy)
595
763
  try {
596
- await i.destroy();
764
+ await n.destroy();
597
765
  } catch (o) {
598
766
  console.error(`Error destroying plugin ${e}:`, o);
599
767
  }
@@ -603,142 +771,142 @@ class Je {
603
771
  }
604
772
  /*! @license DOMPurify 3.2.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.7/LICENSE */
605
773
  const {
606
- entries: _e,
607
- setPrototypeOf: he,
608
- isFrozen: Qe,
609
- getPrototypeOf: tn,
610
- getOwnPropertyDescriptor: en
774
+ entries: Ae,
775
+ setPrototypeOf: pe,
776
+ isFrozen: en,
777
+ getPrototypeOf: nn,
778
+ getOwnPropertyDescriptor: rn
611
779
  } = Object;
612
780
  let {
613
- freeze: k,
614
- seal: w,
615
- create: xe
781
+ freeze: D,
782
+ seal: C,
783
+ create: Ne
616
784
  } = Object, {
617
- apply: Ft,
618
- construct: zt
785
+ apply: Bt,
786
+ construct: $t
619
787
  } = typeof Reflect < "u" && Reflect;
620
- k || (k = function(t) {
788
+ D || (D = function(t) {
621
789
  return t;
622
790
  });
623
- w || (w = function(t) {
791
+ C || (C = function(t) {
624
792
  return t;
625
793
  });
626
- Ft || (Ft = function(t, e) {
627
- for (var i = arguments.length, o = new Array(i > 2 ? i - 2 : 0), a = 2; a < i; a++)
628
- o[a - 2] = arguments[a];
794
+ Bt || (Bt = function(t, e) {
795
+ for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), s = 2; s < n; s++)
796
+ o[s - 2] = arguments[s];
629
797
  return t.apply(e, o);
630
798
  });
631
- zt || (zt = function(t) {
632
- for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
633
- i[o - 1] = arguments[o];
634
- return new t(...i);
799
+ $t || ($t = function(t) {
800
+ for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
801
+ n[o - 1] = arguments[o];
802
+ return new t(...n);
635
803
  });
636
- const mt = L(Array.prototype.forEach), nn = L(Array.prototype.lastIndexOf), fe = L(Array.prototype.pop), J = L(Array.prototype.push), rn = L(Array.prototype.splice), yt = L(String.prototype.toLowerCase), vt = L(String.prototype.toString), Dt = L(String.prototype.match), Q = L(String.prototype.replace), on = L(String.prototype.indexOf), sn = L(String.prototype.trim), N = L(Object.prototype.hasOwnProperty), A = L(RegExp.prototype.test), tt = an(TypeError);
637
- function L(r) {
804
+ const Et = x(Array.prototype.forEach), on = x(Array.prototype.lastIndexOf), me = x(Array.prototype.pop), tt = x(Array.prototype.push), sn = x(Array.prototype.splice), Tt = x(String.prototype.toLowerCase), vt = x(String.prototype.toString), Pt = x(String.prototype.match), et = x(String.prototype.replace), an = x(String.prototype.indexOf), ln = x(String.prototype.trim), M = x(Object.prototype.hasOwnProperty), S = x(RegExp.prototype.test), nt = cn(TypeError);
805
+ function x(r) {
638
806
  return function(t) {
639
807
  t instanceof RegExp && (t.lastIndex = 0);
640
- for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
641
- i[o - 1] = arguments[o];
642
- return Ft(r, t, i);
808
+ for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
809
+ n[o - 1] = arguments[o];
810
+ return Bt(r, t, n);
643
811
  };
644
812
  }
645
- function an(r) {
813
+ function cn(r) {
646
814
  return function() {
647
- for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++)
648
- e[i] = arguments[i];
649
- return zt(r, e);
815
+ for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
816
+ e[n] = arguments[n];
817
+ return $t(r, e);
650
818
  };
651
819
  }
652
- function d(r, t) {
653
- let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : yt;
654
- he && he(r, null);
655
- let i = t.length;
656
- for (; i--; ) {
657
- let o = t[i];
820
+ function u(r, t) {
821
+ let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Tt;
822
+ pe && pe(r, null);
823
+ let n = t.length;
824
+ for (; n--; ) {
825
+ let o = t[n];
658
826
  if (typeof o == "string") {
659
- const a = e(o);
660
- a !== o && (Qe(t) || (t[i] = a), o = a);
827
+ const s = e(o);
828
+ s !== o && (en(t) || (t[n] = s), o = s);
661
829
  }
662
830
  r[o] = !0;
663
831
  }
664
832
  return r;
665
833
  }
666
- function ln(r) {
834
+ function dn(r) {
667
835
  for (let t = 0; t < r.length; t++)
668
- N(r, t) || (r[t] = null);
836
+ M(r, t) || (r[t] = null);
669
837
  return r;
670
838
  }
671
- function U(r) {
672
- const t = xe(null);
673
- for (const [e, i] of _e(r))
674
- N(r, e) && (Array.isArray(i) ? t[e] = ln(i) : i && typeof i == "object" && i.constructor === Object ? t[e] = U(i) : t[e] = i);
839
+ function H(r) {
840
+ const t = Ne(null);
841
+ for (const [e, n] of Ae(r))
842
+ M(r, e) && (Array.isArray(n) ? t[e] = dn(n) : n && typeof n == "object" && n.constructor === Object ? t[e] = H(n) : t[e] = n);
675
843
  return t;
676
844
  }
677
- function et(r, t) {
845
+ function it(r, t) {
678
846
  for (; r !== null; ) {
679
- const i = en(r, t);
680
- if (i) {
681
- if (i.get)
682
- return L(i.get);
683
- if (typeof i.value == "function")
684
- return L(i.value);
847
+ const n = rn(r, t);
848
+ if (n) {
849
+ if (n.get)
850
+ return x(n.get);
851
+ if (typeof n.value == "function")
852
+ return x(n.value);
685
853
  }
686
- r = tn(r);
854
+ r = nn(r);
687
855
  }
688
856
  function e() {
689
857
  return null;
690
858
  }
691
859
  return e;
692
860
  }
693
- const pe = k(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Mt = k(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "slot", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Pt = k(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), cn = k(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Ut = k(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), dn = k(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), me = k(["#text"]), ge = k(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Ht = k(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), ye = k(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), gt = k(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), un = w(/\{\{[\w\W]*|[\w\W]*\}\}/gm), hn = w(/<%[\w\W]*|[\w\W]*%>/gm), fn = w(/\$\{[\w\W]*/gm), pn = w(/^data-[\-\w.\u00B7-\uFFFF]+$/), mn = w(/^aria-[\-\w]+$/), Se = w(
861
+ const ge = D(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Ut = D(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "slot", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Ft = D(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), hn = D(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Ht = D(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), un = D(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Ee = D(["#text"]), ye = D(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Gt = D(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Te = D(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), yt = D(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), fn = C(/\{\{[\w\W]*|[\w\W]*\}\}/gm), pn = C(/<%[\w\W]*|[\w\W]*%>/gm), mn = C(/\$\{[\w\W]*/gm), gn = C(/^data-[\-\w.\u00B7-\uFFFF]+$/), En = C(/^aria-[\-\w]+$/), Se = C(
694
862
  /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
695
863
  // eslint-disable-line no-useless-escape
696
- ), gn = w(/^(?:\w+script|data):/i), yn = w(
864
+ ), yn = C(/^(?:\w+script|data):/i), Tn = C(
697
865
  /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
698
866
  // eslint-disable-line no-control-regex
699
- ), Ae = w(/^html$/i), En = w(/^[a-z][.\w]*(-[.\w]+)+$/i);
700
- var Ee = /* @__PURE__ */ Object.freeze({
867
+ ), De = C(/^html$/i), _n = C(/^[a-z][.\w]*(-[.\w]+)+$/i);
868
+ var _e = /* @__PURE__ */ Object.freeze({
701
869
  __proto__: null,
702
- ARIA_ATTR: mn,
703
- ATTR_WHITESPACE: yn,
704
- CUSTOM_ELEMENT: En,
705
- DATA_ATTR: pn,
706
- DOCTYPE_NAME: Ae,
707
- ERB_EXPR: hn,
870
+ ARIA_ATTR: En,
871
+ ATTR_WHITESPACE: Tn,
872
+ CUSTOM_ELEMENT: _n,
873
+ DATA_ATTR: gn,
874
+ DOCTYPE_NAME: De,
875
+ ERB_EXPR: pn,
708
876
  IS_ALLOWED_URI: Se,
709
- IS_SCRIPT_OR_DATA: gn,
710
- MUSTACHE_EXPR: un,
711
- TMPLIT_EXPR: fn
877
+ IS_SCRIPT_OR_DATA: yn,
878
+ MUSTACHE_EXPR: fn,
879
+ TMPLIT_EXPR: mn
712
880
  });
713
- const nt = {
881
+ const rt = {
714
882
  element: 1,
715
883
  text: 3,
716
884
  // Deprecated
717
885
  progressingInstruction: 7,
718
886
  comment: 8,
719
887
  document: 9
720
- }, Tn = function() {
888
+ }, In = function() {
721
889
  return typeof window > "u" ? null : window;
722
890
  }, bn = function(t, e) {
723
891
  if (typeof t != "object" || typeof t.createPolicy != "function")
724
892
  return null;
725
- let i = null;
893
+ let n = null;
726
894
  const o = "data-tt-policy-suffix";
727
- e && e.hasAttribute(o) && (i = e.getAttribute(o));
728
- const a = "dompurify" + (i ? "#" + i : "");
895
+ e && e.hasAttribute(o) && (n = e.getAttribute(o));
896
+ const s = "dompurify" + (n ? "#" + n : "");
729
897
  try {
730
- return t.createPolicy(a, {
731
- createHTML(u) {
732
- return u;
898
+ return t.createPolicy(s, {
899
+ createHTML(l) {
900
+ return l;
733
901
  },
734
- createScriptURL(u) {
735
- return u;
902
+ createScriptURL(l) {
903
+ return l;
736
904
  }
737
905
  });
738
906
  } catch {
739
- return console.warn("TrustedTypes policy " + a + " could not be created."), null;
907
+ return console.warn("TrustedTypes policy " + s + " could not be created."), null;
740
908
  }
741
- }, Te = function() {
909
+ }, Ie = function() {
742
910
  return {
743
911
  afterSanitizeAttributes: [],
744
912
  afterSanitizeElements: [],
@@ -751,57 +919,57 @@ const nt = {
751
919
  uponSanitizeShadowNode: []
752
920
  };
753
921
  };
754
- function ke() {
755
- let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Tn();
756
- const t = (c) => ke(c);
757
- if (t.version = "3.2.7", t.removed = [], !r || !r.document || r.document.nodeType !== nt.document || !r.Element)
922
+ function xe() {
923
+ let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : In();
924
+ const t = (d) => xe(d);
925
+ if (t.version = "3.2.7", t.removed = [], !r || !r.document || r.document.nodeType !== rt.document || !r.Element)
758
926
  return t.isSupported = !1, t;
759
927
  let {
760
928
  document: e
761
929
  } = r;
762
- const i = e, o = i.currentScript, {
763
- DocumentFragment: a,
764
- HTMLTemplateElement: u,
930
+ const n = e, o = n.currentScript, {
931
+ DocumentFragment: s,
932
+ HTMLTemplateElement: l,
765
933
  Node: h,
766
- Element: p,
767
- NodeFilter: R,
768
- NamedNodeMap: I = r.NamedNodeMap || r.MozNamedAttrMap,
769
- HTMLFormElement: ot,
770
- DOMParser: Ce,
771
- trustedTypes: st
772
- } = r, V = p.prototype, we = et(V, "cloneNode"), Ie = et(V, "remove"), Oe = et(V, "nextSibling"), Ne = et(V, "childNodes"), at = et(V, "parentNode");
773
- if (typeof u == "function") {
774
- const c = e.createElement("template");
775
- c.content && c.content.ownerDocument && (e = c.content.ownerDocument);
776
- }
777
- let x, j = "";
934
+ Element: f,
935
+ NodeFilter: E,
936
+ NamedNodeMap: L = r.NamedNodeMap || r.MozNamedAttrMap,
937
+ HTMLFormElement: at,
938
+ DOMParser: Oe,
939
+ trustedTypes: lt
940
+ } = r, X = f.prototype, Re = it(X, "cloneNode"), Ce = it(X, "remove"), we = it(X, "nextSibling"), Me = it(X, "childNodes"), ct = it(X, "parentNode");
941
+ if (typeof l == "function") {
942
+ const d = e.createElement("template");
943
+ d.content && d.content.ownerDocument && (e = d.content.ownerDocument);
944
+ }
945
+ let A, q = "";
778
946
  const {
779
- implementation: Et,
947
+ implementation: _t,
780
948
  createNodeIterator: ve,
781
- createDocumentFragment: De,
782
- getElementsByTagName: Me
949
+ createDocumentFragment: Pe,
950
+ getElementsByTagName: Ue
783
951
  } = e, {
784
- importNode: Pe
785
- } = i;
786
- let S = Te();
787
- t.isSupported = typeof _e == "function" && typeof at == "function" && Et && Et.createHTMLDocument !== void 0;
952
+ importNode: Fe
953
+ } = n;
954
+ let N = Ie();
955
+ t.isSupported = typeof Ae == "function" && typeof ct == "function" && _t && _t.createHTMLDocument !== void 0;
788
956
  const {
789
- MUSTACHE_EXPR: Tt,
957
+ MUSTACHE_EXPR: It,
790
958
  ERB_EXPR: bt,
791
- TMPLIT_EXPR: _t,
792
- DATA_ATTR: Ue,
793
- ARIA_ATTR: He,
794
- IS_SCRIPT_OR_DATA: Fe,
795
- ATTR_WHITESPACE: $t,
796
- CUSTOM_ELEMENT: ze
797
- } = Ee;
959
+ TMPLIT_EXPR: At,
960
+ DATA_ATTR: He,
961
+ ARIA_ATTR: Ge,
962
+ IS_SCRIPT_OR_DATA: Be,
963
+ ATTR_WHITESPACE: zt,
964
+ CUSTOM_ELEMENT: $e
965
+ } = _e;
798
966
  let {
799
- IS_ALLOWED_URI: Gt
800
- } = Ee, y = null;
801
- const Wt = d({}, [...pe, ...Mt, ...Pt, ...Ut, ...me]);
802
- let T = null;
803
- const Bt = d({}, [...ge, ...Ht, ...ye, ...gt]);
804
- let m = Object.seal(xe(null, {
967
+ IS_ALLOWED_URI: Vt
968
+ } = _e, y = null;
969
+ const Wt = u({}, [...ge, ...Ut, ...Ft, ...Ht, ...Ee]);
970
+ let _ = null;
971
+ const Yt = u({}, [...ye, ...Gt, ...Te, ...yt]);
972
+ let m = Object.seal(Ne(null, {
805
973
  tagNameCheck: {
806
974
  writable: !0,
807
975
  configurable: !1,
@@ -820,168 +988,168 @@ function ke() {
820
988
  enumerable: !0,
821
989
  value: !1
822
990
  }
823
- })), X = null, xt = null, Kt = !0, St = !0, Yt = !1, Vt = !0, z = !1, lt = !0, H = !1, At = !1, kt = !1, $ = !1, ct = !1, dt = !1, jt = !0, Xt = !1;
824
- const $e = "user-content-";
825
- let Lt = !0, q = !1, G = {}, W = null;
826
- const qt = d({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
827
- let Zt = null;
828
- const Jt = d({}, ["audio", "video", "img", "source", "image", "track"]);
829
- let Rt = null;
830
- const Qt = d({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ut = "http://www.w3.org/1998/Math/MathML", ht = "http://www.w3.org/2000/svg", D = "http://www.w3.org/1999/xhtml";
831
- let B = D, Ct = !1, wt = null;
832
- const Ge = d({}, [ut, ht, D], vt);
833
- let ft = d({}, ["mi", "mo", "mn", "ms", "mtext"]), pt = d({}, ["annotation-xml"]);
834
- const We = d({}, ["title", "style", "font", "a", "script"]);
835
- let Z = null;
836
- const Be = ["application/xhtml+xml", "text/html"], Ke = "text/html";
837
- let E = null, K = null;
838
- const Ye = e.createElement("form"), te = function(n) {
839
- return n instanceof RegExp || n instanceof Function;
840
- }, It = function() {
841
- let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
842
- if (!(K && K === n)) {
843
- if ((!n || typeof n != "object") && (n = {}), n = U(n), Z = // eslint-disable-next-line unicorn/prefer-includes
844
- Be.indexOf(n.PARSER_MEDIA_TYPE) === -1 ? Ke : n.PARSER_MEDIA_TYPE, E = Z === "application/xhtml+xml" ? vt : yt, y = N(n, "ALLOWED_TAGS") ? d({}, n.ALLOWED_TAGS, E) : Wt, T = N(n, "ALLOWED_ATTR") ? d({}, n.ALLOWED_ATTR, E) : Bt, wt = N(n, "ALLOWED_NAMESPACES") ? d({}, n.ALLOWED_NAMESPACES, vt) : Ge, Rt = N(n, "ADD_URI_SAFE_ATTR") ? d(U(Qt), n.ADD_URI_SAFE_ATTR, E) : Qt, Zt = N(n, "ADD_DATA_URI_TAGS") ? d(U(Jt), n.ADD_DATA_URI_TAGS, E) : Jt, W = N(n, "FORBID_CONTENTS") ? d({}, n.FORBID_CONTENTS, E) : qt, X = N(n, "FORBID_TAGS") ? d({}, n.FORBID_TAGS, E) : U({}), xt = N(n, "FORBID_ATTR") ? d({}, n.FORBID_ATTR, E) : U({}), G = N(n, "USE_PROFILES") ? n.USE_PROFILES : !1, Kt = n.ALLOW_ARIA_ATTR !== !1, St = n.ALLOW_DATA_ATTR !== !1, Yt = n.ALLOW_UNKNOWN_PROTOCOLS || !1, Vt = n.ALLOW_SELF_CLOSE_IN_ATTR !== !1, z = n.SAFE_FOR_TEMPLATES || !1, lt = n.SAFE_FOR_XML !== !1, H = n.WHOLE_DOCUMENT || !1, $ = n.RETURN_DOM || !1, ct = n.RETURN_DOM_FRAGMENT || !1, dt = n.RETURN_TRUSTED_TYPE || !1, kt = n.FORCE_BODY || !1, jt = n.SANITIZE_DOM !== !1, Xt = n.SANITIZE_NAMED_PROPS || !1, Lt = n.KEEP_CONTENT !== !1, q = n.IN_PLACE || !1, Gt = n.ALLOWED_URI_REGEXP || Se, B = n.NAMESPACE || D, ft = n.MATHML_TEXT_INTEGRATION_POINTS || ft, pt = n.HTML_INTEGRATION_POINTS || pt, m = n.CUSTOM_ELEMENT_HANDLING || {}, n.CUSTOM_ELEMENT_HANDLING && te(n.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (m.tagNameCheck = n.CUSTOM_ELEMENT_HANDLING.tagNameCheck), n.CUSTOM_ELEMENT_HANDLING && te(n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (m.attributeNameCheck = n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), n.CUSTOM_ELEMENT_HANDLING && typeof n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (m.allowCustomizedBuiltInElements = n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), z && (St = !1), ct && ($ = !0), G && (y = d({}, me), T = [], G.html === !0 && (d(y, pe), d(T, ge)), G.svg === !0 && (d(y, Mt), d(T, Ht), d(T, gt)), G.svgFilters === !0 && (d(y, Pt), d(T, Ht), d(T, gt)), G.mathMl === !0 && (d(y, Ut), d(T, ye), d(T, gt))), n.ADD_TAGS && (y === Wt && (y = U(y)), d(y, n.ADD_TAGS, E)), n.ADD_ATTR && (T === Bt && (T = U(T)), d(T, n.ADD_ATTR, E)), n.ADD_URI_SAFE_ATTR && d(Rt, n.ADD_URI_SAFE_ATTR, E), n.FORBID_CONTENTS && (W === qt && (W = U(W)), d(W, n.FORBID_CONTENTS, E)), Lt && (y["#text"] = !0), H && d(y, ["html", "head", "body"]), y.table && (d(y, ["tbody"]), delete X.tbody), n.TRUSTED_TYPES_POLICY) {
845
- if (typeof n.TRUSTED_TYPES_POLICY.createHTML != "function")
846
- throw tt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
847
- if (typeof n.TRUSTED_TYPES_POLICY.createScriptURL != "function")
848
- throw tt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
849
- x = n.TRUSTED_TYPES_POLICY, j = x.createHTML("");
991
+ })), Z = null, Nt = null, Kt = !0, St = !0, jt = !1, Xt = !0, $ = !1, dt = !0, G = !1, Dt = !1, xt = !1, z = !1, ht = !1, ut = !1, qt = !0, Zt = !1;
992
+ const ze = "user-content-";
993
+ let Lt = !0, J = !1, V = {}, W = null;
994
+ const Jt = u({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
995
+ let Qt = null;
996
+ const te = u({}, ["audio", "video", "img", "source", "image", "track"]);
997
+ let kt = null;
998
+ const ee = u({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ft = "http://www.w3.org/1998/Math/MathML", pt = "http://www.w3.org/2000/svg", P = "http://www.w3.org/1999/xhtml";
999
+ let Y = P, Ot = !1, Rt = null;
1000
+ const Ve = u({}, [ft, pt, P], vt);
1001
+ let mt = u({}, ["mi", "mo", "mn", "ms", "mtext"]), gt = u({}, ["annotation-xml"]);
1002
+ const We = u({}, ["title", "style", "font", "a", "script"]);
1003
+ let Q = null;
1004
+ const Ye = ["application/xhtml+xml", "text/html"], Ke = "text/html";
1005
+ let T = null, K = null;
1006
+ const je = e.createElement("form"), ne = function(i) {
1007
+ return i instanceof RegExp || i instanceof Function;
1008
+ }, Ct = function() {
1009
+ let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1010
+ if (!(K && K === i)) {
1011
+ if ((!i || typeof i != "object") && (i = {}), i = H(i), Q = // eslint-disable-next-line unicorn/prefer-includes
1012
+ Ye.indexOf(i.PARSER_MEDIA_TYPE) === -1 ? Ke : i.PARSER_MEDIA_TYPE, T = Q === "application/xhtml+xml" ? vt : Tt, y = M(i, "ALLOWED_TAGS") ? u({}, i.ALLOWED_TAGS, T) : Wt, _ = M(i, "ALLOWED_ATTR") ? u({}, i.ALLOWED_ATTR, T) : Yt, Rt = M(i, "ALLOWED_NAMESPACES") ? u({}, i.ALLOWED_NAMESPACES, vt) : Ve, kt = M(i, "ADD_URI_SAFE_ATTR") ? u(H(ee), i.ADD_URI_SAFE_ATTR, T) : ee, Qt = M(i, "ADD_DATA_URI_TAGS") ? u(H(te), i.ADD_DATA_URI_TAGS, T) : te, W = M(i, "FORBID_CONTENTS") ? u({}, i.FORBID_CONTENTS, T) : Jt, Z = M(i, "FORBID_TAGS") ? u({}, i.FORBID_TAGS, T) : H({}), Nt = M(i, "FORBID_ATTR") ? u({}, i.FORBID_ATTR, T) : H({}), V = M(i, "USE_PROFILES") ? i.USE_PROFILES : !1, Kt = i.ALLOW_ARIA_ATTR !== !1, St = i.ALLOW_DATA_ATTR !== !1, jt = i.ALLOW_UNKNOWN_PROTOCOLS || !1, Xt = i.ALLOW_SELF_CLOSE_IN_ATTR !== !1, $ = i.SAFE_FOR_TEMPLATES || !1, dt = i.SAFE_FOR_XML !== !1, G = i.WHOLE_DOCUMENT || !1, z = i.RETURN_DOM || !1, ht = i.RETURN_DOM_FRAGMENT || !1, ut = i.RETURN_TRUSTED_TYPE || !1, xt = i.FORCE_BODY || !1, qt = i.SANITIZE_DOM !== !1, Zt = i.SANITIZE_NAMED_PROPS || !1, Lt = i.KEEP_CONTENT !== !1, J = i.IN_PLACE || !1, Vt = i.ALLOWED_URI_REGEXP || Se, Y = i.NAMESPACE || P, mt = i.MATHML_TEXT_INTEGRATION_POINTS || mt, gt = i.HTML_INTEGRATION_POINTS || gt, m = i.CUSTOM_ELEMENT_HANDLING || {}, i.CUSTOM_ELEMENT_HANDLING && ne(i.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (m.tagNameCheck = i.CUSTOM_ELEMENT_HANDLING.tagNameCheck), i.CUSTOM_ELEMENT_HANDLING && ne(i.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (m.attributeNameCheck = i.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), i.CUSTOM_ELEMENT_HANDLING && typeof i.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (m.allowCustomizedBuiltInElements = i.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), $ && (St = !1), ht && (z = !0), V && (y = u({}, Ee), _ = [], V.html === !0 && (u(y, ge), u(_, ye)), V.svg === !0 && (u(y, Ut), u(_, Gt), u(_, yt)), V.svgFilters === !0 && (u(y, Ft), u(_, Gt), u(_, yt)), V.mathMl === !0 && (u(y, Ht), u(_, Te), u(_, yt))), i.ADD_TAGS && (y === Wt && (y = H(y)), u(y, i.ADD_TAGS, T)), i.ADD_ATTR && (_ === Yt && (_ = H(_)), u(_, i.ADD_ATTR, T)), i.ADD_URI_SAFE_ATTR && u(kt, i.ADD_URI_SAFE_ATTR, T), i.FORBID_CONTENTS && (W === Jt && (W = H(W)), u(W, i.FORBID_CONTENTS, T)), Lt && (y["#text"] = !0), G && u(y, ["html", "head", "body"]), y.table && (u(y, ["tbody"]), delete Z.tbody), i.TRUSTED_TYPES_POLICY) {
1013
+ if (typeof i.TRUSTED_TYPES_POLICY.createHTML != "function")
1014
+ throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1015
+ if (typeof i.TRUSTED_TYPES_POLICY.createScriptURL != "function")
1016
+ throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1017
+ A = i.TRUSTED_TYPES_POLICY, q = A.createHTML("");
850
1018
  } else
851
- x === void 0 && (x = bn(st, o)), x !== null && typeof j == "string" && (j = x.createHTML(""));
852
- k && k(n), K = n;
1019
+ A === void 0 && (A = bn(lt, o)), A !== null && typeof q == "string" && (q = A.createHTML(""));
1020
+ D && D(i), K = i;
853
1021
  }
854
- }, ee = d({}, [...Mt, ...Pt, ...cn]), ne = d({}, [...Ut, ...dn]), Ve = function(n) {
855
- let s = at(n);
856
- (!s || !s.tagName) && (s = {
857
- namespaceURI: B,
1022
+ }, ie = u({}, [...Ut, ...Ft, ...hn]), re = u({}, [...Ht, ...un]), Xe = function(i) {
1023
+ let a = ct(i);
1024
+ (!a || !a.tagName) && (a = {
1025
+ namespaceURI: Y,
858
1026
  tagName: "template"
859
1027
  });
860
- const l = yt(n.tagName), f = yt(s.tagName);
861
- return wt[n.namespaceURI] ? n.namespaceURI === ht ? s.namespaceURI === D ? l === "svg" : s.namespaceURI === ut ? l === "svg" && (f === "annotation-xml" || ft[f]) : !!ee[l] : n.namespaceURI === ut ? s.namespaceURI === D ? l === "math" : s.namespaceURI === ht ? l === "math" && pt[f] : !!ne[l] : n.namespaceURI === D ? s.namespaceURI === ht && !pt[f] || s.namespaceURI === ut && !ft[f] ? !1 : !ne[l] && (We[l] || !ee[l]) : !!(Z === "application/xhtml+xml" && wt[n.namespaceURI]) : !1;
862
- }, v = function(n) {
863
- J(t.removed, {
864
- element: n
1028
+ const c = Tt(i.tagName), p = Tt(a.tagName);
1029
+ return Rt[i.namespaceURI] ? i.namespaceURI === pt ? a.namespaceURI === P ? c === "svg" : a.namespaceURI === ft ? c === "svg" && (p === "annotation-xml" || mt[p]) : !!ie[c] : i.namespaceURI === ft ? a.namespaceURI === P ? c === "math" : a.namespaceURI === pt ? c === "math" && gt[p] : !!re[c] : i.namespaceURI === P ? a.namespaceURI === pt && !gt[p] || a.namespaceURI === ft && !mt[p] ? !1 : !re[c] && (We[c] || !ie[c]) : !!(Q === "application/xhtml+xml" && Rt[i.namespaceURI]) : !1;
1030
+ }, v = function(i) {
1031
+ tt(t.removed, {
1032
+ element: i
865
1033
  });
866
1034
  try {
867
- at(n).removeChild(n);
1035
+ ct(i).removeChild(i);
868
1036
  } catch {
869
- Ie(n);
1037
+ Ce(i);
870
1038
  }
871
- }, F = function(n, s) {
1039
+ }, B = function(i, a) {
872
1040
  try {
873
- J(t.removed, {
874
- attribute: s.getAttributeNode(n),
875
- from: s
1041
+ tt(t.removed, {
1042
+ attribute: a.getAttributeNode(i),
1043
+ from: a
876
1044
  });
877
1045
  } catch {
878
- J(t.removed, {
1046
+ tt(t.removed, {
879
1047
  attribute: null,
880
- from: s
1048
+ from: a
881
1049
  });
882
1050
  }
883
- if (s.removeAttribute(n), n === "is")
884
- if ($ || ct)
1051
+ if (a.removeAttribute(i), i === "is")
1052
+ if (z || ht)
885
1053
  try {
886
- v(s);
1054
+ v(a);
887
1055
  } catch {
888
1056
  }
889
1057
  else
890
1058
  try {
891
- s.setAttribute(n, "");
1059
+ a.setAttribute(i, "");
892
1060
  } catch {
893
1061
  }
894
- }, ie = function(n) {
895
- let s = null, l = null;
896
- if (kt)
897
- n = "<remove></remove>" + n;
1062
+ }, oe = function(i) {
1063
+ let a = null, c = null;
1064
+ if (xt)
1065
+ i = "<remove></remove>" + i;
898
1066
  else {
899
- const g = Dt(n, /^[\r\n\t ]+/);
900
- l = g && g[0];
1067
+ const g = Pt(i, /^[\r\n\t ]+/);
1068
+ c = g && g[0];
901
1069
  }
902
- Z === "application/xhtml+xml" && B === D && (n = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + n + "</body></html>");
903
- const f = x ? x.createHTML(n) : n;
904
- if (B === D)
1070
+ Q === "application/xhtml+xml" && Y === P && (i = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + i + "</body></html>");
1071
+ const p = A ? A.createHTML(i) : i;
1072
+ if (Y === P)
905
1073
  try {
906
- s = new Ce().parseFromString(f, Z);
1074
+ a = new Oe().parseFromString(p, Q);
907
1075
  } catch {
908
1076
  }
909
- if (!s || !s.documentElement) {
910
- s = Et.createDocument(B, "template", null);
1077
+ if (!a || !a.documentElement) {
1078
+ a = _t.createDocument(Y, "template", null);
911
1079
  try {
912
- s.documentElement.innerHTML = Ct ? j : f;
1080
+ a.documentElement.innerHTML = Ot ? q : p;
913
1081
  } catch {
914
1082
  }
915
1083
  }
916
- const _ = s.body || s.documentElement;
917
- return n && l && _.insertBefore(e.createTextNode(l), _.childNodes[0] || null), B === D ? Me.call(s, H ? "html" : "body")[0] : H ? s.documentElement : _;
918
- }, re = function(n) {
1084
+ const b = a.body || a.documentElement;
1085
+ return i && c && b.insertBefore(e.createTextNode(c), b.childNodes[0] || null), Y === P ? Ue.call(a, G ? "html" : "body")[0] : G ? a.documentElement : b;
1086
+ }, se = function(i) {
919
1087
  return ve.call(
920
- n.ownerDocument || n,
921
- n,
1088
+ i.ownerDocument || i,
1089
+ i,
922
1090
  // eslint-disable-next-line no-bitwise
923
- R.SHOW_ELEMENT | R.SHOW_COMMENT | R.SHOW_TEXT | R.SHOW_PROCESSING_INSTRUCTION | R.SHOW_CDATA_SECTION,
1091
+ E.SHOW_ELEMENT | E.SHOW_COMMENT | E.SHOW_TEXT | E.SHOW_PROCESSING_INSTRUCTION | E.SHOW_CDATA_SECTION,
924
1092
  null
925
1093
  );
926
- }, Ot = function(n) {
927
- return n instanceof ot && (typeof n.nodeName != "string" || typeof n.textContent != "string" || typeof n.removeChild != "function" || !(n.attributes instanceof I) || typeof n.removeAttribute != "function" || typeof n.setAttribute != "function" || typeof n.namespaceURI != "string" || typeof n.insertBefore != "function" || typeof n.hasChildNodes != "function");
928
- }, oe = function(n) {
929
- return typeof h == "function" && n instanceof h;
1094
+ }, wt = function(i) {
1095
+ return i instanceof at && (typeof i.nodeName != "string" || typeof i.textContent != "string" || typeof i.removeChild != "function" || !(i.attributes instanceof L) || typeof i.removeAttribute != "function" || typeof i.setAttribute != "function" || typeof i.namespaceURI != "string" || typeof i.insertBefore != "function" || typeof i.hasChildNodes != "function");
1096
+ }, ae = function(i) {
1097
+ return typeof h == "function" && i instanceof h;
930
1098
  };
931
- function M(c, n, s) {
932
- mt(c, (l) => {
933
- l.call(t, n, s, K);
1099
+ function U(d, i, a) {
1100
+ Et(d, (c) => {
1101
+ c.call(t, i, a, K);
934
1102
  });
935
1103
  }
936
- const se = function(n) {
937
- let s = null;
938
- if (M(S.beforeSanitizeElements, n, null), Ot(n))
939
- return v(n), !0;
940
- const l = E(n.nodeName);
941
- if (M(S.uponSanitizeElement, n, {
942
- tagName: l,
1104
+ const le = function(i) {
1105
+ let a = null;
1106
+ if (U(N.beforeSanitizeElements, i, null), wt(i))
1107
+ return v(i), !0;
1108
+ const c = T(i.nodeName);
1109
+ if (U(N.uponSanitizeElement, i, {
1110
+ tagName: c,
943
1111
  allowedTags: y
944
- }), lt && n.hasChildNodes() && !oe(n.firstElementChild) && A(/<[/\w!]/g, n.innerHTML) && A(/<[/\w!]/g, n.textContent) || n.nodeType === nt.progressingInstruction || lt && n.nodeType === nt.comment && A(/<[/\w]/g, n.data))
945
- return v(n), !0;
946
- if (!y[l] || X[l]) {
947
- if (!X[l] && le(l) && (m.tagNameCheck instanceof RegExp && A(m.tagNameCheck, l) || m.tagNameCheck instanceof Function && m.tagNameCheck(l)))
1112
+ }), dt && i.hasChildNodes() && !ae(i.firstElementChild) && S(/<[/\w!]/g, i.innerHTML) && S(/<[/\w!]/g, i.textContent) || i.nodeType === rt.progressingInstruction || dt && i.nodeType === rt.comment && S(/<[/\w]/g, i.data))
1113
+ return v(i), !0;
1114
+ if (!y[c] || Z[c]) {
1115
+ if (!Z[c] && de(c) && (m.tagNameCheck instanceof RegExp && S(m.tagNameCheck, c) || m.tagNameCheck instanceof Function && m.tagNameCheck(c)))
948
1116
  return !1;
949
- if (Lt && !W[l]) {
950
- const f = at(n) || n.parentNode, _ = Ne(n) || n.childNodes;
951
- if (_ && f) {
952
- const g = _.length;
953
- for (let C = g - 1; C >= 0; --C) {
954
- const P = we(_[C], !0);
955
- P.__removalCount = (n.__removalCount || 0) + 1, f.insertBefore(P, Oe(n));
1117
+ if (Lt && !W[c]) {
1118
+ const p = ct(i) || i.parentNode, b = Me(i) || i.childNodes;
1119
+ if (b && p) {
1120
+ const g = b.length;
1121
+ for (let k = g - 1; k >= 0; --k) {
1122
+ const F = Re(b[k], !0);
1123
+ F.__removalCount = (i.__removalCount || 0) + 1, p.insertBefore(F, we(i));
956
1124
  }
957
1125
  }
958
1126
  }
959
- return v(n), !0;
1127
+ return v(i), !0;
960
1128
  }
961
- return n instanceof p && !Ve(n) || (l === "noscript" || l === "noembed" || l === "noframes") && A(/<\/no(script|embed|frames)/i, n.innerHTML) ? (v(n), !0) : (z && n.nodeType === nt.text && (s = n.textContent, mt([Tt, bt, _t], (f) => {
962
- s = Q(s, f, " ");
963
- }), n.textContent !== s && (J(t.removed, {
964
- element: n.cloneNode()
965
- }), n.textContent = s)), M(S.afterSanitizeElements, n, null), !1);
966
- }, ae = function(n, s, l) {
967
- if (jt && (s === "id" || s === "name") && (l in e || l in Ye))
1129
+ return i instanceof f && !Xe(i) || (c === "noscript" || c === "noembed" || c === "noframes") && S(/<\/no(script|embed|frames)/i, i.innerHTML) ? (v(i), !0) : ($ && i.nodeType === rt.text && (a = i.textContent, Et([It, bt, At], (p) => {
1130
+ a = et(a, p, " ");
1131
+ }), i.textContent !== a && (tt(t.removed, {
1132
+ element: i.cloneNode()
1133
+ }), i.textContent = a)), U(N.afterSanitizeElements, i, null), !1);
1134
+ }, ce = function(i, a, c) {
1135
+ if (qt && (a === "id" || a === "name") && (c in e || c in je))
968
1136
  return !1;
969
- if (!(St && !xt[s] && A(Ue, s))) {
970
- if (!(Kt && A(He, s))) {
971
- if (!T[s] || xt[s]) {
1137
+ if (!(St && !Nt[a] && S(He, a))) {
1138
+ if (!(Kt && S(Ge, a))) {
1139
+ if (!_[a] || Nt[a]) {
972
1140
  if (
973
1141
  // First condition does a very basic check if a) it's basically a valid custom element tagname AND
974
1142
  // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
975
1143
  // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
976
- !(le(n) && (m.tagNameCheck instanceof RegExp && A(m.tagNameCheck, n) || m.tagNameCheck instanceof Function && m.tagNameCheck(n)) && (m.attributeNameCheck instanceof RegExp && A(m.attributeNameCheck, s) || m.attributeNameCheck instanceof Function && m.attributeNameCheck(s, n)) || // Alternative, second condition checks if it's an `is`-attribute, AND
1144
+ !(de(i) && (m.tagNameCheck instanceof RegExp && S(m.tagNameCheck, i) || m.tagNameCheck instanceof Function && m.tagNameCheck(i)) && (m.attributeNameCheck instanceof RegExp && S(m.attributeNameCheck, a) || m.attributeNameCheck instanceof Function && m.attributeNameCheck(a, i)) || // Alternative, second condition checks if it's an `is`-attribute, AND
977
1145
  // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
978
- s === "is" && m.allowCustomizedBuiltInElements && (m.tagNameCheck instanceof RegExp && A(m.tagNameCheck, l) || m.tagNameCheck instanceof Function && m.tagNameCheck(l)))
1146
+ a === "is" && m.allowCustomizedBuiltInElements && (m.tagNameCheck instanceof RegExp && S(m.tagNameCheck, c) || m.tagNameCheck instanceof Function && m.tagNameCheck(c)))
979
1147
  ) return !1;
980
- } else if (!Rt[s]) {
981
- if (!A(Gt, Q(l, $t, ""))) {
982
- if (!((s === "src" || s === "xlink:href" || s === "href") && n !== "script" && on(l, "data:") === 0 && Zt[n])) {
983
- if (!(Yt && !A(Fe, Q(l, $t, "")))) {
984
- if (l)
1148
+ } else if (!kt[a]) {
1149
+ if (!S(Vt, et(c, zt, ""))) {
1150
+ if (!((a === "src" || a === "xlink:href" || a === "href") && i !== "script" && an(c, "data:") === 0 && Qt[i])) {
1151
+ if (!(jt && !S(Be, et(c, zt, "")))) {
1152
+ if (c)
985
1153
  return !1;
986
1154
  }
987
1155
  }
@@ -990,151 +1158,151 @@ function ke() {
990
1158
  }
991
1159
  }
992
1160
  return !0;
993
- }, le = function(n) {
994
- return n !== "annotation-xml" && Dt(n, ze);
995
- }, ce = function(n) {
996
- M(S.beforeSanitizeAttributes, n, null);
1161
+ }, de = function(i) {
1162
+ return i !== "annotation-xml" && Pt(i, $e);
1163
+ }, he = function(i) {
1164
+ U(N.beforeSanitizeAttributes, i, null);
997
1165
  const {
998
- attributes: s
999
- } = n;
1000
- if (!s || Ot(n))
1166
+ attributes: a
1167
+ } = i;
1168
+ if (!a || wt(i))
1001
1169
  return;
1002
- const l = {
1170
+ const c = {
1003
1171
  attrName: "",
1004
1172
  attrValue: "",
1005
1173
  keepAttr: !0,
1006
- allowedAttributes: T,
1174
+ allowedAttributes: _,
1007
1175
  forceKeepAttr: void 0
1008
1176
  };
1009
- let f = s.length;
1010
- for (; f--; ) {
1011
- const _ = s[f], {
1177
+ let p = a.length;
1178
+ for (; p--; ) {
1179
+ const b = a[p], {
1012
1180
  name: g,
1013
- namespaceURI: C,
1014
- value: P
1015
- } = _, Y = E(g), Nt = P;
1016
- let b = g === "value" ? Nt : sn(Nt);
1017
- if (l.attrName = Y, l.attrValue = b, l.keepAttr = !0, l.forceKeepAttr = void 0, M(S.uponSanitizeAttribute, n, l), b = l.attrValue, Xt && (Y === "id" || Y === "name") && (F(g, n), b = $e + b), lt && A(/((--!?|])>)|<\/(style|title|textarea)/i, b)) {
1018
- F(g, n);
1181
+ namespaceURI: k,
1182
+ value: F
1183
+ } = b, j = T(g), Mt = F;
1184
+ let I = g === "value" ? Mt : ln(Mt);
1185
+ if (c.attrName = j, c.attrValue = I, c.keepAttr = !0, c.forceKeepAttr = void 0, U(N.uponSanitizeAttribute, i, c), I = c.attrValue, Zt && (j === "id" || j === "name") && (B(g, i), I = ze + I), dt && S(/((--!?|])>)|<\/(style|title|textarea)/i, I)) {
1186
+ B(g, i);
1019
1187
  continue;
1020
1188
  }
1021
- if (Y === "attributename" && Dt(b, "href")) {
1022
- F(g, n);
1189
+ if (j === "attributename" && Pt(I, "href")) {
1190
+ B(g, i);
1023
1191
  continue;
1024
1192
  }
1025
- if (l.forceKeepAttr)
1193
+ if (c.forceKeepAttr)
1026
1194
  continue;
1027
- if (!l.keepAttr) {
1028
- F(g, n);
1195
+ if (!c.keepAttr) {
1196
+ B(g, i);
1029
1197
  continue;
1030
1198
  }
1031
- if (!Vt && A(/\/>/i, b)) {
1032
- F(g, n);
1199
+ if (!Xt && S(/\/>/i, I)) {
1200
+ B(g, i);
1033
1201
  continue;
1034
1202
  }
1035
- z && mt([Tt, bt, _t], (ue) => {
1036
- b = Q(b, ue, " ");
1203
+ $ && Et([It, bt, At], (fe) => {
1204
+ I = et(I, fe, " ");
1037
1205
  });
1038
- const de = E(n.nodeName);
1039
- if (!ae(de, Y, b)) {
1040
- F(g, n);
1206
+ const ue = T(i.nodeName);
1207
+ if (!ce(ue, j, I)) {
1208
+ B(g, i);
1041
1209
  continue;
1042
1210
  }
1043
- if (x && typeof st == "object" && typeof st.getAttributeType == "function" && !C)
1044
- switch (st.getAttributeType(de, Y)) {
1211
+ if (A && typeof lt == "object" && typeof lt.getAttributeType == "function" && !k)
1212
+ switch (lt.getAttributeType(ue, j)) {
1045
1213
  case "TrustedHTML": {
1046
- b = x.createHTML(b);
1214
+ I = A.createHTML(I);
1047
1215
  break;
1048
1216
  }
1049
1217
  case "TrustedScriptURL": {
1050
- b = x.createScriptURL(b);
1218
+ I = A.createScriptURL(I);
1051
1219
  break;
1052
1220
  }
1053
1221
  }
1054
- if (b !== Nt)
1222
+ if (I !== Mt)
1055
1223
  try {
1056
- C ? n.setAttributeNS(C, g, b) : n.setAttribute(g, b), Ot(n) ? v(n) : fe(t.removed);
1224
+ k ? i.setAttributeNS(k, g, I) : i.setAttribute(g, I), wt(i) ? v(i) : me(t.removed);
1057
1225
  } catch {
1058
- F(g, n);
1226
+ B(g, i);
1059
1227
  }
1060
1228
  }
1061
- M(S.afterSanitizeAttributes, n, null);
1062
- }, je = function c(n) {
1063
- let s = null;
1064
- const l = re(n);
1065
- for (M(S.beforeSanitizeShadowDOM, n, null); s = l.nextNode(); )
1066
- M(S.uponSanitizeShadowNode, s, null), se(s), ce(s), s.content instanceof a && c(s.content);
1067
- M(S.afterSanitizeShadowDOM, n, null);
1229
+ U(N.afterSanitizeAttributes, i, null);
1230
+ }, qe = function d(i) {
1231
+ let a = null;
1232
+ const c = se(i);
1233
+ for (U(N.beforeSanitizeShadowDOM, i, null); a = c.nextNode(); )
1234
+ U(N.uponSanitizeShadowNode, a, null), le(a), he(a), a.content instanceof s && d(a.content);
1235
+ U(N.afterSanitizeShadowDOM, i, null);
1068
1236
  };
1069
- return t.sanitize = function(c) {
1070
- let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = null, l = null, f = null, _ = null;
1071
- if (Ct = !c, Ct && (c = "<!-->"), typeof c != "string" && !oe(c))
1072
- if (typeof c.toString == "function") {
1073
- if (c = c.toString(), typeof c != "string")
1074
- throw tt("dirty is not a string, aborting");
1237
+ return t.sanitize = function(d) {
1238
+ let i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = null, c = null, p = null, b = null;
1239
+ if (Ot = !d, Ot && (d = "<!-->"), typeof d != "string" && !ae(d))
1240
+ if (typeof d.toString == "function") {
1241
+ if (d = d.toString(), typeof d != "string")
1242
+ throw nt("dirty is not a string, aborting");
1075
1243
  } else
1076
- throw tt("toString is not a function");
1244
+ throw nt("toString is not a function");
1077
1245
  if (!t.isSupported)
1078
- return c;
1079
- if (At || It(n), t.removed = [], typeof c == "string" && (q = !1), q) {
1080
- if (c.nodeName) {
1081
- const P = E(c.nodeName);
1082
- if (!y[P] || X[P])
1083
- throw tt("root node is forbidden and cannot be sanitized in-place");
1246
+ return d;
1247
+ if (Dt || Ct(i), t.removed = [], typeof d == "string" && (J = !1), J) {
1248
+ if (d.nodeName) {
1249
+ const F = T(d.nodeName);
1250
+ if (!y[F] || Z[F])
1251
+ throw nt("root node is forbidden and cannot be sanitized in-place");
1084
1252
  }
1085
- } else if (c instanceof h)
1086
- s = ie("<!---->"), l = s.ownerDocument.importNode(c, !0), l.nodeType === nt.element && l.nodeName === "BODY" || l.nodeName === "HTML" ? s = l : s.appendChild(l);
1253
+ } else if (d instanceof h)
1254
+ a = oe("<!---->"), c = a.ownerDocument.importNode(d, !0), c.nodeType === rt.element && c.nodeName === "BODY" || c.nodeName === "HTML" ? a = c : a.appendChild(c);
1087
1255
  else {
1088
- if (!$ && !z && !H && // eslint-disable-next-line unicorn/prefer-includes
1089
- c.indexOf("<") === -1)
1090
- return x && dt ? x.createHTML(c) : c;
1091
- if (s = ie(c), !s)
1092
- return $ ? null : dt ? j : "";
1256
+ if (!z && !$ && !G && // eslint-disable-next-line unicorn/prefer-includes
1257
+ d.indexOf("<") === -1)
1258
+ return A && ut ? A.createHTML(d) : d;
1259
+ if (a = oe(d), !a)
1260
+ return z ? null : ut ? q : "";
1093
1261
  }
1094
- s && kt && v(s.firstChild);
1095
- const g = re(q ? c : s);
1096
- for (; f = g.nextNode(); )
1097
- se(f), ce(f), f.content instanceof a && je(f.content);
1098
- if (q)
1099
- return c;
1100
- if ($) {
1101
- if (ct)
1102
- for (_ = De.call(s.ownerDocument); s.firstChild; )
1103
- _.appendChild(s.firstChild);
1262
+ a && xt && v(a.firstChild);
1263
+ const g = se(J ? d : a);
1264
+ for (; p = g.nextNode(); )
1265
+ le(p), he(p), p.content instanceof s && qe(p.content);
1266
+ if (J)
1267
+ return d;
1268
+ if (z) {
1269
+ if (ht)
1270
+ for (b = Pe.call(a.ownerDocument); a.firstChild; )
1271
+ b.appendChild(a.firstChild);
1104
1272
  else
1105
- _ = s;
1106
- return (T.shadowroot || T.shadowrootmode) && (_ = Pe.call(i, _, !0)), _;
1273
+ b = a;
1274
+ return (_.shadowroot || _.shadowrootmode) && (b = Fe.call(n, b, !0)), b;
1107
1275
  }
1108
- let C = H ? s.outerHTML : s.innerHTML;
1109
- return H && y["!doctype"] && s.ownerDocument && s.ownerDocument.doctype && s.ownerDocument.doctype.name && A(Ae, s.ownerDocument.doctype.name) && (C = "<!DOCTYPE " + s.ownerDocument.doctype.name + `>
1110
- ` + C), z && mt([Tt, bt, _t], (P) => {
1111
- C = Q(C, P, " ");
1112
- }), x && dt ? x.createHTML(C) : C;
1276
+ let k = G ? a.outerHTML : a.innerHTML;
1277
+ return G && y["!doctype"] && a.ownerDocument && a.ownerDocument.doctype && a.ownerDocument.doctype.name && S(De, a.ownerDocument.doctype.name) && (k = "<!DOCTYPE " + a.ownerDocument.doctype.name + `>
1278
+ ` + k), $ && Et([It, bt, At], (F) => {
1279
+ k = et(k, F, " ");
1280
+ }), A && ut ? A.createHTML(k) : k;
1113
1281
  }, t.setConfig = function() {
1114
- let c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1115
- It(c), At = !0;
1282
+ let d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1283
+ Ct(d), Dt = !0;
1116
1284
  }, t.clearConfig = function() {
1117
- K = null, At = !1;
1118
- }, t.isValidAttribute = function(c, n, s) {
1119
- K || It({});
1120
- const l = E(c), f = E(n);
1121
- return ae(l, f, s);
1122
- }, t.addHook = function(c, n) {
1123
- typeof n == "function" && J(S[c], n);
1124
- }, t.removeHook = function(c, n) {
1125
- if (n !== void 0) {
1126
- const s = nn(S[c], n);
1127
- return s === -1 ? void 0 : rn(S[c], s, 1)[0];
1285
+ K = null, Dt = !1;
1286
+ }, t.isValidAttribute = function(d, i, a) {
1287
+ K || Ct({});
1288
+ const c = T(d), p = T(i);
1289
+ return ce(c, p, a);
1290
+ }, t.addHook = function(d, i) {
1291
+ typeof i == "function" && tt(N[d], i);
1292
+ }, t.removeHook = function(d, i) {
1293
+ if (i !== void 0) {
1294
+ const a = on(N[d], i);
1295
+ return a === -1 ? void 0 : sn(N[d], a, 1)[0];
1128
1296
  }
1129
- return fe(S[c]);
1130
- }, t.removeHooks = function(c) {
1131
- S[c] = [];
1297
+ return me(N[d]);
1298
+ }, t.removeHooks = function(d) {
1299
+ N[d] = [];
1132
1300
  }, t.removeAllHooks = function() {
1133
- S = Te();
1301
+ N = Ie();
1134
1302
  }, t;
1135
1303
  }
1136
- var _n = ke();
1137
- const xn = {
1304
+ var An = xe();
1305
+ const Nn = {
1138
1306
  ALLOWED_TAGS: [
1139
1307
  "p",
1140
1308
  "br",
@@ -1188,14 +1356,14 @@ const xn = {
1188
1356
  SANITIZE_DOM: !0,
1189
1357
  SAFE_FOR_TEMPLATES: !0
1190
1358
  };
1191
- function rt(r, t = !1) {
1192
- const e = t ? Sn : xn;
1193
- return _n.sanitize(r, e);
1359
+ function st(r, t = !1) {
1360
+ const e = t ? Sn : Nn;
1361
+ return An.sanitize(r, e);
1194
1362
  }
1195
- function An(r, t = !0) {
1196
- return t ? rt(r) : kn(r);
1363
+ function Dn(r, t = !0) {
1364
+ return t ? st(r) : xn(r);
1197
1365
  }
1198
- function kn(r) {
1366
+ function xn(r) {
1199
1367
  const t = document.createElement("div");
1200
1368
  return t.textContent = r, t.innerHTML;
1201
1369
  }
@@ -1206,18 +1374,18 @@ function Ln(r) {
1206
1374
  for (const t of r.ops) {
1207
1375
  if ("insert" in t) {
1208
1376
  const e = t.insert;
1209
- if (typeof e == "string" && rt(e) !== e && e.includes("<script"))
1377
+ if (typeof e == "string" && st(e) !== e && e.includes("<script"))
1210
1378
  return !1;
1211
1379
  if (typeof e == "object" && e !== null) {
1212
- const i = e;
1213
- if ("script" in i || "onerror" in i || "onclick" in i)
1380
+ const n = e;
1381
+ if ("script" in n || "onerror" in n || "onclick" in n)
1214
1382
  return !1;
1215
1383
  }
1216
1384
  }
1217
1385
  if ("attributes" in t && t.attributes) {
1218
1386
  const e = t.attributes;
1219
- for (const i in e)
1220
- if (i.startsWith("on") || i.toLowerCase().includes("script"))
1387
+ for (const n in e)
1388
+ if (n.startsWith("on") || n.toLowerCase().includes("script"))
1221
1389
  return !1;
1222
1390
  }
1223
1391
  }
@@ -1232,12 +1400,12 @@ function Le(r, t = "polite") {
1232
1400
  e.textContent = r;
1233
1401
  }, 100);
1234
1402
  }
1235
- function Rn(r, t) {
1236
- const e = (i) => {
1403
+ function kn(r, t) {
1404
+ const e = (n) => {
1237
1405
  for (const o of r) {
1238
- const a = o.ctrlKey ? i.ctrlKey : !0, u = o.metaKey ? i.metaKey : !0, h = o.shiftKey ? i.shiftKey : !i.shiftKey, p = o.altKey ? i.altKey : !i.altKey;
1239
- if (i.key.toLowerCase() === o.key.toLowerCase() && a && u && h && p) {
1240
- i.preventDefault(), o.action(), Le(o.description);
1406
+ const s = o.ctrlKey ? n.ctrlKey : !0, l = o.metaKey ? n.metaKey : !0, h = o.shiftKey ? n.shiftKey : !n.shiftKey, f = o.altKey ? n.altKey : !n.altKey;
1407
+ if (n.key.toLowerCase() === o.key.toLowerCase() && s && l && h && f) {
1408
+ n.preventDefault(), o.action(), Le(o.description);
1241
1409
  break;
1242
1410
  }
1243
1411
  }
@@ -1246,15 +1414,25 @@ function Rn(r, t) {
1246
1414
  t.removeEventListener("keydown", e);
1247
1415
  };
1248
1416
  }
1249
- function Cn(r, t) {
1250
- for (const [e, i] of Object.entries(t)) {
1417
+ function On(r, t) {
1418
+ for (const [e, n] of Object.entries(t)) {
1251
1419
  const o = e.startsWith("aria-") ? e : `aria-${e}`;
1252
- r.setAttribute(o, String(i));
1420
+ r.setAttribute(o, String(n));
1253
1421
  }
1254
1422
  }
1255
- class Re extends HTMLElement {
1423
+ class ke extends HTMLElement {
1256
1424
  constructor() {
1257
- super(), this.eventListeners = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.contentElement = null, this.pluginContainerTop = null, this.pluginContainerBottom = null, this.ariaLiveRegion = null, this.config = {
1425
+ super(), this.eventListeners = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.contentElement = null, this.pluginContainerTop = null, this.pluginContainerBottom = null, this.ariaLiveRegion = null, this.pendingPlugins = [], this.isReady = !1, this.handleInput = (e) => {
1426
+ this.updatePlaceholder(), e.target?.closest('[data-node-type="table"]') || this.syncContentToState(), this.emit("change", { state: this.state });
1427
+ }, this.handleKeydown = (e) => {
1428
+ this.emit("keydown", e), !e.defaultPrevented && ((e.ctrlKey || e.metaKey) && e.key === "z" && (e.preventDefault(), e.shiftKey ? (this.redo(), this.announceToScreenReader("Action redone")) : (this.undo(), this.announceToScreenReader("Action undone"))), ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key) && (e.ctrlKey || e.metaKey) && this.announceToScreenReader(`Navigating ${e.key.replace("Arrow", "").toLowerCase()}`));
1429
+ }, this.handleFocus = () => {
1430
+ this.emit("focus", { state: this.state });
1431
+ }, this.handleBlur = () => {
1432
+ this.emit("blur", { state: this.state });
1433
+ }, this.handleContextMenu = (e) => {
1434
+ this.emit("contextmenu", e);
1435
+ }, this.config = {
1258
1436
  placeholder: "Start typing...",
1259
1437
  readonly: !1,
1260
1438
  autofocus: !1,
@@ -1262,9 +1440,11 @@ class Re extends HTMLElement {
1262
1440
  maxHistoryDepth: 100
1263
1441
  };
1264
1442
  const t = be();
1265
- this.state = new it(void 0, t, {
1443
+ this.state = new ot(void 0, t, {
1266
1444
  maxHistoryDepth: this.config.maxHistoryDepth
1267
- }), this.pluginManager = new Je(), this.attachShadow({ mode: "open" });
1445
+ }), this.pluginManager = new tn(), this.readyPromise = new Promise((e) => {
1446
+ this.readyResolve = e;
1447
+ }), this.attachShadow({ mode: "open" });
1268
1448
  }
1269
1449
  /**
1270
1450
  * Observed attributes for the web component
@@ -1275,29 +1455,41 @@ class Re extends HTMLElement {
1275
1455
  /**
1276
1456
  * Called when element is connected to DOM
1277
1457
  */
1278
- connectedCallback() {
1279
- this.render(), this.attachEventListeners(), this.setupAccessibility(), this.setupKeyboardShortcuts(), this.config.autofocus && this.focus();
1458
+ async connectedCallback() {
1459
+ if (this.render(), this.attachEventListeners(), this.setupAccessibility(), this.setupKeyboardShortcuts(), this.isReady = !0, this.pendingPlugins.length > 0) {
1460
+ const t = [...this.pendingPlugins];
1461
+ this.pendingPlugins = [];
1462
+ for (const e of t)
1463
+ try {
1464
+ await this.pluginManager.register(e, this.createPluginContext());
1465
+ } catch (n) {
1466
+ console.error(`Failed to register pending plugin ${e.id}:`, n);
1467
+ }
1468
+ }
1469
+ this.readyResolve && this.readyResolve(), this.emit("ready", { editor: this }), this.config.autofocus && this.focus();
1280
1470
  }
1281
1471
  /**
1282
1472
  * Called when element is disconnected from DOM
1283
1473
  */
1284
1474
  disconnectedCallback() {
1285
- this.detachEventListeners(), this.pluginManager.destroyAll(), this.keyboardShortcutCleanup && this.keyboardShortcutCleanup(), this.ariaLiveRegion && this.ariaLiveRegion.parentNode && this.ariaLiveRegion.parentNode.removeChild(this.ariaLiveRegion);
1475
+ this.detachEventListeners(), this.pluginManager.destroyAll(), this.keyboardShortcutCleanup && this.keyboardShortcutCleanup(), this.ariaLiveRegion && this.ariaLiveRegion.parentNode && this.ariaLiveRegion.parentNode.removeChild(this.ariaLiveRegion), this.isReady = !1, this.readyPromise = new Promise((t) => {
1476
+ this.readyResolve = t;
1477
+ });
1286
1478
  }
1287
1479
  /**
1288
1480
  * Called when attributes change
1289
1481
  */
1290
- attributeChangedCallback(t, e, i) {
1291
- if (e !== i)
1482
+ attributeChangedCallback(t, e, n) {
1483
+ if (e !== n)
1292
1484
  switch (t) {
1293
1485
  case "placeholder":
1294
- this.config.placeholder = i || "", this.updatePlaceholder();
1486
+ this.config.placeholder = n || "", this.updatePlaceholder();
1295
1487
  break;
1296
1488
  case "readonly":
1297
- this.config.readonly = i !== null, this.updateReadonly();
1489
+ this.config.readonly = n !== null, this.updateReadonly();
1298
1490
  break;
1299
1491
  case "autofocus":
1300
- this.config.autofocus = i !== null;
1492
+ this.config.autofocus = n !== null;
1301
1493
  break;
1302
1494
  }
1303
1495
  }
@@ -1423,7 +1615,7 @@ class Re extends HTMLElement {
1423
1615
  renderContent() {
1424
1616
  if (!this.contentElement) return;
1425
1617
  const t = this.state.getDocument(), e = this.documentToHTML(t);
1426
- this.contentElement.innerHTML = this.config.sanitizeHTML ? rt(e) : e;
1618
+ this.contentElement.innerHTML = this.config.sanitizeHTML ? st(e) : e;
1427
1619
  }
1428
1620
  /**
1429
1621
  * Convert document to HTML
@@ -1441,6 +1633,8 @@ class Re extends HTMLElement {
1441
1633
  case "heading":
1442
1634
  const e = t.attrs?.level || 1;
1443
1635
  return `<h${e}>${this.childrenToHTML(t.children || [])}</h${e}>`;
1636
+ case "table":
1637
+ return this.tableToHTML(t);
1444
1638
  default:
1445
1639
  return `<div>${this.childrenToHTML(t.children || [])}</div>`;
1446
1640
  }
@@ -1451,11 +1645,11 @@ class Re extends HTMLElement {
1451
1645
  childrenToHTML(t) {
1452
1646
  return t.map((e) => {
1453
1647
  if (e.type === "text") {
1454
- let i = this.escapeHTML(e.text);
1648
+ let n = this.escapeHTML(e.text);
1455
1649
  if (e.marks)
1456
1650
  for (const o of e.marks)
1457
- i = this.applyMarkHTML(i, o);
1458
- return i;
1651
+ n = this.applyMarkHTML(n, o);
1652
+ return n;
1459
1653
  }
1460
1654
  return this.blockToHTML(e);
1461
1655
  }).join("");
@@ -1487,11 +1681,63 @@ class Re extends HTMLElement {
1487
1681
  const e = document.createElement("div");
1488
1682
  return e.textContent = t, e.innerHTML;
1489
1683
  }
1684
+ tableToHTML(t) {
1685
+ const e = t.attrs?.table, o = [
1686
+ 'data-node-type="table"',
1687
+ `data-block-id="${t.id || crypto.randomUUID()}"`
1688
+ ];
1689
+ if (t.attrs?.style) {
1690
+ const h = this.styleObjectToString(t.attrs.style);
1691
+ h && o.push(`style="${h}"`);
1692
+ }
1693
+ let s = "";
1694
+ const l = Array.isArray(e?.rows) ? e.rows : [];
1695
+ if (l.length === 0) {
1696
+ const h = crypto.randomUUID();
1697
+ s = `
1698
+ <tr data-node-type="table_row" data-row="0" data-block-id="${crypto.randomUUID()}">
1699
+ <td data-node-type="table_cell" data-row="0" data-col="0" data-block-id="${h}"><br></td>
1700
+ </tr>
1701
+ `;
1702
+ } else
1703
+ s = l.map((h, f) => this.tableRowToHTML(h, f)).join("");
1704
+ return `<table ${o.join(" ")}><tbody>${s}</tbody></table>`;
1705
+ }
1706
+ tableRowToHTML(t, e) {
1707
+ const n = t.id || crypto.randomUUID(), o = [
1708
+ 'data-node-type="table_row"',
1709
+ `data-row="${e}"`,
1710
+ `data-block-id="${n}"`
1711
+ ];
1712
+ if (t.attrs?.style) {
1713
+ const h = this.styleObjectToString(t.attrs.style);
1714
+ h && o.push(`style="${h}"`);
1715
+ }
1716
+ const l = (Array.isArray(t.cells) ? t.cells : []).map((h, f) => this.tableCellToHTML(h, e, f)).join("");
1717
+ return `<tr ${o.join(" ")}>${l}</tr>`;
1718
+ }
1719
+ tableCellToHTML(t, e, n) {
1720
+ const o = t.id || crypto.randomUUID(), s = [
1721
+ 'data-node-type="table_cell"',
1722
+ `data-row="${e}"`,
1723
+ `data-col="${n}"`,
1724
+ `data-block-id="${o}"`
1725
+ ], l = Number(t.rowSpan) || 1, h = Number(t.colSpan) || 1;
1726
+ if (l > 1 && s.push(`rowspan="${l}"`), h > 1 && s.push(`colspan="${h}"`), t.attrs?.style) {
1727
+ const L = this.styleObjectToString(t.attrs.style);
1728
+ L && s.push(`style="${L}"`);
1729
+ }
1730
+ const E = (typeof t.content == "string" ? this.escapeHTML(t.content) : "") || "<br>";
1731
+ return `<td ${s.join(" ")}>${E}</td>`;
1732
+ }
1733
+ styleObjectToString(t) {
1734
+ return Object.entries(t).map(([e, n]) => n == null || n === "" ? null : `${e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`)}: ${String(n)}`).filter(Boolean).join("; ");
1735
+ }
1490
1736
  /**
1491
1737
  * Setup accessibility features
1492
1738
  */
1493
1739
  setupAccessibility() {
1494
- this.contentElement && (Cn(this.contentElement, {
1740
+ this.contentElement && (On(this.contentElement, {
1495
1741
  role: "textbox",
1496
1742
  "aria-multiline": !0,
1497
1743
  "aria-label": "Rich text editor",
@@ -1537,7 +1783,7 @@ class Re extends HTMLElement {
1537
1783
  action: () => this.redo()
1538
1784
  }
1539
1785
  ];
1540
- this.keyboardShortcutCleanup = Rn(t, this.contentElement);
1786
+ this.keyboardShortcutCleanup = kn(t, this.contentElement);
1541
1787
  }
1542
1788
  /**
1543
1789
  * Toggle formatting
@@ -1560,16 +1806,16 @@ class Re extends HTMLElement {
1560
1806
  document.execCommand("strikeThrough", !1);
1561
1807
  break;
1562
1808
  case "code":
1563
- const i = document.createElement("code");
1809
+ const n = document.createElement("code");
1564
1810
  if (e.rangeCount > 0) {
1565
1811
  const o = e.getRangeAt(0);
1566
- i.appendChild(o.extractContents()), o.insertNode(i);
1812
+ n.appendChild(o.extractContents()), o.insertNode(n);
1567
1813
  }
1568
1814
  break;
1569
1815
  }
1570
1816
  this.announceToScreenReader(`${t} formatting applied`), this.emit("change", { state: this.state });
1571
- } catch (i) {
1572
- console.error(`Failed to apply ${t} formatting:`, i), this.announceToScreenReader(`Failed to apply ${t} formatting`);
1817
+ } catch (n) {
1818
+ console.error(`Failed to apply ${t} formatting:`, n), this.announceToScreenReader(`Failed to apply ${t} formatting`);
1573
1819
  }
1574
1820
  }
1575
1821
  /**
@@ -1579,48 +1825,48 @@ class Re extends HTMLElement {
1579
1825
  if (this.contentElement)
1580
1826
  try {
1581
1827
  this.contentElement.focus();
1582
- const i = document.createElement("table");
1583
- i.setAttribute("data-notectl-table", "true");
1828
+ const n = document.createElement("table");
1829
+ n.setAttribute("data-notectl-table", "true");
1584
1830
  const o = document.createElement("tbody");
1585
- for (let p = 0; p < t; p++) {
1586
- const R = document.createElement("tr");
1587
- for (let I = 0; I < e; I++) {
1588
- const ot = document.createElement("td");
1589
- ot.textContent = "", R.appendChild(ot);
1831
+ for (let f = 0; f < t; f++) {
1832
+ const E = document.createElement("tr");
1833
+ for (let L = 0; L < e; L++) {
1834
+ const at = document.createElement("td");
1835
+ at.textContent = "", E.appendChild(at);
1590
1836
  }
1591
- o.appendChild(R);
1837
+ o.appendChild(E);
1592
1838
  }
1593
- i.appendChild(o);
1594
- const a = window.getSelection();
1595
- let u = this.contentElement.childNodes.length;
1596
- if (a && a.rangeCount > 0) {
1597
- const p = a.getRangeAt(0);
1598
- if (this.contentElement.contains(p.commonAncestorContainer)) {
1599
- let R = p.startContainer;
1600
- if (R.nodeType === Node.TEXT_NODE && (R = R.parentNode), R === this.contentElement)
1601
- u = p.startOffset;
1839
+ n.appendChild(o);
1840
+ const s = window.getSelection();
1841
+ let l = this.contentElement.childNodes.length;
1842
+ if (s && s.rangeCount > 0) {
1843
+ const f = s.getRangeAt(0);
1844
+ if (this.contentElement.contains(f.commonAncestorContainer)) {
1845
+ let E = f.startContainer;
1846
+ if (E.nodeType === Node.TEXT_NODE && (E = E.parentNode), E === this.contentElement)
1847
+ l = f.startOffset;
1602
1848
  else {
1603
- let I = R;
1604
- for (; I.parentNode && I.parentNode !== this.contentElement; )
1605
- I = I.parentNode;
1606
- I.parentNode === this.contentElement && (u = Array.from(this.contentElement.childNodes).indexOf(I) + 1);
1849
+ let L = E;
1850
+ for (; L.parentNode && L.parentNode !== this.contentElement; )
1851
+ L = L.parentNode;
1852
+ L.parentNode === this.contentElement && (l = Array.from(this.contentElement.childNodes).indexOf(L) + 1);
1607
1853
  }
1608
1854
  }
1609
1855
  }
1610
1856
  const h = document.createElement("p");
1611
- if (h.innerHTML = "<br>", u >= this.contentElement.childNodes.length)
1612
- this.contentElement.appendChild(i), this.contentElement.appendChild(h);
1857
+ if (h.innerHTML = "<br>", l >= this.contentElement.childNodes.length)
1858
+ this.contentElement.appendChild(n), this.contentElement.appendChild(h);
1613
1859
  else {
1614
- const p = this.contentElement.childNodes[u];
1615
- this.contentElement.insertBefore(i, p), this.contentElement.insertBefore(h, p);
1860
+ const f = this.contentElement.childNodes[l];
1861
+ this.contentElement.insertBefore(n, f), this.contentElement.insertBefore(h, f);
1616
1862
  }
1617
- if (a) {
1618
- const p = document.createRange();
1619
- p.setStart(h, 0), p.setEnd(h, 0), a.removeAllRanges(), a.addRange(p);
1863
+ if (s) {
1864
+ const f = document.createRange();
1865
+ f.setStart(h, 0), f.setEnd(h, 0), s.removeAllRanges(), s.addRange(f);
1620
1866
  }
1621
1867
  this.updatePlaceholder(), this.syncContentToState(), this.announceToScreenReader(`Table with ${t} rows and ${e} columns inserted`), this.emit("change", { state: this.state });
1622
- } catch (i) {
1623
- console.error("Failed to insert table:", i), this.announceToScreenReader("Failed to insert table");
1868
+ } catch (n) {
1869
+ console.error("Failed to insert table:", n), this.announceToScreenReader("Failed to insert table");
1624
1870
  }
1625
1871
  }
1626
1872
  /**
@@ -1635,37 +1881,13 @@ class Re extends HTMLElement {
1635
1881
  * Attach event listeners
1636
1882
  */
1637
1883
  attachEventListeners() {
1638
- this.contentElement && (this.contentElement.addEventListener("input", this.handleInput.bind(this)), this.contentElement.addEventListener("keydown", this.handleKeydown.bind(this)), this.contentElement.addEventListener("focus", this.handleFocus.bind(this)), this.contentElement.addEventListener("blur", this.handleBlur.bind(this)));
1884
+ this.contentElement && (this.contentElement.addEventListener("input", this.handleInput), this.contentElement.addEventListener("keydown", this.handleKeydown), this.contentElement.addEventListener("focus", this.handleFocus), this.contentElement.addEventListener("blur", this.handleBlur), this.contentElement.addEventListener("contextmenu", this.handleContextMenu));
1639
1885
  }
1640
1886
  /**
1641
1887
  * Detach event listeners
1642
1888
  */
1643
1889
  detachEventListeners() {
1644
- this.contentElement && (this.contentElement.removeEventListener("input", this.handleInput.bind(this)), this.contentElement.removeEventListener("keydown", this.handleKeydown.bind(this)), this.contentElement.removeEventListener("focus", this.handleFocus.bind(this)), this.contentElement.removeEventListener("blur", this.handleBlur.bind(this)));
1645
- }
1646
- /**
1647
- * Handle input event
1648
- */
1649
- handleInput(t) {
1650
- this.updatePlaceholder(), this.syncContentToState(), this.emit("change", { state: this.state });
1651
- }
1652
- /**
1653
- * Handle keydown event
1654
- */
1655
- handleKeydown(t) {
1656
- (t.ctrlKey || t.metaKey) && t.key === "z" && (t.preventDefault(), t.shiftKey ? (this.redo(), this.announceToScreenReader("Action redone")) : (this.undo(), this.announceToScreenReader("Action undone"))), ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && (t.ctrlKey || t.metaKey) && this.announceToScreenReader(`Navigating ${t.key.replace("Arrow", "").toLowerCase()}`);
1657
- }
1658
- /**
1659
- * Handle focus event
1660
- */
1661
- handleFocus() {
1662
- this.emit("focus", { state: this.state });
1663
- }
1664
- /**
1665
- * Handle blur event
1666
- */
1667
- handleBlur() {
1668
- this.emit("blur", { state: this.state });
1890
+ this.contentElement && (this.contentElement.removeEventListener("input", this.handleInput), this.contentElement.removeEventListener("keydown", this.handleKeydown), this.contentElement.removeEventListener("focus", this.handleFocus), this.contentElement.removeEventListener("blur", this.handleBlur), this.contentElement.removeEventListener("contextmenu", this.handleContextMenu));
1669
1891
  }
1670
1892
  /**
1671
1893
  * Update placeholder visibility
@@ -1682,7 +1904,7 @@ class Re extends HTMLElement {
1682
1904
  if (this.contentElement)
1683
1905
  try {
1684
1906
  const t = this.htmlToDocument(this.contentElement.innerHTML);
1685
- this.state = it.fromJSON(t, this.state.schema);
1907
+ this.state = ot.fromJSON(t, this.state.schema);
1686
1908
  } catch (t) {
1687
1909
  console.error("Failed to sync content to state:", t);
1688
1910
  }
@@ -1691,18 +1913,18 @@ class Re extends HTMLElement {
1691
1913
  * Convert HTML to document structure
1692
1914
  */
1693
1915
  htmlToDocument(t) {
1694
- const o = new DOMParser().parseFromString(t, "text/html").body, a = [];
1695
- return Array.from(o.childNodes).forEach((u) => {
1696
- const h = this.nodeToBlock(u);
1697
- h && a.push(h);
1698
- }), a.length === 0 && a.push({
1916
+ const o = new DOMParser().parseFromString(t, "text/html").body, s = [];
1917
+ return Array.from(o.childNodes).forEach((l) => {
1918
+ const h = this.nodeToBlock(l);
1919
+ h && s.push(h);
1920
+ }), s.length === 0 && s.push({
1699
1921
  id: crypto.randomUUID(),
1700
1922
  type: "paragraph",
1701
1923
  children: []
1702
1924
  }), {
1703
1925
  version: this.state.getDocument().version + 1,
1704
1926
  schemaVersion: "1.0.0",
1705
- children: a
1927
+ children: s
1706
1928
  };
1707
1929
  }
1708
1930
  /**
@@ -1718,15 +1940,15 @@ class Re extends HTMLElement {
1718
1940
  } : null;
1719
1941
  }
1720
1942
  if (t.nodeType === Node.ELEMENT_NODE) {
1721
- const e = t, i = e.tagName.toLowerCase();
1722
- if (i === "p")
1943
+ const e = t, n = e.tagName.toLowerCase();
1944
+ if (n === "p")
1723
1945
  return {
1724
1946
  id: crypto.randomUUID(),
1725
1947
  type: "paragraph",
1726
1948
  children: this.parseChildren(e)
1727
1949
  };
1728
- if (["h1", "h2", "h3", "h4", "h5", "h6"].includes(i)) {
1729
- const o = parseInt(i.charAt(1), 10);
1950
+ if (["h1", "h2", "h3", "h4", "h5", "h6"].includes(n)) {
1951
+ const o = parseInt(n.charAt(1), 10);
1730
1952
  return {
1731
1953
  id: crypto.randomUUID(),
1732
1954
  type: "heading",
@@ -1743,17 +1965,17 @@ class Re extends HTMLElement {
1743
1965
  */
1744
1966
  parseChildren(t) {
1745
1967
  const e = [];
1746
- return Array.from(t.childNodes).forEach((i) => {
1747
- if (i.nodeType === Node.TEXT_NODE) {
1748
- const o = i.textContent || "";
1968
+ return Array.from(t.childNodes).forEach((n) => {
1969
+ if (n.nodeType === Node.TEXT_NODE) {
1970
+ const o = n.textContent || "";
1749
1971
  o && e.push({
1750
1972
  type: "text",
1751
1973
  text: o,
1752
1974
  marks: []
1753
1975
  });
1754
- } else if (i.nodeType === Node.ELEMENT_NODE) {
1755
- const o = i, a = this.parseInlineElement(o);
1756
- a && (Array.isArray(a) ? e.push(...a) : e.push(a));
1976
+ } else if (n.nodeType === Node.ELEMENT_NODE) {
1977
+ const o = n, s = this.parseInlineElement(o);
1978
+ s && (Array.isArray(s) ? e.push(...s) : e.push(s));
1757
1979
  }
1758
1980
  }), e;
1759
1981
  }
@@ -1761,21 +1983,21 @@ class Re extends HTMLElement {
1761
1983
  * Parse inline element with marks
1762
1984
  */
1763
1985
  parseInlineElement(t) {
1764
- const e = t.tagName.toLowerCase(), i = [];
1765
- e === "strong" || e === "b" ? i.push({ type: "bold" }) : e === "em" || e === "i" ? i.push({ type: "italic" }) : e === "u" ? i.push({ type: "underline" }) : e === "s" || e === "strike" ? i.push({ type: "strikethrough" }) : e === "code" && i.push({ type: "code" });
1986
+ const e = t.tagName.toLowerCase(), n = [];
1987
+ e === "strong" || e === "b" ? n.push({ type: "bold" }) : e === "em" || e === "i" ? n.push({ type: "italic" }) : e === "u" ? n.push({ type: "underline" }) : e === "s" || e === "strike" ? n.push({ type: "strikethrough" }) : e === "code" && n.push({ type: "code" });
1766
1988
  const o = [];
1767
- return Array.from(t.childNodes).forEach((a) => {
1768
- if (a.nodeType === Node.TEXT_NODE) {
1769
- const u = a.textContent || "";
1770
- u && o.push({
1989
+ return Array.from(t.childNodes).forEach((s) => {
1990
+ if (s.nodeType === Node.TEXT_NODE) {
1991
+ const l = s.textContent || "";
1992
+ l && o.push({
1771
1993
  type: "text",
1772
- text: u,
1773
- marks: i
1994
+ text: l,
1995
+ marks: n
1774
1996
  });
1775
- } else if (a.nodeType === Node.ELEMENT_NODE) {
1776
- const u = a, h = this.parseInlineElement(u);
1777
- h && (h.type === "text" ? (h.marks = [...i, ...h.marks || []], o.push(h)) : Array.isArray(h) && h.forEach((p) => {
1778
- p.type === "text" && (p.marks = [...i, ...p.marks || []]), o.push(p);
1997
+ } else if (s.nodeType === Node.ELEMENT_NODE) {
1998
+ const l = s, h = this.parseInlineElement(l);
1999
+ h && (h.type === "text" ? (h.marks = [...n, ...h.marks || []], o.push(h)) : Array.isArray(h) && h.forEach((f) => {
2000
+ f.type === "text" && (f.marks = [...n, ...f.marks || []]), o.push(f);
1779
2001
  }));
1780
2002
  }
1781
2003
  }), o.length === 1 ? o[0] : o;
@@ -1788,8 +2010,19 @@ class Re extends HTMLElement {
1788
2010
  }
1789
2011
  /**
1790
2012
  * Register a plugin
2013
+ *
2014
+ * Plugins can be registered before or after the editor is mounted.
2015
+ * If registered before mounting, they will be queued and initialized
2016
+ * automatically when the editor connects to the DOM.
2017
+ *
2018
+ * @param plugin - The plugin to register
2019
+ * @returns Promise that resolves when the plugin is registered
1791
2020
  */
1792
2021
  async registerPlugin(t) {
2022
+ if (!this.isReady) {
2023
+ this.pendingPlugins.push(t);
2024
+ return;
2025
+ }
1793
2026
  const e = this.createPluginContext();
1794
2027
  await this.pluginManager.register(t, e);
1795
2028
  }
@@ -1800,18 +2033,301 @@ class Re extends HTMLElement {
1800
2033
  const e = this.createPluginContext();
1801
2034
  await this.pluginManager.unregister(t, e);
1802
2035
  }
2036
+ /**
2037
+ * Wait for the editor to be ready
2038
+ *
2039
+ * Returns a Promise that resolves when the editor has been mounted
2040
+ * and all pending plugins have been initialized. This is useful when
2041
+ * you need to ensure the editor is fully initialized before performing
2042
+ * operations that depend on the editor being mounted.
2043
+ *
2044
+ * @returns Promise that resolves when the editor is ready
2045
+ * @example
2046
+ * ```typescript
2047
+ * const editor = document.createElement('notectl-editor');
2048
+ * container.appendChild(editor);
2049
+ * await editor.whenReady();
2050
+ * // Editor is now fully initialized
2051
+ * ```
2052
+ */
2053
+ async whenReady() {
2054
+ return this.readyPromise;
2055
+ }
2056
+ // ===== Plugin Context Helper Methods =====
2057
+ /**
2058
+ * Get the block containing the current selection
2059
+ */
2060
+ getSelectedBlock() {
2061
+ const t = this.state.getSelection();
2062
+ return t && this.state.findBlock(t.anchor.blockId) || null;
2063
+ }
2064
+ /**
2065
+ * Find all blocks of a specific type
2066
+ */
2067
+ findBlocksByType(t) {
2068
+ const e = [], n = this.state.getDocument(), o = (s) => {
2069
+ for (const l of s)
2070
+ if (l.type === t && e.push(l), l.children) {
2071
+ const h = l.children.filter(
2072
+ (f) => "id" in f
2073
+ );
2074
+ o(h);
2075
+ }
2076
+ };
2077
+ return o(n.children), e;
2078
+ }
2079
+ /**
2080
+ * Find parent block of a given block
2081
+ */
2082
+ findParentBlock(t) {
2083
+ const e = this.state.getDocument(), n = (o, s = null) => {
2084
+ for (const l of o) {
2085
+ if (l.id === t.id)
2086
+ return s;
2087
+ if (l.children) {
2088
+ const h = l.children.filter(
2089
+ (E) => "id" in E
2090
+ ), f = n(h, l);
2091
+ if (f) return f;
2092
+ }
2093
+ }
2094
+ return null;
2095
+ };
2096
+ return n(e.children);
2097
+ }
2098
+ /**
2099
+ * Get block at current cursor position
2100
+ */
2101
+ getBlockAtCursor() {
2102
+ return this.getSelectedBlock();
2103
+ }
2104
+ /**
2105
+ * Insert a block after another block (Delta-based)
2106
+ */
2107
+ insertBlockAfter(t, e) {
2108
+ const n = this.state.getDocument(), o = e || n.children[n.children.length - 1]?.id;
2109
+ if (!o) {
2110
+ const l = {
2111
+ txnId: crypto.randomUUID(),
2112
+ clientId: "editor",
2113
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2114
+ baseVersion: this.state.getVersion(),
2115
+ ltime: Date.now(),
2116
+ intent: "edit",
2117
+ ops: [
2118
+ {
2119
+ op: "insert_block_after",
2120
+ after: "",
2121
+ block: t
2122
+ }
2123
+ ]
2124
+ };
2125
+ this.applyDelta(l);
2126
+ return;
2127
+ }
2128
+ const s = {
2129
+ txnId: crypto.randomUUID(),
2130
+ clientId: "editor",
2131
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2132
+ baseVersion: this.state.getVersion(),
2133
+ ltime: Date.now(),
2134
+ intent: "edit",
2135
+ ops: [
2136
+ {
2137
+ op: "insert_block_after",
2138
+ after: o,
2139
+ block: t
2140
+ }
2141
+ ]
2142
+ };
2143
+ this.applyDelta(s);
2144
+ }
2145
+ /**
2146
+ * Insert a block before another block (Delta-based)
2147
+ */
2148
+ insertBlockBefore(t, e) {
2149
+ const n = this.state.getDocument(), o = e || n.children[0]?.id;
2150
+ if (!o) {
2151
+ this.insertBlockAfter(t);
2152
+ return;
2153
+ }
2154
+ const s = {
2155
+ txnId: crypto.randomUUID(),
2156
+ clientId: "editor",
2157
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2158
+ baseVersion: this.state.getVersion(),
2159
+ ltime: Date.now(),
2160
+ intent: "edit",
2161
+ ops: [
2162
+ {
2163
+ op: "insert_block_before",
2164
+ before: o,
2165
+ block: t
2166
+ }
2167
+ ]
2168
+ };
2169
+ this.applyDelta(s);
2170
+ }
2171
+ /**
2172
+ * Update block attributes (Delta-based)
2173
+ */
2174
+ updateBlockAttrs(t, e) {
2175
+ const n = {
2176
+ txnId: crypto.randomUUID(),
2177
+ clientId: "editor",
2178
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2179
+ baseVersion: this.state.getVersion(),
2180
+ ltime: Date.now(),
2181
+ intent: "edit",
2182
+ ops: [
2183
+ {
2184
+ op: "set_attrs",
2185
+ target: { blockId: t },
2186
+ attrs: e
2187
+ }
2188
+ ]
2189
+ };
2190
+ this.applyDelta(n);
2191
+ }
2192
+ /**
2193
+ * Delete a block (Delta-based)
2194
+ */
2195
+ deleteBlockById(t) {
2196
+ const e = {
2197
+ txnId: crypto.randomUUID(),
2198
+ clientId: "editor",
2199
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2200
+ baseVersion: this.state.getVersion(),
2201
+ ltime: Date.now(),
2202
+ intent: "edit",
2203
+ ops: [
2204
+ {
2205
+ op: "delete_block",
2206
+ target: { blockId: t }
2207
+ }
2208
+ ]
2209
+ };
2210
+ this.applyDelta(e);
2211
+ }
2212
+ /**
2213
+ * Add mark to current selection (Delta-based)
2214
+ */
2215
+ addMarkToSelection(t) {
2216
+ const e = this.state.getSelection();
2217
+ if (!e) return;
2218
+ const n = {
2219
+ txnId: crypto.randomUUID(),
2220
+ clientId: "editor",
2221
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2222
+ baseVersion: this.state.getVersion(),
2223
+ ltime: Date.now(),
2224
+ intent: "format",
2225
+ ops: [
2226
+ {
2227
+ op: "apply_mark",
2228
+ range: {
2229
+ start: e.anchor,
2230
+ end: e.head
2231
+ },
2232
+ mark: t,
2233
+ add: !0
2234
+ }
2235
+ ]
2236
+ };
2237
+ this.applyDelta(n);
2238
+ }
2239
+ /**
2240
+ * Remove mark from current selection (Delta-based)
2241
+ */
2242
+ removeMarkFromSelection(t) {
2243
+ const e = this.state.getSelection();
2244
+ if (!e) return;
2245
+ const n = {
2246
+ txnId: crypto.randomUUID(),
2247
+ clientId: "editor",
2248
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2249
+ baseVersion: this.state.getVersion(),
2250
+ ltime: Date.now(),
2251
+ intent: "format",
2252
+ ops: [
2253
+ {
2254
+ op: "apply_mark",
2255
+ range: {
2256
+ start: e.anchor,
2257
+ end: e.head
2258
+ },
2259
+ mark: { type: t },
2260
+ add: !1
2261
+ }
2262
+ ]
2263
+ };
2264
+ this.applyDelta(n);
2265
+ }
2266
+ /**
2267
+ * Toggle mark on current selection (Delta-based)
2268
+ */
2269
+ toggleMarkOnSelection(t) {
2270
+ const e = this.state.getSelection();
2271
+ if (!e) return;
2272
+ const n = this.state.findBlock(e.anchor.blockId);
2273
+ if (!n || !n.children) return;
2274
+ const s = n.children.find((h) => "text" in h)?.marks?.some((h) => h.type === t) || !1, l = {
2275
+ txnId: crypto.randomUUID(),
2276
+ clientId: "editor",
2277
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2278
+ baseVersion: this.state.getVersion(),
2279
+ ltime: Date.now(),
2280
+ intent: "format",
2281
+ ops: [
2282
+ {
2283
+ op: "apply_mark",
2284
+ range: {
2285
+ start: e.anchor,
2286
+ end: e.head
2287
+ },
2288
+ mark: { type: t },
2289
+ add: !s
2290
+ }
2291
+ ]
2292
+ };
2293
+ this.applyDelta(l);
2294
+ }
1803
2295
  /**
1804
2296
  * Create plugin context
1805
2297
  */
1806
2298
  createPluginContext() {
1807
2299
  return {
2300
+ // Core state and delta operations
1808
2301
  getState: () => this.state,
1809
2302
  applyDelta: (t) => this.applyDelta(t),
2303
+ // Selection helpers
2304
+ getSelection: () => this.state.getSelection(),
2305
+ setSelection: (t) => {
2306
+ this.state.setSelection(t), this.emit("selection-change", { selection: t });
2307
+ },
2308
+ getSelectedBlock: () => this.getSelectedBlock(),
2309
+ // Node queries
2310
+ findBlocksByType: (t) => this.findBlocksByType(t),
2311
+ findBlockById: (t) => this.state.findBlock(t),
2312
+ findParentBlock: (t) => this.findParentBlock(t),
2313
+ getBlockAtCursor: () => this.getBlockAtCursor(),
2314
+ // Block mutations
2315
+ insertBlockAfter: (t, e) => this.insertBlockAfter(t, e),
2316
+ insertBlockBefore: (t, e) => this.insertBlockBefore(t, e),
2317
+ updateBlockAttrs: (t, e) => this.updateBlockAttrs(t, e),
2318
+ deleteBlock: (t) => this.deleteBlockById(t),
2319
+ // Mark utilities
2320
+ addMark: (t) => this.addMarkToSelection(t),
2321
+ removeMark: (t) => this.removeMarkFromSelection(t),
2322
+ toggleMark: (t) => this.toggleMarkOnSelection(t),
2323
+ // Events
1810
2324
  on: (t, e) => this.on(t, e),
1811
2325
  off: (t, e) => this.off(t, e),
1812
2326
  emit: (t, e) => this.emit(t, e),
2327
+ // Commands
1813
2328
  registerCommand: (t, e) => this.registerCommand(t, e),
1814
2329
  executeCommand: (t, ...e) => this.executeCommand(t, ...e),
2330
+ // DOM access (deprecated)
1815
2331
  getContainer: () => this.contentElement,
1816
2332
  getPluginContainer: (t) => t === "top" ? this.pluginContainerTop : this.pluginContainerBottom
1817
2333
  };
@@ -1842,9 +2358,9 @@ class Re extends HTMLElement {
1842
2358
  * Emit event
1843
2359
  */
1844
2360
  emit(t, e) {
1845
- this.eventListeners.get(t)?.forEach((i) => {
2361
+ this.eventListeners.get(t)?.forEach((n) => {
1846
2362
  try {
1847
- i(e);
2363
+ n(e);
1848
2364
  } catch (o) {
1849
2365
  console.error(`Error in event listener for ${t}:`, o);
1850
2366
  }
@@ -1860,10 +2376,10 @@ class Re extends HTMLElement {
1860
2376
  * Execute command
1861
2377
  */
1862
2378
  executeCommand(t, ...e) {
1863
- const i = this.commands.get(t);
1864
- if (!i)
2379
+ const n = this.commands.get(t);
2380
+ if (!n)
1865
2381
  throw new Error(`Command not found: ${t}`);
1866
- return i(...e);
2382
+ return n(...e);
1867
2383
  }
1868
2384
  /**
1869
2385
  * Undo last change
@@ -1919,21 +2435,21 @@ class Re extends HTMLElement {
1919
2435
  * Set document from JSON
1920
2436
  */
1921
2437
  setJSON(t) {
1922
- this.state = it.fromJSON(t, this.state.schema), this.renderContent();
2438
+ this.state = ot.fromJSON(t, this.state.schema), this.renderContent();
1923
2439
  }
1924
2440
  /**
1925
2441
  * Get HTML content (sanitized)
1926
2442
  */
1927
2443
  getHTML() {
1928
2444
  const t = this.documentToHTML(this.state.getDocument());
1929
- return this.config.sanitizeHTML ? rt(t) : t;
2445
+ return this.config.sanitizeHTML ? st(t) : t;
1930
2446
  }
1931
2447
  /**
1932
2448
  * Set HTML content (with sanitization)
1933
2449
  * @param html - HTML content to set
1934
2450
  */
1935
2451
  setHTML(t) {
1936
- const e = this.config.sanitizeHTML ? rt(t) : t;
2452
+ const e = this.config.sanitizeHTML ? st(t) : t;
1937
2453
  this.contentElement && (this.contentElement.innerHTML = e, this.announceToScreenReader("Content updated"));
1938
2454
  }
1939
2455
  /**
@@ -1942,8 +2458,8 @@ class Re extends HTMLElement {
1942
2458
  * @param allowHTML - Allow HTML tags
1943
2459
  */
1944
2460
  setContent(t, e = !0) {
1945
- const i = this.config.sanitizeHTML ? An(t, e) : t;
1946
- this.contentElement && (this.contentElement.innerHTML = i, this.announceToScreenReader("Content updated"));
2461
+ const n = this.config.sanitizeHTML ? Dn(t, e) : t;
2462
+ this.contentElement && (this.contentElement.innerHTML = n, this.announceToScreenReader("Content updated"));
1947
2463
  }
1948
2464
  /**
1949
2465
  * Export HTML content (sanitized)
@@ -1965,8 +2481,8 @@ class Re extends HTMLElement {
1965
2481
  this.contentElement?.blur();
1966
2482
  }
1967
2483
  }
1968
- customElements.get("notectl-editor") || customElements.define("notectl-editor", Re);
1969
- class Mn {
2484
+ customElements.get("notectl-editor") || customElements.define("notectl-editor", ke);
2485
+ class $n {
1970
2486
  async init(t) {
1971
2487
  this.context = t;
1972
2488
  }
@@ -1979,7 +2495,7 @@ class Mn {
1979
2495
  return this.context;
1980
2496
  }
1981
2497
  }
1982
- class wn {
2498
+ class Rn {
1983
2499
  constructor(t, e) {
1984
2500
  this.operations = [], this.delta = {
1985
2501
  txnId: this.generateTxnId(),
@@ -2047,35 +2563,35 @@ class wn {
2047
2563
  });
2048
2564
  }
2049
2565
  }
2050
- function Pn(r, t) {
2051
- return new wn(r, t);
2566
+ function zn(r, t) {
2567
+ return new Rn(r, t);
2052
2568
  }
2053
- function Un(r) {
2569
+ function Vn(r) {
2054
2570
  return r.inverseOps || [];
2055
2571
  }
2056
- function Hn(r) {
2572
+ function Wn(r) {
2057
2573
  const t = [];
2058
2574
  return r.txnId || t.push("Delta must have a transaction ID"), r.clientId || t.push("Delta must have a client ID"), r.ops.length === 0 && t.push("Delta must contain at least one operation"), r.baseVersion < 0 && t.push("Base version must be non-negative"), {
2059
2575
  valid: t.length === 0,
2060
2576
  errors: t
2061
2577
  };
2062
2578
  }
2063
- function Fn(r) {
2579
+ function Yn(r) {
2064
2580
  return r.op === "insert_text" || r.op === "delete_range" || r.op === "apply_mark";
2065
2581
  }
2066
- function zn(r) {
2582
+ function Kn(r) {
2067
2583
  return r.op === "insert_block_before" || r.op === "insert_block_after" || r.op === "delete_block" || r.op === "set_attrs";
2068
2584
  }
2069
- function $n(r) {
2585
+ function jn(r) {
2070
2586
  return r.op.startsWith("table_");
2071
2587
  }
2072
- function Gn(r) {
2588
+ function Xn(r) {
2073
2589
  return r.op === "update_selection";
2074
2590
  }
2075
- function In(r, t, e) {
2076
- return r.op === "insert_text" && t.op === "insert_text" ? On(r, t, e) : r.op === "insert_text" && t.op === "delete_range" ? Nn(r, t) : r.op === "delete_range" && t.op === "insert_text" ? vn(r, t) : r.op === "delete_range" && t.op === "delete_range" ? Dn(r, t) : r;
2591
+ function Cn(r, t, e) {
2592
+ return r.op === "insert_text" && t.op === "insert_text" ? wn(r, t, e) : r.op === "insert_text" && t.op === "delete_range" ? Mn(r, t) : r.op === "delete_range" && t.op === "insert_text" ? vn(r, t) : r.op === "delete_range" && t.op === "delete_range" ? Pn(r, t) : r;
2077
2593
  }
2078
- function On(r, t, e) {
2594
+ function wn(r, t, e) {
2079
2595
  if (r.target.blockId === t.target.blockId) {
2080
2596
  if (t.target.offset <= r.target.offset)
2081
2597
  return {
@@ -2096,7 +2612,7 @@ function On(r, t, e) {
2096
2612
  }
2097
2613
  return r;
2098
2614
  }
2099
- function Nn(r, t) {
2615
+ function Mn(r, t) {
2100
2616
  if (r.target.blockId === t.range.start.blockId && r.target.offset >= t.range.start.offset) {
2101
2617
  const e = t.range.end.offset - t.range.start.offset;
2102
2618
  return {
@@ -2124,82 +2640,154 @@ function vn(r, t) {
2124
2640
  }
2125
2641
  } : r;
2126
2642
  }
2127
- function Dn(r, t, e) {
2643
+ function Pn(r, t, e) {
2128
2644
  if (r.range.start.blockId === t.range.start.blockId) {
2129
- const i = r.range.start.offset, o = r.range.end.offset, a = t.range.start.offset, u = t.range.end.offset;
2130
- if (u <= i) {
2131
- const h = u - a;
2645
+ const n = r.range.start.offset, o = r.range.end.offset, s = t.range.start.offset, l = t.range.end.offset;
2646
+ if (l <= n) {
2647
+ const h = l - s;
2132
2648
  return {
2133
2649
  ...r,
2134
2650
  range: {
2135
- start: { ...r.range.start, offset: i - h },
2651
+ start: { ...r.range.start, offset: n - h },
2136
2652
  end: { ...r.range.end, offset: o - h }
2137
2653
  }
2138
2654
  };
2139
2655
  }
2140
- if (a <= i && u >= o)
2656
+ if (s <= n && l >= o)
2141
2657
  return {
2142
2658
  ...r,
2143
2659
  range: {
2144
- start: { ...r.range.start, offset: a },
2145
- end: { ...r.range.end, offset: a }
2660
+ start: { ...r.range.start, offset: s },
2661
+ end: { ...r.range.end, offset: s }
2146
2662
  }
2147
2663
  };
2148
2664
  }
2149
2665
  return r;
2150
2666
  }
2151
- function Wn(r, t, e = "left") {
2152
- const i = r.ops.map((o) => {
2153
- let a = o;
2154
- for (const u of t.ops)
2155
- a = In(a, u, e);
2156
- return a;
2667
+ function qn(r, t, e = "left") {
2668
+ const n = r.ops.map((o) => {
2669
+ let s = o;
2670
+ for (const l of t.ops)
2671
+ s = Cn(s, l, e);
2672
+ return s;
2157
2673
  });
2158
2674
  return {
2159
2675
  ...r,
2160
- ops: i,
2676
+ ops: n,
2161
2677
  baseVersion: t.baseVersion + 1
2162
2678
  // Update to new base
2163
2679
  };
2164
2680
  }
2165
- function Bn(r, t) {
2681
+ function Zn(r, t) {
2166
2682
  return {
2167
2683
  ...t,
2168
2684
  ops: [...r.ops, ...t.ops],
2169
2685
  baseVersion: r.baseVersion
2170
2686
  };
2171
2687
  }
2172
- function Kn(r, t) {
2688
+ function Jn(r, t) {
2173
2689
  return t.baseVersion === r.baseVersion || t.clientId === r.clientId;
2174
2690
  }
2175
- function Yn(r, t) {
2176
- const e = new Re();
2691
+ const Qn = {
2692
+ /**
2693
+ * Check if selection is collapsed (cursor)
2694
+ */
2695
+ isCollapsed(r) {
2696
+ return r.anchor.blockId === r.head.blockId && r.anchor.offset === r.head.offset;
2697
+ },
2698
+ /**
2699
+ * Check if selection spans multiple blocks
2700
+ */
2701
+ isMultiBlock(r) {
2702
+ return r.anchor.blockId !== r.head.blockId;
2703
+ },
2704
+ /**
2705
+ * Get the direction of selection (forward/backward)
2706
+ */
2707
+ getDirection(r) {
2708
+ return this.isCollapsed(r) ? "none" : r.anchor.blockId === r.head.blockId ? r.anchor.offset < r.head.offset ? "forward" : "backward" : "forward";
2709
+ },
2710
+ /**
2711
+ * Create a collapsed selection at a position
2712
+ */
2713
+ createCollapsed(r) {
2714
+ return {
2715
+ anchor: r,
2716
+ head: r
2717
+ };
2718
+ },
2719
+ /**
2720
+ * Create a selection range
2721
+ */
2722
+ createRange(r, t) {
2723
+ return {
2724
+ anchor: r,
2725
+ head: t
2726
+ };
2727
+ }
2728
+ }, ti = {
2729
+ /**
2730
+ * Check if a node is a text node
2731
+ */
2732
+ isTextNode(r) {
2733
+ return "text" in r && r.type === "text";
2734
+ },
2735
+ /**
2736
+ * Check if a node is a block node
2737
+ */
2738
+ isBlockNode(r) {
2739
+ return "id" in r && "type" in r;
2740
+ },
2741
+ /**
2742
+ * Get all text content from a block
2743
+ */
2744
+ getTextContent(r) {
2745
+ return r.children ? r.children.map((t) => this.isTextNode(t) ? t.text : this.isBlockNode(t) ? this.getTextContent(t) : "").join("") : "";
2746
+ },
2747
+ /**
2748
+ * Check if block is empty
2749
+ */
2750
+ isEmpty(r) {
2751
+ return !r.children || r.children.length === 0 ? !0 : this.getTextContent(r).trim() === "";
2752
+ }
2753
+ };
2754
+ function ei(r, t) {
2755
+ const e = new ke();
2177
2756
  return r.appendChild(e), e;
2178
2757
  }
2179
- const Vn = "0.0.1";
2758
+ const ni = "0.0.1";
2180
2759
  export {
2181
- Mn as BasePlugin,
2182
- wn as DeltaBuilder,
2183
- it as EditorState,
2184
- qe as NodeFactory,
2185
- Re as NotectlEditor,
2186
- Je as PluginManager,
2187
- Xe as Schema,
2188
- Vn as VERSION,
2189
- Kn as canCompose,
2190
- Bn as composeDelta,
2191
- Un as computeInverse,
2760
+ Fn as ARIA_ANNOUNCEMENT_DELAY,
2761
+ $n as BasePlugin,
2762
+ Hn as DEFAULT_MAX_HISTORY_DEPTH,
2763
+ Gn as DEFAULT_MIN_HEIGHT,
2764
+ Rn as DeltaBuilder,
2765
+ Un as EDITOR_READY_TIMEOUT,
2766
+ ot as EditorState,
2767
+ R as ErrorCodes,
2768
+ Je as NodeFactory,
2769
+ ke as NotectlEditor,
2770
+ O as NotectlError,
2771
+ tn as PluginManager,
2772
+ Ze as Schema,
2773
+ ni as VERSION,
2774
+ Bn as ValidationConstraints,
2775
+ ti as blockHelpers,
2776
+ Jn as canCompose,
2777
+ Zn as composeDelta,
2778
+ Vn as computeInverse,
2192
2779
  be as createDefaultSchema,
2193
- Pn as createDelta,
2194
- Yn as createEditor,
2195
- Ze as createNodeFactory,
2196
- O as generateBlockId,
2197
- zn as isBlockOperation,
2198
- Gn as isSelectionOperation,
2199
- $n as isTableOperation,
2200
- Fn as isTextOperation,
2201
- Wn as transformDelta,
2202
- In as transformOperation,
2203
- Hn as validateDelta
2780
+ zn as createDelta,
2781
+ ei as createEditor,
2782
+ Qe as createNodeFactory,
2783
+ w as generateBlockId,
2784
+ Kn as isBlockOperation,
2785
+ Xn as isSelectionOperation,
2786
+ jn as isTableOperation,
2787
+ Yn as isTextOperation,
2788
+ Qn as selectionHelpers,
2789
+ qn as transformDelta,
2790
+ Cn as transformOperation,
2791
+ Wn as validateDelta
2204
2792
  };
2205
2793
  //# sourceMappingURL=notectl-core.js.map