@minamorl/flashmath 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @minamorl/flashmath
2
2
 
3
- TeX to MathML for React. Version 0.1.0 release candidate; not yet published.
3
+ TeX to MathML for React. Version 0.1.1.
4
4
 
5
5
  ## Usage
6
6
 
@@ -1 +1 @@
1
- import{a as F,b as R}from"./chunk-TXV67IQS.js";import{b as v,d as H}from"./chunk-IHTB7IDO.js";H();function g(t,n=[],i={},o=0){return i.style?.endsWith(";")&&(i.style=i.style.slice(0,-1)),{kind:t,children:n,attributes:i,text:"",start:o}}function L(t){let n=[],i=-1;for(let o=0;o<=t.length;o++){let c=t.charCodeAt(o);o===t.length||c<=32||c===160?i>=0&&(n.push(t.slice(i,o)),i=-1):i<0&&(i=o)}return n}function f(t,n){let i=t.attributes.style??"",o=i+(i&&!i.endsWith(";")?";":"")+n;t.attributes.style=o.endsWith(";")?o.slice(0,-1):o}function _(t){let n=M(t.attributes.lspace,"0em");t.kind="mrow";for(let i of["width","height","depth","lspace","voffset"])delete t.attributes[i];return t.attributes["data-flashmath-bbox"]="true",f(t,`padding:${n};`),t}function M(t,n){if(!t)return n;let i=t.trim(),o=i[0]==="+"?1:0,c=0,m=0;for(;o<i.length;o++){let u=i.charCodeAt(o);if(u>=48&&u<=57)m++;else{if(u===46&&c++===0)continue;break}}let l=i.slice(o);return!m||!["","em","ex","px","pt","pc","in","cm","mm","mu","%"].includes(l)?n:l==="mu"?`${Number(i.slice(0,o))/18}em`:i.slice(0,o)+(l||"em")}function B(t,n,i,o=0,c="4 2 1"){let m=n==="up"||n==="down",p=g("mrow",[],{"data-flashmath-line":n,style:`position:absolute;left:50%;top:50%;width:${m?"hypot(100cqw,100cqh)":n==="vertical"?"100cqh":"100cqw"};height:${i};background-color:currentColor;transform:translate(-50%,-50%) rotate(${m?`calc(${n==="up"?"-1":"1"} * atan2(100cqh,100cqw))`:n==="vertical"?"90deg":"0deg"});`},t.start),s=L(c).map(Number),r=Number.isFinite(s[0])&&s[0]>0?s[0]:4,d=Number.isFinite(s[1])&&s[1]>0?s[1]:2,e=Number.isFinite(s[2])&&s[2]>=0?s[2]:1;for(let a of[1,2])o&a&&p.children.push(g("mrow",[],{style:`position:absolute;${a===1?"right":"left"}:0;top:50%;width:calc(${r+e} * ${i});height:calc(${2*d} * ${i});background-color:currentColor;clip-path:polygon(0 0,100% 50%,0 100%,${100*e/(r+e)}% 50%);transform:translateY(-50%)${a===2?" rotate(180deg)":""};`},t.start));return g("mrow",[p],{"aria-hidden":"true",style:"position:absolute;inset:0;container-type:size;pointer-events:none;"},t.start)}var T={uparrow:["vertical",2],downarrow:["vertical",1],leftarrow:["horizontal",2],rightarrow:["horizontal",1],updownarrow:["vertical",3],leftrightarrow:["horizontal",3],updiagonalarrow:["up",1],northeastarrow:["up",1],southwestarrow:["up",2],southeastarrow:["down",1],northwestarrow:["down",2],northeastsouthwestarrow:["up",3],northwestsoutheastarrow:["down",3]},Y={top:["top"],right:["right"],bottom:["bottom"],left:["left"],actuarial:["top","right"],madruwb:["bottom","right"],box:["top","right","bottom","left"],roundedbox:["top","right","bottom","left"],circle:["top","right","bottom","left"]};function C(t){let n=new Set(L(t.attributes.notation??"longdiv")),i={...t.attributes};delete i.notation;let o=M(i["data-padding"],".2em"),c=M(i["data-thickness"],".067em"),m={...t,kind:"mrow",attributes:i,children:[...t.children]};m.attributes["data-flashmath-enclose"]=[...n].join(" "),i.color&&!i.mathcolor&&(i.mathcolor=i.color),i.background&&!i.mathbackground&&(i.mathbackground=i.background);let l=g("mrow",m.children,{},t.start);n.has("radical")&&(l=g("msqrt",[l],{},t.start)),m.children=[l];let u={position:"relative"},p={top:"0em",right:"0em",bottom:"0em",left:"0em"},s=(a,b)=>{p[a]=p[a]==="0em"||p[a]===b?b:`max(${p[a]},${b})`},r=new Set,d=new Set;for(let a of n)for(let b of Object.hasOwn(Y,a)?Y[a]:[])r.add(b),a!=="circle"&&a!=="roundedbox"&&d.add(b);if(r.size){for(let[a,b]of[["straight",d],["roundedbox",n.has("roundedbox")?r:[]],["circle",n.has("circle")?r:[]]]){let h=[...b].map(w=>`border-${w}:${c} solid currentColor;`).join("");h&&m.children.push(g("mrow",[],{"aria-hidden":"true",style:"position:absolute;inset:0;pointer-events:none;"+h+(a==="circle"?"border-radius:50%;":a==="roundedbox"?`border-radius:calc(${o} + ${c});`:"")},t.start))}for(let a of r)s(a,`calc(${o} + ${c})`)}let e=new Map;for(let a of n)if(Object.hasOwn(T,a)){let[b,h]=T[a];e.set(b,(e.get(b)??0)|h)}else a==="updiagonalstrike"?e.set("up",e.get("up")??0):a==="downdiagonalstrike"?e.set("down",e.get("down")??0):a==="horizontalstrike"?e.set("horizontal",e.get("horizontal")??0):a==="verticalstrike"&&e.set("vertical",e.get("vertical")??0);for(let[a,b]of e){if(a==="up"||a==="down")for(let h of Object.keys(p))s(h,`calc(${o} + ${c})`);else{let[h,w]=a==="horizontal"?["left","right"]:["top","bottom"],[x=4,,$=1]=L(i["data-arrowhead"]??"4 2 1").map(Number),k=Number.isFinite(x+$)&&x>0&&$>=0?x+$+1:6;s(h,b&2?`max(${o},calc(${k} * ${c}))`:o),s(w,b&1?`max(${o},calc(${k} * ${c}))`:o)}m.children.push(B(t,a,c,b,i["data-arrowhead"]))}if(n.has("longdiv")&&(s("left",`calc(2 * ${o} + ${c} / 2)`),s("top",`calc(${o} + ${c})`),s("right",o),s("bottom",o),m.children.push(g("mrow",[],{"aria-hidden":"true",style:`position:absolute;inset:0;pointer-events:none;border-top:${c} solid currentColor;`},t.start)),m.children.push(g("mrow",[],{"aria-hidden":"true",style:`position:absolute;left:calc(-1 * ${o});top:0;bottom:0;width:calc(2 * ${o});border-right:${c} solid currentColor;border-radius:0 50% 50% 0;pointer-events:none;`},t.start))),n.has("phasorangle")){s("left",`calc(1.5 * ${o} + ${c})`),s("bottom",`calc(${o} / 2 + ${c})`),s("top",o),s("right",`calc(${o} / 2)`),m.children.push(g("mrow",[],{"aria-hidden":"true",style:`position:absolute;inset:0;border-bottom:${c} solid currentColor;pointer-events:none;`},t.start));let a=g("mrow",[],{style:`position:absolute;left:0;top:0;bottom:0;width:calc(1.75 * ${o});container-type:size;pointer-events:none;`},t.start);a.children.push(B(t,"up",c)),m.children.push(a)}return u.padding=["top","right","bottom","left"].map(a=>p[a]).join(" "),f(m,Object.entries(u).map(([a,b])=>`${a}:${b}`).join(";")),m}function O(t){if(t.kind!=="mrow")return!1;let n=t.children[1],i=n?.children[0];return t.kind==="mrow"&&t.children.length===2&&n?.kind==="mpadded"&&n.attributes.width==="0"&&n.attributes.lspace==="-.5width"&&i?.kind==="mpadded"&&i.attributes.width==="0"&&i.attributes.lspace==="-.5width"&&n.children[1]?.kind==="mphantom"}function E(t){let n=g("mrow",t.children[1].children[0].children,{style:"transform:translateX(-50%);"},t.start),i=g("mrow",[n],{style:"width:0;min-width:0;"},t.start),o=g("mrow",[t.children[0]],{},t.start);f(t,"display:inline-grid;grid-template-columns:max-content;align-items:baseline;"),t.attributes["data-flashmath-overlay"]="true";for(let c of[o,i])f(c,"grid-area:1 / 1;justify-self:center;");return t.children=[o,i],t}var y=(t,n,i)=>{let o=t===void 0?void 0:L(t);return o?.[Math.min(n,o.length-1)]??i};function W(t,n="right"){let i=t.children.some(l=>l.kind==="mlabeledtr"),o=t.attributes.semantics?.includes("bspr_inferenceRule:")??!1;if(!i&&!o&&!t.attributes.rowlines&&!t.attributes.columnlines&&!t.attributes.frame)return t;let c=(t.attributes.side??n)==="left"?"left":"right",m=Math.max(0,...t.children.map(l=>l.children.length-(l.kind==="mlabeledtr"?1:0)));for(let l=0;l<t.children.length;l++){let u=t.children[l],p=u.kind==="mlabeledtr"?u.children.shift():void 0;for(u.kind="mtr";u.children.length<m;)u.children.push(g("mtd",[],{},u.start));for(let s=0;s<u.children.length;s++){let r=u.children[s],d=r.attributes.columnalign??u.attributes.columnalign??y(t.attributes.columnalign,s,"center"),e=r.attributes.rowalign??u.attributes.rowalign??y(t.attributes.rowalign,l,"baseline");f(r,`text-align:${["left","right","center"].includes(d)?d:"center"};vertical-align:${["top","bottom","center"].includes(e)?e==="center"?"middle":e:"baseline"};`);let a=l?M(y(t.attributes.rowspacing,l-1,".5ex"),".5ex"):"0em",b=l<t.children.length-1?M(y(t.attributes.rowspacing,l,".5ex"),".5ex"):"0em",h=s?M(y(t.attributes.columnspacing,s-1,".8em"),".8em"):"0em",w=s<m-1?M(y(t.attributes.columnspacing,s,".8em"),".8em"):"0em";f(r,`padding:calc(${a} / 2) calc(${w} / 2) calc(${b} / 2) calc(${h} / 2);`);let x=y(t.attributes.rowlines,l-1,"none");l&&["solid","dashed"].includes(x)&&(f(r,`border-top:.067em ${x} currentColor;`),r.attributes["data-flashmath-rule"]=x);let $=y(t.attributes.columnlines,s-1,"none");s&&["solid","dashed"].includes($)&&f(r,`border-left:.067em ${$} currentColor;`),o&&(r.kind="mrow",r.children=[g("mrow",r.children,{},r.start)],f(r,`display:inline-grid;justify-items:center;grid-row:${l+1};grid-column:${s+1};`))}if(i){let s=g("mtd",[],{},u.start),r=p??g("mtd",[],{},u.start);p&&(r.attributes["data-flashmath-label"]=c),f(r,`text-align:${c};padding-${c==="right"?"left":"right"}:1em;`),u.children=c==="right"?[s,...u.children,r]:[r,...u.children,s];for(let d=0;d<u.children.length;d++){let e=u.children[d],a=d===0?"left":d===m+1?"right":e.attributes.columnalign??y(t.attributes.columnalign,d-1,"center");e.kind="mrow",e.attributes["data-flashmath-row"]=String(l+1),f(e,`grid-row:${l+1};grid-column:${d+1};justify-self:${a==="left"?"start":a==="right"?"end":"center"};`)}}}return t.attributes.frame&&["solid","dashed"].includes(t.attributes.frame)&&f(t,`border:.067em ${t.attributes.frame} currentColor;`),i?(t.kind="mrow",t.children=t.children.flatMap(l=>l.children),t.attributes["data-flashmath-tags"]=c,f(t,`display:inline-grid;width:100%;grid-template-columns:minmax(max-content,1fr) repeat(${m},max-content) minmax(max-content,1fr);align-items:baseline;`)):o?(t.kind="mrow",t.children=t.children.flatMap(l=>l.children),f(t,`display:inline-grid;grid-template-columns:repeat(${m},max-content);math-style:compact;`)):f(t,"display:inline-table;border-collapse:collapse;"),delete t.attributes.rowlines,delete t.attributes.columnlines,delete t.attributes.frame,t}function z(t){switch(t){case 58376:return"\u21CC";case 58384:return"\u2504";case 58408:return"\u27F5";case 58409:return"\u27F6";case 58410:return"\u27F7";case 58411:return"\u21C6";case 58412:return"\u2190";case 58413:return"\u2192";case 58414:return"\u2194";default:return""}}function J(t){return t===58377||t===58378||t>=58385&&t<=58387}function P(t){return t.kind==="mo"&&t.text.length===1&&v(t)==="glyph"?t.text.charCodeAt(0):0}function S(t){if(t.kind!=="mpadded"||v(t)!=="arrow-label"||t.children.at(-1)?.kind!=="mspace")return!1;let n=t.attributes,i=t.children.at(-1).attributes;return n.voffset==="-.2em"&&n.height==="-.2em"&&i.depth===".2em"||n.voffset===".15em"&&n.depth==="-.15em"&&i.height===".75em"}function G(t){let n=t.children[1];return(t.kind==="mover"||t.kind==="munder")&&n?.kind==="mo"&&n.text==="\u2015"&&n.attributes.accent==="true"}function I(t){let n=P(t),i=z(n),o={...t.attributes};if(delete o["data-mjx-variant"],i)return{...t,text:i,attributes:o,children:[]};let c=n===58377||n===58378,m=c?.692:n===58385?.238:.428,l={...t,kind:"mrow",text:"",attributes:{...o,"data-flashmath-chem":c?"harpoons":"bond","aria-label":c?"\u21CC":n===58385?"~-":n===58386?"~--":"-~-"},children:[]};delete l.attributes.stretchy,f(l,`display:inline-block;position:relative;${c?"min-width:1.463em;width:100%":"width:.828em"};height:${m}em;transform:translateY(${c?".098":n===58385?"-.131":"-.036"}em);`);let u=(p,s,r,d=!1)=>{let e={kind:"mrow",text:"",children:[],start:t.start,attributes:{"aria-hidden":"true","data-flashmath-chem-stroke":d?"dashed":"solid",style:`display:block;position:absolute;top:${p};left:${s};width:${r};height:.048em;border-radius:.024em;${d?"background:repeating-linear-gradient(to right,currentColor 0em,currentColor .198em,transparent .198em,transparent .258em)":"background-color:currentColor"}`}};return l.children.push(e),e};if(c){let p=n===58378,s=u(".226em",p?".282em":".056em",p?"calc(100% - .563em)":"calc(100% - .112em)"),r=u(".419em",p?".056em":".282em",p?"calc(100% - .112em)":"calc(100% - .563em)");for(let[d,e]of[[s,!0],[r,!1]])d.children.push({kind:"mrow",text:"",children:[],start:t.start,attributes:{"aria-hidden":"true","data-flashmath-chem-head":e?"right":"left",style:`display:block;position:absolute;${e?"right:0;bottom:0":"left:0;top:0"};width:.25em;height:.273em;background-color:currentColor;clip-path:polygon(${e?"100% 100%,0 0,28% 100%":"0 0,100% 100%,72% 0"})`}})}else{let p=n===58385?2:3;for(let s=0;s<p;s++)u(`${s*.19}em`,".057em",".714em",n===58387?s===1:s===0)}return c?(l.attributes.style="display:block;position:absolute;left:.2778em;right:.2778em;top:0;height:.692em;transform:translateY(.098em)",{kind:"mrow",text:"",start:t.start,attributes:{style:"display:inline-block;position:relative;min-width:2.019em;width:100%;height:.692em"},children:[l]}):l}function Z(t,n={}){let i=n.output===void 0?"native":n.output;if(i!=="native"&&i!=="mathjax")throw new TypeError("output must be native or mathjax");if(i==="mathjax")return t;let o=[t],c=!1;for(;o.length;){let r=o.pop(),d=r.attributes["data-mjx-variant"]??r.attributes.mathvariant;if(d&&(d!=="normal"&&(d!=="italic"||r.kind!=="mi"||!(r.text.length===1||r.text.length===2&&r.text.codePointAt(0)>65535))||r.kind==="mstyle")){c=!0;break}if(!r.children.length&&(r.kind==="mi"||r.kind==="mn"||r.kind==="mtext"||r.kind==="mo"&&!(r.text.length===1&&r.text.charCodeAt(0)>=58368&&r.text.charCodeAt(0)<=58414)))continue;let e=v(r),a=r.kind==="mo"&&r.text.length===1&&e==="glyph"?r.text.charCodeAt(0):0;if(z(a)||J(a)||e==="arrow-label"&&S(r)||e==="prescript"||e==="bbox-padding"||r.kind==="menclose"||r.kind==="mlabeledtr"||O(r)||G(r)||r.kind==="mtable"&&(r.attributes.rowlines||r.attributes.columnlines||r.attributes.frame||r.attributes.semantics?.includes("bspr_inferenceRule:"))){c=!0;break}for(let b of r.children)o.push(b)}if(!c)return t;let m=r=>S(r)?{...r,kind:"mrow",attributes:{},children:[]}:{...r,attributes:{...r.attributes},children:[]},l=m(t),u="tagSide"in n&&n.tagSide==="left"?"left":"right",p=!1,s=[{input:t,output:l,variant:"",done:!1}];for(;s.length;){let r=s.pop(),{input:d,output:e}=r,a=d.attributes["data-mjx-variant"]??d.attributes.mathvariant??r.variant;if(!r.done&&d.children.length){r.done=!0,s.push(r);let h=d.children,w=h.length-(S(d)?1:0);for(let x=0;x<w;x++){let $=h[x],k=$;if(v(k)==="prescript"&&h[x+3]){let A=X=>{let j=[$.children[X]];for(;j.length;){let N=j.pop();if(N){if(N.kind==="mphantom")return{kind:N.children.length?"mrow":"none",attributes:{},children:N.children,text:"",start:k.start};for(let D of N.children)j.push(D)}}return{kind:"none",attributes:{},children:[],text:"",start:k.start}};k={kind:"mmultiscripts",attributes:{},children:[h[x+3],{kind:"mprescripts",attributes:{},children:[],text:"",start:k.start},A(1),A(2)],text:"",start:k.start},x+=3}let q=m(k);e.children.push(q),s.push({input:k,output:q,variant:a,done:!1})}continue}let b=P(d);if(z(b)||J(b)){Object.assign(e,I(d));continue}if(a){let h=F(a);if(["mi","mn","mo","mtext"].includes(e.kind)){let w=e.kind==="mtext"?e.text:R(e.text,a);delete e.attributes["data-mjx-variant"],e.kind==="mi"?e.attributes.mathvariant="normal":delete e.attributes.mathvariant,h!=="normal"&&w===e.text&&!["script","bold-script"].includes(h)&&(h.includes("bold")&&f(e,"font-weight:bold;"),(h.includes("italic")||h.includes("script"))&&f(e,"font-style:italic;"),h.includes("sans-serif")&&f(e,"font-family:sans-serif;"),h==="monospace"&&f(e,"font-family:monospace;")),a==="-tex-calligraphic"||a==="-tex-bold-calligraphic"?f(e,`font-family:'Flashmath Calligraphic',math;font-style:normal;font-weight:${a.includes("bold")?"bold":"normal"};`):(h==="script"||h==="bold-script")&&f(e,`font-family:'Flashmath Script',math;font-style:normal;font-weight:${h.includes("bold")?"bold":"normal"};`),e.text=w}else delete e.attributes.mathvariant}if(e.attributes.semantics?.includes("bspr_prooflabel:")){let h=e.attributes.semantics.includes("bspr_prooflabel:right");e.kind="mrow";for(let w of["width","height","depth","voffset","lspace"])delete e.attributes[w];f(e,`display:inline-flex;align-items:baseline;padding-${h?"left":"right"}:.5ex;transform:translateY(.25em);`)}if(v(d)==="bbox-padding")_(e);else if(e.kind==="menclose")Object.assign(e,C(e));else if(O(e))E(e);else if(e.kind==="mtable"){let h=e.children.some(w=>w.kind==="mlabeledtr");W(e,u),p||=h}if(G(e)){let h=e.kind==="munder";Object.assign(e,C({...e,attributes:{...e.attributes,notation:h?"bottom":"top","data-padding":".1em","data-thickness":".04em"},children:[e.children[0]]})),e.attributes["data-flashmath-accent"]=h?"underline":"overline"}}return p&&l.kind==="math"&&l.attributes.display==="block"&&f(l,"width:100%;display:block;"),l}export{Z as a};
1
+ import{a as q,b as F}from"./chunk-TXV67IQS.js";import{b as M,d as H}from"./chunk-CBRBGK2B.js";H();function g(t,n=[],i={},o=0){return i.style?.endsWith(";")&&(i.style=i.style.slice(0,-1)),{kind:t,children:n,attributes:i,text:"",start:o}}function L(t){let n=[],i=-1;for(let o=0;o<=t.length;o++){let c=t.charCodeAt(o);o===t.length||c<=32||c===160?i>=0&&(n.push(t.slice(i,o)),i=-1):i<0&&(i=o)}return n}function f(t,n){let i=t.attributes.style??"",o=i+(i&&!i.endsWith(";")?";":"")+n;t.attributes.style=o.endsWith(";")?o.slice(0,-1):o}function _(t){let n=v(t.attributes.lspace,"0em");t.kind="mrow";for(let i of["width","height","depth","lspace","voffset"])delete t.attributes[i];return t.attributes["data-flashmath-bbox"]="true",f(t,`padding:${n};`),t}function v(t,n){if(!t)return n;let i=t.trim(),o=i[0]==="+"?1:0,c=0,m=0;for(;o<i.length;o++){let u=i.charCodeAt(o);if(u>=48&&u<=57)m++;else{if(u===46&&c++===0)continue;break}}let l=i.slice(o);return!m||!["","em","ex","px","pt","pc","in","cm","mm","mu","%"].includes(l)?n:l==="mu"?`${Number(i.slice(0,o))/18}em`:i.slice(0,o)+(l||"em")}function B(t,n,i,o=0,c="4 2 1"){let m=n==="up"||n==="down",p=g("mrow",[],{"data-flashmath-line":n,style:`position:absolute;left:50%;top:50%;width:${m?"hypot(100cqw,100cqh)":n==="vertical"?"100cqh":"100cqw"};height:${i};background-color:currentColor;transform:translate(-50%,-50%) rotate(${m?`calc(${n==="up"?"-1":"1"} * atan2(100cqh,100cqw))`:n==="vertical"?"90deg":"0deg"});`},t.start),s=L(c).map(Number),r=Number.isFinite(s[0])&&s[0]>0?s[0]:4,d=Number.isFinite(s[1])&&s[1]>0?s[1]:2,e=Number.isFinite(s[2])&&s[2]>=0?s[2]:1;for(let a of[1,2])o&a&&p.children.push(g("mrow",[],{style:`position:absolute;${a===1?"right":"left"}:0;top:50%;width:calc(${r+e} * ${i});height:calc(${2*d} * ${i});background-color:currentColor;clip-path:polygon(0 0,100% 50%,0 100%,${100*e/(r+e)}% 50%);transform:translateY(-50%)${a===2?" rotate(180deg)":""};`},t.start));return g("mrow",[p],{"aria-hidden":"true",style:"position:absolute;inset:0;container-type:size;pointer-events:none;"},t.start)}var T={uparrow:["vertical",2],downarrow:["vertical",1],leftarrow:["horizontal",2],rightarrow:["horizontal",1],updownarrow:["vertical",3],leftrightarrow:["horizontal",3],updiagonalarrow:["up",1],northeastarrow:["up",1],southwestarrow:["up",2],southeastarrow:["down",1],northwestarrow:["down",2],northeastsouthwestarrow:["up",3],northwestsoutheastarrow:["down",3]},Y={top:["top"],right:["right"],bottom:["bottom"],left:["left"],actuarial:["top","right"],madruwb:["bottom","right"],box:["top","right","bottom","left"],roundedbox:["top","right","bottom","left"],circle:["top","right","bottom","left"]};function C(t){let n=new Set(L(t.attributes.notation??"longdiv")),i={...t.attributes};delete i.notation;let o=v(i["data-padding"],".2em"),c=v(i["data-thickness"],".067em"),m={...t,kind:"mrow",attributes:i,children:[...t.children]};m.attributes["data-flashmath-enclose"]=[...n].join(" "),i.color&&!i.mathcolor&&(i.mathcolor=i.color),i.background&&!i.mathbackground&&(i.mathbackground=i.background);let l=g("mrow",m.children,{},t.start);n.has("radical")&&(l=g("msqrt",[l],{},t.start)),m.children=[l];let u={position:"relative"},p={top:"0em",right:"0em",bottom:"0em",left:"0em"},s=(a,b)=>{p[a]=p[a]==="0em"||p[a]===b?b:`max(${p[a]},${b})`},r=new Set,d=new Set;for(let a of n)for(let b of Object.hasOwn(Y,a)?Y[a]:[])r.add(b),a!=="circle"&&a!=="roundedbox"&&d.add(b);if(r.size){for(let[a,b]of[["straight",d],["roundedbox",n.has("roundedbox")?r:[]],["circle",n.has("circle")?r:[]]]){let h=[...b].map(w=>`border-${w}:${c} solid currentColor;`).join("");h&&m.children.push(g("mrow",[],{"aria-hidden":"true",style:"position:absolute;inset:0;pointer-events:none;"+h+(a==="circle"?"border-radius:50%;":a==="roundedbox"?`border-radius:calc(${o} + ${c});`:"")},t.start))}for(let a of r)s(a,`calc(${o} + ${c})`)}let e=new Map;for(let a of n)if(Object.hasOwn(T,a)){let[b,h]=T[a];e.set(b,(e.get(b)??0)|h)}else a==="updiagonalstrike"?e.set("up",e.get("up")??0):a==="downdiagonalstrike"?e.set("down",e.get("down")??0):a==="horizontalstrike"?e.set("horizontal",e.get("horizontal")??0):a==="verticalstrike"&&e.set("vertical",e.get("vertical")??0);for(let[a,b]of e){if(a==="up"||a==="down")for(let h of Object.keys(p))s(h,`calc(${o} + ${c})`);else{let[h,w]=a==="horizontal"?["left","right"]:["top","bottom"],[x=4,,$=1]=L(i["data-arrowhead"]??"4 2 1").map(Number),k=Number.isFinite(x+$)&&x>0&&$>=0?x+$+1:6;s(h,b&2?`max(${o},calc(${k} * ${c}))`:o),s(w,b&1?`max(${o},calc(${k} * ${c}))`:o)}m.children.push(B(t,a,c,b,i["data-arrowhead"]))}if(n.has("longdiv")&&(s("left",`calc(2 * ${o} + ${c} / 2)`),s("top",`calc(${o} + ${c})`),s("right",o),s("bottom",o),m.children.push(g("mrow",[],{"aria-hidden":"true",style:`position:absolute;inset:0;pointer-events:none;border-top:${c} solid currentColor;`},t.start)),m.children.push(g("mrow",[],{"aria-hidden":"true",style:`position:absolute;left:calc(-1 * ${o});top:0;bottom:0;width:calc(2 * ${o});border-right:${c} solid currentColor;border-radius:0 50% 50% 0;pointer-events:none;`},t.start))),n.has("phasorangle")){s("left",`calc(1.5 * ${o} + ${c})`),s("bottom",`calc(${o} / 2 + ${c})`),s("top",o),s("right",`calc(${o} / 2)`),m.children.push(g("mrow",[],{"aria-hidden":"true",style:`position:absolute;inset:0;border-bottom:${c} solid currentColor;pointer-events:none;`},t.start));let a=g("mrow",[],{style:`position:absolute;left:0;top:0;bottom:0;width:calc(1.75 * ${o});container-type:size;pointer-events:none;`},t.start);a.children.push(B(t,"up",c)),m.children.push(a)}return u.padding=["top","right","bottom","left"].map(a=>p[a]).join(" "),f(m,Object.entries(u).map(([a,b])=>`${a}:${b}`).join(";")),m}function O(t){if(t.kind!=="mrow")return!1;let n=t.children[1],i=n?.children[0];return t.kind==="mrow"&&t.children.length===2&&n?.kind==="mpadded"&&n.attributes.width==="0"&&n.attributes.lspace==="-.5width"&&i?.kind==="mpadded"&&i.attributes.width==="0"&&i.attributes.lspace==="-.5width"&&n.children[1]?.kind==="mphantom"}function E(t){let n=g("mrow",t.children[1].children[0].children,{style:"transform:translateX(-50%);"},t.start),i=g("mrow",[n],{style:"width:0;min-width:0;"},t.start),o=g("mrow",[t.children[0]],{},t.start);f(t,"display:inline-grid;grid-template-columns:max-content;align-items:baseline;"),t.attributes["data-flashmath-overlay"]="true";for(let c of[o,i])f(c,"grid-area:1 / 1;justify-self:center;");return t.children=[o,i],t}var y=(t,n,i)=>{let o=t===void 0?void 0:L(t);return o?.[Math.min(n,o.length-1)]??i};function W(t,n="right"){let i=t.children.some(l=>l.kind==="mlabeledtr"),o=t.attributes.semantics?.includes("bspr_inferenceRule:")??!1;if(!i&&!o&&!t.attributes.rowlines&&!t.attributes.columnlines&&!t.attributes.frame)return t;let c=(t.attributes.side??n)==="left"?"left":"right",m=Math.max(0,...t.children.map(l=>l.children.length-(l.kind==="mlabeledtr"?1:0)));for(let l=0;l<t.children.length;l++){let u=t.children[l],p=u.kind==="mlabeledtr"?u.children.shift():void 0;for(u.kind="mtr";u.children.length<m;)u.children.push(g("mtd",[],{},u.start));for(let s=0;s<u.children.length;s++){let r=u.children[s],d=r.attributes.columnalign??u.attributes.columnalign??y(t.attributes.columnalign,s,"center"),e=r.attributes.rowalign??u.attributes.rowalign??y(t.attributes.rowalign,l,"baseline");f(r,`text-align:${["left","right","center"].includes(d)?d:"center"};vertical-align:${["top","bottom","center"].includes(e)?e==="center"?"middle":e:"baseline"};`);let a=l?v(y(t.attributes.rowspacing,l-1,".5ex"),".5ex"):"0em",b=l<t.children.length-1?v(y(t.attributes.rowspacing,l,".5ex"),".5ex"):"0em",h=s?v(y(t.attributes.columnspacing,s-1,".8em"),".8em"):"0em",w=s<m-1?v(y(t.attributes.columnspacing,s,".8em"),".8em"):"0em";f(r,`padding:calc(${a} / 2) calc(${w} / 2) calc(${b} / 2) calc(${h} / 2);`);let x=y(t.attributes.rowlines,l-1,"none");l&&["solid","dashed"].includes(x)&&(f(r,`border-top:.067em ${x} currentColor;`),r.attributes["data-flashmath-rule"]=x);let $=y(t.attributes.columnlines,s-1,"none");s&&["solid","dashed"].includes($)&&f(r,`border-left:.067em ${$} currentColor;`),o&&(r.kind="mrow",r.children=[g("mrow",r.children,{},r.start)],f(r,`display:inline-grid;justify-items:center;grid-row:${l+1};grid-column:${s+1};`))}if(i){let s=g("mtd",[],{},u.start),r=p??g("mtd",[],{},u.start);p&&(r.attributes["data-flashmath-label"]=c),f(r,`text-align:${c};padding-${c==="right"?"left":"right"}:1em;`),u.children=c==="right"?[s,...u.children,r]:[r,...u.children,s];for(let d=0;d<u.children.length;d++){let e=u.children[d],a=d===0?"left":d===m+1?"right":e.attributes.columnalign??y(t.attributes.columnalign,d-1,"center");e.kind="mrow",e.attributes["data-flashmath-row"]=String(l+1),f(e,`grid-row:${l+1};grid-column:${d+1};justify-self:${a==="left"?"start":a==="right"?"end":"center"};`)}}}return t.attributes.frame&&["solid","dashed"].includes(t.attributes.frame)&&f(t,`border:.067em ${t.attributes.frame} currentColor;`),i?(t.kind="mrow",t.children=t.children.flatMap(l=>l.children),t.attributes["data-flashmath-tags"]=c,f(t,`display:inline-grid;width:100%;grid-template-columns:minmax(max-content,1fr) repeat(${m},max-content) minmax(max-content,1fr);align-items:baseline;`)):o?(t.kind="mrow",t.children=t.children.flatMap(l=>l.children),f(t,`display:inline-grid;grid-template-columns:repeat(${m},max-content);math-style:compact;`)):f(t,"display:inline-table;border-collapse:collapse;"),delete t.attributes.rowlines,delete t.attributes.columnlines,delete t.attributes.frame,t}function z(t){switch(t){case 58376:return"\u21CC";case 58384:return"\u2504";case 58408:return"\u27F5";case 58409:return"\u27F6";case 58410:return"\u27F7";case 58411:return"\u21C6";case 58412:return"\u2190";case 58413:return"\u2192";case 58414:return"\u2194";default:return""}}function J(t){return t===58377||t===58378||t>=58385&&t<=58387}function P(t){return t.kind==="mo"&&t.text.length===1&&M(t)==="glyph"?t.text.charCodeAt(0):0}function S(t){let n=M(t);if(t.kind!=="mpadded"||n!=="arrow-label"&&n!=="xarrow-label"||t.children.at(-1)?.kind!=="mspace"||n==="xarrow-label"&&t.children.length===1)return!1;let i=t.attributes,o=t.children.at(-1).attributes;return i.voffset==="-.2em"&&i.height==="-.2em"&&o.depth===".2em"||i.voffset===".15em"&&i.depth==="-.15em"&&o.height===".75em"}function G(t){let n=t.children[1];return(t.kind==="mover"||t.kind==="munder")&&n?.kind==="mo"&&n.text==="\u2015"&&n.attributes.accent==="true"}var I={"\u27F6":"\u2192","\u27F5":"\u2190","\u27F9":"\u21D2","\u27F8":"\u21D0"};function K(t){let n=P(t),i=z(n),o={...t.attributes};if(delete o["data-mjx-variant"],i)return{...t,text:i,attributes:o,children:[]};let c=n===58377||n===58378,m=c?.692:n===58385?.238:.428,l={...t,kind:"mrow",text:"",attributes:{...o,"data-flashmath-chem":c?"harpoons":"bond","aria-label":c?"\u21CC":n===58385?"~-":n===58386?"~--":"-~-"},children:[]};delete l.attributes.stretchy,f(l,`display:inline-block;position:relative;${c?"min-width:1.463em;width:100%":"width:.828em"};height:${m}em;transform:translateY(${c?".098":n===58385?"-.131":"-.036"}em);`);let u=(p,s,r,d=!1)=>{let e={kind:"mrow",text:"",children:[],start:t.start,attributes:{"aria-hidden":"true","data-flashmath-chem-stroke":d?"dashed":"solid",style:`display:block;position:absolute;top:${p};left:${s};width:${r};height:.048em;border-radius:.024em;${d?"background:repeating-linear-gradient(to right,currentColor 0em,currentColor .198em,transparent .198em,transparent .258em)":"background-color:currentColor"}`}};return l.children.push(e),e};if(c){let p=n===58378,s=u(".226em",p?".282em":".056em",p?"calc(100% - .563em)":"calc(100% - .112em)"),r=u(".419em",p?".056em":".282em",p?"calc(100% - .112em)":"calc(100% - .563em)");for(let[d,e]of[[s,!0],[r,!1]])d.children.push({kind:"mrow",text:"",children:[],start:t.start,attributes:{"aria-hidden":"true","data-flashmath-chem-head":e?"right":"left",style:`display:block;position:absolute;${e?"right:0;bottom:0":"left:0;top:0"};width:.25em;height:.273em;background-color:currentColor;clip-path:polygon(${e?"100% 100%,0 0,28% 100%":"0 0,100% 100%,72% 0"})`}})}else{let p=n===58385?2:3;for(let s=0;s<p;s++)u(`${s*.19}em`,".057em",".714em",n===58387?s===1:s===0)}return c?(l.attributes.style="display:block;position:absolute;left:.2778em;right:.2778em;top:0;height:.692em;transform:translateY(.098em)",{kind:"mrow",text:"",start:t.start,attributes:{style:"display:inline-block;position:relative;min-width:2.019em;width:100%;height:.692em"},children:[l]}):l}function tt(t,n={}){let i=n.output===void 0?"native":n.output;if(i!=="native"&&i!=="mathjax")throw new TypeError("output must be native or mathjax");if(i==="mathjax")return t;let o=[t],c=!1;for(;o.length;){let r=o.pop(),d=r.attributes["data-mjx-variant"]??r.attributes.mathvariant;if(d&&(d!=="normal"&&(d!=="italic"||r.kind!=="mi"||!(r.text.length===1||r.text.length===2&&r.text.codePointAt(0)>65535))||r.kind==="mstyle")){c=!0;break}if(!r.children.length&&(r.kind==="mi"||r.kind==="mn"||r.kind==="mtext"||r.kind==="mo"&&!(r.text.length===1&&r.text.charCodeAt(0)>=58368&&r.text.charCodeAt(0)<=58414)))continue;let e=M(r),a=r.kind==="mo"&&r.text.length===1&&e==="glyph"?r.text.charCodeAt(0):0;if(z(a)||J(a)||(e==="arrow-label"||e==="xarrow-label")&&S(r)||e==="prescript"||e==="bbox-padding"||r.kind==="menclose"||r.kind==="mlabeledtr"||O(r)||G(r)||r.kind==="mtable"&&(r.attributes.rowlines||r.attributes.columnlines||r.attributes.frame||r.attributes.semantics?.includes("bspr_inferenceRule:"))){c=!0;break}for(let b of r.children)o.push(b)}if(!c)return t;let m=r=>S(r)?{...r,kind:"mrow",attributes:r.children.length===1?{}:{"data-flashmath-arrow-label":"true",style:`padding-inline:${r.attributes.lspace??"0em"} calc(${r.attributes.width.slice(1)} - ${r.attributes.lspace??"0em"})`},children:[]}:{...r,attributes:{...r.attributes},children:[]},l=m(t),u="tagSide"in n&&n.tagSide==="left"?"left":"right",p=!1,s=[{input:t,output:l,variant:"",done:!1}];for(;s.length;){let r=s.pop(),{input:d,output:e}=r,a=d.attributes["data-mjx-variant"]??d.attributes.mathvariant??r.variant;if(!r.done&&d.children.length){r.done=!0,s.push(r);let h=d.children,w=h.length-(S(d)?1:0);for(let x=0;x<w;x++){let $=h[x],k=$;if(M(k)==="prescript"&&h[x+3]){let R=X=>{let j=[$.children[X]];for(;j.length;){let N=j.pop();if(N){if(N.kind==="mphantom")return{kind:N.children.length?"mrow":"none",attributes:{},children:N.children,text:"",start:k.start};for(let D of N.children)j.push(D)}}return{kind:"none",attributes:{},children:[],text:"",start:k.start}};k={kind:"mmultiscripts",attributes:{},children:[h[x+3],{kind:"mprescripts",attributes:{},children:[],text:"",start:k.start},R(1),R(2)],text:"",start:k.start},x+=3}let A=m(k);e.children.push(A),s.push({input:k,output:A,variant:a,done:!1})}continue}let b=P(d);if(z(b)||J(b)){Object.assign(e,K(d));continue}if(M(d)==="glyph"&&(e.text=I[e.text]??e.text),a){let h=q(a);if(["mi","mn","mo","mtext"].includes(e.kind)){let w=e.kind==="mtext"?e.text:F(e.text,a);delete e.attributes["data-mjx-variant"],e.kind==="mi"?e.attributes.mathvariant="normal":delete e.attributes.mathvariant,h!=="normal"&&w===e.text&&!["script","bold-script"].includes(h)&&(h.includes("bold")&&f(e,"font-weight:bold;"),(h.includes("italic")||h.includes("script"))&&f(e,"font-style:italic;"),h.includes("sans-serif")&&f(e,"font-family:sans-serif;"),h==="monospace"&&f(e,"font-family:monospace;")),a==="-tex-calligraphic"||a==="-tex-bold-calligraphic"?f(e,`font-family:'Flashmath Calligraphic',math;font-style:normal;font-weight:${a.includes("bold")?"bold":"normal"};`):(h==="script"||h==="bold-script")&&f(e,`font-family:'Flashmath Script',math;font-style:normal;font-weight:${h.includes("bold")?"bold":"normal"};`),e.text=w}else delete e.attributes.mathvariant}if(e.attributes.semantics?.includes("bspr_prooflabel:")){let h=e.attributes.semantics.includes("bspr_prooflabel:right");e.kind="mrow";for(let w of["width","height","depth","voffset","lspace"])delete e.attributes[w];f(e,`display:inline-flex;align-items:baseline;padding-${h?"left":"right"}:.5ex;transform:translateY(.25em);`)}if(M(d)==="bbox-padding")_(e);else if(e.kind==="menclose")Object.assign(e,C(e));else if(O(e))E(e);else if(e.kind==="mtable"){let h=e.children.some(w=>w.kind==="mlabeledtr");W(e,u),p||=h}if(G(e)){let h=e.kind==="munder";Object.assign(e,C({...e,attributes:{...e.attributes,notation:h?"bottom":"top","data-padding":".1em","data-thickness":".04em"},children:[e.children[0]]})),e.attributes["data-flashmath-accent"]=h?"underline":"overline"}}return p&&l.kind==="math"&&l.attributes.display==="block"&&f(l,"width:100%;display:block;"),l}export{tt as a};
@@ -0,0 +1 @@
1
+ import{a as c}from"./chunk-WZSFAGJH.js";function k(a,t){return e.set(a,t),a}function g(a,t){let r=e.get(a);r&&e.set(t,r)}var e,p,o=c(()=>{"use strict";e=new WeakMap;p=a=>e.get(a)});export{k as a,p as b,g as c,o as d};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-2BLNXHV2.js";import{A as P,B as Q,C as q,D as re,E as j,F as z,G as ae,M as $,N as V,O as oe,a as M,b as U,d as _,e as L,f as T,g as W,h as se,i as S,j as N,k as x,l as g,m as C,n as w,o as G,p as A,q as K,r as R,s as ne,t as H,u as E,v as B,w as J,x as X,y as I,z as Y}from"./chunk-X6BR56FI.js";ne();_();K();_();K();function Z(b,e,t){let n=0,i=new A(x(b),e),s=[],r=()=>{i.skip();let d=i.next();if(!d)return"";if(d[0]!==123)return w([d]);let m=[],k=1;for(;k;){let u=i.next();if(!u)throw Error("Missing array preamble brace");u[0]===123&&k++,u[0]===125&&k--,k&&m.push(u)}return w(m)},a=[],o="",l="",c="",h="1em",f="",p=(d,m="auto",k=null,u="1em",y="")=>{if(s.length>=e)throw Error("Array column limit exceeded");s.push({align:d,width:m,before:a,after:[],insert:k,separator:o,gap:u,vertical:y}),a=[],o=""};for(;i.peek();){i.skip();let d=i.next();if(!d)break;let m=w([d]);if(m==="*"){let u=Number(r());if(!Number.isSafeInteger(u)||u<0||u>e)throw Error("Invalid array repeat");let y=r();if(y.length*u>e)throw Error("Array preamble limit exceeded");i.push(x(y.repeat(u)));continue}let k=t.get(m);if(k){if(++n>e)throw Error("Array preamble limit exceeded");let u=k.body;for(let y=1;y<=k.count;y++)u=u.replaceAll("#"+y,r());i.push(x(u));continue}if(m==="|"||m===":"){o?(s.length&&s.at(-1).after.push(...x("\\hspace{.5em}")),p("center","auto",x("\\,"),"0"),o=m,a.push(...x("\\hspace{.5em}")),h="0"):(o=m,s.length||(l=m));continue}if(m===">"){a.unshift(...x(r()));continue}if(m==="<"){s.length?s.at(-1).after.unshift(...x(r())):r();continue}if(m==="@"||m==="!"){let u=x(r()),y=m==="@"?"0":".5em";s.length===0&&(f=(m==="@"?"0":".5em")+" .5em"),p("center","auto",u,y),c=m,h=y;continue}if(m==="w"||m==="W"){let u=r(),y=r();p({l:"left",r:"right",c:"center"}[u]??"center",y,null,"1em","top");continue}if(m==="p"||m==="m"||m==="b"){p("left",r(),null,"1em",m==="p"?"top":m==="m"?"middle":"bottom");continue}if(m==="l"||m==="c"||m==="r"){p({l:"left",c:"center",r:"right"}[m]);continue}if(!(m==="{"||m==="}"))throw new M(`Illegal pream-token (${m})`,d[1])}c&&s.at(-1)?.insert&&(f=(f?f.split(" ")[0]:".5em")+" "+(c==="@"?"0":".5em"));for(let d=1;d<s.length;d++)s[d].separator&&s[d-1].insert!==null&&s[d].insert!==null&&(s[d-1].gap!=="0"&&(s[d-1].insert.push(...x("\\hspace{.25em}")),s[d-1].gap="0"),s[d].gap!=="0"&&s[d].insert.unshift(...x("\\hspace{.25em}")));return s.length||p("center"),{columns:s,left:l,right:o,padding:f,spacing:h}}se();oe();function O(){return{packageData:new Map,macros:new Map,environments:new Map,labels:new Map,counter:0,initialized:!1}}ae();re();var te="http://www.w3.org/1998/Math/MathML",v=b=>b>=48&&b<=57,ee=(b,e)=>!!b&&b[0]===e[0]&&g(b)===g(e),F=class b{constructor(e,t,n=V(t.packages),i=O()){this.tex=e;this.options=t;this.configuration=n;this.session=i;if(this.macros=i.macros,this.environments=i.environments,this.numbered=t.tags==="all"&&!!t.display,this.stream=new A(x(e,t.maxTokens??2e5),t.maxTokens??2e5),!i.initialized)for(let[s,r]of Object.entries(t.macros??{}))this.macros.set(s,R(r));i.initialized=!0,this.frame(0,!1,s=>{this.result=s});for(let s of n.initializers)s(this)}tex;options;configuration;session;get characters(){return this.configuration.characterHandlers}stream;macros;environments;localLabels=new Map;frames=[];nodes=0;expansions=0;position=0;columns=new Map;label="";numbered=!1;hasTaggableEnvironment=!1;envStack=[];hsize="";inline=!1;nonscript=!1;pendingBreak="";result=[];currentCommand="";error(e){throw new M(e,this.position)}node(e,t=[],n="",i={},s=this.position){++this.nodes>(this.options.maxNodes??1e5)&&this.error("Node limit exceeded");let r={kind:e,attributes:i,children:t,text:n,start:s,op:0,limits:0,relation:e===3&&H.has(n),fixed:!1,rawAttrs:!1};return(e===1||e===3||e===2||e===4)&&this.f?.tokenTransform?.(r),r}row(e,t=!1){if(!t&&e.length===1)return e[0];let n=this.node(6,e);return n.inferred=!t,n}atom(e,t="ORD"){return this.node(6,e,"",{"data-mjx-texclass":t})}fixInitialMO(e){let t=e.find(n=>(n.kind!==5||n.styledSpace)&&!(n.kind===6&&n.attributes["data-mjx-texclass"]&&!n.children.length));for(;t;){if(t.kind===3||t.attributes["data-mjx-texclass"]==="REL"){e.unshift(this.node(1));return}if([10,11,12,13,14,15].includes(t.kind)){t=t.children[0];continue}if([16,18,19,6].includes(t.kind)){let n=t.children.filter(i=>i.kind!==5&&i.kind!==4);if(n.length===1){t=n[0];continue}}return}}get f(){return this.frames[this.frames.length-1]}frame(e,t,n,i="",s=null){this.frames.length>=(this.options.maxDepth??1024)&&this.error("Nesting limit exceeded");let r=this.f;this.frames.push({tokenTransform:r?.tokenTransform,nodes:[],stop:e,single:t,done:n,font:r?.font??"",multi:r?.multi??!1,level:r?.level??0,display:r?.display??this.options.display??!1,env:i,table:s,fraction:null})}append(e){if(this.pendingBreak){let t=this.pendingBreak;this.pendingBreak="",e.kind===3&&P(e.text)?.[3]?.linebreakstyle!=="after"?e.attributes.linebreak=t:this.f.nodes.push(this.node(5,[],"",t==="auto"?{}:{linebreak:t}))}this.nonscript&&(this.nonscript=!1,this.f.level>0&&(e.kind===5||e.kind===16&&e.children[0]?.kind===5))||(this.f.table?.bottom&&(this.f.table.bottom=""),this.f.nodes.push(e))}close(){let e=this.f;if(this.pendingBreak){let n=this.pendingBreak;this.pendingBreak="",e.nodes.push(this.node(5,[],"",n==="auto"?{}:{linebreak:n}))}let t=e.nodes;if(e.fraction){let n=e.fraction,i=this.node(7,[this.row(n.num),this.row(t)],"",n.attrs);if(n.left||n.right){let s=this.f.level===0?"2.047em":"1.2em";i=this.atom([this.atom([this.delimiterNode(n.left,s)],"OPEN"),i,this.atom([this.delimiterNode(n.right,s)],"CLOSE")])}t=[i]}this.frames.pop(),e.done(t)}argument(e,t=!1,n=""){this.stream.skip();let i=this.stream.peek();(!i||i[0]===0)&&this.error(`Missing argument for ${n||this.currentCommand}`),i[0]===125&&this.error(this.f.env==="argument"?`Missing argument for ${n||this.currentCommand}`:"Extra close brace or missing open brace"),i[0]===123?(this.stream.next(),this.frame(125,!1,s=>e(t?this.atom(s):this.row(s))),this.f.env="argument"):this.frame(0,!0,s=>e(this.row(s))),this.f.argumentScope=!0}args(e,t,n=""){let i=[],s=this.currentCommand,r=()=>{this.currentCommand=s,i.length===e?t(i):this.argument(a=>{i.push(a),r()},!1,n)};r()}tokensArgument(e=this.currentCommand){let t=this.argumentSpan(e);return t.tokens.slice(t.start,t.end)}argumentSpan(e=this.currentCommand){this.stream.skip();let t=this.stream.next();if((!t||t[0]===0)&&this.error(`Missing argument for ${e}`),t[0]===125&&this.error("Extra close brace or missing open brace"),t[0]!==123)return{tokens:[t],start:0,end:1};let n=this.stream.takeGroup();if(n)return n;let i=[],s=1;for(;s;){let r=this.stream.next();r||this.error("Missing close brace"),r[0]===123&&s++,r[0]===125&&s--,s&&i.push(r)}return{tokens:i,start:0,end:i.length}}optional(){if(this.stream.skip(),this.stream.peek()?.[0]!==91)return null;this.stream.next();let e=[],t=0;for(;;){let n=this.stream.next();if(n||this.error(`Could not find closing ']' for argument to ${this.currentCommand}`),n[0]===93&&t===0)return e;n[0]===123&&t++,n[0]===125&&--t<0&&this.error("Extra close brace while looking for ']'"),e.push(n)}}parseTokens(e,t){this.parseSpan({tokens:e,start:0,end:e.length},t)}parseSpan(e,t){this.stream.push([[0,0,0,""]]),this.stream.pushSpan(e),this.frame(-2,!1,n=>t(this.row(n))),this.f.argumentScope=!0}substitute(e,t){let n=[];for(let i=0;i<e.body.length;i++){let s=e.body[i];if(s[0]!==35){n.push(s);continue}let r=e.body[++i];if(r?.[0]===35)n.push(r);else{let a=r?r[0]-49:-1;(a<0||a>=t.length)&&this.error("Illegal macro parameter reference");for(let o of t[a])n.length>=(this.options.maxTokens??2e5)&&this.error("Token limit exceeded"),n.push(o)}n.length>(this.options.maxTokens??2e5)&&this.error("Token limit exceeded")}return n}expand(e){++this.expansions>(this.options.maxExpansions??1e4)&&this.error("Macro expansion limit exceeded"),this.stream.skip();for(let s of e.prefix)ee(this.stream.next(),s)||this.error("Use of macro doesn't match its definition");let t=[];if(e.optional){let s=this.optional()??e.optional;t.push({tokens:s,start:0,end:s.length})}for(let s=t.length;s<e.count;s++){let r=e.delimiters[s]??[];if(!r.length){t.push(this.argumentSpan());continue}let a=[],o=0;for(;;){let l=this.stream.next();if(l||this.error("Missing macro argument delimiter"),a.push(l),l[0]===123&&o++,l[0]===125&&o--,o===0&&a.length>=r.length&&r.every((c,h)=>ee(a[a.length-r.length+h],c))){a.length-=r.length;break}}if(a[0]?.[0]===123&&a.at(-1)?.[0]===125){let l=0,c=!0;for(let h=0;h<a.length-1;h++)a[h][0]===123&&l++,a[h][0]===125&&l--,l===0&&(c=!1);c&&(a.shift(),a.pop())}t.push({tokens:a,start:0,end:a.length})}let n=[],i=0;for(let s=0;s<e.body.length;s++){if(e.body[s][0]!==35)continue;i<s&&n.push({tokens:e.body,start:i,end:s});let r=e.body[++s];if(r?.[0]===35)n.push({tokens:e.body,start:s,end:s+1});else{let a=r?r[0]-49:-1;(a<0||a>=t.length)&&this.error("Illegal macro parameter reference"),n.push(t[a])}i=s+1}i<e.body.length&&n.push({tokens:e.body,start:i,end:e.body.length});for(let s=n.length-1;s>=0;s--)this.stream.pushSpan(n[s])}delimiter(){this.stream.skip();let e=this.stream.next();e?.[0]===123&&(e=this.stream.next(),this.stream.next()?.[0]!==125&&this.error("Missing close brace")),e||this.error(`Missing or unrecognized delimiter for ${this.currentCommand}`);for(let n=0;n<30&&!(e[0]!==-1&&e[0]!==-3);n++){let i=e[0]===-1?this.macros.get(g(e)):void 0;if(i?.body.length===1){e=i.body[0];continue}let s=q(e),r=(s<0?this.configuration.extensions.get(g(e)):this.configuration.commands[s])?.definition;if(r?.char&&(r.type==="delimiter"||E.has(r.char)||"<>".includes(r.char)))return r.char==="<"?"\u27E8":r.char===">"?"\u27E9":r.char;this.error(`Missing or unrecognized delimiter for ${this.currentCommand}`)}let t=g(e);return t==="."?"":t==="<"?"\u27E8":t===">"?"\u27E9":(E.has(t)||this.error(`Missing or unrecognized delimiter for ${this.currentCommand}`),t)}delimiterNode(e,t="",n=""){let i=n?{"data-mjx-texclass":n}:{};return e?!B.has(e)&&e!=="<"&&e!==">"&&Object.assign(i,{fence:"true",symmetric:"true",...["\u23D0","\u23EA","\u23AA","/","\\","\u231C","\u231D","\u231E","\u231F"].includes(e)?{stretchy:"true"}:{}}):Object.assign(i,{fence:"true",stretchy:"true",symmetric:"true"}),t&&Object.assign(i,{minsize:t,maxsize:t,...e==="|"||e==="\u2016"?{fence:"true",stretchy:"true",symmetric:"true"}:{}}),this.node(3,[],e,i)}symbol(e,t,n=L[t]){let i={},s=3,r=n.char;n.type==="lcGreek"?(s=1,i.mathvariant="italic"):n.type==="ucGreek"?(s=1,i.mathvariant=this.f.font||"normal"):n.type==="mathchar0mi"?(s=1,i.mathvariant=String(n.attrs?.mathvariant??(n.attrs&&Object.keys(n.attrs).length?"":"italic")),i.mathvariant||delete i.mathvariant):n.type==="mathchar7"?(s=1,i.mathvariant=this.f.font||String(n.attrs?.mathvariant??"normal")):n.type==="delimiter"&&(B.has(r)&&(i.fence="false"),i.stretchy="false"),s===3&&E.has(r)&&(i.stretchy="false");for(let[o,l]of Object.entries(n.attrs??{}))["mathvariant","largeop","movablelimits","symmetric"].includes(o)&&(i[o]=String(l));n.attrs?.texClass!==void 0&&(i["data-mjx-texclass"]=["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER"][Number(n.attrs.texClass)]??"NONE"),n.attrs?.variantForm&&(i["data-mjx-alternate"]="1"),n.name==="to"&&(i.accent="false"),s===1&&i.mathvariant==="italic"&&Array.from(r).length===1&&delete i.mathvariant;let a=this.node(s,[],r,i,e[1]-1);return a.limits=n.attrs?.movesupsub?1:0,a.fixed=s===3,a}character(e){let t=g(e),n=e[0],i=S(n)?1:3,s=t,r={};if(n>127){let o=t.codePointAt(0),l=W.find(c=>o>=c[0]&&o<=c[1]);l&&(i=l[3]==="mi"?1:3,l[4]&&(r.mathvariant=l[4])),i===1&&(n>=913&&n<=937||n>=12288&&n<55296)&&(r.mathvariant="normal")}n===124&&(r["data-mjx-texclass"]="ORD"),n===45&&(s="\u2212"),n===42&&(s="\u2217"),n===96&&(s="\u2018"),i===3&&E.has(s)&&(r.stretchy="false"),this.f.font&&(r.mathvariant=this.f.font);let a=this.node(i,[],s,r,e[1]);return a.fixed=i===3,a}number(e){if(this.options.numberPattern instanceof RegExp&&!this.f.single){let i=this.options.numberPattern;i.lastIndex=e[1];let s=i.exec(e[3]);if(!s||!s[0].length)return this.character(e);if(s&&s[0].length){let r=e[1]+s[0].length,a=e[2];for(;a<r;){let o=this.stream.peek();if(!o||o[3]!==e[3]||o[1]!==a)break;a=o[2],this.stream.next()}if(a===r)return this.node(2,[],s[0].replace(/[{}]/g,""),this.f.font?{mathvariant:this.f.font}:{},e[1])}}let t=g(e),n=this.options.decimalSeparator===","?44:46;for(;!this.f.single;){let i=this.stream.peek();if(!i)break;if(v(i[0])){t+=g(this.stream.next());continue}if(i[0]===123){let s=this.stream.next(),r=[],a=1,o;for(;a;){let l=this.stream.next();l||this.error("Missing close brace"),l[0]===123&&a++,l[0]===125&&a--,a?r.push(l):o=l}if(r.length===1&&r[0][0]===(n===44?46:44)){let l=[];for(let c=0;c<3&&v(this.stream.peek()?.[0]??0);c++)l.push(this.stream.next());if(l.length===3){if(t+=g(r[0])+w(l),v(this.stream.peek()?.[0]??0))break;continue}this.stream.push([s,...r,o,...l])}else this.stream.push([s,...r,o]);break}if(i[0]===n&&!t.includes(String.fromCharCode(n))){if(this.stream.next(),v(this.stream.peek()?.[0]??0)){t+=String.fromCharCode(n);continue}this.stream.push([i])}break}return this.node(2,[],t,this.f.font?{mathvariant:this.f.font}:{},e[1])}script(e,t=!1){let i=this.f.nodes.pop()??this.node(1),s=r=>{let a=i,o,l,c=a.limits!==0&&(a.kind===13||a.kind===14||a.kind===15);!a.scriptBoundary&&([10,11,12].includes(a.kind)||a.limits!==0&&[13,14,15].includes(a.kind))&&(a.kind===10||a.kind===13?o=a.children[1]:a.kind===11||a.kind===14?l=a.children[1]:(o=a.children[1],l=a.children[2]),a=a.children[0]),e?l&&!t?(l.kind===3&&l.attributes["data-mjx-alternate"]?(l.attributes["data-mjx-pseudoscript"]="true",r=this.row([l,r],!0)):this.error("Double exponent: use braces to clarify"),l=r):l=l?this.row([l,r],!0):r:(o&&this.error("Double subscripts: use braces to clarify"),o=r);let h=a.limits>0&&(a.kind===3||this.f.display||a.limits===2)||c,f=o&&l?h?15:12:o?h?13:10:h?14:11,p=this.node(f,[a,...o?[o]:[],...l?[l]:[]],"",{},a.start);p.op=a.op,p.limits=a.limits,this.append(p)};if(t){[11,12,14,15].includes(i.kind)&&this.error("Prime causes double exponent: use braces to clarify");let r=1;for(;[39,8217].includes(this.stream.peek()?.[0]??0);)this.stream.next(),r++;s(this.node(3,[],["","\u2032","\u2033","\u2034","\u2057"][r]??"\u2032".repeat(r),{"data-mjx-alternate":"1"}))}else{this.stream.skip();let r=this.stream.peek();r||this.error("Missing superscript or subscript argument"),[94,95,39,8217].includes(r[0])&&this.error(`Missing open brace for ${e?"superscript":"subscript"}`);let a=this.f.level;this.argument(o=>{s(o)},!0),this.f.level=a+1,this.f.display=!1,this.f.missingMessage="Extra open brace or missing close brace"}}dimension(){if(this.stream.skip(),this.stream.peek()?.[0]===123)return w(this.tokensArgument()).replace(",",".").trim();let e="";for(;this.stream.peek();){let t=this.stream.peek();if(t[0]===-1||t[0]===123||t[0]===125)break;let n=t[0];if(N(n)){if(this.stream.next(),e)break;continue}if(v(n)||S(n)||n===45||n===43||n===46||n===44){if(e+=g(this.stream.next()),/[a-z]{2}$/i.test(e))break}else break}return e||this.error("Missing dimension"),e.replace(",",".")}text(e,t=""){let n=w(e).replace(/%[^\r\n]*(?:\r?\n|$)/g,"").replace(/\\U\{([0-9a-fA-F]+)\}/g,(i,s)=>String.fromCodePoint(parseInt(s,16))).replace(/\\([{}%$#_& \\])/g,"$1").replace(/~/g,"\xA0");return n.startsWith(" ")&&(n="\xA0"+n.slice(1)),n.endsWith(" ")&&(n=n.slice(0,-1)+"\xA0"),this.node(4,[],n,t?{mathvariant:t}:{})}tagText(e){if(!/[\\$]/.test(e))return[this.node(4,[],e)];let t=O();t.macros=new Map(this.macros),t.labels=new Map([...this.session.labels,...this.localLabels]),t.initialized=!0;let n=(this.options.maxDepth??1024)-this.frames.length;n<1&&this.error("Nesting limit exceeded");let i=new b("\\text{"+e+"}",{...this.options,display:!1,tags:"none",maxDepth:n},this.configuration,t);return i.run(),this.nodes+=i.nodes,this.nodes>(this.options.maxNodes??1e5)&&this.error("Node limit exceeded"),i.result}renderText(e,t="",n=!1){let{tokens:i,start:s,end:r}=Array.isArray(e)?{tokens:e,start:0,end:e.length}:e,a=[],o=s,l=!1;for(let d=s;d<r;d++){let m=i[d],k=m[0]===-1?g(m):"";if(m[0]===123){let u=G(i,d);if(u!==void 0&&u<r){d=u;continue}}(m[0]===36||k==="("||k===")")&&(a.push({math:l,span:{tokens:i,start:o,end:d}}),o=d+1,l=!l)}a.push({math:l,span:{tokens:i,start:o,end:r}}),l&&this.error("Unclosed math delimiter in text");let c=[],h=0,f=this.f.display,p=()=>{for(;h<a.length;){let m=a[h++];if(m.span.start!==m.span.end){if(m.math){this.parseSpan(m.span,k=>{c.push(this.atom(k.kind===6&&!Object.keys(k.attributes).length?k.children:[k])),p()}),this.f.font="",this.f.display=!1;return}c.push(this.text(m.span.tokens.slice(m.span.start,m.span.end),t))}}let d=c.length===1?c[0]:this.row(c,!0);n&&f&&(d=this.node(16,d.kind===6?d.children:[d],"",{displaystyle:"false"})),this.append(d)};p()}tableStart(e,t,n,i){e==="eqnarray"&&(this.hasTaggableEnvironment=!0);let s={rows:[],cells:[],align:t,spacing:"1em",rowspacing:"4pt",display:e==="darray"||e==="eqnarray"||e.includes("eqalign"),lines:[],rowlines:[],frame:"",top:"",bottom:"",position:"",latex:n===-4,plan:Z(t,this.options.maxTokens??2e5,this.columns),originalFont:this.f.font,fill:"",rowBreak:{},cellBreak:{},tableBreak:!0,labels:[],noNumbers:new Set,rowspaces:[],numbered:e==="eqnarray"&&this.numbered,taggable:e==="eqnarray",tagCells:new Map};(e==="eqnarray"||e.includes("eqalign"))&&(s.spacing=e==="eqnarray"?"0em 0.278em":"0.278em",s.rowspacing=".5em"),e==="cases"&&(s.spacing="1em",s.rowspacing=".2em"),this.frame(n,!1,r=>{(r.length||s.cells.length)&&(this.finishCell(s,r),s.rows.push(s.cells),this.tagRow(s)),s.rows.length>1&&s.bottom&&r.length&&(s.bottom=""),this.completeTable(s,e,i??(a=>this.append(a)))},e,s),this.f.display=s.display,s.latex&&(this.stream.skip(),this.startCell(s))}startCell(e){let n=e.plan.columns.filter(i=>i.insert===null)[e.cells.length];n?.before.length&&C(this.stream.peek()??[0,0,0,""])!==T.end&&this.stream.push(n.before)}finishCell(e,t){let i=e.plan.columns.filter(a=>a.insert===null)[e.cells.length];if(i?.after.length)if(w(i.after)==="\\hspace{.5em}")t.push(this.node(5,[],"",{width:".5em"}));else for(let a of i.after)N(a[0])||t.push(this.character(a));let s={};e.fill&&(s.columnalign=e.fill,e.fill="");let r=e.rows.length+":"+e.cells.length;if(e.cellBreak[r]&&(s["data-vertical-align"]=e.cellBreak[r]),i?.width&&i.width!=="auto"){let a=this.node(4,[],X(t));t=[this.node(18,[a],"",{"data-mjx-vbox":i.vertical||"top",width:i.width,"data-overflow":"auto","data-align":i.align,"data-vertical-align":i.vertical||"top"})]}if(e.colors){let a=e.colors.cell||(e.colors.rowIndex===e.rows.length?e.colors.row:"")||e.colors.columns[e.cells.length];a&&(s.mathbackground=a),e.colors.cell=""}e.cells.push(this.node(23,t,"",s))}completeTable(e,t,n){let i=e.plan.columns.map((o,l)=>({c:o,i:l})).filter(o=>o.c.insert!==null),s=0,r=0,a=()=>{for(;s<e.rows.length;){if(r===i.length){r=0,s++;continue}let{c:o,i:l}=i[r++];this.parseTokens(o.insert,c=>{let h=this.node(23,c.kind===6?c.children:[c]),f=e.rows[s][l];f&&!f.children.length&&f.attributes.columnalign&&(h.attributes.columnalign=f.attributes.columnalign,delete f.attributes.columnalign),e.rows[s].splice(l,0,h),a()});return}n(this.tableNode(e,t))};a()}tagTable(){for(let e=this.frames.length-1;e>=0;e--){let t=this.frames[e].table;if(t?.taggable)return t}}setLabel(e){if(e==="")return;let t=this.tagTable();if((t?t.labels[t.rows.length]:this.label)&&this.error("Multiple \\label"),(this.session.labels.has(e)||this.localLabels.has(e))&&!this.options.ignoreDuplicateLabels&&this.error(`Label '${e}' multiply defined`),this.localLabels.set(e,{tag:"???",id:""}),t){t.labels[t.rows.length]=e;let i=t.explicitTags?.get(t.rows.length);if(i!==void 0){let s=String(j(this,"id",(this.options.useLabelIds!==!1?e:"")||i));this.localLabels.set(e,{tag:i,id:s});let r=t.tagCells.get(t.rows.length);r&&(r.attributes.id=s)}}else this.label=e}reference(e,t=!1){let n=this.session.labels.get(e)??this.localLabels.get(e)??{tag:"???",id:""};this.append(this.node(6,t?z(this,n.tag,!1,!0):[this.node(4,[],n.tag)],"",{href:String(j(this,"url",n.id,this.options.baseURL??"")),class:"MathJax_ref"}))}tagRow(e){let t=e.rows.length-1;e.numbered&&!e.noNumbers.has(t)&&!e.tagCells.has(t)&&e.tagCells.set(t,this.labelCell(e.labels[t]??""))}labelCell(e,t,n=!1){let i=t??String(j(this,"number",++this.session.counter)),s=String(j(this,"id",(this.options.useLabelIds!==!1?e:"")||i));return e&&this.localLabels.set(e,{tag:i,id:s}),this.node(23,z(this,i,n),"",{id:s,...this.options.tagAlign&&this.options.tagAlign!=="baseline"?{rowalign:this.options.tagAlign}:{}})}tableNode(e,t){let n=e.plan.columns.map(h=>({left:"l",right:"r",center:"c"})[h.align]).join("")||"c",i={columnspacing:e.spacing,rowspacing:e.rowspacing,columnalign:Array.from(n,h=>({l:"left",c:"center",r:"right"})[h]).join(" ")};!["matrix","array","pmatrix","cases"].includes(t)||t==="array"&&e.align,i.displaystyle=String(e.display),(t==="matrix"||t==="pmatrix")&&(i.columnalign="center"),e.plan.columns.slice(1).some(h=>h.separator)&&(i.columnlines=e.plan.columns.slice(1).map(h=>h.separator==="|"?"solid":h.separator===":"?"dashed":"none").join(" ")),e.plan.columns.some(h=>h.width!=="auto")&&(i.columnwidth=e.plan.columns.map(h=>h.width).join(" ")),e.plan.columns.some(h=>h.insert)&&(i.columnspacing=e.plan.columns.slice(1).map((h,f)=>e.plan.columns[f].insert?e.plan.columns[f].gap:h.insert?h.gap:"1em").join(" "),e.plan.columns.at(-1)?.insert!==null&&(i.columnspacing+=" "+e.plan.columns.at(-1).gap),e.plan.padding&&(i["data-array-padding"]=e.plan.padding)),e.rowlines.slice(0,e.rows.length-1).some(Boolean)&&(i.rowlines=Array.from({length:e.rows.length-1},(h,f)=>e.rowlines[f]??"none").join(" ")),e.rowspaces.length&&(i.rowspacing=Array.from({length:Math.max(e.rows.length,e.rowspaces.length)},(h,f)=>e.rowspaces[f]??(e.rowspacingBase===void 0?"0.4em":e.rowspacingBase+"em")).join(" "));let s=e.plan.left,r=e.plan.right,a="";if(s==="|"&&r==="|"&&e.top==="solid"&&e.bottom==="solid"?a="solid":s===":"&&r===":"&&e.top==="solid"&&e.bottom==="solid"&&(a="dashed"),a&&(delete i["data-frame-styles"],i.frame=a,i.framespacing=e.latex?".5em .125em":".2em .125em"),e.position&&(i.align=e.position),t==="displaylines"&&(i.displaystyle="true",i.rowspacing=".5em"),t==="eqnarray"){let h=Math.max(...e.rows.map(f=>f.length));i.columnalign=Array.from({length:h},(f,p)=>["right","center","left"][p%3]).join(" "),i.columnspacing=Array.from({length:h-1},(f,p)=>p%2===0?"0em":"0.278em").join(" "),i["data-break-align"]=Array.from({length:h},(f,p)=>["bottom","middle","top"][p%3]).join(" "),i.rowspacing="3pt",e.tableBreak||delete i["data-break-align"]}i.columnalign==="center"&&delete i.columnalign,i.displaystyle==="false"&&delete i.displaystyle,(t==="array"||t==="matrix"||t==="pmatrix"||t==="cases")&&(i["data-frame-styles"]="",i.framespacing=e.latex?".5em .125em":".2em .125em"),t==="leqalignno"&&(i.side="left");let o=this.node(20,e.rows.map((h,f)=>{if(t==="eqnarray")for(let p=0;p<h.length;p++)p%3===1&&h.length===3&&h[p].children.unshift(this.node(1)),p%3===2&&(h[p].children=[this.node(16,h[p].children,"",{indentshift:".7em"})]);if(t==="eqalignno"||t==="leqalignno"){let p=h.pop()??this.node(23);return this.node(22,[p,...h])}return e.tagCells.has(f)?this.node(22,[e.tagCells.get(f),...h]):this.node(21,h,"",e.rowBreak[f]?{"data-break-align":e.rowBreak[f]}:{})}),"",i);o.children.some(h=>h.kind===22)&&(this.options.tagSide&&this.options.tagSide!=="right"&&(o.attributes.side=this.options.tagSide),this.options.tagIndent&&this.options.tagIndent!=="0.8em"&&(o.attributes.minlabelspacing=this.options.tagIndent));let l=o,c=[];if((s==="|"||s===":")&&c.push("left"),(r==="|"||r===":")&&c.push("right"),e.top&&c.push("top"),e.bottom&&c.push("bottom"),a==="solid"&&delete o.attributes["data-frame-styles"],a==="dashed"||s==="|"&&r===":"||s===":"&&r==="|")return delete o.attributes.frame,o.attributes["data-frame-styles"]=[e.top||"none",r===":"?"dashed":r==="|"?"solid":"none",e.bottom||"none",s===":"?"dashed":s==="|"?"solid":"none"].join(" "),o;if(c.length&&!a){let h=this.node(24,[o],"",{notation:c.join(" "),"data-padding":"0"});o.attributes.framespacing=e.latex?".5em .125em":".2em .125em",l=h}return t==="pmatrix"&&(l=this.atom([this.delimiterNode("(","","OPEN"),l,this.delimiterNode(")","","CLOSE")],"INNER")),t==="cases"&&(l=this.atom([this.delimiterNode("{","","OPEN"),l,this.delimiterNode("","","CLOSE")],"INNER")),l}run(){for(;this.frames.length;){for(;this.f?.single&&this.f.nodes.length;)this.close();if(!this.frames.length)break;let e=this.stream.next();if(!e){this.frames.length!==1&&this.error(this.f.missingMessage??(this.f.env==="argument"?"Missing close brace":this.f.env==="left"?"Extra \\left or missing \\right":this.f.env?`Missing \\end{${this.f.env}}`:"Extra open brace or missing close brace")),this.close();break}this.position=e[1];let t=e[0];if(t===0&&this.f.stop===-2){this.close();continue}if(t===this.f.stop){this.close();continue}let n=this.options.texOptions?.active?.[g(e)];if(t!==-1&&n!==void 0&&this.configuration.packages.some(a=>a.name==="configmacros")){this.expand(R(n));continue}if(N(t))continue;let i=t>0?this.characters?.get(t):void 0;if(i){let a=!1;for(let o of i)if(o.execute(this,e,o.definition,o.id)!==!1){a=!0;break}if(a)continue}switch(t){case 37:for(;this.stream.peek()&&![10,13].includes(this.stream.peek()[0]);)this.stream.next();this.stream.next();continue;case 123:this.frame(125,!1,a=>this.append(this.atom(a)));continue;case 125:this.error("Extra close brace or missing open brace");case 94:this.script(!0);continue;case 95:this.script(!1);continue;case 39:case 8217:this.script(!0,!0);continue;case 35:this.error("You can't use 'macro parameter character #' in math mode");case 38:{let a=this.f;if(a.table||this.error("Misplaced &"),this.finishCell(a.table,a.nodes),a.nodes=[],a.font=a.table.originalFont,a.env==="cases"&&!a.table.latex){a.table.cells.length>1&&this.error("Extra alignment tab in \\cases text");let o=[],l=0;for(;this.stream.peek();){let c=this.stream.peek();if(l===0&&(c[0]===125||C(c)===T.end||C(c)===T.cr||g(c)==="\\"&&c[0]===-1))break;c[0]===38&&l===0&&this.error("Extra alignment tab in \\cases text"),this.stream.next(),c[0]===123&&l++,c[0]===125&&l--,o.push(c)}for(;o.length&&N(o[0][0]);)o.shift();for(;o.length&&N(o.at(-1)[0]);)o.pop();C(o[0])===T.text?this.stream.push(o):this.renderText(o);continue}a.table.latex&&this.startCell(a.table);continue}case-5:{let a=g(e)==="<"?"\u27E8":g(e)===">"?"\u27E9":g(e),o=this.node(3,[],a,{fence:"false",stretchy:"false",..."|\u2016".includes(a)?{"data-mjx-texclass":"ORD"}:{}});o.rawAttrs=!0,this.append(o);continue}case 126:this.append(this.node(4,[],"\xA0"));continue;case-1:case-3:{let a=q(e),o=L[a],l=o?.name??g(e),c=t===-1&&this.macros.size?this.macros.get(l):void 0;if(c){this.currentCommand="\\"+l,this.expand(c);continue}let h=a<0?this.configuration.extensions.get(l):this.configuration.commands[a]??this.configuration.extensions.get(l);if(!h){let f=[...this.configuration.packages].reverse().find(p=>p.undefinedCommand)?.undefinedCommand;if(f){f(this,l);continue}this.error(`Undefined control sequence \\${l}`)}this.currentCommand="\\"+l,h.execute(this,e,h.definition,a);continue}}let s=this.configuration.characters.size?this.configuration.characters.get(g(e)):void 0;if(s){s.execute(this,e,s.definition,-1);continue}if(v(t)||this.options.numberPattern!==void 0&&(t===44||t===46)||t===(this.options.decimalSeparator===","?44:46)&&v(this.stream.peek()?.[0]??0)){this.append(this.number(e));continue}let r=this.character(e);if(this.f.multi&&r.kind===1&&S(t)){if(this.options.identifierPattern instanceof RegExp){let a=this.options.identifierPattern;a.lastIndex=e[1];let o=a.exec(e[3]);if(o&&o[0].length){let l=e[1]+o[0].length,c=e[2];for(;c<l;){let h=this.stream.peek();if(!h||h[3]!==e[3]||h[1]!==c)break;c=h[2],r.text+=g(this.stream.next())}}}else for(;this.stream.peek()&&S(this.stream.peek()[0]);)r.text+=g(this.stream.next());r.text.length>1&&r.attributes.mathvariant==="normal"&&(r.attributes["data-mjx-auto-op"]="false")}this.append(r)}this.numbered&&!this.hasTaggableEnvironment&&this.options.display&&(this.result=[this.node(20,[this.node(22,[this.labelCell(this.label),this.node(23,this.result)])],"",{displaystyle:"true",...this.options.tagSide&&this.options.tagSide!=="right"?{side:this.options.tagSide}:{},...this.options.tagIndent&&this.options.tagIndent!=="0.8em"?{minlabelspacing:this.options.tagIndent}:{}})]),this.envStack.length&&this.error(`Missing \\end{${this.envStack.at(-1)}}`);for(let[e,t]of this.localLabels)this.session.labels.set(e,t);return this.finish(this.result),U(this.node(0,this.result,"",{xmlns:te,...this.options.display&&!this.inline?{display:"block"}:{},...this.hsize?{maxwidth:this.hsize,overflow:"linebreak"}:{}}))}linebreak(){this.stream.peek()?.[0]===42&&this.stream.next();let e=this.stream.peek()?.[0]===91?this.optional():null;e&&!/^[+-]?(?:\d+(?:[.,]\d*)?|[.,]\d+)\s*(?:em|ex|pt|px|mu|cm|mm|in|pc)$/.test(w(e).trim())&&this.error("Bracket argument to \\\\ must be a dimension");let t=this.f;if(t.table){let n=t.table;this.finishCell(n,t.nodes),n.rows.push(n.cells),this.tagRow(n),n.cells=[],t.nodes=[],t.font=n.originalFont,e&&(n.rowspaces[n.rows.length-1]=n.rowspacingBase===void 0?Q(I(w(e))+.4):I(w(e))+n.rowspacingBase+"em"),n.latex&&this.startCell(n);return}this.append(this.node(5,[],"",{linebreak:"newline",...e?{"data-lineleading":w(e).replace(",",".")}:{}}))}decorationBase(e){if(e.kind===3&&e.limits>0)return e.attributes.movablelimits="false",e.limits=0,e;if((e.limits!==0||e.children[0]?.attributes.movablelimits==="false")&&[13,14,15].includes(e.kind)){let t=e.children[0];return t.attributes.lspace="0",t.attributes.rspace="0",this.row([this.node(3,[],"",{rspace:"0"}),e],!0)}return e}clean(e,t,n){if(e.rawAttrs)return;let i=e.attributes,s=e.kind===3?P(e.text,t===0&&n>1?"prefix":t===n-1&&n>1?"postfix":"infix")?.[3]??{}:{};if(e.kind===3&&i.stretchy==="true"&&s.stretchy&&delete i.stretchy,e.fixed&&(s.stretchy?i.stretchy="false":e.text!=="|"&&e.text!=="\u2016"&&delete i.stretchy),!e.rawAttrs&&e.kind===3)for(let r of["fence","largeop","movablelimits","symmetric","accent"])i[r]===String(s[r]??!1)&&delete i[r];i.mathvariant?.startsWith("-tex-")&&(i["data-mjx-variant"]=i.mathvariant,i.mathvariant=i.mathvariant.includes("calligraphic")?i.mathvariant.includes("bold")?"bold-script":"script":i.mathvariant==="-tex-oldstyle"?"normal":"italic"),i.mathvariant==="italic"&&e.kind===1&&Array.from(e.text).length===1&&!i["data-mjx-variant"]&&delete i.mathvariant,!e.rawAttrs&&!i["data-mjx-variant"]&&i.mathvariant==="normal"&&(e.kind===3||e.kind===2||e.kind===4||e.kind===1&&Array.from(e.text).length>1)&&delete i.mathvariant}functionArgument(e){if(e.kind===5||e.text==="\u2061"||e.kind===16&&e.children[0]?.kind===5)return!1;let t=e;for(;[10,11,12,13,14,15].includes(t.kind);)t=t.children[0];if(t.kind!==3)return!0;let n=t.attributes["data-mjx-texclass"],i=n?["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER"].indexOf(n):P(t.text)?.[2]??0;return![2,3,5,6].includes(i)}finish(e){let t=[{children:e,sequence:!0}];for(;t.length;){let{children:n,sequence:i}=t.pop();for(let s=0;s<n.length;s++){let r=n[s];if(r.children.length&&t.push({children:r.children,sequence:[0,6,23,16,18,8,19,24].includes(r.kind)}),this.clean(r,s,n.length),[10,11,12,13,14,15].includes(r.kind)&&(r.children[0].op=0),i&&r.op&&s+1<n.length&&(r.text||Y(r))){let a=n[s+1];this.functionArgument(a)&&n.splice(++s,0,this.node(3,[],"\u2061",{"data-mjx-texclass":"NONE"}))}if(i&&r.kind===3&&r.relation)for(;s+1<n.length;){let a=n[s+1];if(!a.relation)break;if(this.clean(a,s+1,n.length),!J(r.attributes,a.attributes)){r.attributes.rspace??="0pt",a.attributes.lspace??="0pt";break}a.attributes.stretchy==="false"&&(r.attributes.stretchy="false"),r.text+=a.text,r.attributes["data-mjx-texclass"]="REL",n.splice(s+1,1)}}}}};function ie(b,e,t,n){if(typeof b!="string")throw new TypeError("TeX input must be a string");let i;try{return i=new F(b,e,t,n),i.run()}catch(s){if(!(s instanceof M)&&!(s instanceof Error&&s.message==="Token limit exceeded")||e.throwOnError)throw s;let r=s.message;typeof e.texOptions?.formatError=="function"&&e.texOptions.formatError(null,s);let a=[...(i?.configuration??t).packages].reverse().find(o=>o.formatError)?.formatError;return{kind:"math",attributes:{xmlns:te,...e.display?{display:"block"}:{}},children:a?[a(r,b)]:[{kind:"merror",attributes:{"data-mjx-error":r},children:[{kind:"mtext",attributes:{},children:[],text:r,start:0}],text:"",start:0}],text:"",start:0}}}function le(b={}){let{options:e,configuration:t}=$(b),n=O(),i=(s,r={})=>{let a={...e,...r};return D(ie(s,a,t,n),a)};for(let s of e.prior??[])i(s.tex,{display:s.display??e.display});return{parse:i}}function Te(b,e={}){let t=$(e);return t.options.prior?.length?le(e).parse(b):D(ie(b,t.options,t.configuration,O()),t.options)}export{le as a,Te as b};
1
+ import{a as D}from"./chunk-6CC22KD6.js";import{A as P,B as Q,C as q,D as re,E as j,F as z,G as ae,M as $,N as V,O as oe,a as M,b as U,d as _,e as L,f as T,g as W,h as se,i as S,j as N,k as x,l as g,m as C,n as w,o as G,p as A,q as K,r as R,s as ne,t as H,u as E,v as B,w as J,x as X,y as I,z as Y}from"./chunk-SHAALSPE.js";ne();_();K();_();K();function Z(b,e,t){let n=0,i=new A(x(b),e),s=[],r=()=>{i.skip();let d=i.next();if(!d)return"";if(d[0]!==123)return w([d]);let m=[],k=1;for(;k;){let u=i.next();if(!u)throw Error("Missing array preamble brace");u[0]===123&&k++,u[0]===125&&k--,k&&m.push(u)}return w(m)},a=[],o="",l="",c="",h="1em",f="",p=(d,m="auto",k=null,u="1em",y="")=>{if(s.length>=e)throw Error("Array column limit exceeded");s.push({align:d,width:m,before:a,after:[],insert:k,separator:o,gap:u,vertical:y}),a=[],o=""};for(;i.peek();){i.skip();let d=i.next();if(!d)break;let m=w([d]);if(m==="*"){let u=Number(r());if(!Number.isSafeInteger(u)||u<0||u>e)throw Error("Invalid array repeat");let y=r();if(y.length*u>e)throw Error("Array preamble limit exceeded");i.push(x(y.repeat(u)));continue}let k=t.get(m);if(k){if(++n>e)throw Error("Array preamble limit exceeded");let u=k.body;for(let y=1;y<=k.count;y++)u=u.replaceAll("#"+y,r());i.push(x(u));continue}if(m==="|"||m===":"){o?(s.length&&s.at(-1).after.push(...x("\\hspace{.5em}")),p("center","auto",x("\\,"),"0"),o=m,a.push(...x("\\hspace{.5em}")),h="0"):(o=m,s.length||(l=m));continue}if(m===">"){a.unshift(...x(r()));continue}if(m==="<"){s.length?s.at(-1).after.unshift(...x(r())):r();continue}if(m==="@"||m==="!"){let u=x(r()),y=m==="@"?"0":".5em";s.length===0&&(f=(m==="@"?"0":".5em")+" .5em"),p("center","auto",u,y),c=m,h=y;continue}if(m==="w"||m==="W"){let u=r(),y=r();p({l:"left",r:"right",c:"center"}[u]??"center",y,null,"1em","top");continue}if(m==="p"||m==="m"||m==="b"){p("left",r(),null,"1em",m==="p"?"top":m==="m"?"middle":"bottom");continue}if(m==="l"||m==="c"||m==="r"){p({l:"left",c:"center",r:"right"}[m]);continue}if(!(m==="{"||m==="}"))throw new M(`Illegal pream-token (${m})`,d[1])}c&&s.at(-1)?.insert&&(f=(f?f.split(" ")[0]:".5em")+" "+(c==="@"?"0":".5em"));for(let d=1;d<s.length;d++)s[d].separator&&s[d-1].insert!==null&&s[d].insert!==null&&(s[d-1].gap!=="0"&&(s[d-1].insert.push(...x("\\hspace{.25em}")),s[d-1].gap="0"),s[d].gap!=="0"&&s[d].insert.unshift(...x("\\hspace{.25em}")));return s.length||p("center"),{columns:s,left:l,right:o,padding:f,spacing:h}}se();oe();function O(){return{packageData:new Map,macros:new Map,environments:new Map,labels:new Map,counter:0,initialized:!1}}ae();re();var te="http://www.w3.org/1998/Math/MathML",v=b=>b>=48&&b<=57,ee=(b,e)=>!!b&&b[0]===e[0]&&g(b)===g(e),F=class b{constructor(e,t,n=V(t.packages),i=O()){this.tex=e;this.options=t;this.configuration=n;this.session=i;if(this.macros=i.macros,this.environments=i.environments,this.numbered=t.tags==="all"&&!!t.display,this.stream=new A(x(e,t.maxTokens??2e5),t.maxTokens??2e5),!i.initialized)for(let[s,r]of Object.entries(t.macros??{}))this.macros.set(s,R(r));i.initialized=!0,this.frame(0,!1,s=>{this.result=s});for(let s of n.initializers)s(this)}tex;options;configuration;session;get characters(){return this.configuration.characterHandlers}stream;macros;environments;localLabels=new Map;frames=[];nodes=0;expansions=0;position=0;columns=new Map;label="";numbered=!1;hasTaggableEnvironment=!1;envStack=[];hsize="";inline=!1;nonscript=!1;pendingBreak="";result=[];currentCommand="";error(e){throw new M(e,this.position)}node(e,t=[],n="",i={},s=this.position){++this.nodes>(this.options.maxNodes??1e5)&&this.error("Node limit exceeded");let r={kind:e,attributes:i,children:t,text:n,start:s,op:0,limits:0,relation:e===3&&H.has(n),fixed:!1,rawAttrs:!1};return(e===1||e===3||e===2||e===4)&&this.f?.tokenTransform?.(r),r}row(e,t=!1){if(!t&&e.length===1)return e[0];let n=this.node(6,e);return n.inferred=!t,n}atom(e,t="ORD"){return this.node(6,e,"",{"data-mjx-texclass":t})}fixInitialMO(e){let t=e.find(n=>(n.kind!==5||n.styledSpace)&&!(n.kind===6&&n.attributes["data-mjx-texclass"]&&!n.children.length));for(;t;){if(t.kind===3||t.attributes["data-mjx-texclass"]==="REL"){e.unshift(this.node(1));return}if([10,11,12,13,14,15].includes(t.kind)){t=t.children[0];continue}if([16,18,19,6].includes(t.kind)){let n=t.children.filter(i=>i.kind!==5&&i.kind!==4);if(n.length===1){t=n[0];continue}}return}}get f(){return this.frames[this.frames.length-1]}frame(e,t,n,i="",s=null){this.frames.length>=(this.options.maxDepth??1024)&&this.error("Nesting limit exceeded");let r=this.f;this.frames.push({tokenTransform:r?.tokenTransform,nodes:[],stop:e,single:t,done:n,font:r?.font??"",multi:r?.multi??!1,level:r?.level??0,display:r?.display??this.options.display??!1,env:i,table:s,fraction:null})}append(e){if(this.pendingBreak){let t=this.pendingBreak;this.pendingBreak="",e.kind===3&&P(e.text)?.[3]?.linebreakstyle!=="after"?e.attributes.linebreak=t:this.f.nodes.push(this.node(5,[],"",t==="auto"?{}:{linebreak:t}))}this.nonscript&&(this.nonscript=!1,this.f.level>0&&(e.kind===5||e.kind===16&&e.children[0]?.kind===5))||(this.f.table?.bottom&&(this.f.table.bottom=""),this.f.nodes.push(e))}close(){let e=this.f;if(this.pendingBreak){let n=this.pendingBreak;this.pendingBreak="",e.nodes.push(this.node(5,[],"",n==="auto"?{}:{linebreak:n}))}let t=e.nodes;if(e.fraction){let n=e.fraction,i=this.node(7,[this.row(n.num),this.row(t)],"",n.attrs);if(n.left||n.right){let s=this.f.level===0?"2.047em":"1.2em";i=this.atom([this.atom([this.delimiterNode(n.left,s)],"OPEN"),i,this.atom([this.delimiterNode(n.right,s)],"CLOSE")])}t=[i]}this.frames.pop(),e.done(t)}argument(e,t=!1,n=""){this.stream.skip();let i=this.stream.peek();(!i||i[0]===0)&&this.error(`Missing argument for ${n||this.currentCommand}`),i[0]===125&&this.error(this.f.env==="argument"?`Missing argument for ${n||this.currentCommand}`:"Extra close brace or missing open brace"),i[0]===123?(this.stream.next(),this.frame(125,!1,s=>e(t?this.atom(s):this.row(s))),this.f.env="argument"):this.frame(0,!0,s=>e(this.row(s))),this.f.argumentScope=!0}args(e,t,n=""){let i=[],s=this.currentCommand,r=()=>{this.currentCommand=s,i.length===e?t(i):this.argument(a=>{i.push(a),r()},!1,n)};r()}tokensArgument(e=this.currentCommand){let t=this.argumentSpan(e);return t.tokens.slice(t.start,t.end)}argumentSpan(e=this.currentCommand){this.stream.skip();let t=this.stream.next();if((!t||t[0]===0)&&this.error(`Missing argument for ${e}`),t[0]===125&&this.error("Extra close brace or missing open brace"),t[0]!==123)return{tokens:[t],start:0,end:1};let n=this.stream.takeGroup();if(n)return n;let i=[],s=1;for(;s;){let r=this.stream.next();r||this.error("Missing close brace"),r[0]===123&&s++,r[0]===125&&s--,s&&i.push(r)}return{tokens:i,start:0,end:i.length}}optional(){if(this.stream.skip(),this.stream.peek()?.[0]!==91)return null;this.stream.next();let e=[],t=0;for(;;){let n=this.stream.next();if(n||this.error(`Could not find closing ']' for argument to ${this.currentCommand}`),n[0]===93&&t===0)return e;n[0]===123&&t++,n[0]===125&&--t<0&&this.error("Extra close brace while looking for ']'"),e.push(n)}}parseTokens(e,t){this.parseSpan({tokens:e,start:0,end:e.length},t)}parseSpan(e,t){this.stream.push([[0,0,0,""]]),this.stream.pushSpan(e),this.frame(-2,!1,n=>t(this.row(n))),this.f.argumentScope=!0}substitute(e,t){let n=[];for(let i=0;i<e.body.length;i++){let s=e.body[i];if(s[0]!==35){n.push(s);continue}let r=e.body[++i];if(r?.[0]===35)n.push(r);else{let a=r?r[0]-49:-1;(a<0||a>=t.length)&&this.error("Illegal macro parameter reference");for(let o of t[a])n.length>=(this.options.maxTokens??2e5)&&this.error("Token limit exceeded"),n.push(o)}n.length>(this.options.maxTokens??2e5)&&this.error("Token limit exceeded")}return n}expand(e){++this.expansions>(this.options.maxExpansions??1e4)&&this.error("Macro expansion limit exceeded"),this.stream.skip();for(let s of e.prefix)ee(this.stream.next(),s)||this.error("Use of macro doesn't match its definition");let t=[];if(e.optional){let s=this.optional()??e.optional;t.push({tokens:s,start:0,end:s.length})}for(let s=t.length;s<e.count;s++){let r=e.delimiters[s]??[];if(!r.length){t.push(this.argumentSpan());continue}let a=[],o=0;for(;;){let l=this.stream.next();if(l||this.error("Missing macro argument delimiter"),a.push(l),l[0]===123&&o++,l[0]===125&&o--,o===0&&a.length>=r.length&&r.every((c,h)=>ee(a[a.length-r.length+h],c))){a.length-=r.length;break}}if(a[0]?.[0]===123&&a.at(-1)?.[0]===125){let l=0,c=!0;for(let h=0;h<a.length-1;h++)a[h][0]===123&&l++,a[h][0]===125&&l--,l===0&&(c=!1);c&&(a.shift(),a.pop())}t.push({tokens:a,start:0,end:a.length})}let n=[],i=0;for(let s=0;s<e.body.length;s++){if(e.body[s][0]!==35)continue;i<s&&n.push({tokens:e.body,start:i,end:s});let r=e.body[++s];if(r?.[0]===35)n.push({tokens:e.body,start:s,end:s+1});else{let a=r?r[0]-49:-1;(a<0||a>=t.length)&&this.error("Illegal macro parameter reference"),n.push(t[a])}i=s+1}i<e.body.length&&n.push({tokens:e.body,start:i,end:e.body.length});for(let s=n.length-1;s>=0;s--)this.stream.pushSpan(n[s])}delimiter(){this.stream.skip();let e=this.stream.next();e?.[0]===123&&(e=this.stream.next(),this.stream.next()?.[0]!==125&&this.error("Missing close brace")),e||this.error(`Missing or unrecognized delimiter for ${this.currentCommand}`);for(let n=0;n<30&&!(e[0]!==-1&&e[0]!==-3);n++){let i=e[0]===-1?this.macros.get(g(e)):void 0;if(i?.body.length===1){e=i.body[0];continue}let s=q(e),r=(s<0?this.configuration.extensions.get(g(e)):this.configuration.commands[s])?.definition;if(r?.char&&(r.type==="delimiter"||E.has(r.char)||"<>".includes(r.char)))return r.char==="<"?"\u27E8":r.char===">"?"\u27E9":r.char;this.error(`Missing or unrecognized delimiter for ${this.currentCommand}`)}let t=g(e);return t==="."?"":t==="<"?"\u27E8":t===">"?"\u27E9":(E.has(t)||this.error(`Missing or unrecognized delimiter for ${this.currentCommand}`),t)}delimiterNode(e,t="",n=""){let i=n?{"data-mjx-texclass":n}:{};return e?!B.has(e)&&e!=="<"&&e!==">"&&Object.assign(i,{fence:"true",symmetric:"true",...["\u23D0","\u23EA","\u23AA","/","\\","\u231C","\u231D","\u231E","\u231F"].includes(e)?{stretchy:"true"}:{}}):Object.assign(i,{fence:"true",stretchy:"true",symmetric:"true"}),t&&Object.assign(i,{minsize:t,maxsize:t,...e==="|"||e==="\u2016"?{fence:"true",stretchy:"true",symmetric:"true"}:{}}),this.node(3,[],e,i)}symbol(e,t,n=L[t]){let i={},s=3,r=n.char;n.type==="lcGreek"?(s=1,i.mathvariant="italic"):n.type==="ucGreek"?(s=1,i.mathvariant=this.f.font||"normal"):n.type==="mathchar0mi"?(s=1,i.mathvariant=String(n.attrs?.mathvariant??(n.attrs&&Object.keys(n.attrs).length?"":"italic")),i.mathvariant||delete i.mathvariant):n.type==="mathchar7"?(s=1,i.mathvariant=this.f.font||String(n.attrs?.mathvariant??"normal")):n.type==="delimiter"&&(B.has(r)&&(i.fence="false"),i.stretchy="false"),s===3&&E.has(r)&&(i.stretchy="false");for(let[o,l]of Object.entries(n.attrs??{}))["mathvariant","largeop","movablelimits","symmetric"].includes(o)&&(i[o]=String(l));n.attrs?.texClass!==void 0&&(i["data-mjx-texclass"]=["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER"][Number(n.attrs.texClass)]??"NONE"),n.attrs?.variantForm&&(i["data-mjx-alternate"]="1"),n.name==="to"&&(i.accent="false"),s===1&&i.mathvariant==="italic"&&Array.from(r).length===1&&delete i.mathvariant;let a=this.node(s,[],r,i,e[1]-1);return a.limits=n.attrs?.movesupsub?1:0,a.fixed=s===3,a}character(e){let t=g(e),n=e[0],i=S(n)?1:3,s=t,r={};if(n>127){let o=t.codePointAt(0),l=W.find(c=>o>=c[0]&&o<=c[1]);l&&(i=l[3]==="mi"?1:3,l[4]&&(r.mathvariant=l[4])),i===1&&(n>=913&&n<=937||n>=12288&&n<55296)&&(r.mathvariant="normal")}n===124&&(r["data-mjx-texclass"]="ORD"),n===45&&(s="\u2212"),n===42&&(s="\u2217"),n===96&&(s="\u2018"),i===3&&E.has(s)&&(r.stretchy="false"),this.f.font&&(r.mathvariant=this.f.font);let a=this.node(i,[],s,r,e[1]);return a.fixed=i===3,a}number(e){if(this.options.numberPattern instanceof RegExp&&!this.f.single){let i=this.options.numberPattern;i.lastIndex=e[1];let s=i.exec(e[3]);if(!s||!s[0].length)return this.character(e);if(s&&s[0].length){let r=e[1]+s[0].length,a=e[2];for(;a<r;){let o=this.stream.peek();if(!o||o[3]!==e[3]||o[1]!==a)break;a=o[2],this.stream.next()}if(a===r)return this.node(2,[],s[0].replace(/[{}]/g,""),this.f.font?{mathvariant:this.f.font}:{},e[1])}}let t=g(e),n=this.options.decimalSeparator===","?44:46;for(;!this.f.single;){let i=this.stream.peek();if(!i)break;if(v(i[0])){t+=g(this.stream.next());continue}if(i[0]===123){let s=this.stream.next(),r=[],a=1,o;for(;a;){let l=this.stream.next();l||this.error("Missing close brace"),l[0]===123&&a++,l[0]===125&&a--,a?r.push(l):o=l}if(r.length===1&&r[0][0]===(n===44?46:44)){let l=[];for(let c=0;c<3&&v(this.stream.peek()?.[0]??0);c++)l.push(this.stream.next());if(l.length===3){if(t+=g(r[0])+w(l),v(this.stream.peek()?.[0]??0))break;continue}this.stream.push([s,...r,o,...l])}else this.stream.push([s,...r,o]);break}if(i[0]===n&&!t.includes(String.fromCharCode(n))){if(this.stream.next(),v(this.stream.peek()?.[0]??0)){t+=String.fromCharCode(n);continue}this.stream.push([i])}break}return this.node(2,[],t,this.f.font?{mathvariant:this.f.font}:{},e[1])}script(e,t=!1){let i=this.f.nodes.pop()??this.node(1),s=r=>{let a=i,o,l,c=a.limits!==0&&(a.kind===13||a.kind===14||a.kind===15);!a.scriptBoundary&&([10,11,12].includes(a.kind)||a.limits!==0&&[13,14,15].includes(a.kind))&&(a.kind===10||a.kind===13?o=a.children[1]:a.kind===11||a.kind===14?l=a.children[1]:(o=a.children[1],l=a.children[2]),a=a.children[0]),e?l&&!t?(l.kind===3&&l.attributes["data-mjx-alternate"]?(l.attributes["data-mjx-pseudoscript"]="true",r=this.row([l,r],!0)):this.error("Double exponent: use braces to clarify"),l=r):l=l?this.row([l,r],!0):r:(o&&this.error("Double subscripts: use braces to clarify"),o=r);let h=a.limits>0&&(a.kind===3||this.f.display||a.limits===2)||c,f=o&&l?h?15:12:o?h?13:10:h?14:11,p=this.node(f,[a,...o?[o]:[],...l?[l]:[]],"",{},a.start);p.op=a.op,p.limits=a.limits,this.append(p)};if(t){[11,12,14,15].includes(i.kind)&&this.error("Prime causes double exponent: use braces to clarify");let r=1;for(;[39,8217].includes(this.stream.peek()?.[0]??0);)this.stream.next(),r++;s(this.node(3,[],["","\u2032","\u2033","\u2034","\u2057"][r]??"\u2032".repeat(r),{"data-mjx-alternate":"1"}))}else{this.stream.skip();let r=this.stream.peek();r||this.error("Missing superscript or subscript argument"),[94,95,39,8217].includes(r[0])&&this.error(`Missing open brace for ${e?"superscript":"subscript"}`);let a=this.f.level;this.argument(o=>{s(o)},!0),this.f.level=a+1,this.f.display=!1,this.f.missingMessage="Extra open brace or missing close brace"}}dimension(){if(this.stream.skip(),this.stream.peek()?.[0]===123)return w(this.tokensArgument()).replace(",",".").trim();let e="";for(;this.stream.peek();){let t=this.stream.peek();if(t[0]===-1||t[0]===123||t[0]===125)break;let n=t[0];if(N(n)){if(this.stream.next(),e)break;continue}if(v(n)||S(n)||n===45||n===43||n===46||n===44){if(e+=g(this.stream.next()),/[a-z]{2}$/i.test(e))break}else break}return e||this.error("Missing dimension"),e.replace(",",".")}text(e,t=""){let n=w(e).replace(/%[^\r\n]*(?:\r?\n|$)/g,"").replace(/\\U\{([0-9a-fA-F]+)\}/g,(i,s)=>String.fromCodePoint(parseInt(s,16))).replace(/\\([{}%$#_& \\])/g,"$1").replace(/~/g,"\xA0");return n.startsWith(" ")&&(n="\xA0"+n.slice(1)),n.endsWith(" ")&&(n=n.slice(0,-1)+"\xA0"),this.node(4,[],n,t?{mathvariant:t}:{})}tagText(e){if(!/[\\$]/.test(e))return[this.node(4,[],e)];let t=O();t.macros=new Map(this.macros),t.labels=new Map([...this.session.labels,...this.localLabels]),t.initialized=!0;let n=(this.options.maxDepth??1024)-this.frames.length;n<1&&this.error("Nesting limit exceeded");let i=new b("\\text{"+e+"}",{...this.options,display:!1,tags:"none",maxDepth:n},this.configuration,t);return i.run(),this.nodes+=i.nodes,this.nodes>(this.options.maxNodes??1e5)&&this.error("Node limit exceeded"),i.result}renderText(e,t="",n=!1){let{tokens:i,start:s,end:r}=Array.isArray(e)?{tokens:e,start:0,end:e.length}:e,a=[],o=s,l=!1;for(let d=s;d<r;d++){let m=i[d],k=m[0]===-1?g(m):"";if(m[0]===123){let u=G(i,d);if(u!==void 0&&u<r){d=u;continue}}(m[0]===36||k==="("||k===")")&&(a.push({math:l,span:{tokens:i,start:o,end:d}}),o=d+1,l=!l)}a.push({math:l,span:{tokens:i,start:o,end:r}}),l&&this.error("Unclosed math delimiter in text");let c=[],h=0,f=this.f.display,p=()=>{for(;h<a.length;){let m=a[h++];if(m.span.start!==m.span.end){if(m.math){this.parseSpan(m.span,k=>{c.push(this.atom(k.kind===6&&!Object.keys(k.attributes).length?k.children:[k])),p()}),this.f.font="",this.f.display=!1;return}c.push(this.text(m.span.tokens.slice(m.span.start,m.span.end),t))}}let d=c.length===1?c[0]:this.row(c,!0);n&&f&&(d=this.node(16,d.kind===6?d.children:[d],"",{displaystyle:"false"})),this.append(d)};p()}tableStart(e,t,n,i){e==="eqnarray"&&(this.hasTaggableEnvironment=!0);let s={rows:[],cells:[],align:t,spacing:"1em",rowspacing:"4pt",display:e==="darray"||e==="eqnarray"||e.includes("eqalign"),lines:[],rowlines:[],frame:"",top:"",bottom:"",position:"",latex:n===-4,plan:Z(t,this.options.maxTokens??2e5,this.columns),originalFont:this.f.font,fill:"",rowBreak:{},cellBreak:{},tableBreak:!0,labels:[],noNumbers:new Set,rowspaces:[],numbered:e==="eqnarray"&&this.numbered,taggable:e==="eqnarray",tagCells:new Map};(e==="eqnarray"||e.includes("eqalign"))&&(s.spacing=e==="eqnarray"?"0em 0.278em":"0.278em",s.rowspacing=".5em"),e==="cases"&&(s.spacing="1em",s.rowspacing=".2em"),this.frame(n,!1,r=>{(r.length||s.cells.length)&&(this.finishCell(s,r),s.rows.push(s.cells),this.tagRow(s)),s.rows.length>1&&s.bottom&&r.length&&(s.bottom=""),this.completeTable(s,e,i??(a=>this.append(a)))},e,s),this.f.display=s.display,s.latex&&(this.stream.skip(),this.startCell(s))}startCell(e){let n=e.plan.columns.filter(i=>i.insert===null)[e.cells.length];n?.before.length&&C(this.stream.peek()??[0,0,0,""])!==T.end&&this.stream.push(n.before)}finishCell(e,t){let i=e.plan.columns.filter(a=>a.insert===null)[e.cells.length];if(i?.after.length)if(w(i.after)==="\\hspace{.5em}")t.push(this.node(5,[],"",{width:".5em"}));else for(let a of i.after)N(a[0])||t.push(this.character(a));let s={};e.fill&&(s.columnalign=e.fill,e.fill="");let r=e.rows.length+":"+e.cells.length;if(e.cellBreak[r]&&(s["data-vertical-align"]=e.cellBreak[r]),i?.width&&i.width!=="auto"){let a=this.node(4,[],X(t));t=[this.node(18,[a],"",{"data-mjx-vbox":i.vertical||"top",width:i.width,"data-overflow":"auto","data-align":i.align,"data-vertical-align":i.vertical||"top"})]}if(e.colors){let a=e.colors.cell||(e.colors.rowIndex===e.rows.length?e.colors.row:"")||e.colors.columns[e.cells.length];a&&(s.mathbackground=a),e.colors.cell=""}e.cells.push(this.node(23,t,"",s))}completeTable(e,t,n){let i=e.plan.columns.map((o,l)=>({c:o,i:l})).filter(o=>o.c.insert!==null),s=0,r=0,a=()=>{for(;s<e.rows.length;){if(r===i.length){r=0,s++;continue}let{c:o,i:l}=i[r++];this.parseTokens(o.insert,c=>{let h=this.node(23,c.kind===6?c.children:[c]),f=e.rows[s][l];f&&!f.children.length&&f.attributes.columnalign&&(h.attributes.columnalign=f.attributes.columnalign,delete f.attributes.columnalign),e.rows[s].splice(l,0,h),a()});return}n(this.tableNode(e,t))};a()}tagTable(){for(let e=this.frames.length-1;e>=0;e--){let t=this.frames[e].table;if(t?.taggable)return t}}setLabel(e){if(e==="")return;let t=this.tagTable();if((t?t.labels[t.rows.length]:this.label)&&this.error("Multiple \\label"),(this.session.labels.has(e)||this.localLabels.has(e))&&!this.options.ignoreDuplicateLabels&&this.error(`Label '${e}' multiply defined`),this.localLabels.set(e,{tag:"???",id:""}),t){t.labels[t.rows.length]=e;let i=t.explicitTags?.get(t.rows.length);if(i!==void 0){let s=String(j(this,"id",(this.options.useLabelIds!==!1?e:"")||i));this.localLabels.set(e,{tag:i,id:s});let r=t.tagCells.get(t.rows.length);r&&(r.attributes.id=s)}}else this.label=e}reference(e,t=!1){let n=this.session.labels.get(e)??this.localLabels.get(e)??{tag:"???",id:""};this.append(this.node(6,t?z(this,n.tag,!1,!0):[this.node(4,[],n.tag)],"",{href:String(j(this,"url",n.id,this.options.baseURL??"")),class:"MathJax_ref"}))}tagRow(e){let t=e.rows.length-1;e.numbered&&!e.noNumbers.has(t)&&!e.tagCells.has(t)&&e.tagCells.set(t,this.labelCell(e.labels[t]??""))}labelCell(e,t,n=!1){let i=t??String(j(this,"number",++this.session.counter)),s=String(j(this,"id",(this.options.useLabelIds!==!1?e:"")||i));return e&&this.localLabels.set(e,{tag:i,id:s}),this.node(23,z(this,i,n),"",{id:s,...this.options.tagAlign&&this.options.tagAlign!=="baseline"?{rowalign:this.options.tagAlign}:{}})}tableNode(e,t){let n=e.plan.columns.map(h=>({left:"l",right:"r",center:"c"})[h.align]).join("")||"c",i={columnspacing:e.spacing,rowspacing:e.rowspacing,columnalign:Array.from(n,h=>({l:"left",c:"center",r:"right"})[h]).join(" ")};!["matrix","array","pmatrix","cases"].includes(t)||t==="array"&&e.align,i.displaystyle=String(e.display),(t==="matrix"||t==="pmatrix")&&(i.columnalign="center"),e.plan.columns.slice(1).some(h=>h.separator)&&(i.columnlines=e.plan.columns.slice(1).map(h=>h.separator==="|"?"solid":h.separator===":"?"dashed":"none").join(" ")),e.plan.columns.some(h=>h.width!=="auto")&&(i.columnwidth=e.plan.columns.map(h=>h.width).join(" ")),e.plan.columns.some(h=>h.insert)&&(i.columnspacing=e.plan.columns.slice(1).map((h,f)=>e.plan.columns[f].insert?e.plan.columns[f].gap:h.insert?h.gap:"1em").join(" "),e.plan.columns.at(-1)?.insert!==null&&(i.columnspacing+=" "+e.plan.columns.at(-1).gap),e.plan.padding&&(i["data-array-padding"]=e.plan.padding)),e.rowlines.slice(0,e.rows.length-1).some(Boolean)&&(i.rowlines=Array.from({length:e.rows.length-1},(h,f)=>e.rowlines[f]??"none").join(" ")),e.rowspaces.length&&(i.rowspacing=Array.from({length:Math.max(e.rows.length,e.rowspaces.length)},(h,f)=>e.rowspaces[f]??(e.rowspacingBase===void 0?"0.4em":e.rowspacingBase+"em")).join(" "));let s=e.plan.left,r=e.plan.right,a="";if(s==="|"&&r==="|"&&e.top==="solid"&&e.bottom==="solid"?a="solid":s===":"&&r===":"&&e.top==="solid"&&e.bottom==="solid"&&(a="dashed"),a&&(delete i["data-frame-styles"],i.frame=a,i.framespacing=e.latex?".5em .125em":".2em .125em"),e.position&&(i.align=e.position),t==="displaylines"&&(i.displaystyle="true",i.rowspacing=".5em"),t==="eqnarray"){let h=Math.max(...e.rows.map(f=>f.length));i.columnalign=Array.from({length:h},(f,p)=>["right","center","left"][p%3]).join(" "),i.columnspacing=Array.from({length:h-1},(f,p)=>p%2===0?"0em":"0.278em").join(" "),i["data-break-align"]=Array.from({length:h},(f,p)=>["bottom","middle","top"][p%3]).join(" "),i.rowspacing="3pt",e.tableBreak||delete i["data-break-align"]}i.columnalign==="center"&&delete i.columnalign,i.displaystyle==="false"&&delete i.displaystyle,(t==="array"||t==="matrix"||t==="pmatrix"||t==="cases")&&(i["data-frame-styles"]="",i.framespacing=e.latex?".5em .125em":".2em .125em"),t==="leqalignno"&&(i.side="left");let o=this.node(20,e.rows.map((h,f)=>{if(t==="eqnarray")for(let p=0;p<h.length;p++)p%3===1&&h.length===3&&h[p].children.unshift(this.node(1)),p%3===2&&(h[p].children=[this.node(16,h[p].children,"",{indentshift:".7em"})]);if(t==="eqalignno"||t==="leqalignno"){let p=h.pop()??this.node(23);return this.node(22,[p,...h])}return e.tagCells.has(f)?this.node(22,[e.tagCells.get(f),...h]):this.node(21,h,"",e.rowBreak[f]?{"data-break-align":e.rowBreak[f]}:{})}),"",i);o.children.some(h=>h.kind===22)&&(this.options.tagSide&&this.options.tagSide!=="right"&&(o.attributes.side=this.options.tagSide),this.options.tagIndent&&this.options.tagIndent!=="0.8em"&&(o.attributes.minlabelspacing=this.options.tagIndent));let l=o,c=[];if((s==="|"||s===":")&&c.push("left"),(r==="|"||r===":")&&c.push("right"),e.top&&c.push("top"),e.bottom&&c.push("bottom"),a==="solid"&&delete o.attributes["data-frame-styles"],a==="dashed"||s==="|"&&r===":"||s===":"&&r==="|")return delete o.attributes.frame,o.attributes["data-frame-styles"]=[e.top||"none",r===":"?"dashed":r==="|"?"solid":"none",e.bottom||"none",s===":"?"dashed":s==="|"?"solid":"none"].join(" "),o;if(c.length&&!a){let h=this.node(24,[o],"",{notation:c.join(" "),"data-padding":"0"});o.attributes.framespacing=e.latex?".5em .125em":".2em .125em",l=h}return t==="pmatrix"&&(l=this.atom([this.delimiterNode("(","","OPEN"),l,this.delimiterNode(")","","CLOSE")],"INNER")),t==="cases"&&(l=this.atom([this.delimiterNode("{","","OPEN"),l,this.delimiterNode("","","CLOSE")],"INNER")),l}run(){for(;this.frames.length;){for(;this.f?.single&&this.f.nodes.length;)this.close();if(!this.frames.length)break;let e=this.stream.next();if(!e){this.frames.length!==1&&this.error(this.f.missingMessage??(this.f.env==="argument"?"Missing close brace":this.f.env==="left"?"Extra \\left or missing \\right":this.f.env?`Missing \\end{${this.f.env}}`:"Extra open brace or missing close brace")),this.close();break}this.position=e[1];let t=e[0];if(t===0&&this.f.stop===-2){this.close();continue}if(t===this.f.stop){this.close();continue}let n=this.options.texOptions?.active?.[g(e)];if(t!==-1&&n!==void 0&&this.configuration.packages.some(a=>a.name==="configmacros")){this.expand(R(n));continue}if(N(t))continue;let i=t>0?this.characters?.get(t):void 0;if(i){let a=!1;for(let o of i)if(o.execute(this,e,o.definition,o.id)!==!1){a=!0;break}if(a)continue}switch(t){case 37:for(;this.stream.peek()&&![10,13].includes(this.stream.peek()[0]);)this.stream.next();this.stream.next();continue;case 123:this.frame(125,!1,a=>this.append(this.atom(a)));continue;case 125:this.error("Extra close brace or missing open brace");case 94:this.script(!0);continue;case 95:this.script(!1);continue;case 39:case 8217:this.script(!0,!0);continue;case 35:this.error("You can't use 'macro parameter character #' in math mode");case 38:{let a=this.f;if(a.table||this.error("Misplaced &"),this.finishCell(a.table,a.nodes),a.nodes=[],a.font=a.table.originalFont,a.env==="cases"&&!a.table.latex){a.table.cells.length>1&&this.error("Extra alignment tab in \\cases text");let o=[],l=0;for(;this.stream.peek();){let c=this.stream.peek();if(l===0&&(c[0]===125||C(c)===T.end||C(c)===T.cr||g(c)==="\\"&&c[0]===-1))break;c[0]===38&&l===0&&this.error("Extra alignment tab in \\cases text"),this.stream.next(),c[0]===123&&l++,c[0]===125&&l--,o.push(c)}for(;o.length&&N(o[0][0]);)o.shift();for(;o.length&&N(o.at(-1)[0]);)o.pop();C(o[0])===T.text?this.stream.push(o):this.renderText(o);continue}a.table.latex&&this.startCell(a.table);continue}case-5:{let a=g(e)==="<"?"\u27E8":g(e)===">"?"\u27E9":g(e),o=this.node(3,[],a,{fence:"false",stretchy:"false",..."|\u2016".includes(a)?{"data-mjx-texclass":"ORD"}:{}});o.rawAttrs=!0,this.append(o);continue}case 126:this.append(this.node(4,[],"\xA0"));continue;case-1:case-3:{let a=q(e),o=L[a],l=o?.name??g(e),c=t===-1&&this.macros.size?this.macros.get(l):void 0;if(c){this.currentCommand="\\"+l,this.expand(c);continue}let h=a<0?this.configuration.extensions.get(l):this.configuration.commands[a]??this.configuration.extensions.get(l);if(!h){let f=[...this.configuration.packages].reverse().find(p=>p.undefinedCommand)?.undefinedCommand;if(f){f(this,l);continue}this.error(`Undefined control sequence \\${l}`)}this.currentCommand="\\"+l,h.execute(this,e,h.definition,a);continue}}let s=this.configuration.characters.size?this.configuration.characters.get(g(e)):void 0;if(s){s.execute(this,e,s.definition,-1);continue}if(v(t)||this.options.numberPattern!==void 0&&(t===44||t===46)||t===(this.options.decimalSeparator===","?44:46)&&v(this.stream.peek()?.[0]??0)){this.append(this.number(e));continue}let r=this.character(e);if(this.f.multi&&r.kind===1&&S(t)){if(this.options.identifierPattern instanceof RegExp){let a=this.options.identifierPattern;a.lastIndex=e[1];let o=a.exec(e[3]);if(o&&o[0].length){let l=e[1]+o[0].length,c=e[2];for(;c<l;){let h=this.stream.peek();if(!h||h[3]!==e[3]||h[1]!==c)break;c=h[2],r.text+=g(this.stream.next())}}}else for(;this.stream.peek()&&S(this.stream.peek()[0]);)r.text+=g(this.stream.next());r.text.length>1&&r.attributes.mathvariant==="normal"&&(r.attributes["data-mjx-auto-op"]="false")}this.append(r)}this.numbered&&!this.hasTaggableEnvironment&&this.options.display&&(this.result=[this.node(20,[this.node(22,[this.labelCell(this.label),this.node(23,this.result)])],"",{displaystyle:"true",...this.options.tagSide&&this.options.tagSide!=="right"?{side:this.options.tagSide}:{},...this.options.tagIndent&&this.options.tagIndent!=="0.8em"?{minlabelspacing:this.options.tagIndent}:{}})]),this.envStack.length&&this.error(`Missing \\end{${this.envStack.at(-1)}}`);for(let[e,t]of this.localLabels)this.session.labels.set(e,t);return this.finish(this.result),U(this.node(0,this.result,"",{xmlns:te,...this.options.display&&!this.inline?{display:"block"}:{},...this.hsize?{maxwidth:this.hsize,overflow:"linebreak"}:{}}))}linebreak(){this.stream.peek()?.[0]===42&&this.stream.next();let e=this.stream.peek()?.[0]===91?this.optional():null;e&&!/^[+-]?(?:\d+(?:[.,]\d*)?|[.,]\d+)\s*(?:em|ex|pt|px|mu|cm|mm|in|pc)$/.test(w(e).trim())&&this.error("Bracket argument to \\\\ must be a dimension");let t=this.f;if(t.table){let n=t.table;this.finishCell(n,t.nodes),n.rows.push(n.cells),this.tagRow(n),n.cells=[],t.nodes=[],t.font=n.originalFont,e&&(n.rowspaces[n.rows.length-1]=n.rowspacingBase===void 0?Q(I(w(e))+.4):I(w(e))+n.rowspacingBase+"em"),n.latex&&this.startCell(n);return}this.append(this.node(5,[],"",{linebreak:"newline",...e?{"data-lineleading":w(e).replace(",",".")}:{}}))}decorationBase(e){if(e.kind===3&&e.limits>0)return e.attributes.movablelimits="false",e.limits=0,e;if((e.limits!==0||e.children[0]?.attributes.movablelimits==="false")&&[13,14,15].includes(e.kind)){let t=e.children[0];return t.attributes.lspace="0",t.attributes.rspace="0",this.row([this.node(3,[],"",{rspace:"0"}),e],!0)}return e}clean(e,t,n){if(e.rawAttrs)return;let i=e.attributes,s=e.kind===3?P(e.text,t===0&&n>1?"prefix":t===n-1&&n>1?"postfix":"infix")?.[3]??{}:{};if(e.kind===3&&i.stretchy==="true"&&s.stretchy&&delete i.stretchy,e.fixed&&(s.stretchy?i.stretchy="false":e.text!=="|"&&e.text!=="\u2016"&&delete i.stretchy),!e.rawAttrs&&e.kind===3)for(let r of["fence","largeop","movablelimits","symmetric","accent"])i[r]===String(s[r]??!1)&&delete i[r];i.mathvariant?.startsWith("-tex-")&&(i["data-mjx-variant"]=i.mathvariant,i.mathvariant=i.mathvariant.includes("calligraphic")?i.mathvariant.includes("bold")?"bold-script":"script":i.mathvariant==="-tex-oldstyle"?"normal":"italic"),i.mathvariant==="italic"&&e.kind===1&&Array.from(e.text).length===1&&!i["data-mjx-variant"]&&delete i.mathvariant,!e.rawAttrs&&!i["data-mjx-variant"]&&i.mathvariant==="normal"&&(e.kind===3||e.kind===2||e.kind===4||e.kind===1&&Array.from(e.text).length>1)&&delete i.mathvariant}functionArgument(e){if(e.kind===5||e.text==="\u2061"||e.kind===16&&e.children[0]?.kind===5)return!1;let t=e;for(;[10,11,12,13,14,15].includes(t.kind);)t=t.children[0];if(t.kind!==3)return!0;let n=t.attributes["data-mjx-texclass"],i=n?["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER"].indexOf(n):P(t.text)?.[2]??0;return![2,3,5,6].includes(i)}finish(e){let t=[{children:e,sequence:!0}];for(;t.length;){let{children:n,sequence:i}=t.pop();for(let s=0;s<n.length;s++){let r=n[s];if(r.children.length&&t.push({children:r.children,sequence:[0,6,23,16,18,8,19,24].includes(r.kind)}),this.clean(r,s,n.length),[10,11,12,13,14,15].includes(r.kind)&&(r.children[0].op=0),i&&r.op&&s+1<n.length&&(r.text||Y(r))){let a=n[s+1];this.functionArgument(a)&&n.splice(++s,0,this.node(3,[],"\u2061",{"data-mjx-texclass":"NONE"}))}if(i&&r.kind===3&&r.relation)for(;s+1<n.length;){let a=n[s+1];if(!a.relation)break;if(this.clean(a,s+1,n.length),!J(r.attributes,a.attributes)){r.attributes.rspace??="0pt",a.attributes.lspace??="0pt";break}a.attributes.stretchy==="false"&&(r.attributes.stretchy="false"),r.text+=a.text,r.attributes["data-mjx-texclass"]="REL",n.splice(s+1,1)}}}}};function ie(b,e,t,n){if(typeof b!="string")throw new TypeError("TeX input must be a string");let i;try{return i=new F(b,e,t,n),i.run()}catch(s){if(!(s instanceof M)&&!(s instanceof Error&&s.message==="Token limit exceeded")||e.throwOnError)throw s;let r=s.message;typeof e.texOptions?.formatError=="function"&&e.texOptions.formatError(null,s);let a=[...(i?.configuration??t).packages].reverse().find(o=>o.formatError)?.formatError;return{kind:"math",attributes:{xmlns:te,...e.display?{display:"block"}:{}},children:a?[a(r,b)]:[{kind:"merror",attributes:{"data-mjx-error":r},children:[{kind:"mtext",attributes:{},children:[],text:r,start:0}],text:"",start:0}],text:"",start:0}}}function le(b={}){let{options:e,configuration:t}=$(b),n=O(),i=(s,r={})=>{let a={...e,...r};return D(ie(s,a,t,n),a)};for(let s of e.prior??[])i(s.tex,{display:s.display??e.display});return{parse:i}}function Te(b,e={}){let t=$(e);return t.options.prior?.length?le(e).parse(b):D(ie(b,t.options,t.configuration,O()),t.options)}export{le as a,Te as b};