@pie-element/shared-math-rendering-mathjax 0.1.7-next.20261015154938 → 0.1.7-next.20261018222107

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.
package/dist/index.js CHANGED
@@ -85,15 +85,15 @@ function v(e) {
85
85
  }
86
86
  //#endregion
87
87
  //#region src/unsupported-page.ts
88
- var y = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", ee = "pie-mathjax-version-conflict", b = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
89
- function te(e, t) {
88
+ var y = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", ee = "pie-mathjax-version-conflict", te = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
89
+ function ne(e, t) {
90
90
  if (typeof window > "u") return;
91
91
  let n = globalThis;
92
- n[b] ??= {
92
+ n[te] ??= {
93
93
  logged: !1,
94
94
  conditions: []
95
95
  };
96
- let r = n[b];
96
+ let r = n[te];
97
97
  if (r.conditions.includes(e)) return;
98
98
  r.conditions.push(e);
99
99
  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 ${y}`;
@@ -103,16 +103,16 @@ function te(e, t) {
103
103
  docsUrl: y
104
104
  } }));
105
105
  }
106
- function ne() {
106
+ function re() {
107
107
  let e = window.MathJax?.version;
108
108
  return typeof e == "string" && e.startsWith("3.") ? e : void 0;
109
109
  }
110
110
  //#endregion
111
111
  //#region src/engine/page.ts
112
- function x() {
112
+ function b() {
113
113
  return window.MathJax;
114
114
  }
115
- function re(t, { root: n, speechPath: r }) {
115
+ function ie(t, { root: n, speechPath: r }) {
116
116
  n && (t.loader = {
117
117
  ...t.loader,
118
118
  paths: {
@@ -128,83 +128,83 @@ function re(t, { root: n, speechPath: r }) {
128
128
  }
129
129
  });
130
130
  }
131
- function ie(e, t) {
131
+ function ae(e, t) {
132
132
  let n = t.srcUrl || (t.root ? `${t.root}/mathjax@4.1.3/tex-mml-chtml.js` : void 0);
133
- return n ? (re(e, t), new Promise((t, r) => {
133
+ return n ? (ie(e, t), new Promise((t, r) => {
134
134
  window.MathJax = e;
135
135
  let i = document.createElement("script");
136
136
  i.src = n, i.async = !0, i.onload = () => t(!0), i.onerror = () => r(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(i);
137
137
  })) : (v("untypeset"), Promise.resolve(!1));
138
138
  }
139
- var ae = globalThis, oe = "PIE-MJX-CHTML-styles", se = ["MJX-CHTML-styles", "MJX-SVG-styles"], ce = ne, le = "http://www.w3.org/1998/Math/MathML", ue = /^([a-z_][\w.-]*):math$/, de = /^[a-z][a-z0-9-]*$/;
140
- function fe(e) {
139
+ var oe = globalThis, x = "PIE-MJX-CHTML-styles", se = ["MJX-CHTML-styles", "MJX-SVG-styles"], ce = re, S = "http://www.w3.org/1998/Math/MathML", le = /^([a-z_][\w.-]*):math$/, ue = /^[a-z][a-z0-9-]*$/;
140
+ function de(e) {
141
141
  for (let t of e.querySelectorAll("*")) {
142
- let n = ue.exec(t.tagName.toLowerCase())?.[1];
143
- !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(pe(t, `${n}:`));
142
+ let n = le.exec(t.tagName.toLowerCase())?.[1];
143
+ !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(C(t, `${n}:`));
144
144
  }
145
145
  }
146
- function pe(e, t) {
146
+ function C(e, t) {
147
147
  let n = e.tagName.toLowerCase().slice(t.length);
148
- if (!de.test(n)) return e;
149
- let r = e.ownerDocument.createElementNS(le, n);
148
+ if (!ue.test(n)) return e;
149
+ let r = e.ownerDocument.createElementNS(S, n);
150
150
  for (let t of e.attributes) r.setAttribute(t.name, t.value);
151
151
  for (let n of [...e.childNodes]) {
152
152
  let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
153
- r.appendChild(e ? pe(n, t) : n);
153
+ r.appendChild(e ? C(n, t) : n);
154
154
  }
155
155
  return r;
156
156
  }
157
157
  //#endregion
158
158
  //#region src/elementary-math.ts
159
- var me = /* @__PURE__ */ new Set([
159
+ var fe = /* @__PURE__ */ new Set([
160
160
  "updiagonalstrike",
161
161
  "downdiagonalstrike",
162
162
  "verticalstrike",
163
163
  "horizontalstrike"
164
- ]), he = {
164
+ ]), pe = {
165
165
  thin: "0.035em",
166
166
  medium: "0.07em",
167
167
  thick: "0.14em"
168
- }, S = {
168
+ }, w = {
169
169
  tight: "0em",
170
170
  medium: "0.1em",
171
171
  loose: "0.2em"
172
- }, C = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ge = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, _e = /^(\d+(\.\d*)?|\.\d+)$/, ve = /* @__PURE__ */ new Set([
172
+ }, me = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, he = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ge = /^(\d+(\.\d*)?|\.\d+)$/, _e = /* @__PURE__ */ new Set([
173
173
  "mn",
174
174
  "mo",
175
175
  "mi",
176
176
  "mtext"
177
- ]), ye = /* @__PURE__ */ new Set([
177
+ ]), ve = /* @__PURE__ */ new Set([
178
178
  "stackalign",
179
179
  "charalign",
180
180
  "charspacing",
181
181
  "longdivstyle"
182
182
  ]);
183
- function w(e, t, n = [], r = {}) {
184
- let i = e.createElementNS(le, t);
183
+ function T(e, t, n = [], r = {}) {
184
+ let i = e.createElementNS(S, t);
185
185
  for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
186
186
  for (let e of n) e && i.appendChild(e);
187
187
  return i;
188
188
  }
189
- function T(e, t) {
190
- let n = w(e.document, "mo");
189
+ function E(e, t) {
190
+ let n = T(e.document, "mo");
191
191
  return n.textContent = t, n;
192
192
  }
193
- function be(e) {
194
- let t = w(e.document, "mn");
195
- return t.textContent = "0", w(e.document, "mphantom", [t]);
193
+ function ye(e) {
194
+ let t = T(e.document, "mn");
195
+ return t.textContent = "0", T(e.document, "mphantom", [t]);
196
196
  }
197
- function E(e, t) {
197
+ function D(e, t) {
198
198
  return e.getAttribute(t)?.trim().toLowerCase() || void 0;
199
199
  }
200
- function D(e, t) {
200
+ function O(e, t) {
201
201
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
202
202
  return Number.isFinite(n) ? n : 0;
203
203
  }
204
- function O(e) {
204
+ function k(e) {
205
205
  return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
206
206
  }
207
- function k(e, t, n = e) {
207
+ function A(e, t, n = e) {
208
208
  switch (t) {
209
209
  case "left": return 0;
210
210
  case "center": return Math.floor(e / 2);
@@ -212,14 +212,14 @@ function k(e, t, n = e) {
212
212
  default: return n;
213
213
  }
214
214
  }
215
- function A(e, t, n) {
215
+ function j(e, t, n) {
216
216
  let r = [], i, a, o = (e, t) => {
217
217
  let s = (e) => t.reduceRight((e, t) => {
218
218
  let n = t.cloneNode(!1);
219
219
  return n.appendChild(e), n;
220
220
  }, e);
221
221
  if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
222
- else if (O(e)) r.push(null);
222
+ else if (k(e)) r.push(null);
223
223
  else if (e.localName === "mn" && e.children.length === 0) {
224
224
  let t = [...(e.textContent ?? "").trim()];
225
225
  for (let a of t) {
@@ -228,28 +228,28 @@ function A(e, t, n) {
228
228
  t.textContent = a, r.push(s(t));
229
229
  }
230
230
  t.length && (a ??= r.length);
231
- } else ve.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
231
+ } else _e.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
232
232
  };
233
233
  for (let t of e) o(t, []);
234
234
  return {
235
235
  kind: "digits",
236
236
  cells: r,
237
- anchor: k(r.length, n.stackAlign, i ?? a),
237
+ anchor: A(r.length, n.stackAlign, i ?? a),
238
238
  position: t
239
239
  };
240
240
  }
241
- function xe(e) {
242
- return (e ?? "").toLowerCase().split(/\s+/).filter((e) => me.has(e));
241
+ function be(e) {
242
+ return (e ?? "").toLowerCase().split(/\s+/).filter((e) => fe.has(e));
243
243
  }
244
- function Se(e, t) {
245
- let n = [...e.children].filter((e) => !O(e));
246
- return n.length <= 1 ? n[0] ?? null : w(t.document, "mrow", n);
244
+ function xe(e, t) {
245
+ let n = [...e.children].filter((e) => !k(e));
246
+ return n.length <= 1 ? n[0] ?? null : T(t.document, "mrow", n);
247
247
  }
248
- function Ce(e, t, n) {
249
- let r = E(e, "location") ?? "n", i = xe(e.getAttribute("crossout")), a = [...e.children].map((e) => O(e) ? null : e.localName === "mscarry" ? {
250
- content: Se(e, n),
251
- location: E(e, "location") ?? r,
252
- crossout: e.hasAttribute("crossout") ? xe(e.getAttribute("crossout")) : i
248
+ function Se(e, t, n) {
249
+ let r = D(e, "location") ?? "n", i = be(e.getAttribute("crossout")), a = [...e.children].map((e) => k(e) ? null : e.localName === "mscarry" ? {
250
+ content: xe(e, n),
251
+ location: D(e, "location") ?? r,
252
+ crossout: e.hasAttribute("crossout") ? be(e.getAttribute("crossout")) : i
253
253
  } : {
254
254
  content: e,
255
255
  location: r,
@@ -258,60 +258,60 @@ function Ce(e, t, n) {
258
258
  return {
259
259
  kind: "carries",
260
260
  carries: a,
261
- anchor: k(a.length, n.stackAlign),
261
+ anchor: A(a.length, n.stackAlign),
262
262
  position: t,
263
- scale: _e.test(o) ? o : "0.6"
263
+ scale: ge.test(o) ? o : "0.6"
264
264
  };
265
265
  }
266
- function we(e) {
267
- let t = E(e, "mslinethickness") ?? "medium", n = he[t] ?? (C.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
268
- return `${n} solid ${ge.test(r) ? r : "currentColor"}`;
266
+ function Ce(e) {
267
+ let t = D(e, "mslinethickness") ?? "medium", n = pe[t] ?? (me.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
268
+ return `${n} solid ${he.test(r) ? r : "currentColor"}`;
269
269
  }
270
- function Te(e, t, n) {
271
- let r = Math.max(0, D(e, "length"));
270
+ function we(e, t, n) {
271
+ let r = Math.max(0, O(e, "length"));
272
272
  return {
273
273
  kind: "line",
274
274
  length: r,
275
- anchor: k(r, n.stackAlign),
275
+ anchor: A(r, n.stackAlign),
276
276
  position: t,
277
- border: we(e)
277
+ border: Ce(e)
278
278
  };
279
279
  }
280
- function j(e, t, n, r, i) {
280
+ function M(e, t, n, r, i) {
281
281
  e.forEach((e, a) => {
282
- let o = t + a * n + D(e, "position");
282
+ let o = t + a * n + O(e, "position");
283
283
  switch (e.localName) {
284
284
  case "msgroup":
285
- j([...e.children], o, D(e, "shift"), r, i);
285
+ M([...e.children], o, O(e, "shift"), r, i);
286
286
  break;
287
287
  case "msline":
288
- i.push(Te(e, o, r));
288
+ i.push(we(e, o, r));
289
289
  break;
290
290
  case "mscarries":
291
- i.push(Ce(e, o, r));
291
+ i.push(Se(e, o, r));
292
292
  break;
293
293
  case "msrow":
294
294
  case "mrow":
295
- i.push(A([...e.children], o, r));
295
+ i.push(j([...e.children], o, r));
296
296
  break;
297
- default: i.push(A([e], o, r));
297
+ default: i.push(j([e], o, r));
298
298
  }
299
299
  });
300
300
  }
301
- function M(e) {
301
+ function N(e) {
302
302
  return -e.anchor - e.position;
303
303
  }
304
- function N(e) {
304
+ function Te(e) {
305
305
  return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
306
306
  }
307
- function P(e) {
308
- return M(e) + N(e) - 1;
307
+ function Ee(e) {
308
+ return N(e) + Te(e) - 1;
309
309
  }
310
- function Ee(e, t, n, r) {
311
- let i = (e) => w(r.document, "mpadded", [t], {
310
+ function De(e, t, n, r) {
311
+ let i = (e) => T(r.document, "mpadded", [t], {
312
312
  width: "0",
313
313
  ...e ? { lspace: e } : {}
314
- }), a = (e, t) => w(r.document, e, t);
314
+ }), a = (e, t) => T(r.document, e, t);
315
315
  switch (n) {
316
316
  case "s": return a("munder", [e, i("-0.5width")]);
317
317
  case "ne": return a("msup", [e, i()]);
@@ -333,49 +333,49 @@ function Ee(e, t, n, r) {
333
333
  default: return a("mover", [e, i("-0.5width")]);
334
334
  }
335
335
  }
336
- function De(e, t, n) {
337
- let r = w(n.document, "menclose", [e], {
336
+ function Oe(e, t, n) {
337
+ let r = T(n.document, "menclose", [e], {
338
338
  notation: t.join(" "),
339
339
  "data-padding": "0.1em",
340
340
  "data-thickness": "0.067em"
341
341
  }), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
342
- return i ? w(n.document, "mpadded", [r], {
342
+ return i ? T(n.document, "mpadded", [r], {
343
343
  lspace: `-${i}em`,
344
344
  width: `-${2 * i}em`
345
345
  }) : r;
346
346
  }
347
- function Oe(e, t, n, r, i) {
348
- let a = e && t.crossout.length ? De(e, t.crossout, i) : e;
347
+ function ke(e, t, n, r, i) {
348
+ let a = e && t.crossout.length ? Oe(e, t.crossout, i) : e;
349
349
  if (!t.content) return a;
350
- let o = w(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
351
- return Ee(a ?? be(i), o, n, i);
350
+ let o = T(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
351
+ return De(a ?? ye(i), o, n, i);
352
352
  }
353
- function ke(e, t) {
354
- return e.carries[t - M(e)] ?? null;
353
+ function Ae(e, t) {
354
+ return e.carries[t - N(e)] ?? null;
355
355
  }
356
- function Ae(e, t, n, r) {
356
+ function je(e, t, n, r) {
357
357
  let i = e.content;
358
358
  n.forEach((e, a) => {
359
- let o = n.length - 1 - a, s = n[o], c = ke(s, t), l = n.slice(0, o).some((e) => ke(e, t));
359
+ let o = n.length - 1 - a, s = n[o], c = Ae(s, t), l = n.slice(0, o).some((e) => Ae(e, t));
360
360
  if (!c && !l) return;
361
361
  let u = c ?? {
362
- content: be(r),
362
+ content: ye(r),
363
363
  location: "n",
364
364
  crossout: []
365
365
  }, d = a === 0 ? u.location : "n";
366
- i = Oe(i, u, d, s.scale, r);
366
+ i = ke(i, u, d, s.scale, r);
367
367
  }), e.content = i;
368
368
  }
369
- function je(e, t) {
370
- let n = e.filter((e) => N(e) > 0), r = Math.min(0, ...n.map(M)), i = Math.max(r, ...n.map(P)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
369
+ function Me(e, t) {
370
+ let n = e.filter((e) => Te(e) > 0), r = Math.min(0, ...n.map(N)), i = Math.max(r, ...n.map(Ee)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
371
371
  content: null,
372
372
  borders: {}
373
- })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + M(e) + n), u = [], d = [], f = (e) => {
373
+ })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + N(e) + n), u = [], d = [], f = (e) => {
374
374
  let n = c();
375
375
  e.cells.forEach((t, r) => {
376
- n[a + M(e) + r].content = t;
376
+ n[a + N(e) + r].content = t;
377
377
  }), u.length && n.forEach((e, n) => {
378
- Ae(e, n - a, u, t);
378
+ je(e, n - a, u, t);
379
379
  });
380
380
  for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
381
381
  u = [], d = [], s.set(e, o.length), o.push(n);
@@ -395,44 +395,44 @@ function je(e, t) {
395
395
  origin: a
396
396
  };
397
397
  }
398
- function Me(e, { rows: t }, n) {
399
- let r = w(n.document, "mtable", t.map((e) => w(n.document, "mtr", e.map((e) => {
398
+ function Ne(e, { rows: t }, n) {
399
+ let r = T(n.document, "mtable", t.map((e) => T(n.document, "mtr", e.map((e) => {
400
400
  let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
401
- return w(n.document, "mtd", [e.content], {
401
+ return T(n.document, "mtd", [e.content], {
402
402
  ...t ? { style: t } : {},
403
403
  ...e.align ? { columnalign: e.align } : {}
404
404
  });
405
405
  }))));
406
- for (let { name: t, value: n } of [...e.attributes]) ye.has(t) || r.setAttribute(t, n);
407
- let i = E(e, "charspacing") ?? "medium", a = E(e, "charalign");
408
- return r.setAttribute("columnspacing", S[i] ?? (C.test(i) ? i : S.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
406
+ for (let { name: t, value: n } of [...e.attributes]) ve.has(t) || r.setAttribute(t, n);
407
+ let i = D(e, "charspacing") ?? "medium", a = D(e, "charalign");
408
+ return r.setAttribute("columnspacing", w[i] ?? (me.test(i) ? i : w.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
409
409
  }
410
- function Ne(e) {
410
+ function Pe(e) {
411
411
  return {
412
412
  document: e.ownerDocument,
413
- stackAlign: E(e, "stackalign") ?? "decimalpoint",
413
+ stackAlign: D(e, "stackalign") ?? "decimalpoint",
414
414
  decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
415
415
  };
416
416
  }
417
- function Pe(e) {
418
- let t = Ne(e), n = [];
419
- return j([...e.children], 0, 0, t, n), Me(e, je(n, t), t);
417
+ function Fe(e) {
418
+ let t = Pe(e), n = [];
419
+ return M([...e.children], 0, 0, t, n), Ne(e, Me(n, t), t);
420
420
  }
421
- function F(e, t, n, r, i, a) {
421
+ function P(e, t, n, r, i, a) {
422
422
  for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
423
423
  }
424
- function Fe(e, t) {
425
- let n = T(t, ")");
426
- return n.setAttribute("minsize", "1.2em"), [w(t.document, "mrow", [e, w(t.document, "mspace", [], { width: "0.2em" })]), w(t.document, "mpadded", [n], {
424
+ function Ie(e, t) {
425
+ let n = E(t, ")");
426
+ return n.setAttribute("minsize", "1.2em"), [T(t.document, "mrow", [e, T(t.document, "mspace", [], { width: "0.2em" })]), T(t.document, "mpadded", [n], {
427
427
  voffset: "0.1em",
428
428
  lspace: "-0.15em",
429
429
  depth: "-0.2em",
430
430
  height: "-0.2em"
431
431
  })];
432
432
  }
433
- function Ie(e) {
434
- let t = Ne(e), [n, r, ...i] = [...e.children], a = n && !O(n) ? n : null, o = r && !O(r) ? r : null, s = E(e, "longdivstyle") ?? "lefttop", c = we(e), l = [];
435
- j(i, 0, 0, t, l);
433
+ function Le(e) {
434
+ let t = Pe(e), [n, r, ...i] = [...e.children], a = n && !k(n) ? n : null, o = r && !k(r) ? r : null, s = D(e, "longdivstyle") ?? "lefttop", c = Ce(e), l = [];
435
+ M(i, 0, 0, t, l);
436
436
  let u = l.find((e) => e.kind === "digits");
437
437
  u || (u = {
438
438
  kind: "digits",
@@ -444,51 +444,51 @@ function Ie(e) {
444
444
  u.cells.unshift(...e), u.anchor += e.length;
445
445
  }, p = (...e) => {
446
446
  let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
447
- u.cells.push(...A(n, 0, t).cells);
447
+ u.cells.push(...j(n, 0, t).cells);
448
448
  };
449
449
  switch (s) {
450
450
  case "left/\\right":
451
- f(a, T(t, "/")), p(T(t, "\\"), o);
451
+ f(a, E(t, "/")), p(E(t, "\\"), o);
452
452
  break;
453
453
  case "left)(right":
454
- f(a, T(t, ")")), p(T(t, "("), o);
454
+ f(a, E(t, ")")), p(E(t, "("), o);
455
455
  break;
456
456
  case ":right=right":
457
- p(T(t, ":"), a, T(t, "="), o);
457
+ p(E(t, ":"), a, E(t, "="), o);
458
458
  break;
459
459
  case "righttop":
460
460
  case "stackedleftlinetop":
461
461
  case "lefttop":
462
- o && j([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...Fe(a, t));
462
+ o && M([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...Ie(a, t));
463
463
  break;
464
464
  }
465
- let m = je(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + M(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + P(e)));
465
+ let m = Me(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + N(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + Ee(e)));
466
466
  switch (s) {
467
467
  case "left/\\right":
468
468
  case "left)(right":
469
469
  case ":right=right": break;
470
470
  case "righttop": {
471
471
  let e = h[g][_(u.cells.length - 1)];
472
- e.borders.left = c, e.borders.bottom = c, F(h, g, _(0), _(u.cells.length - 1), "top", c);
472
+ e.borders.left = c, e.borders.bottom = c, P(h, g, _(0), _(u.cells.length - 1), "top", c);
473
473
  break;
474
474
  }
475
475
  case "stackedleftlinetop": {
476
476
  let e = h[g][_(0)];
477
- e.borders.right = c, e.borders.bottom = c, F(h, g, _(1), v, "top", c);
477
+ e.borders.right = c, e.borders.bottom = c, P(h, g, _(1), v, "top", c);
478
478
  break;
479
479
  }
480
480
  case "stackedrightright":
481
481
  case "mediumstackedrightright":
482
482
  case "shortstackedrightright":
483
483
  case "stackedleftleft":
484
- Le(h, g, s, a, o, c, t);
484
+ Re(h, g, s, a, o, c, t);
485
485
  break;
486
- default: F(h, g, _(1), v, "top", c);
486
+ default: P(h, g, _(1), v, "top", c);
487
487
  }
488
- return Me(e, m, t);
488
+ return Ne(e, m, t);
489
489
  }
490
- function Le(e, t, n, r, i, a, o) {
491
- let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && w(o.document, "mpadded", [e], {
490
+ function Re(e, t, n, r, i, a, o) {
491
+ let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && T(o.document, "mpadded", [e], {
492
492
  lspace: "0.2em",
493
493
  width: "+0.4em"
494
494
  });
@@ -507,81 +507,81 @@ function Le(e, t, n, r, i, a, o) {
507
507
  }) : 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);
508
508
  });
509
509
  }
510
- function Re(e) {
511
- for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Pe(t) : Ie(t));
510
+ function ze(e) {
511
+ for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Fe(t) : Le(t));
512
512
  }
513
513
  //#endregion
514
514
  //#region src/explorer-styles.ts
515
- var ze = "PIE-MJX-explorer-styles", I = "var(--pie-text, black)", Be = "var(--pie-background, #ffffff)", Ve = "var(--pie-border-dark, #66686A)", L = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", R = `color-mix(in srgb, ${L} 15%, transparent)`, He = `
515
+ var Be = "PIE-MJX-explorer-styles", F = "var(--pie-text, black)", Ve = "var(--pie-background, #ffffff)", He = "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)`, Ue = `
516
516
  :root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
517
- color: ${I} !important;
518
- fill: ${I} !important;
517
+ color: ${F} !important;
518
+ fill: ${F} !important;
519
519
  }
520
520
  :root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
521
- background-color: ${R} !important;
521
+ background-color: ${L} !important;
522
522
  }
523
523
  :root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
524
- fill: ${R} !important;
524
+ fill: ${L} !important;
525
525
  }
526
526
  :root mjx-container .mjx-selected {
527
- outline: 2px solid ${L} !important;
527
+ outline: 2px solid ${I} !important;
528
528
  }
529
529
  :root mjx-container [data-sre-highlight-2] {
530
- color: ${I} !important;
530
+ color: ${F} !important;
531
531
  background-color: transparent !important;
532
- fill: ${I} !important;
533
- outline: 2px dashed ${L} !important;
532
+ fill: ${F} !important;
533
+ outline: 2px dashed ${I} !important;
534
534
  }
535
535
  :root mjx-container rect[data-sre-highlight-2] {
536
536
  fill: transparent !important;
537
- stroke: ${L} !important;
537
+ stroke: ${I} !important;
538
538
  stroke-width: 2px !important;
539
539
  vector-effect: non-scaling-stroke;
540
540
  }
541
541
  :root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
542
- color: ${I} !important;
543
- background-color: ${Be} !important;
544
- border-color: ${Ve} !important;
542
+ color: ${F} !important;
543
+ background-color: ${Ve} !important;
544
+ border-color: ${He} !important;
545
545
  }
546
546
  :root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
547
- color: ${I} !important;
548
- background-color: ${R} !important;
547
+ color: ${F} !important;
548
+ background-color: ${L} !important;
549
549
  }
550
550
  `;
551
- function Ue(e = document) {
551
+ function We(e = document) {
552
552
  if (e.getElementById("PIE-MJX-explorer-styles")) return;
553
553
  let t = e.createElement("style");
554
- t.id = ze, t.textContent = He, e.head.appendChild(t);
554
+ t.id = Be, t.textContent = Ue, e.head.appendChild(t);
555
555
  }
556
556
  //#endregion
557
557
  //#region src/math-speech.ts
558
- var We = /[⁡-⁤]/g, z = {
558
+ var Ge = /[⁡-⁤]/g, R = {
559
559
  "+": "positive",
560
560
  "-": "negative",
561
561
  "−": "negative",
562
562
  "±": "plus or minus",
563
563
  "∓": "minus or plus"
564
- }, Ge = {
564
+ }, Ke = {
565
565
  "(": "open parenthesis",
566
566
  "[": "open bracket",
567
567
  "{": "open brace",
568
568
  "⟨": "open angle bracket",
569
569
  "⌊": "open floor",
570
570
  "⌈": "open ceiling"
571
- }, B = {
571
+ }, z = {
572
572
  ")": "close parenthesis",
573
573
  "]": "close bracket",
574
574
  "}": "close brace",
575
575
  "⟩": "close angle bracket",
576
576
  "⌋": "close floor",
577
577
  "⌉": "close ceiling"
578
- }, V = {
578
+ }, B = {
579
579
  "!": "factorial",
580
580
  "%": "percent",
581
581
  "°": "degrees",
582
582
  "′": "prime",
583
583
  "″": "double prime"
584
- }, Ke = {
584
+ }, qe = {
585
585
  "+": "plus",
586
586
  "-": "minus",
587
587
  "−": "minus",
@@ -625,16 +625,16 @@ var We = /[⁡-⁤]/g, z = {
625
625
  ":": "colon",
626
626
  "|": "vertical bar",
627
627
  "‖": "double vertical bar",
628
- ...Ge,
629
- ...B,
630
- ...V
631
- }, qe = /* @__PURE__ */ new Set(["|", "‖"]), Je = /* @__PURE__ */ new Set([
628
+ ...Ke,
629
+ ...z,
630
+ ...B
631
+ }, Je = /* @__PURE__ */ new Set(["|", "‖"]), Ye = /* @__PURE__ */ new Set([
632
632
  "∑",
633
633
  "∏",
634
634
  "∫",
635
635
  "∪",
636
636
  "∩"
637
- ]), Ye = {
637
+ ]), Xe = {
638
638
  α: "alpha",
639
639
  β: "beta",
640
640
  γ: "gamma",
@@ -661,7 +661,7 @@ var We = /[⁡-⁤]/g, z = {
661
661
  cot: "cotangent",
662
662
  ln: "natural log",
663
663
  lim: "limit"
664
- }, Xe = {
664
+ }, Ze = {
665
665
  "¯": "bar",
666
666
  "‾": "bar",
667
667
  "―": "bar",
@@ -672,139 +672,139 @@ var We = /[⁡-⁤]/g, z = {
672
672
  "→": "vector",
673
673
  "⃗": "vector",
674
674
  "˙": "dot"
675
- }, H = (e) => (e.textContent ?? "").replace(We, "").replace(/\s+/g, " ").trim(), U = (e) => e.replace(/\s+/g, " ").trim(), W = (e) => [...e.children];
676
- function G(e) {
675
+ }, V = (e) => (e.textContent ?? "").replace(Ge, "").replace(/\s+/g, " ").trim(), H = (e) => e.replace(/\s+/g, " ").trim(), U = (e) => [...e.children];
676
+ function W(e) {
677
677
  return !e || [
678
678
  "mn",
679
679
  "mi",
680
680
  "mtext",
681
681
  "mo"
682
- ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? G(e.children[0]) : !1;
682
+ ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? W(e.children[0]) : !1;
683
683
  }
684
- function Ze(e) {
685
- let t = e ? H(e) : "";
684
+ function Qe(e) {
685
+ let t = e ? V(e) : "";
686
686
  return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
687
687
  }
688
- function Qe(e) {
688
+ function $e(e) {
689
689
  return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
690
690
  1: "st",
691
691
  2: "nd",
692
692
  3: "rd"
693
693
  }[e % 10] ?? "th"}`;
694
694
  }
695
- function $e(e) {
696
- return Ye[e] ?? e;
695
+ function et(e) {
696
+ return Xe[e] ?? e;
697
697
  }
698
- function K(e) {
699
- return Ke[e] ?? e;
698
+ function G(e) {
699
+ return qe[e] ?? e;
700
700
  }
701
- function q(e) {
701
+ function K(e) {
702
702
  let t = [], n = !1;
703
703
  for (let r of e) {
704
704
  if (r.localName !== "mo") {
705
- t.push(J(r)), n = !0;
705
+ t.push(q(r)), n = !0;
706
706
  continue;
707
707
  }
708
- let e = H(r);
709
- e && (!n && z[e] ? t.push(z[e]) : e in V ? t.push(V[e]) : (t.push(K(e)), n = e in B || qe.has(e) && n));
708
+ let e = V(r);
709
+ e && (!n && R[e] ? t.push(R[e]) : e in B ? t.push(B[e]) : (t.push(G(e)), n = e in z || Je.has(e) && n));
710
710
  }
711
711
  return t.filter(Boolean).join(" ");
712
712
  }
713
- function et(e) {
714
- let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(H(e)), a = n.slice(0, -1);
715
- if (a.length && i(t) && i(r) && H(t) === H(r) && !a.some(i)) {
716
- let e = U(q(a));
717
- return H(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
713
+ function tt(e) {
714
+ let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(V(e)), a = n.slice(0, -1);
715
+ if (a.length && i(t) && i(r) && V(t) === V(r) && !a.some(i)) {
716
+ let e = H(K(a));
717
+ return V(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
718
718
  }
719
- return q(e);
719
+ return K(e);
720
720
  }
721
- function tt(e, t) {
722
- let n = e ? J(e) : "", r = t ? J(t) : "";
723
- return G(e) && G(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
721
+ function nt(e, t) {
722
+ let n = e ? q(e) : "", r = t ? q(t) : "";
723
+ return W(e) && W(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
724
724
  }
725
- function nt(e, t, n) {
725
+ function rt(e, t, n) {
726
726
  return n ? `${t} of ${e}` : `${t} of ${e} end root`;
727
727
  }
728
- function rt(e, t) {
729
- let n = t ? H(t) : "";
730
- if (t && G(t)) {
728
+ function it(e, t) {
729
+ let n = t ? V(t) : "";
730
+ if (t && W(t)) {
731
731
  if (n === "2") return `${e} squared`;
732
732
  if (n === "3") return `${e} cubed`;
733
- if (n in V) return `${e} ${V[n]}`;
733
+ if (n in B) return `${e} ${B[n]}`;
734
734
  }
735
- let r = t ? J(t) : "";
736
- return G(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
735
+ let r = t ? q(t) : "";
736
+ return W(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
737
737
  }
738
- function it(e, t) {
739
- let n = t ? J(t) : "";
740
- return G(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
741
- }
742
- function at(e, t, n) {
743
- let r = H(e);
744
- if (r === "lim") return `limit as ${t ? J(t) : ""} of`;
745
- if (!Je.has(r)) return;
746
- let i = t ? `from ${J(t)}` : "", a = n ? `to ${J(n)}` : "";
747
- return `${K(r)} ${i} ${a} of`;
748
- }
749
- function ot(e) {
750
- let t = W(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => W(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) => U(q(W(e)))).join(", ")}`);
751
- return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
738
+ function at(e, t) {
739
+ let n = t ? q(t) : "";
740
+ return W(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
741
+ }
742
+ function ot(e, t, n) {
743
+ let r = V(e);
744
+ if (r === "lim") return `limit as ${t ? q(t) : ""} of`;
745
+ if (!Ye.has(r)) return;
746
+ let i = t ? `from ${q(t)}` : "", a = n ? `to ${q(n)}` : "";
747
+ return `${G(r)} ${i} ${a} of`;
752
748
  }
753
749
  function st(e) {
754
- let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = W(e).map((e, t, n) => t < n.length - 1 ? `${J(e)} ${K(r[Math.min(t, r.length - 1)] ?? ",")}` : J(e));
750
+ let t = U(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => U(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) => H(K(U(e)))).join(", ")}`);
751
+ return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
752
+ }
753
+ function ct(e) {
754
+ let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = U(e).map((e, t, n) => t < n.length - 1 ? `${q(e)} ${G(r[Math.min(t, r.length - 1)] ?? ",")}` : q(e));
755
755
  return [
756
- K(t),
756
+ G(t),
757
757
  ...i,
758
- K(n)
758
+ G(n)
759
759
  ].filter(Boolean).join(" ");
760
760
  }
761
- function J(e) {
762
- let t = W(e);
761
+ function q(e) {
762
+ let t = U(e);
763
763
  switch (e.localName) {
764
- case "mi": return $e(H(e));
764
+ case "mi": return et(V(e));
765
765
  case "mn":
766
766
  case "mtext":
767
- case "ms": return H(e);
768
- case "mo": return K(H(e));
767
+ case "ms": return V(e);
768
+ case "mo": return G(V(e));
769
769
  case "mspace":
770
770
  case "mphantom":
771
771
  case "annotation":
772
772
  case "annotation-xml": return "";
773
- case "semantics": return t[0] ? J(t[0]) : "";
774
- case "mfrac": return tt(t[0], t[1]);
775
- case "msqrt": return nt(U(q(t)), "square root", t.length === 1 && G(t[0]));
773
+ case "semantics": return t[0] ? q(t[0]) : "";
774
+ case "mfrac": return nt(t[0], t[1]);
775
+ case "msqrt": return rt(H(K(t)), "square root", t.length === 1 && W(t[0]));
776
776
  case "mroot": {
777
- let e = Ze(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${Qe(e)} root` : `root with index ${t[1] ? J(t[1]) : ""}`;
778
- return nt(t[0] ? J(t[0]) : "", n, G(t[0]));
777
+ let e = Qe(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${$e(e)} root` : `root with index ${t[1] ? q(t[1]) : ""}`;
778
+ return rt(t[0] ? q(t[0]) : "", n, W(t[0]));
779
779
  }
780
- case "msup": return rt(t[0] ? J(t[0]) : "", t[1]);
781
- case "msub": return it(t[0] ? J(t[0]) : "", t[1]);
782
- case "msubsup": return (t[0] ? at(t[0], t[1], t[2]) : void 0) || rt(it(t[0] ? J(t[0]) : "", t[1]), t[2]);
780
+ case "msup": return it(t[0] ? q(t[0]) : "", t[1]);
781
+ case "msub": return at(t[0] ? q(t[0]) : "", t[1]);
782
+ case "msubsup": return (t[0] ? ot(t[0], t[1], t[2]) : void 0) || it(at(t[0] ? q(t[0]) : "", t[1]), t[2]);
783
783
  case "munder":
784
784
  case "mover":
785
785
  case "munderover": {
786
- 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 ? at(n, a, o) : void 0;
786
+ 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 ? ot(n, a, o) : void 0;
787
787
  if (s) return s;
788
- let c = n ? J(n) : "", l = e.localName === "mover" && r ? Xe[H(r)] : void 0;
788
+ let c = n ? q(n) : "", l = e.localName === "mover" && r ? Ze[V(r)] : void 0;
789
789
  return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
790
790
  c,
791
- a ? `with ${J(a)} below` : "",
792
- o ? `with ${J(o)} above` : ""
791
+ a ? `with ${q(a)} below` : "",
792
+ o ? `with ${q(o)} above` : ""
793
793
  ].filter(Boolean).join(" ");
794
794
  }
795
- case "mfenced": return st(e);
796
- case "mtable": return ot(e);
795
+ case "mfenced": return ct(e);
796
+ case "mtable": return st(e);
797
797
  case "mrow":
798
- case "math": return et(t);
799
- default: return t.length ? q(t) : H(e);
798
+ case "math": return tt(t);
799
+ default: return t.length ? K(t) : V(e);
800
800
  }
801
801
  }
802
- function ct(e) {
803
- return U(J(e));
802
+ function lt(e) {
803
+ return H(q(e));
804
804
  }
805
805
  //#endregion
806
806
  //#region src/math-name.ts
807
- var lt = [
807
+ var ut = [
808
808
  "a[href]",
809
809
  "button",
810
810
  "label",
@@ -824,39 +824,39 @@ var lt = [
824
824
  "treeitem"
825
825
  ].map((e) => `[role="${e}"]`)
826
826
  ].join(", ");
827
- function ut(e) {
828
- if (e.hasAttribute("aria-label") || !e.closest(lt)) return;
829
- let t = e.querySelector("math"), n = t ? ct(t) : "";
827
+ function dt(e) {
828
+ if (e.hasAttribute("aria-label") || !e.closest(ut)) return;
829
+ let t = e.querySelector("math"), n = t ? lt(t) : "";
830
830
  n && e.setAttribute("aria-label", n);
831
831
  }
832
- function Y(e) {
833
- for (let t of e.querySelectorAll("mjx-container")) ut(t);
832
+ function J(e) {
833
+ for (let t of e.querySelectorAll("mjx-container")) dt(t);
834
834
  }
835
835
  //#endregion
836
836
  //#region src/speech-worker.ts
837
- var dt = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
838
- function ft() {
837
+ var ft = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
838
+ function pt() {
839
839
  let e = globalThis;
840
- e[dt] || (e[dt] = !0, console.warn(`[math-rendering] MathJax's speech worker did not start, so speech, braille and the explorer are off. A content security policy must allow blob: workers, and scripts and fetches from the asset root. See ${t}`));
840
+ e[ft] || (e[ft] = !0, console.warn(`[math-rendering] MathJax's speech worker did not start, so speech, braille and the explorer are off. A content security policy must allow blob: workers, and scripts and fetches from the asset root. See ${t}`));
841
841
  }
842
- function pt(e) {
842
+ function mt(e) {
843
843
  let t = e.webworker;
844
844
  if (!t || t.ready) return;
845
845
  e.options ??= {};
846
846
  let n = e.options;
847
- n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(), ft();
847
+ n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(), pt();
848
848
  }
849
- function mt(e) {
849
+ function ht(e) {
850
850
  let t = e?.adaptor, n = t?.createWorker;
851
851
  !e || !t || !n || (t.createWorker = async (r, i) => {
852
852
  let a = await n.call(t, r, i);
853
- return a.addEventListener("error", () => pt(e), { once: !0 }), a;
853
+ return a.addEventListener("error", () => mt(e), { once: !0 }), a;
854
854
  });
855
855
  }
856
856
  `${i}`;
857
857
  //#endregion
858
- //#region src/adapter.ts
859
- var ht = {
858
+ //#region src/tex-dialect.ts
859
+ var gt = {
860
860
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
861
861
  overarc: "\\overparen",
862
862
  napprox: "\\not\\approx",
@@ -864,64 +864,64 @@ var ht = {
864
864
  abs: ["\\left|#1\\right|", 1],
865
865
  perpendicular: "\\perp",
866
866
  divide: "\\div"
867
- }, gt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", _t = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, vt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, yt = /\\embed\{newLine\}\[\]/g, bt = [
867
+ }, _t = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, vt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, yt = /\\embed\{newLine\}\[\]/g, bt = [
868
868
  ["$$", "$$"],
869
869
  ["$", "$"],
870
870
  ["\\[", "\\]"],
871
871
  ["\\(", "\\)"]
872
- ], xt = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), St = "MJX-CHTML-styles", Ct = "PIE-MJX-SVG-styles", X = "PIE-MathJax-Menu-Settings", wt = { "mjx-container[overflow=\"linebreak\"][display]": {
872
+ ];
873
+ function xt(e) {
874
+ for (let [t, n] of bt) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
875
+ return e;
876
+ }
877
+ function St(e) {
878
+ return `\\(${xt(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e)}\\)`.replace(yt, "\\newline ");
879
+ }
880
+ var Ct = "mathjax_ignore", wt = "mathjax_process", Tt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", Et = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Dt = "MJX-CHTML-styles", Ot = "PIE-MJX-SVG-styles", Y = "PIE-MathJax-Menu-Settings", kt = { "mjx-container[overflow=\"linebreak\"][display]": {
873
881
  overflow: "auto clip",
874
882
  "min-width": "initial !important"
875
- } }, Tt = 200, Et = 201, Dt = 202;
876
- function Z(e) {
883
+ } }, At = 200, jt = 201, Mt = 202;
884
+ function X(e) {
877
885
  let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
878
886
  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");
879
887
  }
880
- function Ot(e) {
881
- for (let [t, n] of bt) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
882
- return e;
883
- }
884
- function kt(e) {
885
- return Ot(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
886
- }
887
- var At = "mathjax_ignore", jt = "mathjax_process";
888
- function Mt(e, t) {
889
- let n = e.closest(`.${At}, .${jt}`);
890
- return n !== null && t.contains(n) && !n.classList.contains(jt);
888
+ function Nt(e, t) {
889
+ let n = e.closest(`.${Ct}, .${wt}`);
890
+ return n !== null && t.contains(n) && !n.classList.contains("mathjax_process");
891
891
  }
892
- function Nt(e) {
892
+ function Pt(e) {
893
893
  for (let t of e.querySelectorAll("[data-latex]")) {
894
- if (t.dataset.mathHandled || t.closest("mjx-container") || Mt(t, e)) continue;
894
+ if (t.dataset.mathHandled || t.closest("mjx-container") || Nt(t, e)) continue;
895
895
  let n = t.textContent;
896
- n && (t.textContent = `\\(${kt(n)}\\)`.replace(yt, "\\newline "), t.dataset.mathHandled = "true");
896
+ n && (t.textContent = St(n), t.dataset.mathHandled = "true");
897
897
  }
898
898
  }
899
- function Pt(e) {
899
+ function Ft(e) {
900
900
  for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
901
901
  }
902
- function Ft(e, t) {
902
+ function It(e, t) {
903
903
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
904
904
  return (t ? vt : _t).test(e.textContent ?? "");
905
905
  }
906
- function It(e) {
906
+ function Lt(e) {
907
907
  return new Promise((t, n) => {
908
908
  let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = e, s = f(e, import.meta.url), l = c(), u = {
909
909
  loader: {
910
910
  load: i ? ["a11y/assistive-mml"] : [],
911
911
  failed: (e) => n(e),
912
912
  "output/svg": { ready: (e) => {
913
- let t = x();
914
- return Lt(t) && Rt(t), e;
913
+ let t = b();
914
+ return Rt(t) && zt(t), e;
915
915
  } }
916
916
  },
917
917
  startup: {
918
918
  typeset: !1,
919
919
  ready: () => {
920
- let e = x(), r = e?.startup, i = Lt(e);
921
- i && (Rt(e), zt(e, s.speechLocales), p(e?._?.a11y?.sre_ts?.locales, s.speechLocales)), r?.defaultReady?.(), i && (Bt(r?.document), Vt(r?.document), r?.document?.addStyles?.(wt), mt(r?.document)), Promise.resolve(r?.promise).then(() => t(), n);
920
+ let e = b(), r = e?.startup, i = Rt(e);
921
+ i && (zt(e), Bt(e, s.speechLocales), p(e?._?.a11y?.sre_ts?.locales, s.speechLocales)), r?.defaultReady?.(), i && (Vt(r?.document), Ht(r?.document), r?.document?.addStyles?.(kt), ht(r?.document)), Promise.resolve(r?.promise).then(() => t(), n);
922
922
  }
923
923
  },
924
- tex: { macros: { ...ht } },
924
+ tex: { macros: { ...gt } },
925
925
  output: { displayOverflow: "linebreak" },
926
926
  options: {
927
927
  enableMenu: i,
@@ -933,9 +933,9 @@ function It(e) {
933
933
  a11y: { inTabOrder: l }
934
934
  }
935
935
  };
936
- r && u.tex && (console.warn(gt), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), a || (u.chtml = { fontURL: "" });
936
+ r && u.tex && (console.warn(Tt), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), a || (u.chtml = { fontURL: "" });
937
937
  let d = m(s.speechLocales);
938
- d && u.options && (u.options.sre = { locale: d }), ie(u, {
938
+ d && u.options && (u.options.sre = { locale: d }), ae(u, {
939
939
  ...s,
940
940
  srcUrl: o
941
941
  }).then((e) => {
@@ -943,131 +943,131 @@ function It(e) {
943
943
  }, n);
944
944
  });
945
945
  }
946
- function Lt(e) {
946
+ function Rt(e) {
947
947
  return !!e?.version?.startsWith("4.");
948
948
  }
949
- function Rt(e) {
949
+ function zt(e) {
950
950
  let t = e?._?.output, n = t?.chtml_ts?.CHTML;
951
- n && (n.STYLESHEETID = oe);
951
+ n && (n.STYLESHEETID = x);
952
952
  let r = t?.svg_ts?.SVG;
953
- r && (r.STYLESHEETID = Ct);
953
+ r && (r.STYLESHEETID = Ot);
954
954
  }
955
- function zt(e, t) {
955
+ function Bt(e, t) {
956
956
  let n = e?._?.ui?.menu?.Menu?.Menu;
957
957
  if (n) {
958
- n.MENU_STORAGE = X;
958
+ n.MENU_STORAGE = Y;
959
959
  try {
960
- let e = localStorage.getItem(X);
960
+ let e = localStorage.getItem(Y);
961
961
  if (!e) return;
962
962
  let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
963
963
  if (n === void 0 && a) return;
964
- a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(X, JSON.stringify(i)) : localStorage.removeItem(X);
964
+ a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(Y, JSON.stringify(i)) : localStorage.removeItem(Y);
965
965
  } catch {}
966
966
  }
967
967
  }
968
- function Bt(e) {
968
+ function Vt(e) {
969
969
  if (!e) return;
970
970
  let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
971
971
  let n = e.typesetRoot;
972
- !n || t.has(n) || (Z(n), t.add(n));
972
+ !n || t.has(n) || (X(n), t.add(n));
973
973
  };
974
- e.addRenderAction?.("pie-strip-latex", Et, (e) => {
974
+ e.addRenderAction?.("pie-strip-latex", jt, (e) => {
975
975
  for (let t of e.math ?? []) n(t);
976
976
  return !1;
977
977
  }, (e) => {
978
978
  let t = e.typesetRoot;
979
- return t && Z(t), !1;
979
+ return t && X(t), !1;
980
980
  });
981
981
  let r = e.outputJax?.chtmlStyles;
982
- r?.id === St && (r.id = oe), Wt();
982
+ r?.id === Dt && (r.id = x), Gt();
983
983
  }
984
- function Vt(e) {
984
+ function Ht(e) {
985
985
  let t = (e) => {
986
- e.typesetRoot && ut(e.typesetRoot);
986
+ e.typesetRoot && dt(e.typesetRoot);
987
987
  };
988
- e?.addRenderAction?.("pie-name-math", Dt, (e) => {
988
+ e?.addRenderAction?.("pie-name-math", Mt, (e) => {
989
989
  for (let n of e.math ?? []) t(n);
990
990
  return !1;
991
991
  }, (e) => (t(e), !1));
992
992
  }
993
- function Ht(e) {
993
+ function Ut(e) {
994
994
  return e instanceof HTMLStyleElement && se.includes(e.id);
995
995
  }
996
- function Ut(e) {
997
- te("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
996
+ function Wt(e) {
997
+ ne("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
998
998
  }
999
- function Wt() {
1000
- let e = document.head, t = [...e.children].find(Ht);
999
+ function Gt() {
1000
+ let e = document.head, t = [...e.children].find(Ut);
1001
1001
  if (t) {
1002
- Ut(t);
1002
+ Wt(t);
1003
1003
  return;
1004
1004
  }
1005
1005
  let n = new MutationObserver((e) => {
1006
1006
  for (let t of e) {
1007
- let e = [...t.addedNodes].find(Ht);
1007
+ let e = [...t.addedNodes].find(Ut);
1008
1008
  if (e) {
1009
- Ut(e), n.disconnect();
1009
+ Wt(e), n.disconnect();
1010
1010
  return;
1011
1011
  }
1012
1012
  }
1013
1013
  });
1014
1014
  n.observe(e, { childList: !0 });
1015
1015
  }
1016
- function Gt(e) {
1016
+ function Kt(e) {
1017
1017
  let t = e?.math;
1018
1018
  if (!t?.remove) return;
1019
- let n = [...t].filter((e) => (e.state?.() ?? 0) >= Tt && e.typesetRoot?.isConnected === !1);
1019
+ let n = [...t].filter((e) => (e.state?.() ?? 0) >= At && e.typesetRoot?.isConnected === !1);
1020
1020
  if (n.length !== 0) {
1021
1021
  for (let e of [...n].reverse()) e.clear?.();
1022
1022
  t.remove(...n);
1023
1023
  }
1024
1024
  }
1025
- function Kt(e) {
1025
+ function qt(e) {
1026
1026
  return new Promise((t, n) => {
1027
1027
  let r = e.startup ?? {};
1028
1028
  e.startup = r;
1029
1029
  let i = r.ready;
1030
1030
  r.ready = () => {
1031
- let e = x()?.startup;
1031
+ let e = b()?.startup;
1032
1032
  i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
1033
1033
  };
1034
1034
  });
1035
1035
  }
1036
- function qt(e) {
1037
- let t = x();
1038
- return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : Kt(t) : It(e);
1039
- }
1040
1036
  function Jt(e) {
1041
- return qt(e).then(() => {
1042
- let e = x();
1037
+ let t = b();
1038
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : qt(t) : Lt(e);
1039
+ }
1040
+ function Yt(e) {
1041
+ return Jt(e).then(() => {
1042
+ let e = b();
1043
1043
  e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
1044
1044
  });
1045
1045
  }
1046
- function Yt(e) {
1047
- let t = ae, n = t[xt];
1048
- return n || (n = Jt(e), t[xt] = n), n;
1046
+ function Xt(e) {
1047
+ let t = oe, n = t[Et];
1048
+ return n || (n = Yt(e), t[Et] = n), n;
1049
1049
  }
1050
- function Xt(e = {}) {
1050
+ function Z(e = {}) {
1051
1051
  let t = e.useSingleDollar ?? !1;
1052
1052
  return async (n) => {
1053
1053
  if (typeof window > "u") return;
1054
1054
  let r = ce();
1055
- r && te("mathjax-3-global", `window.MathJax is MathJax ${r}`), Nt(n), fe(n), Pt(n), Re(n);
1056
- let i = Yt(e);
1057
- if (!Ft(n, t)) {
1055
+ r && ne("mathjax-3-global", `window.MathJax is MathJax ${r}`), Pt(n), de(n), Ft(n), ze(n);
1056
+ let i = Xt(e);
1057
+ if (!It(n, t)) {
1058
1058
  i.catch(() => {});
1059
1059
  return;
1060
1060
  }
1061
1061
  await i;
1062
- let a = x();
1062
+ let a = b();
1063
1063
  if (await a?.startup?.promise, typeof a?.typesetPromise == "function") {
1064
- Ue(), Gt(a.startup?.document);
1064
+ We(), Kt(a.startup?.document);
1065
1065
  try {
1066
1066
  await a.typesetPromise([n]);
1067
1067
  } catch (e) {
1068
1068
  throw a.typesetClear?.([n]), e;
1069
1069
  }
1070
- Z(n), Y(n);
1070
+ X(n), J(n);
1071
1071
  }
1072
1072
  };
1073
1073
  }
@@ -1081,7 +1081,7 @@ function an() {
1081
1081
  return !!window[$t]?.opts?.useSingleDollar;
1082
1082
  }
1083
1083
  function on() {
1084
- return rn ||= Xt({ useSingleDollar: an() }), rn;
1084
+ return rn ||= Z({ useSingleDollar: an() }), rn;
1085
1085
  }
1086
1086
  function Q() {
1087
1087
  if (typeof window > "u") return null;
@@ -1118,12 +1118,12 @@ var $ = async (e) => {
1118
1118
  let t = typeof e == "string", n;
1119
1119
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
1120
1120
  let r = Q(), i = r || t ? null : await ln(n);
1121
- return r ? (await r.renderMath?.(n), Y(n)) : i && i !== $ ? (await i(n), Y(n)) : await on()(n), t ? n.innerHTML : void 0;
1121
+ return r ? (await r.renderMath?.(n), J(n)) : i && i !== $ ? (await i(n), J(n)) : await on()(n), t ? n.innerHTML : void 0;
1122
1122
  }, un = (e, t) => {
1123
1123
  let n = Q()?.wrapMath?.(e, t);
1124
1124
  if (n != null) return n;
1125
1125
  let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
1126
- return `${r}${Ot(e)}${i}`;
1126
+ return `${r}${xt(e)}${i}`;
1127
1127
  }, dn = (e) => {
1128
1128
  let t = e.trim();
1129
1129
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
@@ -1153,4 +1153,4 @@ var $ = async (e) => {
1153
1153
  } : { unwrapped: t };
1154
1154
  }, fn = (e) => Q()?.mmlToLatex?.(e) ?? e;
1155
1155
  //#endregion
1156
- export { ee as MATHJAX_CONFLICT_EVENT, h as NO_ASSET_ROOT_EVENT, y as UNSUPPORTED_PAGE_DOCS_URL, Xt as createMathjaxRenderer, Zt as getMathjaxCssUrls, fn as mmlToLatex, $ as renderMath, ct as speakMathml, dn as unWrapMath, un as wrapMath };
1156
+ export { ee as MATHJAX_CONFLICT_EVENT, h as NO_ASSET_ROOT_EVENT, y as UNSUPPORTED_PAGE_DOCS_URL, Z as createMathjaxRenderer, Zt as getMathjaxCssUrls, fn as mmlToLatex, $ as renderMath, lt as speakMathml, dn as unWrapMath, un as wrapMath };