@jetstreamapp/soql-parser-js 6.1.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -3
- package/dist/cjs/index.js +143 -2
- package/dist/cli/index.js +148 -113
- package/dist/esm/index.mjs +143 -0
- package/dist/{cjs/src → types}/index.d.ts +1 -1
- package/package.json +23 -25
- package/dist/cjs/index.js.LICENSE.txt +0 -1
- package/dist/cjs/main.licenses.txt +0 -898
- package/dist/cjs/src/api/api-models.js +0 -2
- package/dist/cjs/src/api/public-utils.js +0 -175
- package/dist/cjs/src/composer/composer.js +0 -295
- package/dist/cjs/src/formatter/formatter.js +0 -236
- package/dist/cjs/src/index.js +0 -23
- package/dist/cjs/src/models.js +0 -2
- package/dist/cjs/src/parser/lexer.js +0 -954
- package/dist/cjs/src/parser/parser.js +0 -697
- package/dist/cjs/src/parser/visitor.js +0 -856
- package/dist/cjs/src/utils.js +0 -245
- package/dist/esm/api/api-models.js +0 -1
- package/dist/esm/api/public-utils.js +0 -153
- package/dist/esm/composer/composer.js +0 -273
- package/dist/esm/formatter/formatter.js +0 -223
- package/dist/esm/index.js +0 -4
- package/dist/esm/models.js +0 -1
- package/dist/esm/parser/lexer.js +0 -947
- package/dist/esm/parser/parser.js +0 -667
- package/dist/esm/parser/visitor.js +0 -823
- package/dist/esm/utils.js +0 -200
- package/dist/src/api/api-models.js +0 -2
- package/dist/src/api/public-utils.js +0 -203
- package/dist/src/composer/composer.js +0 -358
- package/dist/src/formatter/formatter.js +0 -263
- package/dist/src/index.js +0 -28
- package/dist/src/models.js +0 -2
- package/dist/src/parser/lexer.js +0 -997
- package/dist/src/parser/parser.js +0 -711
- package/dist/src/parser/visitor.js +0 -862
- package/dist/src/utils.js +0 -251
- /package/dist/{cjs/src → types}/api/api-models.d.ts +0 -0
- /package/dist/{cjs/src → types}/api/public-utils.d.ts +0 -0
- /package/dist/{cjs/src → types}/composer/composer.d.ts +0 -0
- /package/dist/{cjs/src → types}/formatter/formatter.d.ts +0 -0
- /package/dist/{cjs/src → types}/models.d.ts +0 -0
- /package/dist/{cjs/src → types}/parser/lexer.d.ts +0 -0
- /package/dist/{cjs/src → types}/parser/parser.d.ts +0 -0
- /package/dist/{cjs/src → types}/parser/visitor.d.ts +0 -0
- /package/dist/{cjs/src → types}/utils.d.ts +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
function qt(t){return t=Array.isArray(t)?t[0]:t,t.image&&!0}function Ls(t,e){return e}function k(t){return typeof t=="string"}function Vf(t){return t?t.every(e=>k(e)):!1}function xt(t){return Number.isFinite(t)}function ee(t){return t==null}function wt(t,e,r){return ee(t)?"":`${r||""}${t}${e||""}`}function ys(t,e=!1){return Array.isArray(t)?t.length>0?`(${t.join(", ")})`:e?"()":"":e?`(${t||""})`:t||""}function Ns(t,e,r=""){return xt(t)&&t>0?new Array(t).fill(e).join(r):""}function oo(t){return!t.parameters||t.parameters.length===0?[]:Vf(t.parameters)?t.parameters:k(t.parameters[0])?[t.parameters[0]]:oo(t.parameters[0])}function Os(t){if(!t.parameters||t.parameters.length===0)return!1;let e=t.parameters[0];return k(e)?!1:!!e.isAggregateFn}function An(t){return t&&!ee(t.alias)}function Rs(t){return k(t.field)&&!Array.isArray(t.relationships)&&!Array.isArray(t.conditions)}function Is(t){return!ee(t.functionName||t.fn)}function _s(t){return k(t.field)&&Array.isArray(t.relationships)}function bs(t){return!ee(t.subquery)}function vs(t){return k(t.field)&&Array.isArray(t.conditions)}function zt(t){return k(t.relationshipName)}function Ps(t){return!!t&&!!t.type&&t.type==="FieldSubquery"}function ao(t){return!!t&&!!t.operator&&!!t.right}function jf(t){return!!t&&!!t.operator&&!!t.right}function so(t){return!!t&&!!t.operator&&!!t.right}function Hf(t){return t&&k(t.field)&&k(t.operator)&&!ee(t.value)}function Kf(t){return t&&k(t.field)&&k(t.operator)&&!ee(t.value)&&(t.literalType==="DATE_LITERAL"||Array.isArray(t.literalType)&&t.literalType[0]==="DATE_LITERAL")}function Yf(t){return t&&k(t.field)&&k(t.operator)&&!ee(t.value)&&!ee(t.dateLiteralVariable)}function lo(t){return t&&!ee(t.fn)&&k(t.operator)&&!ee(t.value)}function Br(t){return t&&xt(t.openParen)&&ee(t.operator)&&ee(t.field)&&ee(t.fn)&&ee(t.closeParen)}function uo(t){return t&&k(t.field)&&k(t.operator)&&!ee(t.valueQuery)&&ee(t.value)}function co(t){return t&&!ee(t.field)}function Xf(t){return t&&!ee(t.fn)}function Tn(t){return t&&!ee(t.field)}function qf(t){return t&&!ee(t.fn)}function zf(t){return["IN","NOT IN","INCLUDES","EXCLUDES"].includes(t)}function Fs(t,e,r){if(ee(e))return t;if(r&&e!=="APEX_BIND_VARIABLE"&&zf(r)&&!Array.isArray(t)&&(t=[t],e=Array.isArray(e)?e:[e]),Array.isArray(e)&&Array.isArray(t))return t.map((n,i)=>Qf(n,e?.[i]));switch(Array.isArray(e)&&(e=e[0]),e){case"STRING":return Array.isArray(t)?t.filter(Boolean).map(n=>k(n)&&n.startsWith("'")?n:`'${n??""}'`):(t=String(t??""),k(t)&&t.startsWith("'")?t:`'${t??""}'`);case"APEX_BIND_VARIABLE":return`:${t}`;default:return t}}function Qf(t,e){switch(e){case"STRING":return k(t)&&t.startsWith("'")?t:`'${t??""}'`;default:return t}}var Jf=typeof global=="object"&&global&&global.Object===Object&&global,Sn=Jf;var ep=typeof self=="object"&&self&&self.Object===Object&&self,tp=Sn||ep||Function("return this")(),oe=tp;var rp=oe.Symbol,pe=rp;var Ms=Object.prototype,np=Ms.hasOwnProperty,ip=Ms.toString,Dr=pe?pe.toStringTag:void 0;function op(t){var e=np.call(t,Dr),r=t[Dr];try{t[Dr]=void 0;var n=!0}catch{}var i=ip.call(t);return n&&(e?t[Dr]=r:delete t[Dr]),i}var Us=op;var ap=Object.prototype,sp=ap.toString;function lp(t){return sp.call(t)}var ks=lp;var up="[object Null]",cp="[object Undefined]",ws=pe?pe.toStringTag:void 0;function fp(t){return t==null?t===void 0?cp:up:ws&&ws in Object(t)?Us(t):ks(t)}var Ae=fp;function pp(t){return t!=null&&typeof t=="object"}var te=pp;var hp="[object Symbol]";function dp(t){return typeof t=="symbol"||te(t)&&Ae(t)==hp}var At=dp;function mp(t,e){for(var r=-1,n=t==null?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var Ke=mp;var Ep=Array.isArray,C=Ep;var gp=1/0,Bs=pe?pe.prototype:void 0,Ds=Bs?Bs.toString:void 0;function Gs(t){if(typeof t=="string")return t;if(C(t))return Ke(t,Gs)+"";if(At(t))return Ds?Ds.call(t):"";var e=t+"";return e=="0"&&1/t==-gp?"-0":e}var Ws=Gs;var xp=/\s/;function Ap(t){for(var e=t.length;e--&&xp.test(t.charAt(e)););return e}var $s=Ap;var Tp=/^\s+/;function Sp(t){return t&&t.slice(0,$s(t)+1).replace(Tp,"")}var Vs=Sp;function Cp(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Y=Cp;var js=NaN,Lp=/^[-+]0x[0-9a-f]+$/i,yp=/^0b[01]+$/i,Np=/^0o[0-7]+$/i,Op=parseInt;function Rp(t){if(typeof t=="number")return t;if(At(t))return js;if(Y(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Y(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Vs(t);var r=yp.test(t);return r||Np.test(t)?Op(t.slice(2),r?2:8):Lp.test(t)?js:+t}var Hs=Rp;var Ks=1/0,Ip=17976931348623157e292;function _p(t){if(!t)return t===0?t:0;if(t=Hs(t),t===Ks||t===-Ks){var e=t<0?-1:1;return e*Ip}return t===t?t:0}var Ys=_p;function bp(t){var e=Ys(t),r=e%1;return e===e?r?e-r:e:0}var Ye=bp;function vp(t){return t}var ke=vp;var Pp="[object AsyncFunction]",Fp="[object Function]",Mp="[object GeneratorFunction]",Up="[object Proxy]";function kp(t){if(!Y(t))return!1;var e=Ae(t);return e==Fp||e==Mp||e==Pp||e==Up}var Te=kp;var wp=oe["__core-js_shared__"],Cn=wp;var Xs=function(){var t=/[^.]+$/.exec(Cn&&Cn.keys&&Cn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Bp(t){return!!Xs&&Xs in t}var qs=Bp;var Dp=Function.prototype,Gp=Dp.toString;function Wp(t){if(t!=null){try{return Gp.call(t)}catch{}try{return t+""}catch{}}return""}var lt=Wp;var $p=/[\\^$.*+?()[\]{}|]/g,Vp=/^\[object .+?Constructor\]$/,jp=Function.prototype,Hp=Object.prototype,Kp=jp.toString,Yp=Hp.hasOwnProperty,Xp=RegExp("^"+Kp.call(Yp).replace($p,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function qp(t){if(!Y(t)||qs(t))return!1;var e=Te(t)?Xp:Vp;return e.test(lt(t))}var zs=qp;function zp(t,e){return t?.[e]}var Qs=zp;function Qp(t,e){var r=Qs(t,e);return zs(r)?r:void 0}var Oe=Qp;var Zp=Oe(oe,"WeakMap"),Ln=Zp;var Zs=Object.create,Jp=function(){function t(){}return function(e){if(!Y(e))return{};if(Zs)return Zs(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Js=Jp;function eh(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var el=eh;function th(){}var X=th;function rh(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var tl=rh;var nh=800,ih=16,oh=Date.now;function ah(t){var e=0,r=0;return function(){var n=oh(),i=ih-(n-r);if(r=n,i>0){if(++e>=nh)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var rl=ah;function sh(t){return function(){return t}}var nl=sh;var lh=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Qt=lh;var uh=Qt?function(t,e){return Qt(t,"toString",{configurable:!0,enumerable:!1,value:nl(e),writable:!0})}:ke,il=uh;var ch=rl(il),ol=ch;function fh(t,e){for(var r=-1,n=t==null?0:t.length;++r<n&&e(t[r],r,t)!==!1;);return t}var yn=fh;function ph(t,e,r,n){for(var i=t.length,o=r+(n?1:-1);n?o--:++o<i;)if(e(t[o],o,t))return o;return-1}var Nn=ph;function hh(t){return t!==t}var al=hh;function dh(t,e,r){for(var n=r-1,i=t.length;++n<i;)if(t[n]===e)return n;return-1}var sl=dh;function mh(t,e,r){return e===e?sl(t,e,r):Nn(t,al,r)}var Zt=mh;function Eh(t,e){var r=t==null?0:t.length;return!!r&&Zt(t,e,0)>-1}var On=Eh;var gh=9007199254740991,xh=/^(?:0|[1-9]\d*)$/;function Ah(t,e){var r=typeof t;return e=e??gh,!!e&&(r=="number"||r!="symbol"&&xh.test(t))&&t>-1&&t%1==0&&t<e}var Tt=Ah;function Th(t,e,r){e=="__proto__"&&Qt?Qt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Jt=Th;function Sh(t,e){return t===e||t!==t&&e!==e}var Xe=Sh;var Ch=Object.prototype,Lh=Ch.hasOwnProperty;function yh(t,e,r){var n=t[e];(!(Lh.call(t,e)&&Xe(n,r))||r===void 0&&!(e in t))&&Jt(t,e,r)}var St=yh;function Nh(t,e,r,n){var i=!r;r||(r={});for(var o=-1,a=e.length;++o<a;){var s=e[o],l=n?n(r[s],t[s],s,r,t):void 0;l===void 0&&(l=t[s]),i?Jt(r,s,l):St(r,s,l)}return r}var qe=Nh;var ll=Math.max;function Oh(t,e,r){return e=ll(e===void 0?t.length-1:e,0),function(){for(var n=arguments,i=-1,o=ll(n.length-e,0),a=Array(o);++i<o;)a[i]=n[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=n[i];return s[e]=r(a),el(t,this,s)}}var ul=Oh;function Rh(t,e){return ol(ul(t,e,ke),t+"")}var er=Rh;var Ih=9007199254740991;function _h(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ih}var tr=_h;function bh(t){return t!=null&&tr(t.length)&&!Te(t)}var ae=bh;function vh(t,e,r){if(!Y(r))return!1;var n=typeof e;return(n=="number"?ae(r)&&Tt(e,r.length):n=="string"&&e in r)?Xe(r[e],t):!1}var Ct=vh;function Ph(t){return er(function(e,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(o=t.length>3&&typeof o=="function"?(i--,o):void 0,a&&Ct(r[0],r[1],a)&&(o=i<3?void 0:o,i=1),e=Object(e);++n<i;){var s=r[n];s&&t(e,s,n,o)}return e})}var cl=Ph;var Fh=Object.prototype;function Mh(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Fh;return t===r}var ze=Mh;function Uh(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var fl=Uh;var kh="[object Arguments]";function wh(t){return te(t)&&Ae(t)==kh}var fo=wh;var pl=Object.prototype,Bh=pl.hasOwnProperty,Dh=pl.propertyIsEnumerable,Gh=fo(function(){return arguments}())?fo:function(t){return te(t)&&Bh.call(t,"callee")&&!Dh.call(t,"callee")},Lt=Gh;function Wh(){return!1}var hl=Wh;var El=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dl=El&&typeof module=="object"&&module&&!module.nodeType&&module,$h=dl&&dl.exports===El,ml=$h?oe.Buffer:void 0,Vh=ml?ml.isBuffer:void 0,jh=Vh||hl,ut=jh;var Hh="[object Arguments]",Kh="[object Array]",Yh="[object Boolean]",Xh="[object Date]",qh="[object Error]",zh="[object Function]",Qh="[object Map]",Zh="[object Number]",Jh="[object Object]",ed="[object RegExp]",td="[object Set]",rd="[object String]",nd="[object WeakMap]",id="[object ArrayBuffer]",od="[object DataView]",ad="[object Float32Array]",sd="[object Float64Array]",ld="[object Int8Array]",ud="[object Int16Array]",cd="[object Int32Array]",fd="[object Uint8Array]",pd="[object Uint8ClampedArray]",hd="[object Uint16Array]",dd="[object Uint32Array]",V={};V[ad]=V[sd]=V[ld]=V[ud]=V[cd]=V[fd]=V[pd]=V[hd]=V[dd]=!0;V[Hh]=V[Kh]=V[id]=V[Yh]=V[od]=V[Xh]=V[qh]=V[zh]=V[Qh]=V[Zh]=V[Jh]=V[ed]=V[td]=V[rd]=V[nd]=!1;function md(t){return te(t)&&tr(t.length)&&!!V[Ae(t)]}var gl=md;function Ed(t){return function(e){return t(e)}}var Qe=Ed;var xl=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gr=xl&&typeof module=="object"&&module&&!module.nodeType&&module,gd=Gr&&Gr.exports===xl,po=gd&&Sn.process,xd=function(){try{var t=Gr&&Gr.require&&Gr.require("util").types;return t||po&&po.binding&&po.binding("util")}catch{}}(),we=xd;var Al=we&&we.isTypedArray,Ad=Al?Qe(Al):gl,rr=Ad;var Td=Object.prototype,Sd=Td.hasOwnProperty;function Cd(t,e){var r=C(t),n=!r&&Lt(t),i=!r&&!n&&ut(t),o=!r&&!n&&!i&&rr(t),a=r||n||i||o,s=a?fl(t.length,String):[],l=s.length;for(var c in t)(e||Sd.call(t,c))&&!(a&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Tt(c,l)))&&s.push(c);return s}var Rn=Cd;function Ld(t,e){return function(r){return t(e(r))}}var In=Ld;var yd=In(Object.keys,Object),Tl=yd;var Nd=Object.prototype,Od=Nd.hasOwnProperty;function Rd(t){if(!ze(t))return Tl(t);var e=[];for(var r in Object(t))Od.call(t,r)&&r!="constructor"&&e.push(r);return e}var _n=Rd;function Id(t){return ae(t)?Rn(t):_n(t)}var w=Id;var _d=Object.prototype,bd=_d.hasOwnProperty,vd=cl(function(t,e){if(ze(e)||ae(e)){qe(e,w(e),t);return}for(var r in e)bd.call(e,r)&&St(t,r,e[r])}),de=vd;function Pd(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Sl=Pd;var Fd=Object.prototype,Md=Fd.hasOwnProperty;function Ud(t){if(!Y(t))return Sl(t);var e=ze(t),r=[];for(var n in t)n=="constructor"&&(e||!Md.call(t,n))||r.push(n);return r}var Cl=Ud;function kd(t){return ae(t)?Rn(t,!0):Cl(t)}var yt=kd;var wd=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Bd=/^\w*$/;function Dd(t,e){if(C(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||At(t)?!0:Bd.test(t)||!wd.test(t)||e!=null&&t in Object(e)}var nr=Dd;var Gd=Oe(Object,"create"),ct=Gd;function Wd(){this.__data__=ct?ct(null):{},this.size=0}var Ll=Wd;function $d(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var yl=$d;var Vd="__lodash_hash_undefined__",jd=Object.prototype,Hd=jd.hasOwnProperty;function Kd(t){var e=this.__data__;if(ct){var r=e[t];return r===Vd?void 0:r}return Hd.call(e,t)?e[t]:void 0}var Nl=Kd;var Yd=Object.prototype,Xd=Yd.hasOwnProperty;function qd(t){var e=this.__data__;return ct?e[t]!==void 0:Xd.call(e,t)}var Ol=qd;var zd="__lodash_hash_undefined__";function Qd(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ct&&e===void 0?zd:e,this}var Rl=Qd;function ir(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ir.prototype.clear=Ll;ir.prototype.delete=yl;ir.prototype.get=Nl;ir.prototype.has=Ol;ir.prototype.set=Rl;var ho=ir;function Zd(){this.__data__=[],this.size=0}var Il=Zd;function Jd(t,e){for(var r=t.length;r--;)if(Xe(t[r][0],e))return r;return-1}var Nt=Jd;var em=Array.prototype,tm=em.splice;function rm(t){var e=this.__data__,r=Nt(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():tm.call(e,r,1),--this.size,!0}var _l=rm;function nm(t){var e=this.__data__,r=Nt(e,t);return r<0?void 0:e[r][1]}var bl=nm;function im(t){return Nt(this.__data__,t)>-1}var vl=im;function om(t,e){var r=this.__data__,n=Nt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Pl=om;function or(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}or.prototype.clear=Il;or.prototype.delete=_l;or.prototype.get=bl;or.prototype.has=vl;or.prototype.set=Pl;var Ot=or;var am=Oe(oe,"Map"),Rt=am;function sm(){this.size=0,this.__data__={hash:new ho,map:new(Rt||Ot),string:new ho}}var Fl=sm;function lm(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Ml=lm;function um(t,e){var r=t.__data__;return Ml(e)?r[typeof e=="string"?"string":"hash"]:r.map}var It=um;function cm(t){var e=It(this,t).delete(t);return this.size-=e?1:0,e}var Ul=cm;function fm(t){return It(this,t).get(t)}var kl=fm;function pm(t){return It(this,t).has(t)}var wl=pm;function hm(t,e){var r=It(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var Bl=hm;function ar(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ar.prototype.clear=Fl;ar.prototype.delete=Ul;ar.prototype.get=kl;ar.prototype.has=wl;ar.prototype.set=Bl;var Bt=ar;var dm="Expected a function";function mo(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(dm);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(mo.Cache||Bt),r}mo.Cache=Bt;var Dl=mo;var mm=500;function Em(t){var e=Dl(t,function(n){return r.size===mm&&r.clear(),n}),r=e.cache;return e}var Gl=Em;var gm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xm=/\\(\\)?/g,Am=Gl(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(gm,function(r,n,i,o){e.push(i?o.replace(xm,"$1"):n||r)}),e}),Wl=Am;function Tm(t){return t==null?"":Ws(t)}var $l=Tm;function Sm(t,e){return C(t)?t:nr(t,e)?[t]:Wl($l(t))}var _t=Sm;var Cm=1/0;function Lm(t){if(typeof t=="string"||At(t))return t;var e=t+"";return e=="0"&&1/t==-Cm?"-0":e}var Ze=Lm;function ym(t,e){e=_t(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Ze(e[r++])];return r&&r==n?t:void 0}var sr=ym;function Nm(t,e,r){var n=t==null?void 0:sr(t,e);return n===void 0?r:n}var Vl=Nm;function Om(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var lr=Om;var jl=pe?pe.isConcatSpreadable:void 0;function Rm(t){return C(t)||Lt(t)||!!(jl&&t&&t[jl])}var Hl=Rm;function Kl(t,e,r,n,i){var o=-1,a=t.length;for(r||(r=Hl),i||(i=[]);++o<a;){var s=t[o];e>0&&r(s)?e>1?Kl(s,e-1,r,n,i):lr(i,s):n||(i[i.length]=s)}return i}var ur=Kl;function Im(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var ue=Im;var _m=In(Object.getPrototypeOf,Object),bn=_m;function bm(t,e,r){var n=-1,i=t.length;e<0&&(e=-e>i?0:i+e),r=r>i?i:r,r<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++n<i;)o[n]=t[n+e];return o}var vn=bm;function vm(t,e,r,n){var i=-1,o=t==null?0:t.length;for(n&&o&&(r=t[++i]);++i<o;)r=e(r,t[i],i,t);return r}var Yl=vm;function Pm(){this.__data__=new Ot,this.size=0}var Xl=Pm;function Fm(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ql=Fm;function Mm(t){return this.__data__.get(t)}var zl=Mm;function Um(t){return this.__data__.has(t)}var Ql=Um;var km=200;function wm(t,e){var r=this.__data__;if(r instanceof Ot){var n=r.__data__;if(!Rt||n.length<km-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Bt(n)}return r.set(t,e),this.size=r.size,this}var Zl=wm;function cr(t){var e=this.__data__=new Ot(t);this.size=e.size}cr.prototype.clear=Xl;cr.prototype.delete=ql;cr.prototype.get=zl;cr.prototype.has=Ql;cr.prototype.set=Zl;var bt=cr;function Bm(t,e){return t&&qe(e,w(e),t)}var Jl=Bm;function Dm(t,e){return t&&qe(e,yt(e),t)}var eu=Dm;var iu=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tu=iu&&typeof module=="object"&&module&&!module.nodeType&&module,Gm=tu&&tu.exports===iu,ru=Gm?oe.Buffer:void 0,nu=ru?ru.allocUnsafe:void 0;function Wm(t,e){if(e)return t.slice();var r=t.length,n=nu?nu(r):new t.constructor(r);return t.copy(n),n}var ou=Wm;function $m(t,e){for(var r=-1,n=t==null?0:t.length,i=0,o=[];++r<n;){var a=t[r];e(a,r,t)&&(o[i++]=a)}return o}var fr=$m;function Vm(){return[]}var Pn=Vm;var jm=Object.prototype,Hm=jm.propertyIsEnumerable,au=Object.getOwnPropertySymbols,Km=au?function(t){return t==null?[]:(t=Object(t),fr(au(t),function(e){return Hm.call(t,e)}))}:Pn,pr=Km;function Ym(t,e){return qe(t,pr(t),e)}var su=Ym;var Xm=Object.getOwnPropertySymbols,qm=Xm?function(t){for(var e=[];t;)lr(e,pr(t)),t=bn(t);return e}:Pn,Fn=qm;function zm(t,e){return qe(t,Fn(t),e)}var lu=zm;function Qm(t,e,r){var n=e(t);return C(t)?n:lr(n,r(t))}var Mn=Qm;function Zm(t){return Mn(t,w,pr)}var Wr=Zm;function Jm(t){return Mn(t,yt,Fn)}var Un=Jm;var eE=Oe(oe,"DataView"),kn=eE;var tE=Oe(oe,"Promise"),wn=tE;var rE=Oe(oe,"Set"),vt=rE;var uu="[object Map]",nE="[object Object]",cu="[object Promise]",fu="[object Set]",pu="[object WeakMap]",hu="[object DataView]",iE=lt(kn),oE=lt(Rt),aE=lt(wn),sE=lt(vt),lE=lt(Ln),Dt=Ae;(kn&&Dt(new kn(new ArrayBuffer(1)))!=hu||Rt&&Dt(new Rt)!=uu||wn&&Dt(wn.resolve())!=cu||vt&&Dt(new vt)!=fu||Ln&&Dt(new Ln)!=pu)&&(Dt=function(t){var e=Ae(t),r=e==nE?t.constructor:void 0,n=r?lt(r):"";if(n)switch(n){case iE:return hu;case oE:return uu;case aE:return cu;case sE:return fu;case lE:return pu}return e});var We=Dt;var uE=Object.prototype,cE=uE.hasOwnProperty;function fE(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&cE.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var du=fE;var pE=oe.Uint8Array,hr=pE;function hE(t){var e=new t.constructor(t.byteLength);return new hr(e).set(new hr(t)),e}var dr=hE;function dE(t,e){var r=e?dr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var mu=dE;var mE=/\w*$/;function EE(t){var e=new t.constructor(t.source,mE.exec(t));return e.lastIndex=t.lastIndex,e}var Eu=EE;var gu=pe?pe.prototype:void 0,xu=gu?gu.valueOf:void 0;function gE(t){return xu?Object(xu.call(t)):{}}var Au=gE;function xE(t,e){var r=e?dr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Tu=xE;var AE="[object Boolean]",TE="[object Date]",SE="[object Map]",CE="[object Number]",LE="[object RegExp]",yE="[object Set]",NE="[object String]",OE="[object Symbol]",RE="[object ArrayBuffer]",IE="[object DataView]",_E="[object Float32Array]",bE="[object Float64Array]",vE="[object Int8Array]",PE="[object Int16Array]",FE="[object Int32Array]",ME="[object Uint8Array]",UE="[object Uint8ClampedArray]",kE="[object Uint16Array]",wE="[object Uint32Array]";function BE(t,e,r){var n=t.constructor;switch(e){case RE:return dr(t);case AE:case TE:return new n(+t);case IE:return mu(t,r);case _E:case bE:case vE:case PE:case FE:case ME:case UE:case kE:case wE:return Tu(t,r);case SE:return new n;case CE:case NE:return new n(t);case LE:return Eu(t);case yE:return new n;case OE:return Au(t)}}var Su=BE;function DE(t){return typeof t.constructor=="function"&&!ze(t)?Js(bn(t)):{}}var Cu=DE;var GE="[object Map]";function WE(t){return te(t)&&We(t)==GE}var Lu=WE;var yu=we&&we.isMap,$E=yu?Qe(yu):Lu,Nu=$E;var VE="[object Set]";function jE(t){return te(t)&&We(t)==VE}var Ou=jE;var Ru=we&&we.isSet,HE=Ru?Qe(Ru):Ou,Iu=HE;var KE=1,YE=2,XE=4,_u="[object Arguments]",qE="[object Array]",zE="[object Boolean]",QE="[object Date]",ZE="[object Error]",bu="[object Function]",JE="[object GeneratorFunction]",eg="[object Map]",tg="[object Number]",vu="[object Object]",rg="[object RegExp]",ng="[object Set]",ig="[object String]",og="[object Symbol]",ag="[object WeakMap]",sg="[object ArrayBuffer]",lg="[object DataView]",ug="[object Float32Array]",cg="[object Float64Array]",fg="[object Int8Array]",pg="[object Int16Array]",hg="[object Int32Array]",dg="[object Uint8Array]",mg="[object Uint8ClampedArray]",Eg="[object Uint16Array]",gg="[object Uint32Array]",B={};B[_u]=B[qE]=B[sg]=B[lg]=B[zE]=B[QE]=B[ug]=B[cg]=B[fg]=B[pg]=B[hg]=B[eg]=B[tg]=B[vu]=B[rg]=B[ng]=B[ig]=B[og]=B[dg]=B[mg]=B[Eg]=B[gg]=!0;B[ZE]=B[bu]=B[ag]=!1;function Bn(t,e,r,n,i,o){var a,s=e&KE,l=e&YE,c=e&XE;if(r&&(a=i?r(t,n,i,o):r(t)),a!==void 0)return a;if(!Y(t))return t;var p=C(t);if(p){if(a=du(t),!s)return tl(t,a)}else{var h=We(t),d=h==bu||h==JE;if(ut(t))return ou(t,s);if(h==vu||h==_u||d&&!i){if(a=l||d?{}:Cu(t),!s)return l?lu(t,eu(a,t)):su(t,Jl(a,t))}else{if(!B[h])return i?t:{};a=Su(t,h,s)}}o||(o=new bt);var A=o.get(t);if(A)return A;o.set(t,a),Iu(t)?t.forEach(function(O){a.add(Bn(O,e,r,O,t,o))}):Nu(t)&&t.forEach(function(O,S){a.set(S,Bn(O,e,r,S,t,o))});var L=c?l?Un:Wr:l?yt:w,y=p?void 0:L(t);return yn(y||t,function(O,S){y&&(S=O,O=t[S]),St(a,S,Bn(O,e,r,S,t,o))}),a}var Pu=Bn;var xg=4;function Ag(t){return Pu(t,xg)}var D=Ag;function Tg(t){for(var e=-1,r=t==null?0:t.length,n=0,i=[];++e<r;){var o=t[e];o&&(i[n++]=o)}return i}var Je=Tg;var Sg="__lodash_hash_undefined__";function Cg(t){return this.__data__.set(t,Sg),this}var Fu=Cg;function Lg(t){return this.__data__.has(t)}var Mu=Lg;function Dn(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Bt;++e<r;)this.add(t[e])}Dn.prototype.add=Dn.prototype.push=Fu;Dn.prototype.has=Mu;var mr=Dn;function yg(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var Gn=yg;function Ng(t,e){return t.has(e)}var Er=Ng;var Og=1,Rg=2;function Ig(t,e,r,n,i,o){var a=r&Og,s=t.length,l=e.length;if(s!=l&&!(a&&l>s))return!1;var c=o.get(t),p=o.get(e);if(c&&p)return c==e&&p==t;var h=-1,d=!0,A=r&Rg?new mr:void 0;for(o.set(t,e),o.set(e,t);++h<s;){var L=t[h],y=e[h];if(n)var O=a?n(y,L,h,e,t,o):n(L,y,h,t,e,o);if(O!==void 0){if(O)continue;d=!1;break}if(A){if(!Gn(e,function(S,g){if(!Er(A,g)&&(L===S||i(L,S,r,n,o)))return A.push(g)})){d=!1;break}}else if(!(L===y||i(L,y,r,n,o))){d=!1;break}}return o.delete(t),o.delete(e),d}var Wn=Ig;function _g(t){var e=-1,r=Array(t.size);return t.forEach(function(n,i){r[++e]=[i,n]}),r}var Uu=_g;function bg(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var gr=bg;var vg=1,Pg=2,Fg="[object Boolean]",Mg="[object Date]",Ug="[object Error]",kg="[object Map]",wg="[object Number]",Bg="[object RegExp]",Dg="[object Set]",Gg="[object String]",Wg="[object Symbol]",$g="[object ArrayBuffer]",Vg="[object DataView]",ku=pe?pe.prototype:void 0,Eo=ku?ku.valueOf:void 0;function jg(t,e,r,n,i,o,a){switch(r){case Vg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case $g:return!(t.byteLength!=e.byteLength||!o(new hr(t),new hr(e)));case Fg:case Mg:case wg:return Xe(+t,+e);case Ug:return t.name==e.name&&t.message==e.message;case Bg:case Gg:return t==e+"";case kg:var s=Uu;case Dg:var l=n&vg;if(s||(s=gr),t.size!=e.size&&!l)return!1;var c=a.get(t);if(c)return c==e;n|=Pg,a.set(t,e);var p=Wn(s(t),s(e),n,i,o,a);return a.delete(t),p;case Wg:if(Eo)return Eo.call(t)==Eo.call(e)}return!1}var wu=jg;var Hg=1,Kg=Object.prototype,Yg=Kg.hasOwnProperty;function Xg(t,e,r,n,i,o){var a=r&Hg,s=Wr(t),l=s.length,c=Wr(e),p=c.length;if(l!=p&&!a)return!1;for(var h=l;h--;){var d=s[h];if(!(a?d in e:Yg.call(e,d)))return!1}var A=o.get(t),L=o.get(e);if(A&&L)return A==e&&L==t;var y=!0;o.set(t,e),o.set(e,t);for(var O=a;++h<l;){d=s[h];var S=t[d],g=e[d];if(n)var m=a?n(g,S,d,e,t,o):n(S,g,d,t,e,o);if(!(m===void 0?S===g||i(S,g,r,n,o):m)){y=!1;break}O||(O=d=="constructor")}if(y&&!O){var I=t.constructor,_=e.constructor;I!=_&&"constructor"in t&&"constructor"in e&&!(typeof I=="function"&&I instanceof I&&typeof _=="function"&&_ instanceof _)&&(y=!1)}return o.delete(t),o.delete(e),y}var Bu=Xg;var qg=1,Du="[object Arguments]",Gu="[object Array]",$n="[object Object]",zg=Object.prototype,Wu=zg.hasOwnProperty;function Qg(t,e,r,n,i,o){var a=C(t),s=C(e),l=a?Gu:We(t),c=s?Gu:We(e);l=l==Du?$n:l,c=c==Du?$n:c;var p=l==$n,h=c==$n,d=l==c;if(d&&ut(t)){if(!ut(e))return!1;a=!0,p=!1}if(d&&!p)return o||(o=new bt),a||rr(t)?Wn(t,e,r,n,i,o):wu(t,e,l,r,n,i,o);if(!(r&qg)){var A=p&&Wu.call(t,"__wrapped__"),L=h&&Wu.call(e,"__wrapped__");if(A||L){var y=A?t.value():t,O=L?e.value():e;return o||(o=new bt),i(y,O,r,n,o)}}return d?(o||(o=new bt),Bu(t,e,r,n,i,o)):!1}var $u=Qg;function Vu(t,e,r,n,i){return t===e?!0:t==null||e==null||!te(t)&&!te(e)?t!==t&&e!==e:$u(t,e,r,n,Vu,i)}var Vn=Vu;var Zg=1,Jg=2;function ex(t,e,r,n){var i=r.length,o=i,a=!n;if(t==null)return!o;for(t=Object(t);i--;){var s=r[i];if(a&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++i<o;){s=r[i];var l=s[0],c=t[l],p=s[1];if(a&&s[2]){if(c===void 0&&!(l in t))return!1}else{var h=new bt;if(n)var d=n(c,p,l,t,e,h);if(!(d===void 0?Vn(p,c,Zg|Jg,n,h):d))return!1}}return!0}var ju=ex;function tx(t){return t===t&&!Y(t)}var jn=tx;function rx(t){for(var e=w(t),r=e.length;r--;){var n=e[r],i=t[n];e[r]=[n,i,jn(i)]}return e}var Hu=rx;function nx(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var Hn=nx;function ix(t){var e=Hu(t);return e.length==1&&e[0][2]?Hn(e[0][0],e[0][1]):function(r){return r===t||ju(r,t,e)}}var Ku=ix;function ox(t,e){return t!=null&&e in Object(t)}var Yu=ox;function ax(t,e,r){e=_t(e,t);for(var n=-1,i=e.length,o=!1;++n<i;){var a=Ze(e[n]);if(!(o=t!=null&&r(t,a)))break;t=t[a]}return o||++n!=i?o:(i=t==null?0:t.length,!!i&&tr(i)&&Tt(a,i)&&(C(t)||Lt(t)))}var Kn=ax;function sx(t,e){return t!=null&&Kn(t,e,Yu)}var Xu=sx;var lx=1,ux=2;function cx(t,e){return nr(t)&&jn(e)?Hn(Ze(t),e):function(r){var n=Vl(r,t);return n===void 0&&n===e?Xu(r,t):Vn(e,n,lx|ux)}}var qu=cx;function fx(t){return function(e){return e?.[t]}}var zu=fx;function px(t){return function(e){return sr(e,t)}}var Qu=px;function hx(t){return nr(t)?zu(Ze(t)):Qu(t)}var Zu=hx;function dx(t){return typeof t=="function"?t:t==null?ke:typeof t=="object"?C(t)?qu(t[0],t[1]):Ku(t):Zu(t)}var se=dx;function mx(t,e,r,n){for(var i=-1,o=t==null?0:t.length;++i<o;){var a=t[i];e(n,a,r(a),t)}return n}var Ju=mx;function Ex(t){return function(e,r,n){for(var i=-1,o=Object(e),a=n(e),s=a.length;s--;){var l=a[t?s:++i];if(r(o[l],l,o)===!1)break}return e}}var ec=Ex;var gx=ec(),tc=gx;function xx(t,e){return t&&tc(t,e,w)}var rc=xx;function Ax(t,e){return function(r,n){if(r==null)return r;if(!ae(r))return t(r,n);for(var i=r.length,o=e?i:-1,a=Object(r);(e?o--:++o<i)&&n(a[o],o,a)!==!1;);return r}}var nc=Ax;var Tx=nc(rc),Re=Tx;function Sx(t,e,r,n){return Re(t,function(i,o,a){e(n,i,r(i),a)}),n}var ic=Sx;function Cx(t,e){return function(r,n){var i=C(r)?Ju:ic,o=e?e():{};return i(r,t,se(n,2),o)}}var oc=Cx;var ac=Object.prototype,Lx=ac.hasOwnProperty,yx=er(function(t,e){t=Object(t);var r=-1,n=e.length,i=n>2?e[2]:void 0;for(i&&Ct(e[0],e[1],i)&&(n=1);++r<n;)for(var o=e[r],a=yt(o),s=-1,l=a.length;++s<l;){var c=a[s],p=t[c];(p===void 0||Xe(p,ac[c])&&!Lx.call(t,c))&&(t[c]=o[c])}return t}),xr=yx;function Nx(t){return te(t)&&ae(t)}var go=Nx;function Ox(t,e,r){for(var n=-1,i=t==null?0:t.length;++n<i;)if(r(e,t[n]))return!0;return!1}var Yn=Ox;var Rx=200;function Ix(t,e,r,n){var i=-1,o=On,a=!0,s=t.length,l=[],c=e.length;if(!s)return l;r&&(e=Ke(e,Qe(r))),n?(o=Yn,a=!1):e.length>=Rx&&(o=Er,a=!1,e=new mr(e));e:for(;++i<s;){var p=t[i],h=r==null?p:r(p);if(p=n||p!==0?p:0,a&&h===h){for(var d=c;d--;)if(e[d]===h)continue e;l.push(p)}else o(e,h,n)||l.push(p)}return l}var sc=Ix;var _x=er(function(t,e){return go(t)?sc(t,ur(e,1,go,!0)):[]}),Pt=_x;function bx(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}var et=bx;function vx(t,e,r){var n=t==null?0:t.length;return n?(e=r||e===void 0?1:Ye(e),vn(t,e<0?0:e,n)):[]}var re=vx;function Px(t,e,r){var n=t==null?0:t.length;return n?(e=r||e===void 0?1:Ye(e),e=n-e,vn(t,0,e<0?0:e)):[]}var ft=Px;function Fx(t){return typeof t=="function"?t:ke}var lc=Fx;function Mx(t,e){var r=C(t)?yn:Re;return r(t,lc(e))}var x=Mx;function Ux(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(!e(t[r],r,t))return!1;return!0}var uc=Ux;function kx(t,e){var r=!0;return Re(t,function(n,i,o){return r=!!e(n,i,o),r}),r}var cc=kx;function wx(t,e,r){var n=C(t)?uc:cc;return r&&Ct(t,e,r)&&(e=void 0),n(t,se(e,3))}var Ee=wx;function Bx(t,e){var r=[];return Re(t,function(n,i,o){e(n,i,o)&&r.push(n)}),r}var Xn=Bx;function Dx(t,e){var r=C(t)?fr:Xn;return r(t,se(e,3))}var ge=Dx;function Gx(t){return function(e,r,n){var i=Object(e);if(!ae(e)){var o=se(r,3);e=w(e),r=function(s){return o(i[s],s,i)}}var a=t(e,r,n);return a>-1?i[o?e[a]:a]:void 0}}var fc=Gx;var Wx=Math.max;function $x(t,e,r){var n=t==null?0:t.length;if(!n)return-1;var i=r==null?0:Ye(r);return i<0&&(i=Wx(n+i,0)),Nn(t,se(e,3),i)}var pc=$x;var Vx=fc(pc),tt=Vx;function jx(t){return t&&t.length?t[0]:void 0}var he=jx;function Hx(t,e){var r=-1,n=ae(t)?Array(t.length):[];return Re(t,function(i,o,a){n[++r]=e(i,o,a)}),n}var hc=Hx;function Kx(t,e){var r=C(t)?Ke:hc;return r(t,se(e,3))}var E=Kx;function Yx(t,e){return ur(E(t,e),1)}var Se=Yx;var Xx=Object.prototype,qx=Xx.hasOwnProperty,zx=oc(function(t,e,r){qx.call(t,r)?t[r].push(e):Jt(t,r,[e])}),xo=zx;var Qx=Object.prototype,Zx=Qx.hasOwnProperty;function Jx(t,e){return t!=null&&Zx.call(t,e)}var dc=Jx;function eA(t,e){return t!=null&&Kn(t,e,dc)}var T=eA;var tA="[object String]";function rA(t){return typeof t=="string"||!C(t)&&te(t)&&Ae(t)==tA}var ce=rA;function nA(t,e){return Ke(e,function(r){return t[r]})}var mc=nA;function iA(t){return t==null?[]:mc(t,w(t))}var M=iA;var oA=Math.max;function aA(t,e,r,n){t=ae(t)?t:M(t),r=r&&!n?Ye(r):0;var i=t.length;return r<0&&(r=oA(i+r,0)),ce(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&Zt(t,e,r)>-1}var H=aA;var sA=Math.max;function lA(t,e,r){var n=t==null?0:t.length;if(!n)return-1;var i=r==null?0:Ye(r);return i<0&&(i=sA(n+i,0)),Zt(t,e,i)}var qn=lA;var uA="[object Map]",cA="[object Set]",fA=Object.prototype,pA=fA.hasOwnProperty;function hA(t){if(t==null)return!0;if(ae(t)&&(C(t)||typeof t=="string"||typeof t.splice=="function"||ut(t)||rr(t)||Lt(t)))return!t.length;var e=We(t);if(e==uA||e==cA)return!t.size;if(ze(t))return!_n(t).length;for(var r in t)if(pA.call(t,r))return!1;return!0}var v=hA;var dA="[object RegExp]";function mA(t){return te(t)&&Ae(t)==dA}var Ec=mA;var gc=we&&we.isRegExp,EA=gc?Qe(gc):Ec,Be=EA;function gA(t){return t===void 0}var xe=gA;var xA="Expected a function";function AA(t){if(typeof t!="function")throw new TypeError(xA);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}var xc=AA;function TA(t,e,r,n){if(!Y(t))return t;e=_t(e,t);for(var i=-1,o=e.length,a=o-1,s=t;s!=null&&++i<o;){var l=Ze(e[i]),c=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return t;if(i!=a){var p=s[l];c=n?n(p,l,s):void 0,c===void 0&&(c=Y(p)?p:Tt(e[i+1])?[]:{})}St(s,l,c),s=s[l]}return t}var Ac=TA;function SA(t,e,r){for(var n=-1,i=e.length,o={};++n<i;){var a=e[n],s=sr(t,a);r(s,a)&&Ac(o,_t(a,t),s)}return o}var Tc=SA;function CA(t,e){if(t==null)return{};var r=Ke(Un(t),function(n){return[n]});return e=se(e),Tc(t,r,function(n,i){return e(n,i[0])})}var Ie=CA;function LA(t,e,r,n,i){return i(t,function(o,a,s){r=n?(n=!1,o):e(r,o,a,s)}),r}var Sc=LA;function yA(t,e,r){var n=C(t)?Yl:Sc,i=arguments.length<3;return n(t,se(e,4),r,i,Re)}var le=yA;function NA(t,e){var r=C(t)?fr:Xn;return r(t,xc(se(e,3)))}var Ft=NA;function OA(t,e){var r;return Re(t,function(n,i,o){return r=e(n,i,o),!r}),!!r}var Cc=OA;function RA(t,e,r){var n=C(t)?Gn:Cc;return r&&Ct(t,e,r)&&(e=void 0),n(t,se(e,3))}var $r=RA;var IA=1/0,_A=vt&&1/gr(new vt([,-0]))[1]==IA?function(t){return new vt(t)}:X,Lc=_A;var bA=200;function vA(t,e,r){var n=-1,i=On,o=t.length,a=!0,s=[],l=s;if(r)a=!1,i=Yn;else if(o>=bA){var c=e?null:Lc(t);if(c)return gr(c);a=!1,i=Er,l=new mr}else l=e?[]:s;e:for(;++n<o;){var p=t[n],h=e?e(p):p;if(p=r||p!==0?p:0,a&&h===h){for(var d=l.length;d--;)if(l[d]===h)continue e;e&&l.push(h),s.push(p)}else i(l,h,r)||(l!==s&&l.push(h),s.push(p))}return s}var yc=vA;function PA(t){return t&&t.length?yc(t):[]}var Ar=PA;function Tr(t){console&&console.error&&console.error(`Error: ${t}`)}function Vr(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function jr(t){let e=new Date().getTime(),r=t();return{time:new Date().getTime()-e,value:r}}function Hr(t){function e(){}e.prototype=t;let r=new e;function n(){return typeof r.bar}return n(),n(),t;(0,eval)(t)}function FA(t){return MA(t)?t.LABEL:t.name}function MA(t){return ce(t.LABEL)&&t.LABEL!==""}var Pe=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),x(this.definition,r=>{r.accept(e)})}},G=class extends Pe{constructor(e){super([]),this.idx=1,de(this,Ie(e,r=>r!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},Ce=class extends Pe{constructor(e){super(e.definition),this.orgText="",de(this,Ie(e,r=>r!==void 0))}},W=class extends Pe{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,de(this,Ie(e,r=>r!==void 0))}},j=class extends Pe{constructor(e){super(e.definition),this.idx=1,de(this,Ie(e,r=>r!==void 0))}},ne=class extends Pe{constructor(e){super(e.definition),this.idx=1,de(this,Ie(e,r=>r!==void 0))}},ie=class extends Pe{constructor(e){super(e.definition),this.idx=1,de(this,Ie(e,r=>r!==void 0))}},F=class extends Pe{constructor(e){super(e.definition),this.idx=1,de(this,Ie(e,r=>r!==void 0))}},Z=class extends Pe{constructor(e){super(e.definition),this.idx=1,de(this,Ie(e,r=>r!==void 0))}},J=class extends Pe{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,de(this,Ie(e,r=>r!==void 0))}},P=class{constructor(e){this.idx=1,de(this,Ie(e,r=>r!==void 0))}accept(e){e.visit(this)}};function zn(t){return E(t,Sr)}function Sr(t){function e(r){return E(r,Sr)}if(t instanceof G){let r={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return ce(t.label)&&(r.label=t.label),r}else{if(t instanceof W)return{type:"Alternative",definition:e(t.definition)};if(t instanceof j)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof ne)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof ie)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:Sr(new P({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof Z)return{type:"RepetitionWithSeparator",idx:t.idx,separator:Sr(new P({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof F)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof J)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof P){let r={type:"Terminal",name:t.terminalType.name,label:FA(t.terminalType),idx:t.idx};ce(t.label)&&(r.terminalLabel=t.label);let n=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(r.pattern=Be(n)?n.source:n),r}else{if(t instanceof Ce)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}}var Le=class{visit(e){let r=e;switch(r.constructor){case G:return this.visitNonTerminal(r);case W:return this.visitAlternative(r);case j:return this.visitOption(r);case ne:return this.visitRepetitionMandatory(r);case ie:return this.visitRepetitionMandatoryWithSeparator(r);case Z:return this.visitRepetitionWithSeparator(r);case F:return this.visitRepetition(r);case J:return this.visitAlternation(r);case P:return this.visitTerminal(r);case Ce:return this.visitRule(r);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function Ao(t){return t instanceof W||t instanceof j||t instanceof F||t instanceof ne||t instanceof ie||t instanceof Z||t instanceof P||t instanceof Ce}function Gt(t,e=[]){return t instanceof j||t instanceof F||t instanceof Z?!0:t instanceof J?$r(t.definition,n=>Gt(n,e)):t instanceof G&&H(e,t)?!1:t instanceof Pe?(t instanceof G&&e.push(t),Ee(t.definition,n=>Gt(n,e))):!1}function To(t){return t instanceof J}function _e(t){if(t instanceof G)return"SUBRULE";if(t instanceof j)return"OPTION";if(t instanceof J)return"OR";if(t instanceof ne)return"AT_LEAST_ONE";if(t instanceof ie)return"AT_LEAST_ONE_SEP";if(t instanceof Z)return"MANY_SEP";if(t instanceof F)return"MANY";if(t instanceof P)return"CONSUME";throw Error("non exhaustive match")}var pt=class{walk(e,r=[]){x(e.definition,(n,i)=>{let o=re(e.definition,i+1);if(n instanceof G)this.walkProdRef(n,o,r);else if(n instanceof P)this.walkTerminal(n,o,r);else if(n instanceof W)this.walkFlat(n,o,r);else if(n instanceof j)this.walkOption(n,o,r);else if(n instanceof ne)this.walkAtLeastOne(n,o,r);else if(n instanceof ie)this.walkAtLeastOneSep(n,o,r);else if(n instanceof Z)this.walkManySep(n,o,r);else if(n instanceof F)this.walkMany(n,o,r);else if(n instanceof J)this.walkOr(n,o,r);else throw Error("non exhaustive match")})}walkTerminal(e,r,n){}walkProdRef(e,r,n){}walkFlat(e,r,n){let i=r.concat(n);this.walk(e,i)}walkOption(e,r,n){let i=r.concat(n);this.walk(e,i)}walkAtLeastOne(e,r,n){let i=[new j({definition:e.definition})].concat(r,n);this.walk(e,i)}walkAtLeastOneSep(e,r,n){let i=Nc(e,r,n);this.walk(e,i)}walkMany(e,r,n){let i=[new j({definition:e.definition})].concat(r,n);this.walk(e,i)}walkManySep(e,r,n){let i=Nc(e,r,n);this.walk(e,i)}walkOr(e,r,n){let i=r.concat(n);x(e.definition,o=>{let a=new W({definition:[o]});this.walk(a,i)})}};function Nc(t,e,r){return[new j({definition:[new P({terminalType:t.separator})].concat(t.definition)})].concat(e,r)}function Wt(t){if(t instanceof G)return Wt(t.referencedRule);if(t instanceof P)return wA(t);if(Ao(t))return UA(t);if(To(t))return kA(t);throw Error("non exhaustive match")}function UA(t){let e=[],r=t.definition,n=0,i=r.length>n,o,a=!0;for(;i&&a;)o=r[n],a=Gt(o),e=e.concat(Wt(o)),n=n+1,i=r.length>n;return Ar(e)}function kA(t){let e=E(t.definition,r=>Wt(r));return Ar(ue(e))}function wA(t){return[t.terminalType]}var Qn="_~IN~_";var So=class extends pt{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,r,n){}walkProdRef(e,r,n){let i=BA(e.referencedRule,e.idx)+this.topProd.name,o=r.concat(n),a=new W({definition:o}),s=Wt(a);this.follows[i]=s}};function Oc(t){let e={};return x(t,r=>{let n=new So(r).startWalking();de(e,n)}),e}function BA(t,e){return t.name+e+Qn}function N(t){return t.charCodeAt(0)}function Zn(t,e){Array.isArray(t)?t.forEach(function(r){e.push(r)}):e.push(t)}function Cr(t,e){if(t[e]===!0)throw"duplicate flag "+e;let r=t[e];t[e]=!0}function $t(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function Kr(){throw Error("Internal Error - Should never get here!")}function Co(t){return t.type==="Character"}var Yr=[];for(let t=N("0");t<=N("9");t++)Yr.push(t);var Xr=[N("_")].concat(Yr);for(let t=N("a");t<=N("z");t++)Xr.push(t);for(let t=N("A");t<=N("Z");t++)Xr.push(t);var Lo=[N(" "),N("\f"),N(`
|
|
2
|
+
`),N("\r"),N(" "),N("\v"),N(" "),N("\xA0"),N("\u1680"),N("\u2000"),N("\u2001"),N("\u2002"),N("\u2003"),N("\u2004"),N("\u2005"),N("\u2006"),N("\u2007"),N("\u2008"),N("\u2009"),N("\u200A"),N("\u2028"),N("\u2029"),N("\u202F"),N("\u205F"),N("\u3000"),N("\uFEFF")];var DA=/[0-9a-fA-F]/,Jn=/[0-9]/,GA=/[1-9]/,qr=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let r=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Cr(n,"global");break;case"i":Cr(n,"ignoreCase");break;case"m":Cr(n,"multiLine");break;case"u":Cr(n,"unicode");break;case"y":Cr(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 e=[],r=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(r)}}alternative(){let e=[],r=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(r)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let r;switch(this.popChar()){case"=":r="Lookahead";break;case"!":r="NegativeLookahead";break}$t(r);let n=this.disjunction();return this.consumeChar(")"),{type:r,value:n,loc:this.loc(e)}}return Kr()}quantifier(e=!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(e===!0&&r===void 0)return;$t(r);break}if(!(e===!0&&r===void 0)&&$t(r))return this.peekChar(0)==="?"?(this.consumeChar("?"),r.greedy=!1):r.greedy=!0,r.type="Quantifier",r.loc=this.loc(n),r}atom(){let e,r=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),$t(e)?(e.loc=this.loc(r),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):Kr()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[N(`
|
|
3
|
+
`),N("\r"),N("\u2028"),N("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,r=!1;switch(this.popChar()){case"d":e=Yr;break;case"D":e=Yr,r=!0;break;case"s":e=Lo;break;case"S":e=Lo,r=!0;break;case"w":e=Xr;break;case"W":e=Xr,r=!0;break}return $t(e)?{type:"Set",value:e,complement:r}:Kr()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=N("\f");break;case"n":e=N(`
|
|
4
|
+
`);break;case"r":e=N("\r");break;case"t":e=N(" ");break;case"v":e=N("\v");break}return $t(e)?{type:"Character",value:e}:Kr()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:N("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:N(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
5
|
+
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:N(e)}}}characterClass(){let e=[],r=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),r=!0);this.isClassAtom();){let n=this.classAtom(),i=n.type==="Character";if(Co(n)&&this.isRangeDash()){this.consumeChar("-");let o=this.classAtom(),a=o.type==="Character";if(Co(o)){if(o.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:o.value})}else Zn(n.value,e),e.push(N("-")),Zn(o.value,e)}else Zn(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:r,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
6
|
+
`: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:N("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}let r=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:e,value:r};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(GA.test(e)===!1)throw Error("Expecting a positive integer");for(;Jn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Jn.test(e)===!1)throw Error("Expecting an integer");for(;Jn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
|
|
7
|
+
`: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:N(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return Jn.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
|
|
8
|
+
`: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 e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
|
|
9
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let r="";for(let i=0;i<e;i++){let o=this.popChar();if(DA.test(o)===!1)throw Error("Expecting a HexDecimal digits");r+=o}return{type:"Character",value:parseInt(r,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}};var Mt=class{visitChildren(e){for(let r in e){let n=e[r];e.hasOwnProperty(r)&&(n.type!==void 0?this.visit(n):Array.isArray(n)&&n.forEach(i=>{this.visit(i)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};var ei={},WA=new qr;function Lr(t){let e=t.toString();if(ei.hasOwnProperty(e))return ei[e];{let r=WA.pattern(e);return ei[e]=r,r}}function Rc(){ei={}}var _c="Complement Sets are not supported for first char optimization",zr=`Unable to use "first char" lexer optimizations:
|
|
10
|
+
`;function bc(t,e=!1){try{let r=Lr(t);return yo(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===_c)e&&Vr(`${zr} Unable to optimize: < ${t.toString()} >
|
|
11
|
+
Complement Sets cannot be automatically optimized.
|
|
12
|
+
This will disable the lexer's first char optimizations.
|
|
13
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";e&&(n=`
|
|
14
|
+
This will disable the lexer's first char optimizations.
|
|
15
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Tr(`${zr}
|
|
16
|
+
Failed parsing: < ${t.toString()} >
|
|
17
|
+
Using the @chevrotain/regexp-to-ast library
|
|
18
|
+
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function yo(t,e,r){switch(t.type){case"Disjunction":for(let i=0;i<t.value.length;i++)yo(t.value[i],e,r);break;case"Alternative":let n=t.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 a=o;switch(a.type){case"Character":ti(a.value,e,r);break;case"Set":if(a.complement===!0)throw Error(_c);x(a.value,l=>{if(typeof l=="number")ti(l,e,r);else{let c=l;if(r===!0)for(let p=c.from;p<=c.to;p++)ti(p,e,r);else{for(let p=c.from;p<=c.to&&p<yr;p++)ti(p,e,r);if(c.to>=yr){let p=c.from>=yr?c.from:yr,h=c.to,d=rt(p),A=rt(h);for(let L=d;L<=A;L++)e[L]=L}}}});break;case"Group":yo(a.value,e,r);break;default:throw Error("Non Exhaustive Match")}let s=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&No(a)===!1||a.type!=="Group"&&s===!1)break}break;default:throw Error("non exhaustive match!")}return M(e)}function ti(t,e,r){let n=rt(t);e[n]=n,r===!0&&$A(t,e)}function $A(t,e){let r=String.fromCharCode(t),n=r.toUpperCase();if(n!==r){let i=rt(n.charCodeAt(0));e[i]=i}else{let i=r.toLowerCase();if(i!==r){let o=rt(i.charCodeAt(0));e[o]=o}}}function Ic(t,e){return tt(t.value,r=>{if(typeof r=="number")return H(e,r);{let n=r;return tt(e,i=>n.from<=i&&i<=n.to)!==void 0}})}function No(t){let e=t.quantifier;return e&&e.atLeast===0?!0:t.value?C(t.value)?Ee(t.value,No):No(t.value):!1}var Oo=class extends Mt{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){H(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?Ic(e,this.targetCharCodes)===void 0&&(this.found=!0):Ic(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function ri(t,e){if(e instanceof RegExp){let r=Lr(e),n=new Oo(t);return n.visit(r),n.found}else return tt(e,r=>H(t,r.charCodeAt(0)))!==void 0}var Vt="PATTERN",Nr="defaultMode",ni="modes",Io=typeof new RegExp("(?:)").sticky=="boolean";function Fc(t,e){e=xr(e,{useSticky:Io,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
19
|
+
`],tracer:(g,m)=>m()});let r=e.tracer;r("initCharCodeToOptimizedIndexMap",()=>{aT()});let n;r("Reject Lexer.NA",()=>{n=Ft(t,g=>g[Vt]===b.NA)});let i=!1,o;r("Transform Patterns",()=>{i=!1,o=E(n,g=>{let m=g[Vt];if(Be(m)){let I=m.source;return I.length===1&&I!=="^"&&I!=="$"&&I!=="."&&!m.ignoreCase?I:I.length===2&&I[0]==="\\"&&!H(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],I[1])?I[1]:e.useSticky?Pc(m):vc(m)}else{if(Te(m))return i=!0,{exec:m};if(typeof m=="object")return i=!0,m;if(typeof m=="string"){if(m.length===1)return m;{let I=m.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),_=new RegExp(I);return e.useSticky?Pc(_):vc(_)}}else throw Error("non exhaustive match")}})});let a,s,l,c,p;r("misc mapping",()=>{a=E(n,g=>g.tokenTypeIdx),s=E(n,g=>{let m=g.GROUP;if(m!==b.SKIPPED){if(ce(m))return m;if(xe(m))return!1;throw Error("non exhaustive match")}}),l=E(n,g=>{let m=g.LONGER_ALT;if(m)return C(m)?E(m,_=>qn(n,_)):[qn(n,m)]}),c=E(n,g=>g.PUSH_MODE),p=E(n,g=>T(g,"POP_MODE"))});let h;r("Line Terminator Handling",()=>{let g=Wc(e.lineTerminatorCharacters);h=E(n,m=>!1),e.positionTracking!=="onlyOffset"&&(h=E(n,m=>T(m,"LINE_BREAKS")?!!m.LINE_BREAKS:Gc(m,g)===!1&&ri(g,m.PATTERN)))});let d,A,L,y;r("Misc Mapping #2",()=>{d=E(n,Bc),A=E(o,iT),L=le(n,(g,m)=>{let I=m.GROUP;return ce(I)&&I!==b.SKIPPED&&(g[I]=[]),g},{}),y=E(o,(g,m)=>({pattern:o[m],longerAlt:l[m],canLineTerminator:h[m],isCustom:d[m],short:A[m],group:s[m],push:c[m],pop:p[m],tokenTypeIdx:a[m],tokenType:n[m]}))});let O=!0,S=[];return e.safeMode||r("First Char Optimization",()=>{S=le(n,(g,m,I)=>{if(typeof m.PATTERN=="string"){let _=m.PATTERN.charCodeAt(0),be=rt(_);Ro(g,be,y[I])}else if(C(m.START_CHARS_HINT)){let _;x(m.START_CHARS_HINT,be=>{let to=typeof be=="string"?be.charCodeAt(0):be,He=rt(to);_!==He&&(_=He,Ro(g,He,y[I]))})}else if(Be(m.PATTERN))if(m.PATTERN.unicode)O=!1,e.ensureOptimizations&&Tr(`${zr} Unable to analyze < ${m.PATTERN.toString()} > pattern.
|
|
20
|
+
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
21
|
+
This will disable the lexer's first char optimizations.
|
|
22
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let _=bc(m.PATTERN,e.ensureOptimizations);v(_)&&(O=!1),x(_,be=>{Ro(g,be,y[I])})}else e.ensureOptimizations&&Tr(`${zr} TokenType: <${m.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
23
|
+
This will disable the lexer's first char optimizations.
|
|
24
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),O=!1;return g},[])}),{emptyGroups:L,patternIdxToConfig:y,charCodeToPatternIdxToConfig:S,hasCustom:i,canBeOptimized:O}}function Mc(t,e){let r=[],n=jA(t);r=r.concat(n.errors);let i=HA(n.valid),o=i.valid;return r=r.concat(i.errors),r=r.concat(VA(o)),r=r.concat(JA(o)),r=r.concat(eT(o,e)),r=r.concat(tT(o)),r}function VA(t){let e=[],r=ge(t,n=>Be(n[Vt]));return e=e.concat(YA(r)),e=e.concat(zA(r)),e=e.concat(QA(r)),e=e.concat(ZA(r)),e=e.concat(XA(r)),e}function jA(t){let e=ge(t,i=>!T(i,Vt)),r=E(e,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:K.MISSING_PATTERN,tokenTypes:[i]})),n=Pt(t,e);return{errors:r,valid:n}}function HA(t){let e=ge(t,i=>{let o=i[Vt];return!Be(o)&&!Te(o)&&!T(o,"exec")&&!ce(o)}),r=E(e,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:K.INVALID_PATTERN,tokenTypes:[i]})),n=Pt(t,e);return{errors:r,valid:n}}var KA=/[^\\][$]/;function YA(t){class e extends Mt{constructor(){super(...arguments),this.found=!1}visitEndAnchor(o){this.found=!0}}let r=ge(t,i=>{let o=i.PATTERN;try{let a=Lr(o),s=new e;return s.visit(a),s.found}catch{return KA.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
25
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
26
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:K.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function XA(t){let e=ge(t,n=>n.PATTERN.test(""));return E(e,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:K.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var qA=/[^\\[][\^]|^\^/;function zA(t){class e extends Mt{constructor(){super(...arguments),this.found=!1}visitStartAnchor(o){this.found=!0}}let r=ge(t,i=>{let o=i.PATTERN;try{let a=Lr(o),s=new e;return s.visit(a),s.found}catch{return qA.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
27
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
28
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:K.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function QA(t){let e=ge(t,n=>{let i=n[Vt];return i instanceof RegExp&&(i.multiline||i.global)});return E(e,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:K.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function ZA(t){let e=[],r=E(t,o=>le(t,(a,s)=>(o.PATTERN.source===s.PATTERN.source&&!H(e,s)&&s.PATTERN!==b.NA&&(e.push(s),a.push(s)),a),[]));r=Je(r);let n=ge(r,o=>o.length>1);return E(n,o=>{let a=E(o,l=>l.name);return{message:`The same RegExp pattern ->${he(o).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:K.DUPLICATE_PATTERNS_FOUND,tokenTypes:o}})}function JA(t){let e=ge(t,n=>{if(!T(n,"GROUP"))return!1;let i=n.GROUP;return i!==b.SKIPPED&&i!==b.NA&&!ce(i)});return E(e,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:K.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function eT(t,e){let r=ge(t,i=>i.PUSH_MODE!==void 0&&!H(e,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:K.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function tT(t){let e=[],r=le(t,(n,i,o)=>{let a=i.PATTERN;return a===b.NA||(ce(a)?n.push({str:a,idx:o,tokenType:i}):Be(a)&&nT(a)&&n.push({str:a.source,idx:o,tokenType:i})),n},[]);return x(t,(n,i)=>{x(r,({str:o,idx:a,tokenType:s})=>{if(i<a&&rT(o,n.PATTERN)){let l=`Token: ->${s.name}<- can never be matched.
|
|
29
|
+
Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition.
|
|
30
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:l,type:K.UNREACHABLE_PATTERN,tokenTypes:[n,s]})}})}),e}function rT(t,e){if(Be(e)){let r=e.exec(t);return r!==null&&r.index===0}else{if(Te(e))return e(t,0,[],{});if(T(e,"exec"))return e.exec(t,0,[],{});if(typeof e=="string")return e===t;throw Error("non exhaustive match")}}function nT(t){return tt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>t.source.indexOf(r)!==-1)===void 0}function vc(t){let e=t.ignoreCase?"i":"";return new RegExp(`^(?:${t.source})`,e)}function Pc(t){let e=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,e)}function Uc(t,e,r){let n=[];return T(t,Nr)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Nr+`> property in its definition
|
|
31
|
+
`,type:K.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),T(t,ni)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+ni+`> property in its definition
|
|
32
|
+
`,type:K.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),T(t,ni)&&T(t,Nr)&&!T(t.modes,t.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${Nr}: <${t.defaultMode}>which does not exist
|
|
33
|
+
`,type:K.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),T(t,ni)&&x(t.modes,(i,o)=>{x(i,(a,s)=>{if(xe(a))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${o}> at index: <${s}>
|
|
34
|
+
`,type:K.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(T(a,"LONGER_ALT")){let l=C(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];x(l,c=>{!xe(c)&&!H(i,c)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${c.name}> on token <${a.name}> outside of mode <${o}>
|
|
35
|
+
`,type:K.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function kc(t,e,r){let n=[],i=!1,o=Je(ue(M(t.modes))),a=Ft(o,l=>l[Vt]===b.NA),s=Wc(r);return e&&x(a,l=>{let c=Gc(l,s);if(c!==!1){let h={message:oT(l,c),type:c.issue,tokenType:l};n.push(h)}else T(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):ri(s,l.PATTERN)&&(i=!0)}),e&&!i&&n.push({message:`Warning: No LINE_BREAKS Found.
|
|
36
|
+
This Lexer has been defined to track line and column information,
|
|
37
|
+
But none of the Token Types can be identified as matching a line terminator.
|
|
38
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
39
|
+
for details.`,type:K.NO_LINE_BREAKS_FLAGS}),n}function wc(t){let e={},r=w(t);return x(r,n=>{let i=t[n];if(C(i))e[n]=[];else throw Error("non exhaustive match")}),e}function Bc(t){let e=t.PATTERN;if(Be(e))return!1;if(Te(e))return!0;if(T(e,"exec"))return!0;if(ce(e))return!1;throw Error("non exhaustive match")}function iT(t){return ce(t)&&t.length===1?t.charCodeAt(0):!1}var Dc={test:function(t){let e=t.length;for(let r=this.lastIndex;r<e;r++){let n=t.charCodeAt(r);if(n===10)return this.lastIndex=r+1,!0;if(n===13)return t.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},lastIndex:0};function Gc(t,e){if(T(t,"LINE_BREAKS"))return!1;if(Be(t.PATTERN)){try{ri(e,t.PATTERN)}catch(r){return{issue:K.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(ce(t.PATTERN))return!1;if(Bc(t))return{issue:K.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function oT(t,e){if(e.issue===K.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
40
|
+
The problem is in the <${t.name}> Token Type
|
|
41
|
+
Root cause: ${e.errMsg}.
|
|
42
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===K.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
43
|
+
The problem is in the <${t.name}> Token Type
|
|
44
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function Wc(t){return E(t,r=>ce(r)?r.charCodeAt(0):r)}function Ro(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}var yr=256,ii=[];function rt(t){return t<yr?t:ii[t]}function aT(){if(v(ii)){ii=new Array(65536);for(let t=0;t<65536;t++)ii[t]=t>255?255+~~(t/255):t}}function ht(t,e){let r=t.tokenTypeIdx;return r===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[r]===!0}function Or(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}var $c=1,jc={};function dt(t){let e=sT(t);lT(e),cT(e),uT(e),x(e,r=>{r.isParent=r.categoryMatches.length>0})}function sT(t){let e=D(t),r=t,n=!0;for(;n;){r=Je(ue(E(r,o=>o.CATEGORIES)));let i=Pt(r,e);e=e.concat(i),v(i)?n=!1:r=i}return e}function lT(t){x(t,e=>{_o(e)||(jc[$c]=e,e.tokenTypeIdx=$c++),Vc(e)&&!C(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Vc(e)||(e.CATEGORIES=[]),fT(e)||(e.categoryMatches=[]),pT(e)||(e.categoryMatchesMap={})})}function uT(t){x(t,e=>{e.categoryMatches=[],x(e.categoryMatchesMap,(r,n)=>{e.categoryMatches.push(jc[n].tokenTypeIdx)})})}function cT(t){x(t,e=>{Hc([],e)})}function Hc(t,e){x(t,r=>{e.categoryMatchesMap[r.tokenTypeIdx]=!0}),x(e.CATEGORIES,r=>{let n=t.concat(e);H(n,r)||Hc(n,r)})}function _o(t){return T(t,"tokenTypeIdx")}function Vc(t){return T(t,"CATEGORIES")}function fT(t){return T(t,"categoryMatches")}function pT(t){return T(t,"categoryMatchesMap")}function Kc(t){return T(t,"tokenTypeIdx")}var bo={buildUnableToPopLexerModeMessage(t){return`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(t,e,r,n,i){return`unexpected character: ->${t.charAt(e)}<- at offset: ${e}, skipped ${r} characters.`}};var K;(function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",t[t.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(K||(K={}));var Qr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
45
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:bo,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Qr);var b=class{constructor(e,r=Qr){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,o)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${a}--> <${i}>`);let{time:s,value:l}=jr(o),c=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&c(`${a}<-- <${i}> time: ${s}ms`),this.traceInitIndent--,l}else return o()},typeof r=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
46
|
+
a boolean 2nd argument is no longer supported`);this.config=de({},Qr,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===Qr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Dc;else if(this.config.lineTerminatorCharacters===Qr.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
47
|
+
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),C(e)?i={modes:{defaultMode:D(e)},defaultMode:Nr}:(o=!1,i=D(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Uc(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(kc(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},x(i.modes,(s,l)=>{i.modes[l]=Ft(s,c=>xe(c))});let a=w(i.modes);if(x(i.modes,(s,l)=>{this.TRACE_INIT(`Mode: <${l}> processing`,()=>{if(this.modes.push(l),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Mc(s,a))}),v(this.lexerDefinitionErrors)){dt(s);let c;this.TRACE_INIT("analyzeTokenTypes",()=>{c=Fc(s,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:r.positionTracking,ensureOptimizations:r.ensureOptimizations,safeMode:r.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[l]=c.patternIdxToConfig,this.charCodeToPatternIdxToConfig[l]=c.charCodeToPatternIdxToConfig,this.emptyGroups=de({},this.emptyGroups,c.emptyGroups),this.hasCustom=c.hasCustom||this.hasCustom,this.canModeBeOptimized[l]=c.canBeOptimized}})}),this.defaultMode=i.defaultMode,!v(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let l=E(this.lexerDefinitionErrors,c=>c.message).join(`-----------------------
|
|
48
|
+
`);throw new Error(`Errors detected in definition of Lexer:
|
|
49
|
+
`+l)}x(this.lexerDefinitionWarning,s=>{Vr(s.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(Io?(this.chopInput=ke,this.match=this.matchWithTest):(this.updateLastIndex=X,this.match=this.matchWithExec),o&&(this.handleModes=X),this.trackStartLines===!1&&(this.computeNewColumn=ke),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=X),/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 s=le(this.canModeBeOptimized,(l,c,p)=>(c===!1&&l.push(p),l),[]);if(r.ensureOptimizations&&!v(s))throw Error(`Lexer Modes: < ${s.join(", ")} > cannot be optimized.
|
|
50
|
+
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
51
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Rc()}),this.TRACE_INIT("toFastProperties",()=>{Hr(this)})})}tokenize(e,r=this.defaultMode){if(!v(this.lexerDefinitionErrors)){let i=E(this.lexerDefinitionErrors,o=>o.message).join(`-----------------------
|
|
52
|
+
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
53
|
+
`+i)}return this.tokenizeInternal(e,r)}tokenizeInternal(e,r){let n,i,o,a,s,l,c,p,h,d,A,L,y,O,S,g,m=e,I=m.length,_=0,be=0,to=this.hasCustom?0:Math.floor(e.length/10),He=new Array(to),ro=[],Mr=this.trackStartLines?1:void 0,mt=this.trackStartLines?1:void 0,Ur=wc(this.emptyGroups),Wf=this.trackStartLines,no=this.config.lineTerminatorsPattern,gn=0,Et=[],kr=[],xn=[],gs=[];Object.freeze(gs);let wr;function xs(){return Et}function As(me){let Ue=rt(me),Xt=kr[Ue];return Xt===void 0?gs:Xt}let $f=me=>{if(xn.length===1&&me.tokenType.PUSH_MODE===void 0){let Ue=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(me);ro.push({offset:me.startOffset,line:me.startLine,column:me.startColumn,length:me.image.length,message:Ue})}else{xn.pop();let Ue=et(xn);Et=this.patternIdxToConfig[Ue],kr=this.charCodeToPatternIdxToConfig[Ue],gn=Et.length;let Xt=this.canModeBeOptimized[Ue]&&this.config.safeMode===!1;kr&&Xt?wr=As:wr=xs}};function Ts(me){xn.push(me),kr=this.charCodeToPatternIdxToConfig[me],Et=this.patternIdxToConfig[me],gn=Et.length,gn=Et.length;let Ue=this.canModeBeOptimized[me]&&this.config.safeMode===!1;kr&&Ue?wr=As:wr=xs}Ts.call(this,r);let Ge,Ss=this.config.recoveryEnabled;for(;_<I;){l=null;let me=m.charCodeAt(_),Ue=wr(me),Xt=Ue.length;for(n=0;n<Xt;n++){Ge=Ue[n];let ve=Ge.pattern;c=null;let at=Ge.short;if(at!==!1?me===at&&(l=ve):Ge.isCustom===!0?(g=ve.exec(m,_,He,Ur),g!==null?(l=g[0],g.payload!==void 0&&(c=g.payload)):l=null):(this.updateLastIndex(ve,_),l=this.match(ve,e,_)),l!==null){if(s=Ge.longerAlt,s!==void 0){let gt=s.length;for(o=0;o<gt;o++){let st=Et[s[o]],kt=st.pattern;if(p=null,st.isCustom===!0?(g=kt.exec(m,_,He,Ur),g!==null?(a=g[0],g.payload!==void 0&&(p=g.payload)):a=null):(this.updateLastIndex(kt,_),a=this.match(kt,e,_)),a&&a.length>l.length){l=a,c=p,Ge=st;break}}}break}}if(l!==null){if(h=l.length,d=Ge.group,d!==void 0&&(A=Ge.tokenTypeIdx,L=this.createTokenInstance(l,_,A,Ge.tokenType,Mr,mt,h),this.handlePayload(L,c),d===!1?be=this.addToken(He,be,L):Ur[d].push(L)),e=this.chopInput(e,h),_=_+h,mt=this.computeNewColumn(mt,h),Wf===!0&&Ge.canLineTerminator===!0){let ve=0,at,gt;no.lastIndex=0;do at=no.test(l),at===!0&&(gt=no.lastIndex-1,ve++);while(at===!0);ve!==0&&(Mr=Mr+ve,mt=h-gt,this.updateTokenEndLineColumnLocation(L,d,gt,ve,Mr,mt,h))}this.handleModes(Ge,$f,Ts,L)}else{let ve=_,at=Mr,gt=mt,st=Ss===!1;for(;st===!1&&_<I;)for(e=this.chopInput(e,1),_++,i=0;i<gn;i++){let kt=Et[i],io=kt.pattern,Cs=kt.short;if(Cs!==!1?m.charCodeAt(_)===Cs&&(st=!0):kt.isCustom===!0?st=io.exec(m,_,He,Ur)!==null:(this.updateLastIndex(io,_),st=io.exec(e)!==null),st===!0)break}if(y=_-ve,mt=this.computeNewColumn(mt,y),S=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(m,ve,y,at,gt),ro.push({offset:ve,line:at,column:gt,length:y,message:S}),Ss===!1)break}}return this.hasCustom||(He.length=be),{tokens:He,groups:Ur,errors:ro}}handleModes(e,r,n,i){if(e.pop===!0){let o=e.push;r(i),o!==void 0&&n.call(this,o)}else e.push!==void 0&&n.call(this,e.push)}chopInput(e,r){return e.substring(r)}updateLastIndex(e,r){e.lastIndex=r}updateTokenEndLineColumnLocation(e,r,n,i,o,a,s){let l,c;r!==void 0&&(l=n===s-1,c=l?-1:0,i===1&&l===!0||(e.endLine=o+c,e.endColumn=a-1+-c))}computeNewColumn(e,r){return e+r}createOffsetOnlyToken(e,r,n,i){return{image:e,startOffset:r,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(e,r,n,i,o,a){return{image:e,startOffset:r,startLine:o,startColumn:a,tokenTypeIdx:n,tokenType:i}}createFullToken(e,r,n,i,o,a,s){return{image:e,startOffset:r,endOffset:r+s-1,startLine:o,endLine:o,startColumn:a,endColumn:a+s-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(e,r,n){return e.push(n),r}addTokenUsingMemberAccess(e,r,n){return e[r]=n,r++,r}handlePayloadNoCustom(e,r){}handlePayloadWithCustom(e,r){r!==null&&(e.payload=r)}matchWithTest(e,r,n){return e.test(r)===!0?r.substring(n,e.lastIndex):null}matchWithExec(e,r){let n=e.exec(r);return n!==null?n[0]:null}};b.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.";b.NA=/NOT_APPLICABLE/;function jt(t){return vo(t)?t.LABEL:t.name}function vo(t){return ce(t.LABEL)&&t.LABEL!==""}var hT="parent",Yc="categories",Xc="label",qc="group",zc="push_mode",Qc="pop_mode",Zc="longer_alt",Jc="line_breaks",ef="start_chars_hint";function f(t){return dT(t)}function dT(t){let e=t.pattern,r={};if(r.name=t.name,xe(e)||(r.PATTERN=e),T(t,hT))throw`The parent property is no longer supported.
|
|
54
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return T(t,Yc)&&(r.CATEGORIES=t[Yc]),dt([r]),T(t,Xc)&&(r.LABEL=t[Xc]),T(t,qc)&&(r.GROUP=t[qc]),T(t,Qc)&&(r.POP_MODE=t[Qc]),T(t,zc)&&(r.PUSH_MODE=t[zc]),T(t,Zc)&&(r.LONGER_ALT=t[Zc]),T(t,Jc)&&(r.LINE_BREAKS=t[Jc]),T(t,ef)&&(r.START_CHARS_HINT=t[ef]),r}var $e=f({name:"EOF",pattern:b.NA});dt([$e]);function Ht(t,e,r,n,i,o,a,s){return{image:e,startOffset:r,endOffset:n,startLine:i,endLine:o,startColumn:a,endColumn:s,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function Po(t,e){return ht(t,e)}var oi={buildMismatchTokenMessage({expected:t,actual:e,previous:r,ruleName:n}){return`Expecting ${vo(t)?`--> ${jt(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:t,ruleName:e}){return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage({expectedPathsPerAlt:t,actual:e,previous:r,customUserDescription:n,ruleName:i}){let o="Expecting: ",s=`
|
|
55
|
+
but found: '`+he(e).image+"'";if(n)return o+n+s;{let l=le(t,(d,A)=>d.concat(A),[]),c=E(l,d=>`[${E(d,A=>jt(A)).join(", ")}]`),h=`one of these possible Token sequences:
|
|
56
|
+
${E(c,(d,A)=>` ${A+1}. ${d}`).join(`
|
|
57
|
+
`)}`;return o+h+s}},buildEarlyExitMessage({expectedIterationPaths:t,actual:e,customUserDescription:r,ruleName:n}){let i="Expecting: ",a=`
|
|
58
|
+
but found: '`+he(e).image+"'";if(r)return i+r+a;{let l=`expecting at least one iteration which starts with one of these possible Token sequences::
|
|
59
|
+
<${E(t,c=>`[${E(c,p=>jt(p)).join(",")}]`).join(" ,")}>`;return i+l+a}}};Object.freeze(oi);var tf={buildRuleNotFoundError(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
|
|
60
|
+
inside top level rule: ->`+t.name+"<-"}},Ve={buildDuplicateFoundError(t,e){function r(p){return p instanceof P?p.terminalType.name:p instanceof G?p.nonTerminalName:""}let n=t.name,i=he(e),o=i.idx,a=_e(i),s=r(i),l=o>0,c=`->${a}${l?o:""}<- ${s?`with argument: ->${s}<-`:""}
|
|
61
|
+
appears more than once (${e.length} times) in the top level rule: ->${n}<-.
|
|
62
|
+
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
63
|
+
`;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,`
|
|
64
|
+
`),c},buildNamespaceConflictError(t){return`Namespace conflict found in grammar.
|
|
65
|
+
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${t.name}>.
|
|
66
|
+
To resolve this make sure each Terminal and Non-Terminal names are unique
|
|
67
|
+
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
|
|
68
|
+
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(t){let e=E(t.prefixPath,i=>jt(i)).join(", "),r=t.alternation.idx===0?"":t.alternation.idx;return`Ambiguous alternatives: <${t.ambiguityIndices.join(" ,")}> due to common lookahead prefix
|
|
69
|
+
in <OR${r}> inside <${t.topLevelRule.name}> Rule,
|
|
70
|
+
<${e}> may appears as a prefix path in all these alternatives.
|
|
71
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
|
|
72
|
+
For Further details.`},buildAlternationAmbiguityError(t){let e=E(t.prefixPath,i=>jt(i)).join(", "),r=t.alternation.idx===0?"":t.alternation.idx,n=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(" ,")}> in <OR${r}> inside <${t.topLevelRule.name}> Rule,
|
|
73
|
+
<${e}> may appears as a prefix path in all these alternatives.
|
|
74
|
+
`;return n=n+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
75
|
+
For Further details.`,n},buildEmptyRepetitionError(t){let e=_e(t.repetition);return t.repetition.idx!==0&&(e+=t.repetition.idx),`The repetition <${e}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
|
|
76
|
+
This could lead to an infinite loop.`},buildTokenNameError(t){return"deprecated"},buildEmptyAlternationError(t){return`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
|
|
77
|
+
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(t){return`An Alternation cannot have more than 256 alternatives:
|
|
78
|
+
<OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
|
|
79
|
+
has ${t.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(t){let e=t.topLevelRule.name,r=E(t.leftRecursionPath,o=>o.name),n=`${e} --> ${r.concat([e]).join(" --> ")}`;return`Left Recursion found in grammar.
|
|
80
|
+
rule: <${e}> can be invoked from itself (directly or indirectly)
|
|
81
|
+
without consuming any Tokens. The grammar path that causes this is:
|
|
82
|
+
${n}
|
|
83
|
+
To fix this refactor your grammar to remove the left recursion.
|
|
84
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let e;return t.topLevelRule instanceof Ce?e=t.topLevelRule.name:e=t.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};function rf(t,e){let r=new Fo(t,e);return r.resolveRefs(),r.errors}var Fo=class extends Le{constructor(e,r){super(),this.nameToTopRule=e,this.errMsgProvider=r,this.errors=[]}resolveRefs(){x(M(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let r=this.nameToTopRule[e.nonTerminalName];if(r)e.referencedRule=r;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:fe.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}};var Mo=class extends pt{constructor(e,r){super(),this.topProd=e,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=D(this.path.ruleStack).reverse(),this.occurrenceStack=D(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,r=[]){this.found||super.walk(e,r)}walkProdRef(e,r,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=r.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){v(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},ai=class extends Mo{constructor(e,r){super(e,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,r,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=r.concat(n),o=new W({definition:i});this.possibleTokTypes=Wt(o),this.found=!0}}},Rr=class extends pt{constructor(e,r){super(),this.topRule=e,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},si=class extends Rr{walkMany(e,r,n){if(e.idx===this.occurrence){let i=he(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof P&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,r,n)}},Zr=class extends Rr{walkManySep(e,r,n){if(e.idx===this.occurrence){let i=he(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof P&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,r,n)}},li=class extends Rr{walkAtLeastOne(e,r,n){if(e.idx===this.occurrence){let i=he(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof P&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,r,n)}},Jr=class extends Rr{walkAtLeastOneSep(e,r,n){if(e.idx===this.occurrence){let i=he(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof P&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,r,n)}};function ui(t,e,r=[]){r=D(r);let n=[],i=0;function o(s){return s.concat(re(t,i+1))}function a(s){let l=ui(o(s),e,r);return n.concat(l)}for(;r.length<e&&i<t.length;){let s=t[i];if(s instanceof W)return a(s.definition);if(s instanceof G)return a(s.definition);if(s instanceof j)n=a(s.definition);else if(s instanceof ne){let l=s.definition.concat([new F({definition:s.definition})]);return a(l)}else if(s instanceof ie){let l=[new W({definition:s.definition}),new F({definition:[new P({terminalType:s.separator})].concat(s.definition)})];return a(l)}else if(s instanceof Z){let l=s.definition.concat([new F({definition:[new P({terminalType:s.separator})].concat(s.definition)})]);n=a(l)}else if(s instanceof F){let l=s.definition.concat([new F({definition:s.definition})]);n=a(l)}else{if(s instanceof J)return x(s.definition,l=>{v(l.definition)===!1&&(n=a(l.definition))}),n;if(s instanceof P)r.push(s.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:re(t,i)}),n}function ci(t,e,r,n){let i="EXIT_NONE_TERMINAL",o=[i],a="EXIT_ALTERNATIVE",s=!1,l=e.length,c=l-n-1,p=[],h=[];for(h.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!v(h);){let d=h.pop();if(d===a){s&&et(h).idx<=c&&h.pop();continue}let A=d.def,L=d.idx,y=d.ruleStack,O=d.occurrenceStack;if(v(A))continue;let S=A[0];if(S===i){let g={idx:L,def:re(A),ruleStack:ft(y),occurrenceStack:ft(O)};h.push(g)}else if(S instanceof P)if(L<l-1){let g=L+1,m=e[g];if(r(m,S.terminalType)){let I={idx:g,def:re(A),ruleStack:y,occurrenceStack:O};h.push(I)}}else if(L===l-1)p.push({nextTokenType:S.terminalType,nextTokenOccurrence:S.idx,ruleStack:y,occurrenceStack:O}),s=!0;else throw Error("non exhaustive match");else if(S instanceof G){let g=D(y);g.push(S.nonTerminalName);let m=D(O);m.push(S.idx);let I={idx:L,def:S.definition.concat(o,re(A)),ruleStack:g,occurrenceStack:m};h.push(I)}else if(S instanceof j){let g={idx:L,def:re(A),ruleStack:y,occurrenceStack:O};h.push(g),h.push(a);let m={idx:L,def:S.definition.concat(re(A)),ruleStack:y,occurrenceStack:O};h.push(m)}else if(S instanceof ne){let g=new F({definition:S.definition,idx:S.idx}),m=S.definition.concat([g],re(A)),I={idx:L,def:m,ruleStack:y,occurrenceStack:O};h.push(I)}else if(S instanceof ie){let g=new P({terminalType:S.separator}),m=new F({definition:[g].concat(S.definition),idx:S.idx}),I=S.definition.concat([m],re(A)),_={idx:L,def:I,ruleStack:y,occurrenceStack:O};h.push(_)}else if(S instanceof Z){let g={idx:L,def:re(A),ruleStack:y,occurrenceStack:O};h.push(g),h.push(a);let m=new P({terminalType:S.separator}),I=new F({definition:[m].concat(S.definition),idx:S.idx}),_=S.definition.concat([I],re(A)),be={idx:L,def:_,ruleStack:y,occurrenceStack:O};h.push(be)}else if(S instanceof F){let g={idx:L,def:re(A),ruleStack:y,occurrenceStack:O};h.push(g),h.push(a);let m=new F({definition:S.definition,idx:S.idx}),I=S.definition.concat([m],re(A)),_={idx:L,def:I,ruleStack:y,occurrenceStack:O};h.push(_)}else if(S instanceof J)for(let g=S.definition.length-1;g>=0;g--){let m=S.definition[g],I={idx:L,def:m.definition.concat(re(A)),ruleStack:y,occurrenceStack:O};h.push(I),h.push(a)}else if(S instanceof W)h.push({idx:L,def:S.definition.concat(re(A)),ruleStack:y,occurrenceStack:O});else if(S instanceof Ce)h.push(mT(S,L,y,O));else throw Error("non exhaustive match")}return p}function mT(t,e,r,n){let i=D(r);i.push(t.name);let o=D(n);return o.push(1),{idx:e,def:t.definition,ruleStack:i,occurrenceStack:o}}var q;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(q||(q={}));function pi(t){if(t instanceof j||t==="Option")return q.OPTION;if(t instanceof F||t==="Repetition")return q.REPETITION;if(t instanceof ne||t==="RepetitionMandatory")return q.REPETITION_MANDATORY;if(t instanceof ie||t==="RepetitionMandatoryWithSeparator")return q.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof Z||t==="RepetitionWithSeparator")return q.REPETITION_WITH_SEPARATOR;if(t instanceof J||t==="Alternation")return q.ALTERNATION;throw Error("non exhaustive match")}function of(t,e,r,n,i,o){let a=en(t,e,r),s=ff(a)?Or:ht;return o(a,n,s,i)}function af(t,e,r,n,i,o){let a=tn(t,e,i,r),s=ff(a)?Or:ht;return o(a[0],s,n)}function sf(t,e,r,n){let i=t.length,o=Ee(t,a=>Ee(a,s=>s.length===1));if(e)return function(a){let s=E(a,l=>l.GATE);for(let l=0;l<i;l++){let c=t[l],p=c.length,h=s[l];if(!(h!==void 0&&h.call(this)===!1))e:for(let d=0;d<p;d++){let A=c[d],L=A.length;for(let y=0;y<L;y++){let O=this.LA(y+1);if(r(O,A[y])===!1)continue e}return l}}};if(o&&!n){let a=E(t,l=>ue(l)),s=le(a,(l,c,p)=>(x(c,h=>{T(l,h.tokenTypeIdx)||(l[h.tokenTypeIdx]=p),x(h.categoryMatches,d=>{T(l,d)||(l[d]=p)})}),l),{});return function(){let l=this.LA(1);return s[l.tokenTypeIdx]}}else return function(){for(let a=0;a<i;a++){let s=t[a],l=s.length;e:for(let c=0;c<l;c++){let p=s[c],h=p.length;for(let d=0;d<h;d++){let A=this.LA(d+1);if(r(A,p[d])===!1)continue e}return a}}}}function lf(t,e,r){let n=Ee(t,o=>o.length===1),i=t.length;if(n&&!r){let o=ue(t);if(o.length===1&&v(o[0].categoryMatches)){let s=o[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===s}}else{let a=le(o,(s,l,c)=>(s[l.tokenTypeIdx]=!0,x(l.categoryMatches,p=>{s[p]=!0}),s),[]);return function(){let s=this.LA(1);return a[s.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<i;o++){let a=t[o],s=a.length;for(let l=0;l<s;l++){let c=this.LA(l+1);if(e(c,a[l])===!1)continue e}return!0}return!1}}var ko=class extends pt{constructor(e,r,n){super(),this.topProd=e,this.targetOccurrence=r,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,r,n,i){return e.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=n.concat(i),!0):!1}walkOption(e,r,n){this.checkIsTarget(e,q.OPTION,r,n)||super.walkOption(e,r,n)}walkAtLeastOne(e,r,n){this.checkIsTarget(e,q.REPETITION_MANDATORY,r,n)||super.walkOption(e,r,n)}walkAtLeastOneSep(e,r,n){this.checkIsTarget(e,q.REPETITION_MANDATORY_WITH_SEPARATOR,r,n)||super.walkOption(e,r,n)}walkMany(e,r,n){this.checkIsTarget(e,q.REPETITION,r,n)||super.walkOption(e,r,n)}walkManySep(e,r,n){this.checkIsTarget(e,q.REPETITION_WITH_SEPARATOR,r,n)||super.walkOption(e,r,n)}},fi=class extends Le{constructor(e,r,n){super(),this.targetOccurrence=e,this.targetProdType=r,this.targetRef=n,this.result=[]}checkIsTarget(e,r){e.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,q.OPTION)}visitRepetition(e){this.checkIsTarget(e,q.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,q.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,q.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,q.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,q.ALTERNATION)}};function nf(t){let e=new Array(t);for(let r=0;r<t;r++)e[r]=[];return e}function Uo(t){let e=[""];for(let r=0;r<t.length;r++){let n=t[r],i=[];for(let o=0;o<e.length;o++){let a=e[o];i.push(a+"_"+n.tokenTypeIdx);for(let s=0;s<n.categoryMatches.length;s++){let l="_"+n.categoryMatches[s];i.push(a+l)}}e=i}return e}function ET(t,e,r){for(let n=0;n<t.length;n++){if(n===r)continue;let i=t[n];for(let o=0;o<e.length;o++){let a=e[o];if(i[a]===!0)return!1}}return!0}function uf(t,e){let r=E(t,a=>ui([a],1)),n=nf(r.length),i=E(r,a=>{let s={};return x(a,l=>{let c=Uo(l.partialPath);x(c,p=>{s[p]=!0})}),s}),o=r;for(let a=1;a<=e;a++){let s=o;o=nf(s.length);for(let l=0;l<s.length;l++){let c=s[l];for(let p=0;p<c.length;p++){let h=c[p].partialPath,d=c[p].suffixDef,A=Uo(h);if(ET(i,A,l)||v(d)||h.length===e){let y=n[l];if(hi(y,h)===!1){y.push(h);for(let O=0;O<A.length;O++){let S=A[O];i[l][S]=!0}}}else{let y=ui(d,a+1,h);o[l]=o[l].concat(y),x(y,O=>{let S=Uo(O.partialPath);x(S,g=>{i[l][g]=!0})})}}}}return n}function en(t,e,r,n){let i=new fi(t,q.ALTERNATION,n);return e.accept(i),uf(i.result,r)}function tn(t,e,r,n){let i=new fi(t,r);e.accept(i);let o=i.result,s=new ko(e,t,r).startWalking(),l=new W({definition:o}),c=new W({definition:s});return uf([l,c],n)}function hi(t,e){e:for(let r=0;r<t.length;r++){let n=t[r];if(n.length===e.length){for(let i=0;i<n.length;i++){let o=e[i],a=n[i];if((o===a||a.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function cf(t,e){return t.length<e.length&&Ee(t,(r,n)=>{let i=e[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function ff(t){return Ee(t,e=>Ee(e,r=>Ee(r,n=>v(n.categoryMatches))))}function pf(t){let e=t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName});return E(e,r=>Object.assign({type:fe.CUSTOM_LOOKAHEAD_VALIDATION},r))}function hf(t,e,r,n){let i=Se(t,l=>gT(l,r)),o=LT(t,e,r),a=Se(t,l=>TT(l,r)),s=Se(t,l=>AT(l,t,n,r));return i.concat(o,a,s)}function gT(t,e){let r=new wo;t.accept(r);let n=r.allProductions,i=xo(n,xT),o=Ie(i,s=>s.length>1);return E(M(o),s=>{let l=he(s),c=e.buildDuplicateFoundError(t,s),p=_e(l),h={message:c,type:fe.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:p,occurrence:l.idx},d=df(l);return d&&(h.parameter=d),h})}function xT(t){return`${_e(t)}_#_${t.idx}_#_${df(t)}`}function df(t){return t instanceof P?t.terminalType.name:t instanceof G?t.nonTerminalName:""}var wo=class extends Le{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function AT(t,e,r,n){let i=[];if(le(e,(a,s)=>s.name===t.name?a+1:a,0)>1){let a=n.buildDuplicateRuleNameError({topLevelRule:t,grammarName:r});i.push({message:a,type:fe.DUPLICATE_RULE_NAME,ruleName:t.name})}return i}function mf(t,e,r){let n=[],i;return H(e,t)||(i=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:fe.INVALID_RULE_OVERRIDE,ruleName:t})),n}function Do(t,e,r,n=[]){let i=[],o=di(e.definition);if(v(o))return[];{let a=t.name;H(o,t)&&i.push({message:r.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:n}),type:fe.LEFT_RECURSION,ruleName:a});let l=Pt(o,n.concat([t])),c=Se(l,p=>{let h=D(n);return h.push(p),Do(t,p,r,h)});return i.concat(c)}}function di(t){let e=[];if(v(t))return e;let r=he(t);if(r instanceof G)e.push(r.referencedRule);else if(r instanceof W||r instanceof j||r instanceof ne||r instanceof ie||r instanceof Z||r instanceof F)e=e.concat(di(r.definition));else if(r instanceof J)e=ue(E(r.definition,o=>di(o.definition)));else if(!(r instanceof P))throw Error("non exhaustive match");let n=Gt(r),i=t.length>1;if(n&&i){let o=re(t);return e.concat(di(o))}else return e}var rn=class extends Le{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Ef(t,e){let r=new rn;t.accept(r);let n=r.alternations;return Se(n,o=>{let a=ft(o.definition);return Se(a,(s,l)=>{let c=ci([s],[],ht,1);return v(c)?[{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:o,emptyChoiceIdx:l}),type:fe.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:o.idx,alternative:l+1}]:[]})})}function gf(t,e,r){let n=new rn;t.accept(n);let i=n.alternations;return i=Ft(i,a=>a.ignoreAmbiguities===!0),Se(i,a=>{let s=a.idx,l=a.maxLookahead||e,c=en(s,t,l,a),p=ST(c,a,t,r),h=CT(c,a,t,r);return p.concat(h)})}var Bo=class extends Le{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function TT(t,e){let r=new rn;t.accept(r);let n=r.alternations;return Se(n,o=>o.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:o}),type:fe.TOO_MANY_ALTS,ruleName:t.name,occurrence:o.idx}]:[])}function xf(t,e,r){let n=[];return x(t,i=>{let o=new Bo;i.accept(o);let a=o.allProductions;x(a,s=>{let l=pi(s),c=s.maxLookahead||e,p=s.idx,d=tn(p,i,l,c)[0];if(v(ue(d))){let A=r.buildEmptyRepetitionError({topLevelRule:i,repetition:s});n.push({message:A,type:fe.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function ST(t,e,r,n){let i=[],o=le(t,(s,l,c)=>(e.definition[c].ignoreAmbiguities===!0||x(l,p=>{let h=[c];x(t,(d,A)=>{c!==A&&hi(d,p)&&e.definition[A].ignoreAmbiguities!==!0&&h.push(A)}),h.length>1&&!hi(i,p)&&(i.push(p),s.push({alts:h,path:p}))}),s),[]);return E(o,s=>{let l=E(s.alts,p=>p+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:l,prefixPath:s.path}),type:fe.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:e.idx,alternatives:s.alts}})}function CT(t,e,r,n){let i=le(t,(a,s,l)=>{let c=E(s,p=>({idx:l,path:p}));return a.concat(c)},[]);return Je(Se(i,a=>{if(e.definition[a.idx].ignoreAmbiguities===!0)return[];let l=a.idx,c=a.path,p=ge(i,d=>e.definition[d.idx].ignoreAmbiguities!==!0&&d.idx<l&&cf(d.path,c));return E(p,d=>{let A=[d.idx+1,l+1],L=e.idx===0?"":e.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:A,prefixPath:d.path}),type:fe.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:L,alternatives:A}})}))}function LT(t,e,r){let n=[],i=E(e,o=>o.name);return x(t,o=>{let a=o.name;if(H(i,a)){let s=r.buildNamespaceConflictError(o);n.push({message:s,type:fe.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),n}function Af(t){let e=xr(t,{errMsgProvider:tf}),r={};return x(t.rules,n=>{r[n.name]=n}),rf(r,e.errMsgProvider)}function Tf(t){return t=xr(t,{errMsgProvider:Ve}),hf(t.rules,t.tokenTypes,t.errMsgProvider,t.grammarName)}var Sf="MismatchedTokenException",Cf="NoViableAltException",Lf="EarlyExitException",yf="NotAllInputParsedException",Nf=[Sf,Cf,Lf,yf];Object.freeze(Nf);function Ut(t){return H(Nf,t.name)}var Ir=class extends Error{constructor(e,r){super(e),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Kt=class extends Ir{constructor(e,r,n){super(e,r),this.previousToken=n,this.name=Sf}},nn=class extends Ir{constructor(e,r,n){super(e,r),this.previousToken=n,this.name=Cf}},on=class extends Ir{constructor(e,r){super(e,r),this.name=yf}},an=class extends Ir{constructor(e,r,n){super(e,r),this.previousToken=n,this.name=Lf}};var Go={},$o="InRuleRecoveryException",Wo=class extends Error{constructor(e){super(e),this.name=$o}},mi=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=T(e,"recoveryEnabled")?e.recoveryEnabled:ye.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=yT)}getTokenToInsert(e){let r=Ht(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,r,n,i){let o=this.findReSyncTokenType(),a=this.exportLexerState(),s=[],l=!1,c=this.LA(1),p=this.LA(1),h=()=>{let d=this.LA(0),A=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:c,previous:d,ruleName:this.getCurrRuleFullName()}),L=new Kt(A,c,this.LA(0));L.resyncedTokens=ft(s),this.SAVE_ERROR(L)};for(;!l;)if(this.tokenMatcher(p,i)){h();return}else if(n.call(this)){h(),e.apply(this,r);return}else this.tokenMatcher(p,o)?l=!0:(p=this.SKIP_TOKEN(),this.addToResyncTokens(p,s));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,r,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,r)))}getFollowsForInRuleRecovery(e,r){let n=this.getCurrentGrammarPath(e,r);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,r){if(this.canRecoverWithSingleTokenInsertion(e,r))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new Wo("sad sad panda")}canPerformInRuleRecovery(e,r){return this.canRecoverWithSingleTokenInsertion(e,r)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,r){if(!this.canTokenTypeBeInsertedInRecovery(e)||v(r))return!1;let n=this.LA(1);return tt(r,o=>this.tokenMatcher(n,o))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return H(n,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),r=this.LA(1),n=2;for(;;){let i=tt(e,o=>Po(r,o));if(i!==void 0)return i;r=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Go;let e=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return E(e,(n,i)=>i===0?Go:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:r[i],inRule:this.shortRuleNameToFullName(e[i-1])})}flattenFollowSet(){let e=E(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return ue(e)}getFollowSetFromFollowKey(e){if(e===Go)return[$e];let r=e.ruleName+e.idxInCallingRule+Qn+e.inRule;return this.resyncFollows[r]}addToResyncTokens(e,r){return this.tokenMatcher(e,$e)||r.push(e),r}reSyncTo(e){let r=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return ft(r)}attemptInRepetitionRecovery(e,r,n,i,o,a,s){}getCurrentGrammarPath(e,r){let n=this.getHumanReadableRuleStack(),i=D(this.RULE_OCCURRENCE_STACK);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:r}}getHumanReadableRuleStack(){return E(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function yT(t,e,r,n,i,o,a){let s=this.getKeyForAutomaticLookahead(n,i),l=this.firstAfterRepMap[s];if(l===void 0){let d=this.getCurrRuleFullName(),A=this.getGAstProductions()[d];l=new o(A,i).startWalking(),this.firstAfterRepMap[s]=l}let c=l.token,p=l.occurrence,h=l.isEndOfRule;this.RULE_STACK.length===1&&h&&c===void 0&&(c=$e,p=1),!(c===void 0||p===void 0)&&this.shouldInRepetitionRecoveryBeTried(c,p,a)&&this.tryInRepetitionRecovery(t,e,r,c)}function Ei(t,e,r){return r|e|t}var sn=class{constructor(e){var r;this.maxLookahead=(r=e?.maxLookahead)!==null&&r!==void 0?r:ye.maxLookahead}validate(e){let r=this.validateNoLeftRecursion(e.rules);if(v(r)){let n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...r,...n,...i,...o]}return r}validateNoLeftRecursion(e){return Se(e,r=>Do(r,r,Ve))}validateEmptyOrAlternatives(e){return Se(e,r=>Ef(r,Ve))}validateAmbiguousAlternationAlternatives(e,r){return Se(e,n=>gf(n,r,Ve))}validateSomeNonEmptyLookaheadPath(e,r){return xf(e,r,Ve)}buildLookaheadForAlternation(e){return of(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,sf)}buildLookaheadForOptional(e){return af(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,pi(e.prodType),lf)}};var xi=class{initLooksAhead(e){this.dynamicTokensEnabled=T(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ye.dynamicTokensEnabled,this.maxLookahead=T(e,"maxLookahead")?e.maxLookahead:ye.maxLookahead,this.lookaheadStrategy=T(e,"lookaheadStrategy")?e.lookaheadStrategy:new sn({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){x(e,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:o,repetitionMandatory:a,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:l}=NT(r);x(n,c=>{let p=c.idx===0?"":c.idx;this.TRACE_INIT(`${_e(c)}${p}`,()=>{let h=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:r,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),d=Ei(this.fullRuleNameToShort[r.name],256,c.idx);this.setLaFuncCache(d,h)})}),x(i,c=>{this.computeLookaheadFunc(r,c.idx,768,"Repetition",c.maxLookahead,_e(c))}),x(o,c=>{this.computeLookaheadFunc(r,c.idx,512,"Option",c.maxLookahead,_e(c))}),x(a,c=>{this.computeLookaheadFunc(r,c.idx,1024,"RepetitionMandatory",c.maxLookahead,_e(c))}),x(s,c=>{this.computeLookaheadFunc(r,c.idx,1536,"RepetitionMandatoryWithSeparator",c.maxLookahead,_e(c))}),x(l,c=>{this.computeLookaheadFunc(r,c.idx,1280,"RepetitionWithSeparator",c.maxLookahead,_e(c))})})})}computeLookaheadFunc(e,r,n,i,o,a){this.TRACE_INIT(`${a}${r===0?"":r}`,()=>{let s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:e,maxLookahead:o||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),l=Ei(this.fullRuleNameToShort[e.name],n,r);this.setLaFuncCache(l,s)})}getKeyForAutomaticLookahead(e,r){let n=this.getLastExplicitRuleShortName();return Ei(n,e,r)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,r){this.lookAheadFuncsCache.set(e,r)}},Vo=class extends Le{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},gi=new Vo;function NT(t){gi.reset(),t.accept(gi);let e=gi.dslMethods;return gi.reset(),e}function Ko(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset)}function Yo(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}function Of(t,e,r){t.children[r]===void 0?t.children[r]=[e]:t.children[r].push(e)}function Rf(t,e,r){t.children[e]===void 0?t.children[e]=[r]:t.children[e].push(r)}var OT="name";function Xo(t,e){Object.defineProperty(t,OT,{enumerable:!1,configurable:!0,writable:!1,value:e})}function RT(t,e){let r=w(t),n=r.length;for(let i=0;i<n;i++){let o=r[i],a=t[o],s=a.length;for(let l=0;l<s;l++){let c=a[l];c.tokenTypeIdx===void 0&&this[c.name](c.children,e)}}}function If(t,e){let r=function(){};Xo(r,t+"BaseSemantics");let n={visit:function(i,o){if(C(i)&&(i=i[0]),!xe(i))return this[i.name](i.children,o)},validateVisitor:function(){let i=IT(this,e);if(!v(i)){let o=E(i,a=>a.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
85
|
+
${o.join(`
|
|
86
|
+
|
|
87
|
+
`).replace(/\n/g,`
|
|
88
|
+
`)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=e,r}function _f(t,e,r){let n=function(){};Xo(n,t+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return x(e,o=>{i[o]=RT}),n.prototype=i,n.prototype.constructor=n,n}var qo;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(qo||(qo={}));function IT(t,e){return _T(t,e)}function _T(t,e){let r=ge(e,i=>Te(t[i])===!1),n=E(r,i=>({msg:`Missing visitor method: <${i}> on ${t.constructor.name} CST Visitor.`,type:qo.MISSING_METHOD,methodName:i}));return Je(n)}var Ci=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=T(e,"nodeLocationTracking")?e.nodeLocationTracking:ye.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=X,this.cstFinallyStateUpdate=X,this.cstPostTerminal=X,this.cstPostNonTerminal=X,this.cstPostRule=X;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Yo,this.setNodeLocationFromNode=Yo,this.cstPostRule=X,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=X,this.setNodeLocationFromNode=X,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ko,this.setNodeLocationFromNode=Ko,this.cstPostRule=X,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=X,this.setNodeLocationFromNode=X,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=X,this.setNodeLocationFromNode=X,this.cstPostRule=X,this.setInitialNodeLocation=X;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let r=this.LA(1);e.location={startOffset:r.startOffset,startLine:r.startLine,startColumn:r.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let r={name:e,children:Object.create(null)};this.setInitialNodeLocation(r),this.CST_STACK.push(r)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let r=this.LA(0),n=e.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(e){let r=this.LA(0),n=e.location;n.startOffset<=r.startOffset?n.endOffset=r.endOffset:n.startOffset=NaN}cstPostTerminal(e,r){let n=this.CST_STACK[this.CST_STACK.length-1];Of(n,r,e),this.setNodeLocationFromToken(n.location,r)}cstPostNonTerminal(e,r){let n=this.CST_STACK[this.CST_STACK.length-1];Rf(n,r,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(xe(this.baseCstVisitorConstructor)){let e=If(this.className,w(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(xe(this.baseCstVisitorWithDefaultsConstructor)){let e=_f(this.className,w(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}};var Li=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):_r}LA(e){let r=this.currIdx+e;return r<0||this.tokVectorLength<=r?_r:this.tokVector[r]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}};var yi=class{ACTION(e){return e.call(this)}consume(e,r,n){return this.consumeInternal(r,e,n)}subrule(e,r,n){return this.subruleInternal(r,e,n)}option(e,r){return this.optionInternal(r,e)}or(e,r){return this.orInternal(r,e)}many(e,r){return this.manyInternal(e,r)}atLeastOne(e,r){return this.atLeastOneInternal(e,r)}CONSUME(e,r){return this.consumeInternal(e,0,r)}CONSUME1(e,r){return this.consumeInternal(e,1,r)}CONSUME2(e,r){return this.consumeInternal(e,2,r)}CONSUME3(e,r){return this.consumeInternal(e,3,r)}CONSUME4(e,r){return this.consumeInternal(e,4,r)}CONSUME5(e,r){return this.consumeInternal(e,5,r)}CONSUME6(e,r){return this.consumeInternal(e,6,r)}CONSUME7(e,r){return this.consumeInternal(e,7,r)}CONSUME8(e,r){return this.consumeInternal(e,8,r)}CONSUME9(e,r){return this.consumeInternal(e,9,r)}SUBRULE(e,r){return this.subruleInternal(e,0,r)}SUBRULE1(e,r){return this.subruleInternal(e,1,r)}SUBRULE2(e,r){return this.subruleInternal(e,2,r)}SUBRULE3(e,r){return this.subruleInternal(e,3,r)}SUBRULE4(e,r){return this.subruleInternal(e,4,r)}SUBRULE5(e,r){return this.subruleInternal(e,5,r)}SUBRULE6(e,r){return this.subruleInternal(e,6,r)}SUBRULE7(e,r){return this.subruleInternal(e,7,r)}SUBRULE8(e,r){return this.subruleInternal(e,8,r)}SUBRULE9(e,r){return this.subruleInternal(e,9,r)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,r,n=br){if(H(this.definedRulesNames,e)){let a={message:Ve.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:fe.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(a)}this.definedRulesNames.push(e);let i=this.defineRule(e,r,n);return this[e]=i,i}OVERRIDE_RULE(e,r,n=br){let i=mf(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);let o=this.defineRule(e,r,n);return this[e]=o,o}BACKTRACK(e,r){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,r),!0}catch(i){if(Ut(i))return!1;throw i}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return zn(M(this.gastProductionsCache))}};var Ni=class{initRecognizerEngine(e,r){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Or,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},T(r,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
89
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
90
|
+
For Further details.`);if(C(e)){if(v(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
91
|
+
Note that the first argument for the parser constructor
|
|
92
|
+
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
93
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
94
|
+
For Further details.`)}if(C(e))this.tokensMap=le(e,(o,a)=>(o[a.name]=a,o),{});else if(T(e,"modes")&&Ee(ue(M(e.modes)),Kc)){let o=ue(M(e.modes)),a=Ar(o);this.tokensMap=le(a,(s,l)=>(s[l.name]=l,s),{})}else if(Y(e))this.tokensMap=D(e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=$e;let n=T(e,"modes")?ue(M(e.modes)):M(e),i=Ee(n,o=>v(o.categoryMatches));this.tokenMatcher=i?Or:ht,dt(M(this.tokensMap))}defineRule(e,r,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
|
|
95
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=T(n,"resyncEnabled")?n.resyncEnabled:br.resyncEnabled,o=T(n,"recoveryValueFunc")?n.recoveryValueFunc:br.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let s;return this.outputCst===!0?s=function(...p){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),r.apply(this,p);let h=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(h),h}catch(h){return this.invokeRuleCatch(h,i,o)}finally{this.ruleFinallyStateUpdate()}}:s=function(...p){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),r.apply(this,p)}catch(h){return this.invokeRuleCatch(h,i,o)}finally{this.ruleFinallyStateUpdate()}},Object.assign(s,{ruleName:e,originalGrammarAction:r})}invokeRuleCatch(e,r,n){let i=this.RULE_STACK.length===1,o=r&&!this.isBackTracking()&&this.recoveryEnabled;if(Ut(e)){let a=e;if(o){let s=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(s))if(a.resyncedTokens=this.reSyncTo(s),this.outputCst){let l=this.CST_STACK[this.CST_STACK.length-1];return l.recoveredNode=!0,l}else return n(e);else{if(this.outputCst){let l=this.CST_STACK[this.CST_STACK.length-1];l.recoveredNode=!0,a.partialCstResult=l}throw a}}else{if(i)return this.moveToTerminatedState(),n(e);throw a}}else throw e}optionInternal(e,r){let n=this.getKeyForAutomaticLookahead(512,r);return this.optionInternalLogic(e,r,n)}optionInternalLogic(e,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof e!="function"){o=e.DEF;let a=e.GATE;if(a!==void 0){let s=i;i=()=>a.call(this)&&s.call(this)}}else o=e;if(i.call(this)===!0)return o.call(this)}atLeastOneInternal(e,r){let n=this.getKeyForAutomaticLookahead(1024,e);return this.atLeastOneInternalLogic(e,r,n)}atLeastOneInternalLogic(e,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof r!="function"){o=r.DEF;let a=r.GATE;if(a!==void 0){let s=i;i=()=>a.call(this)&&s.call(this)}}else o=r;if(i.call(this)===!0){let a=this.doSingleRepetition(o);for(;i.call(this)===!0&&a===!0;)a=this.doSingleRepetition(o)}else throw this.raiseEarlyExitException(e,q.REPETITION_MANDATORY,r.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,r],i,1024,e,li)}atLeastOneSepFirstInternal(e,r){let n=this.getKeyForAutomaticLookahead(1536,e);this.atLeastOneSepFirstInternalLogic(e,r,n)}atLeastOneSepFirstInternalLogic(e,r,n){let i=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){i.call(this);let s=()=>this.tokenMatcher(this.LA(1),o);for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,o,s,i,Jr],s,1536,e,Jr)}else throw this.raiseEarlyExitException(e,q.REPETITION_MANDATORY_WITH_SEPARATOR,r.ERR_MSG)}manyInternal(e,r){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,r,n)}manyInternalLogic(e,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof r!="function"){o=r.DEF;let s=r.GATE;if(s!==void 0){let l=i;i=()=>s.call(this)&&l.call(this)}}else o=r;let a=!0;for(;i.call(this)===!0&&a===!0;)a=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[e,r],i,768,e,si,a)}manySepFirstInternal(e,r){let n=this.getKeyForAutomaticLookahead(1280,e);this.manySepFirstInternalLogic(e,r,n)}manySepFirstInternalLogic(e,r,n){let i=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){i.call(this);let s=()=>this.tokenMatcher(this.LA(1),o);for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,o,s,i,Zr],s,1280,e,Zr)}}repetitionSepSecondInternal(e,r,n,i,o){for(;n();)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,r,n,i,o],n,1536,e,o)}doSingleRepetition(e){let r=this.getLexerPosition();return e.call(this),this.getLexerPosition()>r}orInternal(e,r){let n=this.getKeyForAutomaticLookahead(256,r),i=C(e)?e:e.DEF,a=this.getLaFuncFromCache(n).call(this,i);if(a!==void 0)return i[a].ALT.call(this);this.raiseNoAltException(r,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new on(r,e))}}subruleInternal(e,r,n){let i;try{let o=n!==void 0?n.ARGS:void 0;return this.subruleIdx=r,i=e.apply(this,o),this.cstPostNonTerminal(i,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),i}catch(o){throw this.subruleInternalError(o,n,e.ruleName)}}subruleInternalError(e,r,n){throw Ut(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,r!==void 0&&r.LABEL!==void 0?r.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,r,n){let i;try{let o=this.LA(1);this.tokenMatcher(o,e)===!0?(this.consumeToken(),i=o):this.consumeInternalError(e,o,n)}catch(o){i=this.consumeInternalRecovery(e,r,o)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,i),i}consumeInternalError(e,r,n){let i,o=this.LA(0);throw n!==void 0&&n.ERR_MSG?i=n.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:r,previous:o,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Kt(i,r,o))}consumeInternalRecovery(e,r,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(e,r);try{return this.tryInRuleRecovery(e,i)}catch(o){throw o.name===$o?n:o}}else throw n}saveRecogState(){let e=this.errors,r=D(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:r,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,r,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(r)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),$e)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}};var Oi=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=T(e,"errorMessageProvider")?e.errorMessageProvider:ye.errorMessageProvider}SAVE_ERROR(e){if(Ut(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:D(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return D(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,r,n){let i=this.getCurrRuleFullName(),o=this.getGAstProductions()[i],s=tn(e,o,r,this.maxLookahead)[0],l=[];for(let p=1;p<=this.maxLookahead;p++)l.push(this.LA(p));let c=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:s,actual:l,previous:this.LA(0),customUserDescription:n,ruleName:i});throw this.SAVE_ERROR(new an(c,this.LA(1),this.LA(0)))}raiseNoAltException(e,r){let n=this.getCurrRuleFullName(),i=this.getGAstProductions()[n],o=en(e,i,this.maxLookahead),a=[];for(let c=1;c<=this.maxLookahead;c++)a.push(this.LA(c));let s=this.LA(0),l=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:o,actual:a,previous:s,customUserDescription:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new nn(l,this.LA(1),s))}};var Ri=class{initContentAssist(){}computeContentAssist(e,r){let n=this.gastProductionsCache[e];if(xe(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return ci([n],r,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let r=he(e.ruleStack),i=this.getGAstProductions()[r];return new ai(i,e).startWalking()}};var bi={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(bi);var bf=!0,vf=Math.pow(2,8)-1,Ff=f({name:"RECORDING_PHASE_TOKEN",pattern:b.NA});dt([Ff]);var Mf=Ht(Ff,`This IToken indicates the Parser is in Recording Phase
|
|
96
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Mf);var vT={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
97
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Ii=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let r=e>0?e:"";this[`CONSUME${r}`]=function(n,i){return this.consumeInternalRecord(n,e,i)},this[`SUBRULE${r}`]=function(n,i){return this.subruleInternalRecord(n,e,i)},this[`OPTION${r}`]=function(n){return this.optionInternalRecord(n,e)},this[`OR${r}`]=function(n){return this.orInternalRecord(n,e)},this[`MANY${r}`]=function(n){this.manyInternalRecord(e,n)},this[`MANY_SEP${r}`]=function(n){this.manySepFirstInternalRecord(e,n)},this[`AT_LEAST_ONE${r}`]=function(n){this.atLeastOneInternalRecord(e,n)},this[`AT_LEAST_ONE_SEP${r}`]=function(n){this.atLeastOneSepFirstInternalRecord(e,n)}}this.consume=function(e,r,n){return this.consumeInternalRecord(r,e,n)},this.subrule=function(e,r,n){return this.subruleInternalRecord(r,e,n)},this.option=function(e,r){return this.optionInternalRecord(r,e)},this.or=function(e,r){return this.orInternalRecord(r,e)},this.many=function(e,r){this.manyInternalRecord(e,r)},this.atLeastOne=function(e,r){this.atLeastOneInternalRecord(e,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 e=this;for(let r=0;r<10;r++){let n=r>0?r:"";delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,r){return()=>!0}LA_RECORD(e){return _r}topLevelRuleRecord(e,r){try{let n=new Ce({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),r.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
|
|
98
|
+
This error was thrown during the "grammar recording phase" For more info see:
|
|
99
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(e,r){return un.call(this,j,e,r)}atLeastOneInternalRecord(e,r){un.call(this,ne,r,e)}atLeastOneSepFirstInternalRecord(e,r){un.call(this,ie,r,e,bf)}manyInternalRecord(e,r){un.call(this,F,r,e)}manySepFirstInternalRecord(e,r){un.call(this,Z,r,e,bf)}orInternalRecord(e,r){return PT.call(this,e,r)}subruleInternalRecord(e,r,n){if(_i(r),!e||T(e,"ruleName")===!1){let s=new Error(`<SUBRULE${Pf(r)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
|
|
100
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=et(this.recordingProdStack),o=e.ruleName,a=new G({idx:r,nonTerminalName:o,label:n?.LABEL,referencedRule:void 0});return i.definition.push(a),this.outputCst?vT:bi}consumeInternalRecord(e,r,n){if(_i(r),!_o(e)){let a=new Error(`<CONSUME${Pf(r)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
|
|
101
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let i=et(this.recordingProdStack),o=new P({idx:r,terminalType:e,label:n?.LABEL});return i.definition.push(o),Mf}};function un(t,e,r,n=!1){_i(r);let i=et(this.recordingProdStack),o=Te(e)?e:e.DEF,a=new t({definition:[],idx:r});return n&&(a.separator=e.SEP),T(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(a),o.call(this),i.definition.push(a),this.recordingProdStack.pop(),bi}function PT(t,e){_i(e);let r=et(this.recordingProdStack),n=C(t)===!1,i=n===!1?t:t.DEF,o=new J({definition:[],idx:e,ignoreAmbiguities:n&&t.IGNORE_AMBIGUITIES===!0});T(t,"MAX_LOOKAHEAD")&&(o.maxLookahead=t.MAX_LOOKAHEAD);let a=$r(i,s=>Te(s.GATE));return o.hasPredicates=a,r.definition.push(o),x(i,s=>{let l=new W({definition:[]});o.definition.push(l),T(s,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=s.IGNORE_AMBIGUITIES:T(s,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),s.ALT.call(this),this.recordingProdStack.pop()}),bi}function Pf(t){return t===0?"":`${t}`}function _i(t){if(t<0||t>vf){let e=new Error(`Invalid DSL Method idx value: <${t}>
|
|
102
|
+
Idx value must be a none negative value smaller than ${vf+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}var vi=class{initPerformanceTracer(e){if(T(e,"traceInitPerf")){let r=e.traceInitPerf,n=typeof r=="number";this.traceInitMaxIdent=n?r:1/0,this.traceInitPerf=n?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=ye.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,r){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:i,value:o}=jr(r),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,o}else return r()}};function Uf(t,e){e.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(t.prototype,i,o):t.prototype[i]=r.prototype[i]})})}var _r=Ht($e,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(_r);var ye=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:oi,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),br=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),fe;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(fe||(fe={}));var cn=class t{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{Hr(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),x(this.definedRulesNames,i=>{let a=this[i].originalGrammarAction,s;this.TRACE_INIT(`${i} Rule`,()=>{s=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=s})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Af({rules:M(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(v(n)&&this.skipValidations===!1){let i=Tf({rules:M(this.gastProductionsCache),tokenTypes:M(this.tokensMap),errMsgProvider:Ve,grammarName:r}),o=pf({lookaheadStrategy:this.lookaheadStrategy,rules:M(this.gastProductionsCache),tokenTypes:M(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,o)}}),v(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=Oc(M(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:M(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(M(this.gastProductionsCache))})),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!v(this.definitionErrors))throw e=E(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
|
|
103
|
+
${e.join(`
|
|
104
|
+
-------------------------------
|
|
105
|
+
`)}`)})}constructor(e,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(e,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),T(r,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
106
|
+
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
107
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
108
|
+
For further details.`);this.skipValidations=T(r,"skipValidations")?r.skipValidations:ye.skipValidations}};cn.DEFER_DEFINITION_ERRORS_HANDLING=!1;Uf(cn,[mi,xi,Ci,Li,Ni,yi,Oi,Ri,Ii,vi]);var fn=class extends cn{constructor(e,r=ye){let n=D(r);n.outputCst=!0,super(e,n)}};var U=f({name:"KeywordReserved",pattern:b.NA}),R=f({name:"Keyword",pattern:b.NA}),Fe=f({name:"DateFunction",pattern:b.NA}),vr=f({name:"AggregateFunction",pattern:b.NA}),wf=f({name:"LocationFunction",pattern:b.NA}),MT=f({name:"FieldsFunction",pattern:b.NA}),pn=f({name:"FieldsFunctionParamIdentifier",pattern:b.NA}),hn=f({name:"OtherFunction",pattern:b.NA}),$=f({name:"DateLiteral",pattern:b.NA}),z=f({name:"DateLiteralNotIdentifier",pattern:b.NA}),Q=f({name:"DateNLiteral",pattern:b.NA}),Pr=f({name:"RelationalOperator",pattern:b.NA}),je=f({name:"SymbolIdentifier",pattern:b.NA}),dn=f({name:"DateIdentifier",pattern:b.NA}),nt=f({name:"NumberIdentifier",pattern:b.NA}),Pi=f({name:"DecimalNumberIdentifier",pattern:b.NA}),Bf=f({name:"IntegerNumberIdentifier",pattern:b.NA}),UT=f({name:"IdentifierNotKeyword",pattern:b.NA}),it=f({name:"UsingScopeEnumeration",pattern:b.NA}),Df=f({name:"RParenMismatch",pattern:b.NA}),kf=/[a-zA-Z][a-zA-Z0-9_.]*/y;function kT(t,e){kf.lastIndex=e;let r=kf.exec(t);return r&&r[0].includes("..")?null:r}var u=f({name:"Identifier",pattern:kT,line_breaks:!1,categories:[UT],start_chars_hint:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]}),mn=f({name:"StringIdentifier",line_breaks:!0,pattern:/(')(?:(?=(\\?))\2.)*?\1/}),wT=f({name:"WhiteSpace",pattern:/\s+/,group:b.SKIPPED}),Fi=f({name:"AND",pattern:/AND/i,longer_alt:u,categories:[R,U]}),BT=f({name:"AS",pattern:/AS/i,longer_alt:u,categories:[R,U]}),Mi=f({name:"DESC",pattern:/DESC/i,longer_alt:u,categories:[R,U]}),Ui=f({name:"ASC",pattern:/ASC/i,longer_alt:u,categories:[R,U]}),Qo=f({name:"ORDER_BY",pattern:/ORDER BY/i,longer_alt:u}),Zo=f({name:"CUBE",pattern:/CUBE/i,longer_alt:u,categories:[R,U]}),Jo=f({name:"ELSE",pattern:/ELSE/i,longer_alt:u,categories:[R,U]}),ea=f({name:"EXCLUDES",pattern:/EXCLUDES/i,longer_alt:u,categories:[R,U]}),ki=f({name:"FALSE",pattern:/FALSE/i,longer_alt:u,categories:[R,U]}),wi=f({name:"FIRST",pattern:/FIRST/i,longer_alt:u,categories:[R,U]}),ta=f({name:"FROM",pattern:/FROM/i,longer_alt:u,categories:[R,U]}),ra=f({name:"GROUP_BY",pattern:/GROUP BY/i,longer_alt:u}),na=f({name:"HAVING",pattern:/HAVING/i,longer_alt:u,categories:[R,U]}),Bi=f({name:"IN",pattern:/IN/i,longer_alt:u,categories:[R,U]}),ia=f({name:"INCLUDES",pattern:/INCLUDES/i,longer_alt:u,categories:[R,U]}),Di=f({name:"LAST",pattern:/LAST/i,longer_alt:u,categories:[R,U]}),oa=f({name:"LIKE",pattern:/LIKE/i,longer_alt:u,categories:[R,U]}),aa=f({name:"LIMIT",pattern:/LIMIT/i,longer_alt:u,categories:[R,U]}),Gi=f({name:"NOT",pattern:/NOT/i,longer_alt:u,categories:[R,U]}),Wi=f({name:"NULL",pattern:/NULL/i,longer_alt:u,categories:[R,U]}),$i=f({name:"NULLS",pattern:/NULLS/i,longer_alt:u,categories:[R,U]}),sa=f({name:"OR",pattern:/OR/i,longer_alt:u,categories:[R,U]}),la=f({name:"ROLLUP",pattern:/ROLLUP/i,longer_alt:u,categories:[R,U]}),ua=f({name:"SELECT",pattern:/SELECT/i,longer_alt:u,categories:[R,U]}),Vi=f({name:"TRUE",pattern:/TRUE/i,longer_alt:u,categories:[R,U]}),ca=f({name:"USING",pattern:/USING/i,longer_alt:u,categories:[R,U]}),fa=f({name:"WHERE",pattern:/WHERE/i,longer_alt:u,categories:[R,U]}),pa=f({name:"WITH",pattern:/WITH/i,longer_alt:u,categories:[R,U]}),ha=f({name:"FOR",pattern:/FOR/i,longer_alt:u,categories:[R,U]}),ji=f({name:"UPDATE",pattern:/UPDATE/i,longer_alt:u,categories:[R,U]}),da=f({name:"ABOVE",pattern:/ABOVE/i,longer_alt:u,categories:[R,u]}),ma=f({name:"ABOVE_OR_BELOW",pattern:/ABOVE_OR_BELOW/i,longer_alt:u,categories:[R,u]}),Ea=f({name:"new",pattern:/new/i,longer_alt:u,categories:[R,u]}),ga=f({name:"AT",pattern:/AT/i,longer_alt:u,categories:[R,u]}),xa=f({name:"BELOW",pattern:/BELOW/i,longer_alt:u,categories:[R,u]}),Aa=f({name:"DATA_CATEGORY",pattern:/DATA CATEGORY/i,longer_alt:u,categories:[R]}),Ta=f({name:"END",pattern:/END/i,longer_alt:u,categories:[R,u]}),Hi=f({name:"OFFSET",pattern:/OFFSET/i,longer_alt:u,categories:[R,u]}),Sa=f({name:"REFERENCE",pattern:/REFERENCE/i,longer_alt:u,categories:[R,u]}),Ca=f({name:"SCOPE",pattern:/SCOPE/i,longer_alt:u,categories:[R,u]}),La=f({name:"TRACKING",pattern:/TRACKING/i,longer_alt:u,categories:[R,u]}),ya=f({name:"THEN",pattern:/THEN/i,longer_alt:u,categories:[R,u]}),Na=f({name:"TYPEOF",pattern:/TYPEOF/i,longer_alt:u,categories:[R,u]}),Oa=f({name:"VIEW",pattern:/VIEW/i,longer_alt:u,categories:[R,u]}),Ra=f({name:"VIEWSTAT",pattern:/VIEWSTAT/i,longer_alt:u,categories:[R,u]}),Ia=f({name:"WHEN",pattern:/WHEN/i,longer_alt:u,categories:[R,u]}),_a=f({name:"SECURITY_ENFORCED",pattern:/SECURITY_ENFORCED/i,longer_alt:u,categories:[R,u]}),ba=f({name:"SYSTEM_MODE",pattern:/SYSTEM_MODE/i,longer_alt:u,categories:[R,u]}),va=f({name:"USER_MODE",pattern:/USER_MODE/i,longer_alt:u,categories:[R,u]}),Pa=f({name:"CALENDAR_MONTH",pattern:/CALENDAR_MONTH/i,longer_alt:u,categories:[Fe,u]}),Fa=f({name:"CALENDAR_QUARTER",pattern:/CALENDAR_QUARTER/i,longer_alt:u,categories:[Fe,u]}),Ma=f({name:"CALENDAR_YEAR",pattern:/CALENDAR_YEAR/i,longer_alt:u,categories:[Fe,u]}),Ua=f({name:"DAY_IN_MONTH",pattern:/DAY_IN_MONTH/i,longer_alt:u,categories:[Fe,u]}),ka=f({name:"DAY_IN_WEEK",pattern:/DAY_IN_WEEK/i,longer_alt:u,categories:[Fe,u]}),wa=f({name:"DAY_IN_YEAR",pattern:/DAY_IN_YEAR/i,longer_alt:u,categories:[Fe,u]}),Ba=f({name:"DAY_ONLY",pattern:/DAY_ONLY/i,longer_alt:u,categories:[Fe,u]}),Da=f({name:"FISCAL_MONTH",pattern:/FISCAL_MONTH/i,longer_alt:u,categories:[Fe,u]}),Ga=f({name:"FISCAL_QUARTER",pattern:/FISCAL_QUARTER/i,longer_alt:u,categories:[Fe,u]}),Wa=f({name:"FISCAL_YEAR",pattern:/FISCAL_YEAR/i,longer_alt:u,categories:[Fe,u]}),$a=f({name:"HOUR_IN_DAY",pattern:/HOUR_IN_DAY/i,longer_alt:u,categories:[Fe,u]}),Va=f({name:"WEEK_IN_MONTH",pattern:/WEEK_IN_MONTH/i,longer_alt:u,categories:[Fe,u]}),ja=f({name:"WEEK_IN_YEAR",pattern:/WEEK_IN_YEAR/i,longer_alt:u,categories:[Fe,u]}),Ha=f({name:"AVG",pattern:/AVG/i,longer_alt:u,categories:[vr,u]}),Ka=f({name:"COUNT",pattern:/COUNT/i,longer_alt:u,categories:[vr,u]}),Ya=f({name:"COUNT_DISTINCT",pattern:/COUNT_DISTINCT/i,longer_alt:u,categories:[vr,u]}),Xa=f({name:"MIN",pattern:/MIN/i,longer_alt:u,categories:[vr,u]}),qa=f({name:"MAX",pattern:/MAX/i,longer_alt:u,categories:[vr,u]}),za=f({name:"SUM",pattern:/SUM/i,longer_alt:u,categories:[vr,u]}),Qa=f({name:"DISTANCE",pattern:/DISTANCE/i,longer_alt:u,categories:[wf,u]}),Za=f({name:"GEOLOCATION",pattern:/GEOLOCATION/i,longer_alt:u,categories:[wf,u]}),Ja=f({name:"FIELDS",pattern:/FIELDS/i,longer_alt:u,categories:[MT,u]}),es=f({name:"FORMAT",pattern:/FORMAT/i,longer_alt:u,categories:[hn,u]}),ts=f({name:"toLabel",pattern:/TOLABEL/i,longer_alt:u,categories:[hn,u]}),rs=f({name:"convertTimezone",pattern:/CONVERTTIMEZONE/i,longer_alt:u,categories:[hn,u]}),ns=f({name:"convertCurrency",pattern:/CONVERTCURRENCY/i,longer_alt:u,categories:[hn,u]}),Ki=f({name:"GROUPING",pattern:/GROUPING/i,longer_alt:u,categories:[hn,u]}),DT=f({name:"ALL",pattern:/ALL/i,longer_alt:u,categories:[pn,u]}),GT=f({name:"CUSTOM",pattern:/CUSTOM/i,longer_alt:u,categories:[pn,u]}),WT=f({name:"STANDARD",pattern:/STANDARD/i,longer_alt:u,categories:[pn,u]}),$T=f({name:"YESTERDAY",pattern:/YESTERDAY/i,longer_alt:u,categories:[$,u,z]}),VT=f({name:"TODAY",pattern:/TODAY/i,longer_alt:u,categories:[$,u,z]}),jT=f({name:"TOMORROW",pattern:/TOMORROW/i,longer_alt:u,categories:[$,u,z]}),HT=f({name:"LAST_WEEK",pattern:/LAST_WEEK/i,longer_alt:u,categories:[$,u,z]}),KT=f({name:"THIS_WEEK",pattern:/THIS_WEEK/i,longer_alt:u,categories:[$,u,z]}),YT=f({name:"NEXT_WEEK",pattern:/NEXT_WEEK/i,longer_alt:u,categories:[$,u,z]}),XT=f({name:"LAST_MONTH",pattern:/LAST_MONTH/i,longer_alt:u,categories:[$,u,z]}),qT=f({name:"THIS_MONTH",pattern:/THIS_MONTH/i,longer_alt:u,categories:[$,u,z]}),zT=f({name:"NEXT_MONTH",pattern:/NEXT_MONTH/i,longer_alt:u,categories:[$,u,z]}),QT=f({name:"LAST_90_DAYS",pattern:/LAST_90_DAYS/i,longer_alt:u,categories:[$,u,z]}),ZT=f({name:"NEXT_90_DAYS",pattern:/NEXT_90_DAYS/i,longer_alt:u,categories:[$,u,z]}),JT=f({name:"THIS_QUARTER",pattern:/THIS_QUARTER/i,longer_alt:u,categories:[$,u,z]}),eS=f({name:"LAST_QUARTER",pattern:/LAST_QUARTER/i,longer_alt:u,categories:[$,u,z]}),tS=f({name:"NEXT_QUARTER",pattern:/NEXT_QUARTER/i,longer_alt:u,categories:[$,u,z]}),rS=f({name:"THIS_YEAR",pattern:/THIS_YEAR/i,longer_alt:u,categories:[$,u,z]}),nS=f({name:"LAST_YEAR",pattern:/LAST_YEAR/i,longer_alt:u,categories:[$,u,z]}),iS=f({name:"NEXT_YEAR",pattern:/NEXT_YEAR/i,longer_alt:u,categories:[$,u,z]}),oS=f({name:"THIS_FISCAL_QUARTER",pattern:/THIS_FISCAL_QUARTER/i,longer_alt:u,categories:[$,u,z]}),aS=f({name:"LAST_FISCAL_QUARTER",pattern:/LAST_FISCAL_QUARTER/i,longer_alt:u,categories:[$,u,z]}),sS=f({name:"NEXT_FISCAL_QUARTER",pattern:/NEXT_FISCAL_QUARTER/i,longer_alt:u,categories:[$,u,z]}),lS=f({name:"THIS_FISCAL_YEAR",pattern:/THIS_FISCAL_YEAR/i,longer_alt:u,categories:[$,u,z]}),uS=f({name:"LAST_FISCAL_YEAR",pattern:/LAST_FISCAL_YEAR/i,longer_alt:u,categories:[$,u,z]}),cS=f({name:"NEXT_FISCAL_YEAR",pattern:/NEXT_FISCAL_YEAR/i,longer_alt:u,categories:[$,u,z]}),fS=f({name:"NEXT_N_DAYS",pattern:/NEXT_N_DAYS/i,longer_alt:u,categories:[Q,u]}),pS=f({name:"LAST_N_DAYS",pattern:/LAST_N_DAYS/i,longer_alt:u,categories:[Q,u]}),hS=f({name:"N_DAYS_AGO",pattern:/N_DAYS_AGO/i,longer_alt:u,categories:[Q,u]}),dS=f({name:"NEXT_N_WEEKS",pattern:/NEXT_N_WEEKS/i,longer_alt:u,categories:[Q,u]}),mS=f({name:"LAST_N_WEEKS",pattern:/LAST_N_WEEKS/i,longer_alt:u,categories:[Q,u]}),ES=f({name:"N_WEEKS_AGO",pattern:/N_WEEKS_AGO/i,longer_alt:u,categories:[Q,u]}),gS=f({name:"NEXT_N_MONTHS",pattern:/NEXT_N_MONTHS/i,longer_alt:u,categories:[Q,u]}),xS=f({name:"LAST_N_MONTHS",pattern:/LAST_N_MONTHS/i,longer_alt:u,categories:[Q,u]}),AS=f({name:"N_MONTHS_AGO",pattern:/N_MONTHS_AGO/i,longer_alt:u,categories:[Q,u]}),TS=f({name:"NEXT_N_QUARTERS",pattern:/NEXT_N_QUARTERS/i,longer_alt:u,categories:[Q,u]}),SS=f({name:"LAST_N_QUARTERS",pattern:/LAST_N_QUARTERS/i,longer_alt:u,categories:[Q,u]}),CS=f({name:"N_QUARTERS_AGO",pattern:/N_QUARTERS_AGO/i,longer_alt:u,categories:[Q,u]}),LS=f({name:"NEXT_N_YEARS",pattern:/NEXT_N_YEARS/i,longer_alt:u,categories:[Q,u]}),yS=f({name:"LAST_N_YEARS",pattern:/LAST_N_YEARS/i,longer_alt:u,categories:[Q,u]}),NS=f({name:"N_YEARS_AGO",pattern:/N_YEARS_AGO/i,longer_alt:u,categories:[Q,u]}),OS=f({name:"NEXT_N_FISCAL_QUARTERS",pattern:/NEXT_N_FISCAL_QUARTERS/i,longer_alt:u,categories:[Q,u]}),RS=f({name:"LAST_N_FISCAL_QUARTERS",pattern:/LAST_N_FISCAL_QUARTERS/i,longer_alt:u,categories:[Q,u]}),IS=f({name:"N_FISCAL_QUARTERS_AGO",pattern:/N_FISCAL_QUARTERS_AGO/i,longer_alt:u,categories:[Q,u]}),_S=f({name:"NEXT_N_FISCAL_YEARS",pattern:/NEXT_N_FISCAL_YEARS/i,longer_alt:u,categories:[Q,u]}),bS=f({name:"LAST_N_FISCAL_YEARS",pattern:/LAST_N_FISCAL_YEARS/i,longer_alt:u,categories:[Q,u]}),vS=f({name:"N_FISCAL_YEARS_AGO",pattern:/N_FISCAL_YEARS_AGO/i,longer_alt:u,categories:[Q,u]}),is=f({name:"EQUAL",pattern:"=",categories:[Pr]}),os=f({name:"NOT_EQUAL",pattern:/!=|<>/,categories:[Pr]}),Yi=f({name:"LESS_THAN",pattern:"<",categories:[Pr]}),as=f({name:"LESS_THAN_OR_EQUAL",pattern:"<=",categories:[Pr]}),Xi=f({name:"GREATER_THAN",pattern:">",categories:[Pr]}),ss=f({name:"GREATER_THAN_OR_EQUAL",pattern:">=",categories:[Pr]}),qi=f({name:"DECIMAL",pattern:".",categories:[je]}),zi=f({name:"COLON",pattern:":",categories:[je]}),PS=f({name:"SEMICOLON",pattern:";",categories:[je]}),Ne=f({name:"COMMA",pattern:",",categories:[je]}),FS=f({name:"ASTERISK",pattern:"*",categories:[je]}),Me=f({name:"L_PAREN",pattern:"(",categories:[je]}),De=f({name:"R_PAREN",pattern:")",categories:[je]}),ls=f({name:"L_SQUARE_BRACKET",pattern:"[",categories:[je]}),us=f({name:"R_SQUARE_BRACKET",pattern:"]",categories:[je]}),MS=f({name:"PLUS",pattern:"+",categories:[je]}),US=f({name:"MINUS",pattern:"-",categories:[je]}),kS=f({name:"DATETIME",pattern:/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?(\Z|\.[0-9]+Z|\+[0-9]{2}:[0-9]{2}|\-[0-9]{2}:[0-9]{2}|\+[0-9]{4}|\-[0-9]{4})/i,categories:[dn]}),wS=f({name:"DATE",pattern:/[0-9]{4}-[0-9]{2}-[0-9]{2}/,categories:[dn]}),Qi=f({name:"CURRENCY_PREFIXED_DECIMAL",pattern:/[a-zA-Z]{3}[0-9]+\.\d+/,longer_alt:u,categories:[Pi]}),BS=f({name:"SIGNED_DECIMAL",pattern:/(\-|\+)[0-9]*\.\d+/,categories:[nt,Pi]}),DS=f({name:"UNSIGNED_DECIMAL",pattern:/[0-9]*\.\d+/,categories:[nt,Pi]}),Zi=f({name:"CURRENCY_PREFIXED_INTEGER",pattern:/[a-zA-Z]{3}-?[0-9]+/,longer_alt:u,categories:[Pi,u]}),cs=f({name:"SIGNED_INTEGER",pattern:/(\-|\+)[0-9]+/,categories:[nt,Bf]}),En=f({name:"GEOLOCATION_UNIT",pattern:/'(mi|km)'/i,longer_alt:u,categories:[u]}),Yt=f({name:"UNSIGNED_INTEGER",pattern:/0|[1-9]\d*/,categories:[nt,Bf]}),GS=f({name:"Delegated",pattern:/DELEGATED/i,longer_alt:u,categories:[it,u],start_chars_hint:["D","d"]}),WS=f({name:"Everything",pattern:/EVERYTHING/i,longer_alt:u,categories:[it,u],start_chars_hint:["E","e"]}),$S=f({name:"MineAndMyGroups",pattern:/MINEANDMYGROUPS/i,longer_alt:u,categories:[it,u],start_chars_hint:["M","m"]}),VS=f({name:"Mine",pattern:/MINE/i,longer_alt:u,categories:[it,u],start_chars_hint:["M","m"]}),jS=f({name:"MyTerritory",pattern:/MY_TERRITORY/i,longer_alt:u,categories:[it,u],start_chars_hint:["M","m"]}),HS=f({name:"MyTeamTerritory",pattern:/MY_TEAM_TERRITORY/i,longer_alt:u,categories:[it,u],start_chars_hint:["M","m"]}),KS=f({name:"Team",pattern:/TEAM/i,longer_alt:u,categories:[it,u],start_chars_hint:["T","t"]}),YS=f({name:"AllPrivate",pattern:/ALLPRIVATE/i,longer_alt:u,categories:[it,u],start_chars_hint:["A","a"]}),fs=[wT,Fi,Ui,BT,Qo,Zo,Mi,Jo,ea,ki,wi,ta,Ki,ra,na,ia,oa,aa,$i,Wi,la,ua,Vi,ca,fa,pa,ji,GS,WS,$S,VS,jS,HS,KS,YS,ma,da,Ea,ga,xa,Aa,Ta,Hi,Sa,Ca,La,ya,Na,Ra,Oa,Ia,_a,ba,va,Pa,Fa,Ma,Ua,ka,wa,Ba,Da,Ga,Wa,$a,Va,ja,Ha,Ya,Ka,Xa,qa,za,Qa,Za,Ja,es,ts,rs,ns,$T,VT,jT,HT,KT,YT,XT,qT,zT,QT,ZT,JT,eS,tS,rS,nS,iS,oS,aS,sS,lS,uS,cS,fS,pS,hS,dS,mS,ES,gS,xS,AS,TS,SS,CS,LS,yS,NS,OS,RS,IS,_S,bS,vS,En,DT,GT,WT,Bi,ha,sa,Di,Gi,Qi,Zi,mn,u,kS,wS,BS,DS,Yt,cs,is,os,as,Yi,ss,Xi,qi,zi,PS,Ne,FS,Me,De,ls,us,MS,US],XS=new b(fs,{ensureOptimizations:!0,skipValidations:!1});function Gf(t){return XS.tokenize(t)}var ps=class extends Error{constructor(e){super(`${e.message} (${e.line}:${e.column})`),this.name="LexingError"}},Ji=class extends Error{constructor(e){super(e.message),this.name=e.name}},Fr=class extends fn{constructor({ignoreParseErrors:r}={ignoreParseErrors:!1}){super(fs,{skipValidations:!1,recoveryEnabled:!!r});this.$_dateFunctionOr=void 0;this.$_aggregateFunction=void 0;this.$_otherFunction=void 0;this.$_atomicExpression=void 0;this.$_apexBindVariableExpression=void 0;this.$_arrayExpression=void 0;this.$_relationalOperator=void 0;this.$_selectClause=void 0;this.$_selectClauseFunctionIdentifier=void 0;this.$_withDataCategoryArr=void 0;this.allowApexBindVariables=!1;this.ignoreParseErrors=!1;this.selectStatement=this.RULE("selectStatement",()=>{this.SUBRULE(this.selectClause),this.SUBRULE(this.fromClause),this.SUBRULE(this.clauseStatements)});this.selectStatementPartial=this.RULE("selectStatementPartial",()=>{this.OPTION(()=>{this.SUBRULE(this.selectClause)}),this.OPTION1(()=>{this.SUBRULE(this.fromClause)}),this.SUBRULE(this.clauseStatements)});this.clauseStatements=this.RULE("clauseStatements",()=>{this.OPTION(()=>{this.SUBRULE(this.usingScopeClause)}),this.OPTION1(()=>{this.SUBRULE(this.whereClause)}),this.OPTION2(()=>{this.MANY({DEF:()=>{this.SUBRULE(this.withClause)}})}),this.OPTION3(()=>{this.SUBRULE(this.groupByClause),this.OPTION4(()=>{this.SUBRULE(this.havingClause)})}),this.OPTION5(()=>{this.SUBRULE(this.orderByClause)}),this.OPTION6(()=>{this.SUBRULE(this.limitClause)}),this.OPTION7(()=>{this.SUBRULE(this.offsetClause)}),this.OPTION8(()=>{this.SUBRULE(this.forViewOrReference)}),this.OPTION9(()=>{this.SUBRULE(this.updateTrackingViewstat)})});this.selectClause=this.RULE("selectClause",()=>{this.CONSUME(ua),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.OR(this.$_selectClause||(this.$_selectClause=[{ALT:()=>this.SUBRULE(this.selectClauseFunctionIdentifier,{LABEL:"field"})},{ALT:()=>this.SUBRULE(this.selectClauseSubqueryIdentifier,{LABEL:"field"})},{ALT:()=>this.SUBRULE(this.selectClauseTypeOf,{LABEL:"field"})},{ALT:()=>this.SUBRULE(this.selectClauseIdentifier,{LABEL:"field"})}]))}})},{resyncEnabled:!1});this.selectClauseFunctionIdentifier=this.RULE("selectClauseFunctionIdentifier",()=>{this.OR(this.$_selectClauseFunctionIdentifier||(this.$_selectClauseFunctionIdentifier=[{ALT:()=>this.SUBRULE(this.dateFunction,{LABEL:"fn"})},{ALT:()=>this.SUBRULE(this.aggregateFunction,{LABEL:"fn"})},{ALT:()=>this.SUBRULE(this.locationFunction,{LABEL:"fn"})},{ALT:()=>this.SUBRULE(this.fieldsFunction,{LABEL:"fn"})},{ALT:()=>this.SUBRULE(this.otherFunction,{LABEL:"fn"})}])),this.OPTION(()=>this.CONSUME(u,{LABEL:"alias"}))},{resyncEnabled:!1});this.selectClauseSubqueryIdentifier=this.RULE("selectClauseSubqueryIdentifier",()=>{this.CONSUME(Me),this.SUBRULE(this.selectStatement),this.CONSUME(De)},{resyncEnabled:!1});this.selectClauseTypeOf=this.RULE("selectClauseTypeOf",()=>{this.CONSUME(Na),this.CONSUME(u,{LABEL:"typeOfField"}),this.AT_LEAST_ONE({DEF:()=>{this.SUBRULE(this.selectClauseTypeOfThen)}}),this.OPTION(()=>{this.SUBRULE(this.selectClauseTypeOfElse)}),this.CONSUME(Ta)},{resyncEnabled:!1});this.selectClauseIdentifier=this.RULE("selectClauseIdentifier",()=>{this.CONSUME(u,{LABEL:"field"}),this.OPTION(()=>this.CONSUME1(u,{LABEL:"alias"}))},{resyncEnabled:!1});this.selectClauseTypeOfThen=this.RULE("selectClauseTypeOfThen",()=>{this.CONSUME(Ia),this.CONSUME(u,{LABEL:"typeOfField"}),this.CONSUME(ya),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.CONSUME1(u,{LABEL:"field"})}})},{resyncEnabled:!1});this.selectClauseTypeOfElse=this.RULE("selectClauseTypeOfElse",()=>{this.CONSUME(Jo),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.CONSUME(u,{LABEL:"field"})}})},{resyncEnabled:!1});this.fromClause=this.RULE("fromClause",()=>{this.CONSUME(ta),this.CONSUME(u),this.OPTION({GATE:()=>!(this.LA(1).tokenType===Hi&&this.LA(2).tokenType===Yt),DEF:()=>this.CONSUME1(u,{LABEL:"alias"})})},{resyncEnabled:!1});this.usingScopeClause=this.RULE("usingScopeClause",()=>{this.CONSUME(ca),this.CONSUME(Ca),this.CONSUME(it)});this.whereClause=this.RULE("whereClause",()=>{this.CONSUME(fa);let r=this.getParenCount();this.AT_LEAST_ONE({DEF:()=>{this.SUBRULE(this.conditionExpression,{ARGS:[r,!0,!0]})}}),this.$_checkBalancedParens(r)});this.whereClauseSubqueryIdentifier=this.RULE("whereClauseSubqueryIdentifier",()=>{this.CONSUME(Me),this.SUBRULE(this.selectStatement),this.CONSUME(De)});this.conditionExpression=this.RULE("conditionExpression",(r,n,i)=>{r=this.getParenCount(r),this.OPTION(()=>{this.OR([{ALT:()=>this.CONSUME(Fi,{LABEL:"logicalOperator"})},{ALT:()=>this.CONSUME(sa,{LABEL:"logicalOperator"})}])}),this.MANY({MAX_LOOKAHEAD:10,DEF:()=>this.SUBRULE(this.expressionPartWithNegation,{ARGS:[r],LABEL:"expressionNegation"})}),this.OR1({MAX_LOOKAHEAD:10,DEF:[{ALT:()=>this.SUBRULE(this.expression,{ARGS:[r,!1,n,i]})}]})});this.withClause=this.RULE("withClause",()=>{this.CONSUME(pa),this.OR([{ALT:()=>this.CONSUME(_a,{LABEL:"withSecurityEnforced"})},{ALT:()=>this.CONSUME(va,{LABEL:"withAccessLevel"})},{ALT:()=>this.CONSUME(ba,{LABEL:"withAccessLevel"})},{ALT:()=>this.SUBRULE(this.withDataCategory)}])});this.withDataCategory=this.RULE("withDataCategory",()=>{this.CONSUME(Aa),this.AT_LEAST_ONE_SEP({SEP:Fi,DEF:()=>{this.SUBRULE(this.withDataCategoryArr)}})});this.withDataCategoryArr=this.RULE("withDataCategoryArr",()=>{this.CONSUME(u,{LABEL:"dataCategoryGroupName"}),this.OR(this.$_withDataCategoryArr||(this.$_withDataCategoryArr=[{ALT:()=>this.CONSUME(ga,{LABEL:"filteringSelector"})},{ALT:()=>this.CONSUME(da,{LABEL:"filteringSelector"})},{ALT:()=>this.CONSUME(xa,{LABEL:"filteringSelector"})},{ALT:()=>this.CONSUME(ma,{LABEL:"filteringSelector"})}])),this.OPTION(()=>{this.CONSUME1(Me)}),this.AT_LEAST_ONE_SEP1({SEP:Ne,DEF:()=>{this.CONSUME1(u,{LABEL:"dataCategoryName"})}}),this.OPTION1(()=>{this.CONSUME2(De)})});this.groupByClause=this.RULE("groupByClause",()=>{this.CONSUME(ra),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.OR([{ALT:()=>this.SUBRULE(this.cubeFunction,{LABEL:"groupBy"})},{ALT:()=>this.SUBRULE(this.rollupFunction,{LABEL:"groupBy"})},{ALT:()=>this.SUBRULE(this.dateFunction,{LABEL:"groupBy"})},{ALT:()=>this.CONSUME(u,{LABEL:"groupBy"})}])}})});this.havingClause=this.RULE("havingClause",()=>{this.CONSUME(na);let r=this.getParenCount();this.AT_LEAST_ONE({DEF:()=>{this.SUBRULE(this.conditionExpression,{ARGS:[r,!0,!1]})}}),this.$_checkBalancedParens(r)});this.orderByClause=this.RULE("orderByClause",()=>{this.CONSUME(Qo),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.OR([{ALT:()=>this.SUBRULE(this.orderByGroupingFunctionExpression,{LABEL:"orderByExpressionOrFn"})},{ALT:()=>this.SUBRULE(this.orderBySpecialFunctionExpression,{LABEL:"orderByExpressionOrFn"})},{ALT:()=>this.SUBRULE(this.orderByExpression,{LABEL:"orderByExpressionOrFn"})}])}})});this.orderByExpression=this.RULE("orderByExpression",()=>{this.CONSUME(u),this.OPTION(()=>{this.OR([{ALT:()=>this.CONSUME(Ui,{LABEL:"order"})},{ALT:()=>this.CONSUME(Mi,{LABEL:"order"})}])}),this.OPTION1(()=>{this.CONSUME($i),this.OR1([{ALT:()=>this.CONSUME(wi,{LABEL:"nulls"})},{ALT:()=>this.CONSUME(Di,{LABEL:"nulls"})}])})});this.orderByGroupingFunctionExpression=this.RULE("orderByGroupingFunctionExpression",()=>{this.CONSUME(Ki,{LABEL:"fn"}),this.SUBRULE(this.functionExpression)});this.orderBySpecialFunctionExpression=this.RULE("orderBySpecialFunctionExpression",()=>{this.OR([{ALT:()=>this.SUBRULE(this.aggregateFunction)},{ALT:()=>this.SUBRULE(this.dateFunction)},{ALT:()=>this.SUBRULE(this.locationFunction)}]),this.OPTION(()=>{this.OR1([{ALT:()=>this.CONSUME(Ui,{LABEL:"order"})},{ALT:()=>this.CONSUME(Mi,{LABEL:"order"})}])}),this.OPTION1(()=>{this.CONSUME($i),this.OR2([{ALT:()=>this.CONSUME(wi,{LABEL:"nulls"})},{ALT:()=>this.CONSUME(Di,{LABEL:"nulls"})}])})});this.limitClause=this.RULE("limitClause",()=>{this.CONSUME(aa),this.CONSUME(Yt,{LABEL:"value"})});this.offsetClause=this.RULE("offsetClause",()=>{this.CONSUME(Hi),this.CONSUME(Yt,{LABEL:"value"})});this.dateFunction=this.RULE("dateFunction",()=>{this.OR(this.$_dateFunctionOr||(this.$_dateFunctionOr=[{ALT:()=>this.CONSUME(Pa,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Fa,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ma,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ua,{LABEL:"fn"})},{ALT:()=>this.CONSUME(ka,{LABEL:"fn"})},{ALT:()=>this.CONSUME(wa,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ba,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Da,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ga,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Wa,{LABEL:"fn"})},{ALT:()=>this.CONSUME($a,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Va,{LABEL:"fn"})},{ALT:()=>this.CONSUME(ja,{LABEL:"fn"})}])),this.SUBRULE(this.functionExpression)});this.aggregateFunction=this.RULE("aggregateFunction",()=>{this.OR(this.$_aggregateFunction||(this.$_aggregateFunction=[{ALT:()=>this.CONSUME(Ha,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ka,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ya,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Xa,{LABEL:"fn"})},{ALT:()=>this.CONSUME(qa,{LABEL:"fn"})},{ALT:()=>this.CONSUME(za,{LABEL:"fn"})}])),this.SUBRULE(this.functionExpression,{ARGS:[!0]})});this.fieldsFunction=this.RULE("fieldsFunction",()=>{this.CONSUME(Ja,{LABEL:"fn"}),this.CONSUME(Me),this.CONSUME(pn,{LABEL:"params"}),this.CONSUME(De)});this.otherFunction=this.RULE("otherFunction",()=>{this.OR(this.$_otherFunction||(this.$_otherFunction=[{ALT:()=>this.CONSUME(es,{LABEL:"fn"})},{ALT:()=>this.CONSUME(ts,{LABEL:"fn"})},{ALT:()=>this.CONSUME(rs,{LABEL:"fn"})},{ALT:()=>this.CONSUME(ns,{LABEL:"fn"})},{ALT:()=>this.CONSUME(Ki,{LABEL:"fn"})}])),this.SUBRULE(this.functionExpression)});this.cubeFunction=this.RULE("cubeFunction",()=>{this.CONSUME(Zo,{LABEL:"fn"}),this.SUBRULE(this.functionExpression)});this.rollupFunction=this.RULE("rollupFunction",()=>{this.CONSUME(la,{LABEL:"fn"}),this.SUBRULE(this.functionExpression)});this.functionExpression=this.RULE("functionExpression",r=>{this.CONSUME(Me),this.MANY_SEP({SEP:Ne,DEF:()=>{this.OR([{GATE:()=>!r,ALT:()=>this.SUBRULE(this.aggregateFunction,{LABEL:"params"})},{ALT:()=>this.SUBRULE(this.otherFunction,{LABEL:"params"})},{ALT:()=>this.CONSUME(mn,{LABEL:"params"})},{ALT:()=>this.CONSUME(nt,{LABEL:"params"})},{ALT:()=>this.CONSUME(u,{LABEL:"params"})}])}}),this.CONSUME(De)});this.locationFunction=this.RULE("locationFunction",()=>{this.CONSUME(Qa),this.CONSUME(Me),this.CONSUME(u,{LABEL:"location1"}),this.CONSUME(Ne),this.OR([{ALT:()=>this.SUBRULE(this.geolocationFunction,{LABEL:"location2"})},{ALT:()=>this.CONSUME1(u,{LABEL:"location2"})}]),this.CONSUME1(Ne),this.CONSUME(En,{LABEL:"unit"}),this.CONSUME(De)});this.geolocationFunction=this.RULE("geolocationFunction",()=>{this.CONSUME(Za),this.CONSUME(Me),this.CONSUME(nt,{LABEL:"latitude"}),this.CONSUME(Ne),this.CONSUME1(nt,{LABEL:"longitude"}),this.CONSUME(De)});this.expressionPartWithNegation=this.RULE("expressionPartWithNegation",r=>{let n=0;this.MANY(()=>{this.CONSUME(Me),n++}),this.CONSUME(Gi,{LABEL:"expressionNegation"}),r&&n&&(r.left+=n)});this.expression=this.RULE("expression",(r,n,i,o)=>{this.OPTION1(()=>{this.MANY1(()=>{this.CONSUME(Me),r&&r.left++})}),this.OR1([{GATE:()=>!!i,ALT:()=>this.SUBRULE(this.aggregateFunction,{LABEL:"lhs"})},{GATE:()=>!!o,ALT:()=>this.SUBRULE(this.locationFunction,{LABEL:"lhs"})},{ALT:()=>this.SUBRULE(this.dateFunction,{LABEL:"lhs"})},{ALT:()=>this.SUBRULE(this.otherFunction,{LABEL:"lhs"})},{ALT:()=>this.CONSUME(u,{LABEL:"lhs"})}]),this.OR2([{ALT:()=>this.SUBRULE(this.expressionWithRelationalOperator,{LABEL:"operator"})},{ALT:()=>this.SUBRULE(this.expressionWithSetOperator,{LABEL:"operator",ARGS:[n]})}]),this.OPTION3(()=>{this.MANY2({GATE:()=>r?r.left>r.right:!0,DEF:()=>{this.CONSUME(De),r&&r.right++}})})});this.expressionWithRelationalOperator=this.RULE("expressionWithRelationalOperator",()=>{this.SUBRULE(this.relationalOperator),this.SUBRULE(this.atomicExpression,{LABEL:"rhs"})});this.expressionWithSetOperator=this.RULE("expressionWithSetOperator",r=>{this.SUBRULE(this.setOperator),this.SUBRULE2(this.atomicExpression,{LABEL:"rhs",ARGS:[!0,r]})});this.atomicExpression=this.RULE("atomicExpression",(r,n)=>{this.OR(this.$_atomicExpression||(this.$_atomicExpression=[{GATE:()=>this.allowApexBindVariables,ALT:()=>this.SUBRULE(this.apexBindVariableExpression)},{GATE:()=>r,ALT:()=>this.SUBRULE(this.arrayExpression)},{GATE:()=>r&&n,ALT:()=>this.SUBRULE(this.whereClauseSubqueryIdentifier)},{GATE:()=>!r,ALT:()=>this.CONSUME(dn)},{GATE:()=>!r,ALT:()=>this.CONSUME(Qi,{LABEL:"CurrencyPrefixedDecimal"})},{GATE:()=>!r,ALT:()=>this.CONSUME(Zi,{LABEL:"CurrencyPrefixedInteger"})},{GATE:()=>!r,ALT:()=>this.CONSUME(nt)},{GATE:()=>!r,ALT:()=>this.CONSUME(Wi)},{GATE:()=>!r,ALT:()=>this.SUBRULE(this.booleanValue)},{GATE:()=>!r,ALT:()=>this.CONSUME($)},{GATE:()=>!r,ALT:()=>this.SUBRULE(this.dateNLiteral)},{GATE:()=>!r,ALT:()=>this.CONSUME(En,{LABEL:"StringIdentifier"})},{GATE:()=>!r,ALT:()=>this.CONSUME(mn)}]))});this.apexBindVariableExpression=this.RULE("apexBindVariableExpression",()=>{this.CONSUME(zi),this.OPTION(()=>{this.SUBRULE(this.apexBindVariableNewInstantiation,{LABEL:"apex"}),this.OPTION1(()=>{this.CONSUME(qi)})}),this.MANY_SEP({SEP:qi,DEF:()=>{this.OR(this.$_apexBindVariableExpression||(this.$_apexBindVariableExpression=[{ALT:()=>this.SUBRULE(this.apexBindVariableFunctionCall,{LABEL:"apex"})},{ALT:()=>this.SUBRULE(this.apexBindVariableIdentifier,{LABEL:"apex"})}]))}})});this.apexBindVariableIdentifier=this.RULE("apexBindVariableIdentifier",()=>{this.CONSUME(u),this.OPTION(()=>this.SUBRULE(this.apexBindVariableFunctionArrayAccessor))});this.apexBindVariableNewInstantiation=this.RULE("apexBindVariableNewInstantiation",()=>{this.CONSUME(Ea,{LABEL:"new"}),this.CONSUME(u,{LABEL:"function"}),this.OPTION(()=>{this.SUBRULE(this.apexBindVariableGeneric)}),this.SUBRULE(this.apexBindVariableFunctionParams),this.OPTION1(()=>this.SUBRULE(this.apexBindVariableFunctionArrayAccessor))});this.apexBindVariableFunctionCall=this.RULE("apexBindVariableFunctionCall",()=>{this.CONSUME(u,{LABEL:"function"}),this.SUBRULE(this.apexBindVariableFunctionParams),this.OPTION(()=>this.SUBRULE(this.apexBindVariableFunctionArrayAccessor))});this.apexBindVariableGeneric=this.RULE("apexBindVariableGeneric",()=>{this.CONSUME(Yi),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.CONSUME(u,{LABEL:"parameter"})}}),this.CONSUME(Xi)});this.apexBindVariableFunctionParams=this.RULE("apexBindVariableFunctionParams",()=>{this.CONSUME(Me),this.MANY_SEP({SEP:Ne,DEF:()=>{this.CONSUME(u,{LABEL:"parameter"})}}),this.CONSUME(De)});this.apexBindVariableFunctionArrayAccessor=this.RULE("apexBindVariableFunctionArrayAccessor",()=>{this.CONSUME(ls),this.OR([{ALT:()=>this.CONSUME(Yt,{LABEL:"value"})},{ALT:()=>this.CONSUME(u,{LABEL:"value"})}]),this.CONSUME(us)});this.arrayExpression=this.RULE("arrayExpression",()=>{this.CONSUME(Me),this.AT_LEAST_ONE_SEP({SEP:Ne,DEF:()=>{this.OR(this.$_arrayExpression||(this.$_arrayExpression=[{ALT:()=>this.CONSUME(Qi,{LABEL:"value"})},{ALT:()=>this.CONSUME(Zi,{LABEL:"value"})},{ALT:()=>this.CONSUME(nt,{LABEL:"value"})},{ALT:()=>this.CONSUME(dn,{LABEL:"value"})},{ALT:()=>this.CONSUME(Wi,{LABEL:"value"})},{ALT:()=>this.CONSUME(Vi,{LABEL:"value"})},{ALT:()=>this.CONSUME(ki,{LABEL:"value"})},{ALT:()=>this.CONSUME($,{LABEL:"value"})},{ALT:()=>this.SUBRULE(this.dateNLiteral,{LABEL:"value"})},{ALT:()=>this.CONSUME(En,{LABEL:"value"})},{ALT:()=>this.CONSUME(mn,{LABEL:"value"})}]))}}),this.CONSUME(De)});this.relationalOperator=this.RULE("relationalOperator",()=>{this.OR(this.$_relationalOperator||(this.$_relationalOperator=[{ALT:()=>this.CONSUME(is,{LABEL:"operator"})},{ALT:()=>this.CONSUME(os,{LABEL:"operator"})},{ALT:()=>this.CONSUME(Xi,{LABEL:"operator"})},{ALT:()=>this.CONSUME(ss,{LABEL:"operator"})},{ALT:()=>this.CONSUME(Yi,{LABEL:"operator"})},{ALT:()=>this.CONSUME(as,{LABEL:"operator"})},{ALT:()=>this.CONSUME(oa,{LABEL:"operator"})}]))});this.setOperator=this.RULE("setOperator",()=>{this.OR([{ALT:()=>this.CONSUME(Bi,{LABEL:"operator"})},{ALT:()=>this.SUBRULE(this.notInOperator,{LABEL:"notIn"})},{ALT:()=>this.CONSUME(ia,{LABEL:"operator"})},{ALT:()=>this.CONSUME(ea,{LABEL:"operator"})}])});this.notInOperator=this.RULE("notInOperator",()=>{this.CONSUME(Gi,{LABEL:"operator"}),this.CONSUME(Bi,{LABEL:"operator"})});this.booleanValue=this.RULE("booleanValue",()=>{this.OR([{ALT:()=>this.CONSUME(Vi,{LABEL:"boolean"})},{ALT:()=>this.CONSUME(ki,{LABEL:"boolean"})}])});this.dateNLiteral=this.RULE("dateNLiteral",()=>{this.CONSUME(Q,{LABEL:"dateNLiteral"}),this.CONSUME(zi),this.OR1([{ALT:()=>this.CONSUME(Yt,{LABEL:"variable"})},{ALT:()=>this.CONSUME(cs,{LABEL:"variable"})}])});this.forViewOrReference=this.RULE("forViewOrReference",()=>{this.CONSUME(ha),this.OR([{ALT:()=>this.CONSUME(Oa,{LABEL:"value"})},{ALT:()=>this.CONSUME(Sa,{LABEL:"value"})},{ALT:()=>this.CONSUME(ji,{LABEL:"value"})}])});this.updateTrackingViewstat=this.RULE("updateTrackingViewstat",()=>{this.CONSUME(ji),this.OR([{ALT:()=>this.CONSUME(La,{LABEL:"value"})},{ALT:()=>this.CONSUME(Ra,{LABEL:"value"})}])});this.ignoreParseErrors=!!r,this.performSelfAnalysis()}$_checkBalancedParens(r){!this.RECORDING_PHASE&&r&&r.left-r.right!==0&&this.CONSUME(Df,{ERR_MSG:"Expecting a token type of --> RParen <-- but found --> '' <--"})}getParenCount(r){return r||{right:0,left:0}}},ot=new Fr;function hs(t,e){let{allowApexBindVariables:r,logErrors:n,ignoreParseErrors:i,allowPartialQuery:o}=e||{allowApexBindVariables:!1,logErrors:!1,ignoreParseErrors:!1},a=Gf(t);if(a.errors.length>0)throw n&&(console.log("Lexing Errors:"),console.log(a.errors)),new ps(a.errors[0]);ot.ignoreParseErrors!==i&&(ot=new Fr({ignoreParseErrors:i})),ot.input=a.tokens,ot.allowApexBindVariables=r||!1;let s;if(o?s=ot.selectStatementPartial():s=ot.selectStatement(),ot.errors.length>0&&(n&&(console.log("Parsing Errors:"),console.log(ot.errors)),!i))throw new Ji(ot.errors[0]);return{cst:s,parseErrors:ot.errors.map(l=>new Ji(l))}}var zS=new Fr,QS=zS.getBaseCstVisitorConstructor(),ZS=["TRUE","FALSE"],JS=["YESTERDAY","TODAY","TOMORROW","LAST_WEEK","THIS_WEEK","NEXT_WEEK","LAST_MONTH","THIS_MONTH","NEXT_MONTH","LAST_90_DAYS","NEXT_90_DAYS","THIS_QUARTER","LAST_QUARTER","NEXT_QUARTER","THIS_YEAR","LAST_YEAR","NEXT_YEAR","THIS_FISCAL_QUARTER","LAST_FISCAL_QUARTER","NEXT_FISCAL_QUARTER","THIS_FISCAL_YEAR","LAST_FISCAL_YEAR","NEXT_FISCAL_YEAR"],eC=["NEXT_N_DAYS","LAST_N_DAYS","N_DAYS_AGO","NEXT_N_WEEKS","LAST_N_WEEKS","N_WEEKS_AGO","NEXT_N_MONTHS","LAST_N_MONTHS","N_MONTHS_AGO","NEXT_N_QUARTERS","LAST_N_QUARTERS","N_QUARTERS_AGO","NEXT_N_YEARS","LAST_N_YEARS","N_YEARS_AGO","NEXT_N_FISCAL_QUARTERS","LAST_N_FISCAL_QUARTERS","N_FISCAL_QUARTERS_AGO","NEXT_N_FISCAL_YEARS","LAST_N_FISCAL_YEARS","N_FISCAL_YEARS_AGO"],ds=class extends QS{constructor(){super();this.helpers={$_getFieldFunction:(r,n=!1,i=!0)=>{let o=r.functionExpression?r.functionExpression.map(s=>this.visit(s,{includeType:i})).flat():[],a={};return i&&(a.type="FieldFunctionExpression"),a.functionName=r.fn[0].tokenType.name,a.parameters=o,i&&n&&(a.isAggregateFn=n),a.rawValue=`${r.fn[0].image}(${o.map(s=>typeof s=="string"?s:s.rawValue).join(", ")})`,a},$_getLiteralTypeFromTokenType:r=>r==="REAL_NUMBER"?"DECIMAL":r==="CURRENCY_PREFIXED_DECIMAL"?"DECIMAL_WITH_CURRENCY_PREFIX":r==="CURRENCY_PREFIXED_INTEGER"?"INTEGER_WITH_CURRENCY_PREFIX":r==="SIGNED_DECIMAL"||r==="UNSIGNED_DECIMAL"?"DECIMAL":r==="UNSIGNED_INTEGER"||r==="SIGNED_INTEGER"?"INTEGER":r==="DATETIME"?"DATETIME":r==="DATE"?"DATE":r==="NULL"?"NULL":r==="StringIdentifier"||r==="Identifier"?"STRING":ZS.includes(r)?"BOOLEAN":JS.includes(r)?"DATE_LITERAL":eC.includes(r)?"DATE_N_LITERAL":"STRING",$_parseSelect(r,n){let{isSubquery:i}=n||{isSubquery:!1},o={};if(r.selectClause&&(o.fields=this.visit(r.selectClause)),r.fromClause)if(Ls(o,i)){let{sObject:a,alias:s,sObjectPrefix:l}=this.visit(r.fromClause);o.relationshipName=a,s&&(o.sObjectAlias=s),l&&(o.sObjectPrefix=l)}else{let{sObject:a,alias:s}=this.visit(r.fromClause);o.sObject=a,s&&(o.sObjectAlias=s)}return Array.isArray(o.fields)&&o.sObjectAlias&&o.fields.forEach(a=>{a.relationships&&a.relationships[0]===o.sObjectAlias&&(a.relationships=a.relationships.slice(1),a.objectPrefix=o.sObjectAlias),a.relationships&&a.relationships.length===0&&(delete a.relationships,a.type="Field")}),o={...o,...this.visit(r.clauseStatements)},o}};this.validateVisitor()}selectStatement(r,n){return this.helpers.$_parseSelect.bind(this)(r,n)}selectStatementPartial(r,n){return this.helpers.$_parseSelect.bind(this)(r,n)}clauseStatements(r){let n={};return r.usingScopeClause&&!r.usingScopeClause[0].recoveredNode&&(n.usingScope=this.visit(r.usingScopeClause)),r.whereClause&&!r.whereClause[0].recoveredNode&&(n.where=this.visit(r.whereClause)),r.withClause&&r.withClause.filter(i=>!i.recoveredNode).forEach(i=>{let{withSecurityEnforced:o,withAccessLevel:a,withDataCategory:s}=this.visit(i);o&&(n.withSecurityEnforced=o),a&&(n.withAccessLevel=a),s&&(n.withDataCategory=s)}),r.groupByClause&&!r.groupByClause[0].recoveredNode&&(n.groupBy=this.visit(r.groupByClause)),r.havingClause&&!r.havingClause[0].recoveredNode&&(n.having=this.visit(r.havingClause)),r.orderByClause&&!r.orderByClause[0].recoveredNode&&(n.orderBy=this.visit(r.orderByClause)),r.limitClause&&!r.limitClause[0].recoveredNode&&(n.limit=Number(this.visit(r.limitClause))),r.offsetClause&&!r.offsetClause[0].recoveredNode&&(n.offset=Number(this.visit(r.offsetClause))),r.forViewOrReference&&!r.forViewOrReference[0].recoveredNode&&(n.for=this.visit(r.forViewOrReference)),r.updateTrackingViewstat&&!r.updateTrackingViewstat[0].recoveredNode&&(n.update=this.visit(r.updateTrackingViewstat)),n}selectClause(r){return r.field?r.field.map(n=>{if(qt(n)){let i=n.image,o;if(!i.includes("."))o={type:"Field",field:i};else{let a=i.split(".");o={type:"FieldRelationship",field:a[a.length-1],relationships:a.slice(0,a.length-1),rawValue:i}}return o}else return this.visit(n)}):[]}selectClauseFunctionIdentifier(r){let n={...this.visit(r.fn)};return r.alias&&(n.alias=r.alias[0].image),n}selectClauseSubqueryIdentifier(r){return{type:"FieldSubquery",subquery:this.visit(r.selectStatement,{isSubquery:!0})}}selectClauseTypeOf(r){let n=r.selectClauseTypeOfThen.map(i=>this.visit(i));return r.selectClauseTypeOfElse&&n.push(this.visit(r.selectClauseTypeOfElse)),{type:"FieldTypeof",field:r.typeOfField[0].image,conditions:n}}selectClauseIdentifier(r){let n=r.field[0],i=r.alias?r.alias[0].image:void 0,o=n.image,a;if(!o.includes("."))a={type:"Field",field:o};else{let s=o.split(".");a={type:"FieldRelationship",field:s[s.length-1],relationships:s.slice(0,s.length-1),rawValue:o}}return i&&(a.alias=i),a}selectClauseTypeOfThen(r){return{type:"WHEN",objectType:r.typeOfField[0].image,fieldList:r.field.map(n=>n.image)}}selectClauseTypeOfElse(r){return{type:"ELSE",fieldList:r.field.map(n=>n.image)}}fromClause(r){let n=r.Identifier[0].image,i;if(n.includes(".")){let o=n.split(".");i={sObjectPrefix:o.slice(0,o.length-1),sObject:o[o.length-1]}}else i={sObject:n};return r.alias&&r.alias[0]&&(i.alias=r.alias[0].image),i}usingScopeClause(r){return r.UsingScopeEnumeration[0].image}whereClauseSubqueryIdentifier(r){return this.visit(r.selectStatement,{isSubquery:!1})}whereClause(r){return r.conditionExpression.reduce((i,o)=>{let a;i.expressionTree?(a=this.visit(o,{prevExpression:i.prevExpression}),i.prevExpression.right=a):(a=this.visit(o),i.expressionTree=a);let s=a.right,l=a.right;for(;ao(l);)s=l,l=l.right;return i.prevExpression=l||a,i},{prevExpression:void 0,expressionTree:void 0}).expressionTree}conditionExpression(r,n){n=n||{},n.prevExpression&&r.logicalOperator&&(n.prevExpression.operator=r.logicalOperator[0].tokenType.name);let i={},o=i;if(Array.isArray(r.expressionNegation))if(r.expressionNegation.length===1)i=this.visit(r.expressionNegation),o=i.right;else{i=this.visit(r.expressionNegation[0]);let a=i;r.expressionNegation.slice(1).forEach(s=>{a.right=this.visit(s),o=a.right.right})}return o.left=this.visit(r.expression),i}withClause(r){return r.withSecurityEnforced?{withSecurityEnforced:!0}:r.withAccessLevel?{withAccessLevel:r.withAccessLevel[0].image}:{withDataCategory:{conditions:this.visit(r.withDataCategory)}}}withDataCategory(r){return r.withDataCategoryArr.map(n=>this.visit(n))}withDataCategoryArr(r){return{groupName:r.dataCategoryGroupName[0].image,selector:r.filteringSelector[0].image,parameters:r.dataCategoryName.map(n=>n.image)}}groupByClause(r){return r.groupBy.map(n=>qt(n)?{field:n.image}:{fn:this.visit(n,{includeType:!1})})}havingClause(r){return r.conditionExpression.reduce((i,o)=>(i.expressionTree?(i.prevExpression.right=this.visit(o,{prevExpression:i.prevExpression}),i.prevExpression=i.prevExpression.right):(i.expressionTree=this.visit(o),i.prevExpression=i.expressionTree),i),{prevExpression:void 0,expressionTree:void 0}).expressionTree}orderByClause(r){return r.orderByExpressionOrFn.map(n=>this.visit(n))}orderByExpression(r){let n={field:r.Identifier[0].image};return r.order&&r.order[0]&&(n.order=r.order[0].tokenType.name),r.nulls&&r.nulls[0]&&(n.nulls=r.nulls[0].tokenType.name),n}orderByGroupingFunctionExpression(r){let n={fn:this.helpers.$_getFieldFunction(r,!1,!1)};return r.order&&r.order[0]&&(n.order=r.order[0].tokenType.name),r.nulls&&r.nulls[0]&&(n.nulls=r.nulls[0].tokenType.name),n}orderBySpecialFunctionExpression(r){let n={};return r.aggregateFunction?n.fn=this.visit(r.aggregateFunction,{includeType:!1}):r.dateFunction?n.fn=this.visit(r.dateFunction,{includeType:!1}):r.locationFunction&&(n.fn=this.visit(r.locationFunction,{includeType:!1})),r.order&&r.order[0]&&(n.order=r.order[0].tokenType.name),r.nulls&&r.nulls[0]&&(n.nulls=r.nulls[0].tokenType.name),n}limitClause(r){return r.value[0].image}offsetClause(r){return r.value[0].image}dateFunction(r,n={includeType:!0}){return this.helpers.$_getFieldFunction(r,!0,n.includeType)}aggregateFunction(r,n={includeType:!0}){return this.helpers.$_getFieldFunction(r,!0,n.includeType)}fieldsFunction(r,n={includeType:!0}){let i={};return n.includeType&&(i.type="FieldFunctionExpression"),i={...i,functionName:"FIELDS",parameters:[r.params[0].image]},i.rawValue=`FIELDS(${i.parameters[0]})`,i}otherFunction(r,n={includeType:!0}){return this.helpers.$_getFieldFunction(r,!1,n.includeType)}cubeFunction(r){return this.helpers.$_getFieldFunction(r,!1,!1)}rollupFunction(r){return this.helpers.$_getFieldFunction(r,!1,!1)}locationFunction(r,n={includeType:!0}){let i={};return n.includeType&&(i.type="FieldFunctionExpression"),i={...i,functionName:"DISTANCE",parameters:[r.location1[0].image,qt(r.location2)?r.location2[0].image:this.visit(r.location2,n),r.unit[0].image]},n.includeType&&(i.isAggregateFn=!0),i.rawValue=`DISTANCE(${i.parameters[0]}, ${k(i.parameters[1])?i.parameters[1]:i.parameters[1].rawValue}, ${i.parameters[2]})`,i}geolocationFunction(r,n={includeType:!0}){let i={};return n.includeType&&(i.type="FieldFunctionExpression"),i={...i,functionName:"GEOLOCATION",parameters:[r.latitude[0].image,r.longitude[0].image],rawValue:`GEOLOCATION(${r.latitude[0].image}, ${r.longitude[0].image})`},i}functionExpression(r,n={includeType:!0}){return r.params?r.params.map(i=>i.image?i.image:this.visit(i,n)):[]}expression(r){let{value:n,literalType:i,dateLiteralVariable:o,operator:a}=this.visit(r.operator,{returnLiteralType:!0}),s={};return qt(r.lhs)?s.field=r.lhs[0].image:s.fn=this.visit(r.lhs,{includeType:!1}),s.operator=a,s.literalType=i,i==="SUBQUERY"?s.valueQuery=n:s.value=n,o&&(s.dateLiteralVariable=o),r.L_PAREN&&(s.openParen=r.L_PAREN.length),r.R_PAREN&&(s.closeParen=r.R_PAREN.length),s}expressionPartWithNegation(r){return{left:r.L_PAREN?{openParen:r.L_PAREN.length}:null,operator:"NOT",right:{left:{}}}}expressionWithRelationalOperator(r){return r.relationalOperator?{operator:this.visit(r.relationalOperator),...this.visit(r.rhs,{returnLiteralType:!0})}:{operator:this.visit(r.setOperator),...this.visit(r.rhs,{returnLiteralType:!0})}}expressionWithSetOperator(r){return r.relationalOperator?{operator:this.visit(r.relationalOperator),...this.visit(r.rhs,{returnLiteralType:!0})}:{operator:this.visit(r.setOperator),...this.visit(r.rhs,{returnLiteralType:!0})}}atomicExpression(r,n){n=n||{};let i,o,a;if(r.apexBindVariableExpression)i=this.visit(r.apexBindVariableExpression),o="APEX_BIND_VARIABLE";else if(r.NumberIdentifier)i=r.NumberIdentifier[0].image,o=this.helpers.$_getLiteralTypeFromTokenType(r.NumberIdentifier[0].tokenType.name);else if(r.UnsignedInteger)i=r.UnsignedInteger[0].image,o="INTEGER";else if(r.SignedInteger)i=r.SignedInteger[0].image,o="INTEGER";else if(r.RealNumber)i=r.RealNumber[0].image,o="DECIMAL";else if(r.DateIdentifier)i=r.DateIdentifier[0].image,o=this.helpers.$_getLiteralTypeFromTokenType(r.DateIdentifier[0].tokenType.name);else if(r.CurrencyPrefixedInteger)i=r.CurrencyPrefixedInteger[0].image,o="INTEGER_WITH_CURRENCY_PREFIX";else if(r.CurrencyPrefixedDecimal)i=r.CurrencyPrefixedDecimal[0].image,o="DECIMAL_WITH_CURRENCY_PREFIX";else if(r.DateTime)i=r.DateTime[0].image,o="DATETIME";else if(r.date)i=r.DateToken[0].image,o="DATE";else if(r.NULL)i="NULL",o="NULL";else if(r.StringIdentifier)i=r.StringIdentifier[0].image,o="STRING";else if(r.Identifier)i=r.Identifier[0].image,o="STRING";else if(r.booleanValue)i=this.visit(r.booleanValue),o="BOOLEAN";else if(r.DateLiteral)i=r.DateLiteral[0].image,o="DATE_LITERAL";else if(r.dateNLiteral){let s=this.visit(r.dateNLiteral);i=s.value,a=s.variable,o="DATE_N_LITERAL"}else if(r.arrayExpression){let s=this.visit(r.arrayExpression);i=s.map(p=>p.value);let l=s.map(p=>p.variable||null),c=l.some(p=>p!==null);new Set(s.map(p=>p.type)).size===1?o=this.helpers.$_getLiteralTypeFromTokenType(s[0].type):o=s.map(p=>this.helpers.$_getLiteralTypeFromTokenType(p.type)),c&&(a=l),o=o||"STRING"}else r.whereClauseSubqueryIdentifier&&(i=this.visit(r.whereClauseSubqueryIdentifier),o="SUBQUERY");return n.returnLiteralType?{value:i,literalType:o,dateLiteralVariable:a}:i}apexBindVariableExpression(r){return r.apex.map(n=>this.visit(n)).join(".")}apexBindVariableIdentifier(r){let n=r.Identifier[0].image;return r.apexBindVariableFunctionArrayAccessor&&(n+=this.visit(r.apexBindVariableFunctionArrayAccessor[0])),n}apexBindVariableNewInstantiation(r){let n=`new ${r.function[0].image}`;return r.apexBindVariableGeneric&&(n+=this.visit(r.apexBindVariableGeneric[0])),n+=this.visit(r.apexBindVariableFunctionParams[0]),r.apexBindVariableFunctionArrayAccessor&&(n+=this.visit(r.apexBindVariableFunctionArrayAccessor[0])),n}apexBindVariableFunctionCall(r){let n=`${r.function[0].image}${this.visit(r.apexBindVariableFunctionParams[0])}`;return r.apexBindVariableFunctionArrayAccessor&&(n+=this.visit(r.apexBindVariableFunctionArrayAccessor[0])),n}apexBindVariableGeneric(r){return`<${r.parameter.map(n=>n.image).join(", ")}>`}apexBindVariableFunctionParams(r){return`(${(Array.isArray(r.parameter)?r.parameter:[]).map(i=>i.image).join(", ")})`}apexBindVariableFunctionArrayAccessor(r){return`[${r.value[0].image}]`}arrayExpression(r){return r.value.map(n=>qt(n)?{type:n.tokenType.name,value:n.image}:this.visit(n,{includeType:!0}))}relationalOperator(r){return r.operator[0].image}setOperator(r){if(Array.isArray(r.operator))return r.operator[0].tokenType.name.replace("_"," ");if(Array.isArray(r.notIn))return this.visit(r.notIn)}notInOperator(r){return"NOT IN"}booleanValue(r){return r.boolean[0].tokenType.name}dateNLiteral(r,n){let i={value:`${r.dateNLiteral[0].image}:${r.variable[0].image}`,variable:Number(r.variable[0].image)};return n&&n.includeType&&(i.type=r.dateNLiteral[0].tokenType.name),i}forViewOrReference(r){return r.value[0].tokenType.name}updateTrackingViewstat(r){return r.value[0].tokenType.name}},tC=new ds;function ms(t,e){let{cst:r}=hs(t,e);return tC.visit(r)}function rC(t,e){try{let{parseErrors:r}=hs(t,e);return r.length===0}catch{return!1}}function gD(t){return nC(t)}function nC(t){if(typeof t=="string")return{type:"Field",field:t};if(Is(t)){let e=[];return t.parameters&&(e=Array.isArray(t.parameters)?t.parameters:[t.parameters]),{type:"FieldFunctionExpression",functionName:t.functionName||t.fn,parameters:e,alias:t.alias}}else{if(_s(t))return{type:"FieldRelationship",field:t.field,relationships:t.relationships,objectPrefix:t.objectPrefix};if(bs(t))return{type:"FieldSubquery",subquery:t.subquery};if(vs(t))return{type:"FieldTypeof",field:t.field,conditions:t.conditions};if(Rs(t))return{type:"Field",field:t.field,objectPrefix:t.objectPrefix};throw new TypeError("The input object provided did not match any valid field types")}}function xD(t,e){if(!t)return[];t=Ps(t)?t.subquery:t;let r=t.fields;if(!r)return[];let n={};t.groupBy&&(n=(Array.isArray(t.groupBy)?t.groupBy:[t.groupBy]).reduce((l,c)=>(Tn(c)&&(l[c.field.toLocaleLowerCase()]=c.field),l),{}));let i=-1,o=(zt(t)?t.relationshipName:t.sObject||"").toLowerCase(),a=(t.sObjectAlias||"").toLowerCase();return r.flatMap(l=>{switch(l.type){case"Field":return l.alias||l.field;case"FieldFunctionExpression":{let c=oo(l);if(c=c.map(p=>{if(p.includes(".")){let h=p.split("."),d=h[0].toLowerCase();return(d===a||d===o)&&(h=h.slice(1)),h.join(".")}return p}),l.alias&&(l.isAggregateFn||e))return l.alias;if(l.alias){let p=c[0];return p.includes(".")?(c=p.split(".").slice(0,-1),c.push(l.alias),c.join(".")):l.alias}return l.isAggregateFn||Os(l)||e?(i++,`expr${i}`):c.length>0?c.join("."):l.functionName}case"FieldRelationship":{let c=l.relationships[0].toLowerCase();return An(l)?l.alias:l.rawValue&&n[l.rawValue.toLocaleLowerCase()]?l.field:c===a||c===o?l.relationships.concat([l.field]).slice(1).join("."):l.relationships.concat([l.field]).join(".")}case"FieldSubquery":return l.subquery.relationshipName;case"FieldTypeof":{let c=new Set,p=[];return l.conditions.forEach(h=>{h.fieldList.forEach(d=>{c.has(d)||(c.add(d),p.push(`${l.field}.${d}`))})}),p}default:break}}).filter(l=>k(l))}var eo=class{constructor(e,r){this.currIndent=1;this.enabled=e,this.options={numIndent:r.numIndent??1,fieldMaxLineLength:r.fieldMaxLineLength??60,fieldSubqueryParensOnOwnLine:r.fieldSubqueryParensOnOwnLine??!0,whereClauseOperatorsIndented:!0,newLineAfterKeywords:r.newLineAfterKeywords??!1,logging:r.logging??!1},this.options.newLineAfterKeywords&&(this.options.fieldSubqueryParensOnOwnLine=!0)}log(e){this.options.logging&&console.log(e)}getIndent(e=0){return this.repeatChar((this.currIndent+e)*(this.options.numIndent||1)," ")}repeatChar(e,r){return new Array(e).fill(r).join("")}setSubquery(e){this.currIndent=e?this.currIndent+=1:this.currIndent-=1}stepCurrIndex(e){this.currIndent+=e}formatFields(e){function r(n){e.fields[n-1]&&(e.fields[n-1].suffix=e.fields[n-1].suffix.trim())}if(e.fields.forEach((n,i)=>{n.suffix=e.fields.length-1===i?"":", "}),this.enabled){let n=0,i=!1;e.fields.forEach((o,a)=>{o.isSubquery?(r(a),o.prefix=`
|
|
109
|
+
${this.getIndent()}`,o.suffix=e.fields.length-1===a?"":", ",n=0,i=!0):Array.isArray(o.typeOfClause)?(r(a),o.prefix=`
|
|
110
|
+
${this.getIndent()}`,i=!0):xt(this.options.fieldMaxLineLength)&&(n+=o.text.length+o.suffix.length,(n>this.options.fieldMaxLineLength||i)&&(r(a),(!this.options.newLineAfterKeywords||a>0)&&(o.prefix+=`
|
|
111
|
+
${this.getIndent()}`),n=0,i=!1)),this.log(o)})}}formatTyeOfField(e,r){return this.enabled&&this.options.newLineAfterKeywords?r.map((n,i)=>i===0?n:i===r.length-1?`${this.getIndent()}${n}`:`${this.getIndent()} ${n}`).join(`
|
|
112
|
+
`):e}formatTypeofFieldCondition(e){let r="",n=e.fieldList.join(", ");if(this.enabled&&this.options.newLineAfterKeywords){let i=this.getIndent();r=`${e.type}`,e.objectType?r+=`
|
|
113
|
+
${i} ${e.objectType}
|
|
114
|
+
${i} THEN
|
|
115
|
+
${i} ${n}`:r+=`
|
|
116
|
+
${i} ${n}`}else r=e.type,e.objectType?r+=` ${e.objectType} THEN ${n}`:r+=` ${n}`;return r}formatSubquery(e,r=2,n=!1){n&&r++;let i="(",o=")";return this.enabled&&(this.options.fieldSubqueryParensOnOwnLine||this.options.newLineAfterKeywords?(e=e.replace(/\n/g,`
|
|
117
|
+
${this.repeatChar(r," ")}`),i=`(
|
|
118
|
+
${this.repeatChar(r," ")}`,o=`
|
|
119
|
+
${this.repeatChar(r-1," ")})`):e=e.replace(/\n/g,`
|
|
120
|
+
`)),`${i}${e}${o}`}formatClause(e){return this.enabled?this.options.newLineAfterKeywords?`
|
|
121
|
+
${e}
|
|
122
|
+
`:`
|
|
123
|
+
${e}`:` ${e}`}formatText(e){return this.enabled&&(this.options.newLineAfterKeywords||e.startsWith(`
|
|
124
|
+
`))?e:` ${e}`}formatWithIndent(e){return this.enabled?`${this.getIndent()}${e}`:e}formatOrderByArray(e){if(this.enabled){let r=0,n="";return e.forEach((i,o)=>{let a=e[o+1];r+=i.length,a&&(r+a.length>(this.options.fieldMaxLineLength||0)||this.options.newLineAfterKeywords)?(n+=`${i},
|
|
125
|
+
`,r=0):n+=`${i}${a?", ":""}`}),n}else return e.join(", ")}formatParens(e,r,n=!1){let i="";if(xt(e)&&e>0)if(this.enabled)if(r==="("){for(let o=0;o<e;o++)n&&o===e-1?i+="(":o===0?i+=`(
|
|
126
|
+
`:(this.currIndent++,i+=`${this.getIndent()}(
|
|
127
|
+
`);(!n||e>1)&&this.currIndent++}else for(let o=e-1;o>=0;o--)n&&o===e-1?i+=")":(this.currIndent--,i+=`
|
|
128
|
+
${this.getIndent()})`);else i+=Ns(e,r);return i}formatWhereClauseOperators(e,r,n=0){let i=e==="NOT";return this.enabled&&!i?`
|
|
129
|
+
${this.getIndent(n)}${e} ${r}`:`${i?"":" "}${e} ${r}`}formatAddNewLine(e=" ",r){return this.enabled&&!r?`
|
|
130
|
+
`:e}};function OD(t,e,r){return iC(ms(t,r),{format:!0,formatOptions:e})}function iC(t,e={}){if(!t)return"";e=e||{},e.format=!!e.format,e.logging&&(console.time("composer"),console.log("Composing Query:",t),console.log("Format output:",e.format));let r=new Es(t,e).query;return e.logging&&console.timeEnd("composer"),r}var Es=class{constructor(e,r={}){this.soql=e;this.logging=!1;this.format=!1;r={autoCompose:!0,...r};let{logging:n,format:i}=r;this.logging=!!n,this.format=!!i,this.query="",this.formatter=new eo(this.format,{logging:this.logging,...r.formatOptions}),r.autoCompose&&this.start()}start(){this.query=this.parseQuery(this.soql)}log(e){this.logging&&console.log("Current SOQL:",e)}parseFn(e){let r;return e.rawValue?r=e.rawValue:(r=e.functionName,r+=`(${(e.parameters||[]).map(n=>k(n)?n:this.parseFn(n)).join(", ")})`),e.alias&&(r+=` ${e.alias}`),r}parseQuery(e){let r={fields:this.parseFields(e.fields||[]).map(o=>({text:o.text,typeOfClause:o.typeOfClause,isSubquery:o.text.startsWith("("),prefix:"",suffix:""})),isSubquery:zt(e),lineBreaks:[]},n="";e.fields&&(n+=this.formatter.formatClause("SELECT").trimStart()),this.formatter.formatFields(r);let i="";if(r.fields.forEach(o=>{Array.isArray(o.typeOfClause)?i+=`${o.prefix}${this.formatter.formatTyeOfField(o.text,o.typeOfClause)}${o.suffix}`:i+=`${o.prefix}${o.text}${o.suffix}`}),n+=this.formatter.formatText(i),(zt(e)?e.relationshipName:e.sObject)&&(n+=this.formatter.formatClause("FROM")),zt(e)){let o=e.sObjectPrefix||[];o.push(e.relationshipName),n+=this.formatter.formatText(`${o.join(".")}${wt(e.sObjectAlias,""," ")}`)}else e.sObject&&(n+=this.formatter.formatText(`${e.sObject}${wt(e.sObjectAlias,""," ")}`));return this.log(n),e.usingScope&&(n+=this.formatter.formatClause("USING SCOPE"),n+=this.formatter.formatText(e.usingScope),this.log(n)),e.where&&(n+=this.formatter.formatClause("WHERE"),n+=this.formatter.formatText(this.parseWhereOrHavingClause(e.where)),this.log(n)),e.groupBy&&(n+=this.formatter.formatClause("GROUP BY"),n+=this.formatter.formatText(this.parseGroupByClause(e.groupBy)),this.log(n),e.having&&(n+=this.formatter.formatClause("HAVING"),n+=this.formatter.formatText(this.parseWhereOrHavingClause(e.having)),this.log(n))),e.orderBy&&(!Array.isArray(e.orderBy)||e.orderBy.length>0)&&(n+=this.formatter.formatClause("ORDER BY"),n+=this.formatter.formatText(this.parseOrderBy(e.orderBy)),this.log(n)),xt(e.limit)&&(n+=this.formatter.formatClause("LIMIT"),n+=this.formatter.formatText(`${e.limit}`),this.log(n)),xt(e.offset)&&(n+=this.formatter.formatClause("OFFSET"),n+=this.formatter.formatText(`${e.offset}`),this.log(n)),e.withDataCategory&&(n+=this.formatter.formatClause("WITH DATA CATEGORY"),n+=this.formatter.formatText(this.parseWithDataCategory(e.withDataCategory)),this.log(n)),e.withSecurityEnforced&&(n+=this.formatter.formatClause("WITH SECURITY_ENFORCED"),this.log(n)),e.withAccessLevel&&(n+=this.formatter.formatClause(`WITH ${e.withAccessLevel}`),this.log(n)),e.for&&(n+=this.formatter.formatClause("FOR"),n+=this.formatter.formatText(e.for),this.log(n)),e.update&&(n+=this.formatter.formatClause("UPDATE"),n+=this.formatter.formatText(e.update),this.log(n)),n.trim()}parseFields(e){return e.map(r=>{let n="",i,o=r.objectPrefix?`${r.objectPrefix}.`:"";switch(r.type){case"Field":{n=`${o}${r.field}${r.alias?` ${r.alias}`:""}`;break}case"FieldFunctionExpression":{let a="";r.parameters&&(a=r.parameters.map(s=>k(s)?s:this.parseFields([s]).map(l=>l.text)).join(", ")),n=`${r.functionName}(${a})${r.alias?` ${r.alias}`:""}`;break}case"FieldRelationship":{n=`${o}${r.relationships.join(".")}.${r.field}${An(r)?` ${r.alias}`:""}`;break}case"FieldSubquery":{n=this.formatter.formatSubquery(this.parseQuery(r.subquery));break}case"FieldTypeof":{i=this.parseTypeOfField(r),n=i.join(" ");break}default:break}return{text:n,typeOfClause:i}})}parseTypeOfField(e){let r=[`TYPEOF ${e.field}`].concat(e.conditions.map(n=>this.formatter.formatTypeofFieldCondition(n)));return r.push("END"),r}parseWhereOrHavingClause(e,r=0,n=!1){let i="",o=e.left,a=!1;if(o&&(i+=this.formatter.formatParens(o.openParen,"(",Br(o)),!Br(o))){r=r+(o.openParen||0)-(o.closeParen||0),n&&r++;let s="";s+=lo(o)?this.parseFn(o.fn):o.field,s+=` ${o.operator} `,uo(o)?s+=this.formatter.formatSubquery(this.parseQuery(o.valueQuery),1,!0):s+=ys(Fs(o.value,o.literalType,o.operator)),i+=this.formatter.formatWithIndent(s),i+=this.formatter.formatParens(o.closeParen,")",n)}if(so(e)){let s=wt(e.operator);a=s==="NOT";let l=this.formatter.formatWhereClauseOperators(s,this.parseWhereOrHavingClause(e.right,r,Br(o)),r);return`${a?i.trimRight():i}${l}`.trim()}else return i.trim()}parseGroupByClause(e){return(Array.isArray(e)?e:[e]).map(r=>Tn(r)?r.field:this.parseFn(r.fn)).join(", ")}parseOrderBy(e){if(Array.isArray(e))return this.formatter.formatOrderByArray(e.map(r=>this.parseOrderBy(r)));{let r="";return co(e)?r=`${wt(e.field," ")}`:r+=`${this.parseFn(e.fn)} `,r+=`${wt(e.order," ")}${wt(e.nulls,"","NULLS ")}`,r.trim()}}parseWithDataCategory(e){return e.conditions.map(r=>{let n=r.parameters.length>1?`(${r.parameters.join(", ")})`:`${r.parameters.join(", ")}`;return`${r.groupName} ${r.selector} ${n}`}).join(" AND ")}};export{Es as Compose,iC as composeQuery,OD as formatQuery,gD as getComposedField,nC as getField,xD as getFlattenedFields,An as hasAlias,Ps as isFieldSubquery,Tn as isGroupByField,qf as isGroupByFn,jf as isHavingClauseWithRightCondition,Br as isNegationCondition,co as isOrderByField,Xf as isOrderByFn,rC as isQueryValid,k as isString,zt as isSubquery,Hf as isValueCondition,lo as isValueFunctionCondition,uo as isValueQueryCondition,Kf as isValueWithDateLiteralCondition,Yf as isValueWithDateNLiteralCondition,ao as isWhereClauseWithRightCondition,so as isWhereOrHavingClauseWithRightCondition,ms as parseQuery};
|
|
131
|
+
/*! Bundled license information:
|
|
132
|
+
|
|
133
|
+
lodash-es/lodash.js:
|
|
134
|
+
(**
|
|
135
|
+
* @license
|
|
136
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
137
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
138
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
139
|
+
* Released under MIT license <https://lodash.com/license>
|
|
140
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
141
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
142
|
+
*)
|
|
143
|
+
*/
|