"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e,i=require("lezer"); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function O(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function s(t,e,i){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,i),i}class r{constructor(t){this.v=t,this.children=[]}insert(t,e){let i=this;for(const e of Uint32Array.from(t,(t=>t.codePointAt(0))).reverse())void 0===i.children[e]&&(i.children[e]=new r(i.v)),i=i.children[e];i.v=e}lookup(t){let e=this;for(const i of Uint32Array.from(t,(t=>t.codePointAt(0))).reverse())if(e=e.children[i],void 0===e)return null;return e.v}}const a=Math.pow(2,19)-1,c=Math.pow(2,8)+1,o=Math.pow(2,5)-1,Q=Math.pow(2,31)-1;class n{constructor(i,O=0,s){this.groupType=i,this.depth=O,this.parent=s,this.reset=!1,this.command=null,t.set(this,0),e.set(this,!0),this.eqtb=void 0===O||void 0===s?{catcode:new Uint8Array(6*Math.pow(2,16)).fill(204)}:{catcode:[]}}get hash(){return O(this,e)&&(s(this,e,!1),s(this,t,this.generateHash())),O(this,t)}defineCatCode(t,i){if(t>=262144&&t<917504)throw new RangeError("Unicode point is valid, but unassigned");if(t>1114111)throw new RangeError("Unicode point is invalid");t>917503&&(t-=655360);const O=Math.floor(t/2);t%2==0?(this.eqtb.catcode[O]&=240,this.eqtb.catcode[O]+=i):(this.eqtb.catcode[O]&=15,this.eqtb.catcode[O]+=i<<4),s(this,e,!0)}getCatCode(t){if(t>=262144&&t<917504)throw new RangeError("Unicode point is valid, but unassigned");if(t>1114111)throw new RangeError("Unicode point is invalid");if(t<0)return-1;t>917503&&(t-=655360);const e=Math.floor(t/2);let i=this;for(;i&&void 0===i.eqtb.catcode[e];)i=i.parent;if(void 0===i)throw new Error("this shouldn't happen");return t%2==0?15&i.eqtb.catcode[e]:i.eqtb.catcode[e]>>4}generateEqTbHash(){let t=c;return this.eqtb.catcode.reduce(((e,i)=>(t=t*c%a,(e+i*t)%a)),0)<<11}generateHash(){let t=(this.parent?this.parent.hash:0)%o;return t+=this.depth<<5,t+=this.generateEqTbHash(),t%=Q,t}}t=new WeakMap,e=new WeakMap,n.primitives=new r(null);const h=`${/[0-9]+/.source}|${/0b[01]+/.source}|${/0x[a-z0-9]+/.source}|${/0o[0-8]+/.source}`,d=new RegExp(`change category code for code point (${h}) to (${h})`,"i");var l=new class{constructor({test:t,run:e,fallthrough:i}){this.test=t,this.run=e,this.fallthrough=!!i}exec(t,e){const i=this.test(t);return i?this.run(e,...i):null}}({test(t){const e=d.exec(t);if(e){const[,t,i]=e;return[parseInt(t),parseInt(i)]}},run:(t,e,i)=>(t.defineCatCode(e,i),t)}),u=Object.freeze({__proto__:null,catcodeDirective:l});const _=[0,1,2,3,4,5,6,7,8,9,35,36,37,10,0,11];function p(t,e){return(e?`${e}`:t[0]).codePointAt(0)}function f(t){return t>96&&t<103||t>47&&t<58}var m,g;class C{constructor(t){this.chr=t.chr,this.loc=t.loc,this.buf=t.buf,this.tok=t.tok,this.ctx=t.ctx,this.dct=t.dct}}class P extends i.ExternalTokenizer{constructor(){super(((t,e,i)=>{if(0===e.start&&(i.context.reset=!0),e.start>=t.length)return;let O=0;return i.dialectEnabled(0)&&(O|=1),s(this,m,new C({chr:t.get(e.start),loc:e.start+1,buf:t,tok:e,ctx:i.context,dct:O})),this.getNext()}),{contextual:!0}),m.set(this,void 0),g.set(this,2),this.nextIsDirective=()=>O(this,m).buf.get(O(this,m).loc)===p`!`}getNext(){switch(O(this,m).cmd=O(this,m).ctx.getCatCode(O(this,m).chr),O(this,m).cmd){case 1:case 2:case 3:case 4:case 5:case 6:case 8:case 9:case 10:case 11:case 12:case 13:case 15:O(this,m).tok.accept(_[O(this,m).cmd],O(this,m).loc);break;case 0:{this.scanControlSequence();const t=n.primitives.lookup(O(this,m).cs);if(null!==t){O(this,m).tok.accept(t[0],O(this,m).loc);break}O(this,m).tok.accept(38,O(this,m).loc);break}case 14:if((1&O(this,m).dct)>0&&this.nextIsDirective()){this.scanComment(),O(this,m).tok.accept(46,O(this,m).loc);break}this.scanComment(),O(this,m).tok.accept(47,O(this,m).loc);break;case 7:if(this.nextIsExpandedCharacter()){this.scanExpandedCharacter(),O(this,m).loc+=O(this,g),this.getNext();break}O(this,m).tok.accept(_[O(this,m).cmd],O(this,m).loc);break;default:throw new Error("Unknown character")}}scanControlSequence(){if(O(this,m).loc>=O(this,m).buf.length)return;O(this,m).chr=O(this,m).buf.get(O(this,m).loc++),O(this,m).cmd=O(this,m).ctx.getCatCode(O(this,m).chr);const t=[O(this,m).chr];if(7===O(this,m).cmd&&this.nextIsExpandedCharacter()&&(this.scanExpandedCharacter(),O(this,m).loc+=O(this,g),O(this,m).cmd=O(this,m).ctx.getCatCode(O(this,m).chr),t[0]=O(this,m).chr),11===O(this,m).cmd){do{O(this,m).chr=O(this,m).buf.get(O(this,m).loc++),O(this,m).cmd=O(this,m).ctx.getCatCode(O(this,m).chr),t.push(O(this,m).chr),7===O(this,m).cmd&&this.nextIsExpandedCharacter()&&(this.scanExpandedCharacter(),O(this,m).cmd=O(this,m).ctx.getCatCode(O(this,m).chr),11===O(this,m).cmd&&(t.push(O(this,m).chr),O(this,m).loc+=O(this,g)))}while(11===O(this,m).cmd);O(this,m).loc-=1,t.pop(),O(this,m).cs=String.fromCodePoint(...t)}else O(this,m).cs=String.fromCodePoint(...t)}scanComment(){do{O(this,m).chr=O(this,m).buf.get(O(this,m).loc++)}while(O(this,m).chr>-1&&5!==O(this,m).ctx.getCatCode(O(this,m).chr))}nextIsExpandedCharacter(){if(7!==O(this,m).ctx.getCatCode(O(this,m).buf.get(O(this,m).loc)))return!1;const t=O(this,m).buf.get(O(this,m).loc+1);return t>0&&t<128}scanExpandedCharacter(){if(s(this,g,2),O(this,m).chr=O(this,m).buf.get(O(this,m).loc+1),f(O(this,m).chr)){const t=O(this,m).buf.get(O(this,m).loc+2);f(t)&&(s(this,g,O(this,g)+1),O(this,m).chr=parseInt(`0x${String.fromCharCode(O(this,m).chr,t)}`,16))}O(this,m).chr=O(this,m).chr<64?O(this,m).chr+64:O(this,m).chr-64}}function R(){const t=new n(0);t.defineCatCode(p`\\`,0),t.defineCatCode(p`{`,1),t.defineCatCode(p`}`,2),t.defineCatCode(p`$`,3),t.defineCatCode(p`&`,4),t.defineCatCode(p`\r`,5),t.defineCatCode(p`\n`,5),t.defineCatCode(p`#`,6),t.defineCatCode(p`^`,7),t.defineCatCode(p`_`,8),t.defineCatCode(p`\x00`,9),t.defineCatCode(p` `,10);for(let e=p`A`;e<=p`Z`;e++)t.defineCatCode(e,11),t.defineCatCode(e-p`A`+p`a`,11);return t.defineCatCode(p`~`,13),t.defineCatCode(p`%`,14),t.defineCatCode(p`\x7F`,14),t}m=new WeakMap,g=new WeakMap,n.primitives.insert("begingroup",[39,""]),n.primitives.insert("endgroup",[40,""]),n.primitives.insert("let",[43,""]),n.primitives.insert("futurelet",[44,"future"]),n.primitives.insert("catcode",[41,"cat"]),n.primitives.insert("mathcode",[41,"math"]),n.primitives.insert("lccode",[41,"lc"]),n.primitives.insert("uccode",[41,"uc"]),n.primitives.insert("sfcode",[41,"sf"]),n.primitives.insert("delcode",[41,"del"]),n.primitives.insert("long",[45,"long"]),n.primitives.insert("outer",[45,"outer"]),n.primitives.insert("global",[45,"global"]),n.primitives.insert("def",[42,""]),n.primitives.insert("edef",[42,"e"]),n.primitives.insert("gdef",[42,"g"]),n.primitives.insert("xdef",[42,"x"]);class v extends i.ContextTracker{constructor(){super({start:R(),hash:t=>t.hash,shift:(t,e,i,O)=>(t.reset&&(t=R()),this.handleTerm(t,e,i,O))})}handleTerm(t,e,i,O){if(t.command)return t.command.match(e,i.read(O.ruleStart,O.pos)),t.command.ready?t.command.execute(t):t;switch(e){case 1:return new n(1,t.depth+1,t);case 13:return new n(2,t.depth+1,t);case 2:case 14:return t.parent||t;case 17:case 16:return 3!==t.groupType?new n(3,t.depth+1,t):t.parent;case 46:{const e=i.read(O.ruleStart+2,O.pos).trim();for(const i of Object.values(u)){const O=i.exec(e,t);if(O&&(t=O,!i.fallthrough))break}return t}}return t}}const x=new v,b=new P,w={__proto__:null,0:123,1:123,2:123,3:123,4:123,5:123,6:123,7:123,8:123,9:125,"=":111,"+":119,"-":119,"'":127,'"':129,A:133,B:133,C:133,D:133,E:133,F:133,"`":139},q={__proto__:null,A:135,B:135,C:135,D:135,E:135,F:135},T=i.Parser.deserialize({version:13,states:"4^OVQQOOO!jQQO'#D`OOQQ'#Ci'#CiO!qQQO'#DaOOQQ'#Cl'#ClOVQQO'#DbOVQQO'#DcOOQQ'#Ck'#CkOOQQ'#Cn'#CnOOQQ'#Cx'#CxO!xQQO'#DgOOQQ'#Co'#CoOOQQ'#Cp'#CpO#ZQQO'#DdOOQQ'#Cr'#CrO#ZQQO'#DfOOQQ'#Cs'#CsO#cQQO'#DgOOQQ'#Ct'#CtO#hQRO'#DhOOQQ'#Cv'#CvOOQQ'#D_'#D_OOQQ'#Cw'#CwQVQQOOOOQQ,59z,59zO$PQQO,59zOOQQ'#Cj'#CjOOQQ,59{,59{O!qQQO,59{POQQ,59X,59XOOQQ,59|,59|OVQQO,59|OOQQ,59},59}OVQQO,59}OOQQ-E6v-E6vO#ZQQO,5:OO#ZQQO,5:Q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loqRsYdeOPRTUgiloqQy]Q{_S!_sxS!atzQ!hyQ!k{Q!r!SQ!{!^U!}!_!f!iQ#P!`S#R!a!jQ#Y!kW#c!{!|#O#WS#g#P#QS#i#R#XU#o#b#d#eQ#r#fS#t#g#hS#y#p#qS#{#r#sQ$O#xR$P#zQ!iyQ!v!TS#O!_!fS#V!d!sS#d!{!|S#l#S#TQ#p#bR#v#jd_OPRTUgiloqRtYdaOPRTUgiloqRuYdcOPRTUgiloqRvYQ!TcS!dv}Q!u!TQ#S!cU#U!d!s!vW#k#S#T#V#^U#u#j#l#mS#}#v#wR$Q#|QgOQiPQlRQoTQqUZ!XgiloqdYOPRTUgiloqRrYQx]Qz_Q}cQ!^sQ!`tQ!cv!W!exz}!^!`!c!f!j!s!|#Q#T#W#X#^#b#e#f#h#j#m#q#s#w#x#z#|Q!fyQ!j{Q!s!TQ!|!_Q#Q!aQ#T!dQ#W!iQ#X!kQ#^!vQ#b!{Q#e#OQ#f#PQ#h#RQ#j#SQ#m#VQ#q#dQ#s#gQ#w#lQ#x#pQ#z#rR#|#vW!Ocv}!cS!l!O$Rm$R!T!d!s!v#S#T#V#^#j#l#m#v#w#|W!Rcv}!cQ!m!OS!p!t#]l!t!T!d!s!v#S#T#V#^#j#l#m#v#w#|R#]$RQ!m!VQ#Z!nQ#_$SS#`#_#nR#n$TQ!z!WQ#[!oW#a!z#[$U$VQ$U$WR$V$XefOPRTUgiloqdeOPRTUgiloqQ|aR!bueVOPRTUgiloq|!Qcv}!O!T!c!d!s!t!v#S#T#V#]#^#j#l#m#v#w#|$R]!x!W!o$U$V$W$Xa!y!W!o!z#[$U$V$W$Xt!Rcv}!T!c!d!s!v#S#T#V#^#j#l#m#v#w#|T!m!O$RR!r!S",nodeNames:"⚠ left_brace right_brace math_shift tab_mark car_ret mac_param sup_mark sub_mark ignore active_char invalid_char Document begingroup_cs endgroup_cs math_shift_group single_math_shift double_math_shift prefix_cs let_cs control_sequence optional_equal futurelet_cs def_cs defcode_cs integer directive",maxTerm:70,context:x,nodeProps:[[i.NodeProp.closedBy,1,"right_brace",16,"single_math_shift",17,"double_math_shift"],[i.NodeProp.openedBy,2,"left_brace",16,"single_math_shift",17,"double_math_shift"]],skippedNodes:[0],repeatNodeCount:7,tokenData:"RORO",tokenizers:[0,b],topRules:{Document:[0,12]},dialects:{directives:647},specialized:[{term:37,get:t=>w[t]||-1},{term:36,get:t=>q[t]||-1}],tokenPrec:0,termNames:{0:"⚠",1:"left_brace",2:"right_brace",3:"math_shift",4:"tab_mark",5:"car_ret",6:"mac_param",7:"sup_mark",8:"sub_mark",9:"ignore",10:"active_char",11:"invalid_char",12:"@top",13:"begingroup_cs",14:"endgroup_cs",15:"math_shift_group",16:"single_math_shift",17:"double_math_shift",18:"prefix_cs",19:"let_cs",20:"control_sequence",21:"optional_equal",22:"futurelet_cs",23:"def_cs",24:"defcode_cs",25:"integer",26:"directive",27:"statement+",28:"prefix_cs+",29:"spacer+",30:"sign+",31:"dec_digit+",32:"oct_digit+",33:"hex_digit+",34:"␄",35:"spacer",36:"letter",37:"other_char",38:"control_sequence_token",39:"begingroup_cs_token",40:"endgroup_cs_token",41:"defcode_cs_token",42:"def_cs_token",43:"let_cs_token",44:"futurelet_cs_token",45:"prefix_cs_token",46:"directive_comment",47:"line_comment",48:"%mainskip",49:"statement",50:"simple_group",51:"semi_simple_group",52:"ordinary_math_mode",53:"display_math_mode",54:"let_cmd",55:'other_char/"="',56:"futurelet_cmd",57:"def_cmd",58:"defcode_cmd",59:'other_char/"+"',60:"dec_digit",61:'other_char/"0"',62:'other_char/"9"',63:'other_char/"\'"',64:'other_char/"\\""',65:"hex_digit",66:'other_char/"A"',67:'letter/"A"',68:"alpha_number",69:'other_char/"`"',70:"any_char"}});exports.default=T;