@pie-element/shared-math-rendering-mathjax 0.1.7 → 0.1.8-next.20261019145129

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.
@@ -19,71 +19,71 @@ var p = f(), m = `PIE-MJX-CHTML-styles-${p}`, h = ["MJX-CHTML-styles"], g = "htt
19
19
  function ee(e) {
20
20
  for (let t of e.querySelectorAll("*")) {
21
21
  let n = _.exec(t.tagName.toLowerCase())?.[1];
22
- !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(y(t, `${n}:`));
22
+ !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(te(t, `${n}:`));
23
23
  }
24
24
  }
25
- function y(e, t) {
25
+ function te(e, t) {
26
26
  let n = e.tagName.toLowerCase().slice(t.length);
27
27
  if (!v.test(n)) return e;
28
28
  let r = e.ownerDocument.createElementNS(g, n);
29
29
  for (let t of e.attributes) r.setAttribute(t.name, t.value);
30
30
  for (let n of [...e.childNodes]) {
31
31
  let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
32
- r.appendChild(e ? y(n, t) : n);
32
+ r.appendChild(e ? te(n, t) : n);
33
33
  }
34
34
  return r;
35
35
  }
36
36
  //#endregion
37
37
  //#region src/elementary-math.ts
38
- var te = /* @__PURE__ */ new Set([
38
+ var ne = /* @__PURE__ */ new Set([
39
39
  "updiagonalstrike",
40
40
  "downdiagonalstrike",
41
41
  "verticalstrike",
42
42
  "horizontalstrike"
43
- ]), ne = {
43
+ ]), re = {
44
44
  thin: "0.035em",
45
45
  medium: "0.07em",
46
46
  thick: "0.14em"
47
- }, re = {
47
+ }, ie = {
48
48
  tight: "0em",
49
49
  medium: "0.1em",
50
50
  loose: "0.2em"
51
- }, ie = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ae = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, oe = /^(\d+(\.\d*)?|\.\d+)$/, se = /* @__PURE__ */ new Set([
51
+ }, ae = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, oe = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, se = /^(\d+(\.\d*)?|\.\d+)$/, ce = /* @__PURE__ */ new Set([
52
52
  "mn",
53
53
  "mo",
54
54
  "mi",
55
55
  "mtext"
56
- ]), ce = /* @__PURE__ */ new Set([
56
+ ]), le = /* @__PURE__ */ new Set([
57
57
  "stackalign",
58
58
  "charalign",
59
59
  "charspacing",
60
60
  "longdivstyle"
61
61
  ]);
62
- function b(e, t, n = [], r = {}) {
62
+ function y(e, t, n = [], r = {}) {
63
63
  let i = e.createElementNS(g, t);
64
64
  for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
65
65
  for (let e of n) e && i.appendChild(e);
66
66
  return i;
67
67
  }
68
- function x(e, t) {
69
- let n = b(e.document, "mo");
68
+ function b(e, t) {
69
+ let n = y(e.document, "mo");
70
70
  return n.textContent = t, n;
71
71
  }
72
- function S(e) {
73
- let t = b(e.document, "mn");
74
- return t.textContent = "0", b(e.document, "mphantom", [t]);
72
+ function ue(e) {
73
+ let t = y(e.document, "mn");
74
+ return t.textContent = "0", y(e.document, "mphantom", [t]);
75
75
  }
76
- function C(e, t) {
76
+ function x(e, t) {
77
77
  return e.getAttribute(t)?.trim().toLowerCase() || void 0;
78
78
  }
79
- function w(e, t) {
79
+ function S(e, t) {
80
80
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
81
81
  return Number.isFinite(n) ? n : 0;
82
82
  }
83
- function T(e) {
83
+ function C(e) {
84
84
  return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
85
85
  }
86
- function E(e, t, n = e) {
86
+ function w(e, t, n = e) {
87
87
  switch (t) {
88
88
  case "left": return 0;
89
89
  case "center": return Math.floor(e / 2);
@@ -91,14 +91,14 @@ function E(e, t, n = e) {
91
91
  default: return n;
92
92
  }
93
93
  }
94
- function D(e, t, n) {
94
+ function T(e, t, n) {
95
95
  let r = [], i, a, o = (e, t) => {
96
96
  let s = (e) => t.reduceRight((e, t) => {
97
97
  let n = t.cloneNode(!1);
98
98
  return n.appendChild(e), n;
99
99
  }, e);
100
100
  if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
101
- else if (T(e)) r.push(null);
101
+ else if (C(e)) r.push(null);
102
102
  else if (e.localName === "mn" && e.children.length === 0) {
103
103
  let t = [...(e.textContent ?? "").trim()];
104
104
  for (let a of t) {
@@ -107,28 +107,28 @@ function D(e, t, n) {
107
107
  t.textContent = a, r.push(s(t));
108
108
  }
109
109
  t.length && (a ??= r.length);
110
- } else se.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
110
+ } else ce.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
111
111
  };
112
112
  for (let t of e) o(t, []);
113
113
  return {
114
114
  kind: "digits",
115
115
  cells: r,
116
- anchor: E(r.length, n.stackAlign, i ?? a),
116
+ anchor: w(r.length, n.stackAlign, i ?? a),
117
117
  position: t
118
118
  };
119
119
  }
120
- function le(e) {
121
- return (e ?? "").toLowerCase().split(/\s+/).filter((e) => te.has(e));
120
+ function de(e) {
121
+ return (e ?? "").toLowerCase().split(/\s+/).filter((e) => ne.has(e));
122
122
  }
123
- function ue(e, t) {
124
- let n = [...e.children].filter((e) => !T(e));
125
- return n.length <= 1 ? n[0] ?? null : b(t.document, "mrow", n);
123
+ function fe(e, t) {
124
+ let n = [...e.children].filter((e) => !C(e));
125
+ return n.length <= 1 ? n[0] ?? null : y(t.document, "mrow", n);
126
126
  }
127
- function de(e, t, n) {
128
- let r = C(e, "location") ?? "n", i = le(e.getAttribute("crossout")), a = [...e.children].map((e) => T(e) ? null : e.localName === "mscarry" ? {
129
- content: ue(e, n),
130
- location: C(e, "location") ?? r,
131
- crossout: e.hasAttribute("crossout") ? le(e.getAttribute("crossout")) : i
127
+ function pe(e, t, n) {
128
+ let r = x(e, "location") ?? "n", i = de(e.getAttribute("crossout")), a = [...e.children].map((e) => C(e) ? null : e.localName === "mscarry" ? {
129
+ content: fe(e, n),
130
+ location: x(e, "location") ?? r,
131
+ crossout: e.hasAttribute("crossout") ? de(e.getAttribute("crossout")) : i
132
132
  } : {
133
133
  content: e,
134
134
  location: r,
@@ -137,60 +137,60 @@ function de(e, t, n) {
137
137
  return {
138
138
  kind: "carries",
139
139
  carries: a,
140
- anchor: E(a.length, n.stackAlign),
140
+ anchor: w(a.length, n.stackAlign),
141
141
  position: t,
142
- scale: oe.test(o) ? o : "0.6"
142
+ scale: se.test(o) ? o : "0.6"
143
143
  };
144
144
  }
145
- function fe(e) {
146
- let t = C(e, "mslinethickness") ?? "medium", n = ne[t] ?? (ie.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
147
- return `${n} solid ${ae.test(r) ? r : "currentColor"}`;
145
+ function me(e) {
146
+ let t = x(e, "mslinethickness") ?? "medium", n = re[t] ?? (ae.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
147
+ return `${n} solid ${oe.test(r) ? r : "currentColor"}`;
148
148
  }
149
- function pe(e, t, n) {
150
- let r = Math.max(0, w(e, "length"));
149
+ function he(e, t, n) {
150
+ let r = Math.max(0, S(e, "length"));
151
151
  return {
152
152
  kind: "line",
153
153
  length: r,
154
- anchor: E(r, n.stackAlign),
154
+ anchor: w(r, n.stackAlign),
155
155
  position: t,
156
- border: fe(e)
156
+ border: me(e)
157
157
  };
158
158
  }
159
- function O(e, t, n, r, i) {
159
+ function E(e, t, n, r, i) {
160
160
  e.forEach((e, a) => {
161
- let o = t + a * n + w(e, "position");
161
+ let o = t + a * n + S(e, "position");
162
162
  switch (e.localName) {
163
163
  case "msgroup":
164
- O([...e.children], o, w(e, "shift"), r, i);
164
+ E([...e.children], o, S(e, "shift"), r, i);
165
165
  break;
166
166
  case "msline":
167
- i.push(pe(e, o, r));
167
+ i.push(he(e, o, r));
168
168
  break;
169
169
  case "mscarries":
170
- i.push(de(e, o, r));
170
+ i.push(pe(e, o, r));
171
171
  break;
172
172
  case "msrow":
173
173
  case "mrow":
174
- i.push(D([...e.children], o, r));
174
+ i.push(T([...e.children], o, r));
175
175
  break;
176
- default: i.push(D([e], o, r));
176
+ default: i.push(T([e], o, r));
177
177
  }
178
178
  });
179
179
  }
180
- function k(e) {
180
+ function D(e) {
181
181
  return -e.anchor - e.position;
182
182
  }
183
- function me(e) {
183
+ function ge(e) {
184
184
  return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
185
185
  }
186
- function he(e) {
187
- return k(e) + me(e) - 1;
186
+ function O(e) {
187
+ return D(e) + ge(e) - 1;
188
188
  }
189
- function ge(e, t, n, r) {
190
- let i = (e) => b(r.document, "mpadded", [t], {
189
+ function _e(e, t, n, r) {
190
+ let i = (e) => y(r.document, "mpadded", [t], {
191
191
  width: "0",
192
192
  ...e ? { lspace: e } : {}
193
- }), a = (e, t) => b(r.document, e, t);
193
+ }), a = (e, t) => y(r.document, e, t);
194
194
  switch (n) {
195
195
  case "s": return a("munder", [e, i("-0.5width")]);
196
196
  case "ne": return a("msup", [e, i()]);
@@ -212,49 +212,49 @@ function ge(e, t, n, r) {
212
212
  default: return a("mover", [e, i("-0.5width")]);
213
213
  }
214
214
  }
215
- function _e(e, t, n) {
216
- let r = b(n.document, "menclose", [e], {
215
+ function ve(e, t, n) {
216
+ let r = y(n.document, "menclose", [e], {
217
217
  notation: t.join(" "),
218
218
  "data-padding": "0.1em",
219
219
  "data-thickness": "0.067em"
220
220
  }), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
221
- return i ? b(n.document, "mpadded", [r], {
221
+ return i ? y(n.document, "mpadded", [r], {
222
222
  lspace: `-${i}em`,
223
223
  width: `-${2 * i}em`
224
224
  }) : r;
225
225
  }
226
- function ve(e, t, n, r, i) {
227
- let a = e && t.crossout.length ? _e(e, t.crossout, i) : e;
226
+ function ye(e, t, n, r, i) {
227
+ let a = e && t.crossout.length ? ve(e, t.crossout, i) : e;
228
228
  if (!t.content) return a;
229
- let o = b(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
230
- return ge(a ?? S(i), o, n, i);
229
+ let o = y(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
230
+ return _e(a ?? ue(i), o, n, i);
231
231
  }
232
- function A(e, t) {
233
- return e.carries[t - k(e)] ?? null;
232
+ function k(e, t) {
233
+ return e.carries[t - D(e)] ?? null;
234
234
  }
235
- function ye(e, t, n, r) {
235
+ function be(e, t, n, r) {
236
236
  let i = e.content;
237
237
  n.forEach((e, a) => {
238
- let o = n.length - 1 - a, s = n[o], c = A(s, t), l = n.slice(0, o).some((e) => A(e, t));
238
+ let o = n.length - 1 - a, s = n[o], c = k(s, t), l = n.slice(0, o).some((e) => k(e, t));
239
239
  if (!c && !l) return;
240
240
  let u = c ?? {
241
- content: S(r),
241
+ content: ue(r),
242
242
  location: "n",
243
243
  crossout: []
244
244
  }, d = a === 0 ? u.location : "n";
245
- i = ve(i, u, d, s.scale, r);
245
+ i = ye(i, u, d, s.scale, r);
246
246
  }), e.content = i;
247
247
  }
248
- function j(e, t) {
249
- let n = e.filter((e) => me(e) > 0), r = Math.min(0, ...n.map(k)), i = Math.max(r, ...n.map(he)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
248
+ function A(e, t) {
249
+ let n = e.filter((e) => ge(e) > 0), r = Math.min(0, ...n.map(D)), i = Math.max(r, ...n.map(O)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
250
250
  content: null,
251
251
  borders: {}
252
- })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + k(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 + D(e) + n), u = [], d = [], f = (e) => {
253
253
  let n = c();
254
254
  e.cells.forEach((t, r) => {
255
- n[a + k(e) + r].content = t;
255
+ n[a + D(e) + r].content = t;
256
256
  }), u.length && n.forEach((e, n) => {
257
- ye(e, n - a, u, t);
257
+ be(e, n - a, u, t);
258
258
  });
259
259
  for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
260
260
  u = [], d = [], s.set(e, o.length), o.push(n);
@@ -274,44 +274,44 @@ function j(e, t) {
274
274
  origin: a
275
275
  };
276
276
  }
277
- function M(e, { rows: t }, n) {
278
- let r = b(n.document, "mtable", t.map((e) => b(n.document, "mtr", e.map((e) => {
277
+ function j(e, { rows: t }, n) {
278
+ let r = y(n.document, "mtable", t.map((e) => y(n.document, "mtr", e.map((e) => {
279
279
  let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
280
- return b(n.document, "mtd", [e.content], {
280
+ return y(n.document, "mtd", [e.content], {
281
281
  ...t ? { style: t } : {},
282
282
  ...e.align ? { columnalign: e.align } : {}
283
283
  });
284
284
  }))));
285
- for (let { name: t, value: n } of [...e.attributes]) ce.has(t) || r.setAttribute(t, n);
286
- let i = C(e, "charspacing") ?? "medium", a = C(e, "charalign");
287
- return r.setAttribute("columnspacing", re[i] ?? (ie.test(i) ? i : re.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]) le.has(t) || r.setAttribute(t, n);
286
+ let i = x(e, "charspacing") ?? "medium", a = x(e, "charalign");
287
+ return r.setAttribute("columnspacing", ie[i] ?? (ae.test(i) ? i : ie.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
288
288
  }
289
- function N(e) {
289
+ function xe(e) {
290
290
  return {
291
291
  document: e.ownerDocument,
292
- stackAlign: C(e, "stackalign") ?? "decimalpoint",
292
+ stackAlign: x(e, "stackalign") ?? "decimalpoint",
293
293
  decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
294
294
  };
295
295
  }
296
- function be(e) {
297
- let t = N(e), n = [];
298
- return O([...e.children], 0, 0, t, n), M(e, j(n, t), t);
296
+ function Se(e) {
297
+ let t = xe(e), n = [];
298
+ return E([...e.children], 0, 0, t, n), j(e, A(n, t), t);
299
299
  }
300
- function P(e, t, n, r, i, a) {
300
+ function M(e, t, n, r, i, a) {
301
301
  for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
302
302
  }
303
- function xe(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], {
303
+ function Ce(e, t) {
304
+ let n = b(t, ")");
305
+ return n.setAttribute("minsize", "1.2em"), [y(t.document, "mrow", [e, y(t.document, "mspace", [], { width: "0.2em" })]), y(t.document, "mpadded", [n], {
306
306
  voffset: "0.1em",
307
307
  lspace: "-0.15em",
308
308
  depth: "-0.2em",
309
309
  height: "-0.2em"
310
310
  })];
311
311
  }
312
- function Se(e) {
313
- let t = N(e), [n, r, ...i] = [...e.children], a = n && !T(n) ? n : null, o = r && !T(r) ? r : null, s = C(e, "longdivstyle") ?? "lefttop", c = fe(e), l = [];
314
- O(i, 0, 0, t, l);
312
+ function we(e) {
313
+ let t = xe(e), [n, r, ...i] = [...e.children], a = n && !C(n) ? n : null, o = r && !C(r) ? r : null, s = x(e, "longdivstyle") ?? "lefttop", c = me(e), l = [];
314
+ E(i, 0, 0, t, l);
315
315
  let u = l.find((e) => e.kind === "digits");
316
316
  u || (u = {
317
317
  kind: "digits",
@@ -323,51 +323,51 @@ function Se(e) {
323
323
  u.cells.unshift(...e), u.anchor += e.length;
324
324
  }, p = (...e) => {
325
325
  let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
326
- u.cells.push(...D(n, 0, t).cells);
326
+ u.cells.push(...T(n, 0, t).cells);
327
327
  };
328
328
  switch (s) {
329
329
  case "left/\\right":
330
- f(a, x(t, "/")), p(x(t, "\\"), o);
330
+ f(a, b(t, "/")), p(b(t, "\\"), o);
331
331
  break;
332
332
  case "left)(right":
333
- f(a, x(t, ")")), p(x(t, "("), o);
333
+ f(a, b(t, ")")), p(b(t, "("), o);
334
334
  break;
335
335
  case ":right=right":
336
- p(x(t, ":"), a, x(t, "="), o);
336
+ p(b(t, ":"), a, b(t, "="), o);
337
337
  break;
338
338
  case "righttop":
339
339
  case "stackedleftlinetop":
340
340
  case "lefttop":
341
- o && O([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...xe(a, t));
341
+ o && E([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...Ce(a, t));
342
342
  break;
343
343
  }
344
- let m = j(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + k(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + he(e)));
344
+ let m = A(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + D(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + O(e)));
345
345
  switch (s) {
346
346
  case "left/\\right":
347
347
  case "left)(right":
348
348
  case ":right=right": break;
349
349
  case "righttop": {
350
350
  let e = h[g][_(u.cells.length - 1)];
351
- e.borders.left = c, e.borders.bottom = c, P(h, g, _(0), _(u.cells.length - 1), "top", c);
351
+ e.borders.left = c, e.borders.bottom = c, M(h, g, _(0), _(u.cells.length - 1), "top", c);
352
352
  break;
353
353
  }
354
354
  case "stackedleftlinetop": {
355
355
  let e = h[g][_(0)];
356
- e.borders.right = c, e.borders.bottom = c, P(h, g, _(1), v, "top", c);
356
+ e.borders.right = c, e.borders.bottom = c, M(h, g, _(1), v, "top", c);
357
357
  break;
358
358
  }
359
359
  case "stackedrightright":
360
360
  case "mediumstackedrightright":
361
361
  case "shortstackedrightright":
362
362
  case "stackedleftleft":
363
- Ce(h, g, s, a, o, c, t);
363
+ Te(h, g, s, a, o, c, t);
364
364
  break;
365
- default: P(h, g, _(1), v, "top", c);
365
+ default: M(h, g, _(1), v, "top", c);
366
366
  }
367
- return M(e, m, t);
367
+ return j(e, m, t);
368
368
  }
369
- function Ce(e, t, n, r, i, a, o) {
370
- let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && b(o.document, "mpadded", [e], {
369
+ function Te(e, t, n, r, i, a, o) {
370
+ let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && y(o.document, "mpadded", [e], {
371
371
  lspace: "0.2em",
372
372
  width: "+0.4em"
373
373
  });
@@ -386,81 +386,81 @@ function Ce(e, t, n, r, i, a, o) {
386
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);
387
387
  });
388
388
  }
389
- function we(e) {
390
- for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? be(t) : Se(t));
389
+ function Ee(e) {
390
+ for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Se(t) : we(t));
391
391
  }
392
392
  //#endregion
393
393
  //#region src/explorer-styles.ts
394
- var Te = "PIE-MJX-explorer-styles", F = "var(--pie-text, black)", Ee = "var(--pie-background, #ffffff)", De = "var(--pie-border-dark, #66686A)", I = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", L = `color-mix(in srgb, ${I} 15%, transparent)`, Oe = `
394
+ var De = "PIE-MJX-explorer-styles", N = "var(--pie-text, black)", Oe = "var(--pie-background, #ffffff)", ke = "var(--pie-border-dark, #66686A)", P = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", F = `color-mix(in srgb, ${P} 15%, transparent)`, Ae = `
395
395
  :root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
396
- color: ${F} !important;
397
- fill: ${F} !important;
396
+ color: ${N} !important;
397
+ fill: ${N} !important;
398
398
  }
399
399
  :root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
400
- background-color: ${L} !important;
400
+ background-color: ${F} !important;
401
401
  }
402
402
  :root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
403
- fill: ${L} !important;
403
+ fill: ${F} !important;
404
404
  }
405
405
  :root mjx-container .mjx-selected {
406
- outline: 2px solid ${I} !important;
406
+ outline: 2px solid ${P} !important;
407
407
  }
408
408
  :root mjx-container [data-sre-highlight-2] {
409
- color: ${F} !important;
409
+ color: ${N} !important;
410
410
  background-color: transparent !important;
411
- fill: ${F} !important;
412
- outline: 2px dashed ${I} !important;
411
+ fill: ${N} !important;
412
+ outline: 2px dashed ${P} !important;
413
413
  }
414
414
  :root mjx-container rect[data-sre-highlight-2] {
415
415
  fill: transparent !important;
416
- stroke: ${I} !important;
416
+ stroke: ${P} !important;
417
417
  stroke-width: 2px !important;
418
418
  vector-effect: non-scaling-stroke;
419
419
  }
420
420
  :root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
421
- color: ${F} !important;
422
- background-color: ${Ee} !important;
423
- border-color: ${De} !important;
421
+ color: ${N} !important;
422
+ background-color: ${Oe} !important;
423
+ border-color: ${ke} !important;
424
424
  }
425
425
  :root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
426
- color: ${F} !important;
427
- background-color: ${L} !important;
426
+ color: ${N} !important;
427
+ background-color: ${F} !important;
428
428
  }
429
429
  `;
430
- function ke(e = document) {
430
+ function je(e = document) {
431
431
  if (e.getElementById("PIE-MJX-explorer-styles")) return;
432
432
  let t = e.createElement("style");
433
- t.id = Te, t.textContent = Oe, e.head.appendChild(t);
433
+ t.id = De, t.textContent = Ae, e.head.appendChild(t);
434
434
  }
435
435
  //#endregion
436
436
  //#region src/math-speech.ts
437
- var Ae = /[⁡-⁤]/g, je = {
437
+ var Me = /[⁡-⁤]/g, Ne = {
438
438
  "+": "positive",
439
439
  "-": "negative",
440
440
  "−": "negative",
441
441
  "±": "plus or minus",
442
442
  "∓": "minus or plus"
443
- }, Me = {
443
+ }, Pe = {
444
444
  "(": "open parenthesis",
445
445
  "[": "open bracket",
446
446
  "{": "open brace",
447
447
  "⟨": "open angle bracket",
448
448
  "⌊": "open floor",
449
449
  "⌈": "open ceiling"
450
- }, Ne = {
450
+ }, Fe = {
451
451
  ")": "close parenthesis",
452
452
  "]": "close bracket",
453
453
  "}": "close brace",
454
454
  "⟩": "close angle bracket",
455
455
  "⌋": "close floor",
456
456
  "⌉": "close ceiling"
457
- }, R = {
457
+ }, I = {
458
458
  "!": "factorial",
459
459
  "%": "percent",
460
460
  "°": "degrees",
461
461
  "′": "prime",
462
462
  "″": "double prime"
463
- }, Pe = {
463
+ }, Ie = {
464
464
  "+": "plus",
465
465
  "-": "minus",
466
466
  "−": "minus",
@@ -504,16 +504,16 @@ var Ae = /[⁡-⁤]/g, je = {
504
504
  ":": "colon",
505
505
  "|": "vertical bar",
506
506
  "‖": "double vertical bar",
507
- ...Me,
508
- ...Ne,
509
- ...R
510
- }, Fe = /* @__PURE__ */ new Set(["|", "‖"]), Ie = /* @__PURE__ */ new Set([
507
+ ...Pe,
508
+ ...Fe,
509
+ ...I
510
+ }, Le = /* @__PURE__ */ new Set(["|", "‖"]), Re = /* @__PURE__ */ new Set([
511
511
  "∑",
512
512
  "∏",
513
513
  "∫",
514
514
  "∪",
515
515
  "∩"
516
- ]), Le = {
516
+ ]), ze = {
517
517
  α: "alpha",
518
518
  β: "beta",
519
519
  γ: "gamma",
@@ -540,7 +540,7 @@ var Ae = /[⁡-⁤]/g, je = {
540
540
  cot: "cotangent",
541
541
  ln: "natural log",
542
542
  lim: "limit"
543
- }, Re = {
543
+ }, Be = {
544
544
  "¯": "bar",
545
545
  "‾": "bar",
546
546
  "―": "bar",
@@ -551,120 +551,120 @@ var Ae = /[⁡-⁤]/g, je = {
551
551
  "→": "vector",
552
552
  "⃗": "vector",
553
553
  "˙": "dot"
554
- }, z = (e) => (e.textContent ?? "").replace(Ae, "").replace(/\s+/g, " ").trim(), B = (e) => e.replace(/\s+/g, " ").trim(), V = (e) => [...e.children];
555
- function H(e) {
554
+ }, L = (e) => (e.textContent ?? "").replace(Me, "").replace(/\s+/g, " ").trim(), R = (e) => e.replace(/\s+/g, " ").trim(), z = (e) => [...e.children];
555
+ function B(e) {
556
556
  return !e || [
557
557
  "mn",
558
558
  "mi",
559
559
  "mtext",
560
560
  "mo"
561
- ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? H(e.children[0]) : !1;
561
+ ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? B(e.children[0]) : !1;
562
562
  }
563
- function ze(e) {
564
- let t = e ? z(e) : "";
563
+ function Ve(e) {
564
+ let t = e ? L(e) : "";
565
565
  return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
566
566
  }
567
- function Be(e) {
567
+ function He(e) {
568
568
  return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
569
569
  1: "st",
570
570
  2: "nd",
571
571
  3: "rd"
572
572
  }[e % 10] ?? "th"}`;
573
573
  }
574
- function Ve(e) {
575
- return Le[e] ?? e;
574
+ function Ue(e) {
575
+ return ze[e] ?? e;
576
576
  }
577
- function U(e) {
578
- return Pe[e] ?? e;
577
+ function V(e) {
578
+ return Ie[e] ?? e;
579
579
  }
580
- function W(e) {
580
+ function H(e) {
581
581
  let t = [], n = !1;
582
582
  for (let r of e) {
583
583
  if (r.localName !== "mo") {
584
584
  t.push(G(r)), n = !0;
585
585
  continue;
586
586
  }
587
- let e = z(r);
588
- e && (!n && je[e] ? t.push(je[e]) : e in R ? t.push(R[e]) : (t.push(U(e)), n = e in Ne || Fe.has(e) && n));
587
+ let e = L(r);
588
+ e && (!n && Ne[e] ? t.push(Ne[e]) : e in I ? t.push(I[e]) : (t.push(V(e)), n = e in Fe || Le.has(e) && n));
589
589
  }
590
590
  return t.filter(Boolean).join(" ");
591
591
  }
592
- function He(e) {
593
- let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(z(e)), a = n.slice(0, -1);
594
- if (a.length && i(t) && i(r) && z(t) === z(r) && !a.some(i)) {
595
- let e = B(W(a));
596
- return z(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
592
+ function We(e) {
593
+ let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(L(e)), a = n.slice(0, -1);
594
+ if (a.length && i(t) && i(r) && L(t) === L(r) && !a.some(i)) {
595
+ let e = R(H(a));
596
+ return L(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
597
597
  }
598
- return W(e);
598
+ return H(e);
599
599
  }
600
- function Ue(e, t) {
600
+ function Ge(e, t) {
601
601
  let n = e ? G(e) : "", r = t ? G(t) : "";
602
- return H(e) && H(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
602
+ return B(e) && B(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
603
603
  }
604
- function We(e, t, n) {
604
+ function U(e, t, n) {
605
605
  return n ? `${t} of ${e}` : `${t} of ${e} end root`;
606
606
  }
607
- function Ge(e, t) {
608
- let n = t ? z(t) : "";
609
- if (t && H(t)) {
607
+ function W(e, t) {
608
+ let n = t ? L(t) : "";
609
+ if (t && B(t)) {
610
610
  if (n === "2") return `${e} squared`;
611
611
  if (n === "3") return `${e} cubed`;
612
- if (n in R) return `${e} ${R[n]}`;
612
+ if (n in I) return `${e} ${I[n]}`;
613
613
  }
614
614
  let r = t ? G(t) : "";
615
- return H(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
615
+ return B(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
616
616
  }
617
617
  function Ke(e, t) {
618
618
  let n = t ? G(t) : "";
619
- return H(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
619
+ return B(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
620
620
  }
621
621
  function qe(e, t, n) {
622
- let r = z(e);
622
+ let r = L(e);
623
623
  if (r === "lim") return `limit as ${t ? G(t) : ""} of`;
624
- if (!Ie.has(r)) return;
624
+ if (!Re.has(r)) return;
625
625
  let i = t ? `from ${G(t)}` : "", a = n ? `to ${G(n)}` : "";
626
- return `${U(r)} ${i} ${a} of`;
626
+ return `${V(r)} ${i} ${a} of`;
627
627
  }
628
628
  function Je(e) {
629
- let t = V(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => V(e).filter((e) => e.localName === "mtd")), r = Math.max(0, ...n.map((e) => e.length)), i = n.map((e, t) => `row ${t + 1}: ${e.map((e) => B(W(V(e)))).join(", ")}`);
629
+ let t = z(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => z(e).filter((e) => e.localName === "mtd")), r = Math.max(0, ...n.map((e) => e.length)), i = n.map((e, t) => `row ${t + 1}: ${e.map((e) => R(H(z(e)))).join(", ")}`);
630
630
  return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
631
631
  }
632
632
  function Ye(e) {
633
- let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = V(e).map((e, t, n) => t < n.length - 1 ? `${G(e)} ${U(r[Math.min(t, r.length - 1)] ?? ",")}` : G(e));
633
+ let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = z(e).map((e, t, n) => t < n.length - 1 ? `${G(e)} ${V(r[Math.min(t, r.length - 1)] ?? ",")}` : G(e));
634
634
  return [
635
- U(t),
635
+ V(t),
636
636
  ...i,
637
- U(n)
637
+ V(n)
638
638
  ].filter(Boolean).join(" ");
639
639
  }
640
640
  function G(e) {
641
- let t = V(e);
641
+ let t = z(e);
642
642
  switch (e.localName) {
643
- case "mi": return Ve(z(e));
643
+ case "mi": return Ue(L(e));
644
644
  case "mn":
645
645
  case "mtext":
646
- case "ms": return z(e);
647
- case "mo": return U(z(e));
646
+ case "ms": return L(e);
647
+ case "mo": return V(L(e));
648
648
  case "mspace":
649
649
  case "mphantom":
650
650
  case "annotation":
651
651
  case "annotation-xml": return "";
652
652
  case "semantics": return t[0] ? G(t[0]) : "";
653
- case "mfrac": return Ue(t[0], t[1]);
654
- case "msqrt": return We(B(W(t)), "square root", t.length === 1 && H(t[0]));
653
+ case "mfrac": return Ge(t[0], t[1]);
654
+ case "msqrt": return U(R(H(t)), "square root", t.length === 1 && B(t[0]));
655
655
  case "mroot": {
656
- let e = ze(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${Be(e)} root` : `root with index ${t[1] ? G(t[1]) : ""}`;
657
- return We(t[0] ? G(t[0]) : "", n, H(t[0]));
656
+ let e = Ve(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${He(e)} root` : `root with index ${t[1] ? G(t[1]) : ""}`;
657
+ return U(t[0] ? G(t[0]) : "", n, B(t[0]));
658
658
  }
659
- case "msup": return Ge(t[0] ? G(t[0]) : "", t[1]);
659
+ case "msup": return W(t[0] ? G(t[0]) : "", t[1]);
660
660
  case "msub": return Ke(t[0] ? G(t[0]) : "", t[1]);
661
- case "msubsup": return (t[0] ? qe(t[0], t[1], t[2]) : void 0) || Ge(Ke(t[0] ? G(t[0]) : "", t[1]), t[2]);
661
+ case "msubsup": return (t[0] ? qe(t[0], t[1], t[2]) : void 0) || W(Ke(t[0] ? G(t[0]) : "", t[1]), t[2]);
662
662
  case "munder":
663
663
  case "mover":
664
664
  case "munderover": {
665
665
  let [n, r, i] = t, a = e.localName === "mover" ? void 0 : r, o = e.localName === "munder" ? void 0 : e.localName === "mover" ? r : i, s = n ? qe(n, a, o) : void 0;
666
666
  if (s) return s;
667
- let c = n ? G(n) : "", l = e.localName === "mover" && r ? Re[z(r)] : void 0;
667
+ let c = n ? G(n) : "", l = e.localName === "mover" && r ? Be[L(r)] : void 0;
668
668
  return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
669
669
  c,
670
670
  a ? `with ${G(a)} below` : "",
@@ -674,12 +674,12 @@ function G(e) {
674
674
  case "mfenced": return Ye(e);
675
675
  case "mtable": return Je(e);
676
676
  case "mrow":
677
- case "math": return He(t);
678
- default: return t.length ? W(t) : z(e);
677
+ case "math": return We(t);
678
+ default: return t.length ? H(t) : L(e);
679
679
  }
680
680
  }
681
681
  function Xe(e) {
682
- return B(G(e));
682
+ return R(G(e));
683
683
  }
684
684
  //#endregion
685
685
  //#region src/math-name.ts
@@ -702,18 +702,46 @@ var Ze = [
702
702
  "tab",
703
703
  "treeitem"
704
704
  ].map((e) => `[role="${e}"]`)
705
- ].join(", ");
705
+ ].join(", "), K = "data-pie-math-name";
706
706
  function Qe(e) {
707
- if (e.hasAttribute("aria-label") || !e.closest(Ze)) return;
708
- let t = e.querySelector("math"), n = t ? Xe(t) : "";
709
- n && e.setAttribute("aria-label", n);
707
+ if (e.localName !== "label") return e;
708
+ let t = e;
709
+ if (t.control) return t.control;
710
+ let n = t.getAttribute("for"), r = t.getRootNode();
711
+ return (n ? r.getElementById?.(n) : null) ?? t.querySelector("input, select, textarea, button");
712
+ }
713
+ function $e(e, t) {
714
+ let n = e.getRootNode();
715
+ return "getElementById" in n && typeof n.getElementById == "function" ? n.getElementById(t) : n instanceof Element ? (n.id === t ? n : null) ?? n.querySelector(`[id="${CSS.escape(t)}"]`) : null;
716
+ }
717
+ function et(e, t) {
718
+ let n = Qe(e)?.getAttribute("aria-labelledby")?.split(/\s+/).filter(Boolean);
719
+ if (!n?.length) return !1;
720
+ let r = n.map((e) => $e(t, e)).filter((e) => e !== null);
721
+ return r.length > 0 && !r.some((e) => e.contains(t));
722
+ }
723
+ function tt(e) {
724
+ let t = e.getAttribute(K);
725
+ t !== null && (e.getAttribute("aria-label") === t && e.removeAttribute("aria-label"), e.removeAttribute(K));
726
+ }
727
+ function nt(e) {
728
+ if (e.hasAttribute("aria-label") && !e.hasAttribute(K)) return;
729
+ let t = e.closest(Ze);
730
+ if (!t) return;
731
+ if (et(t, e)) {
732
+ tt(e);
733
+ return;
734
+ }
735
+ if (e.hasAttribute("aria-label")) return;
736
+ let n = e.querySelector("math"), r = n ? Xe(n) : "";
737
+ r && (e.setAttribute("aria-label", r), e.setAttribute(K, r));
710
738
  }
711
- function K(e) {
712
- for (let t of e.querySelectorAll("mjx-container")) Qe(t);
739
+ function q(e) {
740
+ for (let t of e.querySelectorAll("mjx-container")) nt(t);
713
741
  }
714
742
  //#endregion
715
743
  //#region src/tex-dialect.ts
716
- var $e = {
744
+ var rt = {
717
745
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
718
746
  overarc: "\\overparen",
719
747
  napprox: "\\not\\approx",
@@ -721,66 +749,66 @@ var $e = {
721
749
  abs: ["\\left|#1\\right|", 1],
722
750
  perpendicular: "\\perp",
723
751
  divide: "\\div"
724
- }, et = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, tt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, nt = /\\embed\{newLine\}\[\]/g, rt = [
752
+ }, it = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, at = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, ot = /\\embed\{newLine\}\[\]/g, st = [
725
753
  ["$$", "$$"],
726
754
  ["$", "$"],
727
755
  ["\\[", "\\]"],
728
756
  ["\\(", "\\)"]
729
757
  ];
730
- function it(e) {
731
- for (let [t, n] of rt) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
758
+ function ct(e) {
759
+ for (let [t, n] of st) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
732
760
  return e;
733
761
  }
734
- function at(e) {
735
- return `\\(${it(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e)}\\)`.replace(nt, "\\newline ");
762
+ function lt(e) {
763
+ return `\\(${ct(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e)}\\)`.replace(ot, "\\newline ");
736
764
  }
737
- var ot = "mathjax_ignore", st = "mathjax_process", q = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", ct = "pie-mathjax-version-conflict", lt = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
738
- function ut(e, t) {
765
+ var ut = "mathjax_ignore", dt = "mathjax_process", J = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", ft = "pie-mathjax-version-conflict", pt = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
766
+ function mt(e, t) {
739
767
  if (typeof window > "u") return;
740
768
  let n = globalThis;
741
- n[lt] ??= {
769
+ n[pt] ??= {
742
770
  logged: !1,
743
771
  conditions: []
744
772
  };
745
- let r = n[lt];
773
+ let r = n[pt];
746
774
  if (r.conditions.includes(e)) return;
747
775
  r.conditions.push(e);
748
- 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 ${q}`;
749
- r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(ct, { detail: {
776
+ 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 ${J}`;
777
+ r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(ft, { detail: {
750
778
  condition: e,
751
779
  message: i,
752
- docsUrl: q
780
+ docsUrl: J
753
781
  } }));
754
782
  }
755
783
  //#endregion
756
784
  //#region src/adapter.ts
757
- var dt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", ft = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), pt = "MJX-CHTML-styles", mt = "PIE-MJX-SVG-styles", J = "PIE-MathJax-Menu-Settings", ht = { "mjx-container[overflow=\"linebreak\"][display]": {
785
+ var ht = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", gt = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), _t = "MJX-CHTML-styles", vt = "PIE-MJX-SVG-styles", Y = "PIE-MathJax-Menu-Settings", yt = { "mjx-container[overflow=\"linebreak\"][display]": {
758
786
  overflow: "auto clip",
759
787
  "min-width": "initial !important"
760
- } }, gt = 200, _t = 201, vt = 202;
761
- function Y(e) {
788
+ } }, bt = 200, xt = 201, St = 202;
789
+ function X(e) {
762
790
  let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
763
791
  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");
764
792
  }
765
- function yt(e, t) {
766
- let n = e.closest(`.${ot}, .${st}`);
793
+ function Ct(e, t) {
794
+ let n = e.closest(`.${ut}, .${dt}`);
767
795
  return n !== null && t.contains(n) && !n.classList.contains("mathjax_process");
768
796
  }
769
- function bt(e) {
797
+ function wt(e) {
770
798
  for (let t of e.querySelectorAll("[data-latex]")) {
771
- if (t.dataset.mathHandled || t.closest("mjx-container") || yt(t, e)) continue;
799
+ if (t.dataset.mathHandled || t.closest("mjx-container") || Ct(t, e)) continue;
772
800
  let n = t.textContent;
773
- n && (t.textContent = at(n), t.dataset.mathHandled = "true");
801
+ n && (t.textContent = lt(n), t.dataset.mathHandled = "true");
774
802
  }
775
803
  }
776
- function xt(e) {
804
+ function Tt(e) {
777
805
  for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
778
806
  }
779
- function St(e, t) {
807
+ function Et(e, t) {
780
808
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
781
- return (t ? tt : et).test(e.textContent ?? "");
809
+ return (t ? at : it).test(e.textContent ?? "");
782
810
  }
783
- function Ct(e) {
811
+ function Dt(e) {
784
812
  return new Promise((o, c) => {
785
813
  let { useSingleDollar: u = !1, accessibility: d = !0, loadFonts: f = !0, srcUrl: p } = e, m = n(e, import.meta.url), h = r(), g = {
786
814
  loader: {
@@ -788,17 +816,17 @@ function Ct(e) {
788
816
  failed: (e) => c(e),
789
817
  "output/svg": { ready: (e) => {
790
818
  let t = s();
791
- return wt(t) && Tt(t), e;
819
+ return Ot(t) && kt(t), e;
792
820
  } }
793
821
  },
794
822
  startup: {
795
823
  typeset: !1,
796
824
  ready: () => {
797
- let e = s(), n = e?.startup, r = wt(e);
798
- r && (Tt(e), Et(e, m.speechLocales), t(e?._?.a11y?.sre_ts?.locales, m.speechLocales)), n?.defaultReady?.(), r && (Dt(n?.document), Ot(n?.document), n?.document?.addStyles?.(ht), a(n?.document)), Promise.resolve(n?.promise).then(() => o(), c);
825
+ let e = s(), n = e?.startup, r = Ot(e);
826
+ r && (kt(e), At(e, m.speechLocales), t(e?._?.a11y?.sre_ts?.locales, m.speechLocales)), n?.defaultReady?.(), r && (jt(n?.document), Mt(n?.document), n?.document?.addStyles?.(yt), a(n?.document)), Promise.resolve(n?.promise).then(() => o(), c);
799
827
  }
800
828
  },
801
- tex: { macros: { ...$e } },
829
+ tex: { macros: { ...rt } },
802
830
  output: { displayOverflow: "linebreak" },
803
831
  options: {
804
832
  enableMenu: d,
@@ -810,7 +838,7 @@ function Ct(e) {
810
838
  a11y: { inTabOrder: h }
811
839
  }
812
840
  };
813
- u && g.tex && (console.warn(dt), g.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], g.tex.processEscapes = !0), f || (g.chtml = { fontURL: "" });
841
+ u && g.tex && (console.warn(ht), g.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], g.tex.processEscapes = !0), f || (g.chtml = { fontURL: "" });
814
842
  let _ = i(m.speechLocales);
815
843
  _ && g.options && (g.options.sre = { locale: _ }), l(g, {
816
844
  ...m,
@@ -820,86 +848,86 @@ function Ct(e) {
820
848
  }, c);
821
849
  });
822
850
  }
823
- function wt(e) {
851
+ function Ot(e) {
824
852
  return !!e?.version?.startsWith("4.");
825
853
  }
826
- function Tt(e) {
854
+ function kt(e) {
827
855
  let t = e?._?.output, n = t?.chtml_ts?.CHTML;
828
856
  n && (n.STYLESHEETID = m);
829
857
  let r = t?.svg_ts?.SVG;
830
- r && (r.STYLESHEETID = mt);
858
+ r && (r.STYLESHEETID = vt);
831
859
  }
832
- function Et(e, t) {
860
+ function At(e, t) {
833
861
  let n = e?._?.ui?.menu?.Menu?.Menu;
834
862
  if (n) {
835
- n.MENU_STORAGE = J;
863
+ n.MENU_STORAGE = Y;
836
864
  try {
837
- let e = localStorage.getItem(J);
865
+ let e = localStorage.getItem(Y);
838
866
  if (!e) return;
839
867
  let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
840
868
  if (n === void 0 && a) return;
841
- a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(J, JSON.stringify(i)) : localStorage.removeItem(J);
869
+ a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(Y, JSON.stringify(i)) : localStorage.removeItem(Y);
842
870
  } catch {}
843
871
  }
844
872
  }
845
- function Dt(e) {
873
+ function jt(e) {
846
874
  if (!e) return;
847
875
  let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
848
876
  let n = e.typesetRoot;
849
- !n || t.has(n) || (Y(n), t.add(n));
877
+ !n || t.has(n) || (X(n), t.add(n));
850
878
  };
851
- e.addRenderAction?.("pie-strip-latex", _t, (e) => {
879
+ e.addRenderAction?.("pie-strip-latex", xt, (e) => {
852
880
  for (let t of e.math ?? []) n(t);
853
881
  return !1;
854
882
  }, (e) => {
855
883
  let t = e.typesetRoot;
856
- return t && Y(t), !1;
884
+ return t && X(t), !1;
857
885
  });
858
886
  let r = e.outputJax?.chtmlStyles;
859
- r?.id === pt && (r.id = m), At();
887
+ r?.id === _t && (r.id = m), Pt();
860
888
  }
861
- function Ot(e) {
889
+ function Mt(e) {
862
890
  let t = (e) => {
863
- e.typesetRoot && Qe(e.typesetRoot);
891
+ e.typesetRoot && nt(e.typesetRoot);
864
892
  };
865
- e?.addRenderAction?.("pie-name-math", vt, (e) => {
893
+ e?.addRenderAction?.("pie-name-math", St, (e) => {
866
894
  for (let n of e.math ?? []) t(n);
867
895
  return !1;
868
896
  }, (e) => (t(e), !1));
869
897
  }
870
- function X(e) {
898
+ function Z(e) {
871
899
  return e instanceof HTMLStyleElement && h.includes(e.id);
872
900
  }
873
- function kt(e) {
874
- ut("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
901
+ function Nt(e) {
902
+ mt("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
875
903
  }
876
- function At() {
877
- let e = document.head, t = [...e.children].find(X);
904
+ function Pt() {
905
+ let e = document.head, t = [...e.children].find(Z);
878
906
  if (t) {
879
- kt(t);
907
+ Nt(t);
880
908
  return;
881
909
  }
882
910
  let n = new MutationObserver((e) => {
883
911
  for (let t of e) {
884
- let e = [...t.addedNodes].find(X);
912
+ let e = [...t.addedNodes].find(Z);
885
913
  if (e) {
886
- kt(e), n.disconnect();
914
+ Nt(e), n.disconnect();
887
915
  return;
888
916
  }
889
917
  }
890
918
  });
891
919
  n.observe(e, { childList: !0 });
892
920
  }
893
- function jt(e) {
921
+ function Ft(e) {
894
922
  let t = e?.math;
895
923
  if (!t?.remove) return;
896
- let n = [...t].filter((e) => (e.state?.() ?? 0) >= gt && e.typesetRoot?.isConnected === !1);
924
+ let n = [...t].filter((e) => (e.state?.() ?? 0) >= bt && e.typesetRoot?.isConnected === !1);
897
925
  if (n.length !== 0) {
898
926
  for (let e of [...n].reverse()) e.clear?.();
899
927
  t.remove(...n);
900
928
  }
901
929
  }
902
- function Mt(e) {
930
+ function It(e) {
903
931
  return new Promise((t, n) => {
904
932
  let r = e.startup ?? {};
905
933
  e.startup = r;
@@ -910,81 +938,81 @@ function Mt(e) {
910
938
  };
911
939
  });
912
940
  }
913
- function Nt(e) {
941
+ function Lt(e) {
914
942
  let t = s();
915
- return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : Mt(t) : Ct(e);
943
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : It(t) : Dt(e);
916
944
  }
917
- function Pt(e) {
918
- return Nt(e).then(() => {
945
+ function Rt(e) {
946
+ return Lt(e).then(() => {
919
947
  let e = s();
920
948
  e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
921
949
  });
922
950
  }
923
- function Ft(e) {
924
- let t = u, n = t[ft];
925
- return n || (n = Pt(e), t[ft] = n), n;
951
+ function zt(e) {
952
+ let t = u, n = t[gt];
953
+ return n || (n = Rt(e), t[gt] = n), n;
926
954
  }
927
- function It(e = {}) {
955
+ function Bt(e = {}) {
928
956
  let t = e.useSingleDollar ?? !1;
929
957
  return async (n) => {
930
958
  if (typeof window > "u") return;
931
- bt(n), ee(n), xt(n), we(n);
932
- let r = Ft(e);
933
- if (!St(n, t)) {
934
- r.catch(() => {});
959
+ wt(n), ee(n), Tt(n), Ee(n);
960
+ let r = zt(e);
961
+ if (!Et(n, t)) {
962
+ r.catch(() => {}), q(n);
935
963
  return;
936
964
  }
937
965
  await r;
938
966
  let i = s();
939
967
  if (await i?.startup?.promise, typeof i?.typesetPromise == "function") {
940
- ke(), jt(i.startup?.document);
968
+ je(), Ft(i.startup?.document);
941
969
  try {
942
970
  await i.typesetPromise([n]);
943
971
  } catch (e) {
944
972
  throw i.typesetClear?.([n]), e;
945
973
  }
946
- Y(n), K(n);
974
+ X(n), q(n);
947
975
  }
948
976
  };
949
977
  }
950
- function Lt() {
978
+ function Vt() {
951
979
  return [];
952
980
  }
953
981
  //#endregion
954
982
  //#region src/render-math.ts
955
- var Rt = "@pie-lib/math-rendering", zt = "@pie-lib/math-rendering@2", Bt = "pie-print", Vt = 50, Ht = 1e4, Ut = null;
956
- function Wt() {
957
- return !!window[zt]?.opts?.useSingleDollar;
983
+ var Ht = "@pie-lib/math-rendering", Ut = "@pie-lib/math-rendering@2", Wt = "pie-print", Gt = 50, Kt = 1e4, qt = null;
984
+ function Jt() {
985
+ return !!window[Ut]?.opts?.useSingleDollar;
958
986
  }
959
- function Gt() {
960
- return Ut ||= It({ useSingleDollar: Wt() }), Ut;
987
+ function Yt() {
988
+ return qt ||= Bt({ useSingleDollar: Jt() }), qt;
961
989
  }
962
- function Z() {
990
+ function Q() {
963
991
  if (typeof window > "u") return null;
964
- let e = window[Rt];
992
+ let e = window[Ht];
965
993
  return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
966
994
  }
967
- function Kt(e) {
995
+ function Xt(e) {
968
996
  let t = e;
969
997
  for (; t;) {
970
- if (t instanceof Element && t.localName === Bt) return t;
998
+ if (t instanceof Element && t.localName === Wt) return t;
971
999
  t = t instanceof ShadowRoot ? t.host : t.parentNode;
972
1000
  }
973
1001
  return null;
974
1002
  }
975
- function Q() {
1003
+ function Zt() {
976
1004
  let e = window.renderMath;
977
1005
  return typeof e == "function" ? e : null;
978
1006
  }
979
- async function qt(e) {
980
- let t = Kt(e);
1007
+ async function Qt(e) {
1008
+ let t = Xt(e);
981
1009
  if (!t) return null;
982
- let n = Q();
1010
+ let n = Zt();
983
1011
  if (n || t.mathRenderingModuleUrlImported !== !0) return n;
984
- let r = Date.now() + Ht;
1012
+ let r = Date.now() + Kt;
985
1013
  for (; Date.now() < r;) {
986
- await new Promise((e) => setTimeout(e, Vt));
987
- let e = Q();
1014
+ await new Promise((e) => setTimeout(e, Gt));
1015
+ let e = Zt();
988
1016
  if (e) return e;
989
1017
  }
990
1018
  return null;
@@ -993,14 +1021,14 @@ var $ = async (e) => {
993
1021
  if (typeof window > "u") return;
994
1022
  let t = typeof e == "string", n;
995
1023
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
996
- let r = Z(), i = r || t ? null : await qt(n);
997
- return r ? (await r.renderMath?.(n), K(n)) : i && i !== $ ? (await i(n), K(n)) : await Gt()(n), t ? n.innerHTML : void 0;
998
- }, Jt = (e, t) => {
999
- let n = Z()?.wrapMath?.(e, t);
1024
+ let r = Q(), i = r || t ? null : await Qt(n);
1025
+ return r ? (await r.renderMath?.(n), q(n)) : i && i !== $ ? (await i(n), q(n)) : await Yt()(n), t ? n.innerHTML : void 0;
1026
+ }, $t = (e, t) => {
1027
+ let n = Q()?.wrapMath?.(e, t);
1000
1028
  if (n != null) return n;
1001
1029
  let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
1002
- return `${r}${it(e)}${i}`;
1003
- }, Yt = (e) => {
1030
+ return `${r}${ct(e)}${i}`;
1031
+ }, en = (e) => {
1004
1032
  let t = e.trim();
1005
1033
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
1006
1034
  unwrapped: t.slice(2, -2).trim(),
@@ -1027,6 +1055,6 @@ var $ = async (e) => {
1027
1055
  close: "$"
1028
1056
  }
1029
1057
  } : { unwrapped: t };
1030
- }, Xt = (e) => Z()?.mmlToLatex?.(e) ?? e;
1058
+ }, tn = (e) => Q()?.mmlToLatex?.(e) ?? e;
1031
1059
  //#endregion
1032
- export { ct as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, q as UNSUPPORTED_PAGE_DOCS_URL, It as createMathjaxRenderer, Lt as getMathjaxCssUrls, Xt as mmlToLatex, $ as renderMath, Xe as speakMathml, Yt as unWrapMath, Jt as wrapMath };
1060
+ export { ft as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, J as UNSUPPORTED_PAGE_DOCS_URL, Bt as createMathjaxRenderer, Vt as getMathjaxCssUrls, tn as mmlToLatex, $ as renderMath, Xe as speakMathml, en as unWrapMath, $t as wrapMath };