@pie-element/shared-math-rendering-mathjax 0.1.2 → 0.1.3-next.20261007003844

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,88 +1,89 @@
1
+ import { a as e, c as t, s as n, t as r, u as i } from "./speech-worker-CP5P4gRS.js";
1
2
  //#region src/engine/bundled.ts
2
- var e;
3
- function t() {
4
- return e;
3
+ var a;
4
+ function o() {
5
+ return a;
5
6
  }
6
- var n = import("./mathjax-D2JHb_R_.js");
7
- n.catch(() => {});
8
- async function r(t, r) {
9
- let { createMathJax: i } = await n;
10
- e = i(t), (t.startup?.ready ?? e.startup?.defaultReady)?.();
7
+ var s = import("./mathjax-BKrHE4xs.js");
8
+ s.catch(() => {});
9
+ async function c(e, t) {
10
+ let { createMathJax: n } = await s;
11
+ return a = n(e, t, f), (e.startup?.ready ?? a.startup?.defaultReady)?.(), !0;
11
12
  }
12
- var i = {}, a = Symbol.for("@pie-element/shared-math-rendering-mathjax/bundled");
13
- function o() {
13
+ var l = {}, u = Symbol.for("@pie-element/shared-math-rendering-mathjax/bundled");
14
+ function d() {
14
15
  let e = globalThis;
15
- return e[a] = (e[a] ?? 0) + 1, `PIE-MJX-CHTML-styles-${e[a]}`;
16
+ return e[u] = (e[u] ?? 0) + 1, e[u];
16
17
  }
17
- var s = o(), c = ["MJX-CHTML-styles"], l = "http://www.w3.org/1998/Math/MathML", u = /^([a-z_][\w.-]*):math$/, d = /^[a-z][a-z0-9-]*$/;
18
- function f(e) {
18
+ var f = d(), p = `PIE-MJX-CHTML-styles-${f}`, m = ["MJX-CHTML-styles"], h = "http://www.w3.org/1998/Math/MathML", g = /^([a-z_][\w.-]*):math$/, _ = /^[a-z][a-z0-9-]*$/;
19
+ function v(e) {
19
20
  for (let t of e.querySelectorAll("*")) {
20
- let n = u.exec(t.tagName.toLowerCase())?.[1];
21
- !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(p(t, `${n}:`));
21
+ let n = g.exec(t.tagName.toLowerCase())?.[1];
22
+ !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(ee(t, `${n}:`));
22
23
  }
23
24
  }
24
- function p(e, t) {
25
+ function ee(e, t) {
25
26
  let n = e.tagName.toLowerCase().slice(t.length);
26
- if (!d.test(n)) return e;
27
- let r = e.ownerDocument.createElementNS(l, n);
27
+ if (!_.test(n)) return e;
28
+ let r = e.ownerDocument.createElementNS(h, n);
28
29
  for (let t of e.attributes) r.setAttribute(t.name, t.value);
29
30
  for (let n of [...e.childNodes]) {
30
31
  let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
31
- r.appendChild(e ? p(n, t) : n);
32
+ r.appendChild(e ? ee(n, t) : n);
32
33
  }
33
34
  return r;
34
35
  }
35
36
  //#endregion
36
37
  //#region src/elementary-math.ts
37
- var m = /* @__PURE__ */ new Set([
38
+ var te = /* @__PURE__ */ new Set([
38
39
  "updiagonalstrike",
39
40
  "downdiagonalstrike",
40
41
  "verticalstrike",
41
42
  "horizontalstrike"
42
- ]), h = {
43
+ ]), ne = {
43
44
  thin: "0.035em",
44
45
  medium: "0.07em",
45
46
  thick: "0.14em"
46
- }, g = {
47
+ }, y = {
47
48
  tight: "0em",
48
49
  medium: "0.1em",
49
50
  loose: "0.2em"
50
- }, _ = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, v = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ee = /^(\d+(\.\d*)?|\.\d+)$/, te = /* @__PURE__ */ new Set([
51
+ }, re = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ie = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ae = /^(\d+(\.\d*)?|\.\d+)$/, oe = /* @__PURE__ */ new Set([
51
52
  "mn",
52
53
  "mo",
53
54
  "mi",
54
55
  "mtext"
55
- ]), ne = /* @__PURE__ */ new Set([
56
+ ]), se = /* @__PURE__ */ new Set([
56
57
  "stackalign",
57
58
  "charalign",
58
59
  "charspacing",
59
60
  "longdivstyle"
60
61
  ]);
61
- function y(e, t, n = [], r = {}) {
62
- let i = e.createElementNS(l, t);
62
+ function b(e, t, n = [], r = {}) {
63
+ let i = e.createElementNS(h, t);
63
64
  for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
64
65
  for (let e of n) e && i.appendChild(e);
65
66
  return i;
66
67
  }
67
- function b(e, t) {
68
- let n = y(e.document, "mo");
68
+ function x(e, t) {
69
+ let n = b(e.document, "mo");
69
70
  return n.textContent = t, n;
70
71
  }
71
- function x(e) {
72
- let t = y(e.document, "mn");
73
- return t.textContent = "0", y(e.document, "mphantom", [t]);
72
+ function S(e) {
73
+ let t = b(e.document, "mn");
74
+ return t.textContent = "0", b(e.document, "mphantom", [t]);
74
75
  }
75
- function S(e, t) {
76
+ function C(e, t) {
76
77
  return e.getAttribute(t)?.trim().toLowerCase() || void 0;
77
78
  }
78
- function C(e, t) {
79
+ function w(e, t) {
79
80
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
80
81
  return Number.isFinite(n) ? n : 0;
81
82
  }
82
- function w(e) {
83
+ function T(e) {
83
84
  return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
84
85
  }
85
- function T(e, t, n = e) {
86
+ function E(e, t, n = e) {
86
87
  switch (t) {
87
88
  case "left": return 0;
88
89
  case "center": return Math.floor(e / 2);
@@ -90,14 +91,14 @@ function T(e, t, n = e) {
90
91
  default: return n;
91
92
  }
92
93
  }
93
- function E(e, t, n) {
94
+ function D(e, t, n) {
94
95
  let r = [], i, a, o = (e, t) => {
95
96
  let s = (e) => t.reduceRight((e, t) => {
96
97
  let n = t.cloneNode(!1);
97
98
  return n.appendChild(e), n;
98
99
  }, e);
99
100
  if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
100
- else if (w(e)) r.push(null);
101
+ else if (T(e)) r.push(null);
101
102
  else if (e.localName === "mn" && e.children.length === 0) {
102
103
  let t = [...(e.textContent ?? "").trim()];
103
104
  for (let a of t) {
@@ -106,28 +107,28 @@ function E(e, t, n) {
106
107
  t.textContent = a, r.push(s(t));
107
108
  }
108
109
  t.length && (a ??= r.length);
109
- } else te.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
110
+ } else oe.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
110
111
  };
111
112
  for (let t of e) o(t, []);
112
113
  return {
113
114
  kind: "digits",
114
115
  cells: r,
115
- anchor: T(r.length, n.stackAlign, i ?? a),
116
+ anchor: E(r.length, n.stackAlign, i ?? a),
116
117
  position: t
117
118
  };
118
119
  }
119
- function D(e) {
120
- return (e ?? "").toLowerCase().split(/\s+/).filter((e) => m.has(e));
120
+ function O(e) {
121
+ return (e ?? "").toLowerCase().split(/\s+/).filter((e) => te.has(e));
121
122
  }
122
- function re(e, t) {
123
- let n = [...e.children].filter((e) => !w(e));
124
- return n.length <= 1 ? n[0] ?? null : y(t.document, "mrow", n);
123
+ function ce(e, t) {
124
+ let n = [...e.children].filter((e) => !T(e));
125
+ return n.length <= 1 ? n[0] ?? null : b(t.document, "mrow", n);
125
126
  }
126
- function ie(e, t, n) {
127
- let r = S(e, "location") ?? "n", i = D(e.getAttribute("crossout")), a = [...e.children].map((e) => w(e) ? null : e.localName === "mscarry" ? {
128
- content: re(e, n),
129
- location: S(e, "location") ?? r,
130
- crossout: e.hasAttribute("crossout") ? D(e.getAttribute("crossout")) : i
127
+ function le(e, t, n) {
128
+ let r = C(e, "location") ?? "n", i = O(e.getAttribute("crossout")), a = [...e.children].map((e) => T(e) ? null : e.localName === "mscarry" ? {
129
+ content: ce(e, n),
130
+ location: C(e, "location") ?? r,
131
+ crossout: e.hasAttribute("crossout") ? O(e.getAttribute("crossout")) : i
131
132
  } : {
132
133
  content: e,
133
134
  location: r,
@@ -136,60 +137,60 @@ function ie(e, t, n) {
136
137
  return {
137
138
  kind: "carries",
138
139
  carries: a,
139
- anchor: T(a.length, n.stackAlign),
140
+ anchor: E(a.length, n.stackAlign),
140
141
  position: t,
141
- scale: ee.test(o) ? o : "0.6"
142
+ scale: ae.test(o) ? o : "0.6"
142
143
  };
143
144
  }
144
- function O(e) {
145
- let t = S(e, "mslinethickness") ?? "medium", n = h[t] ?? (_.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
146
- return `${n} solid ${v.test(r) ? r : "currentColor"}`;
145
+ function k(e) {
146
+ let t = C(e, "mslinethickness") ?? "medium", n = ne[t] ?? (re.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
147
+ return `${n} solid ${ie.test(r) ? r : "currentColor"}`;
147
148
  }
148
- function ae(e, t, n) {
149
- let r = Math.max(0, C(e, "length"));
149
+ function ue(e, t, n) {
150
+ let r = Math.max(0, w(e, "length"));
150
151
  return {
151
152
  kind: "line",
152
153
  length: r,
153
- anchor: T(r, n.stackAlign),
154
+ anchor: E(r, n.stackAlign),
154
155
  position: t,
155
- border: O(e)
156
+ border: k(e)
156
157
  };
157
158
  }
158
- function k(e, t, n, r, i) {
159
+ function A(e, t, n, r, i) {
159
160
  e.forEach((e, a) => {
160
- let o = t + a * n + C(e, "position");
161
+ let o = t + a * n + w(e, "position");
161
162
  switch (e.localName) {
162
163
  case "msgroup":
163
- k([...e.children], o, C(e, "shift"), r, i);
164
+ A([...e.children], o, w(e, "shift"), r, i);
164
165
  break;
165
166
  case "msline":
166
- i.push(ae(e, o, r));
167
+ i.push(ue(e, o, r));
167
168
  break;
168
169
  case "mscarries":
169
- i.push(ie(e, o, r));
170
+ i.push(le(e, o, r));
170
171
  break;
171
172
  case "msrow":
172
173
  case "mrow":
173
- i.push(E([...e.children], o, r));
174
+ i.push(D([...e.children], o, r));
174
175
  break;
175
- default: i.push(E([e], o, r));
176
+ default: i.push(D([e], o, r));
176
177
  }
177
178
  });
178
179
  }
179
- function A(e) {
180
+ function j(e) {
180
181
  return -e.anchor - e.position;
181
182
  }
182
- function j(e) {
183
+ function de(e) {
183
184
  return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
184
185
  }
185
- function M(e) {
186
- return A(e) + j(e) - 1;
186
+ function fe(e) {
187
+ return j(e) + de(e) - 1;
187
188
  }
188
- function oe(e, t, n, r) {
189
- let i = (e) => y(r.document, "mpadded", [t], {
189
+ function pe(e, t, n, r) {
190
+ let i = (e) => b(r.document, "mpadded", [t], {
190
191
  width: "0",
191
192
  ...e ? { lspace: e } : {}
192
- }), a = (e, t) => y(r.document, e, t);
193
+ }), a = (e, t) => b(r.document, e, t);
193
194
  switch (n) {
194
195
  case "s": return a("munder", [e, i("-0.5width")]);
195
196
  case "ne": return a("msup", [e, i()]);
@@ -211,49 +212,49 @@ function oe(e, t, n, r) {
211
212
  default: return a("mover", [e, i("-0.5width")]);
212
213
  }
213
214
  }
214
- function se(e, t, n) {
215
- let r = y(n.document, "menclose", [e], {
215
+ function me(e, t, n) {
216
+ let r = b(n.document, "menclose", [e], {
216
217
  notation: t.join(" "),
217
218
  "data-padding": "0.1em",
218
219
  "data-thickness": "0.067em"
219
220
  }), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
220
- return i ? y(n.document, "mpadded", [r], {
221
+ return i ? b(n.document, "mpadded", [r], {
221
222
  lspace: `-${i}em`,
222
223
  width: `-${2 * i}em`
223
224
  }) : r;
224
225
  }
225
- function ce(e, t, n, r, i) {
226
- let a = e && t.crossout.length ? se(e, t.crossout, i) : e;
226
+ function he(e, t, n, r, i) {
227
+ let a = e && t.crossout.length ? me(e, t.crossout, i) : e;
227
228
  if (!t.content) return a;
228
- let o = y(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
229
- return oe(a ?? x(i), o, n, i);
229
+ let o = b(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
230
+ return pe(a ?? S(i), o, n, i);
230
231
  }
231
- function N(e, t) {
232
- return e.carries[t - A(e)] ?? null;
232
+ function M(e, t) {
233
+ return e.carries[t - j(e)] ?? null;
233
234
  }
234
- function le(e, t, n, r) {
235
+ function ge(e, t, n, r) {
235
236
  let i = e.content;
236
237
  n.forEach((e, a) => {
237
- let o = n.length - 1 - a, s = n[o], c = N(s, t), l = n.slice(0, o).some((e) => N(e, t));
238
+ let o = n.length - 1 - a, s = n[o], c = M(s, t), l = n.slice(0, o).some((e) => M(e, t));
238
239
  if (!c && !l) return;
239
240
  let u = c ?? {
240
- content: x(r),
241
+ content: S(r),
241
242
  location: "n",
242
243
  crossout: []
243
244
  }, d = a === 0 ? u.location : "n";
244
- i = ce(i, u, d, s.scale, r);
245
+ i = he(i, u, d, s.scale, r);
245
246
  }), e.content = i;
246
247
  }
247
- function P(e, t) {
248
- let n = e.filter((e) => j(e) > 0), r = Math.min(0, ...n.map(A)), i = Math.max(r, ...n.map(M)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
248
+ function N(e, t) {
249
+ let n = e.filter((e) => de(e) > 0), r = Math.min(0, ...n.map(j)), i = Math.max(r, ...n.map(fe)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
249
250
  content: null,
250
251
  borders: {}
251
- })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + A(e) + n), u = [], d = [], f = (e) => {
252
+ })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + j(e) + n), u = [], d = [], f = (e) => {
252
253
  let n = c();
253
254
  e.cells.forEach((t, r) => {
254
- n[a + A(e) + r].content = t;
255
+ n[a + j(e) + r].content = t;
255
256
  }), u.length && n.forEach((e, n) => {
256
- le(e, n - a, u, t);
257
+ ge(e, n - a, u, t);
257
258
  });
258
259
  for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
259
260
  u = [], d = [], s.set(e, o.length), o.push(n);
@@ -273,44 +274,44 @@ function P(e, t) {
273
274
  origin: a
274
275
  };
275
276
  }
276
- function F(e, { rows: t }, n) {
277
- let r = y(n.document, "mtable", t.map((e) => y(n.document, "mtr", e.map((e) => {
277
+ function P(e, { rows: t }, n) {
278
+ let r = b(n.document, "mtable", t.map((e) => b(n.document, "mtr", e.map((e) => {
278
279
  let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
279
- return y(n.document, "mtd", [e.content], {
280
+ return b(n.document, "mtd", [e.content], {
280
281
  ...t ? { style: t } : {},
281
282
  ...e.align ? { columnalign: e.align } : {}
282
283
  });
283
284
  }))));
284
- for (let { name: t, value: n } of [...e.attributes]) ne.has(t) || r.setAttribute(t, n);
285
- let i = S(e, "charspacing") ?? "medium", a = S(e, "charalign");
286
- return r.setAttribute("columnspacing", g[i] ?? (_.test(i) ? i : g.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
285
+ for (let { name: t, value: n } of [...e.attributes]) se.has(t) || r.setAttribute(t, n);
286
+ let i = C(e, "charspacing") ?? "medium", a = C(e, "charalign");
287
+ return r.setAttribute("columnspacing", y[i] ?? (re.test(i) ? i : y.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
287
288
  }
288
- function I(e) {
289
+ function F(e) {
289
290
  return {
290
291
  document: e.ownerDocument,
291
- stackAlign: S(e, "stackalign") ?? "decimalpoint",
292
+ stackAlign: C(e, "stackalign") ?? "decimalpoint",
292
293
  decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
293
294
  };
294
295
  }
295
- function ue(e) {
296
- let t = I(e), n = [];
297
- return k([...e.children], 0, 0, t, n), F(e, P(n, t), t);
296
+ function _e(e) {
297
+ let t = F(e), n = [];
298
+ return A([...e.children], 0, 0, t, n), P(e, N(n, t), t);
298
299
  }
299
- function L(e, t, n, r, i, a) {
300
+ function I(e, t, n, r, i, a) {
300
301
  for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
301
302
  }
302
- function de(e, t) {
303
- let n = b(t, ")");
304
- return n.setAttribute("minsize", "1.2em"), [y(t.document, "mrow", [e, y(t.document, "mspace", [], { width: "0.2em" })]), y(t.document, "mpadded", [n], {
303
+ function ve(e, t) {
304
+ let n = x(t, ")");
305
+ return n.setAttribute("minsize", "1.2em"), [b(t.document, "mrow", [e, b(t.document, "mspace", [], { width: "0.2em" })]), b(t.document, "mpadded", [n], {
305
306
  voffset: "0.1em",
306
307
  lspace: "-0.15em",
307
308
  depth: "-0.2em",
308
309
  height: "-0.2em"
309
310
  })];
310
311
  }
311
- function fe(e) {
312
- let t = I(e), [n, r, ...i] = [...e.children], a = n && !w(n) ? n : null, o = r && !w(r) ? r : null, s = S(e, "longdivstyle") ?? "lefttop", c = O(e), l = [];
313
- k(i, 0, 0, t, l);
312
+ function ye(e) {
313
+ let t = F(e), [n, r, ...i] = [...e.children], a = n && !T(n) ? n : null, o = r && !T(r) ? r : null, s = C(e, "longdivstyle") ?? "lefttop", c = k(e), l = [];
314
+ A(i, 0, 0, t, l);
314
315
  let u = l.find((e) => e.kind === "digits");
315
316
  u || (u = {
316
317
  kind: "digits",
@@ -322,51 +323,51 @@ function fe(e) {
322
323
  u.cells.unshift(...e), u.anchor += e.length;
323
324
  }, p = (...e) => {
324
325
  let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
325
- u.cells.push(...E(n, 0, t).cells);
326
+ u.cells.push(...D(n, 0, t).cells);
326
327
  };
327
328
  switch (s) {
328
329
  case "left/\\right":
329
- f(a, b(t, "/")), p(b(t, "\\"), o);
330
+ f(a, x(t, "/")), p(x(t, "\\"), o);
330
331
  break;
331
332
  case "left)(right":
332
- f(a, b(t, ")")), p(b(t, "("), o);
333
+ f(a, x(t, ")")), p(x(t, "("), o);
333
334
  break;
334
335
  case ":right=right":
335
- p(b(t, ":"), a, b(t, "="), o);
336
+ p(x(t, ":"), a, x(t, "="), o);
336
337
  break;
337
338
  case "righttop":
338
339
  case "stackedleftlinetop":
339
340
  case "lefttop":
340
- o && k([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...de(a, t));
341
+ o && A([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...ve(a, t));
341
342
  break;
342
343
  }
343
- let m = P(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + A(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + M(e)));
344
+ let m = N(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + j(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + fe(e)));
344
345
  switch (s) {
345
346
  case "left/\\right":
346
347
  case "left)(right":
347
348
  case ":right=right": break;
348
349
  case "righttop": {
349
350
  let e = h[g][_(u.cells.length - 1)];
350
- e.borders.left = c, e.borders.bottom = c, L(h, g, _(0), _(u.cells.length - 1), "top", c);
351
+ e.borders.left = c, e.borders.bottom = c, I(h, g, _(0), _(u.cells.length - 1), "top", c);
351
352
  break;
352
353
  }
353
354
  case "stackedleftlinetop": {
354
355
  let e = h[g][_(0)];
355
- e.borders.right = c, e.borders.bottom = c, L(h, g, _(1), v, "top", c);
356
+ e.borders.right = c, e.borders.bottom = c, I(h, g, _(1), v, "top", c);
356
357
  break;
357
358
  }
358
359
  case "stackedrightright":
359
360
  case "mediumstackedrightright":
360
361
  case "shortstackedrightright":
361
362
  case "stackedleftleft":
362
- pe(h, g, s, a, o, c, t);
363
+ be(h, g, s, a, o, c, t);
363
364
  break;
364
- default: L(h, g, _(1), v, "top", c);
365
+ default: I(h, g, _(1), v, "top", c);
365
366
  }
366
- return F(e, m, t);
367
+ return P(e, m, t);
367
368
  }
368
- function pe(e, t, n, r, i, a, o) {
369
- let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && y(o.document, "mpadded", [e], {
369
+ function be(e, t, n, r, i, a, o) {
370
+ let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && b(o.document, "mpadded", [e], {
370
371
  lspace: "0.2em",
371
372
  width: "+0.4em"
372
373
  });
@@ -385,307 +386,315 @@ function pe(e, t, n, r, i, a, o) {
385
386
  }) : o === t + 1 ? (u.content = l(i), n !== "shortstackedrightright" && (u.borders[c] = a)) : o > t + 1 && (n === "stackedrightright" || s) && (u.borders[c] = a), s ? e.unshift(u) : e.push(u);
386
387
  });
387
388
  }
388
- function me(e) {
389
- for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? ue(t) : fe(t));
389
+ function xe(e) {
390
+ for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? _e(t) : ye(t));
390
391
  }
391
392
  //#endregion
392
393
  //#region src/explorer-styles.ts
393
- var he = "PIE-MJX-explorer-styles", R = "var(--pie-text, black)", ge = "var(--pie-background, #ffffff)", _e = "var(--pie-border-dark, #66686A)", z = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", B = `color-mix(in srgb, ${z} 15%, transparent)`, ve = `
394
+ var Se = "PIE-MJX-explorer-styles", L = "var(--pie-text, black)", Ce = "var(--pie-background, #ffffff)", we = "var(--pie-border-dark, #66686A)", R = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", z = `color-mix(in srgb, ${R} 15%, transparent)`, Te = `
394
395
  :root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
395
- color: ${R} !important;
396
- fill: ${R} !important;
396
+ color: ${L} !important;
397
+ fill: ${L} !important;
397
398
  }
398
399
  :root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
399
- background-color: ${B} !important;
400
+ background-color: ${z} !important;
400
401
  }
401
402
  :root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
402
- fill: ${B} !important;
403
+ fill: ${z} !important;
403
404
  }
404
405
  :root mjx-container .mjx-selected {
405
- outline: 2px solid ${z} !important;
406
+ outline: 2px solid ${R} !important;
406
407
  }
407
408
  :root mjx-container [data-sre-highlight-2] {
408
- color: ${R} !important;
409
+ color: ${L} !important;
409
410
  background-color: transparent !important;
410
- fill: ${R} !important;
411
- outline: 2px dashed ${z} !important;
411
+ fill: ${L} !important;
412
+ outline: 2px dashed ${R} !important;
412
413
  }
413
414
  :root mjx-container rect[data-sre-highlight-2] {
414
415
  fill: transparent !important;
415
- stroke: ${z} !important;
416
+ stroke: ${R} !important;
416
417
  stroke-width: 2px !important;
417
418
  vector-effect: non-scaling-stroke;
418
419
  }
419
420
  :root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
420
- color: ${R} !important;
421
- background-color: ${ge} !important;
422
- border-color: ${_e} !important;
421
+ color: ${L} !important;
422
+ background-color: ${Ce} !important;
423
+ border-color: ${we} !important;
423
424
  }
424
425
  :root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
425
- color: ${R} !important;
426
- background-color: ${B} !important;
426
+ color: ${L} !important;
427
+ background-color: ${z} !important;
427
428
  }
428
429
  `;
429
- function ye(e = document) {
430
+ function Ee(e = document) {
430
431
  if (e.getElementById("PIE-MJX-explorer-styles")) return;
431
432
  let t = e.createElement("style");
432
- t.id = he, t.textContent = ve, e.head.appendChild(t);
433
+ t.id = Se, t.textContent = Te, e.head.appendChild(t);
433
434
  }
434
435
  //#endregion
435
436
  //#region src/unsupported-page.ts
436
- var V = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", H = "pie-mathjax-version-conflict", U = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
437
- function be(e, t) {
437
+ var B = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", V = "pie-mathjax-version-conflict", H = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
438
+ function De(e, t) {
438
439
  if (typeof window > "u") return;
439
440
  let n = globalThis;
440
- n[U] ??= {
441
+ n[H] ??= {
441
442
  logged: !1,
442
443
  conditions: []
443
444
  };
444
- let r = n[U];
445
+ let r = n[H];
445
446
  if (r.conditions.includes(e)) return;
446
447
  r.conditions.push(e);
447
- let i = `[math-rendering] Unsupported page (${e}): ${t}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${V}`;
448
- r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(H, { detail: {
448
+ let i = `[math-rendering] Unsupported page (${e}): ${t}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${B}`;
449
+ r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(V, { detail: {
449
450
  condition: e,
450
451
  message: i,
451
- docsUrl: V
452
+ docsUrl: B
452
453
  } }));
453
454
  }
454
455
  //#endregion
455
456
  //#region src/adapter.ts
456
- var xe = "https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-mml-chtml.js", Se = {
457
+ var Oe = {
457
458
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
458
459
  overarc: "\\overparen",
459
460
  napprox: "\\not\\approx",
460
461
  longdiv: "\\enclose{longdiv}",
461
462
  abs: ["\\left|#1\\right|", 1]
462
- }, Ce = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", we = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, Te = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, Ee = /\\embed\{newLine\}\[\]/g, De = [
463
+ }, ke = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", Ae = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, je = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, Me = /\\embed\{newLine\}\[\]/g, Ne = [
463
464
  ["$$", "$$"],
464
465
  ["$", "$"],
465
466
  ["\\[", "\\]"],
466
467
  ["\\(", "\\)"]
467
- ], W = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Oe = "MJX-CHTML-styles", ke = "PIE-MJX-SVG-styles", G = "PIE-MathJax-Menu-Settings", Ae = { "mjx-container[overflow=\"linebreak\"][display]": {
468
+ ], U = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Pe = "MJX-CHTML-styles", Fe = "PIE-MJX-SVG-styles", W = "PIE-MathJax-Menu-Settings", Ie = { "mjx-container[overflow=\"linebreak\"][display]": {
468
469
  overflow: "auto clip",
469
470
  "min-width": "initial !important"
470
- } }, je = 200, Me = 201;
471
- function K(e) {
471
+ } }, Le = 200, Re = 201;
472
+ function G(e) {
472
473
  let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
473
474
  for (let e of t) for (let t of [e, ...e.querySelectorAll("[data-latex],[data-latex-item]")]) t.removeAttribute("data-latex"), t.removeAttribute("data-latex-item");
474
475
  }
475
- function q(e) {
476
- for (let [t, n] of De) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
476
+ function K(e) {
477
+ for (let [t, n] of Ne) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
477
478
  return e;
478
479
  }
479
- function Ne(e) {
480
- return q(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
480
+ function ze(e) {
481
+ return K(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
481
482
  }
482
- var Pe = "mathjax_ignore", J = "mathjax_process";
483
- function Fe(e, t) {
484
- let n = e.closest(`.${Pe}, .${J}`);
485
- return n !== null && t.contains(n) && !n.classList.contains(J);
483
+ var Be = "mathjax_ignore", q = "mathjax_process";
484
+ function Ve(e, t) {
485
+ let n = e.closest(`.${Be}, .${q}`);
486
+ return n !== null && t.contains(n) && !n.classList.contains(q);
486
487
  }
487
- function Ie(e) {
488
+ function He(e) {
488
489
  for (let t of e.querySelectorAll("[data-latex]")) {
489
- if (t.dataset.mathHandled || t.closest("mjx-container") || Fe(t, e)) continue;
490
+ if (t.dataset.mathHandled || t.closest("mjx-container") || Ve(t, e)) continue;
490
491
  let n = t.textContent;
491
- n && (t.textContent = `\\(${Ne(n)}\\)`.replace(Ee, "\\newline "), t.dataset.mathHandled = "true");
492
+ n && (t.textContent = `\\(${ze(n)}\\)`.replace(Me, "\\newline "), t.dataset.mathHandled = "true");
492
493
  }
493
494
  }
494
- function Le(e) {
495
+ function Ue(e) {
495
496
  for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
496
497
  }
497
- function Re(e, t) {
498
+ function We(e, t) {
498
499
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
499
- return (t ? Te : we).test(e.textContent ?? "");
500
+ return (t ? je : Ae).test(e.textContent ?? "");
500
501
  }
501
- function ze(e) {
502
- return new Promise((n, i) => {
503
- let { useSingleDollar: a = !1, accessibility: o = !0, loadFonts: s = !0, srcUrl: c } = e, l = {
502
+ function Ge(e) {
503
+ return new Promise((a, s) => {
504
+ let { useSingleDollar: l = !1, accessibility: u = !0, loadFonts: d = !0, srcUrl: f } = e, p = i(e, import.meta.url), m = {
504
505
  loader: {
505
- load: o ? ["a11y/assistive-mml"] : [],
506
- failed: (e) => i(e),
506
+ load: u ? ["a11y/assistive-mml"] : [],
507
+ failed: (e) => s(e),
507
508
  "output/svg": { ready: (e) => {
508
- let n = t();
509
- return Y(n) && X(n), e;
509
+ let t = o();
510
+ return J(t) && Y(t), e;
510
511
  } }
511
512
  },
512
513
  startup: {
513
514
  typeset: !1,
514
515
  ready: () => {
515
- let e = t(), r = e?.startup, a = Y(e);
516
- a && (X(e), Be(e)), r?.defaultReady?.(), a && (Ve(r?.document), r?.document?.addStyles?.(Ae)), Promise.resolve(r?.promise).then(() => n(), i);
516
+ let e = o(), n = e?.startup, i = J(e);
517
+ i && (Y(e), Ke(e, p.speechLocales), t(e?._?.a11y?.sre_ts?.locales, p.speechLocales)), n?.defaultReady?.(), i && (qe(n?.document), n?.document?.addStyles?.(Ie), r(n?.document)), Promise.resolve(n?.promise).then(() => a(), s);
517
518
  }
518
519
  },
519
- tex: { macros: { ...Se } },
520
+ tex: { macros: { ...Oe } },
520
521
  output: { displayOverflow: "linebreak" },
521
522
  options: {
522
- enableMenu: o,
523
+ enableMenu: u,
523
524
  menuOptions: { settings: {
524
- assistiveMml: o,
525
+ assistiveMml: u,
525
526
  enrich: !1,
526
527
  inTabOrder: !1
527
528
  } },
528
529
  a11y: { inTabOrder: !1 }
529
530
  }
530
531
  };
531
- a && l.tex && (console.warn(Ce), l.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], l.tex.processEscapes = !0), s || (l.chtml = { fontURL: "" }), r(l, c || xe).catch(i);
532
+ l && m.tex && (console.warn(ke), m.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], m.tex.processEscapes = !0), d || (m.chtml = { fontURL: "" });
533
+ let h = n(p.speechLocales);
534
+ h && m.options && (m.options.sre = { locale: h }), c(m, {
535
+ ...p,
536
+ srcUrl: f
537
+ }).then((e) => {
538
+ e || a();
539
+ }, s);
532
540
  });
533
541
  }
534
- function Y(e) {
542
+ function J(e) {
535
543
  return !!e?.version?.startsWith("4.");
536
544
  }
537
- function X(e) {
545
+ function Y(e) {
538
546
  let t = e?._?.output, n = t?.chtml_ts?.CHTML;
539
- n && (n.STYLESHEETID = s);
547
+ n && (n.STYLESHEETID = p);
540
548
  let r = t?.svg_ts?.SVG;
541
- r && (r.STYLESHEETID = ke);
549
+ r && (r.STYLESHEETID = Fe);
542
550
  }
543
- function Be(e) {
544
- let t = e?._?.ui?.menu?.Menu?.Menu;
545
- if (t) {
546
- t.MENU_STORAGE = G;
551
+ function Ke(e, t) {
552
+ let n = e?._?.ui?.menu?.Menu?.Menu;
553
+ if (n) {
554
+ n.MENU_STORAGE = W;
547
555
  try {
548
- let e = localStorage.getItem(G);
556
+ let e = localStorage.getItem(W);
549
557
  if (!e) return;
550
- let { assistiveMml: t, ...n } = JSON.parse(e);
551
- if (t === void 0) return;
552
- Object.keys(n).length ? localStorage.setItem(G, JSON.stringify(n)) : localStorage.removeItem(G);
558
+ let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
559
+ if (n === void 0 && a) return;
560
+ a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(W, JSON.stringify(i)) : localStorage.removeItem(W);
553
561
  } catch {}
554
562
  }
555
563
  }
556
- function Ve(e) {
564
+ function qe(e) {
557
565
  if (!e) return;
558
566
  let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
559
567
  let n = e.typesetRoot;
560
- !n || t.has(n) || (K(n), t.add(n));
568
+ !n || t.has(n) || (G(n), t.add(n));
561
569
  };
562
- e.addRenderAction?.("pie-strip-latex", Me, (e) => {
570
+ e.addRenderAction?.("pie-strip-latex", Re, (e) => {
563
571
  for (let t of e.math ?? []) n(t);
564
572
  return !1;
565
573
  }, (e) => {
566
574
  let t = e.typesetRoot;
567
- return t && K(t), !1;
575
+ return t && G(t), !1;
568
576
  });
569
577
  let r = e.outputJax?.chtmlStyles;
570
- r?.id === Oe && (r.id = s), Ue();
578
+ r?.id === Pe && (r.id = p), Ye();
571
579
  }
572
- function Z(e) {
573
- return e instanceof HTMLStyleElement && c.includes(e.id);
580
+ function X(e) {
581
+ return e instanceof HTMLStyleElement && m.includes(e.id);
574
582
  }
575
- function He(e) {
576
- be("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
583
+ function Je(e) {
584
+ De("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
577
585
  }
578
- function Ue() {
579
- let e = document.head, t = [...e.children].find(Z);
586
+ function Ye() {
587
+ let e = document.head, t = [...e.children].find(X);
580
588
  if (t) {
581
- He(t);
589
+ Je(t);
582
590
  return;
583
591
  }
584
592
  let n = new MutationObserver((e) => {
585
593
  for (let t of e) {
586
- let e = [...t.addedNodes].find(Z);
594
+ let e = [...t.addedNodes].find(X);
587
595
  if (e) {
588
- He(e), n.disconnect();
596
+ Je(e), n.disconnect();
589
597
  return;
590
598
  }
591
599
  }
592
600
  });
593
601
  n.observe(e, { childList: !0 });
594
602
  }
595
- function We(e) {
603
+ function Xe(e) {
596
604
  let t = e?.math;
597
605
  if (!t?.remove) return;
598
- let n = [...t].filter((e) => (e.state?.() ?? 0) >= je && e.typesetRoot?.isConnected === !1);
606
+ let n = [...t].filter((e) => (e.state?.() ?? 0) >= Le && e.typesetRoot?.isConnected === !1);
599
607
  if (n.length !== 0) {
600
608
  for (let e of [...n].reverse()) e.clear?.();
601
609
  t.remove(...n);
602
610
  }
603
611
  }
604
- function Ge(e) {
605
- return new Promise((n, r) => {
606
- let i = e.startup ?? {};
607
- e.startup = i;
608
- let a = i.ready;
609
- i.ready = () => {
610
- let e = t()?.startup;
611
- a ? a.call(i) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => n(), r);
612
+ function Ze(e) {
613
+ return new Promise((t, n) => {
614
+ let r = e.startup ?? {};
615
+ e.startup = r;
616
+ let i = r.ready;
617
+ r.ready = () => {
618
+ let e = o()?.startup;
619
+ i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
612
620
  };
613
621
  });
614
622
  }
615
- function Ke(e) {
616
- let n = t();
617
- return n ? n.version ? n.startup?.promise ? Promise.resolve(n.startup.promise).then(() => void 0) : Promise.resolve() : Ge(n) : ze(e);
623
+ function Qe(e) {
624
+ let t = o();
625
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : Ze(t) : Ge(e);
618
626
  }
619
- function qe(e) {
620
- return Ke(e).then(() => {
621
- typeof t()?.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
627
+ function $e(e) {
628
+ return Qe(e).then(() => {
629
+ let e = o();
630
+ e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
622
631
  });
623
632
  }
624
- function Je(e) {
625
- let t = i, n = t[W];
626
- return n || (n = qe(e), t[W] = n), n;
633
+ function et(e) {
634
+ let t = l, n = t[U];
635
+ return n || (n = $e(e), t[U] = n), n;
627
636
  }
628
- function Ye(e = {}) {
629
- let n = e.useSingleDollar ?? !1;
630
- return async (r) => {
637
+ function tt(e = {}) {
638
+ let t = e.useSingleDollar ?? !1;
639
+ return async (n) => {
631
640
  if (typeof window > "u") return;
632
- Ie(r), f(r), Le(r), me(r);
633
- let i = Je(e);
634
- if (!Re(r, n)) {
635
- i.catch(() => {});
641
+ He(n), v(n), Ue(n), xe(n);
642
+ let r = et(e);
643
+ if (!We(n, t)) {
644
+ r.catch(() => {});
636
645
  return;
637
646
  }
638
- await i;
639
- let a = t();
640
- if (await a?.startup?.promise, typeof a?.typesetPromise == "function") {
641
- ye(), We(a.startup?.document);
647
+ await r;
648
+ let i = o();
649
+ if (await i?.startup?.promise, typeof i?.typesetPromise == "function") {
650
+ Ee(), Xe(i.startup?.document);
642
651
  try {
643
- await a.typesetPromise([r]);
652
+ await i.typesetPromise([n]);
644
653
  } catch (e) {
645
- throw a.typesetClear?.([r]), e;
654
+ throw i.typesetClear?.([n]), e;
646
655
  }
647
- K(r);
656
+ G(n);
648
657
  }
649
658
  };
650
659
  }
651
- function Xe() {
660
+ function nt() {
652
661
  return [];
653
662
  }
654
663
  //#endregion
655
664
  //#region src/render-math.ts
656
- var Ze = "@pie-lib/math-rendering", Qe = "@pie-lib/math-rendering@2", $e = "pie-print", et = 50, tt = 1e4, nt = null;
657
- function rt() {
658
- return !!window[Qe]?.opts?.useSingleDollar;
665
+ var rt = "@pie-lib/math-rendering", it = "@pie-lib/math-rendering@2", at = "pie-print", ot = 50, st = 1e4, Z = null;
666
+ function ct() {
667
+ return !!window[it]?.opts?.useSingleDollar;
659
668
  }
660
- function it() {
661
- return nt ||= Ye({ useSingleDollar: rt() }), nt;
669
+ function lt() {
670
+ return Z ||= tt({ useSingleDollar: ct() }), Z;
662
671
  }
663
672
  function Q() {
664
673
  if (typeof window > "u") return null;
665
- let e = window[Ze];
674
+ let e = window[rt];
666
675
  return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
667
676
  }
668
- function at(e) {
677
+ function ut(e) {
669
678
  let t = e;
670
679
  for (; t;) {
671
- if (t instanceof Element && t.localName === $e) return t;
680
+ if (t instanceof Element && t.localName === at) return t;
672
681
  t = t instanceof ShadowRoot ? t.host : t.parentNode;
673
682
  }
674
683
  return null;
675
684
  }
676
- function ot() {
685
+ function dt() {
677
686
  let e = window.renderMath;
678
687
  return typeof e == "function" ? e : null;
679
688
  }
680
- async function st(e) {
681
- let t = at(e);
689
+ async function ft(e) {
690
+ let t = ut(e);
682
691
  if (!t) return null;
683
- let n = ot();
692
+ let n = dt();
684
693
  if (n || t.mathRenderingModuleUrlImported !== !0) return n;
685
- let r = Date.now() + tt;
694
+ let r = Date.now() + st;
686
695
  for (; Date.now() < r;) {
687
- await new Promise((e) => setTimeout(e, et));
688
- let e = ot();
696
+ await new Promise((e) => setTimeout(e, ot));
697
+ let e = dt();
689
698
  if (e) return e;
690
699
  }
691
700
  return null;
@@ -694,14 +703,14 @@ var $ = async (e) => {
694
703
  if (typeof window > "u") return;
695
704
  let t = typeof e == "string", n;
696
705
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
697
- let r = Q(), i = r || t ? null : await st(n);
698
- return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await it()(n), t ? n.innerHTML : void 0;
699
- }, ct = (e, t) => {
706
+ let r = Q(), i = r || t ? null : await ft(n);
707
+ return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await lt()(n), t ? n.innerHTML : void 0;
708
+ }, pt = (e, t) => {
700
709
  let n = Q()?.wrapMath?.(e, t);
701
710
  if (n != null) return n;
702
711
  let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
703
- return `${r}${q(e)}${i}`;
704
- }, lt = (e) => {
712
+ return `${r}${K(e)}${i}`;
713
+ }, mt = (e) => {
705
714
  let t = e.trim();
706
715
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
707
716
  unwrapped: t.slice(2, -2).trim(),
@@ -728,6 +737,6 @@ var $ = async (e) => {
728
737
  close: "$"
729
738
  }
730
739
  } : { unwrapped: t };
731
- }, ut = (e) => Q()?.mmlToLatex?.(e) ?? e;
740
+ }, ht = (e) => Q()?.mmlToLatex?.(e) ?? e;
732
741
  //#endregion
733
- export { H as MATHJAX_CONFLICT_EVENT, V as UNSUPPORTED_PAGE_DOCS_URL, Ye as createMathjaxRenderer, Xe as getMathjaxCssUrls, ut as mmlToLatex, $ as renderMath, lt as unWrapMath, ct as wrapMath };
742
+ export { V as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, B as UNSUPPORTED_PAGE_DOCS_URL, tt as createMathjaxRenderer, nt as getMathjaxCssUrls, ht as mmlToLatex, $ as renderMath, mt as unWrapMath, pt as wrapMath };