temml 0.12.2 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/contrib/mhchem/mhchem.min.js +1 -1
- package/dist/Temml-Asana.css +11 -13
- package/dist/Temml-Latin-Modern.css +11 -13
- package/dist/Temml-Libertinus.css +11 -13
- package/dist/Temml-Local.css +11 -13
- package/dist/Temml-NotoSans.css +11 -13
- package/dist/Temml-STIX2.css +11 -13
- package/dist/temml.cjs +227 -116
- package/dist/temml.js +227 -116
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +227 -116
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +2 -2
- package/src/Parser.js +11 -4
- package/src/Settings.js +1 -0
- package/src/functions/cancelto.js +2 -0
- package/src/functions/color.js +1 -1
- package/src/functions/{delimsizing.js → delimiter.js} +132 -42
- package/src/functions/enclose.js +1 -1
- package/src/functions/genfrac.js +32 -45
- package/src/functions/mclass.js +10 -2
- package/src/functions/op.js +1 -1
- package/src/functions/operatorname.js +9 -1
- package/src/functions/symbolsOrd.js +2 -2
- package/src/functions.js +1 -1
- package/src/linebreaking.js +3 -10
- package/src/macros.js +2 -2
- package/src/parseNode.js +1 -1
- package/src/parseTree.js +20 -4
- package/src/postProcess.js +1 -1
- package/src/symbols.js +2 -3
package/dist/temml.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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<e.length?e.slice(t,t+15)+"…":e.slice(t),s+=a+r+l}const a=new Error(s);return a.name="ParseError",a.__proto__=e.prototype,a.position=n,a}}e.prototype.__proto__=Error.prototype;const t=function(e,t){return void 0===e?t:e},r=/([A-Z])/g,n=function(e){return e.replace(r,"-$1").toLowerCase()},s={"&":"&",">":">","<":"<",'"':""","'":"'"},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αγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";class p{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.macros||{},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),this.maxSize=void 0===e.maxSize?[1/0,1/0]:Array.isArray(e.maxSize)?e.maxSize:[1/0,1/0],this.maxExpand=Math.max(0,t(e.maxExpand,1e3))}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 u={},d={};function h({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;e<t.length;++e)u[t[e]]=o;e&&s&&(d[e]=s)}function g({type:e,mathmlBuilder:t}){h({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:t})}const f=function(e){return"ordgroup"===e.type&&1===e.body.length?e.body[0]:e},b=function(e){return"ordgroup"===e.type?e.body:[e]};class y{constructor(e){this.children=e,this.classes=[],this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createDocumentFragment();for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e="";for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map((e=>e.toText())).join("")}}const w=function(e){return e.filter((e=>e)).join(" ")},x=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},k=function(e){const t=document.createElement(e);t.className=w(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<this.children.length;e++)t.appendChild(this.children[e].toNode());return t},v=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${a(w(this.classes))}"`);let r="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(r+=`${n(e)}:${this.style[e]};`);r&&(t+=` style="${r}"`);for(const e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&(t+=` ${e}="${a(this.attributes[e])}"`);t+=">";for(let e=0;e<this.children.length;e++)t+=this.children[e].toMarkup();return t+=`</${e}>`,t};class A{constructor(e,t,r){x.call(this,e,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return k.call(this,"span")}toMarkup(){return v.call(this,"span")}}let T=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.text)}};class S{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=w(this.classes));for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e=`<a href='${a(this.href)}'`;this.classes.length>0&&(e+=` class="${a(w(this.classes))}"`),e+=">";for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e+="</a>",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=`<img src='${this.src}' alt='${this.alt}'`,t="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${n(e)}:${this.style[e]};`);return t&&(e+=` style="${a(t)}"`),e+=">",e}}function O(e){return new y(e)}class B{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=w(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;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e="<"+this.type;for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="',e+=a(this.attributes[t]),e+='"');this.classes.length>0&&(e+=` class="${a(w(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<this.children.length;t++)e+=this.children[t].toMarkup();return e+="</"+this.type+">",e}toText(){return this.children.map((e=>e.toText())).join("")}}class C{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.toText())}toText(){return this.text}}const N=e=>{let t;return 1===e.length&&"mrow"===e[0].type?(t=e.pop(),t.type="mstyle"):t=new B("mstyle",e),t},z=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(const r of e.body)t+=z(r);else if(e.body)t+=z(e.body);else if("supsub"===e.type)t+=z(e.base),e.sub&&(t+=.7*z(e.sub)),e.sup&&(t+=.7*z(e.sup));else if("mathord"===e.type||"textord"===e.type)for(const r of e.text.split("")){const e=r.codePointAt(0);t+=96<e&&e<123||944<e&&e<970?.56:47<e&&e<58?.5:.92}else t+=1;return t},$={widehat:"^",widecheck:"ˇ",widetilde:"~",wideparen:"⏜",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overbracket:"⎴",underbracket:"⎵",overgroup:"⏠",overparen:"⏜",undergroup:"⏡",underparen:"⏝",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xrightleftarrows:"⇄",xtofrom:"⇄",xleftrightharpoons:"⇋",xrightleftharpoons:"⇌",yields:"→",yieldsLeft:"←",mesomerism:"↔",longrightharpoonup:"⇀",longleftharpoondown:"↽",eqrightharpoonup:"⇀",eqleftharpoondown:"↽","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"=",yieldsLeftRight:"⇄",chemequilibrium:"⇌"},E=function(e){const t=new C($[e.slice(1)]),r=new B("mo",[t]);return r.setAttribute("stretchy","true"),r},I=["\\widetilde","\\widehat","\\widecheck","\\utilde"],L=e=>{const t=E(e.label);if(I.includes(e.label)){const r=z(e.base);1<r&&r<1.6?t.classes.push("tml-crooked-2"):1.6<=r&&r<2.5?t.classes.push("tml-crooked-3"):2.5<=r&&t.classes.push("tml-crooked-4")}return t},F={bin:1,close:1,inner:1,open:1,punct:1,rel:1},M={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},G={math:{},text:{}};function D(e,t,r,n,s){G[e][n]={group:t,replace:r},s&&r&&(G[e][r]=G[e][n])}const j="math",P="text",R="accent-token",U="bin",H="close",V="inner",_="mathord",W="op-token",X="open",Z="punct",Y="rel",J="spacing",K="textord";D(j,Y,"≡","\\equiv",!0),D(j,Y,"≺","\\prec",!0),D(j,Y,"≻","\\succ",!0),D(j,Y,"∼","\\sim",!0),D(j,Y,"⟂","\\perp",!0),D(j,Y,"⪯","\\preceq",!0),D(j,Y,"⪰","\\succeq",!0),D(j,Y,"≃","\\simeq",!0),D(j,Y,"≌","\\backcong",!0),D(j,Y,"|","\\mid",!0),D(j,Y,"≪","\\ll",!0),D(j,Y,"≫","\\gg",!0),D(j,Y,"≍","\\asymp",!0),D(j,Y,"∥","\\parallel"),D(j,Y,"⌣","\\smile",!0),D(j,Y,"⊑","\\sqsubseteq",!0),D(j,Y,"⊒","\\sqsupseteq",!0),D(j,Y,"≐","\\doteq",!0),D(j,Y,"⌢","\\frown",!0),D(j,Y,"∋","\\ni",!0),D(j,Y,"∌","\\notni",!0),D(j,Y,"∝","\\propto",!0),D(j,Y,"⊢","\\vdash",!0),D(j,Y,"⊣","\\dashv",!0),D(j,Y,"∋","\\owns"),D(j,Y,"≘","\\arceq",!0),D(j,Y,"≙","\\wedgeq",!0),D(j,Y,"≚","\\veeeq",!0),D(j,Y,"≛","\\stareq",!0),D(j,Y,"≝","\\eqdef",!0),D(j,Y,"≞","\\measeq",!0),D(j,Y,"≟","\\questeq",!0),D(j,Y,"≠","\\ne",!0),D(j,Y,"≠","\\neq"),D(j,Y,"⩵","\\eqeq",!0),D(j,Y,"⩶","\\eqeqeq",!0),D(j,Y,"∷","\\dblcolon",!0),D(j,Y,"≔","\\coloneqq",!0),D(j,Y,"≕","\\eqqcolon",!0),D(j,Y,"∹","\\eqcolon",!0),D(j,Y,"⩴","\\Coloneqq",!0),D(j,Z,".","\\ldotp"),D(j,Z,"·","\\cdotp"),D(j,K,"#","\\#"),D(P,K,"#","\\#"),D(j,K,"&","\\&"),D(P,K,"&","\\&"),D(j,K,"ℵ","\\aleph",!0),D(j,K,"∀","\\forall",!0),D(j,K,"ℏ","\\hbar",!0),D(j,K,"∃","\\exists",!0),D(j,U,"∇","\\nabla",!0),D(j,K,"♭","\\flat",!0),D(j,K,"ℓ","\\ell",!0),D(j,K,"♮","\\natural",!0),D(j,K,"Å","\\Angstrom",!0),D(P,K,"Å","\\Angstrom",!0),D(j,K,"♣","\\clubsuit",!0),D(j,K,"♧","\\varclubsuit",!0),D(j,K,"℘","\\wp",!0),D(j,K,"♯","\\sharp",!0),D(j,K,"♢","\\diamondsuit",!0),D(j,K,"♦","\\vardiamondsuit",!0),D(j,K,"ℜ","\\Re",!0),D(j,K,"♡","\\heartsuit",!0),D(j,K,"♥","\\varheartsuit",!0),D(j,K,"ℑ","\\Im",!0),D(j,K,"♠","\\spadesuit",!0),D(j,K,"♤","\\varspadesuit",!0),D(j,K,"♀","\\female",!0),D(j,K,"♂","\\male",!0),D(j,K,"§","\\S",!0),D(P,K,"§","\\S"),D(j,K,"¶","\\P",!0),D(P,K,"¶","\\P"),D(P,K,"☺","\\smiley",!0),D(j,K,"☺","\\smiley",!0),D(j,K,"†","\\dag"),D(P,K,"†","\\dag"),D(P,K,"†","\\textdagger"),D(j,K,"‡","\\ddag"),D(P,K,"‡","\\ddag"),D(P,K,"‡","\\textdaggerdbl"),D(j,H,"⎱","\\rmoustache",!0),D(j,X,"⎰","\\lmoustache",!0),D(j,H,"⟯","\\rgroup",!0),D(j,X,"⟮","\\lgroup",!0),D(j,U,"∓","\\mp",!0),D(j,U,"⊖","\\ominus",!0),D(j,U,"⊎","\\uplus",!0),D(j,U,"⊓","\\sqcap",!0),D(j,U,"∗","\\ast"),D(j,U,"⊔","\\sqcup",!0),D(j,U,"◯","\\bigcirc",!0),D(j,U,"∙","\\bullet",!0),D(j,U,"‡","\\ddagger"),D(j,U,"≀","\\wr",!0),D(j,U,"⨿","\\amalg"),D(j,U,"&","\\And"),D(j,U,"⫽","\\sslash",!0),D(j,Y,"⟵","\\longleftarrow",!0),D(j,Y,"⇐","\\Leftarrow",!0),D(j,Y,"⟸","\\Longleftarrow",!0),D(j,Y,"⟶","\\longrightarrow",!0),D(j,Y,"⇒","\\Rightarrow",!0),D(j,Y,"⟹","\\Longrightarrow",!0),D(j,Y,"↔","\\leftrightarrow",!0),D(j,Y,"⟷","\\longleftrightarrow",!0),D(j,Y,"⇔","\\Leftrightarrow",!0),D(j,Y,"⟺","\\Longleftrightarrow",!0),D(j,Y,"↤","\\mapsfrom",!0),D(j,Y,"↦","\\mapsto",!0),D(j,Y,"⟼","\\longmapsto",!0),D(j,Y,"↗","\\nearrow",!0),D(j,Y,"↩","\\hookleftarrow",!0),D(j,Y,"↪","\\hookrightarrow",!0),D(j,Y,"↘","\\searrow",!0),D(j,Y,"↼","\\leftharpoonup",!0),D(j,Y,"⇀","\\rightharpoonup",!0),D(j,Y,"↙","\\swarrow",!0),D(j,Y,"↽","\\leftharpoondown",!0),D(j,Y,"⇁","\\rightharpoondown",!0),D(j,Y,"↖","\\nwarrow",!0),D(j,Y,"⇌","\\rightleftharpoons",!0),D(j,_,"↯","\\lightning",!0),D(j,_,"∎","\\QED",!0),D(j,_,"‰","\\permil",!0),D(P,K,"‰","\\permil"),D(j,_,"☉","\\astrosun",!0),D(j,_,"☼","\\sun",!0),D(j,_,"☾","\\leftmoon",!0),D(j,_,"☽","\\rightmoon",!0),D(j,_,"⊕","\\Earth"),D(j,Y,"≮","\\nless",!0),D(j,Y,"⪇","\\lneq",!0),D(j,Y,"≨","\\lneqq",!0),D(j,Y,"≨︀","\\lvertneqq"),D(j,Y,"⋦","\\lnsim",!0),D(j,Y,"⪉","\\lnapprox",!0),D(j,Y,"⊀","\\nprec",!0),D(j,Y,"⋠","\\npreceq",!0),D(j,Y,"⋨","\\precnsim",!0),D(j,Y,"⪹","\\precnapprox",!0),D(j,Y,"≁","\\nsim",!0),D(j,Y,"∤","\\nmid",!0),D(j,Y,"∤","\\nshortmid"),D(j,Y,"⊬","\\nvdash",!0),D(j,Y,"⊭","\\nvDash",!0),D(j,Y,"⋪","\\ntriangleleft"),D(j,Y,"⋬","\\ntrianglelefteq",!0),D(j,Y,"⊄","\\nsubset",!0),D(j,Y,"⊅","\\nsupset",!0),D(j,Y,"⊊","\\subsetneq",!0),D(j,Y,"⊊︀","\\varsubsetneq"),D(j,Y,"⫋","\\subsetneqq",!0),D(j,Y,"⫋︀","\\varsubsetneqq"),D(j,Y,"≯","\\ngtr",!0),D(j,Y,"⪈","\\gneq",!0),D(j,Y,"≩","\\gneqq",!0),D(j,Y,"≩︀","\\gvertneqq"),D(j,Y,"⋧","\\gnsim",!0),D(j,Y,"⪊","\\gnapprox",!0),D(j,Y,"⊁","\\nsucc",!0),D(j,Y,"⋡","\\nsucceq",!0),D(j,Y,"⋩","\\succnsim",!0),D(j,Y,"⪺","\\succnapprox",!0),D(j,Y,"≆","\\ncong",!0),D(j,Y,"∦","\\nparallel",!0),D(j,Y,"∦","\\nshortparallel"),D(j,Y,"⊯","\\nVDash",!0),D(j,Y,"⋫","\\ntriangleright"),D(j,Y,"⋭","\\ntrianglerighteq",!0),D(j,Y,"⊋","\\supsetneq",!0),D(j,Y,"⊋","\\varsupsetneq"),D(j,Y,"⫌","\\supsetneqq",!0),D(j,Y,"⫌︀","\\varsupsetneqq"),D(j,Y,"⊮","\\nVdash",!0),D(j,Y,"⪵","\\precneqq",!0),D(j,Y,"⪶","\\succneqq",!0),D(j,U,"⊴","\\unlhd"),D(j,U,"⊵","\\unrhd"),D(j,Y,"↚","\\nleftarrow",!0),D(j,Y,"↛","\\nrightarrow",!0),D(j,Y,"⇍","\\nLeftarrow",!0),D(j,Y,"⇏","\\nRightarrow",!0),D(j,Y,"↮","\\nleftrightarrow",!0),D(j,Y,"⇎","\\nLeftrightarrow",!0),D(j,Y,"△","\\vartriangle"),D(j,K,"ℏ","\\hslash"),D(j,K,"▽","\\triangledown"),D(j,K,"◊","\\lozenge"),D(j,K,"Ⓢ","\\circledS"),D(j,K,"®","\\circledR",!0),D(P,K,"®","\\circledR"),D(P,K,"®","\\textregistered"),D(j,K,"∡","\\measuredangle",!0),D(j,K,"∄","\\nexists"),D(j,K,"℧","\\mho"),D(j,K,"Ⅎ","\\Finv",!0),D(j,K,"⅁","\\Game",!0),D(j,K,"‵","\\backprime"),D(j,K,"‶","\\backdprime"),D(j,K,"‷","\\backtrprime"),D(j,K,"▲","\\blacktriangle"),D(j,K,"▼","\\blacktriangledown"),D(j,K,"■","\\blacksquare"),D(j,K,"⧫","\\blacklozenge"),D(j,K,"★","\\bigstar"),D(j,K,"∢","\\sphericalangle",!0),D(j,K,"∁","\\complement",!0),D(j,K,"╱","\\diagup"),D(j,K,"╲","\\diagdown"),D(j,K,"□","\\square"),D(j,K,"□","\\Box"),D(j,K,"◊","\\Diamond"),D(j,K,"¥","\\yen",!0),D(P,K,"¥","\\yen",!0),D(j,K,"✓","\\checkmark",!0),D(P,K,"✓","\\checkmark"),D(j,K,"✗","\\ballotx",!0),D(P,K,"✗","\\ballotx"),D(P,K,"•","\\textbullet"),D(j,K,"ℶ","\\beth",!0),D(j,K,"ℸ","\\daleth",!0),D(j,K,"ℷ","\\gimel",!0),D(j,K,"ϝ","\\digamma",!0),D(j,K,"ϰ","\\varkappa"),D(j,X,"⌜","\\ulcorner",!0),D(j,H,"⌝","\\urcorner",!0),D(j,X,"⌞","\\llcorner",!0),D(j,H,"⌟","\\lrcorner",!0),D(j,Y,"≦","\\leqq",!0),D(j,Y,"⩽","\\leqslant",!0),D(j,Y,"⪕","\\eqslantless",!0),D(j,Y,"≲","\\lesssim",!0),D(j,Y,"⪅","\\lessapprox",!0),D(j,Y,"≊","\\approxeq",!0),D(j,U,"⋖","\\lessdot"),D(j,Y,"⋘","\\lll",!0),D(j,Y,"≶","\\lessgtr",!0),D(j,Y,"⋚","\\lesseqgtr",!0),D(j,Y,"⪋","\\lesseqqgtr",!0),D(j,Y,"≑","\\doteqdot"),D(j,Y,"≓","\\risingdotseq",!0),D(j,Y,"≒","\\fallingdotseq",!0),D(j,Y,"∽","\\backsim",!0),D(j,Y,"⋍","\\backsimeq",!0),D(j,Y,"⫅","\\subseteqq",!0),D(j,Y,"⋐","\\Subset",!0),D(j,Y,"⊏","\\sqsubset",!0),D(j,Y,"≼","\\preccurlyeq",!0),D(j,Y,"⋞","\\curlyeqprec",!0),D(j,Y,"≾","\\precsim",!0),D(j,Y,"⪷","\\precapprox",!0),D(j,Y,"⊲","\\vartriangleleft"),D(j,Y,"⊴","\\trianglelefteq"),D(j,Y,"⊨","\\vDash",!0),D(j,Y,"⊫","\\VDash",!0),D(j,Y,"⊪","\\Vvdash",!0),D(j,Y,"⌣","\\smallsmile"),D(j,Y,"⌢","\\smallfrown"),D(j,Y,"≏","\\bumpeq",!0),D(j,Y,"≎","\\Bumpeq",!0),D(j,Y,"≧","\\geqq",!0),D(j,Y,"⩾","\\geqslant",!0),D(j,Y,"⪖","\\eqslantgtr",!0),D(j,Y,"≳","\\gtrsim",!0),D(j,Y,"⪆","\\gtrapprox",!0),D(j,U,"⋗","\\gtrdot"),D(j,Y,"⋙","\\ggg",!0),D(j,Y,"≷","\\gtrless",!0),D(j,Y,"⋛","\\gtreqless",!0),D(j,Y,"⪌","\\gtreqqless",!0),D(j,Y,"≖","\\eqcirc",!0),D(j,Y,"≗","\\circeq",!0),D(j,Y,"≜","\\triangleq",!0),D(j,Y,"∼","\\thicksim"),D(j,Y,"≈","\\thickapprox"),D(j,Y,"⫆","\\supseteqq",!0),D(j,Y,"⋑","\\Supset",!0),D(j,Y,"⊐","\\sqsupset",!0),D(j,Y,"≽","\\succcurlyeq",!0),D(j,Y,"⋟","\\curlyeqsucc",!0),D(j,Y,"≿","\\succsim",!0),D(j,Y,"⪸","\\succapprox",!0),D(j,Y,"⊳","\\vartriangleright"),D(j,Y,"⊵","\\trianglerighteq"),D(j,Y,"⊩","\\Vdash",!0),D(j,Y,"∣","\\shortmid"),D(j,Y,"∥","\\shortparallel"),D(j,Y,"≬","\\between",!0),D(j,Y,"⋔","\\pitchfork",!0),D(j,Y,"∝","\\varpropto"),D(j,Y,"◀","\\blacktriangleleft"),D(j,Y,"∴","\\therefore",!0),D(j,Y,"∍","\\backepsilon"),D(j,Y,"▶","\\blacktriangleright"),D(j,Y,"∵","\\because",!0),D(j,Y,"⋘","\\llless"),D(j,Y,"⋙","\\gggtr"),D(j,U,"⊲","\\lhd"),D(j,U,"⊳","\\rhd"),D(j,Y,"≂","\\eqsim",!0),D(j,Y,"≑","\\Doteq",!0),D(j,Y,"⥽","\\strictif",!0),D(j,Y,"⥼","\\strictfi",!0),D(j,U,"∔","\\dotplus",!0),D(j,U,"∖","\\smallsetminus"),D(j,U,"⋒","\\Cap",!0),D(j,U,"⋓","\\Cup",!0),D(j,U,"⩞","\\doublebarwedge",!0),D(j,U,"⊟","\\boxminus",!0),D(j,U,"⊞","\\boxplus",!0),D(j,U,"⧄","\\boxslash",!0),D(j,U,"⋇","\\divideontimes",!0),D(j,U,"⋉","\\ltimes",!0),D(j,U,"⋊","\\rtimes",!0),D(j,U,"⋋","\\leftthreetimes",!0),D(j,U,"⋌","\\rightthreetimes",!0),D(j,U,"⋏","\\curlywedge",!0),D(j,U,"⋎","\\curlyvee",!0),D(j,U,"⊝","\\circleddash",!0),D(j,U,"⊛","\\circledast",!0),D(j,U,"⊺","\\intercal",!0),D(j,U,"⋒","\\doublecap"),D(j,U,"⋓","\\doublecup"),D(j,U,"⊠","\\boxtimes",!0),D(j,U,"⋈","\\bowtie",!0),D(j,U,"⋈","\\Join"),D(j,U,"⟕","\\leftouterjoin",!0),D(j,U,"⟖","\\rightouterjoin",!0),D(j,U,"⟗","\\fullouterjoin",!0),D(j,U,"∸","\\dotminus",!0),D(j,U,"⟑","\\wedgedot",!0),D(j,U,"⟇","\\veedot",!0),D(j,U,"⩢","\\doublebarvee",!0),D(j,U,"⩣","\\veedoublebar",!0),D(j,U,"⩟","\\wedgebar",!0),D(j,U,"⩠","\\wedgedoublebar",!0),D(j,U,"⩔","\\Vee",!0),D(j,U,"⩓","\\Wedge",!0),D(j,U,"⩃","\\barcap",!0),D(j,U,"⩂","\\barcup",!0),D(j,U,"⩈","\\capbarcup",!0),D(j,U,"⩀","\\capdot",!0),D(j,U,"⩇","\\capovercup",!0),D(j,U,"⩆","\\cupovercap",!0),D(j,U,"⩍","\\closedvarcap",!0),D(j,U,"⩌","\\closedvarcup",!0),D(j,U,"⨪","\\minusdot",!0),D(j,U,"⨫","\\minusfdots",!0),D(j,U,"⨬","\\minusrdots",!0),D(j,U,"⊻","\\Xor",!0),D(j,U,"⊼","\\Nand",!0),D(j,U,"⊽","\\Nor",!0),D(j,U,"⊽","\\barvee"),D(j,U,"⫴","\\interleave",!0),D(j,U,"⧢","\\shuffle",!0),D(j,U,"⫶","\\threedotcolon",!0),D(j,U,"⦂","\\typecolon",!0),D(j,U,"∾","\\invlazys",!0),D(j,U,"⩋","\\twocaps",!0),D(j,U,"⩊","\\twocups",!0),D(j,U,"⩎","\\Sqcap",!0),D(j,U,"⩏","\\Sqcup",!0),D(j,U,"⩖","\\veeonvee",!0),D(j,U,"⩕","\\wedgeonwedge",!0),D(j,U,"⧗","\\blackhourglass",!0),D(j,U,"⧆","\\boxast",!0),D(j,U,"⧈","\\boxbox",!0),D(j,U,"⧇","\\boxcircle",!0),D(j,U,"⊜","\\circledequal",!0),D(j,U,"⦷","\\circledparallel",!0),D(j,U,"⦶","\\circledvert",!0),D(j,U,"⦵","\\circlehbar",!0),D(j,U,"⟡","\\concavediamond",!0),D(j,U,"⟢","\\concavediamondtickleft",!0),D(j,U,"⟣","\\concavediamondtickright",!0),D(j,U,"⋄","\\diamond",!0),D(j,U,"⧖","\\hourglass",!0),D(j,U,"⟠","\\lozengeminus",!0),D(j,U,"⌽","\\obar",!0),D(j,U,"⦸","\\obslash",!0),D(j,U,"⨸","\\odiv",!0),D(j,U,"⧁","\\ogreaterthan",!0),D(j,U,"⧀","\\olessthan",!0),D(j,U,"⦹","\\operp",!0),D(j,U,"⨷","\\Otimes",!0),D(j,U,"⨶","\\otimeshat",!0),D(j,U,"⋆","\\star",!0),D(j,U,"△","\\triangle",!0),D(j,U,"⨺","\\triangleminus",!0),D(j,U,"⨹","\\triangleplus",!0),D(j,U,"⨻","\\triangletimes",!0),D(j,U,"⟤","\\whitesquaretickleft",!0),D(j,U,"⟥","\\whitesquaretickright",!0),D(j,U,"⨳","\\smashtimes",!0),D(j,Y,"⇢","\\dashrightarrow",!0),D(j,Y,"⇠","\\dashleftarrow",!0),D(j,Y,"⇇","\\leftleftarrows",!0),D(j,Y,"⇆","\\leftrightarrows",!0),D(j,Y,"⇚","\\Lleftarrow",!0),D(j,Y,"↞","\\twoheadleftarrow",!0),D(j,Y,"↢","\\leftarrowtail",!0),D(j,Y,"↫","\\looparrowleft",!0),D(j,Y,"⇋","\\leftrightharpoons",!0),D(j,Y,"↶","\\curvearrowleft",!0),D(j,Y,"↺","\\circlearrowleft",!0),D(j,Y,"↰","\\Lsh",!0),D(j,Y,"⇈","\\upuparrows",!0),D(j,Y,"↿","\\upharpoonleft",!0),D(j,Y,"⇃","\\downharpoonleft",!0),D(j,Y,"⊶","\\origof",!0),D(j,Y,"⊷","\\imageof",!0),D(j,Y,"⊸","\\multimap",!0),D(j,Y,"↭","\\leftrightsquigarrow",!0),D(j,Y,"⇉","\\rightrightarrows",!0),D(j,Y,"⇄","\\rightleftarrows",!0),D(j,Y,"↠","\\twoheadrightarrow",!0),D(j,Y,"↣","\\rightarrowtail",!0),D(j,Y,"↬","\\looparrowright",!0),D(j,Y,"↷","\\curvearrowright",!0),D(j,Y,"↻","\\circlearrowright",!0),D(j,Y,"↱","\\Rsh",!0),D(j,Y,"⇊","\\downdownarrows",!0),D(j,Y,"↾","\\upharpoonright",!0),D(j,Y,"⇂","\\downharpoonright",!0),D(j,Y,"⇝","\\rightsquigarrow",!0),D(j,Y,"⇝","\\leadsto"),D(j,Y,"⇛","\\Rrightarrow",!0),D(j,Y,"↾","\\restriction"),D(j,K,"‘","`"),D(j,K,"$","\\$"),D(P,K,"$","\\$"),D(P,K,"$","\\textdollar"),D(j,K,"¢","\\cent"),D(P,K,"¢","\\cent"),D(j,K,"%","\\%"),D(P,K,"%","\\%"),D(j,K,"_","\\_"),D(P,K,"_","\\_"),D(P,K,"_","\\textunderscore"),D(P,K,"␣","\\textvisiblespace",!0),D(j,K,"∠","\\angle",!0),D(j,K,"∞","\\infty",!0),D(j,K,"′","\\prime"),D(j,K,"″","\\dprime"),D(j,K,"‴","\\trprime"),D(j,K,"⁗","\\qprime"),D(j,K,"△","\\triangle"),D(P,K,"Α","\\Alpha",!0),D(P,K,"Β","\\Beta",!0),D(P,K,"Γ","\\Gamma",!0),D(P,K,"Δ","\\Delta",!0),D(P,K,"Ε","\\Epsilon",!0),D(P,K,"Ζ","\\Zeta",!0),D(P,K,"Η","\\Eta",!0),D(P,K,"Θ","\\Theta",!0),D(P,K,"Ι","\\Iota",!0),D(P,K,"Κ","\\Kappa",!0),D(P,K,"Λ","\\Lambda",!0),D(P,K,"Μ","\\Mu",!0),D(P,K,"Ν","\\Nu",!0),D(P,K,"Ξ","\\Xi",!0),D(P,K,"Ο","\\Omicron",!0),D(P,K,"Π","\\Pi",!0),D(P,K,"Ρ","\\Rho",!0),D(P,K,"Σ","\\Sigma",!0),D(P,K,"Τ","\\Tau",!0),D(P,K,"Υ","\\Upsilon",!0),D(P,K,"Φ","\\Phi",!0),D(P,K,"Χ","\\Chi",!0),D(P,K,"Ψ","\\Psi",!0),D(P,K,"Ω","\\Omega",!0),D(j,_,"Α","\\Alpha",!0),D(j,_,"Β","\\Beta",!0),D(j,_,"Γ","\\Gamma",!0),D(j,_,"Δ","\\Delta",!0),D(j,_,"Ε","\\Epsilon",!0),D(j,_,"Ζ","\\Zeta",!0),D(j,_,"Η","\\Eta",!0),D(j,_,"Θ","\\Theta",!0),D(j,_,"Ι","\\Iota",!0),D(j,_,"Κ","\\Kappa",!0),D(j,_,"Λ","\\Lambda",!0),D(j,_,"Μ","\\Mu",!0),D(j,_,"Ν","\\Nu",!0),D(j,_,"Ξ","\\Xi",!0),D(j,_,"Ο","\\Omicron",!0),D(j,_,"Π","\\Pi",!0),D(j,_,"Ρ","\\Rho",!0),D(j,_,"Σ","\\Sigma",!0),D(j,_,"Τ","\\Tau",!0),D(j,_,"Υ","\\Upsilon",!0),D(j,_,"Φ","\\Phi",!0),D(j,_,"Χ","\\Chi",!0),D(j,_,"Ψ","\\Psi",!0),D(j,_,"Ω","\\Omega",!0),D(j,X,"¬","\\neg",!0),D(j,X,"¬","\\lnot"),D(j,K,"⊤","\\top"),D(j,K,"⊥","\\bot"),D(j,K,"∅","\\emptyset"),D(j,K,"⌀","\\varnothing"),D(j,_,"α","\\alpha",!0),D(j,_,"β","\\beta",!0),D(j,_,"γ","\\gamma",!0),D(j,_,"δ","\\delta",!0),D(j,_,"ϵ","\\epsilon",!0),D(j,_,"ζ","\\zeta",!0),D(j,_,"η","\\eta",!0),D(j,_,"θ","\\theta",!0),D(j,_,"ι","\\iota",!0),D(j,_,"κ","\\kappa",!0),D(j,_,"λ","\\lambda",!0),D(j,_,"μ","\\mu",!0),D(j,_,"ν","\\nu",!0),D(j,_,"ξ","\\xi",!0),D(j,_,"ο","\\omicron",!0),D(j,_,"π","\\pi",!0),D(j,_,"ρ","\\rho",!0),D(j,_,"σ","\\sigma",!0),D(j,_,"τ","\\tau",!0),D(j,_,"υ","\\upsilon",!0),D(j,_,"ϕ","\\phi",!0),D(j,_,"χ","\\chi",!0),D(j,_,"ψ","\\psi",!0),D(j,_,"ω","\\omega",!0),D(j,_,"ε","\\varepsilon",!0),D(j,_,"ϑ","\\vartheta",!0),D(j,_,"ϖ","\\varpi",!0),D(j,_,"ϱ","\\varrho",!0),D(j,_,"ς","\\varsigma",!0),D(j,_,"φ","\\varphi",!0),D(j,_,"Ϙ","\\Coppa",!0),D(j,_,"ϙ","\\coppa",!0),D(j,_,"ϙ","\\varcoppa",!0),D(j,_,"Ϟ","\\Koppa",!0),D(j,_,"ϟ","\\koppa",!0),D(j,_,"Ϡ","\\Sampi",!0),D(j,_,"ϡ","\\sampi",!0),D(j,_,"Ϛ","\\Stigma",!0),D(j,_,"ϛ","\\stigma",!0),D(j,_,"⫫","\\Bot"),D(j,K,"ð","\\eth",!0),D(P,K,"ð","ð"),D(j,K,"Å","\\AA"),D(P,K,"Å","\\AA",!0),D(j,K,"Æ","\\AE",!0),D(P,K,"Æ","\\AE",!0),D(j,K,"Ð","\\DH",!0),D(P,K,"Ð","\\DH",!0),D(j,K,"Þ","\\TH",!0),D(P,K,"Þ","\\TH",!0),D(j,K,"ß","\\ss",!0),D(P,K,"ß","\\ss",!0),D(j,K,"å","\\aa"),D(P,K,"å","\\aa",!0),D(j,K,"æ","\\ae",!0),D(P,K,"æ","\\ae",!0),D(j,K,"ð","\\dh"),D(P,K,"ð","\\dh",!0),D(j,K,"þ","\\th",!0),D(P,K,"þ","\\th",!0),D(j,K,"Đ","\\DJ",!0),D(P,K,"Đ","\\DJ",!0),D(j,K,"đ","\\dj",!0),D(P,K,"đ","\\dj",!0),D(j,K,"Ł","\\L",!0),D(P,K,"Ł","\\L",!0),D(j,K,"Ł","\\l",!0),D(P,K,"Ł","\\l",!0),D(j,K,"Ŋ","\\NG",!0),D(P,K,"Ŋ","\\NG",!0),D(j,K,"ŋ","\\ng",!0),D(P,K,"ŋ","\\ng",!0),D(j,K,"Œ","\\OE",!0),D(P,K,"Œ","\\OE",!0),D(j,K,"œ","\\oe",!0),D(P,K,"œ","\\oe",!0),D(j,U,"∗","∗",!0),D(j,U,"+","+"),D(j,U,"∗","*"),D(j,U,"⁄","/",!0),D(j,U,"⁄","⁄"),D(j,U,"−","-",!0),D(j,U,"⋅","\\cdot",!0),D(j,U,"∘","\\circ",!0),D(j,U,"÷","\\div",!0),D(j,U,"±","\\pm",!0),D(j,U,"×","\\times",!0),D(j,U,"∩","\\cap",!0),D(j,U,"∪","\\cup",!0),D(j,U,"∖","\\setminus",!0),D(j,U,"∧","\\land"),D(j,U,"∨","\\lor"),D(j,U,"∧","\\wedge",!0),D(j,U,"∨","\\vee",!0),D(j,X,"⟦","\\llbracket",!0),D(j,H,"⟧","\\rrbracket",!0),D(j,X,"⟨","\\langle",!0),D(j,X,"⟪","\\lAngle",!0),D(j,X,"⦉","\\llangle",!0),D(j,X,"|","\\lvert"),D(j,X,"‖","\\lVert",!0),D(j,K,"!","\\oc"),D(j,K,"?","\\wn"),D(j,K,"↓","\\shpos"),D(j,K,"↕","\\shift"),D(j,K,"↑","\\shneg"),D(j,H,"?","?"),D(j,H,"!","!"),D(j,H,"‼","‼"),D(j,H,"⟩","\\rangle",!0),D(j,H,"⟫","\\rAngle",!0),D(j,H,"⦊","\\rrangle",!0),D(j,H,"|","\\rvert"),D(j,H,"‖","\\rVert"),D(j,X,"⦃","\\lBrace",!0),D(j,H,"⦄","\\rBrace",!0),D(j,Y,"=","\\equal",!0),D(j,Y,":",":"),D(j,Y,"≈","\\approx",!0),D(j,Y,"≅","\\cong",!0),D(j,Y,"≥","\\ge"),D(j,Y,"≥","\\geq",!0),D(j,Y,"←","\\gets"),D(j,Y,">","\\gt",!0),D(j,Y,"∈","\\in",!0),D(j,Y,"∉","\\notin",!0),D(j,Y,"","\\@not"),D(j,Y,"⊂","\\subset",!0),D(j,Y,"⊃","\\supset",!0),D(j,Y,"⊆","\\subseteq",!0),D(j,Y,"⊇","\\supseteq",!0),D(j,Y,"⊈","\\nsubseteq",!0),D(j,Y,"⊈","\\nsubseteqq"),D(j,Y,"⊉","\\nsupseteq",!0),D(j,Y,"⊉","\\nsupseteqq"),D(j,Y,"⊨","\\models"),D(j,Y,"←","\\leftarrow",!0),D(j,Y,"≤","\\le"),D(j,Y,"≤","\\leq",!0),D(j,Y,"<","\\lt",!0),D(j,Y,"→","\\rightarrow",!0),D(j,Y,"→","\\to"),D(j,Y,"≱","\\ngeq",!0),D(j,Y,"≱","\\ngeqq"),D(j,Y,"≱","\\ngeqslant"),D(j,Y,"≰","\\nleq",!0),D(j,Y,"≰","\\nleqq"),D(j,Y,"≰","\\nleqslant"),D(j,Y,"⫫","\\Perp",!0),D(j,J," ","\\ "),D(j,J," ","\\space"),D(j,J," ","\\nobreakspace"),D(P,J," ","\\ "),D(P,J," "," "),D(P,J," ","\\space"),D(P,J," ","\\nobreakspace"),D(j,J,null,"\\nobreak"),D(j,J,null,"\\allowbreak"),D(j,Z,",",","),D(P,Z,":",":"),D(j,Z,";",";"),D(j,U,"⊼","\\barwedge"),D(j,U,"⊻","\\veebar"),D(j,U,"⊙","\\odot",!0),D(j,U,"⊕︎","\\oplus"),D(j,U,"⊗","\\otimes",!0),D(j,K,"∂","\\partial",!0),D(j,U,"⊘","\\oslash",!0),D(j,U,"⊚","\\circledcirc",!0),D(j,U,"⊡","\\boxdot",!0),D(j,U,"△","\\bigtriangleup"),D(j,U,"▽","\\bigtriangledown"),D(j,U,"†","\\dagger"),D(j,U,"⋄","\\diamond"),D(j,U,"◃","\\triangleleft"),D(j,U,"▹","\\triangleright"),D(j,X,"{","\\{"),D(P,K,"{","\\{"),D(P,K,"{","\\textbraceleft"),D(j,H,"}","\\}"),D(P,K,"}","\\}"),D(P,K,"}","\\textbraceright"),D(j,X,"{","\\lbrace"),D(j,H,"}","\\rbrace"),D(j,X,"[","\\lbrack",!0),D(P,K,"[","\\lbrack",!0),D(j,H,"]","\\rbrack",!0),D(P,K,"]","\\rbrack",!0),D(j,X,"(","\\lparen",!0),D(j,H,")","\\rparen",!0),D(j,X,"⦇","\\llparenthesis",!0),D(j,H,"⦈","\\rrparenthesis",!0),D(P,K,"<","\\textless",!0),D(P,K,">","\\textgreater",!0),D(j,X,"⌊","\\lfloor",!0),D(j,H,"⌋","\\rfloor",!0),D(j,X,"⌈","\\lceil",!0),D(j,H,"⌉","\\rceil",!0),D(j,K,"\\","\\backslash"),D(j,K,"|","|"),D(j,K,"|","\\vert"),D(P,K,"|","\\textbar",!0),D(j,K,"‖","\\|"),D(j,K,"‖","\\Vert"),D(P,K,"‖","\\textbardbl"),D(P,K,"~","\\textasciitilde"),D(P,K,"\\","\\textbackslash"),D(P,K,"^","\\textasciicircum"),D(j,Y,"↑","\\uparrow",!0),D(j,Y,"⇑","\\Uparrow",!0),D(j,Y,"↓","\\downarrow",!0),D(j,Y,"⇓","\\Downarrow",!0),D(j,Y,"↕","\\updownarrow",!0),D(j,Y,"⇕","\\Updownarrow",!0),D(j,W,"∐","\\coprod"),D(j,W,"⋁","\\bigvee"),D(j,W,"⋀","\\bigwedge"),D(j,W,"⨄","\\biguplus"),D(j,W,"⨄","\\bigcupplus"),D(j,W,"⨃","\\bigcupdot"),D(j,W,"⨇","\\bigdoublevee"),D(j,W,"⨈","\\bigdoublewedge"),D(j,W,"⋂","\\bigcap"),D(j,W,"⋃","\\bigcup"),D(j,W,"∫","\\int"),D(j,W,"∫","\\intop"),D(j,W,"∬","\\iint"),D(j,W,"∭","\\iiint"),D(j,W,"∏","\\prod"),D(j,W,"∑","\\sum"),D(j,W,"⨂","\\bigotimes"),D(j,W,"⨁","\\bigoplus"),D(j,W,"⨀","\\bigodot"),D(j,W,"⨉","\\bigtimes"),D(j,W,"∮","\\oint"),D(j,W,"∯","\\oiint"),D(j,W,"∰","\\oiiint"),D(j,W,"∱","\\intclockwise"),D(j,W,"∲","\\varointclockwise"),D(j,W,"⨌","\\iiiint"),D(j,W,"⨍","\\intbar"),D(j,W,"⨎","\\intBar"),D(j,W,"⨏","\\fint"),D(j,W,"⨒","\\rppolint"),D(j,W,"⨓","\\scpolint"),D(j,W,"⨕","\\pointint"),D(j,W,"⨖","\\sqint"),D(j,W,"⨗","\\intlarhk"),D(j,W,"⨘","\\intx"),D(j,W,"⨙","\\intcap"),D(j,W,"⨚","\\intcup"),D(j,W,"⨅","\\bigsqcap"),D(j,W,"⨆","\\bigsqcup"),D(j,W,"∫","\\smallint"),D(P,V,"…","\\textellipsis"),D(j,V,"…","\\mathellipsis"),D(P,V,"…","\\ldots",!0),D(j,V,"…","\\ldots",!0),D(j,V,"⋰","\\iddots",!0),D(j,V,"⋯","\\@cdots",!0),D(j,V,"⋱","\\ddots",!0),D(j,K,"⋮","\\varvdots"),D(P,K,"⋮","\\varvdots"),D(j,R,"´","\\acute"),D(j,R,"`","\\grave"),D(j,R,"¨","\\ddot"),D(j,R,"…","\\dddot"),D(j,R,"….","\\ddddot"),D(j,R,"~","\\tilde"),D(j,R,"‾","\\bar"),D(j,R,"˘","\\breve"),D(j,R,"ˇ","\\check"),D(j,R,"^","\\hat"),D(j,R,"→","\\vec"),D(j,R,"˙","\\dot"),D(j,R,"˚","\\mathring"),D(j,_,"ı","\\imath",!0),D(j,_,"ȷ","\\jmath",!0),D(j,K,"ı","ı"),D(j,K,"ȷ","ȷ"),D(P,K,"ı","\\i",!0),D(P,K,"ȷ","\\j",!0),D(P,K,"ø","\\o",!0),D(j,_,"ø","\\o",!0),D(P,K,"Ø","\\O",!0),D(j,_,"Ø","\\O",!0),D(P,R,"ˊ","\\'"),D(P,R,"ˋ","\\`"),D(P,R,"ˆ","\\^"),D(P,R,"~","\\~"),D(P,R,"ˉ","\\="),D(P,R,"˘","\\u"),D(P,R,"˙","\\."),D(P,R,"¸","\\c"),D(P,R,"˚","\\r"),D(P,R,"ˇ","\\v");D(P,R,"¨",'\\"'),D(P,R,"˝","\\H"),D(j,R,"ˊ","\\'"),D(j,R,"ˋ","\\`"),D(j,R,"ˆ","\\^"),D(j,R,"~","\\~"),D(j,R,"ˉ","\\="),D(j,R,"˘","\\u"),D(j,R,"˙","\\."),D(j,R,"¸","\\c"),D(j,R,"˚","\\r"),D(j,R,"ˇ","\\v"),D(j,R,"¨",'\\"'),D(j,R,"˝","\\H");const Q={"--":!0,"---":!0,"``":!0,"''":!0};D(P,K,"–","--",!0),D(P,K,"–","\\textendash"),D(P,K,"—","---",!0),D(P,K,"—","\\textemdash"),D(P,K,"‘","`",!0),D(P,K,"‘","\\textquoteleft"),D(P,K,"’","'",!0),D(P,K,"’","\\textquoteright"),D(P,K,"“","``",!0),D(P,K,"“","\\textquotedblleft"),D(P,K,"”","''",!0),D(P,K,"”","\\textquotedblright"),D(j,K,"°","\\degree",!0),D(P,K,"°","\\degree"),D(P,K,"°","\\textdegree",!0),D(j,K,"£","\\pounds"),D(j,K,"£","\\mathsterling",!0),D(P,K,"£","\\pounds"),D(P,K,"£","\\textsterling",!0),D(j,K,"✠","\\maltese"),D(P,K,"✠","\\maltese"),D(j,K,"€","\\euro",!0),D(P,K,"€","\\euro",!0),D(P,K,"€","\\texteuro"),D(j,K,"©","\\copyright",!0),D(P,K,"©","\\textcopyright"),D(j,K,"⌀","\\diameter",!0),D(P,K,"⌀","\\diameter"),D(j,K,"𝛤","\\varGamma"),D(j,K,"𝛥","\\varDelta"),D(j,K,"𝛩","\\varTheta"),D(j,K,"𝛬","\\varLambda"),D(j,K,"𝛯","\\varXi"),D(j,K,"𝛱","\\varPi"),D(j,K,"𝛴","\\varSigma"),D(j,K,"𝛶","\\varUpsilon"),D(j,K,"𝛷","\\varPhi"),D(j,K,"𝛹","\\varPsi"),D(j,K,"𝛺","\\varOmega"),D(P,K,"𝛤","\\varGamma"),D(P,K,"𝛥","\\varDelta"),D(P,K,"𝛩","\\varTheta"),D(P,K,"𝛬","\\varLambda"),D(P,K,"𝛯","\\varXi"),D(P,K,"𝛱","\\varPi"),D(P,K,"𝛴","\\varSigma"),D(P,K,"𝛶","\\varUpsilon"),D(P,K,"𝛷","\\varPhi"),D(P,K,"𝛹","\\varPsi"),D(P,K,"𝛺","\\varOmega");const ee='0123456789/@."';for(let e=0;e<14;e++){const t=ee.charAt(e);D(j,K,t,t)}const te='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){const t=te.charAt(e);D(P,K,t,t)}const re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){const t=re.charAt(e);D(j,_,t,t),D(P,K,t,t)}const ne="ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";for(let e=0;e<30;e++){const t=ne.charAt(e);D(j,_,t,t),D(P,K,t,t)}let se="";for(let e=0;e<52;e++){se=String.fromCharCode(55349,56320+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56372+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56424+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56580+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56736+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56788+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56840+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56944+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,56632+e),D(j,_,se,se),D(P,K,se,se);const t=re.charAt(e);se=String.fromCharCode(55349,56476+e),D(j,_,t,se),D(P,K,t,se)}for(let e=0;e<10;e++)se=String.fromCharCode(55349,57294+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,57314+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,57324+e),D(j,_,se,se),D(P,K,se,se),se=String.fromCharCode(55349,57334+e),D(j,_,se,se),D(P,K,se,se);const oe=function(e,t,r){return!G[t][e]||!G[t][e].replace||55349===e.charCodeAt(0)||Object.prototype.hasOwnProperty.call(Q,e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=G[t][e].replace),new C(e)},ae=(e,t)=>{if(0===e.children.length||"mtext"!==e.children[e.children.length-1].type){const r=new B("mtext",[new C(t.children[0].text)]);e.children.push(r)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},le=e=>{if("mrow"!==e.type&&"mstyle"!==e.type)return e;if(0===e.children.length)return e;const t=new B("mrow");for(let r=0;r<e.children.length;r++){const n=e.children[r];if("mtext"===n.type&&0===Object.keys(n.attributes).length)ae(t,n);else if("mrow"===n.type){let e=!0;for(let t=0;t<n.children.length;t++){if("mtext"!==n.children[t].type||0!==Object.keys(n.attributes).length){e=!1;break}}if(e)for(let e=0;e<n.children.length;e++){const r=n.children[e];ae(t,r)}else t.children.push(n)}else t.children.push(n)}for(let r=0;r<t.children.length;r++)if("mtext"===t.children[r].type){const n=t.children[r];" "===n.children[0].text.charAt(0)&&(n.children[0].text=" "+n.children[0].text.slice(1));const s=n.children[0].text.length;s>0&&" "===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},ie=function(e,t=!1){if(!(1!==e.length||e[0]instanceof y))return e[0];if(!t){e[0]instanceof B&&"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 B&&"mo"===e[t].type&&!e[t].attributes.fence&&(e[t].attributes.lspace="0em",e[t].attributes.rspace="0em")}return new B("mrow",e)};function ce(e){if(!e)return!1;if("mi"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof C&&"."===t.text}if("mtext"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof C&&" "===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 C&&","===t.text}return!1}const me=(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},pe=e=>"atom"===e.type&&"rel"===e.family||"mclass"===e.type&&"mrel"===e.mclass,ue=function(e,t,r=!1){if(!r&&1===e.length){const r=he(e[0],t);return r instanceof B&&"mo"===r.type&&(r.setAttribute("lspace","0em"),r.setAttribute("rspace","0em")),[r]}const n=[],s=[];let o;for(let r=0;r<e.length;r++)s.push(he(e[r],t));for(let t=0;t<s.length;t++){const r=s[t];if(t<e.length-1&&pe(e[t])&&pe(e[t+1])&&r.setAttribute("rspace","0em"),t>0&&pe(e[t])&&pe(e[t-1])&&r.setAttribute("lspace","0em"),"mn"===r.type&&o&&"mn"===o.type)o.children.push(...r.children);else if(ce(r)&&o&&"mn"===o.type)o.children.push(...r.children);else if(o&&"mn"===o.type&&t<s.length-1&&"mn"===s[t+1].type&&me(e,t))o.children.push(...r.children);else{if("mn"===r.type&&ce(o))r.children=[...o.children,...r.children],n.pop();else if(("msup"===r.type||"msub"===r.type)&&r.children.length>=1&&o&&("mn"===o.type||ce(o))){const e=r.children[0];e instanceof B&&"mn"===e.type&&o&&(e.children=[...o.children,...e.children],n.pop())}n.push(r),o=r}}return n},de=function(e,t,r=!1){return ie(ue(e,t,r),r)},he=function(t,r){if(!t)return new B("mrow");if(d[t.type]){return d[t.type](t,r)}throw new e("Got group of unknown type: '"+t.type+"'")},ge=e=>new B("mtd",[],[],{padding:"0",width:"50%"}),fe=["mrow","mtd","mtable","mtr"],be=e=>{for(const t of e.children)if(t.type&&fe.includes(t.type)){if(t.classes&&"tml-label"===t.classes[0]){return t.label}{const e=be(t);if(e)return e}}else if(!t.type){const e=be(t);if(e)return e}};function ye(e,t,r,n){let s=null;1===e.length&&"tag"===e[0].type&&(s=e[0].tag,e=e[0].body);const o=ue(e,r);if(1===o.length&&o[0]instanceof S)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 B?o[0]:function(e,t,r){const n=[];let s=[],o=[],a=0,l=0,i=0;for(;l<e.length;){for(;e[l]instanceof y;)e.splice(l,1,...e[l].children);const r=e[l];if(r.attributes&&r.attributes.linebreak&&"newline"===r.attributes.linebreak){o.length>0&&s.push(new B("mrow",o)),s.push(r),o=[];const e=new B("mtd",s);e.style.textAlign="left",n.push(new B("mtr",[e])),s=[],l+=1}else{if(o.push(r),r.type&&"mo"===r.type&&1===r.children.length&&!Object.prototype.hasOwnProperty.call(r.attributes,"movablelimits")){const n=r.children[0].text;if("([{⌊⌈⟨⟮⎰⟦⦃".indexOf(n)>-1)i+=1;else if(")]}⌋⌉⟩⟯⎱⟦⦄".indexOf(n)>-1)i-=1;else if(0===i&&"="===t&&"="===n){if(a+=1,a>1){o.pop();const e=new B("mrow",o);s.push(e),o=[r]}}else if(0===i&&"tex"===t&&"∇"!==n){const t=l<e.length-1?e[l+1]:null;let r=!0;if(!t||"mtext"!==t.type||!t.attributes.linebreak||"nobreak"!==t.attributes.linebreak)for(let t=l+1;t<e.length;t++){const n=e[t];if(!n.type||"mspace"!==n.type||n.attributes.linebreak&&"newline"===n.attributes.linebreak)break;o.push(n),l+=1,n.attributes&&n.attributes.linebreak&&"nobreak"===n.attributes.linebreak&&(r=!1)}if(r){const e=new B("mrow",o);s.push(e),o=[]}}}l+=1}}if(o.length>0){const e=new B("mrow",o);s.push(e)}if(n.length>0){const e=new B("mtd",s);e.style.textAlign="left";const t=new B("mtr",[e]);n.push(t);const o=new B("mtable",n);return r||(o.setAttribute("columnalign","left"),o.setAttribute("rowspacing","0em")),o}return O(s)}(o,a,n.displayMode);if(s&&(i=((e,t,r,n)=>{t=de(t[0].body,r),(t=le(t)).classes.push("tml-tag");const s=be(e);e=new B("mtd",[e]);const o=[ge(),e,ge()];o[n?0:2].children.push(t);const a=new B("mtr",o,["tml-tageqn"]);s&&a.setAttribute("id",s);const l=new B("mtable",[a]);return l.style.width="100%",l.setAttribute("displaystyle","true"),l})(i,s,r,n.leqno)),n.annotate){const e=new B("annotation",[new C(t)]);e.setAttribute("encoding","application/x-tex"),i=new B("semantics",[i,e])}const c=new B("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 we=(e,t)=>{const r=e.isStretchy?L(e):new B("mo",[oe(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=ke.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 B(n,[he(e.base,t),r])},xe=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),ke=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),ve={"\\`":"̀","\\'":"́","\\^":"̂","\\~":"̃","\\=":"̄","\\u":"̆","\\.":"̇",'\\"':"̈","\\r":"̊","\\H":"̋","\\v":"̌","\\c":"̧"};h({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=f(t[0]),n=!xe.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,base:r}},mathmlBuilder:we}),h({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=f(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 ve&&m.indexOf(r.text)>-1?{type:"textord",mode:"text",text:r.text+ve[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:we}),h({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=L(e);r.style["math-depth"]=0;return new B("munder",[he(e.base,t),r])}});const Ae={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},Te=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Se=function(e){return"string"!=typeof e&&(e=e.unit),Te.indexOf(e)>-1},qe=e=>[1,.7,.5][Math.max(e-1,0)],Oe=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*Ae[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*Ae[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+"'")}},Be=e=>{const t=new B("mspace");return t.setAttribute("width",e+"em"),t},Ce=(e,t=.3,r=0,n=!1)=>{if(null==e&&0===r)return Be(t);const s=e?[e]:[];if(0!==t&&s.unshift(Be(t)),r>0&&s.push(Be(r)),n){const e=new B("mpadded",s);return e.setAttribute("height","0.1px"),e}return new B("mrow",s)},Ne=(e,t)=>Number(e)/qe(t),ze=(e,t,r,n)=>{const s=E(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=Ne(a,l.level),c=Ne(a,3),m=Ce(null,i.toFixed(4),0),p=Ce(null,c.toFixed(4),0),u=Ne(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=he(t,l);r=Ce(r,u,u,"\\\\cdrightarrow"===e||"\\\\cdleftarrow"===e),d=new B("mover",[r,p])}const f=r&&r.body&&(r.body.body||r.body.length>0);if(f){let e=he(r,l);e=Ce(e,u,u),h=new B("munder",[e,p])}let b;return b=g||f?g&&f?new B("munderover",[s,h,d]):g?new B("mover",[s,d]):new B("munder",[s,h]):new B("mover",[s,m]),"3.0"===a&&(b.style.height="1em"),b.setAttribute("accent","false"),b};h({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=[ze(e.name,e.body,e.below,t)];return r.unshift(Be(.2778)),r.push(Be(.2778)),new B("mrow",r)}});const $e={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};h({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=$e[e.name][0],n=$e[e.name][1],s=ze(r,e.body,e.upperArrowBelow,t),o=ze(n,e.lowerArrowBody,e.below,t);let a;const l=new B("mpadded",[s]);if(l.setAttribute("voffset","0.3em"),l.setAttribute("height","+0.3em"),l.setAttribute("depth","-0.3em"),"\\equilibriumLeft"===e.name){const e=new B("mpadded",[o]);e.setAttribute("width","0.5em"),a=new B("mpadded",[Be(.2778),e,l,Be(.2778)])}else l.setAttribute("width","\\equilibriumRight"===e.name?"0.5em":"0"),a=new B("mpadded",[Be(.2778),l,o,Be(.2778)]);return a.setAttribute("voffset","-0.18em"),a.setAttribute("height","-0.18em"),a.setAttribute("depth","+0.18em"),a}});const Ee={};function Ie({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<t.length;++e)Ee[t[e]]=o;s&&(d[e]=s)}function Le(e,t){if(!e||e.type!==t)throw new Error(`Expected node of type ${t}, but got `+(e?`node of type ${e.type}`:String(e)));return e}function Fe(e){const t=Me(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?`node of type ${e.type}`:String(e)));return t}function Me(e){return e&&("atom"===e.type||Object.prototype.hasOwnProperty.call(M,e.type))?e:null}const Ge={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},De=e=>"textord"===e.type&&"@"===e.text;function je(e,t,r){const n=Ge[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"}}}h({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 B("mrow",t);const r=he(e.label,t);"left"===e.side&&r.classes.push("tml-shift-left");const n=new B("mtd",[r]);n.style.padding="0";const s=new B("mtr",[n]),o=new B("mtable",[s]),a=new B("mpadded",[o]);return a.setAttribute("width","0.1px"),a.setAttribute("displaystyle","false"),a.setAttribute("scriptlevel","1"),a}}),h({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new B("mrow",[he(e.fragment,t)])});const Pe=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),Re=(e,t)=>({type:t,mode:"math",body:Pe(e)});class Ue{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 Ue(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class He{constructor(e,t){this.text=e,this.loc=t}range(e,t){return new He(t,Ue.range(this,e))}}const Ve=0,_e=1,We=2,Xe=3,Ze={};function Ye(e,t){Ze[e]=t}const Je=Ze;Ye("\\noexpand",(function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}})),Ye("\\expandafter",(function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}})),Ye("\\@firstoftwo",(function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}})),Ye("\\@secondoftwo",(function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}})),Ye("\\@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}})),Ye("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Ye("\\TextOrMath",(function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}}));const Ke=e=>{let t="";for(let r=e.length-1;r>-1;r--)t+=e[r].text;return t},Qe={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},et=e=>{const t=e.future().text;return"EOF"===t?[null,""]:[Qe[t.charAt(0)],t]},tt=(e,t,r)=>{for(let n=1;n<t.length;n++){e*=r,e+=Qe[t.charAt(n)]}return e};function rt(e){const t=e.consumeArgs(1)[0];let r="",n=t[t.length-1].loc.start;for(let e=t.length-1;e>=0;e--){const s=t[e].loc.start;s>n&&(r+=" ",n=s),r+=t[e].text,n+=t[e].text.length}return r}Ye("\\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=Qe[a.charAt(0)],null==s||s>=r)throw new e(`Invalid base-${r} digit ${n.text}`);for(s=tt(s,a,r),[o,a]=et(t);null!=o&&o<r;)s*=r,s+=o,s=tt(s,a,r),t.popToken(),[o,a]=et(t)}return`\\@char{${s}}`})),Ye("\\surd","\\sqrt{\\vphantom{|}}"),Ye("⊕","\\oplus"),Ye("\\long",""),Ye("\\bgroup","{"),Ye("\\egroup","}"),Ye("~","\\nobreakspace"),Ye("\\lq","`"),Ye("\\rq","'"),Ye("\\aa","\\r a"),Ye("\\Bbbk","\\Bbb{k}"),Ye("\\mathstrut","\\vphantom{(}"),Ye("\\underbar","\\underline{\\text{#1}}"),Ye("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),Ye("⋮","\\vdots"),Ye("\\arraystretch","1"),Ye("\\arraycolsep","6pt"),Ye("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Ye("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Ye("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Ye("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");const nt={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\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","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};Ye("\\dots",(function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in nt?t=nt[r]:("\\not"===r.slice(0,4)||r in G.math&&["bin","rel"].includes(G.math[r].group))&&(t="\\dotsb"),t}));const st={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};Ye("\\dotso",(function(e){return e.future().text in st?"\\ldots\\,":"\\ldots"})),Ye("\\dotsc",(function(e){const t=e.future().text;return t in st&&","!==t?"\\ldots\\,":"\\ldots"})),Ye("\\cdots",(function(e){return e.future().text in st?"\\@cdots\\,":"\\@cdots"})),Ye("\\dotsb","\\cdots"),Ye("\\dotsm","\\cdots"),Ye("\\dotsi","\\!\\cdots"),Ye("\\idotsint","\\dotsi"),Ye("\\dotsx","\\ldots\\,"),Ye("\\DOTSI","\\relax"),Ye("\\DOTSB","\\relax"),Ye("\\DOTSX","\\relax"),Ye("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Ye("\\,","{\\tmspace+{3mu}{.1667em}}"),Ye("\\thinspace","\\,"),Ye("\\>","\\mskip{4mu}"),Ye("\\:","{\\tmspace+{4mu}{.2222em}}"),Ye("\\medspace","\\:"),Ye("\\;","{\\tmspace+{5mu}{.2777em}}"),Ye("\\thickspace","\\;"),Ye("\\!","{\\tmspace-{3mu}{.1667em}}"),Ye("\\negthinspace","\\!"),Ye("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),Ye("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),Ye("\\enspace","\\kern.5em "),Ye("\\enskip","\\hskip.5em\\relax"),Ye("\\quad","\\hskip1em\\relax"),Ye("\\qquad","\\hskip2em\\relax"),Ye("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax"),Ye("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Ye("\\tag@paren","\\tag@literal{({#1})}"),Ye("\\tag@literal",(t=>{if(t.macros.get("\\df@tag"))throw new e("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"})),Ye("\\notag","\\nonumber"),Ye("\\nonumber","\\gdef\\@eqnsw{0}"),Ye("\\bmod","\\mathbin{\\text{mod}}"),Ye("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Ye("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Ye("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Ye("\\newline","\\\\\\relax"),Ye("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),Ye("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),Ye("\\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}}"),Ye("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Ye("\\@hspace","\\hskip #1\\relax"),Ye("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Ye("\\colon",'\\mathpunct{\\char"3a}'),Ye("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),Ye("\\ordinarycolon",'\\char"3a'),Ye("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),Ye("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),Ye("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),Ye("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),Ye("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),Ye("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),Ye("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),Ye("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Ye("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Ye("\\ratio","\\vcentcolon"),Ye("\\coloncolon","\\dblcolon"),Ye("\\colonequals","\\coloneqq"),Ye("\\coloncolonequals","\\Coloneqq"),Ye("\\equalscolon","\\eqqcolon"),Ye("\\equalscoloncolon","\\Eqqcolon"),Ye("\\colonminus","\\coloneq"),Ye("\\coloncolonminus","\\Coloneq"),Ye("\\minuscolon","\\eqcolon"),Ye("\\minuscoloncolon","\\Eqcolon"),Ye("\\coloncolonapprox","\\Colonapprox"),Ye("\\coloncolonsim","\\Colonsim"),Ye("\\notni","\\mathrel{\\char`∌}"),Ye("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Ye("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Ye("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Ye("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Ye("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),Ye("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),Ye("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),Ye("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),Ye("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),Ye("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Ye("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Ye("\\plim","\\DOTSB\\operatorname*{plim}"),Ye("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}"),Ye("\\bra","\\mathinner{\\langle{#1}|}"),Ye("\\ket","\\mathinner{|{#1}\\rangle}"),Ye("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Ye("\\Bra","\\left\\langle#1\\right|"),Ye("\\Ket","\\left|#1\\right\\rangle");const ot=(e,t)=>{const r=`}\\,\\middle${"|"===t[0]?"\\vert":"\\Vert"}\\,{`;return e.slice(0,t.index)+r+e.slice(t.index+t[0].length)};Ye("\\Braket",(function(e){let t=rt(e);const r=/\|\||\||\\\|/g;let n;for(;null!==(n=r.exec(t));)t=ot(t,n);return"\\left\\langle{"+t+"}\\right\\rangle"})),Ye("\\Set",(function(e){let t=rt(e);const r=/\|\||\||\\\|/.exec(t);return r&&(t=ot(t,r)),"\\left\\{\\:{"+t+"}\\:\\right\\}"})),Ye("\\set",(function(e){return"\\{{"+rt(e).replace(/\|/,"}\\mid{")+"}\\}"})),Ye("\\angln","{\\angl n}"),Ye("\\odv","\\@ifstar\\odv@next\\odv@numerator"),Ye("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),Ye("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),Ye("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");const at=e=>{const t=e[0][0].text,r=Ke(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 lt(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}Ye("\\pdv@numerator",(function(e){const[t,r,n]=at(e.consumeArgs(2));return`\\frac{${r} ${t}}{${n}}`})),Ye("\\pdv@next",(function(e){const[t,r,n]=at(e.consumeArgs(2));return`\\frac{${r}}{${n}} ${t}`})),Ye("\\upalpha","\\up@greek{\\alpha}"),Ye("\\upbeta","\\up@greek{\\beta}"),Ye("\\upgamma","\\up@greek{\\gamma}"),Ye("\\updelta","\\up@greek{\\delta}"),Ye("\\upepsilon","\\up@greek{\\epsilon}"),Ye("\\upzeta","\\up@greek{\\zeta}"),Ye("\\upeta","\\up@greek{\\eta}"),Ye("\\uptheta","\\up@greek{\\theta}"),Ye("\\upiota","\\up@greek{\\iota}"),Ye("\\upkappa","\\up@greek{\\kappa}"),Ye("\\uplambda","\\up@greek{\\lambda}"),Ye("\\upmu","\\up@greek{\\mu}"),Ye("\\upnu","\\up@greek{\\nu}"),Ye("\\upxi","\\up@greek{\\xi}"),Ye("\\upomicron","\\up@greek{\\omicron}"),Ye("\\uppi","\\up@greek{\\pi}"),Ye("\\upalpha","\\up@greek{\\alpha}"),Ye("\\uprho","\\up@greek{\\rho}"),Ye("\\upsigma","\\up@greek{\\sigma}"),Ye("\\uptau","\\up@greek{\\tau}"),Ye("\\upupsilon","\\up@greek{\\upsilon}"),Ye("\\upphi","\\up@greek{\\phi}"),Ye("\\upchi","\\up@greek{\\chi}"),Ye("\\uppsi","\\up@greek{\\psi}"),Ye("\\upomega","\\up@greek{\\omega}"),Ye("\\invamp",'\\mathbin{\\char"214b}'),Ye("\\parr",'\\mathbin{\\char"214b}'),Ye("\\with",'\\mathbin{\\char"26}'),Ye("\\multimapinv",'\\mathrel{\\char"27dc}'),Ye("\\multimapboth",'\\mathrel{\\char"29df}'),Ye("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),Ye("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),Ye("\\coh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}\n{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}'),Ye("\\incoh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}\n{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}'),Ye("\\standardstate","\\text{\\tiny\\char`⦵}");const it=t=>{if(!t.parser.settings.displayMode)throw new e(`{${t.envName}} can be used only in display mode.`)},ct=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,mt=e=>{let t=e.get("\\arraystretch");"string"!=typeof t&&(t=Ke(t.tokens)),t=isNaN(t)?null:Number(t);let r=e.get("\\arraycolsep");"string"!=typeof r&&(r=Ke(r.tokens));const n=ct.exec(r);return[t,n?{number:+(n[1]+n[2]),unit:n[3]}:null]},pt=t=>{let r="";for(let n=0;n<t.length;n++)if("label"===t[n].type){if(r)throw new e("Multiple \\labels in one row");r=t[n].string}return r};function ut(e){if(-1===e.indexOf("ed"))return-1===e.indexOf("*")}function dt(t,{cols:r,envClasses:n,autoTag:s,singleRow:o,emptySingleRow:a,maxNumCols:l,leqno:i,arraystretch:c,arraycolsep:m},p){const u=n&&n.includes("bordermatrix")?"}":"\\end";t.gullet.beginGroup(),o||t.gullet.macros.set("\\cr","\\\\\\relax"),t.gullet.beginGroup();let d=[];const h=[d],g=[],f=[],b=[],y=null!=s?[]:void 0;function w(){s&&t.gullet.macros.set("\\@eqnsw","1",!0)}function x(){y&&(t.gullet.macros.get("\\df@tag")?(y.push(t.subparse([new He("\\df@tag")])),t.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(s)&&"1"===t.gullet.macros.get("\\@eqnsw")))}for(w(),b.push(lt(t));;){let r=t.parseExpression(!1,o?"\\end":"\\\\");t.gullet.endGroup(),t.gullet.beginGroup(),r={type:"ordgroup",mode:t.mode,body:r,semisimple:!0},d.push(r);const s=t.fetch().text;if("&"===s){if(l&&d.length===l){if(!n.includes("array"))throw new e(2===l?"The split environment accepts no more than two columns":"The equation environment accepts only one column",t.nextToken);if(t.settings.strict)throw new e("Too few columns specified in the {array} column argument.",t.nextToken)}t.consume()}else{if(s===u){x(),1===d.length&&0===r.body.length&&(h.length>1||!a)&&h.pop(),f.push(pt(r.body)),b.length<h.length+1&&b.push([]);break}if("\\\\"!==s)throw new e("Expected & or \\\\ or \\cr or "+u,t.nextToken);{let e;t.consume()," "!==t.gullet.future().text&&(e=t.parseSizeGroup(!0)),g.push(e?e.value:null),x(),f.push(pt(r.body)),b.push(lt(t)),d=[],h.push(d),w()}}}return t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:t.mode,body:h,cols:r,rowGaps:g,hLinesBeforeRow:b,envClasses:n,autoTag:s,scriptLevel:p,tags:y,labels:f,leqno:i,arraystretch:c,arraycolsep:m}}function ht(e){return"d"===e.slice(0,1)?"display":"text"}const gt={c:"center ",l:"left ",r:"right "},ft=e=>{const t=new B("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},bt=function(e,t){const r=[],n=e.body.length,s=e.hLinesBeforeRow,o=e.tags&&e.tags.some((e=>e));for(let a=0;a<n;a++){const l=e.body[a],i=[],c="text"===e.scriptLevel?_e:"script"===e.scriptLevel?We:Ve;for(let r=0;r<l.length;r++){const s=new B("mtd",[he(l[r],t.withLevel(c))]);if(e.envClasses.includes("multline")){const e=0===a?"left":a===n-1?"right":"center";"center"!==e&&s.classes.push("tml-"+e)}i.push(s)}const m=e.body[0].length;for(let e=0;e<m-l.length;e++)i.push(new B("mtd",[],[],t));if(o){const r=e.tags[a];let n;!0===r?n=new B("mtext",[new A(["tml-eqn"])]):!1===r?n=new B("mtext",[],[]):(n=de(r[0].body,t.withLevel(c),!0),n=le(n),n.classes=["tml-tag"]),n&&(i.unshift(ft(e)),i.push(ft(e)),e.leqno?i[0].children.push(n):i[i.length-1].children.push(n))}const p=new B("mtr",i,[]),u=e.labels.shift();u&&e.tags&&e.tags[a]&&(p.setAttribute("id",u),Array.isArray(e.tags[a])&&p.classes.push("tml-tageqn")),0===a&&s[0].length>0&&(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;e<p.children.length;e++){const t=p.children[e].children[0];if(!t||"mpadded"!==t.type||"0px"!==t.attributes.height){d=!1;break}}if(d)for(let e=0;e<p.children.length;e++)p.children[e].style.display="block",p.children[e].style.height="0",p.children[e].style.paddingTop="0",p.children[e].style.paddingBottom="0";r.push(p)}if(e.arraystretch&&1!==e.arraystretch){const t=String(1.4*e.arraystretch-.8)+"ex";for(let e=0;e<r.length;e++)for(let n=0;n<r[e].children.length;n++)r[e].children[n].style.paddingTop=t,r[e].children[n].style.paddingBottom=t}let a,l;if(e.envClasses.length>0&&(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=Oe(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;e<r.length;e++)for(let t=0;t<r[e].children.length;t++)r[e].children[t].style.paddingLeft=`${n(t,0)}${l}`,r[e].children[t].style.paddingRight=`${n(t,1)}${l}`}if(0===e.envClasses.length)for(let e=0;e<r.length;e++)r[e].children[0].style.paddingLeft="0em",r[e].children.length===r[0].children.length&&(r[e].children[r[e].children.length-1].style.paddingRight="0em");if(e.envClasses.length>0){const t=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let n=0;n<r.length;n++){const s=r[n];if(t){for(let e=0;e<s.children.length;e++)s.children[e].classes=["tml-"+(e%2?"left":"right")];if(o){const t=e.leqno?0:s.children.length-1;s.children[t].classes=[]}}if(s.children.length>1&&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 B("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<s;e++)if("align"===t[e].type){const n=gt[t[e].align];a+=1;for(const e of i.children)"center"!==n.trim()&&a<e.children.length&&(e.children[a].classes=["tml-"+n.trim()]);r=!0}else if("separator"===t[e].type){if(r){const r="separator"===t[e+1].type?"0.15em double":"|"===t[e].separator?"0.06em solid":"0.06em dashed";for(const e of i.children)a<e.children.length&&(e.children[a].style.borderRight=r)}r=!1}if("separator"===t[t.length-1].type){const e="separator"===t[t.length-2].type?"0.15em double":"|"===t[t.length-1].separator?"0.06em solid":"0.06em dashed";for(const t of i.children)t.children[t.children.length-1].style.borderRight=e,t.children[t.children.length-1].style.paddingRight="0.4em"}}return e.envClasses.includes("small")&&(i=new B("mstyle",[i]),i.setAttribute("scriptlevel","1")),i},yt=function(t,r){-1===t.envName.indexOf("ed")&&it(t);const n="split"===t.envName,s=[],o=dt(t.parser,{cols:s,emptySingleRow:!0,autoTag:n?void 0:ut(t.envName),envClasses:["abut","jot"],maxNumCols:"split"===t.envName?2:void 0,leqno:t.parser.settings.leqno},"display");let a,l=0;const i=t.envName.indexOf("at")>-1;if(r[0]&&i){let t="";for(let e=0;e<r[0].body.length;e++){t+=Le(r[0].body[e],"textord").text}if(isNaN(t))throw new e("The alignat enviroment requires a numeric first argument.");a=Number(t),l=2*a}o.body.forEach((function(t){if(i){const r=t.length/2;if(a<r)throw new e(`Too many math in a row: expected ${a}, but got ${r}`,t[0])}else l<t.length&&(l=t.length)}));for(let e=0;e<l;++e){let t="r";e%2==1&&(t="l"),s[e]={type:"align",align:t}}return"split"===t.envName||(i?o.envClasses.push("alignat"):o.envClasses[0]="align"),o};Ie({type:"array",names:["array","darray"],props:{numArgs:1},handler(t,r){const n=(Me(r[0])?[r[0]]:Le(r[0],"ordgroup").body).map((function(t){const r=Fe(t).text;if(-1!=="lcr".indexOf(r))return{type:"align",align:r};if("|"===r)return{type:"separator",separator:"|"};if(":"===r)return{type:"separator",separator:":"};throw new e("Unknown column alignment: "+r,t)})),[s,o]=mt(t.parser.gullet.macros),a={cols:n,envClasses:["array"],maxNumCols:n.length,arraystretch:s,arraycolsep:o};return dt(t.parser,a,ht(t.envName))},mathmlBuilder:bt}),Ie({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(t){const r={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[t.envName.replace("*","")];let n="c";const s={envClasses:[],cols:[]};if("*"===t.envName.charAt(t.envName.length-1)){const r=t.parser;if(r.consumeSpaces(),"["===r.fetch().text){if(r.consume(),r.consumeSpaces(),n=r.fetch().text,-1==="lcr".indexOf(n))throw new e("Expected l or c or r",r.nextToken);r.consume(),r.consumeSpaces(),r.expect("]"),r.consume(),s.cols=[]}}const o=dt(t.parser,s,"text");o.cols=o.body.length>0?new Array(o.body[0].length).fill({type:"align",align:n}):[];const[a,l]=mt(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:bt}),Ie({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(e){const t=dt(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<r.length;e++){n[e-1].push(r[e].shift());const t=[];for(let n=0;n<r[e].length;n++)t.push(r[e][n]);n[e-1].push(Re(t,"vphantom"))}const s=new Array(r.length).fill().map((()=>[]));for(let e=0;e<r[0].length;e++)s[0].push(r[0][e]);for(let e=1;e<r.length;e++)for(let t=0;t<r[0].length;t++)s[e].push(Re(r[e][t].body,"hphantom"));for(let e=0;e<r[0].length;e++)r[0][e]=Re(r[0][e].body,"hphantom");const o={type:"array",mode:"math",body:n,cols:[{type:"align",align:"c"}],rowGaps:new Array(n.length-1).fill(null),hLinesBeforeRow:new Array(n.length+1).fill().map((()=>[])),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 Pe([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:bt}),Ie({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>dt(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:bt}),Ie({type:"array",names:["subarray"],props:{numArgs:1},handler(t,r){const n=(Me(r[0])?[r[0]]:Le(r[0],"ordgroup").body).map((function(t){const r=Fe(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=dt(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:bt}),Ie({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=dt(e.parser,{cols:[],envClasses:["cases"]},ht(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:bt}),Ie({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:yt,mathmlBuilder:bt}),Ie({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:yt,mathmlBuilder:bt}),Ie({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){"gathered"!==e.envName&&it(e);const t={cols:[],envClasses:["abut","jot"],autoTag:ut(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return dt(e.parser,t,"display")},mathmlBuilder:bt}),Ie({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){it(e);const t={autoTag:ut(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return dt(e.parser,t,"display")},mathmlBuilder:bt}),Ie({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){it(e);const t={autoTag:"multline"===e.envName,maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return dt(e.parser,t,"display")},mathmlBuilder:bt}),Ie({type:"array",names:["CD"],props:{numArgs:0},handler:t=>(it(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 l=0;l<r.length;l++){const i=r[l];let c={type:"styling",body:[],mode:"math",scriptLevel:"display"};for(let r=0;r<i.length;r++)if(De(i[r])){n.push(c),r+=1;const s=Fe(i[r]).text,l=new Array(2);if(l[0]={type:"ordgroup",mode:"math",body:[]},l[1]={type:"ordgroup",mode:"math",body:[]},"=|.".indexOf(s)>-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 c=r+1;c<i.length;c++){if(a=s,("mathord"===(o=i[c]).type||"atom"===o.type)&&o.text===a){n=!1,r=c;break}if(De(i[c]))throw new e("Missing a "+s+" character to complete a CD arrow.",i[c]);l[t].body.push(i[c])}if(n)throw new e("Missing a "+s+" character to complete a CD arrow.",i[r])}}const m=je(s,l,t);n.push(m),c={type:"styling",body:[],mode:"math",scriptLevel:"display"}}else c.body.push(i[r]);l%2==0?n.push(c):n.shift(),n=[],s.push(n)}var o,a;return s.pop(),t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:"math",body:s,tags:null,labels:new Array(s.length+1).fill(""),envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(s.length+1).fill([])}}(t.parser)),mathmlBuilder:bt}),h({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(t,r){throw new e(`${t.funcName} valid only within array environment`)}});const wt=Ee;h({type:"bordermatrix",names:["\\bordermatrix","\\matrix"],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:t},r,n)=>{let s=["(",")"];if("\\bordermatrix"===t&&n[0]&&n[0].body){const e=n[0].body;2===e.length&&"atom"===e[0].type&&"atom"===e[1].type&&"open"===e[0].family&&"close"===e[1].family&&(s=[e[0].text,e[1].text])}e.consumeSpaces(),e.consume();const o=wt.bordermatrix,a={mode:e.mode,envName:t.slice(1),delimiters:s,parser:e},l=o.handler(a);return e.expect("}",!0),l}}),h({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 B("mrow",[he(e.body,t)],["ff-narrow"]),n=new B("mphantom",[he(e.body,t)]),s=new B("mrow",[n],["tml-cancelto"]);e.isCharacterBox&&m.indexOf(e.body.body[0].text)>-1&&(s.style.left="0.1em",s.style.width="90%");const o=new B("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 B("mspace",[]);e.setAttribute("height","0.85em"),r.children.push(e)}let a;if(e.isCharacterBox)a=new B("mspace",[]),a.setAttribute("height","1em");else{const r=he(e.body,t),n=new B("mpadded",[r]);n.setAttribute("width","0.1px"),a=new B("mphantom",[n])}const l=he(e.to,t),i=new B("mpadded",[l]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){const e=new B("mspace",[]);e.setAttribute("width","0.2em"),i.children.unshift(e)}i.setAttribute("width","0.1px");const c=new B("mover",[a,i]),p=new B("mrow",[],["ff-nudge-left"]);return O([ie([o,c]),p])}}),h({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:t,token:r},n){const s=Le(n[0],"ordgroup").body;let o="";for(let e=0;e<s.length;e++){o+=Le(s[e],"textord").text}const a=parseInt(o);if(isNaN(a))throw new e(`\\@char has non-numeric argument ${o}`,r);return{type:"textord",mode:t.mode,text:String.fromCodePoint(a)}}});const xt=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,kt=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,vt=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,At=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Tt=/^[a-f0-9]{6}$/i,St=e=>{let t=e.toString(16);return 1===t.length&&(t="0"+t),t},qt=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}'),Ot=(t,r)=>{let n="";if("HTML"===t){if(!xt.test(r))throw new e("Invalid HTML input.");n=r}else if("RGB"===t){if(!vt.test(r))throw new e("Invalid RGB input.");r.split(",").map((e=>{n+=St(Number(e.trim()))}))}else{if(!At.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+=St(Number((255*r).toFixed(0)))}))}return"#"!==n.charAt(0)&&(n="#"+n),n},Bt=(t,r,n)=>{const s=`\\\\color@${t}`;if(!kt.exec(t))throw new e("Invalid color: '"+t+"'",n);return Tt.test(t)?"#"+t:("#"===t.charAt(0)||(r.has(s)?t=r.get(s).tokens[0].text:qt[t]&&(t=qt[t])),t)},Ct=(e,t)=>{let r=ue(e.body,t.withColor(e.color));return 0===r.length&&r.push(new B("mrow")),r=r.map((t=>(t.style.color=e.color,t))),O(r)};h({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]&&Le(n[0],"raw").string;let o="";if(s){const e=Le(r[0],"raw").string;o=Ot(s,e)}else o=Bt(Le(r[0],"raw").string,e.gullet.macros,t);const a=r[1];return{type:"color",mode:e.mode,color:o,isTextColor:!0,body:b(a)}},mathmlBuilder:Ct}),h({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]&&Le(s[0],"raw").string;let a="";if(o){const e=Le(n[0],"raw").string;a=Ot(o,e)}else a=Bt(Le(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:Ct}),h({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:t,funcName:r,token:n},s){const o=Le(s[0],"raw").string;if(!/^[A-Za-z]+$/.test(o))throw new e("Color name must be latin letters.",n);const a=Le(s[1],"raw").string;if(!["HTML","RGB","rgb"].includes(a))throw new e("Color model must be HTML, RGB, or rgb.",n);const l=Le(s[2],"raw").string,i=Ot(a,l);return t.gullet.macros.set(`\\\\color@${o}`,{tokens:[{text:i}],numArgs:0}),{type:"internal",mode:t.mode}}}),h({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&&Le(n,"size").value}},mathmlBuilder(e,t){const r=new B("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){const n=Oe(e.size,t);r.setAttribute("height",n.number+n.unit)}return r}});const Nt={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},zt=t=>{const r=t.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(r))throw new e("Expected a control sequence",t);return r},$t=(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)};h({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:t,funcName:r}){t.consumeSpaces();const n=t.fetch();if(Nt[n.text])return"\\global"!==r&&"\\\\globallong"!==r||(n.text=Nt[n.text]),Le(t.parseFunction(),"internal");throw new e("Invalid token after macro prefix",n)}}),h({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===Nt[r]),{type:"internal",mode:t.mode}}}),h({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=zt(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 $t(e,r,n,"\\\\globallet"===t),{type:"internal",mode:e.mode}}}),h({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=zt(e.gullet.popToken()),n=e.gullet.popToken(),s=e.gullet.popToken();return $t(e,r,s,"\\\\globalfuture"===t),e.gullet.pushToken(s),e.gullet.pushToken(n),{type:"internal",mode:e.mode}}}),h({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=zt(t.gullet.popToken()),t.gullet.popToken()):n=zt(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 Et={"\\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}},It=["(","\\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","."],Lt=["}","\\left","\\middle","\\right"],Ft=e=>e.length>0&&(It.includes(e)||Et[e]||Lt.includes(e)),Mt=[0,1.2,1.8,2.4,3];function Gt(t,r){"ordgroup"===t.type&&1===t.body.length&&(t=t.body[0]);const n=Me(t);if(n&&It.includes(n.text))return["<","\\lt"].includes(n.text)&&(n.text="⟨"),[">","\\gt"].includes(n.text)&&(n.text="⟩"),n;throw new e(n?`Invalid delimiter '${n.text}' after '${r.funcName}'`:`Invalid delimiter type '${t.type}'`,t)}const Dt=["/","\\","\\backslash","\\vert","|"];h({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=Gt(t[0],e),n={type:"delimsizing",mode:e.parser.mode,size:Et[e.funcName].size,mclass:Et[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=[];"."===e.delim&&(e.delim=""),t.push(oe(e.delim,e.mode));const r=new B("mo",t);return"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),(Dt.includes(e.delim)||e.delim.indexOf("arrow")>-1)&&r.setAttribute("stretchy","true"),r.setAttribute("symmetric","true"),r.setAttribute("minsize",Mt[e.size]+"em"),r.setAttribute("maxsize",Mt[e.size]+"em"),r}}),h({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>({type:"leftright-right",mode:e.parser.mode,delim:Gt(t[0],e).text})}),h({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=Gt(r[0],t),s=t.parser;++s.leftrightDepth;let o=s.parseExpression(!1,null,!0),a=s.fetch();for(;"\\middle"===a.text;){s.consume();const t=s.fetch().text;if(!G.math[t])throw new e(`Invalid delimiter '${t}' after '\\middle'`);Gt({type:"atom",mode:"math",text:t},{funcName:"\\middle"}),o.push({type:"middle",mode:"math",delim:t}),s.consume(),o=o.concat(s.parseExpression(!1,null,!0)),a=s.fetch()}--s.leftrightDepth,s.expect("\\right",!1);const l=Le(s.parseFunction(),"leftright-right");return{type:"leftright",mode:s.mode,body:o,left:n.text,right:l.delim}},mathmlBuilder:(e,t)=>{!function(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}(e);const r=ue(e.body,t);"."===e.left&&(e.left="");const n=new B("mo",[oe(e.left,e.mode)]);n.setAttribute("fence","true"),n.setAttribute("form","prefix"),("/"===e.left||"\\"===e.left||e.left.indexOf("arrow")>-1)&&n.setAttribute("stretchy","true"),r.unshift(n),"."===e.right&&(e.right="");const s=new B("mo",[oe(e.right,e.mode)]);if(s.setAttribute("fence","true"),s.setAttribute("form","postfix"),("∖"===e.right||e.right.indexOf("arrow")>-1)&&s.setAttribute("stretchy","true"),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),ie(r)}}),h({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=Gt(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,t)=>{const r=oe(e.delim,e.mode),n=new B("mo",[r]);return n.setAttribute("fence","true"),e.delim.indexOf("arrow")>-1&&n.setAttribute("stretchy","true"),n.setAttribute("form","prefix"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});const jt=["\\boxed","\\fcolorbox","\\colorbox"],Pt=(e,t)=>{const r=jt.includes(e.label)?"mrow":"menclose",n=new B(r,[he(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 B("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike"),n.children.push(new B("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":n.setAttribute("notation","horizontalstrike"),n.children.push(new B("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike"),n.classes.push("tml-xcancel");break;case"\\longdiv":n.setAttribute("notation","longdiv"),n.classes.push("longdiv-top"),n.children.push(new B("mrow",[],["longdiv-arc"]));break;case"\\phase":n.setAttribute("notation","phasorangle"),n.classes.push("phasor-bottom"),n.children.push(new B("mrow",[],["phasor-angle"]));break;case"\\textcircled":n.setAttribute("notation","circle"),n.classes.push("circle-pad"),n.children.push(new B("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};h({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]&&Le(n[0],"raw").string;let o="";if(s){const e=Le(r[0],"raw").string;o=Ot(s,e)}else o=Bt(Le(r[0],"raw").string,e.gullet.macros);const a=r[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:o,body:a}},mathmlBuilder:Pt}),h({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]&&Le(n[0],"raw").string;let o,a="";if(s){const e=Le(r[0],"raw").string,t=Le(r[0],"raw").string;a=Ot(s,e),o=Ot(s,t)}else a=Bt(Le(r[0],"raw").string,e.gullet.macros),o=Bt(Le(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:Pt}),h({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]})}),h({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\sout","\\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:Pt}),h({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:Pt}),h({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:Pt}),h({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<s.body.length;++e)o+=Le(s.body[e],"textord").text;if("\\begin"===r){if(!Object.prototype.hasOwnProperty.call(wt,o))throw new e("No such environment: "+o,s);const r=wt[o],{args:n,optArgs:a}=t.parseArguments("\\begin{"+o+"}",r),l={mode:t.mode,envName:o,parser:t},i=r.handler(l,n,a);t.expect("\\end",!1);const c=t.nextToken,m=Le(t.parseFunction(),"environment");if(m.name!==o)throw new e(`Mismatch: \\begin{${o}} matched by \\end{${m.name}}`,c);return i}return{type:"environment",mode:t.mode,name:o,nameGroup:s}}}),h({type:"envTag",names:["\\env@tag"],props:{numArgs:1,argTypes:["math"]},handler:({parser:e},t)=>({type:"envTag",mode:e.mode,body:t[0]}),mathmlBuilder:(e,t)=>new B("mrow")}),h({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new B("mrow")});const Rt=(e,t)=>{const r=e.font,n=t.withFont(r),s=he(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("mathrm"!==t||"ordgroup"!==e.body.type||1===e.body.body.length)return!1;if("mathord"!==e.body.body[0].type)return!1;for(let t=1;t<e.body.body.length;t++){const r=e.body.body[t].type;if("mathord"!==r&&("textord"!==r||isNaN(e.body.body[t].text)))return!1}return!0})(e,r)){const e=s.children[0].children[0].children?s.children[0].children[0]:s.children[0];delete e.attributes.mathvariant;for(let t=1;t<s.children.length;t++)e.children[0].text+=s.children[t].children[0].children?s.children[t].children[0].children[0].text:s.children[t].children[0].text;const t=new B("mpadded",[e]);return t.setAttribute("lspace","0"),t}let o="mo"===s.children[0].type;for(let e=1;e<s.children.length;e++){"mo"===s.children[e].type&&"boldsymbol"===r&&(s.children[e].style.fontWeight="bold"),"mi"!==s.children[e].type&&(o=!1);"normal"!==(s.children[e].attributes&&s.children[e].attributes.mathvariant||"")&&(o=!1)}if(!o)return s;const a=s.children[0];for(let e=1;e<s.children.length;e++)a.children.push(s.children[e].children[0]);if(a.attributes.mathvariant&&"normal"===a.attributes.mathvariant){const e=new B("mtext",new C(""));return new B("mrow",[e,a])}return a},Ut={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};h({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\up@greek","\\boldsymbol","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathsfit","\\mathtt","\\Bbb","\\bm","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=f(r[0]);let s=t;return s in Ut&&(s=Ut[s]),{type:"font",mode:e.mode,font:s.slice(1),body:n}},mathmlBuilder:Rt}),h({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:Rt});const Ht=["display","text","script","scriptscript"],Vt={auto:-1,display:0,text:0,script:1,scriptscript:2},_t=(e,t)=>{const r="auto"===e.scriptLevel?t.incrementLevel():"display"===e.scriptLevel?t.withLevel(_e):"text"===e.scriptLevel?t.withLevel(We):t.withLevel(Xe),n=he(e.numer,r),s=he(e.denom,r);3===t.level&&(n.style.mathDepth="2",n.setAttribute("scriptlevel","2"),s.style.mathDepth="2",s.setAttribute("scriptlevel","2"));let o=new B("mfrac",[n,s]);if(e.hasBarLine){if(e.barSize){const r=Oe(e.barSize,t);o.setAttribute("linethickness",r.number+r.unit)}}else o.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new B("mo",[new C(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(o),null!=e.rightDelim){const r=new B("mo",[new C(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}o=ie(t)}return"auto"!==e.scriptLevel&&(o=new B("mstyle",[o]),o.setAttribute("displaystyle",String("display"===e.scriptLevel)),o.setAttribute("scriptlevel",Vt[e.scriptLevel])),o};h({type:"genfrac",names:["\\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"\\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")}switch(t){case"\\dfrac":case"\\dbinom":i="display";break;case"\\tfrac":case"\\tbinom":i="text"}return{type:"genfrac",mode:e.mode,continued:!1,numer:n,denom:s,hasBarLine:o,leftDelim:a,rightDelim:l,scriptLevel:i,barSize:null}},mathmlBuilder:_t}),h({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:({parser:e,funcName:t},r)=>{const n=r[0],s=r[1];return{type:"genfrac",mode:e.mode,continued:!0,numer:n,denom:s,hasBarLine:!0,leftDelim:null,rightDelim:null,scriptLevel:"display",barSize:null}}}),h({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 Wt=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};h({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=f(t[0]),o="atom"===s.type&&"open"===s.family?Wt(s.text):null,a=f(t[1]),l="atom"===a.type&&"close"===a.family?Wt(a.text):null,i=Le(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=Le(u.body[0],"textord");p=Ht[Number(e.text)]}}else u=Le(u,"textord"),p=Ht[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:_t}),h({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:Le(n[0],"size").value,token:r})}),h({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}(Le(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:_t}),h({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},t)=>({type:"hbox",mode:e.mode,body:b(t[0])}),mathmlBuilder(e,t){const r=t.withLevel(_e),n=de(e.body,r);return le(n)}});h({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=E(e.label);return r.style["math-depth"]=0,new B(e.isOver?"mover":"munder",[he(e.base,t),r])}}),h({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=Le(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<t.length;r++){const n=t[r].split("=");if(2!==n.length)throw new e("Error parsing key-value for \\data");i["data-"+n[0].trim()]=n[1].trim()}l={command:"\\data",attributes:i};break}default:throw new Error("Unrecognized html command")}if(!t.settings.isTrusted(l))throw new e(`Function "${r}" is not trusted`,n);return{type:"html",mode:t.mode,attributes:i,body:b(a)}},mathmlBuilder:(e,t)=>{const r=de(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 Xt=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(!Se(n))throw new e("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};h({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=Le(s[0],"raw").string.split(",");for(let r=0;r<t.length;r++){const n=t[r].split("=");if(2===n.length){const t=n[1].trim();switch(n[0].trim()){case"alt":i=t;break;case"width":o=Xt(t);break;case"height":a=Xt(t);break;case"totalheight":l=Xt(t);break;default:throw new e("Invalid key: '"+n[0]+"' in \\includegraphics.")}}}}const c=Le(n[0],"url").url;if(""===i&&(i=c,i=i.replace(/^.*[\\/]/,""),i=i.substring(0,i.lastIndexOf("."))),!t.settings.isTrusted({command:"\\includegraphics",url:c}))throw new e('Function "\\includegraphics" is not trusted',r);return{type:"includegraphics",mode:t.mode,alt:i,width:o,height:a,totalheight:l,src:c}},mathmlBuilder:(e,t)=>{const r=Oe(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=Oe(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 B("mtext",[a])}}),h({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=Le(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=Oe(e.dimension,t),n=r.number>0&&"em"===r.unit?Zt(r.number):"";if("text"===e.mode&&n.length>0){const e=new C(n);return new B("mtext",[e])}if(r.number>=0){const e=new B("mspace");return e.setAttribute("width",r.number+r.unit),e}{const e=new B("mrow");return e.style.marginLeft=r.number+r.unit,e}}});const Zt=function(e){return e>=.05555&&e<=.05556?" ":e>=.1666&&e<=.1667?" ":e>=.2222&&e<=.2223?" ":e>=.2777&&e<=.2778?" ":""},Yt=/[^A-Za-z_0-9-]/g;h({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(Yt,"")}),mathmlBuilder(e,t){const r=new B("mrow",[],["tml-label"]);return e.string.length>0&&r.setLabel(e.string),r}});const Jt=["\\clap","\\llap","\\rlap"];h({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:t,funcName:r,token:n},s)=>{if(Jt.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=ue(b(e.body),t),s=new B("mphantom",n);r=new B("mpadded",[s]),r.setAttribute("width","0.1px")}const n=he(e.body,t);let s;if("llap"===e.alignment?(n.style.position="absolute",n.style.right="0",n.style.bottom="0",s=new B("mpadded",[r,n])):s=new B("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}}),h({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}}}),h({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,r){throw new e(`Mismatched ${t.funcName}`,r)}});h({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:b(t[0]),text:b(t[1]),script:b(t[2]),scriptscript:b(t[3])}),mathmlBuilder:(e,t)=>{const r=((e,t)=>{switch(t.level){case Ve:return e.display;case _e:return e.text;case We:return e.script;case Xe:return e.scriptscript;default:return e.text}})(e,t);return de(r,t)}});const Kt=["text","textord","mathord","atom"];function Qt(e,t){let r;const n=ue(e.body,t);if("minner"===e.mclass)r=new B("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 B("mi",n);else{r=new B("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 B("mrow",n);const s=t.level<2;"mrow"===r.type?s&&("mbin"===e.mclass?(r.children.unshift(Be(.2222)),r.children.push(Be(.2222))):"mrel"===e.mclass?(r.children.unshift(Be(.2778)),r.children.push(Be(.2778))):"mpunct"===e.mclass?r.children.push(Be(.1667)):"minner"===e.mclass&&(r.children.unshift(Be(.0556)),r.children.push(Be(.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}h({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(!Kt.includes(t.type)){o=!1;break}G[e.mode][t.text]?a.text+=G[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:b(o?a:n),isCharacterBox:s,mustPromote:o}},mathmlBuilder:Qt});const er=e=>{const t="ordgroup"===e.type&&e.body.length&&1===e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};h({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:er(t[0]),body:b(t[1]),isCharacterBox:i(t[1])})}),h({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?er(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:b(n)};return{type:"supsub",mode:s.mode,stack:!0,base:a,sup:"\\underset"===t?null:s,sub:"\\underset"===t?s:null}},mathmlBuilder:Qt});const tr=(e,t,r)=>{if(!e)return r;const n=he(e,t);return"mrow"===n.type&&0===n.children.length?r:n};h({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=he(e.base,t),n=new B("mprescripts"),s=new B("none");let o=[];const a=tr(e.prescripts.sub,t,s),l=tr(e.prescripts.sup,t,s);if(e.isSideset&&(a.setAttribute("style","text-align: left;"),l.setAttribute("style","text-align: left;")),e.postscripts){o=[r,tr(e.postscripts.sub,t,s),tr(e.postscripts.sup,t,s),n,a,l]}else o=[r,n,a,l];return new B("mmultiscripts",o)}}),h({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=b(t[0]),"\\"===n[0].text.charAt(0)&&(n[0].text=G.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 ue(e.body,t,!0)[0]}return de(e.body,t)}});const rr=["textord","mathord","atom"],nr=["\\smallint"],sr=["textord","mathord","ordgroup","close","leftright","font"],or=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},ar=(e,t)=>{let r;if(e.symbol)r=new B("mo",[oe(e.name,e.mode)]),nr.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false"),e.fromMathOp&&or(r);else if(e.body)r=new B("mo",ue(e.body,t)),e.fromMathOp&&or(r);else if(r=new B("mi",[new C(e.name.slice(1))]),!e.parentIsSupSub){const t=[r,new B("mo",[oe("","text")])];if(e.needsLeadingSpace){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.push(e)}r=new B("mrow",t)}return r},lr={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨅":"\\bigsqcap","⨆":"\\bigsqcup","⨃":"\\bigcupdot","⨇":"\\bigdoublevee","⨈":"\\bigdoublewedge","⨉":"\\bigtimes"};h({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=lr[n]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:ar}),h({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&&rr.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:b(r)}},mathmlBuilder:ar});const ir={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint","∱":"\\intclockwise","∲":"\\varointclockwise","⨌":"\\iiiint","⨍":"\\intbar","⨎":"\\intBar","⨏":"\\fint","⨒":"\\rppolint","⨓":"\\scpolint","⨕":"\\pointint","⨖":"\\sqint","⨗":"\\intlarhk","⨘":"\\intx","⨙":"\\intcap","⨚":"\\intcup"};h({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:Ft(n),needsLeadingSpace:r.length>0&&sr.includes(r),name:t}},mathmlBuilder:ar}),h({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:Ft(n),needsLeadingSpace:r.length>0&&sr.includes(r),name:t}},mathmlBuilder:ar}),h({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=ir[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:ar});h({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:b(n),alwaysHandleSupSub:"\\operatornamewithlimits"===t,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:Ft(o),needsLeadingSpace:s.length>0&&sr.includes(s)}},mathmlBuilder:(e,t)=>{let r,n=ue(e.body,t.withFont("mathrm")),s=!0;for(let e=0;e<n.length;e++){let t=n[e];if(t instanceof B)switch(("mrow"===t.type||"mpadded"===t.type)&&1===t.children.length&&t.children[0]instanceof B&&(t=t.children[0]),t.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(t.attributes.width){const r=t.attributes.width.replace("em",""),o=Zt(Number(r));""===o?s=!1:n[e]=new B("mtext",[new C(o)])}break;case"mo":{const e=t.children[0];1===t.children.length&&e instanceof C?e.text=e.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):s=!1;break}default:s=!1}else s=!1}if(s){const e=n.map((e=>e.toText())).join("");n=[new C(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 B("mrow",n);{const e=new B("mo",[oe("","text")]);return O([n[0],e])}}if(s?(r=new B("mi",n),1===n[0].text.length&&r.setAttribute("mathvariant","normal")):r=new B("mrow",n),!e.parentIsSupSub){const t=[r,new B("mo",[oe("","text")])];if(e.needsLeadingSpace){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.push(e)}return O(t)}return r}}),Ye("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),g({type:"ordgroup",mathmlBuilder:(e,t)=>de(e.body,t,e.semisimple)}),h({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"phantom",mode:e.mode,body:b(r)}},mathmlBuilder:(e,t)=>{const r=ue(e.body,t);return new B("mphantom",r)}}),h({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=ue(b(e.body),t),n=new B("mphantom",r),s=new B("mpadded",[n]);return s.setAttribute("height","0px"),s.setAttribute("depth","0px"),s}}),h({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=ue(b(e.body),t),n=new B("mphantom",r),s=new B("mpadded",[n]);return s.setAttribute("width","0px"),s}}),h({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:b(t[0])}),mathmlBuilder(e,t){const r=ue(e.body,t),n=N(r);return n.setAttribute("style","font-weight:bold"),n}});const cr=(e,t)=>{const r=t.withLevel(_e),n=new B("mpadded",[he(e.body,r)]),s=Oe(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};h({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},r){const n=Le(r[0],"size").value;"\\lower"===t&&(n.number*=-1);const s=r[1];return{type:"raise",mode:e.mode,dy:n,body:s}},mathmlBuilder:cr}),h({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},r){const n=Le(r[0],"size").value,s=r[1];return{type:"raise",mode:e.mode,dy:n,body:s}},mathmlBuilder:cr}),h({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(Yt,"")}),mathmlBuilder(e,t){const r="\\ref"===e.funcName?["tml-ref"]:["tml-ref","tml-eqref"];return new S("#"+e.string,r,null)}}),h({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=he(e.body,t);return r.style.transform="scaleX(-1)",r}}),h({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),h({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=Le(t[0],"size"),o=Le(t[1],"size");return{type:"rule",mode:e.mode,shift:n&&Le(n,"size").value,width:s.value,height:o.value}},mathmlBuilder(e,t){const r=Oe(e.width,t),n=Oe(e.height,t),s=e.shift?Oe(e.shift,t):{number:0,unit:"em"},o=t.color&&t.getColor()||"black",a=new B("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 B("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 mr=/^[0-9]$/,pr={0:"₀",1:"₁",2:"₂",3:"₃",4:"₄",5:"₅",6:"₆",7:"₇",8:"₈",9:"₉"},ur={0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹"};h({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||!mr.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||!mr.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=>ur[e])).join(""),n=e.denominator.split("").map((e=>pr[e])).join(""),s=new C(r+"⁄"+n,e.mode,t);return new B("mn",[s],["special-fraction"])}});const dr={"\\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};h({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(dr[e.funcName]),n=ue(e.body,r),s=N(n),o=(dr[e.funcName]/t.fontSize).toFixed(4);return s.setAttribute("mathsize",o+"em"),s}}),h({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]&&Le(r[0],"ordgroup");if(o){let e="";for(let t=0;t<o.body.length;++t){if(e=o.body[t].text,"t"===e)n=!0;else{if("b"!==e){n=!1,s=!1;break}s=!0}}}else n=!0,s=!0;const a=t[0];return{type:"smash",mode:e.mode,body:a,smashHeight:n,smashDepth:s}},mathmlBuilder:(e,t)=>{const r=new B("mpadded",[he(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}});const hr=["a","c","e","ı","m","n","o","r","s","u","v","w","x","z","α","ε","ι","κ","ν","ο","π","σ","τ","υ","ω","\\alpha","\\epsilon","\\iota","\\kappa","\\nu","\\omega","\\pi","\\tau","\\omega"];h({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&&hr.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 B("mroot",[he(r,t),he(n,t.incrementLevel())]):new B("msqrt",[he(r,t)])}});const gr={display:0,text:1,script:2,scriptscript:3},fr={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};h({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(gr[e.scriptLevel]),n=ue(e.body,r),s=N(n),o=fr[e.scriptLevel];return s.setAttribute("scriptlevel",o[0]),s.setAttribute("displaystyle",o[1]),s}});const br=/^m(over|under|underover)$/;g({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?[he(e.base.body[0],t)]:[he(e.base,t)],c=t.inSubOrSup();if(e.sub){const r=he(e.sub,c);3===t.level&&r.setAttribute("scriptlevel","2"),i.push(r)}if(e.sup){const r=he(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===Ve||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.level===Ve||r.limits)?"munderover":"msubsup"}else{const r=e.base;m=e.stack||r&&"op"===r.type&&r.limits&&(t.level===Ve||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===Ve)?"munder":"msub"}else{const r=e.base;m=r&&"op"===r.type&&r.limits&&(t.level===Ve||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===Ve)?"mover":"msup"}let p=new B(m,i);if(o){const e=new B("mo",[oe("","text")]);if(l){const t=new B("mspace");t.setAttribute("width","0.1667em"),p=O([t,p,e])}else p=O([p,e]);if(a){const e=new B("mspace");e.setAttribute("width","0.1667em"),p.children.push(e)}}else br.test(m)&&(p=new B("mrow",[p]));return p}});const yr=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],wr=["\\Rsh","\\Lsh","\\restriction"];g({type:"atom",mathmlBuilder(e,t){const r=new B("mo",[oe(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<t&&t<8704}return e.indexOf("arrow")>-1||e.indexOf("harpoon")>-1||wr.includes(e)})(e.text))r.setAttribute("stretchy","false");else if(yr.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 B("mrow",[Be(.222),r,Be(.222)]):new B("mrow",[Be(.2778),r,Be(.2778)]);return r}});const xr={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},kr=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<t&&t<975?"italic":"normal"}case"up@greek":return"normal";case"boldsymbol":case"mathboldsymbol":return"bold-italic";case"mathbf":return"bold";case"mathbb":return"double-struck";case"mathfrak":return"fraktur";case"mathscr":case"mathcal":return"script";case"mathsf":return"sans-serif";case"mathsfit":return"sans-serif-italic";case"mathtt":return"monospace"}let s=e.text;return G[n][s]&&G[n][s].replace&&(s=G[n][s].replace),Object.prototype.hasOwnProperty.call(xr,r)?xr[r]:null},vr=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),Ar=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Tr=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),Sr=Object.freeze({"ϵ":119527,"ϑ":119564,"ϰ":119534,"φ":119577,"ϱ":119535,"ϖ":119563}),qr=Object.freeze({"ϵ":119643,"ϑ":119680,"ϰ":119650,"φ":119693,"ϱ":119651,"ϖ":119679}),Or=Object.freeze({"ϵ":119701,"ϑ":119738,"ϰ":119708,"φ":119751,"ϱ":119709,"ϖ":119737}),Br=Object.freeze({"ϵ":119759,"ϑ":119796,"ϰ":119766,"φ":119809,"ϱ":119767,"ϖ":119795}),Cr=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>vr[e]||119899,"script-bold":e=>119951,fraktur:e=>Ar[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>Tr[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=>vr[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=>Sr[e]||-51,italic:e=>0,"bold-italic":e=>qr[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Or[e]||116,"sans-serif-bold":e=>Or[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Br[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}}),Nr=(e,t)=>{const r=e.codePointAt(0),n=64<r&&r<91?"upperCaseLatin":96<r&&r<123?"lowerCaseLatin":912<r&&r<938?"upperCaseGreek":944<r&&r<970||"ϕ"===e?"lowerCaseGreek":120545<r&&r<120572||Sr[e]?"varGreek":47<r&&r<58?"numeral":"other";return"other"===n?e:String.fromCodePoint(r+Cr[n][t](e))},zr=Object.freeze({a:"ᴀ",b:"ʙ",c:"ᴄ",d:"ᴅ",e:"ᴇ",f:"ꜰ",g:"ɢ",h:"ʜ",i:"ɪ",j:"ᴊ",k:"ᴋ",l:"ʟ",m:"ᴍ",n:"ɴ",o:"ᴏ",p:"ᴘ",q:"ǫ",r:"ʀ",s:"s",t:"ᴛ",u:"ᴜ",v:"ᴠ",w:"ᴡ",x:"x",y:"ʏ",z:"ᴢ"}),$r=/^\d(?:[\d,.]*\d)?$/,Er=/[A-Ba-z]/,Ir=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);g({type:"mathord",mathmlBuilder(e,t){const r=oe(e.text,e.mode,t),n=r.text.codePointAt(0),s=912<n&&n<938?"normal":"italic",o=kr(e,t)||s;if("script"===o)return r.text=Nr(r.text,o),new B("mi",[r],[t.font]);"italic"!==o&&(r.text=Nr(r.text,o));let a=new B("mi",[r]);return"normal"===o&&(a.setAttribute("mathvariant","normal"),1===r.text.length&&(a=new B("mpadded",[a]),a.setAttribute("lspace","0"))),a}}),g({type:"textord",mathmlBuilder(e,t){let r=e.text;const n=r.codePointAt(0);"textsc"===t.fontFamily&&96<n&&n<123&&(r=zr[r]);const s=oe(r,e.mode,t),o=kr(e,t)||"normal";let a;if($r.test(e.text)){const t="text"===e.mode?"mtext":"mn";if("italic"===o||"bold-italic"===o)return((e,t,r)=>{const n=new B(r,[e]),s=new B("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=>Nr(e,o))).join("")),a=new B(t,[s])}else if("text"===e.mode)"normal"!==o&&(s.text=Nr(s.text,o)),a=new B("mtext",[s]);else if(Ir.has(e.text))a=new B("mo",[s]),a.classes.push("tml-prime");else{const e=s.text;"italic"!==o&&(s.text=Nr(s.text,o)),a=new B("mi",[s]),s.text===e&&Er.test(e)&&a.setAttribute("mathvariant","italic")}return a}});const Lr={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Fr={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};g({type:"spacing",mathmlBuilder(t,r){let n;if(Object.prototype.hasOwnProperty.call(Fr,t.text))n=new B("mtext",[new C(" ")]);else{if(!Object.prototype.hasOwnProperty.call(Lr,t.text))throw new e(`Unknown type of space "${t.text}"`);n=new B("mo"),"\\nobreak"===t.text&&n.setAttribute("linebreak","nobreak")}return n}}),g({type:"tag"});const Mr={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},Gr={"\\textbf":"textbf","\\textmd":"textmd"},Dr={"\\textit":"textit","\\textup":"textup"};h({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:b(n),font:t}},mathmlBuilder(e,t){const r=((e,t)=>{const r=e.font;return r?Mr[r]?t.withTextFontFamily(Mr[r]):Gr[r]?t.withTextFontWeight(Gr[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Dr[r]):t})(e,t),n=de(e.body,r);return le(n)}}),h({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 B("mtd",[he(e.body,t)]);r.style.padding="0";const n=new B("mtr",[r]);return new B("mtable",[n])}}),h({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 C(jr(e)),n=new B("mtext",[r]);return n.setAttribute("mathvariant","monospace"),n}});const jr=e=>e.body.replace(/ /g,e.star?"␣":" "),Pr=u,Rr="[ \r\n\t]",Ur=`(\\\\[a-zA-Z@]+)${Rr}*`,Hr="[̀-ͯ]",Vr=new RegExp(`${Hr}+$`),_r=`(${Rr}+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-‧-豈-]${Hr}*|[\ud800-\udbff][\udc00-\udfff]${Hr}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${Ur}|\\\\[^\ud800-\udfff])`;class Wr{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(_r,"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 He("EOF",new Ue(this,r,r));const n=this.tokenRegex.exec(t);if(null===n||n.index!==r)throw new e(`Unexpected character: '${t[r]}'`,new He(t[r],new Ue(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 He(s,new Ue(this,r,this.tokenRegex.lastIndex))}}class Xr{constructor(e={},t={}){this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}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;t<this.undefStack.length;t++)delete this.undefStack[t][e];this.undefStack.length>0&&(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 Zr={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class Yr{constructor(e,t,r){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Xr(Je,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new Wr(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 He("EOF",r.loc)),this.pushTokens(n),t.range(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;t<n.length;t++){const r=this.popToken();if(n[t]!==r.text)throw new e("Use of the macro doesn't match its definition",r)}}const n=[];for(let e=0;e<t;e++)n.push(this.consumeArg(r&&r[e+1]).tokens);return n}expandOnce(t){const r=this.popToken(),n=r.text,s=r.noexpand?null:this._getExpansion(n);if(null==s||t&&s.unexpandable){if(t&&null==s&&"\\"===n[0]&&!this.isDefined(n))throw new e("Undefined control sequence: "+n);return this.pushToken(r),!1}if(this.expansionCount++,this.expansionCount>this.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 He(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 Wr(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(Pr,e)||Object.prototype.hasOwnProperty.call(G.math,e)||Object.prototype.hasOwnProperty.call(G.text,e)||Object.prototype.hasOwnProperty.call(Zr,e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(Pr,e)&&!Pr[e].primitive}}const Jr=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Kr=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","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),Qr=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 en={"́":{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"}},tn={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","ḋ":"ḋ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","Ḋ":"Ḋ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"Ȯ","Ȱ":"Ȱ","Ő":"Ő","Ṕ":"Ṕ","Ṗ":"Ṗ","Ŕ":"Ŕ","Ř":"Ř","Ṙ":"Ṙ","Ś":"Ś","Ṥ":"Ṥ","Š":"Š","Ṧ":"Ṧ","Ŝ":"Ŝ","Ṡ":"Ṡ","Ť":"Ť","Ṫ":"Ṫ","Ú":"Ú","Ù":"Ù","Ü":"Ü","Ǘ":"Ǘ","Ǜ":"Ǜ","Ǖ":"Ǖ","Ǚ":"Ǚ","Ũ":"Ũ","Ṹ":"Ṹ","Ū":"Ū","Ṻ":"Ṻ","Ŭ":"Ŭ","Ǔ":"Ǔ","Û":"Û","Ů":"Ů","Ű":"Ű","Ṽ":"Ṽ","Ẃ":"Ẃ","Ẁ":"Ẁ","Ẅ":"Ẅ","Ŵ":"Ŵ","Ẇ":"Ẇ","Ẍ":"Ẍ","Ẋ":"Ẋ","Ý":"Ý","Ỳ":"Ỳ","Ÿ":"Ÿ","Ỹ":"Ỹ","Ȳ":"Ȳ","Ŷ":"Ŷ","Ẏ":"Ẏ","Ź":"Ź","Ž":"Ž","Ẑ":"Ẑ","Ż":"Ż","ά":"ά","ὰ":"ὰ","ᾱ":"ᾱ","ᾰ":"ᾰ","έ":"έ","ὲ":"ὲ","ή":"ή","ὴ":"ὴ","ί":"ί","ὶ":"ὶ","ϊ":"ϊ","ΐ":"ΐ","ῒ":"ῒ","ῑ":"ῑ","ῐ":"ῐ","ό":"ό","ὸ":"ὸ","ύ":"ύ","ὺ":"ὺ","ϋ":"ϋ","ΰ":"ΰ","ῢ":"ῢ","ῡ":"ῡ","ῠ":"ῠ","ώ":"ώ","ὼ":"ὼ","Ύ":"Ύ","Ὺ":"Ὺ","Ϋ":"Ϋ","Ῡ":"Ῡ","Ῠ":"Ῠ","Ώ":"Ώ","Ὼ":"Ὼ"};const rn=["bin","op","open","punct","rel"],nn=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,sn=/^ *\\text/;class on{constructor(e,t,r=!1){this.mode="math",this.gullet=new Yr(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 He("}")),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!==on.endOfExpression.indexOf(s.text))break;if(t&&s.text===t)break;if(r&&"\\middle"===s.text)break;if(e&&Pr[s.text]&&Pr[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<t.length;s++)if("infix"===t[s].type){if(-1!==n)throw new e("only one infix operator per group",t[s].token);n=s,r=t[s].replaceWith}if(-1!==n&&r){let e,s;const o=t.slice(0,n),a=t.slice(n+1);let l;return e=1===o.length&&"ordgroup"===o[0].type?o[0]:{type:"ordgroup",mode:this.mode,body:o},s=1===a.length&&"ordgroup"===a[0].type?a[0]:{type:"ordgroup",mode:this.mode,body:a},l="\\\\abovefrac"===r?this.callFunction(r,[e,t[n],s],[]):this.callFunction(r,[e,s],[]),[l]}return t}handleSupSubscript(t){const r=this.fetch(),n=r.text;let s;this.consume(),this.consumeSpaces();do{s=this.parseGroup(t)}while(s.type&&"internal"===s.type);if(!s)throw new e("Expected group after '"+n+"'",r);return s}formatUnsupportedCmd(e){const t=[];for(let r=0;r<e.length;r++)t.push({type:"textord",mode:"text",text:e[r]});const r={type:"text",mode:this.mode,body:t};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(t){const r=this.parseGroup("atom",t);if(r&&"internal"===r.type)return r;if("text"===this.mode)return r;let n,s;for(;;){this.consumeSpaces();const t=this.fetch();if("\\limits"===t.text||"\\nolimits"===t.text){if(r&&"op"===r.type){const e="\\limits"===t.text;r.limits=e,r.alwaysHandleSupSub=!0}else{if(!r||"operatorname"!==r.type)throw new e("Limit controls must follow a math operator",t);r.alwaysHandleSupSub&&(r.limits="\\limits"===t.text)}this.consume()}else if("^"===t.text){if(n)throw new e("Double superscript",t);n=this.handleSupSubscript("superscript")}else if("_"===t.text){if(s)throw new e("Double subscript",t);s=this.handleSupSubscript("subscript")}else if("'"===t.text){if(n)throw new e("Double superscript",t);const r={type:"textord",mode:this.mode,text:"\\prime"},s=[r];for(this.consume();"'"===this.fetch().text;)s.push(r),this.consume();"^"===this.fetch().text&&s.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:s}}else{if(!Kr[t.text])break;{const e=Jr.test(t.text),r=[];for(r.push(new He(Kr[t.text])),this.consume();;){const t=this.fetch().text;if(!Kr[t])break;if(Jr.test(t)!==e)break;r.unshift(new He(Kr[t])),this.consume()}const o=this.subparse(r);e?s={type:"ordgroup",mode:"math",body:o}:n={type:"ordgroup",mode:"math",body:o}}}}if(n||s){if(r&&"multiscript"===r.type&&!r.postscripts)return r.postscripts={sup:n,sub:s},r;{const e=!r||"op"!==r.type&&"operatorname"!==r.type?void 0:Ft(this.nextToken.text);return{type:"supsub",mode:this.mode,base:r,sup:n,sub:s,isFollowedByDelimiter:e}}}return r}parseFunction(t,r){const n=this.fetch(),s=n.text,o=Pr[s];if(!o)return null;if(this.consume(),r&&"atom"!==r&&!o.allowedInArgument)throw new e("Got function '"+s+"' with no arguments"+(r?" as "+r:""),n);if("text"===this.mode&&!o.allowedInText)throw new e("Can't use function '"+s+"' in text mode",n);if("math"===this.mode&&!1===o.allowedInMath)throw new e("Can't use function '"+s+"' in math mode",n);const a=this.prevAtomType,{args:l,optArgs:i}=this.parseArguments(s,o);return this.prevAtomType=a,this.callFunction(s,l,i,n,t)}callFunction(t,r,n,s,o){const a={funcName:t,parser:this,token:s,breakOnTokenText:o},l=Pr[t];if(l&&l.handler)return l.handler(a,r,n);throw new e(`No function handler for ${t}`)}parseArguments(t,r){const n=r.numArgs+r.numOptionalArgs;if(0===n)return{args:[],optArgs:[]};const s=[],o=[];for(let a=0;a<n;a++){let n=r.argTypes&&r.argTypes[a];const l=a<r.numOptionalArgs;(r.primitive&&null==n||"sqrt"===r.type&&1===a&&null==o[0])&&(n="primitive");const i=this.parseGroupOfType(`argument to '${t}'`,n,l);if(l)o.push(i);else{if(null==i)throw new e("Null argument, please report this as a bug");s.push(i)}}return{args:s,optArgs:o}}parseGroupOfType(t,r,n){switch(r){case"size":return this.parseSizeGroup(n);case"url":return this.parseUrlGroup(n);case"math":case"text":return this.parseArgumentGroup(n,r);case"hbox":{const e=this.parseArgumentGroup(n,"text");return null!=e?{type:"styling",mode:e.mode,body:[e],scriptLevel:"text"}:null}case"raw":{const e=this.parseStringGroup("raw",n);return null!=e?{type:"raw",mode:"text",string:e.text}:null}case"primitive":{if(n)throw new e("A primitive argument cannot be optional");const r=this.parseGroup(t);if(null==r)throw new e("Expected group as "+t,this.fetch());return r}case"original":case null:case void 0:return this.parseArgumentGroup(n);default:throw new e("Unknown group type as "+t,this.fetch())}}consumeSpaces(){for(;;){const e=this.fetch().text;if(" "!==e&&" "!==e&&"︎"!==e)break;this.consume()}}parseStringGroup(e,t){const r=this.gullet.scanArgument(t);if(null==r)return null;let n,s="";for(;"EOF"!==(n=this.fetch()).text;)s+=n.text,this.consume();return this.consume(),r.text=s,r}parseRegexGroup(t,r){const n=this.fetch();let s,o=n,a="";for(;"EOF"!==(s=this.fetch()).text&&t.test(a+s.text);)o=s,a+=o.text,this.consume();if(""===a)throw new e("Invalid "+r+": '"+n.text+"'",n);return n.range(o,a)}parseSizeGroup(t){let r,n=!1;if(this.gullet.consumeSpaces(),r=t||"{"===this.gullet.future().text?this.parseStringGroup("size",t):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"),!r)return null;t||0!==r.text.length||(r.text="0pt",n=!0);const s=nn.exec(r.text);if(!s)throw new e("Invalid size: '"+r.text+"'",r);const o={number:+(s[1]+s[2]),unit:s[3]};if(!Se(o))throw new e("Invalid unit: '"+o.unit+"'",r);return{type:"size",mode:this.mode,value:o,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);const t=this.parseStringGroup("url",e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),null==t)return null;let r=t.text.replace(/\\([#$%&~_^{}])/g,"$1");return r=t.text.replace(/{\u2044}/g,"/"),{type:"url",mode:this.mode,url:r}}parseArgumentGroup(e,t){const r=this.gullet.scanArgument(e);if(null==r)return null;const n=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();const s=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();const o={type:"ordgroup",mode:this.mode,loc:r.loc,body:s};return t&&this.switchMode(n),o}parseGroup(e,t){const r=this.fetch(),n=r.text;let s;if("{"===n||"\\begingroup"===n||"\\toggle"===n){this.consume();const e="{"===n?"}":"\\begingroup"===n?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();const t=this.parseExpression(!1,e),o=this.fetch();this.expect(e),this.gullet.endGroup(),s={type:"\\endtoggle"===o.text?"toggle":"ordgroup",mode:this.mode,loc:Ue.range(r,o),body:t,semisimple:"\\begingroup"===n||void 0}}else s=this.parseFunction(t,e)||this.parseSymbol(),null!=s||"\\"!==n[0]||Object.prototype.hasOwnProperty.call(Zr,n)||(s=this.formatUnsupportedCmd(n),this.consume());return s}formLigatures(e){let t=e.length-1;for(let r=0;r<t;++r){const n=e[r],s=n.text;"-"===s&&"-"===e[r+1].text&&(r+1<t&&"-"===e[r+2].text?(e.splice(r,3,{type:"textord",mode:"text",loc:Ue.range(n,e[r+2]),text:"---"}),t-=2):(e.splice(r,2,{type:"textord",mode:"text",loc:Ue.range(n,e[r+1]),text:"--"}),t-=1)),"'"!==s&&"`"!==s||e[r+1].text!==s||(e.splice(r,2,{type:"textord",mode:"text",loc:Ue.range(n,e[r+1]),text:s+s}),t-=1)}}parseSymbol(){const t=this.fetch();let r=t.text;if(/^\\verb[^a-zA-Z]/.test(r)){this.consume();let t=r.slice(5);const n="*"===t.charAt(0);if(n&&(t=t.slice(1)),t.length<2||t.charAt(0)!==t.slice(-1))throw new e("\\verb assertion failed --\n please report what input caused this bug");return t=t.slice(1,-1),{type:"verb",mode:"text",body:t,star:n}}if(Object.prototype.hasOwnProperty.call(tn,r[0])&&"math"===this.mode&&!G[this.mode][r[0]]){if(this.settings.strict&&"math"===this.mode)throw new e(`Accented Unicode text character "${r[0]}" used in math mode`,t);r=tn[r[0]]+r.slice(1)}const n="math"===this.mode?Vr.exec(r):null;let s;if(n&&(r=r.substring(0,n.index),"i"===r?r="ı":"j"===r&&(r="ȷ")),G[this.mode][r]){let e=G[this.mode][r].group;"bin"===e&&rn.includes(this.prevAtomType)&&(e="open");const n=Ue.range(t);let o;if(Object.prototype.hasOwnProperty.call(F,e)){const t=e;o={type:"atom",mode:this.mode,family:t,loc:n,text:r},"rel"!==t&&"bin"!==t||"text"!==this.prevAtomType||sn.test(n.lexer.input.slice(n.end))&&(o.needsSpacing=!0)}else{if(Qr[r]){this.consume();const e=this.fetch().text.charCodeAt(0),t=65025===e?"mathscr":"mathcal";return 65024!==e&&65025!==e||this.consume(),{type:"font",mode:"math",font:t,body:{type:"mathord",mode:"math",loc:n,text:Qr[r]}}}o={type:e,mode:this.mode,loc:n,text:r}}s=o}else{if(!(r.charCodeAt(0)>=128||Vr.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:Ue.range(t),text:r}}if(this.consume(),n)for(let r=0;r<n[0].length;r++){const o=n[0][r];if(!en[o])throw new e(`Unknown accent ' ${o}'`,t);const a=en[o][this.mode]||en[o].text;if(!a)throw new e(`Accent ${o} unsupported in ${this.mode} mode`,t);s={type:"accent",mode:this.mode,loc:Ue.range(t),label:a,isStretchy:!1,base:s}}return s}}const an=function(t,r){if(!("string"==typeof t||t instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new on(t,r);delete n.gullet.macros.current["\\df@tag"];let s=n.parse();if(!(s.length>0&&s[0].type&&"array"===s[0].type&&s[0].addEqnNum)&&n.gullet.macros.get("\\df@tag")){if(!r.displayMode)throw new e("\\tag works only in display mode");n.gullet.feed("\\df@tag"),s=[{type:"tag",mode:"text",body:s,tag:n.parse()}]}return s},ln=[2,2,3,3];class cn{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 cn(t)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:ln[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 mn(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 pn=function(e,t,r){let n=r,s=0;const o=e.length;for(;n<t.length;){const r=t[n];if(s<=0&&t.slice(n,n+o)===e)return n;"\\"===r?n++:"{"===r?s++:"}"===r&&s--,n++}return-1},un=/^\\(?:begin|(?:eq)?ref){/,dn=[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1},{left:"\\[",right:"\\]",display:!0}],hn={$:[{left:"$$",right:"$$",display:!0},{left:"$`",right:"`$",display:!1},{left:"$",right:"$",display:!1}],"(":[{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]},gn=[{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1}],fn=function(t,r){const n=function(e,t){let r;const n=[],s=new RegExp("("+t.map((e=>e.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=pn(t[s].right,e,t[s].left.length),-1===r)break;const o=e.slice(0,r+t[s].right.length),a=un.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<n.length;t++)if("text"===n[t].type)s.appendChild(document.createTextNode(n[t].data));else{const o=document.createElement("span");let a=n[t].data;r.displayMode=n[t].display;try{r.preProcess&&(a=r.preProcess(a)),temml.render(a,o,r)}catch(o){if(!(o instanceof e))throw o;r.errorCallback("Temml auto-render: Failed to parse `"+n[t].data+"` with ",o),s.appendChild(document.createTextNode(n[t].rawData));continue}s.appendChild(o)}return s},bn=function(e,t){for(let r=0;r<e.childNodes.length;r++){const n=e.childNodes[r];if(3===n.nodeType){const s=fn(n.textContent,t);s&&(r+=s.childNodes.length-1,e.replaceChild(s,n))}else if(1===n.nodeType){const e=" "+n.className+" ";-1===t.ignoredTags.indexOf(n.nodeName.toLowerCase())&&t.ignoredClasses.every((t=>-1===e.indexOf(" "+t+" ")))&&bn(n,t)}}};let yn=function(e,t,r={}){t.textContent="";const n="math"===t.tagName.toLowerCase();n&&(r.wrap="none");const s=wn(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."),yn=function(){throw new e("Temml doesn't work in quirks mode.")});const wn=function(t,r){const n=new p(r);try{const e=an(t,n);return ye(e,t,new cn({level:n.displayMode?Ve:_e,maxSize:n.maxSize}),n)}catch(r){return function(t,r,n){if(n.throwOnError||!(t instanceof e))throw t;const s=new A(["temml-error"],[new T(r+"\n\n"+t.toString())]);return s.style.color=n.errorColor,s.style.whiteSpace="pre-line",s}(r,t,n)}};return{version:"0.12.02",render:yn,renderToString:function(e,t){return wn(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 hn[e];if("$+"===e||"(+"===e)return hn[e.slice(0,1)].concat(gn);return"ams"===e?gn:"all"===e?hn["("].concat(hn.$).concat(gn):dn})(r.fences):r.delimiters=r.delimiters||dn,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||{},bn(e,r),mn(e)},postProcess:mn,ParseError:e,definePreamble:function(e,t){const r=new p(t);if(r.macros={},!("string"==typeof e||e instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new on(e,r,!0);delete n.gullet.macros.current["\\df@tag"];return n.parse()},__parse:function(e,t){const r=new p(t);return an(e,r)},__renderToMathMLTree:wn,__defineSymbol:D,__defineMacro:Ye}}();
|
|
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<e.length?e.slice(t,t+15)+"…":e.slice(t),s+=a+r+l}const a=new Error(s);return a.name="ParseError",a.__proto__=e.prototype,a.position=n,a}}e.prototype.__proto__=Error.prototype;const t=function(e,t){return void 0===e?t:e},r=/([A-Z])/g,n=function(e){return e.replace(r,"-$1").toLowerCase()},s={"&":"&",">":">","<":"<",'"':""","'":"'"},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αγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";class p{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.macros||{},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),this.maxSize=void 0===e.maxSize?[1/0,1/0]:Array.isArray(e.maxSize)?e.maxSize:[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 u={},d={};function h({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;e<t.length;++e)u[t[e]]=o;e&&s&&(d[e]=s)}function g({type:e,mathmlBuilder:t}){h({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:t})}const f=function(e){return"ordgroup"===e.type&&1===e.body.length?e.body[0]:e},b=function(e){return"ordgroup"===e.type?e.body:[e]};class y{constructor(e){this.children=e,this.classes=[],this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createDocumentFragment();for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e="";for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>e.toText()).join("")}}const w=function(e){return e.filter(e=>e).join(" ")},x=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},k=function(e){const t=document.createElement(e);t.className=w(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<this.children.length;e++)t.appendChild(this.children[e].toNode());return t},v=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${a(w(this.classes))}"`);let r="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(r+=`${n(e)}:${this.style[e]};`);r&&(t+=` style="${r}"`);for(const e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&(t+=` ${e}="${a(this.attributes[e])}"`);t+=">";for(let e=0;e<this.children.length;e++)t+=this.children[e].toMarkup();return t+=`</${e}>`,t};class A{constructor(e,t,r){x.call(this,e,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return k.call(this,"span")}toMarkup(){return v.call(this,"span")}}let T=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.text)}};class S{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=w(this.classes));for(let t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e=`<a href='${a(this.href)}'`;this.classes.length>0&&(e+=` class="${a(w(this.classes))}"`),e+=">";for(let t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e+="</a>",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=`<img src='${this.src}' alt='${this.alt}'`,t="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${n(e)}:${this.style[e]};`);return t&&(e+=` style="${a(t)}"`),e+=">",e}}function O(e){return new y(e)}class B{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=w(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;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){let e="<"+this.type;for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="',e+=a(this.attributes[t]),e+='"');this.classes.length>0&&(e+=` class="${a(w(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<this.children.length;t++)e+=this.children[t].toMarkup();return e+="</"+this.type+">",e}toText(){return this.children.map(e=>e.toText()).join("")}}class C{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.toText())}toText(){return this.text}}const N=e=>{let t;return 1===e.length&&"mrow"===e[0].type?(t=e.pop(),t.type="mstyle"):t=new B("mstyle",e),t},z=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(const r of e.body)t+=z(r);else if(e.body)t+=z(e.body);else if("supsub"===e.type)t+=z(e.base),e.sub&&(t+=.7*z(e.sub)),e.sup&&(t+=.7*z(e.sup));else if("mathord"===e.type||"textord"===e.type)for(const r of e.text.split("")){const e=r.codePointAt(0);t+=96<e&&e<123||944<e&&e<970?.56:47<e&&e<58?.5:.92}else t+=1;return t},$={widehat:"^",widecheck:"ˇ",widetilde:"~",wideparen:"⏜",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overbracket:"⎴",underbracket:"⎵",overgroup:"⏠",overparen:"⏜",undergroup:"⏡",underparen:"⏝",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xrightleftarrows:"⇄",xtofrom:"⇄",xleftrightharpoons:"⇋",xrightleftharpoons:"⇌",yields:"→",yieldsLeft:"←",mesomerism:"↔",longrightharpoonup:"⇀",longleftharpoondown:"↽",eqrightharpoonup:"⇀",eqleftharpoondown:"↽","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"=",yieldsLeftRight:"⇄",chemequilibrium:"⇌"},E=function(e){const t=new C($[e.slice(1)]),r=new B("mo",[t]);return r.setAttribute("stretchy","true"),r},I=["\\widetilde","\\widehat","\\widecheck","\\utilde"],L=e=>{const t=E(e.label);if(I.includes(e.label)){const r=z(e.base);1<r&&r<1.6?t.classes.push("tml-crooked-2"):1.6<=r&&r<2.5?t.classes.push("tml-crooked-3"):2.5<=r&&t.classes.push("tml-crooked-4")}return t},F={bin:1,close:1,inner:1,open:1,punct:1,rel:1},M={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},D={math:{},text:{}};function G(e,t,r,n,s){D[e][n]={group:t,replace:r},s&&r&&(D[e][r]=D[e][n])}const P="math",j="text",R="accent-token",U="bin",H="close",V="inner",_="mathord",W="op-token",X="open",Z="punct",Y="rel",J="spacing",K="textord";G(P,Y,"≡","\\equiv",!0),G(P,Y,"≺","\\prec",!0),G(P,Y,"≻","\\succ",!0),G(P,Y,"∼","\\sim",!0),G(P,Y,"⟂","\\perp",!0),G(P,Y,"⪯","\\preceq",!0),G(P,Y,"⪰","\\succeq",!0),G(P,Y,"≃","\\simeq",!0),G(P,Y,"≌","\\backcong",!0),G(P,Y,"|","\\mid",!0),G(P,Y,"≪","\\ll",!0),G(P,Y,"≫","\\gg",!0),G(P,Y,"≍","\\asymp",!0),G(P,Y,"∥","\\parallel"),G(P,Y,"⌣","\\smile",!0),G(P,Y,"⊑","\\sqsubseteq",!0),G(P,Y,"⊒","\\sqsupseteq",!0),G(P,Y,"≐","\\doteq",!0),G(P,Y,"⌢","\\frown",!0),G(P,Y,"∋","\\ni",!0),G(P,Y,"∌","\\notni",!0),G(P,Y,"∝","\\propto",!0),G(P,Y,"⊢","\\vdash",!0),G(P,Y,"⊣","\\dashv",!0),G(P,Y,"∋","\\owns"),G(P,Y,"≘","\\arceq",!0),G(P,Y,"≙","\\wedgeq",!0),G(P,Y,"≚","\\veeeq",!0),G(P,Y,"≛","\\stareq",!0),G(P,Y,"≝","\\eqdef",!0),G(P,Y,"≞","\\measeq",!0),G(P,Y,"≟","\\questeq",!0),G(P,Y,"≠","\\ne",!0),G(P,Y,"≠","\\neq"),G(P,Y,"⩵","\\eqeq",!0),G(P,Y,"⩶","\\eqeqeq",!0),G(P,Y,"∷","\\dblcolon",!0),G(P,Y,"≔","\\coloneqq",!0),G(P,Y,"≕","\\eqqcolon",!0),G(P,Y,"∹","\\eqcolon",!0),G(P,Y,"⩴","\\Coloneqq",!0),G(P,Z,".","\\ldotp"),G(P,Z,"·","\\cdotp"),G(P,K,"#","\\#"),G(j,K,"#","\\#"),G(P,K,"&","\\&"),G(j,K,"&","\\&"),G(P,K,"ℵ","\\aleph",!0),G(P,K,"∀","\\forall",!0),G(P,K,"ℏ","\\hbar",!0),G(P,K,"∃","\\exists",!0),G(P,X,"∇","\\nabla",!0),G(P,K,"♭","\\flat",!0),G(P,K,"ℓ","\\ell",!0),G(P,K,"♮","\\natural",!0),G(P,K,"Å","\\Angstrom",!0),G(j,K,"Å","\\Angstrom",!0),G(P,K,"♣","\\clubsuit",!0),G(P,K,"♧","\\varclubsuit",!0),G(P,K,"℘","\\wp",!0),G(P,K,"♯","\\sharp",!0),G(P,K,"♢","\\diamondsuit",!0),G(P,K,"♦","\\vardiamondsuit",!0),G(P,K,"ℜ","\\Re",!0),G(P,K,"♡","\\heartsuit",!0),G(P,K,"♥","\\varheartsuit",!0),G(P,K,"ℑ","\\Im",!0),G(P,K,"♠","\\spadesuit",!0),G(P,K,"♤","\\varspadesuit",!0),G(P,K,"♀","\\female",!0),G(P,K,"♂","\\male",!0),G(P,K,"§","\\S",!0),G(j,K,"§","\\S"),G(P,K,"¶","\\P",!0),G(j,K,"¶","\\P"),G(j,K,"☺","\\smiley",!0),G(P,K,"☺","\\smiley",!0),G(P,K,"†","\\dag"),G(j,K,"†","\\dag"),G(j,K,"†","\\textdagger"),G(P,K,"‡","\\ddag"),G(j,K,"‡","\\ddag"),G(j,K,"‡","\\textdaggerdbl"),G(P,H,"⎱","\\rmoustache",!0),G(P,X,"⎰","\\lmoustache",!0),G(P,H,"⟯","\\rgroup",!0),G(P,X,"⟮","\\lgroup",!0),G(P,U,"∓","\\mp",!0),G(P,U,"⊖","\\ominus",!0),G(P,U,"⊎","\\uplus",!0),G(P,U,"⊓","\\sqcap",!0),G(P,U,"∗","\\ast"),G(P,U,"⊔","\\sqcup",!0),G(P,U,"◯","\\bigcirc",!0),G(P,U,"∙","\\bullet",!0),G(P,U,"‡","\\ddagger"),G(P,U,"≀","\\wr",!0),G(P,U,"⨿","\\amalg"),G(P,U,"&","\\And"),G(P,U,"⫽","\\sslash",!0),G(P,Y,"⟵","\\longleftarrow",!0),G(P,Y,"⇐","\\Leftarrow",!0),G(P,Y,"⟸","\\Longleftarrow",!0),G(P,Y,"⟶","\\longrightarrow",!0),G(P,Y,"⇒","\\Rightarrow",!0),G(P,Y,"⟹","\\Longrightarrow",!0),G(P,Y,"↔","\\leftrightarrow",!0),G(P,Y,"⟷","\\longleftrightarrow",!0),G(P,Y,"⇔","\\Leftrightarrow",!0),G(P,Y,"⟺","\\Longleftrightarrow",!0),G(P,Y,"↤","\\mapsfrom",!0),G(P,Y,"↦","\\mapsto",!0),G(P,Y,"⟼","\\longmapsto",!0),G(P,Y,"↗","\\nearrow",!0),G(P,Y,"↩","\\hookleftarrow",!0),G(P,Y,"↪","\\hookrightarrow",!0),G(P,Y,"↘","\\searrow",!0),G(P,Y,"↼","\\leftharpoonup",!0),G(P,Y,"⇀","\\rightharpoonup",!0),G(P,Y,"↙","\\swarrow",!0),G(P,Y,"↽","\\leftharpoondown",!0),G(P,Y,"⇁","\\rightharpoondown",!0),G(P,Y,"↖","\\nwarrow",!0),G(P,Y,"⇌","\\rightleftharpoons",!0),G(P,_,"↯","\\lightning",!0),G(P,_,"∎","\\QED",!0),G(P,_,"‰","\\permil",!0),G(j,K,"‰","\\permil"),G(P,_,"☉","\\astrosun",!0),G(P,_,"☼","\\sun",!0),G(P,_,"☾","\\leftmoon",!0),G(P,_,"☽","\\rightmoon",!0),G(P,_,"⊕","\\Earth"),G(P,Y,"≮","\\nless",!0),G(P,Y,"⪇","\\lneq",!0),G(P,Y,"≨","\\lneqq",!0),G(P,Y,"≨︀","\\lvertneqq"),G(P,Y,"⋦","\\lnsim",!0),G(P,Y,"⪉","\\lnapprox",!0),G(P,Y,"⊀","\\nprec",!0),G(P,Y,"⋠","\\npreceq",!0),G(P,Y,"⋨","\\precnsim",!0),G(P,Y,"⪹","\\precnapprox",!0),G(P,Y,"≁","\\nsim",!0),G(P,Y,"∤","\\nmid",!0),G(P,Y,"∤","\\nshortmid"),G(P,Y,"⊬","\\nvdash",!0),G(P,Y,"⊭","\\nvDash",!0),G(P,Y,"⋪","\\ntriangleleft"),G(P,Y,"⋬","\\ntrianglelefteq",!0),G(P,Y,"⊄","\\nsubset",!0),G(P,Y,"⊅","\\nsupset",!0),G(P,Y,"⊊","\\subsetneq",!0),G(P,Y,"⊊︀","\\varsubsetneq"),G(P,Y,"⫋","\\subsetneqq",!0),G(P,Y,"⫋︀","\\varsubsetneqq"),G(P,Y,"≯","\\ngtr",!0),G(P,Y,"⪈","\\gneq",!0),G(P,Y,"≩","\\gneqq",!0),G(P,Y,"≩︀","\\gvertneqq"),G(P,Y,"⋧","\\gnsim",!0),G(P,Y,"⪊","\\gnapprox",!0),G(P,Y,"⊁","\\nsucc",!0),G(P,Y,"⋡","\\nsucceq",!0),G(P,Y,"⋩","\\succnsim",!0),G(P,Y,"⪺","\\succnapprox",!0),G(P,Y,"≆","\\ncong",!0),G(P,Y,"∦","\\nparallel",!0),G(P,Y,"∦","\\nshortparallel"),G(P,Y,"⊯","\\nVDash",!0),G(P,Y,"⋫","\\ntriangleright"),G(P,Y,"⋭","\\ntrianglerighteq",!0),G(P,Y,"⊋","\\supsetneq",!0),G(P,Y,"⊋","\\varsupsetneq"),G(P,Y,"⫌","\\supsetneqq",!0),G(P,Y,"⫌︀","\\varsupsetneqq"),G(P,Y,"⊮","\\nVdash",!0),G(P,Y,"⪵","\\precneqq",!0),G(P,Y,"⪶","\\succneqq",!0),G(P,U,"⊴","\\unlhd"),G(P,U,"⊵","\\unrhd"),G(P,Y,"↚","\\nleftarrow",!0),G(P,Y,"↛","\\nrightarrow",!0),G(P,Y,"⇍","\\nLeftarrow",!0),G(P,Y,"⇏","\\nRightarrow",!0),G(P,Y,"↮","\\nleftrightarrow",!0),G(P,Y,"⇎","\\nLeftrightarrow",!0),G(P,Y,"△","\\vartriangle"),G(P,K,"ℏ","\\hslash"),G(P,K,"▽","\\triangledown"),G(P,K,"◊","\\lozenge"),G(P,K,"Ⓢ","\\circledS"),G(P,K,"®","\\circledR",!0),G(j,K,"®","\\circledR"),G(j,K,"®","\\textregistered"),G(P,K,"∡","\\measuredangle",!0),G(P,K,"∄","\\nexists"),G(P,K,"℧","\\mho"),G(P,K,"Ⅎ","\\Finv",!0),G(P,K,"⅁","\\Game",!0),G(P,K,"‵","\\backprime"),G(P,K,"‶","\\backdprime"),G(P,K,"‷","\\backtrprime"),G(P,K,"▲","\\blacktriangle"),G(P,K,"▼","\\blacktriangledown"),G(P,K,"■","\\blacksquare"),G(P,K,"⧫","\\blacklozenge"),G(P,K,"★","\\bigstar"),G(P,K,"∢","\\sphericalangle",!0),G(P,K,"∁","\\complement",!0),G(P,K,"╱","\\diagup"),G(P,K,"╲","\\diagdown"),G(P,K,"□","\\square"),G(P,K,"□","\\Box"),G(P,K,"◊","\\Diamond"),G(P,K,"¥","\\yen",!0),G(j,K,"¥","\\yen",!0),G(P,K,"✓","\\checkmark",!0),G(j,K,"✓","\\checkmark"),G(P,K,"✗","\\ballotx",!0),G(j,K,"✗","\\ballotx"),G(j,K,"•","\\textbullet"),G(P,K,"ℶ","\\beth",!0),G(P,K,"ℸ","\\daleth",!0),G(P,K,"ℷ","\\gimel",!0),G(P,K,"ϝ","\\digamma",!0),G(P,K,"ϰ","\\varkappa"),G(P,X,"⌜","\\ulcorner",!0),G(P,H,"⌝","\\urcorner",!0),G(P,X,"⌞","\\llcorner",!0),G(P,H,"⌟","\\lrcorner",!0),G(P,Y,"≦","\\leqq",!0),G(P,Y,"⩽","\\leqslant",!0),G(P,Y,"⪕","\\eqslantless",!0),G(P,Y,"≲","\\lesssim",!0),G(P,Y,"⪅","\\lessapprox",!0),G(P,Y,"≊","\\approxeq",!0),G(P,U,"⋖","\\lessdot"),G(P,Y,"⋘","\\lll",!0),G(P,Y,"≶","\\lessgtr",!0),G(P,Y,"⋚","\\lesseqgtr",!0),G(P,Y,"⪋","\\lesseqqgtr",!0),G(P,Y,"≑","\\doteqdot"),G(P,Y,"≓","\\risingdotseq",!0),G(P,Y,"≒","\\fallingdotseq",!0),G(P,Y,"∽","\\backsim",!0),G(P,Y,"⋍","\\backsimeq",!0),G(P,Y,"⫅","\\subseteqq",!0),G(P,Y,"⋐","\\Subset",!0),G(P,Y,"⊏","\\sqsubset",!0),G(P,Y,"≼","\\preccurlyeq",!0),G(P,Y,"⋞","\\curlyeqprec",!0),G(P,Y,"≾","\\precsim",!0),G(P,Y,"⪷","\\precapprox",!0),G(P,Y,"⊲","\\vartriangleleft"),G(P,Y,"⊴","\\trianglelefteq"),G(P,Y,"⊨","\\vDash",!0),G(P,Y,"⊫","\\VDash",!0),G(P,Y,"⊪","\\Vvdash",!0),G(P,Y,"⌣","\\smallsmile"),G(P,Y,"⌢","\\smallfrown"),G(P,Y,"≏","\\bumpeq",!0),G(P,Y,"≎","\\Bumpeq",!0),G(P,Y,"≧","\\geqq",!0),G(P,Y,"⩾","\\geqslant",!0),G(P,Y,"⪖","\\eqslantgtr",!0),G(P,Y,"≳","\\gtrsim",!0),G(P,Y,"⪆","\\gtrapprox",!0),G(P,U,"⋗","\\gtrdot"),G(P,Y,"⋙","\\ggg",!0),G(P,Y,"≷","\\gtrless",!0),G(P,Y,"⋛","\\gtreqless",!0),G(P,Y,"⪌","\\gtreqqless",!0),G(P,Y,"≖","\\eqcirc",!0),G(P,Y,"≗","\\circeq",!0),G(P,Y,"≜","\\triangleq",!0),G(P,Y,"∼","\\thicksim"),G(P,Y,"≈","\\thickapprox"),G(P,Y,"⫆","\\supseteqq",!0),G(P,Y,"⋑","\\Supset",!0),G(P,Y,"⊐","\\sqsupset",!0),G(P,Y,"≽","\\succcurlyeq",!0),G(P,Y,"⋟","\\curlyeqsucc",!0),G(P,Y,"≿","\\succsim",!0),G(P,Y,"⪸","\\succapprox",!0),G(P,Y,"⊳","\\vartriangleright"),G(P,Y,"⊵","\\trianglerighteq"),G(P,Y,"⊩","\\Vdash",!0),G(P,Y,"∣","\\shortmid"),G(P,Y,"∥","\\shortparallel"),G(P,Y,"≬","\\between",!0),G(P,Y,"⋔","\\pitchfork",!0),G(P,Y,"∝","\\varpropto"),G(P,Y,"◀","\\blacktriangleleft"),G(P,Y,"∴","\\therefore",!0),G(P,Y,"∍","\\backepsilon"),G(P,Y,"▶","\\blacktriangleright"),G(P,Y,"∵","\\because",!0),G(P,Y,"⋘","\\llless"),G(P,Y,"⋙","\\gggtr"),G(P,U,"⊲","\\lhd"),G(P,U,"⊳","\\rhd"),G(P,Y,"≂","\\eqsim",!0),G(P,Y,"≑","\\Doteq",!0),G(P,Y,"⥽","\\strictif",!0),G(P,Y,"⥼","\\strictfi",!0),G(P,U,"∔","\\dotplus",!0),G(P,U,"∖","\\smallsetminus"),G(P,U,"⋒","\\Cap",!0),G(P,U,"⋓","\\Cup",!0),G(P,U,"⩞","\\doublebarwedge",!0),G(P,U,"⊟","\\boxminus",!0),G(P,U,"⊞","\\boxplus",!0),G(P,U,"⧄","\\boxslash",!0),G(P,U,"⋇","\\divideontimes",!0),G(P,U,"⋉","\\ltimes",!0),G(P,U,"⋊","\\rtimes",!0),G(P,U,"⋋","\\leftthreetimes",!0),G(P,U,"⋌","\\rightthreetimes",!0),G(P,U,"⋏","\\curlywedge",!0),G(P,U,"⋎","\\curlyvee",!0),G(P,U,"⊝","\\circleddash",!0),G(P,U,"⊛","\\circledast",!0),G(P,U,"⊺","\\intercal",!0),G(P,U,"⋒","\\doublecap"),G(P,U,"⋓","\\doublecup"),G(P,U,"⊠","\\boxtimes",!0),G(P,U,"⋈","\\bowtie",!0),G(P,U,"⋈","\\Join"),G(P,U,"⟕","\\leftouterjoin",!0),G(P,U,"⟖","\\rightouterjoin",!0),G(P,U,"⟗","\\fullouterjoin",!0),G(P,U,"∸","\\dotminus",!0),G(P,U,"⟑","\\wedgedot",!0),G(P,U,"⟇","\\veedot",!0),G(P,U,"⩢","\\doublebarvee",!0),G(P,U,"⩣","\\veedoublebar",!0),G(P,U,"⩟","\\wedgebar",!0),G(P,U,"⩠","\\wedgedoublebar",!0),G(P,U,"⩔","\\Vee",!0),G(P,U,"⩓","\\Wedge",!0),G(P,U,"⩃","\\barcap",!0),G(P,U,"⩂","\\barcup",!0),G(P,U,"⩈","\\capbarcup",!0),G(P,U,"⩀","\\capdot",!0),G(P,U,"⩇","\\capovercup",!0),G(P,U,"⩆","\\cupovercap",!0),G(P,U,"⩍","\\closedvarcap",!0),G(P,U,"⩌","\\closedvarcup",!0),G(P,U,"⨪","\\minusdot",!0),G(P,U,"⨫","\\minusfdots",!0),G(P,U,"⨬","\\minusrdots",!0),G(P,U,"⊻","\\Xor",!0),G(P,U,"⊼","\\Nand",!0),G(P,U,"⊽","\\Nor",!0),G(P,U,"⊽","\\barvee"),G(P,U,"⫴","\\interleave",!0),G(P,U,"⧢","\\shuffle",!0),G(P,U,"⫶","\\threedotcolon",!0),G(P,U,"⦂","\\typecolon",!0),G(P,U,"∾","\\invlazys",!0),G(P,U,"⩋","\\twocaps",!0),G(P,U,"⩊","\\twocups",!0),G(P,U,"⩎","\\Sqcap",!0),G(P,U,"⩏","\\Sqcup",!0),G(P,U,"⩖","\\veeonvee",!0),G(P,U,"⩕","\\wedgeonwedge",!0),G(P,U,"⧗","\\blackhourglass",!0),G(P,U,"⧆","\\boxast",!0),G(P,U,"⧈","\\boxbox",!0),G(P,U,"⧇","\\boxcircle",!0),G(P,U,"⊜","\\circledequal",!0),G(P,U,"⦷","\\circledparallel",!0),G(P,U,"⦶","\\circledvert",!0),G(P,U,"⦵","\\circlehbar",!0),G(P,U,"⟡","\\concavediamond",!0),G(P,U,"⟢","\\concavediamondtickleft",!0),G(P,U,"⟣","\\concavediamondtickright",!0),G(P,U,"⋄","\\diamond",!0),G(P,U,"⧖","\\hourglass",!0),G(P,U,"⟠","\\lozengeminus",!0),G(P,U,"⌽","\\obar",!0),G(P,U,"⦸","\\obslash",!0),G(P,U,"⨸","\\odiv",!0),G(P,U,"⧁","\\ogreaterthan",!0),G(P,U,"⧀","\\olessthan",!0),G(P,U,"⦹","\\operp",!0),G(P,U,"⨷","\\Otimes",!0),G(P,U,"⨶","\\otimeshat",!0),G(P,U,"⋆","\\star",!0),G(P,U,"△","\\triangle",!0),G(P,U,"⨺","\\triangleminus",!0),G(P,U,"⨹","\\triangleplus",!0),G(P,U,"⨻","\\triangletimes",!0),G(P,U,"⟤","\\whitesquaretickleft",!0),G(P,U,"⟥","\\whitesquaretickright",!0),G(P,U,"⨳","\\smashtimes",!0),G(P,Y,"⇢","\\dashrightarrow",!0),G(P,Y,"⇠","\\dashleftarrow",!0),G(P,Y,"⇇","\\leftleftarrows",!0),G(P,Y,"⇆","\\leftrightarrows",!0),G(P,Y,"⇚","\\Lleftarrow",!0),G(P,Y,"↞","\\twoheadleftarrow",!0),G(P,Y,"↢","\\leftarrowtail",!0),G(P,Y,"↫","\\looparrowleft",!0),G(P,Y,"⇋","\\leftrightharpoons",!0),G(P,Y,"↶","\\curvearrowleft",!0),G(P,Y,"↺","\\circlearrowleft",!0),G(P,Y,"↰","\\Lsh",!0),G(P,Y,"⇈","\\upuparrows",!0),G(P,Y,"↿","\\upharpoonleft",!0),G(P,Y,"⇃","\\downharpoonleft",!0),G(P,Y,"⊶","\\origof",!0),G(P,Y,"⊷","\\imageof",!0),G(P,Y,"⊸","\\multimap",!0),G(P,Y,"↭","\\leftrightsquigarrow",!0),G(P,Y,"⇉","\\rightrightarrows",!0),G(P,Y,"⇄","\\rightleftarrows",!0),G(P,Y,"↠","\\twoheadrightarrow",!0),G(P,Y,"↣","\\rightarrowtail",!0),G(P,Y,"↬","\\looparrowright",!0),G(P,Y,"↷","\\curvearrowright",!0),G(P,Y,"↻","\\circlearrowright",!0),G(P,Y,"↱","\\Rsh",!0),G(P,Y,"⇊","\\downdownarrows",!0),G(P,Y,"↾","\\upharpoonright",!0),G(P,Y,"⇂","\\downharpoonright",!0),G(P,Y,"⇝","\\rightsquigarrow",!0),G(P,Y,"⇝","\\leadsto"),G(P,Y,"⇛","\\Rrightarrow",!0),G(P,Y,"↾","\\restriction"),G(P,K,"‘","`"),G(P,K,"$","\\$"),G(j,K,"$","\\$"),G(j,K,"$","\\textdollar"),G(P,K,"¢","\\cent"),G(j,K,"¢","\\cent"),G(P,K,"%","\\%"),G(j,K,"%","\\%"),G(P,K,"_","\\_"),G(j,K,"_","\\_"),G(j,K,"_","\\textunderscore"),G(j,K,"␣","\\textvisiblespace",!0),G(P,K,"∠","\\angle",!0),G(P,K,"∞","\\infty",!0),G(P,K,"′","\\prime"),G(P,K,"″","\\dprime"),G(P,K,"‴","\\trprime"),G(P,K,"⁗","\\qprime"),G(P,K,"△","\\triangle"),G(j,K,"Α","\\Alpha",!0),G(j,K,"Β","\\Beta",!0),G(j,K,"Γ","\\Gamma",!0),G(j,K,"Δ","\\Delta",!0),G(j,K,"Ε","\\Epsilon",!0),G(j,K,"Ζ","\\Zeta",!0),G(j,K,"Η","\\Eta",!0),G(j,K,"Θ","\\Theta",!0),G(j,K,"Ι","\\Iota",!0),G(j,K,"Κ","\\Kappa",!0),G(j,K,"Λ","\\Lambda",!0),G(j,K,"Μ","\\Mu",!0),G(j,K,"Ν","\\Nu",!0),G(j,K,"Ξ","\\Xi",!0),G(j,K,"Ο","\\Omicron",!0),G(j,K,"Π","\\Pi",!0),G(j,K,"Ρ","\\Rho",!0),G(j,K,"Σ","\\Sigma",!0),G(j,K,"Τ","\\Tau",!0),G(j,K,"Υ","\\Upsilon",!0),G(j,K,"Φ","\\Phi",!0),G(j,K,"Χ","\\Chi",!0),G(j,K,"Ψ","\\Psi",!0),G(j,K,"Ω","\\Omega",!0),G(P,_,"Α","\\Alpha",!0),G(P,_,"Β","\\Beta",!0),G(P,_,"Γ","\\Gamma",!0),G(P,_,"Δ","\\Delta",!0),G(P,_,"Ε","\\Epsilon",!0),G(P,_,"Ζ","\\Zeta",!0),G(P,_,"Η","\\Eta",!0),G(P,_,"Θ","\\Theta",!0),G(P,_,"Ι","\\Iota",!0),G(P,_,"Κ","\\Kappa",!0),G(P,_,"Λ","\\Lambda",!0),G(P,_,"Μ","\\Mu",!0),G(P,_,"Ν","\\Nu",!0),G(P,_,"Ξ","\\Xi",!0),G(P,_,"Ο","\\Omicron",!0),G(P,_,"Π","\\Pi",!0),G(P,_,"Ρ","\\Rho",!0),G(P,_,"Σ","\\Sigma",!0),G(P,_,"Τ","\\Tau",!0),G(P,_,"Υ","\\Upsilon",!0),G(P,_,"Φ","\\Phi",!0),G(P,_,"Χ","\\Chi",!0),G(P,_,"Ψ","\\Psi",!0),G(P,_,"Ω","\\Omega",!0),G(P,X,"¬","\\neg",!0),G(P,X,"¬","\\lnot"),G(P,K,"⊤","\\top"),G(P,K,"⊥","\\bot"),G(P,K,"∅","\\emptyset"),G(P,K,"⌀","\\varnothing"),G(P,_,"α","\\alpha",!0),G(P,_,"β","\\beta",!0),G(P,_,"γ","\\gamma",!0),G(P,_,"δ","\\delta",!0),G(P,_,"ϵ","\\epsilon",!0),G(P,_,"ζ","\\zeta",!0),G(P,_,"η","\\eta",!0),G(P,_,"θ","\\theta",!0),G(P,_,"ι","\\iota",!0),G(P,_,"κ","\\kappa",!0),G(P,_,"λ","\\lambda",!0),G(P,_,"μ","\\mu",!0),G(P,_,"ν","\\nu",!0),G(P,_,"ξ","\\xi",!0),G(P,_,"ο","\\omicron",!0),G(P,_,"π","\\pi",!0),G(P,_,"ρ","\\rho",!0),G(P,_,"σ","\\sigma",!0),G(P,_,"τ","\\tau",!0),G(P,_,"υ","\\upsilon",!0),G(P,_,"ϕ","\\phi",!0),G(P,_,"χ","\\chi",!0),G(P,_,"ψ","\\psi",!0),G(P,_,"ω","\\omega",!0),G(P,_,"ε","\\varepsilon",!0),G(P,_,"ϑ","\\vartheta",!0),G(P,_,"ϖ","\\varpi",!0),G(P,_,"ϱ","\\varrho",!0),G(P,_,"ς","\\varsigma",!0),G(P,_,"φ","\\varphi",!0),G(P,_,"Ϙ","\\Coppa",!0),G(P,_,"ϙ","\\coppa",!0),G(P,_,"ϙ","\\varcoppa",!0),G(P,_,"Ϟ","\\Koppa",!0),G(P,_,"ϟ","\\koppa",!0),G(P,_,"Ϡ","\\Sampi",!0),G(P,_,"ϡ","\\sampi",!0),G(P,_,"Ϛ","\\Stigma",!0),G(P,_,"ϛ","\\stigma",!0),G(P,_,"⫫","\\Bot"),G(P,K,"ð","\\eth",!0),G(j,K,"ð","ð"),G(P,K,"Å","\\AA"),G(j,K,"Å","\\AA",!0),G(P,K,"Æ","\\AE",!0),G(j,K,"Æ","\\AE",!0),G(P,K,"Ð","\\DH",!0),G(j,K,"Ð","\\DH",!0),G(P,K,"Þ","\\TH",!0),G(j,K,"Þ","\\TH",!0),G(P,K,"ß","\\ss",!0),G(j,K,"ß","\\ss",!0),G(P,K,"å","\\aa"),G(j,K,"å","\\aa",!0),G(P,K,"æ","\\ae",!0),G(j,K,"æ","\\ae",!0),G(P,K,"ð","\\dh"),G(j,K,"ð","\\dh",!0),G(P,K,"þ","\\th",!0),G(j,K,"þ","\\th",!0),G(P,K,"Đ","\\DJ",!0),G(j,K,"Đ","\\DJ",!0),G(P,K,"đ","\\dj",!0),G(j,K,"đ","\\dj",!0),G(P,K,"Ł","\\L",!0),G(j,K,"Ł","\\L",!0),G(P,K,"Ł","\\l",!0),G(j,K,"Ł","\\l",!0),G(P,K,"Ŋ","\\NG",!0),G(j,K,"Ŋ","\\NG",!0),G(P,K,"ŋ","\\ng",!0),G(j,K,"ŋ","\\ng",!0),G(P,K,"Œ","\\OE",!0),G(j,K,"Œ","\\OE",!0),G(P,K,"œ","\\oe",!0),G(j,K,"œ","\\oe",!0),G(P,U,"∗","∗",!0),G(P,U,"+","+"),G(P,U,"∗","*"),G(P,U,"⁄","/",!0),G(P,U,"⁄","⁄"),G(P,U,"−","-",!0),G(P,U,"⋅","\\cdot",!0),G(P,U,"∘","\\circ",!0),G(P,U,"÷","\\div",!0),G(P,U,"±","\\pm",!0),G(P,U,"×","\\times",!0),G(P,U,"∩","\\cap",!0),G(P,U,"∪","\\cup",!0),G(P,U,"∖","\\setminus",!0),G(P,U,"∧","\\land"),G(P,U,"∨","\\lor"),G(P,U,"∧","\\wedge",!0),G(P,U,"∨","\\vee",!0),G(P,X,"⟦","\\llbracket",!0),G(P,H,"⟧","\\rrbracket",!0),G(P,X,"⟨","\\langle",!0),G(P,X,"⟪","\\lAngle",!0),G(P,X,"⦉","\\llangle",!0),G(P,X,"|","\\lvert"),G(P,X,"‖","\\lVert",!0),G(P,K,"!","\\oc"),G(P,K,"?","\\wn"),G(P,K,"↓","\\shpos"),G(P,K,"↕","\\shift"),G(P,K,"↑","\\shneg"),G(P,H,"?","?"),G(P,H,"!","!"),G(P,H,"‼","‼"),G(P,H,"⟩","\\rangle",!0),G(P,H,"⟫","\\rAngle",!0),G(P,H,"⦊","\\rrangle",!0),G(P,H,"|","\\rvert"),G(P,H,"‖","\\rVert"),G(P,X,"⦃","\\lBrace",!0),G(P,H,"⦄","\\rBrace",!0),G(P,Y,"=","\\equal",!0),G(P,Y,":",":"),G(P,Y,"≈","\\approx",!0),G(P,Y,"≅","\\cong",!0),G(P,Y,"≥","\\ge"),G(P,Y,"≥","\\geq",!0),G(P,Y,"←","\\gets"),G(P,Y,">","\\gt",!0),G(P,Y,"∈","\\in",!0),G(P,Y,"∉","\\notin",!0),G(P,Y,"","\\@not"),G(P,Y,"⊂","\\subset",!0),G(P,Y,"⊃","\\supset",!0),G(P,Y,"⊆","\\subseteq",!0),G(P,Y,"⊇","\\supseteq",!0),G(P,Y,"⊈","\\nsubseteq",!0),G(P,Y,"⊈","\\nsubseteqq"),G(P,Y,"⊉","\\nsupseteq",!0),G(P,Y,"⊉","\\nsupseteqq"),G(P,Y,"⊨","\\models"),G(P,Y,"←","\\leftarrow",!0),G(P,Y,"≤","\\le"),G(P,Y,"≤","\\leq",!0),G(P,Y,"<","\\lt",!0),G(P,Y,"→","\\rightarrow",!0),G(P,Y,"→","\\to"),G(P,Y,"≱","\\ngeq",!0),G(P,Y,"≱","\\ngeqq"),G(P,Y,"≱","\\ngeqslant"),G(P,Y,"≰","\\nleq",!0),G(P,Y,"≰","\\nleqq"),G(P,Y,"≰","\\nleqslant"),G(P,Y,"⫫","\\Perp",!0),G(P,J," ","\\ "),G(P,J," ","\\space"),G(P,J," ","\\nobreakspace"),G(j,J," ","\\ "),G(j,J," "," "),G(j,J," ","\\space"),G(j,J," ","\\nobreakspace"),G(P,J,null,"\\nobreak"),G(P,J,null,"\\allowbreak"),G(P,Z,",",","),G(j,Z,":",":"),G(P,Z,";",";"),G(P,U,"⊼","\\barwedge"),G(P,U,"⊻","\\veebar"),G(P,U,"⊙","\\odot",!0),G(P,U,"⊕︎","\\oplus"),G(P,U,"⊗","\\otimes",!0),G(P,K,"∂","\\partial",!0),G(P,U,"⊘","\\oslash",!0),G(P,U,"⊚","\\circledcirc",!0),G(P,U,"⊡","\\boxdot",!0),G(P,U,"△","\\bigtriangleup"),G(P,U,"▽","\\bigtriangledown"),G(P,U,"†","\\dagger"),G(P,U,"⋄","\\diamond"),G(P,U,"◃","\\triangleleft"),G(P,U,"▹","\\triangleright"),G(P,X,"{","\\{"),G(j,K,"{","\\{"),G(j,K,"{","\\textbraceleft"),G(P,H,"}","\\}"),G(j,K,"}","\\}"),G(j,K,"}","\\textbraceright"),G(P,X,"{","\\lbrace"),G(P,H,"}","\\rbrace"),G(P,X,"[","\\lbrack",!0),G(j,K,"[","\\lbrack",!0),G(P,H,"]","\\rbrack",!0),G(j,K,"]","\\rbrack",!0),G(P,X,"(","\\lparen",!0),G(P,H,")","\\rparen",!0),G(P,X,"⦇","\\llparenthesis",!0),G(P,H,"⦈","\\rrparenthesis",!0),G(j,K,"<","\\textless",!0),G(j,K,">","\\textgreater",!0),G(P,X,"⌊","\\lfloor",!0),G(P,H,"⌋","\\rfloor",!0),G(P,X,"⌈","\\lceil",!0),G(P,H,"⌉","\\rceil",!0),G(P,K,"\\","\\backslash"),G(P,K,"|","|"),G(P,K,"|","\\vert"),G(j,K,"|","\\textbar",!0),G(P,K,"‖","\\|"),G(P,K,"‖","\\Vert"),G(j,K,"‖","\\textbardbl"),G(j,K,"~","\\textasciitilde"),G(j,K,"\\","\\textbackslash"),G(j,K,"^","\\textasciicircum"),G(P,Y,"↑","\\uparrow",!0),G(P,Y,"⇑","\\Uparrow",!0),G(P,Y,"↓","\\downarrow",!0),G(P,Y,"⇓","\\Downarrow",!0),G(P,Y,"↕","\\updownarrow",!0),G(P,Y,"⇕","\\Updownarrow",!0),G(P,W,"∐","\\coprod"),G(P,W,"⋁","\\bigvee"),G(P,W,"⋀","\\bigwedge"),G(P,W,"⨄","\\biguplus"),G(P,W,"⨄","\\bigcupplus"),G(P,W,"⨃","\\bigcupdot"),G(P,W,"⨇","\\bigdoublevee"),G(P,W,"⨈","\\bigdoublewedge"),G(P,W,"⋂","\\bigcap"),G(P,W,"⋃","\\bigcup"),G(P,W,"∫","\\int"),G(P,W,"∫","\\intop"),G(P,W,"∬","\\iint"),G(P,W,"∭","\\iiint"),G(P,W,"∏","\\prod"),G(P,W,"∑","\\sum"),G(P,W,"⨂","\\bigotimes"),G(P,W,"⨁","\\bigoplus"),G(P,W,"⨀","\\bigodot"),G(P,W,"⨉","\\bigtimes"),G(P,W,"∮","\\oint"),G(P,W,"∯","\\oiint"),G(P,W,"∰","\\oiiint"),G(P,W,"∱","\\intclockwise"),G(P,W,"∲","\\varointclockwise"),G(P,W,"⨌","\\iiiint"),G(P,W,"⨍","\\intbar"),G(P,W,"⨎","\\intBar"),G(P,W,"⨏","\\fint"),G(P,W,"⨒","\\rppolint"),G(P,W,"⨓","\\scpolint"),G(P,W,"⨕","\\pointint"),G(P,W,"⨖","\\sqint"),G(P,W,"⨗","\\intlarhk"),G(P,W,"⨘","\\intx"),G(P,W,"⨙","\\intcap"),G(P,W,"⨚","\\intcup"),G(P,W,"⨅","\\bigsqcap"),G(P,W,"⨆","\\bigsqcup"),G(P,W,"∫","\\smallint"),G(j,V,"…","\\textellipsis"),G(P,V,"…","\\mathellipsis"),G(j,V,"…","\\ldots",!0),G(P,V,"…","\\ldots",!0),G(P,V,"⋰","\\iddots",!0),G(P,V,"⋯","\\@cdots",!0),G(P,V,"⋱","\\ddots",!0),G(P,K,"⋮","\\varvdots"),G(j,K,"⋮","\\varvdots"),G(P,R,"´","\\acute"),G(P,R,"`","\\grave"),G(P,R,"¨","\\ddot"),G(P,R,"…","\\dddot"),G(P,R,"….","\\ddddot"),G(P,R,"~","\\tilde"),G(P,R,"‾","\\bar"),G(P,R,"˘","\\breve"),G(P,R,"ˇ","\\check"),G(P,R,"^","\\hat"),G(P,R,"→","\\vec"),G(P,R,"˙","\\dot"),G(P,R,"˚","\\mathring"),G(P,_,"ı","\\imath",!0),G(P,_,"ȷ","\\jmath",!0),G(P,K,"ı","ı"),G(P,K,"ȷ","ȷ"),G(j,K,"ı","\\i",!0),G(j,K,"ȷ","\\j",!0),G(j,K,"ø","\\o",!0),G(P,_,"ø","\\o",!0),G(j,K,"Ø","\\O",!0),G(P,_,"Ø","\\O",!0),G(j,R,"ˊ","\\'"),G(j,R,"ˋ","\\`"),G(j,R,"ˆ","\\^"),G(j,R,"~","\\~"),G(j,R,"ˉ","\\="),G(j,R,"˘","\\u"),G(j,R,"˙","\\."),G(j,R,"¸","\\c"),G(j,R,"˚","\\r"),G(j,R,"ˇ","\\v");G(j,R,"¨",'\\"'),G(j,R,"˝","\\H"),G(P,R,"ˊ","\\'"),G(P,R,"ˋ","\\`"),G(P,R,"ˆ","\\^"),G(P,R,"~","\\~"),G(P,R,"ˉ","\\="),G(P,R,"˘","\\u"),G(P,R,"˙","\\."),G(P,R,"¸","\\c"),G(P,R,"˚","\\r"),G(P,R,"ˇ","\\v"),G(P,R,"¨",'\\"'),G(P,R,"˝","\\H");const Q={"--":!0,"---":!0,"``":!0,"''":!0};G(j,K,"–","--",!0),G(j,K,"–","\\textendash"),G(j,K,"—","---",!0),G(j,K,"—","\\textemdash"),G(j,K,"‘","`",!0),G(j,K,"‘","\\textquoteleft"),G(j,K,"’","'",!0),G(j,K,"’","\\textquoteright"),G(j,K,"“","``",!0),G(j,K,"“","\\textquotedblleft"),G(j,K,"”","''",!0),G(j,K,"”","\\textquotedblright"),G(P,K,"°","\\degree",!0),G(j,K,"°","\\degree"),G(j,K,"°","\\textdegree",!0),G(P,K,"£","\\pounds"),G(P,K,"£","\\mathsterling",!0),G(j,K,"£","\\pounds"),G(j,K,"£","\\textsterling",!0),G(P,K,"✠","\\maltese"),G(j,K,"✠","\\maltese"),G(P,K,"€","\\euro",!0),G(j,K,"€","\\euro",!0),G(j,K,"€","\\texteuro"),G(P,K,"©","\\copyright",!0),G(j,K,"©","\\textcopyright"),G(P,K,"⌀","\\diameter",!0),G(j,K,"⌀","\\diameter"),G(P,K,"𝛤","\\varGamma"),G(P,K,"𝛥","\\varDelta"),G(P,K,"𝛩","\\varTheta"),G(P,K,"𝛬","\\varLambda"),G(P,K,"𝛯","\\varXi"),G(P,K,"𝛱","\\varPi"),G(P,K,"𝛴","\\varSigma"),G(P,K,"𝛶","\\varUpsilon"),G(P,K,"𝛷","\\varPhi"),G(P,K,"𝛹","\\varPsi"),G(P,K,"𝛺","\\varOmega"),G(j,K,"𝛤","\\varGamma"),G(j,K,"𝛥","\\varDelta"),G(j,K,"𝛩","\\varTheta"),G(j,K,"𝛬","\\varLambda"),G(j,K,"𝛯","\\varXi"),G(j,K,"𝛱","\\varPi"),G(j,K,"𝛴","\\varSigma"),G(j,K,"𝛶","\\varUpsilon"),G(j,K,"𝛷","\\varPhi"),G(j,K,"𝛹","\\varPsi"),G(j,K,"𝛺","\\varOmega");const ee='0123456789/@."';for(let e=0;e<14;e++){const t=ee.charAt(e);G(P,K,t,t)}const te='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){const t=te.charAt(e);G(j,K,t,t)}const re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){const t=re.charAt(e);G(P,_,t,t),G(j,K,t,t)}const ne="ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";for(let e=0;e<30;e++){const t=ne.charAt(e);G(P,_,t,t),G(j,K,t,t)}let se="";for(let e=0;e<52;e++){se=String.fromCharCode(55349,56320+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56372+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56424+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56580+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56736+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56788+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56840+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56944+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,56632+e),G(P,_,se,se),G(j,K,se,se);const t=re.charAt(e);se=String.fromCharCode(55349,56476+e),G(P,_,t,se),G(j,K,t,se)}for(let e=0;e<10;e++)se=String.fromCharCode(55349,57294+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,57314+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,57324+e),G(P,_,se,se),G(j,K,se,se),se=String.fromCharCode(55349,57334+e),G(P,_,se,se),G(j,K,se,se);const oe=function(e,t,r){return!D[t][e]||!D[t][e].replace||55349===e.charCodeAt(0)||Object.prototype.hasOwnProperty.call(Q,e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=D[t][e].replace),new C(e)},ae=(e,t)=>{if(0===e.children.length||"mtext"!==e.children[e.children.length-1].type){const r=new B("mtext",[new C(t.children[0].text)]);e.children.push(r)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},le=e=>{if("mrow"!==e.type&&"mstyle"!==e.type)return e;if(0===e.children.length)return e;const t=new B("mrow");for(let r=0;r<e.children.length;r++){const n=e.children[r];if("mtext"===n.type&&0===Object.keys(n.attributes).length)ae(t,n);else if("mrow"===n.type){let e=!0;for(let t=0;t<n.children.length;t++){if("mtext"!==n.children[t].type||0!==Object.keys(n.attributes).length){e=!1;break}}if(e)for(let e=0;e<n.children.length;e++){const r=n.children[e];ae(t,r)}else t.children.push(n)}else t.children.push(n)}for(let r=0;r<t.children.length;r++)if("mtext"===t.children[r].type){const n=t.children[r];" "===n.children[0].text.charAt(0)&&(n.children[0].text=" "+n.children[0].text.slice(1));const s=n.children[0].text.length;s>0&&" "===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},ie=function(e,t=!1){if(!(1!==e.length||e[0]instanceof y))return e[0];if(!t){e[0]instanceof B&&"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 B&&"mo"===e[t].type&&!e[t].attributes.fence&&(e[t].attributes.lspace="0em",e[t].attributes.rspace="0em")}return new B("mrow",e)};function ce(e){if(!e)return!1;if("mi"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof C&&"."===t.text}if("mtext"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof C&&" "===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 C&&","===t.text}return!1}const me=(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},pe=e=>"atom"===e.type&&"rel"===e.family||"mclass"===e.type&&"mrel"===e.mclass,ue=function(e,t,r=!1){if(!r&&1===e.length){const r=he(e[0],t);return r instanceof B&&"mo"===r.type&&(r.setAttribute("lspace","0em"),r.setAttribute("rspace","0em")),[r]}const n=[],s=[];let o;for(let r=0;r<e.length;r++)s.push(he(e[r],t));for(let t=0;t<s.length;t++){const r=s[t];if(t<e.length-1&&pe(e[t])&&pe(e[t+1])&&r.setAttribute("rspace","0em"),t>0&&pe(e[t])&&pe(e[t-1])&&r.setAttribute("lspace","0em"),"mn"===r.type&&o&&"mn"===o.type)o.children.push(...r.children);else if(ce(r)&&o&&"mn"===o.type)o.children.push(...r.children);else if(o&&"mn"===o.type&&t<s.length-1&&"mn"===s[t+1].type&&me(e,t))o.children.push(...r.children);else{if("mn"===r.type&&ce(o))r.children=[...o.children,...r.children],n.pop();else if(("msup"===r.type||"msub"===r.type)&&r.children.length>=1&&o&&("mn"===o.type||ce(o))){const e=r.children[0];e instanceof B&&"mn"===e.type&&o&&(e.children=[...o.children,...e.children],n.pop())}n.push(r),o=r}}return n},de=function(e,t,r=!1){return ie(ue(e,t,r),r)},he=function(t,r){if(!t)return new B("mrow");if(d[t.type]){return d[t.type](t,r)}throw new e("Got group of unknown type: '"+t.type+"'")},ge=e=>new B("mtd",[],[],{padding:"0",width:"50%"}),fe=["mrow","mtd","mtable","mtr"],be=e=>{for(const t of e.children)if(t.type&&fe.includes(t.type)){if(t.classes&&"tml-label"===t.classes[0]){return t.label}{const e=be(t);if(e)return e}}else if(!t.type){const e=be(t);if(e)return e}};function ye(e,t,r,n){let s=null;1===e.length&&"tag"===e[0].type&&(s=e[0].tag,e=e[0].body);const o=ue(e,r);if(1===o.length&&o[0]instanceof S)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 B?o[0]:function(e,t,r){const n=[];let s=[],o=[],a=0,l=0;for(;l<e.length;){for(;e[l]instanceof y;)e.splice(l,1,...e[l].children);const r=e[l];if(r.attributes&&r.attributes.linebreak&&"newline"===r.attributes.linebreak){o.length>0&&s.push(new B("mrow",o)),s.push(r),o=[];const e=new B("mtd",s);e.style.textAlign="left",n.push(new B("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 B("mrow",o);s.push(e),o=[r]}}else if("tex"===t){const t=l<e.length-1?e[l+1]:null;let r=!0;if(!t||"mtext"!==t.type||!t.attributes.linebreak||"nobreak"!==t.attributes.linebreak)for(let t=l+1;t<e.length;t++){const n=e[t];if(!n.type||"mspace"!==n.type||n.attributes.linebreak&&"newline"===n.attributes.linebreak)break;o.push(n),l+=1,n.attributes&&n.attributes.linebreak&&"nobreak"===n.attributes.linebreak&&(r=!1)}if(r){const e=new B("mrow",o);s.push(e),o=[]}}}l+=1}if(o.length>0){const e=new B("mrow",o);s.push(e)}if(n.length>0){const e=new B("mtd",s);e.style.textAlign="left";const t=new B("mtr",[e]);n.push(t);const o=new B("mtable",n);return r||(o.setAttribute("columnalign","left"),o.setAttribute("rowspacing","0em")),o}return O(s)}(o,a,n.displayMode);if(s&&(i=((e,t,r,n)=>{t=de(t[0].body,r),(t=le(t)).classes.push("tml-tag");const s=be(e);e=new B("mtd",[e]);const o=[ge(),e,ge()];o[n?0:2].children.push(t);const a=new B("mtr",o,["tml-tageqn"]);s&&a.setAttribute("id",s);const l=new B("mtable",[a]);return l.style.width="100%",l.setAttribute("displaystyle","true"),l})(i,s,r,n.leqno)),n.annotate){const e=new B("annotation",[new C(t)]);e.setAttribute("encoding","application/x-tex"),i=new B("semantics",[i,e])}const c=new B("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 we=(e,t)=>{const r=e.isStretchy?L(e):new B("mo",[oe(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=ke.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 B(n,[he(e.base,t),r])},xe=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),ke=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),ve={"\\`":"̀","\\'":"́","\\^":"̂","\\~":"̃","\\=":"̄","\\u":"̆","\\.":"̇",'\\"':"̈","\\r":"̊","\\H":"̋","\\v":"̌","\\c":"̧"};h({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=f(t[0]),n=!xe.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,base:r}},mathmlBuilder:we}),h({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=f(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 ve&&m.indexOf(r.text)>-1?{type:"textord",mode:"text",text:r.text+ve[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:we}),h({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=L(e);r.style["math-depth"]=0;return new B("munder",[he(e.base,t),r])}});const Ae={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},Te=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Se=function(e){return"string"!=typeof e&&(e=e.unit),Te.indexOf(e)>-1},qe=e=>[1,.7,.5][Math.max(e-1,0)],Oe=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*Ae[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*Ae[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+"'")}},Be=e=>{const t=new B("mspace");return t.setAttribute("width",e+"em"),t},Ce=(e,t=.3,r=0,n=!1)=>{if(null==e&&0===r)return Be(t);const s=e?[e]:[];if(0!==t&&s.unshift(Be(t)),r>0&&s.push(Be(r)),n){const e=new B("mpadded",s);return e.setAttribute("height","0.1px"),e}return new B("mrow",s)},Ne=(e,t)=>Number(e)/qe(t),ze=(e,t,r,n)=>{const s=E(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=Ne(a,l.level),c=Ne(a,3),m=Ce(null,i.toFixed(4),0),p=Ce(null,c.toFixed(4),0),u=Ne(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=he(t,l);r=Ce(r,u,u,"\\\\cdrightarrow"===e||"\\\\cdleftarrow"===e),d=new B("mover",[r,p])}const f=r&&r.body&&(r.body.body||r.body.length>0);if(f){let e=he(r,l);e=Ce(e,u,u),h=new B("munder",[e,p])}let b;return b=g||f?g&&f?new B("munderover",[s,h,d]):g?new B("mover",[s,d]):new B("munder",[s,h]):new B("mover",[s,m]),"3.0"===a&&(b.style.height="1em"),b.setAttribute("accent","false"),b};h({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=[ze(e.name,e.body,e.below,t)];return r.unshift(Be(.2778)),r.push(Be(.2778)),new B("mrow",r)}});const $e={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};h({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=$e[e.name][0],n=$e[e.name][1],s=ze(r,e.body,e.upperArrowBelow,t),o=ze(n,e.lowerArrowBody,e.below,t);let a;const l=new B("mpadded",[s]);if(l.setAttribute("voffset","0.3em"),l.setAttribute("height","+0.3em"),l.setAttribute("depth","-0.3em"),"\\equilibriumLeft"===e.name){const e=new B("mpadded",[o]);e.setAttribute("width","0.5em"),a=new B("mpadded",[Be(.2778),e,l,Be(.2778)])}else l.setAttribute("width","\\equilibriumRight"===e.name?"0.5em":"0"),a=new B("mpadded",[Be(.2778),l,o,Be(.2778)]);return a.setAttribute("voffset","-0.18em"),a.setAttribute("height","-0.18em"),a.setAttribute("depth","+0.18em"),a}});const Ee={};function Ie({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<t.length;++e)Ee[t[e]]=o;s&&(d[e]=s)}function Le(e,t){if(!e||e.type!==t)throw new Error(`Expected node of type ${t}, but got `+(e?`node of type ${e.type}`:String(e)));return e}function Fe(e){const t=Me(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?`node of type ${e.type}`:String(e)));return t}function Me(e){return e&&("atom"===e.type||"delimiter"===e.type||Object.prototype.hasOwnProperty.call(M,e.type))?e:null}const De={">":"\\\\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,je=(e,t)=>("mathord"===e.type||"atom"===e.type)&&e.text===t;function Re(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"}}}h({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 B("mrow",t);const r=he(e.label,t);"left"===e.side&&r.classes.push("tml-shift-left");const n=new B("mtd",[r]);n.style.padding="0";const s=new B("mtr",[n]),o=new B("mtable",[s]),a=new B("mpadded",[o]);return a.setAttribute("width","0.1px"),a.setAttribute("displaystyle","false"),a.setAttribute("scriptlevel","1"),a}}),h({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new B("mrow",[he(e.fragment,t)])});const Ue=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),He=(e,t)=>({type:t,mode:"math",body:Ue(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 _e{constructor(e,t){this.text=e,this.loc=t}range(e,t){return new _e(t,Ve.range(this,e))}}const We=0,Xe=1,Ze=2,Ye=3,Je={};function Ke(e,t){Je[e]=t}const Qe=Je;Ke("\\noexpand",function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Ke("\\expandafter",function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Ke("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Ke("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Ke("\\@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}}),Ke("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Ke("\\TextOrMath",function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});const et=e=>{let t="";for(let r=e.length-1;r>-1;r--)t+=e[r].text;return t},tt={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},rt=e=>{const t=e.future().text;return"EOF"===t?[null,""]:[tt[t.charAt(0)],t]},nt=(e,t,r)=>{for(let n=1;n<t.length;n++){e*=r,e+=tt[t.charAt(n)]}return e};function st(e){const t=e.consumeArgs(1)[0];let r="",n=t[t.length-1].loc.start;for(let e=t.length-1;e>=0;e--){const s=t[e].loc.start;s>n&&(r+=" ",n=s),r+=t[e].text,n+=t[e].text.length}return r}Ke("\\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=tt[a.charAt(0)],null==s||s>=r)throw new e(`Invalid base-${r} digit ${n.text}`);for(s=nt(s,a,r),[o,a]=rt(t);null!=o&&o<r;)s*=r,s+=o,s=nt(s,a,r),t.popToken(),[o,a]=rt(t)}return`\\@char{${s}}`}),Ke("\\surd","\\sqrt{\\vphantom{|}}"),Ke("⊕","\\oplus"),Ke("\\long",""),Ke("\\bgroup","{"),Ke("\\egroup","}"),Ke("~","\\nobreakspace"),Ke("\\lq","`"),Ke("\\rq","'"),Ke("\\aa","\\r a"),Ke("\\Bbbk","\\Bbb{k}"),Ke("\\mathstrut","\\vphantom{(}"),Ke("\\underbar","\\underline{\\text{#1}}"),Ke("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),Ke("⋮","\\vdots"),Ke("\\arraystretch","1"),Ke("\\arraycolsep","6pt"),Ke("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Ke("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Ke("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Ke("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");const ot={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\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"};Ke("\\dots",function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in ot?t=ot[r]:("\\not"===r.slice(0,4)||r in D.math&&["bin","rel"].includes(D.math[r].group))&&(t="\\dotsb"),t});const at={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};Ke("\\dotso",function(e){return e.future().text in at?"\\ldots\\,":"\\ldots"}),Ke("\\dotsc",function(e){const t=e.future().text;return t in at&&","!==t?"\\ldots\\,":"\\ldots"}),Ke("\\cdots",function(e){return e.future().text in at?"\\@cdots\\,":"\\@cdots"}),Ke("\\dotsb","\\cdots"),Ke("\\dotsm","\\cdots"),Ke("\\dotsi","\\!\\cdots"),Ke("\\idotsint","\\int\\!\\cdots\\!\\int"),Ke("\\dotsx","\\ldots\\,"),Ke("\\DOTSI","\\relax"),Ke("\\DOTSB","\\relax"),Ke("\\DOTSX","\\relax"),Ke("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Ke("\\,","{\\tmspace+{3mu}{.1667em}}"),Ke("\\thinspace","\\,"),Ke("\\>","\\mskip{4mu}"),Ke("\\:","{\\tmspace+{4mu}{.2222em}}"),Ke("\\medspace","\\:"),Ke("\\;","{\\tmspace+{5mu}{.2777em}}"),Ke("\\thickspace","\\;"),Ke("\\!","{\\tmspace-{3mu}{.1667em}}"),Ke("\\negthinspace","\\!"),Ke("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),Ke("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),Ke("\\enspace","\\kern.5em "),Ke("\\enskip","\\hskip.5em\\relax"),Ke("\\quad","\\hskip1em\\relax"),Ke("\\qquad","\\hskip2em\\relax"),Ke("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax"),Ke("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Ke("\\tag@paren","\\tag@literal{({#1})}"),Ke("\\tag@literal",t=>{if(t.macros.get("\\df@tag"))throw new e("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),Ke("\\notag","\\nonumber"),Ke("\\nonumber","\\gdef\\@eqnsw{0}"),Ke("\\bmod","\\mathbin{\\text{mod}}"),Ke("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Ke("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Ke("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Ke("\\newline","\\\\\\relax"),Ke("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),Ke("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),Ke("\\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}}"),Ke("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Ke("\\@hspace","\\hskip #1\\relax"),Ke("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Ke("\\colon",'\\mathpunct{\\char"3a}'),Ke("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),Ke("\\ordinarycolon",'\\char"3a'),Ke("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),Ke("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),Ke("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),Ke("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),Ke("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),Ke("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),Ke("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),Ke("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Ke("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Ke("\\ratio","\\vcentcolon"),Ke("\\coloncolon","\\dblcolon"),Ke("\\colonequals","\\coloneqq"),Ke("\\coloncolonequals","\\Coloneqq"),Ke("\\equalscolon","\\eqqcolon"),Ke("\\equalscoloncolon","\\Eqqcolon"),Ke("\\colonminus","\\coloneq"),Ke("\\coloncolonminus","\\Coloneq"),Ke("\\minuscolon","\\eqcolon"),Ke("\\minuscoloncolon","\\Eqcolon"),Ke("\\coloncolonapprox","\\Colonapprox"),Ke("\\coloncolonsim","\\Colonsim"),Ke("\\notni","\\mathrel{\\char`∌}"),Ke("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Ke("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Ke("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Ke("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Ke("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),Ke("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),Ke("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),Ke("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),Ke("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),Ke("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Ke("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Ke("\\plim","\\DOTSB\\operatorname*{plim}"),Ke("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}"),Ke("\\bra","\\mathinner{\\langle{#1}|}"),Ke("\\ket","\\mathinner{|{#1}\\rangle}"),Ke("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Ke("\\Bra","\\left\\langle#1\\right|"),Ke("\\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)};Ke("\\Braket",function(e){let t=st(e);const r=/\|\||\||\\\|/g;let n;for(;null!==(n=r.exec(t));)t=lt(t,n);return"\\left\\langle{"+t+"}\\right\\rangle"}),Ke("\\Set",function(e){let t=st(e);const r=/\|\||\||\\\|/.exec(t);return r&&(t=lt(t,r)),"\\left\\{\\:{"+t+"}\\:\\right\\}"}),Ke("\\set",function(e){return"\\{{"+st(e).replace(/\|/,"}\\mid{")+"}\\}"}),Ke("\\angln","{\\angl n}"),Ke("\\odv","\\@ifstar\\odv@next\\odv@numerator"),Ke("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),Ke("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),Ke("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");const it=e=>{const t=e[0][0].text,r=et(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}Ke("\\pdv@numerator",function(e){const[t,r,n]=it(e.consumeArgs(2));return`\\frac{${r} ${t}}{${n}}`}),Ke("\\pdv@next",function(e){const[t,r,n]=it(e.consumeArgs(2));return`\\frac{${r}}{${n}} ${t}`}),Ke("\\upalpha","\\up@greek{\\alpha}"),Ke("\\upbeta","\\up@greek{\\beta}"),Ke("\\upgamma","\\up@greek{\\gamma}"),Ke("\\updelta","\\up@greek{\\delta}"),Ke("\\upepsilon","\\up@greek{\\epsilon}"),Ke("\\upzeta","\\up@greek{\\zeta}"),Ke("\\upeta","\\up@greek{\\eta}"),Ke("\\uptheta","\\up@greek{\\theta}"),Ke("\\upiota","\\up@greek{\\iota}"),Ke("\\upkappa","\\up@greek{\\kappa}"),Ke("\\uplambda","\\up@greek{\\lambda}"),Ke("\\upmu","\\up@greek{\\mu}"),Ke("\\upnu","\\up@greek{\\nu}"),Ke("\\upxi","\\up@greek{\\xi}"),Ke("\\upomicron","\\up@greek{\\omicron}"),Ke("\\uppi","\\up@greek{\\pi}"),Ke("\\upalpha","\\up@greek{\\alpha}"),Ke("\\uprho","\\up@greek{\\rho}"),Ke("\\upsigma","\\up@greek{\\sigma}"),Ke("\\uptau","\\up@greek{\\tau}"),Ke("\\upupsilon","\\up@greek{\\upsilon}"),Ke("\\upphi","\\up@greek{\\phi}"),Ke("\\upchi","\\up@greek{\\chi}"),Ke("\\uppsi","\\up@greek{\\psi}"),Ke("\\upomega","\\up@greek{\\omega}"),Ke("\\invamp",'\\mathbin{\\char"214b}'),Ke("\\parr",'\\mathbin{\\char"214b}'),Ke("\\upand",'\\mathbin{\\char"214b}'),Ke("\\with",'\\mathbin{\\char"26}'),Ke("\\multimapinv",'\\mathrel{\\char"27dc}'),Ke("\\multimapboth",'\\mathrel{\\char"29df}'),Ke("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),Ke("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),Ke("\\coh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}\n{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}'),Ke("\\incoh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}\n{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}'),Ke("\\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=et(t.tokens)),t=isNaN(t)?null:Number(t);let r=e.get("\\arraycolsep");"string"!=typeof r&&(r=et(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;n<t.length;n++)if("label"===t[n].type){if(r)throw new e("Multiple \\labels in one row");r=t[n].string}return r};function ht(e){if(-1===e.indexOf("ed"))return-1===e.indexOf("*")}function gt(t,{cols:r,envClasses:n,autoTag:s,singleRow:o,emptySingleRow:a,maxNumCols:l,leqno:i,arraystretch:c,arraycolsep:m},p){const u=n&&n.includes("bordermatrix")?"}":"\\end";t.gullet.beginGroup(),o||t.gullet.macros.set("\\cr","\\\\\\relax"),t.gullet.beginGroup();let d=[];const h=[d],g=[],f=[],b=[],y=null!=s?[]:void 0;function w(){s&&t.gullet.macros.set("\\@eqnsw","1",!0)}function x(){y&&(t.gullet.macros.get("\\df@tag")?(y.push(t.subparse([new _e("\\df@tag")])),t.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(s)&&"1"===t.gullet.macros.get("\\@eqnsw")))}for(w(),b.push(ct(t));;){let r=t.parseExpression(!1,o?"\\end":"\\\\");t.gullet.endGroup(),t.gullet.beginGroup(),r={type:"ordgroup",mode:t.mode,body:r,semisimple:!0},d.push(r);const s=t.fetch().text;if("&"===s){if(l&&d.length===l){if(!n.includes("array"))throw new e(2===l?"The split environment accepts no more than two columns":"The equation environment accepts only one column",t.nextToken);if(t.settings.strict)throw new e("Too few columns specified in the {array} column argument.",t.nextToken)}t.consume()}else{if(s===u){x(),1===d.length&&0===r.body.length&&(h.length>1||!a)&&h.pop(),f.push(dt(r.body)),b.length<h.length+1&&b.push([]);break}if("\\\\"!==s)throw new e("Expected & or \\\\ or \\cr or "+u,t.nextToken);{let e;t.consume()," "!==t.gullet.future().text&&(e=t.parseSizeGroup(!0)),g.push(e?e.value:null),x(),f.push(dt(r.body)),b.push(ct(t)),d=[],h.push(d),w()}}}return t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:t.mode,body:h,cols:r,rowGaps:g,hLinesBeforeRow:b,envClasses:n,autoTag:s,scriptLevel:p,tags:y,labels:f,leqno:i,arraystretch:c,arraycolsep:m}}function ft(e){return"d"===e.slice(0,1)?"display":"text"}const bt={c:"center ",l:"left ",r:"right "},yt=e=>{const t=new B("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;a<n;a++){const l=e.body[a],i=[],c="text"===e.scriptLevel?Xe:"script"===e.scriptLevel?Ze:We;for(let r=0;r<l.length;r++){const s=new B("mtd",[he(l[r],t.withLevel(c))]);if(e.envClasses.includes("multline")){const e=0===a?"left":a===n-1?"right":"center";"center"!==e&&s.classes.push("tml-"+e)}i.push(s)}const m=e.body[0].length;for(let e=0;e<m-l.length;e++)i.push(new B("mtd",[],[],t));if(o){const r=e.tags[a];let n;!0===r?n=new B("mtext",[new A(["tml-eqn"])]):!1===r?n=new B("mtext",[],[]):(n=de(r[0].body,t.withLevel(c),!0),n=le(n),n.classes=["tml-tag"]),n&&(i.unshift(yt(e)),i.push(yt(e)),e.leqno?i[0].children.push(n):i[i.length-1].children.push(n))}const p=new B("mtr",i,[]),u=e.labels.shift();u&&e.tags&&e.tags[a]&&(p.setAttribute("id",u),Array.isArray(e.tags[a])&&p.classes.push("tml-tageqn")),0===a&&s[0].length>0&&(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;e<p.children.length;e++){const t=p.children[e].children[0];if(!t||"mpadded"!==t.type||"0px"!==t.attributes.height){d=!1;break}}if(d)for(let e=0;e<p.children.length;e++)p.children[e].style.display="block",p.children[e].style.height="0",p.children[e].style.paddingTop="0",p.children[e].style.paddingBottom="0";r.push(p)}if(e.arraystretch&&1!==e.arraystretch){const t=String(1.4*e.arraystretch-.8)+"ex";for(let e=0;e<r.length;e++)for(let n=0;n<r[e].children.length;n++)r[e].children[n].style.paddingTop=t,r[e].children[n].style.paddingBottom=t}let a,l;if(e.envClasses.length>0&&(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=Oe(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;e<r.length;e++)for(let t=0;t<r[e].children.length;t++)r[e].children[t].style.paddingLeft=`${n(t,0)}${l}`,r[e].children[t].style.paddingRight=`${n(t,1)}${l}`}if(0===e.envClasses.length)for(let e=0;e<r.length;e++)r[e].children[0].style.paddingLeft="0em",r[e].children.length===r[0].children.length&&(r[e].children[r[e].children.length-1].style.paddingRight="0em");if(e.envClasses.length>0){const t=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let n=0;n<r.length;n++){const s=r[n];if(t){for(let e=0;e<s.children.length;e++)s.children[e].classes=["tml-"+(e%2?"left":"right")];if(o){const t=e.leqno?0:s.children.length-1;s.children[t].classes=[]}}if(s.children.length>1&&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 B("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<s;e++)if("align"===t[e].type){const n=bt[t[e].align];a+=1;for(const e of i.children)"center"!==n.trim()&&a<e.children.length&&(e.children[a].classes=["tml-"+n.trim()]);r=!0}else if("separator"===t[e].type){if(r){const r="separator"===t[e+1].type?"0.15em double":"|"===t[e].separator?"0.06em solid":"0.06em dashed";for(const e of i.children)a<e.children.length&&(e.children[a].style.borderRight=r)}r=!1}if("separator"===t[t.length-1].type){const e="separator"===t[t.length-2].type?"0.15em double":"|"===t[t.length-1].separator?"0.06em solid":"0.06em dashed";for(const t of i.children)t.children[t.children.length-1].style.borderRight=e,t.children[t.children.length-1].style.paddingRight="0.4em"}}return e.envClasses.includes("small")&&(i=new B("mstyle",[i]),i.setAttribute("scriptlevel","1")),i},xt=function(t,r){-1===t.envName.indexOf("ed")&&mt(t);const n="split"===t.envName,s=[],o=gt(t.parser,{cols:s,emptySingleRow:!0,autoTag:n?void 0:ht(t.envName),envClasses:["abut","jot"],maxNumCols:"split"===t.envName?2:void 0,leqno:t.parser.settings.leqno},"display");let a,l=0;const i=t.envName.indexOf("at")>-1;if(r[0]&&i){let t="";for(let e=0;e<r[0].body.length;e++){t+=Le(r[0].body[e],"textord").text}if(isNaN(t))throw new e("The alignat enviroment requires a numeric first argument.");a=Number(t),l=2*a}o.body.forEach(function(t){if(i){const r=t.length/2;if(a<r)throw new e(`Too many math in a row: expected ${a}, but got ${r}`,t[0])}else l<t.length&&(l=t.length)});for(let e=0;e<l;++e){let t="r";e%2==1&&(t="l"),s[e]={type:"align",align:t}}return"split"===t.envName||(i?o.envClasses.push("alignat"):o.envClasses[0]="align"),o};Ie({type:"array",names:["array","darray"],props:{numArgs:1},handler(t,r){const n=(Me(r[0])?[r[0]]:Le(r[0],"ordgroup").body).map(function(t){const r=Fe(t).text;if(-1!=="lcr".indexOf(r))return{type:"align",align:r};if("|"===r)return{type:"separator",separator:"|"};if(":"===r)return{type:"separator",separator:":"};throw new e("Unknown column alignment: "+r,t)}),[s,o]=ut(t.parser.gullet.macros),a={cols:n,envClasses:["array"],maxNumCols:n.length,arraystretch:s,arraycolsep:o};return gt(t.parser,a,ft(t.envName))},mathmlBuilder:wt}),Ie({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(t){const r={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[t.envName.replace("*","")];let n="c";const s={envClasses:[],cols:[]};if("*"===t.envName.charAt(t.envName.length-1)){const r=t.parser;if(r.consumeSpaces(),"["===r.fetch().text){if(r.consume(),r.consumeSpaces(),n=r.fetch().text,-1==="lcr".indexOf(n))throw new e("Expected l or c or r",r.nextToken);r.consume(),r.consumeSpaces(),r.expect("]"),r.consume(),s.cols=[]}}const o=gt(t.parser,s,"text");o.cols=o.body.length>0?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}),Ie({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<r.length;e++){n[e-1].push(r[e].shift());const t=[];for(let n=0;n<r[e].length;n++)t.push(r[e][n]);n[e-1].push(He(t,"vphantom"))}const s=new Array(r.length).fill().map(()=>[]);for(let e=0;e<r[0].length;e++)s[0].push(r[0][e]);for(let e=1;e<r.length;e++)for(let t=0;t<r[0].length;t++)s[e].push(He(r[e][t].body,"hphantom"));for(let e=0;e<r[0].length;e++)r[0][e]=He(r[0][e].body,"hphantom");const o={type:"array",mode:"math",body:n,cols:[{type:"align",align:"c"}],rowGaps:new Array(n.length-1).fill(null),hLinesBeforeRow:new Array(n.length+1).fill().map(()=>[]),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 Ue([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}),Ie({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>gt(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:wt}),Ie({type:"array",names:["subarray"],props:{numArgs:1},handler(t,r){const n=(Me(r[0])?[r[0]]:Le(r[0],"ordgroup").body).map(function(t){const r=Fe(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}),Ie({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}),Ie({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:xt,mathmlBuilder:wt}),Ie({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:xt,mathmlBuilder:wt}),Ie({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}),Ie({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}),Ie({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}),Ie({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<r.length;o++){const a=r[o];let l=Ge();for(let r=0;r<a.length;r++)if(Pe(a[r])){n.push(l),r+=1;const s=Fe(a[r]).text,o=new Array(2);if(o[0]={type:"ordgroup",mode:"math",body:[]},o[1]={type:"ordgroup",mode:"math",body:[]},"=|.".indexOf(s)>-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<a.length;l++){if(je(a[l],s)){n=!1,r=l;break}if(Pe(a[l]))throw new e("Missing a "+s+" character to complete a CD arrow.",a[l]);o[t].body.push(a[l])}if(n)throw new e("Missing a "+s+" character to complete a CD arrow.",a[r])}}const i=Re(s,o,t);n.push(i),l=Ge()}else l.body.push(a[r]);o%2==0?n.push(l):n.shift(),n=[],s.push(n)}return s.pop(),t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:"math",body:s,tags:null,labels:new Array(s.length+1).fill(""),envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(s.length+1).fill([])}}(t.parser)),mathmlBuilder:wt}),h({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(t,r){throw new e(`${t.funcName} valid only within array environment`)}});const kt=Ee;h({type:"bordermatrix",names:["\\bordermatrix","\\matrix"],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:t},r,n)=>{let s=["(",")"];if("\\bordermatrix"===t&&n[0]&&n[0].body){const e=n[0].body;2===e.length&&"atom"===e[0].type&&"atom"===e[1].type&&"open"===e[0].family&&"close"===e[1].family&&(s=[e[0].text,e[1].text])}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}}),h({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 B("mrow",[he(e.body,t)],["ff-narrow"]),n=new B("mphantom",[he(e.body,t)]),s=new B("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 B("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 B("mspace",[]);e.setAttribute("height","0.85em"),r.children.push(e)}let a;if(e.isCharacterBox)a=new B("mspace",[]),a.setAttribute("height","1em");else{const r=he(e.body,t),n=new B("mpadded",[r]);n.setAttribute("width","0.1px"),a=new B("mphantom",[n])}const l=he(e.to,t);l.style.color=t.color;const i=new B("mpadded",[l]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){const e=new B("mspace",[]);e.setAttribute("width","0.2em"),i.children.unshift(e)}i.setAttribute("width","0.1px");const c=new B("mover",[a,i]),p=new B("mrow",[],["ff-nudge-left"]);return O([ie([o,c]),p])}}),h({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:t,token:r},n){const s=Le(n[0],"ordgroup").body;let o="";for(let e=0;e<s.length;e++){o+=Le(s[e],"textord").text}const a=parseInt(o);if(isNaN(a))throw new e(`\\@char has non-numeric argument ${o}`,r);return{type:"textord",mode:t.mode,text:String.fromCodePoint(a)}}});const vt=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,At=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,Tt=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,St=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,qt=/^[a-f0-9]{6}$/i,Ot=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+=Ot(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+=Ot(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 qt.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=ue(e.body,t.withColor(e.color));return 0===r.length&&r.push(new B("mrow")),r=r.map(t=>(t.style.color=e.color,t)),O(r)};h({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]&&Le(n[0],"raw").string;let o="";if(s){const e=Le(r[0],"raw").string;o=Ct(s,e)}else o=Nt(Le(r[0],"raw").string,e.gullet.macros,t);const a=r[1];return{type:"color",mode:e.mode,color:o,isTextColor:!0,body:b(a)}},mathmlBuilder:zt}),h({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]&&Le(s[0],"raw").string;let a="";if(o){const e=Le(n[0],"raw").string;a=Ct(o,e)}else a=Nt(Le(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}),h({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:t,funcName:r,token:n},s){const o=Le(s[0],"raw").string;if(!/^[A-Za-z]+$/.test(o))throw new e("Color name must be latin letters.",n);const a=Le(s[1],"raw").string;if(!["HTML","RGB","rgb"].includes(a))throw new e("Color model must be HTML, RGB, or rgb.",n);const l=Le(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}}}),h({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&&Le(n,"size").value}},mathmlBuilder(e,t){const r=new B("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){const n=Oe(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)};h({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]),Le(t.parseFunction(),"internal");throw new e("Invalid token after macro prefix",n)}}),h({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}}}),h({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}}}),h({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}}}),h({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","⦃":"⦄"},Mt=new Set(Object.keys(Ft));new Set(Object.values(Ft));const Dt=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","."]),Gt=new Set(["}","\\left","\\middle","\\right"]),Pt=e=>e.length>0&&(Dt.has(e)||Lt[e]||Gt.has(e)),jt=[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&&Dt.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 B("mo",[oe("."===e?"":e,t)]);return s.setAttribute("fence","true"),s.setAttribute("form",r),s.setAttribute("stretchy",n?"true":"false"),s};function Vt(e){if(!e.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}h({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(oe(r,e.mode));const n=new B("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",jt[e.size]+"em"),n.setAttribute("maxsize",jt[e.size]+"em"),n}}),h({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})}),h({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=Le(s.parseFunction(),"leftright-right");return{type:"leftright",mode:s.mode,body:o,left:n.text,right:l.delim,isStretchy:!0}},mathmlBuilder:(e,t)=>{Vt(e);const r=ue(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),ie(r)}}),h({type:"delimiter",names:Array.from(Mt),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)=>{Vt(e);const r=ue(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),ie(r)}}),h({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=oe(e.delim,e.mode),r=new B("mo",[t]);return r.setAttribute("fence","true"),e.delim.indexOf("arrow")>-1&&r.setAttribute("stretchy","true"),r.setAttribute("form","prefix"),r.setAttribute("lspace","0.05em"),r.setAttribute("rspace","0.05em"),r}});const _t=["\\boxed","\\fcolorbox","\\colorbox"],Wt=(e,t)=>{const r=_t.includes(e.label)?"mrow":"menclose",n=new B(r,[he(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 B("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike"),n.children.push(new B("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":n.setAttribute("notation","horizontalstrike"),n.children.push(new B("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike"),n.children.push(new B("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":n.setAttribute("notation","longdiv"),n.classes.push("longdiv-top"),n.children.push(new B("mrow",[],["longdiv-arc"]));break;case"\\phase":n.setAttribute("notation","phasorangle"),n.classes.push("phasor-bottom"),n.children.push(new B("mrow",[],["phasor-angle"]));break;case"\\textcircled":n.setAttribute("notation","circle"),n.classes.push("circle-pad"),n.children.push(new B("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};h({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]&&Le(n[0],"raw").string;let o="";if(s){const e=Le(r[0],"raw").string;o=Ct(s,e)}else o=Nt(Le(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}),h({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]&&Le(n[0],"raw").string;let o,a="";if(s){const e=Le(r[0],"raw").string,t=Le(r[0],"raw").string;a=Ct(s,e),o=Ct(s,t)}else a=Nt(Le(r[0],"raw").string,e.gullet.macros),o=Nt(Le(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}),h({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]})}),h({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\sout","\\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}),h({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}),h({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}),h({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<s.body.length;++e)o+=Le(s.body[e],"textord").text;if("\\begin"===r){if(!Object.prototype.hasOwnProperty.call(kt,o))throw new e("No such environment: "+o,s);const r=kt[o],{args:n,optArgs:a}=t.parseArguments("\\begin{"+o+"}",r),l={mode:t.mode,envName:o,parser:t},i=r.handler(l,n,a);t.expect("\\end",!1);const c=t.nextToken,m=Le(t.parseFunction(),"environment");if(m.name!==o)throw new e(`Mismatch: \\begin{${o}} matched by \\end{${m.name}}`,c);return i}return{type:"environment",mode:t.mode,name:o,nameGroup:s}}}),h({type:"envTag",names:["\\env@tag"],props:{numArgs:1,argTypes:["math"]},handler:({parser:e},t)=>({type:"envTag",mode:e.mode,body:t[0]}),mathmlBuilder:(e,t)=>new B("mrow")}),h({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new B("mrow")});const Xt=(e,t)=>{const r=e.font,n=t.withFont(r),s=he(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("mathrm"!==t||"ordgroup"!==e.body.type||1===e.body.body.length)return!1;if("mathord"!==e.body.body[0].type)return!1;for(let t=1;t<e.body.body.length;t++){const r=e.body.body[t].type;if("mathord"!==r&&("textord"!==r||isNaN(e.body.body[t].text)))return!1}return!0})(e,r)){const e=s.children[0].children[0].children?s.children[0].children[0]:s.children[0];delete e.attributes.mathvariant;for(let t=1;t<s.children.length;t++)e.children[0].text+=s.children[t].children[0].children?s.children[t].children[0].children[0].text:s.children[t].children[0].text;const t=new B("mpadded",[e]);return t.setAttribute("lspace","0"),t}let o="mo"===s.children[0].type;for(let e=1;e<s.children.length;e++){"mo"===s.children[e].type&&"boldsymbol"===r&&(s.children[e].style.fontWeight="bold"),"mi"!==s.children[e].type&&(o=!1);"normal"!==(s.children[e].attributes&&s.children[e].attributes.mathvariant||"")&&(o=!1)}if(!o)return s;const a=s.children[0];for(let e=1;e<s.children.length;e++)a.children.push(s.children[e].children[0]);if(a.attributes.mathvariant&&"normal"===a.attributes.mathvariant){const e=new B("mtext",new C(""));return new B("mrow",[e,a])}return a},Zt={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};h({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\up@greek","\\boldsymbol","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathsfit","\\mathtt","\\Bbb","\\bm","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=f(r[0]);let s=t;return s in Zt&&(s=Zt[s]),{type:"font",mode:e.mode,font:s.slice(1),body:n}},mathmlBuilder:Xt}),h({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:Xt});const Yt=["display","text","script","scriptscript"],Jt={auto:-1,display:0,text:0,script:1,scriptscript:2},Kt=(e,t)=>{t=((e,t)=>{let r=t;if("display"===e){const e=r.level>=Ze?Xe:We;r=r.withLevel(e)}else"text"===e&&r.level===We?r=r.withLevel(Xe):"auto"===e?r=r.incrementLevel():"script"===e?r=r.withLevel(Ze):"scriptscript"===e&&(r=r.withLevel(Ye));return r})(e.scriptLevel,t);const r=he(e.numer,t),n=he(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 B("mfrac",[r,n]);if(e.hasBarLine){if(e.barSize){const r=Oe(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 B("mo",[new C(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(s),null!=e.rightDelim){const r=new B("mo",[new C(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}s=ie(t)}return"auto"!==e.scriptLevel&&(s=new B("mstyle",[s]),s.setAttribute("displaystyle",String("display"===e.scriptLevel)),s.setAttribute("scriptlevel",Jt[e.scriptLevel])),s};h({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:Kt}),h({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 Qt=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};h({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=f(t[0]),o="atom"===s.type&&"open"===s.family?Qt(s.text):null,a=f(t[1]),l="atom"===a.type&&"close"===a.family?Qt(a.text):null,i=Le(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=Le(u.body[0],"textord");p=Yt[Number(e.text)]}}else u=Le(u,"textord"),p=Yt[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:Kt}),h({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:Le(n[0],"size").value,token:r})}),h({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}(Le(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:Kt}),h({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},t)=>({type:"hbox",mode:e.mode,body:b(t[0])}),mathmlBuilder(e,t){const r=t.withLevel(Xe),n=de(e.body,r);return le(n)}});h({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=E(e.label);return r.style["math-depth"]=0,new B(e.isOver?"mover":"munder",[he(e.base,t),r])}}),h({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=Le(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<t.length;r++){const n=t[r].split("=");if(2!==n.length)throw new e("Error parsing key-value for \\data");i["data-"+n[0].trim()]=n[1].trim()}l={command:"\\data",attributes:i};break}default:throw new Error("Unrecognized html command")}if(!t.settings.isTrusted(l))throw new e(`Function "${r}" is not trusted`,n);return{type:"html",mode:t.mode,attributes:i,body:b(a)}},mathmlBuilder:(e,t)=>{const r=de(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 er=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(!Se(n))throw new e("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};h({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=Le(s[0],"raw").string.split(",");for(let r=0;r<t.length;r++){const n=t[r].split("=");if(2===n.length){const t=n[1].trim();switch(n[0].trim()){case"alt":i=t;break;case"width":o=er(t);break;case"height":a=er(t);break;case"totalheight":l=er(t);break;default:throw new e("Invalid key: '"+n[0]+"' in \\includegraphics.")}}}}const c=Le(n[0],"url").url;if(""===i&&(i=c,i=i.replace(/^.*[\\/]/,""),i=i.substring(0,i.lastIndexOf("."))),!t.settings.isTrusted({command:"\\includegraphics",url:c}))throw new e('Function "\\includegraphics" is not trusted',r);return{type:"includegraphics",mode:t.mode,alt:i,width:o,height:a,totalheight:l,src:c}},mathmlBuilder:(e,t)=>{const r=Oe(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=Oe(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 B("mtext",[a])}}),h({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=Le(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=Oe(e.dimension,t),n=r.number>0&&"em"===r.unit?tr(r.number):"";if("text"===e.mode&&n.length>0){const e=new C(n);return new B("mtext",[e])}if(r.number>=0){const e=new B("mspace");return e.setAttribute("width",r.number+r.unit),e}{const e=new B("mrow");return e.style.marginLeft=r.number+r.unit,e}}});const tr=function(e){return e>=.05555&&e<=.05556?" ":e>=.1666&&e<=.1667?" ":e>=.2222&&e<=.2223?" ":e>=.2777&&e<=.2778?" ":""},rr=/[^A-Za-z_0-9-]/g;h({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(rr,"")}),mathmlBuilder(e,t){const r=new B("mrow",[],["tml-label"]);return e.string.length>0&&r.setLabel(e.string),r}});const nr=["\\clap","\\llap","\\rlap"];h({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:t,funcName:r,token:n},s)=>{if(nr.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=ue(b(e.body),t),s=new B("mphantom",n);r=new B("mpadded",[s]),r.setAttribute("width","0.1px")}const n=he(e.body,t);let s;if("llap"===e.alignment?(n.style.position="absolute",n.style.right="0",n.style.bottom="0",s=new B("mpadded",[r,n])):s=new B("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}}),h({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}}}),h({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,r){throw new e(`Mismatched ${t.funcName}`,r)}});h({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:b(t[0]),text:b(t[1]),script:b(t[2]),scriptscript:b(t[3])}),mathmlBuilder:(e,t)=>{const r=((e,t)=>{switch(t.level){case We:return e.display;case Xe:return e.text;case Ze:return e.script;case Ye:return e.scriptscript;default:return e.text}})(e,t);return de(r,t)}});const sr=["text","textord","mathord","atom"];function or(e,t){let r;const n=ue(e.body,t);if("minner"===e.mclass)r=new B("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 B("mi",n);else{r=new B("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 B("mrow",n);const s=t.level<2;"mrow"===r.type?s&&("mbin"===e.mclass?(r.children.unshift(Be(.2222)),r.children.push(Be(.2222))):"mrel"===e.mclass?(r.children.unshift(Be(.2778)),r.children.push(Be(.2778))):"mpunct"===e.mclass?r.children.push(Be(.1667)):"minner"===e.mclass&&(r.children.unshift(Be(.0556)),r.children.push(Be(.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}h({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(!sr.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:b(o?a:n),isCharacterBox:s,mustPromote:o}},mathmlBuilder:or});const ar=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"};h({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:ar(t[0]),body:b(t[1]),isCharacterBox:i(t[1])})}),h({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?ar(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:b(n)};return{type:"supsub",mode:s.mode,stack:!0,base:a,sup:"\\underset"===t?null:s,sub:"\\underset"===t?s:null}},mathmlBuilder:or});const lr=(e,t,r)=>{if(!e)return r;const n=he(e,t);return"mrow"===n.type&&0===n.children.length?r:n};h({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=he(e.base,t),n=new B("mprescripts"),s=new B("none");let o=[];const a=lr(e.prescripts.sub,t,s),l=lr(e.prescripts.sup,t,s);if(e.isSideset&&(a.setAttribute("style","text-align: left;"),l.setAttribute("style","text-align: left;")),e.postscripts){o=[r,lr(e.postscripts.sub,t,s),lr(e.postscripts.sup,t,s),n,a,l]}else o=[r,n,a,l];return new B("mmultiscripts",o)}}),h({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=b(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 ue(e.body,t,!0)[0]}return de(e.body,t)}});const ir=["textord","mathord","atom"],cr=["\\smallint"],mr=["textord","mathord","ordgroup","close","leftright","font"],pr=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},ur=(e,t)=>{let r;if(e.symbol)r=new B("mo",[oe(e.name,e.mode)]),cr.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false"),e.fromMathOp&&pr(r);else if(e.body)r=new B("mo",ue(e.body,t)),e.fromMathOp&&pr(r);else if(r=new B("mi",[new C(e.name.slice(1))]),!e.parentIsSupSub){const t=[r,new B("mo",[oe("","text")])];if(e.needsLeadingSpace){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.push(e)}r=new B("mrow",t)}return r},dr={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨅":"\\bigsqcap","⨆":"\\bigsqcup","⨃":"\\bigcupdot","⨇":"\\bigdoublevee","⨈":"\\bigdoublewedge","⨉":"\\bigtimes"};h({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=dr[n]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:ur}),h({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&&ir.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:b(r)}},mathmlBuilder:ur});const hr={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint","∱":"\\intclockwise","∲":"\\varointclockwise","⨌":"\\iiiint","⨍":"\\intbar","⨎":"\\intBar","⨏":"\\fint","⨒":"\\rppolint","⨓":"\\scpolint","⨕":"\\pointint","⨖":"\\sqint","⨗":"\\intlarhk","⨘":"\\intx","⨙":"\\intcap","⨚":"\\intcup"};h({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:Pt(n),needsLeadingSpace:r.length>0&&mr.includes(r),name:t}},mathmlBuilder:ur}),h({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:Pt(n),needsLeadingSpace:r.length>0&&mr.includes(r),name:t}},mathmlBuilder:ur}),h({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=hr[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:ur});h({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:b(n),alwaysHandleSupSub:"\\operatornamewithlimits"===t,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:Pt(o),needsLeadingSpace:s.length>0&&mr.includes(s)}},mathmlBuilder:(e,t)=>{let r,n=ue(e.body,t.withFont("mathrm")),s=!0;for(let e=0;e<n.length;e++){let t=n[e];if(t instanceof B)switch((("mrow"===t.type||"mpadded"===t.type)&&1===t.children.length&&t.children[0]instanceof B||"mrow"===t.type&&2===t.children.length&&t.children[0]instanceof B&&t.children[1]instanceof B&&"mspace"===t.children[1].type&&!t.children[1].attributes.width&&0===t.children[1].children.length)&&(t=t.children[0]),t.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(t.attributes.width){const r=t.attributes.width.replace("em",""),o=tr(Number(r));""===o?s=!1:n[e]=new B("mtext",[new C(o)])}break;case"mo":{const e=t.children[0];1===t.children.length&&e instanceof C?e.text=e.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):s=!1;break}default:s=!1}else s=!1}if(s){const e=n.map(e=>e.toText()).join("");n=[new C(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 B("mrow",n);{const e=new B("mo",[oe("","text")]);return O([n[0],e])}}if(s?(r=new B("mi",n),1===n[0].text.length&&r.setAttribute("mathvariant","normal")):r=new B("mrow",n),!e.parentIsSupSub){const t=[r,new B("mo",[oe("","text")])];if(e.needsLeadingSpace){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new B("mspace");e.setAttribute("width","0.1667em"),t.push(e)}return O(t)}return r}}),Ke("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),g({type:"ordgroup",mathmlBuilder:(e,t)=>de(e.body,t,e.semisimple)}),h({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"phantom",mode:e.mode,body:b(r)}},mathmlBuilder:(e,t)=>{const r=ue(e.body,t);return new B("mphantom",r)}}),h({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=ue(b(e.body),t),n=new B("mphantom",r),s=new B("mpadded",[n]);return s.setAttribute("height","0px"),s.setAttribute("depth","0px"),s}}),h({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=ue(b(e.body),t),n=new B("mphantom",r),s=new B("mpadded",[n]);return s.setAttribute("width","0px"),s}}),h({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:b(t[0])}),mathmlBuilder(e,t){const r=ue(e.body,t),n=N(r);return n.setAttribute("style","font-weight:bold"),n}});const gr=(e,t)=>{const r=t.withLevel(Xe),n=new B("mpadded",[he(e.body,r)]),s=Oe(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};h({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},r){const n=Le(r[0],"size").value;"\\lower"===t&&(n.number*=-1);const s=r[1];return{type:"raise",mode:e.mode,dy:n,body:s}},mathmlBuilder:gr}),h({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},r){const n=Le(r[0],"size").value,s=r[1];return{type:"raise",mode:e.mode,dy:n,body:s}},mathmlBuilder:gr}),h({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(rr,"")}),mathmlBuilder(e,t){const r="\\ref"===e.funcName?["tml-ref"]:["tml-ref","tml-eqref"];return new S("#"+e.string,r,null)}}),h({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=he(e.body,t);return r.style.transform="scaleX(-1)",r}}),h({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),h({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=Le(t[0],"size"),o=Le(t[1],"size");return{type:"rule",mode:e.mode,shift:n&&Le(n,"size").value,width:s.value,height:o.value}},mathmlBuilder(e,t){const r=Oe(e.width,t),n=Oe(e.height,t),s=e.shift?Oe(e.shift,t):{number:0,unit:"em"},o=t.color&&t.getColor()||"black",a=new B("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 B("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 fr=/^[0-9]$/,br={0:"₀",1:"₁",2:"₂",3:"₃",4:"₄",5:"₅",6:"₆",7:"₇",8:"₈",9:"₉"},yr={0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹"};h({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||!fr.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||!fr.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=>yr[e]).join(""),n=e.denominator.split("").map(e=>br[e]).join(""),s=new C(r+"⁄"+n,e.mode,t);return new B("mn",[s],["special-fraction"])}});const wr={"\\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};h({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(wr[e.funcName]),n=ue(e.body,r),s=N(n),o=(wr[e.funcName]/t.fontSize).toFixed(4);return s.setAttribute("mathsize",o+"em"),s}}),h({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]&&Le(r[0],"ordgroup");if(o){let e="";for(let t=0;t<o.body.length;++t){if(e=o.body[t].text,"t"===e)n=!0;else{if("b"!==e){n=!1,s=!1;break}s=!0}}}else n=!0,s=!0;const a=t[0];return{type:"smash",mode:e.mode,body:a,smashHeight:n,smashDepth:s}},mathmlBuilder:(e,t)=>{const r=new B("mpadded",[he(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}});const xr=["a","c","e","ı","m","n","o","r","s","u","v","w","x","z","α","ε","ι","κ","ν","ο","π","σ","τ","υ","ω","\\alpha","\\epsilon","\\iota","\\kappa","\\nu","\\omega","\\pi","\\tau","\\omega"];h({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&&xr.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 B("mroot",[he(r,t),he(n,t.incrementLevel())]):new B("msqrt",[he(r,t)])}});const kr={display:0,text:1,script:2,scriptscript:3},vr={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};h({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(kr[e.scriptLevel]),n=ue(e.body,r),s=N(n),o=vr[e.scriptLevel];return s.setAttribute("scriptlevel",o[0]),s.setAttribute("displaystyle",o[1]),s}});const Ar=/^m(over|under|underover)$/;g({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?[he(e.base.body[0],t)]:[he(e.base,t)],c=t.inSubOrSup();if(e.sub){const r=he(e.sub,c);3===t.level&&r.setAttribute("scriptlevel","2"),i.push(r)}if(e.sup){const r=he(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===We||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.level===We||r.limits)?"munderover":"msubsup"}else{const r=e.base;m=e.stack||r&&"op"===r.type&&r.limits&&(t.level===We||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===We)?"munder":"msub"}else{const r=e.base;m=r&&"op"===r.type&&r.limits&&(t.level===We||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===We)?"mover":"msup"}let p=new B(m,i);if(o){const e=new B("mo",[oe("","text")]);if(l){const t=new B("mspace");t.setAttribute("width","0.1667em"),p=O([t,p,e])}else p=O([p,e]);if(a){const e=new B("mspace");e.setAttribute("width","0.1667em"),p.children.push(e)}}else Ar.test(m)&&(p=new B("mrow",[p]));return p}});const Tr=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],Sr=["\\Rsh","\\Lsh","\\restriction"];g({type:"atom",mathmlBuilder(e,t){const r=new B("mo",[oe(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<t&&t<8704}return e.indexOf("arrow")>-1||e.indexOf("harpoon")>-1||Sr.includes(e)})(e.text))r.setAttribute("stretchy","false");else if(Tr.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 B("mrow",[Be(.222),r,Be(.222)]):new B("mrow",[Be(.2778),r,Be(.2778)]);return r}});const qr={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},Or=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<t&&t<975?"italic":"normal"}case"up@greek":return"normal";case"boldsymbol":case"mathboldsymbol":return"bold-italic";case"mathbf":return"bold";case"mathbb":return"double-struck";case"mathfrak":return"fraktur";case"mathscr":case"mathcal":return"script";case"mathsf":return"sans-serif";case"mathsfit":return"sans-serif-italic";case"mathtt":return"monospace"}let s=e.text;return D[n][s]&&D[n][s].replace&&(s=D[n][s].replace),Object.prototype.hasOwnProperty.call(qr,r)?qr[r]:null},Br=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),Cr=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Nr=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),zr=Object.freeze({"ϵ":119527,"ϑ":119564,"ϰ":119534,"φ":119577,"ϱ":119535,"ϖ":119563}),$r=Object.freeze({"ϵ":119643,"ϑ":119680,"ϰ":119650,"φ":119693,"ϱ":119651,"ϖ":119679}),Er=Object.freeze({"ϵ":119701,"ϑ":119738,"ϰ":119708,"φ":119751,"ϱ":119709,"ϖ":119737}),Ir=Object.freeze({"ϵ":119759,"ϑ":119796,"ϰ":119766,"φ":119809,"ϱ":119767,"ϖ":119795}),Lr=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>Br[e]||119899,"script-bold":e=>119951,fraktur:e=>Cr[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>Nr[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=>Br[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=>zr[e]||-51,italic:e=>0,"bold-italic":e=>$r[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Er[e]||116,"sans-serif-bold":e=>Er[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Ir[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}}),Fr=(e,t)=>{const r=e.codePointAt(0),n=64<r&&r<91?"upperCaseLatin":96<r&&r<123?"lowerCaseLatin":912<r&&r<938?"upperCaseGreek":944<r&&r<970||"ϕ"===e?"lowerCaseGreek":120545<r&&r<120572||zr[e]?"varGreek":47<r&&r<58?"numeral":"other";return"other"===n?e:String.fromCodePoint(r+Lr[n][t](e))},Mr=Object.freeze({a:"ᴀ",b:"ʙ",c:"ᴄ",d:"ᴅ",e:"ᴇ",f:"ꜰ",g:"ɢ",h:"ʜ",i:"ɪ",j:"ᴊ",k:"ᴋ",l:"ʟ",m:"ᴍ",n:"ɴ",o:"ᴏ",p:"ᴘ",q:"ǫ",r:"ʀ",s:"s",t:"ᴛ",u:"ᴜ",v:"ᴠ",w:"ᴡ",x:"x",y:"ʏ",z:"ᴢ"}),Dr=/^\d(?:[\d,.]*\d)?$/,Gr=/[A-Ba-z]/,Pr=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);g({type:"mathord",mathmlBuilder(e,t){const r=oe(e.text,e.mode,t),n=r.text.codePointAt(0),s=912<n&&n<938?"normal":"italic",o=Or(e,t)||s;if("script"===o)return r.text=Fr(r.text,o),new B("mi",[r],[t.font]);"italic"!==o&&(r.text=Fr(r.text,o));let a=new B("mi",[r]);if("normal"===o&&(a.setAttribute("mathvariant","normal"),1===r.text.length)){const e=new B("mspace",[]);a=new B("mrow",[a,e])}return a}}),g({type:"textord",mathmlBuilder(e,t){let r=e.text;const n=r.codePointAt(0);"textsc"===t.fontFamily&&96<n&&n<123&&(r=Mr[r]);const s=oe(r,e.mode,t),o=Or(e,t)||"normal";let a;if(Dr.test(e.text)){const t="text"===e.mode?"mtext":"mn";if("italic"===o||"bold-italic"===o)return((e,t,r)=>{const n=new B(r,[e]),s=new B("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=>Fr(e,o)).join("")),a=new B(t,[s])}else if("text"===e.mode)"normal"!==o&&(s.text=Fr(s.text,o)),a=new B("mtext",[s]);else if(Pr.has(e.text))a=new B("mo",[s]),a.classes.push("tml-prime");else{const e=s.text;"italic"!==o&&(s.text=Fr(s.text,o)),a=new B("mi",[s]),s.text===e&&Gr.test(e)&&a.setAttribute("mathvariant","italic")}return a}});const jr={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Rr={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};g({type:"spacing",mathmlBuilder(t,r){let n;if(Object.prototype.hasOwnProperty.call(Rr,t.text))n=new B("mtext",[new C(" ")]);else{if(!Object.prototype.hasOwnProperty.call(jr,t.text))throw new e(`Unknown type of space "${t.text}"`);n=new B("mo"),"\\nobreak"===t.text&&n.setAttribute("linebreak","nobreak")}return n}}),g({type:"tag"});const Ur={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},Hr={"\\textbf":"textbf","\\textmd":"textmd"},Vr={"\\textit":"textit","\\textup":"textup"};h({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:b(n),font:t}},mathmlBuilder(e,t){const r=((e,t)=>{const r=e.font;return r?Ur[r]?t.withTextFontFamily(Ur[r]):Hr[r]?t.withTextFontWeight(Hr[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Vr[r]):t})(e,t),n=de(e.body,r);return le(n)}}),h({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 B("mtd",[he(e.body,t)]);r.style.padding="0";const n=new B("mtr",[r]);return new B("mtable",[n])}}),h({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 C(_r(e)),n=new B("mtext",[r]);return n.setAttribute("mathvariant","monospace"),n}});const _r=e=>e.body.replace(/ /g,e.star?"␣":" "),Wr=u,Xr="[ \r\n\t]",Zr=`(\\\\[a-zA-Z@]+)${Xr}*`,Yr="[̀-ͯ]",Jr=new RegExp(`${Yr}+$`),Kr=`(${Xr}+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-‧-豈-]${Yr}*|[\ud800-\udbff][\udc00-\udfff]${Yr}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${Zr}|\\\\[^\ud800-\udfff])`;class Qr{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(Kr,"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 _e("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 _e(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 _e(s,new Ve(this,r,this.tokenRegex.lastIndex))}}class en{constructor(e={},t={}){this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}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;t<this.undefStack.length;t++)delete this.undefStack[t][e];this.undefStack.length>0&&(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 tn={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class rn{constructor(e,t,r){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new en(Qe,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new Qr(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 _e("EOF",r.loc)),this.pushTokens(n),t.range(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;t<n.length;t++){const r=this.popToken();if(n[t]!==r.text)throw new e("Use of the macro doesn't match its definition",r)}}const n=[];for(let e=0;e<t;e++)n.push(this.consumeArg(r&&r[e+1]).tokens);return n}expandOnce(t){const r=this.popToken(),n=r.text,s=r.noexpand?null:this._getExpansion(n);if(null==s||t&&s.unexpandable){if(t&&null==s&&"\\"===n[0]&&!this.isDefined(n))throw new e("Undefined control sequence: "+n);return this.pushToken(r),!1}if(this.expansionCount++,this.expansionCount>this.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 _e(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 Qr(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(Wr,e)||Object.prototype.hasOwnProperty.call(D.math,e)||Object.prototype.hasOwnProperty.call(D.text,e)||Object.prototype.hasOwnProperty.call(tn,e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(Wr,e)&&!Wr[e].primitive}}const nn=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,sn=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","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),on=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 an={"́":{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"}},ln={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","ḋ":"ḋ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","Ḋ":"Ḋ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"Ȯ","Ȱ":"Ȱ","Ő":"Ő","Ṕ":"Ṕ","Ṗ":"Ṗ","Ŕ":"Ŕ","Ř":"Ř","Ṙ":"Ṙ","Ś":"Ś","Ṥ":"Ṥ","Š":"Š","Ṧ":"Ṧ","Ŝ":"Ŝ","Ṡ":"Ṡ","Ť":"Ť","Ṫ":"Ṫ","Ú":"Ú","Ù":"Ù","Ü":"Ü","Ǘ":"Ǘ","Ǜ":"Ǜ","Ǖ":"Ǖ","Ǚ":"Ǚ","Ũ":"Ũ","Ṹ":"Ṹ","Ū":"Ū","Ṻ":"Ṻ","Ŭ":"Ŭ","Ǔ":"Ǔ","Û":"Û","Ů":"Ů","Ű":"Ű","Ṽ":"Ṽ","Ẃ":"Ẃ","Ẁ":"Ẁ","Ẅ":"Ẅ","Ŵ":"Ŵ","Ẇ":"Ẇ","Ẍ":"Ẍ","Ẋ":"Ẋ","Ý":"Ý","Ỳ":"Ỳ","Ÿ":"Ÿ","Ỹ":"Ỹ","Ȳ":"Ȳ","Ŷ":"Ŷ","Ẏ":"Ẏ","Ź":"Ź","Ž":"Ž","Ẑ":"Ẑ","Ż":"Ż","ά":"ά","ὰ":"ὰ","ᾱ":"ᾱ","ᾰ":"ᾰ","έ":"έ","ὲ":"ὲ","ή":"ή","ὴ":"ὴ","ί":"ί","ὶ":"ὶ","ϊ":"ϊ","ΐ":"ΐ","ῒ":"ῒ","ῑ":"ῑ","ῐ":"ῐ","ό":"ό","ὸ":"ὸ","ύ":"ύ","ὺ":"ὺ","ϋ":"ϋ","ΰ":"ΰ","ῢ":"ῢ","ῡ":"ῡ","ῠ":"ῠ","ώ":"ώ","ὼ":"ὼ","Ύ":"Ύ","Ὺ":"Ὺ","Ϋ":"Ϋ","Ῡ":"Ῡ","Ῠ":"Ῠ","Ώ":"Ώ","Ὼ":"Ὼ"};const cn=["bin","op","open","punct","rel"],mn=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,pn=/^ *\\text/;class un{constructor(e,t,r=!1){this.mode="math",this.gullet=new rn(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 _e("}")),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!==un.endOfExpression.indexOf(s.text))break;if(t&&s.text===t)break;if(r&&"\\middle"===s.text)break;if(e&&Wr[s.text]&&Wr[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<t.length;s++)if("infix"===t[s].type){if(-1!==n)throw new e("only one infix operator per group",t[s].token);n=s,r=t[s].replaceWith}if(-1!==n&&r){let e,s;const o=t.slice(0,n),a=t.slice(n+1);let l;return e=1===o.length&&"ordgroup"===o[0].type?o[0]:{type:"ordgroup",mode:this.mode,body:o},s=1===a.length&&"ordgroup"===a[0].type?a[0]:{type:"ordgroup",mode:this.mode,body:a},l="\\\\abovefrac"===r?this.callFunction(r,[e,t[n],s],[]):this.callFunction(r,[e,s],[]),[l]}return t}handleSupSubscript(t){const r=this.fetch(),n=r.text;let s;this.consume(),this.consumeSpaces();do{s=this.parseGroup(t)}while(s.type&&"internal"===s.type);if(!s)throw new e("Expected group after '"+n+"'",r);return s}formatUnsupportedCmd(e){const t=[];for(let r=0;r<e.length;r++)t.push({type:"textord",mode:"text",text:e[r]});const r={type:"text",mode:this.mode,body:t};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(t){const r=this.parseGroup("atom",t);if(r&&"internal"===r.type)return r;if("text"===this.mode)return r;let n,s;for(;;){this.consumeSpaces();const t=this.fetch();if("\\limits"===t.text||"\\nolimits"===t.text){if(r&&"op"===r.type){const e="\\limits"===t.text;r.limits=e,r.alwaysHandleSupSub=!0}else{if(!r||"operatorname"!==r.type)throw new e("Limit controls must follow a math operator",t);r.alwaysHandleSupSub&&(r.limits="\\limits"===t.text)}this.consume()}else if("^"===t.text){if(n)throw new e("Double superscript",t);n=this.handleSupSubscript("superscript")}else if("_"===t.text){if(s)throw new e("Double subscript",t);s=this.handleSupSubscript("subscript")}else if("'"===t.text){if(n)throw new e("Double superscript",t);const r={type:"textord",mode:this.mode,text:"\\prime"},s=[r];for(this.consume();"'"===this.fetch().text;)s.push(r),this.consume();"^"===this.fetch().text&&s.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:s}}else{if(!sn[t.text])break;{const e=nn.test(t.text),r=[];for(r.push(new _e(sn[t.text])),this.consume();;){const t=this.fetch().text;if(!sn[t])break;if(nn.test(t)!==e)break;r.unshift(new _e(sn[t])),this.consume()}const o=this.subparse(r);e?s={type:"ordgroup",mode:"math",body:o}:n={type:"ordgroup",mode:"math",body:o}}}}if(n||s){if(r&&"multiscript"===r.type&&!r.postscripts)return r.postscripts={sup:n,sub:s},r;{const e=!r||"op"!==r.type&&"operatorname"!==r.type?void 0:Pt(this.nextToken.text);return{type:"supsub",mode:this.mode,base:r,sup:n,sub:s,isFollowedByDelimiter:e}}}return r}parseFunction(t,r){const n=this.fetch(),s=n.text,o=Wr[s];if(!o)return null;if(this.consume(),r&&"atom"!==r&&!o.allowedInArgument)throw new e("Got function '"+s+"' with no arguments"+(r?" as "+r:""),n);if("text"===this.mode&&!o.allowedInText)throw new e("Can't use function '"+s+"' in text mode",n);if("math"===this.mode&&!1===o.allowedInMath)throw new e("Can't use function '"+s+"' in math mode",n);const a=this.prevAtomType,{args:l,optArgs:i}=this.parseArguments(s,o);return this.prevAtomType=a,this.callFunction(s,l,i,n,t)}callFunction(t,r,n,s,o){const a={funcName:t,parser:this,token:s,breakOnTokenText:o},l=Wr[t];if(l&&l.handler)return l.handler(a,r,n);throw new e(`No function handler for ${t}`)}parseArguments(t,r){const n=r.numArgs+r.numOptionalArgs;if(0===n)return{args:[],optArgs:[]};const s=[],o=[];for(let a=0;a<n;a++){let n=r.argTypes&&r.argTypes[a];const l=a<r.numOptionalArgs;(r.primitive&&null==n||"sqrt"===r.type&&1===a&&null==o[0])&&(n="primitive");const i=this.parseGroupOfType(`argument to '${t}'`,n,l);if(l)o.push(i);else{if(null==i)throw new e("Null argument, please report this as a bug");s.push(i)}}return{args:s,optArgs:o}}parseGroupOfType(t,r,n){switch(r){case"size":return this.parseSizeGroup(n);case"url":return this.parseUrlGroup(n);case"math":case"text":return this.parseArgumentGroup(n,r);case"hbox":{const e=this.parseArgumentGroup(n,"text");return null!=e?{type:"styling",mode:e.mode,body:[e],scriptLevel:"text"}:null}case"raw":{const e=this.parseStringGroup("raw",n);return null!=e?{type:"raw",mode:"text",string:e.text}:null}case"primitive":{if(n)throw new e("A primitive argument cannot be optional");const r=this.parseGroup(t);if(null==r)throw new e("Expected group as "+t,this.fetch());return r}case"original":case null:case void 0:return this.parseArgumentGroup(n);default:throw new e("Unknown group type as "+t,this.fetch())}}consumeSpaces(){for(;;){const e=this.fetch().text;if(" "!==e&&" "!==e&&"︎"!==e)break;this.consume()}}parseStringGroup(e,t){const r=this.gullet.scanArgument(t);if(null==r)return null;let n,s="";for(;"EOF"!==(n=this.fetch()).text;)s+=n.text,this.consume();return this.consume(),r.text=s,r}parseRegexGroup(t,r){const n=this.fetch();let s,o=n,a="";for(;"EOF"!==(s=this.fetch()).text&&t.test(a+s.text);)o=s,a+=o.text,this.consume();if(""===a)throw new e("Invalid "+r+": '"+n.text+"'",n);return n.range(o,a)}parseSizeGroup(t){let r,n=!1;if(this.gullet.consumeSpaces(),r=t||"{"===this.gullet.future().text?this.parseStringGroup("size",t):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"),!r)return null;t||0!==r.text.length||(r.text="0pt",n=!0);const s=mn.exec(r.text);if(!s)throw new e("Invalid size: '"+r.text+"'",r);const o={number:+(s[1]+s[2]),unit:s[3]};if(!Se(o))throw new e("Invalid unit: '"+o.unit+"'",r);return{type:"size",mode:this.mode,value:o,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);const t=this.parseStringGroup("url",e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),null==t)return null;let r=t.text.replace(/\\([#$%&~_^{}])/g,"$1");return r=t.text.replace(/{\u2044}/g,"/"),{type:"url",mode:this.mode,url:r}}parseArgumentGroup(e,t){const r=this.gullet.scanArgument(e);if(null==r)return null;const n=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();const s=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();const o={type:"ordgroup",mode:this.mode,loc:r.loc,body:s};return t&&this.switchMode(n),o}parseGroup(t,r){const n=this.fetch(),s=n.text;if("argument to '\\left'"===t)return this.parseSymbol();let o;if("{"===s||"\\begingroup"===s||"\\toggle"===s){this.consume();const e="{"===s?"}":"\\begingroup"===s?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();const t=this.parseExpression(!1,e),r=this.fetch();this.expect(e),this.gullet.endGroup(),o={type:"\\endtoggle"===r.text?"toggle":"ordgroup",mode:this.mode,loc:Ve.range(n,r),body:t,semisimple:"\\begingroup"===s||void 0}}else if(o=this.parseFunction(r,t)||this.parseSymbol(),null==o&&"\\"===s[0]&&!Object.prototype.hasOwnProperty.call(tn,s)){if(this.settings.throwOnError)throw new e("Unsupported function name: "+s,n);o=this.formatUnsupportedCmd(s),this.consume()}return o}formLigatures(e){let t=e.length-1;for(let r=0;r<t;++r){const n=e[r],s=n.text;"-"===s&&"-"===e[r+1].text&&(r+1<t&&"-"===e[r+2].text?(e.splice(r,3,{type:"textord",mode:"text",loc:Ve.range(n,e[r+2]),text:"---"}),t-=2):(e.splice(r,2,{type:"textord",mode:"text",loc:Ve.range(n,e[r+1]),text:"--"}),t-=1)),"'"!==s&&"`"!==s||e[r+1].text!==s||(e.splice(r,2,{type:"textord",mode:"text",loc:Ve.range(n,e[r+1]),text:s+s}),t-=1)}}parseSymbol(){const t=this.fetch();let r=t.text;if(/^\\verb[^a-zA-Z]/.test(r)){this.consume();let t=r.slice(5);const n="*"===t.charAt(0);if(n&&(t=t.slice(1)),t.length<2||t.charAt(0)!==t.slice(-1))throw new e("\\verb assertion failed --\n please report what input caused this bug");return t=t.slice(1,-1),{type:"verb",mode:"text",body:t,star:n}}if(Object.prototype.hasOwnProperty.call(ln,r[0])&&"math"===this.mode&&!D[this.mode][r[0]]){if(this.settings.strict&&"math"===this.mode)throw new e(`Accented Unicode text character "${r[0]}" used in math mode`,t);r=ln[r[0]]+r.slice(1)}const n="math"===this.mode?Jr.exec(r):null;let s;if(n&&(r=r.substring(0,n.index),"i"===r?r="ı":"j"===r&&(r="ȷ")),D[this.mode][r]){let e=D[this.mode][r].group;"bin"!==e||!cn.includes(this.prevAtomType)&&""!==this.prevAtomType||(e="open");const n=Ve.range(t);let o;if(Object.prototype.hasOwnProperty.call(F,e)){const t=e;o={type:"atom",mode:this.mode,family:t,loc:n,text:r},"rel"!==t&&"bin"!==t||"text"!==this.prevAtomType||pn.test(n.lexer.input.slice(n.end))&&(o.needsSpacing=!0)}else{if(on[r]){this.consume();const e=this.fetch().text.charCodeAt(0),t=65025===e?"mathscr":"mathcal";return 65024!==e&&65025!==e||this.consume(),{type:"font",mode:"math",font:t,body:{type:"mathord",mode:"math",loc:n,text:on[r]}}}o={type:e,mode:this.mode,loc:n,text:r}}s=o}else{if(!(r.charCodeAt(0)>=128||Jr.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;r<n[0].length;r++){const o=n[0][r];if(!an[o])throw new e(`Unknown accent ' ${o}'`,t);const a=an[o][this.mode]||an[o].text;if(!a)throw new e(`Accent ${o} unsupported in ${this.mode} mode`,t);s={type:"accent",mode:this.mode,loc:Ve.range(t),label:a,isStretchy:!1,base:s}}return s}}const dn=function(t,r){if(!("string"==typeof t||t instanceof String))throw new TypeError("Temml can only parse string typed expression");let n,s;try{s=new un(t,r),delete s.gullet.macros.current["\\df@tag"],n=s.parse()}catch(e){if("ParseError: Unmatched delimiter"!==e.toString())throw e;r.wrapDelimiterPairs=!1,s=new un(t,r),delete s.gullet.macros.current["\\df@tag"],n=s.parse()}if(!(n.length>0&&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},hn=[2,2,3,3];class gn{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 gn(t)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:hn[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 fn(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 bn=function(e,t,r){let n=r,s=0;const o=e.length;for(;n<t.length;){const r=t[n];if(s<=0&&t.slice(n,n+o)===e)return n;"\\"===r?n++:"{"===r?s++:"}"===r&&s--,n++}return-1},yn=/^\\(?:begin|(?:eq)?ref){/,wn=[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1},{left:"\\[",right:"\\]",display:!0}],xn={$:[{left:"$$",right:"$$",display:!0},{left:"$`",right:"`$",display:!1},{left:"$",right:"$",display:!1}],"(":[{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]},kn=[{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1}],vn=function(t,r){const n=function(e,t){let r;const n=[],s=new RegExp("("+t.map(e=>e.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=bn(t[s].right,e,t[s].left.length),-1===r)break;const o=e.slice(0,r+t[s].right.length),a=yn.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<n.length;t++)if("text"===n[t].type)s.appendChild(document.createTextNode(n[t].data));else{const o=document.createElement("span");let a=n[t].data;r.displayMode=n[t].display;try{r.preProcess&&(a=r.preProcess(a)),temml.render(a,o,r)}catch(o){if(!(o instanceof e))throw o;r.errorCallback("Temml auto-render: Failed to parse `"+n[t].data+"` with ",o),s.appendChild(document.createTextNode(n[t].rawData));continue}s.appendChild(o)}return s},An=function(e,t){for(let r=0;r<e.childNodes.length;r++){const n=e.childNodes[r];if(3===n.nodeType){const s=vn(n.textContent,t);s&&(r+=s.childNodes.length-1,e.replaceChild(s,n))}else if(1===n.nodeType){const e=" "+n.className+" ";-1===t.ignoredTags.indexOf(n.nodeName.toLowerCase())&&t.ignoredClasses.every(t=>-1===e.indexOf(" "+t+" "))&&An(n,t)}}};let Tn=function(e,t,r={}){t.textContent="";const n="math"===t.tagName.toLowerCase();n&&(r.wrap="none");const s=Sn(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."),Tn=function(){throw new e("Temml doesn't work in quirks mode.")});const Sn=function(t,r){const n=new p(r);try{const e=dn(t,n);return ye(e,t,new gn({level:n.displayMode?We:Xe,maxSize:n.maxSize}),n)}catch(r){return function(t,r,n){if(n.throwOnError||!(t instanceof e))throw t;const s=new A(["temml-error"],[new T(r+"\n\n"+t.toString())]);return s.style.color=n.errorColor,s.style.whiteSpace="pre-line",s}(r,t,n)}};return{version:"0.13.02",render:Tn,renderToString:function(e,t){return Sn(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 xn[e];if("$+"===e||"(+"===e)return xn[e.slice(0,1)].concat(kn);return"ams"===e?kn:"all"===e?xn["("].concat(xn.$).concat(kn):wn})(r.fences):r.delimiters=r.delimiters||wn,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||{},An(e,r),fn(e)},postProcess:fn,ParseError:e,definePreamble:function(e,t){const r=new p(t);if(r.macros={},!("string"==typeof e||e instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new un(e,r,!0);delete n.gullet.macros.current["\\df@tag"];return n.parse()},__parse:function(e,t){const r=new p(t);return dn(e,r)},__renderToMathMLTree:Sn,__defineSymbol:G,__defineMacro:Ke}}();
|