From 27fde3e4090f27b278338cd43449a2148fa9e854 Mon Sep 17 00:00:00 2001
From: PathGao <42336971+PathGao@users.noreply.github.com>
Date: Wed, 11 Nov 2026 16:26:22 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F=E5=92=8C=E6=91=98?=
=?UTF-8?q?=E8=AF=BB=E8=AE=B0=E5=BD=95=EF=BC=9AAI=20=E5=9B=9E=E7=AD=94?=
=?UTF-8?q?=E9=87=8C=E7=9A=84=20LaTeX=20=E5=85=AC=E5=BC=8F=E6=B8=B2?=
=?UTF-8?q?=E6=9F=93=E6=88=90=E6=95=B0=E5=AD=A6=E5=BC=8F=20(#462)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CONTRIBUTING.md | 2 +-
THIRD_PARTY_NOTICES.md | 30 +++
extension/history/history.css | 1 +
extension/history/history.html | 2 +
extension/messages.selftest.js | 2 +-
extension/note.js | 31 ++-
extension/note.selftest.js | 23 ++
extension/sidepanel.css | 6 +
extension/sidepanel.html | 2 +
extension/vendor/Temml-Local.css | 372 +++++++++++++++++++++++++++++++
extension/vendor/Temml.woff2 | Bin 0 -> 9404 bytes
extension/vendor/temml.min.js | 1 +
12 files changed, 467 insertions(+), 5 deletions(-)
create mode 100644 extension/vendor/Temml-Local.css
create mode 100644 extension/vendor/Temml.woff2
create mode 100644 extension/vendor/temml.min.js
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index bda940c2..c0b261a2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,7 +41,7 @@ extension/
├── tokens.css 共享的颜色、字号、间距(含深色主题)
├── triage/ B站分拣台:收藏夹(fav-*.js,由 triage.js 启动,纯函数在 triage-core.js)、关注(follow.js,纯函数在 follow-core.js),后台接口 triage-bg.js、follow-bg.js
├── history/ 摘读记录页
-├── vendor/ 第三方代码:defuddle.js(网页正文提取,`scripts/update-defuddle.sh <版本>` 更新,要 bash)
+├── vendor/ 第三方代码:defuddle.js(网页正文提取,`scripts/update-defuddle.sh <版本>` 更新,要 bash);temml.min.js、Temml-Local.css、Temml.woff2(AI 回答里的 LaTeX 公式,来源和版本见 `THIRD_PARTY_NOTICES.md`)
├── dev-sidepanel/ 侧边栏的开发预览
└── dev/ 设置页的开发用假数据
```
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index bfc1534d..7611c493 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -76,3 +76,33 @@ The YouTube subtitle fetching approach follows [jdepoix/youtube-transcript-api](
## catppuccin/palette
The extension's status colors (ok, warn, danger) use the [Catppuccin](https://github.com/catppuccin/palette) palette (MIT, Copyright (c) 2021 Catppuccin): Mocha for dark mode, and Latte for light mode with its accents desaturated and darkened.
+
+## ronkok/Temml
+
+`extension/vendor/temml.min.js`, `Temml-Local.css` and `Temml.woff2` are the files of the same names in `dist/` of [Temml](https://github.com/ronkok/Temml), unmodified. The side panel and 摘读记录 use them to show the LaTeX in an AI answer as MathML. To update, copy the three files from the npm package and change the version below.
+
+Version: 0.14.0
+
+```
+The MIT License (MIT)
+
+Copyright (c) 2020 Ron Kok
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+```
diff --git a/extension/history/history.css b/extension/history/history.css
index 33412be8..320424d7 100644
--- a/extension/history/history.css
+++ b/extension/history/history.css
@@ -61,6 +61,7 @@ summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-xs); }
.turn-a :is(p, ul, ol, pre, table) { margin: var(--space-1) 0; }
.turn-a :is(h3, h4, h5) { margin: var(--space-2) 0 var(--space-1); font-size: var(--fs-sm); color: var(--text); }
.turn-a :is(ul, ol) { padding-left: 1.4em; }
+.turn-a .md-math-block { display: block; overflow-x: auto; }
.turn-a code { font-family: var(--font-mono); }
.turn-a pre { overflow-x: auto; padding: var(--space-2); border-radius: var(--radius-sm); background: var(--surface-muted); }
.turn-a table { border-collapse: collapse; }
diff --git a/extension/history/history.html b/extension/history/history.html
index cd4b7416..65278f4d 100644
--- a/extension/history/history.html
+++ b/extension/history/history.html
@@ -5,6 +5,7 @@
MoonDigest · 摘读记录
+
@@ -118,6 +119,7 @@ 请求和 AI 参数
+
diff --git a/extension/messages.selftest.js b/extension/messages.selftest.js
index 2e52bf59..951f513e 100644
--- a/extension/messages.selftest.js
+++ b/extension/messages.selftest.js
@@ -16,7 +16,7 @@ const vm = require("vm");
const root = __dirname;
const read = (f) => fs.readFileSync(path.join(root, f), "utf8");
-const files = require("./page-sources.selftest.js").walk(".", (d) => /^dev/.test(d)).filter((f) => f.endsWith(".js") && !f.endsWith(".selftest.js") && f !== "messages.js");
+const files = require("./page-sources.selftest.js").walk(".", (d) => /^(dev|vendor$)/.test(d)).filter((f) => f.endsWith(".js") && !f.endsWith(".selftest.js") && f !== "messages.js");
// Comments out, strings kept (field names and types live in them), same offsets.
const blank = (s) => s.replace(/\/\*[\s\S]*?\*\/|(^|[^:"'`\\])\/\/.*$/gm, (m, pre = "") => pre + m.slice(pre.length).replace(/[^\n]/g, " "));
const src = Object.fromEntries(files.map((f) => [f, blank(read(f))]));
diff --git a/extension/note.js b/extension/note.js
index cf18c9d3..fb85ac5c 100644
--- a/extension/note.js
+++ b/extension/note.js
@@ -854,10 +854,33 @@
.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, (c) => `\\x${c.charCodeAt(0).toString(16).padStart(2, "0")}`);
}
+ // LaTeX in an answer: $$..$$ and \[..\] are display math, \(..\) and $..$ inline. A lone $ is math only when it hugs
+ // its content and no digit follows the closing one, so "$5 和 $10" stays text. Code alternatives match first and are
+ // kept, a fence still streaming included. Display math ends at a blank line, so a stray \[ cannot swallow the answer.
+ const MATH_OR_CODE = /```[\s\S]*?(?:```|$)|`[^`\n]+`|\$\$((?:(?!\n[ \t]*\n)[\s\S])+?)\$\$|\\\[((?:(?!\n[ \t]*\n)[\s\S])+?)\\\]|\\\((.+?)\\\)|(? {
+ const tex = dollars ?? bracket ?? paren ?? dollar;
+ if (tex === undefined || !temml) {
+ return all;
+ }
+ const displayMode = dollars !== undefined || bracket !== undefined;
+ let html;
+ try {
+ html = temml.renderToString(tex, { displayMode, throwOnError: false });
+ } catch {
+ // throwOnError covers parse errors only: a runaway macro overflows the stack, and the answer must still show.
+ return all;
+ }
+ return `\u0003${math.push(displayMode ? `${html} ` : html) - 1}\u0003`;
+ });
+ let escaped = escapeHtml(source);
const codeBlocks = [];
escaped = escaped.replace(/```([\s\S]*?)```/g, (_, code) => {
// The fence's first line is its language (```python), not code.
@@ -1002,7 +1025,8 @@
flushPara();
closeList();
// A code block that shares its line with text is shown inline.
- return out.join("").replace(/\u0001MDG_CODE_(\d+)\u0001/g, (_, n) => `${codeBlocks[Number(n)]}`);
+ return out.join("").replace(/\u0001MDG_CODE_(\d+)\u0001/g, (_, n) => `${codeBlocks[Number(n)]}`)
+ .replace(/\u0003(\d+)\u0003/g, (_, n) => math[Number(n)]);
}
// Code spans are set aside first, so the bold, italic and link rules never reach inside them.
@@ -1013,7 +1037,8 @@
.replace(/\*\*([^*\n]+)\*\*/g, (_, c) => `${c} `)
.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g, (_, pre, c) => `${pre}${c} `)
.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_, t, u) => {
- const safeUrl = /^(https?:|mailto:|#)/i.test(u) ? u : "#";
+ // A formula's placeholder would put its HTML inside the attribute.
+ const safeUrl = /^(https?:|mailto:|#)/i.test(u) && !u.includes("\u0003") ? u : "#";
return `${t} `;
})
.replace(/\u0002(\d+)\u0002/g, (_, n) => spans[Number(n)]);
diff --git a/extension/note.selftest.js b/extension/note.selftest.js
index 0cf9284f..7d224168 100644
--- a/extension/note.selftest.js
+++ b/extension/note.selftest.js
@@ -506,6 +506,29 @@ const XSS = [" ", `"'>`];
const assertInert = (html, where) => assert.ok(!/ /i.test(html) && /<|</.test(html), `${where}: ${html}`);
for (const bad of XSS) assertInert(N.renderMarkdown(`${bad}\n\n- **${bad}**\n\n\`${bad}\``), "renderMarkdown");
assert.ok(N.renderMarkdown("[x](javascript:alert(1))").includes('href="#"'), "only http, mailto and # links");
+// #462: LaTeX renders as MathML where Temml is loaded (the side panel and 摘读记录), and stays text elsewhere.
+assert.strictEqual(N.renderMarkdown("\\(x\\) 和 $y$"), "\\(x\\) 和 $y$
", "no Temml, no math");
+{
+ const mctx = vm.createContext({ URL, URLSearchParams, console });
+ for (const f of ["common.js", "limits.js", "errors.js", "settings.js", "sites.js", "tag-core.js", "vendor/temml.min.js", "note.js"]) vm.runInContext(fs.readFileSync(path.join(__dirname, f), "utf8"), mctx);
+ const md = mctx.MdgNote.renderMarkdown;
+ const block = md("得到:\n\n\\[ \\begin{bmatrix} 1 & 3\\\\ 4 & 6 \\end{bmatrix} \\]\n\n$$a]*display="block"/g)?.length, 2, block);
+ assert.ok(block.includes("用 前 $"), "a formula that overflows Temml's stack stays text");
+ assert.ok(!md("```python\nx = '$a$'\ny = '\\(b\\)'\n").includes("code \\] here"), "display math stops at a blank line");
+ assert.ok(md("[x](https://a.com/$b$)").includes('0 plain", "a placeholder character in the answer is dropped");
+}
// 详情 › 笔记标签 shows the tags the note gets: none when the setting is cleared, plus the 分拣台 tags, from one function.
assert.deepStrictEqual([...N.noteTags({ userTags: ["学 习"] }, { tags: "" })], ["学_习"]);
assert.deepStrictEqual([...N.noteTags({}, { tags: "MoonDigest, a" })], ["MoonDigest", "a"]);
diff --git a/extension/sidepanel.css b/extension/sidepanel.css
index 907e3d28..1c3ba912 100644
--- a/extension/sidepanel.css
+++ b/extension/sidepanel.css
@@ -831,6 +831,12 @@ body:has(#spInput:not(:placeholder-shown)) .sp-summary-btn {
overflow-x: auto;
}
+/* A wide matrix scrolls inside the bubble. */
+.sp-msg-assistant .md-math-block {
+ display: block;
+ overflow-x: auto;
+}
+
.sp-msg-assistant pre code {
padding: 0;
background: transparent;
diff --git a/extension/sidepanel.html b/extension/sidepanel.html
index 545e2af3..ace8757d 100644
--- a/extension/sidepanel.html
+++ b/extension/sidepanel.html
@@ -5,6 +5,7 @@
MoonDigest · AI 侧边栏
+
@@ -110,6 +111,7 @@
+
diff --git a/extension/vendor/Temml-Local.css b/extension/vendor/Temml-Local.css
new file mode 100644
index 00000000..9be399b5
--- /dev/null
+++ b/extension/vendor/Temml-Local.css
@@ -0,0 +1,372 @@
+/*
+Temml.woff2 is a clone of KaTeX_Script-Regular, except that the code points
+have been changed from ASCII to Unicode Mathematical Alphanumeric Symbols Script capitals,
+Unicode range 1D49C to 1D4B5.
+*/
+
+@font-face {
+ font-family: 'Temml';
+ src: url('Temml.woff2') format('woff2');
+ font-weight: normal;
+ font-style: normal;
+}
+
+math {
+ font-family: "Cambria Math", 'STIXTwoMath-Regular', 'NotoSansMath-Regular', math;
+ font-style: normal;
+ font-weight: normal;
+ line-height: normal;
+ font-size-adjust: none;
+ text-indent: 0;
+ text-transform: none;
+ letter-spacing: normal;
+ word-wrap: normal;
+ direction: ltr;
+ /* Prevent Firefox from omitting the dot on i or j. */
+ font-feature-settings: "dtls" off;
+}
+
+math * {
+ border-color: currentColor;
+}
+
+/* display: block is necessary in Firefox and Safari.
+ * Not in Chromium, which recognizes display: "block math" written inline. */
+ math.tml-display {
+ display: block;
+ width: 100%;
+}
+
+*.mathcal {
+ /* NotoSans */
+ font-feature-settings: 'ss01';
+}
+
+math .mathscr {
+ font-family: "Temml";
+}
+
+mo.tml-prime {
+ font-family: Temml;
+}
+
+/* Cramped superscripts in WebKit */
+mfrac > :nth-child(2),
+msqrt,
+mover > :first-child {
+ math-shift: compact
+}
+
+.menclose {
+ display: inline-block;
+ position: relative;
+ padding: 0.5ex 0ex;
+}
+.tml-cancelto {
+ display: inline-block;
+ position: absolute;
+ top: 0;
+ left: 0;
+ padding: 0.5ex 0ex;
+ background-color: currentColor;
+ /* Use the SVG as an alpha mask (painted by background-color) */
+ -webkit-mask-image: url("data:image/svg+xml, ");
+ mask-image: url("data:image/svg+xml, ");
+ -webkit-mask-repeat: no-repeat;
+ mask-repeat: no-repeat;
+ -webkit-mask-size: 100% 100%;
+ mask-size: 100% 100%;
+ -webkit-mask-position: 0 0;
+ mask-position: 0 0;
+}
+
+@supports (-moz-appearance: none) {
+ /* \vec w/o italic correction for Firefox */
+ .tml-vec {
+ transform: scale(0.75)
+ }
+ /* Fix \cancelto in Firefox */
+ .ff-narrow {
+ width: 0em;
+ }
+ .ff-nudge-left {
+ margin-left: -0.2em;
+ }
+ /* Squash hidden mrows in \bordermatrix. Messes with centering, but necessary to squash. */
+ .ff-squash mtd {
+ display: block;
+ height: 0;
+ }
+}
+
+@supports (not (-moz-appearance: none)) {
+ /* Chromium and WebKit */
+ /* prime vertical alignment */
+ mo.tml-prime {
+ font-family: Temml;
+ }
+ /* Italic correction on superscripts */
+ .tml-sml-pad {
+ padding-left: 0.05em;
+ }
+ .tml-med-pad {
+ padding-left: 0.10em;
+ }
+ .tml-lrg-pad {
+ padding-left: 0.15em;
+ }
+}
+
+@supports (-webkit-backdrop-filter: blur(1px)) {
+ /* WebKit vertical & italic correction on accents */
+ .wbk-acc {
+ /* lower by x-height distance */
+ transform: translate(0em, 0.431em);
+ }
+ .wbk-sml {
+ transform: translate(0.07em, 0);
+ }
+ .wbk-sml-acc {
+ transform: translate(0.07em, 0.431em);
+ }
+ .wbk-sml-vec {
+ transform: scale(0.75) translate(0.07em, 0);
+ }
+ .wbk-med {
+ transform: translate(0.14em, 0);
+ }
+ .wbk-med-acc {
+ transform: translate(0.14em, 0.431em);
+ }
+ .wbk-med-vec {
+ transform: scale(0.75) translate(0.14em, 0);
+ }
+ .wbk-lrg {
+ transform: translate(0.21em, 0);
+ }
+ .wbk-lrg-acc {
+ transform: translate(0.21em, 0.431em);
+ }
+ .wbk-lrg-vec {
+ transform: scale(0.75) translate(0.21em, 0);
+ }
+}
+
+/* \cancel & \phase use background images. Get them to print. */
+menclose {
+ -webkit-print-color-adjust: exact; /* Chrome & Edge */
+ print-color-adjust: exact;
+}
+
+/* Array cell justification in Firefox & WebKit */
+.tml-right {
+ text-align: right;
+}
+.tml-left {
+ text-align: left;
+}
+
+/* For CD labels that grow to the left in Firefox and WebKit */
+.tml-shift-left { margin-left:-200% }
+
+/* Styles for Chromium only */
+@supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
+ /* Italic correction on accents */
+ .chr-sml {
+ transform: translate(0.07em, 0)
+ }
+ .chr-sml-vec {
+ transform: scale(0.75) translate(0.07em, 0)
+ }
+ .chr-med {
+ transform: translate(0.14em, 0)
+ }
+ .chr-med-vec {
+ transform: scale(0.75) translate(0.14em, 0)
+ }
+ .chr-lrg {
+ transform: translate(0.21em, 0)
+ }
+ .chr-lrg-vec {
+ transform: scale(0.75) translate(0.21em, 0)
+ }
+
+ /* For CD labels that grow to the left */
+ .tml-shift-left { margin-left:-100% }
+
+ /* MathML Core & Chromium do not support the MathML 3.0 element attributes. */
+ /* So use styles. */
+ menclose {
+ position: relative;
+ padding: 0.5ex 0ex;
+ }
+
+ .tml-overline {
+ padding: 0.1em 0 0 0;
+ border-top: 0.065em solid;
+ }
+
+ .tml-underline {
+ padding: 0 0 0.1em 0;
+ border-bottom: 0.065em solid;
+ }
+
+ .tml-cancel {
+ display: inline-block;
+ position: absolute;
+ left: 0.5px;
+ bottom: 0;
+ width: 100%;
+ height: 100%;
+ background-color: currentColor;
+ }
+ .upstrike {
+ clip-path: polygon(0.05em 100%, 0em calc(100% - 0.05em), calc(100% - 0.05em) 0em, 100% 0.05em);
+ }
+ .downstrike {
+ clip-path: polygon(0em 0.05em, 0.05em 0em, 100% calc(100% - 0.05em), calc(100% - 0.05em) 100%);
+ }
+ .sout {
+ clip-path: polygon(0em calc(55% + 0.0333em), 0em calc(55% - 0.0333em), 100% calc(55% - 0.0333em), 100% calc(55% + 0.0333em));
+ }
+ .tml-xcancel {
+ clip-path: polygon(0.05em 0em, 0em 0.05em, calc(50% - 0.05em) 50%, 0em calc(100% - 0.05em), 0.05em 100%, 50% calc(50% + 0.05em), calc(100% - 0.05em) 100%, 100% calc(100% - 0.05em), calc(50% + 0.05em) 50%, 100% 0.05em, calc(100% - 0.05em) 0%, 50% calc(50% - 0.05em));
+ }
+
+ .longdiv-top {
+ border-top: 0.067em solid;
+ padding: 0.1em 0.2em 0.2em 0.433em;
+ }
+ .longdiv-arc {
+ position: absolute;
+ top: 0;
+ bottom: 0.1em;
+ left: -0.4em;
+ width: 0.7em;
+ border: 0.067em solid;
+ transform: translateY(-0.067em);
+ border-radius: 70%;
+ clip-path: inset(0 0 0 0.4em);
+ box-sizing: border-box;}
+ .menclose {display: inline-block;
+ text-align: left;
+ position: relative;
+ }
+
+ .phasor-bottom {
+ border-bottom: 0.067em solid;
+ padding: 0.2em 0.2em 0.1em 0.6em;
+ }
+ .phasor-angle {
+ display: inline-block;
+ position: absolute;
+ left: 0.5px;
+ bottom: -0.04em;
+ height: 100%;
+ aspect-ratio: 0.5;
+ background-color: currentColor;
+ clip-path: polygon(0.05em 100%, 0em calc(100% - 0.05em), calc(100% - 0.05em) 0em, 100% 0.05em);
+ }
+
+ .tml-fbox {
+ padding: 3pt;
+ border: 1px solid;
+ }
+
+ .circle-pad {
+ padding: 0.267em;
+ }
+ .textcircle {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ right: 0;
+ left: 0;
+ border: 0.067em solid;
+ border-radius: 50%;
+ }
+
+ .actuarial {
+ padding: 0.03889em 0.03889em 0 0.03889em;
+ border-width: 0.08em 0.08em 0em 0em;
+ border-style: solid;
+ margin-right: 0.03889em;
+ }
+
+ /* Stretch \widetilde */
+ .tml-tilde-2 {
+ transform: scale(2.0, 1.1)
+ }
+ .tml-tilde-3 {
+ transform: scale(3.0, 1.1)
+ }
+ .tml-tilde-4 {
+ transform: scale(4.0, 1.1)
+ }
+ /* Stretch \widehat */
+ .tml-hat-1 {
+ transform: scale(1.9, 1.0)
+ }
+ .tml-hat-2 {
+ transform: scale(3.9, 1.0)
+ }
+ .tml-hat-3 {
+ transform: scale(5.8, 1.0)
+ }
+ .tml-hat-4 {
+ transform: scale(7.8, 1.0)
+ }
+
+ /* set array cell justification */
+ .tml-right {
+ text-align: -webkit-right;
+ }
+ .tml-left {
+ text-align: -webkit-left;
+ }
+}
+
+.special-fraction {
+ font-family: 'STIX TWO', 'Times New Roman', Times, Tinos, serif;
+}
+
+/* flex-wrap for line-breaking in Chromium */
+math {
+ display: inline-flex;
+ flex-wrap: wrap;
+ align-items: baseline;
+}
+math > mrow {
+ padding: 0.5ex 0ex;
+}
+
+/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
+/* We adjust for jot and small */
+mtable.tml-jot > mtr > mtd {
+ padding-top: 0.7ex;
+ padding-bottom: 0.7ex;
+}
+mtable.tml-small mtd {
+ padding-top: 0.35ex;
+ padding-bottom: 0.35ex;
+}
+
+/* Firefox */
+@-moz-document url-prefix() {
+ /* Avoid flex-wrap */
+ math { display: inline; }
+ math > mrow { padding: 0 }
+ /* Adjust Firefox spacing between array rows */
+ mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
+ mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
+}
+
+/* AMS environment auto-numbering via CSS counter. */
+.tml-eqn::before {
+ counter-increment: tmlEqnNo;
+ content: "(" counter(tmlEqnNo) ")";
+}
+
+body {
+ counter-reset: tmlEqnNo;
+}
diff --git a/extension/vendor/Temml.woff2 b/extension/vendor/Temml.woff2
new file mode 100644
index 0000000000000000000000000000000000000000..fccefda4b3a0d812687d62efff0d6a554347ddc8
GIT binary patch
literal 9404
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
Cd@~6E
literal 0
HcmV?d00001
diff --git a/extension/vendor/temml.min.js b/extension/vendor/temml.min.js
new file mode 100644
index 00000000..29ff11bc
--- /dev/null
+++ b/extension/vendor/temml.min.js
@@ -0,0 +1 @@
+var temml=function(){"use strict";class e{constructor(t,r){let n,s=" "+t;const o=r&&r.loc;if(o&&o.start<=o.end){const e=o.lexer.input;n=o.start;const t=o.end;n===e.length?s+=" at end of input: ":s+=" at position "+(n+1)+": \n";const r=e.slice(n,t).replace(/[^]/g,"$&̲");let a,l;a=n>15?"…"+e.slice(n-15,n):e.slice(0,n),l=t+15":">","<":"<",'"':""","'":"'"},o=/[&><"']/g;function a(e){return String(e).replace(o,e=>s[e])}const l=function(e){return"ordgroup"===e.type||"color"===e.type?1===e.body.length?l(e.body[0]):e:"font"===e.type?l(e.body):e},i=function(e){const t=l(e);return"mathord"===t.type||"textord"===t.type||"atom"===t.type},c=function(e){return+e.toFixed(4)},m="acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳",p=["__proto__","prototype","constructor"];class u{constructor(e){e=e||{},this.displayMode=t(e,"displayMode",!1),this.annotate=t(e,"annotate",!1),this.leqno=t(e,"leqno",!1),this.throwOnError=t(e,"throwOnError",!1),this.errorColor=t(e,"errorColor","#b22222"),this.macros=(e=>{if(null==e||"object"!=typeof e)return Object.create(null);for(const t of p)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return Object.setPrototypeOf(e,null)})(Object.prototype.hasOwnProperty.call(e,"macros")?e.macros:void 0),this.wrap=t(e,"wrap","none"),this.xml=t(e,"xml",!1),this.colorIsTextColor=t(e,"colorIsTextColor",!1),this.strict=t(e,"strict",!1),this.trust=t(e,"trust",!1);const r=Object.prototype.hasOwnProperty.call(e,"maxSize")?e.maxSize:void 0;this.maxSize=void 0===r?[1/0,1/0]:Array.isArray(r)?r:[1/0,1/0],this.maxExpand=Math.max(0,t(e,"maxExpand",1e3)),this.wrapDelimiterPairs=!0}isTrusted(e){if(e.url&&!e.protocol){const t=function(e){const t=/^[\x00-\x20]*([^\\/#?]*?)(:|*58|*3a|&colon)/i.exec(e);return t?":"!==t[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?t[1].toLowerCase():null:"_relative"}(e.url);if(null==t)return!1;e.protocol=t}const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}const d={},h={};function g({type:e,names:t,props:r,handler:n,mathmlBuilder:s}){const o={type:e,numArgs:r.numArgs,argTypes:r.argTypes,allowedInArgument:!!r.allowedInArgument,allowedInText:!!r.allowedInText,allowedInMath:void 0===r.allowedInMath||r.allowedInMath,numOptionalArgs:r.numOptionalArgs||0,infix:!!r.infix,primitive:!!r.primitive,handler:n};for(let e=0;ee.toText()).join("")}}const x=function(e){return e.filter(e=>e).join(" ")},k=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},v=function(e){const t=document.createElement(e);t.className=x(this.classes);for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t.style[e]=this.style[e]);for(const e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&t.setAttribute(e,this.attributes[e]);for(let e=0;e";for(let e=0;e`,t};class T{constructor(e,t,r){k.call(this,e,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return v.call(this,"span")}toMarkup(){return A.call(this,"span")}}let S=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.text)}};class O{constructor(e,t,r){this.href=e,this.classes=t,this.children=r||[]}toNode(){const e=document.createElement("a");e.setAttribute("href",this.href),this.classes.length>0&&(e.className=x(this.classes));for(let t=0;t0&&(e+=` class="${a(x(this.classes))}"`),e+=">";for(let t=0;t",e}}class q{constructor(e,t,r){this.alt=t,this.src=e,this.classes=["mord"],this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createElement("img");e.src=this.src,e.alt=this.alt,e.className="mord";for(const t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);return e}toMarkup(){let e=` ",e}}function B(e){return new w(e)}class C{constructor(e,t,r,n){this.type=e,this.attributes={},this.children=t||[],this.classes=r||[],this.style=n||{},this.label=""}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}setLabel(e){this.label=e}toNode(){const e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=x(this.classes));for(const t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);for(let t=0;t0&&(e+=` class="${a(x(this.classes))}"`);let t="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${n(e)}:${this.style[e]};`);t&&(e+=` style="${t}"`),e+=">";for(let t=0;t",e}toText(){return this.children.map(e=>e.toText()).join("")}}class N{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.toText())}toText(){return this.text}}const z=e=>{let t;return 1===e.length&&"mrow"===e[0].type?(t=e.pop(),t.type="mstyle"):t=new C("mstyle",e),t},$=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(const r of e.body)t+=$(r);else if(e.body)t+=$(e.body);else if("supsub"===e.type)t+=$(e.base),e.sub&&(t+=.7*$(e.sub)),e.sup&&(t+=.7*$(e.sup));else if("mathord"===e.type||"textord"===e.type)for(const r of e.text.split("")){const e=r.codePointAt(0);t+=96{const t=I(e.label);if(e.label.indexOf("tilde")>-1){const r=$(e.base);1","\\gt",!0),G(P,J,"∈","\\in",!0),G(P,J,"∉","\\notin",!0),G(P,J,"","\\@not"),G(P,J,"⊂","\\subset",!0),G(P,J,"⊃","\\supset",!0),G(P,J,"⊆","\\subseteq",!0),G(P,J,"⊇","\\supseteq",!0),G(P,J,"⊈","\\nsubseteq",!0),G(P,J,"⊈","\\nsubseteqq"),G(P,J,"⊉","\\nsupseteq",!0),G(P,J,"⊉","\\nsupseteqq"),G(P,J,"⊨","\\models"),G(P,J,"←","\\leftarrow",!0),G(P,J,"≤","\\le"),G(P,J,"≤","\\leq",!0),G(P,J,"<","\\lt",!0),G(P,J,"→","\\rightarrow",!0),G(P,J,"→","\\to"),G(P,J,"≱","\\ngeq",!0),G(P,J,"≱","\\ngeqq"),G(P,J,"≱","\\ngeqslant"),G(P,J,"≰","\\nleq",!0),G(P,J,"≰","\\nleqq"),G(P,J,"≰","\\nleqslant"),G(P,J,"⫫","\\Perp",!0),G(P,K," ","\\ "),G(P,K," ","\\space"),G(P,K," ","\\nobreakspace"),G(R,K," ","\\ "),G(R,K," "," "),G(R,K," ","\\space"),G(R,K," ","\\nobreakspace"),G(P,K,null,"\\nobreak"),G(P,K,null,"\\allowbreak"),G(P,Y,",",","),G(R,Y,":",":"),G(P,Y,";",";"),G(P,H,"⊼","\\barwedge"),G(P,H,"⊻","\\veebar"),G(P,H,"⊙","\\odot",!0),G(P,H,"⊕︎","\\oplus"),G(P,H,"⊗","\\otimes",!0),G(P,Q,"∂","\\partial",!0),G(P,H,"⊘","\\oslash",!0),G(P,H,"⊚","\\circledcirc",!0),G(P,H,"⊡","\\boxdot",!0),G(P,H,"△","\\bigtriangleup"),G(P,H,"▽","\\bigtriangledown"),G(P,H,"†","\\dagger"),G(P,H,"⋄","\\diamond"),G(P,H,"◃","\\triangleleft"),G(P,H,"▹","\\triangleright"),G(P,Z,"{","\\{"),G(R,Q,"{","\\{"),G(R,Q,"{","\\textbraceleft"),G(P,_,"}","\\}"),G(R,Q,"}","\\}"),G(R,Q,"}","\\textbraceright"),G(P,Z,"{","\\lbrace"),G(P,_,"}","\\rbrace"),G(P,Z,"[","\\lbrack",!0),G(R,Q,"[","\\lbrack",!0),G(P,_,"]","\\rbrack",!0),G(R,Q,"]","\\rbrack",!0),G(P,Z,"(","\\lparen",!0),G(P,_,")","\\rparen",!0),G(P,Z,"⦇","\\llparenthesis",!0),G(P,_,"⦈","\\rrparenthesis",!0),G(R,Q,"<","\\textless",!0),G(R,Q,">","\\textgreater",!0),G(P,Z,"⌊","\\lfloor",!0),G(P,_,"⌋","\\rfloor",!0),G(P,Z,"⌈","\\lceil",!0),G(P,_,"⌉","\\rceil",!0),G(P,Q,"\\","\\backslash"),G(P,Q,"|","|"),G(P,Q,"|","\\vert"),G(R,Q,"|","\\textbar",!0),G(P,Q,"‖","\\|"),G(P,Q,"‖","\\Vert"),G(R,Q,"‖","\\textbardbl"),G(R,Q,"~","\\textasciitilde"),G(R,Q,"\\","\\textbackslash"),G(R,Q,"^","\\textasciicircum"),G(P,J,"↑","\\uparrow",!0),G(P,J,"⇑","\\Uparrow",!0),G(P,J,"↓","\\downarrow",!0),G(P,J,"⇓","\\Downarrow",!0),G(P,J,"↕","\\updownarrow",!0),G(P,J,"⇕","\\Updownarrow",!0),G(P,X,"∐","\\coprod"),G(P,X,"⋁","\\bigvee"),G(P,X,"⋀","\\bigwedge"),G(P,X,"⨄","\\biguplus"),G(P,X,"⨄","\\bigcupplus"),G(P,X,"⨃","\\bigcupdot"),G(P,X,"⨇","\\bigdoublevee"),G(P,X,"⨈","\\bigdoublewedge"),G(P,X,"⋂","\\bigcap"),G(P,X,"⋃","\\bigcup"),G(P,X,"∫","\\int"),G(P,X,"∫","\\intop"),G(P,X,"∬","\\iint"),G(P,X,"∭","\\iiint"),G(P,X,"∏","\\prod"),G(P,X,"∑","\\sum"),G(P,X,"⨂","\\bigotimes"),G(P,X,"⨁","\\bigoplus"),G(P,X,"⨀","\\bigodot"),G(P,X,"⨉","\\bigtimes"),G(P,X,"∮","\\oint"),G(P,X,"∯","\\oiint"),G(P,X,"∰","\\oiiint"),G(P,X,"∱","\\intclockwise"),G(P,X,"∲","\\varointclockwise"),G(P,X,"⨌","\\iiiint"),G(P,X,"⨍","\\intbar"),G(P,X,"⨎","\\intBar"),G(P,X,"⨏","\\fint"),G(P,X,"⨒","\\rppolint"),G(P,X,"⨓","\\scpolint"),G(P,X,"⨕","\\pointint"),G(P,X,"⨖","\\sqint"),G(P,X,"⨗","\\intlarhk"),G(P,X,"⨘","\\intx"),G(P,X,"⨙","\\intcap"),G(P,X,"⨚","\\intcup"),G(P,X,"⨅","\\bigsqcap"),G(P,X,"⨆","\\bigsqcup"),G(P,X,"∫","\\smallint"),G(R,V,"…","\\textellipsis"),G(P,V,"…","\\mathellipsis"),G(R,V,"…","\\ldots",!0),G(P,V,"…","\\dotso"),G(P,V,"…","\\dotsc"),G(P,V,"…","\\ldots",!0),G(P,V,"⋰","\\iddots",!0),G(P,V,"⋯","\\cdots",!0),G(P,V,"⋱","\\ddots",!0),G(P,Q,"⋮","\\varvdots"),G(R,Q,"⋮","\\varvdots"),G(P,U,"´","\\acute"),G(P,U,"`","\\grave"),G(P,U,"¨","\\ddot"),G(P,U,"…","\\dddot"),G(P,U,"….","\\ddddot"),G(P,U,"~","\\tilde"),G(P,U,"‾","\\bar"),G(P,U,"˘","\\breve"),G(P,U,"ˇ","\\check"),G(P,U,"ˆ","\\hat"),G(P,U,"→","\\vec"),G(P,U,"˙","\\dot"),G(P,U,"˚","\\mathring"),G(P,W,"ı","\\imath",!0),G(P,W,"ȷ","\\jmath",!0),G(P,Q,"ı","ı"),G(P,Q,"ȷ","ȷ"),G(R,Q,"ı","\\i",!0),G(R,Q,"ȷ","\\j",!0),G(R,Q,"ø","\\o",!0),G(P,W,"ø","\\o",!0),G(R,Q,"Ø","\\O",!0),G(P,W,"Ø","\\O",!0),G(R,U,"ˊ","\\'"),G(R,U,"ˋ","\\`"),G(R,U,"ˆ","\\^"),G(R,U,"~","\\~"),G(R,U,"ˉ","\\="),G(R,U,"˘","\\u"),G(R,U,"˙","\\."),G(R,U,"¸","\\c");G(R,U,"˚","\\r"),G(R,U,"ˇ","\\v"),G(R,U,"¨",'\\"'),G(R,U,"˝","\\H"),G(P,U,"ˊ","\\'"),G(P,U,"ˋ","\\`"),G(P,U,"ˆ","\\^"),G(P,U,"~","\\~"),G(P,U,"ˉ","\\="),G(P,U,"˘","\\u"),G(P,U,"˙","\\."),G(P,U,"¸","\\c"),G(P,U,"˚","\\r"),G(P,U,"ˇ","\\v"),G(P,U,"¨",'\\"'),G(P,U,"˝","\\H");const ee={"--":!0,"---":!0,"``":!0,"''":!0};G(R,Q,"–","--",!0),G(R,Q,"–","\\textendash"),G(R,Q,"—","---",!0),G(R,Q,"—","\\textemdash"),G(R,Q,"‘","`",!0),G(R,Q,"‘","\\textquoteleft"),G(R,Q,"’","'",!0),G(R,Q,"’","\\textquoteright"),G(R,Q,"“","``",!0),G(R,Q,"“","\\textquotedblleft"),G(R,Q,"”","''",!0),G(R,Q,"”","\\textquotedblright"),G(P,Q,"°","\\degree",!0),G(R,Q,"°","\\degree"),G(R,Q,"°","\\textdegree",!0),G(P,Q,"£","\\pounds"),G(P,Q,"£","\\mathsterling",!0),G(R,Q,"£","\\pounds"),G(R,Q,"£","\\textsterling",!0),G(P,Q,"✠","\\maltese"),G(R,Q,"✠","\\maltese"),G(P,Q,"€","\\euro",!0),G(R,Q,"€","\\euro",!0),G(R,Q,"€","\\texteuro"),G(P,Q,"©","\\copyright",!0),G(R,Q,"©","\\textcopyright"),G(P,Q,"⌀","\\diameter",!0),G(R,Q,"⌀","\\diameter"),G(P,Q,"𝛤","\\varGamma"),G(P,Q,"𝛥","\\varDelta"),G(P,Q,"𝛩","\\varTheta"),G(P,Q,"𝛬","\\varLambda"),G(P,Q,"𝛯","\\varXi"),G(P,Q,"𝛱","\\varPi"),G(P,Q,"𝛴","\\varSigma"),G(P,Q,"𝛶","\\varUpsilon"),G(P,Q,"𝛷","\\varPhi"),G(P,Q,"𝛹","\\varPsi"),G(P,Q,"𝛺","\\varOmega"),G(R,Q,"𝛤","\\varGamma"),G(R,Q,"𝛥","\\varDelta"),G(R,Q,"𝛩","\\varTheta"),G(R,Q,"𝛬","\\varLambda"),G(R,Q,"𝛯","\\varXi"),G(R,Q,"𝛱","\\varPi"),G(R,Q,"𝛴","\\varSigma"),G(R,Q,"𝛶","\\varUpsilon"),G(R,Q,"𝛷","\\varPhi"),G(R,Q,"𝛹","\\varPsi"),G(R,Q,"𝛺","\\varOmega");const te='0123456789/@."';for(let e=0;e<14;e++){const t=te.charAt(e);G(P,Q,t,t)}const re='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){const t=re.charAt(e);G(R,Q,t,t)}const ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){const t=ne.charAt(e);G(P,W,t,t),G(R,Q,t,t)}const se="ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";for(let e=0;e<30;e++){const t=se.charAt(e);G(P,W,t,t),G(R,Q,t,t)}let oe="";for(let e=0;e<52;e++){oe=String.fromCharCode(55349,56320+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56372+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56424+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56580+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56736+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56788+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56840+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56944+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,56632+e),G(P,W,oe,oe),G(R,Q,oe,oe);const t=ne.charAt(e);oe=String.fromCharCode(55349,56476+e),G(P,W,t,oe),G(R,Q,t,oe)}for(let e=0;e<10;e++)oe=String.fromCharCode(55349,57294+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,57314+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,57324+e),G(P,W,oe,oe),G(R,Q,oe,oe),oe=String.fromCharCode(55349,57334+e),G(P,W,oe,oe),G(R,Q,oe,oe);const ae=function(e,t,r){return!D[t][e]||!D[t][e].replace||55349===e.charCodeAt(0)||Object.prototype.hasOwnProperty.call(ee,e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=D[t][e].replace),new N(e)},le=(e,t)=>{if(0===e.children.length||"mtext"!==e.children[e.children.length-1].type){const r=new C("mtext",[new N(t.children[0].text)]);e.children.push(r)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},ie=e=>{if("mrow"!==e.type&&"mstyle"!==e.type)return e;if(0===e.children.length)return e;const t=new C("mrow");for(let r=0;r0&&" "===n.children[0].text.charAt(s-1)&&(n.children[0].text=n.children[0].text.slice(0,-1)+" ");for(const[t,r]of Object.entries(e.attributes))n.attributes[t]=r}return 1===t.children.length&&"mtext"===t.children[0].type?t.children[0]:t},ce=function(e,t=!1){if(!(1!==e.length||e[0]instanceof w))return e[0];if(!t){e[0]instanceof C&&"mo"===e[0].type&&!e[0].attributes.fence&&(e[0].attributes.lspace="0em",e[0].attributes.rspace="0em");const t=e.length-1;e[t]instanceof C&&"mo"===e[t].type&&!e[t].attributes.fence&&(e[t].attributes.lspace="0em",e[t].attributes.rspace="0em")}return new C("mrow",e)};function me(e){if(!e)return!1;if("mi"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof N&&"."===t.text}if("mtext"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof N&&" "===t.text}if("mo"===e.type&&1===e.children.length&&"true"===e.getAttribute("separator")&&"0em"===e.getAttribute("lspace")&&"0em"===e.getAttribute("rspace")){const t=e.children[0];return t instanceof N&&","===t.text}return!1}const pe=(e,t)=>{const r=e[t],n=e[t+1];return"atom"===r.type&&","===r.text&&r.loc&&n.loc&&r.loc.end===n.loc.start},ue=e=>"atom"===e.type&&"rel"===e.family||"mclass"===e.type&&"mrel"===e.mclass,de=function(e,t,r=!1){if(!r&&1===e.length){const r=ge(e[0],t);return r instanceof C&&"mo"===r.type&&(r.setAttribute("lspace","0em"),r.setAttribute("rspace","0em")),[r]}const n=[],s=[];let o;for(let r=0;r0&&ue(e[t])&&ue(e[t-1])&&r.setAttribute("lspace","0em"),"mn"===r.type&&o&&"mn"===o.type)o.children.push(...r.children);else if(me(r)&&o&&"mn"===o.type)o.children.push(...r.children);else if(o&&"mn"===o.type&&t=1&&o&&("mn"===o.type||me(o))){const e=r.children[0];e instanceof C&&"mn"===e.type&&o&&(e.children=[...o.children,...e.children],n.pop())}n.push(r),o=r}}return n},he=function(e,t,r=!1){return ce(de(e,t,r),r)},ge=function(t,r){if(!t)return new C("mrow");if(h[t.type]){return h[t.type](t,r)}throw new e("Got group of unknown type: '"+t.type+"'")},fe=e=>new C("mtd",[],[],{padding:"0",width:"50%"}),be=["mrow","mtd","mtable","mtr"],ye=e=>{for(const t of e.children)if(t.type&&be.includes(t.type)){if(t.classes&&"tml-label"===t.classes[0]){return t.label}{const e=ye(t);if(e)return e}}else if(!t.type){const e=ye(t);if(e)return e}};function we(e,t,r,n){let s=null;1===e.length&&"tag"===e[0].type&&(s=e[0].tag,e=e[0].body);const o=de(e,r);if(1===o.length&&o[0]instanceof O)return o[0];const a=n.displayMode||n.annotate?"none":n.wrap,l=0===o.length?null:o[0];let i=1===o.length&&null===s&&l instanceof C?o[0]:function(e,t,r){const n=[];let s=[],o=[],a=0,l=0;for(;l0&&s.push(new C("mrow",o)),s.push(r),o=[];const e=new C("mtd",s);e.style.textAlign="left",n.push(new C("mtr",[e])),s=[],l+=1;continue}if(o.push(r),r.type&&"mo"===r.type&&1===r.children.length&&(!r.attributes.form||"prefix"!==r.attributes.form)&&!Object.prototype.hasOwnProperty.call(r.attributes,"movablelimits")){const n=r.children[0].text;if("="===t&&"="===n){if(a+=1,a>1){o.pop();const e=new C("mrow",o);s.push(e),o=[r]}}else if("tex"===t){const t=l0){const e=new C("mrow",o);s.push(e)}if(n.length>0){const e=new C("mtd",s);e.style.textAlign="left";const t=new C("mtr",[e]);n.push(t);const o=new C("mtable",n);return r||(o.setAttribute("columnalign","left"),o.setAttribute("rowspacing","0em")),o}return B(s)}(o,a,n.displayMode);if(s&&(i=((e,t,r,n)=>{t=he(t[0].body,r),(t=ie(t)).classes.push("tml-tag");const s=ye(e);e=new C("mtd",[e]);const o=[fe(),e,fe()];o[n?0:2].children.push(t);const a=new C("mtr",o,["tml-tageqn"]);s&&a.setAttribute("id",s);const l=new C("mtable",[a]);return l.style.width="100%",l.setAttribute("displaystyle","true"),l})(i,s,r,n.leqno)),n.annotate){const e=new C("annotation",[new N(t)]);e.setAttribute("encoding","application/x-tex"),i=new C("semantics",[i,e])}const c=new C("math",[i]);return n.xml&&c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n.displayMode&&(c.setAttribute("display","block"),c.style.display="block math",c.classes=["tml-display"]),c}const xe=(e,t)=>{const r=e.isStretchy?F(e):new C("mo",[ae(e.label,e.mode)]);e.isStretchy||r.setAttribute("stretchy","false"),"\\vec"!==e.label&&(r.style.mathDepth="0");const n="\\c"===e.label?"munder":"mover",s=ve.has(e.label);if("mover"===n&&"math"===e.mode&&!e.isStretchy&&e.base.text&&1===e.base.text.length){const t=e.base.text,n="\\vec"===e.label,o="\\vec"===n?"-vec":"";n&&r.classes.push("tml-vec");const a=n?"-vec":s?"-acc":"";"DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ".indexOf(t)>-1?(r.classes.push(`chr-sml${o}`),r.classes.push(`wbk-sml${a}`)):"BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ".indexOf(t)>-1?(r.classes.push(`chr-med${o}`),r.classes.push(`wbk-med${a}`)):"AFJdfΔΛ".indexOf(t)>-1?(r.classes.push(`chr-lrg${o}`),r.classes.push(`wbk-lrg${a}`)):n?r.classes.push("wbk-vec"):s&&r.classes.push("wbk-acc")}else s&&r.classes.push("wbk-acc");return new C(n,[ge(e.base,t),r])},ke=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),ve=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),Ae={"\\`":"̀","\\'":"́","\\^":"̂","\\~":"̃","\\=":"̄","\\u":"̆","\\.":"̇",'\\"':"̈","\\r":"̊","\\H":"̋","\\v":"̌","\\c":"̧"};g({type:"accent",names:["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\overparen","\\widecheck","\\widehat","\\wideparen","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(e,t)=>{const r=b(t[0]),n=!ke.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,base:r}},mathmlBuilder:xe}),g({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=b(t[0]),n=e.parser.mode;return"math"===n&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),"text"===n&&r.text&&1===r.text.length&&e.funcName in Ae&&m.indexOf(r.text)>-1?{type:"textord",mode:"text",text:r.text+Ae[e.funcName]}:"\\c"===e.funcName&&"text"===n&&r.text&&1===r.text.length?{type:"textord",mode:"text",text:r.text+"̧"}:{type:"accent",mode:n,label:e.funcName,isStretchy:!1,base:r}},mathmlBuilder:xe}),g({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underparen","\\utilde"],props:{numArgs:1},handler:({parser:e,funcName:t},r)=>{const n=r[0];return{type:"accentUnder",mode:e.mode,label:t,base:n}},mathmlBuilder:(e,t)=>{const r=F(e);r.style["math-depth"]=0;return new C("munder",[ge(e.base,t),r])}});const Te={pt:800/803,pc:9600/803,dd:1238/1157*800/803,cc:12.792133216944668,nd:685/642*800/803,nc:1370/107*800/803,sp:1/65536*800/803,mm:25.4/72,cm:2.54/72,in:1/72,px:96/72},Se=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Oe=function(e){return"string"!=typeof e&&(e=e.unit),Se.indexOf(e)>-1},qe=e=>[1,.7,.5][Math.max(e-1,0)],Be=function(t,r){let n=t.number;if(r.maxSize[0]<0&&n>0)return{number:0,unit:"em"};const s=t.unit;switch(s){case"mm":case"cm":case"in":case"px":return n*Te[s]>r.maxSize[1]?{number:r.maxSize[1],unit:"pt"}:{number:n,unit:s};case"em":case"ex":return"ex"===s&&(n*=.431),n=Math.min(n/qe(r.level),r.maxSize[0]),{number:c(n),unit:"em"};case"bp":return n>r.maxSize[1]&&(n=r.maxSize[1]),{number:n,unit:"pt"};case"pt":case"pc":case"dd":case"cc":case"nd":case"nc":case"sp":return n=Math.min(n*Te[s],r.maxSize[1]),{number:c(n),unit:"pt"};case"mu":return n=Math.min(n/18,r.maxSize[0]),{number:c(n),unit:"em"};default:throw new e("Invalid unit: '"+s+"'")}},Ce=e=>{const t=new C("mspace");return t.setAttribute("width",e+"em"),t},Ne=(e,t=.3,r=0,n=!1)=>{if(null==e&&0===r)return Ce(t);const s=e?[e]:[];if(0!==t&&s.unshift(Ce(t)),r>0&&s.push(Ce(r)),n){const e=new C("mpadded",s);return e.setAttribute("height","0.1px"),e}return new C("mrow",s)},ze=(e,t)=>Number(e)/qe(t),$e=(e,t,r,n)=>{const s=I(e),o="eq"===e.slice(1,3),a="x"===e.charAt(1)?"1.75":"cd"===e.slice(2,4)?"3.0":o?"1.0":"2.0";s.setAttribute("lspace","0"),s.setAttribute("rspace",o?"0.5em":"0");const l=n.withLevel(n.level<2?2:3),i=ze(a,l.level),c=ze(a,3),m=Ne(null,i.toFixed(4),0),p=Ne(null,c.toFixed(4),0),u=ze(o?0:.3,l.level).toFixed(4);let d,h;const g=t&&t.body&&(t.body.body||t.body.length>0);if(g){let r=ge(t,l);r=Ne(r,u,u,"\\\\cdrightarrow"===e||"\\\\cdleftarrow"===e),d=new C("mover",[r,p])}const f=r&&r.body&&(r.body.body||r.body.length>0);if(f){let e=ge(r,l);e=Ne(e,u,u),h=new C("munder",[e,p])}let b;return b=g||f?g&&f?new C("munderover",[s,h,d]):g?new C("mover",[s,d]):new C("munder",[s,h]):new C("mover",[s,m]),"3.0"===a&&(b.style.height="1em"),b.setAttribute("accent","false"),b};g({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xleftrightharpoons","\\xrightleftharpoons","\\yields","\\yieldsLeft","\\mesomerism","\\longrightharpoonup","\\longleftharpoondown","\\yieldsLeftRight","\\chemequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler:({parser:e,funcName:t},r,n)=>({type:"xArrow",mode:e.mode,name:t,body:r[0],below:n[0]}),mathmlBuilder(e,t){const r=[$e(e.name,e.body,e.below,t)];return r.unshift(Ce(.2778)),r.push(Ce(.2778)),new C("mrow",r)}});const Ee={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};g({type:"stackedArrow",names:["\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},r,n){const s=r[0]?{type:"hphantom",mode:e.mode,body:r[0]}:null,o=n[0]?{type:"hphantom",mode:e.mode,body:n[0]}:null;return{type:"stackedArrow",mode:e.mode,name:t,body:r[0],upperArrowBelow:o,lowerArrowBody:s,below:n[0]}},mathmlBuilder(e,t){const r=Ee[e.name][0],n=Ee[e.name][1],s=$e(r,e.body,e.upperArrowBelow,t),o=$e(n,e.lowerArrowBody,e.below,t);let a;const l=new C("mpadded",[s]);if(l.setAttribute("voffset","0.3em"),l.setAttribute("height","+0.3em"),l.setAttribute("depth","-0.3em"),"\\equilibriumLeft"===e.name){const e=new C("mpadded",[o]);e.setAttribute("width","0.5em"),a=new C("mpadded",[Ce(.2778),e,l,Ce(.2778)])}else l.setAttribute("width","\\equilibriumRight"===e.name?"0.5em":"0"),a=new C("mpadded",[Ce(.2778),l,o,Ce(.2778)]);return a.setAttribute("voffset","-0.18em"),a.setAttribute("height","-0.18em"),a.setAttribute("depth","+0.18em"),a}});const Ie={};function Le({type:e,names:t,props:r,handler:n,mathmlBuilder:s}){const o={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:n};for(let e=0;e":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Ge=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),Pe=e=>"textord"===e.type&&"@"===e.text,Re=(e,t)=>("mathord"===e.type||"atom"===e.type)&&e.text===t;function Ue(e,t,r){const n=De[e];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(n,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{const e={type:"atom",text:n,mode:"math",family:"rel"},s={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])],semisimple:!0};return r.callFunction("\\\\cdparent",[s],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{const e={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[e],[])}default:return{type:"textord",text:" ",mode:"math"}}}g({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler:({parser:e,funcName:t},r)=>({type:"cdlabel",mode:e.mode,side:t.slice(4),label:r[0]}),mathmlBuilder(e,t){if(0===e.label.body.length)return new C("mrow",t);const r=ge(e.label,t);"left"===e.side&&r.classes.push("tml-shift-left");const n=new C("mtd",[r]);n.style.padding="0";const s=new C("mtr",[n]),o=new C("mtable",[s]),a=new C("mpadded",[o]);return a.setAttribute("width","0.1px"),a.setAttribute("displaystyle","false"),a.setAttribute("scriptlevel","1"),a}}),g({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new C("mrow",[ge(e.fragment,t)])});const He=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),_e=(e,t)=>({type:t,mode:"math",body:He(e)});class Ve{constructor(e,t,r){this.lexer=e,this.start=t,this.end=r}static range(e,t){return t?e&&e.loc&&t.loc&&e.loc.lexer===t.loc.lexer?new Ve(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class We{constructor(e,t){this.text=e,this.loc=t}range(e,t){return new We(t,Ve.range(this,e))}}const Xe=0,Ze=1,Ye=2,Je=3,Ke=Object.create(null);function Qe(e,t){Ke[e]=t}const et=Ke;Qe("\\noexpand",function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Qe("\\expandafter",function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Qe("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Qe("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Qe("\\@ifnextchar",function(e){const t=e.consumeArgs(3);e.consumeSpaces();const r=e.future();return 1===t[0].length&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Qe("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Qe("\\TextOrMath",function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});const tt=e=>{let t="";for(let r=e.length-1;r>-1;r--)t+=e[r].text;return t},rt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},nt=e=>{const t=e.future().text;return"EOF"===t?[null,""]:[rt[t.charAt(0)],t]},st=(e,t,r)=>{for(let n=1;n=0;e--){const s=t[e].loc.start;s>n&&(r+=" ",n=s),r+=t[e].text,n+=t[e].text.length}return r}Qe("\\char",function(t){let r,n=t.popToken(),s="";if("'"===n.text)r=8,n=t.popToken();else if('"'===n.text)r=16,n=t.popToken();else if("`"===n.text)if(n=t.popToken(),"\\"===n.text[0])s=n.text.charCodeAt(1);else{if("EOF"===n.text)throw new e("\\char` missing argument");s=n.text.charCodeAt(0)}else r=10;if(r){let o,a=n.text;if(s=rt[a.charAt(0)],null==s||s>=r)throw new e(`Invalid base-${r} digit ${n.text}`);for(s=st(s,a,r),[o,a]=nt(t);null!=o&&o":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcap":"\\dotsb","\\bigsqcup":"\\dotsb","\\bigtimes":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\DOTSX":"\\dotsx"};Qe("\\dots",function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in at?t=at[r]:("\\not"===r.slice(0,4)||r in D.math&&["bin","rel"].includes(D.math[r].group))&&(t="\\dotsb"),t}),Qe("\\dotsb","\\cdots"),Qe("\\dotsm","\\cdots"),Qe("\\dotsi","\\!\\cdots"),Qe("\\idotsint","\\int\\!\\cdots\\!\\int"),Qe("\\dotsx","\\ldots\\,"),Qe("\\DOTSI","\\relax"),Qe("\\DOTSB","\\relax"),Qe("\\DOTSX","\\relax"),Qe("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Qe("\\,","{\\tmspace+{3mu}{.1667em}}"),Qe("\\thinspace","\\,"),Qe("\\>","\\mskip{4mu}"),Qe("\\:","{\\tmspace+{4mu}{.2222em}}"),Qe("\\medspace","\\:"),Qe("\\;","{\\tmspace+{5mu}{.2777em}}"),Qe("\\thickspace","\\;"),Qe("\\!","{\\tmspace-{3mu}{.1667em}}"),Qe("\\negthinspace","\\!"),Qe("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),Qe("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),Qe("\\enspace","\\kern.5em "),Qe("\\enskip","\\hskip.5em\\relax"),Qe("\\quad","\\hskip1em\\relax"),Qe("\\qquad","\\hskip2em\\relax"),Qe("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax"),Qe("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Qe("\\tag@paren","\\tag@literal{({#1})}"),Qe("\\tag@literal",t=>{if(t.macros.get("\\df@tag"))throw new e("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),Qe("\\notag","\\nonumber"),Qe("\\nonumber","\\gdef\\@eqnsw{0}"),Qe("\\bmod","\\mathbin{\\text{mod}}"),Qe("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Qe("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Qe("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Qe("\\newline","\\\\\\relax"),Qe("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),Qe("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),Qe("\\Temml","\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"),Qe("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Qe("\\@hspace","\\hskip #1\\relax"),Qe("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Qe("\\colon",'\\mathpunct{\\char"3a}'),Qe("\\prescript","\\pres@cript{^{#1}_{#2}}{}{#3}"),Qe("\\ordinarycolon",'\\char"3a'),Qe("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),Qe("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),Qe("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),Qe("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),Qe("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),Qe("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),Qe("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),Qe("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Qe("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Qe("\\ratio","\\vcentcolon"),Qe("\\coloncolon","\\dblcolon"),Qe("\\colonequals","\\coloneqq"),Qe("\\coloncolonequals","\\Coloneqq"),Qe("\\equalscolon","\\eqqcolon"),Qe("\\equalscoloncolon","\\Eqqcolon"),Qe("\\colonminus","\\coloneq"),Qe("\\coloncolonminus","\\Coloneq"),Qe("\\minuscolon","\\eqcolon"),Qe("\\minuscoloncolon","\\Eqcolon"),Qe("\\coloncolonapprox","\\Colonapprox"),Qe("\\coloncolonsim","\\Colonsim"),Qe("\\notni","\\mathrel{\\char`∌}"),Qe("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Qe("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Qe("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Qe("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Qe("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),Qe("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),Qe("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),Qe("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),Qe("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),Qe("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Qe("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Qe("\\plim","\\DOTSB\\operatorname*{plim}"),Qe("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}"),Qe("\\bra","\\mathinner{\\langle{#1}|}"),Qe("\\ket","\\mathinner{|{#1}\\rangle}"),Qe("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Qe("\\Bra","\\left\\langle#1\\right|"),Qe("\\Ket","\\left|#1\\right\\rangle");const lt=(e,t)=>{const r=`}\\,\\middle${"|"===t[0]?"\\vert":"\\Vert"}\\,{`;return e.slice(0,t.index)+r+e.slice(t.index+t[0].length)};Qe("\\Braket",function(e){let t=ot(e);const r=/\|\||\||\\\|/g;let n;for(;null!==(n=r.exec(t));)t=lt(t,n);return"\\left\\langle{"+t+"}\\right\\rangle"}),Qe("\\Set",function(e){let t=ot(e);const r=/\|\||\||\\\|/.exec(t);return r&&(t=lt(t,r)),"\\left\\{\\:{"+t+"}\\:\\right\\}"}),Qe("\\set",function(e){return"\\{{"+ot(e).replace(/\|/,"}\\mid{")+"}\\}"}),Qe("\\angln","{\\angl n}"),Qe("\\odv","\\@ifstar\\odv@next\\odv@numerator"),Qe("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),Qe("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),Qe("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");const it=e=>{const t=e[0][0].text,r=tt(e[1]).split(","),n=String(r.length),s="1"===n?"\\partial":`\\partial^${n}`;let o="";return r.map(e=>{o+="\\partial "+e.trim()+"\\,"}),[t,s,o.replace(/\\,$/,"")]};function ct(e){const t=[];e.consumeSpaces();let r=e.fetch().text;for("\\relax"===r&&(e.consume(),e.consumeSpaces(),r=e.fetch().text);"\\hline"===r||"\\hdashline"===r;)e.consume(),t.push("\\hdashline"===r),e.consumeSpaces(),r=e.fetch().text;return t}Qe("\\pdv@numerator",function(e){const[t,r,n]=it(e.consumeArgs(2));return`\\frac{${r} ${t}}{${n}}`}),Qe("\\pdv@next",function(e){const[t,r,n]=it(e.consumeArgs(2));return`\\frac{${r}}{${n}} ${t}`}),Qe("\\upalpha","\\up@greek{\\alpha}"),Qe("\\upbeta","\\up@greek{\\beta}"),Qe("\\upgamma","\\up@greek{\\gamma}"),Qe("\\updelta","\\up@greek{\\delta}"),Qe("\\upepsilon","\\up@greek{\\epsilon}"),Qe("\\upzeta","\\up@greek{\\zeta}"),Qe("\\upeta","\\up@greek{\\eta}"),Qe("\\uptheta","\\up@greek{\\theta}"),Qe("\\upiota","\\up@greek{\\iota}"),Qe("\\upkappa","\\up@greek{\\kappa}"),Qe("\\uplambda","\\up@greek{\\lambda}"),Qe("\\upmu","\\up@greek{\\mu}"),Qe("\\upnu","\\up@greek{\\nu}"),Qe("\\upxi","\\up@greek{\\xi}"),Qe("\\upomicron","\\up@greek{\\omicron}"),Qe("\\uppi","\\up@greek{\\pi}"),Qe("\\upalpha","\\up@greek{\\alpha}"),Qe("\\uprho","\\up@greek{\\rho}"),Qe("\\upsigma","\\up@greek{\\sigma}"),Qe("\\uptau","\\up@greek{\\tau}"),Qe("\\upupsilon","\\up@greek{\\upsilon}"),Qe("\\upphi","\\up@greek{\\phi}"),Qe("\\upchi","\\up@greek{\\chi}"),Qe("\\uppsi","\\up@greek{\\psi}"),Qe("\\upomega","\\up@greek{\\omega}"),Qe("\\invamp",'\\mathbin{\\char"214b}'),Qe("\\parr",'\\mathbin{\\char"214b}'),Qe("\\upand",'\\mathbin{\\char"214b}'),Qe("\\with",'\\mathbin{\\char"26}'),Qe("\\multimapinv",'\\mathrel{\\char"27dc}'),Qe("\\multimapboth",'\\mathrel{\\char"29df}'),Qe("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),Qe("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),Qe("\\coh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}\n{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}'),Qe("\\incoh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}\n{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}'),Qe("\\standardstate","\\text{\\tiny\\char`⦵}");const mt=t=>{if(!t.parser.settings.displayMode)throw new e(`{${t.envName}} can be used only in display mode.`)},pt=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,ut=e=>{let t=e.get("\\arraystretch");"string"!=typeof t&&(t=tt(t.tokens)),t=isNaN(t)?null:Number(t);let r=e.get("\\arraycolsep");"string"!=typeof r&&(r=tt(r.tokens));const n=pt.exec(r);return[t,n?{number:+(n[1]+n[2]),unit:n[3]}:null]},dt=t=>{let r="";for(let n=0;n1||!a)&&h.pop(),f.push(dt(r.body)),b.length{const t=new C("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},wt=function(e,t){const r=[],n=e.body.length,s=e.hLinesBeforeRow,o=e.tags&&e.tags.some(e=>e);for(let a=0;a0&&(2===s[0].length?p.children.forEach(e=>{e.style.borderTop="0.15em double"}):p.children.forEach(e=>{e.style.borderTop=s[0][0]?"0.06em dashed":"0.06em solid"})),s[a+1].length>0&&(2===s[a+1].length?p.children.forEach(e=>{e.style.borderBottom="0.15em double"}):p.children.forEach(e=>{e.style.borderBottom=s[a+1][0]?"0.06em dashed":"0.06em solid"}));let d=!0;for(let e=0;e0&&(a=e.envClasses.includes("abut")||e.envClasses.includes("cases")?"0":e.envClasses.includes("small")?"0.1389":e.envClasses.includes("cd")?"0.25":"0.4",l="em"),e.arraycolsep){const r=Be(e.arraycolsep,t);a=r.number.toFixed(4),l=r.unit}if(a){const t=0===r.length?0:r[0].children.length,n=(r,n)=>0===r&&0===n||r===t-1&&1===n?"0":"align"!==e.envClasses[0]?a:1===n?"0":o?r%2?"1":"0":r%2?"0":"1";for(let e=0;e0){const t=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let n=0;n1&&e.envClasses.includes("cases")&&(s.children[1].style.paddingLeft="1em"),e.envClasses.includes("cases")||e.envClasses.includes("subarray"))for(const e of s.children)e.classes.push("tml-left")}}let i=new C("mtable",r);if(e.envClasses.length>0&&(e.envClasses.includes("jot")?i.classes.push("tml-jot"):e.envClasses.includes("small")&&i.classes.push("tml-small")),"display"===e.scriptLevel&&i.setAttribute("displaystyle","true"),(e.autoTag||e.envClasses.includes("multline"))&&(i.style.width="100%"),e.cols&&e.cols.length>0){const t=e.cols;let r=!1,n=0,s=t.length;for(;"separator"===t[n].type;)n+=1;for(;"separator"===t[s-1].type;)s-=1;if("separator"===t[0].type){const e="separator"===t[1].type?"0.15em double":"|"===t[0].separator?"0.06em solid ":"0.06em dashed ";for(const t of i.children)t.children[0].style.borderLeft=e}let a=o?0:-1;for(let e=n;e-1;if(r[0]&&i){let t="";for(let e=0;e0?new Array(o.body[0].length).fill({type:"align",align:n}):[];const[a,l]=ut(t.parser.gullet.macros);return o.arraystretch=a,!l||6===l&&"pt"===l||(o.arraycolsep=l),r?{type:"leftright",mode:t.mode,body:[o],left:r[0],right:r[1],rightColor:void 0}:o},mathmlBuilder:wt}),Le({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(e){const t=gt(e.parser,{cols:[],envClasses:["bordermatrix"]},"text");return t.cols=t.body.length>0?new Array(t.body[0].length).fill({type:"align",align:"c"}):[],t.envClasses=[],t.arraystretch=1,"matrix"===e.envName?t:((e,t)=>{const r=e.body;r[0].shift();const n=new Array(r.length-1).fill().map(()=>[]);for(let e=1;e[]);for(let e=0;e[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(n.length).fill(""),arraycolsep:{number:.04,unit:"em"}},a={type:"styling",mode:"math",scriptLevel:"text",body:[{type:"array",mode:"math",body:s,cols:new Array(s.length).fill({type:"align",align:"c"}),rowGaps:new Array(s.length-1).fill(null),hLinesBeforeRow:new Array(s.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(s.length).fill(""),arraycolsep:null}]},l={type:"leftright",mode:"math",body:[e],left:t?t[0]:"(",right:t?t[1]:")",rightColor:void 0};return He([o,{type:"supsub",mode:"math",stack:!0,base:{type:"op",mode:"math",limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[l]},sup:a,sub:null}])})(t,e.delimiters)},mathmlBuilder:wt}),Le({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>gt(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:wt}),Le({type:"array",names:["subarray"],props:{numArgs:1},handler(t,r){const n=(Me(r[0])?[r[0]]:Fe(r[0],"ordgroup").body).map(function(t){const r=je(t).text;if(-1!=="lc".indexOf(r))return{type:"align",align:r};throw new e("Unknown column alignment: "+r,t)});if(n.length>1)throw new e("{subarray} can contain only one column");let s={cols:n,envClasses:["small"]};if(s=gt(t.parser,s,"script"),s.body.length>0&&s.body[0].length>1)throw new e("{subarray} can contain only one column");return s},mathmlBuilder:wt}),Le({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=gt(e.parser,{cols:[],envClasses:["cases"]},ft(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.indexOf("r")>-1?".":"\\{",right:e.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},mathmlBuilder:wt}),Le({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:xt,mathmlBuilder:wt}),Le({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:xt,mathmlBuilder:wt}),Le({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){"gathered"!==e.envName&&mt(e);const t={cols:[],envClasses:["abut","jot"],autoTag:ht(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return gt(e.parser,t,"display")},mathmlBuilder:wt}),Le({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){mt(e);const t={autoTag:ht(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return gt(e.parser,t,"display")},mathmlBuilder:wt}),Le({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){mt(e);const t={autoTag:"multline"===e.envName,maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return gt(e.parser,t,"display")},mathmlBuilder:wt}),Le({type:"array",names:["CD"],props:{numArgs:0},handler:t=>(mt(t),function(t){const r=[];for(t.gullet.beginGroup(),t.gullet.macros.set("\\cr","\\\\\\relax"),t.gullet.beginGroup();;){r.push(t.parseExpression(!1,"\\\\")),t.gullet.endGroup(),t.gullet.beginGroup();const n=t.fetch().text;if("&"!==n&&"\\\\"!==n){if("\\end"===n){0===r[r.length-1].length&&r.pop();break}throw new e("Expected \\\\ or \\cr or \\end",t.nextToken)}t.consume()}let n=[];const s=[n];for(let o=0;o-1);else{if(!("<>AV".indexOf(s)>-1))throw new e('Expected one of "<>AV=|." after @.');for(let t=0;t<2;t++){let n=!0;for(let l=r+1;l{let s=["(",")"];if("\\bordermatrix"===t&&n[0]&&n[0].body){const e=n[0].body;1===e.length&&"delimiter"===e[0].type&&(s=[e[0].left,e[0].right])}e.consumeSpaces(),e.consume();const o=kt.bordermatrix,a={mode:e.mode,envName:t.slice(1),delimiters:s,parser:e},l=o.handler(a);return e.expect("}",!0),l}}),g({type:"cancelto",names:["\\cancelto"],props:{numArgs:2},handler({parser:e},t){const r=t[0],n=t[1];return{type:"cancelto",mode:e.mode,body:n,to:r,isCharacterBox:i(n)}},mathmlBuilder(e,t){const r=new C("mrow",[ge(e.body,t)],["ff-narrow"]),n=new C("mphantom",[ge(e.body,t)]),s=new C("mrow",[n],["tml-cancelto"]);s.style.color=t.color,e.isCharacterBox&&m.indexOf(e.body.body[0].text)>-1&&(s.style.left="0.1em",s.style.width="90%");const o=new C("mrow",[r,s],["menclose"]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text))n.style.paddingRight="0.2em";else{n.style.padding="0.5ex 0.1em 0 0";const e=new C("mspace",[]);e.setAttribute("height","0.85em"),r.children.push(e)}let a;if(e.isCharacterBox)a=new C("mspace",[]),a.setAttribute("height","1em");else{const r=ge(e.body,t),n=new C("mpadded",[r]);n.setAttribute("width","0.1px"),a=new C("mphantom",[n])}const l=ge(e.to,t);l.style.color=t.color;const i=new C("mpadded",[l]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){const e=new C("mspace",[]);e.setAttribute("width","0.2em"),i.children.unshift(e)}i.setAttribute("width","0.1px");const c=new C("mover",[a,i]),p=new C("mrow",[],["ff-nudge-left"]);return B([ce([o,c]),p])}}),g({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:t,token:r},n){const s=Fe(n[0],"ordgroup").body;let o="";for(let e=0;e{let t=e.toString(16);return 1===t.length&&(t="0"+t),t},Bt=JSON.parse('{\n "Apricot": "#ffb484",\n "Aquamarine": "#08b4bc",\n "Bittersweet": "#c84c14",\n "blue": "#0000FF",\n "Blue": "#303494",\n "BlueGreen": "#08b4bc",\n "BlueViolet": "#503c94",\n "BrickRed": "#b8341c",\n "brown": "#BF8040",\n "Brown": "#802404",\n "BurntOrange": "#f8941c",\n "CadetBlue": "#78749c",\n "CarnationPink": "#f884b4",\n "Cerulean": "#08a4e4",\n "CornflowerBlue": "#40ace4",\n "cyan": "#00FFFF",\n "Cyan": "#08acec",\n "Dandelion": "#ffbc44",\n "darkgray": "#404040",\n "DarkOrchid": "#a8548c",\n "Emerald": "#08ac9c",\n "ForestGreen": "#089c54",\n "Fuchsia": "#90348c",\n "Goldenrod": "#ffdc44",\n "gray": "#808080",\n "Gray": "#98949c",\n "green": "#00FF00",\n "Green": "#08a44c",\n "GreenYellow": "#e0e474",\n "JungleGreen": "#08ac9c",\n "Lavender": "#f89cc4",\n "lightgray": "#c0c0c0",\n "lime": "#BFFF00",\n "LimeGreen": "#90c43c",\n "magenta": "#FF00FF",\n "Magenta": "#f0048c",\n "Mahogany": "#b0341c",\n "Maroon": "#b03434",\n "Melon": "#f89c7c",\n "MidnightBlue": "#086494",\n "Mulberry": "#b03c94",\n "NavyBlue": "#086cbc",\n "olive": "#7F7F00",\n "OliveGreen": "#407c34",\n "orange": "#FF8000",\n "Orange": "#f8843c",\n "OrangeRed": "#f0145c",\n "Orchid": "#b074ac",\n "Peach": "#f8945c",\n "Periwinkle": "#8074bc",\n "PineGreen": "#088c74",\n "pink": "#ff7f7f",\n "Plum": "#98248c",\n "ProcessBlue": "#08b4ec",\n "purple": "#BF0040",\n "Purple": "#a0449c",\n "RawSienna": "#983c04",\n "red": "#ff0000",\n "Red": "#f01c24",\n "RedOrange": "#f86434",\n "RedViolet": "#a0246c",\n "Rhodamine": "#f0549c",\n "Royallue": "#0874bc",\n "RoyalPurple": "#683c9c",\n "RubineRed": "#f0047c",\n "Salmon": "#f8948c",\n "SeaGreen": "#30bc9c",\n "Sepia": "#701404",\n "SkyBlue": "#48c4dc",\n "SpringGreen": "#c8dc64",\n "Tan": "#e09c74",\n "teal": "#007F7F",\n "TealBlue": "#08acb4",\n "Thistle": "#d884b4",\n "Turquoise": "#08b4cc",\n "violet": "#800080",\n "Violet": "#60449c",\n "VioletRed": "#f054a4",\n "WildStrawberry": "#f0246c",\n "yellow": "#FFFF00",\n "Yellow": "#fff404",\n "YellowGreen": "#98cc6c",\n "YellowOrange": "#ffa41c"\n}'),Ct=(t,r)=>{let n="";if("HTML"===t){if(!vt.test(r))throw new e("Invalid HTML input.");n=r}else if("RGB"===t){if(!Tt.test(r))throw new e("Invalid RGB input.");r.split(",").map(e=>{n+=qt(Number(e.trim()))})}else{if(!St.test(r))throw new e("Invalid rbg input.");r.split(",").map(t=>{const r=Number(t.trim());if(r>1)throw new e("Color rgb input must be < 1.");n+=qt(Number((255*r).toFixed(0)))})}return"#"!==n.charAt(0)&&(n="#"+n),n},Nt=(t,r,n)=>{const s=`\\\\color@${t}`;if(!At.exec(t))throw new e("Invalid color: '"+t+"'",n);return Ot.test(t)?"#"+t:("#"===t.charAt(0)||(r.has(s)?t=r.get(s).tokens[0].text:Bt[t]&&(t=Bt[t])),t)},zt=(e,t)=>{let r=de(e.body,t.withColor(e.color));return 0===r.length&&r.push(new C("mrow")),r=r.map(t=>(t.style.color=e.color,t)),B(r)};g({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:t},r,n){const s=n[0]&&Fe(n[0],"raw").string;let o="";if(s){const e=Fe(r[0],"raw").string;o=Ct(s,e)}else o=Nt(Fe(r[0],"raw").string,e.gullet.macros,t);const a=r[1];return{type:"color",mode:e.mode,color:o,isTextColor:!0,body:y(a)}},mathmlBuilder:zt}),g({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,breakOnTokenText:t,token:r},n,s){const o=s[0]&&Fe(s[0],"raw").string;let a="";if(o){const e=Fe(n[0],"raw").string;a=Ct(o,e)}else a=Nt(Fe(n[0],"raw").string,e.gullet.macros,r);const l=e.parseExpression(!0,t,!0);return{type:"color",mode:e.mode,color:a,isTextColor:!1,body:l}},mathmlBuilder:zt}),g({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:t,funcName:r,token:n},s){const o=Fe(s[0],"raw").string;if(!/^[A-Za-z]+$/.test(o))throw new e("Color name must be latin letters.",n);const a=Fe(s[1],"raw").string;if(!["HTML","RGB","rgb"].includes(a))throw new e("Color model must be HTML, RGB, or rgb.",n);const l=Fe(s[2],"raw").string,i=Ct(a,l);return t.gullet.macros.set(`\\\\color@${o}`,{tokens:[{text:i}],numArgs:0}),{type:"internal",mode:t.mode}}}),g({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},t,r){const n="["===e.gullet.future().text?e.parseSizeGroup(!0):null,s=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:s,size:n&&Fe(n,"size").value}},mathmlBuilder(e,t){const r=new C("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){const n=Be(e.size,t);r.setAttribute("height",n.number+n.unit)}return r}});const $t={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Et=t=>{const r=t.text;if(/^(?:[\\{}$^_]|EOF)$/.test(r))throw new e("Expected a control sequence",t);return r},It=(e,t,r,n)=>{let s=e.gullet.macros.get(r.text);null==s&&(r.noexpand=!0,s={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,s,n)};g({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:t,funcName:r}){t.consumeSpaces();const n=t.fetch();if($t[n.text])return"\\global"!==r&&"\\\\globallong"!==r||(n.text=$t[n.text]),Fe(t.parseFunction(),"internal");throw new e("Invalid token after macro prefix",n)}}),g({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:t,funcName:r}){let n=t.gullet.popToken();const s=n.text;if(/^(?:[\\{}$^_]|EOF)$/.test(s))throw new e("Expected a control sequence",n);let o,a=0;const l=[[]];for(;"{"!==t.gullet.future().text;)if(n=t.gullet.popToken(),"#"===n.text){if("{"===t.gullet.future().text){o=t.gullet.future(),l[a].push("{");break}if(n=t.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new e(`Invalid argument number "${n.text}"`);if(parseInt(n.text)!==a+1)throw new e(`Argument number "${n.text}" out of order`);a++,l.push([])}else{if("EOF"===n.text)throw new e("Expected a macro definition");l[a].push(n.text)}let{tokens:i}=t.gullet.consumeArg();if(o&&i.unshift(o),"\\edef"===r||"\\xdef"===r){if(i=t.gullet.expandTokens(i),i.length>t.gullet.settings.maxExpand)throw new e("Too many expansions in an "+r);i.reverse()}return t.gullet.macros.set(s,{tokens:i,numArgs:a,delimiters:l},r===$t[r]),{type:"internal",mode:t.mode}}}),g({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=Et(e.gullet.popToken());e.gullet.consumeSpaces();const n=(e=>{let t=e.gullet.popToken();return"="===t.text&&(t=e.gullet.popToken()," "===t.text&&(t=e.gullet.popToken())),t})(e);return It(e,r,n,"\\\\globallet"===t),{type:"internal",mode:e.mode}}}),g({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=Et(e.gullet.popToken()),n=e.gullet.popToken(),s=e.gullet.popToken();return It(e,r,s,"\\\\globalfuture"===t),e.gullet.pushToken(s),e.gullet.pushToken(n),{type:"internal",mode:e.mode}}}),g({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:t,funcName:r}){let n="";const s=t.gullet.popToken();"{"===s.text?(n=Et(t.gullet.popToken()),t.gullet.popToken()):n=Et(s);const o=t.gullet.isDefined(n);if(o&&"\\newcommand"===r)throw new e(`\\newcommand{${n}} attempting to redefine ${n}; use \\renewcommand`);if(!o&&"\\renewcommand"===r)throw new e(`\\renewcommand{${n}} when command ${n} does not yet exist; use \\newcommand`);let a=0;if("["===t.gullet.future().text){let r=t.gullet.popToken();if(r=t.gullet.popToken(),!/^[0-9]$/.test(r.text))throw new e(`Invalid number of arguments: "${r.text}"`);if(a=parseInt(r.text),r=t.gullet.popToken(),"]"!==r.text)throw new e(`Invalid argument "${r.text}"`)}const{tokens:l}=t.gullet.consumeArg();return"\\providecommand"===r&&t.gullet.macros.has(n)||t.gullet.macros.set(n,{tokens:l,numArgs:a}),{type:"internal",mode:t.mode}}});const Lt={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},Ft={"(":")","\\lparen":"\\rparen","[":"]","\\lbrack":"\\rbrack","\\{":"\\}","\\lbrace":"\\rbrace","⦇":"⦈","\\llparenthesis":"\\rrparenthesis","\\lfloor":"\\rfloor","⌊":"⌋","\\lceil":"\\rceil","⌈":"⌉","\\langle":"\\rangle","⟨":"⟩","\\lAngle":"\\rAngle","⟪":"⟫","\\llangle":"\\rrangle","⦉":"⦊","\\lvert":"\\rvert","\\lVert":"\\rVert","\\lgroup":"\\rgroup","⟮":"⟯","\\lmoustache":"\\rmoustache","⎰":"⎱","\\llbracket":"\\rrbracket","⟦":"⟧","\\lBrace":"\\rBrace","⦃":"⦄"},jt=new Set(Object.keys(Ft));new Set(Object.values(Ft));const Mt=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","⦇","\\llparenthesis","⦈","\\rrparenthesis","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lAngle","⟪","\\rAngle","⟫","\\llangle","⦉","\\rrangle","⦊","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","\\llbracket","\\rrbracket","⟦","⟧","\\lBrace","\\rBrace","⦃","⦄","/","\\backslash","|","\\vert","\\|","\\Vert","‖","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]),Dt=new Set(["}","\\left","\\middle","\\right"]),Gt=e=>e.length>0&&(Mt.has(e)||Lt[e]||Dt.has(e)),Pt=[0,1.2,1.8,2.4,3];function Rt(t,r){"ordgroup"===t.type&&1===t.body.length&&(t=t.body[0]);const n=Me(t);if(n&&Mt.has(n.text))return"<"!==n.text&&"\\lt"!==n.text||(n.text="⟨"),">"!==n.text&&"\\gt"!==n.text||(n.text="⟩"),n;throw new e(n?`Invalid delimiter '${n.text}' after '${r.funcName}'`:`Invalid delimiter type '${t.type}'`,t)}const Ut=new Set(["/","\\","\\backslash","∖","\\vert","|"]),Ht=(e,t,r,n)=>{const s=new C("mo",[ae("."===e?"":e,t)]);return s.setAttribute("fence","true"),s.setAttribute("form",r),s.setAttribute("stretchy",n?"true":"false"),s};function _t(e){if(!e.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}g({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{const r=Rt(t[0],e),n={type:"delimsizing",mode:e.parser.mode,size:Lt[e.funcName].size,mclass:Lt[e.funcName].mclass,delim:r.text},s=e.parser.fetch().text;return"^"!==s&&"_"!==s?n:{type:"ordgroup",mode:"math",body:[n,{type:"ordgroup",mode:"math",body:[]}]}},mathmlBuilder:e=>{const t=[],r="."===e.delim?"":e.delim;t.push(ae(r,e.mode));const n=new C("mo",t);return"mopen"===e.mclass||"mclose"===e.mclass?n.setAttribute("fence","true"):n.setAttribute("fence","false"),(Ut.has(r)||r.indexOf("arrow")>-1)&&n.setAttribute("stretchy","true"),n.setAttribute("symmetric","true"),n.setAttribute("minsize",Pt[e.size]+"em"),n.setAttribute("maxsize",Pt[e.size]+"em"),n}}),g({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>({type:"leftright-right",mode:e.parser.mode,delim:Rt(t[0],e).text})}),g({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=Rt(r[0],t),s=t.parser;++s.leftrightDepth;let o=s.parseExpression(!1,"\\right",!0),a=s.fetch();for(;"\\middle"===a.text;){s.consume();const t=s.fetch().text;if(!D.math[t])throw new e(`Invalid delimiter '${t}' after '\\middle'`);Rt({type:"atom",mode:"math",text:t},{funcName:"\\middle"}),o.push({type:"middle",mode:"math",delim:t}),s.consume(),o=o.concat(s.parseExpression(!1,"\\right",!0)),a=s.fetch()}--s.leftrightDepth,s.expect("\\right",!1);const l=Fe(s.parseFunction(),"leftright-right");return{type:"leftright",mode:s.mode,body:o,left:n.text,right:l.delim,isStretchy:!0}},mathmlBuilder:(e,t)=>{_t(e);const r=de(e.body,t),n=Ht(e.left,e.mode,"prefix",!0);r.unshift(n);const s=Ht(e.right,e.mode,"postfix",!0);if(e.body.length>0){const t=e.body[e.body.length-1];"color"!==t.type||t.isTextColor||s.setAttribute("mathcolor",t.color)}return r.push(s),ce(r)}}),g({type:"delimiter",names:Array.from(jt),props:{numArgs:0,allowedInText:!0,allowedInMath:!0,allowedInArgument:!0},handler:({parser:t,funcName:r,token:n})=>{if("text"===t.mode)return{type:"textord",mode:"text",text:r,loc:n.loc};if(!t.settings.wrapDelimiterPairs)return{type:"atom",mode:"math",family:"open",loc:n.loc,text:r};const s=Ft[r],o=t.parseExpression(!1,s,!1);if(t.fetch().text!==s)throw new e("Unmatched delimiter");return t.consume(),{type:"delimiter",mode:t.mode,body:o,left:r,right:s}},mathmlBuilder:(e,t)=>{_t(e);const r=de(e.body,t),n=Ht(e.left,e.mode,"prefix",!1);r.unshift(n);const s=Ht(e.right,e.mode,"postfix",!1);if(e.body.length>0){const t=e.body[e.body.length-1];"color"!==t.type||t.isTextColor||s.setAttribute("mathcolor",t.color)}return r.push(s),ce(r)}}),g({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=Rt(r[0],t);if(!t.parser.leftrightDepth)throw new e("\\middle without preceding \\left",n);return{type:"middle",mode:t.parser.mode,delim:n.text}},mathmlBuilder:e=>{const t=ae(e.delim,e.mode),r=new C("mo",[t]);return r.setAttribute("stretchy","true"),r.setAttribute("form","infix"),"/"!==t.text&&(r.setAttribute("lspace","0.05em"),r.setAttribute("rspace","0.05em")),r}});const Vt=["\\boxed","\\fcolorbox","\\colorbox"],Wt=(e,t)=>{const r=Vt.includes(e.label)?"mrow":"menclose",n=new C(r,[ge(e.body,t)]);switch(e.label){case"\\overline":n.setAttribute("notation","top"),n.classes.push("tml-overline");break;case"\\underline":n.setAttribute("notation","bottom"),n.classes.push("tml-underline");break;case"\\cancel":n.setAttribute("notation","updiagonalstrike"),n.children.push(new C("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike"),n.children.push(new C("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":n.setAttribute("notation","horizontalstrike"),n.children.push(new C("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike"),n.children.push(new C("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":n.setAttribute("notation","longdiv"),n.classes.push("longdiv-top"),n.children.push(new C("mrow",[],["longdiv-arc"]));break;case"\\phase":n.setAttribute("notation","phasorangle"),n.classes.push("phasor-bottom"),n.children.push(new C("mrow",[],["phasor-angle"]));break;case"\\textcircled":n.setAttribute("notation","circle"),n.classes.push("circle-pad"),n.children.push(new C("mrow",[],["textcircle"]));break;case"\\angl":n.setAttribute("notation","actuarial"),n.classes.push("actuarial");break;case"\\boxed":n.style.padding="3pt",n.style.border="1px solid",n.setAttribute("scriptlevel","0"),n.setAttribute("displaystyle","true");break;case"\\fbox":n.setAttribute("notation","box"),n.classes.push("tml-fbox");break;case"\\fcolorbox":case"\\colorbox":n.style.padding="0.3em","\\fcolorbox"===e.label&&(n.style.border="0.0667em solid "+String(e.borderColor))}return e.backgroundColor&&n.setAttribute("mathbackground",e.backgroundColor),n};g({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:t},r,n){const s=n[0]&&Fe(n[0],"raw").string;let o="";if(s){const e=Fe(r[0],"raw").string;o=Ct(s,e)}else o=Nt(Fe(r[0],"raw").string,e.gullet.macros);const a=r[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:o,body:a}},mathmlBuilder:Wt}),g({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:t},r,n){const s=n[0]&&Fe(n[0],"raw").string;let o,a="";if(s){const e=Fe(r[0],"raw").string,t=Fe(r[0],"raw").string;a=Ct(s,e),o=Ct(s,t)}else a=Nt(Fe(r[0],"raw").string,e.gullet.macros),o=Nt(Fe(r[1],"raw").string,e.gullet.macros);const l=r[2];return{type:"enclose",mode:e.mode,label:t,backgroundColor:o,borderColor:a,body:l}},mathmlBuilder:Wt}),g({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:e},t)=>({type:"enclose",mode:e.mode,label:"\\fbox",body:t[0]})}),g({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\overline","\\boxed","\\longdiv","\\phase"],props:{numArgs:1},handler({parser:e,funcName:t},r){const n=r[0];return{type:"enclose",mode:e.mode,label:t,body:n}},mathmlBuilder:Wt}),g({type:"enclose",names:["\\sout"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},r){const n=r[0];return{type:"enclose",mode:e.mode,label:t,body:n}},mathmlBuilder:Wt}),g({type:"enclose",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},r){const n=r[0];return{type:"enclose",mode:e.mode,label:t,body:n}},mathmlBuilder:Wt}),g({type:"enclose",names:["\\textcircled"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},r){const n=r[0];return{type:"enclose",mode:e.mode,label:t,body:n}},mathmlBuilder:Wt}),g({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:t,funcName:r},n){const s=n[0];if("ordgroup"!==s.type)throw new e("Invalid environment name",s);let o="";for(let e=0;e({type:"envTag",mode:e.mode,body:t[0]}),mathmlBuilder:(e,t)=>new C("mrow")}),g({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new C("mrow")});const Xt=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),Zt=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Yt=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),Jt=Object.freeze({"ϵ":119527,"ϑ":119564,"ϰ":119534,"φ":119577,"ϱ":119535,"ϖ":119563}),Kt=Object.freeze({"ϵ":119643,"ϑ":119680,"ϰ":119650,"φ":119693,"ϱ":119651,"ϖ":119679}),Qt=Object.freeze({"ϵ":119701,"ϑ":119738,"ϰ":119708,"φ":119751,"ϱ":119709,"ϖ":119737}),er=Object.freeze({"ϵ":119759,"ϑ":119796,"ϰ":119766,"φ":119809,"ϱ":119767,"ϖ":119795}),tr=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>Xt[e]||119899,"script-bold":e=>119951,fraktur:e=>Zt[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>Yt[e]||120055,"sans-serif":e=>120159,"sans-serif-bold":e=>120211,"sans-serif-italic":e=>120263,"sans-serif-bold-italic":e=>120380,monospace:e=>120367},lowerCaseLatin:{normal:e=>0,bold:e=>119737,italic:e=>"h"===e?8358:119789,"bold-italic":e=>119841,script:e=>Xt[e]||119893,"script-bold":e=>119945,fraktur:e=>119997,"fraktur-bold":e=>120101,"double-struck":e=>120049,"sans-serif":e=>120153,"sans-serif-bold":e=>120205,"sans-serif-italic":e=>120257,"sans-serif-bold-italic":e=>120309,monospace:e=>120361},upperCaseGreek:{normal:e=>0,bold:e=>119575,italic:e=>119633,"bold-italic":e=>119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119749,"sans-serif-bold":e=>119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119807,monospace:e=>0},lowerCaseGreek:{normal:e=>0,bold:e=>119569,italic:e=>119627,"bold-italic":e=>"ϕ"===e?119678:119685,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119743,"sans-serif-bold":e=>119743,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119801,monospace:e=>0},varGreek:{normal:e=>0,bold:e=>Jt[e]||-51,italic:e=>0,"bold-italic":e=>Kt[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Qt[e]||116,"sans-serif-bold":e=>Qt[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>er[e]||174,monospace:e=>0},numeral:{normal:e=>0,bold:e=>120734,italic:e=>0,"bold-italic":e=>0,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>120744,"sans-serif":e=>120754,"sans-serif-bold":e=>120764,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>0,monospace:e=>120774}}),rr=(e,t)=>{const r=e.codePointAt(0),n=64{const r=e.font,n=t.withFont(r),s=ge(e.body,n);if(0===s.children.length)return s;if("boldsymbol"===r&&["mo","mpadded","mrow"].includes(s.type))return s.style.fontWeight="bold",s;if(((e,t)=>{if(!sr.includes(t)||!e.body||"ordgroup"!==e.body.type||1===e.body.body.length)return!1;if("mathord"!==e.body.body[0].type)return!1;for(let t=1;trr(e,"italic")).join(""),e;const t=new C("mpadded",[e]);return t.setAttribute("lspace","0"),t}let o="mo"===s.children[0].type;for(let e=1;e{const n=b(r[0]);let s=t;return s in ar&&(s=ar[s]),{type:"font",mode:e.mode,font:s.slice(1),body:n}},mathmlBuilder:or}),g({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:r},n)=>{const{mode:s}=e,o=e.parseExpression(!0,r,!0);return{type:"font",mode:s,font:`math${t.slice(1)}`,body:{type:"ordgroup",mode:e.mode,body:o}}},mathmlBuilder:or});const lr=["display","text","script","scriptscript"],ir={auto:-1,display:0,text:0,script:1,scriptscript:2},cr=(e,t)=>{t=((e,t)=>{let r=t;if("display"===e){const e=r.level>=Ye?Ze:Xe;r=r.withLevel(e)}else"text"===e&&r.level===Xe?r=r.withLevel(Ze):"auto"===e?r=r.incrementLevel():"script"===e?r=r.withLevel(Ye):"scriptscript"===e&&(r=r.withLevel(Je));return r})(e.scriptLevel,t);const r=ge(e.numer,t),n=ge(e.denom,t);3===t.level&&(r.style.mathDepth="2",r.setAttribute("scriptlevel","2"),n.style.mathDepth="2",n.setAttribute("scriptlevel","2"));let s=new C("mfrac",[r,n]);if(e.hasBarLine){if(e.barSize){const r=Be(e.barSize,t);s.setAttribute("linethickness",r.number+r.unit)}}else s.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new C("mo",[new N(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(s),null!=e.rightDelim){const r=new C("mo",[new N(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}s=ce(t)}return"auto"!==e.scriptLevel&&(s=new C("mstyle",[s]),s.setAttribute("displaystyle",String("display"===e.scriptLevel)),s.setAttribute("scriptlevel",ir[e.scriptLevel])),s};g({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=r[0],s=r[1];let o=!1,a=null,l=null,i="auto";switch(t){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":o=!0;break;case"\\\\atopfrac":o=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":a="(",l=")";break;case"\\\\bracefrac":a="\\{",l="\\}";break;case"\\\\brackfrac":a="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}return"\\cfrac"===t||t.startsWith("\\d")?i="display":t.startsWith("\\t")&&(i="text"),{type:"genfrac",mode:e.mode,continued:!1,numer:n,denom:s,hasBarLine:o,leftDelim:a,rightDelim:l,scriptLevel:i,barSize:null}},mathmlBuilder:cr}),g({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler({parser:e,funcName:t,token:r}){let n;switch(t){case"\\over":n="\\frac";break;case"\\choose":n="\\binom";break;case"\\atop":n="\\\\atopfrac";break;case"\\brace":n="\\\\bracefrac";break;case"\\brack":n="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:n,token:r}}});const mr=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};g({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler({parser:e},t){const r=t[4],n=t[5],s=b(t[0]),o="atom"===s.type&&"open"===s.family?mr(s.text):null,a=b(t[1]),l="atom"===a.type&&"close"===a.family?mr(a.text):null,i=Fe(t[2],"size");let c,m=null;i.isBlank?c=!0:(m=i.value,c=m.number>0);let p="auto",u=t[3];if("ordgroup"===u.type){if(u.body.length>0){const e=Fe(u.body[0],"textord");p=lr[Number(e.text)]}}else u=Fe(u,"textord"),p=lr[Number(u.text)];return{type:"genfrac",mode:e.mode,numer:r,denom:n,continued:!1,hasBarLine:c,barSize:m,leftDelim:o,rightDelim:l,scriptLevel:p}},mathmlBuilder:cr}),g({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler:({parser:e,funcName:t,token:r},n)=>({type:"infix",mode:e.mode,replaceWith:"\\\\abovefrac",barSize:Fe(n[0],"size").value,token:r})}),g({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:t},r)=>{const n=r[0],s=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e}(Fe(r[1],"infix").barSize),o=r[2],a=s.number>0;return{type:"genfrac",mode:e.mode,numer:n,denom:o,continued:!1,hasBarLine:a,barSize:s,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:cr}),g({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},t)=>({type:"hbox",mode:e.mode,body:y(t[0])}),mathmlBuilder(e,t){const r=t.withLevel(Ze),n=he(e.body,r);return ie(n)}});g({type:"horizBracket",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],props:{numArgs:1},handler:({parser:e,funcName:t},r)=>({type:"horizBracket",mode:e.mode,label:t,isOver:/^\\over/.test(t),base:r[0]}),mathmlBuilder:(e,t)=>{const r=I(e.label);return r.style["math-depth"]=0,new C(e.isOver?"mover":"munder",[ge(e.base,t),r])}}),g({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:t,funcName:r,token:n},s)=>{const o=Fe(s[0],"raw").string,a=s[1];if(t.settings.strict)throw new e(`Function "${r}" is disabled in strict mode`,n);let l;const i={};switch(r){case"\\class":i.class=o,l={command:"\\class",class:o};break;case"\\id":i.id=o,l={command:"\\id",id:o};break;case"\\style":i.style=o,l={command:"\\style",style:o};break;case"\\data":{const t=o.split(",");for(let r=0;r{const r=he(e.body,t),n=[];e.attributes.class&&n.push(...e.attributes.class.trim().split(/\s+/)),r.classes=n;for(const t in e.attributes)"class"!==t&&Object.prototype.hasOwnProperty.call(e.attributes,t)&&r.setAttribute(t,e.attributes[t]);return r}});const pr=function(t){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(t))return{number:+t,unit:"bp"};{const r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t);if(!r)throw new e("Invalid size: '"+t+"' in \\includegraphics");const n={number:+(r[1]+r[2]),unit:r[3]};if(!Oe(n))throw new e("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};g({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:t,token:r},n,s)=>{let o={number:0,unit:"em"},a={number:.9,unit:"em"},l={number:0,unit:"em"},i="";if(s[0]){const t=Fe(s[0],"raw").string.split(",");for(let r=0;r{const r=Be(e.height,t),n={number:0,unit:"em"};e.totalheight.number>0&&e.totalheight.unit===r.unit&&e.totalheight.number>r.number&&(n.number=e.totalheight.number-r.number,n.unit=r.unit);let s=0;e.width.number>0&&(s=Be(e.width,t));const o={height:r.number+n.number+"em"};s.number>0&&(o.width=s.number+s.unit),n.number>0&&(o.verticalAlign=-n.number+n.unit);const a=new q(e.src,e.alt,o);return a.height=r,a.depth=n,new C("mtext",[a])}}),g({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:t,funcName:r,token:n},s){const o=Fe(s[0],"size");if(t.settings.strict){const s="m"===r[1],a="mu"===o.value.unit;if(s){if(!a)throw new e(`LaTeX's ${r} supports only mu units, not ${o.value.unit} units`,n);if("math"!==t.mode)throw new e(`LaTeX's ${r} works only in math mode`,n)}else if(a)throw new e(`LaTeX's ${r} doesn't support mu units`,n)}return{type:"kern",mode:t.mode,dimension:o.value}},mathmlBuilder(e,t){const r=Be(e.dimension,t),n=r.number>0&&"em"===r.unit?ur(r.number):"";if("text"===e.mode&&n.length>0){const e=new N(n);return new C("mtext",[e])}if(r.number>=0){const e=new C("mspace");return e.setAttribute("width",r.number+r.unit),e}{const e=new C("mrow");return e.style.marginLeft=r.number+r.unit,e}}});const ur=function(e){return e>=.05555&&e<=.05556?" ":e>=.1666&&e<=.1667?" ":e>=.2222&&e<=.2223?" ":e>=.2777&&e<=.2778?" ":""},dr=/[^A-Za-z_0-9-]/g;g({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(dr,"")}),mathmlBuilder(e,t){const r=new C("mrow",[],["tml-label"]);return e.string.length>0&&r.setLabel(e.string),r}});const hr=["\\clap","\\llap","\\rlap"];g({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:t,funcName:r,token:n},s)=>{if(hr.includes(r)){if(t.settings.strict&&"text"!==t.mode)throw new e(`{${r}} can be used only in text mode.\n Try \\math${r.slice(1)}`,n);r=r.slice(1)}else r=r.slice(5);const o=s[0];return{type:"lap",mode:t.mode,alignment:r,body:o}},mathmlBuilder:(e,t)=>{let r;if("llap"===e.alignment){const n=de(y(e.body),t),s=new C("mphantom",n);r=new C("mpadded",[s]),r.setAttribute("width","0.1px")}const n=ge(e.body,t);let s;if("llap"===e.alignment?(n.style.position="absolute",n.style.right="0",n.style.bottom="0",s=new C("mpadded",[r,n])):s=new C("mpadded",[n]),"rlap"===e.alignment)e.body.body.length>0&&"genfrac"===e.body.body[0].type&&s.setAttribute("lspace","0.16667em");else{const t="llap"===e.alignment?"-1":"-0.5";s.setAttribute("lspace",t+"width"),"llap"===e.alignment?s.style.position="relative":(s.style.display="flex",s.style.justifyContent="center")}return s.setAttribute("width","0.1px"),s}}),g({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},r){const n=t.mode;t.switchMode("math");const s="\\("===e?"\\)":"$",o=t.parseExpression(!1,s);return t.expect(s),t.switchMode(n),{type:"ordgroup",mode:t.mode,body:o}}}),g({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,r){throw new e(`Mismatched ${t.funcName}`,r)}});g({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:y(t[0]),text:y(t[1]),script:y(t[2]),scriptscript:y(t[3])}),mathmlBuilder:(e,t)=>{const r=((e,t)=>{switch(t.level){case Xe:return e.display;case Ze:return e.text;case Ye:return e.script;case Je:return e.scriptscript;default:return e.text}})(e,t);return he(r,t)}});const gr=["text","textord","mathord","atom"];function fr(e,t){let r;const n=de(e.body,t);if("minner"===e.mclass)r=new C("mpadded",n);else if("mord"===e.mclass)e.isCharacterBox||"mathord"===n[0].type?(r=n[0],r.type="mi",1===r.children.length&&r.children[0].text&&"∇"===r.children[0].text&&r.setAttribute("mathvariant","normal")):r=new C("mi",n);else{r=new C("mrow",n),e.mustPromote?(r=n[0],r.type="mo",e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&r.setAttribute("mathvariant","italic")):r=new C("mrow",n);const s=t.level<2;"mrow"===r.type?s&&("mbin"===e.mclass?(r.children.unshift(Ce(.2222)),r.children.push(Ce(.2222))):"mrel"===e.mclass?(r.children.unshift(Ce(.2778)),r.children.push(Ce(.2778))):"mpunct"===e.mclass?r.children.push(Ce(.1667)):"minner"===e.mclass&&(r.children.unshift(Ce(.0556)),r.children.push(Ce(.0556)))):"mbin"===e.mclass?(r.attributes.lspace=s?"0.2222em":"0",r.attributes.rspace=s?"0.2222em":"0"):"mrel"===e.mclass?(r.attributes.lspace=s?"0.2778em":"0",r.attributes.rspace=s?"0.2778em":"0"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace=s?"0.1667em":"0"):"mopen"===e.mclass||"mclose"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0em"):"minner"===e.mclass&&s&&(r.attributes.lspace="0.0556em",r.attributes.width="+0.1111em"),"mopen"!==e.mclass&&"mclose"!==e.mclass&&(delete r.attributes.stretchy,delete r.attributes.form)}return r}g({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:t},r){const n=r[0],s=i(n);let o=!0;const a={type:"mathord",text:"",mode:e.mode},l=n.body?n.body:[n];for(const t of l){if(!gr.includes(t.type)){o=!1;break}D[e.mode][t.text]?a.text+=D[e.mode][t.text].replace:t.text?a.text+=t.text:t.body&&t.body.map(e=>{a.text+=e.text})}return o&&"\\mathord"===t&&"mathord"===a.type&&a.text.length>1?a:{type:"mclass",mode:e.mode,mclass:"m"+t.slice(5),body:y(o?a:n),isCharacterBox:s,mustPromote:o}},mathmlBuilder:fr});const br=e=>{const t="ordgroup"===e.type&&e.body.length&&1===e.body.length?e.body[0]:e;if("atom"===t.type){const r=e.body.length>0&&e.body[0].text&&D.math[e.body[0].text]?D.math[e.body[0].text].group:t.family;return"bin"===r||"rel"===r?"m"+r:"mord"}return"mord"};g({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:br(t[0]),body:y(t[1]),isCharacterBox:i(t[1])})}),g({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:t},r){const n=r[1],s=r[0];let o;o="\\stackrel"!==t?br(n):"mrel";const a={type:"mrel"===o||"mbin"===o?"op":"ordgroup",mode:n.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==t,body:y(n)};return{type:"supsub",mode:s.mode,stack:!0,base:a,sup:"\\underset"===t?null:s,sub:"\\underset"===t?s:null}},mathmlBuilder:fr});const yr=(e,t,r)=>{if(!e)return r;const n=ge(e,t);return"mrow"===n.type&&0===n.children.length?r:n};g({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:t,funcName:r,token:n},s){if(0===s[2].body.length)throw new e(r+"cannot parse an empty base.");const o=s[2].body[0];if(t.settings.strict&&"\\sideset"===r&&!o.symbol)throw new e("The base of \\sideset must be a big operator. Try \\prescript.");if(s[0].body.length>0&&"supsub"!==s[0].body[0].type||s[1].body.length>0&&"supsub"!==s[1].body[0].type)throw new e("\\sideset can parse only subscripts and superscripts in its first two arguments",n);const a=s[0].body.length>0?s[0].body[0]:null,l=s[1].body.length>0?s[1].body[0]:null;return a||l?a?{type:"multiscript",mode:t.mode,isSideset:"\\sideset"===r,prescripts:a,postscripts:l,base:o}:{type:"styling",mode:t.mode,scriptLevel:"text",body:[{type:"supsub",mode:t.mode,base:o,sup:l.sup,sub:l.sub}]}:o},mathmlBuilder(e,t){const r=ge(e.base,t),n=new C("mprescripts"),s=new C("none");let o=[];const a=yr(e.prescripts.sub,t,s),l=yr(e.prescripts.sup,t,s);if(e.isSideset&&(a.setAttribute("style","text-align: left;"),l.setAttribute("style","text-align: left;")),e.postscripts){o=[r,yr(e.postscripts.sub,t,s),yr(e.postscripts.sup,t,s),n,a,l]}else o=[r,n,a,l];return new C("mmultiscripts",o)}}),g({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){const r=i(t[0]);let n;if(r)n=y(t[0]),"\\"===n[0].text.charAt(0)&&(n[0].text=D.math[n[0].text].replace),n[0].text=n[0].text.slice(0,1)+"̸"+n[0].text.slice(1);else{n=[{type:"textord",mode:"math",text:"̸"},{type:"kern",mode:"math",dimension:{number:-.6,unit:"em"}},t[0]]}return{type:"not",mode:e.mode,body:n,isCharacterBox:r}},mathmlBuilder(e,t){if(e.isCharacterBox){return de(e.body,t,!0)[0]}return he(e.body,t)}});const wr=["textord","mathord","atom"],xr=["\\smallint"],kr=["textord","mathord","ordgroup","close","leftright","font"],vr=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},Ar=(e,t)=>{let r;if(e.symbol)r=new C("mo",[ae(e.name,e.mode)]),xr.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false"),e.fromMathOp&&vr(r);else if(e.body)r=new C("mo",de(e.body,t)),e.fromMathOp&&vr(r);else if(r=new C("mi",[new N(e.name.slice(1))]),!e.parentIsSupSub){const t=[r,new C("mo",[ae("","text")])];if(e.needsLeadingSpace){const e=new C("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new C("mspace");e.setAttribute("width","0.1667em"),t.push(e)}r=new C("mrow",t)}return r},Tr={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨅":"\\bigsqcap","⨆":"\\bigsqcup","⨃":"\\bigcupdot","⨇":"\\bigdoublevee","⨈":"\\bigdoublewedge","⨉":"\\bigtimes"};g({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcupplus","\\bigcupdot","\\bigcap","\\bigcup","\\bigdoublevee","\\bigdoublewedge","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcap","\\bigsqcup","\\bigtimes","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨃","⨄","⨅","⨆","⨇","⨈","⨉"],props:{numArgs:0},handler:({parser:e,funcName:t},r)=>{let n=t;return 1===n.length&&(n=Tr[n]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:Ar}),g({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{const r=t[0],n=r.body?r.body:[r],s=1===n.length&&wr.includes(n[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:s,fromMathOp:!0,stack:!1,name:s?n[0].text:null,body:s?null:y(r)}},mathmlBuilder:Ar});const Sr={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint","∱":"\\intclockwise","∲":"\\varointclockwise","⨌":"\\iiiint","⨍":"\\intbar","⨎":"\\intBar","⨏":"\\fint","⨒":"\\rppolint","⨓":"\\scpolint","⨕":"\\pointint","⨖":"\\sqint","⨗":"\\intlarhk","⨘":"\\intx","⨙":"\\intcap","⨚":"\\intcup"};g({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\sgn","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler({parser:e,funcName:t}){const r=e.prevAtomType,n=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Gt(n),needsLeadingSpace:r.length>0&&kr.includes(r),name:t}},mathmlBuilder:Ar}),g({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler({parser:e,funcName:t}){const r=e.prevAtomType,n=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Gt(n),needsLeadingSpace:r.length>0&&kr.includes(r),name:t}},mathmlBuilder:Ar}),g({type:"op",names:["\\int","\\iint","\\iiint","\\iiiint","\\oint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\intbar","\\intBar","\\fint","\\rppolint","\\scpolint","\\pointint","\\sqint","\\intlarhk","\\intx","\\intcap","\\intcup","∫","∬","∭","∮","∯","∰","∱","∲","⨌","⨍","⨎","⨏","⨒","⨓","⨕","⨖","⨗","⨘","⨙","⨚"],props:{numArgs:0,allowedInArgument:!0},handler({parser:e,funcName:t}){let r=t;return 1===r.length&&(r=Sr[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:Ar});g({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=r[0],s=e.prevAtomType,o=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:y(n),alwaysHandleSupSub:"\\operatornamewithlimits"===t,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:Gt(o),needsLeadingSpace:s.length>0&&kr.includes(s)}},mathmlBuilder:(e,t)=>{let r,n=de(e.body,t.withFont("mathrm")),s=!0;for(let e=0;ee.toText()).join("");n=[new N(e)]}else if(1===n.length&&["mover","munder"].includes(n[0].type)&&("mi"===n[0].children[0].type||"mtext"===n[0].children[0].type)){if(n[0].children[0].type="mi",e.parentIsSupSub)return new C("mrow",n);{const e=new C("mo",[ae("","text")]);return B([n[0],e])}}if(s?(r=new C("mi",n),1===n[0].text.length&&r.setAttribute("mathvariant","normal")):r=new C("mrow",n),!e.parentIsSupSub){const t=[r,new C("mo",[ae("","text")])];if(e.needsLeadingSpace){const e=new C("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new C("mspace");e.setAttribute("width","0.1667em"),t.push(e)}return B(t)}return r}}),Qe("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),f({type:"ordgroup",mathmlBuilder:(e,t)=>he(e.body,t,e.semisimple)}),g({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"phantom",mode:e.mode,body:y(r)}},mathmlBuilder:(e,t)=>{const r=de(e.body,t);return new C("mphantom",r)}}),g({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"hphantom",mode:e.mode,body:r}},mathmlBuilder:(e,t)=>{const r=de(y(e.body),t),n=new C("mphantom",r),s=new C("mpadded",[n]);return s.setAttribute("height","0px"),s.setAttribute("depth","0px"),s}}),g({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"vphantom",mode:e.mode,body:r}},mathmlBuilder:(e,t)=>{const r=de(y(e.body),t),n=new C("mphantom",r),s=new C("mpadded",[n]);return s.setAttribute("width","0.1px"),s}}),g({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:y(t[0])}),mathmlBuilder(e,t){const r=de(e.body,t),n=z(r);return n.setAttribute("style","font-weight:bold"),n}});const Or=(e,t)=>{const r=t.withLevel(Ze),n=new C("mpadded",[ge(e.body,r)]),s=Be(e.dy,t);return n.setAttribute("voffset",s.number+s.unit),s.number>0?n.style.padding=s.number+s.unit+" 0 0 0":n.style.padding="0 0 "+Math.abs(s.number)+s.unit+" 0",n};g({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},r){const n=Fe(r[0],"size").value;"\\lower"===t&&(n.number*=-1);const s=r[1];return{type:"raise",mode:e.mode,dy:n,body:s}},mathmlBuilder:Or}),g({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},r){const n=Fe(r[0],"size").value,s=r[1];return{type:"raise",mode:e.mode,dy:n,body:s}},mathmlBuilder:Or}),g({type:"ref",names:["\\ref","\\eqref"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e,funcName:t},r)=>({type:"ref",mode:e.mode,funcName:t,string:r[0].string.replace(dr,"")}),mathmlBuilder(e,t){const r="\\ref"===e.funcName?["tml-ref"]:["tml-ref","tml-eqref"];return new O("#"+e.string,r,null)}}),g({type:"reflect",names:["\\reflectbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:e},t)=>({type:"reflect",mode:e.mode,body:t[0]}),mathmlBuilder(e,t){const r=ge(e.body,t);return r.style.transform="scaleX(-1)",r}}),g({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),g({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler({parser:e},t,r){const n=r[0],s=Fe(t[0],"size"),o=Fe(t[1],"size");return{type:"rule",mode:e.mode,shift:n&&Fe(n,"size").value,width:s.value,height:o.value}},mathmlBuilder(e,t){const r=Be(e.width,t),n=Be(e.height,t),s=e.shift?Be(e.shift,t):{number:0,unit:"em"},o=t.color&&t.getColor()||"black",a=new C("mspace");if(r.number>0&&n.number>0&&a.setAttribute("mathbackground",o),a.setAttribute("width",r.number+r.unit),a.setAttribute("height",n.number+n.unit),0===s.number)return a;const l=new C("mpadded",[a]);return s.number>=0?l.setAttribute("height","+"+s.number+s.unit):(l.setAttribute("height",s.number+s.unit),l.setAttribute("depth","+"+-s.number+s.unit)),l.setAttribute("voffset",s.number+s.unit),l}});const qr=/^[0-9]$/,Br={0:"₀",1:"₁",2:"₂",3:"₃",4:"₄",5:"₅",6:"₆",7:"₇",8:"₈",9:"₉"},Cr={0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹"};g({type:"sfrac",names:["\\sfrac"],props:{numArgs:2,allowedInText:!0,allowedInMath:!0},handler({parser:t},r){let n="";for(const t of r[0].body){if("textord"!==t.type||!qr.test(t.text))throw new e("Numerator must be an integer.",t);n+=t.text}let s="";for(const t of r[1].body){if("textord"!==t.type||!qr.test(t.text))throw new e("Denominator must be an integer.",t);s+=t.text}return{type:"sfrac",mode:t.mode,numerator:n,denominator:s}},mathmlBuilder(e,t){const r=e.numerator.split("").map(e=>Cr[e]).join(""),n=e.denominator.split("").map(e=>Br[e]).join(""),s=new N(r+"⁄"+n,e.mode,t);return new C("mn",[s],["special-fraction"])}});const Nr={"\\tiny":.5,"\\sixptsize":.6,"\\Tiny":.6,"\\scriptsize":.7,"\\footnotesize":.8,"\\small":.9,"\\normalsize":1,"\\large":1.2,"\\Large":1.44,"\\LARGE":1.728,"\\huge":2.074,"\\Huge":2.488};g({type:"sizing",names:["\\tiny","\\sixptsize","\\Tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:e,funcName:t,parser:r},n)=>{r.settings.strict&&"math"===r.mode&&console.log(`Temml strict-mode warning: Command ${t} is invalid in math mode.`);const s=r.parseExpression(!1,e,!0);return{type:"sizing",mode:r.mode,funcName:t,body:s}},mathmlBuilder:(e,t)=>{const r=t.withFontSize(Nr[e.funcName]),n=de(e.body,r),s=z(n),o=(Nr[e.funcName]/t.fontSize).toFixed(4);return s.setAttribute("mathsize",o+"em"),s}}),g({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,r)=>{let n=!1,s=!1;const o=r[0]&&Fe(r[0],"ordgroup");if(o){let e="";for(let t=0;t{const r=new C("mpadded",[ge(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}});const zr=["a","c","e","ı","m","n","o","r","s","u","v","w","x","z","α","ε","ι","κ","ν","ο","π","σ","τ","υ","ω","\\alpha","\\epsilon","\\iota","\\kappa","\\nu","\\omega","\\pi","\\tau","\\omega"];g({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,r){const n=r[0],s=t[0];return s.body&&1===s.body.length&&s.body[0].text&&zr.includes(s.body[0].text)&&s.body.push({type:"rule",mode:"math",shift:null,width:{number:0,unit:"pt"},height:{number:.5,unit:"em"}}),{type:"sqrt",mode:e.mode,body:s,index:n}},mathmlBuilder(e,t){const{body:r,index:n}=e;return n?new C("mroot",[ge(r,t),ge(n,t.incrementLevel())]):new C("msqrt",[ge(r,t)])}});const $r={display:0,text:1,script:2,scriptscript:3},Er={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};g({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:r},n){const s=r.parseExpression(!0,e,!0),o=t.slice(1,t.length-5);return{type:"styling",mode:r.mode,scriptLevel:o,body:s}},mathmlBuilder(e,t){const r=t.withLevel($r[e.scriptLevel]),n=de(e.body,r),s=z(n),o=Er[e.scriptLevel];return s.setAttribute("scriptlevel",o[0]),s.setAttribute("displaystyle",o[1]),s}});const Ir=/^m(over|under|underover)$/;f({type:"supsub",mathmlBuilder(e,t){let r,n,s=!1,o=!1,a=!1,l=!1;e.base&&"horizBracket"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(s=!0,r=e.base.isOver)),!e.base||e.stack||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0,o=!e.base.symbol,a=o&&!e.isFollowedByDelimiter,l=e.base.needsLeadingSpace);const i=e.stack&&1===e.base.body.length?[ge(e.base.body[0],t)]:[ge(e.base,t)],c=t.inSubOrSup();if(e.sub){const r=ge(e.sub,c);3===t.level&&r.setAttribute("scriptlevel","2"),i.push(r)}if(e.sup){const r=ge(e.sup,c);if(3===t.level&&r.setAttribute("scriptlevel","2"),e.base&&e.base.text&&1===e.base.text.length){const t=e.base.text;"DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ".indexOf(t)>-1?r.classes.push("tml-sml-pad"):"BCEFGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ".indexOf(t)>-1?r.classes.push("tml-med-pad"):"AJdfΔΛ".indexOf(t)>-1&&r.classes.push("tml-lrg-pad")}i.push(r)}let m;if(s)m=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;m=r&&("op"===r.type&&r.limits||"multiscript"===r.type)&&(t.level===Xe||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.level===Xe||r.limits)?"munderover":"msubsup"}else{const r=e.base;m=e.stack||r&&"op"===r.type&&r.limits&&(t.level===Xe||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===Xe)?"munder":"msub"}else{const r=e.base;m=r&&"op"===r.type&&r.limits&&(t.level===Xe||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===Xe)?"mover":"msup"}let p=new C(m,i);if(o){const e=new C("mo",[ae("","text")]);if(l){const t=new C("mspace");t.setAttribute("width","0.1667em"),p=B([t,p,e])}else p=B([p,e]);if(a){const e=new C("mspace");e.setAttribute("width","0.1667em"),p.children.push(e)}}else Ir.test(m)&&(p=new C("mrow",[p]));return p}});const Lr=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],Fr=["\\Rsh","\\Lsh","\\restriction"];f({type:"atom",mathmlBuilder(e,t){if("inner"===e.family){const t="text"===e.mode?"mtext":"mi";return new C(t,[ae(e.text,e.mode)])}const r=new C("mo",[ae(e.text,e.mode)]);if("punct"===e.family)r.setAttribute("separator","true");else if("open"===e.family||"close"===e.family)"open"===e.family?(r.setAttribute("form","prefix"),r.setAttribute("stretchy","false")):"close"===e.family&&(r.setAttribute("form","postfix"),r.setAttribute("stretchy","false"));else if("\\mid"===e.text)r.setAttribute("lspace","0.22em"),r.setAttribute("rspace","0.22em"),r.setAttribute("stretchy","false");else if("rel"===e.family&&(e=>{if(1===e.length){const t=e.codePointAt(0);return 8591-1||e.indexOf("harpoon")>-1||Fr.includes(e)})(e.text))r.setAttribute("stretchy","false");else if(Lr.includes(e.text))r.setAttribute("mathsize","70%");else if(":"===e.text)r.attributes.lspace="0.2222em",r.attributes.rspace="0.2222em";else if(e.needsSpacing)return"bin"===e.family?new C("mrow",[Ce(.222),r,Ce(.222)]):new C("mrow",[Ce(.2778),r,Ce(.2778)]);return r}});const jr={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},Mr=function(e,t){if("texttt"===t.fontFamily)return"monospace";if("textsc"===t.fontFamily)return"normal";if("textsf"===t.fontFamily)return"textit"===t.fontShape&&"textbf"===t.fontWeight?"sans-serif-bold-italic":"textit"===t.fontShape?"sans-serif-italic":"textbf"===t.fontWeight?"sans-serif-bold":"sans-serif";if("textit"===t.fontShape&&"textbf"===t.fontWeight)return"bold-italic";if("textit"===t.fontShape)return"italic";if("textbf"===t.fontWeight)return"bold";const r=t.font;if(!r||"mathnormal"===r)return null;const n=e.mode;switch(r){case"mathit":case"greekItalic":return"italic";case"mathrm":{const t=e.text.codePointAt(0);return 939{const n=new C(r,[e]),s=new C("mstyle",[n]);return s.style["font-style"]="italic",s.style["font-family"]="Cambria, 'Times New Roman', serif","bold-italic"===t&&(s.style["font-weight"]="bold"),s})(s,o,t);"normal"!==o&&(s.text=s.text.split("").map(e=>rr(e,o)).join("")),a=new C(t,[s])}else if("text"===e.mode)"normal"!==o&&(s.text=rr(s.text,o)),a=new C("mtext",[s]);else if(Pr.has(e.text))a=new C("mo",[s]),a.classes.push("tml-prime");else{const e=s.text;"italic"!==o&&(s.text=rr(s.text,o)),a=new C("mi",[s]),s.text===e&&Gr.test(e)&&a.setAttribute("mathvariant","italic")}return a}});const Rr={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Ur={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};f({type:"spacing",mathmlBuilder(t,r){let n;if(Object.prototype.hasOwnProperty.call(Ur,t.text))n=new C("mtext",[new N(" ")]);else{if(!Object.prototype.hasOwnProperty.call(Rr,t.text))throw new e(`Unknown type of space "${t.text}"`);n=new C("mo"),"\\nobreak"===t.text&&n.setAttribute("linebreak","nobreak")}return n}}),f({type:"tag"});const Hr={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},_r={"\\textbf":"textbf","\\textmd":"textmd"},Vr={"\\textit":"textit","\\textup":"textup"};g({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textsc","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},r){const n=r[0];return{type:"text",mode:e.mode,body:y(n),font:t}},mathmlBuilder(e,t){const r=((e,t)=>{const r=e.font;return r?Hr[r]?t.withTextFontFamily(Hr[r]):_r[r]?t.withTextFontWeight(_r[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Vr[r]):t})(e,t),n=he(e.body,r);return ie(n)}}),g({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler:({parser:e},t)=>({type:"vcenter",mode:e.mode,body:t[0]}),mathmlBuilder(e,t){const r=new C("mtd",[ge(e.body,t)]);r.style.padding="0";const n=new C("mtr",[r]);return new C("mtable",[n])}}),g({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(t,r,n){throw new e("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(e,t){const r=new N(Wr(e)),n=new C("mtext",[r]);return n.setAttribute("mathvariant","monospace"),n}});const Wr=e=>e.body.replace(/ /g,e.star?"␣":" "),Xr=d,Zr="[ \r\n\t]",Yr=`(\\\\[a-zA-Z@]+)${Zr}*`,Jr="[̀-ͯ]",Kr=new RegExp(`${Jr}+$`),Qr=`(${Zr}+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-‧-豈-]${Jr}*|[\ud800-\udbff][\udc00-\udfff]${Jr}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${Yr}|\\\\[^\ud800-\udfff])`;class en{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(Qr,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){const t=this.input,r=this.tokenRegex.lastIndex;if(r===t.length)return new We("EOF",new Ve(this,r,r));const n=this.tokenRegex.exec(t);if(null===n||n.index!==r)throw new e(`Unexpected character: '${t[r]}'`,new We(t[r],new Ve(this,r,r+1)));const s=n[6]||n[3]||(n[2]?"\\ ":" ");if(14===this.catcodes[s]){const r=t.indexOf("\n",this.tokenRegex.lastIndex);if(-1===r){if(this.tokenRegex.lastIndex=t.length,this.settings.strict)throw new e("% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode")}else this.tokenRegex.lastIndex=r+1;return this.lex()}return new We(s,new Ve(this,r,this.tokenRegex.lastIndex))}}class tn{constructor(e=Object.create(null),t=Object.create(null)){this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push(Object.create(null))}endGroup(){if(0===this.undefStack.length)throw new e("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");const t=this.undefStack.pop();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(void 0===t[e]?delete this.current[e]:this.current[e]=t[e])}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:this.builtins[e]}set(e,t,r=!1){if(r){for(let t=0;t0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{const t=this.undefStack[this.undefStack.length-1];t&&!Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=this.current[e])}this.current[e]=t}}const rn={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class nn{constructor(e,t,r){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new tn(et,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new en(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,r,n;if(e){if(this.consumeSpaces(),"["!==this.future().text)return null;t=this.popToken(),({tokens:n,end:r}=this.consumeArg(["]"]))}else({tokens:n,start:t,end:r}=this.consumeArg());return this.pushToken(new We("EOF",r.loc)),this.pushTokens(n),new We("",Ve.range(t,r))}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(t){const r=[],n=t&&t.length>0;n||this.consumeSpaces();const s=this.future();let o,a=0,l=0;do{if(o=this.popToken(),r.push(o),"{"===o.text)++a;else if("}"===o.text){if(--a,-1===a)throw new e("Extra }",o)}else if("EOF"===o.text)throw new e("Unexpected end of input in a macro argument, expected '"+(t&&n?t[l]:"}")+"'",o);if(t&&n)if((0===a||1===a&&"{"===t[l])&&o.text===t[l]){if(++l,l===t.length){r.splice(-l,l);break}}else l=0}while(0!==a||n);return"{"===s.text&&"}"===r[r.length-1].text&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:s,end:o}}consumeArgs(t,r){if(r){if(r.length!==t+1)throw new e("The length of delimiters doesn't match the number of args!");const n=r[0];for(let t=0;tthis.settings.maxExpand)throw new e("Too many expansions: infinite loop or need to increase maxExpand setting");let o=s.tokens;const a=this.consumeArgs(s.numArgs,s.delimiters);if(s.numArgs){o=o.slice();for(let t=o.length-1;t>=0;--t){let r=o[t];if("#"===r.text){if(0===t)throw new e("Incomplete placeholder at end of macro body",r);if(r=o[--t],"#"===r.text)o.splice(t+1,1);else{if(!/^[1-9]$/.test(r.text))throw new e("Not a valid argument number",r);o.splice(t,2,...a[+r.text-1])}}}}return this.pushTokens(o),o.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){const e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new We(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(!1===this.expandOnce(!0)){const e=this.stack.pop();e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(e)}return t}expandMacroAsText(e){const t=this.expandMacro(e);return t?t.map(e=>e.text).join(""):t}_getExpansion(e){const t=this.macros.get(e);if(null==t)return t;if(1===e.length){const t=this.lexer.catcodes[e];if(null!=t&&13!==t)return}const r="function"==typeof t?t(this):t;if("string"==typeof r){let e=0;if(-1!==r.indexOf("#")){const t=r.replace(/##/g,"");for(;-1!==t.indexOf("#"+(e+1));)++e}const t=new en(r,this.settings),n=[];let s=t.lex();for(;"EOF"!==s.text;)n.push(s),s=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Xr,e)||Object.prototype.hasOwnProperty.call(D.math,e)||Object.prototype.hasOwnProperty.call(D.text,e)||Object.prototype.hasOwnProperty.call(rn,e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(Xr,e)&&!Xr[e].primitive}}const sn=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,on=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g","ʰ":"h","ⁱ":"i","ʲ":"j","ᵏ":"k","ˡ":"l","ᵐ":"m","ⁿ":"n","ᵒ":"o","ᵖ":"p","ʳ":"r","ˢ":"s","ᵗ":"t","ᵘ":"u","ᵛ":"v","ʷ":"w","ˣ":"x","ʸ":"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),an=Object.freeze({"𝒜":"A","ℬ":"B","𝒞":"C","𝒟":"D","ℰ":"E","ℱ":"F","𝒢":"G","ℋ":"H","ℐ":"I","𝒥":"J","𝒦":"K","ℒ":"L","ℳ":"M","𝒩":"N","𝒪":"O","𝒫":"P","𝒬":"Q","ℛ":"R","𝒮":"S","𝒯":"T","𝒰":"U","𝒱":"V","𝒲":"W","𝒳":"X","𝒴":"Y","𝒵":"Z"});var ln={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},cn={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","ḋ":"ḋ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","Ḋ":"Ḋ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"Ȯ","Ȱ":"Ȱ","Ő":"Ő","Ṕ":"Ṕ","Ṗ":"Ṗ","Ŕ":"Ŕ","Ř":"Ř","Ṙ":"Ṙ","Ś":"Ś","Ṥ":"Ṥ","Š":"Š","Ṧ":"Ṧ","Ŝ":"Ŝ","Ṡ":"Ṡ","Ť":"Ť","Ṫ":"Ṫ","Ú":"Ú","Ù":"Ù","Ü":"Ü","Ǘ":"Ǘ","Ǜ":"Ǜ","Ǖ":"Ǖ","Ǚ":"Ǚ","Ũ":"Ũ","Ṹ":"Ṹ","Ū":"Ū","Ṻ":"Ṻ","Ŭ":"Ŭ","Ǔ":"Ǔ","Û":"Û","Ů":"Ů","Ű":"Ű","Ṽ":"Ṽ","Ẃ":"Ẃ","Ẁ":"Ẁ","Ẅ":"Ẅ","Ŵ":"Ŵ","Ẇ":"Ẇ","Ẍ":"Ẍ","Ẋ":"Ẋ","Ý":"Ý","Ỳ":"Ỳ","Ÿ":"Ÿ","Ỹ":"Ỹ","Ȳ":"Ȳ","Ŷ":"Ŷ","Ẏ":"Ẏ","Ź":"Ź","Ž":"Ž","Ẑ":"Ẑ","Ż":"Ż","ά":"ά","ὰ":"ὰ","ᾱ":"ᾱ","ᾰ":"ᾰ","έ":"έ","ὲ":"ὲ","ή":"ή","ὴ":"ὴ","ί":"ί","ὶ":"ὶ","ϊ":"ϊ","ΐ":"ΐ","ῒ":"ῒ","ῑ":"ῑ","ῐ":"ῐ","ό":"ό","ὸ":"ὸ","ύ":"ύ","ὺ":"ὺ","ϋ":"ϋ","ΰ":"ΰ","ῢ":"ῢ","ῡ":"ῡ","ῠ":"ῠ","ώ":"ώ","ὼ":"ὼ","Ύ":"Ύ","Ὺ":"Ὺ","Ϋ":"Ϋ","Ῡ":"Ῡ","Ῠ":"Ῠ","Ώ":"Ώ","Ὼ":"Ὼ"};const mn=["bin","op","open","punct","rel"],pn=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,un=/^ *\\text/;class dn{constructor(e,t,r=!1){this.mode="math",this.gullet=new nn(e,t,this.mode),this.settings=t,this.isPreamble=r,this.leftrightDepth=0,this.prevAtomType=""}expect(t,r=!0){if(this.fetch().text!==t)throw new e(`Expected '${t}', got '${this.fetch().text}'`,this.fetch());r&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");const e=this.parseExpression(!1);if(this.expect("EOF"),this.isPreamble){const e=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([t,r])=>{e[t]=r}),this.gullet.endGroup(),e}const t=this.gullet.macros.get("\\df@tag");return this.gullet.endGroup(),t&&(this.gullet.macros.current["\\df@tag"]=t),e}static get endOfExpression(){return["}","\\endgroup","\\end","\\right","\\endtoggle","&"]}subparse(e){const t=this.nextToken;this.consume(),this.gullet.pushToken(new We("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t,r){const n=[];for(this.prevAtomType="";;){"math"===this.mode&&this.consumeSpaces();const s=this.fetch();if(-1!==dn.endOfExpression.indexOf(s.text))break;if(t&&s.text===t)break;if(r&&"\\middle"===s.text)break;if(e&&Xr[s.text]&&Xr[s.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&(n.push(o),this.prevAtomType="atom"===o.type?o.family:o.type)}return"text"===this.mode&&this.formLigatures(n),this.handleInfixNodes(n)}handleInfixNodes(t){let r,n=-1;for(let s=0;s=128||Kr.exec(r)))return null;if(this.settings.strict&&"math"===this.mode)throw new e(`Unicode text character "${r[0]}" used in math mode`,t);s={type:"textord",mode:"text",loc:Ve.range(t),text:r}}if(this.consume(),n)for(let r=0;r0&&n[0].type&&"array"===n[0].type&&n[0].addEqnNum)&&s.gullet.macros.get("\\df@tag")){if(!r.displayMode)throw new e("\\tag works only in display mode");s.gullet.feed("\\df@tag"),n=[{type:"tag",mode:"text",body:n,tag:s.parse()}]}return n},gn=[2,2,3,3];class fn{constructor(e){this.level=e.level,this.color=e.color,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontSize=e.fontSize||1,this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.maxSize=e.maxSize}extend(e){const t={level:this.level,color:this.color,font:this.font,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new fn(t)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:gn[this.level]})}withColor(e){return this.extend({color:e})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withFontSize(e){return this.extend({fontSize:e})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}getColor(){return this.color}}function bn(e){const t={};let r=0;const n=document.getElementsByClassName("tml-eqn");for(let e of n)for(r+=1,e.setAttribute("id","tml-eqn-"+String(r));"mtable"!==e.tagName;){if(e.getElementsByClassName("tml-label").length>0){const n=e.attributes.id.value;t[n]=String(r);break}e=e.parentElement}const s=document.getElementsByClassName("tml-tageqn");for(const e of s){if(e.getElementsByClassName("tml-label").length>0){const r=e.getElementsByClassName("tml-tag");if(r.length>0){const n=e.attributes.id.value;t[n]=r[0].textContent}}}[...e.getElementsByClassName("tml-ref")].forEach(e=>{const r=e.getAttribute("href");let n=t[r.slice(1)];-1===e.className.indexOf("tml-eqref")?(n=n.replace(/^\(/,""),n=n.replace(/\)$/,"")):("("!==n.charAt(0)&&(n="("+n),")"!==n.slice(-1)&&(n+=")"));const s=document.createElementNS("http://www.w3.org/1998/Math/MathML","mtext");s.appendChild(document.createTextNode(n));const o=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");o.appendChild(s),e.textContent="",e.appendChild(o)})}const yn=function(e,t,r){let n=r,s=0;const o=e.length;for(;ne.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;r=e.search(s),-1!==r;){r>0&&(n.push({type:"text",data:e.slice(0,r)}),e=e.slice(r));const s=t.findIndex(t=>e.startsWith(t.left));if(r=yn(t[s].right,e,t[s].left.length),-1===r)break;const o=e.slice(0,r+t[s].right.length),a=wn.test(o)?o:e.slice(t[s].left.length,r);n.push({type:"math",data:a,rawData:o,display:t[s].display}),e=e.slice(r+t[s].right.length)}return""!==e&&n.push({type:"text",data:e}),n}(t,r.delimiters);if(1===n.length&&"text"===n[0].type)return null;const s=document.createDocumentFragment();for(let t=0;t-1===e.indexOf(" "+t+" "))&&Tn(n,t)}}};let Sn=function(e,t,r={}){t.textContent="";const n="math"===t.tagName.toLowerCase();n&&(r.wrap="none");const s=On(e,r);n||s.children.length>1?(t.textContent="",s.children.forEach(e=>{t.appendChild(e.toNode())})):t.appendChild(s.toNode())};"undefined"!=typeof document&&"CSS1Compat"!==document.compatMode&&("undefined"!=typeof console&&console.warn("Warning: Temml doesn't work in quirks mode. Make sure your website has a suitable doctype."),Sn=function(){throw new e("Temml doesn't work in quirks mode.")});const On=function(t,r){const n=new u(r);try{const e=hn(t,n);return we(e,t,new fn({level:n.displayMode?Xe:Ze,maxSize:n.maxSize}),n)}catch(r){return function(t,r,n){if(n.throwOnError||!(t instanceof e))throw t;const s=new T(["temml-error"],[new S(r+"\n\n"+t.toString())]);return s.style.color=n.errorColor,s.style.whiteSpace="pre-line",s}(r,t,n)}};return{version:"0.14.0",render:Sn,renderToString:function(e,t){return On(e,t).toMarkup()},renderMathInElement:function(e,t){if(!e)throw new Error("No element provided to render");const r={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);r.fences?r.delimiters=(e=>{if("$"===e||"("===e)return kn[e];if("$+"===e||"(+"===e)return kn[e.slice(0,1)].concat(vn);return"ams"===e?vn:"all"===e?kn["("].concat(kn.$).concat(vn):xn})(r.fences):r.delimiters=r.delimiters||xn,r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||Object.create(null),Tn(e,r),bn(e)},postProcess:bn,ParseError:e,definePreamble:function(e,t){const r=new u(t);if(r.macros=Object.create(null),!("string"==typeof e||e instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new dn(e,r,!0);delete n.gullet.macros.current["\\df@tag"];return n.parse()},__parse:function(e,t){const r=new u(t);return hn(e,r)},__renderToMathMLTree:On,__defineSymbol:G,__defineMacro:Qe}}();
\ No newline at end of file