fable-editor 1.3.1 → 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.
@@ -1,4 +1,4 @@
1
- const ct = {
1
+ const ht = {
2
2
  en: {
3
3
  dir: "ltr",
4
4
  file: "File",
@@ -384,10 +384,10 @@ const ct = {
384
384
  emcat_flags: "أعلام"
385
385
  }
386
386
  };
387
- function O(h) {
388
- return ct[h];
387
+ function F(h) {
388
+ return ht[h];
389
389
  }
390
- const ht = "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", dt = "file edit view insert format tools table help", pt = [
390
+ const dt = "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", pt = "file edit view insert format tools table help", ut = [
391
391
  ["Andale Mono", "andale mono,times"],
392
392
  ["Arial", "arial,helvetica,sans-serif"],
393
393
  ["Arial Black", "arial black,avant garde"],
@@ -407,7 +407,7 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
407
407
  ["Verdana", "verdana,geneva"],
408
408
  ["Webdings", "webdings"],
409
409
  ["Wingdings", "wingdings,zapf dingbats"]
410
- ], ut = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], mt = 1, gt = 100, W = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], V = ["1px", "2px", "4px", "6px", "8px", "12px"], j = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], X = [
410
+ ], mt = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], gt = 1, ft = 100, U = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], V = ["1px", "2px", "4px", "6px", "8px", "12px"], j = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], X = [
411
411
  ["plain", "Plain text"],
412
412
  ["html", "HTML/XML"],
413
413
  ["css", "CSS"],
@@ -433,7 +433,7 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
433
433
  ["h5", "heading5"],
434
434
  ["h6", "heading6"],
435
435
  ["pre", "pre"]
436
- ], ft = ["#F76707", "#4263EB", "#CC5DE8"], vt = [
436
+ ], vt = ["#F76707", "#4263EB", "#CC5DE8"], bt = [
437
437
  "#FFFFFF",
438
438
  "#F4F4F4",
439
439
  "#E8EAED",
@@ -459,7 +459,7 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
459
459
  "#8E24AA",
460
460
  "#C2185B",
461
461
  "#6D4C41"
462
- ], bt = [
462
+ ], yt = [
463
463
  {
464
464
  key: "chcat_currency",
465
465
  chars: [
@@ -799,7 +799,7 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
799
799
  "ة"
800
800
  ]
801
801
  }
802
- ], yt = [
802
+ ], xt = [
803
803
  {
804
804
  key: "emcat_smileys",
805
805
  chars: [
@@ -1524,7 +1524,7 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
1524
1524
  "🇲🇦"
1525
1525
  ]
1526
1526
  }
1527
- ], pe = [
1527
+ ], ge = [
1528
1528
  "©",
1529
1529
  "®",
1530
1530
  "™",
@@ -1810,7 +1810,7 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
1810
1810
  codesampleic: x(
1811
1811
  '<rect x="3.5" y="4" width="17" height="16" rx="2"/><path d="M3.5 8.5h17"/><path d="M9.5 12 7 14.25l2.5 2.25M14.5 12l2.5 2.25-2.5 2.25"/>'
1812
1812
  )
1813
- }, ue = (h) => `<span class="txt">${h}</span>`, xt = /* @__PURE__ */ new Set([
1813
+ }, fe = (h) => `<span class="txt">${h}</span>`, wt = /* @__PURE__ */ new Set([
1814
1814
  "p",
1815
1815
  "div",
1816
1816
  "span",
@@ -1917,20 +1917,20 @@ const ht = "undo redo | preview print | importword revhistory | fontfamily fonts
1917
1917
  th: ["width", "valign"],
1918
1918
  table: ["width", "cellpadding", "cellspacing"]
1919
1919
  };
1920
- function P(h) {
1920
+ function D(h) {
1921
1921
  const t = {}, e = h.getAttribute && h.getAttribute("style");
1922
1922
  return e && e.split(";").forEach((i) => {
1923
1923
  const s = i.indexOf(":");
1924
1924
  s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
1925
1925
  }), t;
1926
1926
  }
1927
- function wt(h) {
1927
+ function Tt(h) {
1928
1928
  return h.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, "");
1929
1929
  }
1930
- function Tt(h) {
1930
+ function St(h) {
1931
1931
  return /^[0-9]+[\.\)،]/.test(h) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(h) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(h) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(h) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(h) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(h) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(h) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
1932
1932
  }
1933
- function St(h) {
1933
+ function Et(h) {
1934
1934
  const t = (s) => {
1935
1935
  const l = (s.getAttribute("style") || "") + " " + (s.className || "");
1936
1936
  return /mso-list\s*:(?!\s*ignore)/i.test(l) || /MsoListParagraph/i.test(l);
@@ -1945,37 +1945,37 @@ function St(h) {
1945
1945
  i && l && i[i.length - 1] === l ? i.push(s) : (i = [s], e.push(i));
1946
1946
  }), e.forEach((s) => {
1947
1947
  const l = [], n = s[0];
1948
- s.forEach((o) => {
1949
- var y, C, S;
1950
- const a = +(((y = (o.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : y[1]) || 1), d = Array.from(o.querySelectorAll("span")).find(
1951
- (w) => /mso-list\s*:\s*ignore/i.test(w.getAttribute("style") || "")
1952
- ), p = d ? ((C = d.textContent) == null ? void 0 : C.trim()) || "" : (((S = o.textContent) == null ? void 0 : S.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: u, style: g } = Tt(p);
1948
+ s.forEach((r) => {
1949
+ var y, w, S;
1950
+ const a = +(((y = (r.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : y[1]) || 1), d = Array.from(r.querySelectorAll("span")).find(
1951
+ (C) => /mso-list\s*:\s*ignore/i.test(C.getAttribute("style") || "")
1952
+ ), p = d ? ((w = d.textContent) == null ? void 0 : w.trim()) || "" : (((S = r.textContent) == null ? void 0 : S.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: u, style: g } = St(p);
1953
1953
  for (d && d.remove(); l.length && l[l.length - 1].level > a; ) l.pop();
1954
1954
  if (!l.length || l[l.length - 1].level < a) {
1955
- const w = h.createElement(u ? "ol" : "ul");
1956
- if (u && g && (w.style.listStyleType = g), l.length) {
1955
+ const C = h.createElement(u ? "ol" : "ul");
1956
+ if (u && g && (C.style.listStyleType = g), l.length) {
1957
1957
  const k = l[l.length - 1].list;
1958
- (k.lastElementChild || k).appendChild(w);
1958
+ (k.lastElementChild || k).appendChild(C);
1959
1959
  } else
1960
- n.parentNode.insertBefore(w, n);
1961
- l.push({ list: w, level: a });
1960
+ n.parentNode.insertBefore(C, n);
1961
+ l.push({ list: C, level: a });
1962
1962
  }
1963
- const m = h.createElement("li"), f = P(o), b = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((w) => f[w]).map((w) => w + ":" + f[w]).join(";");
1964
- for (b && m.setAttribute("style", b), o.getAttribute("dir") && m.setAttribute("dir", o.getAttribute("dir")); o.firstChild; ) m.appendChild(o.firstChild);
1965
- l[l.length - 1].list.appendChild(m), o.remove();
1963
+ const m = h.createElement("li"), f = D(r), b = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((C) => f[C]).map((C) => C + ":" + f[C]).join(";");
1964
+ for (b && m.setAttribute("style", b), r.getAttribute("dir") && m.setAttribute("dir", r.getAttribute("dir")); r.firstChild; ) m.appendChild(r.firstChild);
1965
+ l[l.length - 1].list.appendChild(m), r.remove();
1966
1966
  });
1967
1967
  });
1968
1968
  }
1969
- function Et(h) {
1969
+ function Mt(h) {
1970
1970
  h.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
1971
1971
  for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
1972
1972
  t.remove();
1973
1973
  });
1974
1974
  }
1975
- function Mt(h) {
1975
+ function Lt(h) {
1976
1976
  h.querySelectorAll("table").forEach((t) => {
1977
1977
  const e = t;
1978
- P(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
1978
+ D(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
1979
1979
  }), h.querySelectorAll("[align]").forEach((t) => {
1980
1980
  const e = t, i = e.getAttribute("align").toLowerCase();
1981
1981
  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) => {
@@ -1999,12 +1999,12 @@ function Z(h, t) {
1999
1999
  }
2000
2000
  if (e.nodeType !== Node.ELEMENT_NODE) return;
2001
2001
  const i = e, s = i.tagName.toLowerCase();
2002
- if (!xt.has(s)) {
2002
+ if (!wt.has(s)) {
2003
2003
  if (s === "font") {
2004
- const r = t.createElement("span");
2005
- i.getAttribute("style") && r.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (r.style.color = i.getAttribute("color")), i.getAttribute("face") && (r.style.fontFamily = i.getAttribute("face"));
2004
+ const o = t.createElement("span");
2005
+ 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"));
2006
2006
  const a = i.getAttribute("size");
2007
- if (a && !r.style.fontSize) {
2007
+ if (a && !o.style.fontSize) {
2008
2008
  const d = {
2009
2009
  1: "8pt",
2010
2010
  2: "10pt",
@@ -2014,10 +2014,10 @@ function Z(h, t) {
2014
2014
  6: "24pt",
2015
2015
  7: "36pt"
2016
2016
  };
2017
- d[a] && (r.style.fontSize = d[a]);
2017
+ d[a] && (o.style.fontSize = d[a]);
2018
2018
  }
2019
- for (; i.firstChild; ) r.appendChild(i.firstChild);
2020
- i.replaceWith(r), Z(r, t);
2019
+ for (; i.firstChild; ) o.appendChild(i.firstChild);
2020
+ i.replaceWith(o), Z(o, t);
2021
2021
  return;
2022
2022
  }
2023
2023
  for (Z(i, t); i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
@@ -2025,31 +2025,31 @@ function Z(h, t) {
2025
2025
  return;
2026
2026
  }
2027
2027
  const l = /* @__PURE__ */ new Set([...G["*"] || [], ...G[s] || []]);
2028
- if (Array.from(i.attributes).forEach((r) => {
2029
- const a = r.name.toLowerCase();
2030
- a !== "style" && !l.has(a) && i.removeAttribute(r.name);
2028
+ if (Array.from(i.attributes).forEach((o) => {
2029
+ const a = o.name.toLowerCase();
2030
+ a !== "style" && !l.has(a) && i.removeAttribute(o.name);
2031
2031
  }), s === "a") {
2032
- const r = i.getAttribute("href") || "";
2033
- /^(https?:|mailto:|tel:|#)/i.test(r) || i.removeAttribute("href");
2032
+ const o = i.getAttribute("href") || "";
2033
+ /^(https?:|mailto:|tel:|#)/i.test(o) || i.removeAttribute("href");
2034
2034
  }
2035
2035
  if (s === "img") {
2036
- const r = i.getAttribute("src") || "";
2037
- if (!/^(https?:|data:image\/|blob:)/i.test(r)) {
2036
+ const o = i.getAttribute("src") || "";
2037
+ if (!/^(https?:|data:image\/|blob:)/i.test(o)) {
2038
2038
  const a = t.createElement("span");
2039
2039
  a.textContent = "[local image — paste it separately]", a.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(a);
2040
2040
  return;
2041
2041
  }
2042
2042
  }
2043
- const n = P(i), o = [];
2044
- for (const [r, a] of Object.entries(n))
2045
- Ct.has(r) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || r === "font-weight" && /^(400|normal)$/i.test(a) || r === "font-style" && /^normal$/i.test(a) || r === "text-decoration" && /^none$/i.test(a) || o.push(r + ":" + a));
2046
- if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), Z(i, t), s === "span" && !i.attributes.length) {
2043
+ const n = D(i), r = [];
2044
+ for (const [o, a] of Object.entries(n))
2045
+ Ct.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));
2046
+ if (r.length ? i.setAttribute("style", r.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), Z(i, t), s === "span" && !i.attributes.length) {
2047
2047
  for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
2048
2048
  i.remove();
2049
2049
  }
2050
2050
  });
2051
2051
  }
2052
- function Lt(h) {
2052
+ function Ht(h) {
2053
2053
  const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
2054
2054
  let i;
2055
2055
  for (; i = e.exec(h); ) {
@@ -2058,16 +2058,16 @@ function Lt(h) {
2058
2058
  let l;
2059
2059
  const n = /([^{}]+)\{([^}]*)\}/g;
2060
2060
  for (; l = n.exec(s); ) {
2061
- const o = l[2].split(";").map((r) => {
2062
- const a = r.indexOf(":");
2063
- return a < 1 ? null : [r.slice(0, a).trim().toLowerCase(), r.slice(a + 1).trim()];
2064
- }).filter((r) => !!r && !!r[1]);
2065
- o.length && l[1].split(",").map((r) => r.trim()).filter((r) => r && !r.startsWith("@")).forEach((r) => t.push({ sel: r, decls: o }));
2061
+ const r = l[2].split(";").map((o) => {
2062
+ const a = o.indexOf(":");
2063
+ return a < 1 ? null : [o.slice(0, a).trim().toLowerCase(), o.slice(a + 1).trim()];
2064
+ }).filter((o) => !!o && !!o[1]);
2065
+ r.length && l[1].split(",").map((o) => o.trim()).filter((o) => o && !o.startsWith("@")).forEach((o) => t.push({ sel: o, decls: r }));
2066
2066
  }
2067
2067
  }
2068
2068
  return t;
2069
2069
  }
2070
- function Ht(h, t) {
2070
+ function kt(h, t) {
2071
2071
  if (!t.length) return;
2072
2072
  const e = /* @__PURE__ */ new Map();
2073
2073
  t.forEach(({ sel: i, decls: s }) => {
@@ -2078,30 +2078,30 @@ function Ht(h, t) {
2078
2078
  return;
2079
2079
  }
2080
2080
  l.forEach((n) => {
2081
- let o = e.get(n);
2082
- o || (o = {}, e.set(n, o)), s.forEach(([r, a]) => {
2083
- o[r] = a;
2081
+ let r = e.get(n);
2082
+ r || (r = {}, e.set(n, r)), s.forEach(([o, a]) => {
2083
+ r[o] = a;
2084
2084
  });
2085
2085
  });
2086
2086
  }), e.forEach((i, s) => {
2087
- const l = P(s), n = s.hasAttribute("dir"), o = s.hasAttribute("align"), r = Object.entries(i).filter(([p]) => !(p in l || (p === "direction" || p === "unicode-bidi") && n || p === "text-align" && (o || n) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2088
- if (!r.length) return;
2089
- const a = r.map(([p, u]) => p + ":" + u).join(";"), d = s.getAttribute("style");
2087
+ const l = D(s), n = s.hasAttribute("dir"), r = s.hasAttribute("align"), o = Object.entries(i).filter(([p]) => !(p in l || (p === "direction" || p === "unicode-bidi") && n || p === "text-align" && (r || n) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2088
+ if (!o.length) return;
2089
+ const a = o.map(([p, u]) => p + ":" + u).join(";"), d = s.getAttribute("style");
2090
2090
  s.setAttribute("style", d ? a + ";" + d : a);
2091
2091
  });
2092
2092
  }
2093
- function lt(h) {
2093
+ function nt(h) {
2094
2094
  return h.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
2095
2095
  }
2096
- function kt(h) {
2096
+ function At(h) {
2097
2097
  const t = h.createTreeWalker(h.body, NodeFilter.SHOW_TEXT, null);
2098
2098
  let e;
2099
2099
  for (; e = t.nextNode(); )
2100
- /[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = lt(e.nodeValue || ""));
2100
+ /[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = nt(e.nodeValue || ""));
2101
2101
  }
2102
- function At(h, t = "ltr") {
2103
- const e = Lt(h), i = new DOMParser().parseFromString(wt(h), "text/html");
2104
- Ht(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && St(i), Et(i), Mt(i), Z(i.body, i), kt(i);
2102
+ function It(h, t = "ltr") {
2103
+ const e = Ht(h), i = new DOMParser().parseFromString(Tt(h), "text/html");
2104
+ kt(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && Et(i), Mt(i), Lt(i), Z(i.body, i), At(i);
2105
2105
  const s = (l) => {
2106
2106
  var n;
2107
2107
  return l && l.tagName === "P" && !((n = l.textContent) != null && n.trim()) && !l.querySelector("img,table");
@@ -2110,11 +2110,11 @@ function At(h, t = "ltr") {
2110
2110
  for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
2111
2111
  return i.body.innerHTML.trim();
2112
2112
  }
2113
- function It(h) {
2114
- const t = lt(h).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2113
+ function qt(h) {
2114
+ const t = nt(h).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2115
2115
  return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
2116
2116
  }
2117
- const qt = 10 * 1024 * 1024, ot = /^(https?:|data:image\/|blob:)/i;
2117
+ const Bt = 10 * 1024 * 1024, ot = /^(https?:|data:image\/|blob:)/i;
2118
2118
  function Y(h, t) {
2119
2119
  const e = [], i = "{\\" + t;
2120
2120
  let s = 0;
@@ -2124,27 +2124,27 @@ function Y(h, t) {
2124
2124
  s += i.length;
2125
2125
  continue;
2126
2126
  }
2127
- let n = 0, o = s;
2128
- for (; o < h.length; o++) {
2129
- const r = h[o];
2130
- if (r === "\\") {
2131
- o++;
2127
+ let n = 0, r = s;
2128
+ for (; r < h.length; r++) {
2129
+ const o = h[r];
2130
+ if (o === "\\") {
2131
+ r++;
2132
2132
  continue;
2133
2133
  }
2134
- if (r === "{") n++;
2135
- else if (r === "}" && (n--, !n))
2134
+ if (o === "{") n++;
2135
+ else if (o === "}" && (n--, !n))
2136
2136
  break;
2137
2137
  }
2138
- e.push({ start: s, end: o + 1, body: h.slice(s + i.length, o) }), s = o + 1;
2138
+ e.push({ start: s, end: r + 1, body: h.slice(s + i.length, r) }), s = r + 1;
2139
2139
  }
2140
2140
  return e;
2141
2141
  }
2142
- function Bt(h) {
2142
+ function Nt(h) {
2143
2143
  const t = new Uint8Array(h.length / 2);
2144
2144
  for (let e = 0; e < t.length; e++) t[e] = parseInt(h.substr(e * 2, 2), 16);
2145
2145
  return t;
2146
2146
  }
2147
- function F(h) {
2147
+ function O(h) {
2148
2148
  let t = "";
2149
2149
  for (let e = 0; e < h.length; e++) t += String.fromCharCode(h[e]);
2150
2150
  return btoa(t);
@@ -2156,20 +2156,20 @@ function K(h, t) {
2156
2156
  }
2157
2157
  return -1;
2158
2158
  }
2159
- const Nt = [137, 80, 78, 71], Rt = [255, 216, 255];
2160
- function Zt(h) {
2159
+ const Rt = [137, 80, 78, 71], Zt = [255, 216, 255];
2160
+ function Pt(h) {
2161
2161
  let t = null;
2162
2162
  if (/\\pngblip/.test(h) ? t = "image/png" : /\\jpegblip/.test(h) ? t = "image/jpeg" : (/\\wmetafile\d*/.test(h) || /\\emfblip/.test(h)) && (t = "metafile"), !t) return null;
2163
- let e = h.replace(/\{[^{}]*\}/g, "").replace(/\\[a-z]+-?\d*\s?/gi, "").replace(/[^0-9a-fA-F]/g, "");
2163
+ let e = h.replace(/\{[^{}]*\}/g, " ").replace(/\\[a-z]+-?\d*\s?/gi, " ").replace(/[^0-9a-fA-F]/g, "");
2164
2164
  if (e.length % 2 && (e = e.slice(0, -1)), !e) return null;
2165
- const i = Bt(e);
2165
+ const i = Nt(e);
2166
2166
  if (t === "metafile") {
2167
- const s = K(i, Nt);
2168
- if (s >= 0) return "data:image/png;base64," + F(i.slice(s));
2169
- const l = K(i, Rt);
2170
- return l >= 0 ? "data:image/jpeg;base64," + F(i.slice(l)) : null;
2167
+ const s = K(i, Rt);
2168
+ if (s >= 0) return "data:image/png;base64," + O(i.slice(s));
2169
+ const l = K(i, Zt);
2170
+ return l >= 0 ? "data:image/jpeg;base64," + O(i.slice(l)) : null;
2171
2171
  }
2172
- return "data:" + t + ";base64," + F(i);
2172
+ return "data:" + t + ";base64," + O(i);
2173
2173
  }
2174
2174
  function Dt(h) {
2175
2175
  if (!h || h.indexOf("\\pict") === -1) return [];
@@ -2177,35 +2177,66 @@ function Dt(h) {
2177
2177
  Y(h, "nonshppict").reverse().forEach((i) => {
2178
2178
  t = t.slice(0, i.start) + t.slice(i.end);
2179
2179
  });
2180
- let e = qt;
2180
+ let e = Bt;
2181
2181
  return Y(t, "pict").map((i) => {
2182
2182
  if (e <= 0) return null;
2183
- const s = Zt(i.body);
2183
+ const s = Pt(i.body);
2184
2184
  return s && (e -= s.length * 0.75), s;
2185
2185
  });
2186
2186
  }
2187
- function nt(h, t) {
2187
+ function J(h) {
2188
+ const t = h.match(/^\s*(-?[\d.]+)\s*(pt|px|in|cm|mm)?\s*$/i);
2189
+ if (!t) return null;
2190
+ const e = parseFloat(t[1]);
2191
+ if (!isFinite(e) || e <= 0) return null;
2192
+ 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;
2193
+ return Math.round(s);
2194
+ }
2195
+ function Ft(h, t) {
2196
+ const e = h.match(new RegExp("\\s" + t + `\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
2197
+ return e ? e[1] ?? e[2] ?? e[3] ?? "" : "";
2198
+ }
2199
+ function Ot(h) {
2200
+ if (!/<v:imagedata\b/i.test(h)) return h;
2201
+ const t = (i, s) => {
2202
+ const l = Ft(i, "src");
2203
+ if (!l) return null;
2204
+ const n = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2205
+ if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + n, "i").test(h)) return null;
2206
+ const r = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", o = J((r.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = J((r.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
2207
+ return '<img src="' + l.replace(/"/g, "&quot;") + '"' + (o ? ' width="' + o + '"' : "") + (a ? ' height="' + a + '"' : "") + ">";
2208
+ };
2209
+ let e = h.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi, (i, s) => {
2210
+ const l = s.match(/<v:imagedata\b[^>]*>/i);
2211
+ return l && t(l[0], s) || i;
2212
+ });
2213
+ return e = e.replace(/<v:shape\b[^>]*>[\s\S]*?<\/v:shape\s*>/gi, (i) => {
2214
+ const s = i.match(/<v:imagedata\b[^>]*>/i);
2215
+ return s && t(s[0], i) || i;
2216
+ }), e.replace(/<v:imagedata\b[^>]*>/gi, (i) => t(i, "") || i);
2217
+ }
2218
+ function rt(h, t) {
2188
2219
  if (!h || !t.length) return { html: h, injected: [] };
2189
2220
  const e = [];
2190
2221
  let i = 0;
2191
- return { html: h.replace(/<img\b[^>]*>/gi, (l) => {
2222
+ return { html: Ot(h).replace(/<img\b[^>]*>/gi, (l) => {
2192
2223
  const n = (l.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2193
2224
  if (ot.test(n)) return l;
2194
- const o = t[i++];
2195
- return o ? (e.push(o), /\ssrc\s*=\s*["']/i.test(l) ? l.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + o + '"') : l.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + o + '"')) : l;
2225
+ const r = t[i++];
2226
+ return r ? (e.push(r), /\ssrc\s*=\s*["']/i.test(l) ? l.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + r + '"') : l.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + r + '"')) : l;
2196
2227
  }), injected: e };
2197
2228
  }
2198
- function Pt(h, t) {
2199
- return !h || !t ? { html: h, injected: [] } : nt(h, Dt(t));
2229
+ function $t(h, t) {
2230
+ return !h || !t ? { html: h, injected: [] } : rt(h, Dt(t));
2200
2231
  }
2201
- function Ot(h) {
2232
+ function _t(h) {
2202
2233
  const t = h.match(/<img\b[^>]*>/gi);
2203
2234
  return t ? t.filter((e) => {
2204
2235
  const i = (e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2205
2236
  return !ot.test(i);
2206
2237
  }).length : 0;
2207
2238
  }
2208
- function Ft(h, t) {
2239
+ function zt(h, t) {
2209
2240
  const e = h.match(/^data:([^;,]+);base64,(.*)$/);
2210
2241
  if (!e) return null;
2211
2242
  const i = (e[1].split("/")[1] || "png").replace(/[^a-z0-9]/gi, "") || "png";
@@ -2217,34 +2248,34 @@ function Ft(h, t) {
2217
2248
  return null;
2218
2249
  }
2219
2250
  }
2220
- function $t(h) {
2251
+ function Wt(h) {
2221
2252
  const t = new DataView(h), e = /* @__PURE__ */ new Map();
2222
2253
  let i = -1;
2223
- for (let o = h.byteLength - 22; o >= Math.max(0, h.byteLength - 22 - 65535); o--)
2224
- if (t.getUint32(o, !0) === 101010256) {
2225
- i = o;
2254
+ for (let r = h.byteLength - 22; r >= Math.max(0, h.byteLength - 22 - 65535); r--)
2255
+ if (t.getUint32(r, !0) === 101010256) {
2256
+ i = r;
2226
2257
  break;
2227
2258
  }
2228
2259
  if (i < 0) throw new Error("EOCD not found");
2229
2260
  const s = t.getUint16(i + 10, !0);
2230
2261
  let l = t.getUint32(i + 16, !0);
2231
2262
  const n = new TextDecoder();
2232
- for (let o = 0; o < s && t.getUint32(l, !0) === 33639248; o++) {
2233
- const r = t.getUint16(l + 10, !0), a = t.getUint32(l + 20, !0), d = t.getUint16(l + 28, !0), p = t.getUint16(l + 30, !0), u = t.getUint16(l + 32, !0), g = t.getUint32(l + 42, !0), m = n.decode(new Uint8Array(h, l + 46, d));
2234
- e.set(m, { name: m, method: r, compSize: a, localOffset: g }), l += 46 + d + p + u;
2263
+ for (let r = 0; r < s && t.getUint32(l, !0) === 33639248; r++) {
2264
+ const o = t.getUint16(l + 10, !0), a = t.getUint32(l + 20, !0), d = t.getUint16(l + 28, !0), p = t.getUint16(l + 30, !0), u = t.getUint16(l + 32, !0), g = t.getUint32(l + 42, !0), m = n.decode(new Uint8Array(h, l + 46, d));
2265
+ e.set(m, { name: m, method: o, compSize: a, localOffset: g }), l += 46 + d + p + u;
2235
2266
  }
2236
2267
  return e;
2237
2268
  }
2238
- async function J(h, t) {
2269
+ async function tt(h, t) {
2239
2270
  const e = new DataView(h, t.localOffset);
2240
2271
  if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
2241
2272
  const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, n = new Uint8Array(h.slice(l, l + t.compSize));
2242
2273
  if (t.method === 0) return n;
2243
2274
  if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
2244
- const o = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2245
- return new Uint8Array(await new Response(o).arrayBuffer());
2275
+ const r = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2276
+ return new Uint8Array(await new Response(r).arrayBuffer());
2246
2277
  }
2247
- const tt = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), D = (h, t) => Array.from(h.children).filter((e) => e.localName === t), E = (h, ...t) => {
2278
+ const et = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), P = (h, t) => Array.from(h.children).filter((e) => e.localName === t), E = (h, ...t) => {
2248
2279
  let e = h;
2249
2280
  for (const i of t) {
2250
2281
  if (!e) return null;
@@ -2261,7 +2292,7 @@ const tt = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2261
2292
  if (!e) return !1;
2262
2293
  const i = T(e);
2263
2294
  return i !== "false" && i !== "0";
2264
- }, et = {
2295
+ }, it = {
2265
2296
  yellow: "#FFFF00",
2266
2297
  green: "#00FF00",
2267
2298
  cyan: "#00FFFF",
@@ -2278,7 +2309,7 @@ const tt = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2278
2309
  lightGray: "#D3D3D3",
2279
2310
  black: "#000000",
2280
2311
  white: "#FFFFFF"
2281
- }, _t = {
2312
+ }, Ut = {
2282
2313
  png: "image/png",
2283
2314
  jpg: "image/jpeg",
2284
2315
  jpeg: "image/jpeg",
@@ -2286,13 +2317,13 @@ const tt = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2286
2317
  bmp: "image/bmp",
2287
2318
  webp: "image/webp"
2288
2319
  };
2289
- function zt(h) {
2320
+ function Vt(h) {
2290
2321
  let t = "";
2291
2322
  for (let e = 0; e < h.length; e += 32768)
2292
2323
  t += String.fromCharCode(...h.subarray(e, e + 32768));
2293
2324
  return btoa(t);
2294
2325
  }
2295
- class Ut {
2326
+ class jt {
2296
2327
  constructor(t, e, i) {
2297
2328
  this.rels = t, this.images = e, this.numFmt = i;
2298
2329
  }
@@ -2305,9 +2336,9 @@ class Ut {
2305
2336
  if (l.localName === "p") {
2306
2337
  const n = this.paraList(l);
2307
2338
  if (n) {
2308
- const o = n.ilvl + 1;
2309
- for (; i.length > o; ) e += `</${i.pop()}>`;
2310
- for (i.length === o && i[o - 1] !== n.type && (e += `</${i.pop()}>`); i.length < o; )
2339
+ const r = n.ilvl + 1;
2340
+ for (; i.length > r; ) e += `</${i.pop()}>`;
2341
+ for (i.length === r && i[r - 1] !== n.type && (e += `</${i.pop()}>`); i.length < r; )
2311
2342
  e += `<${n.type}>`, i.push(n.type);
2312
2343
  e += `<li>${this.runsOf(l) || "<br>"}</li>`;
2313
2344
  continue;
@@ -2329,10 +2360,10 @@ class Ut {
2329
2360
  let s = "p";
2330
2361
  const l = /^Heading([1-6])$/i.exec(i);
2331
2362
  l ? s = "h" + l[1] : /^Title$/i.test(i) && (s = "h1");
2332
- const n = [], o = T(E(t, "pPr", "jc"));
2333
- o === "center" ? n.push("text-align:center") : o === "right" || o === "end" ? n.push("text-align:right") : (o === "both" || o === "distribute") && n.push("text-align:justify"), e && E(e, "bidi") && n.push("direction:rtl");
2334
- const r = this.runsOf(t), a = n.length ? ` style="${n.join(";")}"` : "";
2335
- return `<${s}${a}>${r || "<br>"}</${s}>`;
2363
+ const n = [], r = T(E(t, "pPr", "jc"));
2364
+ r === "center" ? n.push("text-align:center") : r === "right" || r === "end" ? n.push("text-align:right") : (r === "both" || r === "distribute") && n.push("text-align:justify"), e && E(e, "bidi") && n.push("direction:rtl");
2365
+ const o = this.runsOf(t), a = n.length ? ` style="${n.join(";")}"` : "";
2366
+ return `<${s}${a}>${o || "<br>"}</${s}>`;
2336
2367
  }
2337
2368
  runsOf(t) {
2338
2369
  let e = "";
@@ -2343,7 +2374,7 @@ class Ut {
2343
2374
  const l = T(i, "anchor");
2344
2375
  !s && l && (s = "#" + l);
2345
2376
  const n = this.runsOf(i);
2346
- e += s ? `<a href="${tt(s)}">${n}</a>` : n;
2377
+ e += s ? `<a href="${et(s)}">${n}</a>` : n;
2347
2378
  } else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
2348
2379
  return e;
2349
2380
  }
@@ -2351,27 +2382,27 @@ class Ut {
2351
2382
  const e = E(t, "rPr");
2352
2383
  let i = "";
2353
2384
  for (const p of Array.from(t.children))
2354
- p.localName === "t" ? i += tt(p.textContent || "") : p.localName === "br" || p.localName === "cr" ? i += "<br>" : p.localName === "tab" ? i += "&emsp;" : (p.localName === "drawing" || p.localName === "pict" || p.localName === "object") && (i += this.convertImage(p));
2385
+ p.localName === "t" ? i += et(p.textContent || "") : p.localName === "br" || p.localName === "cr" ? i += "<br>" : p.localName === "tab" ? i += "&emsp;" : (p.localName === "drawing" || p.localName === "pict" || p.localName === "object") && (i += this.convertImage(p));
2355
2386
  if (!i) return "";
2356
2387
  const s = [], l = T(e ? E(e, "color") : null);
2357
2388
  l && l !== "auto" && s.push("color:#" + l);
2358
2389
  const n = T(e ? E(e, "highlight") : null);
2359
- n && et[n] && s.push("background-color:" + et[n]);
2360
- const o = parseFloat(T(e ? E(e, "sz") : null));
2361
- o && s.push("font-size:" + Math.round(o / 2 * (4 / 3)) + "px");
2362
- const r = e ? E(e, "rFonts") : null, a = T(r, "ascii") || T(r, "cs");
2390
+ n && it[n] && s.push("background-color:" + it[n]);
2391
+ const r = parseFloat(T(e ? E(e, "sz") : null));
2392
+ r && s.push("font-size:" + Math.round(r / 2 * (4 / 3)) + "px");
2393
+ const o = e ? E(e, "rFonts") : null, a = T(o, "ascii") || T(o, "cs");
2363
2394
  a && s.push(`font-family:'${a}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), B(e, "b") && (i = `<strong>${i}</strong>`), B(e, "i") && (i = `<em>${i}</em>`), B(e, "u") && T(E(e, "u")) !== "none" && (i = `<u>${i}</u>`), B(e, "strike") && (i = `<s>${i}</s>`);
2364
2395
  const d = T(e ? E(e, "vertAlign") : null);
2365
2396
  return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
2366
2397
  }
2367
2398
  convertImage(t) {
2368
2399
  let e = "", i = 0;
2369
- const s = (o) => {
2370
- if (o.localName === "blip" && (e = e || T(o, "embed") || T(o, "link")), o.localName === "imagedata" && (e = e || T(o, "id")), o.localName === "extent") {
2371
- const r = parseFloat(o.getAttribute("cx") || "0");
2372
- r && (i = Math.round(r / 9525));
2400
+ const s = (r) => {
2401
+ if (r.localName === "blip" && (e = e || T(r, "embed") || T(r, "link")), r.localName === "imagedata" && (e = e || T(r, "id")), r.localName === "extent") {
2402
+ const o = parseFloat(r.getAttribute("cx") || "0");
2403
+ o && (i = Math.round(o / 9525));
2373
2404
  }
2374
- for (const r of Array.from(o.children)) s(r);
2405
+ for (const o of Array.from(r.children)) s(o);
2375
2406
  };
2376
2407
  if (s(t), !e) return "";
2377
2408
  const l = this.images.get(e);
@@ -2381,49 +2412,49 @@ class Ut {
2381
2412
  }
2382
2413
  convertTable(t) {
2383
2414
  let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
2384
- for (const i of D(t, "tr")) {
2415
+ for (const i of P(t, "tr")) {
2385
2416
  e += "<tr>";
2386
- for (const s of D(i, "tc")) {
2417
+ for (const s of P(i, "tc")) {
2387
2418
  const l = parseInt(T(E(s, "tcPr", "gridSpan")) || "1", 10) || 1, n = l > 1 ? ` colspan="${l}"` : "";
2388
- let o = "";
2389
- for (const r of Array.from(s.children))
2390
- r.localName === "p" ? o += this.convertPara(r) : r.localName === "tbl" && (o += this.convertTable(r));
2391
- e += `<td style="border:1px solid #b9c2cc"${n}>${o || "<br>"}</td>`;
2419
+ let r = "";
2420
+ for (const o of Array.from(s.children))
2421
+ o.localName === "p" ? r += this.convertPara(o) : o.localName === "tbl" && (r += this.convertTable(o));
2422
+ e += `<td style="border:1px solid #b9c2cc"${n}>${r || "<br>"}</td>`;
2392
2423
  }
2393
2424
  e += "</tr>";
2394
2425
  }
2395
2426
  return e + "</tbody></table>";
2396
2427
  }
2397
2428
  }
2398
- async function Wt(h) {
2399
- const t = h instanceof ArrayBuffer ? h : await h.arrayBuffer(), e = $t(t), i = new TextDecoder(), s = async (m) => {
2429
+ async function Xt(h) {
2430
+ const t = h instanceof ArrayBuffer ? h : await h.arrayBuffer(), e = Wt(t), i = new TextDecoder(), s = async (m) => {
2400
2431
  const f = e.get(m);
2401
- return f ? new DOMParser().parseFromString(i.decode(await J(t, f)), "application/xml") : null;
2432
+ return f ? new DOMParser().parseFromString(i.decode(await tt(t, f)), "application/xml") : null;
2402
2433
  }, l = await s("word/document.xml"), n = l == null ? void 0 : l.getElementsByTagName("*");
2403
- let o = null;
2434
+ let r = null;
2404
2435
  if (n) {
2405
2436
  for (const m of Array.from(n))
2406
2437
  if (m.localName === "body") {
2407
- o = m;
2438
+ r = m;
2408
2439
  break;
2409
2440
  }
2410
2441
  }
2411
- if (!o) throw new Error("word/document.xml missing or invalid");
2412
- const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
2442
+ if (!r) throw new Error("word/document.xml missing or invalid");
2443
+ const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
2413
2444
  if (d)
2414
2445
  for (const m of Array.from(d.getElementsByTagName("*"))) {
2415
2446
  if (m.localName !== "Relationship") continue;
2416
2447
  const f = m.getAttribute("Id") || "", b = m.getAttribute("Target") || "", y = m.getAttribute("Type") || "";
2417
- /hyperlink/i.test(y) ? r.set(f, b) : /image/i.test(y) && a.set(f, b);
2448
+ /hyperlink/i.test(y) ? o.set(f, b) : /image/i.test(y) && a.set(f, b);
2418
2449
  }
2419
2450
  const p = /* @__PURE__ */ new Map();
2420
2451
  for (const [m, f] of a) {
2421
2452
  const b = f.startsWith("/") ? f.slice(1) : "word/" + f.replace(/^\.\//, ""), y = e.get(b);
2422
2453
  if (!y) continue;
2423
- const C = (b.split(".").pop() || "").toLowerCase(), S = _t[C];
2454
+ const w = (b.split(".").pop() || "").toLowerCase(), S = Ut[w];
2424
2455
  if (S)
2425
2456
  try {
2426
- p.set(m, `data:${S};base64,${zt(await J(t, y))}`);
2457
+ p.set(m, `data:${S};base64,${Vt(await tt(t, y))}`);
2427
2458
  } catch {
2428
2459
  }
2429
2460
  }
@@ -2432,33 +2463,33 @@ async function Wt(h) {
2432
2463
  const m = /* @__PURE__ */ new Map(), f = Array.from(g.getElementsByTagName("*"));
2433
2464
  for (const b of f) {
2434
2465
  if (b.localName !== "abstractNum") continue;
2435
- const y = T(b, "abstractNumId"), C = D(b, "lvl").find((w) => T(w, "ilvl") === "0") || D(b, "lvl")[0], S = C ? T(E(C, "numFmt")) : "";
2466
+ const y = T(b, "abstractNumId"), w = P(b, "lvl").find((C) => T(C, "ilvl") === "0") || P(b, "lvl")[0], S = w ? T(E(w, "numFmt")) : "";
2436
2467
  m.set(y, S === "bullet" ? "ul" : "ol");
2437
2468
  }
2438
2469
  for (const b of f) {
2439
2470
  if (b.localName !== "num") continue;
2440
- const y = T(b, "numId"), C = T(E(b, "abstractNumId"));
2441
- u.set(y, m.get(C) || "ul");
2471
+ const y = T(b, "numId"), w = T(E(b, "abstractNumId"));
2472
+ u.set(y, m.get(w) || "ul");
2442
2473
  }
2443
2474
  }
2444
- return new Ut(r, p, u).convertBody(o);
2475
+ return new jt(o, p, u).convertBody(r);
2445
2476
  }
2446
- const Vt = ["nw", "ne", "sw", "se"], $ = ["img-left", "img-right", "img-top", "img-center"], _ = {
2477
+ const Qt = ["nw", "ne", "sw", "se"], $ = ["img-left", "img-right", "img-top", "img-center"], _ = {
2447
2478
  "img-left": "tplimgleft",
2448
2479
  "img-right": "tplimgright",
2449
2480
  "img-top": "tplimgtop",
2450
2481
  "img-center": "tplimgcenter"
2451
- }, jt = {
2482
+ }, Gt = {
2452
2483
  "img-left": c.tplleft,
2453
2484
  "img-right": c.tplright,
2454
2485
  "img-top": c.tpltop,
2455
2486
  "img-center": c.tplcenter
2456
- }, Xt = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
2457
- let M = null, A = null, z = 0, it = !1;
2487
+ }, Yt = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
2488
+ let M = null, A = null, z = 0, st = !1;
2458
2489
  function N() {
2459
2490
  clearTimeout(z), A = null, M && M.classList.remove("show");
2460
2491
  }
2461
- function Qt(h) {
2492
+ function Kt(h) {
2462
2493
  const t = h.dataset.tip;
2463
2494
  if (!t) return;
2464
2495
  A = h, clearTimeout(z);
@@ -2469,58 +2500,58 @@ function Qt(h) {
2469
2500
  const i = h.getBoundingClientRect(), s = M.offsetWidth, l = M.offsetHeight;
2470
2501
  let n = i.left + i.width / 2 - s / 2;
2471
2502
  n = Math.max(6, Math.min(n, innerWidth - s - 6));
2472
- let o = i.bottom + 7;
2473
- o + l > innerHeight - 6 && (o = i.top - l - 7), M.style.left = n + "px", M.style.top = o + "px";
2503
+ let r = i.bottom + 7;
2504
+ r + l > innerHeight - 6 && (r = i.top - l - 7), M.style.left = n + "px", M.style.top = r + "px";
2474
2505
  }, e);
2475
2506
  }
2476
- function Gt() {
2477
- it || (it = !0, document.addEventListener("mouseover", (h) => {
2507
+ function Jt() {
2508
+ st || (st = !0, document.addEventListener("mouseover", (h) => {
2478
2509
  const t = h.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
2479
- if (!e || !e.closest(Xt) || e.closest(".earea")) {
2510
+ if (!e || !e.closest(Yt) || e.closest(".earea")) {
2480
2511
  e !== A && N();
2481
2512
  return;
2482
2513
  }
2483
2514
  const i = e.getAttribute("title");
2484
- i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== A && Qt(e);
2515
+ i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== A && Kt(e);
2485
2516
  }), document.addEventListener("mouseout", (h) => {
2486
2517
  A && !A.contains(h.relatedTarget) && N();
2487
2518
  }), document.addEventListener("mousedown", N, !0), addEventListener("scroll", N, !0));
2488
2519
  }
2489
- const Yt = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, Kt = new RegExp("\\p{L}", "u"), Jt = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
2490
- function te(h) {
2520
+ const te = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, ee = new RegExp("\\p{L}", "u"), ie = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
2521
+ function se(h) {
2491
2522
  for (const t of h) {
2492
- if (Yt.test(t)) return "rtl";
2493
- if (Kt.test(t)) return "ltr";
2523
+ if (te.test(t)) return "rtl";
2524
+ if (ee.test(t)) return "ltr";
2494
2525
  }
2495
2526
  return null;
2496
2527
  }
2497
- const R = ["top", "right", "bottom", "left"], ee = /^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i, ie = /^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i, se = /^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i, le = /^border-(collapse|spacing|radius|image|block|inline|start|end)/i, oe = /^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/, ne = /^(inherit|initial|unset|revert|revert-layer)$/i;
2498
- function rt(h) {
2528
+ const R = ["top", "right", "bottom", "left"], le = /^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i, ne = /^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i, oe = /^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i, re = /^border-(collapse|spacing|radius|image|block|inline|start|end)/i, ae = /^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/, ce = /^(inherit|initial|unset|revert|revert-layer)$/i;
2529
+ function at(h) {
2499
2530
  const t = [];
2500
2531
  let e = 0, i = "";
2501
2532
  for (const s of h)
2502
2533
  s === "(" ? e++ : s === ")" && e--, e === 0 && /\s/.test(s) ? (i && t.push(i), i = "") : i += s;
2503
2534
  return i && t.push(i), t;
2504
2535
  }
2505
- function re(h) {
2536
+ function he(h) {
2506
2537
  const [t, e = t, i = t, s = e] = h;
2507
2538
  return [t, e, i, s];
2508
2539
  }
2509
- function ae(h) {
2540
+ function de(h) {
2510
2541
  const t = { width: "medium", style: "none", color: "" };
2511
- return rt(h).forEach((e) => {
2512
- ee.test(e) ? t.style = e.toLowerCase() : ie.test(e) ? t.width = e : t.color = e;
2542
+ return at(h).forEach((e) => {
2543
+ le.test(e) ? t.style = e.toLowerCase() : ne.test(e) ? t.width = e : t.color = e;
2513
2544
  }), t;
2514
2545
  }
2515
- function ce(h) {
2546
+ function pe(h) {
2516
2547
  return !h || /^currentcolor$/i.test(h) ? "" : /^windowtext$/i.test(h) ? "#000000" : h;
2517
2548
  }
2518
- function he(h) {
2549
+ function ue(h) {
2519
2550
  if (h.width === null && h.style === null && h.color === null) return "";
2520
2551
  const t = h.style ?? "solid";
2521
- return t === "none" || t === "hidden" || h.width && se.test(h.width) ? "none" : [h.width && h.width !== "medium" ? h.width : "", t, ce(h.color || "")].filter(Boolean).join(" ");
2552
+ return t === "none" || t === "hidden" || h.width && oe.test(h.width) ? "none" : [h.width && h.width !== "medium" ? h.width : "", t, pe(h.color || "")].filter(Boolean).join(" ");
2522
2553
  }
2523
- function de(h) {
2554
+ function me(h) {
2524
2555
  h.querySelectorAll("table,td,th").forEach((t) => {
2525
2556
  const e = t.getAttribute("style") || "";
2526
2557
  if (!/border/i.test(e)) return;
@@ -2537,12 +2568,12 @@ function de(h) {
2537
2568
  a.trim() && s.push(a.trim());
2538
2569
  return;
2539
2570
  }
2540
- const p = a.slice(0, d).trim().toLowerCase(), u = a.slice(d + 1).trim(), g = oe.exec(p);
2541
- if (!g || le.test(p)) {
2571
+ const p = a.slice(0, d).trim().toLowerCase(), u = a.slice(d + 1).trim(), g = ae.exec(p);
2572
+ if (!g || re.test(p)) {
2542
2573
  s.push(p + ":" + u);
2543
2574
  return;
2544
2575
  }
2545
- if (ne.test(u)) {
2576
+ if (ce.test(u)) {
2546
2577
  n = !0;
2547
2578
  return;
2548
2579
  }
@@ -2552,23 +2583,23 @@ function de(h) {
2552
2583
  if (m)
2553
2584
  i[m][f] = u;
2554
2585
  else {
2555
- const b = re(rt(u));
2556
- R.forEach((y, C) => {
2557
- i[y][f] = b[C];
2586
+ const b = he(at(u));
2587
+ R.forEach((y, w) => {
2588
+ i[y][f] = b[w];
2558
2589
  });
2559
2590
  }
2560
2591
  else {
2561
- const b = ae(u);
2592
+ const b = de(u);
2562
2593
  (m ? [m] : R.slice()).forEach((y) => {
2563
2594
  i[y] = { ...b };
2564
2595
  });
2565
2596
  }
2566
2597
  }), n || !l) return;
2567
- const o = R.map((a) => he(i[a])), r = s.slice();
2568
- o.every((a) => a && a === o[0]) ? r.push("border:" + o[0]) : R.forEach((a, d) => o[d] && r.push(`border-${a}:` + o[d])), t.setAttribute("style", r.join(";"));
2598
+ const r = R.map((a) => ue(i[a])), o = s.slice();
2599
+ r.every((a) => a && a === r[0]) ? o.push("border:" + r[0]) : R.forEach((a, d) => r[d] && o.push(`border-${a}:` + r[d])), t.setAttribute("style", o.join(";"));
2569
2600
  });
2570
2601
  }
2571
- function at(h) {
2602
+ function ct(h) {
2572
2603
  let t = "";
2573
2604
  return h.childNodes.forEach((e) => {
2574
2605
  if (e.nodeType === Node.TEXT_NODE)
@@ -2576,7 +2607,7 @@ function at(h) {
2576
2607
  else if (e.nodeType === Node.ELEMENT_NODE) {
2577
2608
  const i = e, s = (i.getAttribute("dir") || "").toLowerCase();
2578
2609
  if (s === "rtl" || s === "ltr") return;
2579
- t += at(i);
2610
+ t += ct(i);
2580
2611
  }
2581
2612
  }), t;
2582
2613
  }
@@ -2596,20 +2627,20 @@ const I = class I {
2596
2627
  statusbar: t.statusbar ?? !0,
2597
2628
  readonly: t.readonly ?? !1,
2598
2629
  draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
2599
- fontFamilyFormats: t.fontFamilyFormats ?? pt,
2630
+ fontFamilyFormats: t.fontFamilyFormats ?? ut,
2600
2631
  imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"],
2601
2632
  videoFileTypes: t.videoFileTypes ?? ["video/mp4", "video/webm", "video/ogg"]
2602
2633
  }, this.imageUploadHandler = t.imageUploadHandler, this.onImageUploadError = t.onImageUploadError, this.videoUploadHandler = t.videoUploadHandler, this.onVideoUploadError = t.onVideoUploadError, this.contentStyle = t.contentStyle, this.applyTheme(t), this.lang = this.options.language, this.draftStorageKey = "tmclone-draft:" + this.options.draftKey, this.initDOM(), this.bindEvents(), this.initUI(), this.recordRevision(), this.stampExistingImages(), this.options.onReady(this);
2603
2634
  }
2604
2635
  t(t) {
2605
- const e = O(this.lang)[t];
2636
+ const e = F(this.lang)[t];
2606
2637
  return typeof e == "string" ? e : e.join(",");
2607
2638
  }
2608
2639
  tArr(t) {
2609
- return O(this.lang)[t];
2640
+ return F(this.lang)[t];
2610
2641
  }
2611
2642
  dir() {
2612
- return O(this.lang).dir;
2643
+ return F(this.lang).dir;
2613
2644
  }
2614
2645
  /* ---------------------------------------------------------- DOM setup */
2615
2646
  initDOM() {
@@ -2622,7 +2653,7 @@ const I = class I {
2622
2653
  </span>
2623
2654
  `, this.sbHelp = this.statusbar.querySelector(".mid"), this.sbWords = this.statusbar.querySelector(".words");
2624
2655
  const e = this.statusbar.querySelector(".grip");
2625
- this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell), Gt(), this.options.statusbar || (this.statusbar.style.display = "none"), this.imgInput = document.createElement("input"), this.imgInput.type = "file", this.imgInput.accept = this.options.imageFileTypes.join(","), this.imgInput.style.display = "none", t.appendChild(this.imgInput), this.vidInput = document.createElement("input"), this.vidInput.type = "file", this.vidInput.accept = this.options.videoFileTypes.join(","), this.vidInput.style.display = "none", t.appendChild(this.vidInput), this.docInput = document.createElement("input"), this.docInput.type = "file", this.docInput.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", this.docInput.style.display = "none", t.appendChild(this.docInput);
2656
+ this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell), Jt(), this.options.statusbar || (this.statusbar.style.display = "none"), this.imgInput = document.createElement("input"), this.imgInput.type = "file", this.imgInput.accept = this.options.imageFileTypes.join(","), this.imgInput.style.display = "none", t.appendChild(this.imgInput), this.vidInput = document.createElement("input"), this.vidInput.type = "file", this.vidInput.accept = this.options.videoFileTypes.join(","), this.vidInput.style.display = "none", t.appendChild(this.vidInput), this.docInput = document.createElement("input"), this.docInput.type = "file", this.docInput.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", this.docInput.style.display = "none", t.appendChild(this.docInput);
2626
2657
  }
2627
2658
  /** Theme options land as CSS variables on the document root rather than the editor
2628
2659
  * shell, because dialogs, popups and floating context toolbars are appended to
@@ -2642,12 +2673,12 @@ const I = class I {
2642
2673
  let e = 0, i = 0;
2643
2674
  const s = (l) => {
2644
2675
  e = l.clientY, i = this.ed.offsetHeight, l.preventDefault();
2645
- const n = (r) => {
2646
- this.ed.style.height = Math.max(120, i + r.clientY - e) + "px";
2647
- }, o = () => {
2648
- window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", o);
2676
+ const n = (o) => {
2677
+ this.ed.style.height = Math.max(120, i + o.clientY - e) + "px";
2678
+ }, r = () => {
2679
+ window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", r);
2649
2680
  };
2650
- window.addEventListener("mousemove", n), window.addEventListener("mouseup", o);
2681
+ window.addEventListener("mousemove", n), window.addEventListener("mouseup", r);
2651
2682
  };
2652
2683
  t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
2653
2684
  }
@@ -2665,7 +2696,7 @@ const I = class I {
2665
2696
  }), this.on(this.ed, "keydown", (t) => {
2666
2697
  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);
2667
2698
  }), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
2668
- var l, n, o, r;
2699
+ var l, n, r, o;
2669
2700
  t.preventDefault();
2670
2701
  const e = t.target, i = (l = e.closest) == null ? void 0 : l.call(e, ".img-ph:not(.vid-ph)");
2671
2702
  if (i && this.ed.contains(i) && !this.options.readonly) {
@@ -2673,9 +2704,9 @@ const I = class I {
2673
2704
  a && this.readImageFileInto(a, i);
2674
2705
  return;
2675
2706
  }
2676
- const s = (o = e.closest) == null ? void 0 : o.call(e, ".vid-ph");
2707
+ const s = (r = e.closest) == null ? void 0 : r.call(e, ".vid-ph");
2677
2708
  if (s && this.ed.contains(s) && !this.options.readonly) {
2678
- const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("video/"));
2709
+ const a = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((d) => d.type.startsWith("video/"));
2679
2710
  a && this.readVideoFileInto(a, s);
2680
2711
  }
2681
2712
  }), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
@@ -2688,10 +2719,10 @@ const I = class I {
2688
2719
  l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(l)) : this.clearVphPlaceholderSel();
2689
2720
  const n = (g = e.closest) == null ? void 0 : g.call(e, ".tpl");
2690
2721
  n && this.ed.contains(n) && !this.options.readonly ? this.selectTemplate(n) : this.clearTplSel();
2691
- const o = (m = e.closest) == null ? void 0 : m.call(e, "pre.code-block");
2692
- o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(o)) : this.clearCodeSel();
2693
- const r = (f = e.closest) == null ? void 0 : f.call(e, "img");
2694
- r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectImage(r)) : this.clearImageHandles();
2722
+ const r = (m = e.closest) == null ? void 0 : m.call(e, "pre.code-block");
2723
+ r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(r)) : this.clearCodeSel();
2724
+ const o = (f = e.closest) == null ? void 0 : f.call(e, "img");
2725
+ o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectImage(o)) : this.clearImageHandles();
2695
2726
  const a = (b = e.closest) == null ? void 0 : b.call(e, "video, .video-embed");
2696
2727
  a && this.ed.contains(a) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(a)) : this.clearVidHandles();
2697
2728
  }), this.on(this.ed, "mouseover", (t) => {
@@ -2700,11 +2731,11 @@ const I = class I {
2700
2731
  const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
2701
2732
  e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
2702
2733
  }), this.on(this.ed, "mouseout", (t) => {
2703
- var s, l, n, o;
2734
+ var s, l, n, r;
2704
2735
  const e = (l = (s = t.target).closest) == null ? void 0 : l.call(s, "img");
2705
2736
  if (!e) return;
2706
2737
  const i = t.relatedTarget;
2707
- i && ((n = this.imgCtx) != null && n.contains(i) || this.imgHandles.some((r) => r.contains(i)) || ((o = i.closest) == null ? void 0 : o.call(i, "img")) === e) || this.scheduleImgHide();
2738
+ i && ((n = this.imgCtx) != null && n.contains(i) || this.imgHandles.some((o) => o.contains(i)) || ((r = i.closest) == null ? void 0 : r.call(i, "img")) === e) || this.scheduleImgHide();
2708
2739
  }), this.on(this.ed, "scroll", () => {
2709
2740
  this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx();
2710
2741
  }), this.onWin(
@@ -2786,41 +2817,42 @@ const I = class I {
2786
2817
  * content with no strongly-directional character anywhere falls back to the
2787
2818
  * editor's current direction. */
2788
2819
  getContentForEmail() {
2789
- const t = (o, r) => {
2790
- const a = (o.getAttribute("style") || "").trim();
2791
- o.setAttribute("style", a ? a.replace(/;?$/, "; ") + r : r);
2792
- }, e = document.createElement("div");
2793
- e.innerHTML = this.ed.innerHTML;
2794
- let i = null;
2795
- e.querySelectorAll("[dir]").forEach((o) => {
2796
- const r = (o.getAttribute("dir") || "").toLowerCase();
2797
- if (r !== "rtl" && r !== "ltr") return;
2798
- const a = r;
2799
- i || (i = a), /text-align\s*:/i.test(o.getAttribute("style") || "") || t(o, `text-align:${a === "rtl" ? "right" : "left"}`);
2800
- }), e.querySelectorAll(Jt).forEach((o) => {
2801
- const r = (o.getAttribute("dir") || "").toLowerCase();
2802
- if (r === "rtl" || r === "ltr") return;
2803
- const a = te(at(o));
2804
- if (!a) return;
2805
- i || (i = a), o.setAttribute("dir", a);
2806
- const d = /text-align\s*:/i.test(o.getAttribute("style") || "");
2807
- t(o, d ? `direction:${a}` : `direction:${a};text-align:${a === "rtl" ? "right" : "left"}`);
2820
+ const t = (o, a) => {
2821
+ const d = (o.getAttribute("style") || "").trim();
2822
+ o.setAttribute("style", d ? d.replace(/;?$/, "; ") + a : a);
2823
+ }, e = (o, a) => {
2824
+ const d = (o.getAttribute("style") || "").split(";").map((p) => p.trim()).filter((p) => p && !/^width\s*:/i.test(p));
2825
+ d.push(`width:${a}px`), o.setAttribute("style", d.join("; "));
2826
+ }, i = document.createElement("div");
2827
+ i.innerHTML = this.ed.innerHTML;
2828
+ let s = null;
2829
+ i.querySelectorAll("[dir]").forEach((o) => {
2830
+ const a = (o.getAttribute("dir") || "").toLowerCase();
2831
+ if (a !== "rtl" && a !== "ltr") return;
2832
+ const d = a;
2833
+ s || (s = d), /text-align\s*:/i.test(o.getAttribute("style") || "") || t(o, `text-align:${d === "rtl" ? "right" : "left"}`);
2834
+ }), i.querySelectorAll(ie).forEach((o) => {
2835
+ const a = (o.getAttribute("dir") || "").toLowerCase();
2836
+ if (a === "rtl" || a === "ltr") return;
2837
+ const d = se(ct(o));
2838
+ if (!d) return;
2839
+ s || (s = d), o.setAttribute("dir", d);
2840
+ const p = /text-align\s*:/i.test(o.getAttribute("style") || "");
2841
+ t(o, p ? `direction:${d}` : `direction:${d};text-align:${d === "rtl" ? "right" : "left"}`);
2808
2842
  });
2809
- const s = this.ed.querySelectorAll("img");
2810
- e.querySelectorAll("img").forEach((o, r) => {
2843
+ const l = this.ed.querySelectorAll("img");
2844
+ i.querySelectorAll("img").forEach((o, a) => {
2811
2845
  if (o.closest(".tpl-media")) return;
2812
- const a = s[r], d = Math.round((a == null ? void 0 : a.getBoundingClientRect().width) || 0);
2813
- d > 0 && !o.getAttribute("width") && o.setAttribute("width", String(d));
2814
- const p = o.getAttribute("style") || "";
2815
- d > 0 && !/(^|;)\s*width\s*:/i.test(p) && t(o, `width:${d}px`), /max-width\s*:/i.test(o.getAttribute("style") || "") || t(o, "max-width:100%"), /(^|;)\s*height\s*:/i.test(o.getAttribute("style") || "") || t(o, "height:auto");
2816
- }), de(e), e.querySelectorAll("table").forEach((o) => {
2817
- const r = o.getAttribute("style") || "";
2818
- /border-collapse\s*:/i.test(r) || t(o, "border-collapse:collapse"), !/border-spacing\s*:/i.test(r) && !o.hasAttribute("cellspacing") && o.setAttribute("cellspacing", "0");
2846
+ const d = l[a], p = Math.round((d == null ? void 0 : d.offsetWidth) || 0);
2847
+ p > 0 && (o.setAttribute("width", String(p)), o.removeAttribute("height"), e(o, p)), /max-width\s*:/i.test(o.getAttribute("style") || "") || t(o, "max-width:100%"), /(^|;)\s*height\s*:/i.test(o.getAttribute("style") || "") || t(o, "height:auto");
2848
+ }), me(i), i.querySelectorAll("table").forEach((o) => {
2849
+ const a = o.getAttribute("style") || "";
2850
+ /border-collapse\s*:/i.test(a) || t(o, "border-collapse:collapse"), !/border-spacing\s*:/i.test(a) && !o.hasAttribute("cellspacing") && o.setAttribute("cellspacing", "0");
2819
2851
  });
2820
- const l = i || this.ed.getAttribute("dir") || this.dir();
2821
- return e.querySelectorAll("table:not([dir])").forEach((o) => {
2822
- o.setAttribute("dir", l), /direction\s*:/i.test(o.getAttribute("style") || "") || t(o, `direction:${l}`);
2823
- }), `<div dir="${l}" style="direction:${l};text-align:${l === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
2852
+ const n = s || this.ed.getAttribute("dir") || this.dir();
2853
+ return i.querySelectorAll("table:not([dir])").forEach((o) => {
2854
+ o.setAttribute("dir", n), /direction\s*:/i.test(o.getAttribute("style") || "") || t(o, `direction:${n}`);
2855
+ }), `<div dir="${n}" style="direction:${n};text-align:${n === "rtl" ? "right" : "left"}">${i.innerHTML}</div>`;
2824
2856
  }
2825
2857
  setContent(t) {
2826
2858
  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();
@@ -2835,7 +2867,7 @@ const I = class I {
2835
2867
  this.ed.focus();
2836
2868
  }
2837
2869
  async importWordFile(t) {
2838
- const e = await Wt(t);
2870
+ const e = await Xt(t);
2839
2871
  this.recordRevision(), this.setContent(e), this.recordRevision();
2840
2872
  }
2841
2873
  restoreDraft() {
@@ -2946,24 +2978,24 @@ const I = class I {
2946
2978
  const l = document.createElement("button");
2947
2979
  l.type = "button", l.className = "revrestore", l.textContent = this.t("restore");
2948
2980
  let n = this.revisions.length - 1;
2949
- const o = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
2981
+ const r = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
2950
2982
  year: "numeric",
2951
2983
  month: "short",
2952
2984
  day: "numeric",
2953
2985
  hour: "2-digit",
2954
2986
  minute: "2-digit",
2955
2987
  second: "2-digit"
2956
- }), r = {}, a = (d) => {
2988
+ }), o = {}, a = (d) => {
2957
2989
  n = d, this.revisions.forEach((p, u) => {
2958
2990
  var g;
2959
- return (g = r[u]) == null ? void 0 : g.classList.toggle("on", u === d);
2991
+ return (g = o[u]) == null ? void 0 : g.classList.toggle("on", u === d);
2960
2992
  }), s.innerHTML = this.revisions[d].html, l.disabled = d === this.revisions.length - 1;
2961
2993
  };
2962
2994
  for (let d = this.revisions.length - 1; d >= 0; d--) {
2963
2995
  const p = this.revisions[d], u = document.createElement("button");
2964
2996
  u.type = "button";
2965
2997
  const g = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), m = g ? g.split(/\s+/).length : 0, f = d === this.revisions.length - 1;
2966
- u.innerHTML = `<span>${f ? this.t("currentver") : o.format(new Date(p.time))}</span><span class="wc">${m} ${this.t("words")}</span>`, u.addEventListener("click", () => a(d)), r[d] = u, i.appendChild(u);
2998
+ u.innerHTML = `<span>${f ? this.t("currentver") : r.format(new Date(p.time))}</span><span class="wc">${m} ${this.t("words")}</span>`, u.addEventListener("click", () => a(d)), o[d] = u, i.appendChild(u);
2967
2999
  }
2968
3000
  i.append(l), l.addEventListener("click", () => {
2969
3001
  const d = this.revisions[n];
@@ -3005,10 +3037,10 @@ const I = class I {
3005
3037
  l.className = "pop sub", l.dir = this.dir(), t.subBuild ? t.subBuild(l) : t.sub && this.menuItems(l, t.sub), l.addEventListener("mousedown", (a) => {
3006
3038
  a.target.tagName !== "INPUT" && a.preventDefault();
3007
3039
  }), document.body.appendChild(l);
3008
- let o = this.dir() === "rtl" ? i.left - l.offsetWidth + 2 : i.right - 2;
3009
- o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - l.offsetWidth - 8));
3010
- let r = i.top + scrollY - 6;
3011
- r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left = o + "px", l.style.top = r + "px", this.subStack.push(l);
3040
+ let r = this.dir() === "rtl" ? i.left - l.offsetWidth + 2 : i.right - 2;
3041
+ r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - l.offsetWidth - 8));
3042
+ let o = i.top + scrollY - 6;
3043
+ o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left = r + "px", l.style.top = o + "px", this.subStack.push(l);
3012
3044
  }
3013
3045
  popup(t, e, i) {
3014
3046
  if (this.openPop && this.popAnchor === t) {
@@ -3022,8 +3054,8 @@ const I = class I {
3022
3054
  s.style.minWidth = Math.max(160, Math.round(l.width)) + "px";
3023
3055
  let n = l.bottom + scrollY + 2;
3024
3056
  n = Math.max(8 + scrollY, Math.min(n, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = n + "px";
3025
- let r = this.dir() === "rtl" ? l.right - s.offsetWidth : l.left;
3026
- r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = r + "px", s.addEventListener("mousedown", (a) => {
3057
+ let o = this.dir() === "rtl" ? l.right - s.offsetWidth : l.left;
3058
+ o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = o + "px", s.addEventListener("mousedown", (a) => {
3027
3059
  a.target.tagName !== "INPUT" && a.preventDefault();
3028
3060
  }), this.openPop = s, this.popAnchor = t, t.classList.add("open");
3029
3061
  }
@@ -3067,7 +3099,7 @@ const I = class I {
3067
3099
  return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (n) => {
3068
3100
  n.preventDefault(), this.saveSel();
3069
3101
  }), l;
3070
- }, e = ft.map((s) => {
3102
+ }, e = vt.map((s) => {
3071
3103
  const l = t(this.t("forecolor"));
3072
3104
  return l.style.background = s, l.addEventListener("click", () => this.applyColor("fore", s)), l;
3073
3105
  }), i = t(this.t("forecolor"));
@@ -3103,7 +3135,7 @@ const I = class I {
3103
3135
  ] : [
3104
3136
  ["circle", c.ul_circle],
3105
3137
  ["square", c.ul_square]
3106
- ], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), n = window.getSelection(), o = n ? (a = this.closestBlock(n.anchorNode)) == null ? void 0 : a.closest(e) : null, r = o ? o.style.listStyleType : "";
3138
+ ], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), n = window.getSelection(), r = n ? (a = this.closestBlock(n.anchorNode)) == null ? void 0 : a.closest(e) : null, o = r ? r.style.listStyleType : "";
3107
3139
  this.popup(t, (d) => {
3108
3140
  this.menuItems(d, [
3109
3141
  {
@@ -3116,7 +3148,7 @@ const I = class I {
3116
3148
  const p = document.createElement("div");
3117
3149
  p.className = "mi-grid", s.forEach(([u, g], m) => {
3118
3150
  const f = document.createElement("button");
3119
- f.className = "mi" + (r === u ? " on" : ""), f.innerHTML = `<span class="ic">${g}</span><span class="prev">${l[m]}</span>`, f.addEventListener("click", () => {
3151
+ f.className = "mi" + (o === u ? " on" : ""), f.innerHTML = `<span class="ic">${g}</span><span class="prev">${l[m]}</span>`, f.addEventListener("click", () => {
3120
3152
  this.closePop(), this.setListStyle(e, u);
3121
3153
  }), p.appendChild(f);
3122
3154
  }), d.appendChild(p);
@@ -3127,7 +3159,7 @@ const I = class I {
3127
3159
  * table cell-background menu all show the identical popup. */
3128
3160
  buildPaletteInto(t, e, i) {
3129
3161
  const s = document.createElement("div");
3130
- s.className = "cpal", vt.forEach((p) => {
3162
+ s.className = "cpal", bt.forEach((p) => {
3131
3163
  const u = document.createElement("button");
3132
3164
  u.type = "button", u.style.background = p, u.title = p, u.addEventListener("click", () => {
3133
3165
  this.closePop(), i(p);
@@ -3135,10 +3167,10 @@ const I = class I {
3135
3167
  }), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3136
3168
  const l = document.createElement("div");
3137
3169
  l.className = "cfoot";
3138
- const n = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", o = document.createElement("div");
3139
- o.className = "cswatch cur", o.title = this.t("currentcolor"), o.style.background = n, o.innerHTML = c.check;
3140
- const r = document.createElement("button");
3141
- r.type = "button", r.className = "cswatch nocolor", r.title = this.t("removecolor"), r.addEventListener("click", () => {
3170
+ const n = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", r = document.createElement("div");
3171
+ r.className = "cswatch cur", r.title = this.t("currentcolor"), r.style.background = n, r.innerHTML = c.check;
3172
+ const o = document.createElement("button");
3173
+ o.type = "button", o.className = "cswatch nocolor", o.title = this.t("removecolor"), o.addEventListener("click", () => {
3142
3174
  this.closePop(), i(null);
3143
3175
  });
3144
3176
  const a = document.createElement("label");
@@ -3146,7 +3178,7 @@ const I = class I {
3146
3178
  const d = document.createElement("input");
3147
3179
  d.type = "color", d.value = n, d.addEventListener("change", () => {
3148
3180
  this.closePop(), i(d.value);
3149
- }), a.appendChild(d), l.append(o, r, a), t.appendChild(l);
3181
+ }), a.appendChild(d), l.append(r, o, a), t.appendChild(l);
3150
3182
  }
3151
3183
  colorMenu(t, e) {
3152
3184
  this.popup(
@@ -3176,7 +3208,7 @@ const I = class I {
3176
3208
  this.popup(t, (e) => this.menuItems(e, this.fontItems()));
3177
3209
  }
3178
3210
  sizeItems() {
3179
- return ut.map((t) => ({
3211
+ return mt.map((t) => ({
3180
3212
  label: t,
3181
3213
  on: this.currentSize() === t,
3182
3214
  action: () => this.applyFontSize(t)
@@ -3199,12 +3231,12 @@ const I = class I {
3199
3231
  const e = t.getRangeAt(0), i = e.startContainer;
3200
3232
  if (i.nodeType === 3) {
3201
3233
  const n = i.data;
3202
- let o = e.startOffset, r = e.startOffset;
3203
- for (; o > 0 && /\S/.test(n[o - 1]); ) o--;
3204
- for (; r < n.length && /\S/.test(n[r]); ) r++;
3205
- if (r > o) {
3234
+ let r = e.startOffset, o = e.startOffset;
3235
+ for (; r > 0 && /\S/.test(n[r - 1]); ) r--;
3236
+ for (; o < n.length && /\S/.test(n[o]); ) o++;
3237
+ if (o > r) {
3206
3238
  const a = document.createRange();
3207
- a.setStart(i, o), a.setEnd(i, r), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3239
+ a.setStart(i, r), a.setEnd(i, o), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3208
3240
  return;
3209
3241
  }
3210
3242
  }
@@ -3229,7 +3261,7 @@ const I = class I {
3229
3261
  this.saveSel(), this.refreshState(), this.onChange();
3230
3262
  }
3231
3263
  stepFontSize(t) {
3232
- const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(gt, Math.max(mt, e + t));
3264
+ const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(ft, Math.max(gt, e + t));
3233
3265
  i !== e && this.applyFontSize(i + "px");
3234
3266
  }
3235
3267
  /* ------------------------------------------------ case / spacing / link */
@@ -3240,12 +3272,12 @@ const I = class I {
3240
3272
  const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), l = [];
3241
3273
  let n;
3242
3274
  for (; n = s.nextNode(); ) i.intersectsNode(n) && l.push(n);
3243
- l.forEach((o) => {
3244
- const r = o === i.startContainer ? i.startOffset : 0, a = o === i.endContainer ? i.endOffset : o.data.length;
3245
- if (a <= r) return;
3246
- const d = o.data.slice(r, a);
3275
+ l.forEach((r) => {
3276
+ const o = r === i.startContainer ? i.startOffset : 0, a = r === i.endContainer ? i.endOffset : r.data.length;
3277
+ if (a <= o) return;
3278
+ const d = r.data.slice(o, a);
3247
3279
  let p = d;
3248
- t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (u, g, m) => g + m.toUpperCase()), o.replaceData(r, a - r, p);
3280
+ t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (u, g, m) => g + m.toUpperCase()), r.replaceData(o, a - o, p);
3249
3281
  }), this.saveSel(), this.refreshState(), this.onChange();
3250
3282
  }
3251
3283
  caseItems() {
@@ -3281,7 +3313,7 @@ const I = class I {
3281
3313
  ];
3282
3314
  }
3283
3315
  lineHeightMenu(t) {
3284
- this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", W)));
3316
+ this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", U)));
3285
3317
  }
3286
3318
  wordSpacingMenu(t) {
3287
3319
  this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing", V)));
@@ -3378,13 +3410,13 @@ const I = class I {
3378
3410
  const l = document.createElement("div");
3379
3411
  l.className = "tgridlbl", l.textContent = "1 × 1";
3380
3412
  const n = [];
3381
- for (let o = 0; o < 8; o++)
3382
- for (let r = 0; r < 10; r++) {
3413
+ for (let r = 0; r < 8; r++)
3414
+ for (let o = 0; o < 10; o++) {
3383
3415
  const a = document.createElement("span");
3384
- a.dataset.r = String(o), a.dataset.c = String(r), a.addEventListener("mouseenter", () => {
3385
- n.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= o && +d.dataset.c <= r)), l.textContent = r + 1 + " × " + (o + 1);
3416
+ a.dataset.r = String(r), a.dataset.c = String(o), a.addEventListener("mouseenter", () => {
3417
+ n.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= r && +d.dataset.c <= o)), l.textContent = o + 1 + " × " + (r + 1);
3386
3418
  }), a.addEventListener("click", () => {
3387
- this.closePop(), this.insertTable(o + 1, r + 1), e == null || e();
3419
+ this.closePop(), this.insertTable(r + 1, o + 1), e == null || e();
3388
3420
  }), n.push(a), s.appendChild(a);
3389
3421
  }
3390
3422
  i.append(s, l), t.appendChild(i);
@@ -3470,7 +3502,7 @@ const I = class I {
3470
3502
  }
3471
3503
  buildToolbar() {
3472
3504
  this.toolbar.innerHTML = "";
3473
- const t = this.options.toolbar === !0 ? ht : this.options.toolbar, e = this.buildToolbarRegistry();
3505
+ const t = this.options.toolbar === !0 ? dt : this.options.toolbar, e = this.buildToolbarRegistry();
3474
3506
  this.parseToolbarString(t).forEach((i) => {
3475
3507
  const s = [];
3476
3508
  i.forEach((l) => {
@@ -3479,8 +3511,8 @@ const I = class I {
3479
3511
  console.warn(`FableEditor: unknown toolbar item "${l}"`);
3480
3512
  return;
3481
3513
  }
3482
- const o = n();
3483
- Array.isArray(o) ? s.push(...o) : s.push(o);
3514
+ const r = n();
3515
+ Array.isArray(r) ? s.push(...r) : s.push(r);
3484
3516
  }), s.length && this.toolbar.appendChild(this.group(...s));
3485
3517
  }), this.tbrMore = this.tbtn(c.more, this.t("more"), () => {
3486
3518
  this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
@@ -3580,7 +3612,7 @@ const I = class I {
3580
3612
  { label: this.t("fontsize"), subBuild: (s) => this.menuItems(s, this.sizeItems()) },
3581
3613
  { label: this.t("blocks"), subBuild: (s) => this.menuItems(s, this.blockItems()) },
3582
3614
  { label: this.t("align"), subBuild: (s) => this.menuItems(s, this.alignItems()) },
3583
- { label: this.t("lineheight"), icon: c.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", W)) },
3615
+ { label: this.t("lineheight"), icon: c.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", U)) },
3584
3616
  { label: this.t("wordspacing"), icon: c.wordspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("wordSpacing", V)) },
3585
3617
  { label: this.t("letterspacing"), icon: c.letterspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("letterSpacing", j)) },
3586
3618
  "|",
@@ -3652,7 +3684,7 @@ const I = class I {
3652
3684
  { label: this.t("deltable"), icon: c.trash, action: () => this.tableOp("deltable") }
3653
3685
  ],
3654
3686
  help: [this.mItem("helpttl", c.helpic, () => this.helpDlg(), "Alt+0")]
3655
- }, e = this.options.menubar === !0 ? dt : this.options.menubar, i = /* @__PURE__ */ new Set();
3687
+ }, e = this.options.menubar === !0 ? pt : this.options.menubar, i = /* @__PURE__ */ new Set();
3656
3688
  e.split(/\s+/).filter(Boolean).forEach((s) => {
3657
3689
  if (i.has(s)) return;
3658
3690
  if (i.add(s), !t[s]) {
@@ -3667,20 +3699,20 @@ const I = class I {
3667
3699
  }
3668
3700
  /* ---------------------------------------------------------- table ops */
3669
3701
  tableOp(t) {
3670
- var r, a, d;
3702
+ var o, a, d;
3671
3703
  this.restoreSel();
3672
3704
  const e = window.getSelection();
3673
3705
  if (!e) return;
3674
- const i = ((r = this.closestBlock(e.anchorNode)) == null ? void 0 : r.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
3706
+ const i = ((o = this.closestBlock(e.anchorNode)) == null ? void 0 : o.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
3675
3707
  if (!i) return;
3676
- const s = i.parentElement, l = i.closest("table"), n = Array.from(s.children).indexOf(i), o = () => {
3708
+ const s = i.parentElement, l = i.closest("table"), n = Array.from(s.children).indexOf(i), r = () => {
3677
3709
  const p = s.cloneNode(!1);
3678
3710
  return Array.from(s.children).forEach((u) => {
3679
3711
  const g = document.createElement("td"), m = u.getAttribute("style");
3680
3712
  m && g.setAttribute("style", m), g.style.removeProperty("background-color"), g.innerHTML = "<br>", p.appendChild(g);
3681
3713
  }), p;
3682
3714
  };
3683
- if (t === "rowabove" && s.before(o()), t === "rowbelow" && s.after(o()), t === "delrow") {
3715
+ if (t === "rowabove" && s.before(r()), t === "rowbelow" && s.after(r()), t === "delrow") {
3684
3716
  const p = s.parentElement;
3685
3717
  s.remove(), p.querySelector("tr") || l.remove();
3686
3718
  }
@@ -3701,24 +3733,24 @@ const I = class I {
3701
3733
  if (!e) return;
3702
3734
  const i = e.parentElement, s = e.closest("table"), l = Array.from(i.children).indexOf(e);
3703
3735
  if (t === "rowup") {
3704
- const r = i.previousElementSibling;
3705
- r && r.before(i);
3736
+ const o = i.previousElementSibling;
3737
+ o && o.before(i);
3706
3738
  }
3707
3739
  if (t === "rowdown") {
3708
- const r = i.nextElementSibling;
3709
- r && r.after(i);
3740
+ const o = i.nextElementSibling;
3741
+ o && o.after(i);
3710
3742
  }
3711
- t === "colleft" && l > 0 && s.querySelectorAll("tr").forEach((r) => {
3712
- const a = r.children[l], d = r.children[l - 1];
3743
+ t === "colleft" && l > 0 && s.querySelectorAll("tr").forEach((o) => {
3744
+ const a = o.children[l], d = o.children[l - 1];
3713
3745
  a && d && d.before(a);
3714
- }), t === "colright" && s.querySelectorAll("tr").forEach((r) => {
3715
- const a = r.children[l], d = r.children[l + 1];
3746
+ }), t === "colright" && s.querySelectorAll("tr").forEach((o) => {
3747
+ const a = o.children[l], d = o.children[l + 1];
3716
3748
  a && d && d.after(a);
3717
3749
  });
3718
3750
  const n = document.createRange();
3719
3751
  n.selectNodeContents(e), n.collapse(!0);
3720
- const o = window.getSelection();
3721
- o && (o.removeAllRanges(), o.addRange(n)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
3752
+ const r = window.getSelection();
3753
+ r && (r.removeAllRanges(), r.addRange(n)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
3722
3754
  }
3723
3755
  /** Align the whole table via auto margins — same semantics as the align
3724
3756
  * field in the table-properties dialog. */
@@ -3756,24 +3788,24 @@ const I = class I {
3756
3788
  const t = this.tblActive;
3757
3789
  if (!t) return;
3758
3790
  let e, i, s, l, n;
3759
- const o = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "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 || "", u = d && d.style.padding ? parseFloat(d.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", m = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, b = t.style.marginRight, y = f === "auto" && b === "auto" ? "center" : f === "auto" ? "right" : b === "auto" && f === "0" ? "left" : "";
3791
+ 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", d = t.querySelector("td,th"), p = t.style.width || "", u = d && d.style.padding ? parseFloat(d.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", m = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, b = t.style.marginRight, y = f === "auto" && b === "auto" ? "center" : f === "auto" ? "right" : b === "auto" && f === "0" ? "left" : "";
3760
3792
  this.dialog(
3761
3793
  this.t("tablepropsttl"),
3762
- (C) => {
3763
- const S = (w, k) => {
3794
+ (w) => {
3795
+ const S = (C, k) => {
3764
3796
  const L = document.createElement("div");
3765
- L.style.cssText = o;
3797
+ L.style.cssText = r;
3766
3798
  const H = document.createElement("span");
3767
- H.style.cssText = r, H.textContent = this.t(w), L.append(H, k), C.appendChild(L);
3799
+ H.style.cssText = o, H.textContent = this.t(C), L.append(H, k), w.appendChild(L);
3768
3800
  };
3769
3801
  e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, S("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(u), S("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(g), S("tblcellspacing", s), l = document.createElement("input"), l.type = "number", l.min = "0", l.style.cssText = a, l.value = String(m), S("tblborder", l), n = document.createElement("select"), n.style.cssText = a, [
3770
3802
  ["", "alignnone"],
3771
3803
  ["left", "alignleft"],
3772
3804
  ["center", "aligncenter"],
3773
3805
  ["right", "alignright"]
3774
- ].forEach(([w, k]) => {
3806
+ ].forEach(([C, k]) => {
3775
3807
  const L = document.createElement("option");
3776
- L.value = w, L.textContent = this.t(k), w === y && (L.selected = !0), n.appendChild(L);
3808
+ L.value = C, L.textContent = this.t(k), C === y && (L.selected = !0), n.appendChild(L);
3777
3809
  }), S("tblalign", n);
3778
3810
  },
3779
3811
  [
@@ -3852,8 +3884,8 @@ const I = class I {
3852
3884
  let e, i, s, l, n;
3853
3885
  this.dialog(
3854
3886
  this.t("cellprops").replace("…", ""),
3855
- (o) => {
3856
- 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(
3887
+ (r) => {
3888
+ 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(
3857
3889
  [
3858
3890
  ["", this.t("alignnone")],
3859
3891
  ["left", this.t("alignleft")],
@@ -3861,7 +3893,7 @@ const I = class I {
3861
3893
  ["right", this.t("alignright")]
3862
3894
  ],
3863
3895
  t.style.textAlign || ""
3864
- ), this.formRow(o, this.t("tblalign"), s), l = this.formSelect(
3896
+ ), this.formRow(r, this.t("tblalign"), s), l = this.formSelect(
3865
3897
  [
3866
3898
  ["", this.t("alignnone")],
3867
3899
  ["top", this.t("valigntop")],
@@ -3869,7 +3901,7 @@ const I = class I {
3869
3901
  ["bottom", this.t("valignbottom")]
3870
3902
  ],
3871
3903
  t.style.verticalAlign || ""
3872
- ), this.formRow(o, this.t("valign"), l), n = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), n.wrap);
3904
+ ), this.formRow(r, this.t("valign"), l), n = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), n.wrap);
3873
3905
  },
3874
3906
  [
3875
3907
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3914,12 +3946,12 @@ const I = class I {
3914
3946
  alert(this.t("nocell"));
3915
3947
  return;
3916
3948
  }
3917
- const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), l = Array.from(i.rows).map((r) => r.cells[s]).filter(Boolean);
3918
- let n, o;
3949
+ const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), l = Array.from(i.rows).map((o) => o.cells[s]).filter(Boolean);
3950
+ let n, r;
3919
3951
  this.dialog(
3920
3952
  this.t("colprops").replace("…", ""),
3921
- (r) => {
3922
- n = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(r, this.t("tblwidth"), n), o = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), o.wrap);
3953
+ (o) => {
3954
+ n = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), n), r = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), r.wrap);
3923
3955
  },
3924
3956
  [
3925
3957
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3927,8 +3959,8 @@ const I = class I {
3927
3959
  label: this.t("save"),
3928
3960
  primary: !0,
3929
3961
  action: () => {
3930
- l.forEach((r) => {
3931
- this.setOrClear(r, "width", n.value.trim()), this.setOrClear(r, "background-color", o.fill.checked ? o.color.value : "");
3962
+ l.forEach((o) => {
3963
+ this.setOrClear(o, "width", n.value.trim()), this.setOrClear(o, "background-color", r.fill.checked ? r.color.value : "");
3932
3964
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
3933
3965
  }
3934
3966
  }
@@ -4000,7 +4032,7 @@ const I = class I {
4000
4032
  const e = document.createElement("div");
4001
4033
  e.className = "pv-box";
4002
4034
  const i = this.contentWidth();
4003
- 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);
4035
+ 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);
4004
4036
  });
4005
4037
  }
4006
4038
  /** Two-pane picker shared by the special-character map and the emoji map:
@@ -4011,29 +4043,29 @@ const I = class I {
4011
4043
  l.className = "chmap";
4012
4044
  const n = document.createElement("div");
4013
4045
  n.className = "chtabs";
4014
- const o = document.createElement("div");
4015
- o.className = "chpanel";
4016
4046
  const r = document.createElement("div");
4017
- r.className = "chgrid" + (i ? " emgrid" : ""), o.appendChild(r);
4047
+ r.className = "chpanel";
4048
+ const o = document.createElement("div");
4049
+ o.className = "chgrid" + (i ? " emgrid" : ""), r.appendChild(o);
4018
4050
  const a = (d) => {
4019
- n.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), r.innerHTML = "", e[d].chars.forEach((p) => {
4051
+ n.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), o.innerHTML = "", e[d].chars.forEach((p) => {
4020
4052
  const u = document.createElement("button");
4021
4053
  u.type = "button", u.textContent = p, u.onclick = () => {
4022
4054
  this.closeDlg(), this.exec("insertText", p);
4023
- }, r.appendChild(u);
4024
- }), o.scrollTop = 0;
4055
+ }, o.appendChild(u);
4056
+ }), r.scrollTop = 0;
4025
4057
  };
4026
4058
  e.forEach((d, p) => {
4027
4059
  const u = document.createElement("button");
4028
4060
  u.type = "button", u.textContent = this.t(d.key), u.addEventListener("click", () => a(p)), n.appendChild(u);
4029
- }), l.append(n, o), s.appendChild(l), a(0);
4061
+ }), l.append(n, r), s.appendChild(l), a(0);
4030
4062
  });
4031
4063
  }
4032
4064
  charMap() {
4033
- this.glyphPickerDlg(this.t("charmap").replace("…", ""), bt, !1);
4065
+ this.glyphPickerDlg(this.t("charmap").replace("…", ""), yt, !1);
4034
4066
  }
4035
4067
  emojiMap() {
4036
- this.glyphPickerDlg(this.t("emoji").replace("…", ""), yt, !0);
4068
+ this.glyphPickerDlg(this.t("emoji").replace("…", ""), xt, !0);
4037
4069
  }
4038
4070
  printDoc() {
4039
4071
  const t = window.open("", "_blank");
@@ -4102,10 +4134,10 @@ const I = class I {
4102
4134
  return;
4103
4135
  }
4104
4136
  i.disabled = !0, e.disabled = !0;
4105
- const o = new Image();
4106
- o.onload = () => this.replacePlaceholderWithImage(n, l, ""), o.onerror = () => {
4137
+ const r = new Image();
4138
+ r.onload = () => this.replacePlaceholderWithImage(n, l, ""), r.onerror = () => {
4107
4139
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4108
- }, o.src = l;
4140
+ }, r.src = l;
4109
4141
  };
4110
4142
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (l) => {
4111
4143
  l.key === "Enter" ? (l.preventDefault(), s()) : l.key === "Escape" && (l.stopPropagation(), this.renderPhCtxButtons());
@@ -4170,8 +4202,8 @@ const I = class I {
4170
4202
  if (!this.ed.contains(t) || t.closest(".tpl-media") || t.getAttribute("width") || t.getAttribute("height") || t.style.width || t.style.height) return i(!1);
4171
4203
  const l = t.naturalWidth;
4172
4204
  if (!l) return i(!1);
4173
- const n = this.contentWidth(), o = Math.round(n > 0 ? Math.min(l, n) : l);
4174
- t.setAttribute("width", String(o)), t.style.width = o + "px", t.style.height = "auto", i(!0);
4205
+ const n = this.contentWidth(), r = Math.round(n > 0 ? Math.min(l, n) : l);
4206
+ t.setAttribute("width", String(r)), t.style.width = r + "px", t.style.height = "auto", i(!0);
4175
4207
  };
4176
4208
  t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
4177
4209
  }
@@ -4252,16 +4284,16 @@ const I = class I {
4252
4284
  e.classList.add("err"), e.focus();
4253
4285
  return;
4254
4286
  }
4255
- const o = this.videoEmbedUrl(l);
4256
- if (o) {
4257
- this.replacePlaceholderWithEmbed(n, o);
4287
+ const r = this.videoEmbedUrl(l);
4288
+ if (r) {
4289
+ this.replacePlaceholderWithEmbed(n, r);
4258
4290
  return;
4259
4291
  }
4260
4292
  i.disabled = !0, e.disabled = !0;
4261
- const r = document.createElement("video");
4262
- r.preload = "metadata", r.onloadedmetadata = () => this.replacePlaceholderWithVideo(n, l, ""), r.onerror = () => {
4293
+ const o = document.createElement("video");
4294
+ o.preload = "metadata", o.onloadedmetadata = () => this.replacePlaceholderWithVideo(n, l, ""), o.onerror = () => {
4263
4295
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4264
- }, r.src = l;
4296
+ }, o.src = l;
4265
4297
  };
4266
4298
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (l) => {
4267
4299
  l.key === "Enter" ? (l.preventDefault(), s()) : l.key === "Escape" && (l.stopPropagation(), this.renderVphCtxButtons());
@@ -4332,16 +4364,16 @@ const I = class I {
4332
4364
  (d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
4333
4365
  }, s = (a) => {
4334
4366
  this.setVideoAlign(t, a), i();
4335
- }, l = t.style.float === "left", n = t.style.float === "right", o = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
4367
+ }, l = t.style.float === "left", n = t.style.float === "right", r = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, d, p, u) => {
4336
4368
  const g = this.ctxBtn(a, d, u);
4337
4369
  return g.classList.toggle("on", p), g;
4338
4370
  };
4339
4371
  return e.append(
4340
- r(c.alignleft, this.t("alignleft"), l, () => s("left")),
4341
- r(c.aligncenter, this.t("aligncenter"), o, () => s("center")),
4342
- r(c.alignright, this.t("alignright"), n, () => s("right")),
4372
+ o(c.alignleft, this.t("alignleft"), l, () => s("left")),
4373
+ o(c.aligncenter, this.t("aligncenter"), r, () => s("center")),
4374
+ o(c.alignright, this.t("alignright"), n, () => s("right")),
4343
4375
  this.ctxSep(),
4344
- r(c.trash, this.t("deletevideo"), !1, () => {
4376
+ o(c.trash, this.t("deletevideo"), !1, () => {
4345
4377
  t.remove(), this.clearVidHandles(), this.onChange();
4346
4378
  })
4347
4379
  ), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
@@ -4382,12 +4414,12 @@ const I = class I {
4382
4414
  videoDlg() {
4383
4415
  this.saveSel();
4384
4416
  let t, e, i, s, l, n;
4385
- const o = (a, d) => {
4417
+ const r = (a, d) => {
4386
4418
  const p = document.createElement("div");
4387
4419
  p.className = "dfield";
4388
4420
  const u = document.createElement("label");
4389
4421
  return u.textContent = this.t(a), p.append(u, d), p;
4390
- }, r = () => {
4422
+ }, o = () => {
4391
4423
  const a = document.createElement("input");
4392
4424
  return a.type = "url", a;
4393
4425
  };
@@ -4399,47 +4431,47 @@ const I = class I {
4399
4431
  const p = [], u = (f, b) => {
4400
4432
  const y = document.createElement("button");
4401
4433
  y.type = "button", y.textContent = this.t(f);
4402
- const C = document.createElement("div");
4403
- C.className = "dtabpanel", b(C);
4434
+ const w = document.createElement("div");
4435
+ w.className = "dtabpanel", b(w);
4404
4436
  const S = p.length;
4405
- p.push(C), y.addEventListener("click", () => g(S)), d.appendChild(y);
4437
+ p.push(w), y.addEventListener("click", () => g(S)), d.appendChild(y);
4406
4438
  }, g = (f) => {
4407
4439
  d.querySelectorAll("button").forEach((b, y) => b.classList.toggle("on", y === f)), p.forEach((b, y) => b.style.display = y === f ? "" : "none");
4408
4440
  };
4409
4441
  u("vidgeneral", (f) => {
4410
- t = r(), t.placeholder = this.t("videourlph");
4442
+ t = o(), t.placeholder = this.t("videourlph");
4411
4443
  const b = document.createElement("div");
4412
4444
  b.className = "drow";
4413
4445
  const y = document.createElement("button");
4414
4446
  y.type = "button", y.className = "txtbtn", y.textContent = this.t("uploadvideo");
4415
- const C = document.createElement("input");
4416
- C.type = "file", C.accept = this.options.videoFileTypes.join(","), C.style.display = "none", y.addEventListener("click", () => {
4417
- C.value = "", C.click();
4418
- }), C.addEventListener("change", () => {
4447
+ const w = document.createElement("input");
4448
+ w.type = "file", w.accept = this.options.videoFileTypes.join(","), w.style.display = "none", y.addEventListener("click", () => {
4449
+ w.value = "", w.click();
4450
+ }), w.addEventListener("change", () => {
4419
4451
  var L;
4420
- const w = (L = C.files) == null ? void 0 : L[0];
4421
- if (!w) return;
4452
+ const C = (L = w.files) == null ? void 0 : L[0];
4453
+ if (!C) return;
4422
4454
  y.disabled = !0, y.textContent = this.t("uploading");
4423
4455
  const k = (H) => {
4424
4456
  t.value = H, y.disabled = !1, y.textContent = this.t("uploadvideo");
4425
4457
  };
4426
4458
  if (this.videoUploadHandler)
4427
- this.videoUploadHandler(w).then(k).catch((H) => {
4428
- var U;
4429
- y.disabled = !1, y.textContent = this.t("uploadfailed"), (U = this.onVideoUploadError) == null || U.call(this, H, w);
4459
+ this.videoUploadHandler(C).then(k).catch((H) => {
4460
+ var W;
4461
+ y.disabled = !1, y.textContent = this.t("uploadfailed"), (W = this.onVideoUploadError) == null || W.call(this, H, C);
4430
4462
  });
4431
4463
  else {
4432
4464
  const H = new FileReader();
4433
- H.onload = () => k(H.result), H.readAsDataURL(w);
4465
+ H.onload = () => k(H.result), H.readAsDataURL(C);
4434
4466
  }
4435
- }), b.append(t, y, C), t.style.flex = "1", f.appendChild(o("vidsource", b));
4467
+ }), b.append(t, y, w), t.style.flex = "1", f.appendChild(r("vidsource", b));
4436
4468
  const S = document.createElement("div");
4437
- S.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", S.append(o("tblwidth", e), o("tblheight", i)), f.appendChild(S);
4469
+ S.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", S.append(r("tblwidth", e), r("tblheight", i)), f.appendChild(S);
4438
4470
  }), u("vidembed", (f) => {
4439
4471
  const b = document.createElement("p");
4440
4472
  b.textContent = this.t("vidembedhint"), b.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(b, s);
4441
4473
  }), u("vidadvanced", (f) => {
4442
- l = r(), n = r(), f.append(o("vidaltsource", l), o("vidposter", n));
4474
+ l = o(), n = o(), f.append(r("vidaltsource", l), r("vidposter", n));
4443
4475
  });
4444
4476
  const m = document.createElement("div");
4445
4477
  m.className = "dtabbody", p.forEach((f) => m.appendChild(f)), a.append(d, m), g(0), setTimeout(() => t.focus(), 0);
@@ -4525,39 +4557,39 @@ const I = class I {
4525
4557
  const n = l[1];
4526
4558
  if (/^\s|\s$/.test(n)) return;
4527
4559
  t.preventDefault();
4528
- const o = document.createRange();
4529
- o.setStart(i, e.anchorOffset - n.length - 1), o.setEnd(i, e.anchorOffset), o.deleteContents();
4530
- const r = document.createElement("code");
4531
- r.textContent = n, o.insertNode(r);
4560
+ const r = document.createRange();
4561
+ r.setStart(i, e.anchorOffset - n.length - 1), r.setEnd(i, e.anchorOffset), r.deleteContents();
4562
+ const o = document.createElement("code");
4563
+ o.textContent = n, r.insertNode(o);
4532
4564
  const a = document.createRange();
4533
- a.setStartAfter(r), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
4565
+ a.setStartAfter(o), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
4534
4566
  }
4535
4567
  /** Custom dropdown for dialog fields (a native <select> popup can't be styled):
4536
4568
  * a field-styled button showing the current choice that opens a floating,
4537
4569
  * scrollable option list. Read the current choice via `.value()`. */
4538
4570
  dlgSelect(t, e) {
4539
- var r;
4571
+ var o;
4540
4572
  let i = e;
4541
4573
  const s = document.createElement("div");
4542
4574
  s.className = "dsel";
4543
4575
  const l = document.createElement("button");
4544
4576
  l.type = "button", l.className = "dsel-btn";
4545
4577
  const n = document.createElement("span");
4546
- n.className = "lbl", n.textContent = ((r = t.find(([a]) => a === e)) == null ? void 0 : r[1]) || "", l.append(n), l.insertAdjacentHTML("beforeend", c.chev);
4547
- const o = document.createElement("div");
4548
- return o.className = "dsel-list", t.forEach(([a, d]) => {
4578
+ n.className = "lbl", n.textContent = ((o = t.find(([a]) => a === e)) == null ? void 0 : o[1]) || "", l.append(n), l.insertAdjacentHTML("beforeend", c.chev);
4579
+ const r = document.createElement("div");
4580
+ return r.className = "dsel-list", t.forEach(([a, d]) => {
4549
4581
  const p = document.createElement("button");
4550
4582
  p.type = "button", p.textContent = d, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
4551
- i = a, n.textContent = d, o.querySelectorAll("button").forEach((u) => u.classList.toggle("on", u === p)), s.classList.remove("open"), l.focus();
4552
- }), o.appendChild(p);
4583
+ i = a, n.textContent = d, r.querySelectorAll("button").forEach((u) => u.classList.toggle("on", u === p)), s.classList.remove("open"), l.focus();
4584
+ }), r.appendChild(p);
4553
4585
  }), l.addEventListener("click", () => {
4554
4586
  var a;
4555
- s.classList.toggle("open"), s.classList.contains("open") && ((a = o.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
4587
+ s.classList.toggle("open"), s.classList.contains("open") && ((a = r.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
4556
4588
  }), s.addEventListener("focusout", (a) => {
4557
4589
  s.contains(a.relatedTarget) || s.classList.remove("open");
4558
4590
  }), s.addEventListener("keydown", (a) => {
4559
4591
  a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), l.focus());
4560
- }), s.append(l, o), { el: s, value: () => i };
4592
+ }), s.append(l, r), { el: s, value: () => i };
4561
4593
  }
4562
4594
  /** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
4563
4595
  * paste or type code into. Inserts a non-editable <pre class="code-block">
@@ -4568,11 +4600,11 @@ const I = class I {
4568
4600
  this.dialog(
4569
4601
  this.t("codedlgttl"),
4570
4602
  (s) => {
4571
- var o;
4603
+ var r;
4572
4604
  const l = document.createElement("div");
4573
4605
  l.className = "dfield";
4574
4606
  const n = document.createElement("label");
4575
- n.textContent = this.t("codelang"), e = this.dlgSelect(X, (t == null ? void 0 : t.dataset.lang) || "plain"), l.append(n, 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(l, i), setTimeout(() => i.focus(), 0);
4607
+ n.textContent = this.t("codelang"), e = this.dlgSelect(X, (t == null ? void 0 : t.dataset.lang) || "plain"), l.append(n, 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(l, i), setTimeout(() => i.focus(), 0);
4576
4608
  },
4577
4609
  [
4578
4610
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4580,13 +4612,13 @@ const I = class I {
4580
4612
  label: this.t("save"),
4581
4613
  primary: !0,
4582
4614
  action: () => {
4583
- var o;
4584
- const s = i.value.replace(/\s+$/, ""), l = e.value(), n = ((o = X.find(([r]) => r === l)) == null ? void 0 : o[1]) || l;
4615
+ var r;
4616
+ const s = i.value.replace(/\s+$/, ""), l = e.value(), n = ((r = X.find(([o]) => o === l)) == null ? void 0 : r[1]) || l;
4585
4617
  if (this.closeDlg(), !!s.trim()) {
4586
4618
  if (t) {
4587
4619
  t.dataset.lang = l, t.setAttribute("data-lang-label", n);
4588
- const r = t.querySelector("code") || t;
4589
- r.textContent = s, this.clearCodeSel(), this.onChange();
4620
+ const o = t.querySelector("code") || t;
4621
+ o.textContent = s, this.clearCodeSel(), this.onChange();
4590
4622
  return;
4591
4623
  }
4592
4624
  this.restoreSel(), document.execCommand(
@@ -4649,8 +4681,8 @@ const I = class I {
4649
4681
  /** Miniature div-based mockup of a layout, mirroring what the block looks
4650
4682
  like in the editor: grey box = image slot, bars = heading/paragraph. */
4651
4683
  tplPreviewHTML(t) {
4652
- const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (r) => `<span class="pv-l" style="width:${r}%"></span>`, l = (r) => `<span class="pv-col">${r}</span>`, n = (r) => `<span class="pv-row">${r}</span>`, o = l(i + s(100) + s(88));
4653
- return t === "img-left" ? `<span class="pv">${n(e + o)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${n(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>`;
4684
+ const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (o) => `<span class="pv-l" style="width:${o}%"></span>`, l = (o) => `<span class="pv-col">${o}</span>`, n = (o) => `<span class="pv-row">${o}</span>`, r = l(i + s(100) + s(88));
4685
+ return t === "img-left" ? `<span class="pv">${n(e + r)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${n(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>`;
4654
4686
  }
4655
4687
  buildTemplatePickInto(t, e) {
4656
4688
  const i = document.createElement("div");
@@ -4676,7 +4708,7 @@ const I = class I {
4676
4708
  renderTplCtxButtons() {
4677
4709
  const t = this.tplCtx, e = this.tplActive;
4678
4710
  !t || !e || (t.innerHTML = "", $.forEach((i) => {
4679
- const s = this.ctxBtn(jt[i], this.t(_[i]), () => this.setTplLayout(i));
4711
+ const s = this.ctxBtn(Gt[i], this.t(_[i]), () => this.setTplLayout(i));
4680
4712
  s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
4681
4713
  }), t.append(this.ctxSep(), this.ctxBtn(c.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
4682
4714
  }
@@ -4742,8 +4774,8 @@ const I = class I {
4742
4774
  return;
4743
4775
  }
4744
4776
  this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
4745
- const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), n = t === "row" ? l.left : s.left, o = t === "row" ? l.top : i.top, r = t === "row" ? l.width : s.width, a = t === "row" ? l.height : i.height;
4746
- this.tblOpMark.style.left = n + scrollX + "px", this.tblOpMark.style.top = o + scrollY + "px", this.tblOpMark.style.width = r + "px", this.tblOpMark.style.height = a + "px";
4777
+ const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), n = t === "row" ? l.left : s.left, r = t === "row" ? l.top : i.top, o = t === "row" ? l.width : s.width, a = t === "row" ? l.height : i.height;
4778
+ this.tblOpMark.style.left = n + scrollX + "px", this.tblOpMark.style.top = r + scrollY + "px", this.tblOpMark.style.width = o + "px", this.tblOpMark.style.height = a + "px";
4747
4779
  }
4748
4780
  /** Lowest allowed top for floating context toolbars — keeps them from
4749
4781
  covering the editor menubar/toolbar when the target sits on the first line. */
@@ -4791,18 +4823,18 @@ const I = class I {
4791
4823
  }
4792
4824
  const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY;
4793
4825
  if (this.tblCorner && (this.tblCorner.style.top = n - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : l - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
4794
- const r = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
4795
- let d = s + (l - s) / 2 - r / 2;
4796
- d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - r - 8));
4826
+ const o = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
4827
+ let d = s + (l - s) / 2 - o / 2;
4828
+ d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - o - 8));
4797
4829
  let p = i - a - 8;
4798
4830
  p < this.ctxMinTop() && (p = n + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
4799
4831
  }
4800
- this.tblColBars.forEach((r) => r.remove()), this.tblColBars = [];
4801
- const o = this.tblActive.rows[0];
4802
- if (o)
4803
- for (let r = 0; r < o.cells.length - 1; r++) {
4804
- const a = o.cells[r].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
4805
- p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = n - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (u) => this.startColBarDrag(u, r)), this.tblColBars.push(p);
4832
+ this.tblColBars.forEach((o) => o.remove()), this.tblColBars = [];
4833
+ const r = this.tblActive.rows[0];
4834
+ if (r)
4835
+ for (let o = 0; o < r.cells.length - 1; o++) {
4836
+ const a = r.cells[o].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
4837
+ p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = n - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (u) => this.startColBarDrag(u, o)), this.tblColBars.push(p);
4806
4838
  }
4807
4839
  this.positionCellMarker(), this.positionOpMark();
4808
4840
  }
@@ -4821,26 +4853,26 @@ const I = class I {
4821
4853
  if (!e) return;
4822
4854
  const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, l = e.getBoundingClientRect().width;
4823
4855
  e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((n) => {
4824
- const o = (a) => {
4856
+ const r = (a) => {
4825
4857
  const d = i ? -(a.clientX - s) : a.clientX - s;
4826
4858
  e.style.width = Math.max(60, Math.round(l + d)) + "px", this.positionTableHandles();
4827
- }, r = () => {
4828
- window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", r), n(), this.onChange();
4859
+ }, o = () => {
4860
+ window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", o), n(), this.onChange();
4829
4861
  };
4830
- window.addEventListener("mousemove", o), window.addEventListener("mouseup", r);
4862
+ window.addEventListener("mousemove", r), window.addEventListener("mouseup", o);
4831
4863
  });
4832
4864
  }
4833
4865
  startColBarDrag(t, e) {
4834
4866
  t.preventDefault(), t.stopPropagation();
4835
4867
  const i = this.tblActive;
4836
4868
  if (!i) return;
4837
- const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), n = l.map((p) => p.cells[e]).filter(Boolean), o = l.map((p) => p.cells[e + 1]).filter(Boolean);
4838
- if (!n.length || !o.length) return;
4839
- const r = t.clientX, a = n[0].getBoundingClientRect().width, d = o[0].getBoundingClientRect().width;
4869
+ const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), n = l.map((p) => p.cells[e]).filter(Boolean), r = l.map((p) => p.cells[e + 1]).filter(Boolean);
4870
+ if (!n.length || !r.length) return;
4871
+ const o = t.clientX, a = n[0].getBoundingClientRect().width, d = r[0].getBoundingClientRect().width;
4840
4872
  i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
4841
4873
  const u = (m) => {
4842
- const f = (s ? -1 : 1) * (m.clientX - r);
4843
- n.forEach((b) => b.style.width = Math.max(24, Math.round(a + f)) + "px"), o.forEach((b) => b.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
4874
+ const f = (s ? -1 : 1) * (m.clientX - o);
4875
+ n.forEach((b) => b.style.width = Math.max(24, Math.round(a + f)) + "px"), r.forEach((b) => b.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
4844
4876
  }, g = () => {
4845
4877
  window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", g), p(), this.onChange();
4846
4878
  };
@@ -4859,7 +4891,7 @@ const I = class I {
4859
4891
  this.cancelImgHide(), this.imgHandles.forEach((i) => i.remove()), this.imgHandles = [], (t = this.imgCtx) == null || t.remove(), this.imgCtx = null, (e = this.imgActive) == null || e.classList.remove("img-selected"), this.imgActive = null;
4860
4892
  }
4861
4893
  selectImage(t) {
4862
- this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Vt.map((e) => {
4894
+ this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Qt.map((e) => {
4863
4895
  const i = document.createElement("div");
4864
4896
  return i.className = "img-handle img-handle-" + e, i.dataset.corner = e, i.addEventListener("mousedown", (s) => this.startImageResizeDrag(s, e)), i.addEventListener("mouseenter", () => this.cancelImgHide()), i.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(i), i;
4865
4897
  }), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
@@ -4873,30 +4905,30 @@ const I = class I {
4873
4905
  (d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
4874
4906
  }, s = (a) => {
4875
4907
  this.setImageAlign(t, a), i();
4876
- }, l = t.style.float === "left", n = t.style.float === "right", o = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
4908
+ }, l = t.style.float === "left", n = t.style.float === "right", r = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, d, p, u) => {
4877
4909
  const g = this.ctxBtn(a, d, u);
4878
4910
  return g.classList.toggle("on", p), g;
4879
4911
  };
4880
4912
  return e.append(
4881
- r(c.alignleft, this.t("alignleft"), l, () => s("left")),
4882
- r(c.aligncenter, this.t("aligncenter"), o, () => s("center")),
4883
- r(c.alignright, this.t("alignright"), n, () => s("right")),
4913
+ o(c.alignleft, this.t("alignleft"), l, () => s("left")),
4914
+ o(c.aligncenter, this.t("aligncenter"), r, () => s("center")),
4915
+ o(c.alignright, this.t("alignright"), n, () => s("right")),
4884
4916
  this.ctxSep(),
4885
- r(c.rotateleft, this.t("rotateleft"), !1, () => {
4917
+ o(c.rotateleft, this.t("rotateleft"), !1, () => {
4886
4918
  this.rotateImage(t, -90), i();
4887
4919
  }),
4888
- r(c.rotateright, this.t("rotateright"), !1, () => {
4920
+ o(c.rotateright, this.t("rotateright"), !1, () => {
4889
4921
  this.rotateImage(t, 90), i();
4890
4922
  }),
4891
4923
  this.ctxSep(),
4892
- r(c.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
4924
+ o(c.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
4893
4925
  this.flipImage(t, "x"), i();
4894
4926
  }),
4895
- r(c.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
4927
+ o(c.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
4896
4928
  this.flipImage(t, "y"), i();
4897
4929
  }),
4898
4930
  this.ctxSep(),
4899
- r(c.trash, this.t("deleteimg"), !1, () => {
4931
+ o(c.trash, this.t("deleteimg"), !1, () => {
4900
4932
  const a = t.closest(".tpl-media");
4901
4933
  a && this.ed.contains(a) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
4902
4934
  })
@@ -4928,14 +4960,14 @@ const I = class I {
4928
4960
  sw: [i, l],
4929
4961
  se: [s, l]
4930
4962
  };
4931
- if (this.imgHandles.forEach((o) => {
4932
- const [r, a] = n[o.dataset.corner];
4933
- o.style.left = r - 5 + "px", o.style.top = a - 5 + "px";
4963
+ if (this.imgHandles.forEach((r) => {
4964
+ const [o, a] = n[r.dataset.corner];
4965
+ r.style.left = o - 5 + "px", r.style.top = a - 5 + "px";
4934
4966
  }), this.imgCtx) {
4935
- const o = this.imgCtx.offsetWidth, r = this.imgCtx.offsetHeight;
4936
- let a = i + (s - i) / 2 - o / 2;
4937
- a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
4938
- let d = e - r - 8;
4967
+ const r = this.imgCtx.offsetWidth, o = this.imgCtx.offsetHeight;
4968
+ let a = i + (s - i) / 2 - r / 2;
4969
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - r - 8));
4970
+ let d = e - o - 8;
4939
4971
  d < this.ctxMinTop() && (d = l + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
4940
4972
  }
4941
4973
  }
@@ -4944,16 +4976,17 @@ const I = class I {
4944
4976
  const i = this.imgActive;
4945
4977
  if (!i) return;
4946
4978
  this.cancelImgHide();
4947
- const s = t.clientX, l = i.getBoundingClientRect().width, n = e === "nw" || e === "sw" ? -1 : 1;
4979
+ const s = t.clientX, l = i.offsetWidth || i.getBoundingClientRect().width, n = e === "nw" || e === "sw" ? -1 : 1, r = Math.round(this.contentWidth());
4948
4980
  this.withNoTextSelect((o) => {
4949
- const r = (d) => {
4950
- i.style.width = Math.max(24, Math.round(l + n * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
4951
- }, a = () => {
4952
- window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", a), o();
4953
- const d = parseInt(i.style.width, 10);
4954
- d > 0 && !i.closest(".tpl-media") && (i.setAttribute("width", String(d)), i.removeAttribute("height")), this.onChange();
4981
+ const a = (p) => {
4982
+ let u = Math.max(24, Math.round(l + n * (p.clientX - s)));
4983
+ r > 0 && (u = Math.min(u, r)), i.style.width = u + "px", i.style.height = "auto", this.positionImageHandles();
4984
+ }, d = () => {
4985
+ window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", d), o();
4986
+ const p = Math.round(i.offsetWidth) || parseInt(i.style.width, 10);
4987
+ p > 0 && !i.closest(".tpl-media") && (i.style.width = p + "px", i.setAttribute("width", String(p)), i.removeAttribute("height")), this.onChange();
4955
4988
  };
4956
- window.addEventListener("mousemove", r), window.addEventListener("mouseup", a);
4989
+ window.addEventListener("mousemove", a), window.addEventListener("mouseup", d);
4957
4990
  });
4958
4991
  }
4959
4992
  /* ---------------------------------------------------------- selection bubble toolbar */
@@ -4992,7 +5025,7 @@ const I = class I {
4992
5025
  this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
4993
5026
  }
4994
5027
  buildSelToolbar() {
4995
- var o;
5028
+ var r;
4996
5029
  const t = document.createElement("div");
4997
5030
  t.className = "selctx", t.dir = this.dir();
4998
5031
  const e = this.ctxBtn(
@@ -5000,7 +5033,7 @@ const I = class I {
5000
5033
  this.t("forecolor"),
5001
5034
  () => this.colorMenu(e, "fore")
5002
5035
  ), i = this.ctxBtn(c.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
5003
- (o = i.querySelector("svg")) == null || o.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5036
+ (r = i.querySelector("svg")) == null || r.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5004
5037
  const s = this.ctxBtn(c.caseic, this.t("changecase"), () => this.caseMenu(s)), l = this.ctxBtn(c.lineheight, this.t("lineheight"), () => this.lineHeightMenu(l)), n = this.ctxBtn(c.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(n));
5005
5038
  return t.append(
5006
5039
  this.ctxBtn(c.bold, this.t("bold"), () => this.exec("bold"), "bold"),
@@ -5017,14 +5050,14 @@ const I = class I {
5017
5050
  s,
5018
5051
  l,
5019
5052
  n
5020
- ), t.addEventListener("mousedown", (r) => r.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5053
+ ), t.addEventListener("mousedown", (o) => o.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5021
5054
  }
5022
5055
  positionSelToolbar(t) {
5023
5056
  if (!this.selCtx) return;
5024
- const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY, o = this.selCtx.offsetWidth, r = this.selCtx.offsetHeight;
5025
- let a = s + (l - s) / 2 - o / 2;
5026
- a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
5027
- let d = i - r - 8;
5057
+ const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY, r = this.selCtx.offsetWidth, o = this.selCtx.offsetHeight;
5058
+ let a = s + (l - s) / 2 - r / 2;
5059
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - r - 8));
5060
+ let d = i - o - 8;
5028
5061
  d < this.ctxMinTop() && (d = n + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5029
5062
  }
5030
5063
  repositionSelToolbar() {
@@ -5058,7 +5091,7 @@ const I = class I {
5058
5091
  return t > 0 ? t + "px" : "";
5059
5092
  }
5060
5093
  refreshState() {
5061
- var r, a, d;
5094
+ var o, a, d;
5062
5095
  const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
5063
5096
  [this.toolbar, this.selCtx].filter(Boolean).forEach((p) => {
5064
5097
  [
@@ -5082,13 +5115,13 @@ const I = class I {
5082
5115
  const u = p.querySelector("[data-id=code]");
5083
5116
  u && u.classList.toggle("on", e && !!this.closestInlineCode());
5084
5117
  });
5085
- const l = t ? this.closestBlock(t.anchorNode) : null, n = ((r = l == null ? void 0 : l.closest("[dir]")) == null ? void 0 : r.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5118
+ const l = t ? this.closestBlock(t.anchorNode) : null, n = ((o = l == null ? void 0 : l.closest("[dir]")) == null ? void 0 : o.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5086
5119
  (a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && n === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && n === "rtl");
5087
- const o = (p, u, g) => {
5120
+ const r = (p, u, g) => {
5088
5121
  const m = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
5089
5122
  m && (m.textContent = u || g || "", m.classList.toggle("empty", !u));
5090
5123
  };
5091
- o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel", Q.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5124
+ r("fontsel", this.currentFont()), r("sizesel", this.currentSize().replace("px", "")), e && r("blocksel", Q.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5092
5125
  }
5093
5126
  countWords() {
5094
5127
  const t = (this.ed.textContent || "").trim();
@@ -5114,7 +5147,7 @@ const I = class I {
5114
5147
  return;
5115
5148
  }
5116
5149
  }
5117
- i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, It(e.getData("text/plain"))), this.onChange());
5150
+ i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, qt(e.getData("text/plain"))), this.onChange());
5118
5151
  }
5119
5152
  /** Rich-HTML paste. Before the (untouched) paste engine runs, pictures Word left
5120
5153
  * behind as unreadable file:// refs are pulled out of the clipboard's RTF flavor
@@ -5126,19 +5159,19 @@ const I = class I {
5126
5159
  let s = [];
5127
5160
  const l = e.getData("text/rtf");
5128
5161
  if (l) {
5129
- const n = Pt(t, l);
5162
+ const n = $t(t, l);
5130
5163
  t = n.html, s = n.injected;
5131
5164
  }
5132
- if (i && Ot(t) === 1) {
5165
+ if (i && _t(t) === 1) {
5133
5166
  const n = i.getAsFile();
5134
5167
  if (n) {
5135
- const o = t;
5168
+ const r = t;
5136
5169
  this.saveSel();
5137
- const r = new FileReader();
5138
- r.onload = () => {
5139
- const a = nt(o, [r.result]);
5170
+ const o = new FileReader();
5171
+ o.onload = () => {
5172
+ const a = rt(r, [o.result]);
5140
5173
  this.finishRichPaste(a.html, s.concat(a.injected), !0);
5141
- }, r.onerror = () => this.finishRichPaste(o, s, !0), r.readAsDataURL(n);
5174
+ }, o.onerror = () => this.finishRichPaste(r, s, !0), o.readAsDataURL(n);
5142
5175
  return;
5143
5176
  }
5144
5177
  }
@@ -5152,26 +5185,26 @@ const I = class I {
5152
5185
  this.insertPastedHTML(t, i);
5153
5186
  return;
5154
5187
  }
5155
- const s = this.imageUploadHandler, l = e.filter((n, o) => e.indexOf(n) === o);
5188
+ const s = this.imageUploadHandler, l = e.filter((n, r) => e.indexOf(n) === r);
5156
5189
  i || this.saveSel(), Promise.all(
5157
- l.map((n, o) => {
5158
- const r = Ft(n, "pasted-image-" + (o + 1));
5159
- return r ? s(r).catch((a) => {
5190
+ l.map((n, r) => {
5191
+ const o = zt(n, "pasted-image-" + (r + 1));
5192
+ return o ? s(o).catch((a) => {
5160
5193
  var d;
5161
- return (d = this.onImageUploadError) == null || d.call(this, a, r), n;
5194
+ return (d = this.onImageUploadError) == null || d.call(this, a, o), n;
5162
5195
  }) : Promise.resolve(n);
5163
5196
  })
5164
5197
  ).then((n) => {
5165
- let o = t;
5166
- l.forEach((r, a) => {
5167
- n[a] !== r && (o = o.split(r).join(n[a]));
5168
- }), this.insertPastedHTML(o, !0);
5198
+ let r = t;
5199
+ l.forEach((o, a) => {
5200
+ n[a] !== o && (r = r.split(o).join(n[a]));
5201
+ }), this.insertPastedHTML(r, !0);
5169
5202
  });
5170
5203
  }
5171
5204
  /** `deferred` means the insert is happening after an async hop, so the caret the
5172
5205
  * paste started from has to be put back first. */
5173
5206
  insertPastedHTML(t, e = !1) {
5174
- e && this.restoreSel(), document.execCommand("insertHTML", !1, At(t, this.dir())), e && this.saveSel(), this.onChange();
5207
+ e && this.restoreSel(), document.execCommand("insertHTML", !1, It(t, this.dir())), e && this.saveSel(), this.onChange();
5175
5208
  }
5176
5209
  /* ---------------------------------------------------------- init */
5177
5210
  initUI() {
@@ -5179,18 +5212,18 @@ const I = class I {
5179
5212
  }
5180
5213
  };
5181
5214
  I.instanceCounter = 0, I.TBR_COLLAPSE_MAX = 992;
5182
- let st = I;
5215
+ let lt = I;
5183
5216
  export {
5184
5217
  Q as BLOCKS,
5185
- pe as CHARS,
5186
- vt as COLORS,
5187
- pt as FONTS,
5188
- st as FableEditor,
5189
- ct as I18N,
5218
+ ge as CHARS,
5219
+ bt as COLORS,
5220
+ ut as FONTS,
5221
+ lt as FableEditor,
5222
+ ht as I18N,
5190
5223
  c as IC,
5191
- ut as SIZES,
5192
- ue as TXT,
5193
- At as cleanPastedHTML,
5194
- O as getStrings,
5195
- It as normalizeTextPaste
5224
+ mt as SIZES,
5225
+ fe as TXT,
5226
+ It as cleanPastedHTML,
5227
+ F as getStrings,
5228
+ qt as normalizeTextPaste
5196
5229
  };