Files
to_docx/client/node_modules/chevrotain/lib/chevrotain.min.mjs
T
Chen Xiao 0b64e2de94 First commit.
Signed-off-by: Chen Xiao <abigwc@gmail.com>
2026-05-08 14:43:16 +08:00

155 lines
110 KiB
JavaScript

var tt="12.0.0";function Te(n){console&&console.error&&console.error(`Error: ${n}`)}function we(n){console&&console.warn&&console.warn(`Warning: ${n}`)}function Fe(n){let e=new Date().getTime(),t=n();return{time:new Date().getTime()-e,value:t}}function Ue(n){function e(){}e.prototype=n;let t=new e;function r(){return typeof t.bar}return r(),r(),n;(0,eval)(n)}function Kr(n){return Wr(n)?n.LABEL:n.name}function Wr(n){return typeof n.LABEL=="string"&&n.LABEL!==""}var $=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}},S=class extends ${constructor(e){super([]),this.idx=1,Object.assign(this,q(e))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},G=class extends ${constructor(e){super(e.definition),this.orgText="",Object.assign(this,q(e))}},x=class extends ${constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,q(e))}},_=class extends ${constructor(e){super(e.definition),this.idx=1,Object.assign(this,q(e))}},P=class extends ${constructor(e){super(e.definition),this.idx=1,Object.assign(this,q(e))}},M=class extends ${constructor(e){super(e.definition),this.idx=1,Object.assign(this,q(e))}},N=class extends ${constructor(e){super(e.definition),this.idx=1,Object.assign(this,q(e))}},L=class extends ${constructor(e){super(e.definition),this.idx=1,Object.assign(this,q(e))}},y=class extends ${get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,q(e))}},I=class{constructor(e){this.idx=1,Object.assign(this,q(e))}accept(e){e.visit(this)}};function nt(n){return n.map(ge)}function ge(n){function e(t){return t.map(ge)}if(n instanceof S){let t={type:"NonTerminal",name:n.nonTerminalName,idx:n.idx};return typeof n.label=="string"&&(t.label=n.label),t}else{if(n instanceof x)return{type:"Alternative",definition:e(n.definition)};if(n instanceof _)return{type:"Option",idx:n.idx,definition:e(n.definition)};if(n instanceof P)return{type:"RepetitionMandatory",idx:n.idx,definition:e(n.definition)};if(n instanceof M)return{type:"RepetitionMandatoryWithSeparator",idx:n.idx,separator:ge(new I({terminalType:n.separator})),definition:e(n.definition)};if(n instanceof L)return{type:"RepetitionWithSeparator",idx:n.idx,separator:ge(new I({terminalType:n.separator})),definition:e(n.definition)};if(n instanceof N)return{type:"Repetition",idx:n.idx,definition:e(n.definition)};if(n instanceof y)return{type:"Alternation",idx:n.idx,definition:e(n.definition)};if(n instanceof I){let t={type:"Terminal",name:n.terminalType.name,label:Kr(n.terminalType),idx:n.idx};typeof n.label=="string"&&(t.terminalLabel=n.label);let r=n.terminalType.PATTERN;return n.terminalType.PATTERN&&(t.pattern=r instanceof RegExp?r.source:r),t}else{if(n instanceof G)return{type:"Rule",name:n.name,orgText:n.orgText,definition:e(n.definition)};throw Error("non exhaustive match")}}}function q(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0))}var F=class{visit(e){let t=e;switch(t.constructor){case S:return this.visitNonTerminal(t);case x:return this.visitAlternative(t);case _:return this.visitOption(t);case P:return this.visitRepetitionMandatory(t);case M:return this.visitRepetitionMandatoryWithSeparator(t);case L:return this.visitRepetitionWithSeparator(t);case N:return this.visitRepetition(t);case y:return this.visitAlternation(t);case I:return this.visitTerminal(t);case G:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function Bt(n){return n instanceof x||n instanceof _||n instanceof N||n instanceof P||n instanceof M||n instanceof L||n instanceof I||n instanceof G}function he(n,e=[]){return n instanceof _||n instanceof N||n instanceof L?!0:n instanceof y?n.definition.some(r=>he(r,e)):n instanceof S&&e.includes(n)?!1:n instanceof $?(n instanceof S&&e.push(n),n.definition.every(r=>he(r,e))):!1}function jt(n){return n instanceof y}function j(n){if(n instanceof S)return"SUBRULE";if(n instanceof _)return"OPTION";if(n instanceof y)return"OR";if(n instanceof P)return"AT_LEAST_ONE";if(n instanceof M)return"AT_LEAST_ONE_SEP";if(n instanceof L)return"MANY_SEP";if(n instanceof N)return"MANY";if(n instanceof I)return"CONSUME";throw Error("non exhaustive match")}var J=class{walk(e,t=[]){e.definition.forEach((r,i)=>{let s=e.definition.slice(i+1);if(r instanceof S)this.walkProdRef(r,s,t);else if(r instanceof I)this.walkTerminal(r,s,t);else if(r instanceof x)this.walkFlat(r,s,t);else if(r instanceof _)this.walkOption(r,s,t);else if(r instanceof P)this.walkAtLeastOne(r,s,t);else if(r instanceof M)this.walkAtLeastOneSep(r,s,t);else if(r instanceof L)this.walkManySep(r,s,t);else if(r instanceof N)this.walkMany(r,s,t);else if(r instanceof y)this.walkOr(r,s,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,r){}walkProdRef(e,t,r){}walkFlat(e,t,r){let i=t.concat(r);this.walk(e,i)}walkOption(e,t,r){let i=t.concat(r);this.walk(e,i)}walkAtLeastOne(e,t,r){let i=[new _({definition:e.definition})].concat(t,r);this.walk(e,i)}walkAtLeastOneSep(e,t,r){let i=_n(e,t,r);this.walk(e,i)}walkMany(e,t,r){let i=[new _({definition:e.definition})].concat(t,r);this.walk(e,i)}walkManySep(e,t,r){let i=_n(e,t,r);this.walk(e,i)}walkOr(e,t,r){let i=t.concat(r);e.definition.forEach(s=>{let o=new x({definition:[s]});this.walk(o,i)})}};function _n(n,e,t){return[new _({definition:[new I({terminalType:n.separator})].concat(n.definition)})].concat(e,t)}function ue(n){if(n instanceof S)return ue(n.referencedRule);if(n instanceof I)return Xr(n);if(Bt(n))return Vr(n);if(jt(n))return Hr(n);throw Error("non exhaustive match")}function Vr(n){let e=[],t=n.definition,r=0,i=t.length>r,s,o=!0;for(;i&&o;)s=t[r],o=he(s),e=e.concat(ue(s)),r=r+1,i=t.length>r;return[...new Set(e)]}function Hr(n){let e=n.definition.map(t=>ue(t));return[...new Set(e.flat())]}function Xr(n){return[n.terminalType]}var rt="_~IN~_";var $t=class extends J{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,r){}walkProdRef(e,t,r){let i=zr(e.referencedRule,e.idx)+this.topProd.name,s=t.concat(r),o=new x({definition:s}),a=ue(o);this.follows[i]=a}};function Cn(n){let e={};return n.forEach(t=>{let r=new $t(t).startWalking();Object.assign(e,r)}),e}function zr(n,e){return n.name+e+rt}function g(n){return n.charCodeAt(0)}function it(n,e){Array.isArray(n)?n.forEach(function(t){e.push(t)}):e.push(n)}function Ae(n,e){if(n[e]===!0)throw"duplicate flag "+e;let t=n[e];n[e]=!0}function de(n){if(n===void 0)throw Error("Internal Error - Should never get here!");return!0}function De(){throw Error("Internal Error - Should never get here!")}function Kt(n){return n.type==="Character"}var Ge=[];for(let n=g("0");n<=g("9");n++)Ge.push(n);var Be=[g("_")].concat(Ge);for(let n=g("a");n<=g("z");n++)Be.push(n);for(let n=g("A");n<=g("Z");n++)Be.push(n);var Wt=[g(" "),g("\f"),g(`
`),g("\r"),g(" "),g("\v"),g(" "),g("\xA0"),g("\u1680"),g("\u2000"),g("\u2001"),g("\u2002"),g("\u2003"),g("\u2004"),g("\u2005"),g("\u2006"),g("\u2007"),g("\u2008"),g("\u2009"),g("\u200A"),g("\u2028"),g("\u2029"),g("\u202F"),g("\u205F"),g("\u3000"),g("\uFEFF")];var Yr=/[0-9a-fA-F]/,st=/[0-9]/,qr=/[1-9]/,je=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Ae(r,"global");break;case"i":Ae(r,"ignoreCase");break;case"m":Ae(r,"multiLine");break;case"u":Ae(r,"unicode");break;case"y":Ae(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}de(t);let r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return De()}quantifier(e=!1){let t,r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:i,atMost:i};break;case",":let s;this.isDigit()?(s=this.integerIncludingZero(),t={atLeast:i,atMost:s}):t={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;de(t);break}if(!(e===!0&&t===void 0)&&de(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),de(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):De()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[g(`
`),g("\r"),g("\u2028"),g("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=Ge;break;case"D":e=Ge,t=!0;break;case"s":e=Wt;break;case"S":e=Wt,t=!0;break;case"w":e=Be;break;case"W":e=Be,t=!0;break}return de(e)?{type:"Set",value:e,complement:t}:De()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=g("\f");break;case"n":e=g(`
`);break;case"r":e=g("\r");break;case"t":e=g(" ");break;case"v":e=g("\v");break}return de(e)?{type:"Character",value:e}:De()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:g("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:g(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:g(e)}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let r=this.classAtom(),i=r.type==="Character";if(Kt(r)&&this.isRangeDash()){this.consumeChar("-");let s=this.classAtom(),o=s.type==="Character";if(Kt(s)){if(s.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:s.value})}else it(r.value,e),e.push(g("-")),it(s.value,e)}else it(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:g("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;this.consumeChar("("),this.peekChar(0)==="?"?(this.consumeChar("?"),this.consumeChar(":"),e=!1):this.groupIdx++;let t=this.disjunction();this.consumeChar(")");let r={type:"Group",capturing:e,value:t};return e&&(r.idx=this.groupIdx),r}positiveInteger(){let e=this.popChar();if(qr.test(e)===!1)throw Error("Expecting a positive integer");for(;st.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(st.test(e)===!1)throw Error("Expecting an integer");for(;st.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:g(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return st.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!"||this.peekChar(2)==="<"&&(this.peekChar(3)==="="||this.peekChar(3)==="!"));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let i=0;i<e;i++){let s=this.popChar();if(Yr.test(s)===!1)throw Error("Expecting a HexDecimal digits");t+=s}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}};var oe=class{visitChildren(e){for(let t in e){let r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(i=>{this.visit(i)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};var ot={},Qr=new je;function Re(n){let e=n.toString();if(ot.hasOwnProperty(e))return ot[e];{let t=Qr.pattern(e);return ot[e]=t,t}}function kn(){ot={}}var yn="Complement Sets are not supported for first char optimization",$e=`Unable to use "first char" lexer optimizations:
`;function vn(n,e=!1){try{let t=Re(n);return Vt(t.value,{},t.flags.ignoreCase)}catch(t){if(t.message===yn)e&&we(`${$e} Unable to optimize: < ${n.toString()} >
Complement Sets cannot be automatically optimized.
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let r="";e&&(r=`
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Te(`${$e}
Failed parsing: < ${n.toString()} >
Using the @chevrotain/regexp-to-ast library
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+r)}}return[]}function Vt(n,e,t){switch(n.type){case"Disjunction":for(let i=0;i<n.value.length;i++)Vt(n.value[i],e,t);break;case"Alternative":let r=n.value;for(let i=0;i<r.length;i++){let s=r[i];switch(s.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let o=s;switch(o.type){case"Character":at(o.value,e,t);break;case"Set":if(o.complement===!0)throw Error(yn);o.value.forEach(c=>{if(typeof c=="number")at(c,e,t);else{let l=c;if(t===!0)for(let u=l.from;u<=l.to;u++)at(u,e,t);else{for(let u=l.from;u<=l.to&&u<Ie;u++)at(u,e,t);if(l.to>=Ie){let u=l.from>=Ie?l.from:Ie,h=l.to,f=Q(u),T=Q(h);for(let A=f;A<=T;A++)e[A]=A}}}});break;case"Group":Vt(o.value,e,t);break;default:throw Error("Non Exhaustive Match")}let a=o.quantifier!==void 0&&o.quantifier.atLeast===0;if(o.type==="Group"&&Ht(o)===!1||o.type!=="Group"&&a===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(e)}function at(n,e,t){let r=Q(n);e[r]=r,t===!0&&Zr(n,e)}function Zr(n,e){let t=String.fromCharCode(n),r=t.toUpperCase();if(r!==t){let i=Q(r.charCodeAt(0));e[i]=i}else{let i=t.toLowerCase();if(i!==t){let s=Q(i.charCodeAt(0));e[s]=s}}}function Ln(n,e){return n.value.find(t=>{if(typeof t=="number")return e.includes(t);{let r=t;return e.find(i=>r.from<=i&&i<=r.to)!==void 0}})}function Ht(n){let e=n.quantifier;return e&&e.atLeast===0?!0:n.value?Array.isArray(n.value)?n.value.every(Ht):Ht(n.value):!1}var Xt=class extends oe{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){this.targetCharCodes.includes(e.value)&&(this.found=!0)}visitSet(e){e.complement?Ln(e,this.targetCharCodes)===void 0&&(this.found=!0):Ln(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function ct(n,e){if(e instanceof RegExp){let t=Re(e),r=new Xt(n);return r.visit(t),r.found}else{for(let t of e){let r=t.charCodeAt(0);if(n.includes(r))return!0}return!1}}var fe="PATTERN",Oe="defaultMode",lt="modes";function Mn(n,e){e=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
`],tracer:(m,d)=>d()},e);let t=e.tracer;t("initCharCodeToOptimizedIndexMap",()=>{Ti()});let r;t("Reject Lexer.NA",()=>{r=n.filter(m=>m[fe]!==w.NA)});let i=!1,s;t("Transform Patterns",()=>{i=!1,s=r.map(m=>{let d=m[fe];if(d instanceof RegExp){let p=d.source;return p.length===1&&p!=="^"&&p!=="$"&&p!=="."&&!d.ignoreCase?p:p.length===2&&p[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(p[1])?p[1]:Pn(d)}else{if(typeof d=="function")return i=!0,{exec:d};if(typeof d=="object")return i=!0,d;if(typeof d=="string"){if(d.length===1)return d;{let p=d.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),v=new RegExp(p);return Pn(v)}}else throw Error("non exhaustive match")}})});let o,a,c,l,u;t("misc mapping",()=>{o=r.map(m=>m.tokenTypeIdx),a=r.map(m=>{let d=m.GROUP;if(d!==w.SKIPPED){if(typeof d=="string")return d;if(d===void 0)return!1;throw Error("non exhaustive match")}}),c=r.map(m=>{let d=m.LONGER_ALT;if(d)return Array.isArray(d)?d.map(v=>r.indexOf(v)):[r.indexOf(d)]}),l=r.map(m=>m.PUSH_MODE),u=r.map(m=>Object.hasOwn(m,"POP_MODE"))});let h;t("Line Terminator Handling",()=>{let m=jn(e.lineTerminatorCharacters);h=r.map(d=>!1),e.positionTracking!=="onlyOffset"&&(h=r.map(d=>Object.hasOwn(d,"LINE_BREAKS")?!!d.LINE_BREAKS:Bn(d,m)===!1&&ct(m,d.PATTERN)))});let f,T,A,R;t("Misc Mapping #2",()=>{f=r.map(Dn),T=s.map(mi),A=r.reduce((m,d)=>{let p=d.GROUP;return typeof p=="string"&&p!==w.SKIPPED&&(m[p]=[]),m},{}),R=s.map((m,d)=>({pattern:s[d],longerAlt:c[d],canLineTerminator:h[d],isCustom:f[d],short:T[d],group:a[d],push:l[d],pop:u[d],tokenTypeIdx:o[d],tokenType:r[d]}))});let O=!0,E=[];return e.safeMode||t("First Char Optimization",()=>{E=r.reduce((m,d,p)=>{if(typeof d.PATTERN=="string"){let v=d.PATTERN.charCodeAt(0),V=Q(v);zt(m,V,R[p])}else if(Array.isArray(d.START_CHARS_HINT)){let v;d.START_CHARS_HINT.forEach(V=>{let re=typeof V=="string"?V.charCodeAt(0):V,ce=Q(re);v!==ce&&(v=ce,zt(m,ce,R[p]))})}else if(d.PATTERN instanceof RegExp)if(d.PATTERN.unicode)O=!1,e.ensureOptimizations&&Te(`${$e} Unable to analyze < ${d.PATTERN.toString()} > pattern.
The regexp unicode flag is not currently supported by the regexp-to-ast library.
This will disable the lexer's first char optimizations.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let v=vn(d.PATTERN,e.ensureOptimizations);v.length===0&&(O=!1),v.forEach(V=>{zt(m,V,R[p])})}else e.ensureOptimizations&&Te(`${$e} TokenType: <${d.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
This will disable the lexer's first char optimizations.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),O=!1;return m},[])}),{emptyGroups:A,patternIdxToConfig:R,charCodeToPatternIdxToConfig:E,hasCustom:i,canBeOptimized:O}}function bn(n,e){let t=[],r=ei(n);t=t.concat(r.errors);let i=ti(r.valid),s=i.valid;return t=t.concat(i.errors),t=t.concat(Jr(s)),t=t.concat(li(s)),t=t.concat(hi(s,e)),t=t.concat(ui(s)),t}function Jr(n){let e=[],t=n.filter(r=>r[fe]instanceof RegExp);return e=e.concat(ri(t)),e=e.concat(oi(t)),e=e.concat(ai(t)),e=e.concat(ci(t)),e=e.concat(ii(t)),e}function ei(n){let e=n.filter(i=>!Object.hasOwn(i,fe)),t=e.map(i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:C.MISSING_PATTERN,tokenTypes:[i]})),r=n.filter(i=>!e.includes(i));return{errors:t,valid:r}}function ti(n){let e=n.filter(i=>{let s=i[fe];return!(s instanceof RegExp)&&typeof s!="function"&&!Object.hasOwn(s,"exec")&&typeof s!="string"}),t=e.map(i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:C.INVALID_PATTERN,tokenTypes:[i]})),r=n.filter(i=>!e.includes(i));return{errors:t,valid:r}}var ni=/[^\\][$]/;function ri(n){class e extends oe{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}return n.filter(i=>{let s=i.PATTERN;try{let o=Re(s),a=new e;return a.visit(o),a.found}catch{return ni.test(s.source)}}).map(i=>({message:`Unexpected RegExp Anchor Error:
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:C.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function ii(n){return n.filter(r=>r.PATTERN.test("")).map(r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' must not match an empty string",type:C.EMPTY_MATCH_PATTERN,tokenTypes:[r]}))}var si=/[^\\[][\^]|^\^/;function oi(n){class e extends oe{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}return n.filter(i=>{let s=i.PATTERN;try{let o=Re(s),a=new e;return a.visit(o),a.found}catch{return si.test(s.source)}}).map(i=>({message:`Unexpected RegExp Anchor Error:
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:C.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function ai(n){return n.filter(r=>{let i=r[fe];return i instanceof RegExp&&(i.multiline||i.global)}).map(r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:C.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[r]}))}function ci(n){let e=[],t=n.map(s=>n.reduce((o,a)=>(s.PATTERN.source===a.PATTERN.source&&!e.includes(a)&&a.PATTERN!==w.NA&&(e.push(a),o.push(a)),o),[]));return t=t.filter(Boolean),t.filter(s=>s.length>1).map(s=>{let o=s.map(c=>c.name);return{message:`The same RegExp pattern ->${s[0].PATTERN}<-has been used in all of the following Token Types: ${o.join(", ")} <-`,type:C.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function li(n){return n.filter(r=>{if(!Object.hasOwn(r,"GROUP"))return!1;let i=r.GROUP;return i!==w.SKIPPED&&i!==w.NA&&typeof i!="string"}).map(r=>({message:"Token Type: ->"+r.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:C.INVALID_GROUP_TYPE_FOUND,tokenTypes:[r]}))}function hi(n,e){return n.filter(i=>i.PUSH_MODE!==void 0&&!e.includes(i.PUSH_MODE)).map(i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:C.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function ui(n){let e=[],t=n.reduce((r,i,s)=>{let o=i.PATTERN;return o===w.NA||(typeof o=="string"?r.push({str:o,idx:s,tokenType:i}):o instanceof RegExp&&fi(o)&&r.push({str:o.source,idx:s,tokenType:i})),r},[]);return n.forEach((r,i)=>{t.forEach(({str:s,idx:o,tokenType:a})=>{if(i<o&&di(s,r.PATTERN)){let c=`Token: ->${a.name}<- can never be matched.
Because it appears AFTER the Token Type ->${r.name}<-in the lexer's definition.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:c,type:C.UNREACHABLE_PATTERN,tokenTypes:[r,a]})}})}),e}function di(n,e){if(e instanceof RegExp){if(pi(e))return!1;let t=e.exec(n);return t!==null&&t.index===0}else{if(typeof e=="function")return e(n,0,[],{});if(Object.hasOwn(e,"exec"))return e.exec(n,0,[],{});if(typeof e=="string")return e===n;throw Error("non exhaustive match")}}function fi(n){return[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find(t=>n.source.indexOf(t)!==-1)===void 0}function pi(n){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(n.source)}function Pn(n){let e=n.ignoreCase?"iy":"y";return new RegExp(`${n.source}`,e)}function wn(n,e,t){let r=[];return Object.hasOwn(n,Oe)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+Oe+`> property in its definition
`,type:C.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object.hasOwn(n,lt)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+lt+`> property in its definition
`,type:C.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object.hasOwn(n,lt)&&Object.hasOwn(n,Oe)&&!Object.hasOwn(n.modes,n.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${Oe}: <${n.defaultMode}>which does not exist
`,type:C.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object.hasOwn(n,lt)&&Object.keys(n.modes).forEach(i=>{let s=n.modes[i];s.forEach((o,a)=>{o===void 0?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${i}> at index: <${a}>
`,type:C.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Object.hasOwn(o,"LONGER_ALT")&&(Array.isArray(o.LONGER_ALT)?o.LONGER_ALT:[o.LONGER_ALT]).forEach(l=>{l!==void 0&&!s.includes(l)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${o.name}> outside of mode <${i}>
`,type:C.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function Fn(n,e,t){let r=[],i=!1,o=Object.values(n.modes||{}).flat().filter(Boolean).filter(c=>c[fe]!==w.NA),a=jn(t);return e&&o.forEach(c=>{let l=Bn(c,a);if(l!==!1){let h={message:Ei(c,l),type:l.issue,tokenType:c};r.push(h)}else Object.hasOwn(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(i=!0):ct(a,c.PATTERN)&&(i=!0)}),e&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
This Lexer has been defined to track line and column information,
But none of the Token Types can be identified as matching a line terminator.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
for details.`,type:C.NO_LINE_BREAKS_FLAGS}),r}function Un(n){let e={};return Object.keys(n).forEach(r=>{let i=n[r];if(Array.isArray(i))e[r]=[];else throw Error("non exhaustive match")}),e}function Dn(n){let e=n.PATTERN;if(e instanceof RegExp)return!1;if(typeof e=="function")return!0;if(Object.hasOwn(e,"exec"))return!0;if(typeof e=="string")return!1;throw Error("non exhaustive match")}function mi(n){return typeof n=="string"&&n.length===1?n.charCodeAt(0):!1}var Gn={test:function(n){let e=n.length;for(let t=this.lastIndex;t<e;t++){let r=n.charCodeAt(t);if(r===10)return this.lastIndex=t+1,!0;if(r===13)return n.charCodeAt(t+1)===10?this.lastIndex=t+2:this.lastIndex=t+1,!0}return!1},lastIndex:0};function Bn(n,e){if(Object.hasOwn(n,"LINE_BREAKS"))return!1;if(n.PATTERN instanceof RegExp){try{ct(e,n.PATTERN)}catch(t){return{issue:C.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}else{if(typeof n.PATTERN=="string")return!1;if(Dn(n))return{issue:C.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function Ei(n,e){if(e.issue===C.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
The problem is in the <${n.name}> Token Type
Root cause: ${e.errMsg}.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===C.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
The problem is in the <${n.name}> Token Type
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function jn(n){return n.map(t=>typeof t=="string"?t.charCodeAt(0):t)}function zt(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}var Ie=256,ht=[];function Q(n){return n<Ie?n:ht[n]}function Ti(){if(ht.length===0){ht=new Array(65536);for(let n=0;n<65536;n++)ht[n]=n>255?255+~~(n/255):n}}function ee(n,e){let t=n.tokenTypeIdx;return t===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[t]===!0}function Ne(n,e){return n.tokenTypeIdx===e.tokenTypeIdx}var $n=1,Wn={};function te(n){let e=gi(n);Ai(e),Ii(e),Ri(e),e.forEach(t=>{t.isParent=t.categoryMatches.length>0})}function gi(n){let e=[...n],t=n,r=!0;for(;r;){t=t.map(s=>s.CATEGORIES).flat().filter(Boolean);let i=t.filter(s=>!e.includes(s));e=e.concat(i),i.length===0?r=!1:t=i}return e}function Ai(n){n.forEach(e=>{Yt(e)||(Wn[$n]=e,e.tokenTypeIdx=$n++),Kn(e)&&!Array.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Kn(e)||(e.CATEGORIES=[]),Oi(e)||(e.categoryMatches=[]),Ni(e)||(e.categoryMatchesMap={})})}function Ri(n){n.forEach(e=>{e.categoryMatches=[],Object.keys(e.categoryMatchesMap).forEach(t=>{e.categoryMatches.push(Wn[t].tokenTypeIdx)})})}function Ii(n){n.forEach(e=>{Vn([],e)})}function Vn(n,e){n.forEach(t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),e.CATEGORIES.forEach(t=>{let r=n.concat(e);r.includes(t)||Vn(r,t)})}function Yt(n){return Object.hasOwn(n??{},"tokenTypeIdx")}function Kn(n){return Object.hasOwn(n??{},"CATEGORIES")}function Oi(n){return Object.hasOwn(n??{},"categoryMatches")}function Ni(n){return Object.hasOwn(n??{},"categoryMatchesMap")}function Hn(n){return Object.hasOwn(n??{},"tokenTypeIdx")}var qt={buildUnableToPopLexerModeMessage(n){return`Unable to pop Lexer Mode after encountering Token ->${n.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(n,e,t,r,i,s){return`unexpected character: ->${n.charAt(e)}<- at offset: ${e}, skipped ${t} characters.`}};var C;(function(n){n[n.MISSING_PATTERN=0]="MISSING_PATTERN",n[n.INVALID_PATTERN=1]="INVALID_PATTERN",n[n.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",n[n.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",n[n.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",n[n.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",n[n.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",n[n.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",n[n.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",n[n.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",n[n.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",n[n.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",n[n.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",n[n.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",n[n.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",n[n.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",n[n.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",n[n.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(C||(C={}));var Ke={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:qt,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Ke);var w=class{constructor(e,t=Ke){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,s)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${o}--> <${i}>`);let{time:a,value:c}=Fe(s),l=a>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${o}<-- <${i}> time: ${a}ms`),this.traceInitIndent--,c}else return s()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
a boolean 2nd argument is no longer supported`);this.config=Object.assign({},Ke,t);let r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,s=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Ke.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Gn;else if(this.config.lineTerminatorCharacters===Ke.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e)?i={modes:{defaultMode:[...e]},defaultMode:Oe}:(s=!1,i=Object.assign({},e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(wn(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Fn(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},Object.entries(i.modes).forEach(([a,c])=>{i.modes[a]=c.filter(l=>l!==void 0)});let o=Object.keys(i.modes);if(Object.entries(i.modes).forEach(([a,c])=>{this.TRACE_INIT(`Mode: <${a}> processing`,()=>{if(this.modes.push(a),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(bn(c,o))}),this.lexerDefinitionErrors.length===0){te(c);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=Mn(c,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[a]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[a]=l.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[a]=l.canBeOptimized}})}),this.defaultMode=i.defaultMode,this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){let c=this.lexerDefinitionErrors.map(l=>l.message).join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
`+c)}this.lexerDefinitionWarning.forEach(a=>{we(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(s&&(this.handleModes=()=>{}),this.trackStartLines===!1&&(this.computeNewColumn=a=>a),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=()=>{}),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let a=Object.entries(this.canModeBeOptimized).reduce((c,[l,u])=>(u===!1&&c.push(l),c),[]);if(t.ensureOptimizations&&a.length>0)throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized.
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{kn()}),this.TRACE_INIT("toFastProperties",()=>{Ue(this)})})}tokenize(e,t=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let i=this.lexerDefinitionErrors.map(s=>s.message).join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
`+i)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,i,s,o,a,c,l,u,h,f,T,A,R,O,E,m=e,d=m.length,p=0,v=0,V=this.hasCustom?0:Math.floor(e.length/10),re=new Array(V),ce=[],ye=this.trackStartLines?1:void 0,Y=this.trackStartLines?1:void 0,ve=Un(this.emptyGroups),jr=this.trackStartLines,Ut=this.config.lineTerminatorsPattern,et=0,ie=[],Pe=[],Me=[],On=[];Object.freeze(On);let be=!1,$r=B=>{if(Me.length===1&&B.tokenType.PUSH_MODE===void 0){let K=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(B);ce.push({offset:B.startOffset,line:B.startLine,column:B.startColumn,length:B.image.length,message:K})}else{Me.pop();let K=Me.at(-1);ie=this.patternIdxToConfig[K],Pe=this.charCodeToPatternIdxToConfig[K],et=ie.length;let Dt=this.canModeBeOptimized[K]&&this.config.safeMode===!1;Pe&&Dt?be=!0:be=!1}};function Nn(B){Me.push(B),Pe=this.charCodeToPatternIdxToConfig[B],ie=this.patternIdxToConfig[B],et=ie.length,et=ie.length;let K=this.canModeBeOptimized[B]&&this.config.safeMode===!1;Pe&&K?be=!0:be=!1}Nn.call(this,t);let H,Sn=this.config.recoveryEnabled;for(;p<d;){c=null,h=-1;let B=m.charCodeAt(p),K;if(be){let D=Q(B),W=Pe[D];K=W!==void 0?W:On}else K=ie;let Dt=K.length;for(r=0;r<Dt;r++){H=K[r];let D=H.pattern;l=null;let W=H.short;if(W!==!1?B===W&&(h=1,c=D):H.isCustom===!0?(E=D.exec(m,p,re,ve),E!==null?(c=E[0],h=c.length,E.payload!==void 0&&(l=E.payload)):c=null):(D.lastIndex=p,h=this.matchLength(D,e,p)),h!==-1){if(a=H.longerAlt,a!==void 0){c=e.substring(p,p+h);let se=a.length;for(s=0;s<se;s++){let Z=ie[a[s]],le=Z.pattern;if(u=null,Z.isCustom===!0?(E=le.exec(m,p,re,ve),E!==null?(o=E[0],E.payload!==void 0&&(u=E.payload)):o=null):(le.lastIndex=p,o=this.match(le,e,p)),o&&o.length>c.length){c=o,h=o.length,l=u,H=Z;break}}}break}}if(h!==-1){if(f=H.group,f!==void 0&&(c=c!==null?c:e.substring(p,p+h),T=H.tokenTypeIdx,A=this.createTokenInstance(c,p,T,H.tokenType,ye,Y,h),this.handlePayload(A,l),f===!1?v=this.addToken(re,v,A):ve[f].push(A)),jr===!0&&H.canLineTerminator===!0){let D=0,W,se;Ut.lastIndex=0;do c=c!==null?c:e.substring(p,p+h),W=Ut.test(c),W===!0&&(se=Ut.lastIndex-1,D++);while(W===!0);D!==0?(ye=ye+D,Y=h-se,this.updateTokenEndLineColumnLocation(A,f,se,D,ye,Y,h)):Y=this.computeNewColumn(Y,h)}else Y=this.computeNewColumn(Y,h);p=p+h,this.handleModes(H,$r,Nn,A)}else{let D=p,W=ye,se=Y,Z=Sn===!1;for(;Z===!1&&p<d;)for(p++,i=0;i<et;i++){let le=ie[i],Gt=le.pattern,xn=le.short;if(xn!==!1?m.charCodeAt(p)===xn&&(Z=!0):le.isCustom===!0?Z=Gt.exec(m,p,re,ve)!==null:(Gt.lastIndex=p,Z=Gt.exec(e)!==null),Z===!0)break}if(R=p-D,Y=this.computeNewColumn(Y,R),O=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(m,D,R,W,se,Me.at(-1)),ce.push({offset:D,line:W,column:se,length:R,message:O}),Sn===!1)break}}return this.hasCustom||(re.length=v),{tokens:re,groups:ve,errors:ce}}handleModes(e,t,r,i){if(e.pop===!0){let s=e.push;t(i),s!==void 0&&r.call(this,s)}else e.push!==void 0&&r.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,r,i,s,o,a){let c,l;t!==void 0&&(c=r===a-1,l=c?-1:0,i===1&&c===!0||(e.endLine=s+l,e.endColumn=o-1+-l))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,r,i){return{image:e,startOffset:t,tokenTypeIdx:r,tokenType:i}}createStartOnlyToken(e,t,r,i,s,o){return{image:e,startOffset:t,startLine:s,startColumn:o,tokenTypeIdx:r,tokenType:i}}createFullToken(e,t,r,i,s,o,a){return{image:e,startOffset:t,endOffset:t+a-1,startLine:s,endLine:s,startColumn:o,endColumn:o+a-1,tokenTypeIdx:r,tokenType:i}}addTokenUsingPush(e,t,r){return e.push(r),t}addTokenUsingMemberAccess(e,t,r){return e[t]=r,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,r){return e.test(t)===!0?t.substring(r,e.lastIndex):null}matchLength(e,t,r){return e.test(t)===!0?e.lastIndex-r:-1}};w.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";w.NA=/NOT_APPLICABLE/;function pe(n){return Qt(n)?n.LABEL:n.name}function Si(n){return n.name}function Qt(n){return typeof n.LABEL=="string"&&n.LABEL!==""}var xi="parent",Xn="categories",zn="label",Yn="group",qn="push_mode",Qn="pop_mode",Zn="longer_alt",Jn="line_breaks",er="start_chars_hint";function ut(n){return _i(n)}function _i(n){let e=n.pattern,t={};if(t.name=n.name,e!==void 0&&(t.PATTERN=e),Object.hasOwn(n,xi))throw`The parent property is no longer supported.
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return Object.hasOwn(n,Xn)&&(t.CATEGORIES=n[Xn]),te([t]),Object.hasOwn(n,zn)&&(t.LABEL=n[zn]),Object.hasOwn(n,Yn)&&(t.GROUP=n[Yn]),Object.hasOwn(n,Qn)&&(t.POP_MODE=n[Qn]),Object.hasOwn(n,qn)&&(t.PUSH_MODE=n[qn]),Object.hasOwn(n,Zn)&&(t.LONGER_ALT=n[Zn]),Object.hasOwn(n,Jn)&&(t.LINE_BREAKS=n[Jn]),Object.hasOwn(n,er)&&(t.START_CHARS_HINT=n[er]),t}var X=ut({name:"EOF",pattern:w.NA});te([X]);function me(n,e,t,r,i,s,o,a){return{image:e,startOffset:t,endOffset:r,startLine:i,endLine:s,startColumn:o,endColumn:a,tokenTypeIdx:n.tokenTypeIdx,tokenType:n}}function Zt(n,e){return ee(n,e)}var dt={buildMismatchTokenMessage({expected:n,actual:e,previous:t,ruleName:r}){return`Expecting ${Qt(n)?`--> ${pe(n)} <--`:`token of type --> ${n.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:n,ruleName:e}){return"Redundant input, expecting EOF but found: "+n.image},buildNoViableAltMessage({expectedPathsPerAlt:n,actual:e,previous:t,customUserDescription:r,ruleName:i}){let s="Expecting: ",a=`
but found: '`+e[0].image+"'";if(r)return s+r+a;{let h=`one of these possible Token sequences:
${n.reduce((f,T)=>f.concat(T),[]).map(f=>`[${f.map(T=>pe(T)).join(", ")}]`).map((f,T)=>` ${T+1}. ${f}`).join(`
`)}`;return s+h+a}},buildEarlyExitMessage({expectedIterationPaths:n,actual:e,customUserDescription:t,ruleName:r}){let i="Expecting: ",o=`
but found: '`+e[0].image+"'";if(t)return i+t+o;{let c=`expecting at least one iteration which starts with one of these possible Token sequences::
<${n.map(l=>`[${l.map(u=>pe(u)).join(",")}]`).join(" ,")}>`;return i+c+o}}};Object.freeze(dt);var tr={buildRuleNotFoundError(n,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
inside top level rule: ->`+n.name+"<-"}},z={buildDuplicateFoundError(n,e){function t(u){return u instanceof I?u.terminalType.name:u instanceof S?u.nonTerminalName:""}let r=n.name,i=e[0],s=i.idx,o=j(i),a=t(i),c=s>0,l=`->${o}${c?s:""}<- ${a?`with argument: ->${a}<-`:""}
appears more than once (${e.length} times) in the top level rule: ->${r}<-.
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
`;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,`
`),l},buildNamespaceConflictError(n){return`Namespace conflict found in grammar.
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${n.name}>.
To resolve this make sure each Terminal and Non-Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(n){let e=n.prefixPath.map(i=>pe(i)).join(", "),t=n.alternation.idx===0?"":n.alternation.idx;return`Ambiguous alternatives: <${n.ambiguityIndices.join(" ,")}> due to common lookahead prefix
in <OR${t}> inside <${n.topLevelRule.name}> Rule,
<${e}> may appears as a prefix path in all these alternatives.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
For Further details.`},buildAlternationAmbiguityError(n){let e=n.alternation.idx===0?"":n.alternation.idx,t=n.prefixPath.length===0,r=`Ambiguous Alternatives Detected: <${n.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${n.topLevelRule.name}> Rule,
`;if(t)r+=`These alternatives are all empty (match no tokens), making them indistinguishable.
Only the last alternative may be empty.
`;else{let i=n.prefixPath.map(s=>pe(s)).join(", ");r+=`<${i}> may appears as a prefix path in all these alternatives.
`}return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,r},buildEmptyRepetitionError(n){let e=j(n.repetition);return n.repetition.idx!==0&&(e+=n.repetition.idx),`The repetition <${e}> within Rule <${n.topLevelRule.name}> can never consume any tokens.
This could lead to an infinite loop.`},buildTokenNameError(n){return"deprecated"},buildEmptyAlternationError(n){return`Ambiguous empty alternative: <${n.emptyChoiceIdx+1}> in <OR${n.alternation.idx}> inside <${n.topLevelRule.name}> Rule.
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(n){return`An Alternation cannot have more than 256 alternatives:
<OR${n.alternation.idx}> inside <${n.topLevelRule.name}> Rule.
has ${n.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(n){let e=n.topLevelRule.name,t=n.leftRecursionPath.map(s=>s.name),r=`${e} --> ${t.concat([e]).join(" --> ")}`;return`Left Recursion found in grammar.
rule: <${e}> can be invoked from itself (directly or indirectly)
without consuming any Tokens. The grammar path that causes this is:
${r}
To fix this refactor your grammar to remove the left recursion.
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(n){return"deprecated"},buildDuplicateRuleNameError(n){let e;return n.topLevelRule instanceof G?e=n.topLevelRule.name:e=n.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${n.grammarName}<-`}};function nr(n,e){let t=new Jt(n,e);return t.resolveRefs(),t.errors}var Jt=class extends F{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach(e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:b.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}};var en=class extends J{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){this.ruleStack.length===0?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},ft=class extends en{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=t.concat(r),s=new x({definition:i});this.possibleTokTypes=ue(s),this.found=!0}}},Se=class extends J{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},pt=class extends Se{walkMany(e,t,r){if(e.idx===this.occurrence){let i=t.concat(r)[0];this.result.isEndOfRule=i===void 0,i instanceof I&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,t,r)}},We=class extends Se{walkManySep(e,t,r){if(e.idx===this.occurrence){let i=t.concat(r)[0];this.result.isEndOfRule=i===void 0,i instanceof I&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,t,r)}},mt=class extends Se{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){let i=t.concat(r)[0];this.result.isEndOfRule=i===void 0,i instanceof I&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,t,r)}},Ve=class extends Se{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){let i=t.concat(r)[0];this.result.isEndOfRule=i===void 0,i instanceof I&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,t,r)}};function Et(n,e,t=[]){t=[...t];let r=[],i=0;function s(a){return a.concat(n.slice(i+1))}function o(a){let c=Et(s(a),e,t);return r.concat(c)}for(;t.length<e&&i<n.length;){let a=n[i];if(a instanceof x)return o(a.definition);if(a instanceof S)return o(a.definition);if(a instanceof _)r=o(a.definition);else if(a instanceof P){let c=a.definition.concat([new N({definition:a.definition})]);return o(c)}else if(a instanceof M){let c=[new x({definition:a.definition}),new N({definition:[new I({terminalType:a.separator})].concat(a.definition)})];return o(c)}else if(a instanceof L){let c=a.definition.concat([new N({definition:[new I({terminalType:a.separator})].concat(a.definition)})]);r=o(c)}else if(a instanceof N){let c=a.definition.concat([new N({definition:a.definition})]);r=o(c)}else{if(a instanceof y)return a.definition.forEach(c=>{c.definition.length!==0&&(r=o(c.definition))}),r;if(a instanceof I)t.push(a.terminalType);else throw Error("non exhaustive match")}i++}return r.push({partialPath:t,suffixDef:n.slice(i)}),r}function rr(n,e,t,r){let i="EXIT_NONE_TERMINAL",s=[i],o="EXIT_ALTERNATIVE",a=!1,c=e.length,l=c-r-1,u=[],h=[];for(h.push({idx:-1,def:n,ruleStack:[],occurrenceStack:[]});h.length!==0;){let f=h.pop();if(f===o){a&&h.at(-1).idx<=l&&h.pop();continue}let T=f.def,A=f.idx,R=f.ruleStack,O=f.occurrenceStack;if(T.length===0)continue;let E=T[0];if(E===i){let m={idx:A,def:T.slice(1),ruleStack:R.slice(0,-1),occurrenceStack:O.slice(0,-1)};h.push(m)}else if(E instanceof I)if(A<c-1){let m=A+1,d=e[m];if(t(d,E.terminalType)){let p={idx:m,def:T.slice(1),ruleStack:R,occurrenceStack:O};h.push(p)}}else if(A===c-1)u.push({nextTokenType:E.terminalType,nextTokenOccurrence:E.idx,ruleStack:R,occurrenceStack:O}),a=!0;else throw Error("non exhaustive match");else if(E instanceof S){let m=[...R];m.push(E.nonTerminalName);let d=[...O];d.push(E.idx);let p={idx:A,def:E.definition.concat(s,T.slice(1)),ruleStack:m,occurrenceStack:d};h.push(p)}else if(E instanceof _){let m={idx:A,def:T.slice(1),ruleStack:R,occurrenceStack:O};h.push(m),h.push(o);let d={idx:A,def:E.definition.concat(T.slice(1)),ruleStack:R,occurrenceStack:O};h.push(d)}else if(E instanceof P){let m=new N({definition:E.definition,idx:E.idx}),d=E.definition.concat([m],T.slice(1)),p={idx:A,def:d,ruleStack:R,occurrenceStack:O};h.push(p)}else if(E instanceof M){let m=new I({terminalType:E.separator}),d=new N({definition:[m].concat(E.definition),idx:E.idx}),p=E.definition.concat([d],T.slice(1)),v={idx:A,def:p,ruleStack:R,occurrenceStack:O};h.push(v)}else if(E instanceof L){let m={idx:A,def:T.slice(1),ruleStack:R,occurrenceStack:O};h.push(m),h.push(o);let d=new I({terminalType:E.separator}),p=new N({definition:[d].concat(E.definition),idx:E.idx}),v=E.definition.concat([p],T.slice(1)),V={idx:A,def:v,ruleStack:R,occurrenceStack:O};h.push(V)}else if(E instanceof N){let m={idx:A,def:T.slice(1),ruleStack:R,occurrenceStack:O};h.push(m),h.push(o);let d=new N({definition:E.definition,idx:E.idx}),p=E.definition.concat([d],T.slice(1)),v={idx:A,def:p,ruleStack:R,occurrenceStack:O};h.push(v)}else if(E instanceof y)for(let m=E.definition.length-1;m>=0;m--){let d=E.definition[m],p={idx:A,def:d.definition.concat(T.slice(1)),ruleStack:R,occurrenceStack:O};h.push(p),h.push(o)}else if(E instanceof x)h.push({idx:A,def:E.definition.concat(T.slice(1)),ruleStack:R,occurrenceStack:O});else if(E instanceof G)h.push(Ci(E,A,R,O));else throw Error("non exhaustive match")}return u}function Ci(n,e,t,r){let i=[...t];i.push(n.name);let s=[...r];return s.push(1),{idx:e,def:n.definition,ruleStack:i,occurrenceStack:s}}var k;(function(n){n[n.OPTION=0]="OPTION",n[n.REPETITION=1]="REPETITION",n[n.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",n[n.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",n[n.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",n[n.ALTERNATION=5]="ALTERNATION"})(k||(k={}));function He(n){if(n instanceof _||n==="Option")return k.OPTION;if(n instanceof N||n==="Repetition")return k.REPETITION;if(n instanceof P||n==="RepetitionMandatory")return k.REPETITION_MANDATORY;if(n instanceof M||n==="RepetitionMandatoryWithSeparator")return k.REPETITION_MANDATORY_WITH_SEPARATOR;if(n instanceof L||n==="RepetitionWithSeparator")return k.REPETITION_WITH_SEPARATOR;if(n instanceof y||n==="Alternation")return k.ALTERNATION;throw Error("non exhaustive match")}function ki(n){let{occurrence:e,rule:t,prodType:r,maxLookahead:i}=n,s=He(r);return s===k.ALTERNATION?xe(e,t,i):_e(e,t,s,i)}function sr(n,e,t,r,i,s){let o=xe(n,e,t),a=ur(o)?Ne:ee;return s(o,r,a,i)}function or(n,e,t,r,i,s){let o=_e(n,e,i,t),a=ur(o)?Ne:ee;return s(o[0],a,r)}function ar(n,e,t,r){let i=n.length,s=n.every(o=>o.every(a=>a.length===1));if(e)return function(o){let a=o.map(c=>c.GATE);for(let c=0;c<i;c++){let l=n[c],u=l.length,h=a[c];if(!(h!==void 0&&h.call(this)===!1))e:for(let f=0;f<u;f++){let T=l[f],A=T.length;for(let R=0;R<A;R++){let O=this.LA_FAST(R+1);if(t(O,T[R])===!1)continue e}return c}}};if(s&&!r){let a=n.map(c=>c.flat()).reduce((c,l,u)=>(l.forEach(h=>{h.tokenTypeIdx in c||(c[h.tokenTypeIdx]=u),h.categoryMatches.forEach(f=>{Object.hasOwn(c,f)||(c[f]=u)})}),c),{});return function(){let c=this.LA_FAST(1);return a[c.tokenTypeIdx]}}else return function(){for(let o=0;o<i;o++){let a=n[o],c=a.length;e:for(let l=0;l<c;l++){let u=a[l],h=u.length;for(let f=0;f<h;f++){let T=this.LA_FAST(f+1);if(t(T,u[f])===!1)continue e}return o}}}}function cr(n,e,t){let r=n.every(s=>s.length===1),i=n.length;if(r&&!t){let s=n.flat();if(s.length===1&&s[0].categoryMatches.length===0){let a=s[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===a}}else{let o=s.reduce((a,c,l)=>(a[c.tokenTypeIdx]=!0,c.categoryMatches.forEach(u=>{a[u]=!0}),a),[]);return function(){let a=this.LA_FAST(1);return o[a.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;s<i;s++){let o=n[s],a=o.length;for(let c=0;c<a;c++){let l=this.LA_FAST(c+1);if(e(l,o[c])===!1)continue e}return!0}return!1}}var nn=class extends J{constructor(e,t,r){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=r}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,r,i){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=r.concat(i),!0):!1}walkOption(e,t,r){this.checkIsTarget(e,k.OPTION,t,r)||super.walkOption(e,t,r)}walkAtLeastOne(e,t,r){this.checkIsTarget(e,k.REPETITION_MANDATORY,t,r)||super.walkOption(e,t,r)}walkAtLeastOneSep(e,t,r){this.checkIsTarget(e,k.REPETITION_MANDATORY_WITH_SEPARATOR,t,r)||super.walkOption(e,t,r)}walkMany(e,t,r){this.checkIsTarget(e,k.REPETITION,t,r)||super.walkOption(e,t,r)}walkManySep(e,t,r){this.checkIsTarget(e,k.REPETITION_WITH_SEPARATOR,t,r)||super.walkOption(e,t,r)}},Tt=class extends F{constructor(e,t,r){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=r,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,k.OPTION)}visitRepetition(e){this.checkIsTarget(e,k.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,k.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,k.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,k.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,k.ALTERNATION)}};function ir(n){let e=new Array(n);for(let t=0;t<n;t++)e[t]=[];return e}function tn(n){let e=[""];for(let t=0;t<n.length;t++){let r=n[t],i=[];for(let s=0;s<e.length;s++){let o=e[s];i.push(o+"_"+r.tokenTypeIdx);for(let a=0;a<r.categoryMatches.length;a++){let c="_"+r.categoryMatches[a];i.push(o+c)}}e=i}return e}function Li(n,e,t){for(let r=0;r<n.length;r++){if(r===t)continue;let i=n[r];for(let s=0;s<e.length;s++){let o=e[s];if(i[o]===!0)return!1}}return!0}function lr(n,e){let t=n.map(o=>Et([o],1)),r=ir(t.length),i=t.map(o=>{let a={};return o.forEach(c=>{tn(c.partialPath).forEach(u=>{a[u]=!0})}),a}),s=t;for(let o=1;o<=e;o++){let a=s;s=ir(a.length);for(let c=0;c<a.length;c++){let l=a[c];for(let u=0;u<l.length;u++){let h=l[u].partialPath,f=l[u].suffixDef,T=tn(h);if(Li(i,T,c)||f.length===0||h.length===e){let R=r[c];if(gt(R,h)===!1){R.push(h);for(let O=0;O<T.length;O++){let E=T[O];i[c][E]=!0}}}else{let R=Et(f,o+1,h);s[c]=s[c].concat(R),R.forEach(O=>{tn(O.partialPath).forEach(m=>{i[c][m]=!0})})}}}}return r}function xe(n,e,t,r){let i=new Tt(n,k.ALTERNATION,r);return e.accept(i),lr(i.result,t)}function _e(n,e,t,r){let i=new Tt(n,t);e.accept(i);let s=i.result,a=new nn(e,n,t).startWalking(),c=new x({definition:s}),l=new x({definition:a});return lr([c,l],r)}function gt(n,e){e:for(let t=0;t<n.length;t++){let r=n[t];if(r.length===e.length){for(let i=0;i<r.length;i++){let s=e[i],o=r[i];if((s===o||o.categoryMatchesMap[s.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function hr(n,e){return n.length<e.length&&n.every((t,r)=>{let i=e[r];return t===i||i.categoryMatchesMap[t.tokenTypeIdx]})}function ur(n){return n.every(e=>e.every(t=>t.every(r=>r.categoryMatches.length===0)))}function dr(n){return n.lookaheadStrategy.validate({rules:n.rules,tokenTypes:n.tokenTypes,grammarName:n.grammarName}).map(t=>Object.assign({type:b.CUSTOM_LOOKAHEAD_VALIDATION},t))}function fr(n,e,t,r){let i=n.flatMap(c=>yi(c,t)),s=Fi(n,e,t),o=n.flatMap(c=>Mi(c,t)),a=n.flatMap(c=>Pi(c,n,r,t));return i.concat(s,o,a)}function yi(n,e){let t=new rn;n.accept(t);let r=t.allProductions,i=Object.groupBy(r,vi),s=Object.fromEntries(Object.entries(i).filter(([a,c])=>c.length>1));return Object.values(s).map(a=>{let c=a[0],l=e.buildDuplicateFoundError(n,a),u=j(c),h={message:l,type:b.DUPLICATE_PRODUCTIONS,ruleName:n.name,dslName:u,occurrence:c.idx},f=pr(c);return f&&(h.parameter=f),h})}function vi(n){return`${j(n)}_#_${n.idx}_#_${pr(n)}`}function pr(n){return n instanceof I?n.terminalType.name:n instanceof S?n.nonTerminalName:""}var rn=class extends F{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function Pi(n,e,t,r){let i=[];if(e.reduce((o,a)=>a.name===n.name?o+1:o,0)>1){let o=r.buildDuplicateRuleNameError({topLevelRule:n,grammarName:t});i.push({message:o,type:b.DUPLICATE_RULE_NAME,ruleName:n.name})}return i}function mr(n,e,t){let r=[],i;return e.includes(n)||(i=`Invalid rule override, rule: ->${n}<- cannot be overridden in the grammar: ->${t}<-as it is not defined in any of the super grammars `,r.push({message:i,type:b.INVALID_RULE_OVERRIDE,ruleName:n})),r}function on(n,e,t,r=[]){let i=[],s=At(e.definition);if(s.length===0)return[];{let o=n.name;s.includes(n)&&i.push({message:t.buildLeftRecursionError({topLevelRule:n,leftRecursionPath:r}),type:b.LEFT_RECURSION,ruleName:o});let c=r.concat([n]),u=s.filter(h=>!c.includes(h)).flatMap(h=>{let f=[...r];return f.push(h),on(n,h,t,f)});return i.concat(u)}}function At(n){let e=[];if(n.length===0)return e;let t=n[0];if(t instanceof S)e.push(t.referencedRule);else if(t instanceof x||t instanceof _||t instanceof P||t instanceof M||t instanceof L||t instanceof N)e=e.concat(At(t.definition));else if(t instanceof y)e=t.definition.map(s=>At(s.definition)).flat();else if(!(t instanceof I))throw Error("non exhaustive match");let r=he(t),i=n.length>1;if(r&&i){let s=n.slice(1);return e.concat(At(s))}else return e}var Xe=class extends F{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Er(n,e){let t=new Xe;return n.accept(t),t.alternations.flatMap(s=>s.definition.slice(0,-1).flatMap((a,c)=>rr([a],[],ee,1).length===0?[{message:e.buildEmptyAlternationError({topLevelRule:n,alternation:s,emptyChoiceIdx:c}),type:b.NONE_LAST_EMPTY_ALT,ruleName:n.name,occurrence:s.idx,alternative:c+1}]:[]))}function Tr(n,e,t){let r=new Xe;n.accept(r);let i=r.alternations;return i=i.filter(o=>o.ignoreAmbiguities!==!0),i.flatMap(o=>{let a=o.idx,c=o.maxLookahead||e,l=xe(a,n,c,o),u=bi(l,o,n,t),h=wi(l,o,n,t);return u.concat(h)})}var sn=class extends F{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function Mi(n,e){let t=new Xe;return n.accept(t),t.alternations.flatMap(s=>s.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:n,alternation:s}),type:b.TOO_MANY_ALTS,ruleName:n.name,occurrence:s.idx}]:[])}function gr(n,e,t){let r=[];return n.forEach(i=>{let s=new sn;i.accept(s),s.allProductions.forEach(a=>{let c=He(a),l=a.maxLookahead||e,u=a.idx;if(_e(u,i,c,l)[0].flat().length===0){let T=t.buildEmptyRepetitionError({topLevelRule:i,repetition:a});r.push({message:T,type:b.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),r}function bi(n,e,t,r){let i=[];return n.reduce((a,c,l)=>(e.definition[l].ignoreAmbiguities===!0||c.forEach(u=>{let h=[l];n.forEach((f,T)=>{l!==T&&gt(f,u)&&e.definition[T].ignoreAmbiguities!==!0&&h.push(T)}),h.length>1&&!gt(i,u)&&(i.push(u),a.push({alts:h,path:u}))}),a),[]).map(a=>{let c=a.alts.map(u=>u+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:c,prefixPath:a.path}),type:b.AMBIGUOUS_ALTS,ruleName:t.name,occurrence:e.idx,alternatives:a.alts}})}function wi(n,e,t,r){let i=n.reduce((o,a,c)=>{let l=a.map(u=>({idx:c,path:u}));return o.concat(l)},[]);return i.flatMap(o=>{if(e.definition[o.idx].ignoreAmbiguities===!0)return[];let c=o.idx,l=o.path;return i.filter(f=>e.definition[f.idx].ignoreAmbiguities!==!0&&f.idx<c&&hr(f.path,l)).map(f=>{let T=[f.idx+1,c+1],A=e.idx===0?"":e.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:T,prefixPath:f.path}),type:b.AMBIGUOUS_PREFIX_ALTS,ruleName:t.name,occurrence:A,alternatives:T}})})}function Fi(n,e,t){let r=[],i=e.map(s=>s.name);return n.forEach(s=>{let o=s.name;if(i.includes(o)){let a=t.buildNamespaceConflictError(s);r.push({message:a,type:b.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:o})}}),r}function Ar(n){let e=Object.assign({errMsgProvider:tr},n),t={};return n.rules.forEach(r=>{t[r.name]=r}),nr(t,e.errMsgProvider)}function Rr(n){var e;let t=(e=n.errMsgProvider)!==null&&e!==void 0?e:z;return fr(n.rules,n.tokenTypes,t,n.grammarName)}var Ir="MismatchedTokenException",Or="NoViableAltException",Nr="EarlyExitException",Sr="NotAllInputParsedException",xr=[Ir,Or,Nr,Sr];Object.freeze(xr);function ae(n){return xr.includes(n.name)}var Ce=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Ee=class extends Ce{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Ir}},ze=class extends Ce{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Or}},Ye=class extends Ce{constructor(e,t){super(e,t),this.name=Sr}},qe=class extends Ce{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Nr}};var an={},ln="InRuleRecoveryException",cn=class extends Error{constructor(e){super(e),this.name=ln}},Rt=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:U.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Ui)}getTokenToInsert(e){let t=me(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,r,i){let s=this.findReSyncTokenType(),o=this.exportLexerState(),a=[],c=!1,l=this.LA_FAST(1),u=this.LA_FAST(1),h=()=>{let f=this.LA(0),T=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:f,ruleName:this.getCurrRuleFullName()}),A=new Ee(T,l,this.LA(0));A.resyncedTokens=a.slice(0,-1),this.SAVE_ERROR(A)};for(;!c;)if(this.tokenMatcher(u,i)){h();return}else if(r.call(this)){h(),e.apply(this,t);return}else this.tokenMatcher(u,s)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,t,r){return!(r===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getNextPossibleTokenTypes(e){let t=e.ruleStack[0],i=this.getGAstProductions()[t];return new ft(i,e).startWalking()}getFollowsForInRuleRecovery(e,t){let r=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(r)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let r=this.SKIP_TOKEN();return this.consumeToken(),r}throw new cn("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||t.length===0)return!1;let r=this.LA_FAST(1);return t.find(s=>this.tokenMatcher(r,s))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(t).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),r=2;for(;;){let i=e.find(s=>Zt(t,s));if(i!==void 0)return i;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return an;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(r)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,r=this.RULE_STACK_IDX+1,i=new Array(r);for(let s=0;s<r;s++)s===0?i[s]=an:i[s]={ruleName:this.shortRuleNameToFullName(e[s]),idxInCallingRule:t[s],inRule:this.shortRuleNameToFullName(e[s-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map(t=>this.getFollowSetFromFollowKey(t)).flat()}getFollowSetFromFollowKey(e){if(e===an)return[X];let t=e.ruleName+e.idxInCallingRule+rt+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,X)||t.push(e),t}reSyncTo(e){let t=[],r=this.LA_FAST(1);for(;this.tokenMatcher(r,e)===!1;)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return t.slice(0,-1)}attemptInRepetitionRecovery(e,t,r,i,s,o,a){}getCurrentGrammarPath(e,t){let r=this.getHumanReadableRuleStack(),i=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:r,occurrenceStack:i,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=new Array(e);for(let r=0;r<e;r++)t[r]=this.shortRuleNameToFullName(this.RULE_STACK[r]);return t}};function Ui(n,e,t,r,i,s,o){let a=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[a];if(c===void 0){let f=this.getCurrRuleFullName(),T=this.getGAstProductions()[f];c=new s(T,i).startWalking(),this.firstAfterRepMap[a]=c}let l=c.token,u=c.occurrence,h=c.isEndOfRule;this.RULE_STACK_IDX===0&&h&&l===void 0&&(l=X,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(n,e,t,l)}function It(n,e,t){return t|e|n}var Qe=class{constructor(e){var t;this.maxLookahead=(t=e?.maxLookahead)!==null&&t!==void 0?t:U.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(t.length===0){let r=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),s=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...r,...i,...s]}return t}validateNoLeftRecursion(e){return e.flatMap(t=>on(t,t,z))}validateEmptyOrAlternatives(e){return e.flatMap(t=>Er(t,z))}validateAmbiguousAlternationAlternatives(e,t){return e.flatMap(r=>Tr(r,t,z))}validateSomeNonEmptyLookaheadPath(e,t){return gr(e,t,z)}buildLookaheadForAlternation(e){return sr(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,ar)}buildLookaheadForOptional(e){return or(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,He(e.prodType),cr)}};var Nt=class{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:U.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:U.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new Qe({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){e.forEach(t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:r,repetition:i,option:s,repetitionMandatory:o,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:c}=Di(t);r.forEach(l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${j(l)}${u}`,()=>{let h=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:t,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),f=It(this.fullRuleNameToShort[t.name],256,l.idx);this.setLaFuncCache(f,h)})}),i.forEach(l=>{this.computeLookaheadFunc(t,l.idx,768,"Repetition",l.maxLookahead,j(l))}),s.forEach(l=>{this.computeLookaheadFunc(t,l.idx,512,"Option",l.maxLookahead,j(l))}),o.forEach(l=>{this.computeLookaheadFunc(t,l.idx,1024,"RepetitionMandatory",l.maxLookahead,j(l))}),a.forEach(l=>{this.computeLookaheadFunc(t,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,j(l))}),c.forEach(l=>{this.computeLookaheadFunc(t,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,j(l))})})})}computeLookaheadFunc(e,t,r,i,s,o){this.TRACE_INIT(`${o}${t===0?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:s||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),c=It(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(c,a)})}getKeyForAutomaticLookahead(e,t){return It(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},hn=class extends F{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},Ot=new hn;function Di(n){Ot.reset(),n.accept(Ot);let e=Ot.dslMethods;return Ot.reset(),e}function fn(n,e){isNaN(n.startOffset)===!0?(n.startOffset=e.startOffset,n.endOffset=e.endOffset):n.endOffset<e.endOffset&&(n.endOffset=e.endOffset)}function pn(n,e){isNaN(n.startOffset)===!0?(n.startOffset=e.startOffset,n.startColumn=e.startColumn,n.startLine=e.startLine,n.endOffset=e.endOffset,n.endColumn=e.endColumn,n.endLine=e.endLine):n.endOffset<e.endOffset&&(n.endOffset=e.endOffset,n.endColumn=e.endColumn,n.endLine=e.endLine)}function _r(n,e,t){n.children[t]===void 0?n.children[t]=[e]:n.children[t].push(e)}function Cr(n,e,t){n.children[e]===void 0?n.children[e]=[t]:n.children[e].push(t)}var Gi="name";function mn(n,e){Object.defineProperty(n,Gi,{enumerable:!1,configurable:!0,writable:!1,value:e})}function Bi(n,e){let t=Object.keys(n),r=t.length;for(let i=0;i<r;i++){let s=t[i],o=n[s],a=o.length;for(let c=0;c<a;c++){let l=o[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,e)}}}function kr(n,e){let t=function(){};mn(t,n+"BaseSemantics");let r={visit:function(i,s){if(Array.isArray(i)&&(i=i[0]),i!==void 0)return this[i.name](i.children,s)},validateVisitor:function(){let i=ji(this,e);if(i.length!==0){let s=i.map(o=>o.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
${s.join(`
`).replace(/\n/g,`
`)}`)}}};return t.prototype=r,t.prototype.constructor=t,t._RULE_NAMES=e,t}function Lr(n,e,t){let r=function(){};mn(r,n+"BaseSemanticsWithDefaults");let i=Object.create(t.prototype);return e.forEach(s=>{i[s]=Bi}),r.prototype=i,r.prototype.constructor=r,r}var En;(function(n){n[n.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",n[n.MISSING_METHOD=1]="MISSING_METHOD"})(En||(En={}));function ji(n,e){return $i(n,e)}function $i(n,e){return e.filter(i=>typeof n[i]!="function").map(i=>({msg:`Missing visitor method: <${i}> on ${n.constructor.name} CST Visitor.`,type:En.MISSING_METHOD,methodName:i})).filter(Boolean)}var Ct=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Object.hasOwn(e,"nodeLocationTracking")?e.nodeLocationTracking:U.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=pn,this.setNodeLocationFromNode=pn,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=fn,this.setNodeLocationFromNode=fn,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?(r.endOffset=t.endOffset,r.endLine=t.endLine,r.endColumn=t.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?r.endOffset=t.endOffset:r.startOffset=NaN}cstPostTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];_r(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];Cr(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let e=kr(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let e=Lr(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}};var kt=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):ne}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ne:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}};var Lt=class{ACTION(e){return e.call(this)}consume(e,t,r){return this.consumeInternal(t,e,r)}subrule(e,t,r){return this.subruleInternal(t,e,r)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,r=ke){if(this.definedRulesNames.includes(e)){let o={message:z.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:b.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(o)}this.definedRulesNames.push(e);let i=this.defineRule(e,t,r);return this[e]=i,i}OVERRIDE_RULE(e,t,r=ke){let i=mr(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);let s=this.defineRule(e,t,r);return this[e]=s,s}BACKTRACK(e,t){var r;let i=(r=e.coreRule)!==null&&r!==void 0?r:e;return function(){this.isBackTrackingStack.push(1);let s=this.saveRecogState();try{return i.apply(this,t),!0}catch(o){if(ae(o))return!1;throw o}finally{this.reloadRecogState(s),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return nt(Object.values(this.gastProductionsCache))}};var yt=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Ne,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
For Further details.`);if(Array.isArray(e)){if(e.length===0)throw Error(`A Token Vocabulary cannot be empty.
Note that the first argument for the parser constructor
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
For Further details.`)}if(Array.isArray(e))this.tokensMap=e.reduce((s,o)=>(s[o.name]=o,s),{});else if(Object.hasOwn(e,"modes")&&Object.values(e.modes).flat().every(Hn)){let s=Object.values(e.modes).flat(),o=[...new Set(s)];this.tokensMap=o.reduce((a,c)=>(a[c.name]=c,a),{})}else if(typeof e=="object"&&e!==null)this.tokensMap=Object.assign({},e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=X;let i=(Object.hasOwn(e,"modes")?Object.values(e.modes).flat():Object.values(e)).every(s=>{var o;return((o=s.categoryMatches)===null||o===void 0?void 0:o.length)==0});this.tokenMatcher=i?Ne:ee,te(Object.values(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=Object.hasOwn(r,"resyncEnabled")?r.resyncEnabled:ke.resyncEnabled,s=Object.hasOwn(r,"recoveryValueFunc")?r.recoveryValueFunc:ke.recoveryValueFunc,o=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[o]=e,this.fullRuleNameToShort[e]=o;let a;return this.outputCst===!0?a=function(...h){try{this.ruleInvocationStateUpdate(o,e,this.subruleIdx),t.apply(this,h);let f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,i,s)}finally{this.ruleFinallyStateUpdate()}}:a=function(...h){try{return this.ruleInvocationStateUpdate(o,e,this.subruleIdx),t.apply(this,h)}catch(f){return this.invokeRuleCatch(f,i,s)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...h){this.onBeforeParse(e);try{return a.apply(this,h)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:t,coreRule:a})}invokeRuleCatch(e,t,r){let i=this.RULE_STACK_IDX===0,s=t&&!this.isBackTracking()&&this.recoveryEnabled;if(ae(e)){let o=e;if(s){let a=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(a))if(o.resyncedTokens=this.reSyncTo(a),this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return r(e);else{if(this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,o.partialCstResult=c}throw o}}else{if(i)return this.moveToTerminatedState(),r(e);throw o}}else throw e}optionInternal(e,t){let r=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,r)}optionInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof e!="function"){s=e.DEF;let o=e.GATE;if(o!==void 0){let a=i;i=()=>o.call(this)&&a.call(this)}}else s=e;if(i.call(this)===!0)return s.call(this)}atLeastOneInternal(e,t){let r=this.getKeyForAutomaticLookahead(1024,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof t!="function"){s=t.DEF;let o=t.GATE;if(o!==void 0){let a=i;i=()=>o.call(this)&&a.call(this)}}else s=t;if(i.call(this)===!0){let o=this.doSingleRepetition(s);for(;i.call(this)===!0&&o===!0;)o=this.doSingleRepetition(s)}else throw this.raiseEarlyExitException(e,k.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,1024,e,mt)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(1536,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){let i=t.DEF,s=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){i.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),s);for(;this.tokenMatcher(this.LA_FAST(1),s)===!0;)this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,a,i,Ve],a,1536,e,Ve)}else throw this.raiseEarlyExitException(e,k.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof t!="function"){s=t.DEF;let a=t.GATE;if(a!==void 0){let c=i;i=()=>a.call(this)&&c.call(this)}}else s=t;let o=!0;for(;i.call(this)===!0&&o===!0;)o=this.doSingleRepetition(s);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,768,e,pt,o)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(1280,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){let i=t.DEF,s=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){i.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),s);for(;this.tokenMatcher(this.LA_FAST(1),s)===!0;)this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,a,i,We],a,1280,e,We)}}repetitionSepSecondInternal(e,t,r,i,s){for(;r();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,i,s],r,1536,e,s)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(256,t),i=Array.isArray(e)?e:e.DEF,o=this.getLaFuncFromCache(r).call(this,i);if(o!==void 0)return i[o].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(e,t,r){let i;try{let s=r!==void 0?r.ARGS:void 0;return this.subruleIdx=t,i=e.coreRule.apply(this,s),this.cstPostNonTerminal(i,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),i}catch(s){throw this.subruleInternalError(s,r,e.ruleName)}}subruleInternalError(e,t,r){throw ae(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:r),delete e.partialCstResult),e}consumeInternal(e,t,r){let i;try{let s=this.LA_FAST(1);this.tokenMatcher(s,e)===!0?(this.consumeToken(),i=s):this.consumeInternalError(e,s,r)}catch(s){i=this.consumeInternalRecovery(e,t,s)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,i),i}consumeInternalError(e,t,r){let i,s=this.LA(0);throw r!==void 0&&r.ERR_MSG?i=r.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:s,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Ee(i,t,s))}consumeInternalRecovery(e,t,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(s){throw s.name===ln?r:s}}else throw r}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let r=0;r<t.length;r++)this.RULE_STACK[r]=t[r];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(e,t,r){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=r,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),X)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t<this.maxLookahead+1;t++)this.tokVector.push(ne)}onAfterParse(e){if(this.isAtEndOfInput()===!1){let t=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Ye(r,t))}for(;this.tokVector.at(-1)===ne;)this.tokVector.pop()}};var vt=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,"errorMessageProvider")?e.errorMessageProvider:U.errorMessageProvider}SAVE_ERROR(e){if(ae(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,t,r){let i=this.getCurrRuleFullName(),s=this.getGAstProductions()[i],a=_e(e,s,t,this.maxLookahead)[0],c=[];for(let u=1;u<=this.maxLookahead;u++)c.push(this.LA(u));let l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:c,previous:this.LA(0),customUserDescription:r,ruleName:i});throw this.SAVE_ERROR(new qe(l,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],s=xe(e,i,this.maxLookahead),o=[];for(let l=1;l<=this.maxLookahead;l++)o.push(this.LA(l));let a=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:s,actual:o,previous:a,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ze(c,this.LA(1),a))}};var bt={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(bt);var yr=!0,vr=Math.pow(2,8)-1,Mr=ut({name:"RECORDING_PHASE_TOKEN",pattern:w.NA});te([Mr]);var br=me(Mr,`This IToken indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(br);var Wi={name:`This CSTNode indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Pt=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(r,i){return this.consumeInternalRecord(r,e,i)},this[`SUBRULE${t}`]=function(r,i){return this.subruleInternalRecord(r,e,i)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let e=this;for(let t=0;t<10;t++){let r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return ne}topLevelRuleRecord(e,t){try{let r=new G({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+`
This error was thrown during the "grammar recording phase" For more info see:
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return Je.call(this,_,e,t)}atLeastOneInternalRecord(e,t){Je.call(this,P,t,e)}atLeastOneSepFirstInternalRecord(e,t){Je.call(this,M,t,e,yr)}manyInternalRecord(e,t){Je.call(this,N,t,e)}manySepFirstInternalRecord(e,t){Je.call(this,L,t,e,yr)}orInternalRecord(e,t){return Vi.call(this,e,t)}subruleInternalRecord(e,t,r){if(Mt(t),!e||!Object.hasOwn(e,"ruleName")){let a=new Error(`<SUBRULE${Pr(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let i=this.recordingProdStack.at(-1),s=e.ruleName,o=new S({idx:t,nonTerminalName:s,label:r?.LABEL,referencedRule:void 0});return i.definition.push(o),this.outputCst?Wi:bt}consumeInternalRecord(e,t,r){if(Mt(t),!Yt(e)){let o=new Error(`<CONSUME${Pr(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let i=this.recordingProdStack.at(-1),s=new I({idx:t,terminalType:e,label:r?.LABEL});return i.definition.push(s),br}};function Je(n,e,t,r=!1){Mt(t);let i=this.recordingProdStack.at(-1),s=typeof e=="function"?e:e.DEF,o=new n({definition:[],idx:t});return r&&(o.separator=e.SEP),Object.hasOwn(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(o),s.call(this),i.definition.push(o),this.recordingProdStack.pop(),bt}function Vi(n,e){Mt(e);let t=this.recordingProdStack.at(-1),r=Array.isArray(n)===!1,i=r===!1?n:n.DEF,s=new y({definition:[],idx:e,ignoreAmbiguities:r&&n.IGNORE_AMBIGUITIES===!0});Object.hasOwn(n,"MAX_LOOKAHEAD")&&(s.maxLookahead=n.MAX_LOOKAHEAD);let o=i.some(a=>typeof a.GATE=="function");return s.hasPredicates=o,t.definition.push(s),i.forEach(a=>{let c=new x({definition:[]});s.definition.push(c),Object.hasOwn(a,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=a.IGNORE_AMBIGUITIES:Object.hasOwn(a,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),a.ALT.call(this),this.recordingProdStack.pop()}),bt}function Pr(n){return n===0?"":`${n}`}function Mt(n){if(n<0||n>vr){let e=new Error(`Invalid DSL Method idx value: <${n}>
Idx value must be a none negative value smaller than ${vr+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}var wt=class{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){let t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=U.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${r}--> <${e}>`);let{time:i,value:s}=Fe(t),o=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&o(`${r}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,s}else return t()}};function wr(n,e){e.forEach(t=>{let r=t.prototype;Object.getOwnPropertyNames(r).forEach(i=>{if(i==="constructor")return;let s=Object.getOwnPropertyDescriptor(r,i);s&&(s.get||s.set)?Object.defineProperty(n.prototype,i,s):n.prototype[i]=t.prototype[i]})})}var ne=me(X,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(ne);var U=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:dt,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ke=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),b;(function(n){n[n.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",n[n.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",n[n.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",n[n.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",n[n.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",n[n.LEFT_RECURSION=5]="LEFT_RECURSION",n[n.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",n[n.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",n[n.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",n[n.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",n[n.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",n[n.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",n[n.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",n[n.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(b||(b={}));function Hi(n=void 0){return function(){return n}}var Le=class n{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT("toFastProps",()=>{Ue(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach(i=>{let o=this[i].originalGrammarAction,a;this.TRACE_INIT(`${i} Rule`,()=>{a=this.topLevelRuleRecord(i,o)}),this.gastProductionsCache[i]=a})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT("Grammar Resolving",()=>{r=Ar({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT("Grammar Validations",()=>{if(r.length===0&&this.skipValidations===!1){let i=Rr({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:z,grammarName:t}),s=dr({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(i,s)}}),this.definitionErrors.length===0&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=Cn(Object.values(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})),!n.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw e=this.definitionErrors.map(i=>i.message),new Error(`Parser Definition Errors detected:
${e.join(`
-------------------------------
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let r=this;if(r.initErrorHandler(t),r.initLexerAdapter(),r.initLooksAhead(t),r.initRecognizerEngine(e,t),r.initRecoverable(t),r.initTreeBuilder(t),r.initGastRecorder(t),r.initPerformanceTracer(t),Object.hasOwn(t,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
For further details.`);this.skipValidations=Object.hasOwn(t,"skipValidations")?t.skipValidations:U.skipValidations}};Le.DEFER_DEFINITION_ERRORS_HANDLING=!1;wr(Le,[Rt,Nt,Ct,kt,yt,Lt,vt,Pt,wt]);var gn=class extends Le{constructor(e,t=U){let r=Object.assign({},t);r.outputCst=!0,super(e,r)}},An=class extends Le{constructor(e,t=U){let r=Object.assign({},t);r.outputCst=!1,super(e,r)}};function Fr(n){let e=new Rn;return Object.values(n).map(r=>e.visitRule(r))}var Rn=class extends F{visitRule(e){let t=this.visitEach(e.definition),r=Object.groupBy(t,s=>s.propertyName),i=Object.entries(r).map(([s,o])=>{let a=!o.some(l=>!l.canBeNull),c=o[0].type;return o.length>1&&(c=o.map(l=>l.type)),{name:s,type:c,optional:a}});return{name:e.name,properties:i}}visitAlternative(e){return this.visitEachAndOverrideWith(e.definition,{canBeNull:!0})}visitOption(e){return this.visitEachAndOverrideWith(e.definition,{canBeNull:!0})}visitRepetition(e){return this.visitEachAndOverrideWith(e.definition,{canBeNull:!0})}visitRepetitionMandatory(e){return this.visitEach(e.definition)}visitRepetitionMandatoryWithSeparator(e){return this.visitEach(e.definition).concat({propertyName:e.separator.name,canBeNull:!0,type:Ft(e.separator)})}visitRepetitionWithSeparator(e){return this.visitEachAndOverrideWith(e.definition,{canBeNull:!0}).concat({propertyName:e.separator.name,canBeNull:!0,type:Ft(e.separator)})}visitAlternation(e){return this.visitEachAndOverrideWith(e.definition,{canBeNull:!0})}visitTerminal(e){return[{propertyName:e.label||e.terminalType.name,canBeNull:!1,type:Ft(e)}]}visitNonTerminal(e){return[{propertyName:e.label||e.nonTerminalName,canBeNull:!1,type:Ft(e)}]}visitEachAndOverrideWith(e,t){return this.visitEach(e).map(r=>Object.assign(Object.assign({},r),t))}visitEach(e){return e.flatMap(t=>this.visit(t))}};function Ft(n){return n instanceof S?{kind:"rule",name:n.referencedRule.name}:{kind:"token"}}function Dr(n,e){let t=[];return t=t.concat('import type { CstNode, ICstVisitor, IToken } from "chevrotain";'),t=t.concat(n.flatMap(r=>Xi(r))),e.includeVisitorInterface&&(t=t.concat(Qi(e.visitorInterfaceName,n))),t.join(`
`)+`
`}function Xi(n){let e=zi(n),t=Yi(n);return[e,t]}function zi(n){let e=Gr(n.name),t=In(n.name);return`export interface ${e} extends CstNode {
name: "${n.name}";
children: ${t};
}`}function Yi(n){return`export type ${In(n.name)} = {
${n.properties.map(t=>qi(t)).join(`
`)}
};`}function qi(n){let e=Ji(n.type);return`${n.name}${n.optional?"?":""}: ${e}[];`}function Qi(n,e){return`export interface ${n}<IN, OUT> extends ICstVisitor<IN, OUT> {
${e.map(t=>Zi(t)).join(`
`)}
}`}function Zi(n){let e=In(n.name);return`${n.name}(children: ${e}, param?: IN): OUT;`}function Ji(n){return Array.isArray(n)?"("+[...new Set(n.map(r=>Ur(r)))].join(" | ")+")":Ur(n)}function Ur(n){return n.kind==="token"?"IToken":Gr(n.name)}function Gr(n){return n.charAt(0).toUpperCase()+n.slice(1)+"CstNode"}function In(n){return n.charAt(0).toUpperCase()+n.slice(1)+"CstChildren"}var es={includeVisitorInterface:!0,visitorInterfaceName:"ICstNodeVisitor"};function ts(n,e){let t=Object.assign(Object.assign({},es),e),r=Fr(n);return Dr(r,t)}function ns(n,{resourceBase:e=`https://unpkg.com/chevrotain@${tt}/diagrams/`,css:t=`https://unpkg.com/chevrotain@${tt}/diagrams/diagrams.css`}={}){let r=`
<!-- This is a generated file -->
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background-color: hsl(30, 20%, 95%)
}
</style>
`,i=`
<link rel='stylesheet' href='${t}'>
`,s=`
<script src='${e}vendor/railroad-diagrams.js'><\/script>
<script src='${e}src/diagrams_builder.js'><\/script>
<script src='${e}src/diagrams_behavior.js'><\/script>
<script src='${e}src/main.js'><\/script>
`,o=`
<div id="diagrams" align="center"></div>
`,a=`
<script>
window.serializedGrammar = ${JSON.stringify(n,null," ")};
<\/script>
`;return r+i+s+o+a+`
<script>
var diagramsDiv = document.getElementById("diagrams");
main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);
<\/script>
`}function uc(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
It performs no action other than printing this message.
Please avoid using it as it will be completely removed in the future`)}var Br=class{constructor(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}};export{y as Alternation,x as Alternative,gn as CstParser,Hi as EMPTY_ALT,X as EOF,qe as EarlyExitException,An as EmbeddedActionsParser,F as GAstVisitor,Qe as LLkLookaheadStrategy,w as Lexer,C as LexerDefinitionErrorType,Ee as MismatchedTokenException,ze as NoViableAltException,S as NonTerminal,Ye as NotAllInputParsedException,_ as Option,Br as Parser,b as ParserDefinitionErrorType,N as Repetition,P as RepetitionMandatory,M as RepetitionMandatoryWithSeparator,L as RepetitionWithSeparator,G as Rule,I as Terminal,tt as VERSION,uc as clearCache,ns as createSyntaxDiagramsCode,ut as createToken,me as createTokenInstance,qt as defaultLexerErrorProvider,dt as defaultParserErrorProvider,ts as generateCstDts,ki as getLookaheadPaths,ae as isRecognitionException,nt as serializeGrammar,ge as serializeProduction,pe as tokenLabel,Zt as tokenMatcher,Si as tokenName};
//# sourceMappingURL=chevrotain.min.mjs.map