UNPKG

mathjax

Version:

Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers. This package includes the packaged components (install mathjax-full to get the source

1 lines 108 kB
(()=>{"use strict";var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{FindTeX:()=>K});var r={};t.r(r),t.d(r,{default:()=>V});var s={};t.r(s),t.d(s,{TexConstant:()=>W});var i={};t.r(i),t.d(i,{default:()=>rt});var n={};t.r(n),t.d(n,{ConfigurationType:()=>st,HandlerType:()=>it});var a={};t.r(a),t.d(a,{UnitUtil:()=>at});var o={};t.r(o),t.d(o,{default:()=>ot});var c={};t.r(c),t.d(c,{default:()=>lt});var l={};t.r(l),t.d(l,{BaseItem:()=>ut,MmlStack:()=>ht});var h={};t.r(h),t.d(h,{default:()=>dt});var u={};t.r(u),t.d(u,{default:()=>ft});var d={};t.r(d),t.d(d,{NodeFactory:()=>bt});var m={};t.r(m),t.d(m,{KeyValueDef:()=>kt,KeyValueTypes:()=>vt,ParseUtil:()=>wt});var p={};t.r(p),t.d(p,{ColumnParser:()=>Mt});var g={};t.r(g),t.d(g,{default:()=>Et});var f={};t.r(f),t.d(f,{AbstractTags:()=>It,AllTags:()=>Nt,Label:()=>St,NoTags:()=>Lt,TagInfo:()=>Ct,TagsFactory:()=>Bt});var b={};t.r(b),t.d(b,{Macro:()=>Gt,Token:()=>Dt});var y={};t.r(y),t.d(y,{AbstractParseMap:()=>Kt,AbstractTokenMap:()=>_t,CharacterMap:()=>Ht,CommandMap:()=>qt,DelimiterMap:()=>Xt,EnvironmentMap:()=>$t,MacroMap:()=>zt,RegExpMap:()=>jt,parseResult:()=>Ut});var A={};t.r(A),t.d(A,{MapHandler:()=>Zt,SubHandler:()=>Yt,SubHandlers:()=>Qt});var k={};t.r(k),t.d(k,{Configuration:()=>te,ConfigurationHandler:()=>re,ParserConfiguration:()=>se});var v={};t.r(v),t.d(v,{ArrayItem:()=>Ee,BeginItem:()=>ye,BreakItem:()=>be,CellItem:()=>Pe,CloseItem:()=>le,DotsItem:()=>Oe,EndItem:()=>Ae,EqnArrayItem:()=>Se,EquationItem:()=>Ie,FnItem:()=>we,LeftItem:()=>pe,Middle:()=>ge,MmlItem:()=>Te,MstyleItem:()=>Ce,NonscriptItem:()=>xe,NotItem:()=>Me,NullItem:()=>he,OpenItem:()=>ce,OverItem:()=>me,PositionItem:()=>ve,PrimeItem:()=>ue,RightItem:()=>fe,StartItem:()=>ae,StopItem:()=>oe,StyleItem:()=>ke,SubsupItem:()=>de});var P={};t.r(P),t.d(P,{default:()=>_e,splitAlignArray:()=>De});var T={};t.r(T),t.d(T,{default:()=>He});var w={};t.r(w),t.d(w,{BaseConfiguration:()=>Qe,BaseTags:()=>Ye,Other:()=>Ze});var M={};t.r(M),t.d(M,{TeX:()=>tr});const x=("undefined"!=typeof window?window:t.g).MathJax._.components.global,O=(x.GLOBAL,x.isObject,x.combineConfig,x.combineDefaults,x.combineWithMathJax),E=(x.MathJax,MathJax._.core.InputJax.AbstractInputJax),S=MathJax._.util.Options,C=(S.isObject,S.APPEND,S.REMOVE,S.OPTIONS,S.Expandable,S.expandable,S.makeArray,S.keys,S.copy,S.insert),I=S.defaultOptions,L=S.userOptions,N=(S.selectOptions,S.selectOptionsFromKeys,S.separateOptions),F=S.lookup,R=MathJax._.core.FindMath.AbstractFindMath,B=MathJax._.util.string,D=B.sortLength,G=B.quotePattern,U=(B.unicodeChars,B.unicodeString,B.isPercent,B.split,B.replaceUnicode),_=(B.toEntity,MathJax._.core.MathItem),j=_.protoItem;_.AbstractMathItem,_.STATE,_.newState;class K extends R{constructor(t){super(t),this.getPatterns()}getPatterns(){const t=this.options,e=[],r=[],s=[];this.end={},this.env=this.sub=0;let i=1;t.inlineMath.forEach((t=>this.addPattern(e,t,!1))),t.displayMath.forEach((t=>this.addPattern(e,t,!0))),e.length&&r.push(e.sort(D).join("|")),t.processEnvironments&&(r.push("\\\\begin\\s*\\{([^}]*)\\}"),this.env=i,i++),t.processEscapes&&s.push("\\\\([\\\\$])"),t.processRefs&&s.push("(\\\\(?:eq)?ref\\s*\\{[^}]*\\})"),s.length&&(r.push("("+s.join("|")+")"),this.sub=i),this.start=new RegExp(r.join("|"),"g"),this.hasPatterns=r.length>0}addPattern(t,e,r){const[s,i]=e;t.push(G(s)),this.end[s]=[i,r,this.endPattern(i)]}endPattern(t,e){return new RegExp((e||G(t))+"|\\\\(?:[a-zA-Z]|.)|[{}]","g")}findEnd(t,e,r,s){const[i,n,a]=s,o=a.lastIndex=r.index+r[0].length;let c,l=0;for(;c=a.exec(t);){if((c[1]||c[0])===i&&0===l)return j(r[0],t.substring(o,c.index),c[0],e,r.index,c.index+c[0].length,n);"{"===c[0]?l++:"}"===c[0]&&l&&l--}return null}findMathInString(t,e,r){let s,i;for(this.start.lastIndex=0;s=this.start.exec(r);){if(void 0!==s[this.env]&&this.env){const t="\\\\end\\s*(\\{"+G(s[this.env])+"\\})";i=this.findEnd(r,e,s,["{"+s[this.env]+"}",!0,this.endPattern(null,t)]),i&&(i.math=i.open+i.math+i.close,i.open=i.close="")}else if(void 0!==s[this.sub]&&this.sub){const t=s[this.sub],r=s.index+s[this.sub].length;i=2===t.length?j("\\",t.substring(1),"",e,s.index,r):j("",t,"",e,s.index,r,!1)}else i=this.findEnd(r,e,s,this.end[s[0]]);i&&(t.push(i),this.start.lastIndex=i.end.n)}}findMath(t){const e=[];if(this.hasPatterns)for(let r=0,s=t.length;r<s;r++)this.findMathInString(e,r,t[r]);return e}}K.OPTIONS={inlineMath:[["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0,processRefs:!0};const H=MathJax._.core.MmlTree.MmlNode,X=H.TEXCLASS,z=(H.TEXCLASSNAMES,H.MATHVARIANTS,H.indentAttributes,H.AbstractMmlNode),q=(H.AbstractMmlTokenNode,H.AbstractMmlLayoutNode,H.AbstractMmlBaseNode,H.AbstractMmlEmptyNode),$=(H.TextNode,H.XMLNode,MathJax._.core.MmlTree.MmlNodes.mo.MmlMo),J={attrs:new Set(["autoOP","fnOP","movesupsub","subsupOK","texprimestyle","useHeight","variantForm","withDelims","mathaccent","open","close"]),createEntity:t=>String.fromCodePoint(parseInt(t,16)),getChildren:t=>t.childNodes,getText:t=>t.getText(),appendChildren(t,e){for(const r of e)t.appendChild(r)},setAttribute(t,e,r){t.attributes.set(e,r)},setProperty(t,e,r){t.setProperty(e,r)},setProperties(t,e){for(const r of Object.keys(e)){const s=e[r];"texClass"===r?(t.texClass=s,t.setProperty(r,s)):"movablelimits"===r?(t.setProperty("movablelimits",s),(t.isKind("mo")||t.isKind("mstyle"))&&t.attributes.set("movablelimits",s)):"inferred"===r||(J.attrs.has(r)?t.setProperty(r,s):t.attributes.set(r,s))}},getProperty:(t,e)=>t.getProperty(e),getAttribute:(t,e)=>t.attributes.get(e),removeAttribute(t,e){t.attributes.unset(e)},removeProperties(t,...e){t.removeProperty(...e)},getChildAt:(t,e)=>t.childNodes[e],setChild(t,e,r){t.childNodes[e]=r,r&&(r.parent=t)},copyChildren(t,e){const r=t.childNodes;for(let t=0;t<r.length;t++)this.setChild(e,t,r[t])},copyAttributes(t,e){e.attributes=t.attributes;for(const[r,s]of Object.entries(t.getAllProperties()))e.setProperty(r,s)},isType:(t,e)=>t.isKind(e),isEmbellished:t=>t.isEmbellished,getTexClass:t=>t.texClass,getCoreMO:t=>t.coreMO(),isNode:t=>t instanceof z||t instanceof q,isInferred:t=>t.isInferred,getForm(t){if(!t.isKind("mo"))return null;const e=t,r=e.getForms();for(const t of r){const r=this.getOp(e,t);if(r)return r}return null},getOp:(t,e="infix")=>$.OPTABLE[e][t.getText()]||null,getMoAttribute(t,e){var r,s;if(!t.attributes.isSet(e))for(const i of["infix","postfix","prefix"]){const n=null===(s=null===(r=this.getOp(t,i))||void 0===r?void 0:r[3])||void 0===s?void 0:s[e];if(void 0!==n)return n}return t.attributes.get(e)}},V=J,W={Variant:{NORMAL:"normal",BOLD:"bold",ITALIC:"italic",BOLDITALIC:"bold-italic",DOUBLESTRUCK:"double-struck",FRAKTUR:"fraktur",BOLDFRAKTUR:"bold-fraktur",SCRIPT:"script",BOLDSCRIPT:"bold-script",SANSSERIF:"sans-serif",BOLDSANSSERIF:"bold-sans-serif",SANSSERIFITALIC:"sans-serif-italic",SANSSERIFBOLDITALIC:"sans-serif-bold-italic",MONOSPACE:"monospace",INITIAL:"inital",TAILED:"tailed",LOOPED:"looped",STRETCHED:"stretched",CALLIGRAPHIC:"-tex-calligraphic",BOLDCALLIGRAPHIC:"-tex-bold-calligraphic",OLDSTYLE:"-tex-oldstyle",BOLDOLDSTYLE:"-tex-bold-oldstyle",MATHITALIC:"-tex-mathit"},Form:{PREFIX:"prefix",INFIX:"infix",POSTFIX:"postfix"},LineBreak:{AUTO:"auto",NEWLINE:"newline",NOBREAK:"nobreak",GOODBREAK:"goodbreak",BADBREAK:"badbreak"},LineBreakStyle:{BEFORE:"before",AFTER:"after",DUPLICATE:"duplicate",INFIXLINBREAKSTYLE:"infixlinebreakstyle"},IndentAlign:{LEFT:"left",CENTER:"center",RIGHT:"right",AUTO:"auto",ID:"id",INDENTALIGN:"indentalign"},IndentShift:{INDENTSHIFT:"indentshift"},LineThickness:{THIN:"thin",MEDIUM:"medium",THICK:"thick"},Notation:{LONGDIV:"longdiv",ACTUARIAL:"actuarial",PHASORANGLE:"phasorangle",RADICAL:"radical",BOX:"box",ROUNDEDBOX:"roundedbox",CIRCLE:"circle",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",UPDIAGONALSTRIKE:"updiagonalstrike",DOWNDIAGONALSTRIKE:"downdiagonalstrike",VERTICALSTRIKE:"verticalstrike",HORIZONTALSTRIKE:"horizontalstrike",NORTHEASTARROW:"northeastarrow",MADRUWB:"madruwb",UPDIAGONALARROW:"updiagonalarrow"},Align:{TOP:"top",BOTTOM:"bottom",CENTER:"center",BASELINE:"baseline",AXIS:"axis",LEFT:"left",RIGHT:"right"},Lines:{NONE:"none",SOLID:"solid",DASHED:"dashed"},Side:{LEFT:"left",RIGHT:"right",LEFTOVERLAP:"leftoverlap",RIGHTOVERLAP:"rightoverlap"},Width:{AUTO:"auto",FIT:"fit"},Actiontype:{TOGGLE:"toggle",STATUSLINE:"statusline",TOOLTIP:"tooltip",INPUT:"input"},Overflow:{LINBREAK:"linebreak",SCROLL:"scroll",ELIDE:"elide",TRUNCATE:"truncate",SCALE:"scale"},Unit:{EM:"em",EX:"ex",PX:"px",IN:"in",CM:"cm",MM:"mm",PT:"pt",PC:"pc"},Attr:{LATEX:"data-latex",LATEXITEM:"data-latex-item"}};function Z(t,e,r){const s=e.attributes,i=r.attributes;t.forEach((t=>{const e=i.getExplicit(t);null!=e&&s.set(t,e)}))}function Y(t,e){const r=(t,e)=>t.getExplicitNames().filter((r=>r!==e&&("stretchy"!==r||t.getExplicit("stretchy"))&&"data-latex"!==r&&"data-latex-item"!==r)),s=t.attributes,i=e.attributes,n=r(s,"lspace"),a=r(i,"rspace");if(n.length!==a.length)return!1;for(const t of n)if(s.getExplicit(t)!==i.getExplicit(t))return!1;return!0}function Q(t,e,r){const s=[];for(const i of t.getList("m"+e+r)){const n=i.childNodes;if(n[i[e]]&&n[i[r]])continue;const a=i.parent,o=n[i[e]]?t.nodeFactory.create("node","m"+e,[n[i.base],n[i[e]]]):t.nodeFactory.create("node","m"+r,[n[i.base],n[i[r]]]);V.copyAttributes(i,o),a.replaceChild(o,i),s.push(i)}t.removeFromList("m"+e+r,s)}function tt(t,e,r){const s=[];for(const i of t.getList(e)){if(i.attributes.get("displaystyle"))continue;const e=i.childNodes[i.base],n=e.coreMO();if(e.getProperty("movablelimits")&&!n.attributes.hasExplicit("movablelimits")){const e=t.nodeFactory.create("node",r,i.childNodes);V.copyAttributes(i,e),i.parent.replaceChild(e,i),s.push(i)}}t.removeFromList(e,s)}const et={cleanStretchy(t){var e;const r=t.data;for(const t of r.getList("fixStretchy"))if(V.getProperty(t,"fixStretchy")){const r=V.getForm(t);(null===(e=null==r?void 0:r[3])||void 0===e?void 0:e.stretchy)&&V.setAttribute(t,"stretchy",!1),V.removeProperties(t,"fixStretchy")}},cleanAttributes(t){t.data.root.walkTree((t=>{const e=new Set((t.getProperty("keep-attrs")||"").split(/ /)),r=t.attributes;r.unset(W.Attr.LATEXITEM);for(const s of r.getExplicitNames())e.has(s)||r.get(s)!==t.attributes.getInherited(s)||r.unset(s)}))},combineRelations(t){const e=[];for(const r of t.data.getList("mo")){if(r.getProperty("relationsCombined")||!r.parent||r.parent&&!V.isType(r.parent,"mrow")||V.getTexClass(r)!==X.REL)continue;let t;const s=r.parent.childNodes,i=s.indexOf(r)+1,n=V.getProperty(r,"variantForm");for(;i<s.length&&(t=s[i])&&V.isType(t,"mo")&&V.getTexClass(t)===X.REL;){if(n!==V.getProperty(t,"variantForm")||!Y(r,t)){r.attributes.hasExplicit("rspace")||V.setAttribute(r,"rspace","0pt"),t.attributes.hasExplicit("lspace")||V.setAttribute(t,"lspace","0pt");break}V.appendChildren(r,V.getChildren(t)),Z(["stretchy","rspace"],r,t);for(const e of t.getPropertyNames())r.setProperty(e,t.getProperty(e));t.attributes.get("data-latex")&&r.attributes.set("data-latex",r.attributes.get("data-latex")+t.attributes.get("data-latex")),s.splice(i,1),e.push(t),t.parent=null,t.setProperty("relationsCombined",!0),r.setProperty("texClass",X.REL)}r.attributes.setInherited("form",r.getForms()[0])}t.data.removeFromList("mo",e)},cleanSubSup(t){const e=t.data;e.error||(Q(e,"sub","sup"),Q(e,"under","over"))},moveLimits(t){const e=t.data;tt(e,"munderover","msubsup"),tt(e,"munder","msub"),tt(e,"mover","msup")},setInherited(t){t.data.root.setInheritedAttributes({},t.math.display,0,!1)},checkScriptlevel(t){const e=t.data,r=[];for(const t of e.getList("mstyle")){if(1!==t.childNodes[0].childNodes.length)continue;const e=t.attributes;for(const t of["displaystyle","scriptlevel"])e.getExplicit(t)===e.getInherited(t)&&e.unset(t);const s=e.getExplicitNames();if(0===s.filter((t=>"data-latex"!==t.substring(0,10))).length){const i=t.childNodes[0].childNodes[0];s.forEach((t=>i.attributes.set(t,e.get(t)))),t.parent.replaceChild(i,t),r.push(t)}}e.removeFromList("mstyle",r)}},rt=et;var st,it;!function(t){t.HANDLER="handler",t.FALLBACK="fallback",t.ITEMS="items",t.TAGS="tags",t.OPTIONS="options",t.NODES="nodes",t.PREPROCESSORS="preprocessors",t.POSTPROCESSORS="postprocessors",t.INIT="init",t.CONFIG="config",t.PRIORITY="priority",t.PARSER="parser"}(st||(st={})),function(t){t.DELIMITER="delimiter",t.MACRO="macro",t.CHARACTER="character",t.ENVIRONMENT="environment"}(it||(it={}));const nt=7.2;const at={UNIT_CASES:new class{constructor(t){this.num="([-+]?([.,]\\d+|\\d+([.,]\\d*)?))",this.unit="",this.dimenEnd=/./,this.dimenRest=/./,this.map=new Map(t),this.updateDimen()}updateDimen(){this.unit=`(${Array.from(this.map.keys()).join("|")})`,this.dimenEnd=RegExp("^\\s*"+this.num+"\\s*"+this.unit+"\\s*$"),this.dimenRest=RegExp("^\\s*"+this.num+"\\s*"+this.unit+" ?")}set(t,e){return this.map.set(t,e),this.updateDimen(),this}get(t){return this.map.get(t)||this.map.get("pt")}delete(t){return!!this.map.delete(t)&&(this.updateDimen(),!0)}}([["em",1],["ex",.43],["pt",.1],["pc",1.2],["px",.1],["in",nt],["cm",nt/2.54],["mm",nt/25.4],["mu",1/18]]),matchDimen(t,e=!1){const r=t.match(e?at.UNIT_CASES.dimenRest:at.UNIT_CASES.dimenEnd);return r?function([t,e,r]){return"mu"!==e?[t,e,r]:[at.em(at.UNIT_CASES.get(e)*parseFloat(t)).slice(0,-2),"em",r]}([r[1].replace(/,/,"."),r[4],r[0].length]):[null,null,0]},dimen2em(t){const[e,r]=at.matchDimen(t),s=parseFloat(e||"1");return at.UNIT_CASES.get(r)*s},em:t=>Math.abs(t)<6e-4?"0em":t.toFixed(3).replace(/\.?0+$/,"")+"em",trimSpaces(t){if("string"!=typeof t)return t;let e=t.trim();return e.match(/\\$/)&&t.match(/ $/)&&(e+=" "),e}};class ot{constructor(t,e,r){this._factory=t,this._env=e,this.global={},this.stack=[],this.global={isInner:r},this.stack=[this._factory.create("start",this.global)],e&&(this.stack[0].env=e),this.env=this.stack[0].env}set env(t){this._env=t}get env(){return this._env}Push(...t){for(const e of t){if(!e)continue;const t=V.isNode(e)?this._factory.create("mml",e):e;t.global=this.global;const[r,s]=this.stack.length?this.Top().checkItem(t):[null,!0];s&&(r?(this.Pop(),this.Push(...r)):(t.isKind("null")||this.stack.push(t),t.env?(t.copyEnv&&Object.assign(t.env,this.env),this.env=t.env):t.env=this.env))}}Pop(){const t=this.stack.pop();return t.isOpen||delete t.env,this.env=this.stack.length?this.Top().env:{},t}Top(t=1){return this.stack.length<t?null:this.stack[this.stack.length-t]}Prev(t){const e=this.Top();return t?e.First:e.Pop()}get height(){return this.stack.length}toString(){return"stack[\n "+this.stack.join("\n ")+"\n]"}}class ct{static processString(t,e){const r=t.split(ct.pattern);for(let t=1,s=r.length;t<s;t+=2){let s=r[t].charAt(0);if(s>="0"&&s<="9")r[t]=e[parseInt(r[t],10)-1],"number"==typeof r[t]&&(r[t]=r[t].toString());else if("{"===s)if(s=r[t].substring(1),s>="0"&&s<="9")r[t]=e[parseInt(r[t].substring(1,r[t].length-1),10)-1],"number"==typeof r[t]&&(r[t]=r[t].toString());else{r[t].match(/^\{([a-z]+):%(\d+)\|(.*)\}$/)&&(r[t]="%"+r[t])}}return r.join("")}constructor(t,e,...r){this.id=t,this.message=ct.processString(e,r)}}ct.pattern=/%(\d+|\{\d+\}|\{[a-z]+:%\d+(?:\|(?:%\{\d+\}|%.|[^}])*)+\}|.)/g;const lt=ct;class ht{constructor(t){this._nodes=t,this.startStr="",this.startI=0,this.stopI=0}get nodes(){return this._nodes}Push(...t){this._nodes.push(...t)}Pop(){return this._nodes.pop()}get First(){return this._nodes[this.Size()-1]}set First(t){this._nodes[this.Size()-1]=t}get Last(){return this._nodes[0]}set Last(t){this._nodes[0]=t}Peek(t){return null==t&&(t=1),this._nodes.slice(this.Size()-t)}Size(){return this._nodes.length}Clear(){this._nodes=[]}toMml(t=!0,e){return 1!==this._nodes.length||e?this.create("node",t?"inferredMrow":"mrow",this._nodes,{}):this.First}create(t,...e){return this.factory.configuration.nodeFactory.create(t,...e)}}class ut extends ht{constructor(t,...e){super(e),this.factory=t,this.global={},this._properties={},this.isOpen&&(this._env={})}get kind(){return"base"}get env(){return this._env}set env(t){this._env=t}get copyEnv(){return!0}getProperty(t){return this._properties[t]}setProperty(t,e){return this._properties[t]=e,this}get isOpen(){return!1}get isClose(){return!1}get isFinal(){return!1}isKind(t){return t===this.kind}checkItem(t){if(t.isKind("over")&&this.isOpen&&(t.setProperty("num",this.toMml(!1)),this.Clear()),t.isKind("cell")&&this.isOpen){if(t.getProperty("linebreak"))return ut.fail;throw new lt("Misplaced","Misplaced %1",t.getName())}if(t.isClose&&this.getErrors(t.kind)){const[e,r]=this.getErrors(t.kind);throw new lt(e,r,t.getName())}return t.isFinal?(this.Push(t.First),ut.fail):ut.success}clearEnv(){for(const t of Object.keys(this.env))delete this.env[t]}setProperties(t){return Object.assign(this._properties,t),this}getName(){return this.getProperty("name")}toString(){return this.kind+"["+this.nodes.join("; ")+"]"}getErrors(t){return this.constructor.errors[t]||ut.errors[t]}addLatexItem(t,e=""){const r=this.startStr.slice(this.startI,this.stopI);if(r){const s=e?e+r:r;t.attributes.set(W.Attr.LATEXITEM,s),"}"!==s&&t.attributes.set(W.Attr.LATEX,s)}}}ut.fail=[null,!1],ut.success=[null,!0],ut.errors={end:["MissingBeginExtraEnd","Missing \\begin{%1} or extra \\end{%1}"],close:["ExtraCloseMissingOpen","Extra close brace or missing open brace"],right:["MissingLeftExtraRight","Missing \\left or extra \\right"],middle:["ExtraMiddle","Extra \\middle"]};class dt{constructor(t,e,r){this._string=t,this.configuration=r,this.macroCount=0,this.i=0,this.currentCS="",this.saveI=0;const s=Object.hasOwn(e,"isInner"),i=e.isInner;let n;if(delete e.isInner,e){n={};for(const t of Object.keys(e))n[t]=e[t]}this.configuration.pushParser(this),this.stack=new ot(this.itemFactory,n,!s||i),this.Parse(),this.Push(this.itemFactory.create("stop")),this.stack.env=n}get options(){return this.configuration.options}get itemFactory(){return this.configuration.itemFactory}get tags(){return this.configuration.tags}set string(t){this._string=t}get string(){return this._string}parse(t,e){const r=this.saveI;this.saveI=this.i-("character"===t&&"&"!==e[1]?1:0);const s=this.configuration.handlers.get(t).parse(e);return"macro"!==t&&this.updateResult(e[1],r),this.saveI=r,s}lookup(t,e){return this.configuration.handlers.get(t).lookup(e)}contains(t,e){return this.configuration.handlers.get(t).contains(e)}toString(){let t="";for(const e of Array.from(this.configuration.handlers.keys()))t+=e+": "+this.configuration.handlers.get(e)+"\n";return t}Parse(){let t;for(;this.i<this.string.length;)t=this.getCodePoint(),this.i+=t.length,this.parse(it.CHARACTER,[this,t])}Push(t){t instanceof ut&&(t.startI=this.saveI,t.stopI=this.i,t.startStr=this.string),t instanceof z&&t.isInferred?this.PushAll(t.childNodes):this.stack.Push(t)}PushAll(t){for(const e of t)this.stack.Push(e)}mml(){if(!this.stack.Top().isKind("mml"))return null;const t=this.stack.Top().First;this.configuration.popParser();const e=this.trimTex(this.string);return e&&t.attributes.set(W.Attr.LATEX,e),t}convertDelimiter(t){var e;const r=this.lookup(it.DELIMITER,t);return null!==(e=null==r?void 0:r.char)&&void 0!==e?e:null}getCodePoint(){const t=this.string.codePointAt(this.i);return void 0===t?"":String.fromCodePoint(t)}nextIsSpace(){return!!this.string.charAt(this.i).match(/\s/)}GetNext(){for(;this.nextIsSpace();)this.i++;return this.getCodePoint()}GetCS(){const t=this.string.slice(this.i).match(/^(([a-z]+) ?|[\uD800-\uDBFF].|.)/i);return t?(this.i+=t[0].length,t[2]||t[1]):(this.i++," ")}GetArgument(t,e=!1){switch(this.GetNext()){case"":if(!e)throw new lt("MissingArgFor","Missing argument for %1",this.currentCS);return null;case"}":if(!e)throw new lt("ExtraCloseMissingOpen","Extra close brace or missing open brace");return null;case"\\":return this.i++,"\\"+this.GetCS();case"{":{const t=++this.i;let e=1;for(;this.i<this.string.length;)switch(this.string.charAt(this.i++)){case"\\":this.i++;break;case"{":e++;break;case"}":if(0===--e)return this.string.slice(t,this.i-1)}throw new lt("MissingCloseBrace","Missing close brace")}}const r=this.getCodePoint();return this.i+=r.length,r}GetBrackets(t,e,r=!1){if("["!==this.GetNext())return e;const s=++this.i;let i=0,n=0;for(;this.i<this.string.length;)switch(this.string.charAt(this.i++)){case"{":i++;break;case"\\":this.i++;break;case"}":if(i--<=0)throw new lt("ExtraCloseLooking","Extra close brace while looking for %1","']'");break;case"[":0===i&&n++;break;case"]":if(0===i){if(!r||0===n)return this.string.slice(s,this.i-1);n--}}throw new lt("MissingCloseBracket","Could not find closing ']' for argument to %1",this.currentCS)}GetDelimiter(t,e=!1){let r=this.GetNext();if(this.i+=r.length,this.i<=this.string.length&&("\\"===r?r+=this.GetCS():"{"===r&&e&&(this.i--,r=this.GetArgument(t).trim()),this.contains(it.DELIMITER,r)))return this.convertDelimiter(r);throw new lt("MissingOrUnrecognizedDelim","Missing or unrecognized delimiter for %1",this.currentCS)}GetDimen(t){if("{"===this.GetNext()){const e=this.GetArgument(t),[r,s]=at.matchDimen(e);if(r)return r+s}else{const t=this.string.slice(this.i),[e,r,s]=at.matchDimen(t,!0);if(e)return this.i+=s,e+r}throw new lt("MissingDimOrUnits","Missing dimension or its units for %1",this.currentCS)}GetUpTo(t,e){for(;this.nextIsSpace();)this.i++;const r=this.i;let s=0;for(;this.i<this.string.length;){const t=this.i;let i=this.GetNext();switch(this.i+=i.length,i){case"\\":i+=this.GetCS();break;case"{":s++;break;case"}":if(0===s)throw new lt("ExtraCloseLooking","Extra close brace while looking for %1",e);s--}if(0===s&&i===e)return this.string.slice(r,t)}throw new lt("TokenNotFoundForCommand","Could not find %1 for %2",e,this.currentCS)}ParseArg(t){return new dt(this.GetArgument(t),this.stack.env,this.configuration).mml()}ParseUpTo(t,e){return new dt(this.GetUpTo(t,e),this.stack.env,this.configuration).mml()}GetDelimiterArg(t){const e=at.trimSpaces(this.GetArgument(t));if(""===e)return null;if(this.contains(it.DELIMITER,e))return e;throw new lt("MissingOrUnrecognizedDelim","Missing or unrecognized delimiter for %1",this.currentCS)}GetStar(){const t="*"===this.GetNext();return t&&this.i++,t}create(t,...e){const r=this.configuration.nodeFactory.create(t,...e);return r.isToken&&r.attributes.hasExplicit("mathvariant")&&"-"===r.attributes.get("mathvariant").charAt(0)&&r.setProperty("ignore-variant",!0),r}trimTex(t){return t.trim()+(t.match(/(?:^|[^\\])(?:\\\\)*\\\s+$/)?" ":"")}updateResult(t,e){const r=this.stack.Prev(!0);if(!r)return;const s=W.Attr.LATEX,i=r.attributes.get(s),n=r.attributes.get(W.Attr.LATEXITEM);if(void 0!==n)return void(i||("}"===t||"}"===n?this.composeBraces(r):r.attributes.set(s,n)));e=e<this.saveI?this.saveI:e;const a=this.trimTex(e!==this.i?this.string.slice(e,this.i):t);if(a&&a!==i&&("\\"!==t||"\\"!==a)){if("_"===a||"^"===a)r.setProperty("sub-sup",a);else{switch(r.getProperty("sub-sup")){case"^":if(r.childNodes[2]&&("}"===a?this.composeBraces(r.childNodes[2]):r.childNodes[2].attributes.hasExplicit(s)||r.childNodes[2].attributes.set(s,a)),r.childNodes[1]){const t=r.childNodes[1].attributes.get(s);this.composeLatex(r,`_${t}^`,0,2)}else this.composeLatex(r,"^",0,2);return;case"_":if(r.childNodes[1]&&("}"===a?this.composeBraces(r.childNodes[1]):r.childNodes[1].attributes.hasExplicit(s)||r.childNodes[1].attributes.set(s,a)),r.childNodes[2]){const t=r.childNodes[2].attributes.get(s);this.composeLatex(r,`^${t}_`,0,1)}else this.composeLatex(r,"_",0,1);return}if("}"===a)return void this.composeBraces(r)}r.attributes.set(s,a)}}composeLatex(t,e,r,s){if(!t.childNodes[r]||!t.childNodes[s])return;const i=W.Attr.LATEX,n=(t.childNodes[r].attributes.get(i)||"")+e+t.childNodes[s].attributes.get(i);t.attributes.set(i,n)}composeBraces(t){const e=this.composeBracedContent(t);t.attributes.set(W.Attr.LATEX,`{${e}}`)}composeBracedContent(t){var e,r;const s=(null===(e=t.childNodes[0])||void 0===e?void 0:e.childNodes)||[];let i="";for(const t of s){const e=(null===(r=null==t?void 0:t.attributes)||void 0===r?void 0:r.get(W.Attr.LATEX))||"";e&&(i+=i&&i.match(/[a-zA-Z]$/)&&e.match(/^[a-zA-Z]/)?" "+e:e)}return i}}const mt=MathJax._.core.Tree.Factory.AbstractFactory;class pt extends ut{}class gt extends mt{constructor(){super(...arguments),this.defaultKind="dummy",this.configuration=null}}gt.DefaultStackItems={[pt.prototype.kind]:pt};const ft=gt;class bt{constructor(){this.mmlFactory=null,this.factory={node:bt.createNode,token:bt.createToken,text:bt.createText,error:bt.createError}}static createNode(t,e,r=[],s={},i){const n=t.mmlFactory.create(e);return n.setChildren(r),i&&n.appendChild(i),V.setProperties(n,s),n}static createToken(t,e,r={},s=""){const i=t.create("text",s);return t.create("node",e,[],r,i)}static createText(t,e){return null==e?null:t.mmlFactory.create("text").setText(e)}static createError(t,e){const r=t.create("text",e),s=t.create("node","mtext",[],{},r);return t.create("node","merror",[s],{"data-mjx-error":e})}setMmlFactory(t){this.mmlFactory=t}set(t,e){this.factory[t]=e}setCreators(t){for(const e in t)this.set(e,t[e])}create(t,...e){const r=(this.factory[t]||this.factory.node)(this,e[0],...e.slice(1));return"node"===t&&this.configuration.addNode(e[0],r),r}get(t){return this.factory[t]}}const yt=MathJax._.util.Entities,At=(yt.options,yt.entities);yt.add,yt.remove,yt.translate,yt.numeric;class kt{static oneof(...t){return new this("string",(e=>t.includes(e)),(t=>t))}constructor(t,e,r){this.name=t,this.verify=e,this.convert=r}}const vt={boolean:new kt("boolean",(t=>"true"===t||"false"===t),(t=>"true"===t)),number:new kt("number",(t=>!!t.match(/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[-+]?\d+)?$/)),(t=>parseFloat(t))),integer:new kt("integer",(t=>!!t.match(/^[-+]?\d+$/)),(t=>parseInt(t))),string:new kt("string",(t=>!0),(t=>t)),dimen:new kt("dimen",(t=>null!==at.matchDimen(t)[0]),(t=>t))};function Pt(t,e){if(0===e)return t.replace(/^\s+/,"").replace(/([^\\\s]|^)((?:\\\\)*(?:\\\s)?)?\s+$/,"$1$2");for(;e>0;)t=t.trim().slice(1,-1),e--;return t}function Tt(t,e,r=!1,s=!1){const i=t.length;let n=0,a="",o=0,c=0,l=!0;for(;o<i;){const s=t[o++];switch(s){case"\\":a+=s+(t[o++]||""),l=!1;continue;case" ":break;case"{":l&&c++,n++;break;case"}":if(!n)throw new lt("ExtraCloseMissingOpen","Extra close brace or missing open brace");n--,l=!1;break;default:if(!n&&e.includes(s))return[Pt(a,r?Math.min(1,c):c),s,t.slice(o)];c>n&&(c=n),l=!1}a+=s}if(n)throw new lt("ExtraOpenMissingClose","Extra open brace or missing close brace");return s&&c?["","",Pt(a,1)]:[Pt(a,r?Math.min(1,c):c),"",t.slice(o)]}const wt={cols:(...t)=>t.map((t=>at.em(t))).join(" "),fenced(t,e,r,s,i="",n=""){const a=t.nodeFactory,o=a.create("node","mrow",[],{open:e,close:s,texClass:X.INNER});let c;if(i)c=new dt("\\"+i+"l"+e,t.parser.stack.env,t).mml();else{const t=a.create("text",e);c=a.create("node","mo",[],{fence:!0,stretchy:!0,symmetric:!0,texClass:X.OPEN},t)}if(V.appendChildren(o,[c,r]),i)c=new dt("\\"+i+"r"+s,t.parser.stack.env,t).mml();else{const t=a.create("text",s);c=a.create("node","mo",[],{fence:!0,stretchy:!0,symmetric:!0,texClass:X.CLOSE},t)}return n&&c.attributes.set("mathcolor",n),V.appendChildren(o,[c]),o},fixedFence(t,e,r,s){const i=t.nodeFactory.create("node","mrow",[],{open:e,close:s,texClass:X.ORD});return e&&V.appendChildren(i,[wt.mathPalette(t,e,"l")]),V.isType(r,"mrow")?V.appendChildren(i,V.getChildren(r)):V.appendChildren(i,[r]),s&&V.appendChildren(i,[wt.mathPalette(t,s,"r")]),i},mathPalette(t,e,r){"{"!==e&&"}"!==e||(e="\\"+e);const s="{\\big"+r+" "+e+"}";return new dt("\\mathchoice"+("{\\bigg"+r+" "+e+"}")+s+s+s,{},t).mml()},fixInitialMO(t,e){for(let r=0,s=e.length;r<s;r++){const s=e[r];if(s&&!V.isType(s,"mspace")&&(!V.isType(s,"TeXAtom")||V.getChildren(s)[0]&&V.getChildren(V.getChildren(s)[0]).length)){if(V.isEmbellished(s)||V.isType(s,"TeXAtom")&&V.getTexClass(s)===X.REL){const r=t.nodeFactory.create("node","mi");e.unshift(r)}break}}},internalMath(t,e,r,s){if(e=e.replace(/ +/g," "),t.configuration.options.internalMath)return t.configuration.options.internalMath(t,e,r,s);const i=s||t.stack.env.font,n=i?{mathvariant:i}:{};let a,o,c=[],l=0,h=0,u="",d=0;if(e.match(/\\?[${}\\]|\\\(|\\(?:eq)?ref\s*\{|\\U/)){for(;l<e.length;)if(a=e.charAt(l++),"$"===a)"$"===u&&0===d?(o=t.create("node","TeXAtom",[new dt(e.slice(h,l-1),{},t.configuration).mml()]),c.push(o),u="",h=l):""===u&&(h<l-1&&c.push(wt.internalText(t,e.slice(h,l-1),n)),u="$",h=l);else if("{"===a&&""!==u)d++;else if("}"===a)if("}"===u&&0===d){const r=new dt(e.slice(h,l),{},t.configuration).mml();o=t.create("node","TeXAtom",[r],n),c.push(o),u="",h=l}else""!==u&&d&&d--;else if("\\"===a)if(""===u&&e.substring(l).match(/^(eq)?ref\s*\{/)){const r=RegExp["$&"].length;h<l-1&&c.push(wt.internalText(t,e.slice(h,l-1),n)),u="}",h=l-1,l+=r}else if(a=e.charAt(l++),"("===a&&""===u)h<l-2&&c.push(wt.internalText(t,e.slice(h,l-2),n)),u=")",h=l;else if(")"===a&&")"===u&&0===d)o=t.create("node","TeXAtom",[new dt(e.slice(h,l-2),{},t.configuration).mml()]),c.push(o),u="",h=l;else if(a.match(/[${}\\]/)&&""===u)l--,e=e.substring(0,l-1)+e.substring(l);else if("U"===a){const t=e.substring(l).match(/^\s*(?:([0-9A-F])|\{\s*([0-9A-F]+)\s*\})/);if(!t)throw new lt("BadRawUnicode","Argument to %1 must a hexadecimal number with 1 to 6 digits","\\U");const r=String.fromCodePoint(parseInt(t[1]||t[2],16));e=e.substring(0,l-2)+r+e.substring(l+t[0].length),l=l-2+r.length}if(""!==u)throw new lt("MathNotTerminated","Math mode is not properly terminated")}return h<e.length&&c.push(wt.internalText(t,e.slice(h),n)),null!=r?c=[t.create("node","mstyle",c,{displaystyle:!1,scriptlevel:r})]:c.length>1&&(c=[t.create("node","mrow",c)]),c},internalText(t,e,r){e=e.replace(/\n+/g," ").replace(/^ +/,At.nbsp).replace(/ +$/,At.nbsp);const s=t.create("text",e);return t.create("node","mtext",[],r,s)},underOver(t,e,r,s,i){if(wt.checkMovableLimits(e),V.isType(e,"munderover")&&V.isEmbellished(e)){V.setProperties(V.getCoreMO(e),{lspace:0,rspace:0});const r=t.create("node","mo",[],{rspace:0});e=t.create("node","mrow",[r,e])}const n=t.create("node","munderover",[e]);V.setChild(n,"over"===s?n.over:n.under,r);let a=n;return i&&(a=t.create("node","TeXAtom",[t.create("node","mstyle",[n],{displaystyle:!0,scriptlevel:0})],{texClass:X.OP,movesupsub:!0})),V.setProperty(a,"subsupOK",!0),a},checkMovableLimits(t){const e=V.isType(t,"mo")?V.getForm(t):null;(V.getProperty(t,"movablelimits")||e&&e[3]&&e[3].movablelimits)&&V.setProperties(t,{movablelimits:!1})},setArrayAlign:(t,e,r)=>(r||(e=at.trimSpaces(e||"")),"t"===e?t.arraydef.align="baseline 1":"b"===e?t.arraydef.align="baseline -1":"c"===e?t.arraydef.align="axis":e&&(r?(r.string=`[${e}]`+r.string.slice(r.i),r.i=0):t.arraydef.align=e),t),substituteArgs(t,e,r){let s="",i="",n=0;for(;n<r.length;){let a=r.charAt(n++);if("\\"===a)s+=a+r.charAt(n++);else if("#"===a)if(a=r.charAt(n++),"#"===a)s+=a;else{if(!a.match(/[1-9]/)||parseInt(a,10)>e.length)throw new lt("IllegalMacroParam","Illegal macro parameter reference");i=wt.addArgs(t,wt.addArgs(t,i,s),e[parseInt(a,10)-1]),s=""}else s+=a}return wt.addArgs(t,i,s)},addArgs(t,e,r){if(r.match(/^[a-z]/i)&&e.match(/(^|[^\\])(\\\\)*\\[a-z]+$/i)&&(e+=" "),e.length+r.length>t.configuration.options.maxBuffer)throw new lt("MaxBufferSize","MathJax internal buffer size exceeded; is there a recursive macro call?");return e+r},checkMaxMacros(t,e=!0){if(!(++t.macroCount<=t.configuration.options.maxMacros))throw e?new lt("MaxMacroSub1","MathJax maximum macro substitution count exceeded; is here a recursive macro call?"):new lt("MaxMacroSub2","MathJax maximum substitution count exceeded; is there a recursive latex environment?")},checkEqnEnv(t,e=!0){const r=t.stack.Top(),s=r.First;if(!(r.getProperty("nestable")&&e&&!s||r.getProperty("nestStart"))&&(!r.isKind("start")||s))throw new lt("ErroneousNestingEq","Erroneous nesting of equation structures")},copyNode(t,e){const r=t.copy(),s=e.configuration;return r.walkTree((t=>{s.addNode(t.kind,t);const e=(t.getProperty("in-lists")||"").split(/,/);for(const r of e)r&&s.addNode(r,t)})),r},mmlFilterAttribute:(t,e,r)=>r,getFontDef(t){const e=t.stack.env.font;return e?{mathvariant:e}:{}},keyvalOptions(t,e=null,r=!1,s=!1){const i=function(t,e=!1){const r={};let s,i,n,a=t,o=!0;for(;a;)[i,s,a]=Tt(a,["=",","],e,o),o=!1,"="===s?([n,s,a]=Tt(a,[","],e),n="false"===n||"true"===n?JSON.parse(n):n,r[i]=n):i&&(r[i]=!0);return r}(t,s);if(e)for(const t of Object.keys(i))if(Object.hasOwn(e,t)){if(e[t]instanceof kt){const r=e[t],s=String(i[t]);if(!r.verify(s))throw new lt("InvalidValue","Value for key '%1' is not of the expected type",t);i[t]=r.convert(s)}}else{if(r)throw new lt("InvalidOption","Invalid option: %1",t);delete i[t]}return i},isLatinOrGreekChar:t=>!!t.normalize("NFD").match(/[a-zA-Z\u0370-\u03F0]/)};class Mt{constructor(){this.columnHandler={l:t=>t.calign[t.j++]="left",c:t=>t.calign[t.j++]="center",r:t=>t.calign[t.j++]="right",p:t=>this.getColumn(t,"top"),m:t=>this.getColumn(t,"middle"),b:t=>this.getColumn(t,"bottom"),w:t=>this.getColumn(t,"top",""),W:t=>this.getColumn(t,"top",""),"|":t=>this.addRule(t,"solid"),":":t=>this.addRule(t,"dashed"),">":t=>t.cstart[t.j]=(t.cstart[t.j]||"")+this.getBraces(t),"<":t=>t.cend[t.j-1]=(t.cend[t.j-1]||"")+this.getBraces(t),"@":t=>this.addAt(t,this.getBraces(t)),"!":t=>this.addBang(t,this.getBraces(t)),"*":t=>this.repeat(t),P:t=>this.macroColumn(t,">{$}p{#1}<{$}",1),M:t=>this.macroColumn(t,">{$}m{#1}<{$}",1),B:t=>this.macroColumn(t,">{$}b{#1}<{$}",1)," ":t=>{}},this.MAXCOLUMNS=1e4}process(t,e,r){const s={parser:t,template:e,i:0,j:0,c:"",cwidth:[],calign:[],cspace:[],clines:[],cstart:r.cstart,cend:r.cend,ralign:r.ralign,cextra:r.cextra};let i=0;for(;s.i<s.template.length;){if(i++>this.MAXCOLUMNS)throw new lt("MaxColumns","Too many column specifiers (perhaps looping column definitions?)");const t=s.template.codePointAt(s.i),e=s.c=String.fromCodePoint(t);if(s.i+=e.length,!Object.hasOwn(this.columnHandler,e))throw new lt("BadPreamToken","Illegal pream-token (%1)",e);this.columnHandler[e](s)}this.setColumnAlign(s,r),this.setColumnWidths(s,r),this.setColumnSpacing(s,r),this.setColumnLines(s,r),this.setPadding(s,r)}setColumnAlign(t,e){e.arraydef.columnalign=t.calign.join(" ")}setColumnWidths(t,e){if(!t.cwidth.length)return;const r=[...t.cwidth];r.length<t.calign.length&&r.push("auto"),e.arraydef.columnwidth=r.map((t=>t||"auto")).join(" ")}setColumnSpacing(t,e){if(!t.cspace.length)return;const r=[...t.cspace];r.length<t.calign.length&&r.push("1em"),e.arraydef.columnspacing=r.slice(1).map((t=>t||"1em")).join(" ")}setColumnLines(t,e){if(!t.clines.length)return;const r=[...t.clines];r[0]&&e.frame.push(["left",r[0]]),r.length>t.calign.length?e.frame.push(["right",r.pop()]):r.length<t.calign.length&&r.push("none"),r.length>1&&(e.arraydef.columnlines=r.slice(1).map((t=>t||"none")).join(" "))}setPadding(t,e){if(!t.cextra[0]&&!t.cextra[t.calign.length-1])return;const r=t.calign.length-1,s=t.cspace,i=t.cextra[r]?s[r]:null;e.arraydef["data-array-padding"]=`${s[0]||".5em"} ${i||".5em"}`}getColumn(t,e,r="left"){t.calign[t.j]=r||this.getAlign(t),t.cwidth[t.j]=this.getDimen(t),t.ralign[t.j]=[e,t.cwidth[t.j],t.calign[t.j]],t.j++}getDimen(t){const e=this.getBraces(t);if(!at.matchDimen(e)[0])throw new lt("MissingColumnDimOrUnits","Missing dimension or its units for %1 column declaration",t.c);return e}getAlign(t){const e=this.getBraces(t);return F(e.toLowerCase(),{l:"left",c:"center",r:"right"},"")}getBraces(t){for(;" "===t.template[t.i];)t.i++;if(t.i>=t.template.length)throw new lt("MissingArgForColumn","Missing argument for %1 column declaration",t.c);if("{"!==t.template[t.i])return t.template[t.i++];const e=++t.i;let r=1;for(;t.i<t.template.length;)switch(t.template.charAt(t.i++)){case"\\":t.i++;break;case"{":r++;break;case"}":if(0===--r)return t.template.slice(e,t.i-1)}throw new lt("MissingCloseBrace","Missing close brace")}macroColumn(t,e,r){const s=[];for(;r>0&&r--;)s.push(this.getBraces(t));t.template=wt.substituteArgs(t.parser,s,e)+t.template.slice(t.i),t.i=0}addRule(t,e){t.clines[t.j]&&this.addAt(t,"\\,"),t.clines[t.j]=e,"0"===t.cspace[t.j]&&(t.cstart[t.j]="\\hspace{.5em}")}addAt(t,e){const{cstart:r,cspace:s,j:i}=t;t.cextra[i]=!0,t.calign[i]="center",t.clines[i]&&(".5em"===s[i]?r[i-1]+="\\hspace{.25em}":s[i]||(t.cend[i-1]=(t.cend[i-1]||"")+"\\hspace{.5em}")),r[i]=e,s[i]="0",s[++t.j]="0"}addBang(t,e){const{cstart:r,cspace:s,j:i}=t;t.cextra[i]=!0,t.calign[i]="center",r[i]=("0"===s[i]&&t.clines[i]?"\\hspace{.25em}":"")+e,s[i]||(s[i]=".5em"),s[++t.j]=".5em"}repeat(t){const e=this.getBraces(t),r=this.getBraces(t),s=parseInt(e);if(String(s)!==e)throw new lt("ColArgNotNum","First argument to %1 column specifier must be a number","*");t.template=new Array(s).fill(r).join("")+t.template.substring(t.i),t.i=0}}const xt=W.Variant;class Ot{constructor(t,e=[]){this.options={},this.columnParser=new Mt,this.packageData=new Map,this.parsers=[],this.root=null,this.nodeLists={},this.error=!1,this.handlers=t.handlers,this.nodeFactory=new bt,this.nodeFactory.configuration=this,this.nodeFactory.setCreators(t.nodes),this.itemFactory=new ft(t.items),this.itemFactory.configuration=this,I(this.options,...e),I(this.options,t.options),this.mathStyle=Ot.getVariant.get(this.options.mathStyle)||Ot.getVariant.get("TeX")}pushParser(t){this.parsers.unshift(t)}popParser(){this.parsers.shift()}get parser(){return this.parsers[0]}clear(){this.parsers=[],this.root=null,this.nodeLists={},this.error=!1,this.tags.resetTag()}addNode(t,e){let r=this.nodeLists[t];if(r||(r=this.nodeLists[t]=[]),r.push(e),e.kind!==t){const r=V.getProperty(e,"in-lists")||"",s=(r?r.split(/,/):[]).concat(t).join(",");V.setProperty(e,"in-lists",s)}}getList(t){const e=this.nodeLists[t]||[],r=[];for(const t of e)this.inTree(t)&&r.push(t);return this.nodeLists[t]=r,r}removeFromList(t,e){const r=this.nodeLists[t]||[];for(const t of e){const e=r.indexOf(t);e>=0&&r.splice(e,1)}}inTree(t){for(;t&&t!==this.root;)t=t.parent;return!!t}}Ot.getVariant=new Map([["TeX",(t,e)=>e&&t.match(/^[\u0391-\u03A9\u03F4]/)?xt.NORMAL:""],["ISO",t=>xt.ITALIC],["French",t=>t.normalize("NFD").match(/^[a-z]/)?xt.ITALIC:xt.NORMAL],["upright",t=>xt.NORMAL]]);const Et=Ot;class St{constructor(t="???",e=""){this.tag=t,this.id=e}}class Ct{constructor(t="",e=!1,r=!1,s=null,i="",n="",a=!1,o=""){this.env=t,this.taggable=e,this.defaultTags=r,this.tag=s,this.tagId=i,this.tagFormat=n,this.noTag=a,this.labelId=o}}class It{constructor(){this.counter=0,this.allCounter=0,this.configuration=null,this.ids={},this.allIds={},this.labels={},this.allLabels={},this.redo=!1,this.refUpdate=!1,this.currentTag=new Ct,this.history=[],this.stack=[],this.enTag=function(t,e){const r=this.configuration.nodeFactory,s=r.create("node","mtd",[t]),i=r.create("node","mlabeledtr",[e,s]);return r.create("node","mtable",[i],{side:this.configuration.options.tagSide,minlabelspacing:this.configuration.options.tagIndent,displaystyle:!0})}}start(t,e,r){this.currentTag&&this.stack.push(this.currentTag);const s=this.label;this.currentTag=new Ct(t,e,r),this.label=s}get env(){return this.currentTag.env}end(){this.history.push(this.currentTag);const t=this.label;this.currentTag=this.stack.pop(),t&&!this.label&&(this.label=t)}tag(t,e){this.currentTag.tag=t,this.currentTag.tagFormat=e?t:this.formatTag(t),this.currentTag.noTag=!1}notag(){this.tag("",!0),this.currentTag.noTag=!0}get noTag(){return this.currentTag.noTag}set label(t){this.currentTag.labelId=t}get label(){return this.currentTag.labelId}formatUrl(t,e){return e+"#"+encodeURIComponent(t)}formatTag(t){return["(",t,")"]}formatRef(t){return this.formatTag(t)}formatId(t){return"mjx-eqn:"+t.replace(/\s/g,"_")}formatNumber(t){return t.toString()}autoTag(){null==this.currentTag.tag&&(this.counter++,this.tag(this.formatNumber(this.counter),!1))}clearTag(){this.tag(null,!0),this.currentTag.tagId=""}getTag(t=!1){if(t)return this.autoTag(),this.makeTag();const e=this.currentTag;return e.taggable&&!e.noTag&&(e.defaultTags&&this.autoTag(),e.tag)?this.makeTag():null}resetTag(){this.history=[],this.redo=!1,this.refUpdate=!1,this.clearTag()}reset(t=0){this.resetTag(),this.counter=this.allCounter=t,this.allLabels={},this.allIds={},this.label=""}startEquation(t){this.history=[],this.stack=[],this.clearTag(),this.currentTag=new Ct("",void 0,void 0),this.labels={},this.ids={},this.counter=this.allCounter,this.redo=!1;const e=t.inputData.recompile;e&&(this.refUpdate=!0,this.counter=e.counter)}finishEquation(t){this.redo&&(t.inputData.recompile={state:t.state(),counter:this.allCounter}),this.refUpdate||(this.allCounter=this.counter),Object.assign(this.allIds,this.ids),Object.assign(this.allLabels,this.labels)}finalize(t,e){if(!e.display||this.currentTag.env||null==this.currentTag.tag)return t;const r=this.makeTag();return this.enTag(t,r)}makeId(){this.currentTag.tagId=this.formatId(this.configuration.options.useLabelIds&&this.label||this.currentTag.tag)}makeTag(){var t;this.makeId(),this.label&&(this.labels[this.label]=new St(this.currentTag.tag,this.currentTag.tagId),this.label="");const e=this.currentTag.tagFormat,r=Array.isArray(e)?e:(null===(t=e.match(/^(\(|\[|\{)(.*)(\}|\]|\))$/))||void 0===t?void 0:t.slice(1))||[e],s=new dt(r.map((t=>t?`\\text{${t}}`:"")).join(""),{},this.configuration).mml();return this.configuration.nodeFactory.create("node","mtd",[s],{id:this.currentTag.tagId,rowalign:this.configuration.options.tagAlign})}}class Lt extends It{autoTag(){}getTag(){return this.currentTag.tag?super.getTag():null}}class Nt extends It{finalize(t,e){if(!e.display||this.history.find((function(t){return t.taggable})))return t;const r=this.getTag(!0);return this.enTag(t,r)}}const Ft=new Map([["none",Lt],["all",Nt]]);let Rt="none";const Bt={OPTIONS:{tags:Rt,tagSide:"right",tagIndent:"0.8em",useLabelIds:!0,ignoreDuplicateLabels:!1,tagAlign:"baseline"},add(t,e){Ft.set(t,e)},addTags(t){for(const e of Object.keys(t))Bt.add(e,t[e])},create(t){const e=Ft.get(t)||Ft.get(Rt);if(!e)throw Error("Unknown tags class");return new e},setDefault(t){Rt=t},getDefault:()=>Bt.create(Rt)};class Dt{constructor(t,e,r){this._token=t,this._char=e,this._attributes=r}get token(){return this._token}get char(){return this._char}get attributes(){return this._attributes}}class Gt{constructor(t,e,r=[]){this._token=t,this._func=e,this._args=r}get token(){return this._token}get func(){return this._func}get args(){return this._args}}function Ut(t){return void 0===t||t}class _t{constructor(t,e){this._name=t,this._parser=e,Zt.register(this)}get name(){return this._name}parserFor(t){return this.contains(t)?this.parser:null}parse([t,e]){const r=this.parserFor(e),s=this.lookup(e);return r&&s?Ut(r(t,s)):null}set parser(t){this._parser=t}get parser(){return this._parser}}class jt extends _t{constructor(t,e,r){super(t,e),this._regExp=r}contains(t){return this._regExp.test(t)}lookup(t){return this.contains(t)?t:null}}class Kt extends _t{constructor(){super(...arguments),this.map=new Map}lookup(t){return this.map.get(t)}contains(t){return this.map.has(t)}add(t,e){this.map.set(t,e)}remove(t){this.map.delete(t)}}class Ht extends Kt{constructor(t,e,r){super(t,e);for(const t of Object.keys(r)){const e=r[t],[s,i]="string"==typeof e?[e,null]:e,n=new Dt(t,s,i);this.add(t,n)}}}class Xt extends Ht{parse([t,e]){return super.parse([t,"\\"+e])}}class zt extends Kt{constructor(t,e,r={}){super(t,null);const s=t=>"string"==typeof t?r[t]:t;for(const[t,r]of Object.entries(e)){let e,i;Array.isArray(r)?(e=s(r[0]),i=r.slice(1)):(e=s(r),i=[]);const n=new Gt(t,e,i);this.add(t,n)}}parserFor(t){const e=this.lookup(t);return e?e.func:null}parse([t,e]){const r=this.lookup(e),s=this.parserFor(e);return r&&s?Ut(s(t,r.token,...r.args)):null}}class qt extends zt{parse([t,e]){const r=this.lookup(e),s=this.parserFor(e);if(!r||!s)return null;const i=t.currentCS;t.currentCS="\\"+e;const n=s(t,"\\"+r.token,...r.args);return t.currentCS=i,Ut(n)}}class $t extends zt{constructor(t,e,r,s={}){super(t,r,s),this.parser=e}parse([t,e]){const r=this.lookup(e),s=this.parserFor(e);return r&&s?Ut(this.parser(t,r.token,s,r.args)):null}}const Jt=MathJax._.util.PrioritizedList.PrioritizedList,Vt=MathJax._.util.FunctionList.FunctionList,Wt=new Map,Zt={register(t){Wt.set(t.name,t)},getMap:t=>Wt.get(t)};class Yt{constructor(){this._configuration=new Jt,this._fallback=new Vt}add(t,e,r=Jt.DEFAULTPRIORITY){for(const e of t.slice().reverse()){const t=Zt.getMap(e);if(!t)return void this.warn(`Configuration '${e}' not found! Omitted.`);this._configuration.add(t,r)}e&&this._fallback.add(e,r)}remove(t,e=null){for(const e of t){const t=this.retrieve(e);t&&this._configuration.remove(t)}e&&this._fallback.remove(e)}parse(t){for(const{item:e}of this._configuration){const r=e.parse(t);if(r===Yt.FALLBACK)break;if(r)return r}const[e,r]=t;Array.from(this._fallback)[0].item(e,r)}lookup(t){const e=this.applicable(t);return e?e.lookup(t):null}contains(t){const e=this.applicable(t);return!(!e||e instanceof Ht&&null===e.lookup(t).char)}toString(){const t=[];for(const{item:e}of this._configuration)t.push(e.name);return t.join(", ")}applicable(t){for(const{item:e}of this._configuration)if(e.contains(t))return e;return null}retrieve(t){for(const{item:e}of this._configuration)if(e.name===t)return e;return null}warn(t){console.log("TexParser Warning: "+t)}}Yt.FALLBACK=Symbol("fallback");class Qt{constructor(){this.map=new Map}add(t,e,r=Jt.DEFAULTPRIORITY){for(const s of Object.keys(t)){const i=s;let n=this.get(i);n||(n=new Yt,this.set(i,n)),n.add(t[i],e[i],r)}}remove(t,e){for(const r of Object.keys(t)){const s=this.get(r);s&&s.remove(t[r],e[r])}}set(t,e){this.map.set(t,e)}get(t){return this.map.get(t)}retrieve(t){for(const e of this.map.values()){const r=e.retrieve(t);if(r)return r}return null}keys(){return this.map.keys()}}class te{static makeProcessor(t,e){return Array.isArray(t)?t:[t,e]}static _create(t,e={}){var r;const s=null!==(r=e.priority)&&void 0!==r?r:Jt.DEFAULTPRIORITY,i=e.init?this.makeProcessor(e.init,s):null,n=e.config?this.makeProcessor(e.config,s):null,a=(e.preprocessors||[]).map((t=>this.makeProcessor(t,s))),o=(e.postprocessors||[]).map((t=>this.makeProcessor(t,s))),c=e.parser||"tex";return new te(t,e[st.HANDLER]||{},e[st.FALLBACK]||{},e[st.ITEMS]||{},e[st.TAGS]||{},e[st.OPTIONS]||{},e[st.NODES]||{},a,o,i,n,s,c)}static create(t,e={}){const r=te._create(t,e);return re.set(t,r),r}static local(t={}){return te._create("",t)}constructor(t,e={},r={},s={},i={},n={},a={},o=[],c=[],l=null,h=null,u,d){this.name=t,this.handler=e,this.fallback=r,this.items=s,this.tags=i,this.options=n,this.nodes=a,this.preprocessors=o,this.postprocessors=c,this.initMethod=l,this.configMethod=h,this.priority=u,this.parser=d,this.handler=Object.assign({[it.CHARACTER]:[],[it.DELIMITER]:[],[it.MACRO]:[],[it.ENVIRONMENT]:[]},e)}get init(){return this.initMethod?this.initMethod[0]:null}get config(){return this.configMethod?this.configMethod[0]:null}}const ee=new Map,re={set(t,e){ee.set(t,e)},get:t=>ee.get(t),keys:()=>ee.keys()};class se{constructor(t,e=["tex"]){this.initMethod=new Vt,this.configMethod=new Vt,this.configurations=new Jt,this.parsers=[],this.handlers=new Qt,this.items={},this.tags={},this.options={},this.nodes={},this.parsers=e;for(const e of t.slice().reverse())this.addPackage(e);for(const{item:t,priority:e}of this.configurations)this.append(t,e)}init(){this.initMethod.execute(this)}config(t){this.configMethod.execute(this,t);for(const e of this.configurations)this.addFilters(t,e.item)}addPackage(t){const e="string"==typeof t?t:t[0],r=this.getPackage(e);r&&this.configurations.add(r,"string"==typeof t?r.priority:t[1])}add(t,e,r={}){const s=this.getPackage(t);this.append(s),this.configurations.add(s,s.priority),this.init();const i=e.parseOptions;i.nodeFactory.setCreators(s.nodes);for(const t of Object.keys(s.items))i.itemFactory.setNodeClass(t,s.items[t]);Bt.addTags(s.tags),I(i.options,s.options),L(i.options,r),this.addFilters(e,s),s.config&&s.config(this,e)}getPackage(t){const e=re.get(t);if(e&&!this.parsers.includes(e.parser))throw Error(`Package '${t}' doesn't target the proper parser`);return e||this.warn(`Package '${t}' not found. Omitted.`),e}append(t,e){e=e||t.priority,t.initMethod&&this.initMethod.add(t.initMethod[0],t.initMethod[1]),t.configMethod&&this.configMethod.add(t.configMethod[0],t.configMethod[1]),this.handlers.add(t.handler,t.fallback,e),Object.assign(this.items,t.items),Object.assign(this.tags,t.tags),I(this.options,t.options),Object.assign(this.nodes,t.nodes)}addFilters(t,e){for(const[r,s]of e.preprocessors)t.preFilters.add(r,s);for(const[r,s]of e.postprocessors)t.postFilters.add(r,s)}warn(t){console.warn("MathJax Warning: "+t)}}const ie=MathJax._.util.Styles,ne=ie.TRBL;ie.WSC,ie.Styles;class ae extends ut{constructor(t,e){super(t),this.global=e}get kind(){return"start"}get isOpen(){return!0}checkItem(t){if(t.isKind("stop")){let t=this.toMml();return this.global.isInner||(t=this.factory.configuration.tags.finalize(t,this.env)),[[this.factory.create("mml",t)],!0]}return super.checkItem(t)}}class oe extends ut{get kind(){return"stop"}get isClose(){return!0}}class ce extends ut{get kind(){return"open"}get isOpen(){return!0}checkItem(t){if(t.isKind("close")){const e=this.toMml(),r=this.create("node","TeXAtom",[e]);return t.addLatexItem(r),[[this.factory.create("mml",r)],!0]}return super.checkItem(t)}}ce.errors=Object.assign(Object.create(ut.errors),{stop:["ExtraOpenMissingClose","Extra open brace or missing close brace"]});class le extends ut{get kind(){return"close"}get isClose(){return!0}}class he extends ut{get kind(){return"null"}}class ue extends ut{get kind(){return"prime"}checkItem(t){const[e,r]=this.Peek(2),s=(V.isType(e,"msubsup")||V.isType(e,"msup"))&&!V.getChildAt(e,e.sup),i=(V.isType(e,"munder