digi-mathchem-editor 1.0.27 → 1.0.29

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,6 +1,6 @@
1
1
  var G = Object.defineProperty;
2
- var Y = (o, t, e) => t in o ? G(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var U = (o, t, e) => Y(o, typeof t != "symbol" ? t + "" : t, e);
2
+ var Y = (a, t, e) => t in a ? G(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var U = (a, t, e) => Y(a, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { MathfieldElement as V } from "mathlive";
5
5
  const J = {
6
6
  cmeLeftRightAbove: {
@@ -206,7 +206,10 @@ const z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAA
206
206
  // Group 1 – Cancel (1 col × 1 row)
207
207
  { type: "sep", cols: 1, small: !0 },
208
208
  {
209
- label: "⌿",
209
+ label: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
210
+ <rect x="9" y="7" width="6" height="10" rx="1" stroke="#2E7D32" stroke-width="2" fill="none" />
211
+ <line x1="9" y1="21" x2="15" y2="3" stroke="#666" stroke-width="2" stroke-linecap="round" />
212
+ </svg>`,
210
213
  insert: "\\cancel{#?}",
211
214
  isWidget: !0,
212
215
  title: "Cancel strike"
@@ -267,8 +270,8 @@ const z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAA
267
270
  small: !0,
268
271
  moreItems: [
269
272
  { label: "≠", insert: "\\neq", title: "Not equal" },
270
- { label: "≉", insert: "\\napprox", title: "Not almost equal to" },
271
- { label: "≢", insert: "\\nequiv", title: "Not identical to" },
273
+ { label: "≉", insert: "\\not\\approx", title: "Not almost equal to" },
274
+ { label: "≢", insert: "\\not\\equiv", title: "Not identical to" },
272
275
  { label: "≁", insert: "\\nsim", title: "Not similar" }
273
276
  ]
274
277
  },
@@ -4258,7 +4261,10 @@ const z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAA
4258
4261
  // Group 1 – Cancel (1 col × 1 row)
4259
4262
  { type: "sep", cols: 1, small: !0 },
4260
4263
  {
4261
- label: "⌿",
4264
+ label: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
4265
+ <rect x="9" y="7" width="6" height="10" rx="1" stroke="#2E7D32" stroke-width="2" fill="none" />
4266
+ <line x1="9" y1="21" x2="15" y2="3" stroke="#666" stroke-width="2" stroke-linecap="round" />
4267
+ </svg>`,
4262
4268
  insert: "\\cancel{#?}",
4263
4269
  isWidget: !0,
4264
4270
  title: "Cancel strike"
@@ -6072,24 +6078,32 @@ const z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAA
6072
6078
  label: '<svg width="26" height="26" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="3" style="display: inline-block; vertical-align: middle; color: #2E7D32"><rect x="10" y="6" width="8" height="14" rx="1" /><rect x="28" y="6" width="8" height="14" rx="1" /><rect x="46" y="6" width="8" height="14" rx="1" /><rect x="10" y="25" width="8" height="14" rx="1" /><rect x="28" y="25" width="8" height="14" rx="1" /><rect x="46" y="25" width="8" height="14" rx="1" /><rect x="10" y="44" width="8" height="14" rx="1" /><rect x="28" y="44" width="8" height="14" rx="1" /><rect x="46" y="44" width="8" height="14" rx="1" /></svg>',
6073
6079
  insert: "matrix",
6074
6080
  cls: "template",
6081
+ action: "MATRIX_HOVER",
6082
+ matrixType: "matrix",
6075
6083
  title: "3×3 Matrix"
6076
6084
  },
6077
6085
  {
6078
6086
  label: '<svg width="26" height="26" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="3" style="display: inline-block; vertical-align: middle; color: #2E7D32"><line x1="8" y1="4" x2="8" y2="60" stroke="#222" stroke-width="4" /><line x1="56" y1="4" x2="56" y2="60" stroke="#222" stroke-width="4" /><rect x="18" y="12" width="8" height="14" rx="1" /><rect x="38" y="12" width="8" height="14" rx="1" /><rect x="18" y="38" width="8" height="14" rx="1" /><rect x="38" y="38" width="8" height="14" rx="1" /></svg>',
6079
6087
  insert: "vmatrix",
6080
6088
  cls: "template",
6089
+ action: "MATRIX_HOVER",
6090
+ matrixType: "vmatrix",
6081
6091
  title: "2×2 Determinant"
6082
6092
  },
6083
6093
  {
6084
6094
  label: '<svg width="26" height="26" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="3" style="display: inline-block; vertical-align: middle; color: #2E7D32"><path d="M14 6H8V58H14" stroke="#222" stroke-width="4" fill="none" /><path d="M50 6H56V58H50" stroke="#222" stroke-width="4" fill="none" /><rect x="18" y="12" width="8" height="14" rx="1" /><rect x="38" y="12" width="8" height="14" rx="1" /><rect x="18" y="38" width="8" height="14" rx="1" /><rect x="38" y="38" width="8" height="14" rx="1" /></svg>',
6085
6095
  insert: "bmatrix",
6086
6096
  cls: "template",
6097
+ action: "MATRIX_HOVER",
6098
+ matrixType: "bmatrix",
6087
6099
  title: "2×2 Matrix"
6088
6100
  },
6089
6101
  {
6090
6102
  label: '<svg width="26" height="26" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="3" style="display: inline-block; vertical-align: middle; color: #2E7D32"><path d="M16 6C8 16 8 48 16 58" stroke="#222" stroke-width="4" fill="none" /><path d="M48 6C56 16 56 48 48 58" stroke="#222" stroke-width="4" fill="none" /><rect x="18" y="12" width="8" height="14" rx="1" /><rect x="38" y="12" width="8" height="14" rx="1" /><rect x="18" y="38" width="8" height="14" rx="1" /><rect x="38" y="38" width="8" height="14" rx="1" /></svg>',
6091
6103
  insert: "pmatrix",
6092
6104
  cls: "template",
6105
+ action: "MATRIX_HOVER",
6106
+ matrixType: "pmatrix",
6093
6107
  title: "2×2 Parenthesis Matrix"
6094
6108
  },
6095
6109
  // { label: '□', insert: 'matrix', cls: 'template', title: 'Matrix' },
@@ -7353,58 +7367,58 @@ const z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAA
7353
7367
  // ]
7354
7368
  // },
7355
7369
  ];
7356
- function tt(o) {
7357
- if (!o) return "";
7370
+ function tt(a) {
7371
+ if (!a) return "";
7358
7372
  let t = "", e = 0;
7359
- for (; e < o.length; ) {
7360
- let r = o.indexOf("\\placeholder", e);
7373
+ for (; e < a.length; ) {
7374
+ let r = a.indexOf("\\placeholder", e);
7361
7375
  if (r === -1) {
7362
- t += o.slice(e);
7376
+ t += a.slice(e);
7363
7377
  break;
7364
7378
  }
7365
- if (t += o.slice(e, r), e = r + 12, o[e] === "[") {
7366
- let l = 1;
7367
- for (e++; e < o.length && l > 0; )
7368
- o[e] === "[" ? l++ : o[e] === "]" && l--, e++;
7379
+ if (t += a.slice(e, r), e = r + 12, a[e] === "[") {
7380
+ let s = 1;
7381
+ for (e++; e < a.length && s > 0; )
7382
+ a[e] === "[" ? s++ : a[e] === "]" && s--, e++;
7369
7383
  }
7370
- if (o[e] === "{") {
7371
- let l = 1, a = e + 1;
7372
- for (e++; e < o.length && l > 0; )
7373
- o[e] === "{" ? l++ : o[e] === "}" && l--, e++;
7374
- let s = o.slice(a, e - 1);
7375
- s.trim() === "" ? t += "\\quad " : t += s;
7384
+ if (a[e] === "{") {
7385
+ let s = 1, o = e + 1;
7386
+ for (e++; e < a.length && s > 0; )
7387
+ a[e] === "{" ? s++ : a[e] === "}" && s--, e++;
7388
+ let l = a.slice(o, e - 1);
7389
+ l.trim() === "" ? t += "\\quad " : t += l;
7376
7390
  }
7377
7391
  }
7378
7392
  return t;
7379
7393
  }
7380
- function et(o) {
7381
- if (!o) return "";
7394
+ function et(a) {
7395
+ if (!a) return "";
7382
7396
  let t = "", e = 0;
7383
7397
  const r = "\\text{";
7384
- for (; e < o.length; ) {
7385
- const l = o.indexOf(r, e);
7386
- if (l === -1) {
7387
- t += o.slice(e);
7398
+ for (; e < a.length; ) {
7399
+ const s = a.indexOf(r, e);
7400
+ if (s === -1) {
7401
+ t += a.slice(e);
7388
7402
  break;
7389
7403
  }
7390
- t += o.slice(e, l);
7391
- let a = 1, s = l + r.length;
7392
- for (; s < o.length && a > 0; )
7393
- o[s] === "{" ? a++ : o[s] === "}" && a--, s++;
7394
- const n = o.slice(l + r.length, s - 1);
7395
- /^['"/]+$/.test(n) || n.includes("\\textquotedbl") || n.includes("\\textquotesingle") ? t += "\\text{" + n + "}" : t += n, e = s;
7404
+ t += a.slice(e, s);
7405
+ let o = 1, l = s + r.length;
7406
+ for (; l < a.length && o > 0; )
7407
+ a[l] === "{" ? o++ : a[l] === "}" && o--, l++;
7408
+ const n = a.slice(s + r.length, l - 1);
7409
+ /^['"/]+$/.test(n) || n.includes("\\textquotedbl") || n.includes("\\textquotesingle") ? t += "\\text{" + n + "}" : t += n, e = l;
7396
7410
  }
7397
7411
  return t;
7398
7412
  }
7399
- function P(o, t) {
7413
+ function P(a, t) {
7400
7414
  let e = 0, r = t - 1;
7401
- for (; r >= 0 && o[r] === "\\"; )
7415
+ for (; r >= 0 && a[r] === "\\"; )
7402
7416
  e++, r--;
7403
7417
  return e % 2 === 1;
7404
7418
  }
7405
- function F(o) {
7406
- if (!o || typeof o != "string") return o || "";
7407
- let t = o;
7419
+ function F(a) {
7420
+ if (!a || typeof a != "string") return a || "";
7421
+ let t = a;
7408
7422
  const e = [
7409
7423
  "\\mathbfit{",
7410
7424
  "\\boldsymbol{",
@@ -7423,29 +7437,29 @@ function F(o) {
7423
7437
  "\\mathsf{",
7424
7438
  "\\mathtt{"
7425
7439
  ];
7426
- let r = !0, l = 0;
7427
- for (; r && l < 10; ) {
7428
- r = !1, l++;
7429
- for (const a of e) {
7430
- let s = 0;
7431
- for (; s < t.length; ) {
7432
- const n = t.indexOf(a, s);
7440
+ let r = !0, s = 0;
7441
+ for (; r && s < 10; ) {
7442
+ r = !1, s++;
7443
+ for (const o of e) {
7444
+ let l = 0;
7445
+ for (; l < t.length; ) {
7446
+ const n = t.indexOf(o, l);
7433
7447
  if (n === -1) break;
7434
- let h = 1, c = n + a.length;
7448
+ let h = 1, c = n + o.length;
7435
7449
  for (; c < t.length && h > 0; )
7436
7450
  t[c] === "{" && !P(t, c) ? h++ : t[c] === "}" && !P(t, c) && h--, c++;
7437
7451
  if (h === 0) {
7438
- const w = t.slice(n + a.length, c - 1);
7439
- t = t.slice(0, n) + w + t.slice(c), r = !0, s = n;
7452
+ const g = t.slice(n + o.length, c - 1);
7453
+ t = t.slice(0, n) + g + t.slice(c), r = !0, l = n;
7440
7454
  } else
7441
- s = n + a.length;
7455
+ l = n + o.length;
7442
7456
  }
7443
7457
  }
7444
7458
  }
7445
7459
  return t;
7446
7460
  }
7447
- function it(o) {
7448
- return !o || typeof o != "string" ? !1 : [
7461
+ function it(a) {
7462
+ return !a || typeof a != "string" ? !1 : [
7449
7463
  /[\^_]/,
7450
7464
  /\\frac\b/,
7451
7465
  /\\tfrac\b/,
@@ -7483,40 +7497,40 @@ function it(o) {
7483
7497
  /\\alpha\b|\\beta\b|\\gamma\b|\\delta\b|\\epsilon\b|\\zeta\b|\\eta\b|\\theta\b|\\iota\b|\\kappa\b|\\lambda\b|\\mu\b|\\nu\b|\\xi\b|\\pi\b|\\rho\b|\\sigma\b|\\tau\b|\\upsilon\b|\\phi\b|\\chi\b|\\psi\b|\\omega\b/,
7484
7498
  /\\Gamma\b|\\Delta\b|\\Theta\b|\\Lambda\b|\\Xi\b|\\Pi\b|\\Sigma\b|\\Upsilon\b|\\Phi\b|\\Psi\b|\\Omega\b/,
7485
7499
  /\\pm\b|\\times\b|\\div\b|\\leq\b|\\geq\b|\\neq\b|\\approx\b|\\infty\b|\\partial\b|\\to\b|\\rightarrow\b/
7486
- ].some((e) => e.test(o));
7500
+ ].some((e) => e.test(a));
7487
7501
  }
7488
- function lt(o, t) {
7489
- return o ? it(o) ? o : (t == null ? void 0 : t.fontFamily) === "sans-serif" ? `\\mathsf{${o}}` : (t == null ? void 0 : t.fontFamily) === "monospace" ? `\\mathtt{${o}}` : (t == null ? void 0 : t.fontFamily) === "roman" ? `\\mathrm{${o}}` : o : "";
7502
+ function lt(a, t) {
7503
+ return a ? it(a) ? a : (t == null ? void 0 : t.fontFamily) === "sans-serif" ? `\\mathsf{${a}}` : (t == null ? void 0 : t.fontFamily) === "monospace" ? `\\mathtt{${a}}` : (t == null ? void 0 : t.fontFamily) === "roman" ? `\\mathrm{${a}}` : a : "";
7490
7504
  }
7491
- function q(o, t, e, r) {
7492
- if (!o) return "";
7505
+ function q(a, t, e, r) {
7506
+ if (!a) return "";
7493
7507
  if (!t && !e)
7494
- return lt(o, { fontFamily: r });
7495
- const l = r === "sans-serif", a = r === "monospace", s = r === "roman";
7496
- return t && e ? l ? `\\boldsymbol{\\mathsf{${o}}}` : a ? `\\boldsymbol{\\mathtt{${o}}}` : s ? `\\mathbfit{\\mathrm{${o}}}` : `\\mathbfit{${o}}` : t ? l ? `\\boldsymbol{\\mathsf{${o}}}` : a ? `\\boldsymbol{\\mathtt{${o}}}` : s ? `\\mathbf{\\mathrm{${o}}}` : `\\mathbf{${o}}` : e ? l ? `\\mathsf{${o}}` : a ? `\\mathtt{${o}}` : s ? `\\mathit{\\mathrm{${o}}}` : `\\mathit{${o}}` : o;
7508
+ return lt(a, { fontFamily: r });
7509
+ const s = r === "sans-serif", o = r === "monospace", l = r === "roman";
7510
+ return t && e ? s ? `\\boldsymbol{\\mathsf{${a}}}` : o ? `\\boldsymbol{\\mathtt{${a}}}` : l ? `\\mathbfit{\\mathrm{${a}}}` : `\\mathbfit{${a}}` : t ? s ? `\\boldsymbol{\\mathsf{${a}}}` : o ? `\\boldsymbol{\\mathtt{${a}}}` : l ? `\\mathbf{\\mathrm{${a}}}` : `\\mathbf{${a}}` : e ? s ? `\\mathsf{${a}}` : o ? `\\mathtt{${a}}` : l ? `\\mathit{\\mathrm{${a}}}` : `\\mathit{${a}}` : a;
7497
7511
  }
7498
- function T(o, t, e, r) {
7499
- if (!o) return "";
7500
- let l = o.trim();
7501
- const a = l.match(/^\\displaylines\s*\{([\s\S]*)\}$/i);
7502
- if (a && (l = a[1].trim()), l.match(/^\\begin\{(array|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|align|aligned|gather|cases)\}([\s\S]*)\\end\{\1\}$/i))
7503
- return l;
7504
- const n = l.match(/^\\begin\{(array|gather)\}(\{[\s\S]*?\})?([\s\S]*?)\\end\{\1\}$/i);
7505
- if (n && (l = n[3].trim()), /\\\\|\\cr|\\newline|\\par|\n/.test(l)) {
7512
+ function B(a, t, e, r) {
7513
+ if (!a) return "";
7514
+ let s = a.trim();
7515
+ const o = s.match(/^\\displaylines\s*\{([\s\S]*)\}$/i);
7516
+ if (o && (s = o[1].trim()), s.match(/^\\begin\{(array|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|align|aligned|gather|cases)\}([\s\S]*)\\end\{\1\}$/i))
7517
+ return s;
7518
+ const n = s.match(/^\\begin\{(array|gather)\}(\{[\s\S]*?\})?([\s\S]*?)\\end\{\1\}$/i);
7519
+ if (n && (s = n[3].trim()), /\\\\|\\cr|\\newline|\\par|\n/.test(s)) {
7506
7520
  const h = /\\\\(?:\[[^\]]*\])?|\\cr|\\newline|\\par|\n/;
7507
- return `\\displaylines{${l.split(h).map((x) => {
7508
- const k = x.trim();
7509
- return k ? q(k, t, e, r) : "";
7521
+ return `\\displaylines{${s.split(h).map((x) => {
7522
+ const u = x.trim();
7523
+ return u ? q(u, t, e, r) : "";
7510
7524
  }).filter((x) => x.length > 0).join(" \\\\ ")}}`;
7511
7525
  }
7512
- return q(l, t, e, r);
7526
+ return q(s, t, e, r);
7513
7527
  }
7514
- function rt(o) {
7515
- return o ? o.replace(/\\enclose\{([^}]*)\}\s*\[.*?\]/g, "\\enclose{$1}") : "";
7528
+ function rt(a) {
7529
+ return a ? a.replace(/\\enclose\{([^}]*)\}\s*\[.*?\]/g, "\\enclose{$1}") : "";
7516
7530
  }
7517
- function st(o = "") {
7518
- if (typeof o != "string") return o;
7519
- let t = o.replace(/\\textasciitilde/g, "\\text{~}").replace(/\\textasciicircum/g, "\\text{^}").replace(/\\textasteriskcentered/g, "*").replace(/\\char96/g, "`");
7531
+ function st(a = "") {
7532
+ if (typeof a != "string") return a;
7533
+ let t = a.replace(/\\textasciitilde/g, "\\text{~}").replace(/\\textasciicircum/g, "\\text{^}").replace(/\\textasteriskcentered/g, "*").replace(/\\char96/g, "`");
7520
7534
  return t.includes("\\ce{") && (t = t.replace(/\\ce\{([\s\S]*?)\}/g, (e, r) => r.includes("\\{") || r.includes("\\}") || r.includes("\\lbrace") || r.includes("\\rbrace") ? r : `\\ce{${r.replace(/\\left\[/g, "[").replace(/\\right\]/g, "]").replace(/\\lbrack\b/g, "[").replace(/\\rbrack\b/g, "]").replace(/\\left\(/g, "(").replace(/\\right\)/g, ")").replace(/\\left\|/g, "|").replace(/\\right\|/g, "|").replace(/\\left\./g, "").replace(/\\right\./g, "")}}`)), t;
7521
7535
  }
7522
7536
  const Z = "data-mathfield-shadow-styles", ot = `
@@ -7524,6 +7538,20 @@ const Z = "data-mathfield-shadow-styles", ot = `
7524
7538
  overflow: visible !important;
7525
7539
  contain: none !important;
7526
7540
  }
7541
+ .ML__notation {
7542
+ position: absolute !important;
7543
+ line-height: 0 !important;
7544
+ box-sizing: border-box !important;
7545
+ }
7546
+ .ML__notation svg {
7547
+ position: absolute !important;
7548
+ overflow: visible !important;
7549
+ top: 0 !important;
7550
+ left: 0 !important;
7551
+ width: 100% !important;
7552
+ height: 100% !important;
7553
+ pointer-events: none !important;
7554
+ }
7527
7555
  .wide-circle {
7528
7556
  display: inline-block !important;
7529
7557
  transform: scaleX(1.5) !important;
@@ -7821,12 +7849,12 @@ const Z = "data-mathfield-shadow-styles", ot = `
7821
7849
  padding-top: 0.1em;
7822
7850
  }
7823
7851
  `;
7824
- function I(o) {
7825
- const t = o == null ? void 0 : o.shadowRoot;
7852
+ function L(a) {
7853
+ const t = a == null ? void 0 : a.shadowRoot;
7826
7854
  if (!t) return;
7827
- const e = o.hasAttribute("read-only") || o.hasAttribute("readonly"), r = e ? "readonly" : "editable";
7828
- let l = t.querySelector(`[${Z}]`);
7829
- l && l.getAttribute("data-cache") === r || (l || (l = document.createElement("style"), l.setAttribute(Z, "true"), t.appendChild(l)), l.setAttribute("data-cache", r), l.textContent = `
7855
+ const e = a.hasAttribute("read-only") || a.hasAttribute("readonly"), r = e ? "readonly" : "editable";
7856
+ let s = t.querySelector(`[${Z}]`);
7857
+ s && s.getAttribute("data-cache") === r || (s || (s = document.createElement("style"), s.setAttribute(Z, "true"), t.appendChild(s)), s.setAttribute("data-cache", r), s.textContent = `
7830
7858
  ${e ? `
7831
7859
  :host, :host * { cursor: pointer !important; }
7832
7860
  .ML__latex, .ML__content, .ML__container, .ML__virtual-keyboard-toggle { cursor: pointer !important; }
@@ -7835,21 +7863,21 @@ function I(o) {
7835
7863
  `);
7836
7864
  }
7837
7865
  function at() {
7838
- document.querySelectorAll("math-field").forEach(I);
7866
+ document.querySelectorAll("math-field").forEach(L);
7839
7867
  }
7840
7868
  let N = null;
7841
7869
  function nt() {
7842
- N || (at(), N = new MutationObserver((o) => {
7870
+ N || (at(), N = new MutationObserver((a) => {
7843
7871
  var t, e, r;
7844
- for (const l of o) {
7845
- if (l.type === "attributes" && ((t = l.target.tagName) == null ? void 0 : t.toLowerCase()) === "math-field") {
7846
- I(l.target);
7872
+ for (const s of a) {
7873
+ if (s.type === "attributes" && ((t = s.target.tagName) == null ? void 0 : t.toLowerCase()) === "math-field") {
7874
+ L(s.target);
7847
7875
  continue;
7848
7876
  }
7849
- if (l.addedNodes)
7850
- for (const a of l.addedNodes)
7851
- a instanceof Element && (((e = a.tagName) == null ? void 0 : e.toLowerCase()) === "math-field" && requestAnimationFrame(() => I(a)), (r = a.querySelectorAll) == null || r.call(a, "math-field").forEach(
7852
- (s) => requestAnimationFrame(() => I(s))
7877
+ if (s.addedNodes)
7878
+ for (const o of s.addedNodes)
7879
+ o instanceof Element && (((e = o.tagName) == null ? void 0 : e.toLowerCase()) === "math-field" && requestAnimationFrame(() => L(o)), (r = o.querySelectorAll) == null || r.call(o, "math-field").forEach(
7880
+ (l) => requestAnimationFrame(() => L(l))
7853
7881
  ));
7854
7882
  }
7855
7883
  }), N.observe(document.body, {
@@ -7869,20 +7897,20 @@ const Q = [
7869
7897
  { id: "Phonetic", name: "Phonetic", ranges: [[592, 687], [688, 767], [7424, 7551], [7552, 7615], [43824, 43887]] },
7870
7898
  { id: "Other", name: "Other", ranges: [[8352, 8399], [8448, 8527], [8960, 9215], [9472, 9599], [9600, 9631], [9632, 9727], [10240, 10495], [11008, 11263]] }
7871
7899
  ], ht = () => {
7872
- const o = [];
7900
+ const a = [];
7873
7901
  return Q.slice(1).forEach((t) => {
7874
7902
  t.ranges.forEach((e) => {
7875
7903
  for (let r = e[0]; r <= e[1]; r++) {
7876
7904
  if (r >= 127 && r <= 159) continue;
7877
- const l = String.fromCodePoint(r);
7878
- new RegExp("\\p{C}", "u").test(l) || o.push({
7905
+ const s = String.fromCodePoint(r);
7906
+ new RegExp("\\p{C}", "u").test(s) || a.push({
7879
7907
  code: r.toString(16).toUpperCase().padStart(4, "0"),
7880
- char: l,
7908
+ char: s,
7881
7909
  category: t.id
7882
7910
  });
7883
7911
  }
7884
7912
  });
7885
- }), o;
7913
+ }), a;
7886
7914
  }, ct = ht();
7887
7915
  class dt {
7888
7916
  constructor(t = {}) {
@@ -7916,61 +7944,61 @@ class dt {
7916
7944
  }), e;
7917
7945
  }
7918
7946
  render(t) {
7919
- if (this.overlay && this.overlay.parentNode && this.overlay.parentNode.removeChild(this.overlay), this.overlay = document.createElement("div"), this.overlay.className = "scm-overlay", this.overlay.addEventListener("mousedown", (s) => {
7920
- s.stopPropagation(), this.close();
7921
- }), this.modal = document.createElement("div"), this.modal.className = "scm-modal", this.modal.addEventListener("mousedown", (s) => s.stopPropagation()), t) {
7922
- let s = t.x - 120, n = t.y;
7923
- s < 10 && (s = 10), s + 230 > window.innerWidth && (s = window.innerWidth - 240), n + 200 > window.innerHeight && (n = window.innerHeight - 210), this.modal.style.top = `${n}px`, this.modal.style.left = `${s}px`, this.modal.style.transform = "none";
7947
+ if (this.overlay && this.overlay.parentNode && this.overlay.parentNode.removeChild(this.overlay), this.overlay = document.createElement("div"), this.overlay.className = "scm-overlay", this.overlay.addEventListener("mousedown", (l) => {
7948
+ l.stopPropagation(), this.close();
7949
+ }), this.modal = document.createElement("div"), this.modal.className = "scm-modal", this.modal.addEventListener("mousedown", (l) => l.stopPropagation()), t) {
7950
+ let l = t.x - 120, n = t.y;
7951
+ l < 10 && (l = 10), l + 230 > window.innerWidth && (l = window.innerWidth - 240), n + 200 > window.innerHeight && (n = window.innerHeight - 210), this.modal.style.top = `${n}px`, this.modal.style.left = `${l}px`, this.modal.style.transform = "none";
7924
7952
  } else
7925
7953
  this.modal.style.top = "50%", this.modal.style.left = "50%", this.modal.style.transform = "translate(-50%, -50%)";
7926
7954
  const e = document.createElement("div");
7927
7955
  e.className = "scm-toolbar";
7928
7956
  const r = document.createElement("input");
7929
- r.type = "text", r.placeholder = "Code", r.className = "scm-code-input", r.value = this.searchCode, r.addEventListener("input", (s) => {
7930
- this.searchCode = s.target.value, this.updateGrid();
7957
+ r.type = "text", r.placeholder = "Code", r.className = "scm-code-input", r.value = this.searchCode, r.addEventListener("input", (l) => {
7958
+ this.searchCode = l.target.value, this.updateGrid();
7931
7959
  });
7932
- const l = document.createElement("select");
7933
- l.className = "scm-category-select", Q.forEach((s) => {
7960
+ const s = document.createElement("select");
7961
+ s.className = "scm-category-select", Q.forEach((l) => {
7934
7962
  const n = document.createElement("option");
7935
- n.value = s.id, n.textContent = s.name, l.appendChild(n);
7936
- }), l.value = this.selectedCategory, l.addEventListener("change", (s) => {
7937
- this.selectedCategory = s.target.value, this.updateGrid();
7938
- }), e.appendChild(r), e.appendChild(l), this.modal.appendChild(e);
7939
- const a = document.createElement("div");
7940
- a.className = "scm-body", this.bodyContainer = document.createElement("div"), this.bodyContainer.className = "scm-grid-container", a.appendChild(this.bodyContainer), this.modal.appendChild(a), this.updateGrid(), this.overlay.appendChild(this.modal), document.body.appendChild(this.overlay), setTimeout(() => r.focus(), 50);
7963
+ n.value = l.id, n.textContent = l.name, s.appendChild(n);
7964
+ }), s.value = this.selectedCategory, s.addEventListener("change", (l) => {
7965
+ this.selectedCategory = l.target.value, this.updateGrid();
7966
+ }), e.appendChild(r), e.appendChild(s), this.modal.appendChild(e);
7967
+ const o = document.createElement("div");
7968
+ o.className = "scm-body", this.bodyContainer = document.createElement("div"), this.bodyContainer.className = "scm-grid-container", o.appendChild(this.bodyContainer), this.modal.appendChild(o), this.updateGrid(), this.overlay.appendChild(this.modal), document.body.appendChild(this.overlay), setTimeout(() => r.focus(), 50);
7941
7969
  }
7942
7970
  updateGrid() {
7943
7971
  if (!this.bodyContainer) return;
7944
7972
  this.bodyContainer.innerHTML = "";
7945
7973
  const t = this.getFilteredCharacters(), e = this.getGroupedCharacters(t), r = Object.entries(e);
7946
7974
  if (r.length === 0 || t.length === 0) {
7947
- const l = document.createElement("div");
7948
- l.className = "scm-no-results", l.textContent = "No characters found.", this.bodyContainer.appendChild(l);
7975
+ const s = document.createElement("div");
7976
+ s.className = "scm-no-results", s.textContent = "No characters found.", this.bodyContainer.appendChild(s);
7949
7977
  return;
7950
7978
  }
7951
- r.forEach(([l, a]) => {
7952
- const s = document.createElement("div");
7953
- s.className = "scm-category-group";
7979
+ r.forEach(([s, o]) => {
7980
+ const l = document.createElement("div");
7981
+ l.className = "scm-category-group";
7954
7982
  const n = document.createElement("div");
7955
- n.className = "scm-char-grid", a.forEach((h) => {
7983
+ n.className = "scm-char-grid", o.forEach((h) => {
7956
7984
  const c = document.createElement("button");
7957
- c.type = "button", c.className = "scm-char-btn", c.title = `U+${h.code}`, c.textContent = h.char, c.addEventListener("click", (w) => {
7958
- w.preventDefault(), this.onInsert(h.char), this.close();
7985
+ c.type = "button", c.className = "scm-char-btn", c.title = `U+${h.code}`, c.textContent = h.char, c.addEventListener("click", (g) => {
7986
+ g.preventDefault(), this.onInsert(h.char), this.close();
7959
7987
  }), n.appendChild(c);
7960
- }), s.appendChild(n), this.bodyContainer.appendChild(s);
7988
+ }), l.appendChild(n), this.bodyContainer.appendChild(l);
7961
7989
  });
7962
7990
  }
7963
7991
  destroy() {
7964
7992
  this.close();
7965
7993
  }
7966
7994
  }
7967
- const mt = "1.0.27", S = {
7995
+ const mt = "1.0.29", E = {
7968
7996
  version: mt
7969
7997
  };
7970
7998
  typeof window < "u" && (window.MathfieldElement ? window.MathfieldElement.fontsDirectory = "https://cdn.jsdelivr.net/npm/mathlive/dist/fonts" : V && (V.fontsDirectory = "https://cdn.jsdelivr.net/npm/mathlive/dist/fonts"));
7971
- const L = class L {
7999
+ const D = class D {
7972
8000
  constructor(t = {}) {
7973
- this.version = L.VERSION, this.options = t, this.onInsert = t.onInsert || (() => {
8001
+ this.version = D.VERSION, this.options = t, this.onInsert = t.onInsert || (() => {
7974
8002
  }), this.onClose = t.onClose || (() => {
7975
8003
  }), this.mode = t.mode || "math", this.title = t.title || null, this.isOpen = !1, this.isEditing = !1, this.initialLatex = "", this.activeGroup = 0, this.explicitToggle = !1, this.activeStyles = {
7976
8004
  bold: !1,
@@ -7978,7 +8006,7 @@ const L = class L {
7978
8006
  fontFamily: "none",
7979
8007
  fontSize: "auto",
7980
8008
  color: "none"
7981
- }, this.isMaximized = !1, this.isMinimized = !1, this.position = { x: 0, y: 0 }, this.isDragging = !1, this.dragStart = { x: 0, y: 0 }, this.popup = null, this.mathField = null, this.tabsWrapper = null, this.itemsWrapper = null, this.activeDropdown = null, this.activeMatrixPopup = null, this.colorPickerPopup = null, this.specCharModal = null, this.boundKeyDown = this.handleGlobalKeyDown.bind(this), this.boundDocClick = this.handleDocumentClick.bind(this), this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseUp = this.handleMouseUp.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleMouseUp.bind(this), this.boundResize = this.handleWindowResize.bind(this);
8009
+ }, this.isMaximized = !1, this.isMinimized = !1, this.position = { x: 0, y: 0 }, this.isDragging = !1, this.dragStart = { x: 0, y: 0 }, this.popup = null, this.mathField = null, this.tabsWrapper = null, this.itemsWrapper = null, this.activeDropdown = null, this.activeDropdownBtn = null, this.activeMatrixPopup = null, this.activeMatrixBtn = null, this.colorPickerPopup = null, this.activeColorBtn = null, this.specCharModal = null, this.boundKeyDown = this.handleGlobalKeyDown.bind(this), this.boundDocClick = this.handleDocumentClick.bind(this), this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseUp = this.handleMouseUp.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleMouseUp.bind(this), this.boundResize = this.handleWindowResize.bind(this);
7982
8010
  }
7983
8011
  getGroups() {
7984
8012
  return this.mode === "chem" ? $ : _;
@@ -8004,10 +8032,10 @@ const L = class L {
8004
8032
  fontFamily: "none",
8005
8033
  fontSize: "auto",
8006
8034
  color: "none"
8007
- }, this.render(), window.addEventListener("keydown", this.boundKeyDown), document.addEventListener("mousedown", this.boundDocClick), window.addEventListener("mousemove", this.boundMouseMove), window.addEventListener("mouseup", this.boundMouseUp), window.addEventListener("touchmove", this.boundTouchMove, { passive: !1 }), window.addEventListener("touchend", this.boundTouchEnd), window.addEventListener("resize", this.boundResize);
8035
+ }, this.render(), window.addEventListener("keydown", this.boundKeyDown), document.addEventListener("mousedown", this.boundDocClick, !0), document.addEventListener("pointerdown", this.boundDocClick, !0), window.addEventListener("mousemove", this.boundMouseMove), window.addEventListener("mouseup", this.boundMouseUp), window.addEventListener("touchmove", this.boundTouchMove, { passive: !1 }), window.addEventListener("touchend", this.boundTouchEnd), window.addEventListener("resize", this.boundResize);
8008
8036
  }
8009
8037
  close() {
8010
- this.isOpen && (this.isOpen = !1, window.removeEventListener("keydown", this.boundKeyDown), document.removeEventListener("mousedown", this.boundDocClick), window.removeEventListener("mousemove", this.boundMouseMove), window.removeEventListener("mouseup", this.boundMouseUp), window.removeEventListener("touchmove", this.boundTouchMove), window.removeEventListener("touchend", this.boundTouchEnd), window.removeEventListener("resize", this.boundResize), this.closeAllPopups(), this.specCharModal && this.specCharModal.close(), this.popup && this.popup.parentNode && this.popup.parentNode.removeChild(this.popup), this.popup = null, this.mathField = null, this.onClose());
8038
+ this.isOpen && (this.isOpen = !1, window.removeEventListener("keydown", this.boundKeyDown), document.removeEventListener("mousedown", this.boundDocClick, !0), document.removeEventListener("pointerdown", this.boundDocClick, !0), window.removeEventListener("mousemove", this.boundMouseMove), window.removeEventListener("mouseup", this.boundMouseUp), window.removeEventListener("touchmove", this.boundTouchMove), window.removeEventListener("touchend", this.boundTouchEnd), window.removeEventListener("resize", this.boundResize), this.closeAllPopups(), this.specCharModal && this.specCharModal.close(), this.popup && this.popup.parentNode && this.popup.parentNode.removeChild(this.popup), this.popup = null, this.mathField = null, this.onClose());
8011
8039
  }
8012
8040
  getValue() {
8013
8041
  if (!this.mathField) return "";
@@ -8035,17 +8063,19 @@ const L = class L {
8035
8063
  t.key === "Enter" && (t.ctrlKey || t.metaKey) && (t.preventDefault(), this.handleInsert());
8036
8064
  }
8037
8065
  handleDocumentClick(t) {
8038
- this.popup && (this.activeDropdown && !this.activeDropdown.contains(t.target) && this.closeDropdown(), this.activeMatrixPopup && !this.activeMatrixPopup.contains(t.target) && this.closeMatrixPopup(), this.colorPickerPopup && !this.colorPickerPopup.contains(t.target) && this.closeColorPicker());
8066
+ if (!this.popup) return;
8067
+ const e = t.composedPath ? t.composedPath() : [];
8068
+ this.activeDropdown && (this.activeDropdown === t.target || this.activeDropdown.contains(t.target) || e.includes(this.activeDropdown) || this.activeDropdownBtn && (this.activeDropdownBtn === t.target || this.activeDropdownBtn.contains(t.target) || e.includes(this.activeDropdownBtn)) || this.closeDropdown()), this.activeMatrixPopup && (this.activeMatrixPopup === t.target || this.activeMatrixPopup.contains(t.target) || e.includes(this.activeMatrixPopup) || this.activeMatrixBtn && (this.activeMatrixBtn === t.target || this.activeMatrixBtn.contains(t.target) || e.includes(this.activeMatrixBtn)) || this.closeMatrixPopup()), this.colorPickerPopup && (this.colorPickerPopup === t.target || this.colorPickerPopup.contains(t.target) || e.includes(this.colorPickerPopup) || this.activeColorBtn && (this.activeColorBtn === t.target || this.activeColorBtn.contains(t.target) || e.includes(this.activeColorBtn)) || this.closeColorPicker());
8039
8069
  }
8040
8070
  handleInsert() {
8041
8071
  let t = this.getValue();
8042
8072
  t = tt(t), t = et(t), t = rt(t), this.mode === "chem" && (t.includes("\\displaylines") || t.includes("\\\\") || t.includes("\\class{cme-") || t.includes("\\xleftrightarrows") || t.includes("\\xleftrightharpoons") || t.includes("\\enclose") || t.includes("\\{") || t.includes("\\}") || t.includes("\\lbrace") || t.includes("\\rbrace") ? /^\\ce\{[\s\S]*\}$/i.test(t.trim()) && (t = t.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")) : t.trim() && !t.trim().startsWith("\\ce{") && !t.includes("\\ce{") && (t = `\\ce{${t}}`)), this.onInsert(t), this.close();
8043
8073
  }
8044
8074
  insertAtCursor(t) {
8045
- if (!this.mathField) return;
8075
+ if (this.closeAllPopups(), !this.mathField) return;
8046
8076
  const e = this.mathField;
8047
8077
  if (e.smartSuperscript = !1, e.focus(), typeof t == "string") {
8048
- const r = T(
8078
+ const r = B(
8049
8079
  t,
8050
8080
  this.activeStyles.bold,
8051
8081
  this.activeStyles.italic,
@@ -8057,7 +8087,7 @@ const L = class L {
8057
8087
  { selectionMode: "placeholder" }
8058
8088
  ]) : e.insert(r);
8059
8089
  } else if (t && t.insert) {
8060
- const r = t.action === "INSERT_CUSTOM" || t.directInsert ? T(
8090
+ const r = t.action === "INSERT_CUSTOM" || t.directInsert ? B(
8061
8091
  t.insert,
8062
8092
  this.activeStyles.bold,
8063
8093
  this.activeStyles.italic,
@@ -8079,13 +8109,13 @@ const L = class L {
8079
8109
  try {
8080
8110
  const e = t.model, r = (e == null ? void 0 : e.selection) || t.selection;
8081
8111
  if (r) {
8082
- const l = r.ranges || (Array.isArray(r) ? [r] : []);
8083
- if (l.length > 0) {
8084
- let a = 1 / 0, s = -1 / 0;
8085
- for (const h of l)
8086
- Array.isArray(h) && (a = Math.min(a, h[0], h[1]), s = Math.max(s, h[0], h[1]));
8112
+ const s = r.ranges || (Array.isArray(r) ? [r] : []);
8113
+ if (s.length > 0) {
8114
+ let o = 1 / 0, l = -1 / 0;
8115
+ for (const h of s)
8116
+ Array.isArray(h) && (o = Math.min(o, h[0], h[1]), l = Math.max(l, h[0], h[1]));
8087
8117
  const n = (e == null ? void 0 : e.lastOffset) || 1;
8088
- if (a <= 1 && s >= n)
8118
+ if (o <= 1 && l >= n)
8089
8119
  return !0;
8090
8120
  }
8091
8121
  }
@@ -8129,8 +8159,8 @@ const L = class L {
8129
8159
  }
8130
8160
  try {
8131
8161
  if (typeof t.queryStyle == "function") {
8132
- const e = t.queryStyle({ variantStyle: "bold" }), r = t.queryStyle({ variantStyle: "bolditalic" }), l = t.queryStyle({ fontSeries: "b" });
8133
- if (e === "all" || e === "some" || r === "all" || r === "some" || l === "all" || l === "some")
8162
+ const e = t.queryStyle({ variantStyle: "bold" }), r = t.queryStyle({ variantStyle: "bolditalic" }), s = t.queryStyle({ fontSeries: "b" });
8163
+ if (e === "all" || e === "some" || r === "all" || r === "some" || s === "all" || s === "some")
8134
8164
  return !0;
8135
8165
  }
8136
8166
  } catch {
@@ -8138,10 +8168,10 @@ const L = class L {
8138
8168
  try {
8139
8169
  const e = t.model;
8140
8170
  if (e && !t.selectionIsCollapsed && (e.selection || t.selection)) {
8141
- const r = e.selection || t.selection, l = e.getAtoms(r, { includeChildren: !0 });
8142
- if (l && l.length > 0 && l.some((s) => {
8143
- if (!s || s.type === "first") return !1;
8144
- const n = s.style;
8171
+ const r = e.selection || t.selection, s = e.getAtoms(r, { includeChildren: !0 });
8172
+ if (s && s.length > 0 && s.some((l) => {
8173
+ if (!l || l.type === "first") return !1;
8174
+ const n = l.style;
8145
8175
  return n ? n.variantStyle === "bold" || n.variantStyle === "bolditalic" || n.fontSeries === "b" || n.variant === "bold" : !1;
8146
8176
  }))
8147
8177
  return !0;
@@ -8161,8 +8191,8 @@ const L = class L {
8161
8191
  }
8162
8192
  try {
8163
8193
  if (typeof t.queryStyle == "function") {
8164
- const e = t.queryStyle({ variantStyle: "italic" }), r = t.queryStyle({ variantStyle: "bolditalic" }), l = t.queryStyle({ fontShape: "it" });
8165
- if (e === "all" || e === "some" || r === "all" || r === "some" || l === "all" || l === "some")
8194
+ const e = t.queryStyle({ variantStyle: "italic" }), r = t.queryStyle({ variantStyle: "bolditalic" }), s = t.queryStyle({ fontShape: "it" });
8195
+ if (e === "all" || e === "some" || r === "all" || r === "some" || s === "all" || s === "some")
8166
8196
  return !0;
8167
8197
  }
8168
8198
  } catch {
@@ -8170,10 +8200,10 @@ const L = class L {
8170
8200
  try {
8171
8201
  const e = t.model;
8172
8202
  if (e && !t.selectionIsCollapsed && (e.selection || t.selection)) {
8173
- const r = e.selection || t.selection, l = e.getAtoms(r, { includeChildren: !0 });
8174
- if (l && l.length > 0 && l.some((s) => {
8175
- if (!s || s.type === "first") return !1;
8176
- const n = s.style;
8203
+ const r = e.selection || t.selection, s = e.getAtoms(r, { includeChildren: !0 });
8204
+ if (s && s.length > 0 && s.some((l) => {
8205
+ if (!l || l.type === "first") return !1;
8206
+ const n = l.style;
8177
8207
  return n ? n.variantStyle === "italic" || n.variantStyle === "bolditalic" || n.fontShape === "it" : !1;
8178
8208
  }))
8179
8209
  return !0;
@@ -8192,58 +8222,62 @@ const L = class L {
8192
8222
  } else {
8193
8223
  this.explicitToggle = !1;
8194
8224
  const e = this.checkSelectionBold(t), r = this.checkSelectionItalic(t);
8195
- let l = !1;
8196
- this.activeStyles.bold !== e && (this.activeStyles.bold = e, l = !0), this.activeStyles.italic !== r && (this.activeStyles.italic = r, l = !0), l && this.renderToolbarItems();
8225
+ let s = !1;
8226
+ this.activeStyles.bold !== e && (this.activeStyles.bold = e, s = !0), this.activeStyles.italic !== r && (this.activeStyles.italic = r, s = !0), s && this.renderToolbarItems();
8197
8227
  }
8198
8228
  }
8199
8229
  render() {
8200
- this.popup = document.createElement("div"), this.popup.className = "cme-editor-popup" + (this.isMaximized ? " maximized" : "") + (this.isMinimized ? " minimized" : ""), this.popup.addEventListener("mousedown", (i) => i.stopPropagation());
8230
+ this.popup = document.createElement("div"), this.popup.className = "cme-editor-popup" + (this.isMaximized ? " maximized" : "") + (this.isMinimized ? " minimized" : ""), this.popup.addEventListener("mousedown", (i) => {
8231
+ this.handleDocumentClick(i), i.stopPropagation();
8232
+ }), this.popup.addEventListener("pointerdown", (i) => {
8233
+ this.handleDocumentClick(i);
8234
+ });
8201
8235
  const t = document.createElement("div");
8202
8236
  t.className = "cme-popup-topbar";
8203
8237
  const e = document.createElement("div");
8204
8238
  e.className = "cme-popup-header", e.style.cursor = "grab";
8205
8239
  const r = this.title || (this.isEditing ? this.mode === "chem" ? "Edit Chemistry Formula" : "Edit Math Formula" : this.mode === "chem" ? "Chemistry Editor" : "Math Editor");
8206
8240
  e.innerHTML = `<span>${r}</span>`;
8207
- const l = (i, g, p) => {
8208
- p && p.closest && p.closest(".cme-popup-btn") || (this.isDragging = !0, this.dragStart = {
8241
+ const s = (i, p, b) => {
8242
+ b && b.closest && b.closest(".cme-popup-btn") || (this.closeAllPopups(), this.specCharModal && this.specCharModal.close(), this.isDragging = !0, this.dragStart = {
8209
8243
  x: i - this.position.x,
8210
- y: g - this.position.y
8244
+ y: p - this.position.y
8211
8245
  }, e.style.cursor = "grabbing");
8212
8246
  };
8213
8247
  e.addEventListener("mousedown", (i) => {
8214
- l(i.clientX, i.clientY, i.target);
8248
+ s(i.clientX, i.clientY, i.target);
8215
8249
  }), e.addEventListener(
8216
8250
  "touchstart",
8217
8251
  (i) => {
8218
- i.touches && i.touches.length > 0 && l(i.touches[0].clientX, i.touches[0].clientY, i.target);
8252
+ i.touches && i.touches.length > 0 && s(i.touches[0].clientX, i.touches[0].clientY, i.target);
8219
8253
  },
8220
8254
  { passive: !0 }
8221
8255
  );
8222
- const a = document.createElement("div");
8223
- a.className = "cme-popup-controls";
8224
- const s = document.createElement("button");
8225
- s.type = "button", s.className = "cme-popup-btn", s.textContent = "—", s.title = "Minimize", s.addEventListener("click", () => this.toggleMinimize());
8256
+ const o = document.createElement("div");
8257
+ o.className = "cme-popup-controls";
8258
+ const l = document.createElement("button");
8259
+ l.type = "button", l.className = "cme-popup-btn", l.textContent = "—", l.title = "Minimize", l.addEventListener("click", () => this.toggleMinimize());
8226
8260
  const n = document.createElement("button");
8227
- n.type = "button", n.className = "cme-popup-btn", n.textContent = "⤢", n.title = "Maximize", n.addEventListener("click", () => this.toggleMaximize()), this.minBtn = s, this.maxBtn = n;
8261
+ n.type = "button", n.className = "cme-popup-btn", n.textContent = "⤢", n.title = "Maximize", n.addEventListener("click", () => this.toggleMaximize()), this.minBtn = l, this.maxBtn = n;
8228
8262
  const h = document.createElement("button");
8229
- h.type = "button", h.className = "cme-popup-btn", h.textContent = "✕", h.title = "Close", h.addEventListener("click", () => this.close()), a.appendChild(s), a.appendChild(n), a.appendChild(h), t.appendChild(e), t.appendChild(a), this.popup.appendChild(t);
8263
+ h.type = "button", h.className = "cme-popup-btn", h.textContent = "✕", h.title = "Close", h.addEventListener("click", () => this.close()), o.appendChild(l), o.appendChild(n), o.appendChild(h), t.appendChild(e), t.appendChild(o), this.popup.appendChild(t);
8230
8264
  const c = document.createElement("div");
8231
8265
  c.className = "cme-toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", "Symbol palette"), this.tabsWrapper = document.createElement("div"), this.tabsWrapper.className = "cme-toolbar-groups", this.renderTabs(), c.appendChild(this.tabsWrapper), this.itemsWrapper = document.createElement("div"), this.itemsWrapper.className = "cme-toolbar-items", this.renderToolbarItems(), c.appendChild(this.itemsWrapper), this.popup.appendChild(c);
8232
- const w = document.createElement("div");
8233
- w.className = "cme-mathfield-container", w.addEventListener("mousedown", (i) => {
8234
- var g, p;
8235
- this.explicitToggle = !1, !(this.mathField && (i.target === this.mathField || this.mathField.contains(i.target))) && (i.preventDefault(), (p = (g = this.mathField) == null ? void 0 : g.focus) == null || p.call(g));
8266
+ const g = document.createElement("div");
8267
+ g.className = "cme-mathfield-container", g.addEventListener("mousedown", (i) => {
8268
+ var p, b;
8269
+ this.explicitToggle = !1, this.closeAllPopups(), !(this.mathField && (i.target === this.mathField || this.mathField.contains(i.target))) && (i.preventDefault(), (b = (p = this.mathField) == null ? void 0 : p.focus) == null || b.call(p));
8236
8270
  }), this.mathField = document.createElement("math-field"), this.mathField.className = "cme-mathfield", this.mathField.setAttribute("tabindex", "0"), this.mathField.setAttribute("math-virtual-keyboard-policy", "manual"), this.mathField.setAttribute("smart-superscript", "false"), this.mathField.smartSuperscript = !1, this.mathField.setAttribute("math-mode-space", "\\enspace"), this.mathField.mathModeSpace = "\\enspace", this.mathField.onInsertStyle = () => this.getInsertStyle(), this.mathField.addEventListener("keydown", (i) => {
8237
8271
  if (i.key === "Enter" && !i.ctrlKey && !i.metaKey && !i.altKey) {
8238
8272
  i.preventDefault(), i.stopPropagation(), i.stopImmediatePropagation(), this.activeStyles.bold || this.activeStyles.italic || this.activeStyles.fontFamily && this.activeStyles.fontFamily !== "none" ? this.explicitToggle = !0 : this.explicitToggle = !1;
8239
- const d = this.mathField;
8240
- d != null && d.executeCommand && d.executeCommand("addRowAfter");
8273
+ const m = this.mathField;
8274
+ m != null && m.executeCommand && m.executeCommand("addRowAfter");
8241
8275
  return;
8242
8276
  }
8243
8277
  if (i.key === " " || i.code === "Space") {
8244
8278
  i.preventDefault(), i.stopPropagation(), i.stopImmediatePropagation();
8245
- const d = this.mathField;
8246
- d.executeCommand ? d.executeCommand(["insert", "\\enspace ", { selectionMode: "after" }]) : d.insert && d.insert("\\enspace ");
8279
+ const m = this.mathField;
8280
+ m.executeCommand ? m.executeCommand(["insert", "\\enspace ", { selectionMode: "after" }]) : m.insert && m.insert("\\enspace ");
8247
8281
  return;
8248
8282
  }
8249
8283
  if (i.key === "ArrowLeft" || i.key === "ArrowRight" || i.key === "ArrowUp" || i.key === "ArrowDown" || i.key === "Home" || i.key === "End") {
@@ -8252,32 +8286,34 @@ const L = class L {
8252
8286
  }
8253
8287
  if (!this.activeStyles.bold && !this.activeStyles.italic && this.activeStyles.fontFamily === "none" || i.key.length !== 1 || i.ctrlKey || i.metaKey || i.altKey) return;
8254
8288
  i.preventDefault(), i.stopPropagation(), i.stopImmediatePropagation();
8255
- const g = T(
8289
+ const p = B(
8256
8290
  i.key,
8257
8291
  this.activeStyles.bold,
8258
8292
  this.activeStyles.italic,
8259
8293
  this.activeStyles.fontFamily
8260
- ), p = this.mathField;
8261
- p.executeCommand ? p.executeCommand(["insert", g, { selectionMode: "after" }]) : p.insert && p.insert(g);
8294
+ ), b = this.mathField;
8295
+ b.executeCommand ? b.executeCommand(["insert", p, { selectionMode: "after" }]) : b.insert && b.insert(p);
8262
8296
  }, { capture: !0 });
8263
8297
  const x = () => {
8264
8298
  this.updateStylesFromSelection();
8265
8299
  };
8266
8300
  this.mathField.addEventListener("selection-change", x), this.mathField.addEventListener("pointerup", x), this.mathField.addEventListener("keyup", x), this.mathField.addEventListener("pointerdown", () => {
8267
- this.explicitToggle = !1;
8268
- }), w.appendChild(this.mathField), this.popup.appendChild(w);
8269
- const k = document.createElement("div");
8270
- k.className = "cme-popup-footer";
8301
+ this.explicitToggle = !1, this.closeAllPopups();
8302
+ }), this.mathField.addEventListener("focus", () => {
8303
+ this.closeAllPopups();
8304
+ }), g.appendChild(this.mathField), this.popup.appendChild(g);
8305
+ const u = document.createElement("div");
8306
+ u.className = "cme-popup-footer";
8271
8307
  const y = document.createElement("button");
8272
8308
  y.type = "button", y.className = "cme-insert-btn", y.textContent = this.isEditing ? "Update" : "Insert", y.addEventListener("click", () => this.handleInsert());
8273
- const b = document.createElement("button");
8274
- b.type = "button", b.className = "cme-cancel-btn", b.textContent = "Cancel", b.addEventListener("click", () => this.close()), k.appendChild(y), k.appendChild(b);
8275
- const u = `v${S.version}`;
8276
- if (u) {
8309
+ const w = document.createElement("button");
8310
+ w.type = "button", w.className = "cme-cancel-btn", w.textContent = "Cancel", w.addEventListener("click", () => this.close()), u.appendChild(y), u.appendChild(w);
8311
+ const k = `v${E.version}`;
8312
+ if (k) {
8277
8313
  const i = document.createElement("span");
8278
- i.className = "cme-popup-version", i.textContent = u, i.title = `Version ${S.version}`, k.appendChild(i);
8314
+ i.className = "cme-popup-version", i.textContent = k, i.title = `Version ${E.version}`, u.appendChild(i);
8279
8315
  }
8280
- this.popup.appendChild(k), document.body.appendChild(this.popup), setTimeout(() => {
8316
+ this.popup.appendChild(u), document.body.appendChild(this.popup), setTimeout(() => {
8281
8317
  if (this.mathField) {
8282
8318
  nt();
8283
8319
  try {
@@ -8293,7 +8329,9 @@ const L = class L {
8293
8329
  ...window.__cme_macros || {},
8294
8330
  ...J
8295
8331
  }
8296
- });
8332
+ }), this.mathField.menuItems && Array.isArray(this.mathField.menuItems) && (this.mathField.menuItems = this.mathField.menuItems.filter(
8333
+ (p) => p && p.id !== "insert-matrix" && p.submenuClass !== "insert-matrix-submenu"
8334
+ ));
8297
8335
  } catch {
8298
8336
  }
8299
8337
  let i = this.initialLatex || "";
@@ -8303,14 +8341,15 @@ const L = class L {
8303
8341
  }
8304
8342
  clampPosition(t = this.position.x, e = this.position.y) {
8305
8343
  if (!this.popup) return { x: t, y: e };
8306
- const r = this.popup.getBoundingClientRect(), l = r.left - this.position.x, a = r.top - this.position.y, s = r.width, n = r.height, h = window.innerWidth, c = window.innerHeight;
8307
- let w = -l, x = h - l - s, k = t;
8308
- w > x ? k = w : k = Math.max(w, Math.min(t, x));
8309
- let y = -a, b = c - a - n, u = e;
8310
- return y > b ? u = y : u = Math.max(y, Math.min(e, b)), { x: k, y: u };
8344
+ const r = this.popup.getBoundingClientRect(), s = r.left - this.position.x, o = r.top - this.position.y, l = r.width, n = r.height, h = window.innerWidth, c = window.innerHeight;
8345
+ let g = -s, x = h - s - l, u = t;
8346
+ g > x ? u = g : u = Math.max(g, Math.min(t, x));
8347
+ let y = -o, w = c - o - n, k = e;
8348
+ return y > w ? k = y : k = Math.max(y, Math.min(e, w)), { x: u, y: k };
8311
8349
  }
8312
8350
  handleMouseMove(t) {
8313
8351
  if (!this.isDragging || !this.popup) return;
8352
+ this.closeAllPopups(), this.specCharModal && this.specCharModal.close();
8314
8353
  const e = t.clientX - this.dragStart.x, r = t.clientY - this.dragStart.y;
8315
8354
  this.position = this.clampPosition(e, r), this.popup.style.transform = `translate(${this.position.x}px, ${this.position.y}px)`;
8316
8355
  }
@@ -8342,22 +8381,22 @@ const L = class L {
8342
8381
  renderTabs() {
8343
8382
  if (!this.tabsWrapper) return;
8344
8383
  this.tabsWrapper.innerHTML = "", this.getGroups().forEach((e, r) => {
8345
- const l = this.activeGroup === r, a = document.createElement("button");
8346
- if (a.type = "button", a.className = "cme-group-tab" + (l ? " active" : ""), e.mathLabel) {
8347
- const s = document.createElement("math-field");
8348
- s.setAttribute("read-only", "true"), s.setAttribute("tabindex", "-1"), s.style.pointerEvents = "none", s.style.background = "transparent", s.style.border = "none", s.style.outline = "none", s.style.fontSize = e.fontSize || (e.isMatrix ? "8px" : "11px"), s.style.display = "inline-block", s.style.width = "auto", s.style.padding = "0", s.style.margin = "0", s.style.boxShadow = "none", s.style.color = l ? "#333333" : "#ffffff", s.textContent = e.mathLabel, a.appendChild(s);
8349
- } else typeof e.label == "string" && e.label.includes("<svg") ? a.innerHTML = e.label : a.textContent = e.label;
8350
- a.addEventListener("mousedown", (s) => {
8351
- s.preventDefault(), this.activeGroup = r, this.closeAllPopups(), this.renderTabs(), this.renderToolbarItems();
8352
- }), this.tabsWrapper.appendChild(a);
8384
+ const s = this.activeGroup === r, o = document.createElement("button");
8385
+ if (o.type = "button", o.className = "cme-group-tab" + (s ? " active" : ""), e.mathLabel) {
8386
+ const l = document.createElement("math-field");
8387
+ l.setAttribute("read-only", "true"), l.setAttribute("tabindex", "-1"), l.style.pointerEvents = "none", l.style.background = "transparent", l.style.border = "none", l.style.outline = "none", l.style.fontSize = e.fontSize || (e.isMatrix ? "8px" : "11px"), l.style.display = "inline-block", l.style.width = "auto", l.style.padding = "0", l.style.margin = "0", l.style.boxShadow = "none", l.style.color = s ? "#333333" : "#ffffff", l.textContent = e.mathLabel, o.appendChild(l);
8388
+ } else typeof e.label == "string" && e.label.includes("<svg") ? o.innerHTML = e.label : o.textContent = e.label;
8389
+ o.addEventListener("mousedown", (l) => {
8390
+ l.preventDefault(), this.activeGroup = r, this.closeAllPopups(), this.renderTabs(), this.renderToolbarItems();
8391
+ }), this.tabsWrapper.appendChild(o);
8353
8392
  });
8354
8393
  }
8355
8394
  renderToolbarItems() {
8356
8395
  if (!this.itemsWrapper) return;
8357
8396
  this.itemsWrapper.innerHTML = "";
8358
- const e = this.getGroups()[this.activeGroup] || { items: [] }, r = e.items || [], l = r.some((s) => s.type === "sep"), a = [];
8359
- if (l) {
8360
- let s = {
8397
+ const e = this.getGroups()[this.activeGroup] || { items: [] }, r = e.items || [], s = r.some((l) => l.type === "sep"), o = [];
8398
+ if (s) {
8399
+ let l = {
8361
8400
  cols: 2,
8362
8401
  small: !1,
8363
8402
  cls: "",
@@ -8366,47 +8405,50 @@ const L = class L {
8366
8405
  moreCols: 1
8367
8406
  };
8368
8407
  for (const n of r)
8369
- n.type === "sep" ? (s.items.length > 0 && a.push(s), s = {
8408
+ n.type === "sep" ? (l.items.length > 0 && o.push(l), l = {
8370
8409
  cols: n.cols || 2,
8371
8410
  small: !!n.small,
8372
8411
  cls: n.cls || "",
8373
8412
  items: [],
8374
8413
  moreItems: n.moreItems || null,
8375
8414
  moreCols: n.moreCols || 1
8376
- }) : s.items.push(n);
8377
- s.items.length > 0 && a.push(s);
8415
+ }) : l.items.push(n);
8416
+ l.items.length > 0 && o.push(l);
8378
8417
  } else
8379
8418
  for (let n = 0; n < r.length; n += 4)
8380
- a.push({
8419
+ o.push({
8381
8420
  cols: 2,
8382
8421
  small: !1,
8383
8422
  cls: "",
8384
8423
  items: r.slice(n, n + 4)
8385
8424
  });
8386
- a.forEach((s) => {
8425
+ o.forEach((l) => {
8387
8426
  const n = document.createElement("div");
8388
- if (n.className = "cme-symbol-subgroup" + (s.small ? " cme-symbol-subgroup--small" : "") + (s.cls ? ` ${s.cls}` : "") + (s.moreItems ? " cme-subgroup-has-more" : ""), n.style.gridTemplateColumns = `repeat(${s.cols}, auto)`, n.style.position = "relative", s.moreItems) {
8427
+ if (n.className = "cme-symbol-subgroup" + (l.small ? " cme-symbol-subgroup--small" : "") + (l.cls ? ` ${l.cls}` : "") + (l.moreItems ? " cme-subgroup-has-more" : ""), n.style.gridTemplateColumns = `repeat(${l.cols}, auto)`, n.style.position = "relative", l.moreItems) {
8389
8428
  const h = document.createElement("button");
8390
8429
  h.type = "button", h.className = "cme-more-trigger-btn", h.title = "More", h.textContent = "▶", h.addEventListener("mousedown", (c) => c.preventDefault()), h.addEventListener("click", (c) => {
8391
- c.stopPropagation();
8392
- const w = h.getBoundingClientRect();
8393
- this.openDropdown(s.moreItems, w, s.moreCols || 4);
8430
+ if (c.stopPropagation(), this.activeDropdown && this.activeDropdownBtn === h)
8431
+ this.closeDropdown();
8432
+ else {
8433
+ const g = h.getBoundingClientRect();
8434
+ this.openDropdown(l.moreItems, g, l.moreCols || 4, h);
8435
+ }
8394
8436
  }), n.appendChild(h);
8395
8437
  }
8396
- s.items.forEach((h) => {
8438
+ l.items.forEach((h) => {
8397
8439
  if (h.type === "dropdown") {
8398
- const u = h.label === "Font...", i = h.label === "Size", g = document.createElement("select");
8399
- g.className = "cme-select" + (u ? " cme-select-font" : "") + (i ? " cme-select-size" : "") + (u && this.activeStyles.fontFamily !== "none" || i && this.activeStyles.fontSize !== "auto" ? " active" : ""), u ? ([
8440
+ const k = h.label === "Font...", i = h.label === "Size", p = document.createElement("select");
8441
+ p.className = "cme-select" + (k ? " cme-select-font" : "") + (i ? " cme-select-size" : "") + (k && this.activeStyles.fontFamily !== "none" || i && this.activeStyles.fontSize !== "auto" ? " active" : ""), k ? ([
8400
8442
  { id: "none", label: "Font..." },
8401
8443
  { id: "roman", label: "Roman" },
8402
8444
  { id: "sans-serif", label: "Sans-Serif" },
8403
8445
  { id: "monospace", label: "Monospace" }
8404
- ].forEach((p) => {
8405
- const d = document.createElement("option");
8406
- d.value = p.id, d.textContent = p.label, g.appendChild(d);
8407
- }), g.value = this.activeStyles.fontFamily, g.addEventListener("change", (p) => {
8408
- var d;
8409
- this.activeStyles.fontFamily = p.target.value, (d = this.mathField) != null && d.applyStyle && this.mathField.applyStyle({
8446
+ ].forEach((b) => {
8447
+ const m = document.createElement("option");
8448
+ m.value = b.id, m.textContent = b.label, p.appendChild(m);
8449
+ }), p.value = this.activeStyles.fontFamily, p.addEventListener("change", (b) => {
8450
+ var m;
8451
+ this.activeStyles.fontFamily = b.target.value, (m = this.mathField) != null && m.applyStyle && this.mathField.applyStyle({
8410
8452
  fontFamily: this.activeStyles.fontFamily === "none" ? "none" : this.activeStyles.fontFamily
8411
8453
  }), this.renderToolbarItems();
8412
8454
  })) : i && ([
@@ -8416,48 +8458,53 @@ const L = class L {
8416
8458
  { id: "5", label: "Normal" },
8417
8459
  { id: "7", label: "Large" },
8418
8460
  { id: "9", label: "Huge" }
8419
- ].forEach((p) => {
8420
- const d = document.createElement("option");
8421
- d.value = p.id, d.textContent = p.label, g.appendChild(d);
8422
- }), g.value = this.activeStyles.fontSize, g.addEventListener("change", (p) => {
8423
- var d;
8424
- if (this.activeStyles.fontSize = p.target.value, (d = this.mathField) != null && d.applyStyle) {
8425
- const m = this.activeStyles.fontSize === "auto" ? "none" : parseInt(this.activeStyles.fontSize, 10);
8426
- this.mathField.applyStyle({ fontSize: m });
8461
+ ].forEach((b) => {
8462
+ const m = document.createElement("option");
8463
+ m.value = b.id, m.textContent = b.label, p.appendChild(m);
8464
+ }), p.value = this.activeStyles.fontSize, p.addEventListener("change", (b) => {
8465
+ var m;
8466
+ if (this.activeStyles.fontSize = b.target.value, (m = this.mathField) != null && m.applyStyle) {
8467
+ const M = this.activeStyles.fontSize === "auto" ? "none" : parseInt(this.activeStyles.fontSize, 10);
8468
+ this.mathField.applyStyle({ fontSize: M });
8427
8469
  }
8428
8470
  this.renderToolbarItems();
8429
- })), n.appendChild(g);
8471
+ })), n.appendChild(p);
8430
8472
  return;
8431
8473
  }
8432
- const c = h.action === "BOLD", w = h.action === "ITALIC", x = h.action === "TEXT_COLOR", k = h.action === "SPECIAL_CHARS", y = c && this.activeStyles.bold || w && this.activeStyles.italic || x && this.activeStyles.color !== "none", b = document.createElement("button");
8433
- b.type = "button", b.className = "cme-btn" + (e.isTemplate ? " template" : "") + (h.cls ? ` ${h.cls}` : "") + (y ? " active" : ""), b.title = h.title || h.label || h.insert || "", typeof h.label == "string" && (h.label.includes("<svg") || h.label.includes("<img") || h.label.includes("<strong") || h.label.includes("<em")) ? b.innerHTML = h.label : typeof h.label == "string" && (b.textContent = h.label), b.addEventListener("mousedown", (u) => {
8434
- var g, p, d, m, C, M, f, A, B, H;
8435
- u.preventDefault();
8474
+ const c = h.action === "BOLD", g = h.action === "ITALIC", x = h.action === "TEXT_COLOR", u = h.action === "SPECIAL_CHARS", y = c && this.activeStyles.bold || g && this.activeStyles.italic || x && this.activeStyles.color !== "none", w = document.createElement("button");
8475
+ w.type = "button", w.className = "cme-btn" + (e.isTemplate ? " template" : "") + (h.cls ? ` ${h.cls}` : "") + (y ? " active" : ""), w.title = h.title || h.label || h.insert || "", typeof h.label == "string" && (h.label.includes("<svg") || h.label.includes("<img") || h.label.includes("<strong") || h.label.includes("<em")) ? w.innerHTML = h.label : typeof h.label == "string" && (w.textContent = h.label), w.addEventListener("mousedown", (k) => {
8476
+ var p, b, m, M, d, S, C, f, T, I;
8477
+ k.preventDefault();
8436
8478
  const i = this.mathField;
8437
- if (k) {
8438
- const v = b.getBoundingClientRect();
8479
+ if (u) {
8480
+ this.closeAllPopups();
8481
+ const v = w.getBoundingClientRect();
8439
8482
  this.openSpecialCharacters(v);
8440
- } else if (x) {
8441
- const v = b.getBoundingClientRect();
8442
- this.openColorPicker(v);
8443
- } else if (c) {
8444
- if (this.explicitToggle = !0, this.activeStyles.bold = !this.activeStyles.bold, i) {
8483
+ } else if (x)
8484
+ if (this.colorPickerPopup && this.activeColorBtn === w)
8485
+ this.closeColorPicker();
8486
+ else {
8487
+ const v = w.getBoundingClientRect();
8488
+ this.openColorPicker(v, w);
8489
+ }
8490
+ else if (c) {
8491
+ if (this.closeAllPopups(), this.explicitToggle = !0, this.activeStyles.bold = !this.activeStyles.bold, i) {
8445
8492
  if (i.selectionIsCollapsed)
8446
8493
  this.activeStyles.bold || (i.styleBias = "none", i.defaultStyle && (delete i.defaultStyle.variantStyle, delete i.defaultStyle.fontSeries));
8447
8494
  else {
8448
8495
  const v = this.getSelectionLatex(i);
8449
8496
  if (v && v.trim()) {
8450
- const D = F(v.trim()), E = T(
8451
- D,
8497
+ const R = F(v.trim()), A = B(
8498
+ R,
8452
8499
  this.activeStyles.bold,
8453
8500
  this.activeStyles.italic,
8454
8501
  this.activeStyles.fontFamily
8455
8502
  );
8456
- if (this.activeStyles.bold || (i.styleBias = "none", i.defaultStyle && (delete i.defaultStyle.variantStyle, delete i.defaultStyle.fontSeries)), this.isAllSelected(i) ? (i.setValue(E), i.executeCommand ? i.executeCommand("selectAll") : (g = i.model) != null && g.setSelection && i.model.setSelection(0, i.model.lastOffset)) : i.executeCommand ? i.executeCommand([
8503
+ if (this.activeStyles.bold || (i.styleBias = "none", i.defaultStyle && (delete i.defaultStyle.variantStyle, delete i.defaultStyle.fontSeries)), this.isAllSelected(i) ? (i.setValue(A), i.executeCommand ? i.executeCommand("selectAll") : (p = i.model) != null && p.setSelection && i.model.setSelection(0, i.model.lastOffset)) : i.executeCommand ? i.executeCommand([
8457
8504
  "insert",
8458
- E,
8505
+ A,
8459
8506
  { selectionMode: "item" }
8460
- ]) : i.insert && i.insert(E, { selectionMode: "item" }), !this.activeStyles.bold && i.applyStyle)
8507
+ ]) : i.insert && i.insert(A, { selectionMode: "item" }), !this.activeStyles.bold && i.applyStyle)
8461
8508
  try {
8462
8509
  i.applyStyle(
8463
8510
  {
@@ -8473,24 +8520,24 @@ const L = class L {
8473
8520
  i.focus();
8474
8521
  }
8475
8522
  this.renderToolbarItems();
8476
- } else if (w) {
8477
- if (this.explicitToggle = !0, this.activeStyles.italic = !this.activeStyles.italic, i) {
8523
+ } else if (g) {
8524
+ if (this.closeAllPopups(), this.explicitToggle = !0, this.activeStyles.italic = !this.activeStyles.italic, i) {
8478
8525
  if (i.selectionIsCollapsed)
8479
8526
  this.activeStyles.italic || (i.styleBias = "none", i.defaultStyle && (delete i.defaultStyle.variantStyle, delete i.defaultStyle.fontShape));
8480
8527
  else {
8481
8528
  const v = this.getSelectionLatex(i);
8482
8529
  if (v && v.trim()) {
8483
- const D = F(v.trim()), E = T(
8484
- D,
8530
+ const R = F(v.trim()), A = B(
8531
+ R,
8485
8532
  this.activeStyles.bold,
8486
8533
  this.activeStyles.italic,
8487
8534
  this.activeStyles.fontFamily
8488
8535
  );
8489
- if (this.activeStyles.italic || (i.styleBias = "none", i.defaultStyle && (delete i.defaultStyle.variantStyle, delete i.defaultStyle.fontShape)), this.isAllSelected(i) ? (i.setValue(E), i.executeCommand ? i.executeCommand("selectAll") : (p = i.model) != null && p.setSelection && i.model.setSelection(0, i.model.lastOffset)) : i.executeCommand ? i.executeCommand([
8536
+ if (this.activeStyles.italic || (i.styleBias = "none", i.defaultStyle && (delete i.defaultStyle.variantStyle, delete i.defaultStyle.fontShape)), this.isAllSelected(i) ? (i.setValue(A), i.executeCommand ? i.executeCommand("selectAll") : (b = i.model) != null && b.setSelection && i.model.setSelection(0, i.model.lastOffset)) : i.executeCommand ? i.executeCommand([
8490
8537
  "insert",
8491
- E,
8538
+ A,
8492
8539
  { selectionMode: "item" }
8493
- ]) : i.insert && i.insert(E, { selectionMode: "item" }), !this.activeStyles.italic && i.applyStyle)
8540
+ ]) : i.insert && i.insert(A, { selectionMode: "item" }), !this.activeStyles.italic && i.applyStyle)
8494
8541
  try {
8495
8542
  i.applyStyle(
8496
8543
  {
@@ -8507,122 +8554,141 @@ const L = class L {
8507
8554
  }
8508
8555
  this.renderToolbarItems();
8509
8556
  } else if (h.action === "UNDO")
8510
- (d = i == null ? void 0 : i.executeCommand) == null || d.call(i, "undo");
8557
+ this.closeAllPopups(), (m = i == null ? void 0 : i.executeCommand) == null || m.call(i, "undo");
8511
8558
  else if (h.action === "REDO")
8512
- (m = i == null ? void 0 : i.executeCommand) == null || m.call(i, "redo");
8559
+ this.closeAllPopups(), (M = i == null ? void 0 : i.executeCommand) == null || M.call(i, "redo");
8513
8560
  else if (h.action === "CUT")
8514
- (C = i == null ? void 0 : i.focus) == null || C.call(i), (M = i == null ? void 0 : i.executeCommand) == null || M.call(i, "cutToClipboard");
8561
+ this.closeAllPopups(), (d = i == null ? void 0 : i.focus) == null || d.call(i), (S = i == null ? void 0 : i.executeCommand) == null || S.call(i, "cutToClipboard");
8515
8562
  else if (h.action === "COPY")
8516
- (f = i == null ? void 0 : i.focus) == null || f.call(i), (A = i == null ? void 0 : i.executeCommand) == null || A.call(i, "copyToClipboard");
8563
+ this.closeAllPopups(), (C = i == null ? void 0 : i.focus) == null || C.call(i), (f = i == null ? void 0 : i.executeCommand) == null || f.call(i, "copyToClipboard");
8517
8564
  else if (h.action === "PASTE")
8518
- (B = i == null ? void 0 : i.focus) == null || B.call(i), (H = i == null ? void 0 : i.executeCommand) == null || H.call(i, "pasteFromClipboard");
8519
- else if (h.action === "MATRIX_HOVER") {
8520
- const v = b.getBoundingClientRect();
8521
- this.openMatrixGrid(h.matrixType || "matrix", v);
8522
- } else
8565
+ this.closeAllPopups(), (T = i == null ? void 0 : i.focus) == null || T.call(i), (I = i == null ? void 0 : i.executeCommand) == null || I.call(i, "pasteFromClipboard");
8566
+ else if (h.action === "MATRIX_HOVER")
8567
+ if (this.activeMatrixPopup && this.activeMatrixBtn === w)
8568
+ this.closeMatrixPopup();
8569
+ else {
8570
+ const v = w.getBoundingClientRect();
8571
+ this.openMatrixGrid(h.matrixType || "matrix", v, w);
8572
+ }
8573
+ else
8523
8574
  this.insertAtCursor(h);
8524
- }), n.appendChild(b);
8575
+ }), n.appendChild(w);
8525
8576
  }), this.itemsWrapper.appendChild(n);
8526
8577
  });
8527
8578
  }
8528
- openDropdown(t, e, r) {
8529
- this.closeAllPopups(), this.activeDropdown = document.createElement("div"), this.activeDropdown.className = "cme-more-popup", this.activeDropdown.style.gridTemplateColumns = `repeat(${r}, auto)`, this.activeDropdown.style.left = `${e.left + e.width / 2}px`, this.activeDropdown.style.top = `${e.bottom + 4}px`, this.activeDropdown.style.transform = "translateX(-50%)", t.forEach((l) => {
8530
- const a = document.createElement("button");
8531
- a.type = "button", a.className = "cme-more-popup-btn " + (l.cls || ""), a.title = l.title || l.label || l.insert || "", typeof l.label == "string" && (l.label.includes("<svg") || l.label.includes("<img")) ? a.innerHTML = l.label : a.textContent = l.label, a.addEventListener("mousedown", (s) => {
8532
- s.preventDefault(), this.insertAtCursor(l.insert || l), this.closeDropdown();
8533
- }), this.activeDropdown.appendChild(a);
8579
+ openDropdown(t, e, r, s = null) {
8580
+ this.closeAllPopups(), this.activeDropdownBtn = s, this.activeDropdown = document.createElement("div"), this.activeDropdown.className = "cme-more-popup", this.activeDropdown.style.gridTemplateColumns = `repeat(${r}, auto)`, this.activeDropdown.style.left = `${e.left + e.width / 2}px`, this.activeDropdown.style.top = `${e.bottom + 4}px`, this.activeDropdown.style.transform = "translateX(-50%)", this.activeDropdown.addEventListener(
8581
+ "mousedown",
8582
+ (o) => o.stopPropagation()
8583
+ ), this.activeDropdown.addEventListener(
8584
+ "pointerdown",
8585
+ (o) => o.stopPropagation()
8586
+ ), t.forEach((o) => {
8587
+ const l = document.createElement("button");
8588
+ l.type = "button", l.className = "cme-more-popup-btn " + (o.cls || ""), l.title = o.title || o.label || o.insert || "", typeof o.label == "string" && (o.label.includes("<svg") || o.label.includes("<img")) ? l.innerHTML = o.label : l.textContent = o.label, l.addEventListener("mousedown", (n) => {
8589
+ n.preventDefault(), this.insertAtCursor(o.insert || o), this.closeDropdown();
8590
+ }), this.activeDropdown.appendChild(l);
8534
8591
  }), document.body.appendChild(this.activeDropdown);
8535
8592
  }
8536
8593
  closeDropdown() {
8537
- this.activeDropdown && this.activeDropdown.parentNode && this.activeDropdown.parentNode.removeChild(this.activeDropdown), this.activeDropdown = null;
8594
+ this.activeDropdown && this.activeDropdown.parentNode && this.activeDropdown.parentNode.removeChild(this.activeDropdown), this.activeDropdown = null, this.activeDropdownBtn = null;
8538
8595
  }
8539
- openMatrixGrid(t, e) {
8540
- this.closeAllPopups(), this.activeMatrixPopup = document.createElement("div"), this.activeMatrixPopup.className = "cme-matrix-hover-popover ck-only", this.activeMatrixPopup.style.left = `${e.left + e.width / 2}px`, this.activeMatrixPopup.style.top = `${e.bottom + 6}px`, this.activeMatrixPopup.style.minHeight = "auto", this.activeMatrixPopup.addEventListener(
8596
+ openMatrixGrid(t, e, r = null) {
8597
+ this.closeAllPopups(), this.activeMatrixBtn = r, this.activeMatrixPopup = document.createElement("div"), this.activeMatrixPopup.className = "cme-matrix-hover-popover ck-only", this.activeMatrixPopup.style.left = `${e.left + e.width / 2}px`, this.activeMatrixPopup.style.top = `${e.bottom + 6}px`, this.activeMatrixPopup.style.minHeight = "auto", this.activeMatrixPopup.addEventListener(
8541
8598
  "mousedown",
8542
- (m) => m.stopPropagation()
8599
+ (d) => d.stopPropagation()
8600
+ ), this.activeMatrixPopup.addEventListener(
8601
+ "pointerdown",
8602
+ (d) => d.stopPropagation()
8543
8603
  );
8544
- const r = document.createElement("div");
8545
- r.className = "cme-matrix-hover-title", r.textContent = t === "matrix" ? "MATRIX" : `${t.toUpperCase()} MATRIX`;
8546
- const l = document.createElement("div");
8547
- l.className = "cme-matrix-hover-grid", l.style.flex = "none";
8548
- let a = 2, s = 2;
8549
- const n = document.createElement("div");
8550
- n.className = "cme-matrix-hover-footer";
8604
+ const s = document.createElement("div");
8605
+ s.className = "cme-matrix-hover-title", s.textContent = t === "matrix" ? "MATRIX" : `${t.toUpperCase()} MATRIX`;
8606
+ const o = document.createElement("div");
8607
+ o.className = "cme-matrix-hover-grid", o.style.flex = "none";
8608
+ let l = 2, n = 2;
8551
8609
  const h = document.createElement("div");
8552
- h.className = "cme-matrix-counter";
8553
- const c = document.createElement("input");
8554
- c.type = "number", c.className = "cme-counter-val", c.min = "1", c.max = "10", c.value = a;
8555
- const w = document.createElement("div");
8556
- w.className = "cme-counter-btns";
8557
- const x = document.createElement("button");
8558
- x.type = "button", x.textContent = "▲";
8559
- const k = document.createElement("button");
8560
- k.type = "button", k.textContent = "▼", w.appendChild(x), w.appendChild(k);
8561
- const y = document.createElement("span");
8562
- y.textContent = "×";
8563
- const b = document.createElement("input");
8564
- b.type = "number", b.className = "cme-counter-val", b.min = "1", b.max = "10", b.value = s;
8565
- const u = document.createElement("div");
8566
- u.className = "cme-counter-btns";
8567
- const i = document.createElement("button");
8568
- i.type = "button", i.textContent = "▲";
8569
- const g = document.createElement("button");
8570
- g.type = "button", g.textContent = "▼", u.appendChild(i), u.appendChild(g), h.appendChild(c), h.appendChild(w), h.appendChild(y), h.appendChild(b), h.appendChild(u);
8610
+ h.className = "cme-matrix-hover-footer";
8611
+ const c = document.createElement("div");
8612
+ c.className = "cme-matrix-counter";
8613
+ const g = document.createElement("input");
8614
+ g.type = "number", g.className = "cme-counter-val", g.min = "1", g.max = "10", g.value = l;
8615
+ const x = document.createElement("div");
8616
+ x.className = "cme-counter-btns";
8617
+ const u = document.createElement("button");
8618
+ u.type = "button", u.textContent = "▲";
8619
+ const y = document.createElement("button");
8620
+ y.type = "button", y.textContent = "▼", x.appendChild(u), x.appendChild(y);
8621
+ const w = document.createElement("span");
8622
+ w.textContent = "×";
8623
+ const k = document.createElement("input");
8624
+ k.type = "number", k.className = "cme-counter-val", k.min = "1", k.max = "10", k.value = n;
8625
+ const i = document.createElement("div");
8626
+ i.className = "cme-counter-btns";
8571
8627
  const p = document.createElement("button");
8572
- p.type = "button", p.className = "cme-matrix-insert-btn", p.textContent = "INSERT", n.appendChild(h), n.appendChild(p);
8573
- const d = (m, C) => {
8574
- a = Math.max(1, Math.min(10, m)), s = Math.max(1, Math.min(10, C)), c.value = a, b.value = s, l.querySelectorAll(".cme-matrix-hover-cell").forEach((f) => {
8575
- const A = parseInt(f.dataset.row, 10), B = parseInt(f.dataset.col, 10);
8576
- A <= a && B <= s ? f.classList.add("selected") : f.classList.remove("selected");
8628
+ p.type = "button", p.textContent = "▲";
8629
+ const b = document.createElement("button");
8630
+ b.type = "button", b.textContent = "▼", i.appendChild(p), i.appendChild(b), c.appendChild(g), c.appendChild(x), c.appendChild(w), c.appendChild(k), c.appendChild(i);
8631
+ const m = document.createElement("button");
8632
+ m.type = "button", m.className = "cme-matrix-insert-btn", m.textContent = "INSERT", h.appendChild(c), h.appendChild(m);
8633
+ const M = (d, S) => {
8634
+ l = Math.max(1, Math.min(10, d)), n = Math.max(1, Math.min(10, S)), g.value = l, k.value = n, o.querySelectorAll(".cme-matrix-hover-cell").forEach((f) => {
8635
+ const T = parseInt(f.dataset.row, 10), I = parseInt(f.dataset.col, 10);
8636
+ T <= l && I <= n ? f.classList.add("selected") : f.classList.remove("selected");
8577
8637
  });
8578
8638
  };
8579
- for (let m = 1; m <= 5; m++) {
8580
- const C = document.createElement("div");
8581
- C.className = "cme-matrix-hover-row";
8582
- for (let M = 1; M <= 10; M++) {
8639
+ for (let d = 1; d <= 5; d++) {
8640
+ const S = document.createElement("div");
8641
+ S.className = "cme-matrix-hover-row";
8642
+ for (let C = 1; C <= 10; C++) {
8583
8643
  const f = document.createElement("div");
8584
- f.className = "cme-matrix-hover-cell" + (m <= a && M <= s ? " selected" : ""), f.dataset.row = m, f.dataset.col = M, f.addEventListener("mouseenter", () => {
8585
- d(m, M);
8586
- }), f.addEventListener("click", (A) => {
8587
- A.stopPropagation(), this.insertMatrix(t, m, M), this.closeMatrixPopup();
8588
- }), C.appendChild(f);
8644
+ f.className = "cme-matrix-hover-cell" + (d <= l && C <= n ? " selected" : ""), f.dataset.row = d, f.dataset.col = C, f.addEventListener("mouseenter", () => {
8645
+ M(d, C);
8646
+ }), f.addEventListener("click", (T) => {
8647
+ T.stopPropagation(), this.insertMatrix(t, d, C), this.closeMatrixPopup();
8648
+ }), S.appendChild(f);
8589
8649
  }
8590
- l.appendChild(C);
8650
+ o.appendChild(S);
8591
8651
  }
8592
- c.addEventListener("input", () => {
8593
- const m = parseInt(c.value, 10) || 1;
8594
- d(m, s);
8595
- }), b.addEventListener("input", () => {
8596
- const m = parseInt(b.value, 10) || 1;
8597
- d(a, m);
8598
- }), x.addEventListener("click", (m) => {
8599
- m.preventDefault(), m.stopPropagation(), d(a + 1, s);
8600
- }), k.addEventListener("click", (m) => {
8601
- m.preventDefault(), m.stopPropagation(), d(a - 1, s);
8602
- }), i.addEventListener("click", (m) => {
8603
- m.preventDefault(), m.stopPropagation(), d(a, s + 1);
8604
- }), g.addEventListener("click", (m) => {
8605
- m.preventDefault(), m.stopPropagation(), d(a, s - 1);
8606
- }), p.addEventListener("click", (m) => {
8607
- m.stopPropagation(), this.insertMatrix(t, a, s), this.closeMatrixPopup();
8608
- }), this.activeMatrixPopup.appendChild(r), this.activeMatrixPopup.appendChild(l), this.activeMatrixPopup.appendChild(n), document.body.appendChild(this.activeMatrixPopup);
8652
+ g.addEventListener("input", () => {
8653
+ const d = parseInt(g.value, 10) || 1;
8654
+ M(d, n);
8655
+ }), k.addEventListener("input", () => {
8656
+ const d = parseInt(k.value, 10) || 1;
8657
+ M(l, d);
8658
+ }), u.addEventListener("click", (d) => {
8659
+ d.preventDefault(), d.stopPropagation(), M(l + 1, n);
8660
+ }), y.addEventListener("click", (d) => {
8661
+ d.preventDefault(), d.stopPropagation(), M(l - 1, n);
8662
+ }), p.addEventListener("click", (d) => {
8663
+ d.preventDefault(), d.stopPropagation(), M(l, n + 1);
8664
+ }), b.addEventListener("click", (d) => {
8665
+ d.preventDefault(), d.stopPropagation(), M(l, n - 1);
8666
+ }), m.addEventListener("click", (d) => {
8667
+ d.stopPropagation(), this.insertMatrix(t, l, n), this.closeMatrixPopup();
8668
+ }), this.activeMatrixPopup.appendChild(s), this.activeMatrixPopup.appendChild(o), this.activeMatrixPopup.appendChild(h), document.body.appendChild(this.activeMatrixPopup);
8609
8669
  }
8610
8670
  insertMatrix(t, e, r) {
8611
- let l = [];
8671
+ let s = [];
8612
8672
  for (let n = 0; n < e; n++) {
8613
8673
  let h = [];
8614
8674
  for (let c = 0; c < r; c++)
8615
8675
  h.push("{#?}");
8616
- l.push(h.join(" & "));
8676
+ s.push(h.join(" & "));
8617
8677
  }
8618
- const a = t || "matrix", s = `\\begin{${a}}${l.join(" \\\\ ")}\\end{${a}}`;
8619
- this.insertAtCursor(s);
8678
+ const o = t || "matrix", l = `\\begin{${o}}${s.join(" \\\\ ")}\\end{${o}}`;
8679
+ this.insertAtCursor(l);
8620
8680
  }
8621
8681
  closeMatrixPopup() {
8622
- this.activeMatrixPopup && this.activeMatrixPopup.parentNode && this.activeMatrixPopup.parentNode.removeChild(this.activeMatrixPopup), this.activeMatrixPopup = null;
8682
+ this.activeMatrixPopup && this.activeMatrixPopup.parentNode && this.activeMatrixPopup.parentNode.removeChild(this.activeMatrixPopup), this.activeMatrixPopup = null, this.activeMatrixBtn = null;
8623
8683
  }
8624
- openColorPicker(t) {
8625
- this.closeAllPopups(), this.colorPickerPopup = document.createElement("div"), this.colorPickerPopup.className = "cme-more-popup", this.colorPickerPopup.style.gridTemplateColumns = "repeat(4, auto)", this.colorPickerPopup.style.left = `${t.left + t.width / 2}px`, this.colorPickerPopup.style.top = `${t.bottom + 4}px`, this.colorPickerPopup.style.transform = "translateX(-50%)", [
8684
+ openColorPicker(t, e = null) {
8685
+ this.closeAllPopups(), this.activeColorBtn = e, this.colorPickerPopup = document.createElement("div"), this.colorPickerPopup.className = "cme-more-popup", this.colorPickerPopup.style.gridTemplateColumns = "repeat(4, auto)", this.colorPickerPopup.style.left = `${t.left + t.width / 2}px`, this.colorPickerPopup.style.top = `${t.bottom + 4}px`, this.colorPickerPopup.style.transform = "translateX(-50%)", this.colorPickerPopup.addEventListener(
8686
+ "mousedown",
8687
+ (s) => s.stopPropagation()
8688
+ ), this.colorPickerPopup.addEventListener(
8689
+ "pointerdown",
8690
+ (s) => s.stopPropagation()
8691
+ ), [
8626
8692
  "black",
8627
8693
  "#e53935",
8628
8694
  "#1e88e5",
@@ -8631,16 +8697,16 @@ const L = class L {
8631
8697
  "#8e24aa",
8632
8698
  "#3949ab",
8633
8699
  "#00acc1"
8634
- ].forEach((r) => {
8635
- const l = document.createElement("div");
8636
- l.style.width = "18px", l.style.height = "18px", l.style.borderRadius = "50%", l.style.margin = "4px", l.style.cursor = "pointer", l.style.backgroundColor = r, l.style.border = this.activeStyles.color === r ? "2px solid #222" : "1px solid #ddd", l.addEventListener("mousedown", (a) => {
8637
- var s;
8638
- a.preventDefault(), this.activeStyles.color = r, (s = this.mathField) != null && s.applyStyle && this.mathField.applyStyle({ color: r === "black" ? "none" : r }), this.closeColorPicker(), this.renderToolbarItems();
8639
- }), this.colorPickerPopup.appendChild(l);
8700
+ ].forEach((s) => {
8701
+ const o = document.createElement("div");
8702
+ o.style.width = "18px", o.style.height = "18px", o.style.borderRadius = "50%", o.style.margin = "4px", o.style.cursor = "pointer", o.style.backgroundColor = s, o.style.border = this.activeStyles.color === s ? "2px solid #222" : "1px solid #ddd", o.addEventListener("mousedown", (l) => {
8703
+ var n;
8704
+ l.preventDefault(), this.activeStyles.color = s, (n = this.mathField) != null && n.applyStyle && this.mathField.applyStyle({ color: s === "black" ? "none" : s }), this.closeColorPicker(), this.renderToolbarItems();
8705
+ }), this.colorPickerPopup.appendChild(o);
8640
8706
  }), document.body.appendChild(this.colorPickerPopup);
8641
8707
  }
8642
8708
  closeColorPicker() {
8643
- this.colorPickerPopup && this.colorPickerPopup.parentNode && this.colorPickerPopup.parentNode.removeChild(this.colorPickerPopup), this.colorPickerPopup = null;
8709
+ this.colorPickerPopup && this.colorPickerPopup.parentNode && this.colorPickerPopup.parentNode.removeChild(this.colorPickerPopup), this.colorPickerPopup = null, this.activeColorBtn = null;
8644
8710
  }
8645
8711
  openSpecialCharacters(t) {
8646
8712
  this.specCharModal || (this.specCharModal = new dt({
@@ -8656,10 +8722,10 @@ const L = class L {
8656
8722
  this.close();
8657
8723
  }
8658
8724
  };
8659
- U(L, "VERSION", S == null ? void 0 : S.version);
8660
- let O = L, R = null;
8725
+ U(D, "VERSION", E == null ? void 0 : E.version);
8726
+ let H = D, O = null;
8661
8727
  function pt() {
8662
- return R || (R = new O()), R;
8728
+ return O || (O = new H()), O;
8663
8729
  }
8664
8730
  class X {
8665
8731
  constructor(t = {}) {
@@ -8691,43 +8757,43 @@ class X {
8691
8757
  this.element && this.element.parentNode && this.element.parentNode.removeChild(this.element);
8692
8758
  }
8693
8759
  }
8694
- function wt(o) {
8695
- return new X(o);
8760
+ function wt(a) {
8761
+ return new X(a);
8696
8762
  }
8697
8763
  if (typeof customElements < "u" && !customElements.get("digi-math-widget")) {
8698
- class o extends HTMLElement {
8764
+ class a extends HTMLElement {
8699
8765
  static get observedAttributes() {
8700
8766
  return ["latex", "editable", "mode"];
8701
8767
  }
8702
8768
  connectedCallback() {
8703
- const e = this.getAttribute("latex") || "", r = this.getAttribute("editable") !== "false", l = this.getAttribute("mode") || "math";
8769
+ const e = this.getAttribute("latex") || "", r = this.getAttribute("editable") !== "false", s = this.getAttribute("mode") || "math";
8704
8770
  this.widget = new X({
8705
8771
  container: this,
8706
8772
  latex: e,
8707
8773
  editable: r,
8708
- mode: l,
8709
- onUpdate: (a) => {
8710
- this.setAttribute("latex", a), this.dispatchEvent(new CustomEvent("latexChange", { detail: { latex: a }, bubbles: !0 }));
8774
+ mode: s,
8775
+ onUpdate: (o) => {
8776
+ this.setAttribute("latex", o), this.dispatchEvent(new CustomEvent("latexChange", { detail: { latex: o }, bubbles: !0 }));
8711
8777
  }
8712
8778
  });
8713
8779
  }
8714
- attributeChangedCallback(e, r, l) {
8715
- r !== l && e === "latex" && this.widget && this.widget.setLatex(l);
8780
+ attributeChangedCallback(e, r, s) {
8781
+ r !== s && e === "latex" && this.widget && this.widget.setLatex(s);
8716
8782
  }
8717
8783
  disconnectedCallback() {
8718
8784
  this.widget && this.widget.destroy();
8719
8785
  }
8720
8786
  }
8721
- customElements.define("digi-math-widget", o);
8787
+ customElements.define("digi-math-widget", a);
8722
8788
  }
8723
- const kt = S == null ? void 0 : S.version;
8789
+ const kt = E == null ? void 0 : E.version;
8724
8790
  export {
8725
8791
  ot as CME_SHADOW_DOM_CSS,
8726
- O as DigiMathChemEditor,
8792
+ H as DigiMathChemEditor,
8727
8793
  X as DigiMathWidget,
8728
8794
  dt as SpecialCharacterModal,
8729
8795
  kt as VERSION,
8730
8796
  wt as createMathWidget,
8731
- O as default,
8797
+ H as default,
8732
8798
  nt as initMathFieldCursorFix
8733
8799
  };