tex2typst 0.6.0 → 0.6.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/bun.lock +282 -0
- package/dist/index.js +87 -26
- package/dist/tex2typst.min.js +11 -11
- package/package.json +1 -1
- package/src/convert.ts +0 -19
- package/src/index.ts +3 -1
- package/src/{jslex.ts → lex.ts} +7 -2
- package/src/map.ts +0 -2
- package/src/tex-semantic-analysis.ts +39 -37
- package/src/tex-tokenizer.ts +2 -2
- package/src/typst-semantic-analyais.ts +38 -0
- package/src/typst-tokenizer.ts +2 -2
- package/src/typst-types.ts +55 -0
- package/dist/parser.js +0 -23
package/dist/tex2typst.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";(()=>{function
|
|
2
|
-
`));for(let t=0;t<r.length;t++){let
|
|
3
|
-
`)),e.push(new
|
|
4
|
-
`)-1):this._col+=l,
|
|
5
|
-
`)],[String.raw`\s+`,
|
|
6
|
-
`))&&
|
|
7
|
-
`)t.push(new i(1,
|
|
8
|
-
`),fe=new i(7," ");var ne=class{buffer="";queue=[];options;constructor(e){this.options=e}serialize(e){let r={insideFunctionDepth:0};this.queue.push(...e.serialize(r,this.options))}flushQueue(){let e=this.queue.filter(n=>n.value!==""),r=[];for(let n of e)n.eq(fe)&&r.length>0&&r[r.length-1].eq(fe)||r.push(n);let t=new i(1,"");for(let n=0;n<r.length;n++)r[n].eq(fe)&&(n===0||n===r.length-1||r[n-1].type===6||r[n-1].eq(Be)||r[n+1].eq(Be))&&(r[n]=t);for(let n of r)this.buffer+=n.toString();this.queue=[]}finalize(){this.flushQueue();let e=function(n){let o=n.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return o=o.replace(/floor\(\)/g,'floor("")'),o},r=function(n){let o=n.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return o=o.replace(/ceil\(\)/g,'ceil("")'),o},t=function(n){let o=n.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return o=o.replace(/round\(\)/g,'round("")'),o};if(this.options.optimize){let n=[e,r,t];for(let o of n)this.buffer=o(this.buffer)}return this.buffer=this.buffer.replace(/& =/g,"&="),this.buffer}};var x=new Map([["displaystyle","display"],["textstyle","inline"],["hspace","#h"],["|","bar.v.double"],[",","thin"],[":","med"],[" ","med"],[";","thick"],[">","med"],["~","space.nobreak"],["blacktriangleleft","triangle.filled.l"],["blacktriangleright","triangle.filled.r"],["clubsuit","suit.club.filled"],["hookleftarrow","arrow.l.hook"],["hookrightarrow","arrow.r.hook"],["leftrightarrow","arrow.l.r"],["lgblksquare","square.filled.big"],["lgwhtsquare","square.stroked.big"],["nearrow","arrow.tr"],["nwarrow","arrow.tl"],["searrow","arrow.br"],["swarrow","arrow.bl"],["spadesuit","suit.spade.filled"],["updownarrow","arrow.t.b"],["ln","ln"],["log","log"],["cos","cos"],["sin","sin"],["tan","tan"],["cot","cot"],["sec","sec"],["csc","csc"],["mod","mod"],["omicron","omicron"],["Xi","Xi"],["Upsilon","Upsilon"],["lim","lim"],["binom","binom"],["tilde","tilde"],["hat","hat"],["sqrt","sqrt"],["bmod","mod"],["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["cancel","cancel"],["operatorname","op"],["operatorname*","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathscr","scr"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["leadsto","arrow.r.squiggly"],["P","pilcrow"],["S","section"],["aleph","alef"],["infin","infinity"],["Delta","Delta"],["Gamma","Gamma"],["Lambda","Lambda"],["Omega","Omega"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Sigma","Sigma"],["Theta","Theta"],["alpha","alpha"],["beta","beta"],["bigcirc","circle.big"],["bullet","bullet"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","chevron.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","partial"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","chevron.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["intop","limits(integral)"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),lt=new Map([["acwopencirclearrow","arrow.ccw"],["adots","dots.up"],["angdnr","angle.acute"],["angle","angle"],["angles","angle.s"],["approx","approx"],["approxeq","approx.eq"],["approxident","tilde.triple"],["assert","tack.r.short"],["ast","ast.op"],["astrosun","sun"],["asymp","asymp"],["awint","integral.ccw"],["backcong","tilde.rev.equiv"],["backdprime","prime.double.rev"],["backprime","prime.rev"],["backsim","tilde.rev"],["backsimeq","tilde.eq.rev"],["backslash","backslash"],["backtrprime","prime.triple.rev"],["bardownharpoonleft","harpoon.bl.bar"],["bardownharpoonright","harpoon.br.bar"],["barleftarrow","arrow.l.stop"],["barleftarrowrightarrowbar","arrows.lr.stop"],["barleftharpoondown","harpoon.lb.stop"],["barleftharpoonup","harpoon.lt.stop"],["barrightharpoondown","harpoon.rb.bar"],["barrightharpoonup","harpoon.rt.bar"],["baruparrow","arrow.t.stop"],["barupharpoonleft","harpoon.tl.stop"],["barupharpoonright","harpoon.tr.stop"],["barV","tack.b.double"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["because","because"],["bigblacktriangledown","triangle.filled.b"],["bigblacktriangleup","triangle.filled.t"],["bigbot","tack.t.big"],["bigcap","inter.big"],["bigcup","union.big"],["bigcupdot","union.dot.big"],["biginterleave","interleave.big"],["bigodot","dot.o.big"],["bigoplus","plus.o.big"],["bigotimes","times.o.big"],["bigsqcap","inter.sq.big"],["bigsqcup","union.sq.big"],["bigstar","star.filled"],["bigtimes","times.big"],["bigtop","tack.b.big"],["bigtriangledown","triangle.stroked.b"],["bigtriangleup","triangle.stroked.t"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bigwhitestar","star.stroked"],["blackhourglass","hourglass.filled"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bot","bot"],["boxast","ast.square"],["boxdot","dot.square"],["boxminus","minus.square"],["boxplus","plus.square"],["boxtimes","times.square"],["cap","inter"],["Cap","inter.double"],["capdot","inter.dot"],["capwedge","inter.and"],["caretinsert","caret"],["cdot","dot.op"],["cdotp","dot.c"],["checkmark","checkmark"],["circledast","ast.op.o"],["circledbullet","bullet.o"],["circledcirc","compose.o"],["circleddash","dash.o"],["circledequal","cc.nd"],["circledparallel","parallel.o"],["circledvert","bar.v.o"],["circledwhitebullet","bullet.stroked.o"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["complement","complement"],["cong","tilde.equiv"],["coprod","product.co"],["cup","union"],["Cup","union.double"],["cupdot","union.dot"],["cupleftarrow","union.arrow"],["cupvee","union.or"],["curlyeqprec","eq.prec"],["curlyeqsucc","eq.succ"],["curlyvee","or.curly"],["curlywedge","and.curly"],["curvearrowleft","arrow.ccw.half"],["curvearrowright","arrow.cw.half"],["cwopencirclearrow","arrow.cw"],["dagger","dagger"],["dashcolon","dash.colon"],["dashv","tack.l"],["Dashv","tack.l.double"],["dashVdash","tack.l.r"],["ddagger","dagger.double"],["ddddot","dot.quad"],["dddot","dot.triple"],["ddots","dots.down"],["DDownarrow","arrow.b.quad"],["Ddownarrow","arrow.b.triple"],["diameter","diameter"],["diamondcdot","diamond.stroked.dot"],["diamondsuit","suit.diamond.stroked"],["dicei","die.one"],["diceii","die.two"],["diceiii","die.three"],["diceiv","die.four"],["dicev","die.five"],["dicevi","die.six"],["div","div"],["divideontimes","times.div"],["Doteq","eq.dots"],["dotminus","minus.dot"],["dotplus","plus.dot"],["dotsim","tilde.dot"],["dottedcircle","circle.dotted"],["dottedsquare","square.stroked.dotted"],["doubleplus","plus.double"],["downarrow","arrow.b"],["Downarrow","arrow.b.double"],["downarrowbar","arrow.b.stop"],["downarrowbarred","arrow.b.struck"],["downdasharrow","arrow.b.dashed"],["downdownarrows","arrows.bb"],["downharpoonleft","harpoon.bl"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["downharpoonrightbar","harpoon.br.stop"],["downharpoonsleftright","harpoons.blbr"],["downuparrows","arrows.bt"],["downupharpoonsleftright","harpoons.bltr"],["downwhitearrow","arrow.b.stroked"],["downzigzagarrow","arrow.zigzag"],["dprime","prime.double"],["dualmap","multimap.double"],["eighthnote","note.eighth.alt"],["ell","ell"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["eparsl","parallel.slanted.eq"],["eqcolon","eq.colon"],["eqdef","eq.def"],["eqgtr","eq.gt"],["eqless","eq.lt"],["eqsim","minus.tilde"],["equal","eq"],["equalparallel","parallel.eq"],["equiv","eq.triple"],["Equiv","eq.quad"],["equivVert","parallel.equiv"],["eqvparsl","parallel.slanted.equiv"],["errbarblackcircle","errorbar.circle.filled"],["errbarblackdiamond","errorbar.diamond.filled"],["errbarblacksquare","errorbar.square.filled"],["errbarcircle","errorbar.circle.stroked"],["errbardiamond","errorbar.diamond.stroked"],["errbarsquare","errorbar.square.stroked"],["euro","euro"],["exists","exists"],["fallingdotseq","eq.dots.down"],["fint","integral.slash"],["flat","flat"],["forall","forall"],["fourvdots","fence.dotted"],["frown","frown"],["fullouterjoin","join.l.r"],["geq","gt.eq"],["geqq","gt.equiv"],["geqslant","gt.eq.slant"],["gg","gt.double"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["gnapprox","gt.napprox"],["gneq","gt.neq"],["gneqq","gt.nequiv"],["gnsim","gt.ntilde"],["greater","gt"],["gtlpar","angle.spheric.rev"],["gtrapprox","gt.approx"],["gtrdot","gt.dot"],["gtreqless","gt.eq.lt"],["gtrless","gt.lt"],["gtrsim","gt.tilde"],["heartsuit","suit.heart.stroked"],["hknearrow","arrow.tr.hook"],["hknwarrow","arrow.tl.hook"],["hksearrow","arrow.br.hook"],["hkswarrow","arrow.bl.hook"],["horizbar","bar.h"],["hourglass","hourglass.stroked"],["hrectangle","rect.stroked.h"],["hrectangleblack","rect.filled.h"],["hyphenbullet","bullet.hyph"],["iiiint","integral.quad"],["iiint","integral.triple"],["iinfin","infinity.incomplete"],["iint","integral.double"],["Im","Im"],["imageof","image"],["in","in"],["increment","laplace"],["infty","infinity"],["int","integral"],["intbar","integral.dash"],["intBar","integral.dash.double"],["intcap","integral.inter"],["intclockwise","integral.cw"],["intcup","integral.union"],["interleave","interleave"],["intlarhk","integral.arrow.hook"],["intx","integral.times"],["inversebullet","bullet.hole"],["Join","join"],["langle","chevron.l"],["lAngle","chevron.l.double"],["langledot","chevron.l.dot"],["lat","lat"],["late","lat.eq"],["lbag","bag.l"],["lblkbrbrak","shell.l.filled"],["lbrace","brace.l"],["lBrace","brace.l.stroked"],["lbrack","bracket.l"],["lBrack","bracket.l.stroked"],["lbracklltick","bracket.l.tick.b"],["lbrackultick","bracket.l.tick.t"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.stroked"],["lceil","ceil.l"],["lcurvyangle","chevron.l.curly"],["leftarrow","arrow.l"],["Leftarrow","arrow.l.double"],["leftarrowtail","arrow.l.tail"],["leftarrowtriangle","arrow.l.open"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["leftdowncurvedarrow","arrow.l.curve"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["leftharpoonsupdown","harpoons.ltlb"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["leftleftarrows","arrows.ll"],["leftouterjoin","join.l"],["Leftrightarrow","arrow.l.r.double"],["leftrightarrows","arrows.lr"],["leftrightarrowtriangle","arrow.l.r.open"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsdown","harpoons.lbrb"],["leftrightharpoonsup","harpoons.ltrt"],["leftrightharpoonupdown","harpoon.lt.rb"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightsquigarrow","arrow.l.r.wave"],["leftsquigarrow","arrow.l.squiggly"],["leftthreearrows","arrows.lll"],["leftthreetimes","times.three.l"],["leftwavearrow","arrow.l.wave"],["leftwhitearrow","arrow.l.stroked"],["leq","lt.eq"],["leqq","lt.equiv"],["leqslant","lt.eq.slant"],["less","lt"],["lessapprox","lt.approx"],["lessdot","lt.dot"],["lesseqgtr","lt.eq.gt"],["lessgtr","lt.gt"],["lesssim","lt.tilde"],["lfloor","floor.l"],["lgblkcircle","circle.filled.big"],["lgroup","paren.l.flat"],["lgwhtcircle","circle.stroked.big"],["ll","lt.double"],["llangle","chevron.l.closed"],["llblacktriangle","triangle.filled.bl"],["llcorner","corner.l.b"],["LLeftarrow","arrow.l.quad"],["Lleftarrow","arrow.l.triple"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["llparenthesis","paren.l.closed"],["lltriangle","triangle.stroked.bl"],["lmoustache","mustache.l"],["lnapprox","lt.napprox"],["lneq","lt.neq"],["lneqq","lt.nequiv"],["lnsim","lt.ntilde"],["longdashv","tack.l.long"],["Longleftarrow","arrow.l.double.long"],["longleftarrow","arrow.l.long"],["Longleftrightarrow","arrow.l.r.double.long"],["longleftrightarrow","arrow.l.r.long"],["longleftsquigarrow","arrow.l.long.squiggly"],["Longmapsfrom","arrow.l.double.long.bar"],["longmapsfrom","arrow.l.long.bar"],["longmapsto","arrow.r.long.bar"],["Longmapsto","arrow.r.double.long.bar"],["Longrightarrow","arrow.r.double.long"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowleft","arrow.l.loop"],["looparrowright","arrow.r.loop"],["lparen","paren.l"],["lParen","paren.l.stroked"],["lrblacktriangle","triangle.filled.br"],["lrcorner","corner.r.b"],["lrtriangle","triangle.stroked.br"],["ltimes","times.l"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["maltese","maltese"],["mapsdown","arrow.b.bar"],["mapsfrom","arrow.l.bar"],["Mapsfrom","arrow.l.double.bar"],["mapsto","arrow.r.bar"],["Mapsto","arrow.r.double.bar"],["mapsup","arrow.t.bar"],["mathampersand","amp"],["mathatsign","at"],["mathcolon","colon"],["mathcomma","comma"],["mathdollar","dollar"],["mathexclam","excl"],["mathhyphen","hyph"],["mathparagraph","pilcrow"],["mathpercent","percent"],["mathperiod","dot.basic"],["mathplus","plus"],["mathquestion","quest"],["mathratio","ratio"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["mathsterling","pound"],["mathyen","yen"],["mdblkdiamond","diamond.filled.medium"],["mdblklozenge","lozenge.filled.medium"],["mdlgblkcircle","circle.filled"],["mdlgblkdiamond","diamond.filled"],["mdlgblklozenge","lozenge.filled"],["mdlgblksquare","square.filled"],["mdlgwhtcircle","circle.stroked"],["mdlgwhtdiamond","diamond.stroked"],["mdlgwhtlozenge","lozenge.stroked"],["mdlgwhtsquare","square.stroked"],["mdsmblkcircle","circle.filled.tiny"],["mdsmwhtcircle","circle.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["mdwhtlozenge","lozenge.stroked.medium"],["measeq","eq.m"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["measuredrightangle","angle.right.arc"],["mho","Omega.inv"],["mid","divides"],["minus","minus"],["models","models"],["mp","minus.plus"],["multimap","multimap"],["nabla","gradient"],["napprox","approx.not"],["nasymp","asymp.not"],["natural","natural"],["ncong","tilde.equiv.not"],["ne","eq.not"],["Nearrow","arrow.tr.double"],["neg","not"],["nequiv","equiv.not"],["neswarrow","arrow.tr.bl"],["nexists","exists.not"],["ngeq","gt.eq.not"],["ngtr","gt.not"],["ngtrless","gt.lt.not"],["ngtrsim","gt.tilde.not"],["nHdownarrow","arrow.b.dstruck"],["nhpar","parallel.struck"],["nHuparrow","arrow.t.dstruck"],["nhVvert","interleave.struck"],["ni","in.rev"],["nLeftarrow","arrow.l.double.not"],["nleftarrow","arrow.l.not"],["nLeftrightarrow","arrow.l.r.double.not"],["nleftrightarrow","arrow.l.r.not"],["nleq","lt.eq.not"],["nless","lt.not"],["nlessgtr","lt.gt.not"],["nlesssim","lt.tilde.not"],["nmid","divides.not"],["nni","in.rev.not"],["notin","in.not"],["nparallel","parallel.not"],["nprec","prec.not"],["npreccurlyeq","prec.curly.eq.not"],["nRightarrow","arrow.r.double.not"],["nrightarrow","arrow.r.not"],["nsim","tilde.not"],["nsimeq","tilde.eq.not"],["nsqsubseteq","subset.eq.sq.not"],["nsqsupseteq","supset.eq.sq.not"],["nsubset","subset.not"],["nsubseteq","subset.eq.not"],["nsucc","succ.not"],["nsucccurlyeq","succ.curly.eq.not"],["nsupset","supset.not"],["nsupseteq","supset.eq.not"],["ntrianglelefteq","lt.tri.eq.not"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["nvartriangleright","gt.tri.not"],["nVdash","forces.not"],["nvdash","tack.r.not"],["nvDash","tack.r.double.not"],["nvinfty","infinity.bar"],["nvLeftarrow","arrow.l.double.struck"],["nvleftarrow","arrow.l.struck"],["nVleftarrow","arrow.l.dstruck"],["nvleftarrowtail","arrow.l.tail.struck"],["nVleftarrowtail","arrow.l.tail.dstruck"],["nvLeftrightarrow","arrow.l.r.double.struck"],["nvleftrightarrow","arrow.l.r.struck"],["nVleftrightarrow","arrow.l.r.dstruck"],["nvRightarrow","arrow.r.double.struck"],["nvrightarrow","arrow.r.struck"],["nVrightarrow","arrow.r.dstruck"],["nvrightarrowtail","arrow.r.tail.struck"],["nVrightarrowtail","arrow.r.tail.dstruck"],["nvtwoheadleftarrow","arrow.l.twohead.struck"],["nVtwoheadleftarrow","arrow.l.twohead.dstruck"],["nvtwoheadleftarrowtail","arrow.l.twohead.tail.struck"],["nVtwoheadleftarrowtail","arrow.l.twohead.tail.dstruck"],["nvtwoheadrightarrow","arrow.r.twohead.struck"],["nVtwoheadrightarrow","arrow.r.twohead.dstruck"],["nvtwoheadrightarrowtail","arrow.r.twohead.tail.struck"],["nVtwoheadrightarrowtail","arrow.r.twohead.tail.dstruck"],["Nwarrow","arrow.tl.double"],["nwsearrow","arrow.tl.br"],["obrbrak","shell.t"],["obslash","backslash.o"],["odiv","div.o"],["odot","dot.o"],["odotslashdot","div.slanted.o"],["ogreaterthan","gt.o"],["oiiint","integral.vol"],["oiint","integral.surf"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["olessthan","lt.o"],["ominus","minus.o"],["operp","perp.o"],["oplus","plus.o"],["opluslhrim","plus.o.l"],["oplusrhrim","plus.o.r"],["origof","original"],["oslash","slash.o"],["otimes","times.o"],["otimeshat","times.o.hat"],["otimeslhrim","times.o.l"],["otimesrhrim","times.o.r"],["parallel","parallel"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["parsim","parallel.tilde"],["partial","partial"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["perp","perp"],["pm","plus.minus"],["prec","prec"],["Prec","prec.double"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["prime","prime"],["prod","product"],["propto","prop"],["QED","qed"],["qprime","prime.quad"],["quarternote","note.quarter.alt"],["questeq","eq.quest"],["Question","quest.double"],["rangle","chevron.r"],["rAngle","chevron.r.double"],["rangledot","chevron.r.dot"],["rangledownzigzagarrow","angle.azimuth"],["rbag","bag.r"],["rblkbrbrak","shell.r.filled"],["rbrace","brace.r"],["rBrace","brace.r.stroked"],["rbrack","bracket.r"],["rBrack","bracket.r.stroked"],["rbracklrtick","bracket.r.tick.b"],["rbrackurtick","bracket.r.tick.t"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.stroked"],["rceil","ceil.r"],["rcurvyangle","chevron.r.curly"],["Re","Re"],["revangle","angle.rev"],["revemptyset","emptyset.rev"],["revnmid","divides.not.rev"],["rfloor","floor.r"],["rgroup","paren.r.flat"],["rightangle","angle.right"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.square"],["rightarrow","arrow.r"],["Rightarrow","arrow.r.double"],["rightarrowbar","arrow.r.stop"],["rightarrowonoplus","plus.o.arrow"],["rightarrowtail","arrow.r.tail"],["rightarrowtriangle","arrow.r.open"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["rightdowncurvedarrow","arrow.r.curve"],["rightharpoondown","harpoon.rb"],["rightharpoondownbar","harpoon.rb.stop"],["rightharpoonsupdown","harpoons.rtrb"],["rightharpoonup","harpoon.rt"],["rightharpoonupbar","harpoon.rt.stop"],["rightleftarrows","arrows.rl"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoonsup","harpoons.rtlt"],["rightouterjoin","join.r"],["rightrightarrows","arrows.rr"],["rightsquigarrow","arrow.r.squiggly"],["rightthreearrows","arrows.rrr"],["rightthreetimes","times.three.r"],["rightwavearrow","arrow.r.wave"],["rightwhitearrow","arrow.r.stroked"],["risingdotseq","eq.dots.up"],["rmoustache","mustache.r"],["rparen","paren.r"],["rParen","paren.r.stroked"],["rrangle","chevron.r.closed"],["RRightarrow","arrow.r.quad"],["Rrightarrow","arrow.r.triple"],["rrparenthesis","paren.r.closed"],["rsolbar","backslash.not"],["rtimes","times.r"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["Searrow","arrow.br.double"],["setminus","without"],["sharp","sharp"],["shortdowntack","tack.b.short"],["shortlefttack","tack.l.short"],["shortuptack","tack.t.short"],["sim","tilde.op"],["sime","tilde.eq"],["similarleftarrow","arrow.l.tilde"],["similarrightarrow","arrow.r.tilde"],["simneqq","tilde.nequiv"],["smallblacktriangleleft","triangle.filled.small.l"],["smallblacktriangleright","triangle.filled.small.r"],["smallin","in.small"],["smallni","in.rev.small"],["smalltriangleleft","triangle.stroked.small.l"],["smalltriangleright","triangle.stroked.small.r"],["smashtimes","smash"],["smblkcircle","bullet"],["smblkdiamond","diamond.filled.small"],["smblklozenge","lozenge.filled.small"],["smeparsl","parallel.slanted.eq.tilde"],["smile","smile"],["smt","smt"],["smte","smt.eq"],["smwhtcircle","bullet.stroked"],["smwhtdiamond","diamond.stroked.small"],["smwhtlozenge","lozenge.stroked.small"],["sphericalangle","angle.spheric"],["sphericalangleup","angle.spheric.t"],["sqcap","inter.sq"],["Sqcap","inter.sq.double"],["sqcup","union.sq"],["Sqcup","union.sq.double"],["sqint","integral.square"],["sqsubset","subset.sq"],["sqsubseteq","subset.eq.sq"],["sqsubsetneq","subset.sq.neq"],["sqsupset","supset.sq"],["sqsupseteq","supset.eq.sq"],["sqsupsetneq","supset.sq.neq"],["squoval","square.stroked.rounded"],["sslash","slash.double"],["star","star.op"],["stareq","eq.star"],["subset","subset"],["Subset","subset.double"],["subsetdot","subset.dot"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["Succ","succ.double"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["sum","sum"],["sumint","sum.integral"],["supset","supset"],["Supset","supset.double"],["supsetdot","supset.dot"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["Swarrow","arrow.bl.double"],["therefore","therefore"],["threedangle","angle.spatial"],["threedotcolon","colon.tri.op"],["tieinfty","infinity.tie"],["times","times"],["tminus","miny"],["top","tack.b"],["tplus","tiny"],["trianglecdot","triangle.stroked.dot"],["triangledown","triangle.stroked.small.b"],["triangleleft","triangle.stroked.l"],["trianglelefteq","lt.tri.eq"],["triangleminus","minus.triangle"],["triangleplus","plus.triangle"],["triangleq","eq.delta"],["triangleright","triangle.stroked.r"],["trianglerighteq","gt.tri.eq"],["triangletimes","times.triangle"],["tripleplus","plus.triple"],["trprime","prime.triple"],["trslash","slash.triple"],["turnediota","iota.inv"],["twoheaddownarrow","arrow.b.twohead"],["twoheadleftarrow","arrow.l.twohead"],["twoheadleftarrowtail","arrow.l.twohead.tail"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["twoheadrightarrowtail","arrow.r.twohead.tail"],["twoheaduparrow","arrow.t.twohead"],["twonotes","note.eighth.beamed"],["ubrbrak","shell.b"],["ulblacktriangle","triangle.filled.tl"],["ulcorner","corner.l.t"],["ultriangle","triangle.stroked.tl"],["uminus","union.minus"],["underbrace","brace.b"],["underbracket","bracket.b"],["underparen","paren.b"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["upand","amp.inv"],["uparrow","arrow.t"],["Uparrow","arrow.t.double"],["uparrowbarred","arrow.t.struck"],["upbackepsilon","epsilon.alt.rev"],["updasharrow","arrow.t.dashed"],["upDigamma","Digamma"],["updigamma","digamma"],["Updownarrow","arrow.t.b.double"],["updownarrows","arrows.tb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["upharpoonsleftright","harpoons.tltr"],["uplus","union.plus"],["upuparrows","arrows.tt"],["upwhitearrow","arrow.t.stroked"],["urblacktriangle","triangle.filled.tr"],["urcorner","corner.r.t"],["urtriangle","triangle.stroked.tr"],["UUparrow","arrow.t.quad"],["Uuparrow","arrow.t.triple"],["varclubsuit","suit.club.stroked"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["varnothing","emptyset"],["varointclockwise","integral.cont.cw"],["varspadesuit","suit.spade.stroked"],["vartriangle","triangle.stroked.small.t"],["vartriangleleft","lt.tri"],["vartriangleright","gt.tri"],["Vbar","tack.t.double"],["Vdash","forces"],["vdash","tack.r"],["vDash","tack.r.double"],["vdots","dots.v"],["vee","or"],["Vee","or.double"],["veedot","or.dot"],["veeeq","eq.equi"],["vert","bar.v"],["Vert","bar.v.double"],["vlongdash","tack.r.long"],["vrectangle","rect.stroked.v"],["vrectangleblack","rect.filled.v"],["Vvert","bar.v.triple"],["vysmblkcircle","circle.filled.small"],["vysmwhtcircle","circle.stroked.tiny"],["wedge","and"],["Wedge","and.double"],["wedgedot","and.dot"],["wedgeq","eq.est"],["whiteinwhitetriangle","triangle.stroked.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["wideangledown","angle.obtuse"],["wr","wreath"],["xsol","slash.big"]]),ut=new Map([["gets","leftarrow"],["iff","Longleftrightarrow"],["implies","Longrightarrow"]]);for(let[s,e]of lt)x.has(s)||x.set(s,e);var P=new Map;for(let[s,e]of Array.from(x.entries()).reverse())P.set(e,s);P.set("oo","infty");var pt=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["infinity","infty"],["diff","partial"]]);for(let[s,e]of pt)P.set(s,e);for(let[s,e]of ut)x.has(s)||x.set(s,x.get(e));var z=class extends Error{node;constructor(e,r=null){super(e),this.name="ConverterError",this.node=r}},ct=i.NONE.toNode(),ht=["dim","id","im","mod","Pr","sech","csch"];function dt(s){if(/^[a-zA-Z0-9]$/.test(s))return s;if(s==="/")return"\\/";if(["\\\\","\\{","\\}","\\%"].includes(s))return s.substring(1);if(["\\$","\\#","\\&","\\_"].includes(s))return s;if(s.startsWith("\\")){let e=s.slice(1);return x.has(e)?x.get(e):null}return s}function Y(s,e){let r;switch(s.type){case 0:return i.NONE;case 2:r=1;break;case 1:r=2;break;case 3:r=3;break;case 4:r=5;break;case 5:r=6;break;case 6:r=8;break;case 7:{if(s.value==="\\\\")return new i(7,"\\");if(s.value==="\\!")return new i(1,"#h(-math.thin.amount)");if(s.value==="~"){let n=x.get("~");return new i(1,n)}else if(x.has(s.value.substring(1))){let n=x.get(s.value.substring(1));return new i(1,n)}else throw new Error(`Unknown control sequence: ${s.value}`)}default:throw Error(`Unknown token type: ${s.type}`)}let t=dt(s.value);if(t===null){if(e.nonStrict)return new i(r,s.value.substring(1));throw new z(`Unknown token: ${s.value}`,s)}return new i(r,t)}function Tt(s,e){let[r,t]=s.args;if(e.optimize&&["\\overset{\\text{def}}{=}","\\overset{d e f}{=}"].includes(s.toString()))return new i(1,"eq.def").toNode();let n=new m(new i(1,"limits"),[b(t,e)]);return new O({base:n,sup:b(r,e),sub:null})}function gt(s,e){let[r,t]=s.args,n=new m(new i(1,"limits"),[b(t,e)]);return new O({base:n,sub:b(r,e),sup:null})}function wt(s){let e={},r={l:"#left",c:"#center",r:"#right"},t=Array.from(s),n=[],o=0;for(let l of t)l==="|"?n.push(o):(l==="l"||l==="c"||l==="r")&&o++;if(n.length>0){let l;n.length===1?l=`#${n[0]}`:l=`#(vline: (${n.join(", ")}))`,e.augment=new i(3,l).toNode()}let a=t.map(l=>r[l]).filter(l=>l!==void 0).map(l=>new i(3,l).toNode());if(a.length>0){let l=a.every(p=>p.eq(a[0]));e.align=l?a[0]:new i(3,"#center").toNode()}return e}var bt=new i(2,"("),mt=new i(2,")");function Ee(s){return["group","supsub","matrixLike","fraction","empty"].includes(s.type)?new f(null,{left:bt,right:mt,body:s}):s}function b(s,e){switch(s.type){case"terminal":return Y(s.head,e).toNode();case"text":{let n=s;return new i(4,n.head.value).toNode()}case"ordgroup":let t=s;return new L(t.items.map(n=>b(n,e)));case"supsub":{let n=s,{base:o,sup:a,sub:l}=n;if(o&&o.type==="funcCall"&&o.head.value==="\\overbrace"&&a)return new m(new i(1,"overbrace"),[b(o.args[0],e),b(a,e)]);if(o&&o.type==="funcCall"&&o.head.value==="\\underbrace"&&l)return new m(new i(1,"underbrace"),[b(o.args[0],e),b(l,e)]);let p={base:b(o,e),sup:a?b(a,e):null,sub:l?b(l,e):null};return p.sup&&(p.sup=Ee(p.sup)),p.sub&&(p.sub=Ee(p.sub)),new O(p)}case"leftright":{let n=s,{left:o,right:a}=n,l=b(n.body,e);if(e.optimize&&o!==null&&a!==null){let d=Y(o,e),v=Y(a,e);if(o.value==="\\|"&&a.value==="\\|")return new m(new i(1,"norm"),[l]);if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(o.value+a.value))return new L([d.toNode(),l,v.toNode()])}let p=function(d){return["(",")","{","["].includes(d.value)?new i(2,"\\"+d.value):d},c=o?Y(o,e):null,h=a?Y(a,e):null;return c&&c.value==="<"&&(c=new i(1,"chevron.l")),h&&h.value===">"&&(h=new i(1,"chevron.r")),c===null&&h!==null&&(h=p(h)),h===null&&c!==null&&(c=p(c)),new f(i.LR,{body:l,left:c,right:h})}case"funcCall":{let n=s,o=b(n.args[0],e);if(n.head.value==="\\sqrt"&&n.data){let a=b(n.data,e);return new m(new i(1,"root"),[a,o])}if(n.head.value==="\\mathbf"){let a=new m(new i(1,"bold"),[o]);return new m(new i(1,"upright"),[a])}if(n.head.value==="\\overrightarrow")return new m(new i(1,"arrow"),[o]);if(n.head.value==="\\overleftarrow")return new m(new i(1,"accent"),[o,new i(1,"arrow.l").toNode()]);if(n.head.value==="\\operatorname"||n.head.value==="\\operatorname*"){if(e.optimize&&ht.includes(o.head.value))return new i(1,o.head.value).toNode();let a=new m(new i(1,"op"),[new i(4,o.head.value).toNode()]);return n.head.value==="\\operatorname*"&&a.setOptions({limits:new i(3,"#true").toNode()}),a}if(n.head.value==="\\textcolor"){let a=new D(new i(1,"#text"),[b(n.args[1],e)]);return a.setOptions({fill:o}),a}if(n.head.value==="\\substack"||n.head.value==="\\displaylines"||n.head.value==="\\mathinner")return o;if(n.head.value==="\\mathrel")return new m(new i(1,"class"),[new i(4,"relation").toNode(),o]);if(n.head.value==="\\mathbin")return new m(new i(1,"class"),[new i(4,"binary").toNode(),o]);if(n.head.value==="\\mathop")return new m(new i(1,"class"),[new i(4,"large").toNode(),o]);if(n.head.value==="\\not"){let a=b(n.args[0],e);if(T(a.type==="terminal"),a.head.type===1)return new i(1,a.head.value+".not").toNode();switch(a.head.value){case"=":return new i(1,"eq.not").toNode();default:throw new Error(`Not supported: \\not ${a.head.value}`)}}if(n.head.value==="\\pmod"){let a=new L([new i(1,"mod").toNode(),o]);return new f(null,{body:a,left:i.LEFT_PAREN,right:i.RIGHT_PAREN})}if(n.head.value==="\\overset")return Tt(n,e);if(n.head.value==="\\underset")return gt(n,e);if(["\\bra","\\ket","\\braket","\\set","\\Bra","\\Ket","\\Braket","\\Set"].includes(n.head.value)){let a=function(l,p){let c=new m(new i(1,"mid"),[i.VERTICAL_BAR.toNode()]);if(l.type==="terminal"&&l.head.eq(i.VERTICAL_BAR))return c;if(l.type==="group"){let h=l;for(let d=0;d<h.items.length&&!(h.items[d].type==="terminal"&&h.items[d].head.eq(i.VERTICAL_BAR)&&(h.items[d]=c,p));d++);return h}else return l};var r=a;switch(n.head.value){case"\\bra":return new f(null,{body:o,left:i.LEFT_ANGLE,right:i.VERTICAL_BAR});case"\\ket":return new f(null,{body:o,left:i.VERTICAL_BAR,right:i.RIGHT_ANGLE});case"\\braket":return new f(null,{body:o,left:i.LEFT_ANGLE,right:i.RIGHT_ANGLE});case"\\set":return new f(null,{body:o,left:i.LEFT_BRACE,right:i.RIGHT_BRACE});case"\\Bra":return new f(i.LR,{body:o,left:i.LEFT_ANGLE,right:i.VERTICAL_BAR});case"\\Ket":return new f(i.LR,{body:o,left:i.VERTICAL_BAR,right:i.RIGHT_ANGLE});case"\\Braket":return new f(i.LR,{body:a(o,!1),left:i.LEFT_ANGLE,right:i.RIGHT_ANGLE});case"\\Set":return new f(i.LR,{body:a(o,!0),left:i.LEFT_BRACE,right:i.RIGHT_BRACE});default:}}if(n.head.value==="\\frac"&&e.fracToSlash)return new B(n.args.map(a=>b(a,e)).map(Ee));if(e.optimize){if(n.head.value==="\\mathbb"&&/^\\mathbb{[A-Z]}$/.test(n.toString()))return new i(1,o.head.value.repeat(2)).toNode();if(n.head.value==="\\mathrm"&&n.toString()==="\\mathrm{d}")return new i(1,"dif").toNode()}return new m(Y(n.head,e),n.args.map(a=>b(a,e)))}case"beginend":{let n=s,o=n.matrix.map(a=>a.map(l=>b(l,e)));if(n.head.value.startsWith("align"))return new E(null,o);if(n.head.value==="cases")return new E(E.CASES,o);if(n.head.value==="subarray"){if(n.data)switch(n.data.head.value){case"r":o.forEach(l=>l.push(i.EMPTY.toNode()));break;case"l":o.forEach(l=>l.unshift(i.EMPTY.toNode()));break;default:break}return new E(null,o)}if(n.head.value==="array"){let a={delim:ct};T(n.data!==null&&n.head.type===3);let l=wt(n.data.head.value);Object.assign(a,l);let p=new E(E.MAT,o);return p.setOptions(a),p}if(n.head.value.endsWith("matrix")){let a=new E(E.MAT,o),l;switch(n.head.value){case"matrix":l=i.NONE;break;case"pmatrix":return a;case"bmatrix":l=new i(4,"[");break;case"Bmatrix":l=new i(4,"{");break;case"vmatrix":l=new i(4,"|");break;case"Vmatrix":{l=new i(1,"bar.v.double");break}default:throw new z(`Unimplemented beginend: ${n.head}`,n)}return a.setOptions({delim:l.toNode()}),a}throw new z(`Unimplemented beginend: ${n.head}`,n)}default:throw new z(`Unimplemented node type: ${s.type}`,s)}}function R(s,e="other"){switch(s.type){case 0:return u.EMPTY;case 1:{let r=function(t){switch(t){case"eq":return"=";case"plus":return"+";case"minus":return"-";case"percent":return"%";case"dot":return e==="func-name"?"\\dot":"\\cdot";default:return P.has(t)?"\\"+P.get(t):"\\"+t}};if(s.value.endsWith(".not")){let t=r(s.value.slice(0,-4));return new u(2,t.startsWith("\\")?`\\not${t}`:`\\not ${t}`)}return new u(2,r(s.value))}case 2:{let r;return["{","}","%"].includes(s.value)?r="\\"+s.value:r=s.value,new u(1,r)}case 3:return new u(3,s.value);case 4:return new u(3,s.value);case 5:return new u(4,s.value);case 6:return new u(5,s.value);case 7:{let r;switch(s.value){case"\\":r="\\\\";break;case"&":r="&";break;default:throw new Error(`[typst_token_to_tex]Unimplemented control sequence: ${s.value}`)}return new u(7,r)}case 8:return new u(6,s.value);default:throw new Error(`Unimplemented token type: ${s.type}`)}}var ft=new u(1,",").toNode();function Ne(s,e){let r=t=>Ne(t,e);switch(s.type){case"terminal":{let t=s;if(t.head.type===1){if(t.head.value==="eq.def")return new w(new u(2,"\\overset"),[new _(new u(3,"def")),new u(1,"=").toNode()]);if(t.head.value==="comma")return new u(1,",").toNode();if(t.head.value==="dif")return new w(new u(2,"\\mathrm"),[new u(1,"d").toNode()]);if(t.head.value==="hyph"||t.head.value==="hyph.minus")return new _(new u(3,"-"));if(/^([A-Z])\1$/.test(t.head.value))return new w(new u(2,"\\mathbb"),[new u(1,t.head.value[0]).toNode()])}return t.head.type===4?new _(new u(3,t.head.value)):R(t.head).toNode()}case"group":{let n=s.items.map(r),o=new u(7,"&").toNode(),a=new u(7,"\\\\").toNode();if(K(n,o)){let l=C(n,a),p=[];for(let c of l){let h=C(c,o);p.push(h.map(d=>new y(d)))}return new q(new u(3,"aligned"),p)}return new y(n)}case"leftright":{let t=s,n=r(t.body),o=t.left?R(t.left):new u(1,"."),a=t.right?R(t.right):new u(1,".");return t.isOverHigh()&&(o.value="\\left"+o.value,a.value="\\right"+a.value),new y([o.toNode(),n,a.toNode()])}case"funcCall":{let t=s;switch(t.head.value){case"norm":{let n=t.args[0],o=r(n);return t.isOverHigh()?new A({body:o,left:new u(2,"\\|"),right:new u(2,"\\|")}):o}case"floor":case"ceil":{let n="\\l"+t.head.value,o="\\r"+t.head.value,a=t.args[0],l=r(a),p=new u(2,n),c=new u(2,o);return t.isOverHigh()?new A({body:l,left:p,right:c}):new y([p.toNode(),l,c.toNode()])}case"root":{let[n,o]=t.args,a=r(n);return new w(new u(2,"\\sqrt"),[r(o)],a)}case"overbrace":case"underbrace":{let[n,o]=t.args,a=new w(R(t.head),[r(n)]),l=r(o),p=t.head.value==="overbrace"?{base:a,sup:l,sub:null}:{base:a,sub:l,sup:null};return new S(p)}case"vec":{let n=t.args.map(o=>[r(o)]);return new q(new u(3,"pmatrix"),n)}case"op":{let n=t.args[0];return T(n.head.type===4),new w(R(t.head),[new u(3,n.head.value).toNode()])}case"class":{let n=t.args[0];T(n.head.type===4);let o;switch(n.head.value){case"relation":o="\\mathrel";break;case"binary":o="\\mathbin";break;case"large":o="\\mathop";break;default:throw new Error(`Unimplemented class: ${n.head.value}`)}return new w(new u(2,o),[r(t.args[1])])}case"display":{let n=t.args[0],o=new y([u.COMMAND_DISPLAYSTYLE.toNode(),r(n)]);return e.blockMathMode||o.items.push(u.COMMAND_TEXTSTYLE.toNode()),o}case"inline":{let n=t.args[0],o=new y([u.COMMAND_TEXTSTYLE.toNode(),r(n)]);return e.blockMathMode&&o.items.push(u.COMMAND_DISPLAYSTYLE.toNode()),o}default:{let n=R(t.head,"func-name"),o=W.includes(n.value.substring(1))||H.includes(n.value.substring(1));return n.value.length>0&&o?new w(n,t.args.map(r)):new y([R(t.head).toNode(),new u(1,"(").toNode(),...qe(t.args.map(r),ft),new u(1,")").toNode()])}}}case"markupFunc":{let t=s;switch(t.head.value){case"#text":if(t.options&&t.options.fill){let n=t.options.fill;return new w(new u(2,"\\textcolor"),[r(n),r(t.fragments[0])])}case"#heading":default:throw new Error(`Unimplemented markup function: ${t.head.value}`)}}case"supsub":{let t=s,{base:n,sup:o,sub:a}=t,l=o?r(o):null,p=a?r(a):null;if(n.head.eq(new i(1,"limits"))){let v=r(n.args[0]);if(l!==null&&p===null)return new w(new u(2,"\\overset"),[l,v]);if(l===null&&p!==null)return new w(new u(2,"\\underset"),[p,v]);{let ie=new w(new u(2,"\\underset"),[p,v]);return new w(new u(2,"\\overset"),[l,ie])}}let c=r(n);return new S({base:c,sup:l,sub:p})}case"matrixLike":{let t=s,n=t.matrix.map(o=>o.map(r));if(t.head.eq(E.MAT)){let o="pmatrix";if(t.options&&"delim"in t.options){let a=t.options.delim;switch(a.head.value){case"#none":o="matrix";break;case"[":case"]":o="bmatrix";break;case"(":case")":o="pmatrix";break;case"{":case"}":o="Bmatrix";break;case"|":o="vmatrix";break;case"bar":case"bar.v":o="vmatrix";break;case"bar.v.double":o="Vmatrix";break;default:throw new Error(`Unexpected delimiter ${a.head}`)}}return new q(new u(3,o),n)}else{if(t.head.eq(E.CASES))return new q(new u(3,"cases"),n);throw new Error(`Unexpected matrix type ${t.head}`)}}case"fraction":{let t=s,[n,o]=t.args,a=r(n),l=r(o);return new w(new u(2,"\\frac"),[a,l])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+s.type)}}var yt=Array.from(ee.keys());function Et(){return`(${yt.map(e=>(e=e.replaceAll("|","\\|"),e=e.replaceAll(".","\\."),e=e.replaceAll("[","\\["),e=e.replaceAll("]","\\]"),e)).join("|")})`}var Nt=Et(),xt=new Map([[String.raw`//[^\n]*`,s=>new i(5,s.text().substring(2))],[String.raw`/`,s=>new i(2,s.text())],[String.raw`[_^&]`,s=>new i(7,s.text())],[String.raw`\r?\n`,s=>new i(8,`
|
|
9
|
-
`)],[String.raw`\s+`,
|
|
10
|
-
`)]],[String.raw`\\\s`,
|
|
11
|
-
`))&&o.push(
|
|
1
|
+
"use strict";(()=>{function z(n){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(n)}function T(n,e="Assertion failed."){if(!n)throw new Error(e)}var p=class n{type;value;constructor(e,r){this.type=e,this.value=r}eq(e){return this.type===e.type&&this.value===e.value}toString(){switch(this.type){case 4:return"%"+this.value;default:return this.value}}toNode(){return new ue(this)}static EMPTY=new n(0,"");static COMMAND_DISPLAYSTYLE=new n(2,"\\displaystyle");static COMMAND_TEXTSTYLE=new n(2,"\\textstyle")},M=class{type;head;constructor(e,r){this.type=e,this.head=r||p.EMPTY}eq(e){return this.type===e.type&&this.head.eq(e.head)}toString(){return this.serialize().reduce(ce,"")}},ue=class extends M{constructor(e){super("terminal",e)}serialize(){switch(this.head.type){case 0:return[];case 1:case 2:case 3:case 4:case 7:return[this.head];case 5:case 6:{let e=[];for(let r of this.head.value){let t=r===" "?5:6;e.push(new p(t,r))}return e}default:throw new Error(`Unknown terminal token type: ${this.head.type}`)}}bottomTopTraversalTransform(e){return e(this)}},R=class extends M{constructor(e){T(e.type===3),super("text",e)}serialize(){return[new p(2,"\\text"),new p(1,"{"),this.head,new p(1,"}")]}bottomTopTraversalTransform(e){return e(this)}},y=class n extends M{items;constructor(e){super("ordgroup",p.EMPTY),this.items=e}serialize(){return this.items.map(e=>e.serialize()).flat()}bottomTopTraversalTransform(e){let r=new n(this.items.map(t=>t.bottomTopTraversalTransform(e)));return e(r)}},S=class n extends M{base;sup;sub;constructor(e){super("supsub",p.EMPTY),this.base=e.base,this.sup=e.sup,this.sub=e.sub}serialize(){let e=[],{base:r,sup:t,sub:s}=this;e=e.concat(r.serialize());function o(a){return a.type==="ordgroup"||a.type==="supsub"||a.head.type===0?!0:!!(a.head.type===1&&/\d+(\.\d+)?/.test(a.head.value)&&a.head.value.length>1)}return s&&(e.push(new p(7,"_")),o(s)?(e.push(new p(1,"{")),e=e.concat(s.serialize()),e.push(new p(1,"}"))):e=e.concat(s.serialize())),t&&(e.push(new p(7,"^")),o(t)?(e.push(new p(1,"{")),e=e.concat(t.serialize()),e.push(new p(1,"}"))):e=e.concat(t.serialize())),e}bottomTopTraversalTransform(e){let r=new n({base:this.base.bottomTopTraversalTransform(e),sup:this.sup?this.sup.bottomTopTraversalTransform(e):null,sub:this.sub?this.sub.bottomTopTraversalTransform(e):null});return e(r)}},m=class n extends M{args;data;constructor(e,r,t=null){super("funcCall",e),this.args=r,this.data=t}serialize(){let e=[];e.push(this.head),this.head.value==="\\sqrt"&&this.data&&(e.push(new p(1,"[")),e=e.concat(this.data.serialize()),e.push(new p(1,"]")));for(let r of this.args)e.push(new p(1,"{")),e=e.concat(r.serialize()),e.push(new p(1,"}"));return e}bottomTopTraversalTransform(e){let r=new n(this.head,this.args.map(t=>t.bottomTopTraversalTransform(e)),this.data);return e(r)}},O=class n extends M{body;left;right;constructor(e){super("leftright",p.EMPTY),this.body=e.body,this.left=e.left,this.right=e.right}serialize(){let e=[];return e.push(new p(2,"\\left")),e.push(new p(1,this.left?this.left.value:".")),e=e.concat(this.body.serialize()),e.push(new p(2,"\\right")),e.push(new p(1,this.right?this.right.value:".")),e}bottomTopTraversalTransform(e){let r=new n({body:this.body.bottomTopTraversalTransform(e),left:this.left,right:this.right});return e(r)}},q=class n extends M{matrix;data;constructor(e,r,t=null){T(e.type===3),super("beginend",e),this.matrix=r,this.data=t}serialize(){let e=[],r=this.matrix;e.push(new p(2,"\\begin")),e.push(new p(1,"{")),e=e.concat(this.head),e.push(new p(1,"}")),e.push(new p(6,`
|
|
2
|
+
`));for(let t=0;t<r.length;t++){let s=r[t];for(let o=0;o<s.length;o++){let a=s[o];e=e.concat(a.serialize()),o!==s.length-1&&e.push(new p(7,"&"))}t!==r.length-1&&e.push(new p(7,"\\\\"))}return e.push(new p(6,`
|
|
3
|
+
`)),e.push(new p(2,"\\end")),e.push(new p(1,"{")),e=e.concat(this.head),e.push(new p(1,"}")),e}bottomTopTraversalTransform(e){let r=this.matrix.map(o=>o.map(a=>a.bottomTopTraversalTransform(e))),t=this.data?this.data.bottomTopTraversalTransform(e):null,s=new n(this.head,r,t);return e(s)}};function ce(n,e){let r=e.toString(),t=!1;return e.type===5?t=!0:(t||=/[{\(\[\|]$/.test(n),t||=/\\\w+$/.test(n)&&r==="[",t||=/^[\.,;:!\?\(\)\]{}_^]$/.test(r),t||=["\\{","\\}"].includes(r),t||=r==="'",t||=n.endsWith("_")||n.endsWith("^"),t||=/\s$/.test(n),t||=/^\s/.test(r),t||=n==="",t||=/[\(\[{]\s*(-|\+)$/.test(n)||n==="-"||n==="+",t||=n.endsWith("&")&&r==="=",t||=/\d$/.test(n)&&/^[a-zA-Z]$/.test(r)),t||(n+=" "),n+r}function he(n,e,r=0){let t=n.slice(r).findIndex(s=>s.eq(e));return t===-1?-1:t+r}function K(n,e){return n.some(r=>r.eq(e))}function C(n,e){let r=[],t=[];for(let s of n)s.eq(e)?(r.push(t),t=[]):t.push(s);return r.push(t),r}function qe(n,e){return n.flatMap((r,t)=>t!==n.length-1?[...r,e]:r)}function _e(n,e){return n.flatMap((r,t)=>t!==n.length-1?[r,e]:[r])}var Se={};function Qe(n,e){let r=n.reMatchArray[0].length,t=e.reMatchArray[0].length;return t!==r?t-r:n.index-e.index}var de=class{_input;_lexer;_pos=0;_line=0;_col=0;_offset=0;_less=null;_go=!1;_newstate=null;_state;_text=null;_leng=null;_reMatchArray=null;constructor(e,r){this._input=e,this._lexer=r,this._state=r.states[0]}text(){return this._text}leng(){return this._leng}reMatchArray(){return this._reMatchArray}pos(){return this._pos}line(){return this._line}column(){return this._col}input(){return this._input.charAt(this._pos+this._leng+this._offset++)}unput(){return this._offset=this._offset>0?this._offset--:0}less(e){return this._less=e,this._offset=0,this._text=this._text.substring(0,e),this._leng=this._text.length}pushback(e){return this.less(this._leng-e)}reject(){this._go=!0}begin(e){if(this._lexer.specification[e])return this._newstate=e;let r=this._lexer.states[parseInt(e)];if(r)return this._newstate=r;throw"Unknown state '"+e+"' requested"}state(){return this._state}scan(){if(this._pos>=this._input.length)return Se;let e=this._input.substring(this._pos),r=this._lexer.specification[this._state],t=[];for(let c=0;c<r.length;c++){let h=r[c],d=e.match(h.re);d!==null&&d[0].length>0&&t.push({index:c,rule:h,reMatchArray:d})}if(t.length===0)throw new Error("No match found for input '"+e+"'");t.sort(Qe),this._go=!0;let s,o;for(let c=0,h=t.length;c<h&&this._go;c++){this._offset=0,this._less=null,this._go=!1,this._newstate=null;let d=t[c];if(o=d.reMatchArray[0],this._text=o,this._leng=o.length,this._reMatchArray=d.reMatchArray,s=d.rule.action(this),this._newstate&&this._newstate!=this._state){this._state=this._newstate;break}}let a=this._less===null?o:o.substring(0,this._less),l=a.length;this._pos+=l+this._offset;let u=a.match(/\n/g);return u!==null?(this._line+=u.length,this._col=l-a.lastIndexOf(`
|
|
4
|
+
`)-1):this._col+=l,s}},I=class{states;specification;constructor(e){this.states=Object.keys(e),this.specification={};for(let r of this.states){let t=e[r];if(r in this.specification)throw"Duplicate state declaration encountered for state '"+r+"'";this.specification[r]=[];for(let[s,o]of t.entries()){let a;try{a=new RegExp("^"+s)}catch(l){throw"Invalid regexp '"+s+"' in state '"+r+"' ("+l.message+")"}this.specification[r].push({re:a,action:o})}}}scanner(e){return new de(e,this)}lex(e,r){let t=this.scanner(e);for(;;){let s=t.scan();if(s===Se)return;s!==void 0&&r(s)}}collect(e){let r=[],t=function(s){Array.isArray(s)?r.push(...s):r.push(s)};return this.lex(e,t),r}};var U=["sqrt","text","bar","bold","boldsymbol","ddot","dot","hat","mathbb","mathbf","mathcal","mathfrak","mathit","mathrm","mathscr","mathsf","mathtt","operatorname","operatorname*","overbrace","overline","pmb","rm","tilde","underbrace","underline","vec","widehat","widetilde","overleftarrow","overrightarrow","hspace","substack","displaylines","mathinner","mathrel","mathbin","mathop","not","bra","ket","braket","set","Bra","Ket","Braket","Set","pmod","cancel"],W=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset","underset","textcolor"];function Je(n){let e=["{","}","\\","$","&","#","_","%"];for(let r of e)n=n.replaceAll("\\"+r,r);return n}var et=new Map([[String.raw`\\begin{(array|subarry)}{(.+?)}`,n=>{let e=n.reMatchArray();return[new p(2,"\\begin"),new p(7,"{"),new p(3,e[1]),new p(7,"}"),new p(7,"{"),new p(3,e[2]),new p(7,"}")]}],[String.raw`\\(text|operatorname\*?|textcolor|begin|end|hspace|array)\s*{(.+?)}`,n=>{let e=n.reMatchArray();return[new p(2,"\\"+e[1]),new p(7,"{"),new p(3,Je(e[2])),new p(7,"}")]}],[String.raw`%[^\n]*`,n=>new p(4,n.text().substring(1))],[String.raw`[{}_^&]`,n=>new p(7,n.text())],[String.raw`\\[\\,:;!> ]`,n=>new p(7,n.text())],[String.raw`~`,n=>new p(7,n.text())],[String.raw`\r?\n`,n=>new p(6,`
|
|
5
|
+
`)],[String.raw`\s+`,n=>new p(5,n.text())],[String.raw`\\[{}%$&#_|]`,n=>new p(1,n.text())],[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])\s*([0-9a-zA-Z])`,n=>{let e=n.reMatchArray(),r=e[1];if(W.includes(r.substring(1))){let t=e[2].trimStart(),s=e[3];return[new p(2,r),new p(1,t),new p(1,s)]}else return n.reject(),[]}],[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])`,n=>{let e=n.reMatchArray(),r=e[1];if(U.includes(r.substring(1))){let t=e[2].trimStart();return[new p(2,r),new p(1,t)]}else return n.reject(),[]}],[String.raw`\\[a-zA-Z]+`,n=>new p(2,n.text())],[String.raw`[0-9]+(\.[0-9]+)?`,n=>new p(1,n.text())],[String.raw`[a-zA-Z]`,n=>new p(1,n.text())],[String.raw`[+\-*/='<>!.,;:?()\[\]|]`,n=>new p(1,n.text())],[String.raw`[^\x00-\x7F]`,n=>new p(1,n.text())],[String.raw`.`,n=>new p(8,n.text())]]),tt={start:et};function ge(n){return new I(tt).collect(n)}var rt=["bigl","bigr","bigm","biggl","biggr","biggm","Bigl","Bigr","Bigm","Biggl","Biggr","Biggm"],Oe=p.EMPTY.toNode();function nt(n){return U.includes(n)?1:W.includes(n)?2:0}var Z=new p(7,"{"),H=new p(7,"}"),st=new p(1,"["),ot=new p(1,"]");function Q(n,e){let r=e;for(;r<n.length&&[5,6].includes(n[r].type);)r++;return n.slice(e,r)}function Ae(n,e){let r=n[e];return r.type===1&&["(",")","[","]","|","\\{","\\}",".","\\|","<",">"].includes(r.value)||r.type===2&&["lfloor","rfloor","lceil","rceil","langle","rangle","lparen","rparen","lbrace","rbrace"].includes(r.value.slice(1))?r:null}function G(n,e){let r=e;for(;r<n.length&&n[r].eq(new p(1,"'"));)r+=1;return r-e}function at(n){let e=null,r=[],t=[],s=0;for(;;){if(s===n.length||n[s].head.eq(p.COMMAND_DISPLAYSTYLE)||n[s].head.eq(p.COMMAND_TEXTSTYLE)){if(r.length>0){let o=r.length===1?r[0]:new y(r);t.push(e?new m(e,[o]):o)}if(s===n.length)break;r=[],e=n[s].head}else r.push(n[s]);s++}return t}var Re=new p(2,"\\left"),Ce=new p(2,"\\right"),Ie=new p(2,"\\begin"),Be=new p(2,"\\end"),it=new p(7,"\\\\"),g=class n extends Error{constructor(e){super(e),this.name="LatexParserError"}static UNMATCHED_LEFT_BRACE=new n("Unmatched '\\{'");static UNMATCHED_RIGHT_BRACE=new n("Unmatched '\\}'");static UNMATCHED_LEFT_BRACKET=new n("Unmatched '\\['");static UNMATCHED_RIGHT_BRACKET=new n("Unmatched '\\]'");static UNMATCHED_COMMAND_BEGIN=new n("Unmatched '\\begin'");static UNMATCHED_COMMAND_END=new n("Unmatched '\\end'");static UNMATCHED_COMMAND_LEFT=new n("Unmatched '\\left'");static UNMATCHED_COMMAND_RIGHT=new n("Unmatched '\\right'")},be=new p(7,"_"),me=new p(7,"^"),we=class{space_sensitive;newline_sensitive;alignmentDepth=0;constructor(e=!1,r=!0){this.space_sensitive=e,this.newline_sensitive=r}parse(e){return this.parseGroup(e.slice(0))}parseGroup(e){let[r,t]=this.parseClosure(e,0,null);return r}parseClosure(e,r,t){let s=[],o=r;for(;o<e.length&&!(t!==null&&e[o].eq(t));){let[u,c]=this.parseNextExpr(e,o);o=c,!((u.head.type===5||u.head.type===6)&&(!this.space_sensitive&&u.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&u.head.value===`
|
|
6
|
+
`))&&s.push(u)}if(o>=e.length&&t!==null)return[Oe,-1];let a=at(s),l;return a.length===1?l=a[0]:l=new y(a),[l,o+1]}parseNextExpr(e,r){let[t,s]=this.parseNextExprWithoutSupSub(e,r),o=null,a=null,l=0;if(l+=G(e,s),s+=l,s<e.length){let u=e[s];if(u.eq(be)){[o,s]=this.parseNextExprWithoutSupSub(e,s+1);let c=G(e,s);if(l+=c,s+=c,s<e.length&&e[s].eq(me)&&([a,s]=this.parseNextExprWithoutSupSub(e,s+1),G(e,s)>0))throw new g("Double superscript")}else if(u.eq(me)){if([a,s]=this.parseNextExprWithoutSupSub(e,s+1),G(e,s)>0)throw new g("Double superscript");if(s<e.length&&e[s].eq(be)&&([o,s]=this.parseNextExprWithoutSupSub(e,s+1),G(e,s)>0))throw new g("Double superscript")}}if(o!==null||a!==null||l>0){let u={base:t,sup:null,sub:null};if(o&&(u.sub=o),l>0){let c=[];for(let h=0;h<l;h++)c.push(new p(1,"'").toNode());a&&c.push(a),u.sup=c.length===1?c[0]:new y(c)}else a&&(u.sup=a);return[new S(u),s]}else return[t,s]}parseNextExprWithoutSupSub(e,r){if(r>=e.length)throw new g("Unexpected end of input");let t=e[r];switch(t.type){case 1:case 3:case 4:case 5:case 6:return[t.toNode(),r+1];case 2:let s=t.value.slice(1);if(rt.includes(s))return this.parseNextExprWithoutSupSub(e,r+1);if(t.eq(Ie))return this.parseBeginEndExpr(e,r);if(t.eq(Be))throw g.UNMATCHED_COMMAND_END;if(t.eq(Re))return this.parseLeftRightExpr(e,r);if(t.eq(Ce))throw g.UNMATCHED_COMMAND_RIGHT;return this.parseCommandExpr(e,r);case 7:switch(t.value){case"{":let[a,l]=this.parseClosure(e,r+1,H);if(l===-1)throw g.UNMATCHED_LEFT_BRACE;return[a,l];case"}":throw g.UNMATCHED_RIGHT_BRACE;case"\\\\":case"\\!":case"\\,":case"\\:":case"\\;":case"\\>":return[t.toNode(),r+1];case"\\ ":case"~":return[t.toNode(),r+1];case"_":case"^":return[Oe,r];case"&":if(this.alignmentDepth<=0)throw new g("Unexpected & outside of an alignment");return[t.toNode(),r+1];default:throw new g("Unknown control sequence")}default:throw new g("Unknown token type")}}parseCommandExpr(e,r){T(e[r].type===2);let t=e[r],s=t.value,o=r+1;switch(nt(s.slice(1))){case 0:return[t.toNode(),o];case 1:{if(o>=e.length)throw new g("Expecting argument for "+s);if(s==="\\sqrt"&&o<e.length&&e[o].eq(st)){let[c,h]=this.parseClosure(e,o+1,ot);if(h===-1)throw g.UNMATCHED_LEFT_BRACKET;let[d,v]=this.parseNextArg(e,h);return[new m(t,[d],c),v]}else if(s==="\\text"){if(o+2>=e.length)throw new g("Expecting content for \\text command");T(e[o].eq(Z)),T(e[o+1].type===3),T(e[o+2].eq(H));let c=e[o+1];return[new R(c),o+3]}else if(s==="\\displaylines"){T(e[o].eq(Z));let[c,h]=this.parseAligned(e,o+1,H);if(h===-1)throw g.UNMATCHED_LEFT_BRACE;let d=new y(qe(c,it.toNode()));return[new m(t,[d]),h]}let[l,u]=this.parseNextArg(e,o);return[new m(t,[l]),u]}case 2:{let[l,u]=this.parseNextArg(e,o),[c,h]=this.parseNextArg(e,u);return[new m(t,[l,c]),h]}default:throw new Error("Invalid number of parameters")}}parseNextArg(e,r){let t=r,s=null;for(;t<e.length;){let o;if([o,t]=this.parseNextExprWithoutSupSub(e,t),!(o.head.type===5||o.head.type===6)){s=o;break}}if(s===null)throw new g("Expecting argument but token stream ended");return[s,t]}parseLeftRightExpr(e,r){T(e[r].eq(Re));let t=r+1;if(t+=Q(e,t).length,t>=e.length)throw new g("Expecting a delimiter after \\left");let s=Ae(e,t);if(s===null)throw new g("Invalid delimiter after \\left");t++;let[o,a]=this.parseClosure(e,t,Ce);if(a===-1)throw g.UNMATCHED_COMMAND_LEFT;if(t=a,t+=Q(e,t).length,t>=e.length)throw new g("Expecting a delimiter after \\right");let l=Ae(e,t);if(l===null)throw new g("Invalid delimiter after \\right");t++;let u=s.value==="."?null:s,c=l.value==="."?null:l;return[new O({body:o,left:u,right:c}),t]}parseBeginEndExpr(e,r){T(e[r].eq(Ie));let t=r+1;T(e[t].eq(Z)),T(e[t+1].type===3),T(e[t+2].eq(H));let s=e[t+1].value;t+=3;let o=null;["array","subarray"].includes(s)&&(t+=Q(e,t).length,[o,t]=this.parseNextArg(e,t));let[a,l]=this.parseAligned(e,t,Be);if(l===-1)throw g.UNMATCHED_COMMAND_BEGIN;if(t=l,T(e[t].eq(Z)),T(e[t+1].type===3),T(e[t+2].eq(H)),e[t+1].value!==s)throw new g("\\begin and \\end environments mismatch");return t+=3,[new q(new p(3,s),a,o),t]}parseAligned(e,r,t){this.alignmentDepth++;let s=r;s+=Q(e,s).length;let o;if([o,s]=this.parseClosure(e,s,t),s===-1)return[[],-1];let a;if(o.type==="ordgroup"){let l=o.items;for(;l.length>0&&[5,6].includes(l[l.length-1].head.type);)l.pop();a=C(l,new p(7,"\\\\").toNode()).map(u=>C(u,new p(7,"&").toNode()).map(c=>new y(c)))}else a=[[o]];return this.alignmentDepth--,[a,s]}};function lt(n){let e=t=>t.eq(be)||t.eq(me),r=[];for(let t=0;t<n.length;t++)n[t].type===5&&t+1<n.length&&e(n[t+1])||n[t].type===5&&t-1>=0&&e(n[t-1])||r.push(n[t]);return r}function pt(n,e){let r=[];for(let t of n)if(t.type===2&&e[t.value]){let s=ge(e[t.value]);r=r.concat(s)}else r.push(t);return r}function J(n,e={}){let r=new we,t=ge(n);return t=lt(t),t=pt(t,e),r.parse(t)}var F=new Map([["arrow.l.r.double.long","<==>"],["arrow.l.r.long","<-->"],["arrow.r.bar","|->"],["arrow.r.double.bar","|=>"],["arrow.r.double.long","==>"],["arrow.r.long","-->"],["arrow.r.long.squiggly","~~>"],["arrow.r.tail",">->"],["arrow.r.twohead","->>"],["arrow.l.double.long","<=="],["arrow.l.long","<--"],["arrow.l.long.squiggly","<~~"],["arrow.l.tail","<-<"],["arrow.l.twohead","<<-"],["arrow.l.r.double","<=>"],["colon.double.eq","::="],["dots.h","..."],["gt.triple",">>>"],["lt.triple","<<<"],["arrow.l.r","<->"],["arrow.r","->"],["arrow.r.double","=>"],["arrow.r.squiggly","~>"],["arrow.l","<-"],["arrow.l.squiggly","<~"],["bar.v.double","||"],["bracket.l.stroked","[|"],["bracket.r.stroked","|]"],["colon.eq",":="],["eq.colon","=:"],["eq.not","!="],["gt.double",">>"],["gt.eq",">="],["lt.double","<<"],["lt.eq","<="],["ast.op","*"],["minus","-"],["tilde.op","~"]]),ee=new Map;for(let[n,e]of F.entries())e.length>1&&ee.set(e,n);var i=class n{type;value;constructor(e,r){this.type=e,this.value=r}eq(e){return this.type===e.type&&this.value===e.value}isOneOf(e){return K(e,this)}toNode(){return new $(this)}toString(){switch(this.type){case 4:return`"${this.value}"`;case 5:return`//${this.value}`;default:return this.value}}static NONE=new n(0,"#none");static EMPTY=new n(2,"");static LEFT_BRACE=new n(2,"{");static RIGHT_BRACE=new n(2,"}");static LEFT_PAREN=new n(2,"(");static RIGHT_PAREN=new n(2,")");static LEFT_ANGLE=new n(1,"chevron.l");static RIGHT_ANGLE=new n(1,"chevron.r");static VERTICAL_BAR=new n(2,"|");static PLUS=new n(2,"+");static MINUS=new n(2,"-");static LR=new n(1,"lr");static LEFT_DELIMITERS=[n.LEFT_PAREN,new n(2,"["),n.LEFT_BRACE,n.VERTICAL_BAR,n.LEFT_ANGLE,new n(1,"paren.l"),new n(1,"brace.l")];static RIGHT_DELIMITERS=[n.RIGHT_PAREN,new n(2,"]"),n.RIGHT_BRACE,n.VERTICAL_BAR,n.RIGHT_ANGLE,new n(1,"paren.r"),new n(1,"brace.r")]},fe=class extends Error{node;constructor(e,r){super(e),this.name="TypstWriterError",this.node=r}},N=new i(7," "),k=class{type;head;options;constructor(e,r){this.type=e,this.head=r||i.NONE}setOptions(e){this.options=e}eq(e){return this.type===e.type&&this.head.eq(e.head)}toString(){throw new Error("Unimplemented toString() in base class TypstNode")}},$=class extends k{constructor(e){super("terminal",e)}isOverHigh(){return!1}isLeftSpaceful(){switch(this.head.type){case 6:case 8:return!1;case 4:return!0;case 1:case 2:return!["(","!",",",")","}","]"].includes(this.head.value);default:return!0}}isRightSpaceful(){switch(this.head.type){case 6:case 8:return!1;case 4:return!0;case 1:case 2:return["+","=",",","\\/","dot","dot.op","arrow","arrow.r"].includes(this.head.value);default:return!1}}toString(){return this.head.toString()}serialize(e,r){if(this.head.type===2){if(this.head.value===","&&e.insideFunctionDepth>0)return[N,new i(1,"comma")]}else if(this.head.type===1){let t=this.head.value;return r.preferShorthands&&F.has(t)&&(t=F.get(t)),r.inftyToOo&&t==="infinity"&&(t="oo"),[new i(1,t)]}else if(this.head.type===6||this.head.type===8){let t=[];for(let s of this.head.value)if(s===" ")r.keepSpaces&&t.push(new i(6,s));else if(s===`
|
|
7
|
+
`)t.push(new i(1,s));else throw new fe(`Unexpected whitespace character: ${s}`,this);return t}return[this.head]}bottomTopTraversalTransform(e){return e(this)}},ye=class{queue=[];pushSoftSpace(){if(this.queue.length!==0){{if(this.queue.at(-1).eq(N))return;if(["(","{","["].includes(this.queue.at(-1).value))return}this.queue.push(N)}}pushAll(e){if(e.length!=0)if(e[0].eq(N)&&this.queue.length===0)this.queue.push(...e.slice(1));else{if([")","}","]"].includes(e[0].value))for(;this.queue.at(-1)?.eq(N);)this.queue.pop();this.queue.push(...e)}}getQueue(){let e=Array.from(this.queue);for(;e.at(-1)?.eq(N);)e.pop();return e}},L=class n extends k{items;constructor(e){super("group",i.NONE),this.items=e}isOverHigh(){return this.items.some(e=>e.isOverHigh())}isLeftSpaceful(){return this.items.length===0?!1:this.items[0].isLeftSpaceful()}isRightSpaceful(){return this.items.length===0?!1:this.items.at(-1).isRightSpaceful()}serialize(e,r){if(this.items.length===0)return[];let t=new ye;for(let o=0;o<this.items.length;o++){let a=this.items[o],l=a.serialize(e,r);a.isLeftSpaceful()&&t.pushSoftSpace(),t.pushAll(l),a.isRightSpaceful()&&t.pushSoftSpace()}let s=t.getQueue();if(s.length>0&&(s[0].eq(i.MINUS)||s[0].eq(i.PLUS)))for(;s.length>1&&s[1].eq(N);)s.splice(1,1);return s}bottomTopTraversalTransform(e){let r=new n(this.items.map(t=>t.bottomTopTraversalTransform(e)));return e(r)}},_=class n extends k{base;sup;sub;constructor(e){super("supsub",i.NONE),this.base=e.base,this.sup=e.sup,this.sub=e.sub}isOverHigh(){return this.base.isOverHigh()}isLeftSpaceful(){return!0}isRightSpaceful(){return!0}serialize(e,r){let t=[],{base:s,sup:o,sub:a}=this;t.push(...s.serialize(e,r));let l=o&&o.head.eq(new i(2,"'"));return l&&t.push(new i(2,"'")),a&&(t.push(new i(2,"_")),t.push(...a.serialize(e,r))),o&&!l&&(t.push(new i(2,"^")),t.push(...o.serialize(e,r))),t}bottomTopTraversalTransform(e){let r=new n({base:this.base.bottomTopTraversalTransform(e),sup:this.sup?.bottomTopTraversalTransform(e)||null,sub:this.sub?.bottomTopTraversalTransform(e)||null});return e(r)}},w=class n extends k{args;constructor(e,r){super("funcCall",e),this.args=r}isOverHigh(){return this.head.value==="frac"?!0:this.args.some(e=>e.isOverHigh())}isLeftSpaceful(){return!0}isRightSpaceful(){return!["op","bold","dot"].includes(this.head.value)}serialize(e,r){let t=[],s=this.head;t.push(s),e.insideFunctionDepth++,t.push(te);for(let o=0;o<this.args.length;o++)t.push(...this.args[o].serialize(e,r)),o<this.args.length-1&&(t.push(new i(2,",")),t.push(N));if(this.options)for(let[o,a]of Object.entries(this.options))t.push(new i(3,`, ${o}: ${a.toString()}`));return t.push(re),e.insideFunctionDepth--,t}bottomTopTraversalTransform(e){let r=new n(this.head,this.args.map(t=>t.bottomTopTraversalTransform(e)));return r.options=this.options,e(r)}},B=class n extends k{args;constructor(e){super("fraction",i.NONE),this.args=e}isOverHigh(){return!0}isLeftSpaceful(){return!0}isRightSpaceful(){return!0}serialize(e,r){let t=[],[s,o]=this.args;return t.push(...s.serialize(e,r)),t.push(new i(2,"/")),t.push(...o.serialize(e,r)),t}bottomTopTraversalTransform(e){let r=new n(this.args.map(t=>t.bottomTopTraversalTransform(e)));return e(r)}},te=new i(2,"("),re=new i(2,")"),f=class n extends k{body;left;right;constructor(e,r){super("leftright",e),this.body=r.body,this.left=r.left,this.right=r.right}isOverHigh(){return this.body.isOverHigh()}isLeftSpaceful(){return!0}isRightSpaceful(){return!0}serialize(e,r){let t=[],s=new i(1,"lr"),{left:o,right:a}=this;return this.head.eq(s)&&(t.push(s),t.push(te)),o&&(t.push(o),z(o.value[0])&&t.push(N)),t.push(...this.body.serialize(e,r)),a&&(z(a.value[0])&&t.push(N),t.push(a)),this.head.eq(s)&&t.push(re),t}bottomTopTraversalTransform(e){let r=new n(this.head,{body:this.body.bottomTopTraversalTransform(e),left:this.left,right:this.right});return e(r)}},E=class n extends k{matrix;constructor(e,r){super("matrixLike",e),this.matrix=r}isOverHigh(){return!0}isLeftSpaceful(){return!0}isRightSpaceful(){return!1}serialize(e,r){let t=[],s,o;if(this.head.eq(n.MAT)?(s=new i(2,","),o=new i(2,";")):this.head.eq(n.CASES)?(s=new i(2,"&"),o=new i(2,",")):this.head.eq(i.NONE)&&(s=new i(2,"&"),o=new i(1,"\\")),!this.head.eq(i.NONE)&&(t.push(this.head),e.insideFunctionDepth++,t.push(te),this.options))for(let[a,l]of Object.entries(this.options))t.push(new i(3,`${a}: ${l.toString()}, `));return this.matrix.forEach((a,l)=>{a.forEach((u,c)=>{t.push(...u.serialize(e,r)),c<a.length-1?(s.value==="&"&&t.push(N),t.push(s),t.push(N)):l<this.matrix.length-1&&(o.value==="\\"&&t.push(N),t.push(o),t.push(N))})}),this.head.eq(i.NONE)||(t.push(re),e.insideFunctionDepth--),t}bottomTopTraversalTransform(e){let r=this.matrix.map(s=>s.map(o=>o.bottomTopTraversalTransform(e))),t=new n(this.head,r);return t.options=this.options,e(t)}static MAT=new i(1,"mat");static CASES=new i(1,"cases")},D=class n extends k{fragments;constructor(e,r){super("markupFunc",e),this.fragments=r}isOverHigh(){return this.fragments.some(e=>e.isOverHigh())}isLeftSpaceful(){return!0}isRightSpaceful(){return!0}serialize(e,r){let t=[];if(t.push(this.head),e.insideFunctionDepth++,t.push(te),this.options){let s=Object.entries(this.options);for(let o=0;o<s.length;o++){let[a,l]=s[o];t.push(new i(3,`${a}: ${l.toString()}`)),o<s.length-1&&t.push(new i(2,","))}}t.push(re),t.push(new i(3,"["));for(let s of this.fragments)t.push(new i(3,"$")),t.push(...s.serialize(e,r)),t.push(new i(3,"$"));return t.push(new i(3,"]")),t}bottomTopTraversalTransform(e){let r=new n(this.head,this.fragments.map(t=>t.bottomTopTraversalTransform(e)));return r.options=this.options,e(r)}};var De=new i(1,`
|
|
8
|
+
`),Ee=new i(7," ");var ne=class{buffer="";queue=[];options;constructor(e){this.options=e}serialize(e){let r={insideFunctionDepth:0};this.queue.push(...e.serialize(r,this.options))}flushQueue(){let e=this.queue.filter(s=>s.value!==""),r=[];for(let s of e)s.eq(Ee)&&r.length>0&&r[r.length-1].eq(Ee)||r.push(s);let t=new i(1,"");for(let s=0;s<r.length;s++)r[s].eq(Ee)&&(s===0||s===r.length-1||r[s-1].type===6||r[s-1].eq(De)||r[s+1].eq(De))&&(r[s]=t);for(let s of r)this.buffer+=s.toString();this.queue=[]}finalize(){this.flushQueue();let e=function(s){let o=s.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return o=o.replace(/floor\(\)/g,'floor("")'),o},r=function(s){let o=s.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return o=o.replace(/ceil\(\)/g,'ceil("")'),o},t=function(s){let o=s.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return o=o.replace(/round\(\)/g,'round("")'),o};if(this.options.optimize){let s=[e,r,t];for(let o of s)this.buffer=o(this.buffer)}return this.buffer=this.buffer.replace(/& =/g,"&="),this.buffer}};var x=new Map([["displaystyle","display"],["textstyle","inline"],["hspace","#h"],["|","bar.v.double"],[",","thin"],[":","med"],[" ","med"],[";","thick"],[">","med"],["~","space.nobreak"],["blacktriangleleft","triangle.filled.l"],["blacktriangleright","triangle.filled.r"],["clubsuit","suit.club.filled"],["hookleftarrow","arrow.l.hook"],["hookrightarrow","arrow.r.hook"],["leftrightarrow","arrow.l.r"],["lgblksquare","square.filled.big"],["lgwhtsquare","square.stroked.big"],["nearrow","arrow.tr"],["nwarrow","arrow.tl"],["searrow","arrow.br"],["swarrow","arrow.bl"],["spadesuit","suit.spade.filled"],["updownarrow","arrow.t.b"],["ln","ln"],["log","log"],["cos","cos"],["sin","sin"],["tan","tan"],["cot","cot"],["sec","sec"],["csc","csc"],["mod","mod"],["omicron","omicron"],["Xi","Xi"],["Upsilon","Upsilon"],["lim","lim"],["binom","binom"],["tilde","tilde"],["hat","hat"],["sqrt","sqrt"],["bmod","mod"],["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["cancel","cancel"],["operatorname","op"],["operatorname*","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathscr","scr"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["leadsto","arrow.r.squiggly"],["P","pilcrow"],["S","section"],["aleph","alef"],["infin","infinity"],["Delta","Delta"],["Gamma","Gamma"],["Lambda","Lambda"],["Omega","Omega"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Sigma","Sigma"],["Theta","Theta"],["alpha","alpha"],["beta","beta"],["bigcirc","circle.big"],["bullet","bullet"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","chevron.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","partial"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","chevron.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["intop","limits(integral)"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),ut=new Map([["acwopencirclearrow","arrow.ccw"],["adots","dots.up"],["angdnr","angle.acute"],["angle","angle"],["angles","angle.s"],["approx","approx"],["approxeq","approx.eq"],["approxident","tilde.triple"],["assert","tack.r.short"],["ast","ast.op"],["astrosun","sun"],["asymp","asymp"],["awint","integral.ccw"],["backcong","tilde.rev.equiv"],["backdprime","prime.double.rev"],["backprime","prime.rev"],["backsim","tilde.rev"],["backsimeq","tilde.eq.rev"],["backslash","backslash"],["backtrprime","prime.triple.rev"],["bardownharpoonleft","harpoon.bl.bar"],["bardownharpoonright","harpoon.br.bar"],["barleftarrow","arrow.l.stop"],["barleftarrowrightarrowbar","arrows.lr.stop"],["barleftharpoondown","harpoon.lb.stop"],["barleftharpoonup","harpoon.lt.stop"],["barrightharpoondown","harpoon.rb.bar"],["barrightharpoonup","harpoon.rt.bar"],["baruparrow","arrow.t.stop"],["barupharpoonleft","harpoon.tl.stop"],["barupharpoonright","harpoon.tr.stop"],["barV","tack.b.double"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["because","because"],["bigblacktriangledown","triangle.filled.b"],["bigblacktriangleup","triangle.filled.t"],["bigbot","tack.t.big"],["bigcap","inter.big"],["bigcup","union.big"],["bigcupdot","union.dot.big"],["biginterleave","interleave.big"],["bigodot","dot.o.big"],["bigoplus","plus.o.big"],["bigotimes","times.o.big"],["bigsqcap","inter.sq.big"],["bigsqcup","union.sq.big"],["bigstar","star.filled"],["bigtimes","times.big"],["bigtop","tack.b.big"],["bigtriangledown","triangle.stroked.b"],["bigtriangleup","triangle.stroked.t"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bigwhitestar","star.stroked"],["blackhourglass","hourglass.filled"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bot","bot"],["boxast","ast.square"],["boxdot","dot.square"],["boxminus","minus.square"],["boxplus","plus.square"],["boxtimes","times.square"],["cap","inter"],["Cap","inter.double"],["capdot","inter.dot"],["capwedge","inter.and"],["caretinsert","caret"],["cdot","dot.op"],["cdotp","dot.c"],["checkmark","checkmark"],["circledast","ast.op.o"],["circledbullet","bullet.o"],["circledcirc","compose.o"],["circleddash","dash.o"],["circledequal","cc.nd"],["circledparallel","parallel.o"],["circledvert","bar.v.o"],["circledwhitebullet","bullet.stroked.o"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["complement","complement"],["cong","tilde.equiv"],["coprod","product.co"],["cup","union"],["Cup","union.double"],["cupdot","union.dot"],["cupleftarrow","union.arrow"],["cupvee","union.or"],["curlyeqprec","eq.prec"],["curlyeqsucc","eq.succ"],["curlyvee","or.curly"],["curlywedge","and.curly"],["curvearrowleft","arrow.ccw.half"],["curvearrowright","arrow.cw.half"],["cwopencirclearrow","arrow.cw"],["dagger","dagger"],["dashcolon","dash.colon"],["dashv","tack.l"],["Dashv","tack.l.double"],["dashVdash","tack.l.r"],["ddagger","dagger.double"],["ddddot","dot.quad"],["dddot","dot.triple"],["ddots","dots.down"],["DDownarrow","arrow.b.quad"],["Ddownarrow","arrow.b.triple"],["diameter","diameter"],["diamondcdot","diamond.stroked.dot"],["diamondsuit","suit.diamond.stroked"],["dicei","die.one"],["diceii","die.two"],["diceiii","die.three"],["diceiv","die.four"],["dicev","die.five"],["dicevi","die.six"],["div","div"],["divideontimes","times.div"],["Doteq","eq.dots"],["dotminus","minus.dot"],["dotplus","plus.dot"],["dotsim","tilde.dot"],["dottedcircle","circle.dotted"],["dottedsquare","square.stroked.dotted"],["doubleplus","plus.double"],["downarrow","arrow.b"],["Downarrow","arrow.b.double"],["downarrowbar","arrow.b.stop"],["downarrowbarred","arrow.b.struck"],["downdasharrow","arrow.b.dashed"],["downdownarrows","arrows.bb"],["downharpoonleft","harpoon.bl"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["downharpoonrightbar","harpoon.br.stop"],["downharpoonsleftright","harpoons.blbr"],["downuparrows","arrows.bt"],["downupharpoonsleftright","harpoons.bltr"],["downwhitearrow","arrow.b.stroked"],["downzigzagarrow","arrow.zigzag"],["dprime","prime.double"],["dualmap","multimap.double"],["eighthnote","note.eighth.alt"],["ell","ell"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["eparsl","parallel.slanted.eq"],["eqcolon","eq.colon"],["eqdef","eq.def"],["eqgtr","eq.gt"],["eqless","eq.lt"],["eqsim","minus.tilde"],["equal","eq"],["equalparallel","parallel.eq"],["equiv","eq.triple"],["Equiv","eq.quad"],["equivVert","parallel.equiv"],["eqvparsl","parallel.slanted.equiv"],["errbarblackcircle","errorbar.circle.filled"],["errbarblackdiamond","errorbar.diamond.filled"],["errbarblacksquare","errorbar.square.filled"],["errbarcircle","errorbar.circle.stroked"],["errbardiamond","errorbar.diamond.stroked"],["errbarsquare","errorbar.square.stroked"],["euro","euro"],["exists","exists"],["fallingdotseq","eq.dots.down"],["fint","integral.slash"],["flat","flat"],["forall","forall"],["fourvdots","fence.dotted"],["frown","frown"],["fullouterjoin","join.l.r"],["geq","gt.eq"],["geqq","gt.equiv"],["geqslant","gt.eq.slant"],["gg","gt.double"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["gnapprox","gt.napprox"],["gneq","gt.neq"],["gneqq","gt.nequiv"],["gnsim","gt.ntilde"],["greater","gt"],["gtlpar","angle.spheric.rev"],["gtrapprox","gt.approx"],["gtrdot","gt.dot"],["gtreqless","gt.eq.lt"],["gtrless","gt.lt"],["gtrsim","gt.tilde"],["heartsuit","suit.heart.stroked"],["hknearrow","arrow.tr.hook"],["hknwarrow","arrow.tl.hook"],["hksearrow","arrow.br.hook"],["hkswarrow","arrow.bl.hook"],["horizbar","bar.h"],["hourglass","hourglass.stroked"],["hrectangle","rect.stroked.h"],["hrectangleblack","rect.filled.h"],["hyphenbullet","bullet.hyph"],["iiiint","integral.quad"],["iiint","integral.triple"],["iinfin","infinity.incomplete"],["iint","integral.double"],["Im","Im"],["imageof","image"],["in","in"],["increment","laplace"],["infty","infinity"],["int","integral"],["intbar","integral.dash"],["intBar","integral.dash.double"],["intcap","integral.inter"],["intclockwise","integral.cw"],["intcup","integral.union"],["interleave","interleave"],["intlarhk","integral.arrow.hook"],["intx","integral.times"],["inversebullet","bullet.hole"],["Join","join"],["langle","chevron.l"],["lAngle","chevron.l.double"],["langledot","chevron.l.dot"],["lat","lat"],["late","lat.eq"],["lbag","bag.l"],["lblkbrbrak","shell.l.filled"],["lbrace","brace.l"],["lBrace","brace.l.stroked"],["lbrack","bracket.l"],["lBrack","bracket.l.stroked"],["lbracklltick","bracket.l.tick.b"],["lbrackultick","bracket.l.tick.t"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.stroked"],["lceil","ceil.l"],["lcurvyangle","chevron.l.curly"],["leftarrow","arrow.l"],["Leftarrow","arrow.l.double"],["leftarrowtail","arrow.l.tail"],["leftarrowtriangle","arrow.l.open"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["leftdowncurvedarrow","arrow.l.curve"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["leftharpoonsupdown","harpoons.ltlb"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["leftleftarrows","arrows.ll"],["leftouterjoin","join.l"],["Leftrightarrow","arrow.l.r.double"],["leftrightarrows","arrows.lr"],["leftrightarrowtriangle","arrow.l.r.open"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsdown","harpoons.lbrb"],["leftrightharpoonsup","harpoons.ltrt"],["leftrightharpoonupdown","harpoon.lt.rb"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightsquigarrow","arrow.l.r.wave"],["leftsquigarrow","arrow.l.squiggly"],["leftthreearrows","arrows.lll"],["leftthreetimes","times.three.l"],["leftwavearrow","arrow.l.wave"],["leftwhitearrow","arrow.l.stroked"],["leq","lt.eq"],["leqq","lt.equiv"],["leqslant","lt.eq.slant"],["less","lt"],["lessapprox","lt.approx"],["lessdot","lt.dot"],["lesseqgtr","lt.eq.gt"],["lessgtr","lt.gt"],["lesssim","lt.tilde"],["lfloor","floor.l"],["lgblkcircle","circle.filled.big"],["lgroup","paren.l.flat"],["lgwhtcircle","circle.stroked.big"],["ll","lt.double"],["llangle","chevron.l.closed"],["llblacktriangle","triangle.filled.bl"],["llcorner","corner.l.b"],["LLeftarrow","arrow.l.quad"],["Lleftarrow","arrow.l.triple"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["llparenthesis","paren.l.closed"],["lltriangle","triangle.stroked.bl"],["lmoustache","mustache.l"],["lnapprox","lt.napprox"],["lneq","lt.neq"],["lneqq","lt.nequiv"],["lnsim","lt.ntilde"],["longdashv","tack.l.long"],["Longleftarrow","arrow.l.double.long"],["longleftarrow","arrow.l.long"],["Longleftrightarrow","arrow.l.r.double.long"],["longleftrightarrow","arrow.l.r.long"],["longleftsquigarrow","arrow.l.long.squiggly"],["Longmapsfrom","arrow.l.double.long.bar"],["longmapsfrom","arrow.l.long.bar"],["longmapsto","arrow.r.long.bar"],["Longmapsto","arrow.r.double.long.bar"],["Longrightarrow","arrow.r.double.long"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowleft","arrow.l.loop"],["looparrowright","arrow.r.loop"],["lparen","paren.l"],["lParen","paren.l.stroked"],["lrblacktriangle","triangle.filled.br"],["lrcorner","corner.r.b"],["lrtriangle","triangle.stroked.br"],["ltimes","times.l"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["maltese","maltese"],["mapsdown","arrow.b.bar"],["mapsfrom","arrow.l.bar"],["Mapsfrom","arrow.l.double.bar"],["mapsto","arrow.r.bar"],["Mapsto","arrow.r.double.bar"],["mapsup","arrow.t.bar"],["mathampersand","amp"],["mathatsign","at"],["mathcolon","colon"],["mathcomma","comma"],["mathdollar","dollar"],["mathexclam","excl"],["mathhyphen","hyph"],["mathparagraph","pilcrow"],["mathpercent","percent"],["mathperiod","dot.basic"],["mathplus","plus"],["mathquestion","quest"],["mathratio","ratio"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["mathsterling","pound"],["mathyen","yen"],["mdblkdiamond","diamond.filled.medium"],["mdblklozenge","lozenge.filled.medium"],["mdlgblkcircle","circle.filled"],["mdlgblkdiamond","diamond.filled"],["mdlgblklozenge","lozenge.filled"],["mdlgblksquare","square.filled"],["mdlgwhtcircle","circle.stroked"],["mdlgwhtdiamond","diamond.stroked"],["mdlgwhtlozenge","lozenge.stroked"],["mdlgwhtsquare","square.stroked"],["mdsmblkcircle","circle.filled.tiny"],["mdsmwhtcircle","circle.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["mdwhtlozenge","lozenge.stroked.medium"],["measeq","eq.m"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["measuredrightangle","angle.right.arc"],["mho","Omega.inv"],["mid","divides"],["minus","minus"],["models","models"],["mp","minus.plus"],["multimap","multimap"],["nabla","gradient"],["napprox","approx.not"],["nasymp","asymp.not"],["natural","natural"],["ncong","tilde.equiv.not"],["ne","eq.not"],["Nearrow","arrow.tr.double"],["neg","not"],["nequiv","equiv.not"],["neswarrow","arrow.tr.bl"],["nexists","exists.not"],["ngeq","gt.eq.not"],["ngtr","gt.not"],["ngtrless","gt.lt.not"],["ngtrsim","gt.tilde.not"],["nHdownarrow","arrow.b.dstruck"],["nhpar","parallel.struck"],["nHuparrow","arrow.t.dstruck"],["nhVvert","interleave.struck"],["ni","in.rev"],["nLeftarrow","arrow.l.double.not"],["nleftarrow","arrow.l.not"],["nLeftrightarrow","arrow.l.r.double.not"],["nleftrightarrow","arrow.l.r.not"],["nleq","lt.eq.not"],["nless","lt.not"],["nlessgtr","lt.gt.not"],["nlesssim","lt.tilde.not"],["nmid","divides.not"],["nni","in.rev.not"],["notin","in.not"],["nparallel","parallel.not"],["nprec","prec.not"],["npreccurlyeq","prec.curly.eq.not"],["nRightarrow","arrow.r.double.not"],["nrightarrow","arrow.r.not"],["nsim","tilde.not"],["nsimeq","tilde.eq.not"],["nsqsubseteq","subset.eq.sq.not"],["nsqsupseteq","supset.eq.sq.not"],["nsubset","subset.not"],["nsubseteq","subset.eq.not"],["nsucc","succ.not"],["nsucccurlyeq","succ.curly.eq.not"],["nsupset","supset.not"],["nsupseteq","supset.eq.not"],["ntrianglelefteq","lt.tri.eq.not"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["nvartriangleright","gt.tri.not"],["nVdash","forces.not"],["nvdash","tack.r.not"],["nvDash","tack.r.double.not"],["nvinfty","infinity.bar"],["nvLeftarrow","arrow.l.double.struck"],["nvleftarrow","arrow.l.struck"],["nVleftarrow","arrow.l.dstruck"],["nvleftarrowtail","arrow.l.tail.struck"],["nVleftarrowtail","arrow.l.tail.dstruck"],["nvLeftrightarrow","arrow.l.r.double.struck"],["nvleftrightarrow","arrow.l.r.struck"],["nVleftrightarrow","arrow.l.r.dstruck"],["nvRightarrow","arrow.r.double.struck"],["nvrightarrow","arrow.r.struck"],["nVrightarrow","arrow.r.dstruck"],["nvrightarrowtail","arrow.r.tail.struck"],["nVrightarrowtail","arrow.r.tail.dstruck"],["nvtwoheadleftarrow","arrow.l.twohead.struck"],["nVtwoheadleftarrow","arrow.l.twohead.dstruck"],["nvtwoheadleftarrowtail","arrow.l.twohead.tail.struck"],["nVtwoheadleftarrowtail","arrow.l.twohead.tail.dstruck"],["nvtwoheadrightarrow","arrow.r.twohead.struck"],["nVtwoheadrightarrow","arrow.r.twohead.dstruck"],["nvtwoheadrightarrowtail","arrow.r.twohead.tail.struck"],["nVtwoheadrightarrowtail","arrow.r.twohead.tail.dstruck"],["Nwarrow","arrow.tl.double"],["nwsearrow","arrow.tl.br"],["obrbrak","shell.t"],["obslash","backslash.o"],["odiv","div.o"],["odot","dot.o"],["odotslashdot","div.slanted.o"],["ogreaterthan","gt.o"],["oiiint","integral.vol"],["oiint","integral.surf"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["olessthan","lt.o"],["ominus","minus.o"],["operp","perp.o"],["oplus","plus.o"],["opluslhrim","plus.o.l"],["oplusrhrim","plus.o.r"],["origof","original"],["oslash","slash.o"],["otimes","times.o"],["otimeshat","times.o.hat"],["otimeslhrim","times.o.l"],["otimesrhrim","times.o.r"],["parallel","parallel"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["parsim","parallel.tilde"],["partial","partial"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["perp","perp"],["pm","plus.minus"],["prec","prec"],["Prec","prec.double"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["prime","prime"],["prod","product"],["propto","prop"],["QED","qed"],["qprime","prime.quad"],["quarternote","note.quarter.alt"],["questeq","eq.quest"],["Question","quest.double"],["rangle","chevron.r"],["rAngle","chevron.r.double"],["rangledot","chevron.r.dot"],["rangledownzigzagarrow","angle.azimuth"],["rbag","bag.r"],["rblkbrbrak","shell.r.filled"],["rbrace","brace.r"],["rBrace","brace.r.stroked"],["rbrack","bracket.r"],["rBrack","bracket.r.stroked"],["rbracklrtick","bracket.r.tick.b"],["rbrackurtick","bracket.r.tick.t"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.stroked"],["rceil","ceil.r"],["rcurvyangle","chevron.r.curly"],["Re","Re"],["revangle","angle.rev"],["revemptyset","emptyset.rev"],["revnmid","divides.not.rev"],["rfloor","floor.r"],["rgroup","paren.r.flat"],["rightangle","angle.right"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.square"],["rightarrow","arrow.r"],["Rightarrow","arrow.r.double"],["rightarrowbar","arrow.r.stop"],["rightarrowonoplus","plus.o.arrow"],["rightarrowtail","arrow.r.tail"],["rightarrowtriangle","arrow.r.open"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["rightdowncurvedarrow","arrow.r.curve"],["rightharpoondown","harpoon.rb"],["rightharpoondownbar","harpoon.rb.stop"],["rightharpoonsupdown","harpoons.rtrb"],["rightharpoonup","harpoon.rt"],["rightharpoonupbar","harpoon.rt.stop"],["rightleftarrows","arrows.rl"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoonsup","harpoons.rtlt"],["rightouterjoin","join.r"],["rightrightarrows","arrows.rr"],["rightsquigarrow","arrow.r.squiggly"],["rightthreearrows","arrows.rrr"],["rightthreetimes","times.three.r"],["rightwavearrow","arrow.r.wave"],["rightwhitearrow","arrow.r.stroked"],["risingdotseq","eq.dots.up"],["rmoustache","mustache.r"],["rparen","paren.r"],["rParen","paren.r.stroked"],["rrangle","chevron.r.closed"],["RRightarrow","arrow.r.quad"],["Rrightarrow","arrow.r.triple"],["rrparenthesis","paren.r.closed"],["rsolbar","backslash.not"],["rtimes","times.r"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["Searrow","arrow.br.double"],["setminus","without"],["sharp","sharp"],["shortdowntack","tack.b.short"],["shortlefttack","tack.l.short"],["shortuptack","tack.t.short"],["sim","tilde.op"],["sime","tilde.eq"],["similarleftarrow","arrow.l.tilde"],["similarrightarrow","arrow.r.tilde"],["simneqq","tilde.nequiv"],["smallblacktriangleleft","triangle.filled.small.l"],["smallblacktriangleright","triangle.filled.small.r"],["smallin","in.small"],["smallni","in.rev.small"],["smalltriangleleft","triangle.stroked.small.l"],["smalltriangleright","triangle.stroked.small.r"],["smashtimes","smash"],["smblkcircle","bullet"],["smblkdiamond","diamond.filled.small"],["smblklozenge","lozenge.filled.small"],["smeparsl","parallel.slanted.eq.tilde"],["smile","smile"],["smt","smt"],["smte","smt.eq"],["smwhtcircle","bullet.stroked"],["smwhtdiamond","diamond.stroked.small"],["smwhtlozenge","lozenge.stroked.small"],["sphericalangle","angle.spheric"],["sphericalangleup","angle.spheric.t"],["sqcap","inter.sq"],["Sqcap","inter.sq.double"],["sqcup","union.sq"],["Sqcup","union.sq.double"],["sqint","integral.square"],["sqsubset","subset.sq"],["sqsubseteq","subset.eq.sq"],["sqsubsetneq","subset.sq.neq"],["sqsupset","supset.sq"],["sqsupseteq","supset.eq.sq"],["sqsupsetneq","supset.sq.neq"],["squoval","square.stroked.rounded"],["sslash","slash.double"],["star","star.op"],["stareq","eq.star"],["subset","subset"],["Subset","subset.double"],["subsetdot","subset.dot"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["Succ","succ.double"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["sum","sum"],["sumint","sum.integral"],["supset","supset"],["Supset","supset.double"],["supsetdot","supset.dot"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["Swarrow","arrow.bl.double"],["therefore","therefore"],["threedangle","angle.spatial"],["threedotcolon","colon.tri.op"],["tieinfty","infinity.tie"],["times","times"],["tminus","miny"],["top","tack.b"],["tplus","tiny"],["trianglecdot","triangle.stroked.dot"],["triangledown","triangle.stroked.small.b"],["triangleleft","triangle.stroked.l"],["trianglelefteq","lt.tri.eq"],["triangleminus","minus.triangle"],["triangleplus","plus.triangle"],["triangleq","eq.delta"],["triangleright","triangle.stroked.r"],["trianglerighteq","gt.tri.eq"],["triangletimes","times.triangle"],["tripleplus","plus.triple"],["trprime","prime.triple"],["trslash","slash.triple"],["turnediota","iota.inv"],["twoheaddownarrow","arrow.b.twohead"],["twoheadleftarrow","arrow.l.twohead"],["twoheadleftarrowtail","arrow.l.twohead.tail"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["twoheadrightarrowtail","arrow.r.twohead.tail"],["twoheaduparrow","arrow.t.twohead"],["twonotes","note.eighth.beamed"],["ubrbrak","shell.b"],["ulblacktriangle","triangle.filled.tl"],["ulcorner","corner.l.t"],["ultriangle","triangle.stroked.tl"],["uminus","union.minus"],["underbrace","brace.b"],["underbracket","bracket.b"],["underparen","paren.b"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["upand","amp.inv"],["uparrow","arrow.t"],["Uparrow","arrow.t.double"],["uparrowbarred","arrow.t.struck"],["upbackepsilon","epsilon.alt.rev"],["updasharrow","arrow.t.dashed"],["upDigamma","Digamma"],["updigamma","digamma"],["Updownarrow","arrow.t.b.double"],["updownarrows","arrows.tb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["upharpoonsleftright","harpoons.tltr"],["uplus","union.plus"],["upuparrows","arrows.tt"],["upwhitearrow","arrow.t.stroked"],["urblacktriangle","triangle.filled.tr"],["urcorner","corner.r.t"],["urtriangle","triangle.stroked.tr"],["UUparrow","arrow.t.quad"],["Uuparrow","arrow.t.triple"],["varclubsuit","suit.club.stroked"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["varnothing","emptyset"],["varointclockwise","integral.cont.cw"],["varspadesuit","suit.spade.stroked"],["vartriangle","triangle.stroked.small.t"],["vartriangleleft","lt.tri"],["vartriangleright","gt.tri"],["Vbar","tack.t.double"],["Vdash","forces"],["vdash","tack.r"],["vDash","tack.r.double"],["vdots","dots.v"],["vee","or"],["Vee","or.double"],["veedot","or.dot"],["veeeq","eq.equi"],["vert","bar.v"],["Vert","bar.v.double"],["vlongdash","tack.r.long"],["vrectangle","rect.stroked.v"],["vrectangleblack","rect.filled.v"],["Vvert","bar.v.triple"],["vysmblkcircle","circle.filled.small"],["vysmwhtcircle","circle.stroked.tiny"],["wedge","and"],["Wedge","and.double"],["wedgedot","and.dot"],["wedgeq","eq.est"],["whiteinwhitetriangle","triangle.stroked.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["wideangledown","angle.obtuse"],["wr","wreath"],["xsol","slash.big"]]),ct=new Map([["gets","leftarrow"],["iff","Longleftrightarrow"],["implies","Longrightarrow"]]);for(let[n,e]of ut)x.has(n)||x.set(n,e);var X=new Map;for(let[n,e]of Array.from(x.entries()).reverse())X.set(e,n);var ht=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["infinity","infty"],["diff","partial"]]);for(let[n,e]of ht)X.set(n,e);for(let[n,e]of ct)x.has(n)||x.set(n,x.get(e));var Y=class extends Error{node;constructor(e,r=null){super(e),this.name="ConverterError",this.node=r}},dt=i.NONE.toNode(),Tt=["dim","id","im","mod","Pr","sech","csch"];function gt(n){if(/^[a-zA-Z0-9]$/.test(n))return n;if(n==="/")return"\\/";if(["\\\\","\\{","\\}","\\%"].includes(n))return n.substring(1);if(["\\$","\\#","\\&","\\_"].includes(n))return n;if(n.startsWith("\\")){let e=n.slice(1);return x.has(e)?x.get(e):null}return n}function P(n,e){let r;switch(n.type){case 0:return i.NONE;case 2:r=1;break;case 1:r=2;break;case 3:r=3;break;case 4:r=5;break;case 5:r=6;break;case 6:r=8;break;case 7:{if(n.value==="\\\\")return new i(7,"\\");if(n.value==="\\!")return new i(1,"#h(-math.thin.amount)");if(n.value==="~"){let s=x.get("~");return new i(1,s)}else if(x.has(n.value.substring(1))){let s=x.get(n.value.substring(1));return new i(1,s)}else throw new Error(`Unknown control sequence: ${n.value}`)}default:throw Error(`Unknown token type: ${n.type}`)}let t=gt(n.value);if(t===null){if(e.nonStrict)return new i(r,n.value.substring(1));throw new Y(`Unknown token: ${n.value}`,n)}return new i(r,t)}function bt(n,e){let[r,t]=n.args;if(e.optimize&&["\\overset{\\text{def}}{=}","\\overset{d e f}{=}"].includes(n.toString()))return new i(1,"eq.def").toNode();let s=new w(new i(1,"limits"),[b(t,e)]);return new _({base:s,sup:b(r,e),sub:null})}function mt(n,e){let[r,t]=n.args,s=new w(new i(1,"limits"),[b(t,e)]);return new _({base:s,sub:b(r,e),sup:null})}function wt(n){let e={},r={l:"#left",c:"#center",r:"#right"},t=Array.from(n),s=[],o=0;for(let l of t)l==="|"?s.push(o):(l==="l"||l==="c"||l==="r")&&o++;if(s.length>0){let l;s.length===1?l=`#${s[0]}`:l=`#(vline: (${s.join(", ")}))`,e.augment=new i(3,l).toNode()}let a=t.map(l=>r[l]).filter(l=>l!==void 0).map(l=>new i(3,l).toNode());if(a.length>0){let l=a.every(u=>u.eq(a[0]));e.align=l?a[0]:new i(3,"#center").toNode()}return e}var ft=new i(2,"("),yt=new i(2,")");function Ne(n){return["group","supsub","matrixLike","fraction","empty"].includes(n.type)?new f(null,{left:ft,right:yt,body:n}):n}function b(n,e){switch(n.type){case"terminal":return P(n.head,e).toNode();case"text":{let s=n;return new i(4,s.head.value).toNode()}case"ordgroup":let t=n;return new L(t.items.map(s=>b(s,e)));case"supsub":{let s=n,{base:o,sup:a,sub:l}=s;if(o&&o.type==="funcCall"&&o.head.value==="\\overbrace"&&a)return new w(new i(1,"overbrace"),[b(o.args[0],e),b(a,e)]);if(o&&o.type==="funcCall"&&o.head.value==="\\underbrace"&&l)return new w(new i(1,"underbrace"),[b(o.args[0],e),b(l,e)]);let u={base:b(o,e),sup:a?b(a,e):null,sub:l?b(l,e):null};return u.sup&&(u.sup=Ne(u.sup)),u.sub&&(u.sub=Ne(u.sub)),new _(u)}case"leftright":{let s=n,{left:o,right:a}=s,l=b(s.body,e);if(e.optimize&&o!==null&&a!==null){let d=P(o,e),v=P(a,e);if(o.value==="\\|"&&a.value==="\\|")return new w(new i(1,"norm"),[l]);if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(o.value+a.value))return new L([d.toNode(),l,v.toNode()])}let u=function(d){return["(",")","{","["].includes(d.value)?new i(2,"\\"+d.value):d},c=o?P(o,e):null,h=a?P(a,e):null;return c&&c.value==="<"&&(c=new i(1,"chevron.l")),h&&h.value===">"&&(h=new i(1,"chevron.r")),c===null&&h!==null&&(h=u(h)),h===null&&c!==null&&(c=u(c)),new f(i.LR,{body:l,left:c,right:h})}case"funcCall":{let s=n,o=b(s.args[0],e);if(s.head.value==="\\sqrt"&&s.data){let a=b(s.data,e);return new w(new i(1,"root"),[a,o])}if(s.head.value==="\\mathbf"){let a=new w(new i(1,"bold"),[o]);return new w(new i(1,"upright"),[a])}if(s.head.value==="\\overrightarrow")return new w(new i(1,"arrow"),[o]);if(s.head.value==="\\overleftarrow")return new w(new i(1,"accent"),[o,new i(1,"arrow.l").toNode()]);if(s.head.value==="\\operatorname"||s.head.value==="\\operatorname*"){if(e.optimize&&Tt.includes(o.head.value))return new i(1,o.head.value).toNode();let a=new w(new i(1,"op"),[new i(4,o.head.value).toNode()]);return s.head.value==="\\operatorname*"&&a.setOptions({limits:new i(3,"#true").toNode()}),a}if(s.head.value==="\\textcolor"){let a=new D(new i(1,"#text"),[b(s.args[1],e)]);return a.setOptions({fill:o}),a}if(s.head.value==="\\substack"||s.head.value==="\\displaylines"||s.head.value==="\\mathinner")return o;if(s.head.value==="\\mathrel")return new w(new i(1,"class"),[new i(4,"relation").toNode(),o]);if(s.head.value==="\\mathbin")return new w(new i(1,"class"),[new i(4,"binary").toNode(),o]);if(s.head.value==="\\mathop")return new w(new i(1,"class"),[new i(4,"large").toNode(),o]);if(s.head.value==="\\not"){let a=b(s.args[0],e);if(T(a.type==="terminal"),a.head.type===1)return new i(1,a.head.value+".not").toNode();switch(a.head.value){case"=":return new i(1,"eq.not").toNode();default:throw new Error(`Not supported: \\not ${a.head.value}`)}}if(s.head.value==="\\pmod"){let a=new L([new i(1,"mod").toNode(),o]);return new f(null,{body:a,left:i.LEFT_PAREN,right:i.RIGHT_PAREN})}if(s.head.value==="\\overset")return bt(s,e);if(s.head.value==="\\underset")return mt(s,e);if(["\\bra","\\ket","\\braket","\\set","\\Bra","\\Ket","\\Braket","\\Set"].includes(s.head.value)){let a=function(l,u){let c=new w(new i(1,"mid"),[i.VERTICAL_BAR.toNode()]);if(l.type==="terminal"&&l.head.eq(i.VERTICAL_BAR))return c;if(l.type==="group"){let h=l;for(let d=0;d<h.items.length&&!(h.items[d].type==="terminal"&&h.items[d].head.eq(i.VERTICAL_BAR)&&(h.items[d]=c,u));d++);return h}else return l};var r=a;switch(s.head.value){case"\\bra":return new f(null,{body:o,left:i.LEFT_ANGLE,right:i.VERTICAL_BAR});case"\\ket":return new f(null,{body:o,left:i.VERTICAL_BAR,right:i.RIGHT_ANGLE});case"\\braket":return new f(null,{body:o,left:i.LEFT_ANGLE,right:i.RIGHT_ANGLE});case"\\set":return new f(null,{body:o,left:i.LEFT_BRACE,right:i.RIGHT_BRACE});case"\\Bra":return new f(i.LR,{body:o,left:i.LEFT_ANGLE,right:i.VERTICAL_BAR});case"\\Ket":return new f(i.LR,{body:o,left:i.VERTICAL_BAR,right:i.RIGHT_ANGLE});case"\\Braket":return new f(i.LR,{body:a(o,!1),left:i.LEFT_ANGLE,right:i.RIGHT_ANGLE});case"\\Set":return new f(i.LR,{body:a(o,!0),left:i.LEFT_BRACE,right:i.RIGHT_BRACE});default:}}if(s.head.value==="\\frac"&&e.fracToSlash)return new B(s.args.map(a=>b(a,e)).map(Ne));if(e.optimize){if(s.head.value==="\\mathbb"&&/^\\mathbb{[A-Z]}$/.test(s.toString()))return new i(1,o.head.value.repeat(2)).toNode();if(s.head.value==="\\mathrm"&&s.toString()==="\\mathrm{d}")return new i(1,"dif").toNode()}return new w(P(s.head,e),s.args.map(a=>b(a,e)))}case"beginend":{let s=n,o=s.matrix.map(a=>a.map(l=>b(l,e)));if(s.head.value.startsWith("align"))return new E(null,o);if(s.head.value==="cases")return new E(E.CASES,o);if(s.head.value==="subarray"){if(s.data)switch(s.data.head.value){case"r":o.forEach(l=>l.push(i.EMPTY.toNode()));break;case"l":o.forEach(l=>l.unshift(i.EMPTY.toNode()));break;default:break}return new E(null,o)}if(s.head.value==="array"){let a={delim:dt};T(s.data!==null&&s.head.type===3);let l=wt(s.data.head.value);Object.assign(a,l);let u=new E(E.MAT,o);return u.setOptions(a),u}if(s.head.value.endsWith("matrix")){let a=new E(E.MAT,o),l;switch(s.head.value){case"matrix":l=i.NONE;break;case"pmatrix":return a;case"bmatrix":l=new i(4,"[");break;case"Bmatrix":l=new i(4,"{");break;case"vmatrix":l=new i(4,"|");break;case"Vmatrix":{l=new i(1,"bar.v.double");break}default:throw new Y(`Unimplemented beginend: ${s.head}`,s)}return a.setOptions({delim:l.toNode()}),a}throw new Y(`Unimplemented beginend: ${s.head}`,s)}default:throw new Y(`Unimplemented node type: ${n.type}`,n)}}function A(n,e="other"){switch(n.type){case 0:return p.EMPTY;case 1:{let r=function(t){switch(t){case"eq":return"=";case"plus":return"+";case"minus":return"-";case"percent":return"%";case"dot":return e==="func-name"?"\\dot":"\\cdot";default:return X.has(t)?"\\"+X.get(t):"\\"+t}};if(n.value.endsWith(".not")){let t=r(n.value.slice(0,-4));return new p(2,t.startsWith("\\")?`\\not${t}`:`\\not ${t}`)}return new p(2,r(n.value))}case 2:{let r;return["{","}","%"].includes(n.value)?r="\\"+n.value:r=n.value,new p(1,r)}case 3:return new p(3,n.value);case 4:return new p(3,n.value);case 5:return new p(4,n.value);case 6:return new p(5,n.value);case 7:{let r;switch(n.value){case"\\":r="\\\\";break;case"&":r="&";break;default:throw new Error(`[typst_token_to_tex]Unimplemented control sequence: ${n.value}`)}return new p(7,r)}case 8:return new p(6,n.value);default:throw new Error(`Unimplemented token type: ${n.type}`)}}var Et=new p(1,",").toNode();function xe(n,e){let r=t=>xe(t,e);switch(n.type){case"terminal":{let t=n;return t.head.type===1&&/^([A-Z])\1$/.test(t.head.value)?new m(new p(2,"\\mathbb"),[new p(1,t.head.value[0]).toNode()]):t.head.type===4?new R(new p(3,t.head.value)):A(t.head).toNode()}case"group":{let s=n.items.map(r),o=new p(7,"&").toNode(),a=new p(7,"\\\\").toNode();if(K(s,o)){let l=C(s,a),u=[];for(let c of l){let h=C(c,o);u.push(h.map(d=>new y(d)))}return new q(new p(3,"aligned"),u)}return new y(s)}case"leftright":{let t=n,s=r(t.body),o=t.left?A(t.left):new p(1,"."),a=t.right?A(t.right):new p(1,".");return t.isOverHigh()&&(o.value="\\left"+o.value,a.value="\\right"+a.value),new y([o.toNode(),s,a.toNode()])}case"funcCall":{let t=n;switch(t.head.value){case"norm":{let s=t.args[0],o=r(s);return t.isOverHigh()?new O({body:o,left:new p(2,"\\|"),right:new p(2,"\\|")}):o}case"floor":case"ceil":{let s="\\l"+t.head.value,o="\\r"+t.head.value,a=t.args[0],l=r(a),u=new p(2,s),c=new p(2,o);return t.isOverHigh()?new O({body:l,left:u,right:c}):new y([u.toNode(),l,c.toNode()])}case"root":{let[s,o]=t.args,a=r(s);return new m(new p(2,"\\sqrt"),[r(o)],a)}case"overbrace":case"underbrace":{let[s,o]=t.args,a=new m(A(t.head),[r(s)]),l=r(o),u=t.head.value==="overbrace"?{base:a,sup:l,sub:null}:{base:a,sub:l,sup:null};return new S(u)}case"vec":{let s=t.args.map(o=>[r(o)]);return new q(new p(3,"pmatrix"),s)}case"op":{let s=t.args[0];return T(s.head.type===4),new m(A(t.head),[new p(3,s.head.value).toNode()])}case"class":{let s=t.args[0];T(s.head.type===4);let o;switch(s.head.value){case"relation":o="\\mathrel";break;case"binary":o="\\mathbin";break;case"large":o="\\mathop";break;default:throw new Error(`Unimplemented class: ${s.head.value}`)}return new m(new p(2,o),[r(t.args[1])])}case"display":{let s=t.args[0],o=new y([p.COMMAND_DISPLAYSTYLE.toNode(),r(s)]);return e.blockMathMode||o.items.push(p.COMMAND_TEXTSTYLE.toNode()),o}case"inline":{let s=t.args[0],o=new y([p.COMMAND_TEXTSTYLE.toNode(),r(s)]);return e.blockMathMode&&o.items.push(p.COMMAND_DISPLAYSTYLE.toNode()),o}default:{let s=A(t.head,"func-name"),o=U.includes(s.value.substring(1))||W.includes(s.value.substring(1));return s.value.length>0&&o?new m(s,t.args.map(r)):new y([A(t.head).toNode(),new p(1,"(").toNode(),..._e(t.args.map(r),Et),new p(1,")").toNode()])}}}case"markupFunc":{let t=n;switch(t.head.value){case"#text":if(t.options&&t.options.fill){let s=t.options.fill;return new m(new p(2,"\\textcolor"),[r(s),r(t.fragments[0])])}case"#heading":default:throw new Error(`Unimplemented markup function: ${t.head.value}`)}}case"supsub":{let t=n,{base:s,sup:o,sub:a}=t,l=o?r(o):null,u=a?r(a):null;if(s.head.eq(new i(1,"limits"))){let v=r(s.args[0]);if(l!==null&&u===null)return new m(new p(2,"\\overset"),[l,v]);if(l===null&&u!==null)return new m(new p(2,"\\underset"),[u,v]);{let pe=new m(new p(2,"\\underset"),[u,v]);return new m(new p(2,"\\overset"),[l,pe])}}let c=r(s);return new S({base:c,sup:l,sub:u})}case"matrixLike":{let t=n,s=t.matrix.map(o=>o.map(r));if(t.head.eq(E.MAT)){let o="pmatrix";if(t.options&&"delim"in t.options){let a=t.options.delim;switch(a.head.value){case"#none":o="matrix";break;case"[":case"]":o="bmatrix";break;case"(":case")":o="pmatrix";break;case"{":case"}":o="Bmatrix";break;case"|":o="vmatrix";break;case"bar":case"bar.v":o="vmatrix";break;case"bar.v.double":o="Vmatrix";break;default:throw new Error(`Unexpected delimiter ${a.head}`)}}return new q(new p(3,o),s)}else{if(t.head.eq(E.CASES))return new q(new p(3,"cases"),s);throw new Error(`Unexpected matrix type ${t.head}`)}}case"fraction":{let t=n,[s,o]=t.args,a=r(s),l=r(o);return new m(new p(2,"\\frac"),[a,l])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+n.type)}}var Nt=Array.from(ee.keys());function xt(){return`(${Nt.map(e=>(e=e.replaceAll("|","\\|"),e=e.replaceAll(".","\\."),e=e.replaceAll("[","\\["),e=e.replaceAll("]","\\]"),e)).join("|")})`}var vt=xt(),kt=new Map([[String.raw`//[^\n]*`,n=>new i(5,n.text().substring(2))],[String.raw`/`,n=>new i(2,n.text())],[String.raw`[_^&]`,n=>new i(7,n.text())],[String.raw`\r?\n`,n=>new i(8,`
|
|
9
|
+
`)],[String.raw`\s+`,n=>new i(6,n.text())],[String.raw`\\[$&#_]`,n=>new i(2,n.text())],[String.raw`\\\n`,n=>[new i(7,"\\"),new i(8,`
|
|
10
|
+
`)]],[String.raw`\\\s`,n=>[new i(7,"\\"),new i(6," ")]],[String.raw`\\\S`,n=>new i(7,"")],[String.raw`"([^"]|(\\"))*"`,n=>{let e=n.text().substring(1,n.text().length-1);return e.replaceAll('\\"','"'),new i(4,e)}],[vt,n=>{let e=n.text(),r=ee.get(e);return new i(1,r)}],[String.raw`[0-9]+(\.[0-9]+)?`,n=>new i(2,n.text())],[String.raw`[+\-*/=\'<>!.,;?()\[\]|]`,n=>new i(2,n.text())],[String.raw`#h\((.+?)\)`,n=>{let e=n.reMatchArray();return[new i(1,"#h"),new i(2,"("),new i(3,e[1]),new i(2,")")]}],[String.raw`#none`,n=>new i(0,n.text())],[String.raw`#?[a-zA-Z\.]+`,n=>new i(n.text().length===1?2:1,n.text())],[String.raw`.`,n=>new i(2,n.text())]]),Lt={start:kt};function Pe(n){return new I(Lt).collect(n)}function Ye(n,e){let r=e;for(;r<n.length&&n[r].eq(new i(2,"'"));)r+=1;return r-e}function He(n,e,r,t){T(n[e].isOneOf(r));let s=1,o=e+1;for(;s>0;){if(o>=n.length)throw new Error("Unmatched brackets or parentheses");n[o].isOneOf(t)?s-=1:n[o].isOneOf(r)&&(s+=1),o+=1}return o-1}function ve(n,e){return He(n,e,[V,Ge,At],[oe,Fe,Rt])}function Mt(n){let e=new i(2,":").toNode(),r={},t=[];for(let s=0;s<n.length;s++){if(n[s].type!=="group")continue;let o=n[s],a=he(o.items,e);if(a===-1||a===0)continue;if(t.push(s),o.items[a-1].eq(new i(1,"delim").toNode())){if(o.items.length!==3)throw new j("Invalid number of arguments for delim");r.delim=o.items[a+1]}else throw new j("Not implemented for other named parameters")}for(let s=t.length-1;s>=0;s--)n.splice(t[s],1);return[n,r]}function ze(n){let e=[];for(let r=0;r<n;r++)e.push(new i(2,"'").toNode());return e}var ae=new i(2,"/").toNode();function qt(n,e){let r=e;for(;r<n.length&&(n[r].head.type===6||n[r].head.type===8);)r++;return r===n.length?null:n[r]}function _t(n){let e=!1,r=[];for(let t=0;t<n.length;t++){let s=n[t];(s.head.type===6||s.head.type===8)&&(e||qt(n,t+1)?.eq(ae))||(s.eq(ae)?e=!0:e=!1,r.push(s))}return r}function St(n){n=_t(n);let e=[],r=[],t=0;for(;t<n.length;){let s=n[t];if(s.eq(ae))e.push(s);else if(e.length>0&&e[e.length-1].eq(ae)){let o=s;if(r.length===0)throw new j("Unexpected '/' operator, no numerator before it");let a=r.pop();o.type==="leftright"&&(o=o.body),a.type==="leftright"&&(a=a.body),r.push(new B([a,o])),e.pop()}else r.push(s);t++}return r.length===1?r[0]:new L(r)}function Ot(n){let e=new i(2,":").toNode(),r={};for(let t of n)T(t.items.length==3),T(t.items[1].eq(e)),r[t.items[0].toString()]=new $(new i(3,t.items[2].toString()));return r}var j=class extends Error{constructor(e){super(e),this.name="TypstParserError"}},Ue=new i(7,"_"),We=new i(7,"^"),V=new i(2,"("),oe=new i(2,")"),Ge=new i(2,"["),Fe=new i(2,"]"),At=new i(2,"{"),Rt=new i(2,"}"),ke=new i(2,","),Ct=new i(2,";"),It=new i(7,"&"),Le=class{space_sensitive;newline_sensitive;constructor(e=!0,r=!0){this.space_sensitive=e,this.newline_sensitive=r}parse(e){let[r,t]=this.parseGroup(e,0,e.length);return r}parseGroup(e,r,t){return this.parseUntil(e.slice(r,t),0,null)}parseNextExpr(e,r){let[t,s]=this.parseNextExprWithoutSupSub(e,r),o=null,a=null,l=Ye(e,s);if(l>0&&(t=new L([t].concat(ze(l))),s+=l),s<e.length&&e[s].eq(Ue)?([o,s]=this.parseSupOrSub(e,s+1),s<e.length&&e[s].eq(We)&&([a,s]=this.parseSupOrSub(e,s+1))):s<e.length&&e[s].eq(We)&&([a,s]=this.parseSupOrSub(e,s+1),s<e.length&&e[s].eq(Ue)&&([o,s]=this.parseSupOrSub(e,s+1))),o!==null||a!==null){let u={base:t,sup:a,sub:o};return[new _(u),s]}else return[t,s]}parseUntil(e,r,t,s={}){s.spaceSensitive===void 0&&(s.spaceSensitive=this.space_sensitive),s.newlineSensitive===void 0&&(s.newlineSensitive=this.newline_sensitive);let o=[],a=r;for(;a<e.length&&!(t!==null&&e[a].eq(t));){let[u,c]=this.parseNextExpr(e,a);a=c,!((u.head.type===6||u.head.type===8)&&(!s.spaceSensitive&&u.head.value.replace(/ /g,"").length===0||!s.newlineSensitive&&u.head.value===`
|
|
11
|
+
`))&&o.push(u)}return a>=e.length&&t!==null?[i.NONE.toNode(),-1]:[St(o),a+1]}parseSupOrSub(e,r){let t,s;if(e[r].eq(V)){if([t,s]=this.parseUntil(e,r+1,oe),s===-1)throw new Error("Unmatched '('")}else[t,s]=this.parseNextExprWithoutSupSub(e,r);let o=Ye(e,s);return o>0&&(t=new L([t].concat(ze(o))),s+=o),[t,s]}parseNextExprWithoutSupSub(e,r){let t=e[r],s=t.toNode();if(t.eq(V)){let[o,a]=this.parseUntil(e,r+1,oe);if(a===-1)throw new Error("Unmatched '('");return[new f(null,{body:o,left:V,right:oe}),a]}if(t.type===2&&!z(t.value[0]))return[s,r+1];if([2,1].includes(t.type)&&r+1<e.length&&e[r+1].eq(V)){if(t.value==="mat"){let[u,c,h]=this.parseMatrix(e,r+1,Ct,ke),d=new E(t,u);return d.setOptions(c),[d,h]}if(t.value==="cases"){let[u,c,h]=this.parseMatrix(e,r+1,ke,It),d=new E(t,u);return d.setOptions(c),[d,h]}if(t.value==="lr")return this.parseLrArguments(e,r+1);if(["#heading","#text"].includes(t.value)){let[u,c]=this.parseArguments(e,r+1),h=Ot(u);T(e[c].eq(Ge));let d=new i(2,"$"),v=He(e,c+1,[d],[d]),[pe,Pt]=this.parseGroup(e,c+2,v);T(e[v+1].eq(Fe));let Me=new D(t,[pe]);return Me.setOptions(h),[Me,v+2]}let[o,a]=this.parseArguments(e,r+1);return[new w(t,o),a]}return[s,r+1]}parseArguments(e,r){let t=ve(e,r);return[this.parseArgumentsWithSeparator(e,r+1,t,ke),t+1]}parseLrArguments(e,r){let t=new i(1,"lr"),s=ve(e,r),o=null,a=null,l=r+1,u=s;u>l&&e[l].isOneOf(i.LEFT_DELIMITERS)&&(o=e[l],l+=1),u-1>l&&e[u-1].isOneOf(i.RIGHT_DELIMITERS)&&(a=e[u-1],u-=1);let[c,h]=this.parseGroup(e,l,u);return[new f(t,{body:c,left:o,right:a}),s+1]}parseMatrix(e,r,t,s){let o=ve(e,r),a=[],l={},u=r+1;for(;u<o;)for(;u<o;){let c=he(e,t,u);(c===-1||c>o)&&(c=o);let h=this.parseArgumentsWithSeparator(e,u,c,s),d={};[h,d]=Mt(h),a.push(h),Object.assign(l,d),u=c+1}return[a,l,o+1]}parseArgumentsWithSeparator(e,r,t,s){let o=[],a=r;for(;a<t;){let l,u,c={spaceSensitive:!1,newlineSensitive:!0};[l,u]=this.parseUntil(e.slice(0,t),a,s,c),u==-1&&([l,u]=this.parseUntil(e.slice(0,t),a,null,c)),o.push(l),a=u}return o}};function ie(n){let e=new Le,r=Pe(n);return e.parse(r)}var le=class{buffer="";queue=[];append(e){this.queue=this.queue.concat(e.serialize())}flushQueue(){for(let e=0;e<this.queue.length;e++)this.buffer=ce(this.buffer,this.queue[e]);this.queue=[]}finalize(){return this.flushQueue(),this.buffer=this.buffer.replace(/\\displaystyle \\displaystyle/g,"\\displaystyle"),this.buffer=this.buffer.replace(/\\textstyle \\textstyle/g,"\\textstyle"),this.buffer=this.buffer.replace(/\s?\\textstyle\s?$/,""),this.buffer=this.buffer.replace(/\s?\\displaystyle\s?$/,""),this.buffer}};var $e=new Map([["\\varGamma","\\mathit{\\Gamma}"],["\\varDelta","\\mathit{\\Delta}"],["\\varTheta","\\mathit{\\Theta}"],["\\varLambda","\\mathit{\\Lambda}"],["\\varXi","\\mathit{\\Xi}"],["\\varPi","\\mathit{\\Pi}"],["\\varSigma","\\mathit{\\Sigma}"],["\\varUpsilon","\\mathit{\\Upsilon}"],["\\varPhi","\\mathit{\\Phi}"],["\\varPsi","\\mathit{\\Psi}"],["\\varOmega","\\mathit{\\Omega}"],["\\doteq","\\dot{=}"]]);function Bt(n){switch(n.type){case"terminal":if(n.head.type===2&&$e.has(n.head.value)){let e=$e.get(n.head.value);return J(e)}case"funcCall":default:return n}}function Xe(n){return n.bottomTopTraversalTransform(Bt)}var Ve=new Map([["dif","upright(d)"],["eq.def",'limits(=)^"def"'],["oo","infinity"],["comma",","],["hyph",'"-"'],["hyph.minus",'"-"']]);function Dt(n){switch(n.type){case"terminal":if(n.head.type===1&&Ve.has(n.head.value)){let e=Ve.get(n.head.value);return ie(e)}case"funcCall":default:return n}}function je(n){return n.bottomTopTraversalTransform(Dt)}function Ke(n,e={}){let r={nonStrict:!0,preferShorthands:!0,keepSpaces:!1,fracToSlash:!0,inftyToOo:!1,optimize:!0,customTexMacros:{}};if(typeof e!="object")throw new Error("options must be an object");for(let l in r)l in e&&(r[l]=e[l]);let t=J(n,r.customTexMacros),s=Xe(t),o=b(s,r),a=new ne(r);return a.serialize(o),a.finalize()}function Ze(n,e={}){let r={blockMathMode:!0};if(typeof e!="object")throw new Error("options must be an object");for(let l in r)l in e&&(r[l]=e[l]);let t=ie(n),s=je(t),o=xe(s,r),a=new le;return a.append(o),a.finalize()}window.tex2typst=Ke;window.typst2tex=Ze;})();
|
package/package.json
CHANGED
package/src/convert.ts
CHANGED
|
@@ -752,25 +752,6 @@ export function convert_typst_node_to_tex(abstractNode: TypstNode, options: Typs
|
|
|
752
752
|
case 'terminal': {
|
|
753
753
|
const node = abstractNode as TypstTerminal;
|
|
754
754
|
if (node.head.type === TypstTokenType.SYMBOL) {
|
|
755
|
-
// special hook for eq.def
|
|
756
|
-
if (node.head.value === 'eq.def') {
|
|
757
|
-
return new TexFuncCall(new TexToken(TexTokenType.COMMAND, '\\overset'), [
|
|
758
|
-
new TexText(new TexToken(TexTokenType.LITERAL, 'def')),
|
|
759
|
-
new TexToken(TexTokenType.ELEMENT, '=').toNode()
|
|
760
|
-
]);
|
|
761
|
-
}
|
|
762
|
-
// special hook for comma
|
|
763
|
-
if(node.head.value === 'comma') {
|
|
764
|
-
return new TexToken(TexTokenType.ELEMENT, ',').toNode();
|
|
765
|
-
}
|
|
766
|
-
// special hook for dif
|
|
767
|
-
if(node.head.value === 'dif') {
|
|
768
|
-
return new TexFuncCall(new TexToken(TexTokenType.COMMAND, '\\mathrm'), [new TexToken(TexTokenType.ELEMENT, 'd').toNode()]);
|
|
769
|
-
}
|
|
770
|
-
// special hook for hyph and hyph.minus
|
|
771
|
-
if(node.head.value === 'hyph' || node.head.value === 'hyph.minus') {
|
|
772
|
-
return new TexText(new TexToken(TexTokenType.LITERAL, '-'));
|
|
773
|
-
}
|
|
774
755
|
// special hook for mathbb{R} <-- RR
|
|
775
756
|
if(/^([A-Z])\1$/.test(node.head.value)) {
|
|
776
757
|
return new TexFuncCall(new TexToken(TexTokenType.COMMAND, '\\mathbb'), [
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { parseTypst } from "./typst-parser";
|
|
|
8
8
|
import { TexWriter } from "./tex-writer";
|
|
9
9
|
import { shorthandMap } from "./typst-shorthands";
|
|
10
10
|
import { expand_tex_predefined_macros } from "./tex-semantic-analysis";
|
|
11
|
+
import { expand_typst_predefined_variables } from "./typst-semantic-analyais";
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
export function tex2typst(tex: string, options: Partial<Tex2TypstOptions> = {}): string {
|
|
@@ -53,7 +54,8 @@ export function typst2tex(typst: string, options: Partial<Typst2TexOptions> = {}
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
const typstTree = parseTypst(typst);
|
|
56
|
-
const
|
|
57
|
+
const preprocessedTypstTree = expand_typst_predefined_variables(typstTree);
|
|
58
|
+
const texTree = convert_typst_node_to_tex(preprocessedTypstTree, opt);
|
|
57
59
|
const writer = new TexWriter();
|
|
58
60
|
writer.append(texTree);
|
|
59
61
|
return writer.finalize();
|