@barishnamazov/gsql 0.2.2 → 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 Xu,writeFileSync as JT,existsSync as tS}from"node:fs";import{resolve as Yu,basename as eS,dirname as rS,join as nS}from"node:path";import{fileURLToPath as iS}from"node:url";var Ju=typeof global=="object"&&global&&global.Object===Object&&global,dn=Ju;var tf=typeof self=="object"&&self&&self.Object===Object&&self,ef=dn||tf||Function("return this")(),J=ef;var rf=J.Symbol,at=rf;var Us=Object.prototype,nf=Us.hasOwnProperty,of=Us.toString,Rr=at?at.toStringTag:void 0;function sf(e){var t=nf.call(e,Rr),r=e[Rr];try{e[Rr]=void 0;var n=!0}catch{}var i=of.call(e);return n&&(t?e[Rr]=r:delete e[Rr]),i}var ws=sf;var af=Object.prototype,cf=af.toString;function lf(e){return cf.call(e)}var Ds=lf;var uf="[object Null]",ff="[object Undefined]",Fs=at?at.toStringTag:void 0;function hf(e){return e==null?e===void 0?ff:uf:Fs&&Fs in Object(e)?ws(e):Ds(e)}var mt=hf;function pf(e){return e!=null&&typeof e=="object"}var Y=pf;var mf="[object Symbol]";function df(e){return typeof e=="symbol"||Y(e)&&mt(e)==mf}var ue=df;function gf(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=gf;var Ef=Array.isArray,O=Ef;var xf=1/0,Bs=at?at.prototype:void 0,Gs=Bs?Bs.toString:void 0;function $s(e){if(typeof e=="string")return e;if(O(e))return Gt(e,$s)+"";if(ue(e))return Gs?Gs.call(e):"";var t=e+"";return t=="0"&&1/e==-xf?"-0":t}var js=$s;var Tf=/\s/;function Sf(e){for(var t=e.length;t--&&Tf.test(e.charAt(t)););return t}var Ws=Sf;var Af=/^\s+/;function Nf(e){return e&&e.slice(0,Ws(e)+1).replace(Af,"")}var Ks=Nf;function Of(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var W=Of;var Hs=NaN,If=/^[-+]0x[0-9a-f]+$/i,Cf=/^0b[01]+$/i,Rf=/^0o[0-7]+$/i,yf=parseInt;function Lf(e){if(typeof e=="number")return e;if(ue(e))return Hs;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=Ks(e);var r=Cf.test(e);return r||Rf.test(e)?yf(e.slice(2),r?2:8):If.test(e)?Hs:+e}var qs=Lf;var zs=1/0,_f=17976931348623157e292;function vf(e){if(!e)return e===0?e:0;if(e=qs(e),e===zs||e===-zs){var t=e<0?-1:1;return t*_f}return e===e?e:0}var Vs=vf;function Mf(e){var t=Vs(e),r=t%1;return t===t?r?t-r:t:0}var $t=Mf;function bf(e){return e}var vt=bf;var kf="[object AsyncFunction]",Pf="[object Function]",Uf="[object GeneratorFunction]",wf="[object Proxy]";function Df(e){if(!W(e))return!1;var t=mt(e);return t==Pf||t==Uf||t==kf||t==wf}var dt=Df;var Ff=J["__core-js_shared__"],gn=Ff;var Ys=(function(){var e=/[^.]+$/.exec(gn&&gn.keys&&gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Bf(e){return!!Ys&&Ys in e}var Xs=Bf;var Gf=Function.prototype,$f=Gf.toString;function jf(e){if(e!=null){try{return $f.call(e)}catch{}try{return e+""}catch{}}return""}var te=jf;var Wf=/[\\^$.*+?()[\]{}|]/g,Kf=/^\[object .+?Constructor\]$/,Hf=Function.prototype,qf=Object.prototype,zf=Hf.toString,Vf=qf.hasOwnProperty,Yf=RegExp("^"+zf.call(Vf).replace(Wf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xf(e){if(!W(e)||Xs(e))return!1;var t=dt(e)?Yf:Kf;return t.test(te(e))}var Qs=Xf;function Qf(e,t){return e?.[t]}var Zs=Qf;function Zf(e,t){var r=Zs(e,t);return Qs(r)?r:void 0}var St=Zf;var Jf=St(J,"WeakMap"),En=Jf;var Js=Object.create,th=(function(){function e(){}return function(t){if(!W(t))return{};if(Js)return Js(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),ta=th;function eh(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 ea=eh;function rh(){}var K=rh;function nh(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var ra=nh;var ih=800,oh=16,sh=Date.now;function ah(e){var t=0,r=0;return function(){var n=sh(),i=oh-(n-r);if(r=n,i>0){if(++t>=ih)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var na=ah;function ch(e){return function(){return e}}var ia=ch;var lh=(function(){try{var e=St(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Be=lh;var uh=Be?function(e,t){return Be(e,"toString",{configurable:!0,enumerable:!1,value:ia(t),writable:!0})}:vt,oa=uh;var fh=na(oa),sa=fh;function hh(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var xn=hh;function ph(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=ph;function mh(e){return e!==e}var aa=mh;function dh(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var ca=dh;function gh(e,t,r){return t===t?ca(e,t,r):Tn(e,aa,r)}var Ge=gh;function Eh(e,t){var r=e==null?0:e.length;return!!r&&Ge(e,t,0)>-1}var Sn=Eh;var xh=9007199254740991,Th=/^(?:0|[1-9]\d*)$/;function Sh(e,t){var r=typeof e;return t=t??xh,!!t&&(r=="number"||r!="symbol"&&Th.test(e))&&e>-1&&e%1==0&&e<t}var fe=Sh;function Ah(e,t,r){t=="__proto__"&&Be?Be(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var $e=Ah;function Nh(e,t){return e===t||e!==e&&t!==t}var jt=Nh;var Oh=Object.prototype,Ih=Oh.hasOwnProperty;function Ch(e,t,r){var n=e[t];(!(Ih.call(e,t)&&jt(n,r))||r===void 0&&!(t in e))&&$e(e,t,r)}var he=Ch;function Rh(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=Rh;var la=Math.max;function yh(e,t,r){return t=la(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=la(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),ea(e,this,a)}}var ua=yh;function Lh(e,t){return sa(ua(e,t,vt),e+"")}var je=Lh;var _h=9007199254740991;function vh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=_h}var We=vh;function Mh(e){return e!=null&&We(e.length)&&!dt(e)}var tt=Mh;function bh(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=bh;function kh(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 fa=kh;var Ph=Object.prototype;function Uh(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Ph;return e===r}var Kt=Uh;function wh(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var ha=wh;var Dh="[object Arguments]";function Fh(e){return Y(e)&&mt(e)==Dh}var wo=Fh;var pa=Object.prototype,Bh=pa.hasOwnProperty,Gh=pa.propertyIsEnumerable,$h=wo((function(){return arguments})())?wo:function(e){return Y(e)&&Bh.call(e,"callee")&&!Gh.call(e,"callee")},me=$h;function jh(){return!1}var ma=jh;var Ea=typeof exports=="object"&&exports&&!exports.nodeType&&exports,da=Ea&&typeof module=="object"&&module&&!module.nodeType&&module,Wh=da&&da.exports===Ea,ga=Wh?J.Buffer:void 0,Kh=ga?ga.isBuffer:void 0,Hh=Kh||ma,ee=Hh;var qh="[object Arguments]",zh="[object Array]",Vh="[object Boolean]",Yh="[object Date]",Xh="[object Error]",Qh="[object Function]",Zh="[object Map]",Jh="[object Number]",tp="[object Object]",ep="[object RegExp]",rp="[object Set]",np="[object String]",ip="[object WeakMap]",op="[object ArrayBuffer]",sp="[object DataView]",ap="[object Float32Array]",cp="[object Float64Array]",lp="[object Int8Array]",up="[object Int16Array]",fp="[object Int32Array]",hp="[object Uint8Array]",pp="[object Uint8ClampedArray]",mp="[object Uint16Array]",dp="[object Uint32Array]",B={};B[ap]=B[cp]=B[lp]=B[up]=B[fp]=B[hp]=B[pp]=B[mp]=B[dp]=!0;B[qh]=B[zh]=B[op]=B[Vh]=B[sp]=B[Yh]=B[Xh]=B[Qh]=B[Zh]=B[Jh]=B[tp]=B[ep]=B[rp]=B[np]=B[ip]=!1;function gp(e){return Y(e)&&We(e.length)&&!!B[mt(e)]}var xa=gp;function Ep(e){return function(t){return e(t)}}var Ht=Ep;var Ta=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yr=Ta&&typeof module=="object"&&module&&!module.nodeType&&module,xp=yr&&yr.exports===Ta,Do=xp&&dn.process,Tp=(function(){try{var e=yr&&yr.require&&yr.require("util").types;return e||Do&&Do.binding&&Do.binding("util")}catch{}})(),Mt=Tp;var Sa=Mt&&Mt.isTypedArray,Sp=Sa?Ht(Sa):xa,Ke=Sp;var Ap=Object.prototype,Np=Ap.hasOwnProperty;function Op(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?ha(e.length,String):[],c=a.length;for(var l in e)(t||Np.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=Op;function Ip(e,t){return function(r){return e(t(r))}}var Nn=Ip;var Cp=Nn(Object.keys,Object),Aa=Cp;var Rp=Object.prototype,yp=Rp.hasOwnProperty;function Lp(e){if(!Kt(e))return Aa(e);var t=[];for(var r in Object(e))yp.call(e,r)&&r!="constructor"&&t.push(r);return t}var On=Lp;function _p(e){return tt(e)?An(e):On(e)}var P=_p;var vp=Object.prototype,Mp=vp.hasOwnProperty,bp=fa(function(e,t){if(Kt(t)||tt(t)){Wt(t,P(t),e);return}for(var r in t)Mp.call(t,r)&&he(e,r,t[r])}),lt=bp;function kp(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var Na=kp;var Pp=Object.prototype,Up=Pp.hasOwnProperty;function wp(e){if(!W(e))return Na(e);var t=Kt(e),r=[];for(var n in e)n=="constructor"&&(t||!Up.call(e,n))||r.push(n);return r}var Oa=wp;function Dp(e){return tt(e)?An(e,!0):Oa(e)}var de=Dp;var Fp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Bp=/^\w*$/;function Gp(e,t){if(O(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ue(e)?!0:Bp.test(e)||!Fp.test(e)||t!=null&&e in Object(t)}var He=Gp;var $p=St(Object,"create"),re=$p;function jp(){this.__data__=re?re(null):{},this.size=0}var Ia=jp;function Wp(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ca=Wp;var Kp="__lodash_hash_undefined__",Hp=Object.prototype,qp=Hp.hasOwnProperty;function zp(e){var t=this.__data__;if(re){var r=t[e];return r===Kp?void 0:r}return qp.call(t,e)?t[e]:void 0}var Ra=zp;var Vp=Object.prototype,Yp=Vp.hasOwnProperty;function Xp(e){var t=this.__data__;return re?t[e]!==void 0:Yp.call(t,e)}var ya=Xp;var Qp="__lodash_hash_undefined__";function Zp(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=re&&t===void 0?Qp:t,this}var La=Zp;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=Ia;qe.prototype.delete=Ca;qe.prototype.get=Ra;qe.prototype.has=ya;qe.prototype.set=La;var Fo=qe;function Jp(){this.__data__=[],this.size=0}var _a=Jp;function tm(e,t){for(var r=e.length;r--;)if(jt(e[r][0],t))return r;return-1}var ge=tm;var em=Array.prototype,rm=em.splice;function nm(e){var t=this.__data__,r=ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():rm.call(t,r,1),--this.size,!0}var va=nm;function im(e){var t=this.__data__,r=ge(t,e);return r<0?void 0:t[r][1]}var Ma=im;function om(e){return ge(this.__data__,e)>-1}var ba=om;function sm(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 ka=sm;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=_a;ze.prototype.delete=va;ze.prototype.get=Ma;ze.prototype.has=ba;ze.prototype.set=ka;var Ee=ze;var am=St(J,"Map"),xe=am;function cm(){this.size=0,this.__data__={hash:new Fo,map:new(xe||Ee),string:new Fo}}var Pa=cm;function lm(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Ua=lm;function um(e,t){var r=e.__data__;return Ua(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Te=um;function fm(e){var t=Te(this,e).delete(e);return this.size-=t?1:0,t}var wa=fm;function hm(e){return Te(this,e).get(e)}var Da=hm;function pm(e){return Te(this,e).has(e)}var Fa=pm;function mm(e,t){var r=Te(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var Ba=mm;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=Pa;Ve.prototype.delete=wa;Ve.prototype.get=Da;Ve.prototype.has=Fa;Ve.prototype.set=Ba;var Le=Ve;var dm="Expected a function";function Bo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(dm);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(Bo.Cache||Le),r}Bo.Cache=Le;var Ga=Bo;var gm=500;function Em(e){var t=Ga(e,function(n){return r.size===gm&&r.clear(),n}),r=t.cache;return t}var $a=Em;var xm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Tm=/\\(\\)?/g,Sm=$a(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(xm,function(r,n,i,o){t.push(i?o.replace(Tm,"$1"):n||r)}),t}),ja=Sm;function Am(e){return e==null?"":js(e)}var Wa=Am;function Nm(e,t){return O(e)?e:He(e,t)?[e]:ja(Wa(e))}var Se=Nm;var Om=1/0;function Im(e){if(typeof e=="string"||ue(e))return e;var t=e+"";return t=="0"&&1/e==-Om?"-0":t}var qt=Im;function Cm(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=Cm;function Rm(e,t,r){var n=e==null?void 0:Ye(e,t);return n===void 0?r:n}var Ka=Rm;function ym(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Xe=ym;var Ha=at?at.isConcatSpreadable:void 0;function Lm(e){return O(e)||me(e)||!!(Ha&&e&&e[Ha])}var qa=Lm;function za(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=qa),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?za(a,t-1,r,n,i):Xe(i,a):n||(i[i.length]=a)}return i}var Qe=za;function _m(e){var t=e==null?0:e.length;return t?Qe(e,1):[]}var it=_m;var vm=Nn(Object.getPrototypeOf,Object),In=vm;function Mm(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=Mm;function bm(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 Va=bm;function km(){this.__data__=new Ee,this.size=0}var Ya=km;function Pm(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Xa=Pm;function Um(e){return this.__data__.get(e)}var Qa=Um;function wm(e){return this.__data__.has(e)}var Za=wm;var Dm=200;function Fm(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!xe||n.length<Dm-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 Ja=Fm;function Ze(e){var t=this.__data__=new Ee(e);this.size=t.size}Ze.prototype.clear=Ya;Ze.prototype.delete=Xa;Ze.prototype.get=Qa;Ze.prototype.has=Za;Ze.prototype.set=Ja;var Ae=Ze;function Bm(e,t){return e&&Wt(t,P(t),e)}var tc=Bm;function Gm(e,t){return e&&Wt(t,de(t),e)}var ec=Gm;var oc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rc=oc&&typeof module=="object"&&module&&!module.nodeType&&module,$m=rc&&rc.exports===oc,nc=$m?J.Buffer:void 0,ic=nc?nc.allocUnsafe:void 0;function jm(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 sc=jm;function Wm(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=Wm;function Km(){return[]}var Rn=Km;var Hm=Object.prototype,qm=Hm.propertyIsEnumerable,ac=Object.getOwnPropertySymbols,zm=ac?function(e){return e==null?[]:(e=Object(e),Je(ac(e),function(t){return qm.call(e,t)}))}:Rn,tr=zm;function Vm(e,t){return Wt(e,tr(e),t)}var cc=Vm;var Ym=Object.getOwnPropertySymbols,Xm=Ym?function(e){for(var t=[];e;)Xe(t,tr(e)),e=In(e);return t}:Rn,yn=Xm;function Qm(e,t){return Wt(e,yn(e),t)}var lc=Qm;function Zm(e,t,r){var n=t(e);return O(e)?n:Xe(n,r(e))}var Ln=Zm;function Jm(e){return Ln(e,P,tr)}var Lr=Jm;function td(e){return Ln(e,de,yn)}var _n=td;var ed=St(J,"DataView"),vn=ed;var rd=St(J,"Promise"),Mn=rd;var nd=St(J,"Set"),Ne=nd;var uc="[object Map]",id="[object Object]",fc="[object Promise]",hc="[object Set]",pc="[object WeakMap]",mc="[object DataView]",od=te(vn),sd=te(xe),ad=te(Mn),cd=te(Ne),ld=te(En),_e=mt;(vn&&_e(new vn(new ArrayBuffer(1)))!=mc||xe&&_e(new xe)!=uc||Mn&&_e(Mn.resolve())!=fc||Ne&&_e(new Ne)!=hc||En&&_e(new En)!=pc)&&(_e=function(e){var t=mt(e),r=t==id?e.constructor:void 0,n=r?te(r):"";if(n)switch(n){case od:return mc;case sd:return uc;case ad:return fc;case cd:return hc;case ld:return pc}return t});var Ut=_e;var ud=Object.prototype,fd=ud.hasOwnProperty;function hd(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&fd.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var dc=hd;var pd=J.Uint8Array,er=pd;function md(e){var t=new e.constructor(e.byteLength);return new er(t).set(new er(e)),t}var rr=md;function dd(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var gc=dd;var gd=/\w*$/;function Ed(e){var t=new e.constructor(e.source,gd.exec(e));return t.lastIndex=e.lastIndex,t}var Ec=Ed;var xc=at?at.prototype:void 0,Tc=xc?xc.valueOf:void 0;function xd(e){return Tc?Object(Tc.call(e)):{}}var Sc=xd;function Td(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var Ac=Td;var Sd="[object Boolean]",Ad="[object Date]",Nd="[object Map]",Od="[object Number]",Id="[object RegExp]",Cd="[object Set]",Rd="[object String]",yd="[object Symbol]",Ld="[object ArrayBuffer]",_d="[object DataView]",vd="[object Float32Array]",Md="[object Float64Array]",bd="[object Int8Array]",kd="[object Int16Array]",Pd="[object Int32Array]",Ud="[object Uint8Array]",wd="[object Uint8ClampedArray]",Dd="[object Uint16Array]",Fd="[object Uint32Array]";function Bd(e,t,r){var n=e.constructor;switch(t){case Ld:return rr(e);case Sd:case Ad:return new n(+e);case _d:return gc(e,r);case vd:case Md:case bd:case kd:case Pd:case Ud:case wd:case Dd:case Fd:return Ac(e,r);case Nd:return new n;case Od:case Rd:return new n(e);case Id:return Ec(e);case Cd:return new n;case yd:return Sc(e)}}var Nc=Bd;function Gd(e){return typeof e.constructor=="function"&&!Kt(e)?ta(In(e)):{}}var Oc=Gd;var $d="[object Map]";function jd(e){return Y(e)&&Ut(e)==$d}var Ic=jd;var Cc=Mt&&Mt.isMap,Wd=Cc?Ht(Cc):Ic,Rc=Wd;var Kd="[object Set]";function Hd(e){return Y(e)&&Ut(e)==Kd}var yc=Hd;var Lc=Mt&&Mt.isSet,qd=Lc?Ht(Lc):yc,_c=qd;var zd=1,Vd=2,Yd=4,vc="[object Arguments]",Xd="[object Array]",Qd="[object Boolean]",Zd="[object Date]",Jd="[object Error]",Mc="[object Function]",tg="[object GeneratorFunction]",eg="[object Map]",rg="[object Number]",bc="[object Object]",ng="[object RegExp]",ig="[object Set]",og="[object String]",sg="[object Symbol]",ag="[object WeakMap]",cg="[object ArrayBuffer]",lg="[object DataView]",ug="[object Float32Array]",fg="[object Float64Array]",hg="[object Int8Array]",pg="[object Int16Array]",mg="[object Int32Array]",dg="[object Uint8Array]",gg="[object Uint8ClampedArray]",Eg="[object Uint16Array]",xg="[object Uint32Array]",U={};U[vc]=U[Xd]=U[cg]=U[lg]=U[Qd]=U[Zd]=U[ug]=U[fg]=U[hg]=U[pg]=U[mg]=U[eg]=U[rg]=U[bc]=U[ng]=U[ig]=U[og]=U[sg]=U[dg]=U[gg]=U[Eg]=U[xg]=!0;U[Jd]=U[Mc]=U[ag]=!1;function bn(e,t,r,n,i,o){var s,a=t&zd,c=t&Vd,l=t&Yd;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=dc(e),!a)return ra(e,s)}else{var f=Ut(e),h=f==Mc||f==tg;if(ee(e))return sc(e,a);if(f==bc||f==vc||h&&!i){if(s=c||h?{}:Oc(e),!a)return c?lc(e,ec(s,e)):cc(e,tc(s,e))}else{if(!U[f])return i?e:{};s=Nc(e,f,a)}}o||(o=new Ae);var g=o.get(e);if(g)return g;o.set(e,s),_c(e)?e.forEach(function(R){s.add(bn(R,t,r,R,e,o))}):Rc(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 kc=bn;var Tg=4;function Sg(e){return kc(e,Tg)}var w=Sg;function Ag(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=Ag;var Ng="__lodash_hash_undefined__";function Og(e){return this.__data__.set(e,Ng),this}var Pc=Og;function Ig(e){return this.__data__.has(e)}var Uc=Ig;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=Pc;kn.prototype.has=Uc;var nr=kn;function Cg(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=Cg;function Rg(e,t){return e.has(t)}var ir=Rg;var yg=1,Lg=2;function _g(e,t,r,n,i,o){var s=r&yg,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&Lg?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=_g;function vg(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var wc=vg;function Mg(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var or=Mg;var bg=1,kg=2,Pg="[object Boolean]",Ug="[object Date]",wg="[object Error]",Dg="[object Map]",Fg="[object Number]",Bg="[object RegExp]",Gg="[object Set]",$g="[object String]",jg="[object Symbol]",Wg="[object ArrayBuffer]",Kg="[object DataView]",Dc=at?at.prototype:void 0,Go=Dc?Dc.valueOf:void 0;function Hg(e,t,r,n,i,o,s){switch(r){case Kg:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Wg:return!(e.byteLength!=t.byteLength||!o(new er(e),new er(t)));case Pg:case Ug:case Fg:return jt(+e,+t);case wg:return e.name==t.name&&e.message==t.message;case Bg:case $g:return e==t+"";case Dg:var a=wc;case Gg:var c=n&bg;if(a||(a=or),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=kg,s.set(e,t);var u=Un(a(e),a(t),n,i,o,s);return s.delete(e),u;case jg:if(Go)return Go.call(e)==Go.call(t)}return!1}var Fc=Hg;var qg=1,zg=Object.prototype,Vg=zg.hasOwnProperty;function Yg(e,t,r,n,i,o){var s=r&qg,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:Vg.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 Bc=Yg;var Xg=1,Gc="[object Arguments]",$c="[object Array]",wn="[object Object]",Qg=Object.prototype,jc=Qg.hasOwnProperty;function Zg(e,t,r,n,i,o){var s=O(e),a=O(t),c=s?$c:Ut(e),l=a?$c:Ut(t);c=c==Gc?wn:c,l=l==Gc?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):Fc(e,t,c,r,n,i,o);if(!(r&Xg)){var g=u&&jc.call(e,"__wrapped__"),T=f&&jc.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),Bc(e,t,r,n,i,o)):!1}var Wc=Zg;function Kc(e,t,r,n,i){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:Wc(e,t,r,n,Kc,i)}var Dn=Kc;var Jg=1,tE=2;function eE(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,Jg|tE,n,f):h))return!1}}return!0}var Hc=eE;function rE(e){return e===e&&!W(e)}var Fn=rE;function nE(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 qc=nE;function iE(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Bn=iE;function oE(e){var t=qc(e);return t.length==1&&t[0][2]?Bn(t[0][0],t[0][1]):function(r){return r===e||Hc(r,e,t)}}var zc=oE;function sE(e,t){return e!=null&&t in Object(e)}var Vc=sE;function aE(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=aE;function cE(e,t){return e!=null&&Gn(e,t,Vc)}var Yc=cE;var lE=1,uE=2;function fE(e,t){return He(e)&&Fn(t)?Bn(qt(e),t):function(r){var n=Ka(r,e);return n===void 0&&n===t?Yc(r,e):Dn(t,n,lE|uE)}}var Xc=fE;function hE(e){return function(t){return t?.[e]}}var Qc=hE;function pE(e){return function(t){return Ye(t,e)}}var Zc=pE;function mE(e){return He(e)?Qc(qt(e)):Zc(e)}var Jc=mE;function dE(e){return typeof e=="function"?e:e==null?vt:typeof e=="object"?O(e)?Xc(e[0],e[1]):zc(e):Jc(e)}var et=dE;function gE(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 tl=gE;function EE(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 el=EE;var xE=el(),rl=xE;function TE(e,t){return e&&rl(e,t,P)}var nl=TE;function SE(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 il=SE;var AE=il(nl),At=AE;function NE(e,t,r,n){return At(e,function(i,o,s){t(n,i,r(i),s)}),n}var ol=NE;function OE(e,t){return function(r,n){var i=O(r)?tl:ol,o=t?t():{};return i(r,e,et(n,2),o)}}var sl=OE;var al=Object.prototype,IE=al.hasOwnProperty,CE=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,al[l])&&!IE.call(e,l))&&(e[l]=o[l])}return e}),sr=CE;function RE(e){return Y(e)&&tt(e)}var $o=RE;function yE(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=yE;var LE=200;function _E(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>=LE&&(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 cl=_E;var vE=je(function(e,t){return $o(e)?cl(e,Qe(t,1,$o,!0)):[]}),Oe=vE;function ME(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Vt=ME;function bE(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=bE;function kE(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=kE;function PE(e){return typeof e=="function"?e:vt}var ll=PE;function UE(e,t){var r=O(e)?xn:At;return r(e,ll(t))}var S=UE;function wE(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 ul=wE;function DE(e,t){var r=!0;return At(e,function(n,i,o){return r=!!t(n,i,o),r}),r}var fl=DE;function FE(e,t,r){var n=O(e)?ul:fl;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var ft=FE;function BE(e,t){var r=[];return At(e,function(n,i,o){t(n,i,o)&&r.push(n)}),r}var jn=BE;function GE(e,t){var r=O(e)?Je:jn;return r(e,et(t,3))}var ht=GE;function $E(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 hl=$E;var jE=Math.max;function WE(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=jE(n+i,0)),Tn(e,et(t,3),i)}var pl=WE;var KE=hl(pl),Yt=KE;function HE(e){return e&&e.length?e[0]:void 0}var ct=HE;function qE(e,t){var r=-1,n=tt(e)?Array(e.length):[];return At(e,function(i,o,s){n[++r]=t(i,o,s)}),n}var ml=qE;function zE(e,t){var r=O(e)?Gt:ml;return r(e,et(t,3))}var E=zE;function VE(e,t){return Qe(E(e,t),1)}var gt=VE;var YE=Object.prototype,XE=YE.hasOwnProperty,QE=sl(function(e,t,r){XE.call(e,r)?e[r].push(t):$e(e,r,[t])}),jo=QE;var ZE=Object.prototype,JE=ZE.hasOwnProperty;function tx(e,t){return e!=null&&JE.call(e,t)}var dl=tx;function ex(e,t){return e!=null&&Gn(e,t,dl)}var A=ex;var rx="[object String]";function nx(e){return typeof e=="string"||!O(e)&&Y(e)&&mt(e)==rx}var ot=nx;function ix(e,t){return Gt(t,function(r){return e[r]})}var gl=ix;function ox(e){return e==null?[]:gl(e,P(e))}var k=ox;var sx=Math.max;function ax(e,t,r,n){e=tt(e)?e:k(e),r=r&&!n?$t(r):0;var i=e.length;return r<0&&(r=sx(i+r,0)),ot(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Ge(e,t,r)>-1}var $=ax;var cx=Math.max;function lx(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=cx(n+i,0)),Ge(e,t,i)}var Wn=lx;var ux="[object Map]",fx="[object Set]",hx=Object.prototype,px=hx.hasOwnProperty;function mx(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==ux||t==fx)return!e.size;if(Kt(e))return!On(e).length;for(var r in e)if(px.call(e,r))return!1;return!0}var _=mx;var dx="[object RegExp]";function gx(e){return Y(e)&&mt(e)==dx}var El=gx;var xl=Mt&&Mt.isRegExp,Ex=xl?Ht(xl):El,bt=Ex;function xx(e){return e===void 0}var pt=xx;var Tx="Expected a function";function Sx(e){if(typeof e!="function")throw new TypeError(Tx);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 Tl=Sx;function Ax(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 Sl=Ax;function Nx(e,t,r){for(var n=-1,i=t.length,o={};++n<i;){var s=t[n],a=Ye(e,s);r(a,s)&&Sl(o,Se(s,e),a)}return o}var Al=Nx;function Ox(e,t){if(e==null)return{};var r=Gt(_n(e),function(n){return[n]});return t=et(t),Al(e,r,function(n,i){return t(n,i[0])})}var Nt=Ox;function Ix(e,t,r,n,i){return i(e,function(o,s,a){r=n?(n=!1,o):t(r,o,s,a)}),r}var Nl=Ix;function Cx(e,t,r){var n=O(e)?Va:Nl,i=arguments.length<3;return n(e,et(t,4),r,i,At)}var rt=Cx;function Rx(e,t){var r=O(e)?Je:jn;return r(e,Tl(et(t,3)))}var Ie=Rx;function yx(e,t){var r;return At(e,function(n,i,o){return r=t(n,i,o),!r}),!!r}var Ol=yx;function Lx(e,t,r){var n=O(e)?Pn:Ol;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var _r=Lx;var _x=1/0,vx=Ne&&1/or(new Ne([,-0]))[1]==_x?function(e){return new Ne(e)}:K,Il=vx;var Mx=200;function bx(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>=Mx){var l=t?null:Il(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 Cl=bx;function kx(e){return e&&e.length?Cl(e):[]}var ar=kx;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 Px(e){return Ux(e)?e.LABEL:e.name}function Ux(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,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 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:Px(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 Wo(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 Ko(e){return e instanceof V}function Ot(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=Rl(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=Rl(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 Rl(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 Fx(e);if(Wo(e))return wx(e);if(Ko(e))return Dx(e);throw Error("non exhaustive match")}function wx(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 Dx(e){let t=E(e.definition,r=>Me(r));return ar(it(t))}function Fx(e){return[e.terminalType]}var Hn="_~IN~_";var Ho=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=Bx(t.referencedRule,t.idx)+this.topProd.name,o=r.concat(n),s=new F({definition:o}),a=Me(s);this.follows[i]=a}};function yl(e){let t={};return S(e,r=>{let n=new Ho(r).startWalking();lt(t,n)}),t}function Bx(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 qo(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 zo=[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 Gx=/[0-9a-fA-F]/,zn=/[0-9]/,$x=/[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=zo;break;case"S":t=zo,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(),i=n.type==="Character";if(qo(n)&&this.isRangeDash()){this.consumeChar("-");let o=this.classAtom(),s=o.type==="Character";if(qo(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($x.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 i=0;i<t;i++){let o=this.popChar();if(Gx.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={},jx=new wr;function fr(e){let t=e.toString();if(Vn.hasOwnProperty(t))return Vn[t];{let r=jx.pattern(t);return Vn[t]=r,r}}function Ll(){Vn={}}var vl="Complement Sets are not supported for first char optimization",Dr=`Unable to use "first char" lexer optimizations:
11
- `;function Ml(e,t=!1){try{let r=fr(e);return Vo(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===vl)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 Xu,writeFileSync as JT,existsSync as tS}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 Vo(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)Vo(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(vl);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":Vo(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"&&Yo(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&&Wx(e,t)}function Wx(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 _l(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 Yo(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?O(e.value)?ft(e.value,Yo):Yo(e.value):!1}var Xo=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?_l(t,this.targetCharCodes)===void 0&&(this.found=!0):_l(t,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Xn(e,t){if(t instanceof RegExp){let r=fr(t),n=new Xo(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",Zo=typeof new RegExp("(?:)").sticky=="boolean";function Pl(e,t){t=sr(t,{useSticky:Zo,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
20
- `],tracer:(x,d)=>d()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{aT()});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?kl(d):bl(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?kl(L):bl(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=jl(t.lineTerminatorCharacters);f=E(n,d=>!1),t.positionTracking!=="onlyOffset"&&(f=E(n,d=>A(d,"LINE_BREAKS")?!!d.LINE_BREAKS:$l(d,x)===!1&&Xn(x,d.PATTERN)))});let h,g,T,I;r("Misc Mapping #2",()=>{h=E(n,Bl),g=E(o,oT),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);Qo(x,Rt,I[y])}else if(O(d.START_CHARS_HINT)){let L;S(d.START_CHARS_HINT,Rt=>{let bo=typeof Rt=="string"?Rt.charCodeAt(0):Rt,Bt=Xt(bo);L!==Bt&&(L=Bt,Qo(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.
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=Ml(d.PATTERN,t.ensureOptimizations);_(L)&&(R=!1),S(L,Rt=>{Qo(x,Rt,I[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 x},[])}),{emptyGroups:T,patternIdxToConfig:I,charCodeToPatternIdxToConfig:N,hasCustom:i,canBeOptimized:R}}function Ul(e,t){let r=[],n=Hx(e);r=r.concat(n.errors);let i=qx(n.valid),o=i.valid;return r=r.concat(i.errors),r=r.concat(Kx(o)),r=r.concat(tT(o)),r=r.concat(eT(o,t)),r=r.concat(rT(o)),r}function Kx(e){let t=[],r=ht(e,n=>bt(n[ke]));return t=t.concat(Vx(r)),t=t.concat(Qx(r)),t=t.concat(Zx(r)),t=t.concat(Jx(r)),t=t.concat(Yx(r)),t}function Hx(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 qx(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 zx=/[^\\][$]/;function Vx(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 zx.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
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
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 Yx(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 Xx=/[^\\[][\^]|^\^/;function Qx(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 Xx.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
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
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 Zx(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 Jx(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 tT(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 eT(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 rT(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)&&iT(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&&nT(o,n.PATTERN)){let c=`Token: ->${a.name}<- can never be matched.
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 nT(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 iT(e){return Yt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function bl(e){let t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function kl(e){let t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function wl(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
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
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 Dl(e,t,r){let n=[],i=!1,o=zt(it(k(e.modes))),s=Ie(o,c=>c[ke]===H.NA),a=jl(r);return t&&S(s,c=>{let l=$l(c,a);if(l!==!1){let f={message:sT(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.
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 Fl(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 Bl(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 oT(e){return ot(e)&&e.length===1?e.charCodeAt(0):!1}var Gl={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 $l(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(Bl(e))return{issue:j.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function sT(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 jl(e){return E(e,r=>ot(r)?r.charCodeAt(0):r)}function Qo(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 aT(){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 Wl=1,Hl={};function se(e){let t=cT(e);lT(t),fT(t),uT(t),S(t,r=>{r.isParent=r.categoryMatches.length>0})}function cT(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 lT(e){S(e,t=>{Jo(t)||(Hl[Wl]=t,t.tokenTypeIdx=Wl++),Kl(t)&&!O(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),Kl(t)||(t.CATEGORIES=[]),hT(t)||(t.categoryMatches=[]),pT(t)||(t.categoryMatchesMap={})})}function uT(e){S(e,t=>{t.categoryMatches=[],S(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(Hl[n].tokenTypeIdx)})})}function fT(e){S(e,t=>{ql([],t)})}function ql(e,t){S(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),S(t.CATEGORIES,r=>{let n=e.concat(t);$(n,r)||ql(n,r)})}function Jo(e){return A(e,"tokenTypeIdx")}function Kl(e){return A(e,"CATEGORIES")}function hT(e){return A(e,"categoryMatches")}function pT(e){return A(e,"categoryMatchesMap")}function zl(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,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: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=(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=Gl;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(wl(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Dl(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(Ul(a,s))}),_(this.lexerDefinitionErrors)){se(a);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=Pl(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(`-----------------------
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(Zo?(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.
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",()=>{Ll()}),this.TRACE_INIT("toFastProperties",()=>{br(this)})})}tokenize(t,r=this.defaultMode){if(!_(this.lexerDefinitionErrors)){let i=E(this.lexerDefinitionErrors,o=>o.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
- `+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,bo=this.hasCustom?0:Math.floor(t.length/10),Bt=new Array(bo),ko=[],Nr=this.trackStartLines?1:void 0,ae=this.trackStartLines?1:void 0,Or=Fl(this.emptyGroups),Qu=this.trackStartLines,Po=this.config.lineTerminatorsPattern,pn=0,ce=[],Ir=[],mn=[],_s=[];Object.freeze(_s);let Cr;function vs(){return ce}function Ms(ut){let _t=Xt(ut),Fe=Ir[_t];return Fe===void 0?_s:Fe}let Zu=ut=>{if(mn.length===1&&ut.tokenType.PUSH_MODE===void 0){let _t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ut);ko.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=Ms:Cr=vs}};function bs(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=Ms:Cr=vs}bs.call(this,r);let Pt,ks=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),Qu===!0&&Pt.canLineTerminator===!0){let yt=0,Zt,le;Po.lastIndex=0;do Zt=Po.test(c),Zt===!0&&(le=Po.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,Zu,bs,T)}else{let yt=L,Zt=Nr,le=ae,Jt=ks===!1;for(;Jt===!1&&L<y;)for(t=this.chopInput(t,1),L++,i=0;i<pn;i++){let ye=ce[i],Uo=ye.pattern,Ps=ye.short;if(Ps!==!1?d.charCodeAt(L)===Ps&&(Jt=!0):ye.isCustom===!0?Jt=Uo.exec(d,L,Bt,Or)!==null:(this.updateLastIndex(Uo,L),Jt=Uo.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),ko.push({offset:yt,line:Zt,column:le,length:I,message:N}),ks===!1)break}}return this.hasCustom||(Bt.length=Rt),{tokens:Bt,groups:Or,errors:ko}}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 es(e)?e.LABEL:e.name}function es(e){return ot(e.LABEL)&&e.LABEL!==""}var mT="parent",Vl="categories",Yl="label",Xl="group",Ql="push_mode",Zl="pop_mode",Jl="longer_alt",tu="line_breaks",eu="start_chars_hint";function m(e){return dT(e)}function dT(e){let t=e.pattern,r={};if(r.name=e.name,pt(t)||(r.PATTERN=t),A(e,mT))throw`The parent property is no longer supported.
55
- See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return A(e,Vl)&&(r.CATEGORIES=e[Vl]),se([r]),A(e,Yl)&&(r.LABEL=e[Yl]),A(e,Xl)&&(r.GROUP=e[Xl]),A(e,Zl)&&(r.POP_MODE=e[Zl]),A(e,Ql)&&(r.PUSH_MODE=e[Ql]),A(e,Jl)&&(r.LONGER_ALT=e[Jl]),A(e,tu)&&(r.LINE_BREAKS=e[tu]),A(e,eu)&&(r.START_CHARS_HINT=e[eu]),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 rs(e,t){return oe(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:i}){let o="Expecting: ",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
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
57
  ${E(l,(h,g)=>` ${g+1}. ${h}`).join(`
58
58
  `)}`;return o+f+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",s=`
59
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 ru={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=Ot(i),a=r(i),c=o>0,l=`->${s}${c?o:""}<- ${a?`with argument: ->${a}<-`:""}
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,`
@@ -73,7 +73,7 @@ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFI
73
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=Ot(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.
@@ -82,46 +82,46 @@ 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 nu(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 is=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 is{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(gT(N,T,I,R));else throw Error("non exhaustive match")}return u}function gT(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 ou(e,t,r,n,i,o){let s=$r(e,t,r),a=fu(s)?mr:oe;return o(s,n,a,i)}function su(e,t,r,n,i,o){let s=jr(e,t,i,r),a=fu(s)?mr:oe;return o(s[0],a,n)}function au(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 cu(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 ss=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 iu(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function os(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 ET(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 lu(e,t){let r=E(e,s=>ni([s],1)),n=iu(r.length),i=E(r,s=>{let a={};return S(s,c=>{let l=os(c.partialPath);S(l,u=>{a[u]=!0})}),a}),o=r;for(let s=1;s<=t;s++){let a=o;o=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,g=os(f);if(ET(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=os(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),lu(i.result,r)}function jr(e,t,r,n){let i=new oi(e,r);t.accept(i);let o=i.result,a=new ss(t,e,r).startWalking(),c=new F({definition:o}),l=new F({definition:a});return lu([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 uu(e,t){return e.length<t.length&&ft(e,(r,n)=>{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function fu(e){return ft(e,t=>ft(t,r=>ft(r,n=>_(n.categoryMatches))))}function hu(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 pu(e,t,r,n){let i=gt(e,c=>xT(c,r)),o=IT(e,t,r),s=gt(e,c=>AT(c,r)),a=gt(e,c=>ST(c,e,n,r));return i.concat(o,s,a)}function xT(e,t){let r=new as;e.accept(r);let n=r.allProductions,i=jo(n,TT),o=Nt(i,a=>a.length>1);return E(k(o),a=>{let c=ct(a),l=t.buildDuplicateFoundError(e,a),u=Ot(c),f={message:l,type:st.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:u,occurrence:c.idx},h=mu(c);return h&&(f.parameter=h),f})}function TT(e){return`${Ot(e)}_#_${e.idx}_#_${mu(e)}`}function mu(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 ST(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 du(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 ls(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),ls(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 gu(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 Eu(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=NT(l,s,e,r),f=OT(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 AT(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 xu(e,t,r){let n=[];return S(e,i=>{let o=new cs;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 NT(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 OT(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&&uu(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 IT(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 Tu(e){let t=sr(e,{errMsgProvider:ru}),r={};return S(e.rules,n=>{r[n.name]=n}),nu(r,t.errMsgProvider)}function Su(e){return e=sr(e,{errMsgProvider:Dt}),pu(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Au="MismatchedTokenException",Nu="NoViableAltException",Ou="EarlyExitException",Iu="NotAllInputParsedException",Cu=[Au,Nu,Ou,Iu];Object.freeze(Cu);function Re(e){return $(Cu,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=Au}},Kr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Nu}},Hr=class extends gr{constructor(t,r){super(t,r),this.name=Iu}},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}},li=class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=A(t,"recoveryEnabled")?t.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=CT)}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 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,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=>rs(r,o));if(i!==void 0)return i;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 E(t,(n,i)=>i===0?us:{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===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,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 CT(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=>ls(r,r,Dt))}validateEmptyOrAlternatives(t){return gt(t,r=>gu(r,Dt))}validateAmbiguousAlternationAlternatives(t,r){return gt(t,n=>Eu(n,r,Dt))}validateSomeNonEmptyLookaheadPath(t,r){return xu(t,r,Dt)}buildLookaheadForAlternation(t){return ou(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,au)}buildLookaheadForOptional(t){return su(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,si(t.prodType),cu)}};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}=RT(r);S(n,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${Ot(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,Ot(l))}),S(o,l=>{this.computeLookaheadFunc(r,l.idx,512,"Option",l.maxLookahead,Ot(l))}),S(s,l=>{this.computeLookaheadFunc(r,l.idx,1024,"RepetitionMandatory",l.maxLookahead,Ot(l))}),S(a,l=>{this.computeLookaheadFunc(r,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,Ot(l))}),S(c,l=>{this.computeLookaheadFunc(r,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,Ot(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)}},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)}},fi=new ps;function RT(e){fi.reset(),e.accept(fi);let t=fi.dslMethods;return fi.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 Ru(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function yu(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var yT="name";function xs(e,t){Object.defineProperty(e,yT,{enumerable:!1,configurable:!0,writable:!1,value:t})}function LT(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 Lu(e,t){let r=function(){};xs(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=_T(this,t);if(!_(i)){let o=E(i,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
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
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 _u(e,t,r){let n=function(){};xs(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return S(t,o=>{i[o]=LT}),n.prototype=i,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 _T(e,t){return vT(e,t)}function vT(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:Ts.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=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];Ru(n,r,t),this.setNodeLocationFromToken(n.location,r)}cstPostNonTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];yu(n,r,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(pt(this.baseCstVisitorConstructor)){let t=Lu(this.className,P(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){let t=_u(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=du(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.
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
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(O(t))this.tokensMap=rt(t,(o,s)=>(o[s.name]=s,o),{});else if(A(t,"modes")&&ft(it(k(t.modes)),zl)){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===hs?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 vu=!0,Mu=Math.pow(2,8)-1,ku=m({name:"RECORDING_PHASE_TOKEN",pattern:H.NA});se([ku]);var Pu=Ue(ku,`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(Pu);var bT={name:`This CSTNode indicates the Parser is in Recording Phase
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
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,vu)}manyInternalRecord(t,r){Yr.call(this,b,r,t)}manySepFirstInternalRecord(t,r){Yr.call(this,z,r,t,vu)}orInternalRecord(t,r){return kT.call(this,t,r)}subruleInternalRecord(t,r,n){if(Oi(r),!t||A(t,"ruleName")===!1){let a=new Error(`<SUBRULE${bu(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?bT:Ii}consumeInternalRecord(t,r,n){if(Oi(r),!Jo(t)){let s=new Error(`<CONSUME${bu(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),Pu}};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 kT(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 bu(e){return e===0?"":`${e}`}function Oi(e){if(e<0||e>Mu){let t=new Error(`Invalid DSL Method idx value: <${e}>
103
- Idx value must be a none negative value smaller than ${Mu+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 Uu(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=Tu({rules:k(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(_(n)&&this.skipValidations===!1){let i=Su({rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),errMsgProvider:Dt,grammarName:r}),o=hu({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=yl(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:
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;Uu(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 UT=m({name:"WhiteSpace",pattern:/\s+/,group:H.SKIPPED}),wT=m({name:"LineComment",pattern:/\/\/[^\n]*/,group:H.SKIPPED}),DT=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}),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}),ji=m({name:"Pkey",pattern:/pkey/,longer_alt:p}),Wi=m({name:"Nonull",pattern:/nonull/,longer_alt:p}),Ki=m({name:"Default",pattern:/default/,longer_alt:p}),Hi=m({name:"Ref",pattern:/ref/,longer_alt:p}),qi=m({name:"Cascade",pattern:/cascade/,longer_alt:p}),zi=m({name:"Restrict",pattern:/restrict/,longer_alt:p}),Vi=m({name:"SetNull",pattern:/setnull/,longer_alt:p}),Yi=m({name:"SetDefault",pattern:/setdefault/,longer_alt:p}),Xi=m({name:"NoAction",pattern:/noaction/,longer_alt:p}),Qi=m({name:"Update",pattern:/update/,longer_alt:p}),Zi=m({name:"Insert",pattern:/insert/,longer_alt:p}),Ji=m({name:"Delete",pattern:/delete/,longer_alt:p}),to=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}),eo=m({name:"Serial",pattern:/serial/i,longer_alt:p}),ro=m({name:"BigSerial",pattern:/bigserial/i,longer_alt:p}),no=m({name:"Integer",pattern:/integer/i,longer_alt:p}),io=m({name:"Bigint",pattern:/bigint/i,longer_alt:p}),oo=m({name:"SmallInt",pattern:/smallint/i,longer_alt:p}),so=m({name:"Text",pattern:/text/i,longer_alt:p}),ao=m({name:"Varchar",pattern:/varchar/i,longer_alt:p}),co=m({name:"Char",pattern:/char/i,longer_alt:p}),lo=m({name:"Boolean",pattern:/boolean/i,longer_alt:p}),uo=m({name:"Timestamptz",pattern:/timestamptz/i,longer_alt:p}),fo=m({name:"Timestamp",pattern:/timestamp/i,longer_alt:p}),ho=m({name:"Date",pattern:/date/i,longer_alt:p}),po=m({name:"Time",pattern:/time/i,longer_alt:p}),mo=m({name:"Jsonb",pattern:/jsonb/i,longer_alt:p}),go=m({name:"Json",pattern:/json/i,longer_alt:p}),Eo=m({name:"Uuid",pattern:/uuid/i,longer_alt:p}),xo=m({name:"Inet",pattern:/inet/i,longer_alt:p}),To=m({name:"Citext",pattern:/citext/i,longer_alt:p}),So=m({name:"Decimal",pattern:/decimal/i,longer_alt:p}),Ao=m({name:"Numeric",pattern:/numeric/i,longer_alt:p}),No=m({name:"Real",pattern:/real/i,longer_alt:p}),Oo=m({name:"DoublePrecision",pattern:/double\s+precision/i,longer_alt:p}),Io=m({name:"Bytea",pattern:/bytea/i,longer_alt:p}),Co=m({name:"StringLiteral",pattern:/'(?:[^'\\]|\\.)*'/}),cn=m({name:"NumberLiteral",pattern:/-?\d+(?:\.\d+)?/}),Ro=m({name:"BooleanLiteral",pattern:/true|false/,longer_alt:p}),yo=m({name:"NullLiteral",pattern:/null/i,longer_alt:p}),As=m({name:"Arrow",pattern:/->/}),Lo=m({name:"DoubleColon",pattern:/::/}),Sr=m({name:"LBrace",pattern:/\{/}),Ar=m({name:"RBrace",pattern:/\}/}),It=m({name:"LParen",pattern:/\(/}),Ct=m({name:"RParen",pattern:/\)/}),_o=m({name:"LBracket",pattern:/\[/}),vo=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=[UT,wT,DT,As,Lo,Ri,yi,Li,_i,vi,Mi,bi,ki,Jr,tn,Pi,Ui,wi,Di,Fi,Bi,Gi,$i,Tr,en,rn,nn,on,ji,Wi,Ki,Hi,Yi,Vi,qi,zi,Xi,Qi,Zi,Ji,to,sn,an,Oo,uo,fo,ro,eo,oo,io,no,ao,co,so,lo,ho,po,mo,go,Eo,xo,To,So,Ao,No,Io,Co,cn,Ro,yo,Zr,p,Sr,Ar,It,Ct,_o,vo,ln,un,kt,Qt,fn,hn],FT=new H(Ns,{ensureOptimizations:!0});function wu(e){return FT.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(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(to)},{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(Qi)},{ALT:()=>this.CONSUME(Zi)},{ALT:()=>this.CONSUME(Ji)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(ji)},{ALT:()=>this.CONSUME(Wi)},{ALT:()=>this.CONSUME(Ki)},{ALT:()=>this.CONSUME(Hi)},{ALT:()=>this.CONSUME(wi)},{ALT:()=>this.CONSUME(qi)},{ALT:()=>this.CONSUME(zi)},{ALT:()=>this.CONSUME(Vi)},{ALT:()=>this.CONSUME(Yi)},{ALT:()=>this.CONSUME(Xi)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)},{ALT:()=>this.CONSUME(eo)},{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)}])});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(It),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(to),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(It),this.CONSUME(Ct)});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(eo)},{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(p)}]),this.OPTION(()=>{this.CONSUME(It),this.CONSUME(cn),this.CONSUME(Ct)})});columnConstraint=this.RULE("columnConstraint",()=>{this.OR([{ALT:()=>this.CONSUME(ji)},{ALT:()=>this.CONSUME(Wi)},{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(Ki),this.CONSUME(It),this.SUBRULE(this.defaultValue),this.CONSUME(Ct)});defaultValue=this.RULE("defaultValue",()=>{this.OR([{ALT:()=>this.CONSUME(Co)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ro)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.SUBRULE(this.functionCallExpr)},{ALT:()=>{this.SUBRULE(this.anyIdentifier),this.CONSUME(Lo),this.SUBRULE2(this.anyIdentifier)}},{ALT:()=>this.SUBRULE3(this.anyIdentifier)}])});refConstraint=this.RULE("refConstraint",()=>{this.CONSUME(Hi),this.CONSUME(It),this.CONSUME(p),this.CONSUME(fn),this.CONSUME2(p),this.CONSUME(Ct)});checkConstraint=this.RULE("checkConstraint",()=>{this.CONSUME(tn),this.CONSUME(It),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)});checkExpression=this.RULE("checkExpression",()=>{this.MANY(()=>{this.OR([{ALT:()=>{this.CONSUME(It),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)}},{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Co)},{ALT:()=>this.CONSUME(Ro)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.CONSUME(Lo)},{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(It),this.OR([{ALT:()=>this.CONSUME(qi)},{ALT:()=>this.CONSUME(zi)},{ALT:()=>this.CONSUME(Vi)},{ALT:()=>this.CONSUME(Yi)},{ALT:()=>this.CONSUME(Xi)}]),this.CONSUME(Ct)});indexDef=this.RULE("indexDef",()=>{this.CONSUME(Jr),this.CONSUME(It),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(It),this.SUBRULE(this.checkExpression),this.CONSUME(Ct),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(Qi)},{ALT:()=>this.CONSUME(Zi)},{ALT:()=>this.CONSUME(Ji)}]),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(It),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(_o),this.CONSUME2(p),this.CONSUME(vo)})});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(_o),this.CONSUME2(p),this.CONSUME(vo)})});perInstanceIndex=this.RULE("perInstanceIndex",()=>{this.CONSUME(Jr),this.CONSUME(It),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)})},Os=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 Du(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 Is(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 Rs=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:Du(t)}}visitFunctionDecl(t){let r=Is(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=Du(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=Is(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=Is(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 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 i=t.children.Unique!==void 0,o;return t.children.Gin&&(o="gin"),t.children.Gist&&(o="gist"),t.children.Btree&&(o="btree"),t.children.Hash&&(o="hash"),{type:"IndexDef",columns:r,unique:i,using:o}}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;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:i,unique:o,using:s}}};function Fu(e){let t=wu(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};Os.input=t.tokens;let n=Os.program();for(let s of Os.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 $u(e){return e.includes("::")?e.replace(/(\w+)::(\w+)/g,"'$2'::$1"):e}function BT(e,t){return e==="NULL"||/^'[^']*'::\w+$/.test(e)?e:e.includes("::")?$u(e):`'${e}'::${t}`}function GT(){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 $T(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 ju(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??ys(n??""))+(i??"")}return e}function jT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wu(e,t){let r=e;for(let[n,i]of t.templateSubs){let o=jT(n),s=new RegExp(`\\{${o}\\}`,"g");r=r.replace(s,i)}return r=$u(r),r}function Ku(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
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 WT(e,t){let r=ju(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=BT(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 (${Wu(s.value??"",t)})`);break;case"OnDelete":o.push(`ON DELETE ${s.action??"NO ACTION"}`);break}return[...i,...o].join(" ")}function Hu(e,t,r){let n=t.columns.map(l=>ju(l,r)),i=n.join(", "),o=n.join("_"),s=`idx_${e}_${o}`,a=t.unique===!0?"UNIQUE ":"",c=t.using?`USING ${t.using} `:"";return`CREATE ${a}INDEX ${s} ON ${e} ${c}(${i});`}function KT(e,t,r){return` CHECK (${Wu(t.expression,r)})`}function HT(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}
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
115
  ${n} ${i} ON ${e}
116
- ${o} EXECUTE FUNCTION ${t.executeFunction}();`}function qu(e,t){let r=[];for(let n of e.mixins){let i=t.schemas.get(n);i&&r.push(...qu(i,t))}return r.push(...e.members),r}function Bu(e,t,r){let n=qu(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 Gu(e,t){if(t.generatedTables.has(e.tableName))return;t.generatedTables.add(e.tableName);let r=e.columns.map(s=>WT(s,t)),n=e.checks.map(s=>KT(e.tableName,s,t)),o=[...r,...n].join(`,
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
118
  ${o}
119
- );`);for(let s of e.indexes)t.indexSql.push(Hu(e.tableName,s,t));for(let s of e.triggers)t.triggerSql.push(HT(e.tableName,s,t))}function qT(e,t){t.extensionSql.push(`CREATE EXTENSION IF NOT EXISTS "${e.name}";`)}function zT(e,t){t.functionSql.push(`CREATE OR REPLACE FUNCTION ${e.name}()
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 VT(e,t){Ku(e,t)}function YT(e,t){t.schemas.set(e.name,e)}function XT(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=Bu(s,c,t);Gu(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"),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,ys(c.name)))}let o=r.members.filter(s=>s.type==="EnumDecl");for(let s of o)Ku(s,t);for(let s of n){let a=i.get(s.name);if(a){let c=Bu(s,a.name,t);Gu(c,t)}}}function QT(e,t){let r={type:"IndexDef",columns:e.columns,unique:e.unique,using:e.using};t.perInstanceIndexSql.push(Hu(e.tableName,r,t))}function zu(e){let t=GT();$T(e,t);for(let i of e.declarations)ZT(i,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
 
@@ -136,7 +136,7 @@ $$ LANGUAGE plpgsql;`)}function VT(e,t){Ku(e,t)}function YT(e,t){t.schemas.set(e
136
136
  `+r.join(`
137
137
 
138
138
  `)+`
139
- `}function ZT(e,t){switch(e.type){case"ExtensionDecl":qT(e,t);break;case"FunctionDecl":zT(e,t);break;case"EnumDecl":VT(e,t);break;case"SchemaDecl":YT(e,t);break;case"ConceptDecl":break;case"Instantiation":XT(e,t);break;case"PerInstanceIndex":QT(e,t);break}}function Vu(e){let t=[],r=Fu(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:zu(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 oS=rS(iS(import.meta.url)),sS=JSON.parse(Xu(nS(oS,"..","package.json"),"utf-8")),aS=sS.version,Mo=`
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
- `,Ls=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 cS(e){let t={command:"",inputFile:"",outputFile:null,verbose:!1,help:!1,version:!1},r=new Ls(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 lS(e,t,r){let n=`Error: ${e}`;return t!==void 0&&r!==void 0&&(n=`Error [${t}:${r}]: ${e}`),n}function uS(){let e=process.argv.slice(2),t=cS(e);t.help&&(console.log(Mo),process.exit(0)),t.version&&(console.log(`gsql version ${aS}`),process.exit(0)),t.command||(console.error("Error: No command specified"),console.log(Mo),process.exit(1)),t.command!=="compile"&&(console.error(`Error: Unknown command '${t.command}'`),console.log(Mo),process.exit(1)),t.inputFile||(console.error("Error: No input file specified"),console.log(Mo),process.exit(1));let r=Yu(process.cwd(),t.inputFile);tS(r)||(console.error(`Error: File not found: ${t.inputFile}`),process.exit(1));let n;try{n=Xu(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 ${eS(r)}...`);let i=Vu(n);if(!i.success){for(let o of i.errors)console.error(lS(o.message,o.location?.start.line,o.location?.start.column));process.exit(1)}if(t.outputFile){let o=Yu(process.cwd(),t.outputFile);try{JT(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)}uS();
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: