UNPKG

edgejs-parser

Version:
20 lines 141 kB
(function(je,tt){typeof exports=="object"&&typeof module<"u"?module.exports=tt():typeof define=="function"&&define.amd?define(tt):(je=typeof globalThis<"u"?globalThis:je||self,je["edge-parser"]=tt())})(this,function(){"use strict";var je=typeof global=="object"&&global&&global.Object===Object&&global,tt=typeof self=="object"&&self&&self.Object===Object&&self,fe=je||tt||Function("return this")(),q=fe.Symbol,Er=Object.prototype,Zi=Er.hasOwnProperty,Qi=Er.toString,nt=q?q.toStringTag:void 0;function Ji(t){var e=Zi.call(t,nt),n=t[nt];try{t[nt]=void 0;var r=!0}catch{}var s=Qi.call(t);return r&&(e?t[nt]=n:delete t[nt]),s}var ea=Object.prototype,ta=ea.toString;function na(t){return ta.call(t)}var ra="[object Null]",sa="[object Undefined]",gr=q?q.toStringTag:void 0;function ye(t){return t==null?t===void 0?sa:ra:gr&&gr in Object(t)?Ji(t):na(t)}function re(t){return t!=null&&typeof t=="object"}var ia="[object Symbol]";function Ct(t){return typeof t=="symbol"||re(t)&&ye(t)==ia}function Lt(t,e){for(var n=-1,r=t==null?0:t.length,s=Array(r);++n<r;)s[n]=e(t[n],n,t);return s}var N=Array.isArray,Tr=q?q.prototype:void 0,mr=Tr?Tr.toString:void 0;function Ar(t){if(typeof t=="string")return t;if(N(t))return Lt(t,Ar)+"";if(Ct(t))return mr?mr.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var aa=/\s/;function oa(t){for(var e=t.length;e--&&aa.test(t.charAt(e)););return e}var ca=/^\s+/;function ua(t){return t&&t.slice(0,oa(t)+1).replace(ca,"")}function Z(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Rr=NaN,la=/^[-+]0x[0-9a-f]+$/i,ha=/^0b[01]+$/i,fa=/^0o[0-7]+$/i,da=parseInt;function pa(t){if(typeof t=="number")return t;if(Ct(t))return Rr;if(Z(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Z(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=ua(t);var n=ha.test(t);return n||fa.test(t)?da(t.slice(2),n?2:8):la.test(t)?Rr:+t}var Ir=1/0,Ea=17976931348623157e292;function ga(t){if(!t)return t===0?t:0;if(t=pa(t),t===Ir||t===-Ir){var e=t<0?-1:1;return e*Ea}return t===t?t:0}function yt(t){var e=ga(t),n=e%1;return e===e?n?e-n:e:0}function ze(t){return t}var Ta="[object AsyncFunction]",ma="[object Function]",Aa="[object GeneratorFunction]",Ra="[object Proxy]";function Re(t){if(!Z(t))return!1;var e=ye(t);return e==ma||e==Aa||e==Ta||e==Ra}var gn=fe["__core-js_shared__"],Sr=function(){var t=/[^.]+$/.exec(gn&&gn.keys&&gn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ia(t){return!!Sr&&Sr in t}var Sa=Function.prototype,_a=Sa.toString;function Ue(t){if(t!=null){try{return _a.call(t)}catch{}try{return t+""}catch{}}return""}var Oa=/[\\^$.*+?()[\]{}|]/g,Na=/^\[object .+?Constructor\]$/,Ca=Function.prototype,La=Object.prototype,ya=Ca.toString,va=La.hasOwnProperty,Pa=RegExp("^"+ya.call(va).replace(Oa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ma(t){if(!Z(t)||Ia(t))return!1;var e=Re(t)?Pa:Na;return e.test(Ue(t))}function ka(t,e){return t?.[e]}function Fe(t,e){var n=ka(t,e);return Ma(n)?n:void 0}var Tn=Fe(fe,"WeakMap"),_r=Object.create,xa=function(){function t(){}return function(e){if(!Z(e))return{};if(_r)return _r(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function ba(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function b(){}function wa(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}var Ua=800,Fa=16,Da=Date.now;function $a(t){var e=0,n=0;return function(){var r=Da(),s=Fa-(r-n);if(n=r,s>0){if(++e>=Ua)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function Ga(t){return function(){return t}}var vt=function(){try{var t=Fe(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Ba=vt?function(t,e){return vt(t,"toString",{configurable:!0,enumerable:!1,value:Ga(e),writable:!0})}:ze,Ha=$a(Ba);function Or(t,e){for(var n=-1,r=t==null?0:t.length;++n<r&&e(t[n],n,t)!==!1;);return t}function Nr(t,e,n,r){for(var s=t.length,i=n+-1;++i<s;)if(e(t[i],i,t))return i;return-1}function Ka(t){return t!==t}function Wa(t,e,n){for(var r=n-1,s=t.length;++r<s;)if(t[r]===e)return r;return-1}function mn(t,e,n){return e===e?Wa(t,e,n):Nr(t,Ka,n)}function Cr(t,e){var n=t==null?0:t.length;return!!n&&mn(t,e,0)>-1}var ja=9007199254740991,za=/^(?:0|[1-9]\d*)$/;function Pt(t,e){var n=typeof t;return e=e??ja,!!e&&(n=="number"||n!="symbol"&&za.test(t))&&t>-1&&t%1==0&&t<e}function An(t,e,n){e=="__proto__"&&vt?vt(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function rt(t,e){return t===e||t!==t&&e!==e}var Va=Object.prototype,Ya=Va.hasOwnProperty;function Mt(t,e,n){var r=t[e];(!(Ya.call(t,e)&&rt(r,n))||n===void 0&&!(e in t))&&An(t,e,n)}function Rn(t,e,n,r){var s=!n;n||(n={});for(var i=-1,a=e.length;++i<a;){var o=e[i],c=void 0;c===void 0&&(c=t[o]),s?An(n,o,c):Mt(n,o,c)}return n}var Lr=Math.max;function Xa(t,e,n){return e=Lr(e===void 0?t.length-1:e,0),function(){for(var r=arguments,s=-1,i=Lr(r.length-e,0),a=Array(i);++s<i;)a[s]=r[e+s];s=-1;for(var o=Array(e+1);++s<e;)o[s]=r[s];return o[e]=n(a),ba(t,this,o)}}function In(t,e){return Ha(Xa(t,e,ze),t+"")}var qa=9007199254740991;function Sn(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=qa}function de(t){return t!=null&&Sn(t.length)&&!Re(t)}function yr(t,e,n){if(!Z(n))return!1;var r=typeof e;return(r=="number"?de(n)&&Pt(e,n.length):r=="string"&&e in n)?rt(n[e],t):!1}function Za(t){return In(function(e,n){var r=-1,s=n.length,i=s>1?n[s-1]:void 0,a=s>2?n[2]:void 0;for(i=t.length>3&&typeof i=="function"?(s--,i):void 0,a&&yr(n[0],n[1],a)&&(i=s<3?void 0:i,s=1),e=Object(e);++r<s;){var o=n[r];o&&t(e,o,r,i)}return e})}var Qa=Object.prototype;function st(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Qa;return t===n}function Ja(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}var eo="[object Arguments]";function vr(t){return re(t)&&ye(t)==eo}var Pr=Object.prototype,to=Pr.hasOwnProperty,no=Pr.propertyIsEnumerable,kt=vr(function(){return arguments}())?vr:function(t){return re(t)&&to.call(t,"callee")&&!no.call(t,"callee")};function ro(){return!1}var Mr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kr=Mr&&typeof module=="object"&&module&&!module.nodeType&&module,so=kr&&kr.exports===Mr,xr=so?fe.Buffer:void 0,io=xr?xr.isBuffer:void 0,it=io||ro,ao="[object Arguments]",oo="[object Array]",co="[object Boolean]",uo="[object Date]",lo="[object Error]",ho="[object Function]",fo="[object Map]",po="[object Number]",Eo="[object Object]",go="[object RegExp]",To="[object Set]",mo="[object String]",Ao="[object WeakMap]",Ro="[object ArrayBuffer]",Io="[object DataView]",So="[object Float32Array]",_o="[object Float64Array]",Oo="[object Int8Array]",No="[object Int16Array]",Co="[object Int32Array]",Lo="[object Uint8Array]",yo="[object Uint8ClampedArray]",vo="[object Uint16Array]",Po="[object Uint32Array]",P={};P[So]=P[_o]=P[Oo]=P[No]=P[Co]=P[Lo]=P[yo]=P[vo]=P[Po]=!0,P[ao]=P[oo]=P[Ro]=P[co]=P[Io]=P[uo]=P[lo]=P[ho]=P[fo]=P[po]=P[Eo]=P[go]=P[To]=P[mo]=P[Ao]=!1;function Mo(t){return re(t)&&Sn(t.length)&&!!P[ye(t)]}function xt(t){return function(e){return t(e)}}var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,at=br&&typeof module=="object"&&module&&!module.nodeType&&module,ko=at&&at.exports===br,_n=ko&&je.process,ve=function(){try{var t=at&&at.require&&at.require("util").types;return t||_n&&_n.binding&&_n.binding("util")}catch{}}(),wr=ve&&ve.isTypedArray,On=wr?xt(wr):Mo,xo=Object.prototype,bo=xo.hasOwnProperty;function Ur(t,e){var n=N(t),r=!n&&kt(t),s=!n&&!r&&it(t),i=!n&&!r&&!s&&On(t),a=n||r||s||i,o=a?Ja(t.length,String):[],c=o.length;for(var u in t)(e||bo.call(t,u))&&!(a&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Pt(u,c)))&&o.push(u);return o}function Fr(t,e){return function(n){return t(e(n))}}var wo=Fr(Object.keys,Object),Uo=Object.prototype,Fo=Uo.hasOwnProperty;function Dr(t){if(!st(t))return wo(t);var e=[];for(var n in Object(t))Fo.call(t,n)&&n!="constructor"&&e.push(n);return e}function Q(t){return de(t)?Ur(t):Dr(t)}var Do=Object.prototype,$o=Do.hasOwnProperty,z=Za(function(t,e){if(st(e)||de(e)){Rn(e,Q(e),t);return}for(var n in e)$o.call(e,n)&&Mt(t,n,e[n])});function Go(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var Bo=Object.prototype,Ho=Bo.hasOwnProperty;function Ko(t){if(!Z(t))return Go(t);var e=st(t),n=[];for(var r in t)r=="constructor"&&(e||!Ho.call(t,r))||n.push(r);return n}function $r(t){return de(t)?Ur(t,!0):Ko(t)}var Wo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jo=/^\w*$/;function Nn(t,e){if(N(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Ct(t)?!0:jo.test(t)||!Wo.test(t)||e!=null&&t in Object(e)}var ot=Fe(Object,"create");function zo(){this.__data__=ot?ot(null):{},this.size=0}function Vo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Yo="__lodash_hash_undefined__",Xo=Object.prototype,qo=Xo.hasOwnProperty;function Zo(t){var e=this.__data__;if(ot){var n=e[t];return n===Yo?void 0:n}return qo.call(e,t)?e[t]:void 0}var Qo=Object.prototype,Jo=Qo.hasOwnProperty;function ec(t){var e=this.__data__;return ot?e[t]!==void 0:Jo.call(e,t)}var tc="__lodash_hash_undefined__";function nc(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=ot&&e===void 0?tc:e,this}function De(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}De.prototype.clear=zo,De.prototype.delete=Vo,De.prototype.get=Zo,De.prototype.has=ec,De.prototype.set=nc;function rc(){this.__data__=[],this.size=0}function bt(t,e){for(var n=t.length;n--;)if(rt(t[n][0],e))return n;return-1}var sc=Array.prototype,ic=sc.splice;function ac(t){var e=this.__data__,n=bt(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():ic.call(e,n,1),--this.size,!0}function oc(t){var e=this.__data__,n=bt(e,t);return n<0?void 0:e[n][1]}function cc(t){return bt(this.__data__,t)>-1}function uc(t,e){var n=this.__data__,r=bt(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function Ie(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Ie.prototype.clear=rc,Ie.prototype.delete=ac,Ie.prototype.get=oc,Ie.prototype.has=cc,Ie.prototype.set=uc;var ct=Fe(fe,"Map");function lc(){this.size=0,this.__data__={hash:new De,map:new(ct||Ie),string:new De}}function hc(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function wt(t,e){var n=t.__data__;return hc(e)?n[typeof e=="string"?"string":"hash"]:n.map}function fc(t){var e=wt(this,t).delete(t);return this.size-=e?1:0,e}function dc(t){return wt(this,t).get(t)}function pc(t){return wt(this,t).has(t)}function Ec(t,e){var n=wt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}function Se(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Se.prototype.clear=lc,Se.prototype.delete=fc,Se.prototype.get=dc,Se.prototype.has=pc,Se.prototype.set=Ec;var gc="Expected a function";function Cn(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(gc);var n=function(){var r=arguments,s=e?e.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var a=t.apply(this,r);return n.cache=i.set(s,a)||i,a};return n.cache=new(Cn.Cache||Se),n}Cn.Cache=Se;var Tc=500;function mc(t){var e=Cn(t,function(r){return n.size===Tc&&n.clear(),r}),n=e.cache;return e}var Ac=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Rc=/\\(\\)?/g,Ic=mc(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Ac,function(n,r,s,i){e.push(s?i.replace(Rc,"$1"):r||n)}),e});function Sc(t){return t==null?"":Ar(t)}function Ut(t,e){return N(t)?t:Nn(t,e)?[t]:Ic(Sc(t))}function ut(t){if(typeof t=="string"||Ct(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Ln(t,e){e=Ut(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[ut(e[n++])];return n&&n==r?t:void 0}function _c(t,e,n){var r=t==null?void 0:Ln(t,e);return r===void 0?n:r}function yn(t,e){for(var n=-1,r=e.length,s=t.length;++n<r;)t[s+n]=e[n];return t}var Gr=q?q.isConcatSpreadable:void 0;function Oc(t){return N(t)||kt(t)||!!(Gr&&t&&t[Gr])}function vn(t,e,n,r,s){var i=-1,a=t.length;for(n||(n=Oc),s||(s=[]);++i<a;){var o=t[i];n(o)?yn(s,o):r||(s[s.length]=o)}return s}function se(t){var e=t==null?0:t.length;return e?vn(t):[]}var Br=Fr(Object.getPrototypeOf,Object);function Hr(t,e,n){var r=-1,s=t.length;e<0&&(e=-e>s?0:s+e),n=n>s?s:n,n<0&&(n+=s),s=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(s);++r<s;)i[r]=t[r+e];return i}function Nc(t,e,n,r){var s=-1,i=t==null?0:t.length;for(r&&i&&(n=t[++s]);++s<i;)n=e(n,t[s],s,t);return n}function Cc(){this.__data__=new Ie,this.size=0}function Lc(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function yc(t){return this.__data__.get(t)}function vc(t){return this.__data__.has(t)}var Pc=200;function Mc(t,e){var n=this.__data__;if(n instanceof Ie){var r=n.__data__;if(!ct||r.length<Pc-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Se(r)}return n.set(t,e),this.size=n.size,this}function pe(t){var e=this.__data__=new Ie(t);this.size=e.size}pe.prototype.clear=Cc,pe.prototype.delete=Lc,pe.prototype.get=yc,pe.prototype.has=vc,pe.prototype.set=Mc;function kc(t,e){return t&&Rn(e,Q(e),t)}var Kr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wr=Kr&&typeof module=="object"&&module&&!module.nodeType&&module,xc=Wr&&Wr.exports===Kr,jr=xc?fe.Buffer:void 0,zr=jr?jr.allocUnsafe:void 0;function bc(t,e){var n=t.length,r=zr?zr(n):new t.constructor(n);return t.copy(r),r}function Pn(t,e){for(var n=-1,r=t==null?0:t.length,s=0,i=[];++n<r;){var a=t[n];e(a,n,t)&&(i[s++]=a)}return i}function Vr(){return[]}var wc=Object.prototype,Uc=wc.propertyIsEnumerable,Yr=Object.getOwnPropertySymbols,Mn=Yr?function(t){return t==null?[]:(t=Object(t),Pn(Yr(t),function(e){return Uc.call(t,e)}))}:Vr;function Fc(t,e){return Rn(t,Mn(t),e)}var Dc=Object.getOwnPropertySymbols,$c=Dc?function(t){for(var e=[];t;)yn(e,Mn(t)),t=Br(t);return e}:Vr;function Xr(t,e,n){var r=e(t);return N(t)?r:yn(r,n(t))}function kn(t){return Xr(t,Q,Mn)}function Gc(t){return Xr(t,$r,$c)}var xn=Fe(fe,"DataView"),bn=Fe(fe,"Promise"),Ve=Fe(fe,"Set"),qr="[object Map]",Bc="[object Object]",Zr="[object Promise]",Qr="[object Set]",Jr="[object WeakMap]",es="[object DataView]",Hc=Ue(xn),Kc=Ue(ct),Wc=Ue(bn),jc=Ue(Ve),zc=Ue(Tn),J=ye;(xn&&J(new xn(new ArrayBuffer(1)))!=es||ct&&J(new ct)!=qr||bn&&J(bn.resolve())!=Zr||Ve&&J(new Ve)!=Qr||Tn&&J(new Tn)!=Jr)&&(J=function(t){var e=ye(t),n=e==Bc?t.constructor:void 0,r=n?Ue(n):"";if(r)switch(r){case Hc:return es;case Kc:return qr;case Wc:return Zr;case jc:return Qr;case zc:return Jr}return e});var Vc=Object.prototype,Yc=Vc.hasOwnProperty;function Xc(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&Yc.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var Ft=fe.Uint8Array;function qc(t){var e=new t.constructor(t.byteLength);return new Ft(e).set(new Ft(t)),e}function Zc(t,e){var n=t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}var Qc=/\w*$/;function Jc(t){var e=new t.constructor(t.source,Qc.exec(t));return e.lastIndex=t.lastIndex,e}var ts=q?q.prototype:void 0,ns=ts?ts.valueOf:void 0;function eu(t){return ns?Object(ns.call(t)):{}}function tu(t,e){var n=t.buffer;return new t.constructor(n,t.byteOffset,t.length)}var nu="[object Boolean]",ru="[object Date]",su="[object Map]",iu="[object Number]",au="[object RegExp]",ou="[object Set]",cu="[object String]",uu="[object Symbol]",lu="[object ArrayBuffer]",hu="[object DataView]",fu="[object Float32Array]",du="[object Float64Array]",pu="[object Int8Array]",Eu="[object Int16Array]",gu="[object Int32Array]",Tu="[object Uint8Array]",mu="[object Uint8ClampedArray]",Au="[object Uint16Array]",Ru="[object Uint32Array]";function Iu(t,e,n){var r=t.constructor;switch(e){case lu:return qc(t);case nu:case ru:return new r(+t);case hu:return Zc(t);case fu:case du:case pu:case Eu:case gu:case Tu:case mu:case Au:case Ru:return tu(t);case su:return new r;case iu:case cu:return new r(t);case au:return Jc(t);case ou:return new r;case uu:return eu(t)}}function Su(t){return typeof t.constructor=="function"&&!st(t)?xa(Br(t)):{}}var _u="[object Map]";function Ou(t){return re(t)&&J(t)==_u}var rs=ve&&ve.isMap,Nu=rs?xt(rs):Ou,Cu="[object Set]";function Lu(t){return re(t)&&J(t)==Cu}var ss=ve&&ve.isSet,yu=ss?xt(ss):Lu,is="[object Arguments]",vu="[object Array]",Pu="[object Boolean]",Mu="[object Date]",ku="[object Error]",as="[object Function]",xu="[object GeneratorFunction]",bu="[object Map]",wu="[object Number]",os="[object Object]",Uu="[object RegExp]",Fu="[object Set]",Du="[object String]",$u="[object Symbol]",Gu="[object WeakMap]",Bu="[object ArrayBuffer]",Hu="[object DataView]",Ku="[object Float32Array]",Wu="[object Float64Array]",ju="[object Int8Array]",zu="[object Int16Array]",Vu="[object Int32Array]",Yu="[object Uint8Array]",Xu="[object Uint8ClampedArray]",qu="[object Uint16Array]",Zu="[object Uint32Array]",y={};y[is]=y[vu]=y[Bu]=y[Hu]=y[Pu]=y[Mu]=y[Ku]=y[Wu]=y[ju]=y[zu]=y[Vu]=y[bu]=y[wu]=y[os]=y[Uu]=y[Fu]=y[Du]=y[$u]=y[Yu]=y[Xu]=y[qu]=y[Zu]=!0,y[ku]=y[as]=y[Gu]=!1;function Dt(t,e,n,r,s,i){var a;if(a!==void 0)return a;if(!Z(t))return t;var o=N(t);if(o)return a=Xc(t),wa(t,a);var c=J(t),u=c==as||c==xu;if(it(t))return bc(t);if(c==os||c==is||u&&!s)return a=u?{}:Su(t),Fc(t,kc(a,t));if(!y[c])return s?t:{};a=Iu(t,c),i||(i=new pe);var l=i.get(t);if(l)return l;i.set(t,a),yu(t)?t.forEach(function(p){a.add(Dt(p,e,n,p,t,i))}):Nu(t)&&t.forEach(function(p,T){a.set(T,Dt(p,e,n,T,t,i))});var h=kn,f=o?void 0:h(t);return Or(f||t,function(p,T){f&&(T=p,p=t[T]),Mt(a,T,Dt(p,e,n,T,t,i))}),a}var Qu=4;function F(t){return Dt(t,Qu)}function lt(t){for(var e=-1,n=t==null?0:t.length,r=0,s=[];++e<n;){var i=t[e];i&&(s[r++]=i)}return s}var Ju="__lodash_hash_undefined__";function el(t){return this.__data__.set(t,Ju),this}function tl(t){return this.__data__.has(t)}function Ye(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Se;++e<n;)this.add(t[e])}Ye.prototype.add=Ye.prototype.push=el,Ye.prototype.has=tl;function cs(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function wn(t,e){return t.has(e)}var nl=1,rl=2;function us(t,e,n,r,s,i){var a=n&nl,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var h=-1,f=!0,p=n&rl?new Ye:void 0;for(i.set(t,e),i.set(e,t);++h<o;){var T=t[h],I=e[h];if(r)var O=a?r(I,T,h,e,t,i):r(T,I,h,t,e,i);if(O!==void 0){if(O)continue;f=!1;break}if(p){if(!cs(e,function(g,E){if(!wn(p,E)&&(T===g||s(T,g,n,r,i)))return p.push(E)})){f=!1;break}}else if(!(T===I||s(T,I,n,r,i))){f=!1;break}}return i.delete(t),i.delete(e),f}function sl(t){var e=-1,n=Array(t.size);return t.forEach(function(r,s){n[++e]=[s,r]}),n}function Un(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}var il=1,al=2,ol="[object Boolean]",cl="[object Date]",ul="[object Error]",ll="[object Map]",hl="[object Number]",fl="[object RegExp]",dl="[object Set]",pl="[object String]",El="[object Symbol]",gl="[object ArrayBuffer]",Tl="[object DataView]",ls=q?q.prototype:void 0,Fn=ls?ls.valueOf:void 0;function ml(t,e,n,r,s,i,a){switch(n){case Tl:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case gl:return!(t.byteLength!=e.byteLength||!i(new Ft(t),new Ft(e)));case ol:case cl:case hl:return rt(+t,+e);case ul:return t.name==e.name&&t.message==e.message;case fl:case pl:return t==e+"";case ll:var o=sl;case dl:var c=r&il;if(o||(o=Un),t.size!=e.size&&!c)return!1;var u=a.get(t);if(u)return u==e;r|=al,a.set(t,e);var l=us(o(t),o(e),r,s,i,a);return a.delete(t),l;case El:if(Fn)return Fn.call(t)==Fn.call(e)}return!1}var Al=1,Rl=Object.prototype,Il=Rl.hasOwnProperty;function Sl(t,e,n,r,s,i){var a=n&Al,o=kn(t),c=o.length,u=kn(e),l=u.length;if(c!=l&&!a)return!1;for(var h=c;h--;){var f=o[h];if(!(a?f in e:Il.call(e,f)))return!1}var p=i.get(t),T=i.get(e);if(p&&T)return p==e&&T==t;var I=!0;i.set(t,e),i.set(e,t);for(var O=a;++h<c;){f=o[h];var g=t[f],E=e[f];if(r)var d=a?r(E,g,f,e,t,i):r(g,E,f,t,e,i);if(!(d===void 0?g===E||s(g,E,n,r,i):d)){I=!1;break}O||(O=f=="constructor")}if(I&&!O){var m=t.constructor,L=e.constructor;m!=L&&"constructor"in t&&"constructor"in e&&!(typeof m=="function"&&m instanceof m&&typeof L=="function"&&L instanceof L)&&(I=!1)}return i.delete(t),i.delete(e),I}var _l=1,hs="[object Arguments]",fs="[object Array]",$t="[object Object]",Ol=Object.prototype,ds=Ol.hasOwnProperty;function Nl(t,e,n,r,s,i){var a=N(t),o=N(e),c=a?fs:J(t),u=o?fs:J(e);c=c==hs?$t:c,u=u==hs?$t:u;var l=c==$t,h=u==$t,f=c==u;if(f&&it(t)){if(!it(e))return!1;a=!0,l=!1}if(f&&!l)return i||(i=new pe),a||On(t)?us(t,e,n,r,s,i):ml(t,e,c,n,r,s,i);if(!(n&_l)){var p=l&&ds.call(t,"__wrapped__"),T=h&&ds.call(e,"__wrapped__");if(p||T){var I=p?t.value():t,O=T?e.value():e;return i||(i=new pe),s(I,O,n,r,i)}}return f?(i||(i=new pe),Sl(t,e,n,r,s,i)):!1}function Dn(t,e,n,r,s){return t===e?!0:t==null||e==null||!re(t)&&!re(e)?t!==t&&e!==e:Nl(t,e,n,r,Dn,s)}var Cl=1,Ll=2;function yl(t,e,n,r){var s=n.length,i=s;if(t==null)return!i;for(t=Object(t);s--;){var a=n[s];if(a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++s<i;){a=n[s];var o=a[0],c=t[o],u=a[1];if(a[2]){if(c===void 0&&!(o in t))return!1}else{var l=new pe,h;if(!(h===void 0?Dn(u,c,Cl|Ll,r,l):h))return!1}}return!0}function ps(t){return t===t&&!Z(t)}function vl(t){for(var e=Q(t),n=e.length;n--;){var r=e[n],s=t[r];e[n]=[r,s,ps(s)]}return e}function Es(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}function Pl(t){var e=vl(t);return e.length==1&&e[0][2]?Es(e[0][0],e[0][1]):function(n){return n===t||yl(n,t,e)}}function Ml(t,e){return t!=null&&e in Object(t)}function gs(t,e,n){e=Ut(e,t);for(var r=-1,s=e.length,i=!1;++r<s;){var a=ut(e[r]);if(!(i=t!=null&&n(t,a)))break;t=t[a]}return i||++r!=s?i:(s=t==null?0:t.length,!!s&&Sn(s)&&Pt(a,s)&&(N(t)||kt(t)))}function kl(t,e){return t!=null&&gs(t,e,Ml)}var xl=1,bl=2;function wl(t,e){return Nn(t)&&ps(e)?Es(ut(t),e):function(n){var r=_c(n,t);return r===void 0&&r===e?kl(n,t):Dn(e,r,xl|bl)}}function Ul(t){return function(e){return e?.[t]}}function Fl(t){return function(e){return Ln(e,t)}}function Dl(t){return Nn(t)?Ul(ut(t)):Fl(t)}function Ee(t){return typeof t=="function"?t:t==null?ze:typeof t=="object"?N(t)?wl(t[0],t[1]):Pl(t):Dl(t)}function $l(t,e,n,r){for(var s=-1,i=t==null?0:t.length;++s<i;){var a=t[s];e(r,a,n(a),t)}return r}function Gl(t){return function(e,n,r){for(var s=-1,i=Object(e),a=r(e),o=a.length;o--;){var c=a[++s];if(n(i[c],c,i)===!1)break}return e}}var Bl=Gl();function Hl(t,e){return t&&Bl(t,e,Q)}function Kl(t,e){return function(n,r){if(n==null)return n;if(!de(n))return t(n,r);for(var s=n.length,i=-1,a=Object(n);++i<s&&r(a[i],i,a)!==!1;);return n}}var $e=Kl(Hl);function Wl(t,e,n,r){return $e(t,function(s,i,a){e(r,s,n(s),a)}),r}function jl(t,e){return function(n,r){var s=N(n)?$l:Wl,i=e?e():{};return s(n,t,Ee(r),i)}}var Ts=Object.prototype,zl=Ts.hasOwnProperty,$n=In(function(t,e){t=Object(t);var n=-1,r=e.length,s=r>2?e[2]:void 0;for(s&&yr(e[0],e[1],s)&&(r=1);++n<r;)for(var i=e[n],a=$r(i),o=-1,c=a.length;++o<c;){var u=a[o],l=t[u];(l===void 0||rt(l,Ts[u])&&!zl.call(t,u))&&(t[u]=i[u])}return t});function ms(t){return re(t)&&de(t)}var Vl=200;function Yl(t,e,n,r){var s=-1,i=Cr,a=!0,o=t.length,c=[],u=e.length;if(!o)return c;e.length>=Vl&&(i=wn,a=!1,e=new Ye(e));e:for(;++s<o;){var l=t[s],h=l;if(l=l!==0?l:0,a&&h===h){for(var f=u;f--;)if(e[f]===h)continue e;c.push(l)}else i(e,h,r)||c.push(l)}return c}var Gt=In(function(t,e){return ms(t)?Yl(t,vn(e,1,ms,!0)):[]});function Xe(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}function D(t,e,n){var r=t==null?0:t.length;return r?(e=e===void 0?1:yt(e),Hr(t,e<0?0:e,r)):[]}function ht(t,e,n){var r=t==null?0:t.length;return r?(e=e===void 0?1:yt(e),e=r-e,Hr(t,0,e<0?0:e)):[]}function Xl(t){return typeof t=="function"?t:ze}function S(t,e){var n=N(t)?Or:$e;return n(t,Xl(e))}function ql(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function Zl(t,e){var n=!0;return $e(t,function(r,s,i){return n=!!e(r,s,i),n}),n}function ie(t,e,n){var r=N(t)?ql:Zl;return r(t,Ee(e))}function As(t,e){var n=[];return $e(t,function(r,s,i){e(r,s,i)&&n.push(r)}),n}function ee(t,e){var n=N(t)?Pn:As;return n(t,Ee(e))}function Ql(t){return function(e,n,r){var s=Object(e);if(!de(e)){var i=Ee(n);e=Q(e),n=function(o){return i(s[o],o,s)}}var a=t(e,n,r);return a>-1?s[i?e[a]:a]:void 0}}var Jl=Math.max;function eh(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=n==null?0:yt(n);return s<0&&(s=Jl(r+s,0)),Nr(t,Ee(e),s)}var qe=Ql(eh);function ae(t){return t&&t.length?t[0]:void 0}function th(t,e){var n=-1,r=de(t)?Array(t.length):[];return $e(t,function(s,i,a){r[++n]=e(s,i,a)}),r}function A(t,e){var n=N(t)?Lt:th;return n(t,Ee(e))}function te(t,e){return vn(A(t,e))}var nh=Object.prototype,rh=nh.hasOwnProperty,sh=jl(function(t,e,n){rh.call(t,n)?t[n].push(e):An(t,n,[e])}),ih=Object.prototype,ah=ih.hasOwnProperty;function oh(t,e){return t!=null&&ah.call(t,e)}function R(t,e){return t!=null&&gs(t,e,oh)}var ch="[object String]";function K(t){return typeof t=="string"||!N(t)&&re(t)&&ye(t)==ch}function uh(t,e){return Lt(e,function(n){return t[n]})}function w(t){return t==null?[]:uh(t,Q(t))}var lh=Math.max;function G(t,e,n,r){t=de(t)?t:w(t),n=n?yt(n):0;var s=t.length;return n<0&&(n=lh(s+n,0)),K(t)?n<=s&&t.indexOf(e,n)>-1:!!s&&mn(t,e,n)>-1}function Rs(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=0;return mn(t,e,s)}var hh="[object Map]",fh="[object Set]",dh=Object.prototype,ph=dh.hasOwnProperty;function v(t){if(t==null)return!0;if(de(t)&&(N(t)||typeof t=="string"||typeof t.splice=="function"||it(t)||On(t)||kt(t)))return!t.length;var e=J(t);if(e==hh||e==fh)return!t.size;if(st(t))return!Dr(t).length;for(var n in t)if(ph.call(t,n))return!1;return!0}var Eh="[object RegExp]";function gh(t){return re(t)&&ye(t)==Eh}var Is=ve&&ve.isRegExp,_e=Is?xt(Is):gh;function Oe(t){return t===void 0}var Th="Expected a function";function mh(t){if(typeof t!="function")throw new TypeError(Th);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)}}function Ah(t,e,n,r){if(!Z(t))return t;e=Ut(e,t);for(var s=-1,i=e.length,a=i-1,o=t;o!=null&&++s<i;){var c=ut(e[s]),u=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(s!=a){var l=o[c];u=void 0,u===void 0&&(u=Z(l)?l:Pt(e[s+1])?[]:{})}Mt(o,c,u),o=o[c]}return t}function Rh(t,e,n){for(var r=-1,s=e.length,i={};++r<s;){var a=e[r],o=Ln(t,a);n(o,a)&&Ah(i,Ut(a,t),o)}return i}function oe(t,e){if(t==null)return{};var n=Lt(Gc(t),function(r){return[r]});return e=Ee(e),Rh(t,n,function(r,s){return e(r,s[0])})}function Ih(t,e,n,r,s){return s(t,function(i,a,o){n=r?(r=!1,i):e(n,i,a,o)}),n}function V(t,e,n){var r=N(t)?Nc:Ih,s=arguments.length<3;return r(t,Ee(e),n,s,$e)}function Bt(t,e){var n=N(t)?Pn:As;return n(t,mh(Ee(e)))}function Sh(t,e){var n;return $e(t,function(r,s,i){return n=e(r,s,i),!n}),!!n}function Ss(t,e,n){var r=N(t)?cs:Sh;return r(t,Ee(e))}var _h=1/0,Oh=Ve&&1/Un(new Ve([,-0]))[1]==_h?function(t){return new Ve(t)}:b,Nh=200;function Ch(t,e,n){var r=-1,s=Cr,i=t.length,a=!0,o=[],c=o;if(i>=Nh){var u=Oh(t);if(u)return Un(u);a=!1,s=wn,c=new Ye}else c=o;e:for(;++r<i;){var l=t[r],h=l;if(l=l!==0?l:0,a&&h===h){for(var f=c.length;f--;)if(c[f]===h)continue e;o.push(l)}else s(c,h,n)||(c!==o&&c.push(h),o.push(l))}return o}function Gn(t){return t&&t.length?Ch(t):[]}function Bn(t){console&&console.error&&console.error(`Error: ${t}`)}function _s(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function Os(t){const e=new Date().getTime(),n=t();return{time:new Date().getTime()-e,value:n}}function Ns(t){function e(){}e.prototype=t;const n=new e;function r(){return typeof n.bar}return r(),r(),t}function Lh(t){return yh(t)?t.LABEL:t.name}function yh(t){return K(t.LABEL)&&t.LABEL!==""}class ge{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),S(this.definition,n=>{n.accept(e)})}}class Y extends ge{constructor(e){super([]),this.idx=1,z(this,oe(e,n=>n!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class Ze extends ge{constructor(e){super(e.definition),this.orgText="",z(this,oe(e,n=>n!==void 0))}}class W extends ge{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,z(this,oe(e,n=>n!==void 0))}}class j extends ge{constructor(e){super(e.definition),this.idx=1,z(this,oe(e,n=>n!==void 0))}}class Te extends ge{constructor(e){super(e.definition),this.idx=1,z(this,oe(e,n=>n!==void 0))}}class me extends ge{constructor(e){super(e.definition),this.idx=1,z(this,oe(e,n=>n!==void 0))}}class U extends ge{constructor(e){super(e.definition),this.idx=1,z(this,oe(e,n=>n!==void 0))}}class ce extends ge{constructor(e){super(e.definition),this.idx=1,z(this,oe(e,n=>n!==void 0))}}class ue extends ge{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,z(this,oe(e,n=>n!==void 0))}}class M{constructor(e){this.idx=1,z(this,oe(e,n=>n!==void 0))}accept(e){e.visit(this)}}function vh(t){return A(t,Ht)}function Ht(t){function e(n){return A(n,Ht)}if(t instanceof Y){const n={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return K(t.label)&&(n.label=t.label),n}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 Te)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof me)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:Ht(new M({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ce)return{type:"RepetitionWithSeparator",idx:t.idx,separator:Ht(new M({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof U)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof ue)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof M){const n={type:"Terminal",name:t.terminalType.name,label:Lh(t.terminalType),idx:t.idx};K(t.label)&&(n.terminalLabel=t.label);const r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=_e(r)?r.source:r),n}else{if(t instanceof Ze)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}}class Qe{visit(e){const n=e;switch(n.constructor){case Y:return this.visitNonTerminal(n);case W:return this.visitAlternative(n);case j:return this.visitOption(n);case Te:return this.visitRepetitionMandatory(n);case me:return this.visitRepetitionMandatoryWithSeparator(n);case ce:return this.visitRepetitionWithSeparator(n);case U:return this.visitRepetition(n);case ue:return this.visitAlternation(n);case M:return this.visitTerminal(n);case Ze:return this.visitRule(n);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 Ph(t){return t instanceof W||t instanceof j||t instanceof U||t instanceof Te||t instanceof me||t instanceof ce||t instanceof M||t instanceof Ze}function Kt(t,e=[]){return t instanceof j||t instanceof U||t instanceof ce?!0:t instanceof ue?Ss(t.definition,r=>Kt(r,e)):t instanceof Y&&G(e,t)?!1:t instanceof ge?(t instanceof Y&&e.push(t),ie(t.definition,r=>Kt(r,e))):!1}function Mh(t){return t instanceof ue}function Ae(t){if(t instanceof Y)return"SUBRULE";if(t instanceof j)return"OPTION";if(t instanceof ue)return"OR";if(t instanceof Te)return"AT_LEAST_ONE";if(t instanceof me)return"AT_LEAST_ONE_SEP";if(t instanceof ce)return"MANY_SEP";if(t instanceof U)return"MANY";if(t instanceof M)return"CONSUME";throw Error("non exhaustive match")}class Wt{walk(e,n=[]){S(e.definition,(r,s)=>{const i=D(e.definition,s+1);if(r instanceof Y)this.walkProdRef(r,i,n);else if(r instanceof M)this.walkTerminal(r,i,n);else if(r instanceof W)this.walkFlat(r,i,n);else if(r instanceof j)this.walkOption(r,i,n);else if(r instanceof Te)this.walkAtLeastOne(r,i,n);else if(r instanceof me)this.walkAtLeastOneSep(r,i,n);else if(r instanceof ce)this.walkManySep(r,i,n);else if(r instanceof U)this.walkMany(r,i,n);else if(r instanceof ue)this.walkOr(r,i,n);else throw Error("non exhaustive match")})}walkTerminal(e,n,r){}walkProdRef(e,n,r){}walkFlat(e,n,r){const s=n.concat(r);this.walk(e,s)}walkOption(e,n,r){const s=n.concat(r);this.walk(e,s)}walkAtLeastOne(e,n,r){const s=[new j({definition:e.definition})].concat(n,r);this.walk(e,s)}walkAtLeastOneSep(e,n,r){const s=Cs(e,n,r);this.walk(e,s)}walkMany(e,n,r){const s=[new j({definition:e.definition})].concat(n,r);this.walk(e,s)}walkManySep(e,n,r){const s=Cs(e,n,r);this.walk(e,s)}walkOr(e,n,r){const s=n.concat(r);S(e.definition,i=>{const a=new W({definition:[i]});this.walk(a,s)})}}function Cs(t,e,n){return[new j({definition:[new M({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}function ft(t){if(t instanceof Y)return ft(t.referencedRule);if(t instanceof M)return bh(t);if(Ph(t))return kh(t);if(Mh(t))return xh(t);throw Error("non exhaustive match")}function kh(t){let e=[];const n=t.definition;let r=0,s=n.length>r,i,a=!0;for(;s&&a;)i=n[r],a=Kt(i),e=e.concat(ft(i)),r=r+1,s=n.length>r;return Gn(e)}function xh(t){const e=A(t.definition,n=>ft(n));return Gn(se(e))}function bh(t){return[t.terminalType]}const Ls="_~IN~_";class wh extends Wt{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,n,r){}walkProdRef(e,n,r){const s=Fh(e.referencedRule,e.idx)+this.topProd.name,i=n.concat(r),a=new W({definition:i}),o=ft(a);this.follows[s]=o}}function Uh(t){const e={};return S(t,n=>{const r=new wh(n).startWalking();z(e,r)}),e}function Fh(t,e){return t.name+e+Ls}function _(t){return t.charCodeAt(0)}function Hn(t,e){Array.isArray(t)?t.forEach(function(n){e.push(n)}):e.push(t)}function dt(t,e){if(t[e]===!0)throw"duplicate flag "+e;t[e],t[e]=!0}function Je(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function Dh(){throw Error("Internal Error - Should never get here!")}function ys(t){return t.type==="Character"}const jt=[];for(let t=_("0");t<=_("9");t++)jt.push(t);const zt=[_("_")].concat(jt);for(let t=_("a");t<=_("z");t++)zt.push(t);for(let t=_("A");t<=_("Z");t++)zt.push(t);const vs=[_(" "),_("\f"),_(` `),_("\r"),_(" "),_("\v"),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_(" "),_("\u2028"),_("\u2029"),_(" "),_(" "),_(" "),_("\uFEFF")],$h=/[0-9a-fA-F]/,Vt=/[0-9]/,Gh=/[1-9]/;class Bh{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("/");const n=this.disjunction();this.consumeChar("/");const r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":dt(r,"global");break;case"i":dt(r,"ignoreCase");break;case"m":dt(r,"multiLine");break;case"u":dt(r,"unicode");break;case"y":dt(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:n,loc:this.loc(0)}}disjunction(){const e=[],n=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(n)}}alternative(){const e=[],n=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(n)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const 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 n;switch(this.popChar()){case"=":n="Lookahead";break;case"!":n="NegativeLookahead";break}Je(n);const r=this.disjunction();return this.consumeChar(")"),{type:n,value:r,loc:this.loc(e)}}return Dh()}quantifier(e=!1){let n;const r=this.idx;switch(this.popChar()){case"*":n={atLeast:0,atMost:1/0};break;case"+":n={atLeast:1,atMost:1/0};break;case"?":n={atLeast:0,atMost:1};break;case"{":const s=this.integerIncludingZero();switch(this.popChar()){case"}":n={atLeast:s,atMost:s};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),n={atLeast:s,atMost:i}):n={atLeast:s,atMost:1/0},this.consumeChar("}");break}if(e===!0&&n===void 0)return;Je(n);break}if(!(e===!0&&n===void 0)&&Je(n))return this.peekChar(0)==="?"?(this.consumeChar("?"),n.greedy=!1):n.greedy=!0,n.type="Quantifier",n.loc=this.loc(r),n}atom(){let e;const n=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}if(e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Je(e))return e.loc=this.loc(n),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[_(` `),_("\r"),_("\u2028"),_("\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,n=!1;switch(this.popChar()){case"d":e=jt;break;case"D":e=jt,n=!0;break;case"s":e=vs;break;case"S":e=vs,n=!0;break;case"w":e=zt;break;case"W":e=zt,n=!0;break}if(Je(e))return{type:"Set",value:e,complement:n}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=_("\f");break;case"n":e=_(` `);break;case"r":e=_("\r");break;case"t":e=_(" ");break;case"v":e=_("\v");break}if(Je(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const 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:_("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){const e=this.popChar();return{type:"Character",value:_(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case` `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:const e=this.popChar();return{type:"Character",value:_(e)}}}characterClass(){const e=[];let n=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),n=!0);this.isClassAtom();){const r=this.classAtom();if(r.type,ys(r)&&this.isRangeDash()){this.consumeChar("-");const s=this.classAtom();if(s.type,ys(s)){if(s.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:s.value})}else Hn(r.value,e),e.push(_("-")),Hn(s.value,e)}else Hn(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:n,value:e}}classAtom(){switch(this.peekChar()){case"]":case` `:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:_("\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}const n=this.disjunction();this.consumeChar(")");const r={type:"Group",capturing:e,value:n};return e&&(r.idx=this.groupIdx),r}positiveInteger(){let e=this.popChar();if(Gh.test(e)===!1)throw Error("Expecting a positive integer");for(;Vt.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Vt.test(e)===!1)throw Error("Expecting an integer");for(;Vt.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case` `:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:_(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 Vt.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case` `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}}isQuantifier(){const e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case` `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let n="";for(let s=0;s<e;s++){const i=this.popChar();if($h.test(i)===!1)throw Error("Expecting a HexDecimal digits");n+=i}return{type:"Character",value:parseInt(n,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const 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}}}class Kn{visitChildren(e){for(const n in e){const r=e[n];e.hasOwnProperty(n)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(s=>{this.visit(s)},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){}}let Yt={};const Hh=new Bh;function Xt(t){const e=t.toString();if(Yt.hasOwnProperty(e))return Yt[e];{const n=Hh.pattern(e);return Yt[e]=n,n}}function Kh(){Yt={}}const Ps="Complement Sets are not supported for first char optimization",qt=`Unable to use "first char" lexer optimizations: `;function Wh(t,e=!1){try{const n=Xt(t);return Wn(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===Ps)e&&_s(`${qt} Unable to optimize: < ${t.toString()} > Complement Sets cannot be automatically optimized. This will disable the lexer's first char optimizations. See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let r="";e&&(r=` This will disable the lexer's first char optimizations. See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Bn(`${qt} Failed parsing: < ${t.toString()} > Using the @chevrotain/regexp-to-ast library Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+r)}}return[]}function Wn(t,e,n){switch(t.type){case"Disjunction":for(let s=0;s<t.value.length;s++)Wn(t.value[s],e,n);break;case"Alternative":const r=t.value;for(let s=0;s<r.length;s++){const i=r[s];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const a=i;switch(a.type){case"Character":Zt(a.value,e,n);break;case"Set":if(a.complement===!0)throw Error(Ps);S(a.value,c=>{if(typeof c=="number")Zt(c,e,n);else{const u=c;if(n===!0)for(let l=u.from;l<=u.to;l++)Zt(l,e,n);else{for(let l=u.from;l<=u.to&&l<Et;l++)Zt(l,e,n);if(u.to>=Et){const l=u.from>=Et?u.from:Et,h=u.to,f=Pe(l),p=Pe(h);for(let T=f;T<=p;T++)e[T]=T}}}});break;case"Group":Wn(a.value,e,n);break;default:throw Error("Non Exhaustive Match")}const o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&jn(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return w(e)}function Zt(t,e,n){const r=Pe(t);e[r]=r,n===!0&&jh(t,e)}function jh(t,e){const n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){const s=Pe(r.charCodeAt(0));e[s]=s}else{const s=n.toLowerCase();if(s!==n){const i=Pe(s.charCodeAt(0));e[i]=i}}}function Ms(t,e){return qe(t.value,n=>{if(typeof n=="number")return G(e,n);{const r=n;return qe(e,s=>r.from<=s&&s<=r.to)!==void 0}})}function jn(t){const e=t.quantifier;return e&&e.atLeast===0?!0:t.value?N(t.value)?ie(t.value,jn):jn(t.value):!1}class zh extends Kn{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){G(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?Ms(e,this.targetCharCodes)===void 0&&(this.found=!0):Ms(e,this.targetCharCodes)!==void 0&&(this.found=!0)}}function zn(t,e){if(e instanceof RegExp){const n=Xt(e),r=new zh(t);return r.visit(n),r.found}else return qe(e,n=>G(t,n.charCodeAt(0)))!==void 0}const Ge="PATTERN",pt="defaultMode",Qt="modes";let ks=typeof new RegExp("(?:)").sticky=="boolean";function Vh(t,e){e=$n(e,{useSticky:ks,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` `],tracer:(E,d)=>d()});const n=e.tracer;n("initCharCodeToOptimizedIndexMap",()=>{Tf()});let r;n("Reject Lexer.NA",()=>{r=Bt(t,E=>E[Ge]===B.NA)});let s=!1,i;n("Transform Patterns",()=>{s=!1,i=A(r,E=>{const d=E[Ge];if(_e(d)){const m=d.source;return m.length===1&&m!=="^"&&m!=="$"&&m!=="."&&!d.ignoreCase?m:m.length===2&&m[0]==="\\"&&!G(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],m[1])?m[1]:e.useSticky?bs(d):xs(d)}else{if(Re(d))return s=!0,{exec:d};if(typeof d=="object")return s=!0,d;if(typeof d=="string"){if(d.length===1)return d;{const m=d.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),L=new RegExp(m);return e.useSticky?bs(L):xs(L)}}else throw Error("non exhaustive match")}})});let a,o,c,u,l;n("misc mapping",()=>{a=A(r,E=>E.tokenTypeIdx),o=A(r,E=>{const d=E.GROUP;if(d!==B.SKIPPED){if(K(d))return d;if(Oe(d))return!1;throw Error("non exhaustive match")}}),c=A(r,E=>{const d=E.LONGER_ALT;if(d)return N(d)?A(d,L=>Rs(r,L)):[Rs(r,d)]}),u=A(r,E=>E.PUSH_MODE),l=A(r,E=>R(E,"POP_MODE"))});let h;n("Line Terminator Handling",()=>{const E=Fs(e.lineTerminatorCharacters);h=A(r,d=>!1),e.positionTracking!=="onlyOffset"&&(h=A(r,d=>R(d,"LINE_BREAKS")?!!d.LINE_BREAKS:Us(d,E)===!1&&zn(E,d.PATTERN)))});let f,p,T,I;n("Misc Mapping #2",()=>{f=A(r,ws),p=A(i,pf),T=V(r,(E,d)=>{const m=d.GROUP;return K(m)&&m!==B.SKIPPED&&(E[m]=[]),E},{}),I=A(i,(E,d)=>({pattern:i[d],longerAlt:c[d],canLineTerminator:h[d],isCustom:f[d],short:p[d],group:o[d],push:u[d],pop:l[d],tokenTypeIdx:a[d],tokenType:r[d]}))});let O=!0,g=[];return e.safeMode||n("First Char Optimization",()=>{g=V(r,(E,d,m)=>{if(typeof d.PATTERN=="string"){const L=d.PATTERN.charCodeAt(0),le=Pe(L);Vn(E,le,I[m])}else if(N(d.START_CHARS_HINT)){let L;S(d.START_CHARS_HINT,le=>{const ke=typeof le=="string"?le.charCodeAt(0):le,Ke=Pe(ke);L!==Ke&&(L=Ke,Vn(E,Ke,I[m]))})}else if(_e(d.PATTERN))if(d.PATTERN.unicode)O=!1,e.ensureOptimizations&&Bn(`${qt} Unable to analyze < ${d.PATTERN.toString()} > pattern. The regexp unicode flag is not currently supported by the regex