fable-editor 1.3.1 → 1.3.2

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, 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 = [
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);
@@ -1944,38 +1944,38 @@ function St(h) {
1944
1944
  const l = s.previousElementSibling;
1945
1945
  i && l && i[i.length - 1] === l ? i.push(s) : (i = [s], e.push(i));
1946
1946
  }), e.forEach((s) => {
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);
1947
+ const l = [], o = s[0];
1948
+ s.forEach((n) => {
1949
+ var y, w, S;
1950
+ const a = +(((y = (n.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : y[1]) || 1), d = Array.from(n.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 = n.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
+ o.parentNode.insertBefore(C, o);
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(n), 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), n.getAttribute("dir") && m.setAttribute("dir", n.getAttribute("dir")); n.firstChild; ) m.appendChild(n.firstChild);
1965
+ l[l.length - 1].list.appendChild(m), n.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,7 +1999,7 @@ 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
2004
  const r = t.createElement("span");
2005
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"));
@@ -2040,34 +2040,34 @@ function Z(h, t) {
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 o = D(i), n = [];
2044
+ for (const [r, a] of Object.entries(o))
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) || n.push(r + ":" + a));
2046
+ if (n.length ? i.setAttribute("style", n.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); ) {
2056
2056
  let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
2057
2057
  s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
2058
2058
  let l;
2059
- const n = /([^{}]+)\{([^}]*)\}/g;
2060
- for (; l = n.exec(s); ) {
2061
- const o = l[2].split(";").map((r) => {
2059
+ const o = /([^{}]+)\{([^}]*)\}/g;
2060
+ for (; l = o.exec(s); ) {
2061
+ const n = l[2].split(";").map((r) => {
2062
2062
  const a = r.indexOf(":");
2063
2063
  return a < 1 ? null : [r.slice(0, a).trim().toLowerCase(), r.slice(a + 1).trim()];
2064
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 }));
2065
+ n.length && l[1].split(",").map((r) => r.trim()).filter((r) => r && !r.startsWith("@")).forEach((r) => t.push({ sel: r, decls: n }));
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 }) => {
@@ -2077,44 +2077,44 @@ function Ht(h, t) {
2077
2077
  } catch {
2078
2078
  return;
2079
2079
  }
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;
2080
+ l.forEach((o) => {
2081
+ let n = e.get(o);
2082
+ n || (n = {}, e.set(o, n)), s.forEach(([r, a]) => {
2083
+ n[r] = 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")));
2087
+ const l = D(s), o = s.hasAttribute("dir"), n = s.hasAttribute("align"), r = Object.entries(i).filter(([p]) => !(p in l || (p === "direction" || p === "unicode-bidi") && o || p === "text-align" && (n || o) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2088
2088
  if (!r.length) return;
2089
2089
  const a = r.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
- var n;
2107
- return l && l.tagName === "P" && !((n = l.textContent) != null && n.trim()) && !l.querySelector("img,table");
2106
+ var o;
2107
+ return l && l.tagName === "P" && !((o = l.textContent) != null && o.trim()) && !l.querySelector("img,table");
2108
2108
  };
2109
2109
  for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
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];
2127
+ let o = 0, n = s;
2128
+ for (; n < h.length; n++) {
2129
+ const r = h[n];
2130
2130
  if (r === "\\") {
2131
- o++;
2131
+ n++;
2132
2132
  continue;
2133
2133
  }
2134
- if (r === "{") n++;
2135
- else if (r === "}" && (n--, !n))
2134
+ if (r === "{") o++;
2135
+ else if (r === "}" && (o--, !o))
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: n + 1, body: h.slice(s + i.length, n) }), s = n + 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,74 +2177,105 @@ 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 o = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2205
+ if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + o, "i").test(h)) return null;
2206
+ const n = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", r = J((n.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = J((n.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
2207
+ return '<img src="' + l.replace(/"/g, "&quot;") + '"' + (r ? ' width="' + r + '"' : "") + (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) => {
2192
- const n = (l.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2193
- 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;
2222
+ return { html: Ot(h).replace(/<img\b[^>]*>/gi, (l) => {
2223
+ const o = (l.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2224
+ if (ot.test(o)) return l;
2225
+ const n = t[i++];
2226
+ return n ? (e.push(n), /\ssrc\s*=\s*["']/i.test(l) ? l.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + n + '"') : l.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + n + '"')) : 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";
2212
2243
  try {
2213
2244
  const s = atob(e[2]), l = new Uint8Array(s.length);
2214
- for (let n = 0; n < s.length; n++) l[n] = s.charCodeAt(n);
2245
+ for (let o = 0; o < s.length; o++) l[o] = s.charCodeAt(o);
2215
2246
  return new File([l], t + "." + (i === "jpeg" ? "jpg" : i), { type: e[1] });
2216
2247
  } catch {
2217
2248
  return null;
2218
2249
  }
2219
2250
  }
2220
- function $t(h) {
2251
+ function Ut(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 n = h.byteLength - 22; n >= Math.max(0, h.byteLength - 22 - 65535); n--)
2255
+ if (t.getUint32(n, !0) === 101010256) {
2256
+ i = n;
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
- 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));
2262
+ const o = new TextDecoder();
2263
+ for (let n = 0; n < s && t.getUint32(l, !0) === 33639248; n++) {
2264
+ 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 = o.decode(new Uint8Array(h, l + 46, d));
2234
2265
  e.set(m, { name: m, method: r, 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
- 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
- if (t.method === 0) return n;
2272
+ const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, o = new Uint8Array(h.slice(l, l + t.compSize));
2273
+ if (t.method === 0) return o;
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 n = new Blob([o]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2276
+ return new Uint8Array(await new Response(n).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
+ }, Wt = {
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
  }
@@ -2303,12 +2334,12 @@ class Ut {
2303
2334
  };
2304
2335
  for (const l of Array.from(t.children))
2305
2336
  if (l.localName === "p") {
2306
- const n = this.paraList(l);
2307
- 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; )
2311
- e += `<${n.type}>`, i.push(n.type);
2337
+ const o = this.paraList(l);
2338
+ if (o) {
2339
+ const n = o.ilvl + 1;
2340
+ for (; i.length > n; ) e += `</${i.pop()}>`;
2341
+ for (i.length === n && i[n - 1] !== o.type && (e += `</${i.pop()}>`); i.length < n; )
2342
+ e += `<${o.type}>`, i.push(o.type);
2312
2343
  e += `<li>${this.runsOf(l) || "<br>"}</li>`;
2313
2344
  continue;
2314
2345
  }
@@ -2329,9 +2360,9 @@ 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(";")}"` : "";
2363
+ const o = [], n = T(E(t, "pPr", "jc"));
2364
+ n === "center" ? o.push("text-align:center") : n === "right" || n === "end" ? o.push("text-align:right") : (n === "both" || n === "distribute") && o.push("text-align:justify"), e && E(e, "bidi") && o.push("direction:rtl");
2365
+ const r = this.runsOf(t), a = o.length ? ` style="${o.join(";")}"` : "";
2335
2366
  return `<${s}${a}>${r || "<br>"}</${s}>`;
2336
2367
  }
2337
2368
  runsOf(t) {
@@ -2342,8 +2373,8 @@ class Ut {
2342
2373
  let s = this.rels.get(T(i, "id")) || "";
2343
2374
  const l = T(i, "anchor");
2344
2375
  !s && l && (s = "#" + l);
2345
- const n = this.runsOf(i);
2346
- e += s ? `<a href="${tt(s)}">${n}</a>` : n;
2376
+ const o = this.runsOf(i);
2377
+ e += s ? `<a href="${et(s)}">${o}</a>` : o;
2347
2378
  } else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
2348
2379
  return e;
2349
2380
  }
@@ -2351,14 +2382,14 @@ 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
- 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");
2389
+ const o = T(e ? E(e, "highlight") : null);
2390
+ o && it[o] && s.push("background-color:" + it[o]);
2391
+ const n = parseFloat(T(e ? E(e, "sz") : null));
2392
+ n && s.push("font-size:" + Math.round(n / 2 * (4 / 3)) + "px");
2362
2393
  const r = e ? E(e, "rFonts") : null, a = T(r, "ascii") || T(r, "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);
@@ -2366,49 +2397,49 @@ class Ut {
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");
2400
+ const s = (n) => {
2401
+ if (n.localName === "blip" && (e = e || T(n, "embed") || T(n, "link")), n.localName === "imagedata" && (e = e || T(n, "id")), n.localName === "extent") {
2402
+ const r = parseFloat(n.getAttribute("cx") || "0");
2372
2403
  r && (i = Math.round(r / 9525));
2373
2404
  }
2374
- for (const r of Array.from(o.children)) s(r);
2405
+ for (const r of Array.from(n.children)) s(r);
2375
2406
  };
2376
2407
  if (s(t), !e) return "";
2377
2408
  const l = this.images.get(e);
2378
2409
  if (!l) return "";
2379
- const n = i ? ` width="${i}"` : "";
2380
- return `<img src="${l}" alt=""${n}>`;
2410
+ const o = i ? ` width="${i}"` : "";
2411
+ return `<img src="${l}" alt=""${o}>`;
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")) {
2387
- const l = parseInt(T(E(s, "tcPr", "gridSpan")) || "1", 10) || 1, n = l > 1 ? ` colspan="${l}"` : "";
2388
- let o = "";
2417
+ for (const s of P(i, "tc")) {
2418
+ const l = parseInt(T(E(s, "tcPr", "gridSpan")) || "1", 10) || 1, o = l > 1 ? ` colspan="${l}"` : "";
2419
+ let n = "";
2389
2420
  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>`;
2421
+ r.localName === "p" ? n += this.convertPara(r) : r.localName === "tbl" && (n += this.convertTable(r));
2422
+ e += `<td style="border:1px solid #b9c2cc"${o}>${n || "<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 = Ut(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;
2402
- }, l = await s("word/document.xml"), n = l == null ? void 0 : l.getElementsByTagName("*");
2403
- let o = null;
2404
- if (n) {
2405
- for (const m of Array.from(n))
2432
+ return f ? new DOMParser().parseFromString(i.decode(await tt(t, f)), "application/xml") : null;
2433
+ }, l = await s("word/document.xml"), o = l == null ? void 0 : l.getElementsByTagName("*");
2434
+ let n = null;
2435
+ if (o) {
2436
+ for (const m of Array.from(o))
2406
2437
  if (m.localName === "body") {
2407
- o = m;
2438
+ n = m;
2408
2439
  break;
2409
2440
  }
2410
2441
  }
2411
- if (!o) throw new Error("word/document.xml missing or invalid");
2442
+ if (!n) throw new Error("word/document.xml missing or invalid");
2412
2443
  const r = /* @__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("*"))) {
@@ -2420,10 +2451,10 @@ async function Wt(h) {
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 = Wt[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(r, p, u).convertBody(n);
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);
@@ -2467,60 +2498,60 @@ function Qt(h) {
2467
2498
  if (A !== h || !document.contains(h)) return;
2468
2499
  M || (M = document.createElement("div"), M.className = "etip", document.body.appendChild(M)), M.textContent = t, M.classList.add("show");
2469
2500
  const i = h.getBoundingClientRect(), s = M.offsetWidth, l = M.offsetHeight;
2470
- let n = i.left + i.width / 2 - s / 2;
2471
- 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";
2501
+ let o = i.left + i.width / 2 - s / 2;
2502
+ o = Math.max(6, Math.min(o, innerWidth - s - 6));
2503
+ let n = i.bottom + 7;
2504
+ n + l > innerHeight - 6 && (n = i.top - l - 7), M.style.left = o + "px", M.style.top = n + "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;
@@ -2530,20 +2561,20 @@ function de(h) {
2530
2561
  bottom: { width: null, style: null, color: null },
2531
2562
  left: { width: null, style: null, color: null }
2532
2563
  }, s = [];
2533
- let l = !1, n = !1;
2564
+ let l = !1, o = !1;
2534
2565
  if (e.split(";").forEach((a) => {
2535
2566
  const d = a.indexOf(":");
2536
2567
  if (d < 1) {
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)) {
2546
- n = !0;
2576
+ if (ce.test(u)) {
2577
+ o = !0;
2547
2578
  return;
2548
2579
  }
2549
2580
  l = !0;
@@ -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
- }), 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(";"));
2597
+ }), o || !l) return;
2598
+ const n = R.map((a) => ue(i[a])), r = s.slice();
2599
+ n.every((a) => a && a === n[0]) ? r.push("border:" + n[0]) : R.forEach((a, d) => n[d] && r.push(`border-${a}:` + n[d])), t.setAttribute("style", r.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) => {
2676
+ const o = (r) => {
2646
2677
  this.ed.style.height = Math.max(120, i + r.clientY - e) + "px";
2647
- }, o = () => {
2648
- window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", o);
2678
+ }, n = () => {
2679
+ window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", n);
2649
2680
  };
2650
- window.addEventListener("mousemove", n), window.addEventListener("mouseup", o);
2681
+ window.addEventListener("mousemove", o), window.addEventListener("mouseup", n);
2651
2682
  };
2652
2683
  t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
2653
2684
  }
@@ -2665,15 +2696,15 @@ 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, o, n, r;
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) {
2672
- const a = Array.from(((n = t.dataTransfer) == null ? void 0 : n.files) || []).find((d) => d.type.startsWith("image/"));
2703
+ const a = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((d) => d.type.startsWith("image/"));
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 = (n = e.closest) == null ? void 0 : n.call(e, ".vid-ph");
2677
2708
  if (s && this.ed.contains(s) && !this.options.readonly) {
2678
2709
  const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("video/"));
2679
2710
  a && this.readVideoFileInto(a, s);
@@ -2686,10 +2717,10 @@ const I = class I {
2686
2717
  s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
2687
2718
  const l = (u = e.closest) == null ? void 0 : u.call(e, ".vid-ph");
2688
2719
  l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(l)) : this.clearVphPlaceholderSel();
2689
- const n = (g = e.closest) == null ? void 0 : g.call(e, ".tpl");
2690
- 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();
2720
+ const o = (g = e.closest) == null ? void 0 : g.call(e, ".tpl");
2721
+ o && this.ed.contains(o) && !this.options.readonly ? this.selectTemplate(o) : this.clearTplSel();
2722
+ const n = (m = e.closest) == null ? void 0 : m.call(e, "pre.code-block");
2723
+ n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(n)) : this.clearCodeSel();
2693
2724
  const r = (f = e.closest) == null ? void 0 : f.call(e, "img");
2694
2725
  r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectImage(r)) : this.clearImageHandles();
2695
2726
  const a = (b = e.closest) == null ? void 0 : b.call(e, "video, .video-embed");
@@ -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, o, n;
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 && ((o = this.imgCtx) != null && o.contains(i) || this.imgHandles.some((r) => r.contains(i)) || ((n = i.closest) == null ? void 0 : n.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,40 +2817,40 @@ 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);
2820
+ const t = (n, r) => {
2821
+ const a = (n.getAttribute("style") || "").trim();
2822
+ n.setAttribute("style", a ? a.replace(/;?$/, "; ") + r : r);
2792
2823
  }, e = document.createElement("div");
2793
2824
  e.innerHTML = this.ed.innerHTML;
2794
2825
  let i = null;
2795
- e.querySelectorAll("[dir]").forEach((o) => {
2796
- const r = (o.getAttribute("dir") || "").toLowerCase();
2826
+ e.querySelectorAll("[dir]").forEach((n) => {
2827
+ const r = (n.getAttribute("dir") || "").toLowerCase();
2797
2828
  if (r !== "rtl" && r !== "ltr") return;
2798
2829
  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();
2830
+ i || (i = a), /text-align\s*:/i.test(n.getAttribute("style") || "") || t(n, `text-align:${a === "rtl" ? "right" : "left"}`);
2831
+ }), e.querySelectorAll(ie).forEach((n) => {
2832
+ const r = (n.getAttribute("dir") || "").toLowerCase();
2802
2833
  if (r === "rtl" || r === "ltr") return;
2803
- const a = te(at(o));
2834
+ const a = se(ct(n));
2804
2835
  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"}`);
2836
+ i || (i = a), n.setAttribute("dir", a);
2837
+ const d = /text-align\s*:/i.test(n.getAttribute("style") || "");
2838
+ t(n, d ? `direction:${a}` : `direction:${a};text-align:${a === "rtl" ? "right" : "left"}`);
2808
2839
  });
2809
2840
  const s = this.ed.querySelectorAll("img");
2810
- e.querySelectorAll("img").forEach((o, r) => {
2811
- if (o.closest(".tpl-media")) return;
2841
+ e.querySelectorAll("img").forEach((n, r) => {
2842
+ if (n.closest(".tpl-media")) return;
2812
2843
  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");
2844
+ d > 0 && !n.getAttribute("width") && n.setAttribute("width", String(d));
2845
+ const p = n.getAttribute("style") || "";
2846
+ d > 0 && !/(^|;)\s*width\s*:/i.test(p) && t(n, `width:${d}px`), /max-width\s*:/i.test(n.getAttribute("style") || "") || t(n, "max-width:100%"), /(^|;)\s*height\s*:/i.test(n.getAttribute("style") || "") || t(n, "height:auto");
2847
+ }), me(e), e.querySelectorAll("table").forEach((n) => {
2848
+ const r = n.getAttribute("style") || "";
2849
+ /border-collapse\s*:/i.test(r) || t(n, "border-collapse:collapse"), !/border-spacing\s*:/i.test(r) && !n.hasAttribute("cellspacing") && n.setAttribute("cellspacing", "0");
2819
2850
  });
2820
2851
  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}`);
2852
+ return e.querySelectorAll("table:not([dir])").forEach((n) => {
2853
+ n.setAttribute("dir", l), /direction\s*:/i.test(n.getAttribute("style") || "") || t(n, `direction:${l}`);
2823
2854
  }), `<div dir="${l}" style="direction:${l};text-align:${l === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
2824
2855
  }
2825
2856
  setContent(t) {
@@ -2835,7 +2866,7 @@ const I = class I {
2835
2866
  this.ed.focus();
2836
2867
  }
2837
2868
  async importWordFile(t) {
2838
- const e = await Wt(t);
2869
+ const e = await Xt(t);
2839
2870
  this.recordRevision(), this.setContent(e), this.recordRevision();
2840
2871
  }
2841
2872
  restoreDraft() {
@@ -2894,8 +2925,8 @@ const I = class I {
2894
2925
  t.preventDefault();
2895
2926
  const l = document.createElement("p");
2896
2927
  l.appendChild(document.createElement("br")), s.after(l), i.remove(), s.firstElementChild || s.remove();
2897
- const n = document.createRange();
2898
- n.setStart(l, 0), n.collapse(!0), e.removeAllRanges(), e.addRange(n), this.saveSel(), this.onChange();
2928
+ const o = document.createRange();
2929
+ o.setStart(l, 0), o.collapse(!0), e.removeAllRanges(), e.addRange(o), this.saveSel(), this.onChange();
2899
2930
  }
2900
2931
  selectedBlocks() {
2901
2932
  const t = window.getSelection();
@@ -2945,8 +2976,8 @@ const I = class I {
2945
2976
  s.className = "revprev";
2946
2977
  const l = document.createElement("button");
2947
2978
  l.type = "button", l.className = "revrestore", l.textContent = this.t("restore");
2948
- let n = this.revisions.length - 1;
2949
- const o = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
2979
+ let o = this.revisions.length - 1;
2980
+ const n = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
2950
2981
  year: "numeric",
2951
2982
  month: "short",
2952
2983
  day: "numeric",
@@ -2954,7 +2985,7 @@ const I = class I {
2954
2985
  minute: "2-digit",
2955
2986
  second: "2-digit"
2956
2987
  }), r = {}, a = (d) => {
2957
- n = d, this.revisions.forEach((p, u) => {
2988
+ o = d, this.revisions.forEach((p, u) => {
2958
2989
  var g;
2959
2990
  return (g = r[u]) == null ? void 0 : g.classList.toggle("on", u === d);
2960
2991
  }), s.innerHTML = this.revisions[d].html, l.disabled = d === this.revisions.length - 1;
@@ -2963,12 +2994,12 @@ const I = class I {
2963
2994
  const p = this.revisions[d], u = document.createElement("button");
2964
2995
  u.type = "button";
2965
2996
  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);
2997
+ u.innerHTML = `<span>${f ? this.t("currentver") : n.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);
2967
2998
  }
2968
2999
  i.append(l), l.addEventListener("click", () => {
2969
- const d = this.revisions[n];
3000
+ const d = this.revisions[o];
2970
3001
  d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
2971
- }), e.append(i, s), t.appendChild(e), a(n);
3002
+ }), e.append(i, s), t.appendChild(e), a(o);
2972
3003
  });
2973
3004
  }
2974
3005
  /* ---------------------------------------------------------- popups / menus */
@@ -3005,10 +3036,10 @@ const I = class I {
3005
3036
  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
3037
  a.target.tagName !== "INPUT" && a.preventDefault();
3007
3038
  }), 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));
3039
+ let n = this.dir() === "rtl" ? i.left - l.offsetWidth + 2 : i.right - 2;
3040
+ n = Math.max(8, Math.min(n + scrollX, scrollX + innerWidth - l.offsetWidth - 8));
3010
3041
  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);
3042
+ r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left = n + "px", l.style.top = r + "px", this.subStack.push(l);
3012
3043
  }
3013
3044
  popup(t, e, i) {
3014
3045
  if (this.openPop && this.popAnchor === t) {
@@ -3020,8 +3051,8 @@ const I = class I {
3020
3051
  s.className = "pop" + (i ? " " + i : ""), s.dir = this.dir(), e(s), document.body.appendChild(s);
3021
3052
  const l = t.getBoundingClientRect();
3022
3053
  s.style.minWidth = Math.max(160, Math.round(l.width)) + "px";
3023
- let n = l.bottom + scrollY + 2;
3024
- n = Math.max(8 + scrollY, Math.min(n, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = n + "px";
3054
+ let o = l.bottom + scrollY + 2;
3055
+ o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = o + "px";
3025
3056
  let r = this.dir() === "rtl" ? l.right - s.offsetWidth : l.left;
3026
3057
  r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = r + "px", s.addEventListener("mousedown", (a) => {
3027
3058
  a.target.tagName !== "INPUT" && a.preventDefault();
@@ -3037,18 +3068,18 @@ const I = class I {
3037
3068
  l.className = "mi" + (i.on ? " on" : ""), l.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${c.chev}</span>` : ""}`, l.addEventListener("click", () => {
3038
3069
  i.action && (this.closePop(), i.action());
3039
3070
  }), l.addEventListener("mouseenter", () => {
3040
- var n;
3041
- s ? this.openSubFor(i, l) : this.closeSubFrom(this.subLevelOf(t)), (n = i.hover) == null || n.call(i, !0);
3071
+ var o;
3072
+ s ? this.openSubFor(i, l) : this.closeSubFrom(this.subLevelOf(t)), (o = i.hover) == null || o.call(i, !0);
3042
3073
  }), l.addEventListener("mouseleave", () => {
3043
- var n;
3044
- return (n = i.hover) == null ? void 0 : n.call(i, !1);
3074
+ var o;
3075
+ return (o = i.hover) == null ? void 0 : o.call(i, !1);
3045
3076
  }), t.appendChild(l);
3046
3077
  });
3047
3078
  }
3048
3079
  /* ---------------------------------------------------------- toolbar builders */
3049
3080
  tbtn(t, e, i, s) {
3050
3081
  const l = document.createElement("button");
3051
- return l.className = "tbtn", l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (n) => n.preventDefault()), l.addEventListener("click", i), l;
3082
+ return l.className = "tbtn", l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (o) => o.preventDefault()), l.addEventListener("click", i), l;
3052
3083
  }
3053
3084
  /** Font-size increase / decrease step button. */
3054
3085
  stepBtn(t) {
@@ -3064,10 +3095,10 @@ const I = class I {
3064
3095
  colorChips() {
3065
3096
  const t = (s) => {
3066
3097
  const l = document.createElement("button");
3067
- return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (n) => {
3068
- n.preventDefault(), this.saveSel();
3098
+ return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (o) => {
3099
+ o.preventDefault(), this.saveSel();
3069
3100
  }), l;
3070
- }, e = ft.map((s) => {
3101
+ }, e = vt.map((s) => {
3071
3102
  const l = t(this.t("forecolor"));
3072
3103
  return l.style.background = s, l.addEventListener("click", () => this.applyColor("fore", s)), l;
3073
3104
  }), i = t(this.t("forecolor"));
@@ -3081,17 +3112,17 @@ const I = class I {
3081
3112
  }
3082
3113
  tsel(t, e, i, s) {
3083
3114
  const l = document.createElement("button");
3084
- return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${c.chev}`, l.addEventListener("mousedown", (n) => {
3085
- n.preventDefault(), this.saveSel();
3115
+ return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${c.chev}`, l.addEventListener("mousedown", (o) => {
3116
+ o.preventDefault(), this.saveSel();
3086
3117
  }), l.addEventListener("click", () => s(l)), l;
3087
3118
  }
3088
3119
  setListStyle(t, e) {
3089
- var l, n;
3120
+ var l, o;
3090
3121
  this.restoreSel();
3091
3122
  const i = window.getSelection();
3092
3123
  if (!i) return;
3093
3124
  let s = (l = this.closestBlock(i.anchorNode)) == null ? void 0 : l.closest(t);
3094
- s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (n = this.closestBlock(i.anchorNode)) == null ? void 0 : n.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
3125
+ s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (o = this.closestBlock(i.anchorNode)) == null ? void 0 : o.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
3095
3126
  }
3096
3127
  listMenu(t, e) {
3097
3128
  var a;
@@ -3103,7 +3134,7 @@ const I = class I {
3103
3134
  ] : [
3104
3135
  ["circle", c.ul_circle],
3105
3136
  ["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 : "";
3137
+ ], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), o = window.getSelection(), n = o ? (a = this.closestBlock(o.anchorNode)) == null ? void 0 : a.closest(e) : null, r = n ? n.style.listStyleType : "";
3107
3138
  this.popup(t, (d) => {
3108
3139
  this.menuItems(d, [
3109
3140
  {
@@ -3127,7 +3158,7 @@ const I = class I {
3127
3158
  * table cell-background menu all show the identical popup. */
3128
3159
  buildPaletteInto(t, e, i) {
3129
3160
  const s = document.createElement("div");
3130
- s.className = "cpal", vt.forEach((p) => {
3161
+ s.className = "cpal", bt.forEach((p) => {
3131
3162
  const u = document.createElement("button");
3132
3163
  u.type = "button", u.style.background = p, u.title = p, u.addEventListener("click", () => {
3133
3164
  this.closePop(), i(p);
@@ -3135,8 +3166,8 @@ const I = class I {
3135
3166
  }), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3136
3167
  const l = document.createElement("div");
3137
3168
  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;
3169
+ const o = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", n = document.createElement("div");
3170
+ n.className = "cswatch cur", n.title = this.t("currentcolor"), n.style.background = o, n.innerHTML = c.check;
3140
3171
  const r = document.createElement("button");
3141
3172
  r.type = "button", r.className = "cswatch nocolor", r.title = this.t("removecolor"), r.addEventListener("click", () => {
3142
3173
  this.closePop(), i(null);
@@ -3144,9 +3175,9 @@ const I = class I {
3144
3175
  const a = document.createElement("label");
3145
3176
  a.className = "cswatch cwheel", a.title = this.t("customcolor"), a.innerHTML = c.palette;
3146
3177
  const d = document.createElement("input");
3147
- d.type = "color", d.value = n, d.addEventListener("change", () => {
3178
+ d.type = "color", d.value = o, d.addEventListener("change", () => {
3148
3179
  this.closePop(), i(d.value);
3149
- }), a.appendChild(d), l.append(o, r, a), t.appendChild(l);
3180
+ }), a.appendChild(d), l.append(n, r, a), t.appendChild(l);
3150
3181
  }
3151
3182
  colorMenu(t, e) {
3152
3183
  this.popup(
@@ -3176,7 +3207,7 @@ const I = class I {
3176
3207
  this.popup(t, (e) => this.menuItems(e, this.fontItems()));
3177
3208
  }
3178
3209
  sizeItems() {
3179
- return ut.map((t) => ({
3210
+ return mt.map((t) => ({
3180
3211
  label: t,
3181
3212
  on: this.currentSize() === t,
3182
3213
  action: () => this.applyFontSize(t)
@@ -3192,19 +3223,19 @@ const I = class I {
3192
3223
  const t = window.getSelection();
3193
3224
  if (!t) return;
3194
3225
  if (!t.rangeCount) {
3195
- const n = document.createRange();
3196
- n.selectNodeContents(this.ed), n.collapse(!0), t.addRange(n);
3226
+ const o = document.createRange();
3227
+ o.selectNodeContents(this.ed), o.collapse(!0), t.addRange(o);
3197
3228
  }
3198
3229
  if (!t.isCollapsed) return;
3199
3230
  const e = t.getRangeAt(0), i = e.startContainer;
3200
3231
  if (i.nodeType === 3) {
3201
- 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) {
3232
+ const o = i.data;
3233
+ let n = e.startOffset, r = e.startOffset;
3234
+ for (; n > 0 && /\S/.test(o[n - 1]); ) n--;
3235
+ for (; r < o.length && /\S/.test(o[r]); ) r++;
3236
+ if (r > n) {
3206
3237
  const a = document.createRange();
3207
- a.setStart(i, o), a.setEnd(i, r), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3238
+ a.setStart(i, n), a.setEnd(i, r), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3208
3239
  return;
3209
3240
  }
3210
3241
  }
@@ -3229,7 +3260,7 @@ const I = class I {
3229
3260
  this.saveSel(), this.refreshState(), this.onChange();
3230
3261
  }
3231
3262
  stepFontSize(t) {
3232
- const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(gt, Math.max(mt, e + t));
3263
+ const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(ft, Math.max(gt, e + t));
3233
3264
  i !== e && this.applyFontSize(i + "px");
3234
3265
  }
3235
3266
  /* ------------------------------------------------ case / spacing / link */
@@ -3238,14 +3269,14 @@ const I = class I {
3238
3269
  const e = window.getSelection();
3239
3270
  if (!e || !e.rangeCount || e.isCollapsed) return;
3240
3271
  const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), l = [];
3241
- let n;
3242
- 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;
3272
+ let o;
3273
+ for (; o = s.nextNode(); ) i.intersectsNode(o) && l.push(o);
3274
+ l.forEach((n) => {
3275
+ const r = n === i.startContainer ? i.startOffset : 0, a = n === i.endContainer ? i.endOffset : n.data.length;
3245
3276
  if (a <= r) return;
3246
- const d = o.data.slice(r, a);
3277
+ const d = n.data.slice(r, a);
3247
3278
  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);
3279
+ t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (u, g, m) => g + m.toUpperCase()), n.replaceData(r, a - r, p);
3249
3280
  }), this.saveSel(), this.refreshState(), this.onChange();
3250
3281
  }
3251
3282
  caseItems() {
@@ -3333,8 +3364,8 @@ const I = class I {
3333
3364
  (s) => {
3334
3365
  const l = document.createElement("div");
3335
3366
  l.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
3336
- const n = document.createElement("span");
3337
- n.style.cssText = "width:60px;color:#556;flex:none", n.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", l.append(n, e), s.appendChild(l), setTimeout(() => e.focus(), 0);
3367
+ const o = document.createElement("span");
3368
+ o.style.cssText = "width:60px;color:#556;flex:none", o.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", l.append(o, e), s.appendChild(l), setTimeout(() => e.focus(), 0);
3338
3369
  },
3339
3370
  i
3340
3371
  );
@@ -3377,15 +3408,15 @@ const I = class I {
3377
3408
  s.className = "tgrid";
3378
3409
  const l = document.createElement("div");
3379
3410
  l.className = "tgridlbl", l.textContent = "1 × 1";
3380
- const n = [];
3381
- for (let o = 0; o < 8; o++)
3411
+ const o = [];
3412
+ for (let n = 0; n < 8; n++)
3382
3413
  for (let r = 0; r < 10; r++) {
3383
3414
  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);
3415
+ a.dataset.r = String(n), a.dataset.c = String(r), a.addEventListener("mouseenter", () => {
3416
+ o.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= n && +d.dataset.c <= r)), l.textContent = r + 1 + " × " + (n + 1);
3386
3417
  }), a.addEventListener("click", () => {
3387
- this.closePop(), this.insertTable(o + 1, r + 1), e == null || e();
3388
- }), n.push(a), s.appendChild(a);
3418
+ this.closePop(), this.insertTable(n + 1, r + 1), e == null || e();
3419
+ }), o.push(a), s.appendChild(a);
3389
3420
  }
3390
3421
  i.append(s, l), t.appendChild(i);
3391
3422
  }
@@ -3470,17 +3501,17 @@ const I = class I {
3470
3501
  }
3471
3502
  buildToolbar() {
3472
3503
  this.toolbar.innerHTML = "";
3473
- const t = this.options.toolbar === !0 ? ht : this.options.toolbar, e = this.buildToolbarRegistry();
3504
+ const t = this.options.toolbar === !0 ? dt : this.options.toolbar, e = this.buildToolbarRegistry();
3474
3505
  this.parseToolbarString(t).forEach((i) => {
3475
3506
  const s = [];
3476
3507
  i.forEach((l) => {
3477
- const n = e[l];
3478
- if (!n) {
3508
+ const o = e[l];
3509
+ if (!o) {
3479
3510
  console.warn(`FableEditor: unknown toolbar item "${l}"`);
3480
3511
  return;
3481
3512
  }
3482
- const o = n();
3483
- Array.isArray(o) ? s.push(...o) : s.push(o);
3513
+ const n = o();
3514
+ Array.isArray(n) ? s.push(...n) : s.push(n);
3484
3515
  }), s.length && this.toolbar.appendChild(this.group(...s));
3485
3516
  }), this.tbrMore = this.tbtn(c.more, this.t("more"), () => {
3486
3517
  this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
@@ -3652,7 +3683,7 @@ const I = class I {
3652
3683
  { label: this.t("deltable"), icon: c.trash, action: () => this.tableOp("deltable") }
3653
3684
  ],
3654
3685
  help: [this.mItem("helpttl", c.helpic, () => this.helpDlg(), "Alt+0")]
3655
- }, e = this.options.menubar === !0 ? dt : this.options.menubar, i = /* @__PURE__ */ new Set();
3686
+ }, e = this.options.menubar === !0 ? pt : this.options.menubar, i = /* @__PURE__ */ new Set();
3656
3687
  e.split(/\s+/).filter(Boolean).forEach((s) => {
3657
3688
  if (i.has(s)) return;
3658
3689
  if (i.add(s), !t[s]) {
@@ -3660,9 +3691,9 @@ const I = class I {
3660
3691
  return;
3661
3692
  }
3662
3693
  const l = document.createElement("button");
3663
- l.type = "button", l.textContent = this.t(s), l.dataset.menuKey = s, l.addEventListener("mousedown", (n) => {
3664
- n.preventDefault(), this.saveSel();
3665
- }), l.addEventListener("click", () => this.popup(l, (n) => this.menuItems(n, t[s]))), this.menubar.appendChild(l);
3694
+ l.type = "button", l.textContent = this.t(s), l.dataset.menuKey = s, l.addEventListener("mousedown", (o) => {
3695
+ o.preventDefault(), this.saveSel();
3696
+ }), l.addEventListener("click", () => this.popup(l, (o) => this.menuItems(o, t[s]))), this.menubar.appendChild(l);
3666
3697
  });
3667
3698
  }
3668
3699
  /* ---------------------------------------------------------- table ops */
@@ -3673,23 +3704,23 @@ const I = class I {
3673
3704
  if (!e) return;
3674
3705
  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);
3675
3706
  if (!i) return;
3676
- const s = i.parentElement, l = i.closest("table"), n = Array.from(s.children).indexOf(i), o = () => {
3707
+ const s = i.parentElement, l = i.closest("table"), o = Array.from(s.children).indexOf(i), n = () => {
3677
3708
  const p = s.cloneNode(!1);
3678
3709
  return Array.from(s.children).forEach((u) => {
3679
3710
  const g = document.createElement("td"), m = u.getAttribute("style");
3680
3711
  m && g.setAttribute("style", m), g.style.removeProperty("background-color"), g.innerHTML = "<br>", p.appendChild(g);
3681
3712
  }), p;
3682
3713
  };
3683
- if (t === "rowabove" && s.before(o()), t === "rowbelow" && s.after(o()), t === "delrow") {
3714
+ if (t === "rowabove" && s.before(n()), t === "rowbelow" && s.after(n()), t === "delrow") {
3684
3715
  const p = s.parentElement;
3685
3716
  s.remove(), p.querySelector("tr") || l.remove();
3686
3717
  }
3687
3718
  (t === "colbefore" || t === "colafter") && l.querySelectorAll("tr").forEach((p) => {
3688
- const u = p.children[Math.min(n, p.children.length - 1)], g = document.createElement("td"), m = u.getAttribute("style");
3719
+ const u = p.children[Math.min(o, p.children.length - 1)], g = document.createElement("td"), m = u.getAttribute("style");
3689
3720
  m && g.setAttribute("style", m), g.style.removeProperty("width"), g.style.removeProperty("background-color"), g.innerHTML = "<br>", t === "colbefore" ? u.before(g) : u.after(g);
3690
3721
  }), t === "delcol" && (l.querySelectorAll("tr").forEach((p) => {
3691
3722
  var u;
3692
- return (u = p.children[n]) == null ? void 0 : u.remove();
3723
+ return (u = p.children[o]) == null ? void 0 : u.remove();
3693
3724
  }), l.querySelector("td,th") || l.remove()), t === "deltable" && l.remove(), this.onChange(), this.positionTableHandles();
3694
3725
  }
3695
3726
  /** Reorders the current row/column: 'rowup'/'rowdown' swap the caret's row with
@@ -3715,10 +3746,10 @@ const I = class I {
3715
3746
  const a = r.children[l], d = r.children[l + 1];
3716
3747
  a && d && d.after(a);
3717
3748
  });
3718
- const n = document.createRange();
3719
- 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();
3749
+ const o = document.createRange();
3750
+ o.selectNodeContents(e), o.collapse(!0);
3751
+ const n = window.getSelection();
3752
+ n && (n.removeAllRanges(), n.addRange(o)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
3722
3753
  }
3723
3754
  /** Align the whole table via auto margins — same semantics as the align
3724
3755
  * field in the table-properties dialog. */
@@ -3755,26 +3786,26 @@ const I = class I {
3755
3786
  tablePropsDlg() {
3756
3787
  const t = this.tblActive;
3757
3788
  if (!t) return;
3758
- 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" : "";
3789
+ let e, i, s, l, o;
3790
+ const n = "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" : "";
3760
3791
  this.dialog(
3761
3792
  this.t("tablepropsttl"),
3762
- (C) => {
3763
- const S = (w, k) => {
3793
+ (w) => {
3794
+ const S = (C, k) => {
3764
3795
  const L = document.createElement("div");
3765
- L.style.cssText = o;
3796
+ L.style.cssText = n;
3766
3797
  const H = document.createElement("span");
3767
- H.style.cssText = r, H.textContent = this.t(w), L.append(H, k), C.appendChild(L);
3798
+ H.style.cssText = r, H.textContent = this.t(C), L.append(H, k), w.appendChild(L);
3768
3799
  };
3769
- 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, [
3800
+ 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), o = document.createElement("select"), o.style.cssText = a, [
3770
3801
  ["", "alignnone"],
3771
3802
  ["left", "alignleft"],
3772
3803
  ["center", "aligncenter"],
3773
3804
  ["right", "alignright"]
3774
- ].forEach(([w, k]) => {
3805
+ ].forEach(([C, k]) => {
3775
3806
  const L = document.createElement("option");
3776
- L.value = w, L.textContent = this.t(k), w === y && (L.selected = !0), n.appendChild(L);
3777
- }), S("tblalign", n);
3807
+ L.value = C, L.textContent = this.t(k), C === y && (L.selected = !0), o.appendChild(L);
3808
+ }), S("tblalign", o);
3778
3809
  },
3779
3810
  [
3780
3811
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3787,7 +3818,7 @@ const I = class I {
3787
3818
  cellpadding: i.value.trim(),
3788
3819
  cellspacing: s.value.trim(),
3789
3820
  border: l.value.trim(),
3790
- align: n.value
3821
+ align: o.value
3791
3822
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
3792
3823
  }
3793
3824
  }
@@ -3826,8 +3857,8 @@ const I = class I {
3826
3857
  formSelect(t, e) {
3827
3858
  const i = document.createElement("select");
3828
3859
  return i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff", t.forEach(([s, l]) => {
3829
- const n = document.createElement("option");
3830
- n.value = s, n.textContent = l, s === e && (n.selected = !0), i.appendChild(n);
3860
+ const o = document.createElement("option");
3861
+ o.value = s, o.textContent = l, s === e && (o.selected = !0), i.appendChild(o);
3831
3862
  }), i;
3832
3863
  }
3833
3864
  formBg(t) {
@@ -3837,8 +3868,8 @@ const I = class I {
3837
3868
  s.type = "color", s.value = i || "#ffffff", s.style.cssText = "width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";
3838
3869
  const l = document.createElement("label");
3839
3870
  l.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
3840
- const n = document.createElement("input");
3841
- return n.type = "checkbox", n.checked = !!i, l.append(n, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => n.checked = !0), e.append(s, l), { wrap: e, color: s, fill: n };
3871
+ const o = document.createElement("input");
3872
+ return o.type = "checkbox", o.checked = !!i, l.append(o, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => o.checked = !0), e.append(s, l), { wrap: e, color: s, fill: o };
3842
3873
  }
3843
3874
  setOrClear(t, e, i) {
3844
3875
  i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
@@ -3849,11 +3880,11 @@ const I = class I {
3849
3880
  alert(this.t("nocell"));
3850
3881
  return;
3851
3882
  }
3852
- let e, i, s, l, n;
3883
+ let e, i, s, l, o;
3853
3884
  this.dialog(
3854
3885
  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(
3886
+ (n) => {
3887
+ e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(n, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(n, this.t("tblheight"), i), s = this.formSelect(
3857
3888
  [
3858
3889
  ["", this.t("alignnone")],
3859
3890
  ["left", this.t("alignleft")],
@@ -3861,7 +3892,7 @@ const I = class I {
3861
3892
  ["right", this.t("alignright")]
3862
3893
  ],
3863
3894
  t.style.textAlign || ""
3864
- ), this.formRow(o, this.t("tblalign"), s), l = this.formSelect(
3895
+ ), this.formRow(n, this.t("tblalign"), s), l = this.formSelect(
3865
3896
  [
3866
3897
  ["", this.t("alignnone")],
3867
3898
  ["top", this.t("valigntop")],
@@ -3869,7 +3900,7 @@ const I = class I {
3869
3900
  ["bottom", this.t("valignbottom")]
3870
3901
  ],
3871
3902
  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);
3903
+ ), this.formRow(n, this.t("valign"), l), o = this.formBg(t.style.backgroundColor || ""), this.formRow(n, this.t("backcolor"), o.wrap);
3873
3904
  },
3874
3905
  [
3875
3906
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3877,7 +3908,7 @@ const I = class I {
3877
3908
  label: this.t("save"),
3878
3909
  primary: !0,
3879
3910
  action: () => {
3880
- this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", l.value), this.setOrClear(t, "background-color", n.fill.checked ? n.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
3911
+ this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", l.value), this.setOrClear(t, "background-color", o.fill.checked ? o.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
3881
3912
  }
3882
3913
  }
3883
3914
  ]
@@ -3915,11 +3946,11 @@ const I = class I {
3915
3946
  return;
3916
3947
  }
3917
3948
  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
+ let o, n;
3919
3950
  this.dialog(
3920
3951
  this.t("colprops").replace("…", ""),
3921
3952
  (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 = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(r, this.t("tblwidth"), o), n = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), n.wrap);
3923
3954
  },
3924
3955
  [
3925
3956
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3928,7 +3959,7 @@ const I = class I {
3928
3959
  primary: !0,
3929
3960
  action: () => {
3930
3961
  l.forEach((r) => {
3931
- this.setOrClear(r, "width", n.value.trim()), this.setOrClear(r, "background-color", o.fill.checked ? o.color.value : "");
3962
+ this.setOrClear(r, "width", o.value.trim()), this.setOrClear(r, "background-color", n.fill.checked ? n.color.value : "");
3932
3963
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
3933
3964
  }
3934
3965
  }
@@ -3944,8 +3975,8 @@ const I = class I {
3944
3975
  const s = document.createElement("div");
3945
3976
  s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
3946
3977
  <div class="body"></div><footer></footer>`, s.querySelector("header button").onclick = () => this.closeDlg(), e(s.querySelector(".body")), (i || [{ label: this.t("close"), primary: !0, action: () => this.closeDlg() }]).forEach((l) => {
3947
- const n = document.createElement("button");
3948
- n.type = "button", n.textContent = l.label, l.primary && (n.className = "pri"), n.onclick = l.action, s.querySelector("footer").appendChild(n);
3978
+ const o = document.createElement("button");
3979
+ o.type = "button", o.textContent = l.label, l.primary && (o.className = "pri"), o.onclick = l.action, s.querySelector("footer").appendChild(o);
3949
3980
  }), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (l) => {
3950
3981
  l.target === this.dlgOvl && this.closeDlg();
3951
3982
  }), document.body.appendChild(this.dlgOvl);
@@ -4009,31 +4040,31 @@ const I = class I {
4009
4040
  this.saveSel(), this.dialog(t, (s) => {
4010
4041
  const l = document.createElement("div");
4011
4042
  l.className = "chmap";
4012
- const n = document.createElement("div");
4013
- n.className = "chtabs";
4014
4043
  const o = document.createElement("div");
4015
- o.className = "chpanel";
4044
+ o.className = "chtabs";
4045
+ const n = document.createElement("div");
4046
+ n.className = "chpanel";
4016
4047
  const r = document.createElement("div");
4017
- r.className = "chgrid" + (i ? " emgrid" : ""), o.appendChild(r);
4048
+ r.className = "chgrid" + (i ? " emgrid" : ""), n.appendChild(r);
4018
4049
  const a = (d) => {
4019
- n.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), r.innerHTML = "", e[d].chars.forEach((p) => {
4050
+ o.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), r.innerHTML = "", e[d].chars.forEach((p) => {
4020
4051
  const u = document.createElement("button");
4021
4052
  u.type = "button", u.textContent = p, u.onclick = () => {
4022
4053
  this.closeDlg(), this.exec("insertText", p);
4023
4054
  }, r.appendChild(u);
4024
- }), o.scrollTop = 0;
4055
+ }), n.scrollTop = 0;
4025
4056
  };
4026
4057
  e.forEach((d, p) => {
4027
4058
  const u = document.createElement("button");
4028
- 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);
4059
+ u.type = "button", u.textContent = this.t(d.key), u.addEventListener("click", () => a(p)), o.appendChild(u);
4060
+ }), l.append(o, n), s.appendChild(l), a(0);
4030
4061
  });
4031
4062
  }
4032
4063
  charMap() {
4033
- this.glyphPickerDlg(this.t("charmap").replace("…", ""), bt, !1);
4064
+ this.glyphPickerDlg(this.t("charmap").replace("…", ""), yt, !1);
4034
4065
  }
4035
4066
  emojiMap() {
4036
- this.glyphPickerDlg(this.t("emoji").replace("…", ""), yt, !0);
4067
+ this.glyphPickerDlg(this.t("emoji").replace("…", ""), xt, !0);
4037
4068
  }
4038
4069
  printDoc() {
4039
4070
  const t = window.open("", "_blank");
@@ -4095,17 +4126,17 @@ const I = class I {
4095
4126
  const i = document.createElement("button");
4096
4127
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
4097
4128
  const s = () => {
4098
- const l = e.value.trim(), n = this.phActive;
4099
- if (!n) return;
4129
+ const l = e.value.trim(), o = this.phActive;
4130
+ if (!o) return;
4100
4131
  if (!/^(https?:|data:image\/|blob:)/i.test(l)) {
4101
4132
  e.classList.add("err"), e.focus();
4102
4133
  return;
4103
4134
  }
4104
4135
  i.disabled = !0, e.disabled = !0;
4105
- const o = new Image();
4106
- o.onload = () => this.replacePlaceholderWithImage(n, l, ""), o.onerror = () => {
4136
+ const n = new Image();
4137
+ n.onload = () => this.replacePlaceholderWithImage(o, l, ""), n.onerror = () => {
4107
4138
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4108
- }, o.src = l;
4139
+ }, n.src = l;
4109
4140
  };
4110
4141
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (l) => {
4111
4142
  l.key === "Enter" ? (l.preventDefault(), s()) : l.key === "Escape" && (l.stopPropagation(), this.renderPhCtxButtons());
@@ -4131,8 +4162,8 @@ const I = class I {
4131
4162
  s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((l) => {
4132
4163
  this.ed.contains(e) && this.replacePlaceholderWithImage(e, l, i);
4133
4164
  }).catch((l) => {
4134
- var n;
4135
- this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (n = this.onImageUploadError) == null || n.call(this, l, t));
4165
+ var o;
4166
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (o = this.onImageUploadError) == null || o.call(this, l, t));
4136
4167
  });
4137
4168
  }
4138
4169
  replacePlaceholderWithImage(t, e, i) {
@@ -4170,8 +4201,8 @@ const I = class I {
4170
4201
  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
4202
  const l = t.naturalWidth;
4172
4203
  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);
4204
+ const o = this.contentWidth(), n = Math.round(o > 0 ? Math.min(l, o) : l);
4205
+ t.setAttribute("width", String(n)), t.style.width = n + "px", t.style.height = "auto", i(!0);
4175
4206
  };
4176
4207
  t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
4177
4208
  }
@@ -4246,20 +4277,20 @@ const I = class I {
4246
4277
  const i = document.createElement("button");
4247
4278
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertvideo");
4248
4279
  const s = () => {
4249
- const l = e.value.trim(), n = this.vphActive;
4250
- if (!n) return;
4280
+ const l = e.value.trim(), o = this.vphActive;
4281
+ if (!o) return;
4251
4282
  if (!/^(https?:|data:video\/|blob:)/i.test(l)) {
4252
4283
  e.classList.add("err"), e.focus();
4253
4284
  return;
4254
4285
  }
4255
- const o = this.videoEmbedUrl(l);
4256
- if (o) {
4257
- this.replacePlaceholderWithEmbed(n, o);
4286
+ const n = this.videoEmbedUrl(l);
4287
+ if (n) {
4288
+ this.replacePlaceholderWithEmbed(o, n);
4258
4289
  return;
4259
4290
  }
4260
4291
  i.disabled = !0, e.disabled = !0;
4261
4292
  const r = document.createElement("video");
4262
- r.preload = "metadata", r.onloadedmetadata = () => this.replacePlaceholderWithVideo(n, l, ""), r.onerror = () => {
4293
+ r.preload = "metadata", r.onloadedmetadata = () => this.replacePlaceholderWithVideo(o, l, ""), r.onerror = () => {
4263
4294
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4264
4295
  }, r.src = l;
4265
4296
  };
@@ -4287,8 +4318,8 @@ const I = class I {
4287
4318
  s && (s.textContent = this.t("uploading")), this.videoUploadHandler(t).then((l) => {
4288
4319
  this.ed.contains(e) && this.replacePlaceholderWithVideo(e, l, i);
4289
4320
  }).catch((l) => {
4290
- var n;
4291
- this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (n = this.onVideoUploadError) == null || n.call(this, l, t));
4321
+ var o;
4322
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (o = this.onVideoUploadError) == null || o.call(this, l, t));
4292
4323
  });
4293
4324
  }
4294
4325
  replacePlaceholderWithVideo(t, e, i) {
@@ -4332,14 +4363,14 @@ const I = class I {
4332
4363
  (d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
4333
4364
  }, s = (a) => {
4334
4365
  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) => {
4366
+ }, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
4336
4367
  const g = this.ctxBtn(a, d, u);
4337
4368
  return g.classList.toggle("on", p), g;
4338
4369
  };
4339
4370
  return e.append(
4340
4371
  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
+ r(c.aligncenter, this.t("aligncenter"), n, () => s("center")),
4373
+ r(c.alignright, this.t("alignright"), o, () => s("right")),
4343
4374
  this.ctxSep(),
4344
4375
  r(c.trash, this.t("deletevideo"), !1, () => {
4345
4376
  t.remove(), this.clearVidHandles(), this.onChange();
@@ -4381,8 +4412,8 @@ const I = class I {
4381
4412
  * (videoUploadHandler when configured, else inline base64). */
4382
4413
  videoDlg() {
4383
4414
  this.saveSel();
4384
- let t, e, i, s, l, n;
4385
- const o = (a, d) => {
4415
+ let t, e, i, s, l, o;
4416
+ const n = (a, d) => {
4386
4417
  const p = document.createElement("div");
4387
4418
  p.className = "dfield";
4388
4419
  const u = document.createElement("label");
@@ -4399,10 +4430,10 @@ const I = class I {
4399
4430
  const p = [], u = (f, b) => {
4400
4431
  const y = document.createElement("button");
4401
4432
  y.type = "button", y.textContent = this.t(f);
4402
- const C = document.createElement("div");
4403
- C.className = "dtabpanel", b(C);
4433
+ const w = document.createElement("div");
4434
+ w.className = "dtabpanel", b(w);
4404
4435
  const S = p.length;
4405
- p.push(C), y.addEventListener("click", () => g(S)), d.appendChild(y);
4436
+ p.push(w), y.addEventListener("click", () => g(S)), d.appendChild(y);
4406
4437
  }, g = (f) => {
4407
4438
  d.querySelectorAll("button").forEach((b, y) => b.classList.toggle("on", y === f)), p.forEach((b, y) => b.style.display = y === f ? "" : "none");
4408
4439
  };
@@ -4412,34 +4443,34 @@ const I = class I {
4412
4443
  b.className = "drow";
4413
4444
  const y = document.createElement("button");
4414
4445
  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", () => {
4446
+ const w = document.createElement("input");
4447
+ w.type = "file", w.accept = this.options.videoFileTypes.join(","), w.style.display = "none", y.addEventListener("click", () => {
4448
+ w.value = "", w.click();
4449
+ }), w.addEventListener("change", () => {
4419
4450
  var L;
4420
- const w = (L = C.files) == null ? void 0 : L[0];
4421
- if (!w) return;
4451
+ const C = (L = w.files) == null ? void 0 : L[0];
4452
+ if (!C) return;
4422
4453
  y.disabled = !0, y.textContent = this.t("uploading");
4423
4454
  const k = (H) => {
4424
4455
  t.value = H, y.disabled = !1, y.textContent = this.t("uploadvideo");
4425
4456
  };
4426
4457
  if (this.videoUploadHandler)
4427
- this.videoUploadHandler(w).then(k).catch((H) => {
4458
+ this.videoUploadHandler(C).then(k).catch((H) => {
4428
4459
  var U;
4429
- y.disabled = !1, y.textContent = this.t("uploadfailed"), (U = this.onVideoUploadError) == null || U.call(this, H, w);
4460
+ y.disabled = !1, y.textContent = this.t("uploadfailed"), (U = this.onVideoUploadError) == null || U.call(this, H, C);
4430
4461
  });
4431
4462
  else {
4432
4463
  const H = new FileReader();
4433
- H.onload = () => k(H.result), H.readAsDataURL(w);
4464
+ H.onload = () => k(H.result), H.readAsDataURL(C);
4434
4465
  }
4435
- }), b.append(t, y, C), t.style.flex = "1", f.appendChild(o("vidsource", b));
4466
+ }), b.append(t, y, w), t.style.flex = "1", f.appendChild(n("vidsource", b));
4436
4467
  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);
4468
+ 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(n("tblwidth", e), n("tblheight", i)), f.appendChild(S);
4438
4469
  }), u("vidembed", (f) => {
4439
4470
  const b = document.createElement("p");
4440
4471
  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
4472
  }), u("vidadvanced", (f) => {
4442
- l = r(), n = r(), f.append(o("vidaltsource", l), o("vidposter", n));
4473
+ l = r(), o = r(), f.append(n("vidaltsource", l), n("vidposter", o));
4443
4474
  });
4444
4475
  const m = document.createElement("div");
4445
4476
  m.className = "dtabbody", p.forEach((f) => m.appendChild(f)), a.append(d, m), g(0), setTimeout(() => t.focus(), 0);
@@ -4460,7 +4491,7 @@ const I = class I {
4460
4491
  if (g)
4461
4492
  document.execCommand("insertHTML", !1, this.videoEmbedHTML(g, p, u));
4462
4493
  else {
4463
- const m = l.value.trim(), f = n.value.trim();
4494
+ const m = l.value.trim(), f = o.value.trim();
4464
4495
  document.execCommand(
4465
4496
  "insertHTML",
4466
4497
  !1,
@@ -4522,13 +4553,13 @@ const I = class I {
4522
4553
  if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (d = i.parentElement) != null && d.closest("code, pre")) return;
4523
4554
  const l = (i.textContent || "").slice(0, e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);
4524
4555
  if (!l) return;
4525
- const n = l[1];
4526
- if (/^\s|\s$/.test(n)) return;
4556
+ const o = l[1];
4557
+ if (/^\s|\s$/.test(o)) return;
4527
4558
  t.preventDefault();
4528
- const o = document.createRange();
4529
- o.setStart(i, e.anchorOffset - n.length - 1), o.setEnd(i, e.anchorOffset), o.deleteContents();
4559
+ const n = document.createRange();
4560
+ n.setStart(i, e.anchorOffset - o.length - 1), n.setEnd(i, e.anchorOffset), n.deleteContents();
4530
4561
  const r = document.createElement("code");
4531
- r.textContent = n, o.insertNode(r);
4562
+ r.textContent = o, n.insertNode(r);
4532
4563
  const a = document.createRange();
4533
4564
  a.setStartAfter(r), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
4534
4565
  }
@@ -4542,22 +4573,22 @@ const I = class I {
4542
4573
  s.className = "dsel";
4543
4574
  const l = document.createElement("button");
4544
4575
  l.type = "button", l.className = "dsel-btn";
4545
- 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]) => {
4576
+ const o = document.createElement("span");
4577
+ o.className = "lbl", o.textContent = ((r = t.find(([a]) => a === e)) == null ? void 0 : r[1]) || "", l.append(o), l.insertAdjacentHTML("beforeend", c.chev);
4578
+ const n = document.createElement("div");
4579
+ return n.className = "dsel-list", t.forEach(([a, d]) => {
4549
4580
  const p = document.createElement("button");
4550
4581
  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);
4582
+ i = a, o.textContent = d, n.querySelectorAll("button").forEach((u) => u.classList.toggle("on", u === p)), s.classList.remove("open"), l.focus();
4583
+ }), n.appendChild(p);
4553
4584
  }), l.addEventListener("click", () => {
4554
4585
  var a;
4555
- s.classList.toggle("open"), s.classList.contains("open") && ((a = o.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
4586
+ s.classList.toggle("open"), s.classList.contains("open") && ((a = n.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
4556
4587
  }), s.addEventListener("focusout", (a) => {
4557
4588
  s.contains(a.relatedTarget) || s.classList.remove("open");
4558
4589
  }), s.addEventListener("keydown", (a) => {
4559
4590
  a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), l.focus());
4560
- }), s.append(l, o), { el: s, value: () => i };
4591
+ }), s.append(l, n), { el: s, value: () => i };
4561
4592
  }
4562
4593
  /** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
4563
4594
  * paste or type code into. Inserts a non-editable <pre class="code-block">
@@ -4568,11 +4599,11 @@ const I = class I {
4568
4599
  this.dialog(
4569
4600
  this.t("codedlgttl"),
4570
4601
  (s) => {
4571
- var o;
4602
+ var n;
4572
4603
  const l = document.createElement("div");
4573
4604
  l.className = "dfield";
4574
- 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);
4605
+ const o = document.createElement("label");
4606
+ o.textContent = this.t("codelang"), e = this.dlgSelect(X, (t == null ? void 0 : t.dataset.lang) || "plain"), l.append(o, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((n = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : n.textContent) || "", i.placeholder = "const answer = 42;", s.append(l, i), setTimeout(() => i.focus(), 0);
4576
4607
  },
4577
4608
  [
4578
4609
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4580,11 +4611,11 @@ const I = class I {
4580
4611
  label: this.t("save"),
4581
4612
  primary: !0,
4582
4613
  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;
4614
+ var n;
4615
+ const s = i.value.replace(/\s+$/, ""), l = e.value(), o = ((n = X.find(([r]) => r === l)) == null ? void 0 : n[1]) || l;
4585
4616
  if (this.closeDlg(), !!s.trim()) {
4586
4617
  if (t) {
4587
- t.dataset.lang = l, t.setAttribute("data-lang-label", n);
4618
+ t.dataset.lang = l, t.setAttribute("data-lang-label", o);
4588
4619
  const r = t.querySelector("code") || t;
4589
4620
  r.textContent = s, this.clearCodeSel(), this.onChange();
4590
4621
  return;
@@ -4592,7 +4623,7 @@ const I = class I {
4592
4623
  this.restoreSel(), document.execCommand(
4593
4624
  "insertHTML",
4594
4625
  !1,
4595
- `<pre class="code-block" contenteditable="false" data-lang="${l}" data-lang-label="${this.escapeAttr(n)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
4626
+ `<pre class="code-block" contenteditable="false" data-lang="${l}" data-lang-label="${this.escapeAttr(o)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
4596
4627
  ), this.onChange();
4597
4628
  }
4598
4629
  }
@@ -4649,8 +4680,8 @@ const I = class I {
4649
4680
  /** Miniature div-based mockup of a layout, mirroring what the block looks
4650
4681
  like in the editor: grey box = image slot, bars = heading/paragraph. */
4651
4682
  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>`;
4683
+ 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>`, o = (r) => `<span class="pv-row">${r}</span>`, n = l(i + s(100) + s(88));
4684
+ return t === "img-left" ? `<span class="pv">${o(e + n)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${o(n + 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
4685
  }
4655
4686
  buildTemplatePickInto(t, e) {
4656
4687
  const i = document.createElement("div");
@@ -4676,7 +4707,7 @@ const I = class I {
4676
4707
  renderTplCtxButtons() {
4677
4708
  const t = this.tplCtx, e = this.tplActive;
4678
4709
  !t || !e || (t.innerHTML = "", $.forEach((i) => {
4679
- const s = this.ctxBtn(jt[i], this.t(_[i]), () => this.setTplLayout(i));
4710
+ const s = this.ctxBtn(Gt[i], this.t(_[i]), () => this.setTplLayout(i));
4680
4711
  s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
4681
4712
  }), t.append(this.ctxSep(), this.ctxBtn(c.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
4682
4713
  }
@@ -4715,7 +4746,7 @@ const I = class I {
4715
4746
  /* ---------------------------------------------------------- table resize */
4716
4747
  clearTableHandles() {
4717
4748
  var t, e, i, s, l;
4718
- (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((n) => n.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (l = this.tblActive) == null || l.classList.remove("tbl-selected"), this.tblActive = null;
4749
+ (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((o) => o.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (l = this.tblActive) == null || l.classList.remove("tbl-selected"), this.tblActive = null;
4719
4750
  }
4720
4751
  /** Blue outline around the cell that holds the caret, so it is clear
4721
4752
  which cell / row / column the table operations will target. */
@@ -4742,8 +4773,8 @@ const I = class I {
4742
4773
  return;
4743
4774
  }
4744
4775
  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";
4776
+ const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), o = t === "row" ? l.left : s.left, n = t === "row" ? l.top : i.top, r = t === "row" ? l.width : s.width, a = t === "row" ? l.height : i.height;
4777
+ this.tblOpMark.style.left = o + scrollX + "px", this.tblOpMark.style.top = n + scrollY + "px", this.tblOpMark.style.width = r + "px", this.tblOpMark.style.height = a + "px";
4747
4778
  }
4748
4779
  /** Lowest allowed top for floating context toolbars — keeps them from
4749
4780
  covering the editor menubar/toolbar when the target sits on the first line. */
@@ -4752,7 +4783,7 @@ const I = class I {
4752
4783
  }
4753
4784
  ctxBtn(t, e, i, s) {
4754
4785
  const l = document.createElement("button");
4755
- return l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (n) => n.preventDefault()), l.addEventListener("click", i), l;
4786
+ return l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (o) => o.preventDefault()), l.addEventListener("click", i), l;
4756
4787
  }
4757
4788
  ctxSep() {
4758
4789
  const t = document.createElement("div");
@@ -4789,20 +4820,20 @@ const I = class I {
4789
4820
  this.clearTableHandles();
4790
4821
  return;
4791
4822
  }
4792
- 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
- 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) {
4823
+ const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, o = e.bottom + scrollY;
4824
+ if (this.tblCorner && (this.tblCorner.style.top = o - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : l - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
4794
4825
  const r = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
4795
4826
  let d = s + (l - s) / 2 - r / 2;
4796
4827
  d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - r - 8));
4797
4828
  let p = i - a - 8;
4798
- p < this.ctxMinTop() && (p = n + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
4829
+ p < this.ctxMinTop() && (p = o + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
4799
4830
  }
4800
4831
  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
+ const n = this.tblActive.rows[0];
4833
+ if (n)
4834
+ for (let r = 0; r < n.cells.length - 1; r++) {
4835
+ const a = n.cells[r].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
4836
+ p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = o - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (u) => this.startColBarDrag(u, r)), this.tblColBars.push(p);
4806
4837
  }
4807
4838
  this.positionCellMarker(), this.positionOpMark();
4808
4839
  }
@@ -4820,27 +4851,27 @@ const I = class I {
4820
4851
  const e = this.tblActive;
4821
4852
  if (!e) return;
4822
4853
  const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, l = e.getBoundingClientRect().width;
4823
- e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((n) => {
4824
- const o = (a) => {
4854
+ e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((o) => {
4855
+ const n = (a) => {
4825
4856
  const d = i ? -(a.clientX - s) : a.clientX - s;
4826
4857
  e.style.width = Math.max(60, Math.round(l + d)) + "px", this.positionTableHandles();
4827
4858
  }, r = () => {
4828
- window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", r), n(), this.onChange();
4859
+ window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", r), o(), this.onChange();
4829
4860
  };
4830
- window.addEventListener("mousemove", o), window.addEventListener("mouseup", r);
4861
+ window.addEventListener("mousemove", n), window.addEventListener("mouseup", r);
4831
4862
  });
4832
4863
  }
4833
4864
  startColBarDrag(t, e) {
4834
4865
  t.preventDefault(), t.stopPropagation();
4835
4866
  const i = this.tblActive;
4836
4867
  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;
4868
+ const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), o = l.map((p) => p.cells[e]).filter(Boolean), n = l.map((p) => p.cells[e + 1]).filter(Boolean);
4869
+ if (!o.length || !n.length) return;
4870
+ const r = t.clientX, a = o[0].getBoundingClientRect().width, d = n[0].getBoundingClientRect().width;
4840
4871
  i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
4841
4872
  const u = (m) => {
4842
4873
  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
+ o.forEach((b) => b.style.width = Math.max(24, Math.round(a + f)) + "px"), n.forEach((b) => b.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
4844
4875
  }, g = () => {
4845
4876
  window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", g), p(), this.onChange();
4846
4877
  };
@@ -4859,7 +4890,7 @@ const I = class I {
4859
4890
  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
4891
  }
4861
4892
  selectImage(t) {
4862
- this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Vt.map((e) => {
4893
+ this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Qt.map((e) => {
4863
4894
  const i = document.createElement("div");
4864
4895
  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
4896
  }), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
@@ -4873,14 +4904,14 @@ const I = class I {
4873
4904
  (d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
4874
4905
  }, s = (a) => {
4875
4906
  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) => {
4907
+ }, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
4877
4908
  const g = this.ctxBtn(a, d, u);
4878
4909
  return g.classList.toggle("on", p), g;
4879
4910
  };
4880
4911
  return e.append(
4881
4912
  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
+ r(c.aligncenter, this.t("aligncenter"), n, () => s("center")),
4914
+ r(c.alignright, this.t("alignright"), o, () => s("right")),
4884
4915
  this.ctxSep(),
4885
4916
  r(c.rotateleft, this.t("rotateleft"), !1, () => {
4886
4917
  this.rotateImage(t, -90), i();
@@ -4922,19 +4953,19 @@ const I = class I {
4922
4953
  this.clearImageHandles();
4923
4954
  return;
4924
4955
  }
4925
- const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, l = t.bottom + scrollY, n = {
4956
+ const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, l = t.bottom + scrollY, o = {
4926
4957
  nw: [i, e],
4927
4958
  ne: [s, e],
4928
4959
  sw: [i, l],
4929
4960
  se: [s, l]
4930
4961
  };
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";
4962
+ if (this.imgHandles.forEach((n) => {
4963
+ const [r, a] = o[n.dataset.corner];
4964
+ n.style.left = r - 5 + "px", n.style.top = a - 5 + "px";
4934
4965
  }), 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));
4966
+ const n = this.imgCtx.offsetWidth, r = this.imgCtx.offsetHeight;
4967
+ let a = i + (s - i) / 2 - n / 2;
4968
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - n - 8));
4938
4969
  let d = e - r - 8;
4939
4970
  d < this.ctxMinTop() && (d = l + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
4940
4971
  }
@@ -4944,12 +4975,12 @@ const I = class I {
4944
4975
  const i = this.imgActive;
4945
4976
  if (!i) return;
4946
4977
  this.cancelImgHide();
4947
- const s = t.clientX, l = i.getBoundingClientRect().width, n = e === "nw" || e === "sw" ? -1 : 1;
4948
- this.withNoTextSelect((o) => {
4978
+ const s = t.clientX, l = i.getBoundingClientRect().width, o = e === "nw" || e === "sw" ? -1 : 1;
4979
+ this.withNoTextSelect((n) => {
4949
4980
  const r = (d) => {
4950
- i.style.width = Math.max(24, Math.round(l + n * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
4981
+ i.style.width = Math.max(24, Math.round(l + o * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
4951
4982
  }, a = () => {
4952
- window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", a), o();
4983
+ window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", a), n();
4953
4984
  const d = parseInt(i.style.width, 10);
4954
4985
  d > 0 && !i.closest(".tpl-media") && (i.setAttribute("width", String(d)), i.removeAttribute("height")), this.onChange();
4955
4986
  };
@@ -4992,7 +5023,7 @@ const I = class I {
4992
5023
  this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
4993
5024
  }
4994
5025
  buildSelToolbar() {
4995
- var o;
5026
+ var n;
4996
5027
  const t = document.createElement("div");
4997
5028
  t.className = "selctx", t.dir = this.dir();
4998
5029
  const e = this.ctxBtn(
@@ -5000,8 +5031,8 @@ const I = class I {
5000
5031
  this.t("forecolor"),
5001
5032
  () => this.colorMenu(e, "fore")
5002
5033
  ), 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>');
5004
- 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));
5034
+ (n = i.querySelector("svg")) == null || n.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5035
+ const s = this.ctxBtn(c.caseic, this.t("changecase"), () => this.caseMenu(s)), l = this.ctxBtn(c.lineheight, this.t("lineheight"), () => this.lineHeightMenu(l)), o = this.ctxBtn(c.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(o));
5005
5036
  return t.append(
5006
5037
  this.ctxBtn(c.bold, this.t("bold"), () => this.exec("bold"), "bold"),
5007
5038
  this.ctxBtn(c.italic, this.t("italic"), () => this.exec("italic"), "italic"),
@@ -5016,16 +5047,16 @@ const I = class I {
5016
5047
  this.ctxBtn(c.link, this.t("linkttl"), () => this.linkDlg()),
5017
5048
  s,
5018
5049
  l,
5019
- n
5050
+ o
5020
5051
  ), t.addEventListener("mousedown", (r) => r.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5021
5052
  }
5022
5053
  positionSelToolbar(t) {
5023
5054
  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));
5055
+ const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, o = e.bottom + scrollY, n = this.selCtx.offsetWidth, r = this.selCtx.offsetHeight;
5056
+ let a = s + (l - s) / 2 - n / 2;
5057
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - n - 8));
5027
5058
  let d = i - r - 8;
5028
- d < this.ctxMinTop() && (d = n + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5059
+ d < this.ctxMinTop() && (d = o + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5029
5060
  }
5030
5061
  repositionSelToolbar() {
5031
5062
  if (!this.selCtx) return;
@@ -5082,13 +5113,13 @@ const I = class I {
5082
5113
  const u = p.querySelector("[data-id=code]");
5083
5114
  u && u.classList.toggle("on", e && !!this.closestInlineCode());
5084
5115
  });
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();
5086
- (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) => {
5116
+ const l = t ? this.closestBlock(t.anchorNode) : null, o = ((r = l == null ? void 0 : l.closest("[dir]")) == null ? void 0 : r.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5117
+ (a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && o === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && o === "rtl");
5118
+ const n = (p, u, g) => {
5088
5119
  const m = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
5089
5120
  m && (m.textContent = u || g || "", m.classList.toggle("empty", !u));
5090
5121
  };
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");
5122
+ n("fontsel", this.currentFont()), n("sizesel", this.currentSize().replace("px", "")), e && n("blocksel", Q.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5092
5123
  }
5093
5124
  countWords() {
5094
5125
  const t = (this.ed.textContent || "").trim();
@@ -5108,13 +5139,13 @@ const I = class I {
5108
5139
  return;
5109
5140
  }
5110
5141
  if (!i) {
5111
- const l = e.getData("text/plain"), n = /^\S+$/.test(l.trim()) ? this.videoEmbedUrl(l.trim()) : null;
5112
- if (n) {
5113
- document.execCommand("insertHTML", !1, this.videoEmbedHTML(n)), this.onChange();
5142
+ const l = e.getData("text/plain"), o = /^\S+$/.test(l.trim()) ? this.videoEmbedUrl(l.trim()) : null;
5143
+ if (o) {
5144
+ document.execCommand("insertHTML", !1, this.videoEmbedHTML(o)), this.onChange();
5114
5145
  return;
5115
5146
  }
5116
5147
  }
5117
- i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, It(e.getData("text/plain"))), this.onChange());
5148
+ i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, qt(e.getData("text/plain"))), this.onChange());
5118
5149
  }
5119
5150
  /** Rich-HTML paste. Before the (untouched) paste engine runs, pictures Word left
5120
5151
  * behind as unreadable file:// refs are pulled out of the clipboard's RTF flavor
@@ -5126,19 +5157,19 @@ const I = class I {
5126
5157
  let s = [];
5127
5158
  const l = e.getData("text/rtf");
5128
5159
  if (l) {
5129
- const n = Pt(t, l);
5130
- t = n.html, s = n.injected;
5160
+ const o = $t(t, l);
5161
+ t = o.html, s = o.injected;
5131
5162
  }
5132
- if (i && Ot(t) === 1) {
5133
- const n = i.getAsFile();
5134
- if (n) {
5135
- const o = t;
5163
+ if (i && _t(t) === 1) {
5164
+ const o = i.getAsFile();
5165
+ if (o) {
5166
+ const n = t;
5136
5167
  this.saveSel();
5137
5168
  const r = new FileReader();
5138
5169
  r.onload = () => {
5139
- const a = nt(o, [r.result]);
5170
+ const a = rt(n, [r.result]);
5140
5171
  this.finishRichPaste(a.html, s.concat(a.injected), !0);
5141
- }, r.onerror = () => this.finishRichPaste(o, s, !0), r.readAsDataURL(n);
5172
+ }, r.onerror = () => this.finishRichPaste(n, s, !0), r.readAsDataURL(o);
5142
5173
  return;
5143
5174
  }
5144
5175
  }
@@ -5152,26 +5183,26 @@ const I = class I {
5152
5183
  this.insertPastedHTML(t, i);
5153
5184
  return;
5154
5185
  }
5155
- const s = this.imageUploadHandler, l = e.filter((n, o) => e.indexOf(n) === o);
5186
+ const s = this.imageUploadHandler, l = e.filter((o, n) => e.indexOf(o) === n);
5156
5187
  i || this.saveSel(), Promise.all(
5157
- l.map((n, o) => {
5158
- const r = Ft(n, "pasted-image-" + (o + 1));
5188
+ l.map((o, n) => {
5189
+ const r = zt(o, "pasted-image-" + (n + 1));
5159
5190
  return r ? s(r).catch((a) => {
5160
5191
  var d;
5161
- return (d = this.onImageUploadError) == null || d.call(this, a, r), n;
5162
- }) : Promise.resolve(n);
5192
+ return (d = this.onImageUploadError) == null || d.call(this, a, r), o;
5193
+ }) : Promise.resolve(o);
5163
5194
  })
5164
- ).then((n) => {
5165
- let o = t;
5195
+ ).then((o) => {
5196
+ let n = t;
5166
5197
  l.forEach((r, a) => {
5167
- n[a] !== r && (o = o.split(r).join(n[a]));
5168
- }), this.insertPastedHTML(o, !0);
5198
+ o[a] !== r && (n = n.split(r).join(o[a]));
5199
+ }), this.insertPastedHTML(n, !0);
5169
5200
  });
5170
5201
  }
5171
5202
  /** `deferred` means the insert is happening after an async hop, so the caret the
5172
5203
  * paste started from has to be put back first. */
5173
5204
  insertPastedHTML(t, e = !1) {
5174
- e && this.restoreSel(), document.execCommand("insertHTML", !1, At(t, this.dir())), e && this.saveSel(), this.onChange();
5205
+ e && this.restoreSel(), document.execCommand("insertHTML", !1, It(t, this.dir())), e && this.saveSel(), this.onChange();
5175
5206
  }
5176
5207
  /* ---------------------------------------------------------- init */
5177
5208
  initUI() {
@@ -5179,18 +5210,18 @@ const I = class I {
5179
5210
  }
5180
5211
  };
5181
5212
  I.instanceCounter = 0, I.TBR_COLLAPSE_MAX = 992;
5182
- let st = I;
5213
+ let lt = I;
5183
5214
  export {
5184
5215
  Q as BLOCKS,
5185
- pe as CHARS,
5186
- vt as COLORS,
5187
- pt as FONTS,
5188
- st as FableEditor,
5189
- ct as I18N,
5216
+ ge as CHARS,
5217
+ bt as COLORS,
5218
+ ut as FONTS,
5219
+ lt as FableEditor,
5220
+ ht as I18N,
5190
5221
  c as IC,
5191
- ut as SIZES,
5192
- ue as TXT,
5193
- At as cleanPastedHTML,
5194
- O as getStrings,
5195
- It as normalizeTextPaste
5222
+ mt as SIZES,
5223
+ fe as TXT,
5224
+ It as cleanPastedHTML,
5225
+ F as getStrings,
5226
+ qt as normalizeTextPaste
5196
5227
  };