fable-editor 1.3.2 → 1.4.0

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.
@@ -13,15 +13,15 @@ var Jt;
13
13
  function Ke() {
14
14
  if (Jt) return J;
15
15
  Jt = 1;
16
- var d = me, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = { key: !0, ref: !0, __self: !0, __source: !0 };
17
- function l(r, o, a) {
18
- var u, p = {}, m = null, v = null;
19
- a !== void 0 && (m = "" + a), o.key !== void 0 && (m = "" + o.key), o.ref !== void 0 && (v = o.ref);
20
- for (u in o) i.call(o, u) && !n.hasOwnProperty(u) && (p[u] = o[u]);
21
- if (r && r.defaultProps) for (u in o = r.defaultProps, o) p[u] === void 0 && (p[u] = o[u]);
22
- return { $$typeof: t, type: r, key: m, ref: v, props: p, _owner: s.current };
23
- }
24
- return J.Fragment = e, J.jsx = l, J.jsxs = l, J;
16
+ var u = me, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = { key: !0, ref: !0, __self: !0, __source: !0 };
17
+ function r(o, l, a) {
18
+ var d, p = {}, m = null, v = null;
19
+ a !== void 0 && (m = "" + a), l.key !== void 0 && (m = "" + l.key), l.ref !== void 0 && (v = l.ref);
20
+ for (d in l) i.call(l, d) && !n.hasOwnProperty(d) && (p[d] = l[d]);
21
+ if (o && o.defaultProps) for (d in l = o.defaultProps, l) p[d] === void 0 && (p[d] = l[d]);
22
+ return { $$typeof: t, type: o, key: m, ref: v, props: p, _owner: s.current };
23
+ }
24
+ return J.Fragment = e, J.jsx = r, J.jsxs = r, J;
25
25
  }
26
26
  var tt = {};
27
27
  /**
@@ -36,14 +36,14 @@ var tt = {};
36
36
  var te;
37
37
  function Qe() {
38
38
  return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
39
- var d = me, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), n = Symbol.for("react.profiler"), l = Symbol.for("react.provider"), r = Symbol.for("react.context"), o = Symbol.for("react.forward_ref"), a = Symbol.for("react.suspense"), u = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), v = Symbol.for("react.offscreen"), b = Symbol.iterator, f = "@@iterator";
39
+ var u = me, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), n = Symbol.for("react.profiler"), r = Symbol.for("react.provider"), o = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), a = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), v = Symbol.for("react.offscreen"), b = Symbol.iterator, f = "@@iterator";
40
40
  function y(c) {
41
41
  if (c === null || typeof c != "object")
42
42
  return null;
43
43
  var g = b && c[b] || c[f];
44
44
  return typeof g == "function" ? g : null;
45
45
  }
46
- var C = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
46
+ var C = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
47
  function E(c) {
48
48
  {
49
49
  for (var g = arguments.length, x = new Array(g > 1 ? g - 1 : 0), T = 1; T < g; T++)
@@ -64,7 +64,7 @@ function Qe() {
64
64
  var A = !1, $ = !1, F = !1, Z = !1, et = !1, kt;
65
65
  kt = Symbol.for("react.module.reference");
66
66
  function xe(c) {
67
- return !!(typeof c == "string" || typeof c == "function" || c === i || c === n || et || c === s || c === a || c === u || Z || c === v || A || $ || F || typeof c == "object" && c !== null && (c.$$typeof === m || c.$$typeof === p || c.$$typeof === l || c.$$typeof === r || c.$$typeof === o || // This needs to include all possible module reference object
67
+ return !!(typeof c == "string" || typeof c == "function" || c === i || c === n || et || c === s || c === a || c === d || Z || c === v || A || $ || F || typeof c == "object" && c !== null && (c.$$typeof === m || c.$$typeof === p || c.$$typeof === r || c.$$typeof === o || c.$$typeof === l || // This needs to include all possible module reference object
68
68
  // types supported by any Flight configuration anywhere since
69
69
  // we don't know which Flight build this will end up being used
70
70
  // with.
@@ -98,18 +98,18 @@ function Qe() {
98
98
  return "StrictMode";
99
99
  case a:
100
100
  return "Suspense";
101
- case u:
101
+ case d:
102
102
  return "SuspenseList";
103
103
  }
104
104
  if (typeof c == "object")
105
105
  switch (c.$$typeof) {
106
- case r:
106
+ case o:
107
107
  var g = c;
108
108
  return At(g) + ".Consumer";
109
- case l:
109
+ case r:
110
110
  var x = c;
111
111
  return At(x._context) + ".Provider";
112
- case o:
112
+ case l:
113
113
  return Ce(c, c.render, "ForwardRef");
114
114
  case p:
115
115
  var T = c.displayName || null;
@@ -294,12 +294,12 @@ function Qe() {
294
294
  switch (c) {
295
295
  case a:
296
296
  return it("Suspense");
297
- case u:
297
+ case d:
298
298
  return it("SuspenseList");
299
299
  }
300
300
  if (typeof c == "object")
301
301
  switch (c.$$typeof) {
302
- case o:
302
+ case l:
303
303
  return Se(c.render);
304
304
  case p:
305
305
  return nt(c.type, g, x);
@@ -539,7 +539,7 @@ Check the top-level render call using <` + x + ">.");
539
539
  var x;
540
540
  if (typeof g == "function")
541
541
  x = g.propTypes;
542
- else if (typeof g == "object" && (g.$$typeof === o || // Note: Memo only checks outer props here.
542
+ else if (typeof g == "object" && (g.$$typeof === l || // Note: Memo only checks outer props here.
543
543
  // Inner props are checked in the reconciler.
544
544
  g.$$typeof === p))
545
545
  x = g.propTypes;
@@ -1011,8 +1011,8 @@ const ti = {
1011
1011
  emcat_flags: "أعلام"
1012
1012
  }
1013
1013
  };
1014
- function wt(d) {
1015
- return ti[d];
1014
+ function wt(u) {
1015
+ return ti[u];
1016
1016
  }
1017
1017
  const ei = "undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote code changecase lineheight wordspacing letterspacing | removeformat | blocks | ltr rtl | quickimage quickvideo quicktable codesample template charmap emoji | fullscreen sourcecode", ii = "file edit view insert format tools table help", si = [
1018
1018
  ["Andale Mono", "andale mono,times"],
@@ -2151,8 +2151,8 @@ const ei = "undo redo | preview print | importword revhistory | fontfamily fonts
2151
2151
  "🇲🇦"
2152
2152
  ]
2153
2153
  }
2154
- ], L = (d, t) => `<svg viewBox="${t || "0 0 24 24"}">${d}</svg>`, w = (d) => L(`<path class="f" d="${d}"/>`, "0 -960 960 960"), ot = (d, t = 7.5) => L(
2155
- '<path d="M10 6h10M10 12h10M10 18h10"/>' + d.map(
2154
+ ], L = (u, t) => `<svg viewBox="${t || "0 0 24 24"}">${u}</svg>`, w = (u) => L(`<path class="f" d="${u}"/>`, "0 -960 960 960"), ot = (u, t = 7.5) => L(
2155
+ '<path d="M10 6h10M10 12h10M10 18h10"/>' + u.map(
2156
2156
  (e, i) => `<text x="2.5" y="${8.4 + i * 6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`
2157
2157
  ).join("")
2158
2158
  ), h = {
@@ -2487,26 +2487,26 @@ const ei = "undo redo | preview print | importword revhistory | fontfamily fonts
2487
2487
  th: ["width", "valign"],
2488
2488
  table: ["width", "cellpadding", "cellspacing"]
2489
2489
  };
2490
- function pt(d) {
2491
- const t = {}, e = d.getAttribute && d.getAttribute("style");
2490
+ function pt(u) {
2491
+ const t = {}, e = u.getAttribute && u.getAttribute("style");
2492
2492
  return e && e.split(";").forEach((i) => {
2493
2493
  const s = i.indexOf(":");
2494
2494
  s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
2495
2495
  }), t;
2496
2496
  }
2497
- function pi(d) {
2498
- return d.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi, "$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi, "$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi, "$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi, "").replace(/<\/?(meta|link)[^>]*>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi, "");
2497
+ function pi(u) {
2498
+ return u.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi, "$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi, "$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi, "$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi, "").replace(/<\/?(meta|link)[^>]*>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi, "");
2499
2499
  }
2500
- function mi(d) {
2501
- return /^[0-9]+[\.\)،]/.test(d) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(d) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(d) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(d) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(d) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(d) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(d) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
2500
+ function mi(u) {
2501
+ return /^[0-9]+[\.\)،]/.test(u) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(u) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(u) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(u) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(u) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(u) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(u) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
2502
2502
  }
2503
- function fi(d) {
2503
+ function fi(u) {
2504
2504
  const t = (s) => {
2505
2505
  const n = (s.getAttribute("style") || "") + " " + (s.className || "");
2506
2506
  return /mso-list\s*:(?!\s*ignore)/i.test(n) || /MsoListParagraph/i.test(n);
2507
2507
  }, e = [];
2508
2508
  let i = null;
2509
- Array.from(d.body.querySelectorAll("p")).forEach((s) => {
2509
+ Array.from(u.body.querySelectorAll("p")).forEach((s) => {
2510
2510
  if (!t(s)) {
2511
2511
  i = null;
2512
2512
  return;
@@ -2514,55 +2514,55 @@ function fi(d) {
2514
2514
  const n = s.previousElementSibling;
2515
2515
  i && n && i[i.length - 1] === n ? i.push(s) : (i = [s], e.push(i));
2516
2516
  }), e.forEach((s) => {
2517
- const n = [], l = s[0];
2518
- s.forEach((r) => {
2517
+ const n = [], r = s[0];
2518
+ s.forEach((o) => {
2519
2519
  var C, E, I;
2520
- const a = +(((C = (r.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : C[1]) || 1), u = Array.from(r.querySelectorAll("span")).find(
2520
+ const a = +(((C = (o.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : C[1]) || 1), d = Array.from(o.querySelectorAll("span")).find(
2521
2521
  (A) => /mso-list\s*:\s*ignore/i.test(A.getAttribute("style") || "")
2522
- ), p = u ? ((E = u.textContent) == null ? void 0 : E.trim()) || "" : (((I = r.textContent) == null ? void 0 : I.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: v } = mi(p);
2523
- for (u && u.remove(); n.length && n[n.length - 1].level > a; ) n.pop();
2522
+ ), p = d ? ((E = d.textContent) == null ? void 0 : E.trim()) || "" : (((I = o.textContent) == null ? void 0 : I.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: v } = mi(p);
2523
+ for (d && d.remove(); n.length && n[n.length - 1].level > a; ) n.pop();
2524
2524
  if (!n.length || n[n.length - 1].level < a) {
2525
- const A = d.createElement(m ? "ol" : "ul");
2525
+ const A = u.createElement(m ? "ol" : "ul");
2526
2526
  if (m && v && (A.style.listStyleType = v), n.length) {
2527
2527
  const $ = n[n.length - 1].list;
2528
2528
  ($.lastElementChild || $).appendChild(A);
2529
2529
  } else
2530
- l.parentNode.insertBefore(A, l);
2530
+ r.parentNode.insertBefore(A, r);
2531
2531
  n.push({ list: A, level: a });
2532
2532
  }
2533
- const b = d.createElement("li"), f = pt(r), y = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((A) => f[A]).map((A) => A + ":" + f[A]).join(";");
2534
- for (y && b.setAttribute("style", y), r.getAttribute("dir") && b.setAttribute("dir", r.getAttribute("dir")); r.firstChild; ) b.appendChild(r.firstChild);
2535
- n[n.length - 1].list.appendChild(b), r.remove();
2533
+ const b = u.createElement("li"), f = pt(o), y = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((A) => f[A]).map((A) => A + ":" + f[A]).join(";");
2534
+ for (y && b.setAttribute("style", y), o.getAttribute("dir") && b.setAttribute("dir", o.getAttribute("dir")); o.firstChild; ) b.appendChild(o.firstChild);
2535
+ n[n.length - 1].list.appendChild(b), o.remove();
2536
2536
  });
2537
2537
  });
2538
2538
  }
2539
- function gi(d) {
2540
- d.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
2539
+ function gi(u) {
2540
+ u.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
2541
2541
  for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
2542
2542
  t.remove();
2543
2543
  });
2544
2544
  }
2545
- function vi(d) {
2546
- d.querySelectorAll("table").forEach((t) => {
2545
+ function vi(u) {
2546
+ u.querySelectorAll("table").forEach((t) => {
2547
2547
  const e = t;
2548
2548
  pt(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
2549
- }), d.querySelectorAll("[align]").forEach((t) => {
2549
+ }), u.querySelectorAll("[align]").forEach((t) => {
2550
2550
  const e = t, i = e.getAttribute("align").toLowerCase();
2551
2551
  e.tagName.toLowerCase() === "table" ? i === "center" ? (e.style.marginLeft = e.style.marginLeft || "auto", e.style.marginRight = e.style.marginRight || "auto") : i === "right" ? e.style.marginLeft = e.style.marginLeft || "auto" : i === "left" && (e.style.marginRight = e.style.marginRight || "auto") : ["left", "right", "center", "justify"].includes(i) && (e.style.textAlign = e.style.textAlign || i, Array.from(e.children).forEach((s) => {
2552
2552
  if (s.tagName.toLowerCase() !== "table") return;
2553
2553
  const n = s;
2554
2554
  i === "center" ? (n.style.marginLeft = n.style.marginLeft || "auto", n.style.marginRight = n.style.marginRight || "auto") : i === "right" ? n.style.marginLeft = n.style.marginLeft || "auto" : i === "left" && (n.style.marginRight = n.style.marginRight || "auto");
2555
2555
  })), e.removeAttribute("align");
2556
- }), d.querySelectorAll("center table").forEach((t) => {
2556
+ }), u.querySelectorAll("center table").forEach((t) => {
2557
2557
  const e = t;
2558
2558
  e.style.marginLeft = e.style.marginLeft || "auto", e.style.marginRight = e.style.marginRight || "auto";
2559
- }), d.querySelectorAll("[bgcolor]").forEach((t) => {
2559
+ }), u.querySelectorAll("[bgcolor]").forEach((t) => {
2560
2560
  const e = t;
2561
2561
  e.style.backgroundColor = e.style.backgroundColor || e.getAttribute("bgcolor"), e.removeAttribute("bgcolor");
2562
2562
  });
2563
2563
  }
2564
- function dt(d, t) {
2565
- Array.from(d.childNodes).forEach((e) => {
2564
+ function dt(u, t) {
2565
+ Array.from(u.childNodes).forEach((e) => {
2566
2566
  if (e.nodeType === Node.COMMENT_NODE) {
2567
2567
  e.remove();
2568
2568
  return;
@@ -2571,11 +2571,11 @@ function dt(d, t) {
2571
2571
  const i = e, s = i.tagName.toLowerCase();
2572
2572
  if (!di.has(s)) {
2573
2573
  if (s === "font") {
2574
- const o = t.createElement("span");
2575
- i.getAttribute("style") && o.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (o.style.color = i.getAttribute("color")), i.getAttribute("face") && (o.style.fontFamily = i.getAttribute("face"));
2574
+ const l = t.createElement("span");
2575
+ i.getAttribute("style") && l.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (l.style.color = i.getAttribute("color")), i.getAttribute("face") && (l.style.fontFamily = i.getAttribute("face"));
2576
2576
  const a = i.getAttribute("size");
2577
- if (a && !o.style.fontSize) {
2578
- const u = {
2577
+ if (a && !l.style.fontSize) {
2578
+ const d = {
2579
2579
  1: "8pt",
2580
2580
  2: "10pt",
2581
2581
  3: "12pt",
@@ -2584,10 +2584,10 @@ function dt(d, t) {
2584
2584
  6: "24pt",
2585
2585
  7: "36pt"
2586
2586
  };
2587
- u[a] && (o.style.fontSize = u[a]);
2587
+ d[a] && (l.style.fontSize = d[a]);
2588
2588
  }
2589
- for (; i.firstChild; ) o.appendChild(i.firstChild);
2590
- i.replaceWith(o), dt(o, t);
2589
+ for (; i.firstChild; ) l.appendChild(i.firstChild);
2590
+ i.replaceWith(l), dt(l, t);
2591
2591
  return;
2592
2592
  }
2593
2593
  for (dt(i, t); i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
@@ -2595,142 +2595,142 @@ function dt(d, t) {
2595
2595
  return;
2596
2596
  }
2597
2597
  const n = /* @__PURE__ */ new Set([...le["*"] || [], ...le[s] || []]);
2598
- if (Array.from(i.attributes).forEach((o) => {
2599
- const a = o.name.toLowerCase();
2600
- a !== "style" && !n.has(a) && i.removeAttribute(o.name);
2598
+ if (Array.from(i.attributes).forEach((l) => {
2599
+ const a = l.name.toLowerCase();
2600
+ a !== "style" && !n.has(a) && i.removeAttribute(l.name);
2601
2601
  }), s === "a") {
2602
- const o = i.getAttribute("href") || "";
2603
- /^(https?:|mailto:|tel:|#)/i.test(o) || i.removeAttribute("href");
2602
+ const l = i.getAttribute("href") || "";
2603
+ /^(https?:|mailto:|tel:|#)/i.test(l) || i.removeAttribute("href");
2604
2604
  }
2605
2605
  if (s === "img") {
2606
- const o = i.getAttribute("src") || "";
2607
- if (!/^(https?:|data:image\/|blob:)/i.test(o)) {
2606
+ const l = i.getAttribute("src") || "";
2607
+ if (!/^(https?:|data:image\/|blob:)/i.test(l)) {
2608
2608
  const a = t.createElement("span");
2609
2609
  a.textContent = "[local image — paste it separately]", a.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(a);
2610
2610
  return;
2611
2611
  }
2612
2612
  }
2613
- const l = pt(i), r = [];
2614
- for (const [o, a] of Object.entries(l))
2615
- ui.has(o) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || o === "font-weight" && /^(400|normal)$/i.test(a) || o === "font-style" && /^normal$/i.test(a) || o === "text-decoration" && /^none$/i.test(a) || r.push(o + ":" + a));
2616
- if (r.length ? i.setAttribute("style", r.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), dt(i, t), s === "span" && !i.attributes.length) {
2613
+ const r = pt(i), o = [];
2614
+ for (const [l, a] of Object.entries(r))
2615
+ ui.has(l) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || l === "font-weight" && /^(400|normal)$/i.test(a) || l === "font-style" && /^normal$/i.test(a) || l === "text-decoration" && /^none$/i.test(a) || o.push(l + ":" + a));
2616
+ if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), dt(i, t), s === "span" && !i.attributes.length) {
2617
2617
  for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
2618
2618
  i.remove();
2619
2619
  }
2620
2620
  });
2621
2621
  }
2622
- function bi(d) {
2622
+ function bi(u) {
2623
2623
  const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
2624
2624
  let i;
2625
- for (; i = e.exec(d); ) {
2625
+ for (; i = e.exec(u); ) {
2626
2626
  let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
2627
2627
  s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
2628
2628
  let n;
2629
- const l = /([^{}]+)\{([^}]*)\}/g;
2630
- for (; n = l.exec(s); ) {
2631
- const r = n[2].split(";").map((o) => {
2632
- const a = o.indexOf(":");
2633
- return a < 1 ? null : [o.slice(0, a).trim().toLowerCase(), o.slice(a + 1).trim()];
2634
- }).filter((o) => !!o && !!o[1]);
2635
- r.length && n[1].split(",").map((o) => o.trim()).filter((o) => o && !o.startsWith("@")).forEach((o) => t.push({ sel: o, decls: r }));
2629
+ const r = /([^{}]+)\{([^}]*)\}/g;
2630
+ for (; n = r.exec(s); ) {
2631
+ const o = n[2].split(";").map((l) => {
2632
+ const a = l.indexOf(":");
2633
+ return a < 1 ? null : [l.slice(0, a).trim().toLowerCase(), l.slice(a + 1).trim()];
2634
+ }).filter((l) => !!l && !!l[1]);
2635
+ o.length && n[1].split(",").map((l) => l.trim()).filter((l) => l && !l.startsWith("@")).forEach((l) => t.push({ sel: l, decls: o }));
2636
2636
  }
2637
2637
  }
2638
2638
  return t;
2639
2639
  }
2640
- function yi(d, t) {
2640
+ function yi(u, t) {
2641
2641
  if (!t.length) return;
2642
2642
  const e = /* @__PURE__ */ new Map();
2643
2643
  t.forEach(({ sel: i, decls: s }) => {
2644
2644
  let n;
2645
2645
  try {
2646
- n = d.querySelectorAll(i);
2646
+ n = u.querySelectorAll(i);
2647
2647
  } catch {
2648
2648
  return;
2649
2649
  }
2650
- n.forEach((l) => {
2651
- let r = e.get(l);
2652
- r || (r = {}, e.set(l, r)), s.forEach(([o, a]) => {
2653
- r[o] = a;
2650
+ n.forEach((r) => {
2651
+ let o = e.get(r);
2652
+ o || (o = {}, e.set(r, o)), s.forEach(([l, a]) => {
2653
+ o[l] = a;
2654
2654
  });
2655
2655
  });
2656
2656
  }), e.forEach((i, s) => {
2657
- const n = pt(s), l = s.hasAttribute("dir"), r = s.hasAttribute("align"), o = Object.entries(i).filter(([p]) => !(p in n || (p === "direction" || p === "unicode-bidi") && l || p === "text-align" && (r || l) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2658
- if (!o.length) return;
2659
- const a = o.map(([p, m]) => p + ":" + m).join(";"), u = s.getAttribute("style");
2660
- s.setAttribute("style", u ? a + ";" + u : a);
2657
+ const n = pt(s), r = s.hasAttribute("dir"), o = s.hasAttribute("align"), l = Object.entries(i).filter(([p]) => !(p in n || (p === "direction" || p === "unicode-bidi") && r || p === "text-align" && (o || r) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2658
+ if (!l.length) return;
2659
+ const a = l.map(([p, m]) => p + ":" + m).join(";"), d = s.getAttribute("style");
2660
+ s.setAttribute("style", d ? a + ";" + d : a);
2661
2661
  });
2662
2662
  }
2663
- function fe(d) {
2664
- return d.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
2663
+ function fe(u) {
2664
+ return u.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
2665
2665
  }
2666
- function xi(d) {
2667
- const t = d.createTreeWalker(d.body, NodeFilter.SHOW_TEXT, null);
2666
+ function xi(u) {
2667
+ const t = u.createTreeWalker(u.body, NodeFilter.SHOW_TEXT, null);
2668
2668
  let e;
2669
2669
  for (; e = t.nextNode(); )
2670
2670
  /[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = fe(e.nodeValue || ""));
2671
2671
  }
2672
- function Ci(d, t = "ltr") {
2673
- const e = bi(d), i = new DOMParser().parseFromString(pi(d), "text/html");
2672
+ function Ci(u, t = "ltr") {
2673
+ const e = bi(u), i = new DOMParser().parseFromString(pi(u), "text/html");
2674
2674
  yi(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && fi(i), gi(i), vi(i), dt(i.body, i), xi(i);
2675
2675
  const s = (n) => {
2676
- var l;
2677
- return n && n.tagName === "P" && !((l = n.textContent) != null && l.trim()) && !n.querySelector("img,table");
2676
+ var r;
2677
+ return n && n.tagName === "P" && !((r = n.textContent) != null && r.trim()) && !n.querySelector("img,table");
2678
2678
  };
2679
2679
  for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
2680
2680
  for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
2681
2681
  return i.body.innerHTML.trim();
2682
2682
  }
2683
- function wi(d) {
2684
- const t = fe(d).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2683
+ function wi(u) {
2684
+ const t = fe(u).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2685
2685
  return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
2686
2686
  }
2687
2687
  const Ti = 10 * 1024 * 1024, ge = /^(https?:|data:image\/|blob:)/i;
2688
- function oe(d, t) {
2688
+ function oe(u, t) {
2689
2689
  const e = [], i = "{\\" + t;
2690
2690
  let s = 0;
2691
- for (; (s = d.indexOf(i, s)) !== -1; ) {
2692
- const n = d[s + i.length];
2691
+ for (; (s = u.indexOf(i, s)) !== -1; ) {
2692
+ const n = u[s + i.length];
2693
2693
  if (n && /[a-z0-9]/i.test(n)) {
2694
2694
  s += i.length;
2695
2695
  continue;
2696
2696
  }
2697
- let l = 0, r = s;
2698
- for (; r < d.length; r++) {
2699
- const o = d[r];
2700
- if (o === "\\") {
2701
- r++;
2697
+ let r = 0, o = s;
2698
+ for (; o < u.length; o++) {
2699
+ const l = u[o];
2700
+ if (l === "\\") {
2701
+ o++;
2702
2702
  continue;
2703
2703
  }
2704
- if (o === "{") l++;
2705
- else if (o === "}" && (l--, !l))
2704
+ if (l === "{") r++;
2705
+ else if (l === "}" && (r--, !r))
2706
2706
  break;
2707
2707
  }
2708
- e.push({ start: s, end: r + 1, body: d.slice(s + i.length, r) }), s = r + 1;
2708
+ e.push({ start: s, end: o + 1, body: u.slice(s + i.length, o) }), s = o + 1;
2709
2709
  }
2710
2710
  return e;
2711
2711
  }
2712
- function Ei(d) {
2713
- const t = new Uint8Array(d.length / 2);
2714
- for (let e = 0; e < t.length; e++) t[e] = parseInt(d.substr(e * 2, 2), 16);
2712
+ function Ei(u) {
2713
+ const t = new Uint8Array(u.length / 2);
2714
+ for (let e = 0; e < t.length; e++) t[e] = parseInt(u.substr(e * 2, 2), 16);
2715
2715
  return t;
2716
2716
  }
2717
- function Tt(d) {
2717
+ function Tt(u) {
2718
2718
  let t = "";
2719
- for (let e = 0; e < d.length; e++) t += String.fromCharCode(d[e]);
2719
+ for (let e = 0; e < u.length; e++) t += String.fromCharCode(u[e]);
2720
2720
  return btoa(t);
2721
2721
  }
2722
- function ae(d, t) {
2723
- t: for (let e = 0; e + t.length <= d.length; e++) {
2724
- for (let i = 0; i < t.length; i++) if (d[e + i] !== t[i]) continue t;
2722
+ function ae(u, t) {
2723
+ t: for (let e = 0; e + t.length <= u.length; e++) {
2724
+ for (let i = 0; i < t.length; i++) if (u[e + i] !== t[i]) continue t;
2725
2725
  return e;
2726
2726
  }
2727
2727
  return -1;
2728
2728
  }
2729
2729
  const Si = [137, 80, 78, 71], Mi = [255, 216, 255];
2730
- function Li(d) {
2730
+ function Li(u) {
2731
2731
  let t = null;
2732
- if (/\\pngblip/.test(d) ? t = "image/png" : /\\jpegblip/.test(d) ? t = "image/jpeg" : (/\\wmetafile\d*/.test(d) || /\\emfblip/.test(d)) && (t = "metafile"), !t) return null;
2733
- let e = d.replace(/\{[^{}]*\}/g, " ").replace(/\\[a-z]+-?\d*\s?/gi, " ").replace(/[^0-9a-fA-F]/g, "");
2732
+ if (/\\pngblip/.test(u) ? t = "image/png" : /\\jpegblip/.test(u) ? t = "image/jpeg" : (/\\wmetafile\d*/.test(u) || /\\emfblip/.test(u)) && (t = "metafile"), !t) return null;
2733
+ let e = u.replace(/\{[^{}]*\}/g, " ").replace(/\\[a-z]+-?\d*\s?/gi, " ").replace(/[^0-9a-fA-F]/g, "");
2734
2734
  if (e.length % 2 && (e = e.slice(0, -1)), !e) return null;
2735
2735
  const i = Ei(e);
2736
2736
  if (t === "metafile") {
@@ -2741,10 +2741,10 @@ function Li(d) {
2741
2741
  }
2742
2742
  return "data:" + t + ";base64," + Tt(i);
2743
2743
  }
2744
- function ki(d) {
2745
- if (!d || d.indexOf("\\pict") === -1) return [];
2746
- let t = d;
2747
- oe(d, "nonshppict").reverse().forEach((i) => {
2744
+ function ki(u) {
2745
+ if (!u || u.indexOf("\\pict") === -1) return [];
2746
+ let t = u;
2747
+ oe(u, "nonshppict").reverse().forEach((i) => {
2748
2748
  t = t.slice(0, i.start) + t.slice(i.end);
2749
2749
  });
2750
2750
  let e = Ti;
@@ -2754,29 +2754,29 @@ function ki(d) {
2754
2754
  return s && (e -= s.length * 0.75), s;
2755
2755
  });
2756
2756
  }
2757
- function ce(d) {
2758
- const t = d.match(/^\s*(-?[\d.]+)\s*(pt|px|in|cm|mm)?\s*$/i);
2757
+ function ce(u) {
2758
+ const t = u.match(/^\s*(-?[\d.]+)\s*(pt|px|in|cm|mm)?\s*$/i);
2759
2759
  if (!t) return null;
2760
2760
  const e = parseFloat(t[1]);
2761
2761
  if (!isFinite(e) || e <= 0) return null;
2762
2762
  const i = (t[2] || "px").toLowerCase(), s = i === "pt" ? e * 4 / 3 : i === "in" ? e * 96 : i === "cm" ? e * 96 / 2.54 : i === "mm" ? e * 96 / 25.4 : e;
2763
2763
  return Math.round(s);
2764
2764
  }
2765
- function Ai(d, t) {
2766
- const e = d.match(new RegExp("\\s" + t + `\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
2765
+ function Ai(u, t) {
2766
+ const e = u.match(new RegExp("\\s" + t + `\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
2767
2767
  return e ? e[1] ?? e[2] ?? e[3] ?? "" : "";
2768
2768
  }
2769
- function Hi(d) {
2770
- if (!/<v:imagedata\b/i.test(d)) return d;
2769
+ function Hi(u) {
2770
+ if (!/<v:imagedata\b/i.test(u)) return u;
2771
2771
  const t = (i, s) => {
2772
2772
  const n = Ai(i, "src");
2773
2773
  if (!n) return null;
2774
- const l = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2775
- if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + l, "i").test(d)) return null;
2776
- const r = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", o = ce((r.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = ce((r.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
2777
- return '<img src="' + n.replace(/"/g, "&quot;") + '"' + (o ? ' width="' + o + '"' : "") + (a ? ' height="' + a + '"' : "") + ">";
2774
+ const r = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2775
+ if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + r, "i").test(u)) return null;
2776
+ const o = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", l = ce((o.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = ce((o.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
2777
+ return '<img src="' + n.replace(/"/g, "&quot;") + '"' + (l ? ' width="' + l + '"' : "") + (a ? ' height="' + a + '"' : "") + ">";
2778
2778
  };
2779
- let e = d.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi, (i, s) => {
2779
+ let e = u.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi, (i, s) => {
2780
2780
  const n = s.match(/<v:imagedata\b[^>]*>/i);
2781
2781
  return n && t(n[0], s) || i;
2782
2782
  });
@@ -2785,80 +2785,80 @@ function Hi(d) {
2785
2785
  return s && t(s[0], i) || i;
2786
2786
  }), e.replace(/<v:imagedata\b[^>]*>/gi, (i) => t(i, "") || i);
2787
2787
  }
2788
- function ve(d, t) {
2789
- if (!d || !t.length) return { html: d, injected: [] };
2788
+ function ve(u, t) {
2789
+ if (!u || !t.length) return { html: u, injected: [] };
2790
2790
  const e = [];
2791
2791
  let i = 0;
2792
- return { html: Hi(d).replace(/<img\b[^>]*>/gi, (n) => {
2793
- const l = (n.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2794
- if (ge.test(l)) return n;
2795
- const r = t[i++];
2796
- return r ? (e.push(r), /\ssrc\s*=\s*["']/i.test(n) ? n.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + r + '"') : n.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + r + '"')) : n;
2792
+ return { html: Hi(u).replace(/<img\b[^>]*>/gi, (n) => {
2793
+ const r = (n.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2794
+ if (ge.test(r)) return n;
2795
+ const o = t[i++];
2796
+ return o ? (e.push(o), /\ssrc\s*=\s*["']/i.test(n) ? n.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + o + '"') : n.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + o + '"')) : n;
2797
2797
  }), injected: e };
2798
2798
  }
2799
- function Ii(d, t) {
2800
- return !d || !t ? { html: d, injected: [] } : ve(d, ki(t));
2799
+ function Ii(u, t) {
2800
+ return !u || !t ? { html: u, injected: [] } : ve(u, ki(t));
2801
2801
  }
2802
- function qi(d) {
2803
- const t = d.match(/<img\b[^>]*>/gi);
2802
+ function qi(u) {
2803
+ const t = u.match(/<img\b[^>]*>/gi);
2804
2804
  return t ? t.filter((e) => {
2805
2805
  const i = (e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2806
2806
  return !ge.test(i);
2807
2807
  }).length : 0;
2808
2808
  }
2809
- function Ri(d, t) {
2810
- const e = d.match(/^data:([^;,]+);base64,(.*)$/);
2809
+ function Ri(u, t) {
2810
+ const e = u.match(/^data:([^;,]+);base64,(.*)$/);
2811
2811
  if (!e) return null;
2812
2812
  const i = (e[1].split("/")[1] || "png").replace(/[^a-z0-9]/gi, "") || "png";
2813
2813
  try {
2814
2814
  const s = atob(e[2]), n = new Uint8Array(s.length);
2815
- for (let l = 0; l < s.length; l++) n[l] = s.charCodeAt(l);
2815
+ for (let r = 0; r < s.length; r++) n[r] = s.charCodeAt(r);
2816
2816
  return new File([n], t + "." + (i === "jpeg" ? "jpg" : i), { type: e[1] });
2817
2817
  } catch {
2818
2818
  return null;
2819
2819
  }
2820
2820
  }
2821
- function Pi(d) {
2822
- const t = new DataView(d), e = /* @__PURE__ */ new Map();
2821
+ function Pi(u) {
2822
+ const t = new DataView(u), e = /* @__PURE__ */ new Map();
2823
2823
  let i = -1;
2824
- for (let r = d.byteLength - 22; r >= Math.max(0, d.byteLength - 22 - 65535); r--)
2825
- if (t.getUint32(r, !0) === 101010256) {
2826
- i = r;
2824
+ for (let o = u.byteLength - 22; o >= Math.max(0, u.byteLength - 22 - 65535); o--)
2825
+ if (t.getUint32(o, !0) === 101010256) {
2826
+ i = o;
2827
2827
  break;
2828
2828
  }
2829
2829
  if (i < 0) throw new Error("EOCD not found");
2830
2830
  const s = t.getUint16(i + 10, !0);
2831
2831
  let n = t.getUint32(i + 16, !0);
2832
- const l = new TextDecoder();
2833
- for (let r = 0; r < s && t.getUint32(n, !0) === 33639248; r++) {
2834
- const o = t.getUint16(n + 10, !0), a = t.getUint32(n + 20, !0), u = t.getUint16(n + 28, !0), p = t.getUint16(n + 30, !0), m = t.getUint16(n + 32, !0), v = t.getUint32(n + 42, !0), b = l.decode(new Uint8Array(d, n + 46, u));
2835
- e.set(b, { name: b, method: o, compSize: a, localOffset: v }), n += 46 + u + p + m;
2832
+ const r = new TextDecoder();
2833
+ for (let o = 0; o < s && t.getUint32(n, !0) === 33639248; o++) {
2834
+ const l = t.getUint16(n + 10, !0), a = t.getUint32(n + 20, !0), d = t.getUint16(n + 28, !0), p = t.getUint16(n + 30, !0), m = t.getUint16(n + 32, !0), v = t.getUint32(n + 42, !0), b = r.decode(new Uint8Array(u, n + 46, d));
2835
+ e.set(b, { name: b, method: l, compSize: a, localOffset: v }), n += 46 + d + p + m;
2836
2836
  }
2837
2837
  return e;
2838
2838
  }
2839
- async function he(d, t) {
2840
- const e = new DataView(d, t.localOffset);
2839
+ async function he(u, t) {
2840
+ const e = new DataView(u, t.localOffset);
2841
2841
  if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
2842
- const i = e.getUint16(26, !0), s = e.getUint16(28, !0), n = t.localOffset + 30 + i + s, l = new Uint8Array(d.slice(n, n + t.compSize));
2843
- if (t.method === 0) return l;
2842
+ const i = e.getUint16(26, !0), s = e.getUint16(28, !0), n = t.localOffset + 30 + i + s, r = new Uint8Array(u.slice(n, n + t.compSize));
2843
+ if (t.method === 0) return r;
2844
2844
  if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
2845
- const r = new Blob([l]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2846
- return new Uint8Array(await new Response(r).arrayBuffer());
2845
+ const o = new Blob([r]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2846
+ return new Uint8Array(await new Response(o).arrayBuffer());
2847
2847
  }
2848
- const de = (d) => d.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), ut = (d, t) => Array.from(d.children).filter((e) => e.localName === t), B = (d, ...t) => {
2849
- let e = d;
2848
+ const de = (u) => u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), ut = (u, t) => Array.from(u.children).filter((e) => e.localName === t), B = (u, ...t) => {
2849
+ let e = u;
2850
2850
  for (const i of t) {
2851
2851
  if (!e) return null;
2852
2852
  e = Array.from(e.children).find((s) => s.localName === i) || null;
2853
2853
  }
2854
2854
  return e;
2855
- }, q = (d, t = "val") => {
2856
- if (!d) return "";
2857
- for (const e of Array.from(d.attributes))
2855
+ }, q = (u, t = "val") => {
2856
+ if (!u) return "";
2857
+ for (const e of Array.from(u.attributes))
2858
2858
  if (e.localName === t) return e.value;
2859
2859
  return "";
2860
- }, at = (d, t) => {
2861
- const e = d ? B(d, t) : null;
2860
+ }, at = (u, t) => {
2861
+ const e = u ? B(u, t) : null;
2862
2862
  if (!e) return !1;
2863
2863
  const i = q(e);
2864
2864
  return i !== "false" && i !== "0";
@@ -2887,10 +2887,10 @@ const de = (d) => d.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2887
2887
  bmp: "image/bmp",
2888
2888
  webp: "image/webp"
2889
2889
  };
2890
- function Di(d) {
2890
+ function Di(u) {
2891
2891
  let t = "";
2892
- for (let e = 0; e < d.length; e += 32768)
2893
- t += String.fromCharCode(...d.subarray(e, e + 32768));
2892
+ for (let e = 0; e < u.length; e += 32768)
2893
+ t += String.fromCharCode(...u.subarray(e, e + 32768));
2894
2894
  return btoa(t);
2895
2895
  }
2896
2896
  class Ni {
@@ -2904,12 +2904,12 @@ class Ni {
2904
2904
  };
2905
2905
  for (const n of Array.from(t.children))
2906
2906
  if (n.localName === "p") {
2907
- const l = this.paraList(n);
2908
- if (l) {
2909
- const r = l.ilvl + 1;
2910
- for (; i.length > r; ) e += `</${i.pop()}>`;
2911
- for (i.length === r && i[r - 1] !== l.type && (e += `</${i.pop()}>`); i.length < r; )
2912
- e += `<${l.type}>`, i.push(l.type);
2907
+ const r = this.paraList(n);
2908
+ if (r) {
2909
+ const o = r.ilvl + 1;
2910
+ for (; i.length > o; ) e += `</${i.pop()}>`;
2911
+ for (i.length === o && i[o - 1] !== r.type && (e += `</${i.pop()}>`); i.length < o; )
2912
+ e += `<${r.type}>`, i.push(r.type);
2913
2913
  e += `<li>${this.runsOf(n) || "<br>"}</li>`;
2914
2914
  continue;
2915
2915
  }
@@ -2930,10 +2930,10 @@ class Ni {
2930
2930
  let s = "p";
2931
2931
  const n = /^Heading([1-6])$/i.exec(i);
2932
2932
  n ? s = "h" + n[1] : /^Title$/i.test(i) && (s = "h1");
2933
- const l = [], r = q(B(t, "pPr", "jc"));
2934
- r === "center" ? l.push("text-align:center") : r === "right" || r === "end" ? l.push("text-align:right") : (r === "both" || r === "distribute") && l.push("text-align:justify"), e && B(e, "bidi") && l.push("direction:rtl");
2935
- const o = this.runsOf(t), a = l.length ? ` style="${l.join(";")}"` : "";
2936
- return `<${s}${a}>${o || "<br>"}</${s}>`;
2933
+ const r = [], o = q(B(t, "pPr", "jc"));
2934
+ o === "center" ? r.push("text-align:center") : o === "right" || o === "end" ? r.push("text-align:right") : (o === "both" || o === "distribute") && r.push("text-align:justify"), e && B(e, "bidi") && r.push("direction:rtl");
2935
+ const l = this.runsOf(t), a = r.length ? ` style="${r.join(";")}"` : "";
2936
+ return `<${s}${a}>${l || "<br>"}</${s}>`;
2937
2937
  }
2938
2938
  runsOf(t) {
2939
2939
  let e = "";
@@ -2943,8 +2943,8 @@ class Ni {
2943
2943
  let s = this.rels.get(q(i, "id")) || "";
2944
2944
  const n = q(i, "anchor");
2945
2945
  !s && n && (s = "#" + n);
2946
- const l = this.runsOf(i);
2947
- e += s ? `<a href="${de(s)}">${l}</a>` : l;
2946
+ const r = this.runsOf(i);
2947
+ e += s ? `<a href="${de(s)}">${r}</a>` : r;
2948
2948
  } else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
2949
2949
  return e;
2950
2950
  }
@@ -2956,66 +2956,66 @@ class Ni {
2956
2956
  if (!i) return "";
2957
2957
  const s = [], n = q(e ? B(e, "color") : null);
2958
2958
  n && n !== "auto" && s.push("color:#" + n);
2959
- const l = q(e ? B(e, "highlight") : null);
2960
- l && ue[l] && s.push("background-color:" + ue[l]);
2961
- const r = parseFloat(q(e ? B(e, "sz") : null));
2962
- r && s.push("font-size:" + Math.round(r / 2 * (4 / 3)) + "px");
2963
- const o = e ? B(e, "rFonts") : null, a = q(o, "ascii") || q(o, "cs");
2959
+ const r = q(e ? B(e, "highlight") : null);
2960
+ r && ue[r] && s.push("background-color:" + ue[r]);
2961
+ const o = parseFloat(q(e ? B(e, "sz") : null));
2962
+ o && s.push("font-size:" + Math.round(o / 2 * (4 / 3)) + "px");
2963
+ const l = e ? B(e, "rFonts") : null, a = q(l, "ascii") || q(l, "cs");
2964
2964
  a && s.push(`font-family:'${a}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), at(e, "b") && (i = `<strong>${i}</strong>`), at(e, "i") && (i = `<em>${i}</em>`), at(e, "u") && q(B(e, "u")) !== "none" && (i = `<u>${i}</u>`), at(e, "strike") && (i = `<s>${i}</s>`);
2965
- const u = q(e ? B(e, "vertAlign") : null);
2966
- return u === "superscript" ? i = `<sup>${i}</sup>` : u === "subscript" && (i = `<sub>${i}</sub>`), i;
2965
+ const d = q(e ? B(e, "vertAlign") : null);
2966
+ return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
2967
2967
  }
2968
2968
  convertImage(t) {
2969
2969
  let e = "", i = 0;
2970
- const s = (r) => {
2971
- if (r.localName === "blip" && (e = e || q(r, "embed") || q(r, "link")), r.localName === "imagedata" && (e = e || q(r, "id")), r.localName === "extent") {
2972
- const o = parseFloat(r.getAttribute("cx") || "0");
2973
- o && (i = Math.round(o / 9525));
2970
+ const s = (o) => {
2971
+ if (o.localName === "blip" && (e = e || q(o, "embed") || q(o, "link")), o.localName === "imagedata" && (e = e || q(o, "id")), o.localName === "extent") {
2972
+ const l = parseFloat(o.getAttribute("cx") || "0");
2973
+ l && (i = Math.round(l / 9525));
2974
2974
  }
2975
- for (const o of Array.from(r.children)) s(o);
2975
+ for (const l of Array.from(o.children)) s(l);
2976
2976
  };
2977
2977
  if (s(t), !e) return "";
2978
2978
  const n = this.images.get(e);
2979
2979
  if (!n) return "";
2980
- const l = i ? ` width="${i}"` : "";
2981
- return `<img src="${n}" alt=""${l}>`;
2980
+ const r = i ? ` width="${i}"` : "";
2981
+ return `<img src="${n}" alt=""${r}>`;
2982
2982
  }
2983
2983
  convertTable(t) {
2984
2984
  let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
2985
2985
  for (const i of ut(t, "tr")) {
2986
2986
  e += "<tr>";
2987
2987
  for (const s of ut(i, "tc")) {
2988
- const n = parseInt(q(B(s, "tcPr", "gridSpan")) || "1", 10) || 1, l = n > 1 ? ` colspan="${n}"` : "";
2989
- let r = "";
2990
- for (const o of Array.from(s.children))
2991
- o.localName === "p" ? r += this.convertPara(o) : o.localName === "tbl" && (r += this.convertTable(o));
2992
- e += `<td style="border:1px solid #b9c2cc"${l}>${r || "<br>"}</td>`;
2988
+ const n = parseInt(q(B(s, "tcPr", "gridSpan")) || "1", 10) || 1, r = n > 1 ? ` colspan="${n}"` : "";
2989
+ let o = "";
2990
+ for (const l of Array.from(s.children))
2991
+ l.localName === "p" ? o += this.convertPara(l) : l.localName === "tbl" && (o += this.convertTable(l));
2992
+ e += `<td style="border:1px solid #b9c2cc"${r}>${o || "<br>"}</td>`;
2993
2993
  }
2994
2994
  e += "</tr>";
2995
2995
  }
2996
2996
  return e + "</tbody></table>";
2997
2997
  }
2998
2998
  }
2999
- async function Oi(d) {
3000
- const t = d instanceof ArrayBuffer ? d : await d.arrayBuffer(), e = Pi(t), i = new TextDecoder(), s = async (b) => {
2999
+ async function Oi(u) {
3000
+ const t = u instanceof ArrayBuffer ? u : await u.arrayBuffer(), e = Pi(t), i = new TextDecoder(), s = async (b) => {
3001
3001
  const f = e.get(b);
3002
3002
  return f ? new DOMParser().parseFromString(i.decode(await he(t, f)), "application/xml") : null;
3003
- }, n = await s("word/document.xml"), l = n == null ? void 0 : n.getElementsByTagName("*");
3004
- let r = null;
3005
- if (l) {
3006
- for (const b of Array.from(l))
3003
+ }, n = await s("word/document.xml"), r = n == null ? void 0 : n.getElementsByTagName("*");
3004
+ let o = null;
3005
+ if (r) {
3006
+ for (const b of Array.from(r))
3007
3007
  if (b.localName === "body") {
3008
- r = b;
3008
+ o = b;
3009
3009
  break;
3010
3010
  }
3011
3011
  }
3012
- if (!r) throw new Error("word/document.xml missing or invalid");
3013
- const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = await s("word/_rels/document.xml.rels");
3014
- if (u)
3015
- for (const b of Array.from(u.getElementsByTagName("*"))) {
3012
+ if (!o) throw new Error("word/document.xml missing or invalid");
3013
+ const l = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
3014
+ if (d)
3015
+ for (const b of Array.from(d.getElementsByTagName("*"))) {
3016
3016
  if (b.localName !== "Relationship") continue;
3017
3017
  const f = b.getAttribute("Id") || "", y = b.getAttribute("Target") || "", C = b.getAttribute("Type") || "";
3018
- /hyperlink/i.test(C) ? o.set(f, y) : /image/i.test(C) && a.set(f, y);
3018
+ /hyperlink/i.test(C) ? l.set(f, y) : /image/i.test(C) && a.set(f, y);
3019
3019
  }
3020
3020
  const p = /* @__PURE__ */ new Map();
3021
3021
  for (const [b, f] of a) {
@@ -3042,7 +3042,7 @@ async function Oi(d) {
3042
3042
  m.set(C, b.get(E) || "ul");
3043
3043
  }
3044
3044
  }
3045
- return new Ni(o, p, m).convertBody(r);
3045
+ return new Ni(l, p, m).convertBody(o);
3046
3046
  }
3047
3047
  const Fi = ["nw", "ne", "sw", "se"], Et = ["img-left", "img-right", "img-top", "img-center"], St = {
3048
3048
  "img-left": "tplimgleft",
@@ -3059,70 +3059,70 @@ let O = null, X = null, Lt = 0, pe = !1;
3059
3059
  function ct() {
3060
3060
  clearTimeout(Lt), X = null, O && O.classList.remove("show");
3061
3061
  }
3062
- function $i(d) {
3063
- const t = d.dataset.tip;
3062
+ function $i(u) {
3063
+ const t = u.dataset.tip;
3064
3064
  if (!t) return;
3065
- X = d, clearTimeout(Lt);
3065
+ X = u, clearTimeout(Lt);
3066
3066
  const e = O && O.classList.contains("show") ? 60 : 350;
3067
3067
  Lt = window.setTimeout(() => {
3068
- if (X !== d || !document.contains(d)) return;
3068
+ if (X !== u || !document.contains(u)) return;
3069
3069
  O || (O = document.createElement("div"), O.className = "etip", document.body.appendChild(O)), O.textContent = t, O.classList.add("show");
3070
- const i = d.getBoundingClientRect(), s = O.offsetWidth, n = O.offsetHeight;
3071
- let l = i.left + i.width / 2 - s / 2;
3072
- l = Math.max(6, Math.min(l, innerWidth - s - 6));
3073
- let r = i.bottom + 7;
3074
- r + n > innerHeight - 6 && (r = i.top - n - 7), O.style.left = l + "px", O.style.top = r + "px";
3070
+ const i = u.getBoundingClientRect(), s = O.offsetWidth, n = O.offsetHeight;
3071
+ let r = i.left + i.width / 2 - s / 2;
3072
+ r = Math.max(6, Math.min(r, innerWidth - s - 6));
3073
+ let o = i.bottom + 7;
3074
+ o + n > innerHeight - 6 && (o = i.top - n - 7), O.style.left = r + "px", O.style.top = o + "px";
3075
3075
  }, e);
3076
3076
  }
3077
3077
  function ji() {
3078
- pe || (pe = !0, document.addEventListener("mouseover", (d) => {
3079
- const t = d.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
3078
+ pe || (pe = !0, document.addEventListener("mouseover", (u) => {
3079
+ const t = u.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
3080
3080
  if (!e || !e.closest(_i) || e.closest(".earea")) {
3081
3081
  e !== X && ct();
3082
3082
  return;
3083
3083
  }
3084
3084
  const i = e.getAttribute("title");
3085
3085
  i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== X && $i(e);
3086
- }), document.addEventListener("mouseout", (d) => {
3087
- X && !X.contains(d.relatedTarget) && ct();
3086
+ }), document.addEventListener("mouseout", (u) => {
3087
+ X && !X.contains(u.relatedTarget) && ct();
3088
3088
  }), document.addEventListener("mousedown", ct, !0), addEventListener("scroll", ct, !0));
3089
3089
  }
3090
3090
  const Wi = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, Ui = new RegExp("\\p{L}", "u"), Vi = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
3091
- function zi(d) {
3092
- for (const t of d) {
3091
+ function zi(u) {
3092
+ for (const t of u) {
3093
3093
  if (Wi.test(t)) return "rtl";
3094
3094
  if (Ui.test(t)) return "ltr";
3095
3095
  }
3096
3096
  return null;
3097
3097
  }
3098
3098
  const ht = ["top", "right", "bottom", "left"], Xi = /^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i, Yi = /^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i, Gi = /^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i, Ki = /^border-(collapse|spacing|radius|image|block|inline|start|end)/i, Qi = /^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/, Ji = /^(inherit|initial|unset|revert|revert-layer)$/i;
3099
- function be(d) {
3099
+ function be(u) {
3100
3100
  const t = [];
3101
3101
  let e = 0, i = "";
3102
- for (const s of d)
3102
+ for (const s of u)
3103
3103
  s === "(" ? e++ : s === ")" && e--, e === 0 && /\s/.test(s) ? (i && t.push(i), i = "") : i += s;
3104
3104
  return i && t.push(i), t;
3105
3105
  }
3106
- function ts(d) {
3107
- const [t, e = t, i = t, s = e] = d;
3106
+ function ts(u) {
3107
+ const [t, e = t, i = t, s = e] = u;
3108
3108
  return [t, e, i, s];
3109
3109
  }
3110
- function es(d) {
3110
+ function es(u) {
3111
3111
  const t = { width: "medium", style: "none", color: "" };
3112
- return be(d).forEach((e) => {
3112
+ return be(u).forEach((e) => {
3113
3113
  Xi.test(e) ? t.style = e.toLowerCase() : Yi.test(e) ? t.width = e : t.color = e;
3114
3114
  }), t;
3115
3115
  }
3116
- function is(d) {
3117
- return !d || /^currentcolor$/i.test(d) ? "" : /^windowtext$/i.test(d) ? "#000000" : d;
3116
+ function is(u) {
3117
+ return !u || /^currentcolor$/i.test(u) ? "" : /^windowtext$/i.test(u) ? "#000000" : u;
3118
3118
  }
3119
- function ss(d) {
3120
- if (d.width === null && d.style === null && d.color === null) return "";
3121
- const t = d.style ?? "solid";
3122
- return t === "none" || t === "hidden" || d.width && Gi.test(d.width) ? "none" : [d.width && d.width !== "medium" ? d.width : "", t, is(d.color || "")].filter(Boolean).join(" ");
3119
+ function ss(u) {
3120
+ if (u.width === null && u.style === null && u.color === null) return "";
3121
+ const t = u.style ?? "solid";
3122
+ return t === "none" || t === "hidden" || u.width && Gi.test(u.width) ? "none" : [u.width && u.width !== "medium" ? u.width : "", t, is(u.color || "")].filter(Boolean).join(" ");
3123
3123
  }
3124
- function ns(d) {
3125
- d.querySelectorAll("table,td,th").forEach((t) => {
3124
+ function ns(u) {
3125
+ u.querySelectorAll("table,td,th").forEach((t) => {
3126
3126
  const e = t.getAttribute("style") || "";
3127
3127
  if (!/border/i.test(e)) return;
3128
3128
  const i = {
@@ -3131,20 +3131,20 @@ function ns(d) {
3131
3131
  bottom: { width: null, style: null, color: null },
3132
3132
  left: { width: null, style: null, color: null }
3133
3133
  }, s = [];
3134
- let n = !1, l = !1;
3134
+ let n = !1, r = !1;
3135
3135
  if (e.split(";").forEach((a) => {
3136
- const u = a.indexOf(":");
3137
- if (u < 1) {
3136
+ const d = a.indexOf(":");
3137
+ if (d < 1) {
3138
3138
  a.trim() && s.push(a.trim());
3139
3139
  return;
3140
3140
  }
3141
- const p = a.slice(0, u).trim().toLowerCase(), m = a.slice(u + 1).trim(), v = Qi.exec(p);
3141
+ const p = a.slice(0, d).trim().toLowerCase(), m = a.slice(d + 1).trim(), v = Qi.exec(p);
3142
3142
  if (!v || Ki.test(p)) {
3143
3143
  s.push(p + ":" + m);
3144
3144
  return;
3145
3145
  }
3146
3146
  if (Ji.test(m)) {
3147
- l = !0;
3147
+ r = !0;
3148
3148
  return;
3149
3149
  }
3150
3150
  n = !0;
@@ -3164,14 +3164,14 @@ function ns(d) {
3164
3164
  i[C] = { ...y };
3165
3165
  });
3166
3166
  }
3167
- }), l || !n) return;
3168
- const r = ht.map((a) => ss(i[a])), o = s.slice();
3169
- r.every((a) => a && a === r[0]) ? o.push("border:" + r[0]) : ht.forEach((a, u) => r[u] && o.push(`border-${a}:` + r[u])), t.setAttribute("style", o.join(";"));
3167
+ }), r || !n) return;
3168
+ const o = ht.map((a) => ss(i[a])), l = s.slice();
3169
+ o.every((a) => a && a === o[0]) ? l.push("border:" + o[0]) : ht.forEach((a, d) => o[d] && l.push(`border-${a}:` + o[d])), t.setAttribute("style", l.join(";"));
3170
3170
  });
3171
3171
  }
3172
- function ye(d) {
3172
+ function ye(u) {
3173
3173
  let t = "";
3174
- return d.childNodes.forEach((e) => {
3174
+ return u.childNodes.forEach((e) => {
3175
3175
  if (e.nodeType === Node.TEXT_NODE)
3176
3176
  t += e.nodeValue || "";
3177
3177
  else if (e.nodeType === Node.ELEMENT_NODE) {
@@ -3244,12 +3244,12 @@ let rs = (j = class {
3244
3244
  let e = 0, i = 0;
3245
3245
  const s = (n) => {
3246
3246
  e = n.clientY, i = this.ed.offsetHeight, n.preventDefault();
3247
- const l = (o) => {
3248
- this.ed.style.height = Math.max(120, i + o.clientY - e) + "px";
3249
- }, r = () => {
3250
- window.removeEventListener("mousemove", l), window.removeEventListener("mouseup", r);
3247
+ const r = (l) => {
3248
+ this.ed.style.height = Math.max(120, i + l.clientY - e) + "px";
3249
+ }, o = () => {
3250
+ window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", o);
3251
3251
  };
3252
- window.addEventListener("mousemove", l), window.addEventListener("mouseup", r);
3252
+ window.addEventListener("mousemove", r), window.addEventListener("mouseup", o);
3253
3253
  };
3254
3254
  t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
3255
3255
  }
@@ -3267,33 +3267,33 @@ let rs = (j = class {
3267
3267
  }), this.on(this.ed, "keydown", (t) => {
3268
3268
  t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg()), (t.key === "Delete" || t.key === "Backspace") && this.phActive && (t.preventDefault(), this.removeImgPlaceholder()), (t.key === "Delete" || t.key === "Backspace") && this.vphActive && (t.preventDefault(), this.removeVphPlaceholder()), t.key === "`" && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryCodeTyping(t), t.key === "Enter" && !t.shiftKey && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryExitBlockquote(t);
3269
3269
  }), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
3270
- var n, l, r, o;
3270
+ var n, r, o, l;
3271
3271
  t.preventDefault();
3272
3272
  const e = t.target, i = (n = e.closest) == null ? void 0 : n.call(e, ".img-ph:not(.vid-ph)");
3273
3273
  if (i && this.ed.contains(i) && !this.options.readonly) {
3274
- const a = Array.from(((l = t.dataTransfer) == null ? void 0 : l.files) || []).find((u) => u.type.startsWith("image/"));
3274
+ const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("image/"));
3275
3275
  a && this.readImageFileInto(a, i);
3276
3276
  return;
3277
3277
  }
3278
- const s = (r = e.closest) == null ? void 0 : r.call(e, ".vid-ph");
3278
+ const s = (o = e.closest) == null ? void 0 : o.call(e, ".vid-ph");
3279
3279
  if (s && this.ed.contains(s) && !this.options.readonly) {
3280
- const a = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((u) => u.type.startsWith("video/"));
3280
+ const a = Array.from(((l = t.dataTransfer) == null ? void 0 : l.files) || []).find((d) => d.type.startsWith("video/"));
3281
3281
  a && this.readVideoFileInto(a, s);
3282
3282
  }
3283
3283
  }), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
3284
- var u, p, m, v, b, f, y;
3285
- const e = t.target, i = (u = e.closest) == null ? void 0 : u.call(e, "table");
3284
+ var d, p, m, v, b, f, y;
3285
+ const e = t.target, i = (d = e.closest) == null ? void 0 : d.call(e, "table");
3286
3286
  i && this.ed.contains(i) ? this.selectTableForResize(i) : this.clearTableHandles();
3287
3287
  const s = (p = e.closest) == null ? void 0 : p.call(e, ".img-ph:not(.vid-ph)");
3288
3288
  s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
3289
3289
  const n = (m = e.closest) == null ? void 0 : m.call(e, ".vid-ph");
3290
3290
  n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(n)) : this.clearVphPlaceholderSel();
3291
- const l = (v = e.closest) == null ? void 0 : v.call(e, ".tpl");
3292
- l && this.ed.contains(l) && !this.options.readonly ? this.selectTemplate(l) : this.clearTplSel();
3293
- const r = (b = e.closest) == null ? void 0 : b.call(e, "pre.code-block");
3294
- r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(r)) : this.clearCodeSel();
3295
- const o = (f = e.closest) == null ? void 0 : f.call(e, "img");
3296
- o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectImage(o)) : this.clearImageHandles();
3291
+ const r = (v = e.closest) == null ? void 0 : v.call(e, ".tpl");
3292
+ r && this.ed.contains(r) && !this.options.readonly ? this.selectTemplate(r) : this.clearTplSel();
3293
+ const o = (b = e.closest) == null ? void 0 : b.call(e, "pre.code-block");
3294
+ o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(o)) : this.clearCodeSel();
3295
+ const l = (f = e.closest) == null ? void 0 : f.call(e, "img");
3296
+ l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.selectImage(l)) : this.clearImageHandles();
3297
3297
  const a = (y = e.closest) == null ? void 0 : y.call(e, "video, .video-embed");
3298
3298
  a && this.ed.contains(a) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(a)) : this.clearVidHandles();
3299
3299
  }), this.on(this.ed, "mouseover", (t) => {
@@ -3302,11 +3302,11 @@ let rs = (j = class {
3302
3302
  const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
3303
3303
  e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
3304
3304
  }), this.on(this.ed, "mouseout", (t) => {
3305
- var s, n, l, r;
3305
+ var s, n, r, o;
3306
3306
  const e = (n = (s = t.target).closest) == null ? void 0 : n.call(s, "img");
3307
3307
  if (!e) return;
3308
3308
  const i = t.relatedTarget;
3309
- i && ((l = this.imgCtx) != null && l.contains(i) || this.imgHandles.some((o) => o.contains(i)) || ((r = i.closest) == null ? void 0 : r.call(i, "img")) === e) || this.scheduleImgHide();
3309
+ i && ((r = this.imgCtx) != null && r.contains(i) || this.imgHandles.some((l) => l.contains(i)) || ((o = i.closest) == null ? void 0 : o.call(i, "img")) === e) || this.scheduleImgHide();
3310
3310
  }), this.on(this.ed, "scroll", () => {
3311
3311
  this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx();
3312
3312
  }), this.onWin(
@@ -3388,41 +3388,42 @@ let rs = (j = class {
3388
3388
  * content with no strongly-directional character anywhere falls back to the
3389
3389
  * editor's current direction. */
3390
3390
  getContentForEmail() {
3391
- const t = (r, o) => {
3392
- const a = (r.getAttribute("style") || "").trim();
3393
- r.setAttribute("style", a ? a.replace(/;?$/, "; ") + o : o);
3394
- }, e = document.createElement("div");
3395
- e.innerHTML = this.ed.innerHTML;
3396
- let i = null;
3397
- e.querySelectorAll("[dir]").forEach((r) => {
3398
- const o = (r.getAttribute("dir") || "").toLowerCase();
3399
- if (o !== "rtl" && o !== "ltr") return;
3400
- const a = o;
3401
- i || (i = a), /text-align\s*:/i.test(r.getAttribute("style") || "") || t(r, `text-align:${a === "rtl" ? "right" : "left"}`);
3402
- }), e.querySelectorAll(Vi).forEach((r) => {
3403
- const o = (r.getAttribute("dir") || "").toLowerCase();
3404
- if (o === "rtl" || o === "ltr") return;
3405
- const a = zi(ye(r));
3406
- if (!a) return;
3407
- i || (i = a), r.setAttribute("dir", a);
3408
- const u = /text-align\s*:/i.test(r.getAttribute("style") || "");
3409
- t(r, u ? `direction:${a}` : `direction:${a};text-align:${a === "rtl" ? "right" : "left"}`);
3391
+ const t = (l, a) => {
3392
+ const d = (l.getAttribute("style") || "").trim();
3393
+ l.setAttribute("style", d ? d.replace(/;?$/, "; ") + a : a);
3394
+ }, e = (l, a) => {
3395
+ const d = (l.getAttribute("style") || "").split(";").map((p) => p.trim()).filter((p) => p && !/^width\s*:/i.test(p));
3396
+ d.push(`width:${a}px`), l.setAttribute("style", d.join("; "));
3397
+ }, i = document.createElement("div");
3398
+ i.innerHTML = this.ed.innerHTML;
3399
+ let s = null;
3400
+ i.querySelectorAll("[dir]").forEach((l) => {
3401
+ const a = (l.getAttribute("dir") || "").toLowerCase();
3402
+ if (a !== "rtl" && a !== "ltr") return;
3403
+ const d = a;
3404
+ s || (s = d), /text-align\s*:/i.test(l.getAttribute("style") || "") || t(l, `text-align:${d === "rtl" ? "right" : "left"}`);
3405
+ }), i.querySelectorAll(Vi).forEach((l) => {
3406
+ const a = (l.getAttribute("dir") || "").toLowerCase();
3407
+ if (a === "rtl" || a === "ltr") return;
3408
+ const d = zi(ye(l));
3409
+ if (!d) return;
3410
+ s || (s = d), l.setAttribute("dir", d);
3411
+ const p = /text-align\s*:/i.test(l.getAttribute("style") || "");
3412
+ t(l, p ? `direction:${d}` : `direction:${d};text-align:${d === "rtl" ? "right" : "left"}`);
3410
3413
  });
3411
- const s = this.ed.querySelectorAll("img");
3412
- e.querySelectorAll("img").forEach((r, o) => {
3413
- if (r.closest(".tpl-media")) return;
3414
- const a = s[o], u = Math.round((a == null ? void 0 : a.getBoundingClientRect().width) || 0);
3415
- u > 0 && !r.getAttribute("width") && r.setAttribute("width", String(u));
3416
- const p = r.getAttribute("style") || "";
3417
- u > 0 && !/(^|;)\s*width\s*:/i.test(p) && t(r, `width:${u}px`), /max-width\s*:/i.test(r.getAttribute("style") || "") || t(r, "max-width:100%"), /(^|;)\s*height\s*:/i.test(r.getAttribute("style") || "") || t(r, "height:auto");
3418
- }), ns(e), e.querySelectorAll("table").forEach((r) => {
3419
- const o = r.getAttribute("style") || "";
3420
- /border-collapse\s*:/i.test(o) || t(r, "border-collapse:collapse"), !/border-spacing\s*:/i.test(o) && !r.hasAttribute("cellspacing") && r.setAttribute("cellspacing", "0");
3414
+ const n = this.ed.querySelectorAll("img");
3415
+ i.querySelectorAll("img").forEach((l, a) => {
3416
+ if (l.closest(".tpl-media")) return;
3417
+ const d = n[a], p = Math.round((d == null ? void 0 : d.offsetWidth) || 0);
3418
+ p > 0 && (l.setAttribute("width", String(p)), l.removeAttribute("height"), e(l, p)), /max-width\s*:/i.test(l.getAttribute("style") || "") || t(l, "max-width:100%"), /(^|;)\s*height\s*:/i.test(l.getAttribute("style") || "") || t(l, "height:auto");
3419
+ }), ns(i), i.querySelectorAll("table").forEach((l) => {
3420
+ const a = l.getAttribute("style") || "";
3421
+ /border-collapse\s*:/i.test(a) || t(l, "border-collapse:collapse"), !/border-spacing\s*:/i.test(a) && !l.hasAttribute("cellspacing") && l.setAttribute("cellspacing", "0");
3421
3422
  });
3422
- const n = i || this.ed.getAttribute("dir") || this.dir();
3423
- return e.querySelectorAll("table:not([dir])").forEach((r) => {
3424
- r.setAttribute("dir", n), /direction\s*:/i.test(r.getAttribute("style") || "") || t(r, `direction:${n}`);
3425
- }), `<div dir="${n}" style="direction:${n};text-align:${n === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
3423
+ const r = s || this.ed.getAttribute("dir") || this.dir();
3424
+ return i.querySelectorAll("table:not([dir])").forEach((l) => {
3425
+ l.setAttribute("dir", r), /direction\s*:/i.test(l.getAttribute("style") || "") || t(l, `direction:${r}`);
3426
+ }), `<div dir="${r}" style="direction:${r};text-align:${r === "rtl" ? "right" : "left"}">${i.innerHTML}</div>`;
3426
3427
  }
3427
3428
  setContent(t) {
3428
3429
  this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.clearSelToolbar(), this.onChange(), this.stampExistingImages();
@@ -3496,8 +3497,8 @@ let rs = (j = class {
3496
3497
  t.preventDefault();
3497
3498
  const n = document.createElement("p");
3498
3499
  n.appendChild(document.createElement("br")), s.after(n), i.remove(), s.firstElementChild || s.remove();
3499
- const l = document.createRange();
3500
- l.setStart(n, 0), l.collapse(!0), e.removeAllRanges(), e.addRange(l), this.saveSel(), this.onChange();
3500
+ const r = document.createRange();
3501
+ r.setStart(n, 0), r.collapse(!0), e.removeAllRanges(), e.addRange(r), this.saveSel(), this.onChange();
3501
3502
  }
3502
3503
  selectedBlocks() {
3503
3504
  const t = window.getSelection();
@@ -3547,30 +3548,30 @@ let rs = (j = class {
3547
3548
  s.className = "revprev";
3548
3549
  const n = document.createElement("button");
3549
3550
  n.type = "button", n.className = "revrestore", n.textContent = this.t("restore");
3550
- let l = this.revisions.length - 1;
3551
- const r = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
3551
+ let r = this.revisions.length - 1;
3552
+ const o = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
3552
3553
  year: "numeric",
3553
3554
  month: "short",
3554
3555
  day: "numeric",
3555
3556
  hour: "2-digit",
3556
3557
  minute: "2-digit",
3557
3558
  second: "2-digit"
3558
- }), o = {}, a = (u) => {
3559
- l = u, this.revisions.forEach((p, m) => {
3559
+ }), l = {}, a = (d) => {
3560
+ r = d, this.revisions.forEach((p, m) => {
3560
3561
  var v;
3561
- return (v = o[m]) == null ? void 0 : v.classList.toggle("on", m === u);
3562
- }), s.innerHTML = this.revisions[u].html, n.disabled = u === this.revisions.length - 1;
3562
+ return (v = l[m]) == null ? void 0 : v.classList.toggle("on", m === d);
3563
+ }), s.innerHTML = this.revisions[d].html, n.disabled = d === this.revisions.length - 1;
3563
3564
  };
3564
- for (let u = this.revisions.length - 1; u >= 0; u--) {
3565
- const p = this.revisions[u], m = document.createElement("button");
3565
+ for (let d = this.revisions.length - 1; d >= 0; d--) {
3566
+ const p = this.revisions[d], m = document.createElement("button");
3566
3567
  m.type = "button";
3567
- const v = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), b = v ? v.split(/\s+/).length : 0, f = u === this.revisions.length - 1;
3568
- m.innerHTML = `<span>${f ? this.t("currentver") : r.format(new Date(p.time))}</span><span class="wc">${b} ${this.t("words")}</span>`, m.addEventListener("click", () => a(u)), o[u] = m, i.appendChild(m);
3568
+ const v = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), b = v ? v.split(/\s+/).length : 0, f = d === this.revisions.length - 1;
3569
+ m.innerHTML = `<span>${f ? this.t("currentver") : o.format(new Date(p.time))}</span><span class="wc">${b} ${this.t("words")}</span>`, m.addEventListener("click", () => a(d)), l[d] = m, i.appendChild(m);
3569
3570
  }
3570
3571
  i.append(n), n.addEventListener("click", () => {
3571
- const u = this.revisions[l];
3572
- u && (this.recordRevision(), this.setContent(u.html), this.recordRevision(), this.closeDlg());
3573
- }), e.append(i, s), t.appendChild(e), a(l);
3572
+ const d = this.revisions[r];
3573
+ d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
3574
+ }), e.append(i, s), t.appendChild(e), a(r);
3574
3575
  });
3575
3576
  }
3576
3577
  /* ---------------------------------------------------------- popups / menus */
@@ -3607,10 +3608,10 @@ let rs = (j = class {
3607
3608
  n.className = "pop sub", n.dir = this.dir(), t.subBuild ? t.subBuild(n) : t.sub && this.menuItems(n, t.sub), n.addEventListener("mousedown", (a) => {
3608
3609
  a.target.tagName !== "INPUT" && a.preventDefault();
3609
3610
  }), document.body.appendChild(n);
3610
- let r = this.dir() === "rtl" ? i.left - n.offsetWidth + 2 : i.right - 2;
3611
- r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - n.offsetWidth - 8));
3612
- let o = i.top + scrollY - 6;
3613
- o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - n.offsetHeight - 8)), n.style.left = r + "px", n.style.top = o + "px", this.subStack.push(n);
3611
+ let o = this.dir() === "rtl" ? i.left - n.offsetWidth + 2 : i.right - 2;
3612
+ o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - n.offsetWidth - 8));
3613
+ let l = i.top + scrollY - 6;
3614
+ l = Math.max(8 + scrollY, Math.min(l, scrollY + innerHeight - n.offsetHeight - 8)), n.style.left = o + "px", n.style.top = l + "px", this.subStack.push(n);
3614
3615
  }
3615
3616
  popup(t, e, i) {
3616
3617
  if (this.openPop && this.popAnchor === t) {
@@ -3622,10 +3623,10 @@ let rs = (j = class {
3622
3623
  s.className = "pop" + (i ? " " + i : ""), s.dir = this.dir(), e(s), document.body.appendChild(s);
3623
3624
  const n = t.getBoundingClientRect();
3624
3625
  s.style.minWidth = Math.max(160, Math.round(n.width)) + "px";
3625
- let l = n.bottom + scrollY + 2;
3626
- l = Math.max(8 + scrollY, Math.min(l, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = l + "px";
3627
- let o = this.dir() === "rtl" ? n.right - s.offsetWidth : n.left;
3628
- o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = o + "px", s.addEventListener("mousedown", (a) => {
3626
+ let r = n.bottom + scrollY + 2;
3627
+ r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = r + "px";
3628
+ let l = this.dir() === "rtl" ? n.right - s.offsetWidth : n.left;
3629
+ l = Math.max(8, Math.min(l + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = l + "px", s.addEventListener("mousedown", (a) => {
3629
3630
  a.target.tagName !== "INPUT" && a.preventDefault();
3630
3631
  }), this.openPop = s, this.popAnchor = t, t.classList.add("open");
3631
3632
  }
@@ -3639,18 +3640,18 @@ let rs = (j = class {
3639
3640
  n.className = "mi" + (i.on ? " on" : ""), n.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${h.chev}</span>` : ""}`, n.addEventListener("click", () => {
3640
3641
  i.action && (this.closePop(), i.action());
3641
3642
  }), n.addEventListener("mouseenter", () => {
3642
- var l;
3643
- s ? this.openSubFor(i, n) : this.closeSubFrom(this.subLevelOf(t)), (l = i.hover) == null || l.call(i, !0);
3643
+ var r;
3644
+ s ? this.openSubFor(i, n) : this.closeSubFrom(this.subLevelOf(t)), (r = i.hover) == null || r.call(i, !0);
3644
3645
  }), n.addEventListener("mouseleave", () => {
3645
- var l;
3646
- return (l = i.hover) == null ? void 0 : l.call(i, !1);
3646
+ var r;
3647
+ return (r = i.hover) == null ? void 0 : r.call(i, !1);
3647
3648
  }), t.appendChild(n);
3648
3649
  });
3649
3650
  }
3650
3651
  /* ---------------------------------------------------------- toolbar builders */
3651
3652
  tbtn(t, e, i, s) {
3652
3653
  const n = document.createElement("button");
3653
- return n.className = "tbtn", n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (l) => l.preventDefault()), n.addEventListener("click", i), n;
3654
+ return n.className = "tbtn", n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (r) => r.preventDefault()), n.addEventListener("click", i), n;
3654
3655
  }
3655
3656
  /** Font-size increase / decrease step button. */
3656
3657
  stepBtn(t) {
@@ -3666,8 +3667,8 @@ let rs = (j = class {
3666
3667
  colorChips() {
3667
3668
  const t = (s) => {
3668
3669
  const n = document.createElement("button");
3669
- return n.type = "button", n.className = "cchip", n.title = s, n.addEventListener("mousedown", (l) => {
3670
- l.preventDefault(), this.saveSel();
3670
+ return n.type = "button", n.className = "cchip", n.title = s, n.addEventListener("mousedown", (r) => {
3671
+ r.preventDefault(), this.saveSel();
3671
3672
  }), n;
3672
3673
  }, e = oi.map((s) => {
3673
3674
  const n = t(this.t("forecolor"));
@@ -3683,17 +3684,17 @@ let rs = (j = class {
3683
3684
  }
3684
3685
  tsel(t, e, i, s) {
3685
3686
  const n = document.createElement("button");
3686
- return n.className = "tsel " + t, n.type = "button", n.dataset.id = e, n.innerHTML = `<span class="lbl empty">${i || ""}</span>${h.chev}`, n.addEventListener("mousedown", (l) => {
3687
- l.preventDefault(), this.saveSel();
3687
+ return n.className = "tsel " + t, n.type = "button", n.dataset.id = e, n.innerHTML = `<span class="lbl empty">${i || ""}</span>${h.chev}`, n.addEventListener("mousedown", (r) => {
3688
+ r.preventDefault(), this.saveSel();
3688
3689
  }), n.addEventListener("click", () => s(n)), n;
3689
3690
  }
3690
3691
  setListStyle(t, e) {
3691
- var n, l;
3692
+ var n, r;
3692
3693
  this.restoreSel();
3693
3694
  const i = window.getSelection();
3694
3695
  if (!i) return;
3695
3696
  let s = (n = this.closestBlock(i.anchorNode)) == null ? void 0 : n.closest(t);
3696
- s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (l = this.closestBlock(i.anchorNode)) == null ? void 0 : l.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
3697
+ s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (r = this.closestBlock(i.anchorNode)) == null ? void 0 : r.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
3697
3698
  }
3698
3699
  listMenu(t, e) {
3699
3700
  var a;
@@ -3705,23 +3706,23 @@ let rs = (j = class {
3705
3706
  ] : [
3706
3707
  ["circle", h.ul_circle],
3707
3708
  ["square", h.ul_square]
3708
- ], n = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), l = window.getSelection(), r = l ? (a = this.closestBlock(l.anchorNode)) == null ? void 0 : a.closest(e) : null, o = r ? r.style.listStyleType : "";
3709
- this.popup(t, (u) => {
3710
- this.menuItems(u, [
3709
+ ], n = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), r = window.getSelection(), o = r ? (a = this.closestBlock(r.anchorNode)) == null ? void 0 : a.closest(e) : null, l = o ? o.style.listStyleType : "";
3710
+ this.popup(t, (d) => {
3711
+ this.menuItems(d, [
3711
3712
  {
3712
3713
  label: this.t(e === "ol" ? "numlist" : "bullist"),
3713
3714
  icon: e === "ol" ? h.numlist : h.bullist,
3714
3715
  on: document.queryCommandState(i),
3715
3716
  action: () => this.exec(i)
3716
3717
  }
3717
- ]), u.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3718
+ ]), d.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3718
3719
  const p = document.createElement("div");
3719
3720
  p.className = "mi-grid", s.forEach(([m, v], b) => {
3720
3721
  const f = document.createElement("button");
3721
- f.className = "mi" + (o === m ? " on" : ""), f.innerHTML = `<span class="ic">${v}</span><span class="prev">${n[b]}</span>`, f.addEventListener("click", () => {
3722
+ f.className = "mi" + (l === m ? " on" : ""), f.innerHTML = `<span class="ic">${v}</span><span class="prev">${n[b]}</span>`, f.addEventListener("click", () => {
3722
3723
  this.closePop(), this.setListStyle(e, m);
3723
3724
  }), p.appendChild(f);
3724
- }), u.appendChild(p);
3725
+ }), d.appendChild(p);
3725
3726
  });
3726
3727
  }
3727
3728
  /** Shared color-picker popup body — swatch grid plus the current-color /
@@ -3737,18 +3738,18 @@ let rs = (j = class {
3737
3738
  }), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3738
3739
  const n = document.createElement("div");
3739
3740
  n.className = "cfoot";
3740
- const l = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", r = document.createElement("div");
3741
- r.className = "cswatch cur", r.title = this.t("currentcolor"), r.style.background = l, r.innerHTML = h.check;
3742
- const o = document.createElement("button");
3743
- o.type = "button", o.className = "cswatch nocolor", o.title = this.t("removecolor"), o.addEventListener("click", () => {
3741
+ const r = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", o = document.createElement("div");
3742
+ o.className = "cswatch cur", o.title = this.t("currentcolor"), o.style.background = r, o.innerHTML = h.check;
3743
+ const l = document.createElement("button");
3744
+ l.type = "button", l.className = "cswatch nocolor", l.title = this.t("removecolor"), l.addEventListener("click", () => {
3744
3745
  this.closePop(), i(null);
3745
3746
  });
3746
3747
  const a = document.createElement("label");
3747
3748
  a.className = "cswatch cwheel", a.title = this.t("customcolor"), a.innerHTML = h.palette;
3748
- const u = document.createElement("input");
3749
- u.type = "color", u.value = l, u.addEventListener("change", () => {
3750
- this.closePop(), i(u.value);
3751
- }), a.appendChild(u), n.append(r, o, a), t.appendChild(n);
3749
+ const d = document.createElement("input");
3750
+ d.type = "color", d.value = r, d.addEventListener("change", () => {
3751
+ this.closePop(), i(d.value);
3752
+ }), a.appendChild(d), n.append(o, l, a), t.appendChild(n);
3752
3753
  }
3753
3754
  colorMenu(t, e) {
3754
3755
  this.popup(
@@ -3794,19 +3795,19 @@ let rs = (j = class {
3794
3795
  const t = window.getSelection();
3795
3796
  if (!t) return;
3796
3797
  if (!t.rangeCount) {
3797
- const l = document.createRange();
3798
- l.selectNodeContents(this.ed), l.collapse(!0), t.addRange(l);
3798
+ const r = document.createRange();
3799
+ r.selectNodeContents(this.ed), r.collapse(!0), t.addRange(r);
3799
3800
  }
3800
3801
  if (!t.isCollapsed) return;
3801
3802
  const e = t.getRangeAt(0), i = e.startContainer;
3802
3803
  if (i.nodeType === 3) {
3803
- const l = i.data;
3804
- let r = e.startOffset, o = e.startOffset;
3805
- for (; r > 0 && /\S/.test(l[r - 1]); ) r--;
3806
- for (; o < l.length && /\S/.test(l[o]); ) o++;
3807
- if (o > r) {
3804
+ const r = i.data;
3805
+ let o = e.startOffset, l = e.startOffset;
3806
+ for (; o > 0 && /\S/.test(r[o - 1]); ) o--;
3807
+ for (; l < r.length && /\S/.test(r[l]); ) l++;
3808
+ if (l > o) {
3808
3809
  const a = document.createRange();
3809
- a.setStart(i, r), a.setEnd(i, o), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3810
+ a.setStart(i, o), a.setEnd(i, l), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3810
3811
  return;
3811
3812
  }
3812
3813
  }
@@ -3840,14 +3841,14 @@ let rs = (j = class {
3840
3841
  const e = window.getSelection();
3841
3842
  if (!e || !e.rangeCount || e.isCollapsed) return;
3842
3843
  const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), n = [];
3843
- let l;
3844
- for (; l = s.nextNode(); ) i.intersectsNode(l) && n.push(l);
3845
- n.forEach((r) => {
3846
- const o = r === i.startContainer ? i.startOffset : 0, a = r === i.endContainer ? i.endOffset : r.data.length;
3847
- if (a <= o) return;
3848
- const u = r.data.slice(o, a);
3849
- let p = u;
3850
- t === "lower" ? p = u.toLowerCase() : t === "upper" ? p = u.toUpperCase() : p = u.replace(/(^|\s)(\S)/g, (m, v, b) => v + b.toUpperCase()), r.replaceData(o, a - o, p);
3844
+ let r;
3845
+ for (; r = s.nextNode(); ) i.intersectsNode(r) && n.push(r);
3846
+ n.forEach((o) => {
3847
+ const l = o === i.startContainer ? i.startOffset : 0, a = o === i.endContainer ? i.endOffset : o.data.length;
3848
+ if (a <= l) return;
3849
+ const d = o.data.slice(l, a);
3850
+ let p = d;
3851
+ t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (m, v, b) => v + b.toUpperCase()), o.replaceData(l, a - l, p);
3851
3852
  }), this.saveSel(), this.refreshState(), this.onChange();
3852
3853
  }
3853
3854
  caseItems() {
@@ -3935,8 +3936,8 @@ let rs = (j = class {
3935
3936
  (s) => {
3936
3937
  const n = document.createElement("div");
3937
3938
  n.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
3938
- const l = document.createElement("span");
3939
- l.style.cssText = "width:60px;color:#556;flex:none", l.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", n.append(l, e), s.appendChild(n), setTimeout(() => e.focus(), 0);
3939
+ const r = document.createElement("span");
3940
+ r.style.cssText = "width:60px;color:#556;flex:none", r.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", n.append(r, e), s.appendChild(n), setTimeout(() => e.focus(), 0);
3940
3941
  },
3941
3942
  i
3942
3943
  );
@@ -3979,15 +3980,15 @@ let rs = (j = class {
3979
3980
  s.className = "tgrid";
3980
3981
  const n = document.createElement("div");
3981
3982
  n.className = "tgridlbl", n.textContent = "1 × 1";
3982
- const l = [];
3983
- for (let r = 0; r < 8; r++)
3984
- for (let o = 0; o < 10; o++) {
3983
+ const r = [];
3984
+ for (let o = 0; o < 8; o++)
3985
+ for (let l = 0; l < 10; l++) {
3985
3986
  const a = document.createElement("span");
3986
- a.dataset.r = String(r), a.dataset.c = String(o), a.addEventListener("mouseenter", () => {
3987
- l.forEach((u) => u.classList.toggle("hot", +u.dataset.r <= r && +u.dataset.c <= o)), n.textContent = o + 1 + " × " + (r + 1);
3987
+ a.dataset.r = String(o), a.dataset.c = String(l), a.addEventListener("mouseenter", () => {
3988
+ r.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= o && +d.dataset.c <= l)), n.textContent = l + 1 + " × " + (o + 1);
3988
3989
  }), a.addEventListener("click", () => {
3989
- this.closePop(), this.insertTable(r + 1, o + 1), e == null || e();
3990
- }), l.push(a), s.appendChild(a);
3990
+ this.closePop(), this.insertTable(o + 1, l + 1), e == null || e();
3991
+ }), r.push(a), s.appendChild(a);
3991
3992
  }
3992
3993
  i.append(s, n), t.appendChild(i);
3993
3994
  }
@@ -4076,13 +4077,13 @@ let rs = (j = class {
4076
4077
  this.parseToolbarString(t).forEach((i) => {
4077
4078
  const s = [];
4078
4079
  i.forEach((n) => {
4079
- const l = e[n];
4080
- if (!l) {
4080
+ const r = e[n];
4081
+ if (!r) {
4081
4082
  console.warn(`FableEditor: unknown toolbar item "${n}"`);
4082
4083
  return;
4083
4084
  }
4084
- const r = l();
4085
- Array.isArray(r) ? s.push(...r) : s.push(r);
4085
+ const o = r();
4086
+ Array.isArray(o) ? s.push(...o) : s.push(o);
4086
4087
  }), s.length && this.toolbar.appendChild(this.group(...s));
4087
4088
  }), this.tbrMore = this.tbtn(h.more, this.t("more"), () => {
4088
4089
  this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
@@ -4262,36 +4263,36 @@ let rs = (j = class {
4262
4263
  return;
4263
4264
  }
4264
4265
  const n = document.createElement("button");
4265
- n.type = "button", n.textContent = this.t(s), n.dataset.menuKey = s, n.addEventListener("mousedown", (l) => {
4266
- l.preventDefault(), this.saveSel();
4267
- }), n.addEventListener("click", () => this.popup(n, (l) => this.menuItems(l, t[s]))), this.menubar.appendChild(n);
4266
+ n.type = "button", n.textContent = this.t(s), n.dataset.menuKey = s, n.addEventListener("mousedown", (r) => {
4267
+ r.preventDefault(), this.saveSel();
4268
+ }), n.addEventListener("click", () => this.popup(n, (r) => this.menuItems(r, t[s]))), this.menubar.appendChild(n);
4268
4269
  });
4269
4270
  }
4270
4271
  /* ---------------------------------------------------------- table ops */
4271
4272
  tableOp(t) {
4272
- var o, a, u;
4273
+ var l, a, d;
4273
4274
  this.restoreSel();
4274
4275
  const e = window.getSelection();
4275
4276
  if (!e) return;
4276
- const i = ((o = this.closestBlock(e.anchorNode)) == null ? void 0 : o.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (u = (a = e.anchorNode).closest) == null ? void 0 : u.call(a, "td,th") : null);
4277
+ const i = ((l = this.closestBlock(e.anchorNode)) == null ? void 0 : l.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
4277
4278
  if (!i) return;
4278
- const s = i.parentElement, n = i.closest("table"), l = Array.from(s.children).indexOf(i), r = () => {
4279
+ const s = i.parentElement, n = i.closest("table"), r = Array.from(s.children).indexOf(i), o = () => {
4279
4280
  const p = s.cloneNode(!1);
4280
4281
  return Array.from(s.children).forEach((m) => {
4281
4282
  const v = document.createElement("td"), b = m.getAttribute("style");
4282
4283
  b && v.setAttribute("style", b), v.style.removeProperty("background-color"), v.innerHTML = "<br>", p.appendChild(v);
4283
4284
  }), p;
4284
4285
  };
4285
- if (t === "rowabove" && s.before(r()), t === "rowbelow" && s.after(r()), t === "delrow") {
4286
+ if (t === "rowabove" && s.before(o()), t === "rowbelow" && s.after(o()), t === "delrow") {
4286
4287
  const p = s.parentElement;
4287
4288
  s.remove(), p.querySelector("tr") || n.remove();
4288
4289
  }
4289
4290
  (t === "colbefore" || t === "colafter") && n.querySelectorAll("tr").forEach((p) => {
4290
- const m = p.children[Math.min(l, p.children.length - 1)], v = document.createElement("td"), b = m.getAttribute("style");
4291
+ const m = p.children[Math.min(r, p.children.length - 1)], v = document.createElement("td"), b = m.getAttribute("style");
4291
4292
  b && v.setAttribute("style", b), v.style.removeProperty("width"), v.style.removeProperty("background-color"), v.innerHTML = "<br>", t === "colbefore" ? m.before(v) : m.after(v);
4292
4293
  }), t === "delcol" && (n.querySelectorAll("tr").forEach((p) => {
4293
4294
  var m;
4294
- return (m = p.children[l]) == null ? void 0 : m.remove();
4295
+ return (m = p.children[r]) == null ? void 0 : m.remove();
4295
4296
  }), n.querySelector("td,th") || n.remove()), t === "deltable" && n.remove(), this.onChange(), this.positionTableHandles();
4296
4297
  }
4297
4298
  /** Reorders the current row/column: 'rowup'/'rowdown' swap the caret's row with
@@ -4303,24 +4304,24 @@ let rs = (j = class {
4303
4304
  if (!e) return;
4304
4305
  const i = e.parentElement, s = e.closest("table"), n = Array.from(i.children).indexOf(e);
4305
4306
  if (t === "rowup") {
4306
- const o = i.previousElementSibling;
4307
- o && o.before(i);
4307
+ const l = i.previousElementSibling;
4308
+ l && l.before(i);
4308
4309
  }
4309
4310
  if (t === "rowdown") {
4310
- const o = i.nextElementSibling;
4311
- o && o.after(i);
4311
+ const l = i.nextElementSibling;
4312
+ l && l.after(i);
4312
4313
  }
4313
- t === "colleft" && n > 0 && s.querySelectorAll("tr").forEach((o) => {
4314
- const a = o.children[n], u = o.children[n - 1];
4315
- a && u && u.before(a);
4316
- }), t === "colright" && s.querySelectorAll("tr").forEach((o) => {
4317
- const a = o.children[n], u = o.children[n + 1];
4318
- a && u && u.after(a);
4314
+ t === "colleft" && n > 0 && s.querySelectorAll("tr").forEach((l) => {
4315
+ const a = l.children[n], d = l.children[n - 1];
4316
+ a && d && d.before(a);
4317
+ }), t === "colright" && s.querySelectorAll("tr").forEach((l) => {
4318
+ const a = l.children[n], d = l.children[n + 1];
4319
+ a && d && d.after(a);
4319
4320
  });
4320
- const l = document.createRange();
4321
- l.selectNodeContents(e), l.collapse(!0);
4322
- const r = window.getSelection();
4323
- r && (r.removeAllRanges(), r.addRange(l)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
4321
+ const r = document.createRange();
4322
+ r.selectNodeContents(e), r.collapse(!0);
4323
+ const o = window.getSelection();
4324
+ o && (o.removeAllRanges(), o.addRange(r)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
4324
4325
  }
4325
4326
  /** Align the whole table via auto margins — same semantics as the align
4326
4327
  * field in the table-properties dialog. */
@@ -4357,26 +4358,26 @@ let rs = (j = class {
4357
4358
  tablePropsDlg() {
4358
4359
  const t = this.tblActive;
4359
4360
  if (!t) return;
4360
- let e, i, s, n, l;
4361
- const r = "display:flex;align-items:center;gap:10px;margin:10px 0", o = "width:120px;color:#556;flex:none", a = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", u = t.querySelector("td,th"), p = t.style.width || "", m = u && u.style.padding ? parseFloat(u.style.padding) : "", v = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", b = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, y = t.style.marginRight, C = f === "auto" && y === "auto" ? "center" : f === "auto" ? "right" : y === "auto" && f === "0" ? "left" : "";
4361
+ let e, i, s, n, r;
4362
+ const o = "display:flex;align-items:center;gap:10px;margin:10px 0", l = "width:120px;color:#556;flex:none", a = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), p = t.style.width || "", m = d && d.style.padding ? parseFloat(d.style.padding) : "", v = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", b = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, y = t.style.marginRight, C = f === "auto" && y === "auto" ? "center" : f === "auto" ? "right" : y === "auto" && f === "0" ? "left" : "";
4362
4363
  this.dialog(
4363
4364
  this.t("tablepropsttl"),
4364
4365
  (E) => {
4365
4366
  const I = (A, $) => {
4366
4367
  const F = document.createElement("div");
4367
- F.style.cssText = r;
4368
+ F.style.cssText = o;
4368
4369
  const Z = document.createElement("span");
4369
- Z.style.cssText = o, Z.textContent = this.t(A), F.append(Z, $), E.appendChild(F);
4370
+ Z.style.cssText = l, Z.textContent = this.t(A), F.append(Z, $), E.appendChild(F);
4370
4371
  };
4371
- e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, I("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(m), I("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(v), I("tblcellspacing", s), n = document.createElement("input"), n.type = "number", n.min = "0", n.style.cssText = a, n.value = String(b), I("tblborder", n), l = document.createElement("select"), l.style.cssText = a, [
4372
+ e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, I("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(m), I("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(v), I("tblcellspacing", s), n = document.createElement("input"), n.type = "number", n.min = "0", n.style.cssText = a, n.value = String(b), I("tblborder", n), r = document.createElement("select"), r.style.cssText = a, [
4372
4373
  ["", "alignnone"],
4373
4374
  ["left", "alignleft"],
4374
4375
  ["center", "aligncenter"],
4375
4376
  ["right", "alignright"]
4376
4377
  ].forEach(([A, $]) => {
4377
4378
  const F = document.createElement("option");
4378
- F.value = A, F.textContent = this.t($), A === C && (F.selected = !0), l.appendChild(F);
4379
- }), I("tblalign", l);
4379
+ F.value = A, F.textContent = this.t($), A === C && (F.selected = !0), r.appendChild(F);
4380
+ }), I("tblalign", r);
4380
4381
  },
4381
4382
  [
4382
4383
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4389,7 +4390,7 @@ let rs = (j = class {
4389
4390
  cellpadding: i.value.trim(),
4390
4391
  cellspacing: s.value.trim(),
4391
4392
  border: n.value.trim(),
4392
- align: l.value
4393
+ align: r.value
4393
4394
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
4394
4395
  }
4395
4396
  }
@@ -4428,8 +4429,8 @@ let rs = (j = class {
4428
4429
  formSelect(t, e) {
4429
4430
  const i = document.createElement("select");
4430
4431
  return i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff", t.forEach(([s, n]) => {
4431
- const l = document.createElement("option");
4432
- l.value = s, l.textContent = n, s === e && (l.selected = !0), i.appendChild(l);
4432
+ const r = document.createElement("option");
4433
+ r.value = s, r.textContent = n, s === e && (r.selected = !0), i.appendChild(r);
4433
4434
  }), i;
4434
4435
  }
4435
4436
  formBg(t) {
@@ -4439,8 +4440,8 @@ let rs = (j = class {
4439
4440
  s.type = "color", s.value = i || "#ffffff", s.style.cssText = "width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";
4440
4441
  const n = document.createElement("label");
4441
4442
  n.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
4442
- const l = document.createElement("input");
4443
- return l.type = "checkbox", l.checked = !!i, n.append(l, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => l.checked = !0), e.append(s, n), { wrap: e, color: s, fill: l };
4443
+ const r = document.createElement("input");
4444
+ return r.type = "checkbox", r.checked = !!i, n.append(r, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => r.checked = !0), e.append(s, n), { wrap: e, color: s, fill: r };
4444
4445
  }
4445
4446
  setOrClear(t, e, i) {
4446
4447
  i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
@@ -4451,11 +4452,11 @@ let rs = (j = class {
4451
4452
  alert(this.t("nocell"));
4452
4453
  return;
4453
4454
  }
4454
- let e, i, s, n, l;
4455
+ let e, i, s, n, r;
4455
4456
  this.dialog(
4456
4457
  this.t("cellprops").replace("…", ""),
4457
- (r) => {
4458
- e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(r, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(r, this.t("tblheight"), i), s = this.formSelect(
4458
+ (o) => {
4459
+ e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(o, this.t("tblheight"), i), s = this.formSelect(
4459
4460
  [
4460
4461
  ["", this.t("alignnone")],
4461
4462
  ["left", this.t("alignleft")],
@@ -4463,7 +4464,7 @@ let rs = (j = class {
4463
4464
  ["right", this.t("alignright")]
4464
4465
  ],
4465
4466
  t.style.textAlign || ""
4466
- ), this.formRow(r, this.t("tblalign"), s), n = this.formSelect(
4467
+ ), this.formRow(o, this.t("tblalign"), s), n = this.formSelect(
4467
4468
  [
4468
4469
  ["", this.t("alignnone")],
4469
4470
  ["top", this.t("valigntop")],
@@ -4471,7 +4472,7 @@ let rs = (j = class {
4471
4472
  ["bottom", this.t("valignbottom")]
4472
4473
  ],
4473
4474
  t.style.verticalAlign || ""
4474
- ), this.formRow(r, this.t("valign"), n), l = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), l.wrap);
4475
+ ), this.formRow(o, this.t("valign"), n), r = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), r.wrap);
4475
4476
  },
4476
4477
  [
4477
4478
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4479,7 +4480,7 @@ let rs = (j = class {
4479
4480
  label: this.t("save"),
4480
4481
  primary: !0,
4481
4482
  action: () => {
4482
- this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", n.value), this.setOrClear(t, "background-color", l.fill.checked ? l.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
4483
+ this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", n.value), this.setOrClear(t, "background-color", r.fill.checked ? r.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
4483
4484
  }
4484
4485
  }
4485
4486
  ]
@@ -4516,12 +4517,12 @@ let rs = (j = class {
4516
4517
  alert(this.t("nocell"));
4517
4518
  return;
4518
4519
  }
4519
- const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), n = Array.from(i.rows).map((o) => o.cells[s]).filter(Boolean);
4520
- let l, r;
4520
+ const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), n = Array.from(i.rows).map((l) => l.cells[s]).filter(Boolean);
4521
+ let r, o;
4521
4522
  this.dialog(
4522
4523
  this.t("colprops").replace("…", ""),
4523
- (o) => {
4524
- l = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), l), r = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), r.wrap);
4524
+ (l) => {
4525
+ r = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(l, this.t("tblwidth"), r), o = this.formBg(t.style.backgroundColor || ""), this.formRow(l, this.t("backcolor"), o.wrap);
4525
4526
  },
4526
4527
  [
4527
4528
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4529,8 +4530,8 @@ let rs = (j = class {
4529
4530
  label: this.t("save"),
4530
4531
  primary: !0,
4531
4532
  action: () => {
4532
- n.forEach((o) => {
4533
- this.setOrClear(o, "width", l.value.trim()), this.setOrClear(o, "background-color", r.fill.checked ? r.color.value : "");
4533
+ n.forEach((l) => {
4534
+ this.setOrClear(l, "width", r.value.trim()), this.setOrClear(l, "background-color", o.fill.checked ? o.color.value : "");
4534
4535
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
4535
4536
  }
4536
4537
  }
@@ -4546,8 +4547,8 @@ let rs = (j = class {
4546
4547
  const s = document.createElement("div");
4547
4548
  s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
4548
4549
  <div class="body"></div><footer></footer>`, s.querySelector("header button").onclick = () => this.closeDlg(), e(s.querySelector(".body")), (i || [{ label: this.t("close"), primary: !0, action: () => this.closeDlg() }]).forEach((n) => {
4549
- const l = document.createElement("button");
4550
- l.type = "button", l.textContent = n.label, n.primary && (l.className = "pri"), l.onclick = n.action, s.querySelector("footer").appendChild(l);
4550
+ const r = document.createElement("button");
4551
+ r.type = "button", r.textContent = n.label, n.primary && (r.className = "pri"), r.onclick = n.action, s.querySelector("footer").appendChild(r);
4551
4552
  }), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (n) => {
4552
4553
  n.target === this.dlgOvl && this.closeDlg();
4553
4554
  }), document.body.appendChild(this.dlgOvl);
@@ -4602,7 +4603,7 @@ let rs = (j = class {
4602
4603
  const e = document.createElement("div");
4603
4604
  e.className = "pv-box";
4604
4605
  const i = this.contentWidth();
4605
- e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
4606
+ e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;box-sizing:content-box;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
4606
4607
  });
4607
4608
  }
4608
4609
  /** Two-pane picker shared by the special-character map and the emoji map:
@@ -4611,24 +4612,24 @@ let rs = (j = class {
4611
4612
  this.saveSel(), this.dialog(t, (s) => {
4612
4613
  const n = document.createElement("div");
4613
4614
  n.className = "chmap";
4614
- const l = document.createElement("div");
4615
- l.className = "chtabs";
4616
4615
  const r = document.createElement("div");
4617
- r.className = "chpanel";
4616
+ r.className = "chtabs";
4618
4617
  const o = document.createElement("div");
4619
- o.className = "chgrid" + (i ? " emgrid" : ""), r.appendChild(o);
4620
- const a = (u) => {
4621
- l.querySelectorAll("button").forEach((p, m) => p.classList.toggle("on", m === u)), o.innerHTML = "", e[u].chars.forEach((p) => {
4618
+ o.className = "chpanel";
4619
+ const l = document.createElement("div");
4620
+ l.className = "chgrid" + (i ? " emgrid" : ""), o.appendChild(l);
4621
+ const a = (d) => {
4622
+ r.querySelectorAll("button").forEach((p, m) => p.classList.toggle("on", m === d)), l.innerHTML = "", e[d].chars.forEach((p) => {
4622
4623
  const m = document.createElement("button");
4623
4624
  m.type = "button", m.textContent = p, m.onclick = () => {
4624
4625
  this.closeDlg(), this.exec("insertText", p);
4625
- }, o.appendChild(m);
4626
- }), r.scrollTop = 0;
4626
+ }, l.appendChild(m);
4627
+ }), o.scrollTop = 0;
4627
4628
  };
4628
- e.forEach((u, p) => {
4629
+ e.forEach((d, p) => {
4629
4630
  const m = document.createElement("button");
4630
- m.type = "button", m.textContent = this.t(u.key), m.addEventListener("click", () => a(p)), l.appendChild(m);
4631
- }), n.append(l, r), s.appendChild(n), a(0);
4631
+ m.type = "button", m.textContent = this.t(d.key), m.addEventListener("click", () => a(p)), r.appendChild(m);
4632
+ }), n.append(r, o), s.appendChild(n), a(0);
4632
4633
  });
4633
4634
  }
4634
4635
  charMap() {
@@ -4697,17 +4698,17 @@ let rs = (j = class {
4697
4698
  const i = document.createElement("button");
4698
4699
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
4699
4700
  const s = () => {
4700
- const n = e.value.trim(), l = this.phActive;
4701
- if (!l) return;
4701
+ const n = e.value.trim(), r = this.phActive;
4702
+ if (!r) return;
4702
4703
  if (!/^(https?:|data:image\/|blob:)/i.test(n)) {
4703
4704
  e.classList.add("err"), e.focus();
4704
4705
  return;
4705
4706
  }
4706
4707
  i.disabled = !0, e.disabled = !0;
4707
- const r = new Image();
4708
- r.onload = () => this.replacePlaceholderWithImage(l, n, ""), r.onerror = () => {
4708
+ const o = new Image();
4709
+ o.onload = () => this.replacePlaceholderWithImage(r, n, ""), o.onerror = () => {
4709
4710
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4710
- }, r.src = n;
4711
+ }, o.src = n;
4711
4712
  };
4712
4713
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (n) => {
4713
4714
  n.key === "Enter" ? (n.preventDefault(), s()) : n.key === "Escape" && (n.stopPropagation(), this.renderPhCtxButtons());
@@ -4733,8 +4734,8 @@ let rs = (j = class {
4733
4734
  s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((n) => {
4734
4735
  this.ed.contains(e) && this.replacePlaceholderWithImage(e, n, i);
4735
4736
  }).catch((n) => {
4736
- var l;
4737
- this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (l = this.onImageUploadError) == null || l.call(this, n, t));
4737
+ var r;
4738
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (r = this.onImageUploadError) == null || r.call(this, n, t));
4738
4739
  });
4739
4740
  }
4740
4741
  replacePlaceholderWithImage(t, e, i) {
@@ -4772,8 +4773,8 @@ let rs = (j = class {
4772
4773
  if (!this.ed.contains(t) || t.closest(".tpl-media") || t.getAttribute("width") || t.getAttribute("height") || t.style.width || t.style.height) return i(!1);
4773
4774
  const n = t.naturalWidth;
4774
4775
  if (!n) return i(!1);
4775
- const l = this.contentWidth(), r = Math.round(l > 0 ? Math.min(n, l) : n);
4776
- t.setAttribute("width", String(r)), t.style.width = r + "px", t.style.height = "auto", i(!0);
4776
+ const r = this.contentWidth(), o = Math.round(r > 0 ? Math.min(n, r) : n);
4777
+ t.setAttribute("width", String(o)), t.style.width = o + "px", t.style.height = "auto", i(!0);
4777
4778
  };
4778
4779
  t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
4779
4780
  }
@@ -4848,22 +4849,22 @@ let rs = (j = class {
4848
4849
  const i = document.createElement("button");
4849
4850
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertvideo");
4850
4851
  const s = () => {
4851
- const n = e.value.trim(), l = this.vphActive;
4852
- if (!l) return;
4852
+ const n = e.value.trim(), r = this.vphActive;
4853
+ if (!r) return;
4853
4854
  if (!/^(https?:|data:video\/|blob:)/i.test(n)) {
4854
4855
  e.classList.add("err"), e.focus();
4855
4856
  return;
4856
4857
  }
4857
- const r = this.videoEmbedUrl(n);
4858
- if (r) {
4859
- this.replacePlaceholderWithEmbed(l, r);
4858
+ const o = this.videoEmbedUrl(n);
4859
+ if (o) {
4860
+ this.replacePlaceholderWithEmbed(r, o);
4860
4861
  return;
4861
4862
  }
4862
4863
  i.disabled = !0, e.disabled = !0;
4863
- const o = document.createElement("video");
4864
- o.preload = "metadata", o.onloadedmetadata = () => this.replacePlaceholderWithVideo(l, n, ""), o.onerror = () => {
4864
+ const l = document.createElement("video");
4865
+ l.preload = "metadata", l.onloadedmetadata = () => this.replacePlaceholderWithVideo(r, n, ""), l.onerror = () => {
4865
4866
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4866
- }, o.src = n;
4867
+ }, l.src = n;
4867
4868
  };
4868
4869
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (n) => {
4869
4870
  n.key === "Enter" ? (n.preventDefault(), s()) : n.key === "Escape" && (n.stopPropagation(), this.renderVphCtxButtons());
@@ -4889,8 +4890,8 @@ let rs = (j = class {
4889
4890
  s && (s.textContent = this.t("uploading")), this.videoUploadHandler(t).then((n) => {
4890
4891
  this.ed.contains(e) && this.replacePlaceholderWithVideo(e, n, i);
4891
4892
  }).catch((n) => {
4892
- var l;
4893
- this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (l = this.onVideoUploadError) == null || l.call(this, n, t));
4893
+ var r;
4894
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (r = this.onVideoUploadError) == null || r.call(this, n, t));
4894
4895
  });
4895
4896
  }
4896
4897
  replacePlaceholderWithVideo(t, e, i) {
@@ -4929,21 +4930,21 @@ let rs = (j = class {
4929
4930
  const e = document.createElement("div");
4930
4931
  e.className = "imgctx", e.dir = this.dir();
4931
4932
  const i = () => {
4932
- var u;
4933
+ var d;
4933
4934
  const a = this.buildVideoCtxToolbar(t);
4934
- (u = this.vidCtx) == null || u.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
4935
+ (d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
4935
4936
  }, s = (a) => {
4936
4937
  this.setVideoAlign(t, a), i();
4937
- }, n = t.style.float === "left", l = t.style.float === "right", r = !n && !l && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, u, p, m) => {
4938
- const v = this.ctxBtn(a, u, m);
4938
+ }, n = t.style.float === "left", r = t.style.float === "right", o = !n && !r && t.style.marginLeft === "auto" && t.style.marginRight === "auto", l = (a, d, p, m) => {
4939
+ const v = this.ctxBtn(a, d, m);
4939
4940
  return v.classList.toggle("on", p), v;
4940
4941
  };
4941
4942
  return e.append(
4942
- o(h.alignleft, this.t("alignleft"), n, () => s("left")),
4943
- o(h.aligncenter, this.t("aligncenter"), r, () => s("center")),
4944
- o(h.alignright, this.t("alignright"), l, () => s("right")),
4943
+ l(h.alignleft, this.t("alignleft"), n, () => s("left")),
4944
+ l(h.aligncenter, this.t("aligncenter"), o, () => s("center")),
4945
+ l(h.alignright, this.t("alignright"), r, () => s("right")),
4945
4946
  this.ctxSep(),
4946
- o(h.trash, this.t("deletevideo"), !1, () => {
4947
+ l(h.trash, this.t("deletevideo"), !1, () => {
4947
4948
  t.remove(), this.clearVidHandles(), this.onChange();
4948
4949
  })
4949
4950
  ), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
@@ -4983,33 +4984,33 @@ let rs = (j = class {
4983
4984
  * (videoUploadHandler when configured, else inline base64). */
4984
4985
  videoDlg() {
4985
4986
  this.saveSel();
4986
- let t, e, i, s, n, l;
4987
- const r = (a, u) => {
4987
+ let t, e, i, s, n, r;
4988
+ const o = (a, d) => {
4988
4989
  const p = document.createElement("div");
4989
4990
  p.className = "dfield";
4990
4991
  const m = document.createElement("label");
4991
- return m.textContent = this.t(a), p.append(m, u), p;
4992
- }, o = () => {
4992
+ return m.textContent = this.t(a), p.append(m, d), p;
4993
+ }, l = () => {
4993
4994
  const a = document.createElement("input");
4994
4995
  return a.type = "url", a;
4995
4996
  };
4996
4997
  this.dialog(
4997
4998
  this.t("videodlgttl"),
4998
4999
  (a) => {
4999
- const u = document.createElement("div");
5000
- u.className = "dtabs";
5000
+ const d = document.createElement("div");
5001
+ d.className = "dtabs";
5001
5002
  const p = [], m = (f, y) => {
5002
5003
  const C = document.createElement("button");
5003
5004
  C.type = "button", C.textContent = this.t(f);
5004
5005
  const E = document.createElement("div");
5005
5006
  E.className = "dtabpanel", y(E);
5006
5007
  const I = p.length;
5007
- p.push(E), C.addEventListener("click", () => v(I)), u.appendChild(C);
5008
+ p.push(E), C.addEventListener("click", () => v(I)), d.appendChild(C);
5008
5009
  }, v = (f) => {
5009
- u.querySelectorAll("button").forEach((y, C) => y.classList.toggle("on", C === f)), p.forEach((y, C) => y.style.display = C === f ? "" : "none");
5010
+ d.querySelectorAll("button").forEach((y, C) => y.classList.toggle("on", C === f)), p.forEach((y, C) => y.style.display = C === f ? "" : "none");
5010
5011
  };
5011
5012
  m("vidgeneral", (f) => {
5012
- t = o(), t.placeholder = this.t("videourlph");
5013
+ t = l(), t.placeholder = this.t("videourlph");
5013
5014
  const y = document.createElement("div");
5014
5015
  y.className = "drow";
5015
5016
  const C = document.createElement("button");
@@ -5034,17 +5035,17 @@ let rs = (j = class {
5034
5035
  const Z = new FileReader();
5035
5036
  Z.onload = () => $(Z.result), Z.readAsDataURL(A);
5036
5037
  }
5037
- }), y.append(t, C, E), t.style.flex = "1", f.appendChild(r("vidsource", y));
5038
+ }), y.append(t, C, E), t.style.flex = "1", f.appendChild(o("vidsource", y));
5038
5039
  const I = document.createElement("div");
5039
- I.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", I.append(r("tblwidth", e), r("tblheight", i)), f.appendChild(I);
5040
+ I.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", I.append(o("tblwidth", e), o("tblheight", i)), f.appendChild(I);
5040
5041
  }), m("vidembed", (f) => {
5041
5042
  const y = document.createElement("p");
5042
5043
  y.textContent = this.t("vidembedhint"), y.style.cssText = "margin:0 0 8px;color:#556;font-size:13.5px", s = document.createElement("textarea"), s.style.cssText = "width:100%;box-sizing:border-box;height:160px", f.append(y, s);
5043
5044
  }), m("vidadvanced", (f) => {
5044
- n = o(), l = o(), f.append(r("vidaltsource", n), r("vidposter", l));
5045
+ n = l(), r = l(), f.append(o("vidaltsource", n), o("vidposter", r));
5045
5046
  });
5046
5047
  const b = document.createElement("div");
5047
- b.className = "dtabbody", p.forEach((f) => b.appendChild(f)), a.append(u, b), v(0), setTimeout(() => t.focus(), 0);
5048
+ b.className = "dtabbody", p.forEach((f) => b.appendChild(f)), a.append(d, b), v(0), setTimeout(() => t.focus(), 0);
5048
5049
  },
5049
5050
  [
5050
5051
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -5052,21 +5053,21 @@ let rs = (j = class {
5052
5053
  label: this.t("save"),
5053
5054
  primary: !0,
5054
5055
  action: () => {
5055
- const a = s.value.trim(), u = t.value.trim(), p = parseInt(e.value, 10) || 560, m = parseInt(i.value, 10) || 314;
5056
- if (this.closeDlg(), !a && !u) return;
5056
+ const a = s.value.trim(), d = t.value.trim(), p = parseInt(e.value, 10) || 560, m = parseInt(i.value, 10) || 314;
5057
+ if (this.closeDlg(), !a && !d) return;
5057
5058
  if (this.restoreSel(), a) {
5058
5059
  document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${a}</span>`), this.onChange();
5059
5060
  return;
5060
5061
  }
5061
- const v = this.videoEmbedUrl(u);
5062
+ const v = this.videoEmbedUrl(d);
5062
5063
  if (v)
5063
5064
  document.execCommand("insertHTML", !1, this.videoEmbedHTML(v, p, m));
5064
5065
  else {
5065
- const b = n.value.trim(), f = l.value.trim();
5066
+ const b = n.value.trim(), f = r.value.trim();
5066
5067
  document.execCommand(
5067
5068
  "insertHTML",
5068
5069
  !1,
5069
- `<video controls width="${p}" height="${m}"${f ? ` poster="${this.escapeAttr(f)}"` : ""}><source src="${this.escapeAttr(u)}">${b ? `<source src="${this.escapeAttr(b)}">` : ""}</video>`
5070
+ `<video controls width="${p}" height="${m}"${f ? ` poster="${this.escapeAttr(f)}"` : ""}><source src="${this.escapeAttr(d)}">${b ? `<source src="${this.escapeAttr(b)}">` : ""}</video>`
5070
5071
  );
5071
5072
  }
5072
5073
  this.onChange();
@@ -5117,49 +5118,49 @@ let rs = (j = class {
5117
5118
  /** Typing `snippet` converts to an inline <code> run the moment the closing
5118
5119
  * backtick is typed, so code can be marked up without reaching for the toolbar. */
5119
5120
  tryCodeTyping(t) {
5120
- var u;
5121
+ var d;
5121
5122
  const e = window.getSelection();
5122
5123
  if (!e || !e.isCollapsed || !e.anchorNode) return;
5123
5124
  const i = e.anchorNode;
5124
- if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (u = i.parentElement) != null && u.closest("code, pre")) return;
5125
+ if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (d = i.parentElement) != null && d.closest("code, pre")) return;
5125
5126
  const n = (i.textContent || "").slice(0, e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);
5126
5127
  if (!n) return;
5127
- const l = n[1];
5128
- if (/^\s|\s$/.test(l)) return;
5128
+ const r = n[1];
5129
+ if (/^\s|\s$/.test(r)) return;
5129
5130
  t.preventDefault();
5130
- const r = document.createRange();
5131
- r.setStart(i, e.anchorOffset - l.length - 1), r.setEnd(i, e.anchorOffset), r.deleteContents();
5132
- const o = document.createElement("code");
5133
- o.textContent = l, r.insertNode(o);
5131
+ const o = document.createRange();
5132
+ o.setStart(i, e.anchorOffset - r.length - 1), o.setEnd(i, e.anchorOffset), o.deleteContents();
5133
+ const l = document.createElement("code");
5134
+ l.textContent = r, o.insertNode(l);
5134
5135
  const a = document.createRange();
5135
- a.setStartAfter(o), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
5136
+ a.setStartAfter(l), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
5136
5137
  }
5137
5138
  /** Custom dropdown for dialog fields (a native <select> popup can't be styled):
5138
5139
  * a field-styled button showing the current choice that opens a floating,
5139
5140
  * scrollable option list. Read the current choice via `.value()`. */
5140
5141
  dlgSelect(t, e) {
5141
- var o;
5142
+ var l;
5142
5143
  let i = e;
5143
5144
  const s = document.createElement("div");
5144
5145
  s.className = "dsel";
5145
5146
  const n = document.createElement("button");
5146
5147
  n.type = "button", n.className = "dsel-btn";
5147
- const l = document.createElement("span");
5148
- l.className = "lbl", l.textContent = ((o = t.find(([a]) => a === e)) == null ? void 0 : o[1]) || "", n.append(l), n.insertAdjacentHTML("beforeend", h.chev);
5149
- const r = document.createElement("div");
5150
- return r.className = "dsel-list", t.forEach(([a, u]) => {
5148
+ const r = document.createElement("span");
5149
+ r.className = "lbl", r.textContent = ((l = t.find(([a]) => a === e)) == null ? void 0 : l[1]) || "", n.append(r), n.insertAdjacentHTML("beforeend", h.chev);
5150
+ const o = document.createElement("div");
5151
+ return o.className = "dsel-list", t.forEach(([a, d]) => {
5151
5152
  const p = document.createElement("button");
5152
- p.type = "button", p.textContent = u, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
5153
- i = a, l.textContent = u, r.querySelectorAll("button").forEach((m) => m.classList.toggle("on", m === p)), s.classList.remove("open"), n.focus();
5154
- }), r.appendChild(p);
5153
+ p.type = "button", p.textContent = d, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
5154
+ i = a, r.textContent = d, o.querySelectorAll("button").forEach((m) => m.classList.toggle("on", m === p)), s.classList.remove("open"), n.focus();
5155
+ }), o.appendChild(p);
5155
5156
  }), n.addEventListener("click", () => {
5156
5157
  var a;
5157
- s.classList.toggle("open"), s.classList.contains("open") && ((a = r.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
5158
+ s.classList.toggle("open"), s.classList.contains("open") && ((a = o.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
5158
5159
  }), s.addEventListener("focusout", (a) => {
5159
5160
  s.contains(a.relatedTarget) || s.classList.remove("open");
5160
5161
  }), s.addEventListener("keydown", (a) => {
5161
5162
  a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), n.focus());
5162
- }), s.append(n, r), { el: s, value: () => i };
5163
+ }), s.append(n, o), { el: s, value: () => i };
5163
5164
  }
5164
5165
  /** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
5165
5166
  * paste or type code into. Inserts a non-editable <pre class="code-block">
@@ -5170,11 +5171,11 @@ let rs = (j = class {
5170
5171
  this.dialog(
5171
5172
  this.t("codedlgttl"),
5172
5173
  (s) => {
5173
- var r;
5174
+ var o;
5174
5175
  const n = document.createElement("div");
5175
5176
  n.className = "dfield";
5176
- const l = document.createElement("label");
5177
- l.textContent = this.t("codelang"), e = this.dlgSelect(ne, (t == null ? void 0 : t.dataset.lang) || "plain"), n.append(l, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((r = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : r.textContent) || "", i.placeholder = "const answer = 42;", s.append(n, i), setTimeout(() => i.focus(), 0);
5177
+ const r = document.createElement("label");
5178
+ r.textContent = this.t("codelang"), e = this.dlgSelect(ne, (t == null ? void 0 : t.dataset.lang) || "plain"), n.append(r, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((o = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : o.textContent) || "", i.placeholder = "const answer = 42;", s.append(n, i), setTimeout(() => i.focus(), 0);
5178
5179
  },
5179
5180
  [
5180
5181
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -5182,19 +5183,19 @@ let rs = (j = class {
5182
5183
  label: this.t("save"),
5183
5184
  primary: !0,
5184
5185
  action: () => {
5185
- var r;
5186
- const s = i.value.replace(/\s+$/, ""), n = e.value(), l = ((r = ne.find(([o]) => o === n)) == null ? void 0 : r[1]) || n;
5186
+ var o;
5187
+ const s = i.value.replace(/\s+$/, ""), n = e.value(), r = ((o = ne.find(([l]) => l === n)) == null ? void 0 : o[1]) || n;
5187
5188
  if (this.closeDlg(), !!s.trim()) {
5188
5189
  if (t) {
5189
- t.dataset.lang = n, t.setAttribute("data-lang-label", l);
5190
- const o = t.querySelector("code") || t;
5191
- o.textContent = s, this.clearCodeSel(), this.onChange();
5190
+ t.dataset.lang = n, t.setAttribute("data-lang-label", r);
5191
+ const l = t.querySelector("code") || t;
5192
+ l.textContent = s, this.clearCodeSel(), this.onChange();
5192
5193
  return;
5193
5194
  }
5194
5195
  this.restoreSel(), document.execCommand(
5195
5196
  "insertHTML",
5196
5197
  !1,
5197
- `<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(l)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
5198
+ `<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(r)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
5198
5199
  ), this.onChange();
5199
5200
  }
5200
5201
  }
@@ -5251,8 +5252,8 @@ let rs = (j = class {
5251
5252
  /** Miniature div-based mockup of a layout, mirroring what the block looks
5252
5253
  like in the editor: grey box = image slot, bars = heading/paragraph. */
5253
5254
  tplPreviewHTML(t) {
5254
- const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (o) => `<span class="pv-l" style="width:${o}%"></span>`, n = (o) => `<span class="pv-col">${o}</span>`, l = (o) => `<span class="pv-row">${o}</span>`, r = n(i + s(100) + s(88));
5255
- return t === "img-left" ? `<span class="pv">${l(e + r)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${l(r + e)}${s(100)}${s(72)}</span>` : t === "img-top" ? `<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>` : `<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`;
5255
+ const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (l) => `<span class="pv-l" style="width:${l}%"></span>`, n = (l) => `<span class="pv-col">${l}</span>`, r = (l) => `<span class="pv-row">${l}</span>`, o = n(i + s(100) + s(88));
5256
+ return t === "img-left" ? `<span class="pv">${r(e + o)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${r(o + e)}${s(100)}${s(72)}</span>` : t === "img-top" ? `<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>` : `<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`;
5256
5257
  }
5257
5258
  buildTemplatePickInto(t, e) {
5258
5259
  const i = document.createElement("div");
@@ -5317,7 +5318,7 @@ let rs = (j = class {
5317
5318
  /* ---------------------------------------------------------- table resize */
5318
5319
  clearTableHandles() {
5319
5320
  var t, e, i, s, n;
5320
- (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((l) => l.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (n = this.tblActive) == null || n.classList.remove("tbl-selected"), this.tblActive = null;
5321
+ (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((r) => r.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (n = this.tblActive) == null || n.classList.remove("tbl-selected"), this.tblActive = null;
5321
5322
  }
5322
5323
  /** Blue outline around the cell that holds the caret, so it is clear
5323
5324
  which cell / row / column the table operations will target. */
@@ -5337,15 +5338,15 @@ let rs = (j = class {
5337
5338
  this.tblOpMarkKind = t, this.positionOpMark();
5338
5339
  }
5339
5340
  positionOpMark() {
5340
- var u;
5341
+ var d;
5341
5342
  const t = this.tblOpMarkKind, e = t ? this.currentCell() : null;
5342
5343
  if (!t || !e || !this.tblActive || e.closest("table") !== this.tblActive) {
5343
- (u = this.tblOpMark) == null || u.remove(), this.tblOpMark = null;
5344
+ (d = this.tblOpMark) == null || d.remove(), this.tblOpMark = null;
5344
5345
  return;
5345
5346
  }
5346
5347
  this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
5347
- const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), n = e.parentElement.getBoundingClientRect(), l = t === "row" ? n.left : s.left, r = t === "row" ? n.top : i.top, o = t === "row" ? n.width : s.width, a = t === "row" ? n.height : i.height;
5348
- this.tblOpMark.style.left = l + scrollX + "px", this.tblOpMark.style.top = r + scrollY + "px", this.tblOpMark.style.width = o + "px", this.tblOpMark.style.height = a + "px";
5348
+ const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), n = e.parentElement.getBoundingClientRect(), r = t === "row" ? n.left : s.left, o = t === "row" ? n.top : i.top, l = t === "row" ? n.width : s.width, a = t === "row" ? n.height : i.height;
5349
+ this.tblOpMark.style.left = r + scrollX + "px", this.tblOpMark.style.top = o + scrollY + "px", this.tblOpMark.style.width = l + "px", this.tblOpMark.style.height = a + "px";
5349
5350
  }
5350
5351
  /** Lowest allowed top for floating context toolbars — keeps them from
5351
5352
  covering the editor menubar/toolbar when the target sits on the first line. */
@@ -5354,7 +5355,7 @@ let rs = (j = class {
5354
5355
  }
5355
5356
  ctxBtn(t, e, i, s) {
5356
5357
  const n = document.createElement("button");
5357
- return n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (l) => l.preventDefault()), n.addEventListener("click", i), n;
5358
+ return n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (r) => r.preventDefault()), n.addEventListener("click", i), n;
5358
5359
  }
5359
5360
  ctxSep() {
5360
5361
  const t = document.createElement("div");
@@ -5391,20 +5392,20 @@ let rs = (j = class {
5391
5392
  this.clearTableHandles();
5392
5393
  return;
5393
5394
  }
5394
- const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, l = e.bottom + scrollY;
5395
- if (this.tblCorner && (this.tblCorner.style.top = l - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : n - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
5396
- const o = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
5397
- let u = s + (n - s) / 2 - o / 2;
5398
- u = Math.max(8 + scrollX, Math.min(u, scrollX + innerWidth - o - 8));
5395
+ const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, r = e.bottom + scrollY;
5396
+ if (this.tblCorner && (this.tblCorner.style.top = r - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : n - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
5397
+ const l = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
5398
+ let d = s + (n - s) / 2 - l / 2;
5399
+ d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - l - 8));
5399
5400
  let p = i - a - 8;
5400
- p < this.ctxMinTop() && (p = l + 8), this.tblCtx.style.left = u + "px", this.tblCtx.style.top = p + "px";
5401
+ p < this.ctxMinTop() && (p = r + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
5401
5402
  }
5402
- this.tblColBars.forEach((o) => o.remove()), this.tblColBars = [];
5403
- const r = this.tblActive.rows[0];
5404
- if (r)
5405
- for (let o = 0; o < r.cells.length - 1; o++) {
5406
- const a = r.cells[o].getBoundingClientRect(), u = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
5407
- p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = u + "px", p.style.height = l - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (m) => this.startColBarDrag(m, o)), this.tblColBars.push(p);
5403
+ this.tblColBars.forEach((l) => l.remove()), this.tblColBars = [];
5404
+ const o = this.tblActive.rows[0];
5405
+ if (o)
5406
+ for (let l = 0; l < o.cells.length - 1; l++) {
5407
+ const a = o.cells[l].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
5408
+ p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = r - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (m) => this.startColBarDrag(m, l)), this.tblColBars.push(p);
5408
5409
  }
5409
5410
  this.positionCellMarker(), this.positionOpMark();
5410
5411
  }
@@ -5422,27 +5423,27 @@ let rs = (j = class {
5422
5423
  const e = this.tblActive;
5423
5424
  if (!e) return;
5424
5425
  const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, n = e.getBoundingClientRect().width;
5425
- e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((l) => {
5426
- const r = (a) => {
5427
- const u = i ? -(a.clientX - s) : a.clientX - s;
5428
- e.style.width = Math.max(60, Math.round(n + u)) + "px", this.positionTableHandles();
5429
- }, o = () => {
5430
- window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", o), l(), this.onChange();
5426
+ e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((r) => {
5427
+ const o = (a) => {
5428
+ const d = i ? -(a.clientX - s) : a.clientX - s;
5429
+ e.style.width = Math.max(60, Math.round(n + d)) + "px", this.positionTableHandles();
5430
+ }, l = () => {
5431
+ window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", l), r(), this.onChange();
5431
5432
  };
5432
- window.addEventListener("mousemove", r), window.addEventListener("mouseup", o);
5433
+ window.addEventListener("mousemove", o), window.addEventListener("mouseup", l);
5433
5434
  });
5434
5435
  }
5435
5436
  startColBarDrag(t, e) {
5436
5437
  t.preventDefault(), t.stopPropagation();
5437
5438
  const i = this.tblActive;
5438
5439
  if (!i) return;
5439
- const s = this.ed.getAttribute("dir") === "rtl", n = Array.from(i.rows), l = n.map((p) => p.cells[e]).filter(Boolean), r = n.map((p) => p.cells[e + 1]).filter(Boolean);
5440
- if (!l.length || !r.length) return;
5441
- const o = t.clientX, a = l[0].getBoundingClientRect().width, u = r[0].getBoundingClientRect().width;
5440
+ const s = this.ed.getAttribute("dir") === "rtl", n = Array.from(i.rows), r = n.map((p) => p.cells[e]).filter(Boolean), o = n.map((p) => p.cells[e + 1]).filter(Boolean);
5441
+ if (!r.length || !o.length) return;
5442
+ const l = t.clientX, a = r[0].getBoundingClientRect().width, d = o[0].getBoundingClientRect().width;
5442
5443
  i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
5443
5444
  const m = (b) => {
5444
- const f = (s ? -1 : 1) * (b.clientX - o);
5445
- l.forEach((y) => y.style.width = Math.max(24, Math.round(a + f)) + "px"), r.forEach((y) => y.style.width = Math.max(24, Math.round(u - f)) + "px"), this.positionTableHandles();
5445
+ const f = (s ? -1 : 1) * (b.clientX - l);
5446
+ r.forEach((y) => y.style.width = Math.max(24, Math.round(a + f)) + "px"), o.forEach((y) => y.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
5446
5447
  }, v = () => {
5447
5448
  window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", v), p(), this.onChange();
5448
5449
  };
@@ -5470,35 +5471,35 @@ let rs = (j = class {
5470
5471
  const e = document.createElement("div");
5471
5472
  e.className = "imgctx", e.dir = this.dir();
5472
5473
  const i = () => {
5473
- var u;
5474
+ var d;
5474
5475
  const a = this.buildImageCtxToolbar(t);
5475
- (u = this.imgCtx) == null || u.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
5476
+ (d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
5476
5477
  }, s = (a) => {
5477
5478
  this.setImageAlign(t, a), i();
5478
- }, n = t.style.float === "left", l = t.style.float === "right", r = !n && !l && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, u, p, m) => {
5479
- const v = this.ctxBtn(a, u, m);
5479
+ }, n = t.style.float === "left", r = t.style.float === "right", o = !n && !r && t.style.marginLeft === "auto" && t.style.marginRight === "auto", l = (a, d, p, m) => {
5480
+ const v = this.ctxBtn(a, d, m);
5480
5481
  return v.classList.toggle("on", p), v;
5481
5482
  };
5482
5483
  return e.append(
5483
- o(h.alignleft, this.t("alignleft"), n, () => s("left")),
5484
- o(h.aligncenter, this.t("aligncenter"), r, () => s("center")),
5485
- o(h.alignright, this.t("alignright"), l, () => s("right")),
5484
+ l(h.alignleft, this.t("alignleft"), n, () => s("left")),
5485
+ l(h.aligncenter, this.t("aligncenter"), o, () => s("center")),
5486
+ l(h.alignright, this.t("alignright"), r, () => s("right")),
5486
5487
  this.ctxSep(),
5487
- o(h.rotateleft, this.t("rotateleft"), !1, () => {
5488
+ l(h.rotateleft, this.t("rotateleft"), !1, () => {
5488
5489
  this.rotateImage(t, -90), i();
5489
5490
  }),
5490
- o(h.rotateright, this.t("rotateright"), !1, () => {
5491
+ l(h.rotateright, this.t("rotateright"), !1, () => {
5491
5492
  this.rotateImage(t, 90), i();
5492
5493
  }),
5493
5494
  this.ctxSep(),
5494
- o(h.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
5495
+ l(h.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
5495
5496
  this.flipImage(t, "x"), i();
5496
5497
  }),
5497
- o(h.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
5498
+ l(h.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
5498
5499
  this.flipImage(t, "y"), i();
5499
5500
  }),
5500
5501
  this.ctxSep(),
5501
- o(h.trash, this.t("deleteimg"), !1, () => {
5502
+ l(h.trash, this.t("deleteimg"), !1, () => {
5502
5503
  const a = t.closest(".tpl-media");
5503
5504
  a && this.ed.contains(a) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
5504
5505
  })
@@ -5524,21 +5525,21 @@ let rs = (j = class {
5524
5525
  this.clearImageHandles();
5525
5526
  return;
5526
5527
  }
5527
- const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, n = t.bottom + scrollY, l = {
5528
+ const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, n = t.bottom + scrollY, r = {
5528
5529
  nw: [i, e],
5529
5530
  ne: [s, e],
5530
5531
  sw: [i, n],
5531
5532
  se: [s, n]
5532
5533
  };
5533
- if (this.imgHandles.forEach((r) => {
5534
- const [o, a] = l[r.dataset.corner];
5535
- r.style.left = o - 5 + "px", r.style.top = a - 5 + "px";
5534
+ if (this.imgHandles.forEach((o) => {
5535
+ const [l, a] = r[o.dataset.corner];
5536
+ o.style.left = l - 5 + "px", o.style.top = a - 5 + "px";
5536
5537
  }), this.imgCtx) {
5537
- const r = this.imgCtx.offsetWidth, o = this.imgCtx.offsetHeight;
5538
- let a = i + (s - i) / 2 - r / 2;
5539
- a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - r - 8));
5540
- let u = e - o - 8;
5541
- u < this.ctxMinTop() && (u = n + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = u + "px";
5538
+ const o = this.imgCtx.offsetWidth, l = this.imgCtx.offsetHeight;
5539
+ let a = i + (s - i) / 2 - o / 2;
5540
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
5541
+ let d = e - l - 8;
5542
+ d < this.ctxMinTop() && (d = n + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
5542
5543
  }
5543
5544
  }
5544
5545
  startImageResizeDrag(t, e) {
@@ -5546,16 +5547,17 @@ let rs = (j = class {
5546
5547
  const i = this.imgActive;
5547
5548
  if (!i) return;
5548
5549
  this.cancelImgHide();
5549
- const s = t.clientX, n = i.getBoundingClientRect().width, l = e === "nw" || e === "sw" ? -1 : 1;
5550
- this.withNoTextSelect((r) => {
5551
- const o = (u) => {
5552
- i.style.width = Math.max(24, Math.round(n + l * (u.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
5553
- }, a = () => {
5554
- window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", a), r();
5555
- const u = parseInt(i.style.width, 10);
5556
- u > 0 && !i.closest(".tpl-media") && (i.setAttribute("width", String(u)), i.removeAttribute("height")), this.onChange();
5550
+ const s = t.clientX, n = i.offsetWidth || i.getBoundingClientRect().width, r = e === "nw" || e === "sw" ? -1 : 1, o = Math.round(this.contentWidth());
5551
+ this.withNoTextSelect((l) => {
5552
+ const a = (p) => {
5553
+ let m = Math.max(24, Math.round(n + r * (p.clientX - s)));
5554
+ o > 0 && (m = Math.min(m, o)), i.style.width = m + "px", i.style.height = "auto", this.positionImageHandles();
5555
+ }, d = () => {
5556
+ window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", d), l();
5557
+ const p = Math.round(i.offsetWidth) || parseInt(i.style.width, 10);
5558
+ p > 0 && !i.closest(".tpl-media") && (i.style.width = p + "px", i.setAttribute("width", String(p)), i.removeAttribute("height")), this.onChange();
5557
5559
  };
5558
- window.addEventListener("mousemove", o), window.addEventListener("mouseup", a);
5560
+ window.addEventListener("mousemove", a), window.addEventListener("mouseup", d);
5559
5561
  });
5560
5562
  }
5561
5563
  /* ---------------------------------------------------------- selection bubble toolbar */
@@ -5594,7 +5596,7 @@ let rs = (j = class {
5594
5596
  this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
5595
5597
  }
5596
5598
  buildSelToolbar() {
5597
- var r;
5599
+ var o;
5598
5600
  const t = document.createElement("div");
5599
5601
  t.className = "selctx", t.dir = this.dir();
5600
5602
  const e = this.ctxBtn(
@@ -5602,8 +5604,8 @@ let rs = (j = class {
5602
5604
  this.t("forecolor"),
5603
5605
  () => this.colorMenu(e, "fore")
5604
5606
  ), i = this.ctxBtn(h.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
5605
- (r = i.querySelector("svg")) == null || r.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5606
- const s = this.ctxBtn(h.caseic, this.t("changecase"), () => this.caseMenu(s)), n = this.ctxBtn(h.lineheight, this.t("lineheight"), () => this.lineHeightMenu(n)), l = this.ctxBtn(h.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(l));
5607
+ (o = i.querySelector("svg")) == null || o.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5608
+ const s = this.ctxBtn(h.caseic, this.t("changecase"), () => this.caseMenu(s)), n = this.ctxBtn(h.lineheight, this.t("lineheight"), () => this.lineHeightMenu(n)), r = this.ctxBtn(h.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(r));
5607
5609
  return t.append(
5608
5610
  this.ctxBtn(h.bold, this.t("bold"), () => this.exec("bold"), "bold"),
5609
5611
  this.ctxBtn(h.italic, this.t("italic"), () => this.exec("italic"), "italic"),
@@ -5618,16 +5620,16 @@ let rs = (j = class {
5618
5620
  this.ctxBtn(h.link, this.t("linkttl"), () => this.linkDlg()),
5619
5621
  s,
5620
5622
  n,
5621
- l
5622
- ), t.addEventListener("mousedown", (o) => o.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5623
+ r
5624
+ ), t.addEventListener("mousedown", (l) => l.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5623
5625
  }
5624
5626
  positionSelToolbar(t) {
5625
5627
  if (!this.selCtx) return;
5626
- const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, l = e.bottom + scrollY, r = this.selCtx.offsetWidth, o = this.selCtx.offsetHeight;
5627
- let a = s + (n - s) / 2 - r / 2;
5628
- a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - r - 8));
5629
- let u = i - o - 8;
5630
- u < this.ctxMinTop() && (u = l + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = u + "px";
5628
+ const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, r = e.bottom + scrollY, o = this.selCtx.offsetWidth, l = this.selCtx.offsetHeight;
5629
+ let a = s + (n - s) / 2 - o / 2;
5630
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
5631
+ let d = i - l - 8;
5632
+ d < this.ctxMinTop() && (d = r + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5631
5633
  }
5632
5634
  repositionSelToolbar() {
5633
5635
  if (!this.selCtx) return;
@@ -5660,7 +5662,7 @@ let rs = (j = class {
5660
5662
  return t > 0 ? t + "px" : "";
5661
5663
  }
5662
5664
  refreshState() {
5663
- var o, a, u;
5665
+ var l, a, d;
5664
5666
  const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
5665
5667
  [this.toolbar, this.selCtx].filter(Boolean).forEach((p) => {
5666
5668
  [
@@ -5684,13 +5686,13 @@ let rs = (j = class {
5684
5686
  const m = p.querySelector("[data-id=code]");
5685
5687
  m && m.classList.toggle("on", e && !!this.closestInlineCode());
5686
5688
  });
5687
- const n = t ? this.closestBlock(t.anchorNode) : null, l = ((o = n == null ? void 0 : n.closest("[dir]")) == null ? void 0 : o.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5688
- (a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && l === "ltr"), (u = this.toolbar.querySelector("[data-id=rtl]")) == null || u.classList.toggle("on", e && l === "rtl");
5689
- const r = (p, m, v) => {
5689
+ const n = t ? this.closestBlock(t.anchorNode) : null, r = ((l = n == null ? void 0 : n.closest("[dir]")) == null ? void 0 : l.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5690
+ (a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && r === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && r === "rtl");
5691
+ const o = (p, m, v) => {
5690
5692
  const b = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
5691
5693
  b && (b.textContent = m || v || "", b.classList.toggle("empty", !m));
5692
5694
  };
5693
- r("fontsel", this.currentFont()), r("sizesel", this.currentSize().replace("px", "")), e && r("blocksel", re.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5695
+ o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel", re.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5694
5696
  }
5695
5697
  countWords() {
5696
5698
  const t = (this.ed.textContent || "").trim();
@@ -5710,9 +5712,9 @@ let rs = (j = class {
5710
5712
  return;
5711
5713
  }
5712
5714
  if (!i) {
5713
- const n = e.getData("text/plain"), l = /^\S+$/.test(n.trim()) ? this.videoEmbedUrl(n.trim()) : null;
5714
- if (l) {
5715
- document.execCommand("insertHTML", !1, this.videoEmbedHTML(l)), this.onChange();
5715
+ const n = e.getData("text/plain"), r = /^\S+$/.test(n.trim()) ? this.videoEmbedUrl(n.trim()) : null;
5716
+ if (r) {
5717
+ document.execCommand("insertHTML", !1, this.videoEmbedHTML(r)), this.onChange();
5716
5718
  return;
5717
5719
  }
5718
5720
  }
@@ -5728,19 +5730,19 @@ let rs = (j = class {
5728
5730
  let s = [];
5729
5731
  const n = e.getData("text/rtf");
5730
5732
  if (n) {
5731
- const l = Ii(t, n);
5732
- t = l.html, s = l.injected;
5733
+ const r = Ii(t, n);
5734
+ t = r.html, s = r.injected;
5733
5735
  }
5734
5736
  if (i && qi(t) === 1) {
5735
- const l = i.getAsFile();
5736
- if (l) {
5737
- const r = t;
5737
+ const r = i.getAsFile();
5738
+ if (r) {
5739
+ const o = t;
5738
5740
  this.saveSel();
5739
- const o = new FileReader();
5740
- o.onload = () => {
5741
- const a = ve(r, [o.result]);
5741
+ const l = new FileReader();
5742
+ l.onload = () => {
5743
+ const a = ve(o, [l.result]);
5742
5744
  this.finishRichPaste(a.html, s.concat(a.injected), !0);
5743
- }, o.onerror = () => this.finishRichPaste(r, s, !0), o.readAsDataURL(l);
5745
+ }, l.onerror = () => this.finishRichPaste(o, s, !0), l.readAsDataURL(r);
5744
5746
  return;
5745
5747
  }
5746
5748
  }
@@ -5754,20 +5756,20 @@ let rs = (j = class {
5754
5756
  this.insertPastedHTML(t, i);
5755
5757
  return;
5756
5758
  }
5757
- const s = this.imageUploadHandler, n = e.filter((l, r) => e.indexOf(l) === r);
5759
+ const s = this.imageUploadHandler, n = e.filter((r, o) => e.indexOf(r) === o);
5758
5760
  i || this.saveSel(), Promise.all(
5759
- n.map((l, r) => {
5760
- const o = Ri(l, "pasted-image-" + (r + 1));
5761
- return o ? s(o).catch((a) => {
5762
- var u;
5763
- return (u = this.onImageUploadError) == null || u.call(this, a, o), l;
5764
- }) : Promise.resolve(l);
5761
+ n.map((r, o) => {
5762
+ const l = Ri(r, "pasted-image-" + (o + 1));
5763
+ return l ? s(l).catch((a) => {
5764
+ var d;
5765
+ return (d = this.onImageUploadError) == null || d.call(this, a, l), r;
5766
+ }) : Promise.resolve(r);
5765
5767
  })
5766
- ).then((l) => {
5767
- let r = t;
5768
- n.forEach((o, a) => {
5769
- l[a] !== o && (r = r.split(o).join(l[a]));
5770
- }), this.insertPastedHTML(r, !0);
5768
+ ).then((r) => {
5769
+ let o = t;
5770
+ n.forEach((l, a) => {
5771
+ r[a] !== l && (o = o.split(l).join(r[a]));
5772
+ }), this.insertPastedHTML(o, !0);
5771
5773
  });
5772
5774
  }
5773
5775
  /** `deferred` means the insert is happening after an async hop, so the caret the
@@ -5781,9 +5783,9 @@ let rs = (j = class {
5781
5783
  }
5782
5784
  }, j.instanceCounter = 0, j.TBR_COLLAPSE_MAX = 992, j);
5783
5785
  const ls = Ye(
5784
- ({ value: d, defaultValue: t, onChange: e, onReady: i, className: s, style: n, ...l }, r) => {
5785
- const o = z(null), a = z(null), u = z(!1), p = z(d ?? t), m = z(null), v = z(e), b = z(i);
5786
- return v.current = e, b.current = i, Ge(r, () => ({
5786
+ ({ value: u, defaultValue: t, onChange: e, onReady: i, className: s, style: n, ...r }, o) => {
5787
+ const l = z(null), a = z(null), d = z(!1), p = z(u ?? t), m = z(null), v = z(e), b = z(i);
5788
+ return v.current = e, b.current = i, Ge(o, () => ({
5787
5789
  getContent: () => {
5788
5790
  var f;
5789
5791
  return ((f = a.current) == null ? void 0 : f.getContent()) ?? "";
@@ -5825,38 +5827,38 @@ const ls = Ye(
5825
5827
  return ((f = a.current) == null ? void 0 : f.getRevisions()) ?? [];
5826
5828
  }
5827
5829
  })), lt(() => {
5828
- if (!o.current) return;
5830
+ if (!l.current) return;
5829
5831
  const f = new rs({
5830
- target: o.current,
5832
+ target: l.current,
5831
5833
  initialContent: p.current,
5832
5834
  onChange: (y) => {
5833
5835
  var C;
5834
- u.current = !0, p.current = y, (C = v.current) == null || C.call(v, y);
5836
+ d.current = !0, p.current = y, (C = v.current) == null || C.call(v, y);
5835
5837
  },
5836
5838
  onReady: (y) => {
5837
5839
  var C;
5838
5840
  return (C = b.current) == null ? void 0 : C.call(b, y);
5839
5841
  },
5840
- ...l
5842
+ ...r
5841
5843
  });
5842
5844
  return a.current = f, () => {
5843
5845
  f.destroy(), a.current = null;
5844
5846
  };
5845
5847
  }, []), lt(() => {
5846
5848
  var f, y;
5847
- if (d !== void 0 && d !== p.current) {
5848
- if (u.current) {
5849
- u.current = !1;
5849
+ if (u !== void 0 && u !== p.current) {
5850
+ if (d.current) {
5851
+ d.current = !1;
5850
5852
  return;
5851
5853
  }
5852
- if ((f = o.current) != null && f.contains(document.activeElement)) {
5853
- m.current = d;
5854
+ if ((f = l.current) != null && f.contains(document.activeElement)) {
5855
+ m.current = u;
5854
5856
  return;
5855
5857
  }
5856
- p.current = d, (y = a.current) == null || y.setContent(d);
5858
+ p.current = u, (y = a.current) == null || y.setContent(u);
5857
5859
  }
5858
- }, [d]), lt(() => {
5859
- const f = o.current;
5860
+ }, [u]), lt(() => {
5861
+ const f = l.current;
5860
5862
  if (!f) return;
5861
5863
  const y = (C) => {
5862
5864
  var A;
@@ -5869,8 +5871,8 @@ const ls = Ye(
5869
5871
  return f.addEventListener("focusout", y), () => f.removeEventListener("focusout", y);
5870
5872
  }, []), lt(() => {
5871
5873
  var f;
5872
- l.language && ((f = a.current) == null || f.setLanguage(l.language));
5873
- }, [l.language]), /* @__PURE__ */ Je.jsx("div", { ref: o, className: s, style: n });
5874
+ r.language && ((f = a.current) == null || f.setLanguage(r.language));
5875
+ }, [r.language]), /* @__PURE__ */ Je.jsx("div", { ref: l, className: s, style: n });
5874
5876
  }
5875
5877
  );
5876
5878
  ls.displayName = "FableEditor";