temml 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/temml.min.js CHANGED
@@ -1 +1 @@
1
- var temml=function(){"use strict";class e{constructor(t,r){let n,o=" "+t;const s=r&&r.loc;if(s&&s.start<=s.end){const e=s.lexer.input;n=s.start;const t=s.end;n===e.length?o+=" at end of input: ":o+=" at position "+(n+1)+": ";const r=e.slice(n,t).replace(/[^]/g,"$&̲");let a,i;a=n>15?"…"+e.slice(n-15,n):e.slice(0,n),i=t+15<e.length?e.slice(t,t+15)+"…":e.slice(t),o+=a+r+i}const a=new Error(o);return a.name="ParseError",a.__proto__=e.prototype,a.position=n,a}}e.prototype.__proto__=Error.prototype;const t=/([A-Z])/g,r={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},n=/[&><"']/g;const o=function(e){return"ordgroup"===e.type||"color"===e.type?1===e.body.length?o(e.body[0]):e:"font"===e.type?o(e.body):e};var s={deflt:function(e,t){return void 0===e?t:e},escape:function(e){return String(e).replace(n,(e=>r[e]))},hyphenate:function(e){return e.replace(t,"-$1").toLowerCase()},getBaseElem:o,isCharacterBox:function(e){const t=o(e);return"mathord"===t.type||"textord"===t.type||"atom"===t.type},protocolFromUrl:function(e){const t=/^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(e);return null!=t?t[1]:"_relative"},round:function(e){return+e.toFixed(4)}};class a{constructor(e){e=e||{},this.displayMode=s.deflt(e.displayMode,!1),this.annotate=s.deflt(e.annotate,!1),this.leqno=s.deflt(e.leqno,!1),this.errorColor=s.deflt(e.errorColor,"#b22222"),this.macros=e.macros||{},this.wrap=s.deflt(e.wrap,"none"),this.xml=s.deflt(e.xml,!1),this.colorIsTextColor=s.deflt(e.colorIsTextColor,!1),this.strict=s.deflt(e.strict,!1),this.trust=s.deflt(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,s.deflt(e.maxExpand,1e3))}isTrusted(e){e.url&&!e.protocol&&(e.protocol=s.protocolFromUrl(e.url));const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}const i={},l={};function c({type:e,names:t,props:r,handler:n,mathmlBuilder:o}){const s={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)i[t[e]]=s;e&&o&&(l[e]=o)}function m({type:e,mathmlBuilder:t}){c({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:t})}const u=function(e){return"ordgroup"===e.type&&1===e.body.length?e.body[0]:e},p=function(e){return"ordgroup"===e.type?e.body:[e]};class d{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 h=function(e){return e.filter((e=>e)).join(" ")},g=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},f=function(e){const t=document.createElement(e);t.className=h(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},b=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${s.escape(h(this.classes))}"`);let r="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(r+=`${s.hyphenate(e)}:${this.style[e]};`);r&&(t+=` style="${r}"`);for(const e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&(t+=` ${e}="${s.escape(this.attributes[e])}"`);t+=">";for(let e=0;e<this.children.length;e++)t+=this.children[e].toMarkup();return t+=`</${e}>`,t};class y{constructor(e,t,r){g.call(this,e,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return f.call(this,"span")}toMarkup(){return b.call(this,"span")}}class w{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return s.escape(this.text)}}class x{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+=`${s.hyphenate(e)}:${this.style[e]};`);return t&&(e+=` style="${s.escape(t)}"`),e+="/>",e}}class k{constructor(e,t,r,n){this.type=e,this.attributes={},this.children=t||[],this.classes=r||[],this.style=n||{}}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[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=h(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+=s.escape(this.attributes[t]),e+='"');this.classes.length>0&&(e+=` class="${s.escape(h(this.classes))}"`);let t="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${s.hyphenate(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 v{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return s.escape(this.toText())}toText(){return this.text}}const A=e=>{let t;return 1===e.length&&"mrow"===e[0].type?(t=e.pop(),t.type="mstyle"):t=new k("mstyle",e),t};var N={MathNode:k,TextNode:v,newDocumentFragment:function(e){return new d(e)}};const T={widehat:"^",widecheck:"ˇ",widetilde:"~",wideparen:"⏜",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",overparen:"⏜",undergroup:"⏡",underparen:"⏝",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xrightleftarrows:"⇄",yields:"→",yieldsLeft:"←",mesomerism:"↔",longrightharpoonup:"⇀",longleftharpoondown:"↽",eqrightharpoonup:"⇀",eqleftharpoondown:"↽","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"="};var S=function(e){const t=new N.TextNode(T[e.slice(1)]),r=new N.MathNode("mo",[t]);return r.setAttribute("stretchy","true"),r};const q={bin:1,close:1,inner:1,open:1,punct:1,rel:1},O={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},M={math:{},text:{}};function B(e,t,r,n,o){M[e][n]={group:t,replace:r},o&&r&&(M[e][r]=M[e][n])}const C="math",z="text",E="accent-token",I="bin",L="close",F="inner",$="mathord",G="op-token",D="open",P="punct",R="rel",j="spacing",U="textord";B(C,R,"≡","\\equiv",!0),B(C,R,"≺","\\prec",!0),B(C,R,"≻","\\succ",!0),B(C,R,"∼","\\sim",!0),B(C,R,"⟂","\\perp",!0),B(C,R,"⪯","\\preceq",!0),B(C,R,"⪰","\\succeq",!0),B(C,R,"≃","\\simeq",!0),B(C,R,"≌","\\backcong",!0),B(C,R,"|","\\mid",!0),B(C,R,"≪","\\ll",!0),B(C,R,"≫","\\gg",!0),B(C,R,"≍","\\asymp",!0),B(C,R,"∥","\\parallel"),B(C,R,"⋈","\\bowtie",!0),B(C,R,"⌣","\\smile",!0),B(C,R,"⊑","\\sqsubseteq",!0),B(C,R,"⊒","\\sqsupseteq",!0),B(C,R,"≐","\\doteq",!0),B(C,R,"⌢","\\frown",!0),B(C,R,"∋","\\ni",!0),B(C,R,"∌","\\notni",!0),B(C,R,"∝","\\propto",!0),B(C,R,"⊢","\\vdash",!0),B(C,R,"⊣","\\dashv",!0),B(C,R,"∋","\\owns"),B(C,R,"≘","\\arceq",!0),B(C,R,"≙","\\wedgeq",!0),B(C,R,"≚","\\veeeq",!0),B(C,R,"≛","\\stareq",!0),B(C,R,"≝","\\eqdef",!0),B(C,R,"≞","\\measeq",!0),B(C,R,"≟","\\questeq",!0),B(C,R,"≠","\\ne",!0),B(C,R,"≠","\\neq"),B(C,R,"∷","\\dblcolon",!0),B(C,R,"≔","\\coloneqq",!0),B(C,R,"≕","\\eqqcolon",!0),B(C,R,"∹","\\eqcolon",!0),B(C,R,"⩴","\\Coloneqq",!0),B(C,P,".","\\ldotp"),B(C,P,"·","\\cdotp"),B(C,U,"#","\\#"),B(z,U,"#","\\#"),B(C,U,"&","\\&"),B(z,U,"&","\\&"),B(C,U,"ℵ","\\aleph",!0),B(C,U,"∀","\\forall",!0),B(C,U,"ℏ","\\hbar",!0),B(C,U,"∃","\\exists",!0),B(C,U,"∇","\\nabla",!0),B(C,U,"♭","\\flat",!0),B(C,U,"ℓ","\\ell",!0),B(C,U,"♮","\\natural",!0),B(C,U,"Å","\\AA",!0),B(z,U,"Å","\\AA",!0),B(C,U,"♣","\\clubsuit",!0),B(C,U,"♧","\\varclubsuit",!0),B(C,U,"℘","\\wp",!0),B(C,U,"♯","\\sharp",!0),B(C,U,"♢","\\diamondsuit",!0),B(C,U,"♦","\\vardiamondsuit",!0),B(C,U,"ℜ","\\Re",!0),B(C,U,"♡","\\heartsuit",!0),B(C,U,"♥","\\varheartsuit",!0),B(C,U,"ℑ","\\Im",!0),B(C,U,"♠","\\spadesuit",!0),B(C,U,"♤","\\varspadesuit",!0),B(C,U,"♀","\\female",!0),B(C,U,"♂","\\male",!0),B(C,U,"§","\\S",!0),B(z,U,"§","\\S"),B(C,U,"¶","\\P",!0),B(z,U,"¶","\\P"),B(z,U,"☺","\\smiley",!0),B(C,U,"☺","\\smiley",!0),B(C,U,"†","\\dag"),B(z,U,"†","\\dag"),B(z,U,"†","\\textdagger"),B(C,U,"‡","\\ddag"),B(z,U,"‡","\\ddag"),B(z,U,"‡","\\textdaggerdbl"),B(C,L,"⎱","\\rmoustache",!0),B(C,D,"⎰","\\lmoustache",!0),B(C,L,"⟯","\\rgroup",!0),B(C,D,"⟮","\\lgroup",!0),B(C,I,"∓","\\mp",!0),B(C,I,"⊖","\\ominus",!0),B(C,I,"⊎","\\uplus",!0),B(C,I,"⊓","\\sqcap",!0),B(C,I,"∗","\\ast"),B(C,I,"⊔","\\sqcup",!0),B(C,I,"◯","\\bigcirc",!0),B(C,I,"∙","\\bullet",!0),B(C,I,"‡","\\ddagger"),B(C,I,"≀","\\wr",!0),B(C,I,"⨿","\\amalg"),B(C,I,"&","\\And"),B(C,R,"⟵","\\longleftarrow",!0),B(C,R,"⇐","\\Leftarrow",!0),B(C,R,"⟸","\\Longleftarrow",!0),B(C,R,"⟶","\\longrightarrow",!0),B(C,R,"⇒","\\Rightarrow",!0),B(C,R,"⟹","\\Longrightarrow",!0),B(C,R,"↔","\\leftrightarrow",!0),B(C,R,"⟷","\\longleftrightarrow",!0),B(C,R,"⇔","\\Leftrightarrow",!0),B(C,R,"⟺","\\Longleftrightarrow",!0),B(C,R,"↤","\\mapsfrom",!0),B(C,R,"↦","\\mapsto",!0),B(C,R,"⟼","\\longmapsto",!0),B(C,R,"↗","\\nearrow",!0),B(C,R,"↩","\\hookleftarrow",!0),B(C,R,"↪","\\hookrightarrow",!0),B(C,R,"↘","\\searrow",!0),B(C,R,"↼","\\leftharpoonup",!0),B(C,R,"⇀","\\rightharpoonup",!0),B(C,R,"↙","\\swarrow",!0),B(C,R,"↽","\\leftharpoondown",!0),B(C,R,"⇁","\\rightharpoondown",!0),B(C,R,"↖","\\nwarrow",!0),B(C,R,"⇌","\\rightleftharpoons",!0),B(C,$,"↯","\\lightning",!0),B(C,$,"‰","\\permil",!0),B(z,U,"‰","\\permil"),B(C,R,"≮","\\nless",!0),B(C,R,"⪇","\\lneq",!0),B(C,R,"≨","\\lneqq",!0),B(C,R,"≨︀","\\lvertneqq"),B(C,R,"⋦","\\lnsim",!0),B(C,R,"⪉","\\lnapprox",!0),B(C,R,"⊀","\\nprec",!0),B(C,R,"⋠","\\npreceq",!0),B(C,R,"⋨","\\precnsim",!0),B(C,R,"⪹","\\precnapprox",!0),B(C,R,"≁","\\nsim",!0),B(C,R,"∤","\\nmid",!0),B(C,R,"∤","\\nshortmid"),B(C,R,"⊬","\\nvdash",!0),B(C,R,"⊭","\\nvDash",!0),B(C,R,"⋪","\\ntriangleleft"),B(C,R,"⋬","\\ntrianglelefteq",!0),B(C,R,"⊄","\\nsubset",!0),B(C,R,"⊅","\\nsupset",!0),B(C,R,"⊊","\\subsetneq",!0),B(C,R,"⊊︀","\\varsubsetneq"),B(C,R,"⫋","\\subsetneqq",!0),B(C,R,"⫋︀","\\varsubsetneqq"),B(C,R,"≯","\\ngtr",!0),B(C,R,"⪈","\\gneq",!0),B(C,R,"≩","\\gneqq",!0),B(C,R,"≩︀","\\gvertneqq"),B(C,R,"⋧","\\gnsim",!0),B(C,R,"⪊","\\gnapprox",!0),B(C,R,"⊁","\\nsucc",!0),B(C,R,"⋡","\\nsucceq",!0),B(C,R,"⋩","\\succnsim",!0),B(C,R,"⪺","\\succnapprox",!0),B(C,R,"≆","\\ncong",!0),B(C,R,"∦","\\nparallel",!0),B(C,R,"∦","\\nshortparallel"),B(C,R,"⊯","\\nVDash",!0),B(C,R,"⋫","\\ntriangleright"),B(C,R,"⋭","\\ntrianglerighteq",!0),B(C,R,"⊋","\\supsetneq",!0),B(C,R,"⊋","\\varsupsetneq"),B(C,R,"⫌","\\supsetneqq",!0),B(C,R,"⫌︀","\\varsupsetneqq"),B(C,R,"⊮","\\nVdash",!0),B(C,R,"⪵","\\precneqq",!0),B(C,R,"⪶","\\succneqq",!0),B(C,I,"⊴","\\unlhd"),B(C,I,"⊵","\\unrhd"),B(C,R,"↚","\\nleftarrow",!0),B(C,R,"↛","\\nrightarrow",!0),B(C,R,"⇍","\\nLeftarrow",!0),B(C,R,"⇏","\\nRightarrow",!0),B(C,R,"↮","\\nleftrightarrow",!0),B(C,R,"⇎","\\nLeftrightarrow",!0),B(C,R,"△","\\vartriangle"),B(C,U,"ℏ","\\hslash"),B(C,U,"▽","\\triangledown"),B(C,U,"◊","\\lozenge"),B(C,U,"Ⓢ","\\circledS"),B(C,U,"®","\\circledR",!0),B(z,U,"®","\\circledR"),B(z,U,"®","\\textregistered"),B(C,U,"∡","\\measuredangle",!0),B(C,U,"∄","\\nexists"),B(C,U,"℧","\\mho"),B(C,U,"Ⅎ","\\Finv",!0),B(C,U,"⅁","\\Game",!0),B(C,U,"‵","\\backprime"),B(C,U,"▲","\\blacktriangle"),B(C,U,"▼","\\blacktriangledown"),B(C,U,"■","\\blacksquare"),B(C,U,"⧫","\\blacklozenge"),B(C,U,"★","\\bigstar"),B(C,U,"∢","\\sphericalangle",!0),B(C,U,"∁","\\complement",!0),B(C,U,"ð","\\eth",!0),B(z,U,"ð","ð"),B(C,U,"╱","\\diagup"),B(C,U,"╲","\\diagdown"),B(C,U,"□","\\square"),B(C,U,"□","\\Box"),B(C,U,"◊","\\Diamond"),B(C,U,"¥","\\yen",!0),B(z,U,"¥","\\yen",!0),B(C,U,"✓","\\checkmark",!0),B(z,U,"✓","\\checkmark"),B(C,U,"✗","\\ballotx",!0),B(z,U,"✗","\\ballotx"),B(z,U,"•","\\textbullet"),B(C,U,"ℶ","\\beth",!0),B(C,U,"ℸ","\\daleth",!0),B(C,U,"ℷ","\\gimel",!0),B(C,U,"ϝ","\\digamma",!0),B(C,U,"ϰ","\\varkappa"),B(C,D,"⌜","\\ulcorner",!0),B(C,L,"⌝","\\urcorner",!0),B(C,D,"⌞","\\llcorner",!0),B(C,L,"⌟","\\lrcorner",!0),B(C,R,"≦","\\leqq",!0),B(C,R,"⩽","\\leqslant",!0),B(C,R,"⪕","\\eqslantless",!0),B(C,R,"≲","\\lesssim",!0),B(C,R,"⪅","\\lessapprox",!0),B(C,R,"≊","\\approxeq",!0),B(C,I,"⋖","\\lessdot"),B(C,R,"⋘","\\lll",!0),B(C,R,"≶","\\lessgtr",!0),B(C,R,"⋚","\\lesseqgtr",!0),B(C,R,"⪋","\\lesseqqgtr",!0),B(C,R,"≑","\\doteqdot"),B(C,R,"≓","\\risingdotseq",!0),B(C,R,"≒","\\fallingdotseq",!0),B(C,R,"∽","\\backsim",!0),B(C,R,"⋍","\\backsimeq",!0),B(C,R,"⫅","\\subseteqq",!0),B(C,R,"⋐","\\Subset",!0),B(C,R,"⊏","\\sqsubset",!0),B(C,R,"≼","\\preccurlyeq",!0),B(C,R,"⋞","\\curlyeqprec",!0),B(C,R,"≾","\\precsim",!0),B(C,R,"⪷","\\precapprox",!0),B(C,R,"⊲","\\vartriangleleft"),B(C,R,"⊴","\\trianglelefteq"),B(C,R,"⊨","\\vDash",!0),B(C,R,"⊪","\\Vvdash",!0),B(C,R,"⌣","\\smallsmile"),B(C,R,"⌢","\\smallfrown"),B(C,R,"≏","\\bumpeq",!0),B(C,R,"≎","\\Bumpeq",!0),B(C,R,"≧","\\geqq",!0),B(C,R,"⩾","\\geqslant",!0),B(C,R,"⪖","\\eqslantgtr",!0),B(C,R,"≳","\\gtrsim",!0),B(C,R,"⪆","\\gtrapprox",!0),B(C,I,"⋗","\\gtrdot"),B(C,R,"⋙","\\ggg",!0),B(C,R,"≷","\\gtrless",!0),B(C,R,"⋛","\\gtreqless",!0),B(C,R,"⪌","\\gtreqqless",!0),B(C,R,"≖","\\eqcirc",!0),B(C,R,"≗","\\circeq",!0),B(C,R,"≜","\\triangleq",!0),B(C,R,"∼","\\thicksim"),B(C,R,"≈","\\thickapprox"),B(C,R,"⫆","\\supseteqq",!0),B(C,R,"⋑","\\Supset",!0),B(C,R,"⊐","\\sqsupset",!0),B(C,R,"≽","\\succcurlyeq",!0),B(C,R,"⋟","\\curlyeqsucc",!0),B(C,R,"≿","\\succsim",!0),B(C,R,"⪸","\\succapprox",!0),B(C,R,"⊳","\\vartriangleright"),B(C,R,"⊵","\\trianglerighteq"),B(C,R,"⊩","\\Vdash",!0),B(C,R,"∣","\\shortmid"),B(C,R,"∥","\\shortparallel"),B(C,R,"≬","\\between",!0),B(C,R,"⋔","\\pitchfork",!0),B(C,R,"∝","\\varpropto"),B(C,R,"◀","\\blacktriangleleft"),B(C,R,"∴","\\therefore",!0),B(C,R,"∍","\\backepsilon"),B(C,R,"▶","\\blacktriangleright"),B(C,R,"∵","\\because",!0),B(C,R,"⋘","\\llless"),B(C,R,"⋙","\\gggtr"),B(C,I,"⊲","\\lhd"),B(C,I,"⊳","\\rhd"),B(C,R,"≂","\\eqsim",!0),B(C,R,"⋈","\\Join"),B(C,R,"≑","\\Doteq",!0),B(C,R,"⥽","\\strictif",!0),B(C,R,"⥼","\\strictfi",!0),B(C,I,"∔","\\dotplus",!0),B(C,I,"∖","\\smallsetminus"),B(C,I,"⋒","\\Cap",!0),B(C,I,"⋓","\\Cup",!0),B(C,I,"⩞","\\doublebarwedge",!0),B(C,I,"⊟","\\boxminus",!0),B(C,I,"⊞","\\boxplus",!0),B(C,I,"⋇","\\divideontimes",!0),B(C,I,"⋉","\\ltimes",!0),B(C,I,"⋊","\\rtimes",!0),B(C,I,"⋋","\\leftthreetimes",!0),B(C,I,"⋌","\\rightthreetimes",!0),B(C,I,"⋏","\\curlywedge",!0),B(C,I,"⋎","\\curlyvee",!0),B(C,I,"⊝","\\circleddash",!0),B(C,I,"⊛","\\circledast",!0),B(C,I,"⊺","\\intercal",!0),B(C,I,"⋒","\\doublecap"),B(C,I,"⋓","\\doublecup"),B(C,I,"⊠","\\boxtimes",!0),B(C,R,"⇢","\\dashrightarrow",!0),B(C,R,"⇠","\\dashleftarrow",!0),B(C,R,"⇇","\\leftleftarrows",!0),B(C,R,"⇆","\\leftrightarrows",!0),B(C,R,"⇚","\\Lleftarrow",!0),B(C,R,"↞","\\twoheadleftarrow",!0),B(C,R,"↢","\\leftarrowtail",!0),B(C,R,"↫","\\looparrowleft",!0),B(C,R,"⇋","\\leftrightharpoons",!0),B(C,R,"↶","\\curvearrowleft",!0),B(C,R,"↺","\\circlearrowleft",!0),B(C,R,"↰","\\Lsh",!0),B(C,R,"⇈","\\upuparrows",!0),B(C,R,"↿","\\upharpoonleft",!0),B(C,R,"⇃","\\downharpoonleft",!0),B(C,R,"⊶","\\origof",!0),B(C,R,"⊷","\\imageof",!0),B(C,R,"⊸","\\multimap",!0),B(C,R,"↭","\\leftrightsquigarrow",!0),B(C,R,"⇉","\\rightrightarrows",!0),B(C,R,"⇄","\\rightleftarrows",!0),B(C,R,"↠","\\twoheadrightarrow",!0),B(C,R,"↣","\\rightarrowtail",!0),B(C,R,"↬","\\looparrowright",!0),B(C,R,"↷","\\curvearrowright",!0),B(C,R,"↻","\\circlearrowright",!0),B(C,R,"↱","\\Rsh",!0),B(C,R,"⇊","\\downdownarrows",!0),B(C,R,"↾","\\upharpoonright",!0),B(C,R,"⇂","\\downharpoonright",!0),B(C,R,"⇝","\\rightsquigarrow",!0),B(C,R,"⇝","\\leadsto"),B(C,R,"⇛","\\Rrightarrow",!0),B(C,R,"↾","\\restriction"),B(C,U,"‘","`"),B(C,U,"$","\\$"),B(z,U,"$","\\$"),B(z,U,"$","\\textdollar"),B(C,U,"%","\\%"),B(z,U,"%","\\%"),B(C,U,"_","\\_"),B(z,U,"_","\\_"),B(z,U,"_","\\textunderscore"),B(z,U,"␣","\\textvisiblespace",!0),B(C,U,"∠","\\angle",!0),B(C,U,"∞","\\infty",!0),B(C,U,"′","\\prime"),B(C,U,"△","\\triangle"),B(z,U,"Α","\\Alpha",!0),B(z,U,"Β","\\Beta",!0),B(z,U,"Γ","\\Gamma",!0),B(z,U,"Δ","\\Delta",!0),B(z,U,"Ε","\\Epsilon",!0),B(z,U,"Ζ","\\Zeta",!0),B(z,U,"Η","\\Eta",!0),B(z,U,"Θ","\\Theta",!0),B(z,U,"Ι","\\Iota",!0),B(z,U,"Κ","\\Kappa",!0),B(z,U,"Λ","\\Lambda",!0),B(z,U,"Μ","\\Mu",!0),B(z,U,"Ν","\\Nu",!0),B(z,U,"Ξ","\\Xi",!0),B(z,U,"Ο","\\Omicron",!0),B(z,U,"Π","\\Pi",!0),B(z,U,"Ρ","\\Rho",!0),B(z,U,"Σ","\\Sigma",!0),B(z,U,"Τ","\\Tau",!0),B(z,U,"Υ","\\Upsilon",!0),B(z,U,"Φ","\\Phi",!0),B(z,U,"Χ","\\Chi",!0),B(z,U,"Ψ","\\Psi",!0),B(z,U,"Ω","\\Omega",!0),B(C,$,"Α","\\Alpha",!0),B(C,$,"Β","\\Beta",!0),B(C,$,"Γ","\\Gamma",!0),B(C,$,"Δ","\\Delta",!0),B(C,$,"Ε","\\Epsilon",!0),B(C,$,"Ζ","\\Zeta",!0),B(C,$,"Η","\\Eta",!0),B(C,$,"Θ","\\Theta",!0),B(C,$,"Ι","\\Iota",!0),B(C,$,"Κ","\\Kappa",!0),B(C,$,"Λ","\\Lambda",!0),B(C,$,"Μ","\\Mu",!0),B(C,$,"Ν","\\Nu",!0),B(C,$,"Ξ","\\Xi",!0),B(C,$,"Ο","\\Omicron",!0),B(C,$,"Π","\\Pi",!0),B(C,$,"Ρ","\\Rho",!0),B(C,$,"Σ","\\Sigma",!0),B(C,$,"Τ","\\Tau",!0),B(C,$,"Υ","\\Upsilon",!0),B(C,$,"Φ","\\Phi",!0),B(C,$,"Χ","\\Chi",!0),B(C,$,"Ψ","\\Psi",!0),B(C,$,"Ω","\\Omega",!0),B(C,D,"¬","\\neg",!0),B(C,D,"¬","\\lnot"),B(C,U,"⊤","\\top"),B(C,U,"⊥","\\bot"),B(C,U,"∅","\\emptyset"),B(C,U,"ø","\\varnothing"),B(C,$,"α","\\alpha",!0),B(C,$,"β","\\beta",!0),B(C,$,"γ","\\gamma",!0),B(C,$,"δ","\\delta",!0),B(C,$,"ϵ","\\epsilon",!0),B(C,$,"ζ","\\zeta",!0),B(C,$,"η","\\eta",!0),B(C,$,"θ","\\theta",!0),B(C,$,"ι","\\iota",!0),B(C,$,"κ","\\kappa",!0),B(C,$,"λ","\\lambda",!0),B(C,$,"μ","\\mu",!0),B(C,$,"ν","\\nu",!0),B(C,$,"ξ","\\xi",!0),B(C,$,"ο","\\omicron",!0),B(C,$,"π","\\pi",!0),B(C,$,"ρ","\\rho",!0),B(C,$,"σ","\\sigma",!0),B(C,$,"τ","\\tau",!0),B(C,$,"υ","\\upsilon",!0),B(C,$,"ϕ","\\phi",!0),B(C,$,"χ","\\chi",!0),B(C,$,"ψ","\\psi",!0),B(C,$,"ω","\\omega",!0),B(C,$,"ε","\\varepsilon",!0),B(C,$,"ϑ","\\vartheta",!0),B(C,$,"ϖ","\\varpi",!0),B(C,$,"ϱ","\\varrho",!0),B(C,$,"ς","\\varsigma",!0),B(C,$,"φ","\\varphi",!0),B(C,$,"Ϙ","\\Coppa",!0),B(C,$,"ϙ","\\coppa",!0),B(C,$,"ϙ","\\varcoppa",!0),B(C,$,"Ϟ","\\Koppa",!0),B(C,$,"ϟ","\\koppa",!0),B(C,$,"Ϡ","\\Sampi",!0),B(C,$,"ϡ","\\sampi",!0),B(C,$,"Ϛ","\\Stigma",!0),B(C,$,"ϛ","\\stigma",!0),B(C,$,"⫫","\\Bot"),B(C,I,"∗","∗",!0),B(C,I,"+","+"),B(C,I,"*","*"),B(C,I,"⁄","⁄"),B(C,I,"−","-",!0),B(C,I,"⋅","\\cdot",!0),B(C,I,"∘","\\circ",!0),B(C,I,"÷","\\div",!0),B(C,I,"±","\\pm",!0),B(C,I,"×","\\times",!0),B(C,I,"∩","\\cap",!0),B(C,I,"∪","\\cup",!0),B(C,I,"∖","\\setminus",!0),B(C,I,"∧","\\land"),B(C,I,"∨","\\lor"),B(C,I,"∧","\\wedge",!0),B(C,I,"∨","\\vee",!0),B(C,D,"⟦","\\llbracket",!0),B(C,L,"⟧","\\rrbracket",!0),B(C,D,"⟨","\\langle",!0),B(C,D,"|","\\lvert"),B(C,D,"‖","\\lVert"),B(C,U,"!","\\oc"),B(C,U,"?","\\wn"),B(C,U,"↓","\\shpos"),B(C,U,"↕","\\shift"),B(C,U,"↑","\\shneg"),B(C,L,"?","?"),B(C,L,"!","!"),B(C,L,"‼","‼"),B(C,L,"⟩","\\rangle",!0),B(C,L,"|","\\rvert"),B(C,L,"‖","\\rVert"),B(C,D,"⦃","\\lBrace",!0),B(C,L,"⦄","\\rBrace",!0),B(C,R,"=","\\equal",!0),B(C,R,":",":"),B(C,R,"≈","\\approx",!0),B(C,R,"≅","\\cong",!0),B(C,R,"≥","\\ge"),B(C,R,"≥","\\geq",!0),B(C,R,"←","\\gets"),B(C,R,">","\\gt",!0),B(C,R,"∈","\\in",!0),B(C,R,"∉","\\notin",!0),B(C,R,"","\\@not"),B(C,R,"⊂","\\subset",!0),B(C,R,"⊃","\\supset",!0),B(C,R,"⊆","\\subseteq",!0),B(C,R,"⊇","\\supseteq",!0),B(C,R,"⊈","\\nsubseteq",!0),B(C,R,"⊈","\\nsubseteqq"),B(C,R,"⊉","\\nsupseteq",!0),B(C,R,"⊉","\\nsupseteqq"),B(C,R,"⊨","\\models"),B(C,R,"←","\\leftarrow",!0),B(C,R,"≤","\\le"),B(C,R,"≤","\\leq",!0),B(C,R,"<","\\lt",!0),B(C,R,"→","\\rightarrow",!0),B(C,R,"→","\\to"),B(C,R,"≱","\\ngeq",!0),B(C,R,"≱","\\ngeqq"),B(C,R,"≱","\\ngeqslant"),B(C,R,"≰","\\nleq",!0),B(C,R,"≰","\\nleqq"),B(C,R,"≰","\\nleqslant"),B(C,R,"⫫","\\Perp",!0),B(C,j," ","\\ "),B(C,j," ","\\space"),B(C,j," ","\\nobreakspace"),B(z,j," ","\\ "),B(z,j," "," "),B(z,j," ","\\space"),B(z,j," ","\\nobreakspace"),B(C,j,null,"\\nobreak"),B(C,j,null,"\\allowbreak"),B(C,P,",",","),B(z,P,":",":"),B(C,P,";",";"),B(C,I,"⊼","\\barwedge",!0),B(C,I,"⊻","\\veebar",!0),B(C,I,"⊙","\\odot",!0),B(C,I,"⊕","\\oplus",!0),B(C,I,"⊗","\\otimes",!0),B(C,U,"∂","\\partial",!0),B(C,I,"⊘","\\oslash",!0),B(C,I,"⊚","\\circledcirc",!0),B(C,I,"⊡","\\boxdot",!0),B(C,I,"△","\\bigtriangleup"),B(C,I,"▽","\\bigtriangledown"),B(C,I,"†","\\dagger"),B(C,I,"⋄","\\diamond"),B(C,I,"⋆","\\star"),B(C,I,"◃","\\triangleleft"),B(C,I,"▹","\\triangleright"),B(C,D,"{","\\{"),B(z,U,"{","\\{"),B(z,U,"{","\\textbraceleft"),B(C,L,"}","\\}"),B(z,U,"}","\\}"),B(z,U,"}","\\textbraceright"),B(C,D,"{","\\lbrace"),B(C,L,"}","\\rbrace"),B(C,D,"[","\\lbrack",!0),B(z,U,"[","\\lbrack",!0),B(C,L,"]","\\rbrack",!0),B(z,U,"]","\\rbrack",!0),B(C,D,"(","\\lparen",!0),B(C,L,")","\\rparen",!0),B(z,U,"<","\\textless",!0),B(z,U,">","\\textgreater",!0),B(C,D,"⌊","\\lfloor",!0),B(C,L,"⌋","\\rfloor",!0),B(C,D,"⌈","\\lceil",!0),B(C,L,"⌉","\\rceil",!0),B(C,U,"\\","\\backslash"),B(C,U,"|","|"),B(C,U,"|","\\vert"),B(z,U,"|","\\textbar",!0),B(C,U,"‖","\\|"),B(C,U,"‖","\\Vert"),B(z,U,"‖","\\textbardbl"),B(z,U,"~","\\textasciitilde"),B(z,U,"\\","\\textbackslash"),B(z,U,"^","\\textasciicircum"),B(C,R,"↑","\\uparrow",!0),B(C,R,"⇑","\\Uparrow",!0),B(C,R,"↓","\\downarrow",!0),B(C,R,"⇓","\\Downarrow",!0),B(C,R,"↕","\\updownarrow",!0),B(C,R,"⇕","\\Updownarrow",!0),B(C,G,"∐","\\coprod"),B(C,G,"⋁","\\bigvee"),B(C,G,"⋀","\\bigwedge"),B(C,G,"⨄","\\biguplus"),B(C,G,"⋂","\\bigcap"),B(C,G,"⋃","\\bigcup"),B(C,G,"∫","\\int"),B(C,G,"∫","\\intop"),B(C,G,"∬","\\iint"),B(C,G,"∭","\\iiint"),B(C,G,"∏","\\prod"),B(C,G,"∑","\\sum"),B(C,G,"⨂","\\bigotimes"),B(C,G,"⨁","\\bigoplus"),B(C,G,"⨀","\\bigodot"),B(C,G,"∮","\\oint"),B(C,G,"∯","\\oiint"),B(C,G,"∰","\\oiiint"),B(C,G,"∱","\\intclockwise"),B(C,G,"∲","\\varointclockwise"),B(C,G,"⨌","\\iiiint"),B(C,G,"⨍","\\intbar"),B(C,G,"⨎","\\intBar"),B(C,G,"⨏","\\fint"),B(C,G,"⨒","\\rppolint"),B(C,G,"⨓","\\scpolint"),B(C,G,"⨕","\\pointint"),B(C,G,"⨖","\\sqint"),B(C,G,"⨗","\\intlarhk"),B(C,G,"⨘","\\intx"),B(C,G,"⨙","\\intcap"),B(C,G,"⨚","\\intcup"),B(C,G,"⨅","\\bigsqcap"),B(C,G,"⨆","\\bigsqcup"),B(C,G,"∫","\\smallint"),B(z,F,"…","\\textellipsis"),B(C,F,"…","\\mathellipsis"),B(z,F,"…","\\ldots",!0),B(C,F,"…","\\ldots",!0),B(C,F,"⋰","\\iddots",!0),B(C,F,"⋯","\\@cdots",!0),B(C,F,"⋱","\\ddots",!0),B(C,U,"⋮","\\varvdots"),B(C,E,"ˊ","\\acute"),B(C,E,"`","\\grave"),B(C,E,"¨","\\ddot"),B(C,E,"…","\\dddot"),B(C,E,"….","\\ddddot"),B(C,E,"~","\\tilde"),B(C,E,"‾","\\bar"),B(C,E,"˘","\\breve"),B(C,E,"ˇ","\\check"),B(C,E,"^","\\hat"),B(C,E,"→","\\vec"),B(C,E,"˙","\\dot"),B(C,E,"˚","\\mathring"),B(C,$,"ı","\\imath",!0),B(C,$,"ȷ","\\jmath",!0),B(C,U,"ı","ı"),B(C,U,"ȷ","ȷ"),B(z,U,"ı","\\i",!0),B(z,U,"ȷ","\\j",!0),B(z,U,"ß","\\ss",!0),B(z,U,"æ","\\ae",!0),B(z,U,"œ","\\oe",!0),B(z,U,"ø","\\o",!0),B(C,$,"ø","\\o",!0),B(z,U,"Æ","\\AE",!0),B(z,U,"Œ","\\OE",!0),B(z,U,"Ø","\\O",!0),B(C,$,"Ø","\\O",!0),B(z,E,"ˊ","\\'"),B(z,E,"ˋ","\\`"),B(z,E,"ˆ","\\^"),B(z,E,"˜","\\~"),B(z,E,"ˉ","\\="),B(z,E,"˘","\\u"),B(z,E,"˙","\\."),B(z,E,"¸","\\c"),B(z,E,"˚","\\r"),B(z,E,"ˇ","\\v"),B(z,E,"¨",'\\"'),B(z,E,"˝","\\H"),B(C,E,"ˊ","\\'"),B(C,E,"ˋ","\\`"),B(C,E,"ˆ","\\^"),B(C,E,"˜","\\~"),B(C,E,"ˉ","\\="),B(C,E,"˘","\\u"),B(C,E,"˙","\\."),B(C,E,"¸","\\c"),B(C,E,"˚","\\r"),B(C,E,"ˇ","\\v"),B(C,E,"¨",'\\"'),B(C,E,"˝","\\H");const H={"--":!0,"---":!0,"``":!0,"''":!0};B(z,U,"–","--",!0),B(z,U,"–","\\textendash"),B(z,U,"—","---",!0),B(z,U,"—","\\textemdash"),B(z,U,"‘","`",!0),B(z,U,"‘","\\textquoteleft"),B(z,U,"’","'",!0),B(z,U,"’","\\textquoteright"),B(z,U,"“","``",!0),B(z,U,"“","\\textquotedblleft"),B(z,U,"”","''",!0),B(z,U,"”","\\textquotedblright"),B(C,U,"°","\\degree",!0),B(z,U,"°","\\degree"),B(z,U,"°","\\textdegree",!0),B(C,U,"£","\\pounds"),B(C,U,"£","\\mathsterling",!0),B(z,U,"£","\\pounds"),B(z,U,"£","\\textsterling",!0),B(C,U,"✠","\\maltese"),B(z,U,"✠","\\maltese"),B(C,U,"€","\\euro",!0),B(z,U,"€","\\euro",!0),B(z,U,"€","\\texteuro"),B(C,U,"©","\\copyright",!0),B(z,U,"©","\\textcopyright"),B(C,U,"𝛤","\\varGamma"),B(C,U,"𝛥","\\varDelta"),B(C,U,"𝛩","\\varTheta"),B(C,U,"𝛬","\\varLambda"),B(C,U,"𝛯","\\varXi"),B(C,U,"𝛱","\\varPi"),B(C,U,"𝛴","\\varSigma"),B(C,U,"𝛶","\\varUpsilon"),B(C,U,"𝛷","\\varPhi"),B(C,U,"𝛹","\\varPsi"),B(C,U,"𝛺","\\varOmega"),B(z,U,"𝛤","\\varGamma"),B(z,U,"𝛥","\\varDelta"),B(z,U,"𝛩","\\varTheta"),B(z,U,"𝛬","\\varLambda"),B(z,U,"𝛯","\\varXi"),B(z,U,"𝛱","\\varPi"),B(z,U,"𝛴","\\varSigma"),B(z,U,"𝛶","\\varUpsilon"),B(z,U,"𝛷","\\varPhi"),B(z,U,"𝛹","\\varPsi"),B(z,U,"𝛺","\\varOmega");const _='0123456789/@."';for(let e=0;e<_.length;e++){const t=_.charAt(e);B(C,U,t,t)}const V='0123456789!@*()-=+";:?/.,';for(let e=0;e<V.length;e++){const t=V.charAt(e);B(z,U,t,t)}const W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<W.length;e++){const t=W.charAt(e);B(C,$,t,t),B(z,U,t,t)}const X="ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";for(let e=0;e<X.length;e++){const t=X.charAt(e);B(C,$,t,t),B(z,U,t,t)}let Z="";for(let e=0;e<W.length;e++){Z=String.fromCharCode(55349,56320+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56372+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56424+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56580+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56736+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56788+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56840+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56944+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56632+e),B(C,$,Z,Z),B(z,U,Z,Z);const t=W.charAt(e);Z=String.fromCharCode(55349,56476+e),B(C,$,t,Z),B(z,U,t,Z)}for(let e=0;e<10;e++)Z=String.fromCharCode(55349,57294+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,57314+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,57324+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,57334+e),B(C,$,Z,Z),B(z,U,Z,Z);function Y(e,t,r,n){if(void 0===n&&"none"!==t){for(let n=e.length-1;n>=0;n--){const o=e[n];if("mstyle"===o.type&&o.attributes.mathcolor){const s=o.attributes.mathcolor,a=Y(o.children,t,r,s);a.type&&"mtable"!==a.type||e.splice(n,1,...a.children)}}}const o=n?"mstyle":"mrow",s=[];let a=[],i=[],l=0,c=!1;for(let r=0;r<e.length;r++){const m=e[r];if(m.type&&"mstyle"===m.type&&m.attributes.mathcolor)i.length>0&&a.push(new N.MathNode(o,i)),a.push(m),i=[];else if(m.attributes&&m.attributes.linebreak&&"newline"===m.attributes.linebreak){if(i.length>0){const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(new N.MathNode(o,i))}a.push(m),i=[];const e=new N.MathNode("mtd",a);s.push(new N.MathNode("mtr",[e])),a=[]}else if(i.push(m),m.type&&"mo"===m.type&&"="===t){if(1===m.children.length&&"="===m.children[0].text&&(l+=1,l>1)){i.pop();const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(e),i=[m]}}else if(m.type&&"mo"===m.type&&"tex"===t){if(c&&!m.attributes.form){const t=r<e.length-1?e[r+1]:null;let s=!0;if(!t||"mtext"!==t.type||!t.attributes.linebreak||"nobreak"!==t.attributes.linebreak)for(let t=r+1;t<e.length;t++){const n=e[t];if(!n.type||"mspace"!==n.type||n.attributes.linebreak&&"newline"===n.attributes.linebreak)break;i.push(n),r+=1,n.attributes&&n.attributes.linebreak&&"nobreak"===n.attributes.linebreak&&(s=!1)}if(s){const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(e),i=[]}c=!1}const t=m.attributes.form&&"prefix"===m.attributes.form;c=!(m.attributes.separator||t)}else c=!0}if(i.length>0){const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(e)}if(s.length>0){const e=new N.MathNode("mtd",a),t=new N.MathNode("mtr",[e]);s.push(t);const n=new N.MathNode("mtable",s);return r||(n.setAttribute("columnalign","left"),n.setAttribute("rowspacing","0em")),n}return N.newDocumentFragment(a)}const K=function(e,t,r){return!M[t][e]||!M[t][e].replace||55349===e.charCodeAt(0)||Object.prototype.hasOwnProperty.call(H,e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=M[t][e].replace),new N.TextNode(e)},J=e=>{if("mrow"!==e.type)return e;if(0===e.children.length)return e;if(!e.children[0].attributes||"mtext"!==e.children[0].type)return e;const t=e.children[0].attributes.mathvariant||"",r=new N.MathNode("mtext",[new N.TextNode(e.children[0].children[0].text)]);for(let n=1;n<e.children.length;n++){const o=e.children[n].attributes.mathvariant||"";if("mrow"===e.children[n].type){const o=e.children[n];for(let n=0;n<o.children.length;n++){if((o.children[n].attributes.mathvariant||"")!==t||"mtext"!==o.children[n].type)return e;r.children[0].text+=o.children[n].children[0].text}}else{if(o!==t||"mtext"!==e.children[n].type)return e;r.children[0].text+=e.children[n].children[0].text}}" "===r.children[0].text.charAt(0)&&(r.children[0].text=" "+r.children[0].text.slice(1));const n=r.children[0].text.length;return n>0&&" "===r.children[0].text.charAt(n-1)&&(r.children[0].text=r.children[0].text.slice(0,-1)+" "),r},Q=function(e){return 1===e.length?e[0]:new N.MathNode("mrow",e)},ee=e=>"atom"===e.type&&"rel"===e.family||"mclass"===e.type&&"mrel"===e.mclass,te=function(e,t,r){if(1===e.length){const n=ne(e[0],t);return r&&n instanceof k&&"mo"===n.type&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}const n=[];for(let r=0;r<e.length;r++){const o=ne(e[r],t);r<e.length-1&&ee(e[r])&&ee(e[r+1])&&o.setAttribute("rspace","0em"),r>0&&ee(e[r])&&ee(e[r-1])&&o.setAttribute("lspace","0em"),n.push(o)}return n},re=function(e,t,r){return Q(te(e,t,r))},ne=function(t,r){if(!t)return new N.MathNode("mrow");if(l[t.type]){return l[t.type](t,r)}throw new e("Got group of unknown type: '"+t.type+"'")},oe=e=>new N.MathNode("mtd",[],[],{padding:"0",width:"50%"});function se(e,t,r,n){let o=null;1===e.length&&"tag"===e[0].type&&(o=e[0].tag,e=e[0].body);const s=te(e,r),a=n.displayMode||n.annotate?"none":n.wrap,i=0===s.length?null:s[0];let l=1===s.length&&null===o&&i instanceof k&&("mstyle"!==i.type||!i.attributes.mathcolor)?s[0]:s.length>1&&"none"===a?new N.MathNode("mrow",s):Y(s,a,n.displayMode);if(o&&(l=((e,t,r,n)=>{t=re(t[0].body,r),(t=J(t)).classes.push("tml-tag"),e=new N.MathNode("mtd",[e]);const o=[oe(),e,oe()];n?(o[0].children.push(t),o[0].style.textAlign="-webkit-left"):(o[2].children.push(t),o[2].style.textAlign="-webkit-right");const s=new N.MathNode("mtr",o,["tml-tageqn"]),a=new N.MathNode("mtable",[s]);return a.style.width="100%",a.setAttribute("displaystyle","true"),a})(l,o,r,n.leqno)),n.annotate){const e=new N.MathNode("annotation",[new N.TextNode(t)]);e.setAttribute("encoding","application/x-tex"),l=new N.MathNode("semantics",[l,e])}if("none"!==a){const e=[];for(let t=0;t<l.children.length;t++){const r=new N.MathNode("math",[l.children[t]]);n.xml&&r.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),e.push(r)}return N.newDocumentFragment(e)}const c=new N.MathNode("math",[l]);return n.xml&&c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n.displayMode&&c.setAttribute("display","block"),c}const ae=(e,t)=>{const r=e.isStretchy?S(e.label):new N.MathNode("mo",[K(e.label,e.mode)]);"\\vec"===e.label?r.style.transform="scale(0.75) translate(10%, 30%)":(r.style.mathStyle="normal",r.style.mathDepth="0"),e.isStretchy||r.setAttribute("stretchy","false");return new N.MathNode("\\c"===e.label?"munder":"mover",[ne(e.base,t),r])},ie=new RegExp(["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map((e=>`\\${e}`)).join("|"));c({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=u(t[0]),n=!ie.test(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,base:r}},mathmlBuilder:ae}),c({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=u(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.`),{type:"accent",mode:n,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}},mathmlBuilder:ae}),c({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=S(e.label);r.style["math-depth"]=0;return new N.MathNode("munder",[ne(e.base,t),r])}});const le={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},ce=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],me=function(e){return"string"!=typeof e&&(e=e.unit),ce.indexOf(e)>-1},ue=e=>[1,.7,.5][Math.max(e-1,0)],pe=function(t,r){let n=t.number;if(r.maxSize[0]<0&&n>0)return{number:0,unit:"em"};const o=t.unit;switch(o){case"mm":case"cm":case"in":case"px":return n*le[o]>r.maxSize[1]?{number:r.maxSize[1],unit:"pt"}:{number:n,unit:o};case"em":case"ex":return"ex"===o&&(n*=.431),n=Math.min(n/ue(r.level),r.maxSize[0]),{number:s.round(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*le[o],r.maxSize[1]),{number:s.round(n),unit:"pt"};case"mu":return n=Math.min(n/18,r.maxSize[0]),{number:s.round(n),unit:"em"};default:throw new e("Invalid unit: '"+o+"'")}},de=e=>{const t=new N.MathNode("mspace");return t.setAttribute("width",e+"em"),t},he=(e,t=.3,r=0)=>{if(null==e&&0===r)return de(t);const n=e?[e]:[];return 0!==t&&n.unshift(de(t)),r>0&&n.push(de(r)),new N.MathNode("mrow",n)},ge=(e,t)=>(e/ue(t)).toFixed(4),fe=(e,t,r,n)=>{const o=S(e),s="eq"===e.slice(1,3),a="x"===e.charAt(1)?"1.75":"cd"===e.slice(2,4)?"3.0":s?"1.0":"2.0";o.setAttribute("minsize",String(a)+"em"),o.setAttribute("lspace","0"),o.setAttribute("rspace",s?"0.5em":"0");const i=n.withLevel(n.level<2?2:3),l=ge(a,i.level),c=ge(s?0:.3,i.level),m=ge(s?0:.3,i.level),u=t&&t.body&&(t.body.body||t.body.length>0)?he(ne(t,i),c,m):he(null,l,0),p=r&&r.body&&(r.body.body||r.body.length>0)?he(ne(r,i),c,m):he(null,l,0),d=new N.MathNode("munderover",[o,p,u]);return"3.0"===a&&(d.style.height="1em"),d};c({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\yields","\\yieldsLeft","\\mesomerism","\\longrightharpoonup","\\longleftharpoondown","\\\\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=[fe(e.name,e.body,e.below,t)];return r.unshift(de(.2778)),r.push(de(.2778)),new N.MathNode("mrow",r)}});const be={"\\xtofrom":["\\xrightarrow","\\xleftarrow"],"\\xleftrightharpoons":["\\xleftharpoonup","\\xrightharpoondown"],"\\xrightleftharpoons":["\\xrightharpoonup","\\xleftharpoondown"],"\\yieldsLeftRight":["\\yields","\\yieldsLeft"],"\\equilibrium":["\\longrightharpoonup","\\longleftharpoondown"],"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};function ye(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 we(e){const t=xe(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 xe(e){return e&&("atom"===e.type||Object.prototype.hasOwnProperty.call(O,e.type))?e:null}c({type:"stackedArrow",names:["\\xtofrom","\\xleftrightharpoons","\\xrightleftharpoons","\\yieldsLeftRight","\\equilibrium","\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},r,n){const o=r[0]?{type:"hphantom",mode:e.mode,body:r[0]}:null,s=n[0]?{type:"hphantom",mode:e.mode,body:n[0]}:null;return{type:"stackedArrow",mode:e.mode,name:t,body:r[0],upperArrowBelow:s,lowerArrowBody:o,below:n[0]}},mathmlBuilder(e,t){const r=be[e.name][0],n=be[e.name][1],o=fe(r,e.body,e.upperArrowBelow,t),s=fe(n,e.lowerArrowBody,e.below,t);let a;const i=new N.MathNode("mpadded",[o]);if(i.setAttribute("voffset","0.3em"),i.setAttribute("height","+0.3em"),i.setAttribute("depth","-0.3em"),"\\equilibriumLeft"===e.name){const e=new N.MathNode("mpadded",[s]);e.setAttribute("width","0.5em"),a=new N.MathNode("mpadded",[de(.2778),e,i,de(.2778)])}else i.setAttribute("width","\\equilibriumRight"===e.name?"0.5em":"0"),a=new N.MathNode("mpadded",[de(.2778),i,s,de(.2778)]);return a.setAttribute("voffset","-0.18em"),a.setAttribute("height","-0.18em"),a.setAttribute("depth","+0.18em"),a}});const ke={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},ve=e=>"textord"===e.type&&"@"===e.text;function Ae(e,t,r){const n=ke[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"},o={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[o],[])}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"}}}c({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){let r=new N.MathNode("mrow",[ne(e.label,t)]);return r=new N.MathNode("mpadded",[r]),r.setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new N.MathNode("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),c({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new N.MathNode("mrow",[ne(e.fragment,t)])}),c({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:t,token:r},n){const o=ye(n[0],"ordgroup").body;let s="";for(let e=0;e<o.length;e++){s+=ye(o[e],"textord").text}const a=parseInt(s);if(isNaN(a))throw new e(`\\@char has non-numeric argument ${s}`,r);return{type:"textord",mode:t.mode,text:String.fromCodePoint(a)}}});const Ne=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,Te=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,Se=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,qe=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Oe=/^[a-f0-9]{6}$/i,Me=e=>{let t=e.toString(16);return 1===t.length&&(t="0"+t),t},Be=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}'),Ce=(t,r)=>{let n="";if("HTML"===t){if(!Ne.test(r))throw new e("Invalid HTML input.");n=r}else if("RGB"===t){if(!Se.test(r))throw new e("Invalid RGB input.");r.split(",").map((e=>{n+=Me(Number(e.trim()))}))}else{if(!qe.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+=Me(255*r)}))}return"#"!==n.charAt(0)&&(n="#"+n),n},ze=(t,r,n)=>{const o=`\\\\color@${t}`;if(!Te.exec(t))throw new e("Invalid color: '"+t+"'",n);return Oe.test(t)?"#"+t:("#"===t.charAt(0)||(r.has(o)?t=r.get(o).tokens[0].text:Be[t]&&(t=Be[t])),t)},Ee=(e,t)=>{const r=te(e.body,t.withColor(e.color)),n=A(r);return n.setAttribute("mathcolor",e.color),n};c({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s="";if(o){const e=ye(r[0],"raw").string;s=Ce(o,e)}else s=ze(ye(r[0],"raw").string,e.gullet.macros,t);const a=r[1];return{type:"color",mode:e.mode,color:s,body:p(a)}},mathmlBuilder:Ee}),c({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,token:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s="";if(o){const e=ye(r[0],"raw").string;s=Ce(o,e)}else s=ze(ye(r[0],"raw").string,e.gullet.macros,t);e.gullet.macros.set("\\current@color",s);const a=e.parseExpression(!0,"\\color");return{type:"color",mode:e.mode,color:s,body:a}},mathmlBuilder:Ee}),c({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:t,funcName:r,token:n},o){const s=ye(o[0],"raw").string;if(!/^[A-Za-z]+$/.test(s))throw new e("Color name must be latin letters.",n);const a=ye(o[1],"raw").string;if(!["HTML","RGB","rgb"].includes(a))throw new e("Color model must be HTML, RGB, or rgb.",n);const i=ye(o[2],"raw").string,l=Ce(a,i);return t.gullet.macros.set(`\\\\color@${s}`,{tokens:[{text:l}],numArgs:0}),{type:"internal",mode:t.mode}}}),c({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:1,argTypes:["size"],allowedInText:!0},handler({parser:e},t,r){const n=r[0],o=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:o,size:n&&ye(n,"size").value}},mathmlBuilder(e,t){const r=new N.MathNode("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){const n=pe(e.size,t);r.setAttribute("height",n.number+n.unit)}return r}});const Ie={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Le=t=>{const r=t.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(r))throw new e("Expected a control sequence",t);return r},Fe=(e,t,r,n)=>{let o=e.gullet.macros.get(r.text);null==o&&(r.noexpand=!0,o={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,o,n)};c({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:t,funcName:r}){t.consumeSpaces();const n=t.fetch();if(Ie[n.text])return"\\global"!==r&&"\\\\globallong"!==r||(n.text=Ie[n.text]),ye(t.parseFunction(),"internal");throw new e("Invalid token after macro prefix",n)}}),c({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 o=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(o))throw new e("Expected a control sequence",n);let s,a=0;const i=[[]];for(;"{"!==t.gullet.future().text;)if(n=t.gullet.popToken(),"#"===n.text){if("{"===t.gullet.future().text){s=t.gullet.future(),i[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++,i.push([])}else{if("EOF"===n.text)throw new e("Expected a macro definition");i[a].push(n.text)}let{tokens:l}=t.gullet.consumeArg();return s&&l.unshift(s),"\\edef"!==r&&"\\xdef"!==r||(l=t.gullet.expandTokens(l),l.reverse()),t.gullet.macros.set(o,{tokens:l,numArgs:a,delimiters:i},r===Ie[r]),{type:"internal",mode:t.mode}}}),c({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=Le(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 Fe(e,r,n,"\\\\globallet"===t),{type:"internal",mode:e.mode}}}),c({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=Le(e.gullet.popToken()),n=e.gullet.popToken(),o=e.gullet.popToken();return Fe(e,r,o,"\\\\globalfuture"===t),e.gullet.pushToken(o),e.gullet.pushToken(n),{type:"internal",mode:e.mode}}}),c({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:t,funcName:r}){let n="";const o=t.gullet.popToken();"{"===o.text?(n=Le(t.gullet.popToken()),t.gullet.popToken()):n=Le(o);const s=t.gullet.isDefined(n);if(s&&"\\newcommand"===r)throw new e(`\\newcommand{${n}} attempting to redefine ${n}; use \\renewcommand`);if(!s&&"\\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:i}=t.gullet.consumeArg();return t.gullet.macros.set(n,{tokens:i,numArgs:a},!t.settings.strict),{type:"internal",mode:t.mode}}});const $e={"\\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}},Ge=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","\\llbracket","\\rrbracket","⟦","⟦","\\lBrace","\\rBrace","⦃","⦄","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."],De=[0,1.2,1.8,2.4,3];function Pe(t,r){"ordgroup"===t.type&&1===t.body.length&&"⁄"===t.body[0].text&&(t={type:"textord",text:"/",mode:"math"});const n=xe(t);if(n&&Ge.includes(n.text))return["<","\\lt"].includes(n.text)&&(n.text="⟨"),[">","\\gt"].includes(n.text)&&(n.text="⟩"),"/"===n.text&&(n.text="∕"),"\\backslash"===n.text&&(n.text="∖"),n;throw new e(n?`Invalid delimiter '${n.text}' after '${r.funcName}'`:`Invalid delimiter type '${t.type}'`,t)}c({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=Pe(t[0],e);return{type:"delimsizing",mode:e.parser.mode,size:$e[e.funcName].size,mclass:$e[e.funcName].mclass,delim:r.text}},mathmlBuilder:e=>{const t=[];"."===e.delim&&(e.delim=""),t.push(K(e.delim,e.mode));const r=new N.MathNode("mo",t);return"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),("∖"===e.delim||e.delim.indexOf("arrow")>-1)&&r.setAttribute("stretchy","true"),r.setAttribute("symmetric","true"),r.setAttribute("minsize",De[e.size]+"em"),r}}),c({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=t.parser.gullet.macros.get("\\current@color");if(n&&"string"!=typeof n)throw new e("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:t.parser.mode,delim:Pe(r[0],t).text,color:n}}}),c({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{const r=Pe(t[0],e),n=e.parser;++n.leftrightDepth;const o=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);const s=ye(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:o,left:r.text,right:s.delim,rightColor:s.color}},mathmlBuilder:(e,t)=>{!function(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}(e);const r=te(e.body,t);"."===e.left&&(e.left="");const n=new N.MathNode("mo",[K(e.left,e.mode)]);n.setAttribute("fence","true"),n.setAttribute("form","prefix"),("∖"===e.left||e.left.indexOf("arrow")>-1)&&n.setAttribute("stretchy","true"),r.unshift(n),"."===e.right&&(e.right="");const o=new N.MathNode("mo",[K(e.right,e.mode)]);return o.setAttribute("fence","true"),o.setAttribute("form","postfix"),("∖"===e.right||e.right.indexOf("arrow")>-1)&&o.setAttribute("stretchy","true"),e.rightColor&&o.setAttribute("mathcolor",e.rightColor),r.push(o),Q(r)}}),c({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=Pe(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=K(e.delim,e.mode),n=new N.MathNode("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 Re=e=>{const t=new N.MathNode("mspace");return t.setAttribute("width","3pt"),t},je=(e,t)=>{let r;switch(r=e.label.indexOf("colorbox")>-1?new N.MathNode("mpadded",[Re(),ne(e.body,t),Re()]):new N.MathNode("menclose",[ne(e.body,t)]),e.label){case"\\overline":r.setAttribute("notation","top"),r.style.padding="0.1em 0 0 0",r.style.borderTop="0.065em solid";break;case"\\underline":r.setAttribute("notation","bottom"),r.style.padding="0 0 0.1em 0",r.style.borderBottom="0.065em solid";break;case"\\cancel":r.setAttribute("notation","updiagonalstrike"),r.classes.push("cancel");break;case"\\bcancel":r.setAttribute("notation","downdiagonalstrike"),r.classes.push("bcancel");break;case"\\angl":r.setAttribute("notation","actuarial"),r.style.padding="0.03889em 0.03889em 0 0.03889em",r.style.borderTop="0.049em solid",r.style.borderRight="0.049em solid",r.style.marginRight="0.03889em";break;case"\\sout":r.setAttribute("notation","horizontalstrike"),r.style["text-decoration"]="line-through 0.08em solid";break;case"\\fbox":r.setAttribute("notation","box"),r.style={padding:"3pt",border:"1px solid"};break;case"\\fcolorbox":case"\\colorbox":{const t={padding:"3pt 0 3pt 0"};"\\fcolorbox"===e.label&&(t.border="0.06em solid "+String(e.borderColor)),r.style=t;break}case"\\xcancel":r.setAttribute("notation","updiagonalstrike downdiagonalstrike"),r.classes.push("xcancel")}return e.backgroundColor&&r.setAttribute("mathbackground",e.backgroundColor),r};c({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s="";if(o){const e=ye(r[0],"raw").string;s=Ce(o,e)}else s=ze(ye(r[0],"raw").string,e.gullet.macros);const a=r[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:s,body:a}},mathmlBuilder:je}),c({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s,a="";if(o){const e=ye(r[0],"raw").string,t=ye(r[0],"raw").string;a=Ce(o,e),s=Ce(o,t)}else a=ze(ye(r[0],"raw").string,e.gullet.macros),s=ze(ye(r[1],"raw").string,e.gullet.macros);const i=r[2];return{type:"enclose",mode:e.mode,label:t,backgroundColor:s,borderColor:a,body:i}},mathmlBuilder:je}),c({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]})}),c({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\sout","\\overline","\\underline"],props:{numArgs:1},handler({parser:e,funcName:t},r){const n=r[0];return{type:"enclose",mode:e.mode,label:t,body:n}},mathmlBuilder:je});const Ue={};function He({type:e,names:t,props:r,handler:n,mathmlBuilder:o}){const s={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:n};for(let e=0;e<t.length;++e)Ue[t[e]]=s;o&&(l[e]=o)}const _e=0,Ve=1,We=2,Xe=3;function Ze(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}const Ye=t=>{if(!t.parser.settings.displayMode)throw new e(`{${t.envName}} can be used only in display mode.`)},Ke=(e,t,r)=>{let n;const o=e.tags.shift();if(o){if(!o.body)return n=new N.MathNode("mtext",[],[]),n;n=re(o.body,t),n.classes=["tml-tag"]}else{if(e.envClasses.includes("multline")&&(e.leqno&&0!==r||!e.leqno&&r!==e.body.length-1))return n=new N.MathNode("mtext",[],[]),n;n=new N.MathNode("mtext",[],["tml-eqn"])}return n};function Je(t,{cols:r,envClasses:n,addEqnNum:o,singleRow:s,emptySingleRow:a,maxNumCols:i,leqno:l},c){t.gullet.beginGroup(),s||t.gullet.macros.set("\\cr","\\\\\\relax"),o&&(t.gullet.macros.set("\\tag","\\env@tag{\\text{#1}}"),t.gullet.macros.set("\\notag","\\env@notag"),t.gullet.macros.set("\\nonumber","\\env@notag")),t.gullet.beginGroup();let m=[];const u=[m],p=[],d=[];let h;const g=[];for(g.push(Ze(t));;){let r=t.parseExpression(!1,s?"\\end":"\\\\");if(o&&!h)for(let e=0;e<r.length;e++)if("envTag"===r[e].type||"noTag"===r[e].type){h="envTag"===r[e].type?r.splice(e,1)[0].body.body[0]:{body:null};break}t.gullet.endGroup(),t.gullet.beginGroup(),r={type:"ordgroup",mode:t.mode,body:r},m.push(r);const l=t.fetch().text;if("&"===l){if(i&&m.length===i){if(!n.includes("array"))throw new e(2===i?"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("\\end"===l){1===m.length&&0===r.body.length&&(u.length>1||!a)&&u.pop(),g.length<u.length+1&&g.push([]);break}if("\\\\"!==l)throw new e("Expected & or \\\\ or \\cr or \\end",t.nextToken);{let e;t.consume()," "!==t.gullet.future().text&&(e=t.parseSizeGroup(!0)),p.push(e?e.value:null),d.push(h),g.push(Ze(t)),m=[],h=null,u.push(m)}}}return t.gullet.endGroup(),t.gullet.endGroup(),d.push(h),{type:"array",mode:t.mode,body:u,cols:r,rowGaps:p,hLinesBeforeRow:g,envClasses:n,addEqnNum:o,scriptLevel:c,tags:d,leqno:l}}function Qe(e){return"d"===e.slice(0,1)?"display":"text"}const et={c:"center ",l:"left ",r:"right "},tt=e=>{const t=new N.MathNode("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},rt=function(e,t){const r=[],n=e.body.length,o=e.hLinesBeforeRow;for(let s=0;s<n;s++){const a=e.body[s],i=[],l="text"===e.scriptLevel?Ve:"script"===e.scriptLevel?We:_e;for(let r=0;r<a.length;r++){const o=new N.MathNode("mtd",[ne(a[r],t.withLevel(l))]);if(e.envClasses.includes("multline")){const e=0===s?"left":s===n-1?"right":"center";o.setAttribute("columnalign",e),"center"!==e&&(o.style.textAlign="-webkit-"+e)}i.push(o)}if(e.addEqnNum){i.unshift(tt(e)),i.push(tt(e));const r=Ke(e,t.withLevel(l),s);e.leqno?(i[0].children.push(r),i[0].style.textAlign="-webkit-left"):(i[i.length-1].children.push(r),i[i.length-1].style.textAlign="-webkit-right")}const c=new N.MathNode("mtr",i,[]);0===s&&o[0].length>0&&(2===o[0].length?c.classes.push("tml-top-double"):c.classes.push(o[0][0]?"tml-top-dashed":"tml-top-solid")),o[s+1].length>0&&(2===o[s+1].length?c.classes.push("tml-hline-double"):c.classes.push(o[s+1][0]?"tml-hline-dashed":"tml-hline-solid")),r.push(c)}let s=new N.MathNode("mtable",r);e.envClasses.length>0&&(s.classes=e.envClasses.map((e=>"tml-"+e))),"display"===e.scriptLevel&&s.setAttribute("displaystyle","true"),(e.addEqnNum||e.envClasses.includes("multline"))&&(s.style.width="100%");let a="";if(e.cols&&e.cols.length>0){const t=e.cols;let r=!1,n=0,o=t.length;for(;"separator"===t[n].type;)n+=1;for(;"separator"===t[o-1].type;)o-=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 s.children)t.children[0].style.borderLeft=e}let i=e.addEqnNum?0:-1;for(let e=n;e<o;e++)if("align"===t[e].type){const n=et[t[e].align];a+=n,i+=1;for(const e of s.children)"center"!==n.trim()&&i<e.children.length&&(e.children[i].style.textAlign="-webkit-"+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 s.children)i<e.children.length&&(e.children[i].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 s.children)t.children[t.children.length-1].style.borderRight=e,t.children[t.children.length-1].style.paddingRight="0.4em"}}return e.addEqnNum&&(a="left "+(a.length>0?a:"center ")+"right "),a&&s.setAttribute("columnalign",a.trim()),e.envClasses.includes("small")&&(s=new N.MathNode("mstyle",[s]),s.setAttribute("scriptlevel","1")),s},nt=function(t,r){-1===t.envName.indexOf("ed")&&Ye(t);const n=[],o=Je(t.parser,{cols:n,addEqnNum:"align"===t.envName||"alignat"===t.envName,emptySingleRow:!0,envClasses:["jot","abut"],maxNumCols:"split"===t.envName?2:void 0,leqno:t.parser.settings.leqno},"display");let s,a=0;if(r[0]&&"ordgroup"===r[0].type){let e="";for(let t=0;t<r[0].body.length;t++){e+=ye(r[0].body[t],"textord").text}s=Number(e),a=2*s}const i=!a;o.body.forEach((function(t){if(i)a<t.length&&(a=t.length);else{const r=t.length/2;if(s<r)throw new e(`Too many math in a row: expected ${s}, but got ${r}`,t[0])}}));for(let e=0;e<a;++e){let t="r";e%2==1&&(t="l"),n[e]={type:"align",align:t}}return"split"===t.envName||(t.envName.indexOf("ed")>-1?o.envClasses.push("aligned"):i?o.envClasses[1]="align*"===t.envName?"align-star":"align":o.envClasses.push("aligned")),o};He({type:"array",names:["array","darray"],props:{numArgs:1},handler(t,r){const n=(xe(r[0])?[r[0]]:ye(r[0],"ordgroup").body).map((function(t){const r=we(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)})),o={cols:n,envClasses:["array"],maxNumCols:n.length};return Je(t.parser,o,Qe(t.envName))},mathmlBuilder:rt}),He({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 o={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(),o.cols=[]}}const s=Je(t.parser,o,"text");return s.cols=new Array(s.body[0].length).fill({type:"align",align:n}),r?{type:"leftright",mode:t.mode,body:[s],left:r[0],right:r[1],rightColor:void 0}:s},mathmlBuilder:rt}),He({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){const t=Je(e.parser,{type:"small"},"script");return t.envClasses=["small"],t},mathmlBuilder:rt}),He({type:"array",names:["subarray"],props:{numArgs:1},handler(t,r){const n=(xe(r[0])?[r[0]]:ye(r[0],"ordgroup").body).map((function(t){const r=we(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 o={cols:n,envClasses:["small"]};if(o=Je(t.parser,o,"script"),o.body.length>0&&o.body[0].length>1)throw new e("{subarray} can contain only one column");return o},mathmlBuilder:rt}),He({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=Je(e.parser,{cols:[],envClasses:["cases"]},Qe(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:rt}),He({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:nt,mathmlBuilder:rt}),He({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:nt,mathmlBuilder:rt}),He({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){"gathered"!==e.envName&&Ye(e);const t={cols:[],envClasses:["jot","abut"],addEqnNum:"gather"===e.envName,emptySingleRow:!0,leqno:e.parser.settings.leqno};return Je(e.parser,t,"display")},mathmlBuilder:rt}),He({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){Ye(e);const t={addEqnNum:"equation"===e.envName,emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return Je(e.parser,t,"display")},mathmlBuilder:rt}),He({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){Ye(e);const t={addEqnNum:"multline"===e.envName,maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return Je(e.parser,t,"display")},mathmlBuilder:rt}),He({type:"array",names:["CD"],props:{numArgs:0},handler:t=>(Ye(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 o=[n];for(let i=0;i<r.length;i++){const l=r[i];let c={type:"styling",body:[],mode:"math",scriptLevel:"display"};for(let r=0;r<l.length;r++)if(ve(l[r])){n.push(c),r+=1;const o=we(l[r]).text,i=new Array(2);if(i[0]={type:"ordgroup",mode:"math",body:[]},i[1]={type:"ordgroup",mode:"math",body:[]},"=|.".indexOf(o)>-1);else{if(!("<>AV".indexOf(o)>-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<l.length;c++){if(a=o,("mathord"===(s=l[c]).type||"atom"===s.type)&&s.text===a){n=!1,r=c;break}if(ve(l[c]))throw new e("Missing a "+o+" character to complete a CD arrow.",l[c]);i[t].body.push(l[c])}if(n)throw new e("Missing a "+o+" character to complete a CD arrow.",l[r])}}const m=Ae(o,i,t);n.push(m),c={type:"styling",body:[],mode:"math",scriptLevel:"display"}}else c.body.push(l[r]);i%2==0?n.push(c):n.shift(),n=[],o.push(n)}var s,a;return o.pop(),t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:"math",body:o,envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(o.length+1).fill([])}}(t.parser)),mathmlBuilder:rt}),c({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 ot=Ue;c({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:t,funcName:r},n){const o=n[0];if("ordgroup"!==o.type)throw new e("Invalid environment name",o);let s="";for(let e=0;e<o.body.length;++e)s+=ye(o.body[e],"textord").text;if("\\begin"===r){if(!Object.prototype.hasOwnProperty.call(ot,s))throw new e("No such environment: "+s,o);const r=ot[s],{args:n,optArgs:a}=t.parseArguments("\\begin{"+s+"}",r),i={mode:t.mode,envName:s,parser:t},l=r.handler(i,n,a);t.expect("\\end",!1);const c=t.nextToken,m=ye(t.parseFunction(),"environment");if(m.name!==s)throw new e(`Mismatch: \\begin{${s}} matched by \\end{${m.name}}`,c);return l}return{type:"environment",mode:t.mode,name:s,nameGroup:o}}}),c({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 N.MathNode("mrow")}),c({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new N.MathNode("mrow")});const st=(e,t)=>{const r=e.font,n=t.withFont(r),o=ne(e.body,n);if(0===o.children.length)return o;if("boldsymbol"===r&&["mo","mpadded"].includes(o.type))return o.style.fontWeight="bold",o;let s="mo"===o.children[0].type;for(let e=1;e<o.children.length;e++){"mo"===o.children[e].type&&"boldsymbol"===r&&(o.children[e].style.fontWeight="bold"),"mi"!==o.children[e].type&&(s=!1);"normal"!==(o.children[e].attributes&&o.children[e].attributes.mathvariant||"")&&(s=!1)}if(!s)return o;const a=o.children[0];for(let e=1;e<o.children.length;e++)a.children.push(o.children[e].children[0]);if(o.attributes.mathcolor&&(a.attributes.mathcolor=o.attributes.mathcolor),a.attributes.mathvariant&&"normal"===a.attributes.mathvariant){const e=new N.MathNode("mtext",new N.TextNode("​"));return new N.MathNode("mrow",[e,a])}return a},at={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};c({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\up@greek","\\boldsymbol","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\oldstylenums","\\Bbb","\\bm","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=u(r[0]);let o=t;return o in at&&(o=at[o]),{type:"font",mode:e.mode,font:o.slice(1),body:n}},mathmlBuilder:st}),c({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:r},n)=>{const{mode:o}=e,s=e.parseExpression(!0,r);return{type:"font",mode:o,font:`math${t.slice(1)}`,body:{type:"ordgroup",mode:e.mode,body:s}}},mathmlBuilder:st});const it=["display","text","script","scriptscript"],lt={auto:-1,display:0,text:0,script:1,scriptscript:2},ct=(e,t)=>{const r="auto"===e.scriptLevel?t.incrementLevel():"display"===e.scriptLevel?t.withLevel(Ve):"text"===e.scriptLevel?t.withLevel(We):t.withLevel(Xe);let n=new N.MathNode("mfrac",[ne(e.numer,r),ne(e.denom,r)]);if(e.hasBarLine){if(e.barSize){const r=pe(e.barSize,t);n.setAttribute("linethickness",r.number+r.unit)}}else n.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new N.MathNode("mo",[new N.TextNode(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(n),null!=e.rightDelim){const r=new N.MathNode("mo",[new N.TextNode(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}n=Q(t)}return"auto"!==e.scriptLevel&&(n=new N.MathNode("mstyle",[n]),n.setAttribute("displaystyle",String("display"===e.scriptLevel)),n.setAttribute("scriptlevel",lt[e.scriptLevel])),n};c({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],o=r[1];let s=!1,a=null,i=null,l="auto";switch(t){case"\\dfrac":case"\\frac":case"\\tfrac":s=!0;break;case"\\\\atopfrac":s=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":a="(",i=")";break;case"\\\\bracefrac":a="\\{",i="\\}";break;case"\\\\brackfrac":a="[",i="]";break;default:throw new Error("Unrecognized genfrac command")}switch(t){case"\\dfrac":case"\\dbinom":l="display";break;case"\\tfrac":case"\\tbinom":l="text"}return{type:"genfrac",mode:e.mode,continued:!1,numer:n,denom:o,hasBarLine:s,leftDelim:a,rightDelim:i,scriptLevel:l,barSize:null}},mathmlBuilder:ct}),c({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:({parser:e,funcName:t},r)=>{const n=r[0],o=r[1];return{type:"genfrac",mode:e.mode,continued:!0,numer:n,denom:o,hasBarLine:!0,leftDelim:null,rightDelim:null,scriptLevel:"display",barSize:null}}}),c({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 mt=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};c({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],o=u(t[0]),s="atom"===o.type&&"open"===o.family?mt(o.text):null,a=u(t[1]),i="atom"===a.type&&"close"===a.family?mt(a.text):null,l=ye(t[2],"size");let c,m=null;l.isBlank?c=!0:(m=l.value,c=m.number>0);let p="auto",d=t[3];if("ordgroup"===d.type){if(d.body.length>0){const e=ye(d.body[0],"textord");p=it[Number(e.text)]}}else d=ye(d,"textord"),p=it[Number(d.text)];return{type:"genfrac",mode:e.mode,numer:r,denom:n,continued:!1,hasBarLine:c,barSize:m,leftDelim:s,rightDelim:i,scriptLevel:p}},mathmlBuilder:ct}),c({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:ye(n[0],"size").value,token:r})}),c({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:t},r)=>{const n=r[0],o=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e}(ye(r[1],"infix").barSize),s=r[2],a=o.number>0;return{type:"genfrac",mode:e.mode,numer:n,denom:s,continued:!1,hasBarLine:a,barSize:o,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:ct});c({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler:({parser:e,funcName:t},r)=>({type:"horizBrace",mode:e.mode,label:t,isOver:/^\\over/.test(t),base:r[0]}),mathmlBuilder:(e,t)=>{const r=S(e.label);return r.style["math-depth"]=0,new N.MathNode(e.isOver?"mover":"munder",[ne(e.base,t),r])}}),c({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:({parser:t,token:r},n)=>{const o=n[1],s=ye(n[0],"url").url;if(!t.settings.isTrusted({command:"\\href",url:s}))throw new e('Function "\\href" is not trusted',r);return{type:"href",mode:t.mode,href:s,body:p(o)}},mathmlBuilder:(e,t)=>{let r=re(e.body,t);return r instanceof k||(r=new k("mrow",[r])),r.setAttribute("href",e.href),r}}),c({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:({parser:t,token:r},n)=>{const o=ye(n[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:o}))throw new e('Function "\\url" is not trusted',r);const s=[];for(let e=0;e<o.length;e++){let t=o[e];"~"===t&&(t="\\textasciitilde"),s.push({type:"textord",mode:"text",text:t})}const a={type:"text",mode:t.mode,font:"\\texttt",body:s};return{type:"href",mode:t.mode,href:o,body:p(a)}}}),c({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:t,funcName:r,token:n},o)=>{const s=ye(o[0],"raw").string,a=o[1];if(t.settings.strict)throw new e(`Function "${r}" is disabled in strict mode`,n);let i;const l={};switch(r){case"\\class":l.class=s,i={command:"\\class",class:s};break;case"\\id":l.id=s,i={command:"\\id",id:s};break;case"\\style":l.style=s,i={command:"\\style",style:s};break;case"\\data":{const t=s.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");l["data-"+n[0].trim()]=n[1].trim()}i={command:"\\data",attributes:l};break}default:throw new Error("Unrecognized html command")}if(!t.settings.isTrusted(i))throw new e(`Function "${r}" is not trusted`,n);return{type:"html",mode:t.mode,attributes:l,body:p(a)}},mathmlBuilder:(e,t)=>{const r=re(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 ut=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(!me(n))throw new e("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};c({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:t,token:r},n,o)=>{let s={number:0,unit:"em"},a={number:.9,unit:"em"},i={number:0,unit:"em"},l="";if(o[0]){const t=ye(o[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":l=t;break;case"width":s=ut(t);break;case"height":a=ut(t);break;case"totalheight":i=ut(t);break;default:throw new e("Invalid key: '"+n[0]+"' in \\includegraphics.")}}}}const c=ye(n[0],"url").url;if(""===l&&(l=c,l=l.replace(/^.*[\\/]/,""),l=l.substring(0,l.lastIndexOf("."))),!t.settings.isTrusted({command:"\\includegraphics",url:c}))throw new e('Function "\\includegraphics" is not trusted',r);return{type:"includegraphics",mode:t.mode,alt:l,width:s,height:a,totalheight:i,src:c}},mathmlBuilder:(e,t)=>{const r=pe(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 o=0;e.width.number>0&&(o=pe(e.width,t));const s={height:r.number+n.number+"em"};o.number>0&&(s.width=o.number+o.unit),n.number>0&&(s.verticalAlign=-n.number+n.unit);const a=new x(e.src,e.alt,s);return a.height=r,a.depth=n,new N.MathNode("mtext",[a])}}),c({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:t,funcName:r,token:n},o){const s=ye(o[0],"size");if(t.settings.strict){const o="m"===r[1],a="mu"===s.value.unit;if(o){if(!a)throw new e(`LaTeX's ${r} supports only mu units, not ${s.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:s.value}},mathmlBuilder(e,t){const r=pe(e.dimension,t),n="em"===r.unit?pt(r.number):"";if("text"===e.mode&&n.length>0){const e=new N.TextNode(n);return new N.MathNode("mtext",[e])}{const e=new N.MathNode("mspace");return e.setAttribute("width",r.number+r.unit),r.number<0&&(e.style.marginLeft=r.number+r.unit),e}}});const pt=function(e){return e>=.05555&&e<=.05556?" ":e>=.1666&&e<=.1667?" ":e>=.2222&&e<=.2223?" ":e>=.2777&&e<=.2778?"  ":""},dt=/[^A-Za-z_0-9-]/g;c({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(dt,"")}),mathmlBuilder(e,t){const r=new N.MathNode("mrow",[],["tml-label"]);return e.string.length>0&&r.setAttribute("id",e.string),r}});const ht=["\\clap","\\llap","\\rlap"];c({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:t,funcName:r,token:n},o)=>{if(ht.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 s=o[0];return{type:"lap",mode:t.mode,alignment:r,body:s}},mathmlBuilder:(e,t)=>{let r;if("llap"===e.alignment){const n=te(p(e.body),t),o=new N.MathNode("mphantom",n);r=new N.MathNode("mpadded",[o]),r.setAttribute("width","0px")}const n=ne(e.body,t);let o;if("llap"===e.alignment?(n.style.position="absolute",n.style.right="0",n.style.bottom="0",o=new N.MathNode("mpadded",[r,n])):o=new N.MathNode("mpadded",[n]),"rlap"===e.alignment)e.body.body.length>0&&"genfrac"===e.body.body[0].type&&o.setAttribute("lspace","0.16667em");else{const t="llap"===e.alignment?"-1":"-0.5";o.setAttribute("lspace",t+"width"),"llap"===e.alignment?o.style.position="relative":(o.style.display="flex",o.style.justifyContent="center")}return o.setAttribute("width","0px"),o}}),c({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},r){const n=t.mode;t.switchMode("math");const o="\\("===e?"\\)":"$",s=t.parseExpression(!1,o);return t.expect(o),t.switchMode(n),{type:"ordgroup",mode:t.mode,body:s}}}),c({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,r){throw new e(`Mismatched ${t.funcName}`,r)}});c({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:p(t[0]),text:p(t[1]),script:p(t[2]),scriptscript:p(t[3])}),mathmlBuilder:(e,t)=>{const r=((e,t)=>{switch(t.level){case _e:return e.display;case Ve:return e.text;case We:return e.script;case Xe:return e.scriptscript;default:return e.text}})(e,t);return re(r,t)}});const gt=["text","textord","mathord","atom"],ft=e=>{const t=new N.MathNode("mspace");return t.setAttribute("width",e+"em"),t};function bt(e,t){let r;const n=te(e.body,t);if("minner"===e.mclass)r=new N.MathNode("mpadded",n);else if("mord"===e.mclass)e.isCharacterBox||"mathord"===n[0].type?(r=n[0],r.type="mi"):r=new N.MathNode("mi",n);else{r=new N.MathNode("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 N.MathNode("mrow",n);const o=t.level<2;"mrow"===r.type?o&&("mbin"===e.mclass?(r.children.unshift(ft(.2222)),r.children.push(ft(.2222))):"mrel"===e.mclass?(r.children.unshift(ft(.2778)),r.children.push(ft(.2778))):"mpunct"===e.mclass?r.children.push(ft(.1667)):"minner"===e.mclass&&(r.children.unshift(ft(.0556)),r.children.push(ft(.0556)))):"mbin"===e.mclass?(r.attributes.lspace=o?"0.2222em":"0",r.attributes.rspace=o?"0.2222em":"0"):"mrel"===e.mclass?(r.attributes.lspace=o?"0.2778em":"0",r.attributes.rspace=o?"0.2778em":"0"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace=o?"0.1667em":"0"):"mopen"===e.mclass||"mclose"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0em"):"minner"===e.mclass&&o&&(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}c({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],o=s.isCharacterBox(n);let a=!0;const i={type:"mathord",text:"",mode:e.mode},l=n.body?n.body:[n];for(const e of l){if(!gt.includes(e.type)){a=!1;break}e.text?i.text+=e.text:e.body&&e.body.map((e=>{i.text+=e.text}))}return{type:"mclass",mode:e.mode,mclass:"m"+t.slice(5),body:p(a?i:n),isCharacterBox:o,mustPromote:a}},mathmlBuilder:bt});const yt=e=>{const t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};c({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:yt(t[0]),body:p(t[1]),isCharacterBox:s.isCharacterBox(t[1])})}),c({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:t},r){const n=r[1],o=r[0],s={type:"op",mode:n.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,stack:!0,suppressBaseShift:"\\stackrel"!==t,body:p(n)};return{type:"supsub",mode:o.mode,base:s,sup:"\\underset"===t?null:o,sub:"\\underset"===t?o:null}},mathmlBuilder:bt});const wt=(e,t,r)=>{if(!e)return r;const n=ne(e,t);return"mrow"===n.type&&0===n.children.length?r:n};c({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:t,funcName:r,token:n},o){if(0===o[2].body.length)throw new e(r+"cannot parse an empty base.");const s=o[2].body[0];if(t.settings.strict&&"\\sideset"===r&&!s.symbol)throw new e("The base of \\sideset must be a big operator. Try \\prescript.");if(o[0].body.length>0&&"supsub"!==o[0].body[0].type||o[1].body.length>0&&"supsub"!==o[1].body[0].type)throw new e("\\sideset can parse only subscripts and superscripts in its first two arguments",n);const a=o[0].body.length>0?o[0].body[0]:null,i=o[1].body.length>0?o[1].body[0]:null;return a||i?a?{type:"multiscript",mode:t.mode,isSideset:"\\sideset"===r,prescripts:a,postscripts:i,base:s}:{type:"styling",mode:t.mode,scriptLevel:"text",body:[{type:"supsub",mode:t.mode,base:s,sup:i.sup,sub:i.sub}]}:s},mathmlBuilder(e,t){const r=ne(e.base,t),n=new N.MathNode("mprescripts"),o=new N.MathNode("none");let s=[];const a=wt(e.prescripts.sub,t,o),i=wt(e.prescripts.sup,t,o);if(e.isSideset&&(a.setAttribute("style","text-align: left;"),i.setAttribute("style","text-align: left;")),e.postscripts){s=[r,wt(e.postscripts.sub,t,o),wt(e.postscripts.sup,t,o),n,a,i]}else s=[r,n,a,i];return new N.MathNode("mmultiscripts",s)}}),c({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){const r=s.isCharacterBox(t[0]);let n;if(r)n=p(t[0]),"\\"===n[0].text.charAt(0)&&(n[0].text=M.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 te(e.body,t)[0]}return re(e.body,t,!0)}});const xt=["textord","mathord","atom"],kt=["\\smallint"],vt=["textord","mathord","ordgroup","close","leftright"],At=["}","\\left","\\middle","\\right"],Nt=e=>e.length>0&&(Ge.includes(e)||$e[e]||At.includes(e)),Tt=(e,t)=>{let r;if(e.symbol)r=new k("mo",[K(e.name,e.mode)]),kt.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false");else if(e.body)r=new k("mo",te(e.body,t));else if(r=new k("mi",[new v(e.name.slice(1))]),!e.parentIsSupSub){const t=[r,new k("mo",[K("⁡","text")])];if(e.needsLeadingSpace){const e=new k("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new k("mspace");e.setAttribute("width","0.1667em"),t.push(e)}r=new k("mrow",t)}return r},St={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨅":"\\bigsqcap","⨆":"\\bigsqcup"};c({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcap","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],props:{numArgs:0},handler:({parser:e,funcName:t},r)=>{let n=t;return 1===n.length&&(n=St[n]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:Tt}),c({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{const r=t[0],n=r.body?r.body:[r],o=1===n.length&&xt.includes(n[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:o,stack:!1,name:o?n[0].text:null,body:o?null:p(r)}},mathmlBuilder:Tt});const qt={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint","∱":"\\intclockwise","∲":"\\varointclockwise","⨌":"\\iiiint","⨍":"\\intbar","⨎":"\\intBar","⨏":"\\fint","⨒":"\\rppolint","⨓":"\\scpolint","⨕":"\\pointint","⨖":"\\sqint","⨗":"\\intlarhk","⨘":"\\intx","⨙":"\\intcap","⨚":"\\intcup"};c({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:Nt(n),needsLeadingSpace:r.length>0&&vt.includes(r),name:t}},mathmlBuilder:Tt}),c({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:Nt(n),needsLeadingSpace:r.length>0&&vt.includes(r),name:t}},mathmlBuilder:Tt}),c({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},handler({parser:e,funcName:t}){let r=t;return 1===r.length&&(r=qt[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:Tt});const Ot={};function Mt(e,t){Ot[e]=t}const Bt=["}","\\left","\\middle","\\right"];c({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=r[0],o=e.prevAtomType,s=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:p(n),alwaysHandleSupSub:"\\operatornamewithlimits"===t,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:(a=s,a.length>0&&(Ge.includes(a)||$e[a]||Bt.includes(a))),needsLeadingSpace:o.length>0&&vt.includes(o)};var a},mathmlBuilder:(e,t)=>{let r,n=te(e.body,t.withFont("mathrm")),o=!0;for(let e=0;e<n.length;e++){const t=n[e];if(t instanceof N.MathNode)switch(t.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(t.attributes.width){const r=t.attributes.width.replace("em",""),s=pt(Number(r));""===s?o=!1:n[e]=new N.MathNode("mtext",[new N.TextNode(s)])}break;case"mo":{const e=t.children[0];1===t.children.length&&e instanceof N.TextNode?e.text=e.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):o=!1;break}default:o=!1}else o=!1}if(o){const e=n.map((e=>e.toText())).join("");n=[new N.TextNode(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 N.MathNode("mrow",n);{const e=new N.MathNode("mo",[K("⁡","text")]);return N.newDocumentFragment([n[0],e])}}if(o?(r=new N.MathNode("mi",n),r.setAttribute("mathvariant","normal")):r=new N.MathNode("mrow",n),!e.parentIsSupSub){const t=[r,new N.MathNode("mo",[K("⁡","text")])];if(e.needsLeadingSpace){const e=new N.MathNode("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new N.MathNode("mspace");e.setAttribute("width","0.1667em"),t.push(e)}return N.newDocumentFragment(t)}return r}}),Mt("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),m({type:"ordgroup",mathmlBuilder:(e,t)=>re(e.body,t,!0)}),c({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"phantom",mode:e.mode,body:p(r)}},mathmlBuilder:(e,t)=>{const r=te(e.body,t);return new N.MathNode("mphantom",r)}}),c({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=te(p(e.body),t),n=new N.MathNode("mphantom",r),o=new N.MathNode("mpadded",[n]);return o.setAttribute("height","0px"),o.setAttribute("depth","0px"),o}}),c({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=te(p(e.body),t),n=new N.MathNode("mphantom",r),o=new N.MathNode("mpadded",[n]);return o.setAttribute("width","0px"),o}}),c({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:p(t[0])}),mathmlBuilder(e,t){const r=te(e.body,t),n=A(r);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});const Ct=e=>e>=0?"+":"-",zt=(e,t)=>{const r=t.withLevel(Ve),n=new N.MathNode("mpadded",[ne(e.body,r)]),o=pe(e.dy,t);n.setAttribute("voffset",o.number+o.unit);const s=Math.abs(o.number);return n.setAttribute("height",Ct(o.number)+s+o.unit),n.setAttribute("depth",Ct(-o.number)+s+o.unit),n};c({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},r){const n=ye(r[0],"size").value;"\\lower"===t&&(n.number*=-1);const o=r[1];return{type:"raise",mode:e.mode,dy:n,body:o}},mathmlBuilder:zt}),c({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},r){const n=ye(r[0],"size").value,o=r[1];return{type:"raise",mode:e.mode,dy:n,body:o}},mathmlBuilder:zt}),c({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(dt,"")}),mathmlBuilder(e,t){const r="\\ref"===e.funcName?["tml-ref"]:["tml-ref","tml-eqref"],n=new N.MathNode("mtext",[new N.TextNode("")],r);return n.setAttribute("href","#"+e.string),n}}),c({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),c({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"]},handler({parser:e},t,r){const n=r[0],o=ye(t[0],"size"),s=ye(t[1],"size");return{type:"rule",mode:e.mode,shift:n&&ye(n,"size").value,width:o.value,height:s.value}},mathmlBuilder(e,t){const r=pe(e.width,t),n=pe(e.height,t),o=e.shift?pe(e.shift,t):{number:0,unit:"em"},s=t.color&&t.getColor()||"black",a=new N.MathNode("mspace");if(r.number>0&&n.number>0&&a.setAttribute("mathbackground",s),a.setAttribute("width",r.number+r.unit),a.setAttribute("height",n.number+n.unit),0===o.number)return a;const i=new N.MathNode("mpadded",[a]);return o.number>=0?i.setAttribute("height","+"+o.number+o.unit):(i.setAttribute("height",o.number+o.unit),i.setAttribute("depth","+"+-o.number+o.unit)),i.setAttribute("voffset",o.number+o.unit),i}});const Et={"\\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};c({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 o=r.parseExpression(!1,e);return{type:"sizing",mode:r.mode,funcName:t,body:o}},mathmlBuilder:(e,t)=>{const r=t.withFontSize(Et[e.funcName]),n=te(e.body,r),o=A(n),s=(Et[e.funcName]/t.fontSize).toFixed(4);return o.setAttribute("mathsize",s+"em"),o}}),c({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,r)=>{let n=!1,o=!1;const s=r[0]&&ye(r[0],"ordgroup");if(s){let e="";for(let t=0;t<s.body.length;++t){if(e=s.body[t].text,"t"===e)n=!0;else{if("b"!==e){n=!1,o=!1;break}o=!0}}}else n=!0,o=!0;const a=t[0];return{type:"smash",mode:e.mode,body:a,smashHeight:n,smashDepth:o}},mathmlBuilder:(e,t)=>{const r=new N.MathNode("mpadded",[ne(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),c({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,r){const n=r[0],o=t[0];return{type:"sqrt",mode:e.mode,body:o,index:n}},mathmlBuilder(e,t){const{body:r,index:n}=e;return n?new N.MathNode("mroot",[ne(r,t),ne(n,t.incrementLevel())]):new N.MathNode("msqrt",[ne(r,t)])}});const It={display:0,text:1,script:2,scriptscript:3},Lt={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};c({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:r},n){const o=r.parseExpression(!0,e),s=t.slice(1,t.length-5);return{type:"styling",mode:r.mode,scriptLevel:s,body:o}},mathmlBuilder(e,t){const r=t.withLevel(It[e.scriptLevel]),n=te(e.body,r),o=A(n),s=Lt[e.scriptLevel];return o.setAttribute("scriptlevel",s[0]),o.setAttribute("displaystyle",s[1]),o}});const Ft=/^m(over|under|underover)$/;m({type:"supsub",mathmlBuilder(e,t){let r,n,o=!1,s=!1,a=!1;e.base&&"horizBrace"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(o=!0,r=e.base.isOver)),!e.base||e.base.stack||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0,s=!e.base.symbol,a=e.base.needsLeadingSpace);const i=e.base&&e.base.stack?[ne(e.base.body[0],t)]:[ne(e.base,t)],l=t.inSubOrSup();let c;if(e.sub&&i.push(ne(e.sub,l)),e.sup&&i.push(ne(e.sup,l)),o)c=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;c=r&&("op"===r.type&&r.limits||"multiscript"===r.type)&&(t.level===_e||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.level===_e||r.limits)?"munderover":"msubsup"}else{const r=e.base;c=r&&"op"===r.type&&r.limits&&(t.level===_e||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===_e)?"munder":"msub"}else{const r=e.base;c=r&&"op"===r.type&&r.limits&&(t.level===_e||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===_e)?"mover":"msup"}let m=new N.MathNode(c,i);if(s){const e=new N.MathNode("mo",[K("⁡","text")]);if(a){const t=new N.MathNode("mspace");t.setAttribute("width","0.1667em"),m=N.newDocumentFragment([t,m,e])}else m=N.newDocumentFragment([m,e])}else Ft.test(c)&&(m=new N.MathNode("mrow",[m]));return m}});const $t=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],Gt=["\\Rsh","\\Lsh","\\restriction"];m({type:"atom",mathmlBuilder(e,t){const r=new N.MathNode("mo",[K(e.text,e.mode)]);return"punct"===e.family?r.setAttribute("separator","true"):"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")):"\\mid"===e.text?(r.setAttribute("lspace","0.22em"),r.setAttribute("rspace","0.22em"),r.setAttribute("stretchy","false")):"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||Gt.includes(e)})(e.text)?r.setAttribute("stretchy","false"):$t.includes(e.text)?r.setAttribute("mathsize","70%"):":"===e.text&&(r.attributes.lspace="0.2222em",r.attributes.rspace="0.2222em"),r}});const Dt={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace",oldstylenums:"oldstylenums"},Pt=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"mathtt":return"monospace";case"oldstylenums":return"oldstylenums"}let o=e.text;return M[n][o]&&M[n][o].replace&&(o=M[n][o].replace),Object.prototype.hasOwnProperty.call(Dt,r)?Dt[r]:null},Rt=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),jt=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Ut=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),Ht=Object.freeze({"ϵ":119527,"ϑ":119564,"ϰ":119534,"φ":119577,"ϱ":119535,"ϖ":119563}),_t=Object.freeze({"ϵ":119643,"ϑ":119680,"ϰ":119650,"φ":119693,"ϱ":119651,"ϖ":119679}),Vt=Object.freeze({"ϵ":119701,"ϑ":119738,"ϰ":119708,"φ":119751,"ϱ":119709,"ϖ":119737}),Wt=Object.freeze({"ϵ":119759,"ϑ":119796,"ϰ":119766,"φ":119809,"ϱ":119767,"ϖ":119795}),Xt=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>Rt[e]||119899,"script-bold":e=>119951,fraktur:e=>jt[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>Ut[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=>Rt[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=>"∇"===e?111802:119575,italic:e=>"∇"===e?111860:119633,"bold-italic":e=>"∇"===e?111802:119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>"∇"===e?111976:119749,"sans-serif-bold":e=>"∇"===e?111976:119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>"∇"===e?112034: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=>Ht[e]||-51,italic:e=>0,"bold-italic":e=>_t[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Vt[e]||116,"sans-serif-bold":e=>Vt[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Wt[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}}),Zt=(e,t)=>{const r=e.codePointAt(0),n=64<r&&r<91?"upperCaseLatin":96<r&&r<123?"lowerCaseLatin":912<r&&r<938||"∇"===e?"upperCaseGreek":944<r&&r<970||"ϕ"===e?"lowerCaseGreek":120545<r&&r<120572||Ht[e]?"varGreek":47<r&&r<58?"numeral":"other";return"other"===n?e:String.fromCodePoint(r+Xt[n][t](e))},Yt=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:"ᴢ"}),Kt=/^\d(?:[\d,.]*\d)?$/,Jt=/[A-Ba-z]/,Qt=(e,t)=>{const r=new N.MathNode("mn",[e]),n=new N.MathNode("mstyle",[r]);return n.style["font-style"]="italic",n.style["font-family"]="Cambria, 'Times New Roman', serif","bold-italic"===t&&(n.style["font-weight"]="bold"),n};m({type:"mathord",mathmlBuilder(e,t){const r=K(e.text,e.mode,t),n=r.text.codePointAt(0),o=912<n&&n<938?"normal":"italic",s=Pt(e,t)||o;if("script"===s)return r.text=Zt(r.text,s),new N.MathNode("mi",[r],[t.font]);"italic"!==s&&(r.text=Zt(r.text,s));let a=new N.MathNode("mi",[r]);return"normal"===s&&(a.setAttribute("mathvariant","normal"),1===r.text.length&&(a=new N.MathNode("mrow",[a]))),a}}),m({type:"textord",mathmlBuilder(e,t){let r=e.text;const n=r.codePointAt(0);"textsc"===t.fontFamily&&96<n&&n<123&&(r=Yt[r]);const o=K(r,e.mode,t),s=Pt(e,t)||"normal";let a;if("text"===e.mode){if(("italic"===s||"bold-italic"===s)&&Kt.test(e.text))return Qt(o,s);"normal"!==s&&(o.text=Zt(o.text,s)),a=new N.MathNode("mtext",[o])}else if(Kt.test(e.text))if("oldstylenums"===s){const e=new N.MathNode("mstyle",[o],["oldstylenums"]);a=new N.MathNode("mn",[e])}else{if("italic"===s||"bold-italic"===s)return Qt(o,s);"normal"!==s&&(o.text=o.text.split("").map((e=>Zt(e,s))).join("")),a=new N.MathNode("mn",[o])}else if("\\prime"===e.text)a=new N.MathNode("mo",[o]),a.classes.push("tml-prime");else{const e=o.text;"italic"!==s&&(o.text=Zt(o.text,s)),a=new N.MathNode("mi",[o]),o.text===e&&Jt.test(e)&&a.setAttribute("mathvariant","italic")}return a}});const er={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},tr={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};m({type:"spacing",mathmlBuilder(t,r){let n;if(Object.prototype.hasOwnProperty.call(tr,t.text))n=new N.MathNode("mtext",[new N.TextNode(" ")]);else{if(!Object.prototype.hasOwnProperty.call(er,t.text))throw new e(`Unknown type of space "${t.text}"`);n=new N.MathNode("mo"),"\\nobreak"===t.text&&n.setAttribute("linebreak","nobreak")}return n}}),m({type:"tag"});const rr={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},nr={"\\textbf":"textbf","\\textmd":"textmd"},or={"\\textit":"textit","\\textup":"textup"};c({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textsc","\\textbf","\\textmd","\\textit","\\textup"],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:p(n),font:t}},mathmlBuilder(e,t){const r=((e,t)=>{const r=e.font;return r?rr[r]?t.withTextFontFamily(rr[r]):nr[r]?t.withTextFontWeight(nr[r]):t.withTextFontShape(or[r]):t})(e,t),n=re(e.body,r);return J(n)}}),c({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(t,r,n){throw new e("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(e,t){const r=new N.TextNode(sr(e)),n=new N.MathNode("mtext",[r]);return n.setAttribute("mathvariant","monospace"),n}});const sr=e=>e.body.replace(/ /g,e.star?"␣":" "),ar=i;class ir{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 ir(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class lr{constructor(e,t){this.text=e,this.loc=t}range(e,t){return new lr(t,ir.range(this,e))}}const cr=new RegExp("[̀-ͯ]+$"),mr="([ \r\n\t]+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|(number|[!-\\[\\]-‧‪-퟿豈-￿][̀-ͯ]*|[\ud800-\udbff][\udc00-\udfff][̀-ͯ]*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|(\\\\[a-zA-Z@]+)[ \r\n\t]*|\\\\[^\ud800-\udfff])";class ur{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(mr.replace("number|",t.strict?"":"\\d(?:[\\d,.]*\\d)?|"),"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 lr("EOF",new ir(this,r,r));const n=this.tokenRegex.exec(t);if(null===n||n.index!==r)throw new e(`Unexpected character: '${t[r]}'`,new lr(t[r],new ir(this,r,r+1)));const o=n[6]||n[3]||(n[2]?"\\ ":" ");if(14===this.catcodes[o]){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 lr(o,new ir(this,r,this.tokenRegex.lastIndex))}}class pr{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 dr=Ot;Mt("\\noexpand",(function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}})),Mt("\\expandafter",(function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}})),Mt("\\@firstoftwo",(function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}})),Mt("\\@secondoftwo",(function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}})),Mt("\\@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}})),Mt("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Mt("\\TextOrMath",(function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}}));const hr={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},gr=e=>{const t=e.future().text;return"EOF"===t?[null,""]:[hr[t.charAt(0)],t]},fr=(e,t,r)=>{for(let n=1;n<t.length;n++){e*=r,e+=hr[t.charAt(n)]}return e};Mt("\\char",(function(t){let r,n=t.popToken(),o="";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])o=n.text.charCodeAt(1);else{if("EOF"===n.text)throw new e("\\char` missing argument");o=n.text.charCodeAt(0)}else r=10;if(r){let s,a=n.text;if(o=hr[a.charAt(0)],null==o||o>=r)throw new e(`Invalid base-${r} digit ${n.text}`);for(o=fr(o,a,r),[s,a]=gr(t);null!=s&&s<r;)o*=r,o+=s,o=fr(o,a,r),t.popToken(),[s,a]=gr(t)}return`\\@char{${o}}`})),Mt("\\surd","\\sqrt{\\vphantom{|}}"),Mt("\\hbox","\\text{#1}"),Mt("/","{⁄}"),Mt("\\long",""),Mt("\\bgroup","{"),Mt("\\egroup","}"),Mt("~","\\nobreakspace"),Mt("\\lq","`"),Mt("\\rq","'"),Mt("\\aa","\\r a"),Mt("\\Bbbk","\\Bbb{k}"),Mt("\\mathstrut","\\vphantom{(}"),Mt("\\underbar","\\underline{\\text{#1}}"),Mt("\\vdots","\\mathord{\\varvdots\\rule{0pt}{15pt}}"),Mt("⋮","\\vdots"),Mt("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Mt("\\boxed","\\fbox{$\\displaystyle{#1}$}"),Mt("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Mt("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Mt("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");const br={",":"\\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","\\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"};Mt("\\dots",(function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in br?t=br[r]:("\\not"===r.slice(0,4)||r in M.math&&["bin","rel"].includes(M.math[r].group))&&(t="\\dotsb"),t}));const yr={")":!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};Mt("\\dotso",(function(e){return e.future().text in yr?"\\ldots\\,":"\\ldots"})),Mt("\\dotsc",(function(e){const t=e.future().text;return t in yr&&","!==t?"\\ldots\\,":"\\ldots"})),Mt("\\cdots",(function(e){return e.future().text in yr?"\\@cdots\\,":"\\@cdots"})),Mt("\\dotsb","\\cdots"),Mt("\\dotsm","\\cdots"),Mt("\\dotsi","\\!\\cdots"),Mt("\\idotsint","\\dotsi"),Mt("\\dotsx","\\ldots\\,"),Mt("\\DOTSI","\\relax"),Mt("\\DOTSB","\\relax"),Mt("\\DOTSX","\\relax"),Mt("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Mt("\\,","{\\tmspace+{3mu}{.1667em}}"),Mt("\\thinspace","\\,"),Mt("\\>","\\mskip{4mu}"),Mt("\\:","{\\tmspace+{4mu}{.2222em}}"),Mt("\\medspace","\\:"),Mt("\\;","{\\tmspace+{5mu}{.2777em}}"),Mt("\\thickspace","\\;"),Mt("\\!","{\\tmspace-{3mu}{.1667em}}"),Mt("\\negthinspace","\\!"),Mt("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),Mt("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),Mt("\\enspace","\\kern.5em "),Mt("\\enskip","\\hskip.5em\\relax"),Mt("\\quad","\\hskip1em\\relax"),Mt("\\qquad","\\hskip2em\\relax"),Mt("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Mt("\\tag@paren","\\tag@literal{({#1})}"),Mt("\\tag@literal",(t=>{if(t.macros.get("\\df@tag"))throw new e("Multiple \\tag");return"\\def\\df@tag{\\text{#1}}"})),Mt("\\bmod","\\mathbin{\\text{mod}}"),Mt("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Mt("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Mt("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Mt("\\newline","\\\\\\relax"),Mt("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),Mt("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),Mt("\\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}}"),Mt("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Mt("\\@hspace","\\hskip #1\\relax"),Mt("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Mt("\\colon",'\\mathpunct{\\char"3a}'),Mt("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),Mt("\\ordinarycolon",'\\char"3a'),Mt("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),Mt("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),Mt("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),Mt("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),Mt("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),Mt("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),Mt("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),Mt("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Mt("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Mt("\\ratio","\\vcentcolon"),Mt("\\coloncolon","\\dblcolon"),Mt("\\colonequals","\\coloneqq"),Mt("\\coloncolonequals","\\Coloneqq"),Mt("\\equalscolon","\\eqqcolon"),Mt("\\equalscoloncolon","\\Eqqcolon"),Mt("\\colonminus","\\coloneq"),Mt("\\coloncolonminus","\\Coloneq"),Mt("\\minuscolon","\\eqcolon"),Mt("\\minuscoloncolon","\\Eqcolon"),Mt("\\coloncolonapprox","\\Colonapprox"),Mt("\\coloncolonsim","\\Colonsim"),Mt("\\notni","\\mathrel{\\char`∌}"),Mt("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Mt("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Mt("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Mt("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Mt("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),Mt("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),Mt("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),Mt("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),Mt("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),Mt("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Mt("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Mt("\\plim","\\DOTSB\\operatorname*{plim}"),Mt("\\bra","\\mathinner{\\langle{#1}|}"),Mt("\\ket","\\mathinner{|{#1}\\rangle}"),Mt("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Mt("\\Bra","\\left\\langle#1\\right|"),Mt("\\Ket","\\left|#1\\right\\rangle");const wr=e=>t=>{const r=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,s=t.consumeArg().tokens,a=t.macros.get("|"),i=t.macros.get("\\|");t.macros.beginGroup();const l=t=>r=>{e&&(r.macros.set("|",a),o.length&&r.macros.set("\\|",i));let s=t;if(!t&&o.length){"|"===r.future().text&&(r.popToken(),s=!0)}return{tokens:s?o:n,numArgs:0}};t.macros.set("|",l(!1)),o.length&&t.macros.set("\\|",l(!0));const c=t.consumeArg().tokens,m=t.expandTokens([...s,...c,...r]);return t.macros.endGroup(),{tokens:m.reverse(),numArgs:0}};Mt("\\bra@ket",wr(!1)),Mt("\\bra@set",wr(!0)),Mt("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),Mt("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),Mt("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),Mt("\\angln","{\\angl n}"),Mt("\\odv","\\@ifstar\\odv@next\\odv@numerator"),Mt("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),Mt("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),Mt("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");const xr=e=>{const t=e[0][0].text,r=(e=>{let t="";for(let r=e.length-1;r>-1;r--)t+=e[r].text;return t})(e[1]).split(","),n=String(r.length),o="1"===n?"\\partial":`\\partial^${n}`;let s="";return r.map((e=>{s+="\\partial "+e.trim()+"\\,"})),[t,o,s.replace(/\\,$/,"")]};Mt("\\pdv@numerator",(function(e){const[t,r,n]=xr(e.consumeArgs(2));return`\\frac{${r} ${t}}{${n}}`})),Mt("\\pdv@next",(function(e){const[t,r,n]=xr(e.consumeArgs(2));return`\\frac{${r}}{${n}} ${t}`})),Mt("\\upalpha","\\up@greek{\\alpha}"),Mt("\\upbeta","\\up@greek{\\beta}"),Mt("\\upgamma","\\up@greek{\\gamma}"),Mt("\\updelta","\\up@greek{\\delta}"),Mt("\\upepsilon","\\up@greek{\\epsilon}"),Mt("\\upzeta","\\up@greek{\\zeta}"),Mt("\\upeta","\\up@greek{\\eta}"),Mt("\\uptheta","\\up@greek{\\theta}"),Mt("\\upiota","\\up@greek{\\iota}"),Mt("\\upkappa","\\up@greek{\\kappa}"),Mt("\\uplambda","\\up@greek{\\lambda}"),Mt("\\upmu","\\up@greek{\\mu}"),Mt("\\upnu","\\up@greek{\\nu}"),Mt("\\upxi","\\up@greek{\\xi}"),Mt("\\upomicron","\\up@greek{\\omicron}"),Mt("\\uppi","\\up@greek{\\pi}"),Mt("\\upalpha","\\up@greek{\\alpha}"),Mt("\\uprho","\\up@greek{\\rho}"),Mt("\\upsigma","\\up@greek{\\sigma}"),Mt("\\uptau","\\up@greek{\\tau}"),Mt("\\upupsilon","\\up@greek{\\upsilon}"),Mt("\\upphi","\\up@greek{\\phi}"),Mt("\\upchi","\\up@greek{\\chi}"),Mt("\\uppsi","\\up@greek{\\psi}"),Mt("\\upomega","\\up@greek{\\omega}"),Mt("\\invamp",'\\mathbin{\\char"214b}'),Mt("\\parr",'\\mathbin{\\char"214b}'),Mt("\\with",'\\mathbin{\\char"26}'),Mt("\\multimapinv",'\\mathrel{\\char"27dc}'),Mt("\\multimapboth",'\\mathrel{\\char"29df}'),Mt("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),Mt("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),Mt("\\coh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}\n{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}'),Mt("\\incoh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}\n{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}'),Mt("\\standardstate","\\text{\\tiny\\char`⦵}");const kr={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class vr{constructor(e,t,r){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new pr(dr,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new ur(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 lr("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 o=this.future();let s,a=0,i=0;do{if(s=this.popToken(),r.push(s),"{"===s.text)++a;else if("}"===s.text){if(--a,-1===a)throw new e("Extra }",s)}else if("EOF"===s.text)throw new e("Unexpected end of input in a macro argument, expected '"+(t&&n?t[i]:"}")+"'",s);if(t&&n)if((0===a||1===a&&"{"===t[i])&&s.text===t[i]){if(++i,i===t.length){r.splice(-i,i);break}}else i=0}while(0!==a||n);return"{"===o.text&&"}"===r[r.length-1].text&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:o,end:s}}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,o=r.noexpand?null:this._getExpansion(n);if(null==o||t&&o.unexpandable){if(t&&null==o&&"\\"===n[0]&&!this.isDefined(n))throw new e("Undefined control sequence: "+n);return this.pushToken(r),r}if(this.expansionCount++,this.expansionCount>this.settings.maxExpand)throw new e("Too many expansions: infinite loop or need to increase maxExpand setting");let s=o.tokens;const a=this.consumeArgs(o.numArgs,o.delimiters);if(o.numArgs){s=s.slice();for(let t=s.length-1;t>=0;--t){let r=s[t];if("#"===r.text){if(0===t)throw new e("Incomplete placeholder at end of macro body",r);if(r=s[--t],"#"===r.text)s.splice(t+1,1);else{if(!/^[1-9]$/.test(r.text))throw new e("Not a valid argument number",r);s.splice(t,2,...a[+r.text-1])}}}}return this.pushTokens(s),s}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;){const e=this.expandOnce();if(e instanceof lr)return e.treatAsRelax&&(e.text="\\relax"),this.stack.pop()}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new lr(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;){const e=this.expandOnce(!0);e instanceof lr&&(e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(this.stack.pop()))}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 ur(r,this.settings),n=[];let o=t.lex();for(;"EOF"!==o.text;)n.push(o),o=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(ar,e)||Object.prototype.hasOwnProperty.call(M.math,e)||Object.prototype.hasOwnProperty.call(M.text,e)||Object.prototype.hasOwnProperty.call(kr,e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(ar,e)&&!ar[e].primitive}}const Ar=[];[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}].forEach((e=>e.blocks.forEach((e=>Ar.push(...e)))));const Nr=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Tr=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","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"});var Sr={"́":{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"}},qr={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","ḋ":"ḋ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","Ḋ":"Ḋ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"Ȯ","Ȱ":"Ȱ","Ő":"Ő","Ṕ":"Ṕ","Ṗ":"Ṗ","Ŕ":"Ŕ","Ř":"Ř","Ṙ":"Ṙ","Ś":"Ś","Ṥ":"Ṥ","Š":"Š","Ṧ":"Ṧ","Ŝ":"Ŝ","Ṡ":"Ṡ","Ť":"Ť","Ṫ":"Ṫ","Ú":"Ú","Ù":"Ù","Ü":"Ü","Ǘ":"Ǘ","Ǜ":"Ǜ","Ǖ":"Ǖ","Ǚ":"Ǚ","Ũ":"Ũ","Ṹ":"Ṹ","Ū":"Ū","Ṻ":"Ṻ","Ŭ":"Ŭ","Ǔ":"Ǔ","Û":"Û","Ů":"Ů","Ű":"Ű","Ṽ":"Ṽ","Ẃ":"Ẃ","Ẁ":"Ẁ","Ẅ":"Ẅ","Ŵ":"Ŵ","Ẇ":"Ẇ","Ẍ":"Ẍ","Ẋ":"Ẋ","Ý":"Ý","Ỳ":"Ỳ","Ÿ":"Ÿ","Ỹ":"Ỹ","Ȳ":"Ȳ","Ŷ":"Ŷ","Ẏ":"Ẏ","Ź":"Ź","Ž":"Ž","Ẑ":"Ẑ","Ż":"Ż","ά":"ά","ὰ":"ὰ","ᾱ":"ᾱ","ᾰ":"ᾰ","έ":"έ","ὲ":"ὲ","ή":"ή","ὴ":"ὴ","ί":"ί","ὶ":"ὶ","ϊ":"ϊ","ΐ":"ΐ","ῒ":"ῒ","ῑ":"ῑ","ῐ":"ῐ","ό":"ό","ὸ":"ὸ","ύ":"ύ","ὺ":"ὺ","ϋ":"ϋ","ΰ":"ΰ","ῢ":"ῢ","ῡ":"ῡ","ῠ":"ῠ","ώ":"ώ","ὼ":"ὼ","Ύ":"Ύ","Ὺ":"Ὺ","Ϋ":"Ϋ","Ῡ":"Ῡ","Ῠ":"Ῠ","Ώ":"Ώ","Ὼ":"Ὼ"};const Or=/^\d(?:[\d,.]*\d)?$/;class Mr{constructor(e,t,r=!1){this.mode="math",this.gullet=new vr(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 lr("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){const r=[];for(;;){"math"===this.mode&&this.consumeSpaces();const n=this.fetch();if(-1!==Mr.endOfExpression.indexOf(n.text))break;if(t&&n.text===t)break;if(e&&ar[n.text]&&ar[n.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&(r.push(o),this.prevAtomType="atom"===o.type?o.family:o.type)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(t){let r,n=-1;for(let o=0;o<t.length;o++)if("infix"===t[o].type){if(-1!==n)throw new e("only one infix operator per group",t[o].token);n=o,r=t[o].replaceWith}if(-1!==n&&r){let e,o;const s=t.slice(0,n),a=t.slice(n+1);let i;return e=1===s.length&&"ordgroup"===s[0].type?s[0]:{type:"ordgroup",mode:this.mode,body:s},o=1===a.length&&"ordgroup"===a[0].type?a[0]:{type:"ordgroup",mode:this.mode,body:a},i="\\\\abovefrac"===r?this.callFunction(r,[e,t[n],o],[]):this.callFunction(r,[e,o],[]),[i]}return t}handleSupSubscript(t){const r=this.fetch(),n=r.text;this.consume(),this.consumeSpaces();const o=this.parseGroup(t);if(!o)throw new e("Expected group after '"+n+"'",r);return o}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("text"===this.mode)return r;let n,o;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(o)throw new e("Double subscript",t);o=this.handleSupSubscript("subscript")}else if("'"===t.text){if(n)throw new e("Double superscript",t);const r={type:"textord",mode:this.mode,text:"\\prime"},o=[r];for(this.consume();"'"===this.fetch().text;)o.push(r),this.consume();"^"===this.fetch().text&&o.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:o}}else{if(!Tr[t.text])break;{const e=Nr.test(t.text),r=[];for(r.push(new lr(Tr[t.text])),this.consume();;){const t=this.fetch().text;if(!Tr[t])break;if(Nr.test(t)!==e)break;r.unshift(new lr(Tr[t])),this.consume()}const s=this.subparse(r);e?o={type:"ordgroup",mode:"math",body:s}:n={type:"ordgroup",mode:"math",body:s}}}}return n||o?r&&"multiscript"===r.type&&!r.postscripts?(r.postscripts={sup:n,sub:o},r):{type:"supsub",mode:this.mode,base:r,sup:n,sub:o}:r}parseFunction(t,r){const n=this.fetch(),o=n.text,s=ar[o];if(!s)return null;if(this.consume(),r&&"atom"!==r&&!s.allowedInArgument)throw new e("Got function '"+o+"' with no arguments"+(r?" as "+r:""),n);if("text"===this.mode&&!s.allowedInText)throw new e("Can't use function '"+o+"' in text mode",n);if("math"===this.mode&&!1===s.allowedInMath)throw new e("Can't use function '"+o+"' in math mode",n);const a=this.prevAtomType,{args:i,optArgs:l}=this.parseArguments(o,s);return this.prevAtomType=a,this.callFunction(o,i,l,n,t)}callFunction(t,r,n,o,s){const a={funcName:t,parser:this,token:o,breakOnTokenText:s},i=ar[t];if(i&&i.handler)return i.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 o=[],s=[];for(let a=0;a<n;a++){let n=r.argTypes&&r.argTypes[a];const i=a<r.numOptionalArgs;(r.primitive&&null==n||"sqrt"===r.type&&1===a&&null==s[0])&&(n="primitive");const l=this.parseGroupOfType(`argument to '${t}'`,n,i);if(i)s.push(l);else{if(null==l)throw new e("Null argument, please report this as a bug");o.push(l)}}return{args:o,optArgs:s}}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)break;this.consume()}}parseStringGroup(e,t){const r=this.gullet.scanArgument(t);if(null==r)return null;let n,o="";for(;"EOF"!==(n=this.fetch()).text;)o+=n.text,this.consume();return this.consume(),r.text=o,r}parseRegexGroup(t,r){const n=this.fetch();let o,s=n,a="";for(;"EOF"!==(o=this.fetch()).text&&t.test(a+o.text);)s=o,a+=s.text,this.consume();if(""===a)throw new e("Invalid "+r+": '"+n.text+"'",n);return n.range(s,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 o=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(r.text);if(!o)throw new e("Invalid size: '"+r.text+"'",r);const s={number:+(o[1]+o[2]),unit:o[3]};if(!me(s))throw new e("Invalid unit: '"+s.unit+"'",r);return{type:"size",mode:this.mode,value:s,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 o=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();const s={type:"ordgroup",mode:this.mode,loc:r.loc,body:o};return t&&this.switchMode(n),s}parseGroup(e,t){const r=this.fetch(),n=r.text;let o;if("{"===n||"\\begingroup"===n||"\\toggle"===n){this.consume();const e="{"===n?"}":"\\begingroup"===n?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();const t=this.parseExpression(!1,e),s=this.fetch();this.expect(e),this.gullet.endGroup(),o={type:"\\endtoggle"===s.text?"toggle":"ordgroup",mode:this.mode,loc:ir.range(r,s),body:t,semisimple:"\\begingroup"===n||void 0}}else o=this.parseFunction(t,e)||this.parseSymbol(),null!=o||"\\"!==n[0]||Object.prototype.hasOwnProperty.call(kr,n)||(o=this.formatUnsupportedCmd(n),this.consume());return o}formLigatures(e){let t=e.length-1;for(let r=0;r<t;++r){const n=e[r],o=n.text;"-"===o&&"-"===e[r+1].text&&(r+1<t&&"-"===e[r+2].text?(e.splice(r,3,{type:"textord",mode:"text",loc:ir.range(n,e[r+2]),text:"---"}),t-=2):(e.splice(r,2,{type:"textord",mode:"text",loc:ir.range(n,e[r+1]),text:"--"}),t-=1)),"'"!==o&&"`"!==o||e[r+1].text!==o||(e.splice(r,2,{type:"textord",mode:"text",loc:ir.range(n,e[r+1]),text:o+o}),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(qr,r[0])&&!M[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=qr[r[0]]+r.slice(1)}const n=cr.exec(r);let o;if(n&&(r=r.substring(0,n.index),"i"===r?r="ı":"j"===r&&(r="ȷ")),M[this.mode][r]){const e=M[this.mode][r].group,n=ir.range(t);let s;if(Object.prototype.hasOwnProperty.call(q,e)){const t=e;s={type:"atom",mode:this.mode,family:t,loc:n,text:r}}else s={type:e,mode:this.mode,loc:n,text:r};o=s}else{if(!this.strict&&Or.test(r))return this.consume(),{type:"textord",mode:this.mode,loc:ir.range(t),text:r};if(!(r.charCodeAt(0)>=128))return null;if(this.settings.strict){if(!function(e){for(let t=0;t<Ar.length;t+=2)if(e>=Ar[t]&&e<=Ar[t+1])return!0;return!1}(r.charCodeAt(0)))throw new e(`Unrecognized Unicode character "${r[0]}" (${r.charCodeAt(0)})`,t);if("math"===this.mode)throw new e(`Unicode text character "${r[0]}" used in math mode`,t)}o={type:"textord",mode:"text",loc:ir.range(t),text:r}}if(this.consume(),n)for(let r=0;r<n[0].length;r++){const s=n[0][r];if(!Sr[s])throw new e(`Unknown accent ' ${s}'`,t);const a=Sr[s][this.mode]||Sr[s].text;if(!a)throw new e(`Accent ${s} unsupported in ${this.mode} mode`,t);o={type:"accent",mode:this.mode,loc:ir.range(t),label:a,isStretchy:!1,isShifty:!0,base:o}}return o}}const Br=function(t,r){if(!("string"==typeof t||t instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new Mr(t,r);delete n.gullet.macros.current["\\df@tag"];let o=n.parse();if(!(o.length>0&&o[0].type&&"array"===o[0].type&&o[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"),o=[{type:"tag",mode:"text",body:o,tag:n.parse()}]}return o},Cr=[2,2,3,3];class zr{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 zr(t)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:Cr[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}}let Er=function(e,t,r){t.textContent="";const n="MATH"===t.tagName;n&&(r.wrap="none");const o=Ir(e,r);n||o.children.length>1?(t.textContent="",o.children.forEach((e=>{t.appendChild(e.toNode())}))):t.appendChild(o.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."),Er=function(){throw new e("Temml doesn't work in quirks mode.")});const Ir=function(t,r){const n=new a(r);try{const e=Br(t,n);return se(e,t,new zr({level:n.displayMode?_e:Ve,maxSize:n.maxSize}),n)}catch(r){return function(t,r,n){if(n.throwOnError||!(t instanceof e))throw t;const o=new y(["temml-error"],[new w(r+"\n"+t.toString())]);return o.style.color=n.errorColor,o.style.whiteSpace="pre-line",o}(r,t,n)}};return{version:"0.9.1",render:Er,renderToString:function(e,t){return Ir(e,t).toMarkup()},postProcess:function(e){const t={};let r=0;const n=e.getElementsByClassName("tml-tageqn");for(const e of n){const n=e.getElementsByClassName("tml-eqn");n.length>0&&(r+=1,n[0].id="tml-eqn-"+r);const o=e.getElementsByClassName("tml-label");if(0!==o.length)if(n.length>0)t[o[0].id]=String(r);else{const r=e.getElementsByClassName("tml-tag");r.length>0&&(t[o[0].id]=r[0].textContent)}}[...e.getElementsByClassName("tml-ref")].forEach((e=>{let r=t[e.getAttribute("href").slice(1)];-1===e.className.indexOf("tml-eqref")&&(r=r.replace(/^\(/,""),r=r.replace(/\($/,"")),"("!==r.charAt(0)&&(r="("+r),")"!==r.slice(-1)&&(r+=")"),e.textContent=r}))},ParseError:e,definePreamble:function(e,t){const r=new a(t);if(r.macros={},!("string"==typeof e||e instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new Mr(e,r,!0);delete n.gullet.macros.current["\\df@tag"];return n.parse()},__parse:function(e,t){const r=new a(t);return Br(e,r)},__renderToMathMLTree:Ir,__defineSymbol:B,__defineMacro:Mt}}();
1
+ var temml=function(){"use strict";class e{constructor(t,r){let n,o=" "+t;const s=r&&r.loc;if(s&&s.start<=s.end){const e=s.lexer.input;n=s.start;const t=s.end;n===e.length?o+=" at end of input: ":o+=" at position "+(n+1)+": ";const r=e.slice(n,t).replace(/[^]/g,"$&̲");let a,i;a=n>15?"…"+e.slice(n-15,n):e.slice(0,n),i=t+15<e.length?e.slice(t,t+15)+"…":e.slice(t),o+=a+r+i}const a=new Error(o);return a.name="ParseError",a.__proto__=e.prototype,a.position=n,a}}e.prototype.__proto__=Error.prototype;const t=/([A-Z])/g,r={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},n=/[&><"']/g;const o=function(e){return"ordgroup"===e.type||"color"===e.type?1===e.body.length?o(e.body[0]):e:"font"===e.type?o(e.body):e};var s={deflt:function(e,t){return void 0===e?t:e},escape:function(e){return String(e).replace(n,(e=>r[e]))},hyphenate:function(e){return e.replace(t,"-$1").toLowerCase()},getBaseElem:o,isCharacterBox:function(e){const t=o(e);return"mathord"===t.type||"textord"===t.type||"atom"===t.type},protocolFromUrl:function(e){const t=/^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(e);return null!=t?t[1]:"_relative"},round:function(e){return+e.toFixed(4)}};class a{constructor(e){e=e||{},this.displayMode=s.deflt(e.displayMode,!1),this.annotate=s.deflt(e.annotate,!1),this.leqno=s.deflt(e.leqno,!1),this.errorColor=s.deflt(e.errorColor,"#b22222"),this.macros=e.macros||{},this.wrap=s.deflt(e.wrap,"none"),this.xml=s.deflt(e.xml,!1),this.colorIsTextColor=s.deflt(e.colorIsTextColor,!1),this.strict=s.deflt(e.strict,!1),this.trust=s.deflt(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,s.deflt(e.maxExpand,1e3))}isTrusted(e){e.url&&!e.protocol&&(e.protocol=s.protocolFromUrl(e.url));const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}const i={},l={};function c({type:e,names:t,props:r,handler:n,mathmlBuilder:o}){const s={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)i[t[e]]=s;e&&o&&(l[e]=o)}function m({type:e,mathmlBuilder:t}){c({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:t})}const u=function(e){return"ordgroup"===e.type&&1===e.body.length?e.body[0]:e},p=function(e){return"ordgroup"===e.type?e.body:[e]};class d{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 h=function(e){return e.filter((e=>e)).join(" ")},g=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},f=function(e){const t=document.createElement(e);t.className=h(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},b=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${s.escape(h(this.classes))}"`);let r="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(r+=`${s.hyphenate(e)}:${this.style[e]};`);r&&(t+=` style="${r}"`);for(const e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&(t+=` ${e}="${s.escape(this.attributes[e])}"`);t+=">";for(let e=0;e<this.children.length;e++)t+=this.children[e].toMarkup();return t+=`</${e}>`,t};class y{constructor(e,t,r){g.call(this,e,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return f.call(this,"span")}toMarkup(){return b.call(this,"span")}}class w{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return s.escape(this.text)}}class x{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+=`${s.hyphenate(e)}:${this.style[e]};`);return t&&(e+=` style="${s.escape(t)}"`),e+="/>",e}}class k{constructor(e,t,r,n){this.type=e,this.attributes={},this.children=t||[],this.classes=r||[],this.style=n||{}}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[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=h(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+=s.escape(this.attributes[t]),e+='"');this.classes.length>0&&(e+=` class="${s.escape(h(this.classes))}"`);let t="";for(const e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${s.hyphenate(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 v{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return s.escape(this.toText())}toText(){return this.text}}const A=e=>{let t;return 1===e.length&&"mrow"===e[0].type?(t=e.pop(),t.type="mstyle"):t=new k("mstyle",e),t};var N={MathNode:k,TextNode:v,newDocumentFragment:function(e){return new d(e)}};const T={widehat:"^",widecheck:"ˇ",widetilde:"~",wideparen:"⏜",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",overparen:"⏜",undergroup:"⏡",underparen:"⏝",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xrightleftarrows:"⇄",yields:"→",yieldsLeft:"←",mesomerism:"↔",longrightharpoonup:"⇀",longleftharpoondown:"↽",eqrightharpoonup:"⇀",eqleftharpoondown:"↽","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"="};var S=function(e){const t=new N.TextNode(T[e.slice(1)]),r=new N.MathNode("mo",[t]);return r.setAttribute("stretchy","true"),r};const q={bin:1,close:1,inner:1,open:1,punct:1,rel:1},O={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},M={math:{},text:{}};function B(e,t,r,n,o){M[e][n]={group:t,replace:r},o&&r&&(M[e][r]=M[e][n])}const C="math",z="text",E="accent-token",I="bin",L="close",F="inner",$="mathord",G="op-token",D="open",P="punct",R="rel",j="spacing",U="textord";B(C,R,"≡","\\equiv",!0),B(C,R,"≺","\\prec",!0),B(C,R,"≻","\\succ",!0),B(C,R,"∼","\\sim",!0),B(C,R,"⟂","\\perp",!0),B(C,R,"⪯","\\preceq",!0),B(C,R,"⪰","\\succeq",!0),B(C,R,"≃","\\simeq",!0),B(C,R,"≌","\\backcong",!0),B(C,R,"|","\\mid",!0),B(C,R,"≪","\\ll",!0),B(C,R,"≫","\\gg",!0),B(C,R,"≍","\\asymp",!0),B(C,R,"∥","\\parallel"),B(C,R,"⋈","\\bowtie",!0),B(C,R,"⌣","\\smile",!0),B(C,R,"⊑","\\sqsubseteq",!0),B(C,R,"⊒","\\sqsupseteq",!0),B(C,R,"≐","\\doteq",!0),B(C,R,"⌢","\\frown",!0),B(C,R,"∋","\\ni",!0),B(C,R,"∌","\\notni",!0),B(C,R,"∝","\\propto",!0),B(C,R,"⊢","\\vdash",!0),B(C,R,"⊣","\\dashv",!0),B(C,R,"∋","\\owns"),B(C,R,"≘","\\arceq",!0),B(C,R,"≙","\\wedgeq",!0),B(C,R,"≚","\\veeeq",!0),B(C,R,"≛","\\stareq",!0),B(C,R,"≝","\\eqdef",!0),B(C,R,"≞","\\measeq",!0),B(C,R,"≟","\\questeq",!0),B(C,R,"≠","\\ne",!0),B(C,R,"≠","\\neq"),B(C,R,"∷","\\dblcolon",!0),B(C,R,"≔","\\coloneqq",!0),B(C,R,"≕","\\eqqcolon",!0),B(C,R,"∹","\\eqcolon",!0),B(C,R,"⩴","\\Coloneqq",!0),B(C,P,".","\\ldotp"),B(C,P,"·","\\cdotp"),B(C,U,"#","\\#"),B(z,U,"#","\\#"),B(C,U,"&","\\&"),B(z,U,"&","\\&"),B(C,U,"ℵ","\\aleph",!0),B(C,U,"∀","\\forall",!0),B(C,U,"ℏ","\\hbar",!0),B(C,U,"∃","\\exists",!0),B(C,U,"∇","\\nabla",!0),B(C,U,"♭","\\flat",!0),B(C,U,"ℓ","\\ell",!0),B(C,U,"♮","\\natural",!0),B(C,U,"Å","\\AA",!0),B(z,U,"Å","\\AA",!0),B(C,U,"♣","\\clubsuit",!0),B(C,U,"♧","\\varclubsuit",!0),B(C,U,"℘","\\wp",!0),B(C,U,"♯","\\sharp",!0),B(C,U,"♢","\\diamondsuit",!0),B(C,U,"♦","\\vardiamondsuit",!0),B(C,U,"ℜ","\\Re",!0),B(C,U,"♡","\\heartsuit",!0),B(C,U,"♥","\\varheartsuit",!0),B(C,U,"ℑ","\\Im",!0),B(C,U,"♠","\\spadesuit",!0),B(C,U,"♤","\\varspadesuit",!0),B(C,U,"♀","\\female",!0),B(C,U,"♂","\\male",!0),B(C,U,"§","\\S",!0),B(z,U,"§","\\S"),B(C,U,"¶","\\P",!0),B(z,U,"¶","\\P"),B(z,U,"☺","\\smiley",!0),B(C,U,"☺","\\smiley",!0),B(C,U,"†","\\dag"),B(z,U,"†","\\dag"),B(z,U,"†","\\textdagger"),B(C,U,"‡","\\ddag"),B(z,U,"‡","\\ddag"),B(z,U,"‡","\\textdaggerdbl"),B(C,L,"⎱","\\rmoustache",!0),B(C,D,"⎰","\\lmoustache",!0),B(C,L,"⟯","\\rgroup",!0),B(C,D,"⟮","\\lgroup",!0),B(C,I,"∓","\\mp",!0),B(C,I,"⊖","\\ominus",!0),B(C,I,"⊎","\\uplus",!0),B(C,I,"⊓","\\sqcap",!0),B(C,I,"∗","\\ast"),B(C,I,"⊔","\\sqcup",!0),B(C,I,"◯","\\bigcirc",!0),B(C,I,"∙","\\bullet",!0),B(C,I,"‡","\\ddagger"),B(C,I,"≀","\\wr",!0),B(C,I,"⨿","\\amalg"),B(C,I,"&","\\And"),B(C,R,"⟵","\\longleftarrow",!0),B(C,R,"⇐","\\Leftarrow",!0),B(C,R,"⟸","\\Longleftarrow",!0),B(C,R,"⟶","\\longrightarrow",!0),B(C,R,"⇒","\\Rightarrow",!0),B(C,R,"⟹","\\Longrightarrow",!0),B(C,R,"↔","\\leftrightarrow",!0),B(C,R,"⟷","\\longleftrightarrow",!0),B(C,R,"⇔","\\Leftrightarrow",!0),B(C,R,"⟺","\\Longleftrightarrow",!0),B(C,R,"↤","\\mapsfrom",!0),B(C,R,"↦","\\mapsto",!0),B(C,R,"⟼","\\longmapsto",!0),B(C,R,"↗","\\nearrow",!0),B(C,R,"↩","\\hookleftarrow",!0),B(C,R,"↪","\\hookrightarrow",!0),B(C,R,"↘","\\searrow",!0),B(C,R,"↼","\\leftharpoonup",!0),B(C,R,"⇀","\\rightharpoonup",!0),B(C,R,"↙","\\swarrow",!0),B(C,R,"↽","\\leftharpoondown",!0),B(C,R,"⇁","\\rightharpoondown",!0),B(C,R,"↖","\\nwarrow",!0),B(C,R,"⇌","\\rightleftharpoons",!0),B(C,$,"↯","\\lightning",!0),B(C,$,"‰","\\permil",!0),B(z,U,"‰","\\permil"),B(C,R,"≮","\\nless",!0),B(C,R,"⪇","\\lneq",!0),B(C,R,"≨","\\lneqq",!0),B(C,R,"≨︀","\\lvertneqq"),B(C,R,"⋦","\\lnsim",!0),B(C,R,"⪉","\\lnapprox",!0),B(C,R,"⊀","\\nprec",!0),B(C,R,"⋠","\\npreceq",!0),B(C,R,"⋨","\\precnsim",!0),B(C,R,"⪹","\\precnapprox",!0),B(C,R,"≁","\\nsim",!0),B(C,R,"∤","\\nmid",!0),B(C,R,"∤","\\nshortmid"),B(C,R,"⊬","\\nvdash",!0),B(C,R,"⊭","\\nvDash",!0),B(C,R,"⋪","\\ntriangleleft"),B(C,R,"⋬","\\ntrianglelefteq",!0),B(C,R,"⊄","\\nsubset",!0),B(C,R,"⊅","\\nsupset",!0),B(C,R,"⊊","\\subsetneq",!0),B(C,R,"⊊︀","\\varsubsetneq"),B(C,R,"⫋","\\subsetneqq",!0),B(C,R,"⫋︀","\\varsubsetneqq"),B(C,R,"≯","\\ngtr",!0),B(C,R,"⪈","\\gneq",!0),B(C,R,"≩","\\gneqq",!0),B(C,R,"≩︀","\\gvertneqq"),B(C,R,"⋧","\\gnsim",!0),B(C,R,"⪊","\\gnapprox",!0),B(C,R,"⊁","\\nsucc",!0),B(C,R,"⋡","\\nsucceq",!0),B(C,R,"⋩","\\succnsim",!0),B(C,R,"⪺","\\succnapprox",!0),B(C,R,"≆","\\ncong",!0),B(C,R,"∦","\\nparallel",!0),B(C,R,"∦","\\nshortparallel"),B(C,R,"⊯","\\nVDash",!0),B(C,R,"⋫","\\ntriangleright"),B(C,R,"⋭","\\ntrianglerighteq",!0),B(C,R,"⊋","\\supsetneq",!0),B(C,R,"⊋","\\varsupsetneq"),B(C,R,"⫌","\\supsetneqq",!0),B(C,R,"⫌︀","\\varsupsetneqq"),B(C,R,"⊮","\\nVdash",!0),B(C,R,"⪵","\\precneqq",!0),B(C,R,"⪶","\\succneqq",!0),B(C,I,"⊴","\\unlhd"),B(C,I,"⊵","\\unrhd"),B(C,R,"↚","\\nleftarrow",!0),B(C,R,"↛","\\nrightarrow",!0),B(C,R,"⇍","\\nLeftarrow",!0),B(C,R,"⇏","\\nRightarrow",!0),B(C,R,"↮","\\nleftrightarrow",!0),B(C,R,"⇎","\\nLeftrightarrow",!0),B(C,R,"△","\\vartriangle"),B(C,U,"ℏ","\\hslash"),B(C,U,"▽","\\triangledown"),B(C,U,"◊","\\lozenge"),B(C,U,"Ⓢ","\\circledS"),B(C,U,"®","\\circledR",!0),B(z,U,"®","\\circledR"),B(z,U,"®","\\textregistered"),B(C,U,"∡","\\measuredangle",!0),B(C,U,"∄","\\nexists"),B(C,U,"℧","\\mho"),B(C,U,"Ⅎ","\\Finv",!0),B(C,U,"⅁","\\Game",!0),B(C,U,"‵","\\backprime"),B(C,U,"▲","\\blacktriangle"),B(C,U,"▼","\\blacktriangledown"),B(C,U,"■","\\blacksquare"),B(C,U,"⧫","\\blacklozenge"),B(C,U,"★","\\bigstar"),B(C,U,"∢","\\sphericalangle",!0),B(C,U,"∁","\\complement",!0),B(C,U,"ð","\\eth",!0),B(z,U,"ð","ð"),B(C,U,"╱","\\diagup"),B(C,U,"╲","\\diagdown"),B(C,U,"□","\\square"),B(C,U,"□","\\Box"),B(C,U,"◊","\\Diamond"),B(C,U,"¥","\\yen",!0),B(z,U,"¥","\\yen",!0),B(C,U,"✓","\\checkmark",!0),B(z,U,"✓","\\checkmark"),B(C,U,"✗","\\ballotx",!0),B(z,U,"✗","\\ballotx"),B(z,U,"•","\\textbullet"),B(C,U,"ℶ","\\beth",!0),B(C,U,"ℸ","\\daleth",!0),B(C,U,"ℷ","\\gimel",!0),B(C,U,"ϝ","\\digamma",!0),B(C,U,"ϰ","\\varkappa"),B(C,D,"⌜","\\ulcorner",!0),B(C,L,"⌝","\\urcorner",!0),B(C,D,"⌞","\\llcorner",!0),B(C,L,"⌟","\\lrcorner",!0),B(C,R,"≦","\\leqq",!0),B(C,R,"⩽","\\leqslant",!0),B(C,R,"⪕","\\eqslantless",!0),B(C,R,"≲","\\lesssim",!0),B(C,R,"⪅","\\lessapprox",!0),B(C,R,"≊","\\approxeq",!0),B(C,I,"⋖","\\lessdot"),B(C,R,"⋘","\\lll",!0),B(C,R,"≶","\\lessgtr",!0),B(C,R,"⋚","\\lesseqgtr",!0),B(C,R,"⪋","\\lesseqqgtr",!0),B(C,R,"≑","\\doteqdot"),B(C,R,"≓","\\risingdotseq",!0),B(C,R,"≒","\\fallingdotseq",!0),B(C,R,"∽","\\backsim",!0),B(C,R,"⋍","\\backsimeq",!0),B(C,R,"⫅","\\subseteqq",!0),B(C,R,"⋐","\\Subset",!0),B(C,R,"⊏","\\sqsubset",!0),B(C,R,"≼","\\preccurlyeq",!0),B(C,R,"⋞","\\curlyeqprec",!0),B(C,R,"≾","\\precsim",!0),B(C,R,"⪷","\\precapprox",!0),B(C,R,"⊲","\\vartriangleleft"),B(C,R,"⊴","\\trianglelefteq"),B(C,R,"⊨","\\vDash",!0),B(C,R,"⊪","\\Vvdash",!0),B(C,R,"⌣","\\smallsmile"),B(C,R,"⌢","\\smallfrown"),B(C,R,"≏","\\bumpeq",!0),B(C,R,"≎","\\Bumpeq",!0),B(C,R,"≧","\\geqq",!0),B(C,R,"⩾","\\geqslant",!0),B(C,R,"⪖","\\eqslantgtr",!0),B(C,R,"≳","\\gtrsim",!0),B(C,R,"⪆","\\gtrapprox",!0),B(C,I,"⋗","\\gtrdot"),B(C,R,"⋙","\\ggg",!0),B(C,R,"≷","\\gtrless",!0),B(C,R,"⋛","\\gtreqless",!0),B(C,R,"⪌","\\gtreqqless",!0),B(C,R,"≖","\\eqcirc",!0),B(C,R,"≗","\\circeq",!0),B(C,R,"≜","\\triangleq",!0),B(C,R,"∼","\\thicksim"),B(C,R,"≈","\\thickapprox"),B(C,R,"⫆","\\supseteqq",!0),B(C,R,"⋑","\\Supset",!0),B(C,R,"⊐","\\sqsupset",!0),B(C,R,"≽","\\succcurlyeq",!0),B(C,R,"⋟","\\curlyeqsucc",!0),B(C,R,"≿","\\succsim",!0),B(C,R,"⪸","\\succapprox",!0),B(C,R,"⊳","\\vartriangleright"),B(C,R,"⊵","\\trianglerighteq"),B(C,R,"⊩","\\Vdash",!0),B(C,R,"∣","\\shortmid"),B(C,R,"∥","\\shortparallel"),B(C,R,"≬","\\between",!0),B(C,R,"⋔","\\pitchfork",!0),B(C,R,"∝","\\varpropto"),B(C,R,"◀","\\blacktriangleleft"),B(C,R,"∴","\\therefore",!0),B(C,R,"∍","\\backepsilon"),B(C,R,"▶","\\blacktriangleright"),B(C,R,"∵","\\because",!0),B(C,R,"⋘","\\llless"),B(C,R,"⋙","\\gggtr"),B(C,I,"⊲","\\lhd"),B(C,I,"⊳","\\rhd"),B(C,R,"≂","\\eqsim",!0),B(C,R,"⋈","\\Join"),B(C,R,"≑","\\Doteq",!0),B(C,R,"⥽","\\strictif",!0),B(C,R,"⥼","\\strictfi",!0),B(C,I,"∔","\\dotplus",!0),B(C,I,"∖","\\smallsetminus"),B(C,I,"⋒","\\Cap",!0),B(C,I,"⋓","\\Cup",!0),B(C,I,"⩞","\\doublebarwedge",!0),B(C,I,"⊟","\\boxminus",!0),B(C,I,"⊞","\\boxplus",!0),B(C,I,"⋇","\\divideontimes",!0),B(C,I,"⋉","\\ltimes",!0),B(C,I,"⋊","\\rtimes",!0),B(C,I,"⋋","\\leftthreetimes",!0),B(C,I,"⋌","\\rightthreetimes",!0),B(C,I,"⋏","\\curlywedge",!0),B(C,I,"⋎","\\curlyvee",!0),B(C,I,"⊝","\\circleddash",!0),B(C,I,"⊛","\\circledast",!0),B(C,I,"⊺","\\intercal",!0),B(C,I,"⋒","\\doublecap"),B(C,I,"⋓","\\doublecup"),B(C,I,"⊠","\\boxtimes",!0),B(C,R,"⇢","\\dashrightarrow",!0),B(C,R,"⇠","\\dashleftarrow",!0),B(C,R,"⇇","\\leftleftarrows",!0),B(C,R,"⇆","\\leftrightarrows",!0),B(C,R,"⇚","\\Lleftarrow",!0),B(C,R,"↞","\\twoheadleftarrow",!0),B(C,R,"↢","\\leftarrowtail",!0),B(C,R,"↫","\\looparrowleft",!0),B(C,R,"⇋","\\leftrightharpoons",!0),B(C,R,"↶","\\curvearrowleft",!0),B(C,R,"↺","\\circlearrowleft",!0),B(C,R,"↰","\\Lsh",!0),B(C,R,"⇈","\\upuparrows",!0),B(C,R,"↿","\\upharpoonleft",!0),B(C,R,"⇃","\\downharpoonleft",!0),B(C,R,"⊶","\\origof",!0),B(C,R,"⊷","\\imageof",!0),B(C,R,"⊸","\\multimap",!0),B(C,R,"↭","\\leftrightsquigarrow",!0),B(C,R,"⇉","\\rightrightarrows",!0),B(C,R,"⇄","\\rightleftarrows",!0),B(C,R,"↠","\\twoheadrightarrow",!0),B(C,R,"↣","\\rightarrowtail",!0),B(C,R,"↬","\\looparrowright",!0),B(C,R,"↷","\\curvearrowright",!0),B(C,R,"↻","\\circlearrowright",!0),B(C,R,"↱","\\Rsh",!0),B(C,R,"⇊","\\downdownarrows",!0),B(C,R,"↾","\\upharpoonright",!0),B(C,R,"⇂","\\downharpoonright",!0),B(C,R,"⇝","\\rightsquigarrow",!0),B(C,R,"⇝","\\leadsto"),B(C,R,"⇛","\\Rrightarrow",!0),B(C,R,"↾","\\restriction"),B(C,U,"‘","`"),B(C,U,"$","\\$"),B(z,U,"$","\\$"),B(z,U,"$","\\textdollar"),B(C,U,"%","\\%"),B(z,U,"%","\\%"),B(C,U,"_","\\_"),B(z,U,"_","\\_"),B(z,U,"_","\\textunderscore"),B(z,U,"␣","\\textvisiblespace",!0),B(C,U,"∠","\\angle",!0),B(C,U,"∞","\\infty",!0),B(C,U,"′","\\prime"),B(C,U,"△","\\triangle"),B(z,U,"Α","\\Alpha",!0),B(z,U,"Β","\\Beta",!0),B(z,U,"Γ","\\Gamma",!0),B(z,U,"Δ","\\Delta",!0),B(z,U,"Ε","\\Epsilon",!0),B(z,U,"Ζ","\\Zeta",!0),B(z,U,"Η","\\Eta",!0),B(z,U,"Θ","\\Theta",!0),B(z,U,"Ι","\\Iota",!0),B(z,U,"Κ","\\Kappa",!0),B(z,U,"Λ","\\Lambda",!0),B(z,U,"Μ","\\Mu",!0),B(z,U,"Ν","\\Nu",!0),B(z,U,"Ξ","\\Xi",!0),B(z,U,"Ο","\\Omicron",!0),B(z,U,"Π","\\Pi",!0),B(z,U,"Ρ","\\Rho",!0),B(z,U,"Σ","\\Sigma",!0),B(z,U,"Τ","\\Tau",!0),B(z,U,"Υ","\\Upsilon",!0),B(z,U,"Φ","\\Phi",!0),B(z,U,"Χ","\\Chi",!0),B(z,U,"Ψ","\\Psi",!0),B(z,U,"Ω","\\Omega",!0),B(C,$,"Α","\\Alpha",!0),B(C,$,"Β","\\Beta",!0),B(C,$,"Γ","\\Gamma",!0),B(C,$,"Δ","\\Delta",!0),B(C,$,"Ε","\\Epsilon",!0),B(C,$,"Ζ","\\Zeta",!0),B(C,$,"Η","\\Eta",!0),B(C,$,"Θ","\\Theta",!0),B(C,$,"Ι","\\Iota",!0),B(C,$,"Κ","\\Kappa",!0),B(C,$,"Λ","\\Lambda",!0),B(C,$,"Μ","\\Mu",!0),B(C,$,"Ν","\\Nu",!0),B(C,$,"Ξ","\\Xi",!0),B(C,$,"Ο","\\Omicron",!0),B(C,$,"Π","\\Pi",!0),B(C,$,"Ρ","\\Rho",!0),B(C,$,"Σ","\\Sigma",!0),B(C,$,"Τ","\\Tau",!0),B(C,$,"Υ","\\Upsilon",!0),B(C,$,"Φ","\\Phi",!0),B(C,$,"Χ","\\Chi",!0),B(C,$,"Ψ","\\Psi",!0),B(C,$,"Ω","\\Omega",!0),B(C,D,"¬","\\neg",!0),B(C,D,"¬","\\lnot"),B(C,U,"⊤","\\top"),B(C,U,"⊥","\\bot"),B(C,U,"∅","\\emptyset"),B(C,U,"ø","\\varnothing"),B(C,$,"α","\\alpha",!0),B(C,$,"β","\\beta",!0),B(C,$,"γ","\\gamma",!0),B(C,$,"δ","\\delta",!0),B(C,$,"ϵ","\\epsilon",!0),B(C,$,"ζ","\\zeta",!0),B(C,$,"η","\\eta",!0),B(C,$,"θ","\\theta",!0),B(C,$,"ι","\\iota",!0),B(C,$,"κ","\\kappa",!0),B(C,$,"λ","\\lambda",!0),B(C,$,"μ","\\mu",!0),B(C,$,"ν","\\nu",!0),B(C,$,"ξ","\\xi",!0),B(C,$,"ο","\\omicron",!0),B(C,$,"π","\\pi",!0),B(C,$,"ρ","\\rho",!0),B(C,$,"σ","\\sigma",!0),B(C,$,"τ","\\tau",!0),B(C,$,"υ","\\upsilon",!0),B(C,$,"ϕ","\\phi",!0),B(C,$,"χ","\\chi",!0),B(C,$,"ψ","\\psi",!0),B(C,$,"ω","\\omega",!0),B(C,$,"ε","\\varepsilon",!0),B(C,$,"ϑ","\\vartheta",!0),B(C,$,"ϖ","\\varpi",!0),B(C,$,"ϱ","\\varrho",!0),B(C,$,"ς","\\varsigma",!0),B(C,$,"φ","\\varphi",!0),B(C,$,"Ϙ","\\Coppa",!0),B(C,$,"ϙ","\\coppa",!0),B(C,$,"ϙ","\\varcoppa",!0),B(C,$,"Ϟ","\\Koppa",!0),B(C,$,"ϟ","\\koppa",!0),B(C,$,"Ϡ","\\Sampi",!0),B(C,$,"ϡ","\\sampi",!0),B(C,$,"Ϛ","\\Stigma",!0),B(C,$,"ϛ","\\stigma",!0),B(C,$,"⫫","\\Bot"),B(C,I,"∗","∗",!0),B(C,I,"+","+"),B(C,I,"*","*"),B(C,I,"⁄","⁄"),B(C,I,"−","-",!0),B(C,I,"⋅","\\cdot",!0),B(C,I,"∘","\\circ",!0),B(C,I,"÷","\\div",!0),B(C,I,"±","\\pm",!0),B(C,I,"×","\\times",!0),B(C,I,"∩","\\cap",!0),B(C,I,"∪","\\cup",!0),B(C,I,"∖","\\setminus",!0),B(C,I,"∧","\\land"),B(C,I,"∨","\\lor"),B(C,I,"∧","\\wedge",!0),B(C,I,"∨","\\vee",!0),B(C,D,"⟦","\\llbracket",!0),B(C,L,"⟧","\\rrbracket",!0),B(C,D,"⟨","\\langle",!0),B(C,D,"|","\\lvert"),B(C,D,"‖","\\lVert"),B(C,U,"!","\\oc"),B(C,U,"?","\\wn"),B(C,U,"↓","\\shpos"),B(C,U,"↕","\\shift"),B(C,U,"↑","\\shneg"),B(C,L,"?","?"),B(C,L,"!","!"),B(C,L,"‼","‼"),B(C,L,"⟩","\\rangle",!0),B(C,L,"|","\\rvert"),B(C,L,"‖","\\rVert"),B(C,D,"⦃","\\lBrace",!0),B(C,L,"⦄","\\rBrace",!0),B(C,R,"=","\\equal",!0),B(C,R,":",":"),B(C,R,"≈","\\approx",!0),B(C,R,"≅","\\cong",!0),B(C,R,"≥","\\ge"),B(C,R,"≥","\\geq",!0),B(C,R,"←","\\gets"),B(C,R,">","\\gt",!0),B(C,R,"∈","\\in",!0),B(C,R,"∉","\\notin",!0),B(C,R,"","\\@not"),B(C,R,"⊂","\\subset",!0),B(C,R,"⊃","\\supset",!0),B(C,R,"⊆","\\subseteq",!0),B(C,R,"⊇","\\supseteq",!0),B(C,R,"⊈","\\nsubseteq",!0),B(C,R,"⊈","\\nsubseteqq"),B(C,R,"⊉","\\nsupseteq",!0),B(C,R,"⊉","\\nsupseteqq"),B(C,R,"⊨","\\models"),B(C,R,"←","\\leftarrow",!0),B(C,R,"≤","\\le"),B(C,R,"≤","\\leq",!0),B(C,R,"<","\\lt",!0),B(C,R,"→","\\rightarrow",!0),B(C,R,"→","\\to"),B(C,R,"≱","\\ngeq",!0),B(C,R,"≱","\\ngeqq"),B(C,R,"≱","\\ngeqslant"),B(C,R,"≰","\\nleq",!0),B(C,R,"≰","\\nleqq"),B(C,R,"≰","\\nleqslant"),B(C,R,"⫫","\\Perp",!0),B(C,j," ","\\ "),B(C,j," ","\\space"),B(C,j," ","\\nobreakspace"),B(z,j," ","\\ "),B(z,j," "," "),B(z,j," ","\\space"),B(z,j," ","\\nobreakspace"),B(C,j,null,"\\nobreak"),B(C,j,null,"\\allowbreak"),B(C,P,",",","),B(z,P,":",":"),B(C,P,";",";"),B(C,I,"⊼","\\barwedge",!0),B(C,I,"⊻","\\veebar",!0),B(C,I,"⊙","\\odot",!0),B(C,I,"⊕","\\oplus",!0),B(C,I,"⊗","\\otimes",!0),B(C,U,"∂","\\partial",!0),B(C,I,"⊘","\\oslash",!0),B(C,I,"⊚","\\circledcirc",!0),B(C,I,"⊡","\\boxdot",!0),B(C,I,"△","\\bigtriangleup"),B(C,I,"▽","\\bigtriangledown"),B(C,I,"†","\\dagger"),B(C,I,"⋄","\\diamond"),B(C,I,"⋆","\\star"),B(C,I,"◃","\\triangleleft"),B(C,I,"▹","\\triangleright"),B(C,D,"{","\\{"),B(z,U,"{","\\{"),B(z,U,"{","\\textbraceleft"),B(C,L,"}","\\}"),B(z,U,"}","\\}"),B(z,U,"}","\\textbraceright"),B(C,D,"{","\\lbrace"),B(C,L,"}","\\rbrace"),B(C,D,"[","\\lbrack",!0),B(z,U,"[","\\lbrack",!0),B(C,L,"]","\\rbrack",!0),B(z,U,"]","\\rbrack",!0),B(C,D,"(","\\lparen",!0),B(C,L,")","\\rparen",!0),B(z,U,"<","\\textless",!0),B(z,U,">","\\textgreater",!0),B(C,D,"⌊","\\lfloor",!0),B(C,L,"⌋","\\rfloor",!0),B(C,D,"⌈","\\lceil",!0),B(C,L,"⌉","\\rceil",!0),B(C,U,"\\","\\backslash"),B(C,U,"|","|"),B(C,U,"|","\\vert"),B(z,U,"|","\\textbar",!0),B(C,U,"‖","\\|"),B(C,U,"‖","\\Vert"),B(z,U,"‖","\\textbardbl"),B(z,U,"~","\\textasciitilde"),B(z,U,"\\","\\textbackslash"),B(z,U,"^","\\textasciicircum"),B(C,R,"↑","\\uparrow",!0),B(C,R,"⇑","\\Uparrow",!0),B(C,R,"↓","\\downarrow",!0),B(C,R,"⇓","\\Downarrow",!0),B(C,R,"↕","\\updownarrow",!0),B(C,R,"⇕","\\Updownarrow",!0),B(C,G,"∐","\\coprod"),B(C,G,"⋁","\\bigvee"),B(C,G,"⋀","\\bigwedge"),B(C,G,"⨄","\\biguplus"),B(C,G,"⋂","\\bigcap"),B(C,G,"⋃","\\bigcup"),B(C,G,"∫","\\int"),B(C,G,"∫","\\intop"),B(C,G,"∬","\\iint"),B(C,G,"∭","\\iiint"),B(C,G,"∏","\\prod"),B(C,G,"∑","\\sum"),B(C,G,"⨂","\\bigotimes"),B(C,G,"⨁","\\bigoplus"),B(C,G,"⨀","\\bigodot"),B(C,G,"∮","\\oint"),B(C,G,"∯","\\oiint"),B(C,G,"∰","\\oiiint"),B(C,G,"∱","\\intclockwise"),B(C,G,"∲","\\varointclockwise"),B(C,G,"⨌","\\iiiint"),B(C,G,"⨍","\\intbar"),B(C,G,"⨎","\\intBar"),B(C,G,"⨏","\\fint"),B(C,G,"⨒","\\rppolint"),B(C,G,"⨓","\\scpolint"),B(C,G,"⨕","\\pointint"),B(C,G,"⨖","\\sqint"),B(C,G,"⨗","\\intlarhk"),B(C,G,"⨘","\\intx"),B(C,G,"⨙","\\intcap"),B(C,G,"⨚","\\intcup"),B(C,G,"⨅","\\bigsqcap"),B(C,G,"⨆","\\bigsqcup"),B(C,G,"∫","\\smallint"),B(z,F,"…","\\textellipsis"),B(C,F,"…","\\mathellipsis"),B(z,F,"…","\\ldots",!0),B(C,F,"…","\\ldots",!0),B(C,F,"⋰","\\iddots",!0),B(C,F,"⋯","\\@cdots",!0),B(C,F,"⋱","\\ddots",!0),B(C,U,"⋮","\\varvdots"),B(C,E,"ˊ","\\acute"),B(C,E,"`","\\grave"),B(C,E,"¨","\\ddot"),B(C,E,"…","\\dddot"),B(C,E,"….","\\ddddot"),B(C,E,"~","\\tilde"),B(C,E,"‾","\\bar"),B(C,E,"˘","\\breve"),B(C,E,"ˇ","\\check"),B(C,E,"^","\\hat"),B(C,E,"→","\\vec"),B(C,E,"˙","\\dot"),B(C,E,"˚","\\mathring"),B(C,$,"ı","\\imath",!0),B(C,$,"ȷ","\\jmath",!0),B(C,U,"ı","ı"),B(C,U,"ȷ","ȷ"),B(z,U,"ı","\\i",!0),B(z,U,"ȷ","\\j",!0),B(z,U,"ß","\\ss",!0),B(z,U,"æ","\\ae",!0),B(z,U,"œ","\\oe",!0),B(z,U,"ø","\\o",!0),B(C,$,"ø","\\o",!0),B(z,U,"Æ","\\AE",!0),B(z,U,"Œ","\\OE",!0),B(z,U,"Ø","\\O",!0),B(C,$,"Ø","\\O",!0),B(z,E,"ˊ","\\'"),B(z,E,"ˋ","\\`"),B(z,E,"ˆ","\\^"),B(z,E,"˜","\\~"),B(z,E,"ˉ","\\="),B(z,E,"˘","\\u"),B(z,E,"˙","\\."),B(z,E,"¸","\\c"),B(z,E,"˚","\\r"),B(z,E,"ˇ","\\v"),B(z,E,"¨",'\\"'),B(z,E,"˝","\\H"),B(C,E,"ˊ","\\'"),B(C,E,"ˋ","\\`"),B(C,E,"ˆ","\\^"),B(C,E,"˜","\\~"),B(C,E,"ˉ","\\="),B(C,E,"˘","\\u"),B(C,E,"˙","\\."),B(C,E,"¸","\\c"),B(C,E,"˚","\\r"),B(C,E,"ˇ","\\v"),B(C,E,"¨",'\\"'),B(C,E,"˝","\\H");const H={"--":!0,"---":!0,"``":!0,"''":!0};B(z,U,"–","--",!0),B(z,U,"–","\\textendash"),B(z,U,"—","---",!0),B(z,U,"—","\\textemdash"),B(z,U,"‘","`",!0),B(z,U,"‘","\\textquoteleft"),B(z,U,"’","'",!0),B(z,U,"’","\\textquoteright"),B(z,U,"“","``",!0),B(z,U,"“","\\textquotedblleft"),B(z,U,"”","''",!0),B(z,U,"”","\\textquotedblright"),B(C,U,"°","\\degree",!0),B(z,U,"°","\\degree"),B(z,U,"°","\\textdegree",!0),B(C,U,"£","\\pounds"),B(C,U,"£","\\mathsterling",!0),B(z,U,"£","\\pounds"),B(z,U,"£","\\textsterling",!0),B(C,U,"✠","\\maltese"),B(z,U,"✠","\\maltese"),B(C,U,"€","\\euro",!0),B(z,U,"€","\\euro",!0),B(z,U,"€","\\texteuro"),B(C,U,"©","\\copyright",!0),B(z,U,"©","\\textcopyright"),B(C,U,"𝛤","\\varGamma"),B(C,U,"𝛥","\\varDelta"),B(C,U,"𝛩","\\varTheta"),B(C,U,"𝛬","\\varLambda"),B(C,U,"𝛯","\\varXi"),B(C,U,"𝛱","\\varPi"),B(C,U,"𝛴","\\varSigma"),B(C,U,"𝛶","\\varUpsilon"),B(C,U,"𝛷","\\varPhi"),B(C,U,"𝛹","\\varPsi"),B(C,U,"𝛺","\\varOmega"),B(z,U,"𝛤","\\varGamma"),B(z,U,"𝛥","\\varDelta"),B(z,U,"𝛩","\\varTheta"),B(z,U,"𝛬","\\varLambda"),B(z,U,"𝛯","\\varXi"),B(z,U,"𝛱","\\varPi"),B(z,U,"𝛴","\\varSigma"),B(z,U,"𝛶","\\varUpsilon"),B(z,U,"𝛷","\\varPhi"),B(z,U,"𝛹","\\varPsi"),B(z,U,"𝛺","\\varOmega");const _='0123456789/@."';for(let e=0;e<_.length;e++){const t=_.charAt(e);B(C,U,t,t)}const V='0123456789!@*()-=+";:?/.,';for(let e=0;e<V.length;e++){const t=V.charAt(e);B(z,U,t,t)}const W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<W.length;e++){const t=W.charAt(e);B(C,$,t,t),B(z,U,t,t)}const X="ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";for(let e=0;e<X.length;e++){const t=X.charAt(e);B(C,$,t,t),B(z,U,t,t)}let Z="";for(let e=0;e<W.length;e++){Z=String.fromCharCode(55349,56320+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56372+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56424+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56580+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56736+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56788+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56840+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56944+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,56632+e),B(C,$,Z,Z),B(z,U,Z,Z);const t=W.charAt(e);Z=String.fromCharCode(55349,56476+e),B(C,$,t,Z),B(z,U,t,Z)}for(let e=0;e<10;e++)Z=String.fromCharCode(55349,57294+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,57314+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,57324+e),B(C,$,Z,Z),B(z,U,Z,Z),Z=String.fromCharCode(55349,57334+e),B(C,$,Z,Z),B(z,U,Z,Z);function Y(e,t,r,n){if(void 0===n&&"none"!==t){for(let n=e.length-1;n>=0;n--){const o=e[n];if("mstyle"===o.type&&o.attributes.mathcolor){const s=o.attributes.mathcolor,a=Y(o.children,t,r,s);a.type&&"mtable"!==a.type||e.splice(n,1,...a.children)}}}const o=n?"mstyle":"mrow",s=[];let a=[],i=[],l=0,c=!1;for(let r=0;r<e.length;r++){const m=e[r];if(m.type&&"mstyle"===m.type&&m.attributes.mathcolor)i.length>0&&a.push(new N.MathNode(o,i)),a.push(m),i=[];else if(m.attributes&&m.attributes.linebreak&&"newline"===m.attributes.linebreak){if(i.length>0){const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(new N.MathNode(o,i))}a.push(m),i=[];const e=new N.MathNode("mtd",a);s.push(new N.MathNode("mtr",[e])),a=[]}else if(i.push(m),m.type&&"mo"===m.type&&"="===t){if(1===m.children.length&&"="===m.children[0].text&&(l+=1,l>1)){i.pop();const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(e),i=[m]}}else if(m.type&&"mo"===m.type&&"tex"===t){if(c&&!m.attributes.form){const t=r<e.length-1?e[r+1]:null;let s=!0;if(!t||"mtext"!==t.type||!t.attributes.linebreak||"nobreak"!==t.attributes.linebreak)for(let t=r+1;t<e.length;t++){const n=e[t];if(!n.type||"mspace"!==n.type||n.attributes.linebreak&&"newline"===n.attributes.linebreak)break;i.push(n),r+=1,n.attributes&&n.attributes.linebreak&&"nobreak"===n.attributes.linebreak&&(s=!1)}if(s){const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(e),i=[]}c=!1}const t=m.attributes.form&&"prefix"===m.attributes.form;c=!(m.attributes.separator||t)}else c=!0}if(i.length>0){const e=new N.MathNode(o,i);n&&e.setAttribute("mathcolor",n),a.push(e)}if(s.length>0){const e=new N.MathNode("mtd",a),t=new N.MathNode("mtr",[e]);s.push(t);const n=new N.MathNode("mtable",s);return r||(n.setAttribute("columnalign","left"),n.setAttribute("rowspacing","0em")),n}return N.newDocumentFragment(a)}const K=function(e,t,r){return!M[t][e]||!M[t][e].replace||55349===e.charCodeAt(0)||Object.prototype.hasOwnProperty.call(H,e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=M[t][e].replace),new N.TextNode(e)},J=e=>{if("mrow"!==e.type)return e;if(0===e.children.length)return e;if(!e.children[0].attributes||"mtext"!==e.children[0].type)return e;const t=e.children[0].attributes.mathvariant||"",r=new N.MathNode("mtext",[new N.TextNode(e.children[0].children[0].text)]);for(let n=1;n<e.children.length;n++){const o=e.children[n].attributes.mathvariant||"";if("mrow"===e.children[n].type){const o=e.children[n];for(let n=0;n<o.children.length;n++){if((o.children[n].attributes.mathvariant||"")!==t||"mtext"!==o.children[n].type)return e;r.children[0].text+=o.children[n].children[0].text}}else{if(o!==t||"mtext"!==e.children[n].type)return e;r.children[0].text+=e.children[n].children[0].text}}" "===r.children[0].text.charAt(0)&&(r.children[0].text=" "+r.children[0].text.slice(1));const n=r.children[0].text.length;return n>0&&" "===r.children[0].text.charAt(n-1)&&(r.children[0].text=r.children[0].text.slice(0,-1)+" "),r},Q=function(e){return 1===e.length?e[0]:new N.MathNode("mrow",e)},ee=e=>"atom"===e.type&&"rel"===e.family||"mclass"===e.type&&"mrel"===e.mclass,te=function(e,t,r){if(1===e.length){const n=ne(e[0],t);return r&&n instanceof k&&"mo"===n.type&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}const n=[];for(let r=0;r<e.length;r++){const o=ne(e[r],t);r<e.length-1&&ee(e[r])&&ee(e[r+1])&&o.setAttribute("rspace","0em"),r>0&&ee(e[r])&&ee(e[r-1])&&o.setAttribute("lspace","0em"),n.push(o)}return n},re=function(e,t,r){return Q(te(e,t,r))},ne=function(t,r){if(!t)return new N.MathNode("mrow");if(l[t.type]){return l[t.type](t,r)}throw new e("Got group of unknown type: '"+t.type+"'")},oe=e=>new N.MathNode("mtd",[],[],{padding:"0",width:"50%"});function se(e,t,r,n){let o=null;1===e.length&&"tag"===e[0].type&&(o=e[0].tag,e=e[0].body);const s=te(e,r),a=n.displayMode||n.annotate?"none":n.wrap,i=0===s.length?null:s[0];let l=1===s.length&&null===o&&i instanceof k&&("mstyle"!==i.type||!i.attributes.mathcolor)?s[0]:Y(s,a,n.displayMode);if(o&&(l=((e,t,r,n)=>{t=re(t[0].body,r),(t=J(t)).classes.push("tml-tag"),e=new N.MathNode("mtd",[e]);const o=[oe(),e,oe()];n?(o[0].children.push(t),o[0].style.textAlign="-webkit-left"):(o[2].children.push(t),o[2].style.textAlign="-webkit-right");const s=new N.MathNode("mtr",o,["tml-tageqn"]),a=new N.MathNode("mtable",[s]);return a.style.width="100%",a.setAttribute("displaystyle","true"),a})(l,o,r,n.leqno)),n.annotate){const e=new N.MathNode("annotation",[new N.TextNode(t)]);e.setAttribute("encoding","application/x-tex"),l=new N.MathNode("semantics",[l,e])}if("none"!==a&&l.children.length>1){const e=[];for(let t=0;t<l.children.length;t++){const r=new N.MathNode("math",[l.children[t]]);n.xml&&r.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),e.push(r)}return N.newDocumentFragment(e)}const c=new N.MathNode("math",[l]);return n.xml&&c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n.displayMode&&c.setAttribute("display","block"),c}const ae=(e,t)=>{const r=e.isStretchy?S(e.label):new N.MathNode("mo",[K(e.label,e.mode)]);"\\vec"===e.label?r.style.transform="scale(0.75) translate(10%, 30%)":(r.style.mathStyle="normal",r.style.mathDepth="0"),e.isStretchy||r.setAttribute("stretchy","false");return new N.MathNode("\\c"===e.label?"munder":"mover",[ne(e.base,t),r])},ie=new RegExp(["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map((e=>`\\${e}`)).join("|"));c({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=u(t[0]),n=!ie.test(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,base:r}},mathmlBuilder:ae}),c({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=u(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.`),{type:"accent",mode:n,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}},mathmlBuilder:ae}),c({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=S(e.label);r.style["math-depth"]=0;return new N.MathNode("munder",[ne(e.base,t),r])}});const le={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},ce=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],me=function(e){return"string"!=typeof e&&(e=e.unit),ce.indexOf(e)>-1},ue=e=>[1,.7,.5][Math.max(e-1,0)],pe=function(t,r){let n=t.number;if(r.maxSize[0]<0&&n>0)return{number:0,unit:"em"};const o=t.unit;switch(o){case"mm":case"cm":case"in":case"px":return n*le[o]>r.maxSize[1]?{number:r.maxSize[1],unit:"pt"}:{number:n,unit:o};case"em":case"ex":return"ex"===o&&(n*=.431),n=Math.min(n/ue(r.level),r.maxSize[0]),{number:s.round(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*le[o],r.maxSize[1]),{number:s.round(n),unit:"pt"};case"mu":return n=Math.min(n/18,r.maxSize[0]),{number:s.round(n),unit:"em"};default:throw new e("Invalid unit: '"+o+"'")}},de=e=>{const t=new N.MathNode("mspace");return t.setAttribute("width",e+"em"),t},he=(e,t=.3,r=0)=>{if(null==e&&0===r)return de(t);const n=e?[e]:[];return 0!==t&&n.unshift(de(t)),r>0&&n.push(de(r)),new N.MathNode("mrow",n)},ge=(e,t)=>(e/ue(t)).toFixed(4),fe=(e,t,r,n)=>{const o=S(e),s="eq"===e.slice(1,3),a="x"===e.charAt(1)?"1.75":"cd"===e.slice(2,4)?"3.0":s?"1.0":"2.0";o.setAttribute("minsize",String(a)+"em"),o.setAttribute("lspace","0"),o.setAttribute("rspace",s?"0.5em":"0");const i=n.withLevel(n.level<2?2:3),l=ge(a,i.level),c=ge(s?0:.3,i.level),m=ge(s?0:.3,i.level),u=t&&t.body&&(t.body.body||t.body.length>0)?he(ne(t,i),c,m):he(null,l,0),p=r&&r.body&&(r.body.body||r.body.length>0)?he(ne(r,i),c,m):he(null,l,0),d=new N.MathNode("munderover",[o,p,u]);return"3.0"===a&&(d.style.height="1em"),d};c({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\yields","\\yieldsLeft","\\mesomerism","\\longrightharpoonup","\\longleftharpoondown","\\\\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=[fe(e.name,e.body,e.below,t)];return r.unshift(de(.2778)),r.push(de(.2778)),new N.MathNode("mrow",r)}});const be={"\\xtofrom":["\\xrightarrow","\\xleftarrow"],"\\xleftrightharpoons":["\\xleftharpoonup","\\xrightharpoondown"],"\\xrightleftharpoons":["\\xrightharpoonup","\\xleftharpoondown"],"\\yieldsLeftRight":["\\yields","\\yieldsLeft"],"\\equilibrium":["\\longrightharpoonup","\\longleftharpoondown"],"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};function ye(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 we(e){const t=xe(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 xe(e){return e&&("atom"===e.type||Object.prototype.hasOwnProperty.call(O,e.type))?e:null}c({type:"stackedArrow",names:["\\xtofrom","\\xleftrightharpoons","\\xrightleftharpoons","\\yieldsLeftRight","\\equilibrium","\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},r,n){const o=r[0]?{type:"hphantom",mode:e.mode,body:r[0]}:null,s=n[0]?{type:"hphantom",mode:e.mode,body:n[0]}:null;return{type:"stackedArrow",mode:e.mode,name:t,body:r[0],upperArrowBelow:s,lowerArrowBody:o,below:n[0]}},mathmlBuilder(e,t){const r=be[e.name][0],n=be[e.name][1],o=fe(r,e.body,e.upperArrowBelow,t),s=fe(n,e.lowerArrowBody,e.below,t);let a;const i=new N.MathNode("mpadded",[o]);if(i.setAttribute("voffset","0.3em"),i.setAttribute("height","+0.3em"),i.setAttribute("depth","-0.3em"),"\\equilibriumLeft"===e.name){const e=new N.MathNode("mpadded",[s]);e.setAttribute("width","0.5em"),a=new N.MathNode("mpadded",[de(.2778),e,i,de(.2778)])}else i.setAttribute("width","\\equilibriumRight"===e.name?"0.5em":"0"),a=new N.MathNode("mpadded",[de(.2778),i,s,de(.2778)]);return a.setAttribute("voffset","-0.18em"),a.setAttribute("height","-0.18em"),a.setAttribute("depth","+0.18em"),a}});const ke={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},ve=e=>"textord"===e.type&&"@"===e.text;function Ae(e,t,r){const n=ke[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"},o={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[o],[])}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"}}}c({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){let r=new N.MathNode("mrow",[ne(e.label,t)]);return r=new N.MathNode("mpadded",[r]),r.setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new N.MathNode("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),c({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new N.MathNode("mrow",[ne(e.fragment,t)])}),c({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:t,token:r},n){const o=ye(n[0],"ordgroup").body;let s="";for(let e=0;e<o.length;e++){s+=ye(o[e],"textord").text}const a=parseInt(s);if(isNaN(a))throw new e(`\\@char has non-numeric argument ${s}`,r);return{type:"textord",mode:t.mode,text:String.fromCodePoint(a)}}});const Ne=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,Te=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,Se=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,qe=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Oe=/^[a-f0-9]{6}$/i,Me=e=>{let t=e.toString(16);return 1===t.length&&(t="0"+t),t},Be=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}'),Ce=(t,r)=>{let n="";if("HTML"===t){if(!Ne.test(r))throw new e("Invalid HTML input.");n=r}else if("RGB"===t){if(!Se.test(r))throw new e("Invalid RGB input.");r.split(",").map((e=>{n+=Me(Number(e.trim()))}))}else{if(!qe.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+=Me(255*r)}))}return"#"!==n.charAt(0)&&(n="#"+n),n},ze=(t,r,n)=>{const o=`\\\\color@${t}`;if(!Te.exec(t))throw new e("Invalid color: '"+t+"'",n);return Oe.test(t)?"#"+t:("#"===t.charAt(0)||(r.has(o)?t=r.get(o).tokens[0].text:Be[t]&&(t=Be[t])),t)},Ee=(e,t)=>{const r=te(e.body,t.withColor(e.color)),n=A(r);return n.setAttribute("mathcolor",e.color),n};c({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s="";if(o){const e=ye(r[0],"raw").string;s=Ce(o,e)}else s=ze(ye(r[0],"raw").string,e.gullet.macros,t);const a=r[1];return{type:"color",mode:e.mode,color:s,body:p(a)}},mathmlBuilder:Ee}),c({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,token:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s="";if(o){const e=ye(r[0],"raw").string;s=Ce(o,e)}else s=ze(ye(r[0],"raw").string,e.gullet.macros,t);e.gullet.macros.set("\\current@color",s);const a=e.parseExpression(!0,"\\color");return{type:"color",mode:e.mode,color:s,body:a}},mathmlBuilder:Ee}),c({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:t,funcName:r,token:n},o){const s=ye(o[0],"raw").string;if(!/^[A-Za-z]+$/.test(s))throw new e("Color name must be latin letters.",n);const a=ye(o[1],"raw").string;if(!["HTML","RGB","rgb"].includes(a))throw new e("Color model must be HTML, RGB, or rgb.",n);const i=ye(o[2],"raw").string,l=Ce(a,i);return t.gullet.macros.set(`\\\\color@${s}`,{tokens:[{text:l}],numArgs:0}),{type:"internal",mode:t.mode}}}),c({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:1,argTypes:["size"],allowedInText:!0},handler({parser:e},t,r){const n=r[0],o=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:o,size:n&&ye(n,"size").value}},mathmlBuilder(e,t){const r=new N.MathNode("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){const n=pe(e.size,t);r.setAttribute("height",n.number+n.unit)}return r}});const Ie={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Le=t=>{const r=t.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(r))throw new e("Expected a control sequence",t);return r},Fe=(e,t,r,n)=>{let o=e.gullet.macros.get(r.text);null==o&&(r.noexpand=!0,o={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,o,n)};c({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:t,funcName:r}){t.consumeSpaces();const n=t.fetch();if(Ie[n.text])return"\\global"!==r&&"\\\\globallong"!==r||(n.text=Ie[n.text]),ye(t.parseFunction(),"internal");throw new e("Invalid token after macro prefix",n)}}),c({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 o=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(o))throw new e("Expected a control sequence",n);let s,a=0;const i=[[]];for(;"{"!==t.gullet.future().text;)if(n=t.gullet.popToken(),"#"===n.text){if("{"===t.gullet.future().text){s=t.gullet.future(),i[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++,i.push([])}else{if("EOF"===n.text)throw new e("Expected a macro definition");i[a].push(n.text)}let{tokens:l}=t.gullet.consumeArg();return s&&l.unshift(s),"\\edef"!==r&&"\\xdef"!==r||(l=t.gullet.expandTokens(l),l.reverse()),t.gullet.macros.set(o,{tokens:l,numArgs:a,delimiters:i},r===Ie[r]),{type:"internal",mode:t.mode}}}),c({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=Le(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 Fe(e,r,n,"\\\\globallet"===t),{type:"internal",mode:e.mode}}}),c({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){const r=Le(e.gullet.popToken()),n=e.gullet.popToken(),o=e.gullet.popToken();return Fe(e,r,o,"\\\\globalfuture"===t),e.gullet.pushToken(o),e.gullet.pushToken(n),{type:"internal",mode:e.mode}}}),c({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:t,funcName:r}){let n="";const o=t.gullet.popToken();"{"===o.text?(n=Le(t.gullet.popToken()),t.gullet.popToken()):n=Le(o);const s=t.gullet.isDefined(n);if(s&&"\\newcommand"===r)throw new e(`\\newcommand{${n}} attempting to redefine ${n}; use \\renewcommand`);if(!s&&"\\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:i}=t.gullet.consumeArg();return t.gullet.macros.set(n,{tokens:i,numArgs:a},!t.settings.strict),{type:"internal",mode:t.mode}}});const $e={"\\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}},Ge=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","\\llbracket","\\rrbracket","⟦","⟦","\\lBrace","\\rBrace","⦃","⦄","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."],De=[0,1.2,1.8,2.4,3];function Pe(t,r){"ordgroup"===t.type&&1===t.body.length&&"⁄"===t.body[0].text&&(t={type:"textord",text:"/",mode:"math"});const n=xe(t);if(n&&Ge.includes(n.text))return["<","\\lt"].includes(n.text)&&(n.text="⟨"),[">","\\gt"].includes(n.text)&&(n.text="⟩"),"/"===n.text&&(n.text="∕"),"\\backslash"===n.text&&(n.text="∖"),n;throw new e(n?`Invalid delimiter '${n.text}' after '${r.funcName}'`:`Invalid delimiter type '${t.type}'`,t)}c({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=Pe(t[0],e);return{type:"delimsizing",mode:e.parser.mode,size:$e[e.funcName].size,mclass:$e[e.funcName].mclass,delim:r.text}},mathmlBuilder:e=>{const t=[];"."===e.delim&&(e.delim=""),t.push(K(e.delim,e.mode));const r=new N.MathNode("mo",t);return"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),("∖"===e.delim||e.delim.indexOf("arrow")>-1)&&r.setAttribute("stretchy","true"),r.setAttribute("symmetric","true"),r.setAttribute("minsize",De[e.size]+"em"),r}}),c({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=t.parser.gullet.macros.get("\\current@color");if(n&&"string"!=typeof n)throw new e("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:t.parser.mode,delim:Pe(r[0],t).text,color:n}}}),c({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{const r=Pe(t[0],e),n=e.parser;++n.leftrightDepth;const o=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);const s=ye(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:o,left:r.text,right:s.delim,rightColor:s.color}},mathmlBuilder:(e,t)=>{!function(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}(e);const r=te(e.body,t);"."===e.left&&(e.left="");const n=new N.MathNode("mo",[K(e.left,e.mode)]);n.setAttribute("fence","true"),n.setAttribute("form","prefix"),("∖"===e.left||e.left.indexOf("arrow")>-1)&&n.setAttribute("stretchy","true"),r.unshift(n),"."===e.right&&(e.right="");const o=new N.MathNode("mo",[K(e.right,e.mode)]);return o.setAttribute("fence","true"),o.setAttribute("form","postfix"),("∖"===e.right||e.right.indexOf("arrow")>-1)&&o.setAttribute("stretchy","true"),e.rightColor&&o.setAttribute("mathcolor",e.rightColor),r.push(o),Q(r)}}),c({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,r)=>{const n=Pe(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=K(e.delim,e.mode),n=new N.MathNode("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 Re=e=>{const t=new N.MathNode("mspace");return t.setAttribute("width","3pt"),t},je=(e,t)=>{let r;switch(r=e.label.indexOf("colorbox")>-1?new N.MathNode("mpadded",[Re(),ne(e.body,t),Re()]):new N.MathNode("menclose",[ne(e.body,t)]),e.label){case"\\overline":r.setAttribute("notation","top"),r.style.padding="0.1em 0 0 0",r.style.borderTop="0.065em solid";break;case"\\underline":r.setAttribute("notation","bottom"),r.style.padding="0 0 0.1em 0",r.style.borderBottom="0.065em solid";break;case"\\cancel":r.setAttribute("notation","updiagonalstrike"),r.classes.push("cancel");break;case"\\bcancel":r.setAttribute("notation","downdiagonalstrike"),r.classes.push("bcancel");break;case"\\angl":r.setAttribute("notation","actuarial"),r.style.padding="0.03889em 0.03889em 0 0.03889em",r.style.borderTop="0.049em solid",r.style.borderRight="0.049em solid",r.style.marginRight="0.03889em";break;case"\\sout":r.setAttribute("notation","horizontalstrike"),r.style["text-decoration"]="line-through 0.08em solid";break;case"\\fbox":r.setAttribute("notation","box"),r.style={padding:"3pt",border:"1px solid"};break;case"\\fcolorbox":case"\\colorbox":{const t={padding:"3pt 0 3pt 0"};"\\fcolorbox"===e.label&&(t.border="0.06em solid "+String(e.borderColor)),r.style=t;break}case"\\xcancel":r.setAttribute("notation","updiagonalstrike downdiagonalstrike"),r.classes.push("xcancel")}return e.backgroundColor&&r.setAttribute("mathbackground",e.backgroundColor),r};c({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s="";if(o){const e=ye(r[0],"raw").string;s=Ce(o,e)}else s=ze(ye(r[0],"raw").string,e.gullet.macros);const a=r[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:s,body:a}},mathmlBuilder:je}),c({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:t},r,n){const o=n[0]&&ye(n[0],"raw").string;let s,a="";if(o){const e=ye(r[0],"raw").string,t=ye(r[0],"raw").string;a=Ce(o,e),s=Ce(o,t)}else a=ze(ye(r[0],"raw").string,e.gullet.macros),s=ze(ye(r[1],"raw").string,e.gullet.macros);const i=r[2];return{type:"enclose",mode:e.mode,label:t,backgroundColor:s,borderColor:a,body:i}},mathmlBuilder:je}),c({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]})}),c({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\sout","\\overline"],props:{numArgs:1},handler({parser:e,funcName:t},r){const n=r[0];return{type:"enclose",mode:e.mode,label:t,body:n}},mathmlBuilder:je}),c({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:je});const Ue={};function He({type:e,names:t,props:r,handler:n,mathmlBuilder:o}){const s={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:n};for(let e=0;e<t.length;++e)Ue[t[e]]=s;o&&(l[e]=o)}const _e=0,Ve=1,We=2,Xe=3;function Ze(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}const Ye=t=>{if(!t.parser.settings.displayMode)throw new e(`{${t.envName}} can be used only in display mode.`)},Ke=(e,t,r)=>{let n;const o=e.tags.shift();if(o){if(!o.body)return n=new N.MathNode("mtext",[],[]),n;n=re(o.body,t),n.classes=["tml-tag"]}else{if(e.envClasses.includes("multline")&&(e.leqno&&0!==r||!e.leqno&&r!==e.body.length-1))return n=new N.MathNode("mtext",[],[]),n;n=new N.MathNode("mtext",[],["tml-eqn"])}return n};function Je(t,{cols:r,envClasses:n,addEqnNum:o,singleRow:s,emptySingleRow:a,maxNumCols:i,leqno:l},c){t.gullet.beginGroup(),s||t.gullet.macros.set("\\cr","\\\\\\relax"),o&&(t.gullet.macros.set("\\tag","\\env@tag{\\text{#1}}"),t.gullet.macros.set("\\notag","\\env@notag"),t.gullet.macros.set("\\nonumber","\\env@notag")),t.gullet.beginGroup();let m=[];const u=[m],p=[],d=[];let h;const g=[];for(g.push(Ze(t));;){let r=t.parseExpression(!1,s?"\\end":"\\\\");if(o&&!h)for(let e=0;e<r.length;e++)if("envTag"===r[e].type||"noTag"===r[e].type){h="envTag"===r[e].type?r.splice(e,1)[0].body.body[0]:{body:null};break}t.gullet.endGroup(),t.gullet.beginGroup(),r={type:"ordgroup",mode:t.mode,body:r},m.push(r);const l=t.fetch().text;if("&"===l){if(i&&m.length===i){if(!n.includes("array"))throw new e(2===i?"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("\\end"===l){1===m.length&&0===r.body.length&&(u.length>1||!a)&&u.pop(),g.length<u.length+1&&g.push([]);break}if("\\\\"!==l)throw new e("Expected & or \\\\ or \\cr or \\end",t.nextToken);{let e;t.consume()," "!==t.gullet.future().text&&(e=t.parseSizeGroup(!0)),p.push(e?e.value:null),d.push(h),g.push(Ze(t)),m=[],h=null,u.push(m)}}}return t.gullet.endGroup(),t.gullet.endGroup(),d.push(h),{type:"array",mode:t.mode,body:u,cols:r,rowGaps:p,hLinesBeforeRow:g,envClasses:n,addEqnNum:o,scriptLevel:c,tags:d,leqno:l}}function Qe(e){return"d"===e.slice(0,1)?"display":"text"}const et={c:"center ",l:"left ",r:"right "},tt=e=>{const t=new N.MathNode("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},rt=function(e,t){const r=[],n=e.body.length,o=e.hLinesBeforeRow;for(let s=0;s<n;s++){const a=e.body[s],i=[],l="text"===e.scriptLevel?Ve:"script"===e.scriptLevel?We:_e;for(let r=0;r<a.length;r++){const o=new N.MathNode("mtd",[ne(a[r],t.withLevel(l))]);if(e.envClasses.includes("multline")){const e=0===s?"left":s===n-1?"right":"center";o.setAttribute("columnalign",e),"center"!==e&&(o.style.textAlign="-webkit-"+e)}i.push(o)}if(e.addEqnNum){i.unshift(tt(e)),i.push(tt(e));const r=Ke(e,t.withLevel(l),s);e.leqno?(i[0].children.push(r),i[0].style.textAlign="-webkit-left"):(i[i.length-1].children.push(r),i[i.length-1].style.textAlign="-webkit-right")}const c=new N.MathNode("mtr",i,[]);0===s&&o[0].length>0&&(2===o[0].length?c.classes.push("tml-top-double"):c.classes.push(o[0][0]?"tml-top-dashed":"tml-top-solid")),o[s+1].length>0&&(2===o[s+1].length?c.classes.push("tml-hline-double"):c.classes.push(o[s+1][0]?"tml-hline-dashed":"tml-hline-solid")),r.push(c)}let s=new N.MathNode("mtable",r);e.envClasses.length>0&&(s.classes=e.envClasses.map((e=>"tml-"+e))),"display"===e.scriptLevel&&s.setAttribute("displaystyle","true"),(e.addEqnNum||e.envClasses.includes("multline"))&&(s.style.width="100%");let a="";if(e.cols&&e.cols.length>0){const t=e.cols;let r=!1,n=0,o=t.length;for(;"separator"===t[n].type;)n+=1;for(;"separator"===t[o-1].type;)o-=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 s.children)t.children[0].style.borderLeft=e}let i=e.addEqnNum?0:-1;for(let e=n;e<o;e++)if("align"===t[e].type){const n=et[t[e].align];a+=n,i+=1;for(const e of s.children)"center"!==n.trim()&&i<e.children.length&&(e.children[i].style.textAlign="-webkit-"+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 s.children)i<e.children.length&&(e.children[i].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 s.children)t.children[t.children.length-1].style.borderRight=e,t.children[t.children.length-1].style.paddingRight="0.4em"}}return e.addEqnNum&&(a="left "+(a.length>0?a:"center ")+"right "),a&&s.setAttribute("columnalign",a.trim()),e.envClasses.includes("small")&&(s=new N.MathNode("mstyle",[s]),s.setAttribute("scriptlevel","1")),s},nt=function(t,r){-1===t.envName.indexOf("ed")&&Ye(t);const n=[],o=Je(t.parser,{cols:n,addEqnNum:"align"===t.envName||"alignat"===t.envName,emptySingleRow:!0,envClasses:["jot","abut"],maxNumCols:"split"===t.envName?2:void 0,leqno:t.parser.settings.leqno},"display");let s,a=0;if(r[0]&&"ordgroup"===r[0].type){let e="";for(let t=0;t<r[0].body.length;t++){e+=ye(r[0].body[t],"textord").text}s=Number(e),a=2*s}const i=!a;o.body.forEach((function(t){if(i)a<t.length&&(a=t.length);else{const r=t.length/2;if(s<r)throw new e(`Too many math in a row: expected ${s}, but got ${r}`,t[0])}}));for(let e=0;e<a;++e){let t="r";e%2==1&&(t="l"),n[e]={type:"align",align:t}}return"split"===t.envName||(t.envName.indexOf("ed")>-1?o.envClasses.push("aligned"):i?o.envClasses[1]="align*"===t.envName?"align-star":"align":o.envClasses.push("aligned")),o};He({type:"array",names:["array","darray"],props:{numArgs:1},handler(t,r){const n=(xe(r[0])?[r[0]]:ye(r[0],"ordgroup").body).map((function(t){const r=we(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)})),o={cols:n,envClasses:["array"],maxNumCols:n.length};return Je(t.parser,o,Qe(t.envName))},mathmlBuilder:rt}),He({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 o={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(),o.cols=[]}}const s=Je(t.parser,o,"text");return s.cols=new Array(s.body[0].length).fill({type:"align",align:n}),r?{type:"leftright",mode:t.mode,body:[s],left:r[0],right:r[1],rightColor:void 0}:s},mathmlBuilder:rt}),He({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){const t=Je(e.parser,{type:"small"},"script");return t.envClasses=["small"],t},mathmlBuilder:rt}),He({type:"array",names:["subarray"],props:{numArgs:1},handler(t,r){const n=(xe(r[0])?[r[0]]:ye(r[0],"ordgroup").body).map((function(t){const r=we(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 o={cols:n,envClasses:["small"]};if(o=Je(t.parser,o,"script"),o.body.length>0&&o.body[0].length>1)throw new e("{subarray} can contain only one column");return o},mathmlBuilder:rt}),He({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=Je(e.parser,{cols:[],envClasses:["cases"]},Qe(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:rt}),He({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:nt,mathmlBuilder:rt}),He({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:nt,mathmlBuilder:rt}),He({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){"gathered"!==e.envName&&Ye(e);const t={cols:[],envClasses:["jot","abut"],addEqnNum:"gather"===e.envName,emptySingleRow:!0,leqno:e.parser.settings.leqno};return Je(e.parser,t,"display")},mathmlBuilder:rt}),He({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){Ye(e);const t={addEqnNum:"equation"===e.envName,emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return Je(e.parser,t,"display")},mathmlBuilder:rt}),He({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){Ye(e);const t={addEqnNum:"multline"===e.envName,maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return Je(e.parser,t,"display")},mathmlBuilder:rt}),He({type:"array",names:["CD"],props:{numArgs:0},handler:t=>(Ye(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 o=[n];for(let i=0;i<r.length;i++){const l=r[i];let c={type:"styling",body:[],mode:"math",scriptLevel:"display"};for(let r=0;r<l.length;r++)if(ve(l[r])){n.push(c),r+=1;const o=we(l[r]).text,i=new Array(2);if(i[0]={type:"ordgroup",mode:"math",body:[]},i[1]={type:"ordgroup",mode:"math",body:[]},"=|.".indexOf(o)>-1);else{if(!("<>AV".indexOf(o)>-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<l.length;c++){if(a=o,("mathord"===(s=l[c]).type||"atom"===s.type)&&s.text===a){n=!1,r=c;break}if(ve(l[c]))throw new e("Missing a "+o+" character to complete a CD arrow.",l[c]);i[t].body.push(l[c])}if(n)throw new e("Missing a "+o+" character to complete a CD arrow.",l[r])}}const m=Ae(o,i,t);n.push(m),c={type:"styling",body:[],mode:"math",scriptLevel:"display"}}else c.body.push(l[r]);i%2==0?n.push(c):n.shift(),n=[],o.push(n)}var s,a;return o.pop(),t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:"math",body:o,envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(o.length+1).fill([])}}(t.parser)),mathmlBuilder:rt}),c({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 ot=Ue;c({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:t,funcName:r},n){const o=n[0];if("ordgroup"!==o.type)throw new e("Invalid environment name",o);let s="";for(let e=0;e<o.body.length;++e)s+=ye(o.body[e],"textord").text;if("\\begin"===r){if(!Object.prototype.hasOwnProperty.call(ot,s))throw new e("No such environment: "+s,o);const r=ot[s],{args:n,optArgs:a}=t.parseArguments("\\begin{"+s+"}",r),i={mode:t.mode,envName:s,parser:t},l=r.handler(i,n,a);t.expect("\\end",!1);const c=t.nextToken,m=ye(t.parseFunction(),"environment");if(m.name!==s)throw new e(`Mismatch: \\begin{${s}} matched by \\end{${m.name}}`,c);return l}return{type:"environment",mode:t.mode,name:s,nameGroup:o}}}),c({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 N.MathNode("mrow")}),c({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new N.MathNode("mrow")});const st=(e,t)=>{const r=e.font,n=t.withFont(r),o=ne(e.body,n);if(0===o.children.length)return o;if("boldsymbol"===r&&["mo","mpadded"].includes(o.type))return o.style.fontWeight="bold",o;let s="mo"===o.children[0].type;for(let e=1;e<o.children.length;e++){"mo"===o.children[e].type&&"boldsymbol"===r&&(o.children[e].style.fontWeight="bold"),"mi"!==o.children[e].type&&(s=!1);"normal"!==(o.children[e].attributes&&o.children[e].attributes.mathvariant||"")&&(s=!1)}if(!s)return o;const a=o.children[0];for(let e=1;e<o.children.length;e++)a.children.push(o.children[e].children[0]);if(o.attributes.mathcolor&&(a.attributes.mathcolor=o.attributes.mathcolor),a.attributes.mathvariant&&"normal"===a.attributes.mathvariant){const e=new N.MathNode("mtext",new N.TextNode("​"));return new N.MathNode("mrow",[e,a])}return a},at={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};c({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\up@greek","\\boldsymbol","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\oldstylenums","\\Bbb","\\bm","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=u(r[0]);let o=t;return o in at&&(o=at[o]),{type:"font",mode:e.mode,font:o.slice(1),body:n}},mathmlBuilder:st}),c({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:r},n)=>{const{mode:o}=e,s=e.parseExpression(!0,r);return{type:"font",mode:o,font:`math${t.slice(1)}`,body:{type:"ordgroup",mode:e.mode,body:s}}},mathmlBuilder:st});const it=["display","text","script","scriptscript"],lt={auto:-1,display:0,text:0,script:1,scriptscript:2},ct=(e,t)=>{const r="auto"===e.scriptLevel?t.incrementLevel():"display"===e.scriptLevel?t.withLevel(Ve):"text"===e.scriptLevel?t.withLevel(We):t.withLevel(Xe);let n=new N.MathNode("mfrac",[ne(e.numer,r),ne(e.denom,r)]);if(e.hasBarLine){if(e.barSize){const r=pe(e.barSize,t);n.setAttribute("linethickness",r.number+r.unit)}}else n.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new N.MathNode("mo",[new N.TextNode(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(n),null!=e.rightDelim){const r=new N.MathNode("mo",[new N.TextNode(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}n=Q(t)}return"auto"!==e.scriptLevel&&(n=new N.MathNode("mstyle",[n]),n.setAttribute("displaystyle",String("display"===e.scriptLevel)),n.setAttribute("scriptlevel",lt[e.scriptLevel])),n};c({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],o=r[1];let s=!1,a=null,i=null,l="auto";switch(t){case"\\dfrac":case"\\frac":case"\\tfrac":s=!0;break;case"\\\\atopfrac":s=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":a="(",i=")";break;case"\\\\bracefrac":a="\\{",i="\\}";break;case"\\\\brackfrac":a="[",i="]";break;default:throw new Error("Unrecognized genfrac command")}switch(t){case"\\dfrac":case"\\dbinom":l="display";break;case"\\tfrac":case"\\tbinom":l="text"}return{type:"genfrac",mode:e.mode,continued:!1,numer:n,denom:o,hasBarLine:s,leftDelim:a,rightDelim:i,scriptLevel:l,barSize:null}},mathmlBuilder:ct}),c({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:({parser:e,funcName:t},r)=>{const n=r[0],o=r[1];return{type:"genfrac",mode:e.mode,continued:!0,numer:n,denom:o,hasBarLine:!0,leftDelim:null,rightDelim:null,scriptLevel:"display",barSize:null}}}),c({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 mt=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};c({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],o=u(t[0]),s="atom"===o.type&&"open"===o.family?mt(o.text):null,a=u(t[1]),i="atom"===a.type&&"close"===a.family?mt(a.text):null,l=ye(t[2],"size");let c,m=null;l.isBlank?c=!0:(m=l.value,c=m.number>0);let p="auto",d=t[3];if("ordgroup"===d.type){if(d.body.length>0){const e=ye(d.body[0],"textord");p=it[Number(e.text)]}}else d=ye(d,"textord"),p=it[Number(d.text)];return{type:"genfrac",mode:e.mode,numer:r,denom:n,continued:!1,hasBarLine:c,barSize:m,leftDelim:s,rightDelim:i,scriptLevel:p}},mathmlBuilder:ct}),c({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:ye(n[0],"size").value,token:r})}),c({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:t},r)=>{const n=r[0],o=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e}(ye(r[1],"infix").barSize),s=r[2],a=o.number>0;return{type:"genfrac",mode:e.mode,numer:n,denom:s,continued:!1,hasBarLine:a,barSize:o,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:ct});c({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler:({parser:e,funcName:t},r)=>({type:"horizBrace",mode:e.mode,label:t,isOver:/^\\over/.test(t),base:r[0]}),mathmlBuilder:(e,t)=>{const r=S(e.label);return r.style["math-depth"]=0,new N.MathNode(e.isOver?"mover":"munder",[ne(e.base,t),r])}}),c({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:({parser:t,token:r},n)=>{const o=n[1],s=ye(n[0],"url").url;if(!t.settings.isTrusted({command:"\\href",url:s}))throw new e('Function "\\href" is not trusted',r);return{type:"href",mode:t.mode,href:s,body:p(o)}},mathmlBuilder:(e,t)=>{let r=re(e.body,t);return r instanceof k||(r=new k("mrow",[r])),r.setAttribute("href",e.href),r}}),c({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:({parser:t,token:r},n)=>{const o=ye(n[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:o}))throw new e('Function "\\url" is not trusted',r);const s=[];for(let e=0;e<o.length;e++){let t=o[e];"~"===t&&(t="\\textasciitilde"),s.push({type:"textord",mode:"text",text:t})}const a={type:"text",mode:t.mode,font:"\\texttt",body:s};return{type:"href",mode:t.mode,href:o,body:p(a)}}}),c({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:t,funcName:r,token:n},o)=>{const s=ye(o[0],"raw").string,a=o[1];if(t.settings.strict)throw new e(`Function "${r}" is disabled in strict mode`,n);let i;const l={};switch(r){case"\\class":l.class=s,i={command:"\\class",class:s};break;case"\\id":l.id=s,i={command:"\\id",id:s};break;case"\\style":l.style=s,i={command:"\\style",style:s};break;case"\\data":{const t=s.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");l["data-"+n[0].trim()]=n[1].trim()}i={command:"\\data",attributes:l};break}default:throw new Error("Unrecognized html command")}if(!t.settings.isTrusted(i))throw new e(`Function "${r}" is not trusted`,n);return{type:"html",mode:t.mode,attributes:l,body:p(a)}},mathmlBuilder:(e,t)=>{const r=re(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 ut=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(!me(n))throw new e("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};c({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:t,token:r},n,o)=>{let s={number:0,unit:"em"},a={number:.9,unit:"em"},i={number:0,unit:"em"},l="";if(o[0]){const t=ye(o[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":l=t;break;case"width":s=ut(t);break;case"height":a=ut(t);break;case"totalheight":i=ut(t);break;default:throw new e("Invalid key: '"+n[0]+"' in \\includegraphics.")}}}}const c=ye(n[0],"url").url;if(""===l&&(l=c,l=l.replace(/^.*[\\/]/,""),l=l.substring(0,l.lastIndexOf("."))),!t.settings.isTrusted({command:"\\includegraphics",url:c}))throw new e('Function "\\includegraphics" is not trusted',r);return{type:"includegraphics",mode:t.mode,alt:l,width:s,height:a,totalheight:i,src:c}},mathmlBuilder:(e,t)=>{const r=pe(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 o=0;e.width.number>0&&(o=pe(e.width,t));const s={height:r.number+n.number+"em"};o.number>0&&(s.width=o.number+o.unit),n.number>0&&(s.verticalAlign=-n.number+n.unit);const a=new x(e.src,e.alt,s);return a.height=r,a.depth=n,new N.MathNode("mtext",[a])}}),c({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:t,funcName:r,token:n},o){const s=ye(o[0],"size");if(t.settings.strict){const o="m"===r[1],a="mu"===s.value.unit;if(o){if(!a)throw new e(`LaTeX's ${r} supports only mu units, not ${s.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:s.value}},mathmlBuilder(e,t){const r=pe(e.dimension,t),n="em"===r.unit?pt(r.number):"";if("text"===e.mode&&n.length>0){const e=new N.TextNode(n);return new N.MathNode("mtext",[e])}{const e=new N.MathNode("mspace");return e.setAttribute("width",r.number+r.unit),r.number<0&&(e.style.marginLeft=r.number+r.unit),e}}});const pt=function(e){return e>=.05555&&e<=.05556?" ":e>=.1666&&e<=.1667?" ":e>=.2222&&e<=.2223?" ":e>=.2777&&e<=.2778?"  ":""},dt=/[^A-Za-z_0-9-]/g;c({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(dt,"")}),mathmlBuilder(e,t){const r=new N.MathNode("mrow",[],["tml-label"]);return e.string.length>0&&r.setAttribute("id",e.string),r}});const ht=["\\clap","\\llap","\\rlap"];c({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:t,funcName:r,token:n},o)=>{if(ht.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 s=o[0];return{type:"lap",mode:t.mode,alignment:r,body:s}},mathmlBuilder:(e,t)=>{let r;if("llap"===e.alignment){const n=te(p(e.body),t),o=new N.MathNode("mphantom",n);r=new N.MathNode("mpadded",[o]),r.setAttribute("width","0px")}const n=ne(e.body,t);let o;if("llap"===e.alignment?(n.style.position="absolute",n.style.right="0",n.style.bottom="0",o=new N.MathNode("mpadded",[r,n])):o=new N.MathNode("mpadded",[n]),"rlap"===e.alignment)e.body.body.length>0&&"genfrac"===e.body.body[0].type&&o.setAttribute("lspace","0.16667em");else{const t="llap"===e.alignment?"-1":"-0.5";o.setAttribute("lspace",t+"width"),"llap"===e.alignment?o.style.position="relative":(o.style.display="flex",o.style.justifyContent="center")}return o.setAttribute("width","0px"),o}}),c({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},r){const n=t.mode;t.switchMode("math");const o="\\("===e?"\\)":"$",s=t.parseExpression(!1,o);return t.expect(o),t.switchMode(n),{type:"ordgroup",mode:t.mode,body:s}}}),c({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,r){throw new e(`Mismatched ${t.funcName}`,r)}});c({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:p(t[0]),text:p(t[1]),script:p(t[2]),scriptscript:p(t[3])}),mathmlBuilder:(e,t)=>{const r=((e,t)=>{switch(t.level){case _e:return e.display;case Ve:return e.text;case We:return e.script;case Xe:return e.scriptscript;default:return e.text}})(e,t);return re(r,t)}});const gt=["text","textord","mathord","atom"],ft=e=>{const t=new N.MathNode("mspace");return t.setAttribute("width",e+"em"),t};function bt(e,t){let r;const n=te(e.body,t);if("minner"===e.mclass)r=new N.MathNode("mpadded",n);else if("mord"===e.mclass)e.isCharacterBox||"mathord"===n[0].type?(r=n[0],r.type="mi"):r=new N.MathNode("mi",n);else{r=new N.MathNode("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 N.MathNode("mrow",n);const o=t.level<2;"mrow"===r.type?o&&("mbin"===e.mclass?(r.children.unshift(ft(.2222)),r.children.push(ft(.2222))):"mrel"===e.mclass?(r.children.unshift(ft(.2778)),r.children.push(ft(.2778))):"mpunct"===e.mclass?r.children.push(ft(.1667)):"minner"===e.mclass&&(r.children.unshift(ft(.0556)),r.children.push(ft(.0556)))):"mbin"===e.mclass?(r.attributes.lspace=o?"0.2222em":"0",r.attributes.rspace=o?"0.2222em":"0"):"mrel"===e.mclass?(r.attributes.lspace=o?"0.2778em":"0",r.attributes.rspace=o?"0.2778em":"0"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace=o?"0.1667em":"0"):"mopen"===e.mclass||"mclose"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0em"):"minner"===e.mclass&&o&&(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}c({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],o=s.isCharacterBox(n);let a=!0;const i={type:"mathord",text:"",mode:e.mode},l=n.body?n.body:[n];for(const e of l){if(!gt.includes(e.type)){a=!1;break}e.text?i.text+=e.text:e.body&&e.body.map((e=>{i.text+=e.text}))}return{type:"mclass",mode:e.mode,mclass:"m"+t.slice(5),body:p(a?i:n),isCharacterBox:o,mustPromote:a}},mathmlBuilder:bt});const yt=e=>{const t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};c({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:yt(t[0]),body:p(t[1]),isCharacterBox:s.isCharacterBox(t[1])})}),c({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:t},r){const n=r[1],o=r[0],s={type:"op",mode:n.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,stack:!0,suppressBaseShift:"\\stackrel"!==t,body:p(n)};return{type:"supsub",mode:o.mode,base:s,sup:"\\underset"===t?null:o,sub:"\\underset"===t?o:null}},mathmlBuilder:bt});const wt=(e,t,r)=>{if(!e)return r;const n=ne(e,t);return"mrow"===n.type&&0===n.children.length?r:n};c({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:t,funcName:r,token:n},o){if(0===o[2].body.length)throw new e(r+"cannot parse an empty base.");const s=o[2].body[0];if(t.settings.strict&&"\\sideset"===r&&!s.symbol)throw new e("The base of \\sideset must be a big operator. Try \\prescript.");if(o[0].body.length>0&&"supsub"!==o[0].body[0].type||o[1].body.length>0&&"supsub"!==o[1].body[0].type)throw new e("\\sideset can parse only subscripts and superscripts in its first two arguments",n);const a=o[0].body.length>0?o[0].body[0]:null,i=o[1].body.length>0?o[1].body[0]:null;return a||i?a?{type:"multiscript",mode:t.mode,isSideset:"\\sideset"===r,prescripts:a,postscripts:i,base:s}:{type:"styling",mode:t.mode,scriptLevel:"text",body:[{type:"supsub",mode:t.mode,base:s,sup:i.sup,sub:i.sub}]}:s},mathmlBuilder(e,t){const r=ne(e.base,t),n=new N.MathNode("mprescripts"),o=new N.MathNode("none");let s=[];const a=wt(e.prescripts.sub,t,o),i=wt(e.prescripts.sup,t,o);if(e.isSideset&&(a.setAttribute("style","text-align: left;"),i.setAttribute("style","text-align: left;")),e.postscripts){s=[r,wt(e.postscripts.sub,t,o),wt(e.postscripts.sup,t,o),n,a,i]}else s=[r,n,a,i];return new N.MathNode("mmultiscripts",s)}}),c({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){const r=s.isCharacterBox(t[0]);let n;if(r)n=p(t[0]),"\\"===n[0].text.charAt(0)&&(n[0].text=M.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 te(e.body,t)[0]}return re(e.body,t,!0)}});const xt=["textord","mathord","atom"],kt=["\\smallint"],vt=["textord","mathord","ordgroup","close","leftright"],At=["}","\\left","\\middle","\\right"],Nt=e=>e.length>0&&(Ge.includes(e)||$e[e]||At.includes(e)),Tt=(e,t)=>{let r;if(e.symbol)r=new k("mo",[K(e.name,e.mode)]),kt.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false");else if(e.body)r=new k("mo",te(e.body,t));else if(r=new k("mi",[new v(e.name.slice(1))]),!e.parentIsSupSub){const t=[r,new k("mo",[K("⁡","text")])];if(e.needsLeadingSpace){const e=new k("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new k("mspace");e.setAttribute("width","0.1667em"),t.push(e)}r=new k("mrow",t)}return r},St={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨅":"\\bigsqcap","⨆":"\\bigsqcup"};c({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcap","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],props:{numArgs:0},handler:({parser:e,funcName:t},r)=>{let n=t;return 1===n.length&&(n=St[n]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:Tt}),c({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{const r=t[0],n=r.body?r.body:[r],o=1===n.length&&xt.includes(n[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:o,stack:!1,name:o?n[0].text:null,body:o?null:p(r)}},mathmlBuilder:Tt});const qt={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint","∱":"\\intclockwise","∲":"\\varointclockwise","⨌":"\\iiiint","⨍":"\\intbar","⨎":"\\intBar","⨏":"\\fint","⨒":"\\rppolint","⨓":"\\scpolint","⨕":"\\pointint","⨖":"\\sqint","⨗":"\\intlarhk","⨘":"\\intx","⨙":"\\intcap","⨚":"\\intcup"};c({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:Nt(n),needsLeadingSpace:r.length>0&&vt.includes(r),name:t}},mathmlBuilder:Tt}),c({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:Nt(n),needsLeadingSpace:r.length>0&&vt.includes(r),name:t}},mathmlBuilder:Tt}),c({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},handler({parser:e,funcName:t}){let r=t;return 1===r.length&&(r=qt[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:Tt});const Ot={};function Mt(e,t){Ot[e]=t}const Bt=["}","\\left","\\middle","\\right"];c({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{const n=r[0],o=e.prevAtomType,s=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:p(n),alwaysHandleSupSub:"\\operatornamewithlimits"===t,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:(a=s,a.length>0&&(Ge.includes(a)||$e[a]||Bt.includes(a))),needsLeadingSpace:o.length>0&&vt.includes(o)};var a},mathmlBuilder:(e,t)=>{let r,n=te(e.body,t.withFont("mathrm")),o=!0;for(let e=0;e<n.length;e++){const t=n[e];if(t instanceof N.MathNode)switch(t.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(t.attributes.width){const r=t.attributes.width.replace("em",""),s=pt(Number(r));""===s?o=!1:n[e]=new N.MathNode("mtext",[new N.TextNode(s)])}break;case"mo":{const e=t.children[0];1===t.children.length&&e instanceof N.TextNode?e.text=e.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):o=!1;break}default:o=!1}else o=!1}if(o){const e=n.map((e=>e.toText())).join("");n=[new N.TextNode(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 N.MathNode("mrow",n);{const e=new N.MathNode("mo",[K("⁡","text")]);return N.newDocumentFragment([n[0],e])}}if(o?(r=new N.MathNode("mi",n),r.setAttribute("mathvariant","normal")):r=new N.MathNode("mrow",n),!e.parentIsSupSub){const t=[r,new N.MathNode("mo",[K("⁡","text")])];if(e.needsLeadingSpace){const e=new N.MathNode("mspace");e.setAttribute("width","0.1667em"),t.unshift(e)}if(!e.isFollowedByDelimiter){const e=new N.MathNode("mspace");e.setAttribute("width","0.1667em"),t.push(e)}return N.newDocumentFragment(t)}return r}}),Mt("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),m({type:"ordgroup",mathmlBuilder:(e,t)=>re(e.body,t,!0)}),c({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{const r=t[0];return{type:"phantom",mode:e.mode,body:p(r)}},mathmlBuilder:(e,t)=>{const r=te(e.body,t);return new N.MathNode("mphantom",r)}}),c({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=te(p(e.body),t),n=new N.MathNode("mphantom",r),o=new N.MathNode("mpadded",[n]);return o.setAttribute("height","0px"),o.setAttribute("depth","0px"),o}}),c({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=te(p(e.body),t),n=new N.MathNode("mphantom",r),o=new N.MathNode("mpadded",[n]);return o.setAttribute("width","0px"),o}}),c({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:p(t[0])}),mathmlBuilder(e,t){const r=te(e.body,t),n=A(r);return n.setAttribute("style","font-weight:bold"),n}});const Ct=e=>e>=0?"+":"-",zt=(e,t)=>{const r=t.withLevel(Ve),n=new N.MathNode("mpadded",[ne(e.body,r)]),o=pe(e.dy,t);n.setAttribute("voffset",o.number+o.unit);const s=Math.abs(o.number);return n.setAttribute("height",Ct(o.number)+s+o.unit),n.setAttribute("depth",Ct(-o.number)+s+o.unit),n};c({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},r){const n=ye(r[0],"size").value;"\\lower"===t&&(n.number*=-1);const o=r[1];return{type:"raise",mode:e.mode,dy:n,body:o}},mathmlBuilder:zt}),c({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},r){const n=ye(r[0],"size").value,o=r[1];return{type:"raise",mode:e.mode,dy:n,body:o}},mathmlBuilder:zt}),c({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(dt,"")}),mathmlBuilder(e,t){const r="\\ref"===e.funcName?["tml-ref"]:["tml-ref","tml-eqref"],n=new N.MathNode("mtext",[new N.TextNode("")],r);return n.setAttribute("href","#"+e.string),n}}),c({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),c({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"]},handler({parser:e},t,r){const n=r[0],o=ye(t[0],"size"),s=ye(t[1],"size");return{type:"rule",mode:e.mode,shift:n&&ye(n,"size").value,width:o.value,height:s.value}},mathmlBuilder(e,t){const r=pe(e.width,t),n=pe(e.height,t),o=e.shift?pe(e.shift,t):{number:0,unit:"em"},s=t.color&&t.getColor()||"black",a=new N.MathNode("mspace");if(r.number>0&&n.number>0&&a.setAttribute("mathbackground",s),a.setAttribute("width",r.number+r.unit),a.setAttribute("height",n.number+n.unit),0===o.number)return a;const i=new N.MathNode("mpadded",[a]);return o.number>=0?i.setAttribute("height","+"+o.number+o.unit):(i.setAttribute("height",o.number+o.unit),i.setAttribute("depth","+"+-o.number+o.unit)),i.setAttribute("voffset",o.number+o.unit),i}});const Et={"\\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};c({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 o=r.parseExpression(!1,e);return{type:"sizing",mode:r.mode,funcName:t,body:o}},mathmlBuilder:(e,t)=>{const r=t.withFontSize(Et[e.funcName]),n=te(e.body,r),o=A(n),s=(Et[e.funcName]/t.fontSize).toFixed(4);return o.setAttribute("mathsize",s+"em"),o}}),c({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,r)=>{let n=!1,o=!1;const s=r[0]&&ye(r[0],"ordgroup");if(s){let e="";for(let t=0;t<s.body.length;++t){if(e=s.body[t].text,"t"===e)n=!0;else{if("b"!==e){n=!1,o=!1;break}o=!0}}}else n=!0,o=!0;const a=t[0];return{type:"smash",mode:e.mode,body:a,smashHeight:n,smashDepth:o}},mathmlBuilder:(e,t)=>{const r=new N.MathNode("mpadded",[ne(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),c({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,r){const n=r[0],o=t[0];return{type:"sqrt",mode:e.mode,body:o,index:n}},mathmlBuilder(e,t){const{body:r,index:n}=e;return n?new N.MathNode("mroot",[ne(r,t),ne(n,t.incrementLevel())]):new N.MathNode("msqrt",[ne(r,t)])}});const It={display:0,text:1,script:2,scriptscript:3},Lt={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};c({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:r},n){const o=r.parseExpression(!0,e),s=t.slice(1,t.length-5);return{type:"styling",mode:r.mode,scriptLevel:s,body:o}},mathmlBuilder(e,t){const r=t.withLevel(It[e.scriptLevel]),n=te(e.body,r),o=A(n),s=Lt[e.scriptLevel];return o.setAttribute("scriptlevel",s[0]),o.setAttribute("displaystyle",s[1]),o}});const Ft=/^m(over|under|underover)$/;m({type:"supsub",mathmlBuilder(e,t){let r,n,o=!1,s=!1,a=!1;e.base&&"horizBrace"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(o=!0,r=e.base.isOver)),!e.base||e.base.stack||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0,s=!e.base.symbol,a=e.base.needsLeadingSpace);const i=e.base&&e.base.stack?[ne(e.base.body[0],t)]:[ne(e.base,t)],l=t.inSubOrSup();let c;if(e.sub&&i.push(ne(e.sub,l)),e.sup&&i.push(ne(e.sup,l)),o)c=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;c=r&&("op"===r.type&&r.limits||"multiscript"===r.type)&&(t.level===_e||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.level===_e||r.limits)?"munderover":"msubsup"}else{const r=e.base;c=r&&"op"===r.type&&r.limits&&(t.level===_e||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===_e)?"munder":"msub"}else{const r=e.base;c=r&&"op"===r.type&&r.limits&&(t.level===_e||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.level===_e)?"mover":"msup"}let m=new N.MathNode(c,i);if(s){const e=new N.MathNode("mo",[K("⁡","text")]);if(a){const t=new N.MathNode("mspace");t.setAttribute("width","0.1667em"),m=N.newDocumentFragment([t,m,e])}else m=N.newDocumentFragment([m,e])}else Ft.test(c)&&(m=new N.MathNode("mrow",[m]));return m}});const $t=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],Gt=["\\Rsh","\\Lsh","\\restriction"];m({type:"atom",mathmlBuilder(e,t){const r=new N.MathNode("mo",[K(e.text,e.mode)]);return"punct"===e.family?r.setAttribute("separator","true"):"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")):"\\mid"===e.text?(r.setAttribute("lspace","0.22em"),r.setAttribute("rspace","0.22em"),r.setAttribute("stretchy","false")):"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||Gt.includes(e)})(e.text)?r.setAttribute("stretchy","false"):$t.includes(e.text)?r.setAttribute("mathsize","70%"):":"===e.text&&(r.attributes.lspace="0.2222em",r.attributes.rspace="0.2222em"),r}});const Dt={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace",oldstylenums:"oldstylenums"},Pt=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"mathtt":return"monospace";case"oldstylenums":return"oldstylenums"}let o=e.text;return M[n][o]&&M[n][o].replace&&(o=M[n][o].replace),Object.prototype.hasOwnProperty.call(Dt,r)?Dt[r]:null},Rt=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),jt=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Ut=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),Ht=Object.freeze({"ϵ":119527,"ϑ":119564,"ϰ":119534,"φ":119577,"ϱ":119535,"ϖ":119563}),_t=Object.freeze({"ϵ":119643,"ϑ":119680,"ϰ":119650,"φ":119693,"ϱ":119651,"ϖ":119679}),Vt=Object.freeze({"ϵ":119701,"ϑ":119738,"ϰ":119708,"φ":119751,"ϱ":119709,"ϖ":119737}),Wt=Object.freeze({"ϵ":119759,"ϑ":119796,"ϰ":119766,"φ":119809,"ϱ":119767,"ϖ":119795}),Xt=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>Rt[e]||119899,"script-bold":e=>119951,fraktur:e=>jt[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>Ut[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=>Rt[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=>"∇"===e?111802:119575,italic:e=>"∇"===e?111860:119633,"bold-italic":e=>"∇"===e?111802:119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>"∇"===e?111976:119749,"sans-serif-bold":e=>"∇"===e?111976:119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>"∇"===e?112034: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=>Ht[e]||-51,italic:e=>0,"bold-italic":e=>_t[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Vt[e]||116,"sans-serif-bold":e=>Vt[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Wt[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}}),Zt=(e,t)=>{const r=e.codePointAt(0),n=64<r&&r<91?"upperCaseLatin":96<r&&r<123?"lowerCaseLatin":912<r&&r<938||"∇"===e?"upperCaseGreek":944<r&&r<970||"ϕ"===e?"lowerCaseGreek":120545<r&&r<120572||Ht[e]?"varGreek":47<r&&r<58?"numeral":"other";return"other"===n?e:String.fromCodePoint(r+Xt[n][t](e))},Yt=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:"ᴢ"}),Kt=/^\d(?:[\d,.]*\d)?$/,Jt=/[A-Ba-z]/;m({type:"mathord",mathmlBuilder(e,t){const r=K(e.text,e.mode,t),n=r.text.codePointAt(0),o=912<n&&n<938?"normal":"italic",s=Pt(e,t)||o;if("script"===s)return r.text=Zt(r.text,s),new N.MathNode("mi",[r],[t.font]);"italic"!==s&&(r.text=Zt(r.text,s));let a=new N.MathNode("mi",[r]);return"normal"===s&&(a.setAttribute("mathvariant","normal"),1===r.text.length&&(a=new N.MathNode("mrow",[a]))),a}}),m({type:"textord",mathmlBuilder(e,t){let r=e.text;const n=r.codePointAt(0);"textsc"===t.fontFamily&&96<n&&n<123&&(r=Yt[r]);const o=K(r,e.mode,t),s=Pt(e,t)||"normal";let a;if(Kt.test(e.text)){const t="text"===e.mode?"mtext":"mn";if("oldstylenums"===s){const e=new N.MathNode("mstyle",[o],["oldstylenums"]);a=new N.MathNode(t,[e])}else{if("italic"===s||"bold-italic"===s)return((e,t,r)=>{const n=new N.MathNode(r,[e]),o=new N.MathNode("mstyle",[n]);return o.style["font-style"]="italic",o.style["font-family"]="Cambria, 'Times New Roman', serif","bold-italic"===t&&(o.style["font-weight"]="bold"),o})(o,s,t);"normal"!==s&&(o.text=o.text.split("").map((e=>Zt(e,s))).join("")),a=new N.MathNode(t,[o])}}else if("text"===e.mode)"normal"!==s&&(o.text=Zt(o.text,s)),a=new N.MathNode("mtext",[o]);else if("\\prime"===e.text)a=new N.MathNode("mo",[o]),a.classes.push("tml-prime");else{const e=o.text;"italic"!==s&&(o.text=Zt(o.text,s)),a=new N.MathNode("mi",[o]),o.text===e&&Jt.test(e)&&a.setAttribute("mathvariant","italic")}return a}});const Qt={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},er={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};m({type:"spacing",mathmlBuilder(t,r){let n;if(Object.prototype.hasOwnProperty.call(er,t.text))n=new N.MathNode("mtext",[new N.TextNode(" ")]);else{if(!Object.prototype.hasOwnProperty.call(Qt,t.text))throw new e(`Unknown type of space "${t.text}"`);n=new N.MathNode("mo"),"\\nobreak"===t.text&&n.setAttribute("linebreak","nobreak")}return n}}),m({type:"tag"});const tr={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},rr={"\\textbf":"textbf","\\textmd":"textmd"},nr={"\\textit":"textit","\\textup":"textup"};c({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textsc","\\textbf","\\textmd","\\textit","\\textup"],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:p(n),font:t}},mathmlBuilder(e,t){const r=((e,t)=>{const r=e.font;return r?tr[r]?t.withTextFontFamily(tr[r]):rr[r]?t.withTextFontWeight(rr[r]):t.withTextFontShape(nr[r]):t})(e,t),n=re(e.body,r);return J(n)}}),c({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(t,r,n){throw new e("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(e,t){const r=new N.TextNode(or(e)),n=new N.MathNode("mtext",[r]);return n.setAttribute("mathvariant","monospace"),n}});const or=e=>e.body.replace(/ /g,e.star?"␣":" "),sr=i;class ar{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 ar(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class ir{constructor(e,t){this.text=e,this.loc=t}range(e,t){return new ir(t,ar.range(this,e))}}const lr=new RegExp("[̀-ͯ]+$"),cr="([ \r\n\t]+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|(number|[!-\\[\\]-‧‪-퟿豈-￿][̀-ͯ]*|[\ud800-\udbff][\udc00-\udfff][̀-ͯ]*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|(\\\\[a-zA-Z@]+)[ \r\n\t]*|\\\\[^\ud800-\udfff])";class mr{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(cr.replace("number|",t.strict?"":"\\d(?:[\\d,.]*\\d)?|"),"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 ir("EOF",new ar(this,r,r));const n=this.tokenRegex.exec(t);if(null===n||n.index!==r)throw new e(`Unexpected character: '${t[r]}'`,new ir(t[r],new ar(this,r,r+1)));const o=n[6]||n[3]||(n[2]?"\\ ":" ");if(14===this.catcodes[o]){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 ir(o,new ar(this,r,this.tokenRegex.lastIndex))}}class ur{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 pr=Ot;Mt("\\noexpand",(function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}})),Mt("\\expandafter",(function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}})),Mt("\\@firstoftwo",(function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}})),Mt("\\@secondoftwo",(function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}})),Mt("\\@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}})),Mt("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Mt("\\TextOrMath",(function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}}));const dr={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},hr=e=>{const t=e.future().text;return"EOF"===t?[null,""]:[dr[t.charAt(0)],t]},gr=(e,t,r)=>{for(let n=1;n<t.length;n++){e*=r,e+=dr[t.charAt(n)]}return e};Mt("\\char",(function(t){let r,n=t.popToken(),o="";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])o=n.text.charCodeAt(1);else{if("EOF"===n.text)throw new e("\\char` missing argument");o=n.text.charCodeAt(0)}else r=10;if(r){let s,a=n.text;if(o=dr[a.charAt(0)],null==o||o>=r)throw new e(`Invalid base-${r} digit ${n.text}`);for(o=gr(o,a,r),[s,a]=hr(t);null!=s&&s<r;)o*=r,o+=s,o=gr(o,a,r),t.popToken(),[s,a]=hr(t)}return`\\@char{${o}}`})),Mt("\\surd","\\sqrt{\\vphantom{|}}"),Mt("\\hbox","\\text{#1}"),Mt("/","{⁄}"),Mt("\\long",""),Mt("\\bgroup","{"),Mt("\\egroup","}"),Mt("~","\\nobreakspace"),Mt("\\lq","`"),Mt("\\rq","'"),Mt("\\aa","\\r a"),Mt("\\Bbbk","\\Bbb{k}"),Mt("\\mathstrut","\\vphantom{(}"),Mt("\\underbar","\\underline{\\text{#1}}"),Mt("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),Mt("⋮","\\vdots"),Mt("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Mt("\\boxed","\\fbox{$\\displaystyle{#1}$}"),Mt("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Mt("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Mt("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");const fr={",":"\\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","\\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"};Mt("\\dots",(function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in fr?t=fr[r]:("\\not"===r.slice(0,4)||r in M.math&&["bin","rel"].includes(M.math[r].group))&&(t="\\dotsb"),t}));const br={")":!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};Mt("\\dotso",(function(e){return e.future().text in br?"\\ldots\\,":"\\ldots"})),Mt("\\dotsc",(function(e){const t=e.future().text;return t in br&&","!==t?"\\ldots\\,":"\\ldots"})),Mt("\\cdots",(function(e){return e.future().text in br?"\\@cdots\\,":"\\@cdots"})),Mt("\\dotsb","\\cdots"),Mt("\\dotsm","\\cdots"),Mt("\\dotsi","\\!\\cdots"),Mt("\\idotsint","\\dotsi"),Mt("\\dotsx","\\ldots\\,"),Mt("\\DOTSI","\\relax"),Mt("\\DOTSB","\\relax"),Mt("\\DOTSX","\\relax"),Mt("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Mt("\\,","{\\tmspace+{3mu}{.1667em}}"),Mt("\\thinspace","\\,"),Mt("\\>","\\mskip{4mu}"),Mt("\\:","{\\tmspace+{4mu}{.2222em}}"),Mt("\\medspace","\\:"),Mt("\\;","{\\tmspace+{5mu}{.2777em}}"),Mt("\\thickspace","\\;"),Mt("\\!","{\\tmspace-{3mu}{.1667em}}"),Mt("\\negthinspace","\\!"),Mt("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),Mt("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),Mt("\\enspace","\\kern.5em "),Mt("\\enskip","\\hskip.5em\\relax"),Mt("\\quad","\\hskip1em\\relax"),Mt("\\qquad","\\hskip2em\\relax"),Mt("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Mt("\\tag@paren","\\tag@literal{({#1})}"),Mt("\\tag@literal",(t=>{if(t.macros.get("\\df@tag"))throw new e("Multiple \\tag");return"\\def\\df@tag{\\text{#1}}"})),Mt("\\bmod","\\mathbin{\\text{mod}}"),Mt("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Mt("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Mt("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Mt("\\newline","\\\\\\relax"),Mt("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),Mt("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),Mt("\\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}}"),Mt("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Mt("\\@hspace","\\hskip #1\\relax"),Mt("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Mt("\\colon",'\\mathpunct{\\char"3a}'),Mt("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),Mt("\\ordinarycolon",'\\char"3a'),Mt("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),Mt("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),Mt("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),Mt("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),Mt("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),Mt("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),Mt("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),Mt("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Mt("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),Mt("\\ratio","\\vcentcolon"),Mt("\\coloncolon","\\dblcolon"),Mt("\\colonequals","\\coloneqq"),Mt("\\coloncolonequals","\\Coloneqq"),Mt("\\equalscolon","\\eqqcolon"),Mt("\\equalscoloncolon","\\Eqqcolon"),Mt("\\colonminus","\\coloneq"),Mt("\\coloncolonminus","\\Coloneq"),Mt("\\minuscolon","\\eqcolon"),Mt("\\minuscoloncolon","\\Eqcolon"),Mt("\\coloncolonapprox","\\Colonapprox"),Mt("\\coloncolonsim","\\Colonsim"),Mt("\\notni","\\mathrel{\\char`∌}"),Mt("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Mt("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Mt("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Mt("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Mt("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),Mt("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),Mt("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),Mt("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),Mt("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),Mt("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Mt("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Mt("\\plim","\\DOTSB\\operatorname*{plim}"),Mt("\\bra","\\mathinner{\\langle{#1}|}"),Mt("\\ket","\\mathinner{|{#1}\\rangle}"),Mt("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Mt("\\Bra","\\left\\langle#1\\right|"),Mt("\\Ket","\\left|#1\\right\\rangle");const yr=e=>t=>{const r=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,s=t.consumeArg().tokens,a=t.macros.get("|"),i=t.macros.get("\\|");t.macros.beginGroup();const l=t=>r=>{e&&(r.macros.set("|",a),o.length&&r.macros.set("\\|",i));let s=t;if(!t&&o.length){"|"===r.future().text&&(r.popToken(),s=!0)}return{tokens:s?o:n,numArgs:0}};t.macros.set("|",l(!1)),o.length&&t.macros.set("\\|",l(!0));const c=t.consumeArg().tokens,m=t.expandTokens([...s,...c,...r]);return t.macros.endGroup(),{tokens:m.reverse(),numArgs:0}};Mt("\\bra@ket",yr(!1)),Mt("\\bra@set",yr(!0)),Mt("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),Mt("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),Mt("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),Mt("\\angln","{\\angl n}"),Mt("\\odv","\\@ifstar\\odv@next\\odv@numerator"),Mt("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),Mt("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),Mt("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");const wr=e=>{const t=e[0][0].text,r=(e=>{let t="";for(let r=e.length-1;r>-1;r--)t+=e[r].text;return t})(e[1]).split(","),n=String(r.length),o="1"===n?"\\partial":`\\partial^${n}`;let s="";return r.map((e=>{s+="\\partial "+e.trim()+"\\,"})),[t,o,s.replace(/\\,$/,"")]};Mt("\\pdv@numerator",(function(e){const[t,r,n]=wr(e.consumeArgs(2));return`\\frac{${r} ${t}}{${n}}`})),Mt("\\pdv@next",(function(e){const[t,r,n]=wr(e.consumeArgs(2));return`\\frac{${r}}{${n}} ${t}`})),Mt("\\upalpha","\\up@greek{\\alpha}"),Mt("\\upbeta","\\up@greek{\\beta}"),Mt("\\upgamma","\\up@greek{\\gamma}"),Mt("\\updelta","\\up@greek{\\delta}"),Mt("\\upepsilon","\\up@greek{\\epsilon}"),Mt("\\upzeta","\\up@greek{\\zeta}"),Mt("\\upeta","\\up@greek{\\eta}"),Mt("\\uptheta","\\up@greek{\\theta}"),Mt("\\upiota","\\up@greek{\\iota}"),Mt("\\upkappa","\\up@greek{\\kappa}"),Mt("\\uplambda","\\up@greek{\\lambda}"),Mt("\\upmu","\\up@greek{\\mu}"),Mt("\\upnu","\\up@greek{\\nu}"),Mt("\\upxi","\\up@greek{\\xi}"),Mt("\\upomicron","\\up@greek{\\omicron}"),Mt("\\uppi","\\up@greek{\\pi}"),Mt("\\upalpha","\\up@greek{\\alpha}"),Mt("\\uprho","\\up@greek{\\rho}"),Mt("\\upsigma","\\up@greek{\\sigma}"),Mt("\\uptau","\\up@greek{\\tau}"),Mt("\\upupsilon","\\up@greek{\\upsilon}"),Mt("\\upphi","\\up@greek{\\phi}"),Mt("\\upchi","\\up@greek{\\chi}"),Mt("\\uppsi","\\up@greek{\\psi}"),Mt("\\upomega","\\up@greek{\\omega}"),Mt("\\invamp",'\\mathbin{\\char"214b}'),Mt("\\parr",'\\mathbin{\\char"214b}'),Mt("\\with",'\\mathbin{\\char"26}'),Mt("\\multimapinv",'\\mathrel{\\char"27dc}'),Mt("\\multimapboth",'\\mathrel{\\char"29df}'),Mt("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),Mt("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),Mt("\\coh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}\n{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}'),Mt("\\incoh",'{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}\n{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}'),Mt("\\standardstate","\\text{\\tiny\\char`⦵}");const xr={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class kr{constructor(e,t,r){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new ur(pr,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new mr(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 ir("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 o=this.future();let s,a=0,i=0;do{if(s=this.popToken(),r.push(s),"{"===s.text)++a;else if("}"===s.text){if(--a,-1===a)throw new e("Extra }",s)}else if("EOF"===s.text)throw new e("Unexpected end of input in a macro argument, expected '"+(t&&n?t[i]:"}")+"'",s);if(t&&n)if((0===a||1===a&&"{"===t[i])&&s.text===t[i]){if(++i,i===t.length){r.splice(-i,i);break}}else i=0}while(0!==a||n);return"{"===o.text&&"}"===r[r.length-1].text&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:o,end:s}}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,o=r.noexpand?null:this._getExpansion(n);if(null==o||t&&o.unexpandable){if(t&&null==o&&"\\"===n[0]&&!this.isDefined(n))throw new e("Undefined control sequence: "+n);return this.pushToken(r),r}if(this.expansionCount++,this.expansionCount>this.settings.maxExpand)throw new e("Too many expansions: infinite loop or need to increase maxExpand setting");let s=o.tokens;const a=this.consumeArgs(o.numArgs,o.delimiters);if(o.numArgs){s=s.slice();for(let t=s.length-1;t>=0;--t){let r=s[t];if("#"===r.text){if(0===t)throw new e("Incomplete placeholder at end of macro body",r);if(r=s[--t],"#"===r.text)s.splice(t+1,1);else{if(!/^[1-9]$/.test(r.text))throw new e("Not a valid argument number",r);s.splice(t,2,...a[+r.text-1])}}}}return this.pushTokens(s),s}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;){const e=this.expandOnce();if(e instanceof ir)return e.treatAsRelax&&(e.text="\\relax"),this.stack.pop()}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new ir(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;){const e=this.expandOnce(!0);e instanceof ir&&(e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(this.stack.pop()))}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 mr(r,this.settings),n=[];let o=t.lex();for(;"EOF"!==o.text;)n.push(o),o=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(sr,e)||Object.prototype.hasOwnProperty.call(M.math,e)||Object.prototype.hasOwnProperty.call(M.text,e)||Object.prototype.hasOwnProperty.call(xr,e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(sr,e)&&!sr[e].primitive}}const vr=[];[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}].forEach((e=>e.blocks.forEach((e=>vr.push(...e)))));const Ar=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Nr=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","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"});var Tr={"́":{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"}},Sr={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","ḋ":"ḋ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","Ḋ":"Ḋ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"Ȯ","Ȱ":"Ȱ","Ő":"Ő","Ṕ":"Ṕ","Ṗ":"Ṗ","Ŕ":"Ŕ","Ř":"Ř","Ṙ":"Ṙ","Ś":"Ś","Ṥ":"Ṥ","Š":"Š","Ṧ":"Ṧ","Ŝ":"Ŝ","Ṡ":"Ṡ","Ť":"Ť","Ṫ":"Ṫ","Ú":"Ú","Ù":"Ù","Ü":"Ü","Ǘ":"Ǘ","Ǜ":"Ǜ","Ǖ":"Ǖ","Ǚ":"Ǚ","Ũ":"Ũ","Ṹ":"Ṹ","Ū":"Ū","Ṻ":"Ṻ","Ŭ":"Ŭ","Ǔ":"Ǔ","Û":"Û","Ů":"Ů","Ű":"Ű","Ṽ":"Ṽ","Ẃ":"Ẃ","Ẁ":"Ẁ","Ẅ":"Ẅ","Ŵ":"Ŵ","Ẇ":"Ẇ","Ẍ":"Ẍ","Ẋ":"Ẋ","Ý":"Ý","Ỳ":"Ỳ","Ÿ":"Ÿ","Ỹ":"Ỹ","Ȳ":"Ȳ","Ŷ":"Ŷ","Ẏ":"Ẏ","Ź":"Ź","Ž":"Ž","Ẑ":"Ẑ","Ż":"Ż","ά":"ά","ὰ":"ὰ","ᾱ":"ᾱ","ᾰ":"ᾰ","έ":"έ","ὲ":"ὲ","ή":"ή","ὴ":"ὴ","ί":"ί","ὶ":"ὶ","ϊ":"ϊ","ΐ":"ΐ","ῒ":"ῒ","ῑ":"ῑ","ῐ":"ῐ","ό":"ό","ὸ":"ὸ","ύ":"ύ","ὺ":"ὺ","ϋ":"ϋ","ΰ":"ΰ","ῢ":"ῢ","ῡ":"ῡ","ῠ":"ῠ","ώ":"ώ","ὼ":"ὼ","Ύ":"Ύ","Ὺ":"Ὺ","Ϋ":"Ϋ","Ῡ":"Ῡ","Ῠ":"Ῠ","Ώ":"Ώ","Ὼ":"Ὼ"};const qr=/^\d(?:[\d,.]*\d)?$/;class Or{constructor(e,t,r=!1){this.mode="math",this.gullet=new kr(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 ir("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){const r=[];for(;;){"math"===this.mode&&this.consumeSpaces();const n=this.fetch();if(-1!==Or.endOfExpression.indexOf(n.text))break;if(t&&n.text===t)break;if(e&&sr[n.text]&&sr[n.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&(r.push(o),this.prevAtomType="atom"===o.type?o.family:o.type)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(t){let r,n=-1;for(let o=0;o<t.length;o++)if("infix"===t[o].type){if(-1!==n)throw new e("only one infix operator per group",t[o].token);n=o,r=t[o].replaceWith}if(-1!==n&&r){let e,o;const s=t.slice(0,n),a=t.slice(n+1);let i;return e=1===s.length&&"ordgroup"===s[0].type?s[0]:{type:"ordgroup",mode:this.mode,body:s},o=1===a.length&&"ordgroup"===a[0].type?a[0]:{type:"ordgroup",mode:this.mode,body:a},i="\\\\abovefrac"===r?this.callFunction(r,[e,t[n],o],[]):this.callFunction(r,[e,o],[]),[i]}return t}handleSupSubscript(t){const r=this.fetch(),n=r.text;this.consume(),this.consumeSpaces();const o=this.parseGroup(t);if(!o)throw new e("Expected group after '"+n+"'",r);return o}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("text"===this.mode)return r;let n,o;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(o)throw new e("Double subscript",t);o=this.handleSupSubscript("subscript")}else if("'"===t.text){if(n)throw new e("Double superscript",t);const r={type:"textord",mode:this.mode,text:"\\prime"},o=[r];for(this.consume();"'"===this.fetch().text;)o.push(r),this.consume();"^"===this.fetch().text&&o.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:o}}else{if(!Nr[t.text])break;{const e=Ar.test(t.text),r=[];for(r.push(new ir(Nr[t.text])),this.consume();;){const t=this.fetch().text;if(!Nr[t])break;if(Ar.test(t)!==e)break;r.unshift(new ir(Nr[t])),this.consume()}const s=this.subparse(r);e?o={type:"ordgroup",mode:"math",body:s}:n={type:"ordgroup",mode:"math",body:s}}}}return n||o?r&&"multiscript"===r.type&&!r.postscripts?(r.postscripts={sup:n,sub:o},r):{type:"supsub",mode:this.mode,base:r,sup:n,sub:o}:r}parseFunction(t,r){const n=this.fetch(),o=n.text,s=sr[o];if(!s)return null;if(this.consume(),r&&"atom"!==r&&!s.allowedInArgument)throw new e("Got function '"+o+"' with no arguments"+(r?" as "+r:""),n);if("text"===this.mode&&!s.allowedInText)throw new e("Can't use function '"+o+"' in text mode",n);if("math"===this.mode&&!1===s.allowedInMath)throw new e("Can't use function '"+o+"' in math mode",n);const a=this.prevAtomType,{args:i,optArgs:l}=this.parseArguments(o,s);return this.prevAtomType=a,this.callFunction(o,i,l,n,t)}callFunction(t,r,n,o,s){const a={funcName:t,parser:this,token:o,breakOnTokenText:s},i=sr[t];if(i&&i.handler)return i.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 o=[],s=[];for(let a=0;a<n;a++){let n=r.argTypes&&r.argTypes[a];const i=a<r.numOptionalArgs;(r.primitive&&null==n||"sqrt"===r.type&&1===a&&null==s[0])&&(n="primitive");const l=this.parseGroupOfType(`argument to '${t}'`,n,i);if(i)s.push(l);else{if(null==l)throw new e("Null argument, please report this as a bug");o.push(l)}}return{args:o,optArgs:s}}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)break;this.consume()}}parseStringGroup(e,t){const r=this.gullet.scanArgument(t);if(null==r)return null;let n,o="";for(;"EOF"!==(n=this.fetch()).text;)o+=n.text,this.consume();return this.consume(),r.text=o,r}parseRegexGroup(t,r){const n=this.fetch();let o,s=n,a="";for(;"EOF"!==(o=this.fetch()).text&&t.test(a+o.text);)s=o,a+=s.text,this.consume();if(""===a)throw new e("Invalid "+r+": '"+n.text+"'",n);return n.range(s,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 o=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(r.text);if(!o)throw new e("Invalid size: '"+r.text+"'",r);const s={number:+(o[1]+o[2]),unit:o[3]};if(!me(s))throw new e("Invalid unit: '"+s.unit+"'",r);return{type:"size",mode:this.mode,value:s,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 o=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();const s={type:"ordgroup",mode:this.mode,loc:r.loc,body:o};return t&&this.switchMode(n),s}parseGroup(e,t){const r=this.fetch(),n=r.text;let o;if("{"===n||"\\begingroup"===n||"\\toggle"===n){this.consume();const e="{"===n?"}":"\\begingroup"===n?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();const t=this.parseExpression(!1,e),s=this.fetch();this.expect(e),this.gullet.endGroup(),o={type:"\\endtoggle"===s.text?"toggle":"ordgroup",mode:this.mode,loc:ar.range(r,s),body:t,semisimple:"\\begingroup"===n||void 0}}else o=this.parseFunction(t,e)||this.parseSymbol(),null!=o||"\\"!==n[0]||Object.prototype.hasOwnProperty.call(xr,n)||(o=this.formatUnsupportedCmd(n),this.consume());return o}formLigatures(e){let t=e.length-1;for(let r=0;r<t;++r){const n=e[r],o=n.text;"-"===o&&"-"===e[r+1].text&&(r+1<t&&"-"===e[r+2].text?(e.splice(r,3,{type:"textord",mode:"text",loc:ar.range(n,e[r+2]),text:"---"}),t-=2):(e.splice(r,2,{type:"textord",mode:"text",loc:ar.range(n,e[r+1]),text:"--"}),t-=1)),"'"!==o&&"`"!==o||e[r+1].text!==o||(e.splice(r,2,{type:"textord",mode:"text",loc:ar.range(n,e[r+1]),text:o+o}),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(Sr,r[0])&&!M[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=Sr[r[0]]+r.slice(1)}const n=lr.exec(r);let o;if(n&&(r=r.substring(0,n.index),"i"===r?r="ı":"j"===r&&(r="ȷ")),M[this.mode][r]){const e=M[this.mode][r].group,n=ar.range(t);let s;if(Object.prototype.hasOwnProperty.call(q,e)){const t=e;s={type:"atom",mode:this.mode,family:t,loc:n,text:r}}else s={type:e,mode:this.mode,loc:n,text:r};o=s}else{if(!this.strict&&qr.test(r))return this.consume(),{type:"textord",mode:this.mode,loc:ar.range(t),text:r};if(!(r.charCodeAt(0)>=128))return null;if(this.settings.strict){if(!function(e){for(let t=0;t<vr.length;t+=2)if(e>=vr[t]&&e<=vr[t+1])return!0;return!1}(r.charCodeAt(0)))throw new e(`Unrecognized Unicode character "${r[0]}" (${r.charCodeAt(0)})`,t);if("math"===this.mode)throw new e(`Unicode text character "${r[0]}" used in math mode`,t)}o={type:"textord",mode:"text",loc:ar.range(t),text:r}}if(this.consume(),n)for(let r=0;r<n[0].length;r++){const s=n[0][r];if(!Tr[s])throw new e(`Unknown accent ' ${s}'`,t);const a=Tr[s][this.mode]||Tr[s].text;if(!a)throw new e(`Accent ${s} unsupported in ${this.mode} mode`,t);o={type:"accent",mode:this.mode,loc:ar.range(t),label:a,isStretchy:!1,isShifty:!0,base:o}}return o}}const Mr=function(t,r){if(!("string"==typeof t||t instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new Or(t,r);delete n.gullet.macros.current["\\df@tag"];let o=n.parse();if(!(o.length>0&&o[0].type&&"array"===o[0].type&&o[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"),o=[{type:"tag",mode:"text",body:o,tag:n.parse()}]}return o},Br=[2,2,3,3];class Cr{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 Cr(t)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:Br[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}}let zr=function(e,t,r){t.textContent="";const n="MATH"===t.tagName;n&&(r.wrap="none");const o=Er(e,r);n||o.children.length>1?(t.textContent="",o.children.forEach((e=>{t.appendChild(e.toNode())}))):t.appendChild(o.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."),zr=function(){throw new e("Temml doesn't work in quirks mode.")});const Er=function(t,r){const n=new a(r);try{const e=Mr(t,n);return se(e,t,new Cr({level:n.displayMode?_e:Ve,maxSize:n.maxSize}),n)}catch(r){return function(t,r,n){if(n.throwOnError||!(t instanceof e))throw t;const o=new y(["temml-error"],[new w(r+"\n"+t.toString())]);return o.style.color=n.errorColor,o.style.whiteSpace="pre-line",o}(r,t,n)}};return{version:"0.9.2",render:zr,renderToString:function(e,t){return Er(e,t).toMarkup()},postProcess:function(e){const t={};let r=0;const n=e.getElementsByClassName("tml-tageqn");for(const e of n){const n=e.getElementsByClassName("tml-eqn");n.length>0&&(r+=1,n[0].id="tml-eqn-"+r);const o=e.getElementsByClassName("tml-label");if(0!==o.length)if(n.length>0)t[o[0].id]=String(r);else{const r=e.getElementsByClassName("tml-tag");r.length>0&&(t[o[0].id]=r[0].textContent)}}[...e.getElementsByClassName("tml-ref")].forEach((e=>{let r=t[e.getAttribute("href").slice(1)];-1===e.className.indexOf("tml-eqref")&&(r=r.replace(/^\(/,""),r=r.replace(/\($/,"")),"("!==r.charAt(0)&&(r="("+r),")"!==r.slice(-1)&&(r+=")"),e.textContent=r}))},ParseError:e,definePreamble:function(e,t){const r=new a(t);if(r.macros={},!("string"==typeof e||e instanceof String))throw new TypeError("Temml can only parse string typed expression");const n=new Or(e,r,!0);delete n.gullet.macros.current["\\df@tag"];return n.parse()},__parse:function(e,t){const r=new a(t);return Mr(e,r)},__renderToMathMLTree:Er,__defineSymbol:B,__defineMacro:Mt}}();