@barishnamazov/gsql 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import{readFileSync as Vu,writeFileSync as QT,existsSync as ZT}from"node:fs";import{resolve as zu,basename as JT,dirname as tS,join as eS}from"node:path";import{fileURLToPath as rS}from"node:url";var Qu=typeof global=="object"&&global&&global.Object===Object&&global,dn=Qu;var Zu=typeof self=="object"&&self&&self.Object===Object&&self,Ju=dn||Zu||Function("return this")(),J=Ju;var tf=J.Symbol,at=tf;var ws=Object.prototype,ef=ws.hasOwnProperty,rf=ws.toString,Rr=at?at.toStringTag:void 0;function nf(e){var t=ef.call(e,Rr),r=e[Rr];try{e[Rr]=void 0;var n=!0}catch{}var o=rf.call(e);return n&&(t?e[Rr]=r:delete e[Rr]),o}var Ds=nf;var of=Object.prototype,sf=of.toString;function af(e){return sf.call(e)}var Fs=af;var cf="[object Null]",lf="[object Undefined]",Bs=at?at.toStringTag:void 0;function uf(e){return e==null?e===void 0?lf:cf:Bs&&Bs in Object(e)?Ds(e):Fs(e)}var mt=uf;function ff(e){return e!=null&&typeof e=="object"}var Y=ff;var hf="[object Symbol]";function pf(e){return typeof e=="symbol"||Y(e)&&mt(e)==hf}var ue=pf;function mf(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Gt=mf;var df=Array.isArray,I=df;var gf=1/0,Gs=at?at.prototype:void 0,$s=Gs?Gs.toString:void 0;function js(e){if(typeof e=="string")return e;if(I(e))return Gt(e,js)+"";if(ue(e))return $s?$s.call(e):"";var t=e+"";return t=="0"&&1/e==-gf?"-0":t}var Ws=js;var Ef=/\s/;function xf(e){for(var t=e.length;t--&&Ef.test(e.charAt(t)););return t}var Ks=xf;var Tf=/^\s+/;function Sf(e){return e&&e.slice(0,Ks(e)+1).replace(Tf,"")}var Hs=Sf;function Af(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var W=Af;var qs=NaN,Nf=/^[-+]0x[0-9a-f]+$/i,If=/^0b[01]+$/i,Of=/^0o[0-7]+$/i,Cf=parseInt;function Rf(e){if(typeof e=="number")return e;if(ue(e))return qs;if(W(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=W(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Hs(e);var r=If.test(e);return r||Of.test(e)?Cf(e.slice(2),r?2:8):Nf.test(e)?qs:+e}var zs=Rf;var Vs=1/0,yf=17976931348623157e292;function Lf(e){if(!e)return e===0?e:0;if(e=zs(e),e===Vs||e===-Vs){var t=e<0?-1:1;return t*yf}return e===e?e:0}var Ys=Lf;function _f(e){var t=Ys(e),r=t%1;return t===t?r?t-r:t:0}var $t=_f;function vf(e){return e}var vt=vf;var Mf="[object AsyncFunction]",bf="[object Function]",kf="[object GeneratorFunction]",Pf="[object Proxy]";function Uf(e){if(!W(e))return!1;var t=mt(e);return t==bf||t==kf||t==Mf||t==Pf}var dt=Uf;var wf=J["__core-js_shared__"],gn=wf;var Xs=(function(){var e=/[^.]+$/.exec(gn&&gn.keys&&gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Df(e){return!!Xs&&Xs in e}var Qs=Df;var Ff=Function.prototype,Bf=Ff.toString;function Gf(e){if(e!=null){try{return Bf.call(e)}catch{}try{return e+""}catch{}}return""}var te=Gf;var $f=/[\\^$.*+?()[\]{}|]/g,jf=/^\[object .+?Constructor\]$/,Wf=Function.prototype,Kf=Object.prototype,Hf=Wf.toString,qf=Kf.hasOwnProperty,zf=RegExp("^"+Hf.call(qf).replace($f,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vf(e){if(!W(e)||Qs(e))return!1;var t=dt(e)?zf:jf;return t.test(te(e))}var Zs=Vf;function Yf(e,t){return e?.[t]}var Js=Yf;function Xf(e,t){var r=Js(e,t);return Zs(r)?r:void 0}var St=Xf;var Qf=St(J,"WeakMap"),En=Qf;var ta=Object.create,Zf=(function(){function e(){}return function(t){if(!W(t))return{};if(ta)return ta(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),ea=Zf;function Jf(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var ra=Jf;function th(){}var K=th;function eh(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var na=eh;var rh=800,nh=16,oh=Date.now;function ih(e){var t=0,r=0;return function(){var n=oh(),o=nh-(n-r);if(r=n,o>0){if(++t>=rh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var oa=ih;function sh(e){return function(){return e}}var ia=sh;var ah=(function(){try{var e=St(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Be=ah;var ch=Be?function(e,t){return Be(e,"toString",{configurable:!0,enumerable:!1,value:ia(t),writable:!0})}:vt,sa=ch;var lh=oa(sa),aa=lh;function uh(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var xn=uh;function fh(e,t,r,n){for(var o=e.length,i=r+(n?1:-1);n?i--:++i<o;)if(t(e[i],i,e))return i;return-1}var Tn=fh;function hh(e){return e!==e}var ca=hh;function ph(e,t,r){for(var n=r-1,o=e.length;++n<o;)if(e[n]===t)return n;return-1}var la=ph;function mh(e,t,r){return t===t?la(e,t,r):Tn(e,ca,r)}var Ge=mh;function dh(e,t){var r=e==null?0:e.length;return!!r&&Ge(e,t,0)>-1}var Sn=dh;var gh=9007199254740991,Eh=/^(?:0|[1-9]\d*)$/;function xh(e,t){var r=typeof e;return t=t??gh,!!t&&(r=="number"||r!="symbol"&&Eh.test(e))&&e>-1&&e%1==0&&e<t}var fe=xh;function Th(e,t,r){t=="__proto__"&&Be?Be(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var $e=Th;function Sh(e,t){return e===t||e!==e&&t!==t}var jt=Sh;var Ah=Object.prototype,Nh=Ah.hasOwnProperty;function Ih(e,t,r){var n=e[t];(!(Nh.call(e,t)&&jt(n,r))||r===void 0&&!(t in e))&&$e(e,t,r)}var he=Ih;function Oh(e,t,r,n){var o=!r;r||(r={});for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n?n(r[a],e[a],a,r,e):void 0;c===void 0&&(c=e[a]),o?$e(r,a,c):he(r,a,c)}return r}var Wt=Oh;var ua=Math.max;function Ch(e,t,r){return t=ua(t===void 0?e.length-1:t,0),function(){for(var n=arguments,o=-1,i=ua(n.length-t,0),s=Array(i);++o<i;)s[o]=n[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=n[o];return a[t]=r(s),ra(e,this,a)}}var fa=Ch;function Rh(e,t){return aa(fa(e,t,vt),e+"")}var je=Rh;var yh=9007199254740991;function Lh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=yh}var We=Lh;function _h(e){return e!=null&&We(e.length)&&!dt(e)}var tt=_h;function vh(e,t,r){if(!W(r))return!1;var n=typeof t;return(n=="number"?tt(r)&&fe(t,r.length):n=="string"&&t in r)?jt(r[t],e):!1}var pe=vh;function Mh(e){return je(function(t,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(i=e.length>3&&typeof i=="function"?(o--,i):void 0,s&&pe(r[0],r[1],s)&&(i=o<3?void 0:i,o=1),t=Object(t);++n<o;){var a=r[n];a&&e(t,a,n,i)}return t})}var ha=Mh;var bh=Object.prototype;function kh(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||bh;return e===r}var Kt=kh;function Ph(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var pa=Ph;var Uh="[object Arguments]";function wh(e){return Y(e)&&mt(e)==Uh}var wi=wh;var ma=Object.prototype,Dh=ma.hasOwnProperty,Fh=ma.propertyIsEnumerable,Bh=wi((function(){return arguments})())?wi:function(e){return Y(e)&&Dh.call(e,"callee")&&!Fh.call(e,"callee")},me=Bh;function Gh(){return!1}var da=Gh;var xa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ga=xa&&typeof module=="object"&&module&&!module.nodeType&&module,$h=ga&&ga.exports===xa,Ea=$h?J.Buffer:void 0,jh=Ea?Ea.isBuffer:void 0,Wh=jh||da,ee=Wh;var Kh="[object Arguments]",Hh="[object Array]",qh="[object Boolean]",zh="[object Date]",Vh="[object Error]",Yh="[object Function]",Xh="[object Map]",Qh="[object Number]",Zh="[object Object]",Jh="[object RegExp]",tp="[object Set]",ep="[object String]",rp="[object WeakMap]",np="[object ArrayBuffer]",op="[object DataView]",ip="[object Float32Array]",sp="[object Float64Array]",ap="[object Int8Array]",cp="[object Int16Array]",lp="[object Int32Array]",up="[object Uint8Array]",fp="[object Uint8ClampedArray]",hp="[object Uint16Array]",pp="[object Uint32Array]",B={};B[ip]=B[sp]=B[ap]=B[cp]=B[lp]=B[up]=B[fp]=B[hp]=B[pp]=!0;B[Kh]=B[Hh]=B[np]=B[qh]=B[op]=B[zh]=B[Vh]=B[Yh]=B[Xh]=B[Qh]=B[Zh]=B[Jh]=B[tp]=B[ep]=B[rp]=!1;function mp(e){return Y(e)&&We(e.length)&&!!B[mt(e)]}var Ta=mp;function dp(e){return function(t){return e(t)}}var Ht=dp;var Sa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yr=Sa&&typeof module=="object"&&module&&!module.nodeType&&module,gp=yr&&yr.exports===Sa,Di=gp&&dn.process,Ep=(function(){try{var e=yr&&yr.require&&yr.require("util").types;return e||Di&&Di.binding&&Di.binding("util")}catch{}})(),Mt=Ep;var Aa=Mt&&Mt.isTypedArray,xp=Aa?Ht(Aa):Ta,Ke=xp;var Tp=Object.prototype,Sp=Tp.hasOwnProperty;function Ap(e,t){var r=I(e),n=!r&&me(e),o=!r&&!n&&ee(e),i=!r&&!n&&!o&&Ke(e),s=r||n||o||i,a=s?pa(e.length,String):[],c=a.length;for(var l in e)(t||Sp.call(e,l))&&!(s&&(l=="length"||o&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||fe(l,c)))&&a.push(l);return a}var An=Ap;function Np(e,t){return function(r){return e(t(r))}}var Nn=Np;var Ip=Nn(Object.keys,Object),Na=Ip;var Op=Object.prototype,Cp=Op.hasOwnProperty;function Rp(e){if(!Kt(e))return Na(e);var t=[];for(var r in Object(e))Cp.call(e,r)&&r!="constructor"&&t.push(r);return t}var In=Rp;function yp(e){return tt(e)?An(e):In(e)}var P=yp;var Lp=Object.prototype,_p=Lp.hasOwnProperty,vp=ha(function(e,t){if(Kt(t)||tt(t)){Wt(t,P(t),e);return}for(var r in t)_p.call(t,r)&&he(e,r,t[r])}),lt=vp;function Mp(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var Ia=Mp;var bp=Object.prototype,kp=bp.hasOwnProperty;function Pp(e){if(!W(e))return Ia(e);var t=Kt(e),r=[];for(var n in e)n=="constructor"&&(t||!kp.call(e,n))||r.push(n);return r}var Oa=Pp;function Up(e){return tt(e)?An(e,!0):Oa(e)}var de=Up;var wp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Dp=/^\w*$/;function Fp(e,t){if(I(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ue(e)?!0:Dp.test(e)||!wp.test(e)||t!=null&&e in Object(t)}var He=Fp;var Bp=St(Object,"create"),re=Bp;function Gp(){this.__data__=re?re(null):{},this.size=0}var Ca=Gp;function $p(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ra=$p;var jp="__lodash_hash_undefined__",Wp=Object.prototype,Kp=Wp.hasOwnProperty;function Hp(e){var t=this.__data__;if(re){var r=t[e];return r===jp?void 0:r}return Kp.call(t,e)?t[e]:void 0}var ya=Hp;var qp=Object.prototype,zp=qp.hasOwnProperty;function Vp(e){var t=this.__data__;return re?t[e]!==void 0:zp.call(t,e)}var La=Vp;var Yp="__lodash_hash_undefined__";function Xp(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=re&&t===void 0?Yp:t,this}var _a=Xp;function qe(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}qe.prototype.clear=Ca;qe.prototype.delete=Ra;qe.prototype.get=ya;qe.prototype.has=La;qe.prototype.set=_a;var Fi=qe;function Qp(){this.__data__=[],this.size=0}var va=Qp;function Zp(e,t){for(var r=e.length;r--;)if(jt(e[r][0],t))return r;return-1}var ge=Zp;var Jp=Array.prototype,tm=Jp.splice;function em(e){var t=this.__data__,r=ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():tm.call(t,r,1),--this.size,!0}var Ma=em;function rm(e){var t=this.__data__,r=ge(t,e);return r<0?void 0:t[r][1]}var ba=rm;function nm(e){return ge(this.__data__,e)>-1}var ka=nm;function om(e,t){var r=this.__data__,n=ge(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var Pa=om;function ze(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=va;ze.prototype.delete=Ma;ze.prototype.get=ba;ze.prototype.has=ka;ze.prototype.set=Pa;var Ee=ze;var im=St(J,"Map"),xe=im;function sm(){this.size=0,this.__data__={hash:new Fi,map:new(xe||Ee),string:new Fi}}var Ua=sm;function am(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var wa=am;function cm(e,t){var r=e.__data__;return wa(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Te=cm;function lm(e){var t=Te(this,e).delete(e);return this.size-=t?1:0,t}var Da=lm;function um(e){return Te(this,e).get(e)}var Fa=um;function fm(e){return Te(this,e).has(e)}var Ba=fm;function hm(e,t){var r=Te(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var Ga=hm;function Ve(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=Ua;Ve.prototype.delete=Da;Ve.prototype.get=Fa;Ve.prototype.has=Ba;Ve.prototype.set=Ga;var Le=Ve;var pm="Expected a function";function Bi(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(pm);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(Bi.Cache||Le),r}Bi.Cache=Le;var $a=Bi;var mm=500;function dm(e){var t=$a(e,function(n){return r.size===mm&&r.clear(),n}),r=t.cache;return t}var ja=dm;var gm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Em=/\\(\\)?/g,xm=ja(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(gm,function(r,n,o,i){t.push(o?i.replace(Em,"$1"):n||r)}),t}),Wa=xm;function Tm(e){return e==null?"":Ws(e)}var Ka=Tm;function Sm(e,t){return I(e)?e:He(e,t)?[e]:Wa(Ka(e))}var Se=Sm;var Am=1/0;function Nm(e){if(typeof e=="string"||ue(e))return e;var t=e+"";return t=="0"&&1/e==-Am?"-0":t}var qt=Nm;function Im(e,t){t=Se(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[qt(t[r++])];return r&&r==n?e:void 0}var Ye=Im;function Om(e,t,r){var n=e==null?void 0:Ye(e,t);return n===void 0?r:n}var Ha=Om;function Cm(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}var Xe=Cm;var qa=at?at.isConcatSpreadable:void 0;function Rm(e){return I(e)||me(e)||!!(qa&&e&&e[qa])}var za=Rm;function Va(e,t,r,n,o){var i=-1,s=e.length;for(r||(r=za),o||(o=[]);++i<s;){var a=e[i];t>0&&r(a)?t>1?Va(a,t-1,r,n,o):Xe(o,a):n||(o[o.length]=a)}return o}var Qe=Va;function ym(e){var t=e==null?0:e.length;return t?Qe(e,1):[]}var ot=ym;var Lm=Nn(Object.getPrototypeOf,Object),On=Lm;function _m(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}var Cn=_m;function vm(e,t,r,n){var o=-1,i=e==null?0:e.length;for(n&&i&&(r=e[++o]);++o<i;)r=t(r,e[o],o,e);return r}var Ya=vm;function Mm(){this.__data__=new Ee,this.size=0}var Xa=Mm;function bm(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Qa=bm;function km(e){return this.__data__.get(e)}var Za=km;function Pm(e){return this.__data__.has(e)}var Ja=Pm;var Um=200;function wm(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!xe||n.length<Um-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Le(n)}return r.set(e,t),this.size=r.size,this}var tc=wm;function Ze(e){var t=this.__data__=new Ee(e);this.size=t.size}Ze.prototype.clear=Xa;Ze.prototype.delete=Qa;Ze.prototype.get=Za;Ze.prototype.has=Ja;Ze.prototype.set=tc;var Ae=Ze;function Dm(e,t){return e&&Wt(t,P(t),e)}var ec=Dm;function Fm(e,t){return e&&Wt(t,de(t),e)}var rc=Fm;var sc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nc=sc&&typeof module=="object"&&module&&!module.nodeType&&module,Bm=nc&&nc.exports===sc,oc=Bm?J.Buffer:void 0,ic=oc?oc.allocUnsafe:void 0;function Gm(e,t){if(t)return e.slice();var r=e.length,n=ic?ic(r):new e.constructor(r);return e.copy(n),n}var ac=Gm;function $m(e,t){for(var r=-1,n=e==null?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}var Je=$m;function jm(){return[]}var Rn=jm;var Wm=Object.prototype,Km=Wm.propertyIsEnumerable,cc=Object.getOwnPropertySymbols,Hm=cc?function(e){return e==null?[]:(e=Object(e),Je(cc(e),function(t){return Km.call(e,t)}))}:Rn,tr=Hm;function qm(e,t){return Wt(e,tr(e),t)}var lc=qm;var zm=Object.getOwnPropertySymbols,Vm=zm?function(e){for(var t=[];e;)Xe(t,tr(e)),e=On(e);return t}:Rn,yn=Vm;function Ym(e,t){return Wt(e,yn(e),t)}var uc=Ym;function Xm(e,t,r){var n=t(e);return I(e)?n:Xe(n,r(e))}var Ln=Xm;function Qm(e){return Ln(e,P,tr)}var Lr=Qm;function Zm(e){return Ln(e,de,yn)}var _n=Zm;var Jm=St(J,"DataView"),vn=Jm;var td=St(J,"Promise"),Mn=td;var ed=St(J,"Set"),Ne=ed;var fc="[object Map]",rd="[object Object]",hc="[object Promise]",pc="[object Set]",mc="[object WeakMap]",dc="[object DataView]",nd=te(vn),od=te(xe),id=te(Mn),sd=te(Ne),ad=te(En),_e=mt;(vn&&_e(new vn(new ArrayBuffer(1)))!=dc||xe&&_e(new xe)!=fc||Mn&&_e(Mn.resolve())!=hc||Ne&&_e(new Ne)!=pc||En&&_e(new En)!=mc)&&(_e=function(e){var t=mt(e),r=t==rd?e.constructor:void 0,n=r?te(r):"";if(n)switch(n){case nd:return dc;case od:return fc;case id:return hc;case sd:return pc;case ad:return mc}return t});var Ut=_e;var cd=Object.prototype,ld=cd.hasOwnProperty;function ud(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&ld.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var gc=ud;var fd=J.Uint8Array,er=fd;function hd(e){var t=new e.constructor(e.byteLength);return new er(t).set(new er(e)),t}var rr=hd;function pd(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var Ec=pd;var md=/\w*$/;function dd(e){var t=new e.constructor(e.source,md.exec(e));return t.lastIndex=e.lastIndex,t}var xc=dd;var Tc=at?at.prototype:void 0,Sc=Tc?Tc.valueOf:void 0;function gd(e){return Sc?Object(Sc.call(e)):{}}var Ac=gd;function Ed(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var Nc=Ed;var xd="[object Boolean]",Td="[object Date]",Sd="[object Map]",Ad="[object Number]",Nd="[object RegExp]",Id="[object Set]",Od="[object String]",Cd="[object Symbol]",Rd="[object ArrayBuffer]",yd="[object DataView]",Ld="[object Float32Array]",_d="[object Float64Array]",vd="[object Int8Array]",Md="[object Int16Array]",bd="[object Int32Array]",kd="[object Uint8Array]",Pd="[object Uint8ClampedArray]",Ud="[object Uint16Array]",wd="[object Uint32Array]";function Dd(e,t,r){var n=e.constructor;switch(t){case Rd:return rr(e);case xd:case Td:return new n(+e);case yd:return Ec(e,r);case Ld:case _d:case vd:case Md:case bd:case kd:case Pd:case Ud:case wd:return Nc(e,r);case Sd:return new n;case Ad:case Od:return new n(e);case Nd:return xc(e);case Id:return new n;case Cd:return Ac(e)}}var Ic=Dd;function Fd(e){return typeof e.constructor=="function"&&!Kt(e)?ea(On(e)):{}}var Oc=Fd;var Bd="[object Map]";function Gd(e){return Y(e)&&Ut(e)==Bd}var Cc=Gd;var Rc=Mt&&Mt.isMap,$d=Rc?Ht(Rc):Cc,yc=$d;var jd="[object Set]";function Wd(e){return Y(e)&&Ut(e)==jd}var Lc=Wd;var _c=Mt&&Mt.isSet,Kd=_c?Ht(_c):Lc,vc=Kd;var Hd=1,qd=2,zd=4,Mc="[object Arguments]",Vd="[object Array]",Yd="[object Boolean]",Xd="[object Date]",Qd="[object Error]",bc="[object Function]",Zd="[object GeneratorFunction]",Jd="[object Map]",tg="[object Number]",kc="[object Object]",eg="[object RegExp]",rg="[object Set]",ng="[object String]",og="[object Symbol]",ig="[object WeakMap]",sg="[object ArrayBuffer]",ag="[object DataView]",cg="[object Float32Array]",lg="[object Float64Array]",ug="[object Int8Array]",fg="[object Int16Array]",hg="[object Int32Array]",pg="[object Uint8Array]",mg="[object Uint8ClampedArray]",dg="[object Uint16Array]",gg="[object Uint32Array]",U={};U[Mc]=U[Vd]=U[sg]=U[ag]=U[Yd]=U[Xd]=U[cg]=U[lg]=U[ug]=U[fg]=U[hg]=U[Jd]=U[tg]=U[kc]=U[eg]=U[rg]=U[ng]=U[og]=U[pg]=U[mg]=U[dg]=U[gg]=!0;U[Qd]=U[bc]=U[ig]=!1;function bn(e,t,r,n,o,i){var s,a=t&Hd,c=t&qd,l=t&zd;if(r&&(s=o?r(e,n,o,i):r(e)),s!==void 0)return s;if(!W(e))return e;var u=I(e);if(u){if(s=gc(e),!a)return na(e,s)}else{var f=Ut(e),h=f==bc||f==Zd;if(ee(e))return ac(e,a);if(f==kc||f==Mc||h&&!o){if(s=c||h?{}:Oc(e),!a)return c?uc(e,rc(s,e)):lc(e,ec(s,e))}else{if(!U[f])return o?e:{};s=Ic(e,f,a)}}i||(i=new Ae);var x=i.get(e);if(x)return x;i.set(e,s),vc(e)?e.forEach(function(R){s.add(bn(R,t,r,R,e,i))}):yc(e)&&e.forEach(function(R,N){s.set(N,bn(R,t,r,N,e,i))});var T=l?c?_n:Lr:c?de:P,O=u?void 0:T(e);return xn(O||e,function(R,N){O&&(N=R,R=e[N]),he(s,N,bn(R,t,r,N,e,i))}),s}var Pc=bn;var Eg=4;function xg(e){return Pc(e,Eg)}var w=xg;function Tg(e){for(var t=-1,r=e==null?0:e.length,n=0,o=[];++t<r;){var i=e[t];i&&(o[n++]=i)}return o}var zt=Tg;var Sg="__lodash_hash_undefined__";function Ag(e){return this.__data__.set(e,Sg),this}var Uc=Ag;function Ng(e){return this.__data__.has(e)}var wc=Ng;function kn(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Le;++t<r;)this.add(e[t])}kn.prototype.add=kn.prototype.push=Uc;kn.prototype.has=wc;var nr=kn;function Ig(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Pn=Ig;function Og(e,t){return e.has(t)}var or=Og;var Cg=1,Rg=2;function yg(e,t,r,n,o,i){var s=r&Cg,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var f=-1,h=!0,x=r&Rg?new nr:void 0;for(i.set(e,t),i.set(t,e);++f<a;){var T=e[f],O=t[f];if(n)var R=s?n(O,T,f,t,e,i):n(T,O,f,e,t,i);if(R!==void 0){if(R)continue;h=!1;break}if(x){if(!Pn(t,function(N,E){if(!or(x,E)&&(T===N||o(T,N,r,n,i)))return x.push(E)})){h=!1;break}}else if(!(T===O||o(T,O,r,n,i))){h=!1;break}}return i.delete(e),i.delete(t),h}var Un=yg;function Lg(e){var t=-1,r=Array(e.size);return e.forEach(function(n,o){r[++t]=[o,n]}),r}var Dc=Lg;function _g(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var ir=_g;var vg=1,Mg=2,bg="[object Boolean]",kg="[object Date]",Pg="[object Error]",Ug="[object Map]",wg="[object Number]",Dg="[object RegExp]",Fg="[object Set]",Bg="[object String]",Gg="[object Symbol]",$g="[object ArrayBuffer]",jg="[object DataView]",Fc=at?at.prototype:void 0,Gi=Fc?Fc.valueOf:void 0;function Wg(e,t,r,n,o,i,s){switch(r){case jg:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case $g:return!(e.byteLength!=t.byteLength||!i(new er(e),new er(t)));case bg:case kg:case wg:return jt(+e,+t);case Pg:return e.name==t.name&&e.message==t.message;case Dg:case Bg:return e==t+"";case Ug:var a=Dc;case Fg:var c=n&vg;if(a||(a=ir),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=Mg,s.set(e,t);var u=Un(a(e),a(t),n,o,i,s);return s.delete(e),u;case Gg:if(Gi)return Gi.call(e)==Gi.call(t)}return!1}var Bc=Wg;var Kg=1,Hg=Object.prototype,qg=Hg.hasOwnProperty;function zg(e,t,r,n,o,i){var s=r&Kg,a=Lr(e),c=a.length,l=Lr(t),u=l.length;if(c!=u&&!s)return!1;for(var f=c;f--;){var h=a[f];if(!(s?h in t:qg.call(t,h)))return!1}var x=i.get(e),T=i.get(t);if(x&&T)return x==t&&T==e;var O=!0;i.set(e,t),i.set(t,e);for(var R=s;++f<c;){h=a[f];var N=e[h],E=t[h];if(n)var d=s?n(E,N,h,t,e,i):n(N,E,h,e,t,i);if(!(d===void 0?N===E||o(N,E,r,n,i):d)){O=!1;break}R||(R=h=="constructor")}if(O&&!R){var y=e.constructor,L=t.constructor;y!=L&&"constructor"in e&&"constructor"in t&&!(typeof y=="function"&&y instanceof y&&typeof L=="function"&&L instanceof L)&&(O=!1)}return i.delete(e),i.delete(t),O}var Gc=zg;var Vg=1,$c="[object Arguments]",jc="[object Array]",wn="[object Object]",Yg=Object.prototype,Wc=Yg.hasOwnProperty;function Xg(e,t,r,n,o,i){var s=I(e),a=I(t),c=s?jc:Ut(e),l=a?jc:Ut(t);c=c==$c?wn:c,l=l==$c?wn:l;var u=c==wn,f=l==wn,h=c==l;if(h&&ee(e)){if(!ee(t))return!1;s=!0,u=!1}if(h&&!u)return i||(i=new Ae),s||Ke(e)?Un(e,t,r,n,o,i):Bc(e,t,c,r,n,o,i);if(!(r&Vg)){var x=u&&Wc.call(e,"__wrapped__"),T=f&&Wc.call(t,"__wrapped__");if(x||T){var O=x?e.value():e,R=T?t.value():t;return i||(i=new Ae),o(O,R,r,n,i)}}return h?(i||(i=new Ae),Gc(e,t,r,n,o,i)):!1}var Kc=Xg;function Hc(e,t,r,n,o){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:Kc(e,t,r,n,Hc,o)}var Dn=Hc;var Qg=1,Zg=2;function Jg(e,t,r,n){var o=r.length,i=o,s=!n;if(e==null)return!i;for(e=Object(e);o--;){var a=r[o];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<i;){a=r[o];var c=a[0],l=e[c],u=a[1];if(s&&a[2]){if(l===void 0&&!(c in e))return!1}else{var f=new Ae;if(n)var h=n(l,u,c,e,t,f);if(!(h===void 0?Dn(u,l,Qg|Zg,n,f):h))return!1}}return!0}var qc=Jg;function tE(e){return e===e&&!W(e)}var Fn=tE;function eE(e){for(var t=P(e),r=t.length;r--;){var n=t[r],o=e[n];t[r]=[n,o,Fn(o)]}return t}var zc=eE;function rE(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Bn=rE;function nE(e){var t=zc(e);return t.length==1&&t[0][2]?Bn(t[0][0],t[0][1]):function(r){return r===e||qc(r,e,t)}}var Vc=nE;function oE(e,t){return e!=null&&t in Object(e)}var Yc=oE;function iE(e,t,r){t=Se(t,e);for(var n=-1,o=t.length,i=!1;++n<o;){var s=qt(t[n]);if(!(i=e!=null&&r(e,s)))break;e=e[s]}return i||++n!=o?i:(o=e==null?0:e.length,!!o&&We(o)&&fe(s,o)&&(I(e)||me(e)))}var Gn=iE;function sE(e,t){return e!=null&&Gn(e,t,Yc)}var Xc=sE;var aE=1,cE=2;function lE(e,t){return He(e)&&Fn(t)?Bn(qt(e),t):function(r){var n=Ha(r,e);return n===void 0&&n===t?Xc(r,e):Dn(t,n,aE|cE)}}var Qc=lE;function uE(e){return function(t){return t?.[e]}}var Zc=uE;function fE(e){return function(t){return Ye(t,e)}}var Jc=fE;function hE(e){return He(e)?Zc(qt(e)):Jc(e)}var tl=hE;function pE(e){return typeof e=="function"?e:e==null?vt:typeof e=="object"?I(e)?Qc(e[0],e[1]):Vc(e):tl(e)}var et=pE;function mE(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;){var s=e[o];t(n,s,r(s),e)}return n}var el=mE;function dE(e){return function(t,r,n){for(var o=-1,i=Object(t),s=n(t),a=s.length;a--;){var c=s[e?a:++o];if(r(i[c],c,i)===!1)break}return t}}var rl=dE;var gE=rl(),nl=gE;function EE(e,t){return e&&nl(e,t,P)}var ol=EE;function xE(e,t){return function(r,n){if(r==null)return r;if(!tt(r))return e(r,n);for(var o=r.length,i=t?o:-1,s=Object(r);(t?i--:++i<o)&&n(s[i],i,s)!==!1;);return r}}var il=xE;var TE=il(ol),At=TE;function SE(e,t,r,n){return At(e,function(o,i,s){t(n,o,r(o),s)}),n}var sl=SE;function AE(e,t){return function(r,n){var o=I(r)?el:sl,i=t?t():{};return o(r,e,et(n,2),i)}}var al=AE;var cl=Object.prototype,NE=cl.hasOwnProperty,IE=je(function(e,t){e=Object(e);var r=-1,n=t.length,o=n>2?t[2]:void 0;for(o&&pe(t[0],t[1],o)&&(n=1);++r<n;)for(var i=t[r],s=de(i),a=-1,c=s.length;++a<c;){var l=s[a],u=e[l];(u===void 0||jt(u,cl[l])&&!NE.call(e,l))&&(e[l]=i[l])}return e}),sr=IE;function OE(e){return Y(e)&&tt(e)}var $i=OE;function CE(e,t,r){for(var n=-1,o=e==null?0:e.length;++n<o;)if(r(t,e[n]))return!0;return!1}var $n=CE;var RE=200;function yE(e,t,r,n){var o=-1,i=Sn,s=!0,a=e.length,c=[],l=t.length;if(!a)return c;r&&(t=Gt(t,Ht(r))),n?(i=$n,s=!1):t.length>=RE&&(i=or,s=!1,t=new nr(t));t:for(;++o<a;){var u=e[o],f=r==null?u:r(u);if(u=n||u!==0?u:0,s&&f===f){for(var h=l;h--;)if(t[h]===f)continue t;c.push(u)}else i(t,f,n)||c.push(u)}return c}var ll=yE;var LE=je(function(e,t){return $i(e)?ll(e,Qe(t,1,$i,!0)):[]}),Ie=LE;function _E(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Vt=_E;function vE(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),Cn(e,t<0?0:t,n)):[]}var X=vE;function ME(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),t=n-t,Cn(e,0,t<0?0:t)):[]}var ne=ME;function bE(e){return typeof e=="function"?e:vt}var ul=bE;function kE(e,t){var r=I(e)?xn:At;return r(e,ul(t))}var S=kE;function PE(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}var fl=PE;function UE(e,t){var r=!0;return At(e,function(n,o,i){return r=!!t(n,o,i),r}),r}var hl=UE;function wE(e,t,r){var n=I(e)?fl:hl;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var ft=wE;function DE(e,t){var r=[];return At(e,function(n,o,i){t(n,o,i)&&r.push(n)}),r}var jn=DE;function FE(e,t){var r=I(e)?Je:jn;return r(e,et(t,3))}var ht=FE;function BE(e){return function(t,r,n){var o=Object(t);if(!tt(t)){var i=et(r,3);t=P(t),r=function(a){return i(o[a],a,o)}}var s=e(t,r,n);return s>-1?o[i?t[s]:s]:void 0}}var pl=BE;var GE=Math.max;function $E(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var o=r==null?0:$t(r);return o<0&&(o=GE(n+o,0)),Tn(e,et(t,3),o)}var ml=$E;var jE=pl(ml),Yt=jE;function WE(e){return e&&e.length?e[0]:void 0}var ct=WE;function KE(e,t){var r=-1,n=tt(e)?Array(e.length):[];return At(e,function(o,i,s){n[++r]=t(o,i,s)}),n}var dl=KE;function HE(e,t){var r=I(e)?Gt:dl;return r(e,et(t,3))}var g=HE;function qE(e,t){return Qe(g(e,t),1)}var gt=qE;var zE=Object.prototype,VE=zE.hasOwnProperty,YE=al(function(e,t,r){VE.call(e,r)?e[r].push(t):$e(e,r,[t])}),ji=YE;var XE=Object.prototype,QE=XE.hasOwnProperty;function ZE(e,t){return e!=null&&QE.call(e,t)}var gl=ZE;function JE(e,t){return e!=null&&Gn(e,t,gl)}var A=JE;var tx="[object String]";function ex(e){return typeof e=="string"||!I(e)&&Y(e)&&mt(e)==tx}var it=ex;function rx(e,t){return Gt(t,function(r){return e[r]})}var El=rx;function nx(e){return e==null?[]:El(e,P(e))}var k=nx;var ox=Math.max;function ix(e,t,r,n){e=tt(e)?e:k(e),r=r&&!n?$t(r):0;var o=e.length;return r<0&&(r=ox(o+r,0)),it(e)?r<=o&&e.indexOf(t,r)>-1:!!o&&Ge(e,t,r)>-1}var $=ix;var sx=Math.max;function ax(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var o=r==null?0:$t(r);return o<0&&(o=sx(n+o,0)),Ge(e,t,o)}var Wn=ax;var cx="[object Map]",lx="[object Set]",ux=Object.prototype,fx=ux.hasOwnProperty;function hx(e){if(e==null)return!0;if(tt(e)&&(I(e)||typeof e=="string"||typeof e.splice=="function"||ee(e)||Ke(e)||me(e)))return!e.length;var t=Ut(e);if(t==cx||t==lx)return!e.size;if(Kt(e))return!In(e).length;for(var r in e)if(fx.call(e,r))return!1;return!0}var _=hx;var px="[object RegExp]";function mx(e){return Y(e)&&mt(e)==px}var xl=mx;var Tl=Mt&&Mt.isRegExp,dx=Tl?Ht(Tl):xl,bt=dx;function gx(e){return e===void 0}var pt=gx;var Ex="Expected a function";function xx(e){if(typeof e!="function")throw new TypeError(Ex);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var Sl=xx;function Tx(e,t,r,n){if(!W(e))return e;t=Se(t,e);for(var o=-1,i=t.length,s=i-1,a=e;a!=null&&++o<i;){var c=qt(t[o]),l=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(o!=s){var u=a[c];l=n?n(u,c,a):void 0,l===void 0&&(l=W(u)?u:fe(t[o+1])?[]:{})}he(a,c,l),a=a[c]}return e}var Al=Tx;function Sx(e,t,r){for(var n=-1,o=t.length,i={};++n<o;){var s=t[n],a=Ye(e,s);r(a,s)&&Al(i,Se(s,e),a)}return i}var Nl=Sx;function Ax(e,t){if(e==null)return{};var r=Gt(_n(e),function(n){return[n]});return t=et(t),Nl(e,r,function(n,o){return t(n,o[0])})}var Nt=Ax;function Nx(e,t,r,n,o){return o(e,function(i,s,a){r=n?(n=!1,i):t(r,i,s,a)}),r}var Il=Nx;function Ix(e,t,r){var n=I(e)?Ya:Il,o=arguments.length<3;return n(e,et(t,4),r,o,At)}var rt=Ix;function Ox(e,t){var r=I(e)?Je:jn;return r(e,Sl(et(t,3)))}var Oe=Ox;function Cx(e,t){var r;return At(e,function(n,o,i){return r=t(n,o,i),!r}),!!r}var Ol=Cx;function Rx(e,t,r){var n=I(e)?Pn:Ol;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var _r=Rx;var yx=1/0,Lx=Ne&&1/ir(new Ne([,-0]))[1]==yx?function(e){return new Ne(e)}:K,Cl=Lx;var _x=200;function vx(e,t,r){var n=-1,o=Sn,i=e.length,s=!0,a=[],c=a;if(r)s=!1,o=$n;else if(i>=_x){var l=t?null:Cl(e);if(l)return ir(l);s=!1,o=or,c=new nr}else c=t?[]:a;t:for(;++n<i;){var u=e[n],f=t?t(u):u;if(u=r||u!==0?u:0,s&&f===f){for(var h=c.length;h--;)if(c[h]===f)continue t;t&&c.push(f),a.push(u)}else o(c,f,r)||(c!==a&&c.push(f),a.push(u))}return a}var Rl=vx;function Mx(e){return e&&e.length?Rl(e):[]}var ar=Mx;function cr(e){console&&console.error&&console.error(`Error: ${e}`)}function vr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function Mr(e){let t=new Date().getTime(),r=e();return{time:new Date().getTime()-t,value:r}}function br(e){function t(){}t.prototype=e;let r=new t;function n(){return typeof r.bar}return n(),n(),e;(0,eval)(e)}function bx(e){return kx(e)?e.LABEL:e.name}function kx(e){return it(e.LABEL)&&e.LABEL!==""}var Lt=class{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),S(this.definition,r=>{r.accept(t)})}},D=class extends Lt{constructor(t){super([]),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}set definition(t){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(t){t.visit(this)}},Et=class extends Lt{constructor(t){super(t.definition),this.orgText="",lt(this,Nt(t,r=>r!==void 0))}},F=class extends Lt{constructor(t){super(t.definition),this.ignoreAmbiguities=!1,lt(this,Nt(t,r=>r!==void 0))}},G=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},Q=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},Z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},b=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},V=class extends Lt{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,lt(this,Nt(t,r=>r!==void 0))}},v=class{constructor(t){this.idx=1,lt(this,Nt(t,r=>r!==void 0))}accept(t){t.visit(this)}};function Kn(e){return g(e,lr)}function lr(e){function t(r){return g(r,lr)}if(e instanceof D){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return it(e.label)&&(r.label=e.label),r}else{if(e instanceof F)return{type:"Alternative",definition:t(e.definition)};if(e instanceof G)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof Q)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof Z)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof z)return{type:"RepetitionWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof b)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof V)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof v){let r={type:"Terminal",name:e.terminalType.name,label:bx(e.terminalType),idx:e.idx};it(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=bt(n)?n.source:n),r}else{if(e instanceof Et)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var xt=class{visit(t){let r=t;switch(r.constructor){case D:return this.visitNonTerminal(r);case F:return this.visitAlternative(r);case G:return this.visitOption(r);case Q:return this.visitRepetitionMandatory(r);case Z:return this.visitRepetitionMandatoryWithSeparator(r);case z:return this.visitRepetitionWithSeparator(r);case b:return this.visitRepetition(r);case V:return this.visitAlternation(r);case v:return this.visitTerminal(r);case Et:return this.visitRule(r);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}};function Wi(e){return e instanceof F||e instanceof G||e instanceof b||e instanceof Q||e instanceof Z||e instanceof z||e instanceof v||e instanceof Et}function ve(e,t=[]){return e instanceof G||e instanceof b||e instanceof z?!0:e instanceof V?_r(e.definition,n=>ve(n,t)):e instanceof D&&$(t,e)?!1:e instanceof Lt?(e instanceof D&&t.push(e),ft(e.definition,n=>ve(n,t))):!1}function Ki(e){return e instanceof V}function It(e){if(e instanceof D)return"SUBRULE";if(e instanceof G)return"OPTION";if(e instanceof V)return"OR";if(e instanceof Q)return"AT_LEAST_ONE";if(e instanceof Z)return"AT_LEAST_ONE_SEP";if(e instanceof z)return"MANY_SEP";if(e instanceof b)return"MANY";if(e instanceof v)return"CONSUME";throw Error("non exhaustive match")}var oe=class{walk(t,r=[]){S(t.definition,(n,o)=>{let i=X(t.definition,o+1);if(n instanceof D)this.walkProdRef(n,i,r);else if(n instanceof v)this.walkTerminal(n,i,r);else if(n instanceof F)this.walkFlat(n,i,r);else if(n instanceof G)this.walkOption(n,i,r);else if(n instanceof Q)this.walkAtLeastOne(n,i,r);else if(n instanceof Z)this.walkAtLeastOneSep(n,i,r);else if(n instanceof z)this.walkManySep(n,i,r);else if(n instanceof b)this.walkMany(n,i,r);else if(n instanceof V)this.walkOr(n,i,r);else throw Error("non exhaustive match")})}walkTerminal(t,r,n){}walkProdRef(t,r,n){}walkFlat(t,r,n){let o=r.concat(n);this.walk(t,o)}walkOption(t,r,n){let o=r.concat(n);this.walk(t,o)}walkAtLeastOne(t,r,n){let o=[new G({definition:t.definition})].concat(r,n);this.walk(t,o)}walkAtLeastOneSep(t,r,n){let o=yl(t,r,n);this.walk(t,o)}walkMany(t,r,n){let o=[new G({definition:t.definition})].concat(r,n);this.walk(t,o)}walkManySep(t,r,n){let o=yl(t,r,n);this.walk(t,o)}walkOr(t,r,n){let o=r.concat(n);S(t.definition,i=>{let s=new F({definition:[i]});this.walk(s,o)})}};function yl(e,t,r){return[new G({definition:[new v({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Me(e){if(e instanceof D)return Me(e.referencedRule);if(e instanceof v)return wx(e);if(Wi(e))return Px(e);if(Ki(e))return Ux(e);throw Error("non exhaustive match")}function Px(e){let t=[],r=e.definition,n=0,o=r.length>n,i,s=!0;for(;o&&s;)i=r[n],s=ve(i),t=t.concat(Me(i)),n=n+1,o=r.length>n;return ar(t)}function Ux(e){let t=g(e.definition,r=>Me(r));return ar(ot(t))}function wx(e){return[e.terminalType]}var Hn="_~IN~_";var Hi=class extends oe{constructor(t){super(),this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,r,n){}walkProdRef(t,r,n){let o=Dx(t.referencedRule,t.idx)+this.topProd.name,i=r.concat(n),s=new F({definition:i}),a=Me(s);this.follows[o]=a}};function Ll(e){let t={};return S(e,r=>{let n=new Hi(r).startWalking();lt(t,n)}),t}function Dx(e,t){return e.name+t+Hn}function C(e){return e.charCodeAt(0)}function qn(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function ur(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function be(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function kr(){throw Error("Internal Error - Should never get here!")}function qi(e){return e.type==="Character"}var Pr=[];for(let e=C("0");e<=C("9");e++)Pr.push(e);var Ur=[C("_")].concat(Pr);for(let e=C("a");e<=C("z");e++)Ur.push(e);for(let e=C("A");e<=C("Z");e++)Ur.push(e);var zi=[C(" "),C("\f"),C(`
3
- `),C("\r"),C(" "),C("\v"),C(" "),C("\xA0"),C("\u1680"),C("\u2000"),C("\u2001"),C("\u2002"),C("\u2003"),C("\u2004"),C("\u2005"),C("\u2006"),C("\u2007"),C("\u2008"),C("\u2009"),C("\u200A"),C("\u2028"),C("\u2029"),C("\u202F"),C("\u205F"),C("\u3000"),C("\uFEFF")];var Fx=/[0-9a-fA-F]/,zn=/[0-9]/,Bx=/[1-9]/,wr=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");let r=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":ur(n,"global");break;case"i":ur(n,"ignoreCase");break;case"m":ur(n,"multiLine");break;case"u":ur(n,"unicode");break;case"y":ur(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:r,loc:this.loc(0)}}disjunction(){let t=[],r=this.idx;for(t.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(r)}}alternative(){let t=[],r=this.idx;for(;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(r)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let r;switch(this.popChar()){case"=":r="Lookahead";break;case"!":r="NegativeLookahead";break}be(r);let n=this.disjunction();return this.consumeChar(")"),{type:r,value:n,loc:this.loc(t)}}return kr()}quantifier(t=!1){let r,n=this.idx;switch(this.popChar()){case"*":r={atLeast:0,atMost:1/0};break;case"+":r={atLeast:1,atMost:1/0};break;case"?":r={atLeast:0,atMost:1};break;case"{":let o=this.integerIncludingZero();switch(this.popChar()){case"}":r={atLeast:o,atMost:o};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),r={atLeast:o,atMost:i}):r={atLeast:o,atMost:1/0},this.consumeChar("}");break}if(t===!0&&r===void 0)return;be(r);break}if(!(t===!0&&r===void 0)&&be(r))return this.peekChar(0)==="?"?(this.consumeChar("?"),r.greedy=!1):r.greedy=!0,r.type="Quantifier",r.loc=this.loc(n),r}atom(){let t,r=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group();break}return t===void 0&&this.isPatternCharacter()&&(t=this.patternCharacter()),be(t)?(t.loc=this.loc(r),this.isQuantifier()&&(t.quantifier=this.quantifier()),t):kr()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
4
- `),C("\r"),C("\u2028"),C("\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 t,r=!1;switch(this.popChar()){case"d":t=Pr;break;case"D":t=Pr,r=!0;break;case"s":t=zi;break;case"S":t=zi,r=!0;break;case"w":t=Ur;break;case"W":t=Ur,r=!0;break}return be(t)?{type:"Set",value:t,complement:r}:kr()}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=C("\f");break;case"n":t=C(`
2
+ import{readFileSync as Qu,writeFileSync as tS,existsSync as eS}from"node:fs";import{resolve as Xu,basename as rS,dirname as nS,join as iS}from"node:path";import{fileURLToPath as oS}from"node:url";var tf=typeof global=="object"&&global&&global.Object===Object&&global,dn=tf;var ef=typeof self=="object"&&self&&self.Object===Object&&self,rf=dn||ef||Function("return this")(),J=rf;var nf=J.Symbol,at=nf;var Ds=Object.prototype,of=Ds.hasOwnProperty,sf=Ds.toString,Rr=at?at.toStringTag:void 0;function af(e){var t=of.call(e,Rr),r=e[Rr];try{e[Rr]=void 0;var n=!0}catch{}var i=sf.call(e);return n&&(t?e[Rr]=r:delete e[Rr]),i}var Fs=af;var cf=Object.prototype,lf=cf.toString;function uf(e){return lf.call(e)}var Bs=uf;var ff="[object Null]",hf="[object Undefined]",Gs=at?at.toStringTag:void 0;function pf(e){return e==null?e===void 0?hf:ff:Gs&&Gs in Object(e)?Fs(e):Bs(e)}var mt=pf;function mf(e){return e!=null&&typeof e=="object"}var Y=mf;var df="[object Symbol]";function gf(e){return typeof e=="symbol"||Y(e)&&mt(e)==df}var ue=gf;function Ef(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Gt=Ef;var xf=Array.isArray,O=xf;var Tf=1/0,$s=at?at.prototype:void 0,js=$s?$s.toString:void 0;function Ws(e){if(typeof e=="string")return e;if(O(e))return Gt(e,Ws)+"";if(ue(e))return js?js.call(e):"";var t=e+"";return t=="0"&&1/e==-Tf?"-0":t}var Ks=Ws;var Sf=/\s/;function Af(e){for(var t=e.length;t--&&Sf.test(e.charAt(t)););return t}var Hs=Af;var Nf=/^\s+/;function Of(e){return e&&e.slice(0,Hs(e)+1).replace(Nf,"")}var qs=Of;function If(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var W=If;var zs=NaN,Cf=/^[-+]0x[0-9a-f]+$/i,Rf=/^0b[01]+$/i,yf=/^0o[0-7]+$/i,Lf=parseInt;function _f(e){if(typeof e=="number")return e;if(ue(e))return zs;if(W(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=W(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=qs(e);var r=Rf.test(e);return r||yf.test(e)?Lf(e.slice(2),r?2:8):Cf.test(e)?zs:+e}var Vs=_f;var Ys=1/0,vf=17976931348623157e292;function Mf(e){if(!e)return e===0?e:0;if(e=Vs(e),e===Ys||e===-Ys){var t=e<0?-1:1;return t*vf}return e===e?e:0}var Xs=Mf;function bf(e){var t=Xs(e),r=t%1;return t===t?r?t-r:t:0}var $t=bf;function kf(e){return e}var vt=kf;var Pf="[object AsyncFunction]",Uf="[object Function]",wf="[object GeneratorFunction]",Df="[object Proxy]";function Ff(e){if(!W(e))return!1;var t=mt(e);return t==Uf||t==wf||t==Pf||t==Df}var dt=Ff;var Bf=J["__core-js_shared__"],gn=Bf;var Qs=(function(){var e=/[^.]+$/.exec(gn&&gn.keys&&gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Gf(e){return!!Qs&&Qs in e}var Zs=Gf;var $f=Function.prototype,jf=$f.toString;function Wf(e){if(e!=null){try{return jf.call(e)}catch{}try{return e+""}catch{}}return""}var te=Wf;var Kf=/[\\^$.*+?()[\]{}|]/g,Hf=/^\[object .+?Constructor\]$/,qf=Function.prototype,zf=Object.prototype,Vf=qf.toString,Yf=zf.hasOwnProperty,Xf=RegExp("^"+Vf.call(Yf).replace(Kf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qf(e){if(!W(e)||Zs(e))return!1;var t=dt(e)?Xf:Hf;return t.test(te(e))}var Js=Qf;function Zf(e,t){return e?.[t]}var ta=Zf;function Jf(e,t){var r=ta(e,t);return Js(r)?r:void 0}var Nt=Jf;var th=Nt(J,"WeakMap"),En=th;var ea=Object.create,eh=(function(){function e(){}return function(t){if(!W(t))return{};if(ea)return ea(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),ra=eh;function rh(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var na=rh;function nh(){}var K=nh;function ih(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var ia=ih;var oh=800,sh=16,ah=Date.now;function ch(e){var t=0,r=0;return function(){var n=ah(),i=sh-(n-r);if(r=n,i>0){if(++t>=oh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var oa=ch;function lh(e){return function(){return e}}var sa=lh;var uh=(function(){try{var e=Nt(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Be=uh;var fh=Be?function(e,t){return Be(e,"toString",{configurable:!0,enumerable:!1,value:sa(t),writable:!0})}:vt,aa=fh;var hh=oa(aa),ca=hh;function ph(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var xn=ph;function mh(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o<i;)if(t(e[o],o,e))return o;return-1}var Tn=mh;function dh(e){return e!==e}var la=dh;function gh(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var ua=gh;function Eh(e,t,r){return t===t?ua(e,t,r):Tn(e,la,r)}var Ge=Eh;function xh(e,t){var r=e==null?0:e.length;return!!r&&Ge(e,t,0)>-1}var Sn=xh;var Th=9007199254740991,Sh=/^(?:0|[1-9]\d*)$/;function Ah(e,t){var r=typeof e;return t=t??Th,!!t&&(r=="number"||r!="symbol"&&Sh.test(e))&&e>-1&&e%1==0&&e<t}var fe=Ah;function Nh(e,t,r){t=="__proto__"&&Be?Be(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var $e=Nh;function Oh(e,t){return e===t||e!==e&&t!==t}var jt=Oh;var Ih=Object.prototype,Ch=Ih.hasOwnProperty;function Rh(e,t,r){var n=e[t];(!(Ch.call(e,t)&&jt(n,r))||r===void 0&&!(t in e))&&$e(e,t,r)}var he=Rh;function yh(e,t,r,n){var i=!r;r||(r={});for(var o=-1,s=t.length;++o<s;){var a=t[o],c=n?n(r[a],e[a],a,r,e):void 0;c===void 0&&(c=e[a]),i?$e(r,a,c):he(r,a,c)}return r}var Wt=yh;var fa=Math.max;function Lh(e,t,r){return t=fa(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=fa(n.length-t,0),s=Array(o);++i<o;)s[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=r(s),na(e,this,a)}}var ha=Lh;function _h(e,t){return ca(ha(e,t,vt),e+"")}var je=_h;var vh=9007199254740991;function Mh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=vh}var We=Mh;function bh(e){return e!=null&&We(e.length)&&!dt(e)}var tt=bh;function kh(e,t,r){if(!W(r))return!1;var n=typeof t;return(n=="number"?tt(r)&&fe(t,r.length):n=="string"&&t in r)?jt(r[t],e):!1}var pe=kh;function Ph(e){return je(function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(o=e.length>3&&typeof o=="function"?(i--,o):void 0,s&&pe(r[0],r[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++n<i;){var a=r[n];a&&e(t,a,n,o)}return t})}var pa=Ph;var Uh=Object.prototype;function wh(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Uh;return e===r}var Kt=wh;function Dh(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var ma=Dh;var Fh="[object Arguments]";function Bh(e){return Y(e)&&mt(e)==Fh}var Do=Bh;var da=Object.prototype,Gh=da.hasOwnProperty,$h=da.propertyIsEnumerable,jh=Do((function(){return arguments})())?Do:function(e){return Y(e)&&Gh.call(e,"callee")&&!$h.call(e,"callee")},me=jh;function Wh(){return!1}var ga=Wh;var Ta=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ea=Ta&&typeof module=="object"&&module&&!module.nodeType&&module,Kh=Ea&&Ea.exports===Ta,xa=Kh?J.Buffer:void 0,Hh=xa?xa.isBuffer:void 0,qh=Hh||ga,ee=qh;var zh="[object Arguments]",Vh="[object Array]",Yh="[object Boolean]",Xh="[object Date]",Qh="[object Error]",Zh="[object Function]",Jh="[object Map]",tp="[object Number]",ep="[object Object]",rp="[object RegExp]",np="[object Set]",ip="[object String]",op="[object WeakMap]",sp="[object ArrayBuffer]",ap="[object DataView]",cp="[object Float32Array]",lp="[object Float64Array]",up="[object Int8Array]",fp="[object Int16Array]",hp="[object Int32Array]",pp="[object Uint8Array]",mp="[object Uint8ClampedArray]",dp="[object Uint16Array]",gp="[object Uint32Array]",B={};B[cp]=B[lp]=B[up]=B[fp]=B[hp]=B[pp]=B[mp]=B[dp]=B[gp]=!0;B[zh]=B[Vh]=B[sp]=B[Yh]=B[ap]=B[Xh]=B[Qh]=B[Zh]=B[Jh]=B[tp]=B[ep]=B[rp]=B[np]=B[ip]=B[op]=!1;function Ep(e){return Y(e)&&We(e.length)&&!!B[mt(e)]}var Sa=Ep;function xp(e){return function(t){return e(t)}}var Ht=xp;var Aa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yr=Aa&&typeof module=="object"&&module&&!module.nodeType&&module,Tp=yr&&yr.exports===Aa,Fo=Tp&&dn.process,Sp=(function(){try{var e=yr&&yr.require&&yr.require("util").types;return e||Fo&&Fo.binding&&Fo.binding("util")}catch{}})(),Mt=Sp;var Na=Mt&&Mt.isTypedArray,Ap=Na?Ht(Na):Sa,Ke=Ap;var Np=Object.prototype,Op=Np.hasOwnProperty;function Ip(e,t){var r=O(e),n=!r&&me(e),i=!r&&!n&&ee(e),o=!r&&!n&&!i&&Ke(e),s=r||n||i||o,a=s?ma(e.length,String):[],c=a.length;for(var l in e)(t||Op.call(e,l))&&!(s&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||fe(l,c)))&&a.push(l);return a}var An=Ip;function Cp(e,t){return function(r){return e(t(r))}}var Nn=Cp;var Rp=Nn(Object.keys,Object),Oa=Rp;var yp=Object.prototype,Lp=yp.hasOwnProperty;function _p(e){if(!Kt(e))return Oa(e);var t=[];for(var r in Object(e))Lp.call(e,r)&&r!="constructor"&&t.push(r);return t}var On=_p;function vp(e){return tt(e)?An(e):On(e)}var P=vp;var Mp=Object.prototype,bp=Mp.hasOwnProperty,kp=pa(function(e,t){if(Kt(t)||tt(t)){Wt(t,P(t),e);return}for(var r in t)bp.call(t,r)&&he(e,r,t[r])}),lt=kp;function Pp(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var Ia=Pp;var Up=Object.prototype,wp=Up.hasOwnProperty;function Dp(e){if(!W(e))return Ia(e);var t=Kt(e),r=[];for(var n in e)n=="constructor"&&(t||!wp.call(e,n))||r.push(n);return r}var Ca=Dp;function Fp(e){return tt(e)?An(e,!0):Ca(e)}var de=Fp;var Bp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Gp=/^\w*$/;function $p(e,t){if(O(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ue(e)?!0:Gp.test(e)||!Bp.test(e)||t!=null&&e in Object(t)}var He=$p;var jp=Nt(Object,"create"),re=jp;function Wp(){this.__data__=re?re(null):{},this.size=0}var Ra=Wp;function Kp(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ya=Kp;var Hp="__lodash_hash_undefined__",qp=Object.prototype,zp=qp.hasOwnProperty;function Vp(e){var t=this.__data__;if(re){var r=t[e];return r===Hp?void 0:r}return zp.call(t,e)?t[e]:void 0}var La=Vp;var Yp=Object.prototype,Xp=Yp.hasOwnProperty;function Qp(e){var t=this.__data__;return re?t[e]!==void 0:Xp.call(t,e)}var _a=Qp;var Zp="__lodash_hash_undefined__";function Jp(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=re&&t===void 0?Zp:t,this}var va=Jp;function qe(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}qe.prototype.clear=Ra;qe.prototype.delete=ya;qe.prototype.get=La;qe.prototype.has=_a;qe.prototype.set=va;var Bo=qe;function tm(){this.__data__=[],this.size=0}var Ma=tm;function em(e,t){for(var r=e.length;r--;)if(jt(e[r][0],t))return r;return-1}var ge=em;var rm=Array.prototype,nm=rm.splice;function im(e){var t=this.__data__,r=ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():nm.call(t,r,1),--this.size,!0}var ba=im;function om(e){var t=this.__data__,r=ge(t,e);return r<0?void 0:t[r][1]}var ka=om;function sm(e){return ge(this.__data__,e)>-1}var Pa=sm;function am(e,t){var r=this.__data__,n=ge(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var Ua=am;function ze(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=Ma;ze.prototype.delete=ba;ze.prototype.get=ka;ze.prototype.has=Pa;ze.prototype.set=Ua;var Ee=ze;var cm=Nt(J,"Map"),xe=cm;function lm(){this.size=0,this.__data__={hash:new Bo,map:new(xe||Ee),string:new Bo}}var wa=lm;function um(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Da=um;function fm(e,t){var r=e.__data__;return Da(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Te=fm;function hm(e){var t=Te(this,e).delete(e);return this.size-=t?1:0,t}var Fa=hm;function pm(e){return Te(this,e).get(e)}var Ba=pm;function mm(e){return Te(this,e).has(e)}var Ga=mm;function dm(e,t){var r=Te(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var $a=dm;function Ve(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=wa;Ve.prototype.delete=Fa;Ve.prototype.get=Ba;Ve.prototype.has=Ga;Ve.prototype.set=$a;var Le=Ve;var gm="Expected a function";function Go(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(gm);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(Go.Cache||Le),r}Go.Cache=Le;var ja=Go;var Em=500;function xm(e){var t=ja(e,function(n){return r.size===Em&&r.clear(),n}),r=t.cache;return t}var Wa=xm;var Tm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Sm=/\\(\\)?/g,Am=Wa(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Tm,function(r,n,i,o){t.push(i?o.replace(Sm,"$1"):n||r)}),t}),Ka=Am;function Nm(e){return e==null?"":Ks(e)}var Ha=Nm;function Om(e,t){return O(e)?e:He(e,t)?[e]:Ka(Ha(e))}var Se=Om;var Im=1/0;function Cm(e){if(typeof e=="string"||ue(e))return e;var t=e+"";return t=="0"&&1/e==-Im?"-0":t}var qt=Cm;function Rm(e,t){t=Se(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[qt(t[r++])];return r&&r==n?e:void 0}var Ye=Rm;function ym(e,t,r){var n=e==null?void 0:Ye(e,t);return n===void 0?r:n}var qa=ym;function Lm(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Xe=Lm;var za=at?at.isConcatSpreadable:void 0;function _m(e){return O(e)||me(e)||!!(za&&e&&e[za])}var Va=_m;function Ya(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=Va),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?Ya(a,t-1,r,n,i):Xe(i,a):n||(i[i.length]=a)}return i}var Qe=Ya;function vm(e){var t=e==null?0:e.length;return t?Qe(e,1):[]}var it=vm;var Mm=Nn(Object.getPrototypeOf,Object),In=Mm;function bm(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o}var Cn=bm;function km(e,t,r,n){var i=-1,o=e==null?0:e.length;for(n&&o&&(r=e[++i]);++i<o;)r=t(r,e[i],i,e);return r}var Xa=km;function Pm(){this.__data__=new Ee,this.size=0}var Qa=Pm;function Um(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Za=Um;function wm(e){return this.__data__.get(e)}var Ja=wm;function Dm(e){return this.__data__.has(e)}var tc=Dm;var Fm=200;function Bm(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!xe||n.length<Fm-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Le(n)}return r.set(e,t),this.size=r.size,this}var ec=Bm;function Ze(e){var t=this.__data__=new Ee(e);this.size=t.size}Ze.prototype.clear=Qa;Ze.prototype.delete=Za;Ze.prototype.get=Ja;Ze.prototype.has=tc;Ze.prototype.set=ec;var Ae=Ze;function Gm(e,t){return e&&Wt(t,P(t),e)}var rc=Gm;function $m(e,t){return e&&Wt(t,de(t),e)}var nc=$m;var ac=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ic=ac&&typeof module=="object"&&module&&!module.nodeType&&module,jm=ic&&ic.exports===ac,oc=jm?J.Buffer:void 0,sc=oc?oc.allocUnsafe:void 0;function Wm(e,t){if(t)return e.slice();var r=e.length,n=sc?sc(r):new e.constructor(r);return e.copy(n),n}var cc=Wm;function Km(e,t){for(var r=-1,n=e==null?0:e.length,i=0,o=[];++r<n;){var s=e[r];t(s,r,e)&&(o[i++]=s)}return o}var Je=Km;function Hm(){return[]}var Rn=Hm;var qm=Object.prototype,zm=qm.propertyIsEnumerable,lc=Object.getOwnPropertySymbols,Vm=lc?function(e){return e==null?[]:(e=Object(e),Je(lc(e),function(t){return zm.call(e,t)}))}:Rn,tr=Vm;function Ym(e,t){return Wt(e,tr(e),t)}var uc=Ym;var Xm=Object.getOwnPropertySymbols,Qm=Xm?function(e){for(var t=[];e;)Xe(t,tr(e)),e=In(e);return t}:Rn,yn=Qm;function Zm(e,t){return Wt(e,yn(e),t)}var fc=Zm;function Jm(e,t,r){var n=t(e);return O(e)?n:Xe(n,r(e))}var Ln=Jm;function td(e){return Ln(e,P,tr)}var Lr=td;function ed(e){return Ln(e,de,yn)}var _n=ed;var rd=Nt(J,"DataView"),vn=rd;var nd=Nt(J,"Promise"),Mn=nd;var id=Nt(J,"Set"),Ne=id;var hc="[object Map]",od="[object Object]",pc="[object Promise]",mc="[object Set]",dc="[object WeakMap]",gc="[object DataView]",sd=te(vn),ad=te(xe),cd=te(Mn),ld=te(Ne),ud=te(En),_e=mt;(vn&&_e(new vn(new ArrayBuffer(1)))!=gc||xe&&_e(new xe)!=hc||Mn&&_e(Mn.resolve())!=pc||Ne&&_e(new Ne)!=mc||En&&_e(new En)!=dc)&&(_e=function(e){var t=mt(e),r=t==od?e.constructor:void 0,n=r?te(r):"";if(n)switch(n){case sd:return gc;case ad:return hc;case cd:return pc;case ld:return mc;case ud:return dc}return t});var Ut=_e;var fd=Object.prototype,hd=fd.hasOwnProperty;function pd(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&hd.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Ec=pd;var md=J.Uint8Array,er=md;function dd(e){var t=new e.constructor(e.byteLength);return new er(t).set(new er(e)),t}var rr=dd;function gd(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var xc=gd;var Ed=/\w*$/;function xd(e){var t=new e.constructor(e.source,Ed.exec(e));return t.lastIndex=e.lastIndex,t}var Tc=xd;var Sc=at?at.prototype:void 0,Ac=Sc?Sc.valueOf:void 0;function Td(e){return Ac?Object(Ac.call(e)):{}}var Nc=Td;function Sd(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var Oc=Sd;var Ad="[object Boolean]",Nd="[object Date]",Od="[object Map]",Id="[object Number]",Cd="[object RegExp]",Rd="[object Set]",yd="[object String]",Ld="[object Symbol]",_d="[object ArrayBuffer]",vd="[object DataView]",Md="[object Float32Array]",bd="[object Float64Array]",kd="[object Int8Array]",Pd="[object Int16Array]",Ud="[object Int32Array]",wd="[object Uint8Array]",Dd="[object Uint8ClampedArray]",Fd="[object Uint16Array]",Bd="[object Uint32Array]";function Gd(e,t,r){var n=e.constructor;switch(t){case _d:return rr(e);case Ad:case Nd:return new n(+e);case vd:return xc(e,r);case Md:case bd:case kd:case Pd:case Ud:case wd:case Dd:case Fd:case Bd:return Oc(e,r);case Od:return new n;case Id:case yd:return new n(e);case Cd:return Tc(e);case Rd:return new n;case Ld:return Nc(e)}}var Ic=Gd;function $d(e){return typeof e.constructor=="function"&&!Kt(e)?ra(In(e)):{}}var Cc=$d;var jd="[object Map]";function Wd(e){return Y(e)&&Ut(e)==jd}var Rc=Wd;var yc=Mt&&Mt.isMap,Kd=yc?Ht(yc):Rc,Lc=Kd;var Hd="[object Set]";function qd(e){return Y(e)&&Ut(e)==Hd}var _c=qd;var vc=Mt&&Mt.isSet,zd=vc?Ht(vc):_c,Mc=zd;var Vd=1,Yd=2,Xd=4,bc="[object Arguments]",Qd="[object Array]",Zd="[object Boolean]",Jd="[object Date]",tg="[object Error]",kc="[object Function]",eg="[object GeneratorFunction]",rg="[object Map]",ng="[object Number]",Pc="[object Object]",ig="[object RegExp]",og="[object Set]",sg="[object String]",ag="[object Symbol]",cg="[object WeakMap]",lg="[object ArrayBuffer]",ug="[object DataView]",fg="[object Float32Array]",hg="[object Float64Array]",pg="[object Int8Array]",mg="[object Int16Array]",dg="[object Int32Array]",gg="[object Uint8Array]",Eg="[object Uint8ClampedArray]",xg="[object Uint16Array]",Tg="[object Uint32Array]",U={};U[bc]=U[Qd]=U[lg]=U[ug]=U[Zd]=U[Jd]=U[fg]=U[hg]=U[pg]=U[mg]=U[dg]=U[rg]=U[ng]=U[Pc]=U[ig]=U[og]=U[sg]=U[ag]=U[gg]=U[Eg]=U[xg]=U[Tg]=!0;U[tg]=U[kc]=U[cg]=!1;function bn(e,t,r,n,i,o){var s,a=t&Vd,c=t&Yd,l=t&Xd;if(r&&(s=i?r(e,n,i,o):r(e)),s!==void 0)return s;if(!W(e))return e;var u=O(e);if(u){if(s=Ec(e),!a)return ia(e,s)}else{var f=Ut(e),h=f==kc||f==eg;if(ee(e))return cc(e,a);if(f==Pc||f==bc||h&&!i){if(s=c||h?{}:Cc(e),!a)return c?fc(e,nc(s,e)):uc(e,rc(s,e))}else{if(!U[f])return i?e:{};s=Ic(e,f,a)}}o||(o=new Ae);var g=o.get(e);if(g)return g;o.set(e,s),Mc(e)?e.forEach(function(R){s.add(bn(R,t,r,R,e,o))}):Lc(e)&&e.forEach(function(R,N){s.set(N,bn(R,t,r,N,e,o))});var T=l?c?_n:Lr:c?de:P,I=u?void 0:T(e);return xn(I||e,function(R,N){I&&(N=R,R=e[N]),he(s,N,bn(R,t,r,N,e,o))}),s}var Uc=bn;var Sg=4;function Ag(e){return Uc(e,Sg)}var w=Ag;function Ng(e){for(var t=-1,r=e==null?0:e.length,n=0,i=[];++t<r;){var o=e[t];o&&(i[n++]=o)}return i}var zt=Ng;var Og="__lodash_hash_undefined__";function Ig(e){return this.__data__.set(e,Og),this}var wc=Ig;function Cg(e){return this.__data__.has(e)}var Dc=Cg;function kn(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Le;++t<r;)this.add(e[t])}kn.prototype.add=kn.prototype.push=wc;kn.prototype.has=Dc;var nr=kn;function Rg(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Pn=Rg;function yg(e,t){return e.has(t)}var ir=yg;var Lg=1,_g=2;function vg(e,t,r,n,i,o){var s=r&Lg,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=o.get(e),u=o.get(t);if(l&&u)return l==t&&u==e;var f=-1,h=!0,g=r&_g?new nr:void 0;for(o.set(e,t),o.set(t,e);++f<a;){var T=e[f],I=t[f];if(n)var R=s?n(I,T,f,t,e,o):n(T,I,f,e,t,o);if(R!==void 0){if(R)continue;h=!1;break}if(g){if(!Pn(t,function(N,x){if(!ir(g,x)&&(T===N||i(T,N,r,n,o)))return g.push(x)})){h=!1;break}}else if(!(T===I||i(T,I,r,n,o))){h=!1;break}}return o.delete(e),o.delete(t),h}var Un=vg;function Mg(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var Fc=Mg;function bg(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var or=bg;var kg=1,Pg=2,Ug="[object Boolean]",wg="[object Date]",Dg="[object Error]",Fg="[object Map]",Bg="[object Number]",Gg="[object RegExp]",$g="[object Set]",jg="[object String]",Wg="[object Symbol]",Kg="[object ArrayBuffer]",Hg="[object DataView]",Bc=at?at.prototype:void 0,$o=Bc?Bc.valueOf:void 0;function qg(e,t,r,n,i,o,s){switch(r){case Hg:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Kg:return!(e.byteLength!=t.byteLength||!o(new er(e),new er(t)));case Ug:case wg:case Bg:return jt(+e,+t);case Dg:return e.name==t.name&&e.message==t.message;case Gg:case jg:return e==t+"";case Fg:var a=Fc;case $g:var c=n&kg;if(a||(a=or),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=Pg,s.set(e,t);var u=Un(a(e),a(t),n,i,o,s);return s.delete(e),u;case Wg:if($o)return $o.call(e)==$o.call(t)}return!1}var Gc=qg;var zg=1,Vg=Object.prototype,Yg=Vg.hasOwnProperty;function Xg(e,t,r,n,i,o){var s=r&zg,a=Lr(e),c=a.length,l=Lr(t),u=l.length;if(c!=u&&!s)return!1;for(var f=c;f--;){var h=a[f];if(!(s?h in t:Yg.call(t,h)))return!1}var g=o.get(e),T=o.get(t);if(g&&T)return g==t&&T==e;var I=!0;o.set(e,t),o.set(t,e);for(var R=s;++f<c;){h=a[f];var N=e[h],x=t[h];if(n)var d=s?n(x,N,h,t,e,o):n(N,x,h,e,t,o);if(!(d===void 0?N===x||i(N,x,r,n,o):d)){I=!1;break}R||(R=h=="constructor")}if(I&&!R){var y=e.constructor,L=t.constructor;y!=L&&"constructor"in e&&"constructor"in t&&!(typeof y=="function"&&y instanceof y&&typeof L=="function"&&L instanceof L)&&(I=!1)}return o.delete(e),o.delete(t),I}var $c=Xg;var Qg=1,jc="[object Arguments]",Wc="[object Array]",wn="[object Object]",Zg=Object.prototype,Kc=Zg.hasOwnProperty;function Jg(e,t,r,n,i,o){var s=O(e),a=O(t),c=s?Wc:Ut(e),l=a?Wc:Ut(t);c=c==jc?wn:c,l=l==jc?wn:l;var u=c==wn,f=l==wn,h=c==l;if(h&&ee(e)){if(!ee(t))return!1;s=!0,u=!1}if(h&&!u)return o||(o=new Ae),s||Ke(e)?Un(e,t,r,n,i,o):Gc(e,t,c,r,n,i,o);if(!(r&Qg)){var g=u&&Kc.call(e,"__wrapped__"),T=f&&Kc.call(t,"__wrapped__");if(g||T){var I=g?e.value():e,R=T?t.value():t;return o||(o=new Ae),i(I,R,r,n,o)}}return h?(o||(o=new Ae),$c(e,t,r,n,i,o)):!1}var Hc=Jg;function qc(e,t,r,n,i){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:Hc(e,t,r,n,qc,i)}var Dn=qc;var tE=1,eE=2;function rE(e,t,r,n){var i=r.length,o=i,s=!n;if(e==null)return!o;for(e=Object(e);i--;){var a=r[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){a=r[i];var c=a[0],l=e[c],u=a[1];if(s&&a[2]){if(l===void 0&&!(c in e))return!1}else{var f=new Ae;if(n)var h=n(l,u,c,e,t,f);if(!(h===void 0?Dn(u,l,tE|eE,n,f):h))return!1}}return!0}var zc=rE;function nE(e){return e===e&&!W(e)}var Fn=nE;function iE(e){for(var t=P(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Fn(i)]}return t}var Vc=iE;function oE(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Bn=oE;function sE(e){var t=Vc(e);return t.length==1&&t[0][2]?Bn(t[0][0],t[0][1]):function(r){return r===e||zc(r,e,t)}}var Yc=sE;function aE(e,t){return e!=null&&t in Object(e)}var Xc=aE;function cE(e,t,r){t=Se(t,e);for(var n=-1,i=t.length,o=!1;++n<i;){var s=qt(t[n]);if(!(o=e!=null&&r(e,s)))break;e=e[s]}return o||++n!=i?o:(i=e==null?0:e.length,!!i&&We(i)&&fe(s,i)&&(O(e)||me(e)))}var Gn=cE;function lE(e,t){return e!=null&&Gn(e,t,Xc)}var Qc=lE;var uE=1,fE=2;function hE(e,t){return He(e)&&Fn(t)?Bn(qt(e),t):function(r){var n=qa(r,e);return n===void 0&&n===t?Qc(r,e):Dn(t,n,uE|fE)}}var Zc=hE;function pE(e){return function(t){return t?.[e]}}var Jc=pE;function mE(e){return function(t){return Ye(t,e)}}var tl=mE;function dE(e){return He(e)?Jc(qt(e)):tl(e)}var el=dE;function gE(e){return typeof e=="function"?e:e==null?vt:typeof e=="object"?O(e)?Zc(e[0],e[1]):Yc(e):el(e)}var et=gE;function EE(e,t,r,n){for(var i=-1,o=e==null?0:e.length;++i<o;){var s=e[i];t(n,s,r(s),e)}return n}var rl=EE;function xE(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var c=s[e?a:++i];if(r(o[c],c,o)===!1)break}return t}}var nl=xE;var TE=nl(),il=TE;function SE(e,t){return e&&il(e,t,P)}var ol=SE;function AE(e,t){return function(r,n){if(r==null)return r;if(!tt(r))return e(r,n);for(var i=r.length,o=t?i:-1,s=Object(r);(t?o--:++o<i)&&n(s[o],o,s)!==!1;);return r}}var sl=AE;var NE=sl(ol),Ot=NE;function OE(e,t,r,n){return Ot(e,function(i,o,s){t(n,i,r(i),s)}),n}var al=OE;function IE(e,t){return function(r,n){var i=O(r)?rl:al,o=t?t():{};return i(r,e,et(n,2),o)}}var cl=IE;var ll=Object.prototype,CE=ll.hasOwnProperty,RE=je(function(e,t){e=Object(e);var r=-1,n=t.length,i=n>2?t[2]:void 0;for(i&&pe(t[0],t[1],i)&&(n=1);++r<n;)for(var o=t[r],s=de(o),a=-1,c=s.length;++a<c;){var l=s[a],u=e[l];(u===void 0||jt(u,ll[l])&&!CE.call(e,l))&&(e[l]=o[l])}return e}),sr=RE;function yE(e){return Y(e)&&tt(e)}var jo=yE;function LE(e,t,r){for(var n=-1,i=e==null?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}var $n=LE;var _E=200;function vE(e,t,r,n){var i=-1,o=Sn,s=!0,a=e.length,c=[],l=t.length;if(!a)return c;r&&(t=Gt(t,Ht(r))),n?(o=$n,s=!1):t.length>=_E&&(o=ir,s=!1,t=new nr(t));t:for(;++i<a;){var u=e[i],f=r==null?u:r(u);if(u=n||u!==0?u:0,s&&f===f){for(var h=l;h--;)if(t[h]===f)continue t;c.push(u)}else o(t,f,n)||c.push(u)}return c}var ul=vE;var ME=je(function(e,t){return jo(e)?ul(e,Qe(t,1,jo,!0)):[]}),Oe=ME;function bE(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Vt=bE;function kE(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),Cn(e,t<0?0:t,n)):[]}var X=kE;function PE(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),t=n-t,Cn(e,0,t<0?0:t)):[]}var ne=PE;function UE(e){return typeof e=="function"?e:vt}var fl=UE;function wE(e,t){var r=O(e)?xn:Ot;return r(e,fl(t))}var S=wE;function DE(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}var hl=DE;function FE(e,t){var r=!0;return Ot(e,function(n,i,o){return r=!!t(n,i,o),r}),r}var pl=FE;function BE(e,t,r){var n=O(e)?hl:pl;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var ft=BE;function GE(e,t){var r=[];return Ot(e,function(n,i,o){t(n,i,o)&&r.push(n)}),r}var jn=GE;function $E(e,t){var r=O(e)?Je:jn;return r(e,et(t,3))}var ht=$E;function jE(e){return function(t,r,n){var i=Object(t);if(!tt(t)){var o=et(r,3);t=P(t),r=function(a){return o(i[a],a,i)}}var s=e(t,r,n);return s>-1?i[o?t[s]:s]:void 0}}var ml=jE;var WE=Math.max;function KE(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:$t(r);return i<0&&(i=WE(n+i,0)),Tn(e,et(t,3),i)}var dl=KE;var HE=ml(dl),Yt=HE;function qE(e){return e&&e.length?e[0]:void 0}var ct=qE;function zE(e,t){var r=-1,n=tt(e)?Array(e.length):[];return Ot(e,function(i,o,s){n[++r]=t(i,o,s)}),n}var gl=zE;function VE(e,t){var r=O(e)?Gt:gl;return r(e,et(t,3))}var E=VE;function YE(e,t){return Qe(E(e,t),1)}var gt=YE;var XE=Object.prototype,QE=XE.hasOwnProperty,ZE=cl(function(e,t,r){QE.call(e,r)?e[r].push(t):$e(e,r,[t])}),Wo=ZE;var JE=Object.prototype,tx=JE.hasOwnProperty;function ex(e,t){return e!=null&&tx.call(e,t)}var El=ex;function rx(e,t){return e!=null&&Gn(e,t,El)}var A=rx;var nx="[object String]";function ix(e){return typeof e=="string"||!O(e)&&Y(e)&&mt(e)==nx}var ot=ix;function ox(e,t){return Gt(t,function(r){return e[r]})}var xl=ox;function sx(e){return e==null?[]:xl(e,P(e))}var k=sx;var ax=Math.max;function cx(e,t,r,n){e=tt(e)?e:k(e),r=r&&!n?$t(r):0;var i=e.length;return r<0&&(r=ax(i+r,0)),ot(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Ge(e,t,r)>-1}var $=cx;var lx=Math.max;function ux(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:$t(r);return i<0&&(i=lx(n+i,0)),Ge(e,t,i)}var Wn=ux;var fx="[object Map]",hx="[object Set]",px=Object.prototype,mx=px.hasOwnProperty;function dx(e){if(e==null)return!0;if(tt(e)&&(O(e)||typeof e=="string"||typeof e.splice=="function"||ee(e)||Ke(e)||me(e)))return!e.length;var t=Ut(e);if(t==fx||t==hx)return!e.size;if(Kt(e))return!On(e).length;for(var r in e)if(mx.call(e,r))return!1;return!0}var _=dx;var gx="[object RegExp]";function Ex(e){return Y(e)&&mt(e)==gx}var Tl=Ex;var Sl=Mt&&Mt.isRegExp,xx=Sl?Ht(Sl):Tl,bt=xx;function Tx(e){return e===void 0}var pt=Tx;var Sx="Expected a function";function Ax(e){if(typeof e!="function")throw new TypeError(Sx);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var Al=Ax;function Nx(e,t,r,n){if(!W(e))return e;t=Se(t,e);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var c=qt(t[i]),l=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(i!=s){var u=a[c];l=n?n(u,c,a):void 0,l===void 0&&(l=W(u)?u:fe(t[i+1])?[]:{})}he(a,c,l),a=a[c]}return e}var Nl=Nx;function Ox(e,t,r){for(var n=-1,i=t.length,o={};++n<i;){var s=t[n],a=Ye(e,s);r(a,s)&&Nl(o,Se(s,e),a)}return o}var Ol=Ox;function Ix(e,t){if(e==null)return{};var r=Gt(_n(e),function(n){return[n]});return t=et(t),Ol(e,r,function(n,i){return t(n,i[0])})}var It=Ix;function Cx(e,t,r,n,i){return i(e,function(o,s,a){r=n?(n=!1,o):t(r,o,s,a)}),r}var Il=Cx;function Rx(e,t,r){var n=O(e)?Xa:Il,i=arguments.length<3;return n(e,et(t,4),r,i,Ot)}var rt=Rx;function yx(e,t){var r=O(e)?Je:jn;return r(e,Al(et(t,3)))}var Ie=yx;function Lx(e,t){var r;return Ot(e,function(n,i,o){return r=t(n,i,o),!r}),!!r}var Cl=Lx;function _x(e,t,r){var n=O(e)?Pn:Cl;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var _r=_x;var vx=1/0,Mx=Ne&&1/or(new Ne([,-0]))[1]==vx?function(e){return new Ne(e)}:K,Rl=Mx;var bx=200;function kx(e,t,r){var n=-1,i=Sn,o=e.length,s=!0,a=[],c=a;if(r)s=!1,i=$n;else if(o>=bx){var l=t?null:Rl(e);if(l)return or(l);s=!1,i=ir,c=new nr}else c=t?[]:a;t:for(;++n<o;){var u=e[n],f=t?t(u):u;if(u=r||u!==0?u:0,s&&f===f){for(var h=c.length;h--;)if(c[h]===f)continue t;t&&c.push(f),a.push(u)}else i(c,f,r)||(c!==a&&c.push(f),a.push(u))}return a}var yl=kx;function Px(e){return e&&e.length?yl(e):[]}var ar=Px;function cr(e){console&&console.error&&console.error(`Error: ${e}`)}function vr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function Mr(e){let t=new Date().getTime(),r=e();return{time:new Date().getTime()-t,value:r}}function br(e){function t(){}t.prototype=e;let r=new t;function n(){return typeof r.bar}return n(),n(),e;(0,eval)(e)}function Ux(e){return wx(e)?e.LABEL:e.name}function wx(e){return ot(e.LABEL)&&e.LABEL!==""}var Lt=class{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),S(this.definition,r=>{r.accept(t)})}},D=class extends Lt{constructor(t){super([]),this.idx=1,lt(this,It(t,r=>r!==void 0))}set definition(t){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(t){t.visit(this)}},Et=class extends Lt{constructor(t){super(t.definition),this.orgText="",lt(this,It(t,r=>r!==void 0))}},F=class extends Lt{constructor(t){super(t.definition),this.ignoreAmbiguities=!1,lt(this,It(t,r=>r!==void 0))}},G=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,It(t,r=>r!==void 0))}},Q=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,It(t,r=>r!==void 0))}},Z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,It(t,r=>r!==void 0))}},b=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,It(t,r=>r!==void 0))}},z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,It(t,r=>r!==void 0))}},V=class extends Lt{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,lt(this,It(t,r=>r!==void 0))}},v=class{constructor(t){this.idx=1,lt(this,It(t,r=>r!==void 0))}accept(t){t.visit(this)}};function Kn(e){return E(e,lr)}function lr(e){function t(r){return E(r,lr)}if(e instanceof D){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return ot(e.label)&&(r.label=e.label),r}else{if(e instanceof F)return{type:"Alternative",definition:t(e.definition)};if(e instanceof G)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof Q)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof Z)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof z)return{type:"RepetitionWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof b)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof V)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof v){let r={type:"Terminal",name:e.terminalType.name,label:Ux(e.terminalType),idx:e.idx};ot(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=bt(n)?n.source:n),r}else{if(e instanceof Et)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var xt=class{visit(t){let r=t;switch(r.constructor){case D:return this.visitNonTerminal(r);case F:return this.visitAlternative(r);case G:return this.visitOption(r);case Q:return this.visitRepetitionMandatory(r);case Z:return this.visitRepetitionMandatoryWithSeparator(r);case z:return this.visitRepetitionWithSeparator(r);case b:return this.visitRepetition(r);case V:return this.visitAlternation(r);case v:return this.visitTerminal(r);case Et:return this.visitRule(r);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}};function Ko(e){return e instanceof F||e instanceof G||e instanceof b||e instanceof Q||e instanceof Z||e instanceof z||e instanceof v||e instanceof Et}function ve(e,t=[]){return e instanceof G||e instanceof b||e instanceof z?!0:e instanceof V?_r(e.definition,n=>ve(n,t)):e instanceof D&&$(t,e)?!1:e instanceof Lt?(e instanceof D&&t.push(e),ft(e.definition,n=>ve(n,t))):!1}function Ho(e){return e instanceof V}function Ct(e){if(e instanceof D)return"SUBRULE";if(e instanceof G)return"OPTION";if(e instanceof V)return"OR";if(e instanceof Q)return"AT_LEAST_ONE";if(e instanceof Z)return"AT_LEAST_ONE_SEP";if(e instanceof z)return"MANY_SEP";if(e instanceof b)return"MANY";if(e instanceof v)return"CONSUME";throw Error("non exhaustive match")}var ie=class{walk(t,r=[]){S(t.definition,(n,i)=>{let o=X(t.definition,i+1);if(n instanceof D)this.walkProdRef(n,o,r);else if(n instanceof v)this.walkTerminal(n,o,r);else if(n instanceof F)this.walkFlat(n,o,r);else if(n instanceof G)this.walkOption(n,o,r);else if(n instanceof Q)this.walkAtLeastOne(n,o,r);else if(n instanceof Z)this.walkAtLeastOneSep(n,o,r);else if(n instanceof z)this.walkManySep(n,o,r);else if(n instanceof b)this.walkMany(n,o,r);else if(n instanceof V)this.walkOr(n,o,r);else throw Error("non exhaustive match")})}walkTerminal(t,r,n){}walkProdRef(t,r,n){}walkFlat(t,r,n){let i=r.concat(n);this.walk(t,i)}walkOption(t,r,n){let i=r.concat(n);this.walk(t,i)}walkAtLeastOne(t,r,n){let i=[new G({definition:t.definition})].concat(r,n);this.walk(t,i)}walkAtLeastOneSep(t,r,n){let i=Ll(t,r,n);this.walk(t,i)}walkMany(t,r,n){let i=[new G({definition:t.definition})].concat(r,n);this.walk(t,i)}walkManySep(t,r,n){let i=Ll(t,r,n);this.walk(t,i)}walkOr(t,r,n){let i=r.concat(n);S(t.definition,o=>{let s=new F({definition:[o]});this.walk(s,i)})}};function Ll(e,t,r){return[new G({definition:[new v({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Me(e){if(e instanceof D)return Me(e.referencedRule);if(e instanceof v)return Bx(e);if(Ko(e))return Dx(e);if(Ho(e))return Fx(e);throw Error("non exhaustive match")}function Dx(e){let t=[],r=e.definition,n=0,i=r.length>n,o,s=!0;for(;i&&s;)o=r[n],s=ve(o),t=t.concat(Me(o)),n=n+1,i=r.length>n;return ar(t)}function Fx(e){let t=E(e.definition,r=>Me(r));return ar(it(t))}function Bx(e){return[e.terminalType]}var Hn="_~IN~_";var qo=class extends ie{constructor(t){super(),this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,r,n){}walkProdRef(t,r,n){let i=Gx(t.referencedRule,t.idx)+this.topProd.name,o=r.concat(n),s=new F({definition:o}),a=Me(s);this.follows[i]=a}};function _l(e){let t={};return S(e,r=>{let n=new qo(r).startWalking();lt(t,n)}),t}function Gx(e,t){return e.name+t+Hn}function C(e){return e.charCodeAt(0)}function qn(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function ur(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function be(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function kr(){throw Error("Internal Error - Should never get here!")}function zo(e){return e.type==="Character"}var Pr=[];for(let e=C("0");e<=C("9");e++)Pr.push(e);var Ur=[C("_")].concat(Pr);for(let e=C("a");e<=C("z");e++)Ur.push(e);for(let e=C("A");e<=C("Z");e++)Ur.push(e);var Vo=[C(" "),C("\f"),C(`
3
+ `),C("\r"),C(" "),C("\v"),C(" "),C("\xA0"),C("\u1680"),C("\u2000"),C("\u2001"),C("\u2002"),C("\u2003"),C("\u2004"),C("\u2005"),C("\u2006"),C("\u2007"),C("\u2008"),C("\u2009"),C("\u200A"),C("\u2028"),C("\u2029"),C("\u202F"),C("\u205F"),C("\u3000"),C("\uFEFF")];var $x=/[0-9a-fA-F]/,zn=/[0-9]/,jx=/[1-9]/,wr=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");let r=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":ur(n,"global");break;case"i":ur(n,"ignoreCase");break;case"m":ur(n,"multiLine");break;case"u":ur(n,"unicode");break;case"y":ur(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:r,loc:this.loc(0)}}disjunction(){let t=[],r=this.idx;for(t.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(r)}}alternative(){let t=[],r=this.idx;for(;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(r)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let r;switch(this.popChar()){case"=":r="Lookahead";break;case"!":r="NegativeLookahead";break}be(r);let n=this.disjunction();return this.consumeChar(")"),{type:r,value:n,loc:this.loc(t)}}return kr()}quantifier(t=!1){let r,n=this.idx;switch(this.popChar()){case"*":r={atLeast:0,atMost:1/0};break;case"+":r={atLeast:1,atMost:1/0};break;case"?":r={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":r={atLeast:i,atMost:i};break;case",":let o;this.isDigit()?(o=this.integerIncludingZero(),r={atLeast:i,atMost:o}):r={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(t===!0&&r===void 0)return;be(r);break}if(!(t===!0&&r===void 0)&&be(r))return this.peekChar(0)==="?"?(this.consumeChar("?"),r.greedy=!1):r.greedy=!0,r.type="Quantifier",r.loc=this.loc(n),r}atom(){let t,r=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group();break}return t===void 0&&this.isPatternCharacter()&&(t=this.patternCharacter()),be(t)?(t.loc=this.loc(r),this.isQuantifier()&&(t.quantifier=this.quantifier()),t):kr()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
4
+ `),C("\r"),C("\u2028"),C("\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 t,r=!1;switch(this.popChar()){case"d":t=Pr;break;case"D":t=Pr,r=!0;break;case"s":t=Vo;break;case"S":t=Vo,r=!0;break;case"w":t=Ur;break;case"W":t=Ur,r=!0;break}return be(t)?{type:"Set",value:t,complement:r}:kr()}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=C("\f");break;case"n":t=C(`
5
5
  `);break;case"r":t=C("\r");break;case"t":t=C(" ");break;case"v":t=C("\v");break}return be(t)?{type:"Character",value:t}:kr()}controlLetterEscapeAtom(){this.consumeChar("c");let t=this.popChar();if(/[a-zA-Z]/.test(t)===!1)throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:C("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let t=this.popChar();return{type:"Character",value:C(t)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
6
- `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let t=this.popChar();return{type:"Character",value:C(t)}}}characterClass(){let t=[],r=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),r=!0);this.isClassAtom();){let n=this.classAtom(),o=n.type==="Character";if(qi(n)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),s=i.type==="Character";if(qi(i)){if(i.value<n.value)throw Error("Range out of order in character class");t.push({from:n.value,to:i.value})}else qn(n.value,t),t.push(C("-")),qn(i.value,t)}else qn(n.value,t)}return this.consumeChar("]"),{type:"Set",complement:r,value:t}}classAtom(){switch(this.peekChar()){case"]":case`
7
- `: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:C("\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 t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++;break}let r=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:t,value:r};return t&&(n.idx=this.groupIdx),n}positiveInteger(){let t=this.popChar();if(Bx.test(t)===!1)throw Error("Expecting a positive integer");for(;zn.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(zn.test(t)===!1)throw Error("Expecting an integer");for(;zn.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}patternCharacter(){let t=this.popChar();switch(t){case`
6
+ `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let t=this.popChar();return{type:"Character",value:C(t)}}}characterClass(){let t=[],r=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),r=!0);this.isClassAtom();){let n=this.classAtom(),i=n.type==="Character";if(zo(n)&&this.isRangeDash()){this.consumeChar("-");let o=this.classAtom(),s=o.type==="Character";if(zo(o)){if(o.value<n.value)throw Error("Range out of order in character class");t.push({from:n.value,to:o.value})}else qn(n.value,t),t.push(C("-")),qn(o.value,t)}else qn(n.value,t)}return this.consumeChar("]"),{type:"Set",complement:r,value:t}}classAtom(){switch(this.peekChar()){case"]":case`
7
+ `: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:C("\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 t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++;break}let r=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:t,value:r};return t&&(n.idx=this.groupIdx),n}positiveInteger(){let t=this.popChar();if(jx.test(t)===!1)throw Error("Expecting a positive integer");for(;zn.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(zn.test(t)===!1)throw Error("Expecting an integer");for(;zn.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}patternCharacter(){let t=this.popChar();switch(t){case`
8
8
  `: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:C(t)}}}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 zn.test(this.peekChar(0))}isClassAtom(t=0){switch(this.peekChar(t)){case"]":case`
9
9
  `: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)==="!");default:return!1}}isQuantifier(){let t=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(t)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
10
- `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(t){let r="";for(let o=0;o<t;o++){let i=this.popChar();if(Fx.test(i)===!1)throw Error("Expecting a HexDecimal digits");r+=i}return{type:"Character",value:parseInt(r,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){let t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(t!==void 0&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}};var Ce=class{visitChildren(t){for(let r in t){let n=t[r];t.hasOwnProperty(r)&&(n.type!==void 0?this.visit(n):Array.isArray(n)&&n.forEach(o=>{this.visit(o)},this))}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t);break}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}};var Vn={},Gx=new wr;function fr(e){let t=e.toString();if(Vn.hasOwnProperty(t))return Vn[t];{let r=Gx.pattern(t);return Vn[t]=r,r}}function _l(){Vn={}}var Ml="Complement Sets are not supported for first char optimization",Dr=`Unable to use "first char" lexer optimizations:
11
- `;function bl(e,t=!1){try{let r=fr(e);return Vi(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===Ml)t&&vr(`${Dr} Unable to optimize: < ${e.toString()} >
10
+ `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(t){let r="";for(let i=0;i<t;i++){let o=this.popChar();if($x.test(o)===!1)throw Error("Expecting a HexDecimal digits");r+=o}return{type:"Character",value:parseInt(r,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){let t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(t!==void 0&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}};var Ce=class{visitChildren(t){for(let r in t){let n=t[r];t.hasOwnProperty(r)&&(n.type!==void 0?this.visit(n):Array.isArray(n)&&n.forEach(i=>{this.visit(i)},this))}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t);break}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}};var Vn={},Wx=new wr;function fr(e){let t=e.toString();if(Vn.hasOwnProperty(t))return Vn[t];{let r=Wx.pattern(t);return Vn[t]=r,r}}function vl(){Vn={}}var bl="Complement Sets are not supported for first char optimization",Dr=`Unable to use "first char" lexer optimizations:
11
+ `;function kl(e,t=!1){try{let r=fr(e);return Yo(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===bl)t&&vr(`${Dr} Unable to optimize: < ${e.toString()} >
12
12
  Complement Sets cannot be automatically optimized.
13
13
  This will disable the lexer's first char optimizations.
14
14
  See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=`
@@ -16,49 +16,49 @@ import{readFileSync as Vu,writeFileSync as QT,existsSync as ZT}from"node:fs";imp
16
16
  See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),cr(`${Dr}
17
17
  Failed parsing: < ${e.toString()} >
18
18
  Using the @chevrotain/regexp-to-ast library
19
- Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Vi(e,t,r){switch(e.type){case"Disjunction":for(let o=0;o<e.value.length;o++)Vi(e.value[o],t,r);break;case"Alternative":let n=e.value;for(let o=0;o<n.length;o++){let i=n[o];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let s=i;switch(s.type){case"Character":Yn(s.value,t,r);break;case"Set":if(s.complement===!0)throw Error(Ml);S(s.value,c=>{if(typeof c=="number")Yn(c,t,r);else{let l=c;if(r===!0)for(let u=l.from;u<=l.to;u++)Yn(u,t,r);else{for(let u=l.from;u<=l.to&&u<hr;u++)Yn(u,t,r);if(l.to>=hr){let u=l.from>=hr?l.from:hr,f=l.to,h=Xt(u),x=Xt(f);for(let T=h;T<=x;T++)t[T]=T}}}});break;case"Group":Vi(s.value,t,r);break;default:throw Error("Non Exhaustive Match")}let a=s.quantifier!==void 0&&s.quantifier.atLeast===0;if(s.type==="Group"&&Yi(s)===!1||s.type!=="Group"&&a===!1)break}break;default:throw Error("non exhaustive match!")}return k(t)}function Yn(e,t,r){let n=Xt(e);t[n]=n,r===!0&&$x(e,t)}function $x(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let o=Xt(n.charCodeAt(0));t[o]=o}else{let o=r.toLowerCase();if(o!==r){let i=Xt(o.charCodeAt(0));t[i]=i}}}function vl(e,t){return Yt(e.value,r=>{if(typeof r=="number")return $(t,r);{let n=r;return Yt(t,o=>n.from<=o&&o<=n.to)!==void 0}})}function Yi(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?I(e.value)?ft(e.value,Yi):Yi(e.value):!1}var Xi=class extends Ce{constructor(t){super(),this.targetCharCodes=t,this.found=!1}visitChildren(t){if(this.found!==!0){switch(t.type){case"Lookahead":this.visitLookahead(t);return;case"NegativeLookahead":this.visitNegativeLookahead(t);return}super.visitChildren(t)}}visitCharacter(t){$(this.targetCharCodes,t.value)&&(this.found=!0)}visitSet(t){t.complement?vl(t,this.targetCharCodes)===void 0&&(this.found=!0):vl(t,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Xn(e,t){if(t instanceof RegExp){let r=fr(t),n=new Xi(e);return n.visit(r),n.found}else return Yt(t,r=>$(e,r.charCodeAt(0)))!==void 0}var ke="PATTERN",pr="defaultMode",Qn="modes",Zi=typeof new RegExp("(?:)").sticky=="boolean";function Ul(e,t){t=sr(t,{useSticky:Zi,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
20
- `],tracer:(E,d)=>d()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{iT()});let n;r("Reject Lexer.NA",()=>{n=Oe(e,E=>E[ke]===H.NA)});let o=!1,i;r("Transform Patterns",()=>{o=!1,i=g(n,E=>{let d=E[ke];if(bt(d)){let y=d.source;return y.length===1&&y!=="^"&&y!=="$"&&y!=="."&&!d.ignoreCase?y:y.length===2&&y[0]==="\\"&&!$(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],y[1])?y[1]:t.useSticky?Pl(d):kl(d)}else{if(dt(d))return o=!0,{exec:d};if(typeof d=="object")return o=!0,d;if(typeof d=="string"){if(d.length===1)return d;{let y=d.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),L=new RegExp(y);return t.useSticky?Pl(L):kl(L)}}else throw Error("non exhaustive match")}})});let s,a,c,l,u;r("misc mapping",()=>{s=g(n,E=>E.tokenTypeIdx),a=g(n,E=>{let d=E.GROUP;if(d!==H.SKIPPED){if(it(d))return d;if(pt(d))return!1;throw Error("non exhaustive match")}}),c=g(n,E=>{let d=E.LONGER_ALT;if(d)return I(d)?g(d,L=>Wn(n,L)):[Wn(n,d)]}),l=g(n,E=>E.PUSH_MODE),u=g(n,E=>A(E,"POP_MODE"))});let f;r("Line Terminator Handling",()=>{let E=Wl(t.lineTerminatorCharacters);f=g(n,d=>!1),t.positionTracking!=="onlyOffset"&&(f=g(n,d=>A(d,"LINE_BREAKS")?!!d.LINE_BREAKS:jl(d,E)===!1&&Xn(E,d.PATTERN)))});let h,x,T,O;r("Misc Mapping #2",()=>{h=g(n,Gl),x=g(i,nT),T=rt(n,(E,d)=>{let y=d.GROUP;return it(y)&&y!==H.SKIPPED&&(E[y]=[]),E},{}),O=g(i,(E,d)=>({pattern:i[d],longerAlt:c[d],canLineTerminator:f[d],isCustom:h[d],short:x[d],group:a[d],push:l[d],pop:u[d],tokenTypeIdx:s[d],tokenType:n[d]}))});let R=!0,N=[];return t.safeMode||r("First Char Optimization",()=>{N=rt(n,(E,d,y)=>{if(typeof d.PATTERN=="string"){let L=d.PATTERN.charCodeAt(0),Rt=Xt(L);Qi(E,Rt,O[y])}else if(I(d.START_CHARS_HINT)){let L;S(d.START_CHARS_HINT,Rt=>{let bi=typeof Rt=="string"?Rt.charCodeAt(0):Rt,Bt=Xt(bi);L!==Bt&&(L=Bt,Qi(E,Bt,O[y]))})}else if(bt(d.PATTERN))if(d.PATTERN.unicode)R=!1,t.ensureOptimizations&&cr(`${Dr} Unable to analyze < ${d.PATTERN.toString()} > pattern.
19
+ Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Yo(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)Yo(e.value[i],t,r);break;case"Alternative":let n=e.value;for(let i=0;i<n.length;i++){let o=n[i];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let s=o;switch(s.type){case"Character":Yn(s.value,t,r);break;case"Set":if(s.complement===!0)throw Error(bl);S(s.value,c=>{if(typeof c=="number")Yn(c,t,r);else{let l=c;if(r===!0)for(let u=l.from;u<=l.to;u++)Yn(u,t,r);else{for(let u=l.from;u<=l.to&&u<hr;u++)Yn(u,t,r);if(l.to>=hr){let u=l.from>=hr?l.from:hr,f=l.to,h=Xt(u),g=Xt(f);for(let T=h;T<=g;T++)t[T]=T}}}});break;case"Group":Yo(s.value,t,r);break;default:throw Error("Non Exhaustive Match")}let a=s.quantifier!==void 0&&s.quantifier.atLeast===0;if(s.type==="Group"&&Xo(s)===!1||s.type!=="Group"&&a===!1)break}break;default:throw Error("non exhaustive match!")}return k(t)}function Yn(e,t,r){let n=Xt(e);t[n]=n,r===!0&&Kx(e,t)}function Kx(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=Xt(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let o=Xt(i.charCodeAt(0));t[o]=o}}}function Ml(e,t){return Yt(e.value,r=>{if(typeof r=="number")return $(t,r);{let n=r;return Yt(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function Xo(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?O(e.value)?ft(e.value,Xo):Xo(e.value):!1}var Qo=class extends Ce{constructor(t){super(),this.targetCharCodes=t,this.found=!1}visitChildren(t){if(this.found!==!0){switch(t.type){case"Lookahead":this.visitLookahead(t);return;case"NegativeLookahead":this.visitNegativeLookahead(t);return}super.visitChildren(t)}}visitCharacter(t){$(this.targetCharCodes,t.value)&&(this.found=!0)}visitSet(t){t.complement?Ml(t,this.targetCharCodes)===void 0&&(this.found=!0):Ml(t,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Xn(e,t){if(t instanceof RegExp){let r=fr(t),n=new Qo(e);return n.visit(r),n.found}else return Yt(t,r=>$(e,r.charCodeAt(0)))!==void 0}var ke="PATTERN",pr="defaultMode",Qn="modes",Jo=typeof new RegExp("(?:)").sticky=="boolean";function wl(e,t){t=sr(t,{useSticky:Jo,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
20
+ `],tracer:(x,d)=>d()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{cT()});let n;r("Reject Lexer.NA",()=>{n=Ie(e,x=>x[ke]===H.NA)});let i=!1,o;r("Transform Patterns",()=>{i=!1,o=E(n,x=>{let d=x[ke];if(bt(d)){let y=d.source;return y.length===1&&y!=="^"&&y!=="$"&&y!=="."&&!d.ignoreCase?y:y.length===2&&y[0]==="\\"&&!$(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],y[1])?y[1]:t.useSticky?Ul(d):Pl(d)}else{if(dt(d))return i=!0,{exec:d};if(typeof d=="object")return i=!0,d;if(typeof d=="string"){if(d.length===1)return d;{let y=d.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),L=new RegExp(y);return t.useSticky?Ul(L):Pl(L)}}else throw Error("non exhaustive match")}})});let s,a,c,l,u;r("misc mapping",()=>{s=E(n,x=>x.tokenTypeIdx),a=E(n,x=>{let d=x.GROUP;if(d!==H.SKIPPED){if(ot(d))return d;if(pt(d))return!1;throw Error("non exhaustive match")}}),c=E(n,x=>{let d=x.LONGER_ALT;if(d)return O(d)?E(d,L=>Wn(n,L)):[Wn(n,d)]}),l=E(n,x=>x.PUSH_MODE),u=E(n,x=>A(x,"POP_MODE"))});let f;r("Line Terminator Handling",()=>{let x=Kl(t.lineTerminatorCharacters);f=E(n,d=>!1),t.positionTracking!=="onlyOffset"&&(f=E(n,d=>A(d,"LINE_BREAKS")?!!d.LINE_BREAKS:Wl(d,x)===!1&&Xn(x,d.PATTERN)))});let h,g,T,I;r("Misc Mapping #2",()=>{h=E(n,$l),g=E(o,sT),T=rt(n,(x,d)=>{let y=d.GROUP;return ot(y)&&y!==H.SKIPPED&&(x[y]=[]),x},{}),I=E(o,(x,d)=>({pattern:o[d],longerAlt:c[d],canLineTerminator:f[d],isCustom:h[d],short:g[d],group:a[d],push:l[d],pop:u[d],tokenTypeIdx:s[d],tokenType:n[d]}))});let R=!0,N=[];return t.safeMode||r("First Char Optimization",()=>{N=rt(n,(x,d,y)=>{if(typeof d.PATTERN=="string"){let L=d.PATTERN.charCodeAt(0),Rt=Xt(L);Zo(x,Rt,I[y])}else if(O(d.START_CHARS_HINT)){let L;S(d.START_CHARS_HINT,Rt=>{let ko=typeof Rt=="string"?Rt.charCodeAt(0):Rt,Bt=Xt(ko);L!==Bt&&(L=Bt,Zo(x,Bt,I[y]))})}else if(bt(d.PATTERN))if(d.PATTERN.unicode)R=!1,t.ensureOptimizations&&cr(`${Dr} Unable to analyze < ${d.PATTERN.toString()} > pattern.
21
21
  The regexp unicode flag is not currently supported by the regexp-to-ast library.
22
22
  This will disable the lexer's first char optimizations.
23
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let L=bl(d.PATTERN,t.ensureOptimizations);_(L)&&(R=!1),S(L,Rt=>{Qi(E,Rt,O[y])})}else t.ensureOptimizations&&cr(`${Dr} TokenType: <${d.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
23
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let L=kl(d.PATTERN,t.ensureOptimizations);_(L)&&(R=!1),S(L,Rt=>{Zo(x,Rt,I[y])})}else t.ensureOptimizations&&cr(`${Dr} TokenType: <${d.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
24
24
  This will disable the lexer's first char optimizations.
25
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),R=!1;return E},[])}),{emptyGroups:T,patternIdxToConfig:O,charCodeToPatternIdxToConfig:N,hasCustom:o,canBeOptimized:R}}function wl(e,t){let r=[],n=Wx(e);r=r.concat(n.errors);let o=Kx(n.valid),i=o.valid;return r=r.concat(o.errors),r=r.concat(jx(i)),r=r.concat(Zx(i)),r=r.concat(Jx(i,t)),r=r.concat(tT(i)),r}function jx(e){let t=[],r=ht(e,n=>bt(n[ke]));return t=t.concat(qx(r)),t=t.concat(Yx(r)),t=t.concat(Xx(r)),t=t.concat(Qx(r)),t=t.concat(zx(r)),t}function Wx(e){let t=ht(e,o=>!A(o,ke)),r=g(t,o=>({message:"Token Type: ->"+o.name+"<- missing static 'PATTERN' property",type:j.MISSING_PATTERN,tokenTypes:[o]})),n=Ie(e,t);return{errors:r,valid:n}}function Kx(e){let t=ht(e,o=>{let i=o[ke];return!bt(i)&&!dt(i)&&!A(i,"exec")&&!it(i)}),r=g(t,o=>({message:"Token Type: ->"+o.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:j.INVALID_PATTERN,tokenTypes:[o]})),n=Ie(e,t);return{errors:r,valid:n}}var Hx=/[^\\][$]/;function qx(e){class t extends Ce{constructor(){super(...arguments),this.found=!1}visitEndAnchor(i){this.found=!0}}let r=ht(e,o=>{let i=o.PATTERN;try{let s=fr(i),a=new t;return a.visit(s),a.found}catch{return Hx.test(i.source)}});return g(r,o=>({message:`Unexpected RegExp Anchor Error:
26
- Token Type: ->`+o.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
27
- See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[o]}))}function zx(e){let t=ht(e,n=>n.PATTERN.test(""));return g(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:j.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var Vx=/[^\\[][\^]|^\^/;function Yx(e){class t extends Ce{constructor(){super(...arguments),this.found=!1}visitStartAnchor(i){this.found=!0}}let r=ht(e,o=>{let i=o.PATTERN;try{let s=fr(i),a=new t;return a.visit(s),a.found}catch{return Vx.test(i.source)}});return g(r,o=>({message:`Unexpected RegExp Anchor Error:
28
- Token Type: ->`+o.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
29
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[o]}))}function Xx(e){let t=ht(e,n=>{let o=n[ke];return o instanceof RegExp&&(o.multiline||o.global)});return g(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:j.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function Qx(e){let t=[],r=g(e,i=>rt(e,(s,a)=>(i.PATTERN.source===a.PATTERN.source&&!$(t,a)&&a.PATTERN!==H.NA&&(t.push(a),s.push(a)),s),[]));r=zt(r);let n=ht(r,i=>i.length>1);return g(n,i=>{let s=g(i,c=>c.name);return{message:`The same RegExp pattern ->${ct(i).PATTERN}<-has been used in all of the following Token Types: ${s.join(", ")} <-`,type:j.DUPLICATE_PATTERNS_FOUND,tokenTypes:i}})}function Zx(e){let t=ht(e,n=>{if(!A(n,"GROUP"))return!1;let o=n.GROUP;return o!==H.SKIPPED&&o!==H.NA&&!it(o)});return g(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:j.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function Jx(e,t){let r=ht(e,o=>o.PUSH_MODE!==void 0&&!$(t,o.PUSH_MODE));return g(r,o=>({message:`Token Type: ->${o.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${o.PUSH_MODE}<-which does not exist`,type:j.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[o]}))}function tT(e){let t=[],r=rt(e,(n,o,i)=>{let s=o.PATTERN;return s===H.NA||(it(s)?n.push({str:s,idx:i,tokenType:o}):bt(s)&&rT(s)&&n.push({str:s.source,idx:i,tokenType:o})),n},[]);return S(e,(n,o)=>{S(r,({str:i,idx:s,tokenType:a})=>{if(o<s&&eT(i,n.PATTERN)){let c=`Token: ->${a.name}<- can never be matched.
25
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),R=!1;return x},[])}),{emptyGroups:T,patternIdxToConfig:I,charCodeToPatternIdxToConfig:N,hasCustom:i,canBeOptimized:R}}function Dl(e,t){let r=[],n=qx(e);r=r.concat(n.errors);let i=zx(n.valid),o=i.valid;return r=r.concat(i.errors),r=r.concat(Hx(o)),r=r.concat(eT(o)),r=r.concat(rT(o,t)),r=r.concat(nT(o)),r}function Hx(e){let t=[],r=ht(e,n=>bt(n[ke]));return t=t.concat(Yx(r)),t=t.concat(Zx(r)),t=t.concat(Jx(r)),t=t.concat(tT(r)),t=t.concat(Xx(r)),t}function qx(e){let t=ht(e,i=>!A(i,ke)),r=E(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:j.MISSING_PATTERN,tokenTypes:[i]})),n=Oe(e,t);return{errors:r,valid:n}}function zx(e){let t=ht(e,i=>{let o=i[ke];return!bt(o)&&!dt(o)&&!A(o,"exec")&&!ot(o)}),r=E(t,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:j.INVALID_PATTERN,tokenTypes:[i]})),n=Oe(e,t);return{errors:r,valid:n}}var Vx=/[^\\][$]/;function Yx(e){class t extends Ce{constructor(){super(...arguments),this.found=!1}visitEndAnchor(o){this.found=!0}}let r=ht(e,i=>{let o=i.PATTERN;try{let s=fr(o),a=new t;return a.visit(s),a.found}catch{return Vx.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
26
+ Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
27
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function Xx(e){let t=ht(e,n=>n.PATTERN.test(""));return E(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:j.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var Qx=/[^\\[][\^]|^\^/;function Zx(e){class t extends Ce{constructor(){super(...arguments),this.found=!1}visitStartAnchor(o){this.found=!0}}let r=ht(e,i=>{let o=i.PATTERN;try{let s=fr(o),a=new t;return a.visit(s),a.found}catch{return Qx.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
28
+ Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
29
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function Jx(e){let t=ht(e,n=>{let i=n[ke];return i instanceof RegExp&&(i.multiline||i.global)});return E(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:j.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function tT(e){let t=[],r=E(e,o=>rt(e,(s,a)=>(o.PATTERN.source===a.PATTERN.source&&!$(t,a)&&a.PATTERN!==H.NA&&(t.push(a),s.push(a)),s),[]));r=zt(r);let n=ht(r,o=>o.length>1);return E(n,o=>{let s=E(o,c=>c.name);return{message:`The same RegExp pattern ->${ct(o).PATTERN}<-has been used in all of the following Token Types: ${s.join(", ")} <-`,type:j.DUPLICATE_PATTERNS_FOUND,tokenTypes:o}})}function eT(e){let t=ht(e,n=>{if(!A(n,"GROUP"))return!1;let i=n.GROUP;return i!==H.SKIPPED&&i!==H.NA&&!ot(i)});return E(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:j.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function rT(e,t){let r=ht(e,i=>i.PUSH_MODE!==void 0&&!$(t,i.PUSH_MODE));return E(r,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:j.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function nT(e){let t=[],r=rt(e,(n,i,o)=>{let s=i.PATTERN;return s===H.NA||(ot(s)?n.push({str:s,idx:o,tokenType:i}):bt(s)&&oT(s)&&n.push({str:s.source,idx:o,tokenType:i})),n},[]);return S(e,(n,i)=>{S(r,({str:o,idx:s,tokenType:a})=>{if(i<s&&iT(o,n.PATTERN)){let c=`Token: ->${a.name}<- can never be matched.
30
30
  Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition.
31
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:c,type:j.UNREACHABLE_PATTERN,tokenTypes:[n,a]})}})}),t}function eT(e,t){if(bt(t)){let r=t.exec(e);return r!==null&&r.index===0}else{if(dt(t))return t(e,0,[],{});if(A(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function rT(e){return Yt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function kl(e){let t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function Pl(e){let t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function Dl(e,t,r){let n=[];return A(e,pr)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+pr+`> property in its definition
31
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:c,type:j.UNREACHABLE_PATTERN,tokenTypes:[n,a]})}})}),t}function iT(e,t){if(bt(t)){let r=t.exec(e);return r!==null&&r.index===0}else{if(dt(t))return t(e,0,[],{});if(A(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function oT(e){return Yt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function Pl(e){let t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function Ul(e){let t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function Fl(e,t,r){let n=[];return A(e,pr)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+pr+`> property in its definition
32
32
  `,type:j.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),A(e,Qn)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Qn+`> property in its definition
33
33
  `,type:j.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),A(e,Qn)&&A(e,pr)&&!A(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${pr}: <${e.defaultMode}>which does not exist
34
- `,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),A(e,Qn)&&S(e.modes,(o,i)=>{S(o,(s,a)=>{if(pt(s))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${i}> at index: <${a}>
35
- `,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(A(s,"LONGER_ALT")){let c=I(s.LONGER_ALT)?s.LONGER_ALT:[s.LONGER_ALT];S(c,l=>{!pt(l)&&!$(o,l)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${s.name}> outside of mode <${i}>
36
- `,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function Fl(e,t,r){let n=[],o=!1,i=zt(ot(k(e.modes))),s=Oe(i,c=>c[ke]===H.NA),a=Wl(r);return t&&S(s,c=>{let l=jl(c,a);if(l!==!1){let f={message:oT(c,l),type:l.issue,tokenType:c};n.push(f)}else A(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(o=!0):Xn(a,c.PATTERN)&&(o=!0)}),t&&!o&&n.push({message:`Warning: No LINE_BREAKS Found.
34
+ `,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),A(e,Qn)&&S(e.modes,(i,o)=>{S(i,(s,a)=>{if(pt(s))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${o}> at index: <${a}>
35
+ `,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(A(s,"LONGER_ALT")){let c=O(s.LONGER_ALT)?s.LONGER_ALT:[s.LONGER_ALT];S(c,l=>{!pt(l)&&!$(i,l)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${s.name}> outside of mode <${o}>
36
+ `,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function Bl(e,t,r){let n=[],i=!1,o=zt(it(k(e.modes))),s=Ie(o,c=>c[ke]===H.NA),a=Kl(r);return t&&S(s,c=>{let l=Wl(c,a);if(l!==!1){let f={message:aT(c,l),type:l.issue,tokenType:c};n.push(f)}else A(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(i=!0):Xn(a,c.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found.
37
37
  This Lexer has been defined to track line and column information,
38
38
  But none of the Token Types can be identified as matching a line terminator.
39
39
  See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
40
- for details.`,type:j.NO_LINE_BREAKS_FLAGS}),n}function Bl(e){let t={},r=P(e);return S(r,n=>{let o=e[n];if(I(o))t[n]=[];else throw Error("non exhaustive match")}),t}function Gl(e){let t=e.PATTERN;if(bt(t))return!1;if(dt(t))return!0;if(A(t,"exec"))return!0;if(it(t))return!1;throw Error("non exhaustive match")}function nT(e){return it(e)&&e.length===1?e.charCodeAt(0):!1}var $l={test:function(e){let t=e.length;for(let r=this.lastIndex;r<t;r++){let n=e.charCodeAt(r);if(n===10)return this.lastIndex=r+1,!0;if(n===13)return e.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},lastIndex:0};function jl(e,t){if(A(e,"LINE_BREAKS"))return!1;if(bt(e.PATTERN)){try{Xn(t,e.PATTERN)}catch(r){return{issue:j.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(it(e.PATTERN))return!1;if(Gl(e))return{issue:j.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function oT(e,t){if(t.issue===j.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
40
+ for details.`,type:j.NO_LINE_BREAKS_FLAGS}),n}function Gl(e){let t={},r=P(e);return S(r,n=>{let i=e[n];if(O(i))t[n]=[];else throw Error("non exhaustive match")}),t}function $l(e){let t=e.PATTERN;if(bt(t))return!1;if(dt(t))return!0;if(A(t,"exec"))return!0;if(ot(t))return!1;throw Error("non exhaustive match")}function sT(e){return ot(e)&&e.length===1?e.charCodeAt(0):!1}var jl={test:function(e){let t=e.length;for(let r=this.lastIndex;r<t;r++){let n=e.charCodeAt(r);if(n===10)return this.lastIndex=r+1,!0;if(n===13)return e.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},lastIndex:0};function Wl(e,t){if(A(e,"LINE_BREAKS"))return!1;if(bt(e.PATTERN)){try{Xn(t,e.PATTERN)}catch(r){return{issue:j.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(ot(e.PATTERN))return!1;if($l(e))return{issue:j.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function aT(e,t){if(t.issue===j.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
41
41
  The problem is in the <${e.name}> Token Type
42
42
  Root cause: ${t.errMsg}.
43
43
  For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===j.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
44
44
  The problem is in the <${e.name}> Token Type
45
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function Wl(e){return g(e,r=>it(r)?r.charCodeAt(0):r)}function Qi(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var hr=256,Zn=[];function Xt(e){return e<hr?e:Zn[e]}function iT(){if(_(Zn)){Zn=new Array(65536);for(let e=0;e<65536;e++)Zn[e]=e>255?255+~~(e/255):e}}function ie(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function mr(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var Kl=1,ql={};function se(e){let t=sT(e);aT(t),lT(t),cT(t),S(t,r=>{r.isParent=r.categoryMatches.length>0})}function sT(e){let t=w(e),r=e,n=!0;for(;n;){r=zt(ot(g(r,i=>i.CATEGORIES)));let o=Ie(r,t);t=t.concat(o),_(o)?n=!1:r=o}return t}function aT(e){S(e,t=>{Ji(t)||(ql[Kl]=t,t.tokenTypeIdx=Kl++),Hl(t)&&!I(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),Hl(t)||(t.CATEGORIES=[]),uT(t)||(t.categoryMatches=[]),fT(t)||(t.categoryMatchesMap={})})}function cT(e){S(e,t=>{t.categoryMatches=[],S(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(ql[n].tokenTypeIdx)})})}function lT(e){S(e,t=>{zl([],t)})}function zl(e,t){S(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),S(t.CATEGORIES,r=>{let n=e.concat(t);$(n,r)||zl(n,r)})}function Ji(e){return A(e,"tokenTypeIdx")}function Hl(e){return A(e,"CATEGORIES")}function uT(e){return A(e,"categoryMatches")}function fT(e){return A(e,"categoryMatchesMap")}function Vl(e){return A(e,"tokenTypeIdx")}var ts={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,o){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}};var j;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(j||(j={}));var Fr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
46
- `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ts,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Fr);var H=class{constructor(t,r=Fr){if(this.lexerDefinition=t,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=(o,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${o}>`);let{time:a,value:c}=Mr(i),l=a>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${s}<-- <${o}> time: ${a}ms`),this.traceInitIndent--,c}else return i()},typeof r=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
47
- a boolean 2nd argument is no longer supported`);this.config=lt({},Fr,r);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let o,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Fr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=$l;else if(this.config.lineTerminatorCharacters===Fr.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
48
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(r.safeMode&&r.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),I(t)?o={modes:{defaultMode:w(t)},defaultMode:pr}:(i=!1,o=w(t))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Dl(o,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Fl(o,this.trackStartLines,this.config.lineTerminatorCharacters))})),o.modes=o.modes?o.modes:{},S(o.modes,(a,c)=>{o.modes[c]=Oe(a,l=>pt(l))});let s=P(o.modes);if(S(o.modes,(a,c)=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(wl(a,s))}),_(this.lexerDefinitionErrors)){se(a);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=Ul(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:r.positionTracking,ensureOptimizations:r.ensureOptimizations,safeMode:r.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=l.charCodeToPatternIdxToConfig,this.emptyGroups=lt({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=l.canBeOptimized}})}),this.defaultMode=o.defaultMode,!_(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let c=g(this.lexerDefinitionErrors,l=>l.message).join(`-----------------------
45
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function Kl(e){return E(e,r=>ot(r)?r.charCodeAt(0):r)}function Zo(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var hr=256,Zn=[];function Xt(e){return e<hr?e:Zn[e]}function cT(){if(_(Zn)){Zn=new Array(65536);for(let e=0;e<65536;e++)Zn[e]=e>255?255+~~(e/255):e}}function oe(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function mr(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var Hl=1,zl={};function se(e){let t=lT(e);uT(t),hT(t),fT(t),S(t,r=>{r.isParent=r.categoryMatches.length>0})}function lT(e){let t=w(e),r=e,n=!0;for(;n;){r=zt(it(E(r,o=>o.CATEGORIES)));let i=Oe(r,t);t=t.concat(i),_(i)?n=!1:r=i}return t}function uT(e){S(e,t=>{ts(t)||(zl[Hl]=t,t.tokenTypeIdx=Hl++),ql(t)&&!O(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),ql(t)||(t.CATEGORIES=[]),pT(t)||(t.categoryMatches=[]),mT(t)||(t.categoryMatchesMap={})})}function fT(e){S(e,t=>{t.categoryMatches=[],S(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(zl[n].tokenTypeIdx)})})}function hT(e){S(e,t=>{Vl([],t)})}function Vl(e,t){S(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),S(t.CATEGORIES,r=>{let n=e.concat(t);$(n,r)||Vl(n,r)})}function ts(e){return A(e,"tokenTypeIdx")}function ql(e){return A(e,"CATEGORIES")}function pT(e){return A(e,"categoryMatches")}function mT(e){return A(e,"categoryMatchesMap")}function Yl(e){return A(e,"tokenTypeIdx")}var es={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}};var j;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(j||(j={}));var Fr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
46
+ `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:es,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Fr);var H=class{constructor(t,r=Fr){if(this.lexerDefinition=t,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,o)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${i}>`);let{time:a,value:c}=Mr(o),l=a>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${s}<-- <${i}> time: ${a}ms`),this.traceInitIndent--,c}else return o()},typeof r=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
47
+ a boolean 2nd argument is no longer supported`);this.config=lt({},Fr,r);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,o=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Fr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=jl;else if(this.config.lineTerminatorCharacters===Fr.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
48
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(r.safeMode&&r.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),O(t)?i={modes:{defaultMode:w(t)},defaultMode:pr}:(o=!1,i=w(t))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Fl(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Bl(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},S(i.modes,(a,c)=>{i.modes[c]=Ie(a,l=>pt(l))});let s=P(i.modes);if(S(i.modes,(a,c)=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Dl(a,s))}),_(this.lexerDefinitionErrors)){se(a);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=wl(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:r.positionTracking,ensureOptimizations:r.ensureOptimizations,safeMode:r.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=l.charCodeToPatternIdxToConfig,this.emptyGroups=lt({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=l.canBeOptimized}})}),this.defaultMode=i.defaultMode,!_(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let c=E(this.lexerDefinitionErrors,l=>l.message).join(`-----------------------
49
49
  `);throw new Error(`Errors detected in definition of Lexer:
50
- `+c)}S(this.lexerDefinitionWarning,a=>{vr(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(Zi?(this.chopInput=vt,this.match=this.matchWithTest):(this.updateLastIndex=K,this.match=this.matchWithExec),i&&(this.handleModes=K),this.trackStartLines===!1&&(this.computeNewColumn=vt),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=K),/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=rt(this.canModeBeOptimized,(c,l,u)=>(l===!1&&c.push(u),c),[]);if(r.ensureOptimizations&&!_(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized.
50
+ `+c)}S(this.lexerDefinitionWarning,a=>{vr(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(Jo?(this.chopInput=vt,this.match=this.matchWithTest):(this.updateLastIndex=K,this.match=this.matchWithExec),o&&(this.handleModes=K),this.trackStartLines===!1&&(this.computeNewColumn=vt),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=K),/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=rt(this.canModeBeOptimized,(c,l,u)=>(l===!1&&c.push(u),c),[]);if(r.ensureOptimizations&&!_(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized.
51
51
  Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
52
- Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{_l()}),this.TRACE_INIT("toFastProperties",()=>{br(this)})})}tokenize(t,r=this.defaultMode){if(!_(this.lexerDefinitionErrors)){let o=g(this.lexerDefinitionErrors,i=>i.message).join(`-----------------------
52
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{vl()}),this.TRACE_INIT("toFastProperties",()=>{br(this)})})}tokenize(t,r=this.defaultMode){if(!_(this.lexerDefinitionErrors)){let i=E(this.lexerDefinitionErrors,o=>o.message).join(`-----------------------
53
53
  `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
54
- `+o)}return this.tokenizeInternal(t,r)}tokenizeInternal(t,r){let n,o,i,s,a,c,l,u,f,h,x,T,O,R,N,E,d=t,y=d.length,L=0,Rt=0,bi=this.hasCustom?0:Math.floor(t.length/10),Bt=new Array(bi),ki=[],Nr=this.trackStartLines?1:void 0,ae=this.trackStartLines?1:void 0,Ir=Bl(this.emptyGroups),Yu=this.trackStartLines,Pi=this.config.lineTerminatorsPattern,pn=0,ce=[],Or=[],mn=[],vs=[];Object.freeze(vs);let Cr;function Ms(){return ce}function bs(ut){let _t=Xt(ut),Fe=Or[_t];return Fe===void 0?vs:Fe}let Xu=ut=>{if(mn.length===1&&ut.tokenType.PUSH_MODE===void 0){let _t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ut);ki.push({offset:ut.startOffset,line:ut.startLine,column:ut.startColumn,length:ut.image.length,message:_t})}else{mn.pop();let _t=Vt(mn);ce=this.patternIdxToConfig[_t],Or=this.charCodeToPatternIdxToConfig[_t],pn=ce.length;let Fe=this.canModeBeOptimized[_t]&&this.config.safeMode===!1;Or&&Fe?Cr=bs:Cr=Ms}};function ks(ut){mn.push(ut),Or=this.charCodeToPatternIdxToConfig[ut],ce=this.patternIdxToConfig[ut],pn=ce.length,pn=ce.length;let _t=this.canModeBeOptimized[ut]&&this.config.safeMode===!1;Or&&_t?Cr=bs:Cr=Ms}ks.call(this,r);let Pt,Ps=this.config.recoveryEnabled;for(;L<y;){c=null;let ut=d.charCodeAt(L),_t=Cr(ut),Fe=_t.length;for(n=0;n<Fe;n++){Pt=_t[n];let yt=Pt.pattern;l=null;let Zt=Pt.short;if(Zt!==!1?ut===Zt&&(c=yt):Pt.isCustom===!0?(E=yt.exec(d,L,Bt,Ir),E!==null?(c=E[0],E.payload!==void 0&&(l=E.payload)):c=null):(this.updateLastIndex(yt,L),c=this.match(yt,t,L)),c!==null){if(a=Pt.longerAlt,a!==void 0){let le=a.length;for(i=0;i<le;i++){let Jt=ce[a[i]],ye=Jt.pattern;if(u=null,Jt.isCustom===!0?(E=ye.exec(d,L,Bt,Ir),E!==null?(s=E[0],E.payload!==void 0&&(u=E.payload)):s=null):(this.updateLastIndex(ye,L),s=this.match(ye,t,L)),s&&s.length>c.length){c=s,l=u,Pt=Jt;break}}}break}}if(c!==null){if(f=c.length,h=Pt.group,h!==void 0&&(x=Pt.tokenTypeIdx,T=this.createTokenInstance(c,L,x,Pt.tokenType,Nr,ae,f),this.handlePayload(T,l),h===!1?Rt=this.addToken(Bt,Rt,T):Ir[h].push(T)),t=this.chopInput(t,f),L=L+f,ae=this.computeNewColumn(ae,f),Yu===!0&&Pt.canLineTerminator===!0){let yt=0,Zt,le;Pi.lastIndex=0;do Zt=Pi.test(c),Zt===!0&&(le=Pi.lastIndex-1,yt++);while(Zt===!0);yt!==0&&(Nr=Nr+yt,ae=f-le,this.updateTokenEndLineColumnLocation(T,h,le,yt,Nr,ae,f))}this.handleModes(Pt,Xu,ks,T)}else{let yt=L,Zt=Nr,le=ae,Jt=Ps===!1;for(;Jt===!1&&L<y;)for(t=this.chopInput(t,1),L++,o=0;o<pn;o++){let ye=ce[o],Ui=ye.pattern,Us=ye.short;if(Us!==!1?d.charCodeAt(L)===Us&&(Jt=!0):ye.isCustom===!0?Jt=Ui.exec(d,L,Bt,Ir)!==null:(this.updateLastIndex(Ui,L),Jt=Ui.exec(t)!==null),Jt===!0)break}if(O=L-yt,ae=this.computeNewColumn(ae,O),N=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(d,yt,O,Zt,le),ki.push({offset:yt,line:Zt,column:le,length:O,message:N}),Ps===!1)break}}return this.hasCustom||(Bt.length=Rt),{tokens:Bt,groups:Ir,errors:ki}}handleModes(t,r,n,o){if(t.pop===!0){let i=t.push;r(o),i!==void 0&&n.call(this,i)}else t.push!==void 0&&n.call(this,t.push)}chopInput(t,r){return t.substring(r)}updateLastIndex(t,r){t.lastIndex=r}updateTokenEndLineColumnLocation(t,r,n,o,i,s,a){let c,l;r!==void 0&&(c=n===a-1,l=c?-1:0,o===1&&c===!0||(t.endLine=i+l,t.endColumn=s-1+-l))}computeNewColumn(t,r){return t+r}createOffsetOnlyToken(t,r,n,o){return{image:t,startOffset:r,tokenTypeIdx:n,tokenType:o}}createStartOnlyToken(t,r,n,o,i,s){return{image:t,startOffset:r,startLine:i,startColumn:s,tokenTypeIdx:n,tokenType:o}}createFullToken(t,r,n,o,i,s,a){return{image:t,startOffset:r,endOffset:r+a-1,startLine:i,endLine:i,startColumn:s,endColumn:s+a-1,tokenTypeIdx:n,tokenType:o}}addTokenUsingPush(t,r,n){return t.push(n),r}addTokenUsingMemberAccess(t,r,n){return t[r]=n,r++,r}handlePayloadNoCustom(t,r){}handlePayloadWithCustom(t,r){r!==null&&(t.payload=r)}matchWithTest(t,r,n){return t.test(r)===!0?r.substring(n,t.lastIndex):null}matchWithExec(t,r){let n=t.exec(r);return n!==null?n[0]:null}};H.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";H.NA=/NOT_APPLICABLE/;function Pe(e){return es(e)?e.LABEL:e.name}function es(e){return it(e.LABEL)&&e.LABEL!==""}var hT="parent",Yl="categories",Xl="label",Ql="group",Zl="push_mode",Jl="pop_mode",tu="longer_alt",eu="line_breaks",ru="start_chars_hint";function m(e){return pT(e)}function pT(e){let t=e.pattern,r={};if(r.name=e.name,pt(t)||(r.PATTERN=t),A(e,hT))throw`The parent property is no longer supported.
55
- See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return A(e,Yl)&&(r.CATEGORIES=e[Yl]),se([r]),A(e,Xl)&&(r.LABEL=e[Xl]),A(e,Ql)&&(r.GROUP=e[Ql]),A(e,Jl)&&(r.POP_MODE=e[Jl]),A(e,Zl)&&(r.PUSH_MODE=e[Zl]),A(e,tu)&&(r.LONGER_ALT=e[tu]),A(e,eu)&&(r.LINE_BREAKS=e[eu]),A(e,ru)&&(r.START_CHARS_HINT=e[ru]),r}var wt=m({name:"EOF",pattern:H.NA});se([wt]);function Ue(e,t,r,n,o,i,s,a){return{image:t,startOffset:r,endOffset:n,startLine:o,endLine:i,startColumn:s,endColumn:a,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function rs(e,t){return ie(e,t)}var Jn={buildMismatchTokenMessage({expected:e,actual:t,previous:r,ruleName:n}){return`Expecting ${es(e)?`--> ${Pe(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:o}){let i="Expecting: ",a=`
56
- but found: '`+ct(t).image+"'";if(n)return i+n+a;{let c=rt(e,(h,x)=>h.concat(x),[]),l=g(c,h=>`[${g(h,x=>Pe(x)).join(", ")}]`),f=`one of these possible Token sequences:
57
- ${g(l,(h,x)=>` ${x+1}. ${h}`).join(`
58
- `)}`;return i+f+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let o="Expecting: ",s=`
59
- but found: '`+ct(t).image+"'";if(r)return o+r+s;{let c=`expecting at least one iteration which starts with one of these possible Token sequences::
60
- <${g(e,l=>`[${g(l,u=>Pe(u)).join(",")}]`).join(" ,")}>`;return o+c+s}}};Object.freeze(Jn);var nu={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<-
61
- inside top level rule: ->`+e.name+"<-"}},Dt={buildDuplicateFoundError(e,t){function r(u){return u instanceof v?u.terminalType.name:u instanceof D?u.nonTerminalName:""}let n=e.name,o=ct(t),i=o.idx,s=It(o),a=r(o),c=i>0,l=`->${s}${c?i:""}<- ${a?`with argument: ->${a}<-`:""}
54
+ `+i)}return this.tokenizeInternal(t,r)}tokenizeInternal(t,r){let n,i,o,s,a,c,l,u,f,h,g,T,I,R,N,x,d=t,y=d.length,L=0,Rt=0,ko=this.hasCustom?0:Math.floor(t.length/10),Bt=new Array(ko),Po=[],Nr=this.trackStartLines?1:void 0,ae=this.trackStartLines?1:void 0,Or=Gl(this.emptyGroups),Zu=this.trackStartLines,Uo=this.config.lineTerminatorsPattern,pn=0,ce=[],Ir=[],mn=[],Ms=[];Object.freeze(Ms);let Cr;function bs(){return ce}function ks(ut){let _t=Xt(ut),Fe=Ir[_t];return Fe===void 0?Ms:Fe}let Ju=ut=>{if(mn.length===1&&ut.tokenType.PUSH_MODE===void 0){let _t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ut);Po.push({offset:ut.startOffset,line:ut.startLine,column:ut.startColumn,length:ut.image.length,message:_t})}else{mn.pop();let _t=Vt(mn);ce=this.patternIdxToConfig[_t],Ir=this.charCodeToPatternIdxToConfig[_t],pn=ce.length;let Fe=this.canModeBeOptimized[_t]&&this.config.safeMode===!1;Ir&&Fe?Cr=ks:Cr=bs}};function Ps(ut){mn.push(ut),Ir=this.charCodeToPatternIdxToConfig[ut],ce=this.patternIdxToConfig[ut],pn=ce.length,pn=ce.length;let _t=this.canModeBeOptimized[ut]&&this.config.safeMode===!1;Ir&&_t?Cr=ks:Cr=bs}Ps.call(this,r);let Pt,Us=this.config.recoveryEnabled;for(;L<y;){c=null;let ut=d.charCodeAt(L),_t=Cr(ut),Fe=_t.length;for(n=0;n<Fe;n++){Pt=_t[n];let yt=Pt.pattern;l=null;let Zt=Pt.short;if(Zt!==!1?ut===Zt&&(c=yt):Pt.isCustom===!0?(x=yt.exec(d,L,Bt,Or),x!==null?(c=x[0],x.payload!==void 0&&(l=x.payload)):c=null):(this.updateLastIndex(yt,L),c=this.match(yt,t,L)),c!==null){if(a=Pt.longerAlt,a!==void 0){let le=a.length;for(o=0;o<le;o++){let Jt=ce[a[o]],ye=Jt.pattern;if(u=null,Jt.isCustom===!0?(x=ye.exec(d,L,Bt,Or),x!==null?(s=x[0],x.payload!==void 0&&(u=x.payload)):s=null):(this.updateLastIndex(ye,L),s=this.match(ye,t,L)),s&&s.length>c.length){c=s,l=u,Pt=Jt;break}}}break}}if(c!==null){if(f=c.length,h=Pt.group,h!==void 0&&(g=Pt.tokenTypeIdx,T=this.createTokenInstance(c,L,g,Pt.tokenType,Nr,ae,f),this.handlePayload(T,l),h===!1?Rt=this.addToken(Bt,Rt,T):Or[h].push(T)),t=this.chopInput(t,f),L=L+f,ae=this.computeNewColumn(ae,f),Zu===!0&&Pt.canLineTerminator===!0){let yt=0,Zt,le;Uo.lastIndex=0;do Zt=Uo.test(c),Zt===!0&&(le=Uo.lastIndex-1,yt++);while(Zt===!0);yt!==0&&(Nr=Nr+yt,ae=f-le,this.updateTokenEndLineColumnLocation(T,h,le,yt,Nr,ae,f))}this.handleModes(Pt,Ju,Ps,T)}else{let yt=L,Zt=Nr,le=ae,Jt=Us===!1;for(;Jt===!1&&L<y;)for(t=this.chopInput(t,1),L++,i=0;i<pn;i++){let ye=ce[i],wo=ye.pattern,ws=ye.short;if(ws!==!1?d.charCodeAt(L)===ws&&(Jt=!0):ye.isCustom===!0?Jt=wo.exec(d,L,Bt,Or)!==null:(this.updateLastIndex(wo,L),Jt=wo.exec(t)!==null),Jt===!0)break}if(I=L-yt,ae=this.computeNewColumn(ae,I),N=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(d,yt,I,Zt,le),Po.push({offset:yt,line:Zt,column:le,length:I,message:N}),Us===!1)break}}return this.hasCustom||(Bt.length=Rt),{tokens:Bt,groups:Or,errors:Po}}handleModes(t,r,n,i){if(t.pop===!0){let o=t.push;r(i),o!==void 0&&n.call(this,o)}else t.push!==void 0&&n.call(this,t.push)}chopInput(t,r){return t.substring(r)}updateLastIndex(t,r){t.lastIndex=r}updateTokenEndLineColumnLocation(t,r,n,i,o,s,a){let c,l;r!==void 0&&(c=n===a-1,l=c?-1:0,i===1&&c===!0||(t.endLine=o+l,t.endColumn=s-1+-l))}computeNewColumn(t,r){return t+r}createOffsetOnlyToken(t,r,n,i){return{image:t,startOffset:r,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(t,r,n,i,o,s){return{image:t,startOffset:r,startLine:o,startColumn:s,tokenTypeIdx:n,tokenType:i}}createFullToken(t,r,n,i,o,s,a){return{image:t,startOffset:r,endOffset:r+a-1,startLine:o,endLine:o,startColumn:s,endColumn:s+a-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(t,r,n){return t.push(n),r}addTokenUsingMemberAccess(t,r,n){return t[r]=n,r++,r}handlePayloadNoCustom(t,r){}handlePayloadWithCustom(t,r){r!==null&&(t.payload=r)}matchWithTest(t,r,n){return t.test(r)===!0?r.substring(n,t.lastIndex):null}matchWithExec(t,r){let n=t.exec(r);return n!==null?n[0]:null}};H.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";H.NA=/NOT_APPLICABLE/;function Pe(e){return rs(e)?e.LABEL:e.name}function rs(e){return ot(e.LABEL)&&e.LABEL!==""}var dT="parent",Xl="categories",Ql="label",Zl="group",Jl="push_mode",tu="pop_mode",eu="longer_alt",ru="line_breaks",nu="start_chars_hint";function m(e){return gT(e)}function gT(e){let t=e.pattern,r={};if(r.name=e.name,pt(t)||(r.PATTERN=t),A(e,dT))throw`The parent property is no longer supported.
55
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return A(e,Xl)&&(r.CATEGORIES=e[Xl]),se([r]),A(e,Ql)&&(r.LABEL=e[Ql]),A(e,Zl)&&(r.GROUP=e[Zl]),A(e,tu)&&(r.POP_MODE=e[tu]),A(e,Jl)&&(r.PUSH_MODE=e[Jl]),A(e,eu)&&(r.LONGER_ALT=e[eu]),A(e,ru)&&(r.LINE_BREAKS=e[ru]),A(e,nu)&&(r.START_CHARS_HINT=e[nu]),r}var wt=m({name:"EOF",pattern:H.NA});se([wt]);function Ue(e,t,r,n,i,o,s,a){return{image:t,startOffset:r,endOffset:n,startLine:i,endLine:o,startColumn:s,endColumn:a,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function ns(e,t){return oe(e,t)}var Jn={buildMismatchTokenMessage({expected:e,actual:t,previous:r,ruleName:n}){return`Expecting ${rs(e)?`--> ${Pe(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:i}){let o="Expecting: ",a=`
56
+ but found: '`+ct(t).image+"'";if(n)return o+n+a;{let c=rt(e,(h,g)=>h.concat(g),[]),l=E(c,h=>`[${E(h,g=>Pe(g)).join(", ")}]`),f=`one of these possible Token sequences:
57
+ ${E(l,(h,g)=>` ${g+1}. ${h}`).join(`
58
+ `)}`;return o+f+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",s=`
59
+ but found: '`+ct(t).image+"'";if(r)return i+r+s;{let c=`expecting at least one iteration which starts with one of these possible Token sequences::
60
+ <${E(e,l=>`[${E(l,u=>Pe(u)).join(",")}]`).join(" ,")}>`;return i+c+s}}};Object.freeze(Jn);var iu={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<-
61
+ inside top level rule: ->`+e.name+"<-"}},Dt={buildDuplicateFoundError(e,t){function r(u){return u instanceof v?u.terminalType.name:u instanceof D?u.nonTerminalName:""}let n=e.name,i=ct(t),o=i.idx,s=Ct(i),a=r(i),c=o>0,l=`->${s}${c?o:""}<- ${a?`with argument: ->${a}<-`:""}
62
62
  appears more than once (${t.length} times) in the top level rule: ->${n}<-.
63
63
  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
64
64
  `;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,`
@@ -66,68 +66,68 @@ inside top level rule: ->`+e.name+"<-"}},Dt={buildDuplicateFoundError(e,t){funct
66
66
  The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
67
67
  To resolve this make sure each Terminal and Non-Terminal names are unique
68
68
  This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
69
- and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=g(e.prefixPath,o=>Pe(o)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
69
+ and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=E(e.prefixPath,i=>Pe(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
70
70
  in <OR${r}> inside <${e.topLevelRule.name}> Rule,
71
71
  <${t}> may appears as a prefix path in all these alternatives.
72
72
  See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
73
- For Further details.`},buildAlternationAmbiguityError(e){let t=g(e.prefixPath,o=>Pe(o)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx,n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${r}> inside <${e.topLevelRule.name}> Rule,
73
+ For Further details.`},buildAlternationAmbiguityError(e){let t=E(e.prefixPath,i=>Pe(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx,n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${r}> inside <${e.topLevelRule.name}> Rule,
74
74
  <${t}> may appears as a prefix path in all these alternatives.
75
75
  `;return n=n+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
76
- For Further details.`,n},buildEmptyRepetitionError(e){let t=It(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
76
+ For Further details.`,n},buildEmptyRepetitionError(e){let t=Ct(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
77
77
  This could lead to an infinite loop.`},buildTokenNameError(e){return"deprecated"},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
78
78
  Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:
79
79
  <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
80
- has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=g(e.leftRecursionPath,i=>i.name),n=`${t} --> ${r.concat([t]).join(" --> ")}`;return`Left Recursion found in grammar.
80
+ has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=E(e.leftRecursionPath,o=>o.name),n=`${t} --> ${r.concat([t]).join(" --> ")}`;return`Left Recursion found in grammar.
81
81
  rule: <${t}> can be invoked from itself (directly or indirectly)
82
82
  without consuming any Tokens. The grammar path that causes this is:
83
83
  ${n}
84
84
  To fix this refactor your grammar to remove the left recursion.
85
- see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof Et?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function ou(e,t){let r=new ns(e,t);return r.resolveRefs(),r.errors}var ns=class extends xt{constructor(t,r){super(),this.nameToTopRule=t,this.errMsgProvider=r,this.errors=[]}resolveRefs(){S(k(this.nameToTopRule),t=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let r=this.nameToTopRule[t.nonTerminalName];if(r)t.referencedRule=r;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:st.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}}};var os=class extends oe{constructor(t,r){super(),this.topProd=t,this.path=r,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=w(this.path.ruleStack).reverse(),this.occurrenceStack=w(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,r=[]){this.found||super.walk(t,r)}walkProdRef(t,r,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let o=r.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,o)}}updateExpectedNext(){_(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},to=class extends os{constructor(t,r){super(t,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,r,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let o=r.concat(n),i=new F({definition:o});this.possibleTokTypes=Me(i),this.found=!0}}},dr=class extends oe{constructor(t,r){super(),this.topRule=t,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},eo=class extends dr{walkMany(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkMany(t,r,n)}},Br=class extends dr{walkManySep(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkManySep(t,r,n)}},ro=class extends dr{walkAtLeastOne(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkAtLeastOne(t,r,n)}},Gr=class extends dr{walkAtLeastOneSep(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkAtLeastOneSep(t,r,n)}};function no(e,t,r=[]){r=w(r);let n=[],o=0;function i(a){return a.concat(X(e,o+1))}function s(a){let c=no(i(a),t,r);return n.concat(c)}for(;r.length<t&&o<e.length;){let a=e[o];if(a instanceof F)return s(a.definition);if(a instanceof D)return s(a.definition);if(a instanceof G)n=s(a.definition);else if(a instanceof Q){let c=a.definition.concat([new b({definition:a.definition})]);return s(c)}else if(a instanceof Z){let c=[new F({definition:a.definition}),new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})];return s(c)}else if(a instanceof z){let c=a.definition.concat([new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})]);n=s(c)}else if(a instanceof b){let c=a.definition.concat([new b({definition:a.definition})]);n=s(c)}else{if(a instanceof V)return S(a.definition,c=>{_(c.definition)===!1&&(n=s(c.definition))}),n;if(a instanceof v)r.push(a.terminalType);else throw Error("non exhaustive match")}o++}return n.push({partialPath:r,suffixDef:X(e,o)}),n}function oo(e,t,r,n){let o="EXIT_NONE_TERMINAL",i=[o],s="EXIT_ALTERNATIVE",a=!1,c=t.length,l=c-n-1,u=[],f=[];for(f.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!_(f);){let h=f.pop();if(h===s){a&&Vt(f).idx<=l&&f.pop();continue}let x=h.def,T=h.idx,O=h.ruleStack,R=h.occurrenceStack;if(_(x))continue;let N=x[0];if(N===o){let E={idx:T,def:X(x),ruleStack:ne(O),occurrenceStack:ne(R)};f.push(E)}else if(N instanceof v)if(T<c-1){let E=T+1,d=t[E];if(r(d,N.terminalType)){let y={idx:E,def:X(x),ruleStack:O,occurrenceStack:R};f.push(y)}}else if(T===c-1)u.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:O,occurrenceStack:R}),a=!0;else throw Error("non exhaustive match");else if(N instanceof D){let E=w(O);E.push(N.nonTerminalName);let d=w(R);d.push(N.idx);let y={idx:T,def:N.definition.concat(i,X(x)),ruleStack:E,occurrenceStack:d};f.push(y)}else if(N instanceof G){let E={idx:T,def:X(x),ruleStack:O,occurrenceStack:R};f.push(E),f.push(s);let d={idx:T,def:N.definition.concat(X(x)),ruleStack:O,occurrenceStack:R};f.push(d)}else if(N instanceof Q){let E=new b({definition:N.definition,idx:N.idx}),d=N.definition.concat([E],X(x)),y={idx:T,def:d,ruleStack:O,occurrenceStack:R};f.push(y)}else if(N instanceof Z){let E=new v({terminalType:N.separator}),d=new b({definition:[E].concat(N.definition),idx:N.idx}),y=N.definition.concat([d],X(x)),L={idx:T,def:y,ruleStack:O,occurrenceStack:R};f.push(L)}else if(N instanceof z){let E={idx:T,def:X(x),ruleStack:O,occurrenceStack:R};f.push(E),f.push(s);let d=new v({terminalType:N.separator}),y=new b({definition:[d].concat(N.definition),idx:N.idx}),L=N.definition.concat([y],X(x)),Rt={idx:T,def:L,ruleStack:O,occurrenceStack:R};f.push(Rt)}else if(N instanceof b){let E={idx:T,def:X(x),ruleStack:O,occurrenceStack:R};f.push(E),f.push(s);let d=new b({definition:N.definition,idx:N.idx}),y=N.definition.concat([d],X(x)),L={idx:T,def:y,ruleStack:O,occurrenceStack:R};f.push(L)}else if(N instanceof V)for(let E=N.definition.length-1;E>=0;E--){let d=N.definition[E],y={idx:T,def:d.definition.concat(X(x)),ruleStack:O,occurrenceStack:R};f.push(y),f.push(s)}else if(N instanceof F)f.push({idx:T,def:N.definition.concat(X(x)),ruleStack:O,occurrenceStack:R});else if(N instanceof Et)f.push(mT(N,T,O,R));else throw Error("non exhaustive match")}return u}function mT(e,t,r,n){let o=w(r);o.push(e.name);let i=w(n);return i.push(1),{idx:t,def:e.definition,ruleStack:o,occurrenceStack:i}}var q;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(q||(q={}));function so(e){if(e instanceof G||e==="Option")return q.OPTION;if(e instanceof b||e==="Repetition")return q.REPETITION;if(e instanceof Q||e==="RepetitionMandatory")return q.REPETITION_MANDATORY;if(e instanceof Z||e==="RepetitionMandatoryWithSeparator")return q.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof z||e==="RepetitionWithSeparator")return q.REPETITION_WITH_SEPARATOR;if(e instanceof V||e==="Alternation")return q.ALTERNATION;throw Error("non exhaustive match")}function su(e,t,r,n,o,i){let s=$r(e,t,r),a=hu(s)?mr:ie;return i(s,n,a,o)}function au(e,t,r,n,o,i){let s=jr(e,t,o,r),a=hu(s)?mr:ie;return i(s[0],a,n)}function cu(e,t,r,n){let o=e.length,i=ft(e,s=>ft(s,a=>a.length===1));if(t)return function(s){let a=g(s,c=>c.GATE);for(let c=0;c<o;c++){let l=e[c],u=l.length,f=a[c];if(!(f!==void 0&&f.call(this)===!1))t:for(let h=0;h<u;h++){let x=l[h],T=x.length;for(let O=0;O<T;O++){let R=this.LA(O+1);if(r(R,x[O])===!1)continue t}return c}}};if(i&&!n){let s=g(e,c=>ot(c)),a=rt(s,(c,l,u)=>(S(l,f=>{A(c,f.tokenTypeIdx)||(c[f.tokenTypeIdx]=u),S(f.categoryMatches,h=>{A(c,h)||(c[h]=u)})}),c),{});return function(){let c=this.LA(1);return a[c.tokenTypeIdx]}}else return function(){for(let s=0;s<o;s++){let a=e[s],c=a.length;t:for(let l=0;l<c;l++){let u=a[l],f=u.length;for(let h=0;h<f;h++){let x=this.LA(h+1);if(r(x,u[h])===!1)continue t}return s}}}}function lu(e,t,r){let n=ft(e,i=>i.length===1),o=e.length;if(n&&!r){let i=ot(e);if(i.length===1&&_(i[0].categoryMatches)){let a=i[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===a}}else{let s=rt(i,(a,c,l)=>(a[c.tokenTypeIdx]=!0,S(c.categoryMatches,u=>{a[u]=!0}),a),[]);return function(){let a=this.LA(1);return s[a.tokenTypeIdx]===!0}}}else return function(){t:for(let i=0;i<o;i++){let s=e[i],a=s.length;for(let c=0;c<a;c++){let l=this.LA(c+1);if(t(l,s[c])===!1)continue t}return!0}return!1}}var ss=class extends oe{constructor(t,r,n){super(),this.topProd=t,this.targetOccurrence=r,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,r,n,o){return t.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=n.concat(o),!0):!1}walkOption(t,r,n){this.checkIsTarget(t,q.OPTION,r,n)||super.walkOption(t,r,n)}walkAtLeastOne(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY,r,n)||super.walkOption(t,r,n)}walkAtLeastOneSep(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}walkMany(t,r,n){this.checkIsTarget(t,q.REPETITION,r,n)||super.walkOption(t,r,n)}walkManySep(t,r,n){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}},io=class extends xt{constructor(t,r,n){super(),this.targetOccurrence=t,this.targetProdType=r,this.targetRef=n,this.result=[]}checkIsTarget(t,r){t.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||t===this.targetRef)&&(this.result=t.definition)}visitOption(t){this.checkIsTarget(t,q.OPTION)}visitRepetition(t){this.checkIsTarget(t,q.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,q.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,q.ALTERNATION)}};function iu(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function is(e){let t=[""];for(let r=0;r<e.length;r++){let n=e[r],o=[];for(let i=0;i<t.length;i++){let s=t[i];o.push(s+"_"+n.tokenTypeIdx);for(let a=0;a<n.categoryMatches.length;a++){let c="_"+n.categoryMatches[a];o.push(s+c)}}t=o}return t}function dT(e,t,r){for(let n=0;n<e.length;n++){if(n===r)continue;let o=e[n];for(let i=0;i<t.length;i++){let s=t[i];if(o[s]===!0)return!1}}return!0}function uu(e,t){let r=g(e,s=>no([s],1)),n=iu(r.length),o=g(r,s=>{let a={};return S(s,c=>{let l=is(c.partialPath);S(l,u=>{a[u]=!0})}),a}),i=r;for(let s=1;s<=t;s++){let a=i;i=iu(a.length);for(let c=0;c<a.length;c++){let l=a[c];for(let u=0;u<l.length;u++){let f=l[u].partialPath,h=l[u].suffixDef,x=is(f);if(dT(o,x,c)||_(h)||f.length===t){let O=n[c];if(ao(O,f)===!1){O.push(f);for(let R=0;R<x.length;R++){let N=x[R];o[c][N]=!0}}}else{let O=no(h,s+1,f);i[c]=i[c].concat(O),S(O,R=>{let N=is(R.partialPath);S(N,E=>{o[c][E]=!0})})}}}}return n}function $r(e,t,r,n){let o=new io(e,q.ALTERNATION,n);return t.accept(o),uu(o.result,r)}function jr(e,t,r,n){let o=new io(e,r);t.accept(o);let i=o.result,a=new ss(t,e,r).startWalking(),c=new F({definition:i}),l=new F({definition:a});return uu([c,l],n)}function ao(e,t){t:for(let r=0;r<e.length;r++){let n=e[r];if(n.length===t.length){for(let o=0;o<n.length;o++){let i=t[o],s=n[o];if((i===s||s.categoryMatchesMap[i.tokenTypeIdx]!==void 0)===!1)continue t}return!0}}return!1}function fu(e,t){return e.length<t.length&&ft(e,(r,n)=>{let o=t[n];return r===o||o.categoryMatchesMap[r.tokenTypeIdx]})}function hu(e){return ft(e,t=>ft(t,r=>ft(r,n=>_(n.categoryMatches))))}function pu(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return g(t,r=>Object.assign({type:st.CUSTOM_LOOKAHEAD_VALIDATION},r))}function mu(e,t,r,n){let o=gt(e,c=>gT(c,r)),i=NT(e,t,r),s=gt(e,c=>TT(c,r)),a=gt(e,c=>xT(c,e,n,r));return o.concat(i,s,a)}function gT(e,t){let r=new as;e.accept(r);let n=r.allProductions,o=ji(n,ET),i=Nt(o,a=>a.length>1);return g(k(i),a=>{let c=ct(a),l=t.buildDuplicateFoundError(e,a),u=It(c),f={message:l,type:st.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:u,occurrence:c.idx},h=du(c);return h&&(f.parameter=h),f})}function ET(e){return`${It(e)}_#_${e.idx}_#_${du(e)}`}function du(e){return e instanceof v?e.terminalType.name:e instanceof D?e.nonTerminalName:""}var as=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}};function xT(e,t,r,n){let o=[];if(rt(t,(s,a)=>a.name===e.name?s+1:s,0)>1){let s=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});o.push({message:s,type:st.DUPLICATE_RULE_NAME,ruleName:e.name})}return o}function gu(e,t,r){let n=[],o;return $(t,e)||(o=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:o,type:st.INVALID_RULE_OVERRIDE,ruleName:e})),n}function ls(e,t,r,n=[]){let o=[],i=co(t.definition);if(_(i))return[];{let s=e.name;$(i,e)&&o.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:st.LEFT_RECURSION,ruleName:s});let c=Ie(i,n.concat([e])),l=gt(c,u=>{let f=w(n);return f.push(u),ls(e,u,r,f)});return o.concat(l)}}function co(e){let t=[];if(_(e))return t;let r=ct(e);if(r instanceof D)t.push(r.referencedRule);else if(r instanceof F||r instanceof G||r instanceof Q||r instanceof Z||r instanceof z||r instanceof b)t=t.concat(co(r.definition));else if(r instanceof V)t=ot(g(r.definition,i=>co(i.definition)));else if(!(r instanceof v))throw Error("non exhaustive match");let n=ve(r),o=e.length>1;if(n&&o){let i=X(e);return t.concat(co(i))}else return t}var Wr=class extends xt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(t){this.alternations.push(t)}};function Eu(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,i=>{let s=ne(i.definition);return gt(s,(a,c)=>{let l=oo([a],[],ie,1);return _(l)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:i,emptyChoiceIdx:c}),type:st.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:i.idx,alternative:c+1}]:[]})})}function xu(e,t,r){let n=new Wr;e.accept(n);let o=n.alternations;return o=Oe(o,s=>s.ignoreAmbiguities===!0),gt(o,s=>{let a=s.idx,c=s.maxLookahead||t,l=$r(a,e,c,s),u=ST(l,s,e,r),f=AT(l,s,e,r);return u.concat(f)})}var cs=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}};function TT(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,i=>i.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:i}),type:st.TOO_MANY_ALTS,ruleName:e.name,occurrence:i.idx}]:[])}function Tu(e,t,r){let n=[];return S(e,o=>{let i=new cs;o.accept(i);let s=i.allProductions;S(s,a=>{let c=so(a),l=a.maxLookahead||t,u=a.idx,h=jr(u,o,c,l)[0];if(_(ot(h))){let x=r.buildEmptyRepetitionError({topLevelRule:o,repetition:a});n.push({message:x,type:st.NO_NON_EMPTY_LOOKAHEAD,ruleName:o.name})}})}),n}function ST(e,t,r,n){let o=[],i=rt(e,(a,c,l)=>(t.definition[l].ignoreAmbiguities===!0||S(c,u=>{let f=[l];S(e,(h,x)=>{l!==x&&ao(h,u)&&t.definition[x].ignoreAmbiguities!==!0&&f.push(x)}),f.length>1&&!ao(o,u)&&(o.push(u),a.push({alts:f,path:u}))}),a),[]);return g(i,a=>{let c=g(a.alts,u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:c,prefixPath:a.path}),type:st.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:a.alts}})}function AT(e,t,r,n){let o=rt(e,(s,a,c)=>{let l=g(a,u=>({idx:c,path:u}));return s.concat(l)},[]);return zt(gt(o,s=>{if(t.definition[s.idx].ignoreAmbiguities===!0)return[];let c=s.idx,l=s.path,u=ht(o,h=>t.definition[h.idx].ignoreAmbiguities!==!0&&h.idx<c&&fu(h.path,l));return g(u,h=>{let x=[h.idx+1,c+1],T=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:x,prefixPath:h.path}),type:st.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:T,alternatives:x}})}))}function NT(e,t,r){let n=[],o=g(t,i=>i.name);return S(e,i=>{let s=i.name;if($(o,s)){let a=r.buildNamespaceConflictError(i);n.push({message:a,type:st.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:s})}}),n}function Su(e){let t=sr(e,{errMsgProvider:nu}),r={};return S(e.rules,n=>{r[n.name]=n}),ou(r,t.errMsgProvider)}function Au(e){return e=sr(e,{errMsgProvider:Dt}),mu(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Nu="MismatchedTokenException",Iu="NoViableAltException",Ou="EarlyExitException",Cu="NotAllInputParsedException",Ru=[Nu,Iu,Ou,Cu];Object.freeze(Ru);function Re(e){return $(Ru,e.name)}var gr=class extends Error{constructor(t,r){super(t),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},we=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Nu}},Kr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Iu}},Hr=class extends gr{constructor(t,r){super(t,r),this.name=Cu}},qr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Ou}};var us={},hs="InRuleRecoveryException",fs=class extends Error{constructor(t){super(t),this.name=hs}},lo=class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=A(t,"recoveryEnabled")?t.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=IT)}getTokenToInsert(t){let r=Ue(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,r,n,o){let i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],c=!1,l=this.LA(1),u=this.LA(1),f=()=>{let h=this.LA(0),x=this.errorMessageProvider.buildMismatchTokenMessage({expected:o,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),T=new we(x,l,this.LA(0));T.resyncedTokens=ne(a),this.SAVE_ERROR(T)};for(;!c;)if(this.tokenMatcher(u,o)){f();return}else if(n.call(this)){f(),t.apply(this,r);return}else this.tokenMatcher(u,i)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(t,r,n){return!(n===!1||this.tokenMatcher(this.LA(1),t)||this.isBackTracking()||this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,r)))}getFollowsForInRuleRecovery(t,r){let n=this.getCurrentGrammarPath(t,r);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(t,r){if(this.canRecoverWithSingleTokenInsertion(t,r))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new fs("sad sad panda")}canPerformInRuleRecovery(t,r){return this.canRecoverWithSingleTokenInsertion(t,r)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,r){if(!this.canTokenTypeBeInsertedInRecovery(t)||_(r))return!1;let n=this.LA(1);return Yt(r,i=>this.tokenMatcher(n,i))!==void 0}canRecoverWithSingleTokenDeletion(t){return this.canTokenTypeBeDeletedInRecovery(t)?this.tokenMatcher(this.LA(2),t):!1}isInCurrentRuleReSyncSet(t){let r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return $(n,t)}findReSyncTokenType(){let t=this.flattenFollowSet(),r=this.LA(1),n=2;for(;;){let o=Yt(t,i=>rs(r,i));if(o!==void 0)return o;r=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return us;let t=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return g(t,(n,o)=>o===0?us:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:r[o],inRule:this.shortRuleNameToFullName(t[o-1])})}flattenFollowSet(){let t=g(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return ot(t)}getFollowSetFromFollowKey(t){if(t===us)return[wt];let r=t.ruleName+t.idxInCallingRule+Hn+t.inRule;return this.resyncFollows[r]}addToResyncTokens(t,r){return this.tokenMatcher(t,wt)||r.push(t),r}reSyncTo(t){let r=[],n=this.LA(1);for(;this.tokenMatcher(n,t)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return ne(r)}attemptInRepetitionRecovery(t,r,n,o,i,s,a){}getCurrentGrammarPath(t,r){let n=this.getHumanReadableRuleStack(),o=w(this.RULE_OCCURRENCE_STACK);return{ruleStack:n,occurrenceStack:o,lastTok:t,lastTokOccurrence:r}}getHumanReadableRuleStack(){return g(this.RULE_STACK,t=>this.shortRuleNameToFullName(t))}};function IT(e,t,r,n,o,i,s){let a=this.getKeyForAutomaticLookahead(n,o),c=this.firstAfterRepMap[a];if(c===void 0){let h=this.getCurrRuleFullName(),x=this.getGAstProductions()[h];c=new i(x,o).startWalking(),this.firstAfterRepMap[a]=c}let l=c.token,u=c.occurrence,f=c.isEndOfRule;this.RULE_STACK.length===1&&f&&l===void 0&&(l=wt,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,s)&&this.tryInRepetitionRecovery(e,t,r,l)}function uo(e,t,r){return r|t|e}var zr=class{constructor(t){var r;this.maxLookahead=(r=t?.maxLookahead)!==null&&r!==void 0?r:Tt.maxLookahead}validate(t){let r=this.validateNoLeftRecursion(t.rules);if(_(r)){let n=this.validateEmptyOrAlternatives(t.rules),o=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...r,...n,...o,...i]}return r}validateNoLeftRecursion(t){return gt(t,r=>ls(r,r,Dt))}validateEmptyOrAlternatives(t){return gt(t,r=>Eu(r,Dt))}validateAmbiguousAlternationAlternatives(t,r){return gt(t,n=>xu(n,r,Dt))}validateSomeNonEmptyLookaheadPath(t,r){return Tu(t,r,Dt)}buildLookaheadForAlternation(t){return su(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,cu)}buildLookaheadForOptional(t){return au(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,so(t.prodType),lu)}};var ho=class{initLooksAhead(t){this.dynamicTokensEnabled=A(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Tt.dynamicTokensEnabled,this.maxLookahead=A(t,"maxLookahead")?t.maxLookahead:Tt.maxLookahead,this.lookaheadStrategy=A(t,"lookaheadStrategy")?t.lookaheadStrategy:new zr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){S(t,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:n,repetition:o,option:i,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:c}=OT(r);S(n,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${It(l)}${u}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:r,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=uo(this.fullRuleNameToShort[r.name],256,l.idx);this.setLaFuncCache(h,f)})}),S(o,l=>{this.computeLookaheadFunc(r,l.idx,768,"Repetition",l.maxLookahead,It(l))}),S(i,l=>{this.computeLookaheadFunc(r,l.idx,512,"Option",l.maxLookahead,It(l))}),S(s,l=>{this.computeLookaheadFunc(r,l.idx,1024,"RepetitionMandatory",l.maxLookahead,It(l))}),S(a,l=>{this.computeLookaheadFunc(r,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,It(l))}),S(c,l=>{this.computeLookaheadFunc(r,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,It(l))})})})}computeLookaheadFunc(t,r,n,o,i,s){this.TRACE_INIT(`${s}${r===0?"":r}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:t,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:o}),c=uo(this.fullRuleNameToShort[t.name],n,r);this.setLaFuncCache(c,a)})}getKeyForAutomaticLookahead(t,r){let n=this.getLastExplicitRuleShortName();return uo(n,t,r)}getLaFuncFromCache(t){return this.lookAheadFuncsCache.get(t)}setLaFuncCache(t,r){this.lookAheadFuncsCache.set(t,r)}},ps=class extends xt{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}},fo=new ps;function OT(e){fo.reset(),e.accept(fo);let t=fo.dslMethods;return fo.reset(),t}function gs(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function Es(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function yu(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function Lu(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var CT="name";function xs(e,t){Object.defineProperty(e,CT,{enumerable:!1,configurable:!0,writable:!1,value:t})}function RT(e,t){let r=P(e),n=r.length;for(let o=0;o<n;o++){let i=r[o],s=e[i],a=s.length;for(let c=0;c<a;c++){let l=s[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,t)}}}function _u(e,t){let r=function(){};xs(r,e+"BaseSemantics");let n={visit:function(o,i){if(I(o)&&(o=o[0]),!pt(o))return this[o.name](o.children,i)},validateVisitor:function(){let o=yT(this,t);if(!_(o)){let i=g(o,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
86
- ${i.join(`
85
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof Et?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function ou(e,t){let r=new is(e,t);return r.resolveRefs(),r.errors}var is=class extends xt{constructor(t,r){super(),this.nameToTopRule=t,this.errMsgProvider=r,this.errors=[]}resolveRefs(){S(k(this.nameToTopRule),t=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let r=this.nameToTopRule[t.nonTerminalName];if(r)t.referencedRule=r;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:st.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}}};var os=class extends ie{constructor(t,r){super(),this.topProd=t,this.path=r,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=w(this.path.ruleStack).reverse(),this.occurrenceStack=w(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,r=[]){this.found||super.walk(t,r)}walkProdRef(t,r,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let i=r.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,i)}}updateExpectedNext(){_(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},ti=class extends os{constructor(t,r){super(t,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,r,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let i=r.concat(n),o=new F({definition:i});this.possibleTokTypes=Me(o),this.found=!0}}},dr=class extends ie{constructor(t,r){super(),this.topRule=t,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},ei=class extends dr{walkMany(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(t,r,n)}},Br=class extends dr{walkManySep(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(t,r,n)}},ri=class extends dr{walkAtLeastOne(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(t,r,n)}},Gr=class extends dr{walkAtLeastOneSep(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(t,r,n)}};function ni(e,t,r=[]){r=w(r);let n=[],i=0;function o(a){return a.concat(X(e,i+1))}function s(a){let c=ni(o(a),t,r);return n.concat(c)}for(;r.length<t&&i<e.length;){let a=e[i];if(a instanceof F)return s(a.definition);if(a instanceof D)return s(a.definition);if(a instanceof G)n=s(a.definition);else if(a instanceof Q){let c=a.definition.concat([new b({definition:a.definition})]);return s(c)}else if(a instanceof Z){let c=[new F({definition:a.definition}),new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})];return s(c)}else if(a instanceof z){let c=a.definition.concat([new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})]);n=s(c)}else if(a instanceof b){let c=a.definition.concat([new b({definition:a.definition})]);n=s(c)}else{if(a instanceof V)return S(a.definition,c=>{_(c.definition)===!1&&(n=s(c.definition))}),n;if(a instanceof v)r.push(a.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:X(e,i)}),n}function ii(e,t,r,n){let i="EXIT_NONE_TERMINAL",o=[i],s="EXIT_ALTERNATIVE",a=!1,c=t.length,l=c-n-1,u=[],f=[];for(f.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!_(f);){let h=f.pop();if(h===s){a&&Vt(f).idx<=l&&f.pop();continue}let g=h.def,T=h.idx,I=h.ruleStack,R=h.occurrenceStack;if(_(g))continue;let N=g[0];if(N===i){let x={idx:T,def:X(g),ruleStack:ne(I),occurrenceStack:ne(R)};f.push(x)}else if(N instanceof v)if(T<c-1){let x=T+1,d=t[x];if(r(d,N.terminalType)){let y={idx:x,def:X(g),ruleStack:I,occurrenceStack:R};f.push(y)}}else if(T===c-1)u.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:I,occurrenceStack:R}),a=!0;else throw Error("non exhaustive match");else if(N instanceof D){let x=w(I);x.push(N.nonTerminalName);let d=w(R);d.push(N.idx);let y={idx:T,def:N.definition.concat(o,X(g)),ruleStack:x,occurrenceStack:d};f.push(y)}else if(N instanceof G){let x={idx:T,def:X(g),ruleStack:I,occurrenceStack:R};f.push(x),f.push(s);let d={idx:T,def:N.definition.concat(X(g)),ruleStack:I,occurrenceStack:R};f.push(d)}else if(N instanceof Q){let x=new b({definition:N.definition,idx:N.idx}),d=N.definition.concat([x],X(g)),y={idx:T,def:d,ruleStack:I,occurrenceStack:R};f.push(y)}else if(N instanceof Z){let x=new v({terminalType:N.separator}),d=new b({definition:[x].concat(N.definition),idx:N.idx}),y=N.definition.concat([d],X(g)),L={idx:T,def:y,ruleStack:I,occurrenceStack:R};f.push(L)}else if(N instanceof z){let x={idx:T,def:X(g),ruleStack:I,occurrenceStack:R};f.push(x),f.push(s);let d=new v({terminalType:N.separator}),y=new b({definition:[d].concat(N.definition),idx:N.idx}),L=N.definition.concat([y],X(g)),Rt={idx:T,def:L,ruleStack:I,occurrenceStack:R};f.push(Rt)}else if(N instanceof b){let x={idx:T,def:X(g),ruleStack:I,occurrenceStack:R};f.push(x),f.push(s);let d=new b({definition:N.definition,idx:N.idx}),y=N.definition.concat([d],X(g)),L={idx:T,def:y,ruleStack:I,occurrenceStack:R};f.push(L)}else if(N instanceof V)for(let x=N.definition.length-1;x>=0;x--){let d=N.definition[x],y={idx:T,def:d.definition.concat(X(g)),ruleStack:I,occurrenceStack:R};f.push(y),f.push(s)}else if(N instanceof F)f.push({idx:T,def:N.definition.concat(X(g)),ruleStack:I,occurrenceStack:R});else if(N instanceof Et)f.push(ET(N,T,I,R));else throw Error("non exhaustive match")}return u}function ET(e,t,r,n){let i=w(r);i.push(e.name);let o=w(n);return o.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:o}}var q;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(q||(q={}));function si(e){if(e instanceof G||e==="Option")return q.OPTION;if(e instanceof b||e==="Repetition")return q.REPETITION;if(e instanceof Q||e==="RepetitionMandatory")return q.REPETITION_MANDATORY;if(e instanceof Z||e==="RepetitionMandatoryWithSeparator")return q.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof z||e==="RepetitionWithSeparator")return q.REPETITION_WITH_SEPARATOR;if(e instanceof V||e==="Alternation")return q.ALTERNATION;throw Error("non exhaustive match")}function au(e,t,r,n,i,o){let s=$r(e,t,r),a=pu(s)?mr:oe;return o(s,n,a,i)}function cu(e,t,r,n,i,o){let s=jr(e,t,i,r),a=pu(s)?mr:oe;return o(s[0],a,n)}function lu(e,t,r,n){let i=e.length,o=ft(e,s=>ft(s,a=>a.length===1));if(t)return function(s){let a=E(s,c=>c.GATE);for(let c=0;c<i;c++){let l=e[c],u=l.length,f=a[c];if(!(f!==void 0&&f.call(this)===!1))t:for(let h=0;h<u;h++){let g=l[h],T=g.length;for(let I=0;I<T;I++){let R=this.LA(I+1);if(r(R,g[I])===!1)continue t}return c}}};if(o&&!n){let s=E(e,c=>it(c)),a=rt(s,(c,l,u)=>(S(l,f=>{A(c,f.tokenTypeIdx)||(c[f.tokenTypeIdx]=u),S(f.categoryMatches,h=>{A(c,h)||(c[h]=u)})}),c),{});return function(){let c=this.LA(1);return a[c.tokenTypeIdx]}}else return function(){for(let s=0;s<i;s++){let a=e[s],c=a.length;t:for(let l=0;l<c;l++){let u=a[l],f=u.length;for(let h=0;h<f;h++){let g=this.LA(h+1);if(r(g,u[h])===!1)continue t}return s}}}}function uu(e,t,r){let n=ft(e,o=>o.length===1),i=e.length;if(n&&!r){let o=it(e);if(o.length===1&&_(o[0].categoryMatches)){let a=o[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===a}}else{let s=rt(o,(a,c,l)=>(a[c.tokenTypeIdx]=!0,S(c.categoryMatches,u=>{a[u]=!0}),a),[]);return function(){let a=this.LA(1);return s[a.tokenTypeIdx]===!0}}}else return function(){t:for(let o=0;o<i;o++){let s=e[o],a=s.length;for(let c=0;c<a;c++){let l=this.LA(c+1);if(t(l,s[c])===!1)continue t}return!0}return!1}}var as=class extends ie{constructor(t,r,n){super(),this.topProd=t,this.targetOccurrence=r,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,r,n,i){return t.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=n.concat(i),!0):!1}walkOption(t,r,n){this.checkIsTarget(t,q.OPTION,r,n)||super.walkOption(t,r,n)}walkAtLeastOne(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY,r,n)||super.walkOption(t,r,n)}walkAtLeastOneSep(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}walkMany(t,r,n){this.checkIsTarget(t,q.REPETITION,r,n)||super.walkOption(t,r,n)}walkManySep(t,r,n){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}},oi=class extends xt{constructor(t,r,n){super(),this.targetOccurrence=t,this.targetProdType=r,this.targetRef=n,this.result=[]}checkIsTarget(t,r){t.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||t===this.targetRef)&&(this.result=t.definition)}visitOption(t){this.checkIsTarget(t,q.OPTION)}visitRepetition(t){this.checkIsTarget(t,q.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,q.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,q.ALTERNATION)}};function su(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function ss(e){let t=[""];for(let r=0;r<e.length;r++){let n=e[r],i=[];for(let o=0;o<t.length;o++){let s=t[o];i.push(s+"_"+n.tokenTypeIdx);for(let a=0;a<n.categoryMatches.length;a++){let c="_"+n.categoryMatches[a];i.push(s+c)}}t=i}return t}function xT(e,t,r){for(let n=0;n<e.length;n++){if(n===r)continue;let i=e[n];for(let o=0;o<t.length;o++){let s=t[o];if(i[s]===!0)return!1}}return!0}function fu(e,t){let r=E(e,s=>ni([s],1)),n=su(r.length),i=E(r,s=>{let a={};return S(s,c=>{let l=ss(c.partialPath);S(l,u=>{a[u]=!0})}),a}),o=r;for(let s=1;s<=t;s++){let a=o;o=su(a.length);for(let c=0;c<a.length;c++){let l=a[c];for(let u=0;u<l.length;u++){let f=l[u].partialPath,h=l[u].suffixDef,g=ss(f);if(xT(i,g,c)||_(h)||f.length===t){let I=n[c];if(ai(I,f)===!1){I.push(f);for(let R=0;R<g.length;R++){let N=g[R];i[c][N]=!0}}}else{let I=ni(h,s+1,f);o[c]=o[c].concat(I),S(I,R=>{let N=ss(R.partialPath);S(N,x=>{i[c][x]=!0})})}}}}return n}function $r(e,t,r,n){let i=new oi(e,q.ALTERNATION,n);return t.accept(i),fu(i.result,r)}function jr(e,t,r,n){let i=new oi(e,r);t.accept(i);let o=i.result,a=new as(t,e,r).startWalking(),c=new F({definition:o}),l=new F({definition:a});return fu([c,l],n)}function ai(e,t){t:for(let r=0;r<e.length;r++){let n=e[r];if(n.length===t.length){for(let i=0;i<n.length;i++){let o=t[i],s=n[i];if((o===s||s.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue t}return!0}}return!1}function hu(e,t){return e.length<t.length&&ft(e,(r,n)=>{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function pu(e){return ft(e,t=>ft(t,r=>ft(r,n=>_(n.categoryMatches))))}function mu(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return E(t,r=>Object.assign({type:st.CUSTOM_LOOKAHEAD_VALIDATION},r))}function du(e,t,r,n){let i=gt(e,c=>TT(c,r)),o=CT(e,t,r),s=gt(e,c=>NT(c,r)),a=gt(e,c=>AT(c,e,n,r));return i.concat(o,s,a)}function TT(e,t){let r=new cs;e.accept(r);let n=r.allProductions,i=Wo(n,ST),o=It(i,a=>a.length>1);return E(k(o),a=>{let c=ct(a),l=t.buildDuplicateFoundError(e,a),u=Ct(c),f={message:l,type:st.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:u,occurrence:c.idx},h=gu(c);return h&&(f.parameter=h),f})}function ST(e){return`${Ct(e)}_#_${e.idx}_#_${gu(e)}`}function gu(e){return e instanceof v?e.terminalType.name:e instanceof D?e.nonTerminalName:""}var cs=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}};function AT(e,t,r,n){let i=[];if(rt(t,(s,a)=>a.name===e.name?s+1:s,0)>1){let s=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:s,type:st.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function Eu(e,t,r){let n=[],i;return $(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:st.INVALID_RULE_OVERRIDE,ruleName:e})),n}function us(e,t,r,n=[]){let i=[],o=ci(t.definition);if(_(o))return[];{let s=e.name;$(o,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:st.LEFT_RECURSION,ruleName:s});let c=Oe(o,n.concat([e])),l=gt(c,u=>{let f=w(n);return f.push(u),us(e,u,r,f)});return i.concat(l)}}function ci(e){let t=[];if(_(e))return t;let r=ct(e);if(r instanceof D)t.push(r.referencedRule);else if(r instanceof F||r instanceof G||r instanceof Q||r instanceof Z||r instanceof z||r instanceof b)t=t.concat(ci(r.definition));else if(r instanceof V)t=it(E(r.definition,o=>ci(o.definition)));else if(!(r instanceof v))throw Error("non exhaustive match");let n=ve(r),i=e.length>1;if(n&&i){let o=X(e);return t.concat(ci(o))}else return t}var Wr=class extends xt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(t){this.alternations.push(t)}};function xu(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,o=>{let s=ne(o.definition);return gt(s,(a,c)=>{let l=ii([a],[],oe,1);return _(l)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:c}),type:st.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:c+1}]:[]})})}function Tu(e,t,r){let n=new Wr;e.accept(n);let i=n.alternations;return i=Ie(i,s=>s.ignoreAmbiguities===!0),gt(i,s=>{let a=s.idx,c=s.maxLookahead||t,l=$r(a,e,c,s),u=OT(l,s,e,r),f=IT(l,s,e,r);return u.concat(f)})}var ls=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}};function NT(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,o=>o.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:o}),type:st.TOO_MANY_ALTS,ruleName:e.name,occurrence:o.idx}]:[])}function Su(e,t,r){let n=[];return S(e,i=>{let o=new ls;i.accept(o);let s=o.allProductions;S(s,a=>{let c=si(a),l=a.maxLookahead||t,u=a.idx,h=jr(u,i,c,l)[0];if(_(it(h))){let g=r.buildEmptyRepetitionError({topLevelRule:i,repetition:a});n.push({message:g,type:st.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function OT(e,t,r,n){let i=[],o=rt(e,(a,c,l)=>(t.definition[l].ignoreAmbiguities===!0||S(c,u=>{let f=[l];S(e,(h,g)=>{l!==g&&ai(h,u)&&t.definition[g].ignoreAmbiguities!==!0&&f.push(g)}),f.length>1&&!ai(i,u)&&(i.push(u),a.push({alts:f,path:u}))}),a),[]);return E(o,a=>{let c=E(a.alts,u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:c,prefixPath:a.path}),type:st.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:a.alts}})}function IT(e,t,r,n){let i=rt(e,(s,a,c)=>{let l=E(a,u=>({idx:c,path:u}));return s.concat(l)},[]);return zt(gt(i,s=>{if(t.definition[s.idx].ignoreAmbiguities===!0)return[];let c=s.idx,l=s.path,u=ht(i,h=>t.definition[h.idx].ignoreAmbiguities!==!0&&h.idx<c&&hu(h.path,l));return E(u,h=>{let g=[h.idx+1,c+1],T=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:g,prefixPath:h.path}),type:st.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:T,alternatives:g}})}))}function CT(e,t,r){let n=[],i=E(t,o=>o.name);return S(e,o=>{let s=o.name;if($(i,s)){let a=r.buildNamespaceConflictError(o);n.push({message:a,type:st.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:s})}}),n}function Au(e){let t=sr(e,{errMsgProvider:iu}),r={};return S(e.rules,n=>{r[n.name]=n}),ou(r,t.errMsgProvider)}function Nu(e){return e=sr(e,{errMsgProvider:Dt}),du(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Ou="MismatchedTokenException",Iu="NoViableAltException",Cu="EarlyExitException",Ru="NotAllInputParsedException",yu=[Ou,Iu,Cu,Ru];Object.freeze(yu);function Re(e){return $(yu,e.name)}var gr=class extends Error{constructor(t,r){super(t),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},we=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Ou}},Kr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Iu}},Hr=class extends gr{constructor(t,r){super(t,r),this.name=Ru}},qr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Cu}};var fs={},ps="InRuleRecoveryException",hs=class extends Error{constructor(t){super(t),this.name=ps}},li=class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=A(t,"recoveryEnabled")?t.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=RT)}getTokenToInsert(t){let r=Ue(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,r,n,i){let o=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],c=!1,l=this.LA(1),u=this.LA(1),f=()=>{let h=this.LA(0),g=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),T=new we(g,l,this.LA(0));T.resyncedTokens=ne(a),this.SAVE_ERROR(T)};for(;!c;)if(this.tokenMatcher(u,i)){f();return}else if(n.call(this)){f(),t.apply(this,r);return}else this.tokenMatcher(u,o)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(t,r,n){return!(n===!1||this.tokenMatcher(this.LA(1),t)||this.isBackTracking()||this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,r)))}getFollowsForInRuleRecovery(t,r){let n=this.getCurrentGrammarPath(t,r);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(t,r){if(this.canRecoverWithSingleTokenInsertion(t,r))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new hs("sad sad panda")}canPerformInRuleRecovery(t,r){return this.canRecoverWithSingleTokenInsertion(t,r)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,r){if(!this.canTokenTypeBeInsertedInRecovery(t)||_(r))return!1;let n=this.LA(1);return Yt(r,o=>this.tokenMatcher(n,o))!==void 0}canRecoverWithSingleTokenDeletion(t){return this.canTokenTypeBeDeletedInRecovery(t)?this.tokenMatcher(this.LA(2),t):!1}isInCurrentRuleReSyncSet(t){let r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return $(n,t)}findReSyncTokenType(){let t=this.flattenFollowSet(),r=this.LA(1),n=2;for(;;){let i=Yt(t,o=>ns(r,o));if(i!==void 0)return i;r=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return fs;let t=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return E(t,(n,i)=>i===0?fs:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:r[i],inRule:this.shortRuleNameToFullName(t[i-1])})}flattenFollowSet(){let t=E(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return it(t)}getFollowSetFromFollowKey(t){if(t===fs)return[wt];let r=t.ruleName+t.idxInCallingRule+Hn+t.inRule;return this.resyncFollows[r]}addToResyncTokens(t,r){return this.tokenMatcher(t,wt)||r.push(t),r}reSyncTo(t){let r=[],n=this.LA(1);for(;this.tokenMatcher(n,t)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return ne(r)}attemptInRepetitionRecovery(t,r,n,i,o,s,a){}getCurrentGrammarPath(t,r){let n=this.getHumanReadableRuleStack(),i=w(this.RULE_OCCURRENCE_STACK);return{ruleStack:n,occurrenceStack:i,lastTok:t,lastTokOccurrence:r}}getHumanReadableRuleStack(){return E(this.RULE_STACK,t=>this.shortRuleNameToFullName(t))}};function RT(e,t,r,n,i,o,s){let a=this.getKeyForAutomaticLookahead(n,i),c=this.firstAfterRepMap[a];if(c===void 0){let h=this.getCurrRuleFullName(),g=this.getGAstProductions()[h];c=new o(g,i).startWalking(),this.firstAfterRepMap[a]=c}let l=c.token,u=c.occurrence,f=c.isEndOfRule;this.RULE_STACK.length===1&&f&&l===void 0&&(l=wt,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,s)&&this.tryInRepetitionRecovery(e,t,r,l)}function ui(e,t,r){return r|t|e}var zr=class{constructor(t){var r;this.maxLookahead=(r=t?.maxLookahead)!==null&&r!==void 0?r:Tt.maxLookahead}validate(t){let r=this.validateNoLeftRecursion(t.rules);if(_(r)){let n=this.validateEmptyOrAlternatives(t.rules),i=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...r,...n,...i,...o]}return r}validateNoLeftRecursion(t){return gt(t,r=>us(r,r,Dt))}validateEmptyOrAlternatives(t){return gt(t,r=>xu(r,Dt))}validateAmbiguousAlternationAlternatives(t,r){return gt(t,n=>Tu(n,r,Dt))}validateSomeNonEmptyLookaheadPath(t,r){return Su(t,r,Dt)}buildLookaheadForAlternation(t){return au(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,lu)}buildLookaheadForOptional(t){return cu(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,si(t.prodType),uu)}};var hi=class{initLooksAhead(t){this.dynamicTokensEnabled=A(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Tt.dynamicTokensEnabled,this.maxLookahead=A(t,"maxLookahead")?t.maxLookahead:Tt.maxLookahead,this.lookaheadStrategy=A(t,"lookaheadStrategy")?t.lookaheadStrategy:new zr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){S(t,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:o,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:c}=yT(r);S(n,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${Ct(l)}${u}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:r,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=ui(this.fullRuleNameToShort[r.name],256,l.idx);this.setLaFuncCache(h,f)})}),S(i,l=>{this.computeLookaheadFunc(r,l.idx,768,"Repetition",l.maxLookahead,Ct(l))}),S(o,l=>{this.computeLookaheadFunc(r,l.idx,512,"Option",l.maxLookahead,Ct(l))}),S(s,l=>{this.computeLookaheadFunc(r,l.idx,1024,"RepetitionMandatory",l.maxLookahead,Ct(l))}),S(a,l=>{this.computeLookaheadFunc(r,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,Ct(l))}),S(c,l=>{this.computeLookaheadFunc(r,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,Ct(l))})})})}computeLookaheadFunc(t,r,n,i,o,s){this.TRACE_INIT(`${s}${r===0?"":r}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:t,maxLookahead:o||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),c=ui(this.fullRuleNameToShort[t.name],n,r);this.setLaFuncCache(c,a)})}getKeyForAutomaticLookahead(t,r){let n=this.getLastExplicitRuleShortName();return ui(n,t,r)}getLaFuncFromCache(t){return this.lookAheadFuncsCache.get(t)}setLaFuncCache(t,r){this.lookAheadFuncsCache.set(t,r)}},ms=class extends xt{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}},fi=new ms;function yT(e){fi.reset(),e.accept(fi);let t=fi.dslMethods;return fi.reset(),t}function Es(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function xs(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Lu(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function _u(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var LT="name";function Ts(e,t){Object.defineProperty(e,LT,{enumerable:!1,configurable:!0,writable:!1,value:t})}function _T(e,t){let r=P(e),n=r.length;for(let i=0;i<n;i++){let o=r[i],s=e[o],a=s.length;for(let c=0;c<a;c++){let l=s[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,t)}}}function vu(e,t){let r=function(){};Ts(r,e+"BaseSemantics");let n={visit:function(i,o){if(O(i)&&(i=i[0]),!pt(i))return this[i.name](i.children,o)},validateVisitor:function(){let i=vT(this,t);if(!_(i)){let o=E(i,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
86
+ ${o.join(`
87
87
 
88
88
  `).replace(/\n/g,`
89
- `)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function vu(e,t,r){let n=function(){};xs(n,e+"BaseSemanticsWithDefaults");let o=Object.create(r.prototype);return S(t,i=>{o[i]=RT}),n.prototype=o,n.prototype.constructor=n,n}var Ts;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(Ts||(Ts={}));function yT(e,t){return LT(e,t)}function LT(e,t){let r=ht(t,o=>dt(e[o])===!1),n=g(r,o=>({msg:`Missing visitor method: <${o}> on ${e.constructor.name} CST Visitor.`,type:Ts.MISSING_METHOD,methodName:o}));return zt(n)}var Eo=class{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=A(t,"nodeLocationTracking")?t.nodeLocationTracking:Tt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=K,this.cstFinallyStateUpdate=K,this.cstPostTerminal=K,this.cstPostNonTerminal=K,this.cstPostRule=K;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Es,this.setNodeLocationFromNode=Es,this.cstPostRule=K,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=gs,this.setNodeLocationFromNode=gs,this.cstPostRule=K,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=K,this.setInitialNodeLocation=K;else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(t){let r=this.LA(1);t.location={startOffset:r.startOffset,startLine:r.startLine,startColumn:r.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(t){let r={name:t,children:Object.create(null)};this.setInitialNodeLocation(r),this.CST_STACK.push(r)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let r=this.LA(0),n=t.location;n.startOffset<=r.startOffset?(n.endOffset=r.endOffset,n.endLine=r.endLine,n.endColumn=r.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(t){let r=this.LA(0),n=t.location;n.startOffset<=r.startOffset?n.endOffset=r.endOffset:n.startOffset=NaN}cstPostTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];yu(n,r,t),this.setNodeLocationFromToken(n.location,r)}cstPostNonTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];Lu(n,r,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(pt(this.baseCstVisitorConstructor)){let t=_u(this.className,P(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){let t=vu(this.className,P(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let t=this.RULE_STACK;return t[t.length-1]}getPreviousExplicitRuleShortName(){let t=this.RULE_STACK;return t[t.length-2]}getLastExplicitRuleOccurrenceIndex(){let t=this.RULE_OCCURRENCE_STACK;return t[t.length-1]}};var xo=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Er}LA(t){let r=this.currIdx+t;return r<0||this.tokVectorLength<=r?Er:this.tokVector[r]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}};var To=class{ACTION(t){return t.call(this)}consume(t,r,n){return this.consumeInternal(r,t,n)}subrule(t,r,n){return this.subruleInternal(r,t,n)}option(t,r){return this.optionInternal(r,t)}or(t,r){return this.orInternal(r,t)}many(t,r){return this.manyInternal(t,r)}atLeastOne(t,r){return this.atLeastOneInternal(t,r)}CONSUME(t,r){return this.consumeInternal(t,0,r)}CONSUME1(t,r){return this.consumeInternal(t,1,r)}CONSUME2(t,r){return this.consumeInternal(t,2,r)}CONSUME3(t,r){return this.consumeInternal(t,3,r)}CONSUME4(t,r){return this.consumeInternal(t,4,r)}CONSUME5(t,r){return this.consumeInternal(t,5,r)}CONSUME6(t,r){return this.consumeInternal(t,6,r)}CONSUME7(t,r){return this.consumeInternal(t,7,r)}CONSUME8(t,r){return this.consumeInternal(t,8,r)}CONSUME9(t,r){return this.consumeInternal(t,9,r)}SUBRULE(t,r){return this.subruleInternal(t,0,r)}SUBRULE1(t,r){return this.subruleInternal(t,1,r)}SUBRULE2(t,r){return this.subruleInternal(t,2,r)}SUBRULE3(t,r){return this.subruleInternal(t,3,r)}SUBRULE4(t,r){return this.subruleInternal(t,4,r)}SUBRULE5(t,r){return this.subruleInternal(t,5,r)}SUBRULE6(t,r){return this.subruleInternal(t,6,r)}SUBRULE7(t,r){return this.subruleInternal(t,7,r)}SUBRULE8(t,r){return this.subruleInternal(t,8,r)}SUBRULE9(t,r){return this.subruleInternal(t,9,r)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,r,n=xr){if($(this.definedRulesNames,t)){let s={message:Dt.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:st.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(s)}this.definedRulesNames.push(t);let o=this.defineRule(t,r,n);return this[t]=o,o}OVERRIDE_RULE(t,r,n=xr){let o=gu(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(o);let i=this.defineRule(t,r,n);return this[t]=i,i}BACKTRACK(t,r){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return t.apply(this,r),!0}catch(o){if(Re(o))return!1;throw o}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Kn(k(this.gastProductionsCache))}};var So=class{initRecognizerEngine(t,r){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=mr,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},A(r,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
89
+ `)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function Mu(e,t,r){let n=function(){};Ts(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return S(t,o=>{i[o]=_T}),n.prototype=i,n.prototype.constructor=n,n}var Ss;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(Ss||(Ss={}));function vT(e,t){return MT(e,t)}function MT(e,t){let r=ht(t,i=>dt(e[i])===!1),n=E(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:Ss.MISSING_METHOD,methodName:i}));return zt(n)}var gi=class{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=A(t,"nodeLocationTracking")?t.nodeLocationTracking:Tt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=K,this.cstFinallyStateUpdate=K,this.cstPostTerminal=K,this.cstPostNonTerminal=K,this.cstPostRule=K;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=xs,this.setNodeLocationFromNode=xs,this.cstPostRule=K,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Es,this.setNodeLocationFromNode=Es,this.cstPostRule=K,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=K,this.setInitialNodeLocation=K;else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(t){let r=this.LA(1);t.location={startOffset:r.startOffset,startLine:r.startLine,startColumn:r.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(t){let r={name:t,children:Object.create(null)};this.setInitialNodeLocation(r),this.CST_STACK.push(r)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let r=this.LA(0),n=t.location;n.startOffset<=r.startOffset?(n.endOffset=r.endOffset,n.endLine=r.endLine,n.endColumn=r.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(t){let r=this.LA(0),n=t.location;n.startOffset<=r.startOffset?n.endOffset=r.endOffset:n.startOffset=NaN}cstPostTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];Lu(n,r,t),this.setNodeLocationFromToken(n.location,r)}cstPostNonTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];_u(n,r,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(pt(this.baseCstVisitorConstructor)){let t=vu(this.className,P(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){let t=Mu(this.className,P(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let t=this.RULE_STACK;return t[t.length-1]}getPreviousExplicitRuleShortName(){let t=this.RULE_STACK;return t[t.length-2]}getLastExplicitRuleOccurrenceIndex(){let t=this.RULE_OCCURRENCE_STACK;return t[t.length-1]}};var Ei=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Er}LA(t){let r=this.currIdx+t;return r<0||this.tokVectorLength<=r?Er:this.tokVector[r]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}};var xi=class{ACTION(t){return t.call(this)}consume(t,r,n){return this.consumeInternal(r,t,n)}subrule(t,r,n){return this.subruleInternal(r,t,n)}option(t,r){return this.optionInternal(r,t)}or(t,r){return this.orInternal(r,t)}many(t,r){return this.manyInternal(t,r)}atLeastOne(t,r){return this.atLeastOneInternal(t,r)}CONSUME(t,r){return this.consumeInternal(t,0,r)}CONSUME1(t,r){return this.consumeInternal(t,1,r)}CONSUME2(t,r){return this.consumeInternal(t,2,r)}CONSUME3(t,r){return this.consumeInternal(t,3,r)}CONSUME4(t,r){return this.consumeInternal(t,4,r)}CONSUME5(t,r){return this.consumeInternal(t,5,r)}CONSUME6(t,r){return this.consumeInternal(t,6,r)}CONSUME7(t,r){return this.consumeInternal(t,7,r)}CONSUME8(t,r){return this.consumeInternal(t,8,r)}CONSUME9(t,r){return this.consumeInternal(t,9,r)}SUBRULE(t,r){return this.subruleInternal(t,0,r)}SUBRULE1(t,r){return this.subruleInternal(t,1,r)}SUBRULE2(t,r){return this.subruleInternal(t,2,r)}SUBRULE3(t,r){return this.subruleInternal(t,3,r)}SUBRULE4(t,r){return this.subruleInternal(t,4,r)}SUBRULE5(t,r){return this.subruleInternal(t,5,r)}SUBRULE6(t,r){return this.subruleInternal(t,6,r)}SUBRULE7(t,r){return this.subruleInternal(t,7,r)}SUBRULE8(t,r){return this.subruleInternal(t,8,r)}SUBRULE9(t,r){return this.subruleInternal(t,9,r)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,r,n=xr){if($(this.definedRulesNames,t)){let s={message:Dt.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:st.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(s)}this.definedRulesNames.push(t);let i=this.defineRule(t,r,n);return this[t]=i,i}OVERRIDE_RULE(t,r,n=xr){let i=Eu(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);let o=this.defineRule(t,r,n);return this[t]=o,o}BACKTRACK(t,r){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return t.apply(this,r),!0}catch(i){if(Re(i))return!1;throw i}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Kn(k(this.gastProductionsCache))}};var Ti=class{initRecognizerEngine(t,r){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=mr,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},A(r,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
90
90
  See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
91
- For Further details.`);if(I(t)){if(_(t))throw Error(`A Token Vocabulary cannot be empty.
91
+ For Further details.`);if(O(t)){if(_(t))throw Error(`A Token Vocabulary cannot be empty.
92
92
  Note that the first argument for the parser constructor
93
93
  is no longer a Token vector (since v4.0).`);if(typeof t[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
94
94
  See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
95
- For Further details.`)}if(I(t))this.tokensMap=rt(t,(i,s)=>(i[s.name]=s,i),{});else if(A(t,"modes")&&ft(ot(k(t.modes)),Vl)){let i=ot(k(t.modes)),s=ar(i);this.tokensMap=rt(s,(a,c)=>(a[c.name]=c,a),{})}else if(W(t))this.tokensMap=w(t);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=wt;let n=A(t,"modes")?ot(k(t.modes)):k(t),o=ft(n,i=>_(i.categoryMatches));this.tokenMatcher=o?mr:ie,se(k(this.tokensMap))}defineRule(t,r,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'
96
- Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let o=A(n,"resyncEnabled")?n.resyncEnabled:xr.resyncEnabled,i=A(n,"recoveryValueFunc")?n.recoveryValueFunc:xr.recoveryValueFunc,s=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=t,this.fullRuleNameToShort[t]=s;let a;return this.outputCst===!0?a=function(...u){try{this.ruleInvocationStateUpdate(s,t,this.subruleIdx),r.apply(this,u);let f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,o,i)}finally{this.ruleFinallyStateUpdate()}}:a=function(...u){try{return this.ruleInvocationStateUpdate(s,t,this.subruleIdx),r.apply(this,u)}catch(f){return this.invokeRuleCatch(f,o,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(a,{ruleName:t,originalGrammarAction:r})}invokeRuleCatch(t,r,n){let o=this.RULE_STACK.length===1,i=r&&!this.isBackTracking()&&this.recoveryEnabled;if(Re(t)){let s=t;if(i){let a=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(a))if(s.resyncedTokens=this.reSyncTo(a),this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return n(t);else{if(this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,s.partialCstResult=c}throw s}}else{if(o)return this.moveToTerminatedState(),n(t);throw s}}else throw t}optionInternal(t,r){let n=this.getKeyForAutomaticLookahead(512,r);return this.optionInternalLogic(t,r,n)}optionInternalLogic(t,r,n){let o=this.getLaFuncFromCache(n),i;if(typeof t!="function"){i=t.DEF;let s=t.GATE;if(s!==void 0){let a=o;o=()=>s.call(this)&&a.call(this)}}else i=t;if(o.call(this)===!0)return i.call(this)}atLeastOneInternal(t,r){let n=this.getKeyForAutomaticLookahead(1024,t);return this.atLeastOneInternalLogic(t,r,n)}atLeastOneInternalLogic(t,r,n){let o=this.getLaFuncFromCache(n),i;if(typeof r!="function"){i=r.DEF;let s=r.GATE;if(s!==void 0){let a=o;o=()=>s.call(this)&&a.call(this)}}else i=r;if(o.call(this)===!0){let s=this.doSingleRepetition(i);for(;o.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(t,q.REPETITION_MANDATORY,r.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,r],o,1024,t,ro)}atLeastOneSepFirstInternal(t,r){let n=this.getKeyForAutomaticLookahead(1536,t);this.atLeastOneSepFirstInternalLogic(t,r,n)}atLeastOneSepFirstInternalLogic(t,r,n){let o=r.DEF,i=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){o.call(this);let a=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,a,o,Gr],a,1536,t,Gr)}else throw this.raiseEarlyExitException(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r.ERR_MSG)}manyInternal(t,r){let n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,r,n)}manyInternalLogic(t,r,n){let o=this.getLaFuncFromCache(n),i;if(typeof r!="function"){i=r.DEF;let a=r.GATE;if(a!==void 0){let c=o;o=()=>a.call(this)&&c.call(this)}}else i=r;let s=!0;for(;o.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[t,r],o,768,t,eo,s)}manySepFirstInternal(t,r){let n=this.getKeyForAutomaticLookahead(1280,t);this.manySepFirstInternalLogic(t,r,n)}manySepFirstInternalLogic(t,r,n){let o=r.DEF,i=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){o.call(this);let a=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,a,o,Br],a,1280,t,Br)}}repetitionSepSecondInternal(t,r,n,o,i){for(;n();)this.CONSUME(r),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,r,n,o,i],n,1536,t,i)}doSingleRepetition(t){let r=this.getLexerPosition();return t.call(this),this.getLexerPosition()>r}orInternal(t,r){let n=this.getKeyForAutomaticLookahead(256,r),o=I(t)?t:t.DEF,s=this.getLaFuncFromCache(n).call(this,o);if(s!==void 0)return o[s].ALT.call(this);this.raiseNoAltException(r,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let t=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Hr(r,t))}}subruleInternal(t,r,n){let o;try{let i=n!==void 0?n.ARGS:void 0;return this.subruleIdx=r,o=t.apply(this,i),this.cstPostNonTerminal(o,n!==void 0&&n.LABEL!==void 0?n.LABEL:t.ruleName),o}catch(i){throw this.subruleInternalError(i,n,t.ruleName)}}subruleInternalError(t,r,n){throw Re(t)&&t.partialCstResult!==void 0&&(this.cstPostNonTerminal(t.partialCstResult,r!==void 0&&r.LABEL!==void 0?r.LABEL:n),delete t.partialCstResult),t}consumeInternal(t,r,n){let o;try{let i=this.LA(1);this.tokenMatcher(i,t)===!0?(this.consumeToken(),o=i):this.consumeInternalError(t,i,n)}catch(i){o=this.consumeInternalRecovery(t,r,i)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:t.name,o),o}consumeInternalError(t,r,n){let o,i=this.LA(0);throw n!==void 0&&n.ERR_MSG?o=n.ERR_MSG:o=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:r,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new we(o,r,i))}consumeInternalRecovery(t,r,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){let o=this.getFollowsForInRuleRecovery(t,r);try{return this.tryInRuleRecovery(t,o)}catch(i){throw i.name===hs?n:i}}else throw n}saveRecogState(){let t=this.errors,r=w(this.RULE_STACK);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:r,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState),this.RULE_STACK=t.RULE_STACK}ruleInvocationStateUpdate(t,r,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(t),this.cstInvocationStateUpdate(r)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),wt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}};var Ao=class{initErrorHandler(t){this._errors=[],this.errorMessageProvider=A(t,"errorMessageProvider")?t.errorMessageProvider:Tt.errorMessageProvider}SAVE_ERROR(t){if(Re(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:w(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return w(this._errors)}set errors(t){this._errors=t}raiseEarlyExitException(t,r,n){let o=this.getCurrRuleFullName(),i=this.getGAstProductions()[o],a=jr(t,i,r,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:n,ruleName:o});throw this.SAVE_ERROR(new qr(l,this.LA(1),this.LA(0)))}raiseNoAltException(t,r){let n=this.getCurrRuleFullName(),o=this.getGAstProductions()[n],i=$r(t,o,this.maxLookahead),s=[];for(let l=1;l<=this.maxLookahead;l++)s.push(this.LA(l));let a=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:s,previous:a,customUserDescription:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Kr(c,this.LA(1),a))}};var No=class{initContentAssist(){}computeContentAssist(t,r){let n=this.gastProductionsCache[t];if(pt(n))throw Error(`Rule ->${t}<- does not exist in this grammar.`);return oo([n],r,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(t){let r=ct(t.ruleStack),o=this.getGAstProductions()[r];return new to(o,t).startWalking()}};var Co={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Co);var Mu=!0,bu=Math.pow(2,8)-1,Pu=m({name:"RECORDING_PHASE_TOKEN",pattern:H.NA});se([Pu]);var Uu=Ue(Pu,`This IToken indicates the Parser is in Recording Phase
97
- See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Uu);var vT={name:`This CSTNode indicates the Parser is in Recording Phase
98
- See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Io=class{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let r=t>0?t:"";this[`CONSUME${r}`]=function(n,o){return this.consumeInternalRecord(n,t,o)},this[`SUBRULE${r}`]=function(n,o){return this.subruleInternalRecord(n,t,o)},this[`OPTION${r}`]=function(n){return this.optionInternalRecord(n,t)},this[`OR${r}`]=function(n){return this.orInternalRecord(n,t)},this[`MANY${r}`]=function(n){this.manyInternalRecord(t,n)},this[`MANY_SEP${r}`]=function(n){this.manySepFirstInternalRecord(t,n)},this[`AT_LEAST_ONE${r}`]=function(n){this.atLeastOneInternalRecord(t,n)},this[`AT_LEAST_ONE_SEP${r}`]=function(n){this.atLeastOneSepFirstInternalRecord(t,n)}}this.consume=function(t,r,n){return this.consumeInternalRecord(r,t,n)},this.subrule=function(t,r,n){return this.subruleInternalRecord(r,t,n)},this.option=function(t,r){return this.optionInternalRecord(r,t)},this.or=function(t,r){return this.orInternalRecord(r,t)},this.many=function(t,r){this.manyInternalRecord(t,r)},this.atLeastOne=function(t,r){this.atLeastOneInternalRecord(t,r)},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 t=this;for(let r=0;r<10;r++){let n=r>0?r:"";delete t[`CONSUME${n}`],delete t[`SUBRULE${n}`],delete t[`OPTION${n}`],delete t[`OR${n}`],delete t[`MANY${n}`],delete t[`MANY_SEP${n}`],delete t[`AT_LEAST_ONE${n}`],delete t[`AT_LEAST_ONE_SEP${n}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,r){return()=>!0}LA_RECORD(t){return Er}topLevelRuleRecord(t,r){try{let n=new Et({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),r.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
95
+ For Further details.`)}if(O(t))this.tokensMap=rt(t,(o,s)=>(o[s.name]=s,o),{});else if(A(t,"modes")&&ft(it(k(t.modes)),Yl)){let o=it(k(t.modes)),s=ar(o);this.tokensMap=rt(s,(a,c)=>(a[c.name]=c,a),{})}else if(W(t))this.tokensMap=w(t);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=wt;let n=A(t,"modes")?it(k(t.modes)):k(t),i=ft(n,o=>_(o.categoryMatches));this.tokenMatcher=i?mr:oe,se(k(this.tokensMap))}defineRule(t,r,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'
96
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=A(n,"resyncEnabled")?n.resyncEnabled:xr.resyncEnabled,o=A(n,"recoveryValueFunc")?n.recoveryValueFunc:xr.recoveryValueFunc,s=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=t,this.fullRuleNameToShort[t]=s;let a;return this.outputCst===!0?a=function(...u){try{this.ruleInvocationStateUpdate(s,t,this.subruleIdx),r.apply(this,u);let f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,i,o)}finally{this.ruleFinallyStateUpdate()}}:a=function(...u){try{return this.ruleInvocationStateUpdate(s,t,this.subruleIdx),r.apply(this,u)}catch(f){return this.invokeRuleCatch(f,i,o)}finally{this.ruleFinallyStateUpdate()}},Object.assign(a,{ruleName:t,originalGrammarAction:r})}invokeRuleCatch(t,r,n){let i=this.RULE_STACK.length===1,o=r&&!this.isBackTracking()&&this.recoveryEnabled;if(Re(t)){let s=t;if(o){let a=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(a))if(s.resyncedTokens=this.reSyncTo(a),this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return n(t);else{if(this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,s.partialCstResult=c}throw s}}else{if(i)return this.moveToTerminatedState(),n(t);throw s}}else throw t}optionInternal(t,r){let n=this.getKeyForAutomaticLookahead(512,r);return this.optionInternalLogic(t,r,n)}optionInternalLogic(t,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof t!="function"){o=t.DEF;let s=t.GATE;if(s!==void 0){let a=i;i=()=>s.call(this)&&a.call(this)}}else o=t;if(i.call(this)===!0)return o.call(this)}atLeastOneInternal(t,r){let n=this.getKeyForAutomaticLookahead(1024,t);return this.atLeastOneInternalLogic(t,r,n)}atLeastOneInternalLogic(t,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof r!="function"){o=r.DEF;let s=r.GATE;if(s!==void 0){let a=i;i=()=>s.call(this)&&a.call(this)}}else o=r;if(i.call(this)===!0){let s=this.doSingleRepetition(o);for(;i.call(this)===!0&&s===!0;)s=this.doSingleRepetition(o)}else throw this.raiseEarlyExitException(t,q.REPETITION_MANDATORY,r.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,r],i,1024,t,ri)}atLeastOneSepFirstInternal(t,r){let n=this.getKeyForAutomaticLookahead(1536,t);this.atLeastOneSepFirstInternalLogic(t,r,n)}atLeastOneSepFirstInternalLogic(t,r,n){let i=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){i.call(this);let a=()=>this.tokenMatcher(this.LA(1),o);for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,a,i,Gr],a,1536,t,Gr)}else throw this.raiseEarlyExitException(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r.ERR_MSG)}manyInternal(t,r){let n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,r,n)}manyInternalLogic(t,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof r!="function"){o=r.DEF;let a=r.GATE;if(a!==void 0){let c=i;i=()=>a.call(this)&&c.call(this)}}else o=r;let s=!0;for(;i.call(this)===!0&&s===!0;)s=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[t,r],i,768,t,ei,s)}manySepFirstInternal(t,r){let n=this.getKeyForAutomaticLookahead(1280,t);this.manySepFirstInternalLogic(t,r,n)}manySepFirstInternalLogic(t,r,n){let i=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){i.call(this);let a=()=>this.tokenMatcher(this.LA(1),o);for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,a,i,Br],a,1280,t,Br)}}repetitionSepSecondInternal(t,r,n,i,o){for(;n();)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,r,n,i,o],n,1536,t,o)}doSingleRepetition(t){let r=this.getLexerPosition();return t.call(this),this.getLexerPosition()>r}orInternal(t,r){let n=this.getKeyForAutomaticLookahead(256,r),i=O(t)?t:t.DEF,s=this.getLaFuncFromCache(n).call(this,i);if(s!==void 0)return i[s].ALT.call(this);this.raiseNoAltException(r,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let t=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Hr(r,t))}}subruleInternal(t,r,n){let i;try{let o=n!==void 0?n.ARGS:void 0;return this.subruleIdx=r,i=t.apply(this,o),this.cstPostNonTerminal(i,n!==void 0&&n.LABEL!==void 0?n.LABEL:t.ruleName),i}catch(o){throw this.subruleInternalError(o,n,t.ruleName)}}subruleInternalError(t,r,n){throw Re(t)&&t.partialCstResult!==void 0&&(this.cstPostNonTerminal(t.partialCstResult,r!==void 0&&r.LABEL!==void 0?r.LABEL:n),delete t.partialCstResult),t}consumeInternal(t,r,n){let i;try{let o=this.LA(1);this.tokenMatcher(o,t)===!0?(this.consumeToken(),i=o):this.consumeInternalError(t,o,n)}catch(o){i=this.consumeInternalRecovery(t,r,o)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:t.name,i),i}consumeInternalError(t,r,n){let i,o=this.LA(0);throw n!==void 0&&n.ERR_MSG?i=n.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:r,previous:o,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new we(i,r,o))}consumeInternalRecovery(t,r,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(t,r);try{return this.tryInRuleRecovery(t,i)}catch(o){throw o.name===ps?n:o}}else throw n}saveRecogState(){let t=this.errors,r=w(this.RULE_STACK);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:r,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState),this.RULE_STACK=t.RULE_STACK}ruleInvocationStateUpdate(t,r,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(t),this.cstInvocationStateUpdate(r)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),wt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}};var Si=class{initErrorHandler(t){this._errors=[],this.errorMessageProvider=A(t,"errorMessageProvider")?t.errorMessageProvider:Tt.errorMessageProvider}SAVE_ERROR(t){if(Re(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:w(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return w(this._errors)}set errors(t){this._errors=t}raiseEarlyExitException(t,r,n){let i=this.getCurrRuleFullName(),o=this.getGAstProductions()[i],a=jr(t,o,r,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:n,ruleName:i});throw this.SAVE_ERROR(new qr(l,this.LA(1),this.LA(0)))}raiseNoAltException(t,r){let n=this.getCurrRuleFullName(),i=this.getGAstProductions()[n],o=$r(t,i,this.maxLookahead),s=[];for(let l=1;l<=this.maxLookahead;l++)s.push(this.LA(l));let a=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:o,actual:s,previous:a,customUserDescription:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Kr(c,this.LA(1),a))}};var Ai=class{initContentAssist(){}computeContentAssist(t,r){let n=this.gastProductionsCache[t];if(pt(n))throw Error(`Rule ->${t}<- does not exist in this grammar.`);return ii([n],r,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(t){let r=ct(t.ruleStack),i=this.getGAstProductions()[r];return new ti(i,t).startWalking()}};var Ii={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ii);var bu=!0,ku=Math.pow(2,8)-1,Uu=m({name:"RECORDING_PHASE_TOKEN",pattern:H.NA});se([Uu]);var wu=Ue(Uu,`This IToken indicates the Parser is in Recording Phase
97
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(wu);var kT={name:`This CSTNode indicates the Parser is in Recording Phase
98
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Ni=class{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let r=t>0?t:"";this[`CONSUME${r}`]=function(n,i){return this.consumeInternalRecord(n,t,i)},this[`SUBRULE${r}`]=function(n,i){return this.subruleInternalRecord(n,t,i)},this[`OPTION${r}`]=function(n){return this.optionInternalRecord(n,t)},this[`OR${r}`]=function(n){return this.orInternalRecord(n,t)},this[`MANY${r}`]=function(n){this.manyInternalRecord(t,n)},this[`MANY_SEP${r}`]=function(n){this.manySepFirstInternalRecord(t,n)},this[`AT_LEAST_ONE${r}`]=function(n){this.atLeastOneInternalRecord(t,n)},this[`AT_LEAST_ONE_SEP${r}`]=function(n){this.atLeastOneSepFirstInternalRecord(t,n)}}this.consume=function(t,r,n){return this.consumeInternalRecord(r,t,n)},this.subrule=function(t,r,n){return this.subruleInternalRecord(r,t,n)},this.option=function(t,r){return this.optionInternalRecord(r,t)},this.or=function(t,r){return this.orInternalRecord(r,t)},this.many=function(t,r){this.manyInternalRecord(t,r)},this.atLeastOne=function(t,r){this.atLeastOneInternalRecord(t,r)},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 t=this;for(let r=0;r<10;r++){let n=r>0?r:"";delete t[`CONSUME${n}`],delete t[`SUBRULE${n}`],delete t[`OPTION${n}`],delete t[`OR${n}`],delete t[`MANY${n}`],delete t[`MANY_SEP${n}`],delete t[`AT_LEAST_ONE${n}`],delete t[`AT_LEAST_ONE_SEP${n}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,r){return()=>!0}LA_RECORD(t){return Er}topLevelRuleRecord(t,r){try{let n=new Et({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),r.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
99
99
  This error was thrown during the "grammar recording phase" For more info see:
100
- https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(t,r){return Yr.call(this,G,t,r)}atLeastOneInternalRecord(t,r){Yr.call(this,Q,r,t)}atLeastOneSepFirstInternalRecord(t,r){Yr.call(this,Z,r,t,Mu)}manyInternalRecord(t,r){Yr.call(this,b,r,t)}manySepFirstInternalRecord(t,r){Yr.call(this,z,r,t,Mu)}orInternalRecord(t,r){return MT.call(this,t,r)}subruleInternalRecord(t,r,n){if(Oo(r),!t||A(t,"ruleName")===!1){let a=new Error(`<SUBRULE${ku(r)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
101
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let o=Vt(this.recordingProdStack),i=t.ruleName,s=new D({idx:r,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return o.definition.push(s),this.outputCst?vT:Co}consumeInternalRecord(t,r,n){if(Oo(r),!Ji(t)){let s=new Error(`<CONSUME${ku(r)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
102
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let o=Vt(this.recordingProdStack),i=new v({idx:r,terminalType:t,label:n?.LABEL});return o.definition.push(i),Uu}};function Yr(e,t,r,n=!1){Oo(r);let o=Vt(this.recordingProdStack),i=dt(t)?t:t.DEF,s=new e({definition:[],idx:r});return n&&(s.separator=t.SEP),A(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(s),i.call(this),o.definition.push(s),this.recordingProdStack.pop(),Co}function MT(e,t){Oo(t);let r=Vt(this.recordingProdStack),n=I(e)===!1,o=n===!1?e:e.DEF,i=new V({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});A(e,"MAX_LOOKAHEAD")&&(i.maxLookahead=e.MAX_LOOKAHEAD);let s=_r(o,a=>dt(a.GATE));return i.hasPredicates=s,r.definition.push(i),S(o,a=>{let c=new F({definition:[]});i.definition.push(c),A(a,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=a.IGNORE_AMBIGUITIES:A(a,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),a.ALT.call(this),this.recordingProdStack.pop()}),Co}function ku(e){return e===0?"":`${e}`}function Oo(e){if(e<0||e>bu){let t=new Error(`Invalid DSL Method idx value: <${e}>
103
- Idx value must be a none negative value smaller than ${bu+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Ro=class{initPerformanceTracer(t){if(A(t,"traceInitPerf")){let r=t.traceInitPerf,n=typeof r=="number";this.traceInitMaxIdent=n?r:1/0,this.traceInitPerf=n?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=Tt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,r){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${t}>`);let{time:o,value:i}=Mr(r),s=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${o}ms`),this.traceInitIndent--,i}else return r()}};function wu(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(o=>{if(o==="constructor")return;let i=Object.getOwnPropertyDescriptor(n,o);i&&(i.get||i.set)?Object.defineProperty(e.prototype,o,i):e.prototype[o]=r.prototype[o]})})}var Er=Ue(wt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Er);var Tt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Jn,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),xr=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),st;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(st||(st={}));var Xr=class e{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{br(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),S(this.definedRulesNames,o=>{let s=this[o].originalGrammarAction,a;this.TRACE_INIT(`${o} Rule`,()=>{a=this.topLevelRuleRecord(o,s)}),this.gastProductionsCache[o]=a})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Su({rules:k(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(_(n)&&this.skipValidations===!1){let o=Au({rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),errMsgProvider:Dt,grammarName:r}),i=pu({lookaheadStrategy:this.lookaheadStrategy,rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(o,i)}}),_(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let o=Ll(k(this.gastProductionsCache));this.resyncFollows=o}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var o,i;(i=(o=this.lookaheadStrategy).initialize)===null||i===void 0||i.call(o,{rules:k(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(k(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!_(this.definitionErrors))throw t=g(this.definitionErrors,o=>o.message),new Error(`Parser Definition Errors detected:
100
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(t,r){return Yr.call(this,G,t,r)}atLeastOneInternalRecord(t,r){Yr.call(this,Q,r,t)}atLeastOneSepFirstInternalRecord(t,r){Yr.call(this,Z,r,t,bu)}manyInternalRecord(t,r){Yr.call(this,b,r,t)}manySepFirstInternalRecord(t,r){Yr.call(this,z,r,t,bu)}orInternalRecord(t,r){return PT.call(this,t,r)}subruleInternalRecord(t,r,n){if(Oi(r),!t||A(t,"ruleName")===!1){let a=new Error(`<SUBRULE${Pu(r)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
101
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let i=Vt(this.recordingProdStack),o=t.ruleName,s=new D({idx:r,nonTerminalName:o,label:n?.LABEL,referencedRule:void 0});return i.definition.push(s),this.outputCst?kT:Ii}consumeInternalRecord(t,r,n){if(Oi(r),!ts(t)){let s=new Error(`<CONSUME${Pu(r)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
102
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=Vt(this.recordingProdStack),o=new v({idx:r,terminalType:t,label:n?.LABEL});return i.definition.push(o),wu}};function Yr(e,t,r,n=!1){Oi(r);let i=Vt(this.recordingProdStack),o=dt(t)?t:t.DEF,s=new e({definition:[],idx:r});return n&&(s.separator=t.SEP),A(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(s),o.call(this),i.definition.push(s),this.recordingProdStack.pop(),Ii}function PT(e,t){Oi(t);let r=Vt(this.recordingProdStack),n=O(e)===!1,i=n===!1?e:e.DEF,o=new V({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});A(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD);let s=_r(i,a=>dt(a.GATE));return o.hasPredicates=s,r.definition.push(o),S(i,a=>{let c=new F({definition:[]});o.definition.push(c),A(a,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=a.IGNORE_AMBIGUITIES:A(a,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),a.ALT.call(this),this.recordingProdStack.pop()}),Ii}function Pu(e){return e===0?"":`${e}`}function Oi(e){if(e<0||e>ku){let t=new Error(`Invalid DSL Method idx value: <${e}>
103
+ Idx value must be a none negative value smaller than ${ku+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Ci=class{initPerformanceTracer(t){if(A(t,"traceInitPerf")){let r=t.traceInitPerf,n=typeof r=="number";this.traceInitMaxIdent=n?r:1/0,this.traceInitPerf=n?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=Tt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,r){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${t}>`);let{time:i,value:o}=Mr(r),s=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${i}ms`),this.traceInitIndent--,o}else return r()}};function Du(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let o=Object.getOwnPropertyDescriptor(n,i);o&&(o.get||o.set)?Object.defineProperty(e.prototype,i,o):e.prototype[i]=r.prototype[i]})})}var Er=Ue(wt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Er);var Tt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Jn,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),xr=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),st;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(st||(st={}));var Xr=class e{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{br(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),S(this.definedRulesNames,i=>{let s=this[i].originalGrammarAction,a;this.TRACE_INIT(`${i} Rule`,()=>{a=this.topLevelRuleRecord(i,s)}),this.gastProductionsCache[i]=a})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Au({rules:k(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(_(n)&&this.skipValidations===!1){let i=Nu({rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),errMsgProvider:Dt,grammarName:r}),o=mu({lookaheadStrategy:this.lookaheadStrategy,rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,o)}}),_(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=_l(k(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,o;(o=(i=this.lookaheadStrategy).initialize)===null||o===void 0||o.call(i,{rules:k(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(k(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!_(this.definitionErrors))throw t=E(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
104
104
  ${t.join(`
105
105
  -------------------------------
106
106
  `)}`)})}constructor(t,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(t,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),A(r,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
107
107
  Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
108
108
  See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
109
- For further details.`);this.skipValidations=A(r,"skipValidations")?r.skipValidations:Tt.skipValidations}};Xr.DEFER_DEFINITION_ERRORS_HANDLING=!1;wu(Xr,[lo,ho,Eo,xo,So,To,Ao,No,Io,Ro]);var Qr=class extends Xr{constructor(t,r=Tt){let n=w(r);n.outputCst=!0,super(t,n)}};var kT=m({name:"WhiteSpace",pattern:/\s+/,group:H.SKIPPED}),PT=m({name:"LineComment",pattern:/\/\/[^\n]*/,group:H.SKIPPED}),UT=m({name:"BlockComment",pattern:/\/\*[\s\S]*?\*\//,group:H.SKIPPED}),p=m({name:"Identifier",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/}),Zr=m({name:"TemplateIdentifier",pattern:/\{[a-zA-Z_][a-zA-Z0-9_]*\}/}),yo=m({name:"Concept",pattern:/concept/,longer_alt:p}),Lo=m({name:"Schema",pattern:/schema/,longer_alt:p}),_o=m({name:"Mixin",pattern:/mixin/,longer_alt:p}),vo=m({name:"Enum",pattern:/enum/,longer_alt:p}),Mo=m({name:"Extension",pattern:/extension/,longer_alt:p}),bo=m({name:"Function",pattern:/function/,longer_alt:p}),ko=m({name:"Func",pattern:/func/,longer_alt:p}),Po=m({name:"Trigger",pattern:/trigger/,longer_alt:p}),Jr=m({name:"Index",pattern:/index/,longer_alt:p}),tn=m({name:"Check",pattern:/check/,longer_alt:p}),Uo=m({name:"Before",pattern:/before/,longer_alt:p}),wo=m({name:"After",pattern:/after/,longer_alt:p}),Do=m({name:"Ondelete",pattern:/ondelete/,longer_alt:p}),Fo=m({name:"On",pattern:/on/,longer_alt:p}),Bo=m({name:"Each",pattern:/each/,longer_alt:p}),Go=m({name:"Row",pattern:/row/,longer_alt:p}),$o=m({name:"Statement",pattern:/statement/,longer_alt:p}),jo=m({name:"Execute",pattern:/execute/,longer_alt:p}),Tr=m({name:"Unique",pattern:/unique/,longer_alt:p}),en=m({name:"Gin",pattern:/gin/,longer_alt:p}),rn=m({name:"Gist",pattern:/gist/,longer_alt:p}),nn=m({name:"Btree",pattern:/btree/,longer_alt:p}),on=m({name:"Hash",pattern:/hash/,longer_alt:p}),Wo=m({name:"Pkey",pattern:/pkey/,longer_alt:p}),Ko=m({name:"Nonull",pattern:/nonull/,longer_alt:p}),Ho=m({name:"Default",pattern:/default/,longer_alt:p}),qo=m({name:"Ref",pattern:/ref/,longer_alt:p}),zo=m({name:"Cascade",pattern:/cascade/,longer_alt:p}),Vo=m({name:"Restrict",pattern:/restrict/,longer_alt:p}),Yo=m({name:"SetNull",pattern:/setnull/,longer_alt:p}),Xo=m({name:"SetDefault",pattern:/setdefault/,longer_alt:p}),Qo=m({name:"NoAction",pattern:/noaction/,longer_alt:p}),Zo=m({name:"Update",pattern:/update/,longer_alt:p}),Jo=m({name:"Insert",pattern:/insert/,longer_alt:p}),ti=m({name:"Delete",pattern:/delete/,longer_alt:p}),ei=m({name:"Return",pattern:/return/,longer_alt:p}),sn=m({name:"New",pattern:/NEW/,longer_alt:p}),an=m({name:"Old",pattern:/OLD/,longer_alt:p}),ri=m({name:"Serial",pattern:/serial/i,longer_alt:p}),ni=m({name:"BigSerial",pattern:/bigserial/i,longer_alt:p}),oi=m({name:"Integer",pattern:/integer/i,longer_alt:p}),ii=m({name:"Bigint",pattern:/bigint/i,longer_alt:p}),si=m({name:"SmallInt",pattern:/smallint/i,longer_alt:p}),ai=m({name:"Text",pattern:/text/i,longer_alt:p}),ci=m({name:"Varchar",pattern:/varchar/i,longer_alt:p}),li=m({name:"Char",pattern:/char/i,longer_alt:p}),ui=m({name:"Boolean",pattern:/boolean/i,longer_alt:p}),fi=m({name:"Timestamptz",pattern:/timestamptz/i,longer_alt:p}),hi=m({name:"Timestamp",pattern:/timestamp/i,longer_alt:p}),pi=m({name:"Date",pattern:/date/i,longer_alt:p}),mi=m({name:"Time",pattern:/time/i,longer_alt:p}),di=m({name:"Jsonb",pattern:/jsonb/i,longer_alt:p}),gi=m({name:"Json",pattern:/json/i,longer_alt:p}),Ei=m({name:"Uuid",pattern:/uuid/i,longer_alt:p}),xi=m({name:"Inet",pattern:/inet/i,longer_alt:p}),Ti=m({name:"Citext",pattern:/citext/i,longer_alt:p}),Si=m({name:"Decimal",pattern:/decimal/i,longer_alt:p}),Ai=m({name:"Numeric",pattern:/numeric/i,longer_alt:p}),Ni=m({name:"Real",pattern:/real/i,longer_alt:p}),Ii=m({name:"DoublePrecision",pattern:/double\s+precision/i,longer_alt:p}),Oi=m({name:"Bytea",pattern:/bytea/i,longer_alt:p}),Ci=m({name:"StringLiteral",pattern:/'(?:[^'\\]|\\.)*'/}),cn=m({name:"NumberLiteral",pattern:/-?\d+(?:\.\d+)?/}),Ri=m({name:"BooleanLiteral",pattern:/true|false/,longer_alt:p}),yi=m({name:"NullLiteral",pattern:/null/i,longer_alt:p}),As=m({name:"Arrow",pattern:/->/}),Li=m({name:"DoubleColon",pattern:/::/}),Sr=m({name:"LBrace",pattern:/\{/}),Ar=m({name:"RBrace",pattern:/\}/}),Ot=m({name:"LParen",pattern:/\(/}),Ct=m({name:"RParen",pattern:/\)/}),_i=m({name:"LBracket",pattern:/\[/}),vi=m({name:"RBracket",pattern:/\]/}),ln=m({name:"LAngle",pattern:/</}),un=m({name:"RAngle",pattern:/>/}),kt=m({name:"Semicolon",pattern:/;/}),Qt=m({name:"Comma",pattern:/,/}),fn=m({name:"Dot",pattern:/\./}),hn=m({name:"Equals",pattern:/=/}),Ns=[kT,PT,UT,As,Li,yo,Lo,_o,vo,Mo,bo,ko,Po,Jr,tn,Uo,wo,Do,Fo,Bo,Go,$o,jo,Tr,en,rn,nn,on,Wo,Ko,Ho,qo,Xo,Yo,zo,Vo,Qo,Zo,Jo,ti,ei,sn,an,Ii,fi,hi,ni,ri,si,ii,oi,ci,li,ai,ui,pi,mi,di,gi,Ei,xi,Ti,Si,Ai,Ni,Oi,Ci,cn,Ri,yi,Zr,p,Sr,Ar,Ot,Ct,_i,vi,ln,un,kt,Qt,fn,hn],wT=new H(Ns,{ensureOptimizations:!0});function Du(e){return wT.tokenize(e)}var Cs=class extends Qr{constructor(){super(Ns,{recoveryEnabled:!0,maxLookahead:3}),this.performSelfAnalysis()}anyIdentifier=this.RULE("anyIdentifier",()=>{this.OR([{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.CONSUME(Lo)},{ALT:()=>this.CONSUME(_o)},{ALT:()=>this.CONSUME(vo)},{ALT:()=>this.CONSUME(Mo)},{ALT:()=>this.CONSUME(ko)},{ALT:()=>this.CONSUME(Po)},{ALT:()=>this.CONSUME(Jr)},{ALT:()=>this.CONSUME(tn)},{ALT:()=>this.CONSUME(Uo)},{ALT:()=>this.CONSUME(wo)},{ALT:()=>this.CONSUME(Fo)},{ALT:()=>this.CONSUME(Bo)},{ALT:()=>this.CONSUME(Go)},{ALT:()=>this.CONSUME($o)},{ALT:()=>this.CONSUME(jo)},{ALT:()=>this.CONSUME(bo)},{ALT:()=>this.CONSUME(ei)},{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(Zo)},{ALT:()=>this.CONSUME(Jo)},{ALT:()=>this.CONSUME(ti)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(Wo)},{ALT:()=>this.CONSUME(Ko)},{ALT:()=>this.CONSUME(Ho)},{ALT:()=>this.CONSUME(qo)},{ALT:()=>this.CONSUME(Do)},{ALT:()=>this.CONSUME(zo)},{ALT:()=>this.CONSUME(Vo)},{ALT:()=>this.CONSUME(Yo)},{ALT:()=>this.CONSUME(Xo)},{ALT:()=>this.CONSUME(Qo)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)},{ALT:()=>this.CONSUME(ri)},{ALT:()=>this.CONSUME(ni)},{ALT:()=>this.CONSUME(oi)},{ALT:()=>this.CONSUME(ii)},{ALT:()=>this.CONSUME(si)},{ALT:()=>this.CONSUME(ai)},{ALT:()=>this.CONSUME(ci)},{ALT:()=>this.CONSUME(li)},{ALT:()=>this.CONSUME(ui)},{ALT:()=>this.CONSUME(fi)},{ALT:()=>this.CONSUME(hi)},{ALT:()=>this.CONSUME(pi)},{ALT:()=>this.CONSUME(mi)},{ALT:()=>this.CONSUME(di)},{ALT:()=>this.CONSUME(gi)},{ALT:()=>this.CONSUME(Ei)},{ALT:()=>this.CONSUME(xi)},{ALT:()=>this.CONSUME(Ti)},{ALT:()=>this.CONSUME(Si)},{ALT:()=>this.CONSUME(Ai)},{ALT:()=>this.CONSUME(Ni)},{ALT:()=>this.CONSUME(Ii)},{ALT:()=>this.CONSUME(Oi)}])});program=this.RULE("program",()=>{this.MANY(()=>{this.SUBRULE(this.topLevelDeclaration)})});topLevelDeclaration=this.RULE("topLevelDeclaration",()=>{this.OR([{ALT:()=>this.SUBRULE(this.extensionDecl)},{ALT:()=>this.SUBRULE(this.functionDecl)},{ALT:()=>this.SUBRULE(this.conceptDecl)},{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)},{ALT:()=>this.SUBRULE(this.instantiation)},{ALT:()=>this.SUBRULE(this.perInstanceIndex)}])});extensionDecl=this.RULE("extensionDecl",()=>{this.CONSUME(Mo),this.SUBRULE(this.anyIdentifier),this.CONSUME(kt)});functionDecl=this.RULE("functionDecl",()=>{this.CONSUME(ko),this.SUBRULE(this.anyIdentifier),this.CONSUME(Ot),this.CONSUME(Ct),this.CONSUME(As),this.SUBRULE2(this.anyIdentifier),this.SUBRULE(this.functionBody)});functionBody=this.RULE("functionBody",()=>{this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.functionStatement)}),this.CONSUME(Ar)});functionStatement=this.RULE("functionStatement",()=>{this.OR([{ALT:()=>this.SUBRULE(this.returnStatement)},{ALT:()=>this.SUBRULE(this.assignmentStatement)}])});returnStatement=this.RULE("returnStatement",()=>{this.CONSUME(ei),this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(kt)});assignmentStatement=this.RULE("assignmentStatement",()=>{this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(fn),this.SUBRULE(this.anyIdentifier),this.CONSUME(hn),this.SUBRULE(this.functionCallExpr),this.CONSUME(kt)});functionCallExpr=this.RULE("functionCallExpr",()=>{this.CONSUME(p),this.CONSUME(Ot),this.CONSUME(Ct)});conceptDecl=this.RULE("conceptDecl",()=>{this.CONSUME(yo),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.typeParamList)}),this.CONSUME(Sr),this.MANY(()=>{this.OR([{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)}])}),this.CONSUME(Ar)});typeParamList=this.RULE("typeParamList",()=>{this.CONSUME(ln),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)}),this.CONSUME(un)});enumDecl=this.RULE("enumDecl",()=>{this.CONSUME(vo),this.SUBRULE(this.anyIdentifier),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE2(this.anyIdentifier),this.CONSUME(kt)}),this.CONSUME(Ar)});schemaDecl=this.RULE("schemaDecl",()=>{this.CONSUME(Lo),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.mixinList)}),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.schemaBodyItem)}),this.CONSUME(Ar)});mixinList=this.RULE("mixinList",()=>{this.CONSUME(_o),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)})});schemaBodyItem=this.RULE("schemaBodyItem",()=>{this.OR([{ALT:()=>this.SUBRULE(this.indexDef)},{ALT:()=>this.SUBRULE(this.checkDef)},{ALT:()=>this.SUBRULE(this.triggerDef)},{ALT:()=>this.SUBRULE(this.columnDef)}])});columnDef=this.RULE("columnDef",()=>{this.SUBRULE(this.columnName),this.SUBRULE(this.dataType),this.MANY(()=>{this.SUBRULE(this.columnConstraint)}),this.CONSUME(kt)});columnName=this.RULE("columnName",()=>{this.OR([{ALT:()=>{this.CONSUME(Zr),this.OPTION(()=>{this.CONSUME(p)})}},{ALT:()=>this.CONSUME2(p)}])});dataType=this.RULE("dataType",()=>{this.OR([{ALT:()=>this.CONSUME(ri)},{ALT:()=>this.CONSUME(ni)},{ALT:()=>this.CONSUME(oi)},{ALT:()=>this.CONSUME(ii)},{ALT:()=>this.CONSUME(si)},{ALT:()=>this.CONSUME(ai)},{ALT:()=>this.CONSUME(ci)},{ALT:()=>this.CONSUME(li)},{ALT:()=>this.CONSUME(ui)},{ALT:()=>this.CONSUME(fi)},{ALT:()=>this.CONSUME(hi)},{ALT:()=>this.CONSUME(pi)},{ALT:()=>this.CONSUME(mi)},{ALT:()=>this.CONSUME(di)},{ALT:()=>this.CONSUME(gi)},{ALT:()=>this.CONSUME(Ei)},{ALT:()=>this.CONSUME(xi)},{ALT:()=>this.CONSUME(Ti)},{ALT:()=>this.CONSUME(Si)},{ALT:()=>this.CONSUME(Ai)},{ALT:()=>this.CONSUME(Ni)},{ALT:()=>this.CONSUME(Ii)},{ALT:()=>this.CONSUME(Oi)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME(Ot),this.CONSUME(cn),this.CONSUME(Ct)})});columnConstraint=this.RULE("columnConstraint",()=>{this.OR([{ALT:()=>this.CONSUME(Wo)},{ALT:()=>this.CONSUME(Ko)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.SUBRULE(this.defaultConstraint)},{ALT:()=>this.SUBRULE(this.refConstraint)},{ALT:()=>this.SUBRULE(this.checkConstraint)},{ALT:()=>this.SUBRULE(this.onDeleteConstraint)}])});defaultConstraint=this.RULE("defaultConstraint",()=>{this.CONSUME(Ho),this.CONSUME(Ot),this.SUBRULE(this.defaultValue),this.CONSUME(Ct)});defaultValue=this.RULE("defaultValue",()=>{this.OR([{ALT:()=>this.CONSUME(Ci)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ri)},{ALT:()=>this.CONSUME(yi)},{ALT:()=>this.SUBRULE(this.functionCallExpr)},{ALT:()=>{this.SUBRULE(this.anyIdentifier),this.CONSUME(Li),this.SUBRULE2(this.anyIdentifier)}},{ALT:()=>this.SUBRULE3(this.anyIdentifier)}])});refConstraint=this.RULE("refConstraint",()=>{this.CONSUME(qo),this.CONSUME(Ot),this.CONSUME(p),this.CONSUME(fn),this.CONSUME2(p),this.CONSUME(Ct)});checkConstraint=this.RULE("checkConstraint",()=>{this.CONSUME(tn),this.CONSUME(Ot),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)});checkExpression=this.RULE("checkExpression",()=>{this.MANY(()=>{this.OR([{ALT:()=>{this.CONSUME(Ot),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)}},{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ci)},{ALT:()=>this.CONSUME(Ri)},{ALT:()=>this.CONSUME(yi)},{ALT:()=>this.CONSUME(Li)},{ALT:()=>this.CONSUME(hn)},{ALT:()=>this.CONSUME(Qt)},{ALT:()=>this.CONSUME(fn)},{ALT:()=>this.CONSUME(ln)},{ALT:()=>this.CONSUME(un)}])})});onDeleteConstraint=this.RULE("onDeleteConstraint",()=>{this.CONSUME(Do),this.CONSUME(Ot),this.OR([{ALT:()=>this.CONSUME(zo)},{ALT:()=>this.CONSUME(Vo)},{ALT:()=>this.CONSUME(Yo)},{ALT:()=>this.CONSUME(Xo)},{ALT:()=>this.CONSUME(Qo)}]),this.CONSUME(Ct)});indexDef=this.RULE("indexDef",()=>{this.CONSUME(Jr),this.CONSUME(Ot),this.SUBRULE(this.indexColumnList),this.CONSUME(Ct),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.CONSUME(kt)});indexColumnList=this.RULE("indexColumnList",()=>{this.SUBRULE(this.indexColumn),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.indexColumn)})});indexColumn=this.RULE("indexColumn",()=>{this.OR([{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME2(p)})});checkDef=this.RULE("checkDef",()=>{this.CONSUME(tn),this.CONSUME(Ot),this.SUBRULE(this.checkExpression),this.CONSUME(Ct),this.CONSUME(kt)});triggerDef=this.RULE("triggerDef",()=>{this.CONSUME(Po),this.CONSUME(p),this.OR([{ALT:()=>this.CONSUME(Uo)},{ALT:()=>this.CONSUME(wo)}]),this.OR2([{ALT:()=>this.CONSUME(Zo)},{ALT:()=>this.CONSUME(Jo)},{ALT:()=>this.CONSUME(ti)}]),this.CONSUME(Fo),this.CONSUME(Bo),this.OR3([{ALT:()=>this.CONSUME(Go)},{ALT:()=>this.CONSUME($o)}]),this.CONSUME(jo),this.CONSUME(bo),this.CONSUME2(p),this.CONSUME(Ot),this.CONSUME(Ct),this.CONSUME(kt)});instantiation=this.RULE("instantiation",()=>{this.SUBRULE(this.instantiationTargetList),this.CONSUME(hn),this.SUBRULE(this.conceptReference),this.CONSUME(kt)});instantiationTargetList=this.RULE("instantiationTargetList",()=>{this.SUBRULE(this.instantiationTarget),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.instantiationTarget)})});instantiationTarget=this.RULE("instantiationTarget",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(_i),this.CONSUME2(p),this.CONSUME(vi)})});conceptReference=this.RULE("conceptReference",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(ln),this.SUBRULE(this.typeArgList),this.CONSUME(un)})});typeArgList=this.RULE("typeArgList",()=>{this.SUBRULE(this.typeArg),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.typeArg)})});typeArg=this.RULE("typeArg",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(_i),this.CONSUME2(p),this.CONSUME(vi)})});perInstanceIndex=this.RULE("perInstanceIndex",()=>{this.CONSUME(Jr),this.CONSUME(Ot),this.CONSUME(p),this.CONSUME(Qt),this.CONSUME2(p),this.MANY(()=>{this.CONSUME2(Qt),this.CONSUME3(p)}),this.CONSUME(Ct),this.MANY2(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.CONSUME(kt)})},Is=new Cs;function nt(e,t){let r=e.children[t];if(r&&r.length>0){let n=r[0];if(n&&"image"in n)return n.image}return""}function De(e,t){let r=e.children[t];return r?r.map(n=>"image"in n?n.image:"").filter(n=>n!==""):[]}function M(e,t){let n=e.children[t]?.[0];if(n&&"children"in n)return n}function Ft(e,t){let r=e.children[t];return r?r.filter(n=>"children"in n):[]}function Fu(e){let r=Ft(e,"anyIdentifier")[0];if(r)for(let n of Object.keys(r.children)){let i=r.children[n]?.[0];if(i&&"image"in i)return i.image}return""}function Os(e){let t=Ft(e,"anyIdentifier"),r=[];for(let n of t)for(let o of Object.keys(n.children)){let s=n.children[o]?.[0];if(s&&"image"in s){r.push(s.image);break}}return r}var Rs=class{visit(t){let r=[],n=Ft(t,"topLevelDeclaration");for(let o of n){let i=this.visitTopLevelDeclaration(o);i&&r.push(i)}return{type:"Program",declarations:r}}visitTopLevelDeclaration(t){let r=M(t,"extensionDecl");if(r)return this.visitExtensionDecl(r);let n=M(t,"functionDecl");if(n)return this.visitFunctionDecl(n);let o=M(t,"conceptDecl");if(o)return this.visitConceptDecl(o);let i=M(t,"enumDecl");if(i)return this.visitEnumDecl(i);let s=M(t,"schemaDecl");if(s)return this.visitSchemaDecl(s);let a=M(t,"instantiation");if(a)return this.visitInstantiation(a);let c=M(t,"perInstanceIndex");return c?this.visitPerInstanceIndex(c):null}visitExtensionDecl(t){return{type:"ExtensionDecl",name:Fu(t)}}visitFunctionDecl(t){let r=Os(t),n=r[0]??"",o=r[1]??"",i=M(t,"functionBody"),s="";if(i){let a=Ft(i,"functionStatement"),c=[];for(let l of a){let u=M(l,"returnStatement");if(u){let h=nt(u,"Identifier");h||(h=nt(u,"New")),h||(h=nt(u,"Old")),c.push(`RETURN ${h};`)}let f=M(l,"assignmentStatement");if(f){let h=nt(f,"Identifier");h||(h=nt(f,"New")),h||(h=nt(f,"Old"));let x=Fu(f),T=M(f,"functionCallExpr"),O=T?nt(T,"Identifier"):"";c.push(`${h}.${x} := ${O}();`)}}s=c.join(`
110
- `)}return{type:"FunctionDecl",name:n,returnType:o,body:s}}visitConceptDecl(t){let r=nt(t,"Identifier"),n=[],o=M(t,"typeParamList");o&&n.push(...De(o,"Identifier"));let i=[],s=Ft(t,"schemaDecl");for(let c of s){let l=this.visitSchemaDecl(c);l.conceptScope=r,i.push(l)}let a=Ft(t,"enumDecl");for(let c of a){let l=this.visitEnumDecl(c);l.conceptScope=r,i.push(l)}return{type:"ConceptDecl",name:r,typeParams:n,members:i}}visitEnumDecl(t){let r=Os(t),n=r[0]??"",o=r.slice(1);return{type:"EnumDecl",name:n,values:o}}visitSchemaDecl(t){let r=nt(t,"Identifier"),n=[],o=M(t,"mixinList");o&&n.push(...De(o,"Identifier"));let i=[],s=Ft(t,"schemaBodyItem");for(let a of s){let c=this.visitSchemaBodyItem(a);c&&i.push(c)}return{type:"SchemaDecl",name:r,mixins:n,members:i}}visitSchemaBodyItem(t){let r=M(t,"columnDef");if(r)return this.visitColumnDef(r);let n=M(t,"indexDef");if(n)return this.visitIndexDef(n);let o=M(t,"checkDef");if(o)return this.visitCheckDef(o);let i=M(t,"triggerDef");return i?this.visitTriggerDef(i):null}visitColumnDef(t){let r=M(t,"columnName"),n="";if(r){let c=nt(r,"TemplateIdentifier"),l=nt(r,"Identifier");n=c?c+l:l}let o=M(t,"dataType"),i="";if(o){for(let u of Object.keys(o.children)){let h=o.children[u]?.[0];if(h&&"image"in h){i=h.image;break}}let l=o.children.NumberLiteral?.[0];l&&"image"in l&&(i+=`(${l.image})`)}let s=[],a=Ft(t,"columnConstraint");for(let c of a){let l=this.visitColumnConstraint(c);l&&s.push(l)}return{type:"ColumnDef",name:n,dataType:i,constraints:s}}visitColumnConstraint(t){if(t.children.Pkey)return{type:"PrimaryKey"};if(t.children.Nonull)return{type:"NotNull"};if(t.children.Unique)return{type:"Unique"};let r=M(t,"defaultConstraint");if(r){let s=M(r,"defaultValue"),a="";if(s){let c=nt(s,"StringLiteral"),l=nt(s,"NumberLiteral"),u=nt(s,"BooleanLiteral"),f=nt(s,"NullLiteral"),h=M(s,"functionCallExpr"),x=nt(s,"DoubleColon"),T=Os(s);c?a=c:l?a=l:u?a=u:f?a=f:h?a=nt(h,"Identifier")+"()":x&&T.length===2&&T[0]&&T[1]?a=`${T[0]}::${T[1]}`:T.length>0&&T[0]&&(a=T[0])}return{type:"Default",value:a}}let n=M(t,"refConstraint");if(n){let s=De(n,"Identifier");return{type:"Reference",table:s[0]??"",column:s[1]??""}}let o=M(t,"checkConstraint");if(o){let s=M(o,"checkExpression");return{type:"Check",value:s?this.reconstructCheckExpression(s):""}}let i=M(t,"onDeleteConstraint");if(i){let s={Cascade:"CASCADE",Restrict:"RESTRICT",SetNull:"SET NULL",SetDefault:"SET DEFAULT",NoAction:"NO ACTION"};for(let[a,c]of Object.entries(s))if(i.children[a])return{type:"OnDelete",action:c}}return null}reconstructCheckExpression(t){let r=[];for(let n of Object.keys(t.children)){let o=t.children[n];if(o){for(let i of o)if("image"in i)r.push(i.image);else if("children"in i&&n==="checkExpression"){let s=this.reconstructCheckExpression(i);s&&r.push(`(${s})`)}}}return r.join(" ")}visitIndexDef(t){let r=[],n=M(t,"indexColumnList");if(n){let s=Ft(n,"indexColumn");for(let a of s){let c=nt(a,"TemplateIdentifier"),l=nt(a,"Identifier");r.push(c?c+l:l)}}let o=t.children.Unique!==void 0,i;return t.children.Gin&&(i="gin"),t.children.Gist&&(i="gist"),t.children.Btree&&(i="btree"),t.children.Hash&&(i="hash"),{type:"IndexDef",columns:r,unique:o,using:i}}visitCheckDef(t){let r=M(t,"checkExpression");return{type:"CheckDef",expression:r?this.reconstructCheckExpression(r):""}}visitTriggerDef(t){let r=De(t,"Identifier"),n=r[0]??"",o=r[1]??"",i=t.children.Before?"before":"after",s="update";t.children.Insert&&(s="insert"),t.children.Delete&&(s="delete");let a=t.children.Row?"row":"statement";return{type:"TriggerDef",name:n,timing:i,event:s,forEach:a,executeFunction:o}}visitInstantiation(t){let r=[],n=M(t,"instantiationTargetList");if(n){let a=Ft(n,"instantiationTarget");for(let c of a){let l=De(c,"Identifier");r.push({tableName:l[0]??"",alias:l[1]})}}let o=M(t,"conceptReference"),i="",s=[];if(o){i=nt(o,"Identifier");let a=M(o,"typeArgList");if(a){let c=Ft(a,"typeArg");for(let l of c){let u=De(l,"Identifier");s.push({tableName:u[0]??"",alias:u[1]})}}}return{type:"Instantiation",targets:r,conceptName:i,typeArgs:s}}visitPerInstanceIndex(t){let r=De(t,"Identifier"),n=r[0]??"",o=r.slice(1),i=t.children.Unique!==void 0,s;return t.children.Gin&&(s="gin"),t.children.Gist&&(s="gist"),t.children.Btree&&(s="btree"),t.children.Hash&&(s="hash"),{type:"PerInstanceIndex",tableName:n,columns:o,unique:i,using:s}}};function Bu(e){let t=Du(e),r=[];for(let s of t.errors)r.push({message:s.message,location:{start:{line:s.line??0,column:s.column??0,offset:s.offset},end:{line:s.line??0,column:s.column??0,offset:s.offset}},severity:"error"});if(r.length>0)return{ast:null,errors:r};Is.input=t.tokens;let n=Is.program();for(let s of Is.errors){let a=s.token;r.push({message:s.message,location:{start:{line:a.startLine??0,column:a.startColumn??0,offset:a.startOffset},end:{line:a.endLine??0,column:a.endColumn??0,offset:a.endOffset??a.startOffset}},severity:"error"})}return r.length>0?{ast:null,errors:r}:{ast:new Rs().visit(n),errors:r}}function ys(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function DT(){return{concepts:new Map,schemas:new Map,enums:new Map,tableToSchema:new Map,templateSubs:new Map,enumSql:[],tableSql:[],indexSql:[],triggerSql:[],extensionSql:[],functionSql:[],perInstanceIndexSql:[],generatedEnums:new Set,generatedTables:new Set}}function FT(e,t){for(let r of e.declarations)switch(r.type){case"ConceptDecl":t.concepts.set(r.name,r);break;case"SchemaDecl":t.schemas.set(r.name,r);break;case"EnumDecl":t.enums.set(r.name,r);break}}function Ls(e,t){let r=e.match(/^\{([^}]+)\}(.*)$/);if(r){let[,n,o]=r,i;for(let[s,a]of t.templateSubs)if(s===n){i=a;break}return(i??ys(n??""))+(o??"")}return e}function BT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ju(e,t){let r=e;for(let[n,o]of t.templateSubs){let i=BT(n),s=new RegExp(`\\{${i}\\}`,"g");r=r.replace(s,o)}return r=r.replace(/(\w+)::(\w+)/g,"'$2'::$1"),r}function Wu(e,t){let r=e.name;if(t.generatedEnums.has(r))return;t.generatedEnums.add(r);let n=e.values.map(o=>`'${o}'`).join(", ");t.enumSql.push(`DO $$ BEGIN
109
+ For further details.`);this.skipValidations=A(r,"skipValidations")?r.skipValidations:Tt.skipValidations}};Xr.DEFER_DEFINITION_ERRORS_HANDLING=!1;Du(Xr,[li,hi,gi,Ei,Ti,xi,Si,Ai,Ni,Ci]);var Qr=class extends Xr{constructor(t,r=Tt){let n=w(r);n.outputCst=!0,super(t,n)}};var wT=m({name:"WhiteSpace",pattern:/\s+/,group:H.SKIPPED}),DT=m({name:"LineComment",pattern:/\/\/[^\n]*/,group:H.SKIPPED}),FT=m({name:"BlockComment",pattern:/\/\*[\s\S]*?\*\//,group:H.SKIPPED}),p=m({name:"Identifier",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/}),Zr=m({name:"TemplateIdentifier",pattern:/\{[a-zA-Z_][a-zA-Z0-9_]*\}/}),Ri=m({name:"Concept",pattern:/concept/,longer_alt:p}),yi=m({name:"Schema",pattern:/schema/,longer_alt:p}),Li=m({name:"Mixin",pattern:/mixin/,longer_alt:p}),_i=m({name:"Enum",pattern:/enum/,longer_alt:p}),vi=m({name:"Extension",pattern:/extension/,longer_alt:p}),Mi=m({name:"Function",pattern:/function/,longer_alt:p}),bi=m({name:"Func",pattern:/func/,longer_alt:p}),ki=m({name:"Trigger",pattern:/trigger/,longer_alt:p}),Jr=m({name:"Index",pattern:/index/,longer_alt:p}),tn=m({name:"Check",pattern:/check/,longer_alt:p}),Pi=m({name:"Before",pattern:/before/,longer_alt:p}),Ui=m({name:"After",pattern:/after/,longer_alt:p}),wi=m({name:"Ondelete",pattern:/ondelete/,longer_alt:p}),Di=m({name:"On",pattern:/on/,longer_alt:p}),Fi=m({name:"Each",pattern:/each/,longer_alt:p}),Bi=m({name:"Row",pattern:/row/,longer_alt:p}),Gi=m({name:"Statement",pattern:/statement/,longer_alt:p}),$i=m({name:"Execute",pattern:/execute/,longer_alt:p}),ji=m({name:"Where",pattern:/where/,longer_alt:p}),Tr=m({name:"Unique",pattern:/unique/,longer_alt:p}),en=m({name:"Gin",pattern:/gin/,longer_alt:p}),rn=m({name:"Gist",pattern:/gist/,longer_alt:p}),nn=m({name:"Btree",pattern:/btree/,longer_alt:p}),on=m({name:"Hash",pattern:/hash/,longer_alt:p}),Wi=m({name:"Pkey",pattern:/pkey/,longer_alt:p}),Ki=m({name:"Nonull",pattern:/nonull/,longer_alt:p}),Hi=m({name:"Default",pattern:/default/,longer_alt:p}),qi=m({name:"Ref",pattern:/ref/,longer_alt:p}),zi=m({name:"Cascade",pattern:/cascade/,longer_alt:p}),Vi=m({name:"Restrict",pattern:/restrict/,longer_alt:p}),Yi=m({name:"SetNull",pattern:/setnull/,longer_alt:p}),Xi=m({name:"SetDefault",pattern:/setdefault/,longer_alt:p}),Qi=m({name:"NoAction",pattern:/noaction/,longer_alt:p}),Zi=m({name:"Update",pattern:/update/,longer_alt:p}),Ji=m({name:"Insert",pattern:/insert/,longer_alt:p}),to=m({name:"Delete",pattern:/delete/,longer_alt:p}),eo=m({name:"Return",pattern:/return/,longer_alt:p}),sn=m({name:"New",pattern:/NEW/,longer_alt:p}),an=m({name:"Old",pattern:/OLD/,longer_alt:p}),ro=m({name:"Serial",pattern:/serial/i,longer_alt:p}),no=m({name:"BigSerial",pattern:/bigserial/i,longer_alt:p}),io=m({name:"Integer",pattern:/integer/i,longer_alt:p}),oo=m({name:"Bigint",pattern:/bigint/i,longer_alt:p}),so=m({name:"SmallInt",pattern:/smallint/i,longer_alt:p}),ao=m({name:"Text",pattern:/text/i,longer_alt:p}),co=m({name:"Varchar",pattern:/varchar/i,longer_alt:p}),lo=m({name:"Char",pattern:/char/i,longer_alt:p}),uo=m({name:"Boolean",pattern:/boolean/i,longer_alt:p}),fo=m({name:"Timestamptz",pattern:/timestamptz/i,longer_alt:p}),ho=m({name:"Timestamp",pattern:/timestamp/i,longer_alt:p}),po=m({name:"Date",pattern:/date/i,longer_alt:p}),mo=m({name:"Time",pattern:/time/i,longer_alt:p}),go=m({name:"Jsonb",pattern:/jsonb/i,longer_alt:p}),Eo=m({name:"Json",pattern:/json/i,longer_alt:p}),xo=m({name:"Uuid",pattern:/uuid/i,longer_alt:p}),To=m({name:"Inet",pattern:/inet/i,longer_alt:p}),So=m({name:"Citext",pattern:/citext/i,longer_alt:p}),Ao=m({name:"Decimal",pattern:/decimal/i,longer_alt:p}),No=m({name:"Numeric",pattern:/numeric/i,longer_alt:p}),Oo=m({name:"Real",pattern:/real/i,longer_alt:p}),Io=m({name:"DoublePrecision",pattern:/double\s+precision/i,longer_alt:p}),Co=m({name:"Bytea",pattern:/bytea/i,longer_alt:p}),Ro=m({name:"StringLiteral",pattern:/'(?:[^'\\]|\\.)*'/}),cn=m({name:"NumberLiteral",pattern:/-?\d+(?:\.\d+)?/}),yo=m({name:"BooleanLiteral",pattern:/true|false/,longer_alt:p}),Lo=m({name:"NullLiteral",pattern:/null/i,longer_alt:p}),Ns=m({name:"Arrow",pattern:/->/}),_o=m({name:"DoubleColon",pattern:/::/}),Sr=m({name:"LBrace",pattern:/\{/}),Ar=m({name:"RBrace",pattern:/\}/}),St=m({name:"LParen",pattern:/\(/}),At=m({name:"RParen",pattern:/\)/}),vo=m({name:"LBracket",pattern:/\[/}),Mo=m({name:"RBracket",pattern:/\]/}),ln=m({name:"LAngle",pattern:/</}),un=m({name:"RAngle",pattern:/>/}),kt=m({name:"Semicolon",pattern:/;/}),Qt=m({name:"Comma",pattern:/,/}),fn=m({name:"Dot",pattern:/\./}),hn=m({name:"Equals",pattern:/=/}),Os=[wT,DT,FT,Ns,_o,Ri,yi,Li,_i,vi,Mi,bi,ki,Jr,tn,Pi,Ui,wi,Di,Fi,Bi,Gi,$i,ji,Tr,en,rn,nn,on,Wi,Ki,Hi,qi,Xi,Yi,zi,Vi,Qi,Zi,Ji,to,eo,sn,an,Io,fo,ho,no,ro,so,oo,io,co,lo,ao,uo,po,mo,go,Eo,xo,To,So,Ao,No,Oo,Co,Ro,cn,yo,Lo,Zr,p,Sr,Ar,St,At,vo,Mo,ln,un,kt,Qt,fn,hn],BT=new H(Os,{ensureOptimizations:!0});function Fu(e){return BT.tokenize(e)}var Rs=class extends Qr{constructor(){super(Os,{recoveryEnabled:!0,maxLookahead:3}),this.performSelfAnalysis()}anyIdentifier=this.RULE("anyIdentifier",()=>{this.OR([{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Ri)},{ALT:()=>this.CONSUME(yi)},{ALT:()=>this.CONSUME(Li)},{ALT:()=>this.CONSUME(_i)},{ALT:()=>this.CONSUME(vi)},{ALT:()=>this.CONSUME(bi)},{ALT:()=>this.CONSUME(ki)},{ALT:()=>this.CONSUME(Jr)},{ALT:()=>this.CONSUME(tn)},{ALT:()=>this.CONSUME(Pi)},{ALT:()=>this.CONSUME(Ui)},{ALT:()=>this.CONSUME(Di)},{ALT:()=>this.CONSUME(Fi)},{ALT:()=>this.CONSUME(Bi)},{ALT:()=>this.CONSUME(Gi)},{ALT:()=>this.CONSUME($i)},{ALT:()=>this.CONSUME(Mi)},{ALT:()=>this.CONSUME(eo)},{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(Zi)},{ALT:()=>this.CONSUME(Ji)},{ALT:()=>this.CONSUME(to)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(Wi)},{ALT:()=>this.CONSUME(Ki)},{ALT:()=>this.CONSUME(Hi)},{ALT:()=>this.CONSUME(qi)},{ALT:()=>this.CONSUME(wi)},{ALT:()=>this.CONSUME(zi)},{ALT:()=>this.CONSUME(Vi)},{ALT:()=>this.CONSUME(Yi)},{ALT:()=>this.CONSUME(Xi)},{ALT:()=>this.CONSUME(Qi)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)},{ALT:()=>this.CONSUME(ji)},{ALT:()=>this.CONSUME(ro)},{ALT:()=>this.CONSUME(no)},{ALT:()=>this.CONSUME(io)},{ALT:()=>this.CONSUME(oo)},{ALT:()=>this.CONSUME(so)},{ALT:()=>this.CONSUME(ao)},{ALT:()=>this.CONSUME(co)},{ALT:()=>this.CONSUME(lo)},{ALT:()=>this.CONSUME(uo)},{ALT:()=>this.CONSUME(fo)},{ALT:()=>this.CONSUME(ho)},{ALT:()=>this.CONSUME(po)},{ALT:()=>this.CONSUME(mo)},{ALT:()=>this.CONSUME(go)},{ALT:()=>this.CONSUME(Eo)},{ALT:()=>this.CONSUME(xo)},{ALT:()=>this.CONSUME(To)},{ALT:()=>this.CONSUME(So)},{ALT:()=>this.CONSUME(Ao)},{ALT:()=>this.CONSUME(No)},{ALT:()=>this.CONSUME(Oo)},{ALT:()=>this.CONSUME(Io)},{ALT:()=>this.CONSUME(Co)}])});program=this.RULE("program",()=>{this.MANY(()=>{this.SUBRULE(this.topLevelDeclaration)})});topLevelDeclaration=this.RULE("topLevelDeclaration",()=>{this.OR([{ALT:()=>this.SUBRULE(this.extensionDecl)},{ALT:()=>this.SUBRULE(this.functionDecl)},{ALT:()=>this.SUBRULE(this.conceptDecl)},{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)},{ALT:()=>this.SUBRULE(this.instantiation)},{ALT:()=>this.SUBRULE(this.perInstanceIndex)}])});extensionDecl=this.RULE("extensionDecl",()=>{this.CONSUME(vi),this.SUBRULE(this.anyIdentifier),this.CONSUME(kt)});functionDecl=this.RULE("functionDecl",()=>{this.CONSUME(bi),this.SUBRULE(this.anyIdentifier),this.CONSUME(St),this.CONSUME(At),this.CONSUME(Ns),this.SUBRULE2(this.anyIdentifier),this.SUBRULE(this.functionBody)});functionBody=this.RULE("functionBody",()=>{this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.functionStatement)}),this.CONSUME(Ar)});functionStatement=this.RULE("functionStatement",()=>{this.OR([{ALT:()=>this.SUBRULE(this.returnStatement)},{ALT:()=>this.SUBRULE(this.assignmentStatement)}])});returnStatement=this.RULE("returnStatement",()=>{this.CONSUME(eo),this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(kt)});assignmentStatement=this.RULE("assignmentStatement",()=>{this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(fn),this.SUBRULE(this.anyIdentifier),this.CONSUME(hn),this.SUBRULE(this.functionCallExpr),this.CONSUME(kt)});functionCallExpr=this.RULE("functionCallExpr",()=>{this.CONSUME(p),this.CONSUME(St),this.CONSUME(At)});conceptDecl=this.RULE("conceptDecl",()=>{this.CONSUME(Ri),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.typeParamList)}),this.CONSUME(Sr),this.MANY(()=>{this.OR([{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)}])}),this.CONSUME(Ar)});typeParamList=this.RULE("typeParamList",()=>{this.CONSUME(ln),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)}),this.CONSUME(un)});enumDecl=this.RULE("enumDecl",()=>{this.CONSUME(_i),this.SUBRULE(this.anyIdentifier),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE2(this.anyIdentifier),this.CONSUME(kt)}),this.CONSUME(Ar)});schemaDecl=this.RULE("schemaDecl",()=>{this.CONSUME(yi),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.mixinList)}),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.schemaBodyItem)}),this.CONSUME(Ar)});mixinList=this.RULE("mixinList",()=>{this.CONSUME(Li),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)})});schemaBodyItem=this.RULE("schemaBodyItem",()=>{this.OR([{ALT:()=>this.SUBRULE(this.indexDef)},{ALT:()=>this.SUBRULE(this.checkDef)},{ALT:()=>this.SUBRULE(this.triggerDef)},{ALT:()=>this.SUBRULE(this.columnDef)}])});columnDef=this.RULE("columnDef",()=>{this.SUBRULE(this.columnName),this.SUBRULE(this.dataType),this.MANY(()=>{this.SUBRULE(this.columnConstraint)}),this.CONSUME(kt)});columnName=this.RULE("columnName",()=>{this.OR([{ALT:()=>{this.CONSUME(Zr),this.OPTION(()=>{this.CONSUME(p)})}},{ALT:()=>this.CONSUME2(p)}])});dataType=this.RULE("dataType",()=>{this.OR([{ALT:()=>this.CONSUME(ro)},{ALT:()=>this.CONSUME(no)},{ALT:()=>this.CONSUME(io)},{ALT:()=>this.CONSUME(oo)},{ALT:()=>this.CONSUME(so)},{ALT:()=>this.CONSUME(ao)},{ALT:()=>this.CONSUME(co)},{ALT:()=>this.CONSUME(lo)},{ALT:()=>this.CONSUME(uo)},{ALT:()=>this.CONSUME(fo)},{ALT:()=>this.CONSUME(ho)},{ALT:()=>this.CONSUME(po)},{ALT:()=>this.CONSUME(mo)},{ALT:()=>this.CONSUME(go)},{ALT:()=>this.CONSUME(Eo)},{ALT:()=>this.CONSUME(xo)},{ALT:()=>this.CONSUME(To)},{ALT:()=>this.CONSUME(So)},{ALT:()=>this.CONSUME(Ao)},{ALT:()=>this.CONSUME(No)},{ALT:()=>this.CONSUME(Oo)},{ALT:()=>this.CONSUME(Io)},{ALT:()=>this.CONSUME(Co)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME(St),this.CONSUME(cn),this.CONSUME(At)})});columnConstraint=this.RULE("columnConstraint",()=>{this.OR([{ALT:()=>this.CONSUME(Wi)},{ALT:()=>this.CONSUME(Ki)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.SUBRULE(this.defaultConstraint)},{ALT:()=>this.SUBRULE(this.refConstraint)},{ALT:()=>this.SUBRULE(this.checkConstraint)},{ALT:()=>this.SUBRULE(this.onDeleteConstraint)}])});defaultConstraint=this.RULE("defaultConstraint",()=>{this.CONSUME(Hi),this.CONSUME(St),this.SUBRULE(this.defaultValue),this.CONSUME(At)});defaultValue=this.RULE("defaultValue",()=>{this.OR([{ALT:()=>this.CONSUME(Ro)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.CONSUME(Lo)},{ALT:()=>this.SUBRULE(this.functionCallExpr)},{ALT:()=>{this.SUBRULE(this.anyIdentifier),this.CONSUME(_o),this.SUBRULE2(this.anyIdentifier)}},{ALT:()=>this.SUBRULE3(this.anyIdentifier)}])});refConstraint=this.RULE("refConstraint",()=>{this.CONSUME(qi),this.CONSUME(St),this.CONSUME(p),this.CONSUME(fn),this.CONSUME2(p),this.CONSUME(At)});checkConstraint=this.RULE("checkConstraint",()=>{this.CONSUME(tn),this.CONSUME(St),this.SUBRULE(this.checkExpression),this.CONSUME(At)});checkExpression=this.RULE("checkExpression",()=>{this.MANY(()=>{this.OR([{ALT:()=>{this.CONSUME(St),this.SUBRULE(this.checkExpression),this.CONSUME(At)}},{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ro)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.CONSUME(Lo)},{ALT:()=>this.CONSUME(_o)},{ALT:()=>this.CONSUME(hn)},{ALT:()=>this.CONSUME(Qt)},{ALT:()=>this.CONSUME(fn)},{ALT:()=>this.CONSUME(ln)},{ALT:()=>this.CONSUME(un)}])})});onDeleteConstraint=this.RULE("onDeleteConstraint",()=>{this.CONSUME(wi),this.CONSUME(St),this.OR([{ALT:()=>this.CONSUME(zi)},{ALT:()=>this.CONSUME(Vi)},{ALT:()=>this.CONSUME(Yi)},{ALT:()=>this.CONSUME(Xi)},{ALT:()=>this.CONSUME(Qi)}]),this.CONSUME(At)});indexDef=this.RULE("indexDef",()=>{this.CONSUME(Jr),this.CONSUME(St),this.SUBRULE(this.indexColumnList),this.CONSUME(At),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.OPTION(()=>{this.SUBRULE(this.whereClause)}),this.CONSUME(kt)});whereClause=this.RULE("whereClause",()=>{this.CONSUME(ji),this.CONSUME(St),this.SUBRULE(this.checkExpression),this.CONSUME(At)});indexColumnList=this.RULE("indexColumnList",()=>{this.SUBRULE(this.indexColumn),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.indexColumn)})});indexColumn=this.RULE("indexColumn",()=>{this.OR([{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME2(p)})});checkDef=this.RULE("checkDef",()=>{this.CONSUME(tn),this.CONSUME(St),this.SUBRULE(this.checkExpression),this.CONSUME(At),this.CONSUME(kt)});triggerDef=this.RULE("triggerDef",()=>{this.CONSUME(ki),this.CONSUME(p),this.OR([{ALT:()=>this.CONSUME(Pi)},{ALT:()=>this.CONSUME(Ui)}]),this.OR2([{ALT:()=>this.CONSUME(Zi)},{ALT:()=>this.CONSUME(Ji)},{ALT:()=>this.CONSUME(to)}]),this.CONSUME(Di),this.CONSUME(Fi),this.OR3([{ALT:()=>this.CONSUME(Bi)},{ALT:()=>this.CONSUME(Gi)}]),this.CONSUME($i),this.CONSUME(Mi),this.CONSUME2(p),this.CONSUME(St),this.CONSUME(At),this.CONSUME(kt)});instantiation=this.RULE("instantiation",()=>{this.SUBRULE(this.instantiationTargetList),this.CONSUME(hn),this.SUBRULE(this.conceptReference),this.CONSUME(kt)});instantiationTargetList=this.RULE("instantiationTargetList",()=>{this.SUBRULE(this.instantiationTarget),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.instantiationTarget)})});instantiationTarget=this.RULE("instantiationTarget",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(vo),this.CONSUME2(p),this.CONSUME(Mo)})});conceptReference=this.RULE("conceptReference",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(ln),this.SUBRULE(this.typeArgList),this.CONSUME(un)})});typeArgList=this.RULE("typeArgList",()=>{this.SUBRULE(this.typeArg),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.typeArg)})});typeArg=this.RULE("typeArg",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(vo),this.CONSUME2(p),this.CONSUME(Mo)})});perInstanceIndex=this.RULE("perInstanceIndex",()=>{this.CONSUME(Jr),this.CONSUME(St),this.CONSUME(p),this.CONSUME(Qt),this.CONSUME2(p),this.MANY(()=>{this.CONSUME2(Qt),this.CONSUME3(p)}),this.CONSUME(At),this.MANY2(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.OPTION(()=>{this.SUBRULE(this.whereClause)}),this.CONSUME(kt)})},Is=new Rs;function nt(e,t){let r=e.children[t];if(r&&r.length>0){let n=r[0];if(n&&"image"in n)return n.image}return""}function De(e,t){let r=e.children[t];return r?r.map(n=>"image"in n?n.image:"").filter(n=>n!==""):[]}function M(e,t){let n=e.children[t]?.[0];if(n&&"children"in n)return n}function Ft(e,t){let r=e.children[t];return r?r.filter(n=>"children"in n):[]}function Bu(e){let r=Ft(e,"anyIdentifier")[0];if(r)for(let n of Object.keys(r.children)){let o=r.children[n]?.[0];if(o&&"image"in o)return o.image}return""}function Cs(e){let t=Ft(e,"anyIdentifier"),r=[];for(let n of t)for(let i of Object.keys(n.children)){let s=n.children[i]?.[0];if(s&&"image"in s){r.push(s.image);break}}return r}var ys=class{visit(t){let r=[],n=Ft(t,"topLevelDeclaration");for(let i of n){let o=this.visitTopLevelDeclaration(i);o&&r.push(o)}return{type:"Program",declarations:r}}visitTopLevelDeclaration(t){let r=M(t,"extensionDecl");if(r)return this.visitExtensionDecl(r);let n=M(t,"functionDecl");if(n)return this.visitFunctionDecl(n);let i=M(t,"conceptDecl");if(i)return this.visitConceptDecl(i);let o=M(t,"enumDecl");if(o)return this.visitEnumDecl(o);let s=M(t,"schemaDecl");if(s)return this.visitSchemaDecl(s);let a=M(t,"instantiation");if(a)return this.visitInstantiation(a);let c=M(t,"perInstanceIndex");return c?this.visitPerInstanceIndex(c):null}visitExtensionDecl(t){return{type:"ExtensionDecl",name:Bu(t)}}visitFunctionDecl(t){let r=Cs(t),n=r[0]??"",i=r[1]??"",o=M(t,"functionBody"),s="";if(o){let a=Ft(o,"functionStatement"),c=[];for(let l of a){let u=M(l,"returnStatement");if(u){let h=nt(u,"Identifier");h||(h=nt(u,"New")),h||(h=nt(u,"Old")),c.push(`RETURN ${h};`)}let f=M(l,"assignmentStatement");if(f){let h=nt(f,"Identifier");h||(h=nt(f,"New")),h||(h=nt(f,"Old"));let g=Bu(f),T=M(f,"functionCallExpr"),I=T?nt(T,"Identifier"):"";c.push(`${h}.${g} := ${I}();`)}}s=c.join(`
110
+ `)}return{type:"FunctionDecl",name:n,returnType:i,body:s}}visitConceptDecl(t){let r=nt(t,"Identifier"),n=[],i=M(t,"typeParamList");i&&n.push(...De(i,"Identifier"));let o=[],s=Ft(t,"schemaDecl");for(let c of s){let l=this.visitSchemaDecl(c);l.conceptScope=r,o.push(l)}let a=Ft(t,"enumDecl");for(let c of a){let l=this.visitEnumDecl(c);l.conceptScope=r,o.push(l)}return{type:"ConceptDecl",name:r,typeParams:n,members:o}}visitEnumDecl(t){let r=Cs(t),n=r[0]??"",i=r.slice(1);return{type:"EnumDecl",name:n,values:i}}visitSchemaDecl(t){let r=nt(t,"Identifier"),n=[],i=M(t,"mixinList");i&&n.push(...De(i,"Identifier"));let o=[],s=Ft(t,"schemaBodyItem");for(let a of s){let c=this.visitSchemaBodyItem(a);c&&o.push(c)}return{type:"SchemaDecl",name:r,mixins:n,members:o}}visitSchemaBodyItem(t){let r=M(t,"columnDef");if(r)return this.visitColumnDef(r);let n=M(t,"indexDef");if(n)return this.visitIndexDef(n);let i=M(t,"checkDef");if(i)return this.visitCheckDef(i);let o=M(t,"triggerDef");return o?this.visitTriggerDef(o):null}visitColumnDef(t){let r=M(t,"columnName"),n="";if(r){let c=nt(r,"TemplateIdentifier"),l=nt(r,"Identifier");n=c?c+l:l}let i=M(t,"dataType"),o="";if(i){for(let u of Object.keys(i.children)){let h=i.children[u]?.[0];if(h&&"image"in h){o=h.image;break}}let l=i.children.NumberLiteral?.[0];l&&"image"in l&&(o+=`(${l.image})`)}let s=[],a=Ft(t,"columnConstraint");for(let c of a){let l=this.visitColumnConstraint(c);l&&s.push(l)}return{type:"ColumnDef",name:n,dataType:o,constraints:s}}visitColumnConstraint(t){if(t.children.Pkey)return{type:"PrimaryKey"};if(t.children.Nonull)return{type:"NotNull"};if(t.children.Unique)return{type:"Unique"};let r=M(t,"defaultConstraint");if(r){let s=M(r,"defaultValue"),a="";if(s){let c=nt(s,"StringLiteral"),l=nt(s,"NumberLiteral"),u=nt(s,"BooleanLiteral"),f=nt(s,"NullLiteral"),h=M(s,"functionCallExpr"),g=nt(s,"DoubleColon"),T=Cs(s);c?a=c:l?a=l:u?a=u:f?a=f:h?a=nt(h,"Identifier")+"()":g&&T.length===2&&T[0]&&T[1]?a=`${T[0]}::${T[1]}`:T.length>0&&T[0]&&(a=T[0])}return{type:"Default",value:a}}let n=M(t,"refConstraint");if(n){let s=De(n,"Identifier");return{type:"Reference",table:s[0]??"",column:s[1]??""}}let i=M(t,"checkConstraint");if(i){let s=M(i,"checkExpression");return{type:"Check",value:s?this.reconstructCheckExpression(s):""}}let o=M(t,"onDeleteConstraint");if(o){let s={Cascade:"CASCADE",Restrict:"RESTRICT",SetNull:"SET NULL",SetDefault:"SET DEFAULT",NoAction:"NO ACTION"};for(let[a,c]of Object.entries(s))if(o.children[a])return{type:"OnDelete",action:c}}return null}reconstructCheckExpression(t){let r=[];for(let i of Object.keys(t.children)){let o=t.children[i];if(o){for(let s of o)if("image"in s&&"startOffset"in s){let a=typeof s.startOffset=="number"?s.startOffset:0;r.push({image:s.image,startOffset:a,isParenExpr:!1})}else if("children"in s&&i==="checkExpression"){let a=this.reconstructCheckExpression(s);if(a){let c=1/0;for(let l of Object.keys(s.children)){let u=s.children[l];if(u)for(let f of u)"startOffset"in f&&typeof f.startOffset=="number"&&(c=Math.min(c,f.startOffset))}r.push({image:a,startOffset:c===1/0?0:c,isParenExpr:!1})}}}}r.sort((i,o)=>i.startOffset-o.startOffset);let n="";for(let i=0;i<r.length;i++){let o=r[i],s=i>0?r[i-1]:null;if(!o)continue;let a=o.image,c=[")",",",".","::",">","<"],l=["(",".","::"];if(s&&!o.isParenExpr){let u=s.image,f=u[u.length-1]??"",h=(u===">"||u==="<")&&a==="=",g=(a===">"||a==="<")&&!l.includes(u)&&f!=="(";(!c.includes(a)&&!l.includes(u)&&f!=="("&&!h||g)&&(n+=" ")}else if(s&&o.isParenExpr){let u=s.image;(u[u.length-1]??"")!=="("&&(n+=" ")}n+=a}return n}visitIndexDef(t){let r=[],n=M(t,"indexColumnList");if(n){let c=Ft(n,"indexColumn");for(let l of c){let u=nt(l,"TemplateIdentifier"),f=nt(l,"Identifier");r.push(u?u+f:f)}}let i=t.children.Unique!==void 0,o;t.children.Gin&&(o="gin"),t.children.Gist&&(o="gist"),t.children.Btree&&(o="btree"),t.children.Hash&&(o="hash");let s,a=M(t,"whereClause");if(a){let c=M(a,"checkExpression");c&&(s=this.reconstructCheckExpression(c))}return{type:"IndexDef",columns:r,unique:i,using:o,where:s}}visitCheckDef(t){let r=M(t,"checkExpression");return{type:"CheckDef",expression:r?this.reconstructCheckExpression(r):""}}visitTriggerDef(t){let r=De(t,"Identifier"),n=r[0]??"",i=r[1]??"",o=t.children.Before?"before":"after",s="update";t.children.Insert&&(s="insert"),t.children.Delete&&(s="delete");let a=t.children.Row?"row":"statement";return{type:"TriggerDef",name:n,timing:o,event:s,forEach:a,executeFunction:i}}visitInstantiation(t){let r=[],n=M(t,"instantiationTargetList");if(n){let a=Ft(n,"instantiationTarget");for(let c of a){let l=De(c,"Identifier");r.push({tableName:l[0]??"",alias:l[1]})}}let i=M(t,"conceptReference"),o="",s=[];if(i){o=nt(i,"Identifier");let a=M(i,"typeArgList");if(a){let c=Ft(a,"typeArg");for(let l of c){let u=De(l,"Identifier");s.push({tableName:u[0]??"",alias:u[1]})}}}return{type:"Instantiation",targets:r,conceptName:o,typeArgs:s}}visitPerInstanceIndex(t){let r=De(t,"Identifier"),n=r[0]??"",i=r.slice(1),o=t.children.Unique!==void 0,s;t.children.Gin&&(s="gin"),t.children.Gist&&(s="gist"),t.children.Btree&&(s="btree"),t.children.Hash&&(s="hash");let a,c=M(t,"whereClause");if(c){let l=M(c,"checkExpression");l&&(a=this.reconstructCheckExpression(l))}return{type:"PerInstanceIndex",tableName:n,columns:i,unique:o,using:s,where:a}}};function Gu(e){let t=Fu(e),r=[];for(let s of t.errors)r.push({message:s.message,location:{start:{line:s.line??0,column:s.column??0,offset:s.offset},end:{line:s.line??0,column:s.column??0,offset:s.offset}},severity:"error"});if(r.length>0)return{ast:null,errors:r};Is.input=t.tokens;let n=Is.program();for(let s of Is.errors){let a=s.token;r.push({message:s.message,location:{start:{line:a.startLine??0,column:a.startColumn??0,offset:a.startOffset},end:{line:a.endLine??0,column:a.endColumn??0,offset:a.endOffset??a.startOffset}},severity:"error"})}return r.length>0?{ast:null,errors:r}:{ast:new ys().visit(n),errors:r}}function Ls(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function Wu(e){return e.includes("::")?e.replace(/(\w+)::(\w+)/g,"'$2'::$1"):e}function GT(e,t){return e==="NULL"||/^'[^']*'::\w+$/.test(e)?e:e.includes("::")?Wu(e):`'${e}'::${t}`}function $T(){return{concepts:new Map,schemas:new Map,enums:new Map,tableToSchema:new Map,templateSubs:new Map,enumSql:[],tableSql:[],indexSql:[],triggerSql:[],extensionSql:[],functionSql:[],perInstanceIndexSql:[],generatedEnums:new Set,generatedTables:new Set}}function jT(e,t){for(let r of e.declarations)switch(r.type){case"ConceptDecl":t.concepts.set(r.name,r);break;case"SchemaDecl":t.schemas.set(r.name,r);break;case"EnumDecl":t.enums.set(r.name,r);break}}function Ku(e,t){let r=e.match(/^\{([^}]+)\}(.*)$/);if(r){let[,n,i]=r,o;for(let[s,a]of t.templateSubs)if(s===n){o=a;break}return(o??Ls(n??""))+(i??"")}return e}function WT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _s(e,t){let r=e;for(let[n,i]of t.templateSubs){let o=WT(n),s=new RegExp(`\\{${o}\\}`,"g");r=r.replace(s,i)}return r=Wu(r),r}function Hu(e,t){let r=e.name;if(t.generatedEnums.has(r))return;t.generatedEnums.add(r),t.enums.set(r,e);let n=e.values.map(i=>`'${i}'`).join(", ");t.enumSql.push(`DO $$ BEGIN
111
111
  CREATE TYPE ${r} AS ENUM (${n});
112
112
  EXCEPTION
113
113
  WHEN duplicate_object THEN null;
114
- END $$;`)}function GT(e,t){let r=Ls(e.name,t),n=e.dataType.toUpperCase(),o=[` ${r} ${n}`],i=[];for(let s of e.constraints)switch(s.type){case"PrimaryKey":o.push("PRIMARY KEY");break;case"NotNull":o.push("NOT NULL");break;case"Unique":o.push("UNIQUE");break;case"Default":o.push(`DEFAULT ${s.value??"NULL"}`);break;case"Reference":{let a=s.table??"";t.tableToSchema.has(a)&&(a=t.tableToSchema.get(a)??a),i.push(`REFERENCES ${a}(${s.column??"id"})`);break}case"Check":o.push(`CHECK (${ju(s.value??"",t)})`);break;case"OnDelete":i.push(`ON DELETE ${s.action??"NO ACTION"}`);break}return[...o,...i].join(" ")}function $T(e,t,r){let n=t.columns.map(c=>Ls(c,r)).join(", "),o=t.columns.map(c=>Ls(c,r)).join("_"),i=`idx_${e}_${o}`,s=t.unique===!0?"UNIQUE ":"",a=t.using?`USING ${t.using} `:"";return`CREATE ${s}INDEX ${i} ON ${e} ${a}(${n});`}function jT(e,t,r){return` CHECK (${ju(t.expression,r)})`}function WT(e,t,r){let n=t.timing.toUpperCase(),o=t.event.toUpperCase(),i=t.forEach==="row"?"FOR EACH ROW":"FOR EACH STATEMENT";return`CREATE TRIGGER ${t.name}_${e}
115
- ${n} ${o} ON ${e}
116
- ${i} EXECUTE FUNCTION ${t.executeFunction}();`}function Ku(e,t){let r=[];for(let n of e.mixins){let o=t.schemas.get(n);o&&r.push(...Ku(o,t))}return r.push(...e.members),r}function Gu(e,t,r){let n=Ku(e,r),o=[],i=[],s=[],a=[];for(let c of n)switch(c.type){case"ColumnDef":o.push(c);break;case"IndexDef":i.push(c);break;case"CheckDef":s.push(c);break;case"TriggerDef":a.push(c);break}return{tableName:t,columns:o,indexes:i,checks:s,triggers:a}}function $u(e,t){if(t.generatedTables.has(e.tableName))return;t.generatedTables.add(e.tableName);let r=e.columns.map(s=>GT(s,t)),n=e.checks.map(s=>jT(e.tableName,s,t)),i=[...r,...n].join(`,
114
+ END $$;`)}function KT(e,t){let r=Ku(e.name,t),n=e.dataType.toUpperCase(),i=[` ${r} ${n}`],o=[];for(let s of e.constraints)switch(s.type){case"PrimaryKey":i.push("PRIMARY KEY");break;case"NotNull":i.push("NOT NULL");break;case"Unique":i.push("UNIQUE");break;case"Default":{let a=s.value??"NULL",c=e.dataType.toLowerCase();t.enums.has(c)&&(a=GT(a,c)),i.push(`DEFAULT ${a}`);break}case"Reference":{let a=s.table??"";t.tableToSchema.has(a)&&(a=t.tableToSchema.get(a)??a),o.push(`REFERENCES ${a}(${s.column??"id"})`);break}case"Check":i.push(`CHECK (${_s(s.value??"",t)})`);break;case"OnDelete":o.push(`ON DELETE ${s.action??"NO ACTION"}`);break}return[...i,...o].join(" ")}function qu(e,t,r){let n=t.columns.map(u=>Ku(u,r)),i=n.join(", "),o=n.join("_"),s=`idx_${e}_${o}`,a=t.unique===!0?"UNIQUE ":"",c=t.using?`USING ${t.using} `:"",l=t.where?` WHERE (${_s(t.where,r)})`:"";return`CREATE ${a}INDEX ${s} ON ${e} ${c}(${i})${l};`}function HT(e,t,r){return` CHECK (${_s(t.expression,r)})`}function qT(e,t,r){let n=t.timing.toUpperCase(),i=t.event.toUpperCase(),o=t.forEach==="row"?"FOR EACH ROW":"FOR EACH STATEMENT";return`CREATE TRIGGER ${t.name}_${e}
115
+ ${n} ${i} ON ${e}
116
+ ${o} EXECUTE FUNCTION ${t.executeFunction}();`}function zu(e,t){let r=[];for(let n of e.mixins){let i=t.schemas.get(n);i&&r.push(...zu(i,t))}return r.push(...e.members),r}function $u(e,t,r){let n=zu(e,r),i=[],o=[],s=[],a=[];for(let c of n)switch(c.type){case"ColumnDef":i.push(c);break;case"IndexDef":o.push(c);break;case"CheckDef":s.push(c);break;case"TriggerDef":a.push(c);break}return{tableName:t,columns:i,indexes:o,checks:s,triggers:a}}function ju(e,t){if(t.generatedTables.has(e.tableName))return;t.generatedTables.add(e.tableName);let r=e.columns.map(s=>KT(s,t)),n=e.checks.map(s=>HT(e.tableName,s,t)),o=[...r,...n].join(`,
117
117
  `);t.tableSql.push(`CREATE TABLE ${e.tableName} (
118
- ${i}
119
- );`);for(let s of e.indexes)t.indexSql.push($T(e.tableName,s,t));for(let s of e.triggers)t.triggerSql.push(WT(e.tableName,s,t))}function KT(e,t){t.extensionSql.push(`CREATE EXTENSION IF NOT EXISTS "${e.name}";`)}function HT(e,t){t.functionSql.push(`CREATE OR REPLACE FUNCTION ${e.name}()
118
+ ${o}
119
+ );`);for(let s of e.indexes)t.indexSql.push(qu(e.tableName,s,t));for(let s of e.triggers)t.triggerSql.push(qT(e.tableName,s,t))}function zT(e,t){t.extensionSql.push(`CREATE EXTENSION IF NOT EXISTS "${e.name}";`)}function VT(e,t){t.functionSql.push(`CREATE OR REPLACE FUNCTION ${e.name}()
120
120
  RETURNS TRIGGER AS $$
121
121
  BEGIN
122
122
  ${e.body}
123
123
  END;
124
- $$ LANGUAGE plpgsql;`)}function qT(e,t){Wu(e,t)}function zT(e,t){t.schemas.set(e.name,e)}function VT(e,t){let r=t.concepts.get(e.conceptName);if(!r){let s=t.schemas.get(e.conceptName);if(s){let a=e.targets[0];if(a){let c=a.tableName;t.tableToSchema.set(s.name,c);let l=Gu(s,c,t);$u(l,t)}}return}t.templateSubs.clear();for(let s=0;s<r.typeParams.length;s++){let a=r.typeParams[s],c=e.typeArgs[s];a&&c&&(t.templateSubs.set(a,c.alias??ys(a)),t.tableToSchema.set(a,c.tableName))}let n=r.members.filter(s=>s.type==="SchemaDecl"),o=new Map;for(let s=0;s<e.targets.length&&s<n.length;s++){let a=e.targets[s],c=n[s];a&&c&&(o.set(c.name,{name:a.tableName,alias:a.alias}),t.tableToSchema.set(c.name,a.tableName),a.alias?t.templateSubs.set(c.name,a.alias):t.templateSubs.set(c.name,ys(c.name)))}let i=r.members.filter(s=>s.type==="EnumDecl");for(let s of i)Wu(s,t);for(let s of n){let a=o.get(s.name);if(a){let c=Gu(s,a.name,t);$u(c,t)}}}function YT(e,t){let r=e.columns.join(", "),n=`idx_${e.tableName}_${e.columns.join("_")}`,o=e.unique===!0?"UNIQUE ":"",i=e.using?`USING ${e.using} `:"";t.perInstanceIndexSql.push(`CREATE ${o}INDEX ${n} ON ${e.tableName} ${i}(${r});`)}function Hu(e){let t=DT();FT(e,t);for(let o of e.declarations)XT(o,t);let r=[];t.extensionSql.length>0&&r.push(t.extensionSql.join(`
124
+ $$ LANGUAGE plpgsql;`)}function YT(e,t){Hu(e,t)}function XT(e,t){t.schemas.set(e.name,e)}function QT(e,t){let r=t.concepts.get(e.conceptName);if(!r){let s=t.schemas.get(e.conceptName);if(s){let a=e.targets[0];if(a){let c=a.tableName;t.tableToSchema.set(s.name,c);let l=$u(s,c,t);ju(l,t)}}return}t.templateSubs.clear();for(let s=0;s<r.typeParams.length;s++){let a=r.typeParams[s],c=e.typeArgs[s];a&&c&&(t.templateSubs.set(a,c.alias??Ls(a)),t.tableToSchema.set(a,c.tableName))}let n=r.members.filter(s=>s.type==="SchemaDecl"),i=new Map;for(let s=0;s<e.targets.length&&s<n.length;s++){let a=e.targets[s],c=n[s];a&&c&&(i.set(c.name,{name:a.tableName,alias:a.alias}),t.tableToSchema.set(c.name,a.tableName),a.alias?t.templateSubs.set(c.name,a.alias):t.templateSubs.set(c.name,Ls(c.name)))}let o=r.members.filter(s=>s.type==="EnumDecl");for(let s of o)Hu(s,t);for(let s of n){let a=i.get(s.name);if(a){let c=$u(s,a.name,t);ju(c,t)}}}function ZT(e,t){let r={type:"IndexDef",columns:e.columns,unique:e.unique,using:e.using,where:e.where};t.perInstanceIndexSql.push(qu(e.tableName,r,t))}function Vu(e){let t=$T();jT(e,t);for(let i of e.declarations)JT(i,t);let r=[];t.extensionSql.length>0&&r.push(t.extensionSql.join(`
125
125
 
126
126
  `)),t.functionSql.length>0&&r.push(t.functionSql.join(`
127
127
 
128
128
  `)),t.enumSql.length>0&&r.push(t.enumSql.join(`
129
129
 
130
- `));let n=[];for(let o of t.tableSql){o&&n.push(o);let i=o.match(/CREATE TABLE (\w+)/);if(i){let s=i[1]??"";for(let a of t.indexSql)a.includes(` ON ${s} `)&&n.push(a);for(let a of t.triggerSql)a.includes(` ON ${s}`)&&n.push(a)}}return n.length>0&&r.push(n.join(`
130
+ `));let n=[];for(let i of t.tableSql){i&&n.push(i);let o=i.match(/CREATE TABLE (\w+)/);if(o){let s=o[1]??"";for(let a of t.indexSql)a.includes(` ON ${s} `)&&n.push(a);for(let a of t.triggerSql)a.includes(` ON ${s}`)&&n.push(a)}}return n.length>0&&r.push(n.join(`
131
131
 
132
132
  `)),t.perInstanceIndexSql.length>0&&r.push(t.perInstanceIndexSql.join(`
133
133
 
@@ -136,7 +136,7 @@ $$ LANGUAGE plpgsql;`)}function qT(e,t){Wu(e,t)}function zT(e,t){t.schemas.set(e
136
136
  `+r.join(`
137
137
 
138
138
  `)+`
139
- `}function XT(e,t){switch(e.type){case"ExtensionDecl":KT(e,t);break;case"FunctionDecl":HT(e,t);break;case"EnumDecl":qT(e,t);break;case"SchemaDecl":zT(e,t);break;case"ConceptDecl":break;case"Instantiation":VT(e,t);break;case"PerInstanceIndex":YT(e,t);break}}function qu(e){let t=[],r=Bu(e);if(r.errors.length>0)return{success:!1,errors:r.errors,ast:r.ast??void 0};if(!r.ast)return t.push({message:"Failed to parse source code",severity:"error"}),{success:!1,errors:t};try{return{success:!0,sql:Hu(r.ast),errors:[],ast:r.ast}}catch(n){let o=n instanceof Error?n.message:String(n);return t.push({message:`Code generation failed: ${o}`,severity:"error"}),{success:!1,errors:t,ast:r.ast}}}var nS=tS(rS(import.meta.url)),oS=JSON.parse(Vu(eS(nS,"..","package.json"),"utf-8")),iS=oS.version,Mi=`
139
+ `}function JT(e,t){switch(e.type){case"ExtensionDecl":zT(e,t);break;case"FunctionDecl":VT(e,t);break;case"EnumDecl":YT(e,t);break;case"SchemaDecl":XT(e,t);break;case"ConceptDecl":break;case"Instantiation":QT(e,t);break;case"PerInstanceIndex":ZT(e,t);break}}function Yu(e){let t=[],r=Gu(e);if(r.errors.length>0)return{success:!1,errors:r.errors,ast:r.ast??void 0};if(!r.ast)return t.push({message:"Failed to parse source code",severity:"error"}),{success:!1,errors:t};try{return{success:!0,sql:Vu(r.ast),errors:[],ast:r.ast}}catch(n){let i=n instanceof Error?n.message:String(n);return t.push({message:`Code generation failed: ${i}`,severity:"error"}),{success:!1,errors:t,ast:r.ast}}}var sS=nS(oS(import.meta.url)),aS=JSON.parse(Qu(iS(sS,"..","package.json"),"utf-8")),cS=aS.version,bo=`
140
140
  GSQL - Generic SQL Compiler
141
141
  Parametric polymorphism for SQL schemas
142
142
 
@@ -158,7 +158,7 @@ Examples:
158
158
  gsql compile schema.gsql
159
159
  gsql compile schema.gsql -o schema.sql
160
160
  gsql compile schema.gsql > schema.sql
161
- `,_s=class{constructor(t){this.args=t}index=0;current(){return this.args[this.index]}next(){return this.index++,this.args[this.index]}advance(){this.index++}hasMore(){return this.index<this.args.length}};function sS(e){let t={command:"",inputFile:"",outputFile:null,verbose:!1,help:!1,version:!1},r=new _s(e);for(;r.hasMore();){let n=r.current();if(!n){r.advance();continue}if(n==="-h"||n==="--help")t.help=!0;else if(n==="--version")t.version=!0;else if(n==="-v"||n==="--verbose")t.verbose=!0;else if(n==="-o"||n==="--output"){let o=r.next();o&&(t.outputFile=o)}else n.startsWith("-")||(t.command?t.inputFile||(t.inputFile=n):t.command=n);r.advance()}return t}function aS(e,t,r){let n=`Error: ${e}`;return t!==void 0&&r!==void 0&&(n=`Error [${t}:${r}]: ${e}`),n}function cS(){let e=process.argv.slice(2),t=sS(e);t.help&&(console.log(Mi),process.exit(0)),t.version&&(console.log(`gsql version ${iS}`),process.exit(0)),t.command||(console.error("Error: No command specified"),console.log(Mi),process.exit(1)),t.command!=="compile"&&(console.error(`Error: Unknown command '${t.command}'`),console.log(Mi),process.exit(1)),t.inputFile||(console.error("Error: No input file specified"),console.log(Mi),process.exit(1));let r=zu(process.cwd(),t.inputFile);ZT(r)||(console.error(`Error: File not found: ${t.inputFile}`),process.exit(1));let n;try{n=Vu(r,"utf-8")}catch(i){let s=i instanceof Error?i.message:String(i);console.error(`Error reading file: ${s}`),process.exit(1)}t.verbose&&console.error(`Compiling ${JT(r)}...`);let o=qu(n);if(!o.success){for(let i of o.errors)console.error(aS(i.message,i.location?.start.line,i.location?.start.column));process.exit(1)}if(t.outputFile){let i=zu(process.cwd(),t.outputFile);try{QT(i,o.sql??""),t.verbose&&console.error(`Output written to ${t.outputFile}`)}catch(s){let a=s instanceof Error?s.message:String(s);console.error(`Error writing file: ${a}`),process.exit(1)}}else console.log(o.sql)}cS();
161
+ `,vs=class{constructor(t){this.args=t}index=0;current(){return this.args[this.index]}next(){return this.index++,this.args[this.index]}advance(){this.index++}hasMore(){return this.index<this.args.length}};function lS(e){let t={command:"",inputFile:"",outputFile:null,verbose:!1,help:!1,version:!1},r=new vs(e);for(;r.hasMore();){let n=r.current();if(!n){r.advance();continue}if(n==="-h"||n==="--help")t.help=!0;else if(n==="--version")t.version=!0;else if(n==="-v"||n==="--verbose")t.verbose=!0;else if(n==="-o"||n==="--output"){let i=r.next();i&&(t.outputFile=i)}else n.startsWith("-")||(t.command?t.inputFile||(t.inputFile=n):t.command=n);r.advance()}return t}function uS(e,t,r){let n=`Error: ${e}`;return t!==void 0&&r!==void 0&&(n=`Error [${t}:${r}]: ${e}`),n}function fS(){let e=process.argv.slice(2),t=lS(e);t.help&&(console.log(bo),process.exit(0)),t.version&&(console.log(`gsql version ${cS}`),process.exit(0)),t.command||(console.error("Error: No command specified"),console.log(bo),process.exit(1)),t.command!=="compile"&&(console.error(`Error: Unknown command '${t.command}'`),console.log(bo),process.exit(1)),t.inputFile||(console.error("Error: No input file specified"),console.log(bo),process.exit(1));let r=Xu(process.cwd(),t.inputFile);eS(r)||(console.error(`Error: File not found: ${t.inputFile}`),process.exit(1));let n;try{n=Qu(r,"utf-8")}catch(o){let s=o instanceof Error?o.message:String(o);console.error(`Error reading file: ${s}`),process.exit(1)}t.verbose&&console.error(`Compiling ${rS(r)}...`);let i=Yu(n);if(!i.success){for(let o of i.errors)console.error(uS(o.message,o.location?.start.line,o.location?.start.column));process.exit(1)}if(t.outputFile){let o=Xu(process.cwd(),t.outputFile);try{tS(o,i.sql??""),t.verbose&&console.error(`Output written to ${t.outputFile}`)}catch(s){let a=s instanceof Error?s.message:String(s);console.error(`Error writing file: ${a}`),process.exit(1)}}else console.log(i.sql)}fS();
162
162
  /*! Bundled license information:
163
163
 
164
164
  lodash-es/lodash.js: