@dbml/parse 5.5.0 → 5.5.1-alpha.0

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.
@@ -1,15 +1,15 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Uc=typeof global=="object"&&global&&global.Object===Object&&global,kT=typeof self=="object"&&self&&self.Object===Object&&self,an=Uc||kT||Function("return this")(),Gt=an.Symbol,kc=Object.prototype,FT=kc.hasOwnProperty,CT=kc.toString,Cr=Gt?Gt.toStringTag:void 0;function BT(t){var r=FT.call(t,Cr),i=t[Cr];try{t[Cr]=void 0;var s=!0}catch{}var o=CT.call(t);return s&&(r?t[Cr]=i:delete t[Cr]),o}var GT=Object.prototype,VT=GT.toString;function $T(t){return VT.call(t)}var WT="[object Null]",XT="[object Undefined]",ql=Gt?Gt.toStringTag:void 0;function lr(t){return t==null?t===void 0?XT:WT:ql&&ql in Object(t)?BT(t):$T(t)}function Fn(t){return t!=null&&typeof t=="object"}var HT="[object Symbol]";function ts(t){return typeof t=="symbol"||Fn(t)&&lr(t)==HT}function Fc(t,r){for(var i=-1,s=t==null?0:t.length,o=Array(s);++i<s;)o[i]=r(t[i],i,t);return o}var Pt=Array.isArray,zl=Gt?Gt.prototype:void 0,Kl=zl?zl.toString:void 0;function Cc(t){if(typeof t=="string")return t;if(Pt(t))return Fc(t,Cc)+"";if(ts(t))return Kl?Kl.call(t):"";var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}var qT=/\s/;function zT(t){for(var r=t.length;r--&&qT.test(t.charAt(r)););return r}var KT=/^\s+/;function YT(t){return t&&t.slice(0,zT(t)+1).replace(KT,"")}function ar(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}var Yl=NaN,JT=/^[-+]0x[0-9a-f]+$/i,QT=/^0b[01]+$/i,ZT=/^0o[0-7]+$/i,jT=parseInt;function ev(t){if(typeof t=="number")return t;if(ts(t))return Yl;if(ar(t)){var r=typeof t.valueOf=="function"?t.valueOf():t;t=ar(r)?r+"":r}if(typeof t!="string")return t===0?t:+t;t=YT(t);var i=QT.test(t);return i||ZT.test(t)?jT(t.slice(2),i?2:8):JT.test(t)?Yl:+t}var Jl=1/0,tv=17976931348623157e292;function nv(t){if(!t)return t===0?t:0;if(t=ev(t),t===Jl||t===-Jl){var r=t<0?-1:1;return r*tv}return t===t?t:0}function rv(t){var r=nv(t),i=r%1;return r===r?i?r-i:r:0}function ns(t){return t}var iv="[object AsyncFunction]",sv="[object Function]",av="[object GeneratorFunction]",ov="[object Proxy]";function Bc(t){if(!ar(t))return!1;var r=lr(t);return r==sv||r==av||r==iv||r==ov}var Da=an["__core-js_shared__"],Ql=function(){var t=/[^.]+$/.exec(Da&&Da.keys&&Da.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function uv(t){return!!Ql&&Ql in t}var lv=Function.prototype,cv=lv.toString;function Gn(t){if(t!=null){try{return cv.call(t)}catch{}try{return t+""}catch{}}return""}var fv=/[\\^$.*+?()[\]{}|]/g,hv=/^\[object .+?Constructor\]$/,pv=Function.prototype,dv=Object.prototype,Ev=pv.toString,_v=dv.hasOwnProperty,gv=RegExp("^"+Ev.call(_v).replace(fv,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Nv(t){if(!ar(t)||uv(t))return!1;var r=Bc(t)?gv:hv;return r.test(Gn(t))}function Tv(t,r){return t?.[r]}function Vn(t,r){var i=Tv(t,r);return Nv(i)?i:void 0}var ka=Vn(an,"WeakMap");function vv(t,r,i){switch(i.length){case 0:return t.call(r);case 1:return t.call(r,i[0]);case 2:return t.call(r,i[0],i[1]);case 3:return t.call(r,i[0],i[1],i[2])}return t.apply(r,i)}var bv=800,mv=16,Iv=Date.now;function Av(t){var r=0,i=0;return function(){var s=Iv(),o=mv-(s-i);if(i=s,o>0){if(++r>=bv)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}function wv(t){return function(){return t}}var Zl=function(){try{var t=Vn(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Lv=Zl?function(t,r){return Zl(t,"toString",{configurable:!0,enumerable:!1,value:wv(r),writable:!0})}:ns,yv=Av(Lv);function xv(t,r,i,s){t.length;for(var o=i+1;o--;)if(r(t[o],o,t))return o;return-1}var Sv=9007199254740991,Ov=/^(?:0|[1-9]\d*)$/;function Gc(t,r){var i=typeof t;return r=r??Sv,!!r&&(i=="number"||i!="symbol"&&Ov.test(t))&&t>-1&&t%1==0&&t<r}function Vc(t,r){return t===r||t!==t&&r!==r}var jl=Math.max;function Pv(t,r,i){return r=jl(r===void 0?t.length-1:r,0),function(){for(var s=arguments,o=-1,l=jl(s.length-r,0),f=Array(l);++o<l;)f[o]=s[r+o];o=-1;for(var d=Array(r+1);++o<r;)d[o]=s[o];return d[r]=i(f),vv(t,this,d)}}function Rv(t,r){return yv(Pv(t,r,ns),t+"")}var Dv=9007199254740991;function za(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Dv}function rs(t){return t!=null&&za(t.length)&&!Bc(t)}var Mv=Object.prototype;function $c(t){var r=t&&t.constructor,i=typeof r=="function"&&r.prototype||Mv;return t===i}function Wc(t,r){for(var i=-1,s=Array(t);++i<t;)s[i]=r(i);return s}var Uv="[object Arguments]";function ec(t){return Fn(t)&&lr(t)==Uv}var Xc=Object.prototype,kv=Xc.hasOwnProperty,Fv=Xc.propertyIsEnumerable,Ka=ec(function(){return arguments}())?ec:function(t){return Fn(t)&&kv.call(t,"callee")&&!Fv.call(t,"callee")};function Cv(){return!1}var Hc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tc=Hc&&typeof module=="object"&&module&&!module.nodeType&&module,Bv=tc&&tc.exports===Hc,nc=Bv?an.Buffer:void 0,Gv=nc?nc.isBuffer:void 0,Fa=Gv||Cv,Vv="[object Arguments]",$v="[object Array]",Wv="[object Boolean]",Xv="[object Date]",Hv="[object Error]",qv="[object Function]",zv="[object Map]",Kv="[object Number]",Yv="[object Object]",Jv="[object RegExp]",Qv="[object Set]",Zv="[object String]",jv="[object WeakMap]",eb="[object ArrayBuffer]",tb="[object DataView]",nb="[object Float32Array]",rb="[object Float64Array]",ib="[object Int8Array]",sb="[object Int16Array]",ab="[object Int32Array]",ob="[object Uint8Array]",ub="[object Uint8ClampedArray]",lb="[object Uint16Array]",cb="[object Uint32Array]",he={};he[nb]=he[rb]=he[ib]=he[sb]=he[ab]=he[ob]=he[ub]=he[lb]=he[cb]=!0;he[Vv]=he[$v]=he[eb]=he[Wv]=he[tb]=he[Xv]=he[Hv]=he[qv]=he[zv]=he[Kv]=he[Yv]=he[Jv]=he[Qv]=he[Zv]=he[jv]=!1;function fb(t){return Fn(t)&&za(t.length)&&!!he[lr(t)]}function hb(t){return function(r){return t(r)}}var qc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vr=qc&&typeof module=="object"&&module&&!module.nodeType&&module,pb=Vr&&Vr.exports===qc,Ma=pb&&Uc.process,rc=function(){try{var t=Vr&&Vr.require&&Vr.require("util").types;return t||Ma&&Ma.binding&&Ma.binding("util")}catch{}}(),ic=rc&&rc.isTypedArray,zc=ic?hb(ic):fb,db=Object.prototype,Eb=db.hasOwnProperty;function Kc(t,r){var i=Pt(t),s=!i&&Ka(t),o=!i&&!s&&Fa(t),l=!i&&!s&&!o&&zc(t),f=i||s||o||l,d=f?Wc(t.length,String):[],m=d.length;for(var I in t)(r||Eb.call(t,I))&&!(f&&(I=="length"||o&&(I=="offset"||I=="parent")||l&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||Gc(I,m)))&&d.push(I);return d}function _b(t,r){return function(i){return t(r(i))}}var gb=_b(Object.keys,Object),Nb=Object.prototype,Tb=Nb.hasOwnProperty;function vb(t){if(!$c(t))return gb(t);var r=[];for(var i in Object(t))Tb.call(t,i)&&i!="constructor"&&r.push(i);return r}function Ya(t){return rs(t)?Kc(t):vb(t)}function bb(t){var r=[];if(t!=null)for(var i in Object(t))r.push(i);return r}var mb=Object.prototype,Ib=mb.hasOwnProperty;function Ab(t){if(!ar(t))return bb(t);var r=$c(t),i=[];for(var s in t)s=="constructor"&&(r||!Ib.call(t,s))||i.push(s);return i}function wb(t){return rs(t)?Kc(t,!0):Ab(t)}var Lb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yb=/^\w*$/;function Ja(t,r){if(Pt(t))return!1;var i=typeof t;return i=="number"||i=="symbol"||i=="boolean"||t==null||ts(t)?!0:yb.test(t)||!Lb.test(t)||r!=null&&t in Object(r)}var Wr=Vn(Object,"create");function xb(){this.__data__=Wr?Wr(null):{},this.size=0}function Sb(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}var Ob="__lodash_hash_undefined__",Pb=Object.prototype,Rb=Pb.hasOwnProperty;function Db(t){var r=this.__data__;if(Wr){var i=r[t];return i===Ob?void 0:i}return Rb.call(r,t)?r[t]:void 0}var Mb=Object.prototype,Ub=Mb.hasOwnProperty;function kb(t){var r=this.__data__;return Wr?r[t]!==void 0:Ub.call(r,t)}var Fb="__lodash_hash_undefined__";function Cb(t,r){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Wr&&r===void 0?Fb:r,this}function Cn(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}Cn.prototype.clear=xb;Cn.prototype.delete=Sb;Cn.prototype.get=Db;Cn.prototype.has=kb;Cn.prototype.set=Cb;function Bb(){this.__data__=[],this.size=0}function is(t,r){for(var i=t.length;i--;)if(Vc(t[i][0],r))return i;return-1}var Gb=Array.prototype,Vb=Gb.splice;function $b(t){var r=this.__data__,i=is(r,t);if(i<0)return!1;var s=r.length-1;return i==s?r.pop():Vb.call(r,i,1),--this.size,!0}function Wb(t){var r=this.__data__,i=is(r,t);return i<0?void 0:r[i][1]}function Xb(t){return is(this.__data__,t)>-1}function Hb(t,r){var i=this.__data__,s=is(i,t);return s<0?(++this.size,i.push([t,r])):i[s][1]=r,this}function on(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}on.prototype.clear=Bb;on.prototype.delete=$b;on.prototype.get=Wb;on.prototype.has=Xb;on.prototype.set=Hb;var Xr=Vn(an,"Map");function qb(){this.size=0,this.__data__={hash:new Cn,map:new(Xr||on),string:new Cn}}function zb(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}function ss(t,r){var i=t.__data__;return zb(r)?i[typeof r=="string"?"string":"hash"]:i.map}function Kb(t){var r=ss(this,t).delete(t);return this.size-=r?1:0,r}function Yb(t){return ss(this,t).get(t)}function Jb(t){return ss(this,t).has(t)}function Qb(t,r){var i=ss(this,t),s=i.size;return i.set(t,r),this.size+=i.size==s?0:1,this}function un(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}un.prototype.clear=qb;un.prototype.delete=Kb;un.prototype.get=Yb;un.prototype.has=Jb;un.prototype.set=Qb;var Zb="Expected a function";function Qa(t,r){if(typeof t!="function"||r!=null&&typeof r!="function")throw new TypeError(Zb);var i=function(){var s=arguments,o=r?r.apply(this,s):s[0],l=i.cache;if(l.has(o))return l.get(o);var f=t.apply(this,s);return i.cache=l.set(o,f)||l,f};return i.cache=new(Qa.Cache||un),i}Qa.Cache=un;var jb=500;function em(t){var r=Qa(t,function(s){return i.size===jb&&i.clear(),s}),i=r.cache;return r}var tm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nm=/\\(\\)?/g,rm=em(function(t){var r=[];return t.charCodeAt(0)===46&&r.push(""),t.replace(tm,function(i,s,o,l){r.push(o?l.replace(nm,"$1"):s||i)}),r});function im(t){return t==null?"":Cc(t)}function Yc(t,r){return Pt(t)?t:Ja(t,r)?[t]:rm(im(t))}function as(t){if(typeof t=="string"||ts(t))return t;var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Jc(t,r){r=Yc(r,t);for(var i=0,s=r.length;t!=null&&i<s;)t=t[as(r[i++])];return i&&i==s?t:void 0}function Qc(t,r,i){var s=t==null?void 0:Jc(t,r);return s===void 0?i:s}function Zc(t,r){for(var i=-1,s=r.length,o=t.length;++i<s;)t[o+i]=r[i];return t}var sc=Gt?Gt.isConcatSpreadable:void 0;function sm(t){return Pt(t)||Ka(t)||!!(sc&&t&&t[sc])}function am(t,r,i,s,o){var l=-1,f=t.length;for(i||(i=sm),o||(o=[]);++l<f;){var d=t[l];i(d)?Zc(o,d):o[o.length]=d}return o}function ac(t){var r=t==null?0:t.length;return r?am(t):[]}function om(){this.__data__=new on,this.size=0}function um(t){var r=this.__data__,i=r.delete(t);return this.size=r.size,i}function lm(t){return this.__data__.get(t)}function cm(t){return this.__data__.has(t)}var fm=200;function hm(t,r){var i=this.__data__;if(i instanceof on){var s=i.__data__;if(!Xr||s.length<fm-1)return s.push([t,r]),this.size=++i.size,this;i=this.__data__=new un(s)}return i.set(t,r),this.size=i.size,this}function rn(t){var r=this.__data__=new on(t);this.size=r.size}rn.prototype.clear=om;rn.prototype.delete=um;rn.prototype.get=lm;rn.prototype.has=cm;rn.prototype.set=hm;function jc(t,r){for(var i=-1,s=t==null?0:t.length,o=0,l=[];++i<s;){var f=t[i];r(f,i,t)&&(l[o++]=f)}return l}function pm(){return[]}var dm=Object.prototype,Em=dm.propertyIsEnumerable,oc=Object.getOwnPropertySymbols,_m=oc?function(t){return t==null?[]:(t=Object(t),jc(oc(t),function(r){return Em.call(t,r)}))}:pm;function gm(t,r,i){var s=r(t);return Pt(t)?s:Zc(s,i(t))}function uc(t){return gm(t,Ya,_m)}var Ca=Vn(an,"DataView"),Ba=Vn(an,"Promise"),Ga=Vn(an,"Set"),lc="[object Map]",Nm="[object Object]",cc="[object Promise]",fc="[object Set]",hc="[object WeakMap]",pc="[object DataView]",Tm=Gn(Ca),vm=Gn(Xr),bm=Gn(Ba),mm=Gn(Ga),Im=Gn(ka),bn=lr;(Ca&&bn(new Ca(new ArrayBuffer(1)))!=pc||Xr&&bn(new Xr)!=lc||Ba&&bn(Ba.resolve())!=cc||Ga&&bn(new Ga)!=fc||ka&&bn(new ka)!=hc)&&(bn=function(t){var r=lr(t),i=r==Nm?t.constructor:void 0,s=i?Gn(i):"";if(s)switch(s){case Tm:return pc;case vm:return lc;case bm:return cc;case mm:return fc;case Im:return hc}return r});var dc=an.Uint8Array,Am="__lodash_hash_undefined__";function wm(t){return this.__data__.set(t,Am),this}function Lm(t){return this.__data__.has(t)}function Yi(t){var r=-1,i=t==null?0:t.length;for(this.__data__=new un;++r<i;)this.add(t[r])}Yi.prototype.add=Yi.prototype.push=wm;Yi.prototype.has=Lm;function ym(t,r){for(var i=-1,s=t==null?0:t.length;++i<s;)if(r(t[i],i,t))return!0;return!1}function xm(t,r){return t.has(r)}var Sm=1,Om=2;function ef(t,r,i,s,o,l){var f=i&Sm,d=t.length,m=r.length;if(d!=m&&!(f&&m>d))return!1;var I=l.get(t),T=l.get(r);if(I&&T)return I==r&&T==t;var y=-1,$=!0,J=i&Om?new Yi:void 0;for(l.set(t,r),l.set(r,t);++y<d;){var ne=t[y],re=r[y];if(s)var j=f?s(re,ne,y,r,t,l):s(ne,re,y,t,r,l);if(j!==void 0){if(j)continue;$=!1;break}if(J){if(!ym(r,function(de,et){if(!xm(J,et)&&(ne===de||o(ne,de,i,s,l)))return J.push(et)})){$=!1;break}}else if(!(ne===re||o(ne,re,i,s,l))){$=!1;break}}return l.delete(t),l.delete(r),$}function Pm(t){var r=-1,i=Array(t.size);return t.forEach(function(s,o){i[++r]=[o,s]}),i}function Rm(t){var r=-1,i=Array(t.size);return t.forEach(function(s){i[++r]=s}),i}var Dm=1,Mm=2,Um="[object Boolean]",km="[object Date]",Fm="[object Error]",Cm="[object Map]",Bm="[object Number]",Gm="[object RegExp]",Vm="[object Set]",$m="[object String]",Wm="[object Symbol]",Xm="[object ArrayBuffer]",Hm="[object DataView]",Ec=Gt?Gt.prototype:void 0,Ua=Ec?Ec.valueOf:void 0;function qm(t,r,i,s,o,l,f){switch(i){case Hm:if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case Xm:return!(t.byteLength!=r.byteLength||!l(new dc(t),new dc(r)));case Um:case km:case Bm:return Vc(+t,+r);case Fm:return t.name==r.name&&t.message==r.message;case Gm:case $m:return t==r+"";case Cm:var d=Pm;case Vm:var m=s&Dm;if(d||(d=Rm),t.size!=r.size&&!m)return!1;var I=f.get(t);if(I)return I==r;s|=Mm,f.set(t,r);var T=ef(d(t),d(r),s,o,l,f);return f.delete(t),T;case Wm:if(Ua)return Ua.call(t)==Ua.call(r)}return!1}var zm=1,Km=Object.prototype,Ym=Km.hasOwnProperty;function Jm(t,r,i,s,o,l){var f=i&zm,d=uc(t),m=d.length,I=uc(r),T=I.length;if(m!=T&&!f)return!1;for(var y=m;y--;){var $=d[y];if(!(f?$ in r:Ym.call(r,$)))return!1}var J=l.get(t),ne=l.get(r);if(J&&ne)return J==r&&ne==t;var re=!0;l.set(t,r),l.set(r,t);for(var j=f;++y<m;){$=d[y];var de=t[$],et=r[$];if(s)var ft=f?s(et,de,$,r,t,l):s(de,et,$,t,r,l);if(!(ft===void 0?de===et||o(de,et,i,s,l):ft)){re=!1;break}j||(j=$=="constructor")}if(re&&!j){var Rt=t.constructor,ze=r.constructor;Rt!=ze&&"constructor"in t&&"constructor"in r&&!(typeof Rt=="function"&&Rt instanceof Rt&&typeof ze=="function"&&ze instanceof ze)&&(re=!1)}return l.delete(t),l.delete(r),re}var Qm=1,_c="[object Arguments]",gc="[object Array]",qi="[object Object]",Zm=Object.prototype,Nc=Zm.hasOwnProperty;function jm(t,r,i,s,o,l){var f=Pt(t),d=Pt(r),m=f?gc:bn(t),I=d?gc:bn(r);m=m==_c?qi:m,I=I==_c?qi:I;var T=m==qi,y=I==qi,$=m==I;if($&&Fa(t)){if(!Fa(r))return!1;f=!0,T=!1}if($&&!T)return l||(l=new rn),f||zc(t)?ef(t,r,i,s,o,l):qm(t,r,m,i,s,o,l);if(!(i&Qm)){var J=T&&Nc.call(t,"__wrapped__"),ne=y&&Nc.call(r,"__wrapped__");if(J||ne){var re=J?t.value():t,j=ne?r.value():r;return l||(l=new rn),o(re,j,i,s,l)}}return $?(l||(l=new rn),Jm(t,r,i,s,o,l)):!1}function Za(t,r,i,s,o){return t===r?!0:t==null||r==null||!Fn(t)&&!Fn(r)?t!==t&&r!==r:jm(t,r,i,s,Za,o)}var eI=1,tI=2;function nI(t,r,i,s){var o=i.length,l=o;if(t==null)return!l;for(t=Object(t);o--;){var f=i[o];if(f[2]?f[1]!==t[f[0]]:!(f[0]in t))return!1}for(;++o<l;){f=i[o];var d=f[0],m=t[d],I=f[1];if(f[2]){if(m===void 0&&!(d in t))return!1}else{var T=new rn,y;if(!(y===void 0?Za(I,m,eI|tI,s,T):y))return!1}}return!0}function tf(t){return t===t&&!ar(t)}function rI(t){for(var r=Ya(t),i=r.length;i--;){var s=r[i],o=t[s];r[i]=[s,o,tf(o)]}return r}function nf(t,r){return function(i){return i==null?!1:i[t]===r&&(r!==void 0||t in Object(i))}}function iI(t){var r=rI(t);return r.length==1&&r[0][2]?nf(r[0][0],r[0][1]):function(i){return i===t||nI(i,t,r)}}function sI(t,r){return t!=null&&r in Object(t)}function aI(t,r,i){r=Yc(r,t);for(var s=-1,o=r.length,l=!1;++s<o;){var f=as(r[s]);if(!(l=t!=null&&i(t,f)))break;t=t[f]}return l||++s!=o?l:(o=t==null?0:t.length,!!o&&za(o)&&Gc(f,o)&&(Pt(t)||Ka(t)))}function oI(t,r){return t!=null&&aI(t,r,sI)}var uI=1,lI=2;function cI(t,r){return Ja(t)&&tf(r)?nf(as(t),r):function(i){var s=Qc(i,t);return s===void 0&&s===r?oI(i,t):Za(r,s,uI|lI)}}function rf(t){return function(r){return r?.[t]}}function fI(t){return function(r){return Jc(r,t)}}function hI(t){return Ja(t)?rf(as(t)):fI(t)}function sf(t){return typeof t=="function"?t:t==null?ns:typeof t=="object"?Pt(t)?cI(t[0],t[1]):iI(t):hI(t)}function pI(t,r,i,s){for(var o=-1,l=t==null?0:t.length;++o<l;){var f=t[o];r(s,f,i(f),t)}return s}function dI(t){return function(r,i,s){for(var o=-1,l=Object(r),f=s(r),d=f.length;d--;){var m=f[++o];if(i(l[m],m,l)===!1)break}return r}}var af=dI();function EI(t,r){return t&&af(t,r,Ya)}function _I(t,r){return function(i,s){if(i==null)return i;if(!rs(i))return t(i,s);for(var o=i.length,l=-1,f=Object(i);++l<o&&s(f[l],l,f)!==!1;);return i}}var gI=_I(EI);function NI(t,r,i,s){return gI(t,function(o,l,f){r(s,o,i(o),f)}),s}function TI(t,r){return function(i,s){var o=Pt(i)?pI:NI,l=r?r():{};return o(i,t,sf(s),l)}}function vI(t){return Fn(t)&&rs(t)}function me(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}function bI(t){return typeof t=="function"?t:ns}var mI=Math.max,II=Math.min;function AI(t,r,i){var s=t==null?0:t.length;if(!s)return-1;var o=s-1;return i!==void 0&&(o=rv(i),o=i<0?mI(s+o,0):II(o,s-1)),xv(t,sf(r),o)}function wI(t){return t&&t.length?t[0]:void 0}function Hr(t,r){return t==null?t:af(t,bI(r),wb)}var ct=TI(function(t,r,i){t[i?0:1].push(r)},function(){return[[],[]]}),LI=Math.max;function yI(t){if(!(t&&t.length))return[];var r=0;return t=jc(t,function(i){if(vI(i))return r=LI(i.length,r),!0}),Wc(r,function(i){return Fc(t,rf(i))})}var Va=Rv(yI),A=(t=>(t.SPACE="<space>",t.TAB="<tab>",t.NEWLINE="<newline>",t.COMMA="<comma>",t.LPAREN="<lparen>",t.RPAREN="<rparen>",t.LBRACE="<lbrace>",t.RBRACE="<rbrace>",t.LBRACKET="<lbracket>",t.RBRACKET="<rbracket>",t.LANGLE="<langle>",t.RANGLE="<rangle>",t.OP="<op>",t.EOF="<eof>",t.NUMERIC_LITERAL="<number>",t.STRING_LITERAL="<string>",t.COLOR_LITERAL="<color>",t.FUNCTION_EXPRESSION="<function-expression>",t.QUOTED_STRING="<variable>",t.IDENTIFIER="<identifier>",t.SEMICOLON="<semicolon>",t.COLON="<colon>",t.SINGLE_LINE_COMMENT="<single-line-comment>",t.MULTILINE_COMMENT="<multiline-comment>",t))(A||{});function xI(t){switch(t.kind){case"<newline>":case"<space>":case"<tab>":case"<single-line-comment>":case"<multiline-comment>":return!0;default:return!1}}function SI(t){if(!t)return!1;switch(t){case"+":case"-":case"*":case"/":case"%":case"<":case">":case"=":case"!":case".":case"&":case"|":case"~":return!0;default:return!1}}function Tc(t){return t!==void 0&&t.kind==="<op>"}class Ze{constructor(r,i,s,o,l){this.kind=r,this.startPos=i,this.endPos=s,this.value=o,this.leadingTrivia=[],this.trailingTrivia=[],this.leadingInvalid=[],this.trailingInvalid=[],this.isInvalid=l,this.start=i.offset,this.end=s.offset}static create(r,i,s,o,l){return new Ze(r,i,s,o,l)}}function of(t){return t.trailingTrivia.find(({kind:r})=>r===A.NEWLINE)!==void 0}function vc(t,r){return r.leadingTrivia.find(({kind:s})=>s===A.NEWLINE)!==void 0||of(t)}function $a(t){return t.trailingTrivia.find(({kind:r})=>[A.SPACE,A.TAB].includes(r))!==void 0}function uf(t){return t.trailingTrivia.length===0?t.end:uf(me(t.trailingTrivia))}function lf(t){return t.leadingTrivia.length===0?t.start:lf(t.leadingTrivia[0])}function OI(t){return[A.SINGLE_LINE_COMMENT,A.MULTILINE_COMMENT].includes(t.kind)}class PI{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class Te{constructor(r,i,s){this.id=r,this.kind=i;const o=s.find(f=>f!==void 0&&!Number.isNaN(f.start));o?(this.startPos=o.startPos,this.fullStart=o instanceof Ze?lf(o):o.fullStart):(this.startPos={offset:NaN,column:NaN,line:NaN},this.fullStart=NaN);const l=[...s].reverse().find(f=>f!==void 0&&!Number.isNaN(f.end));l?(this.endPos=l.endPos,this.fullEnd=l instanceof Ze?uf(l):l.fullEnd):(this.endPos={offset:NaN,column:NaN,line:NaN},this.fullEnd=NaN),this.start=this.startPos.offset,this.end=this.endPos.offset}}var kn=(t=>(t.PROGRAM="<program>",t.ELEMENT_DECLARATION="<element-declaration>",t.ATTRIBUTE="<attribute>",t.IDENTIFIER_STREAM="<identifer-stream>",t.LITERAL="<literal>",t.VARIABLE="<variable>",t.PREFIX_EXPRESSION="<prefix-expression>",t.INFIX_EXPRESSION="<infix-expression>",t.POSTFIX_EXPRESSION="<postfix-expression>",t.FUNCTION_EXPRESSION="<function-expression>",t.FUNCTION_APPLICATION="<function-application>",t.BLOCK_EXPRESSION="<block-expression>",t.LIST_EXPRESSION="<list-expression>",t.TUPLE_EXPRESSION="<tuple-expression>",t.CALL_EXPRESSION="<call-expression>",t.PRIMARY_EXPRESSION="<primary-expression>",t.GROUP_EXPRESSION="<group-expression>",t.DUMMY="<dummy>",t.ARRAY="<array>",t))(kn||{});class qe extends Te{constructor({body:r=[],eof:i},s){super(s,"<program>",[...r,i]),this.body=r,this.eof=i}}class se extends Te{constructor({type:r,name:i,as:s,alias:o,attributeList:l,bodyColon:f,body:d},m){if(super(m,"<element-declaration>",[r,i,s,o,l,f,d]),d&&f&&!(d instanceof W||d instanceof se))throw new Error("If an element has a simple body, it must be a function application node");this.type=r,this.name=i,this.as=s,this.alias=o,this.attributeList=l,this.bodyColon=f,this.body=d}}class yt extends Te{constructor({identifiers:r=[]},i){super(i,"<identifer-stream>",r||[]),this.identifiers=r}}class xt extends Te{constructor({name:r,colon:i,value:s},o){super(o,"<attribute>",[r,i,s]),this.name=r,this.value=s,this.colon=i}}class je extends Te{constructor({op:r,expression:i},s){super(s,"<prefix-expression>",[r,i]),this.op=r,this.expression=i}}class Vt extends Te{constructor({op:r,leftExpression:i,rightExpression:s},o){super(o,"<infix-expression>",[i,r,s]),this.op=r,this.leftExpression=i,this.rightExpression=s}}class os extends Te{constructor({op:r,expression:i},s){super(s,"<postfix-expression>",[i,r]),this.op=r,this.expression=i}}class vt extends Te{constructor({value:r},i){super(i,"<function-expression>",[r]),this.value=r}}class W extends Te{constructor({callee:r,args:i=[]},s){super(s,"<function-application>",[r,...i]),this.callee=r,this.args=i}}class ke extends Te{constructor({blockOpenBrace:r,body:i=[],blockCloseBrace:s},o){super(o,"<block-expression>",[r,...i,s]),this.blockOpenBrace=r,this.body=i,this.blockCloseBrace=s}}class _e extends Te{constructor({listOpenBracket:r,elementList:i=[],commaList:s=[],listCloseBracket:o},l){super(l,"<list-expression>",[r,...cf(i,s),o]),this.listOpenBracket=r,this.elementList=i,this.commaList=s,this.listCloseBracket=o}}class Wt extends Te{constructor({tupleOpenParen:r,elementList:i=[],commaList:s=[],tupleCloseParen:o},l){super(l,"<tuple-expression>",[r,...cf(i,s),o]),this.tupleOpenParen=r,this.elementList=i,this.commaList=s,this.tupleCloseParen=o}}class ja extends Wt{constructor({groupOpenParen:r,expression:i,groupCloseParen:s},o){super({tupleOpenParen:r,elementList:i&&[i],commaList:[],tupleCloseParen:s},o),this.kind="<group-expression>"}}class He extends Te{constructor({callee:r,argumentList:i},s){super(s,"<call-expression>",[r,i]),this.callee=r,this.argumentList=i}}class cr extends Te{constructor({literal:r},i){super(i,"<literal>",[r]),this.literal=r}}class ln extends Te{constructor({variable:r},i){super(i,"<variable>",[r]),this.variable=r}}class ut extends Te{constructor({expression:r},i){super(i,"<primary-expression>",[r]),this.expression=r}}class Br extends Te{constructor({pre:r},i){const s=Ze.create(A.SPACE,r.endPos,r.endPos," ",!1);super(i,"<dummy>",[s])}}class Bt extends Te{constructor({expression:r,indexer:i},s){super(s,"<array>",[r,i]),this.array=r,this.indexer=i}}function cf(t,r){if(!t||t.length===0)return r||[];if(!r||r.length===0)return t||[];const[i]=t,[s]=r;return(i.start<s.start?ac(Va(t,r)):ac(Va(r,t))).filter(o=>o!==null)}function RI(t,r=!1){return JSON.stringify(t,function(i,s){return!(this instanceof qe)&&i==="symbol"?s?.id:i==="symbol"?{symbolTable:s?.symbolTable,id:s?.id,references:s?.references.map(o=>o.id),declaration:s?.declaration?.id}:i==="referee"||i==="parent"||i==="declaration"?s?.id:i==="symbolTable"?Object.fromEntries(s.table):s},r?2:0)}class DI{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class eo{constructor({symbolTable:r},i){this.references=[],this.id=i,this.symbolTable=r}}class ff{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class hf{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class qr{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class to{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class pf{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class df{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class Ef{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class _f{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class gf{constructor({declaration:r,tablePartialSymbol:i},s){this.references=[],this.id=s,this.declaration=r,this.tablePartialSymbol=i}}var _=(t=>(t[t.UNKNOWN_SYMBOL=1e3]="UNKNOWN_SYMBOL",t[t.UNEXPECTED_SYMBOL=1001]="UNEXPECTED_SYMBOL",t[t.UNEXPECTED_EOF=1002]="UNEXPECTED_EOF",t[t.UNEXPECTED_NEWLINE=1003]="UNEXPECTED_NEWLINE",t[t.UNKNOWN_TOKEN=1004]="UNKNOWN_TOKEN",t[t.UNEXPECTED_TOKEN=1005]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_ELEMENT_DECLARATION=1006]="UNEXPECTED_ELEMENT_DECLARATION",t[t.MISSING_SPACES=1007]="MISSING_SPACES",t[t.UNKNOWN_PREFIX_OP=1008]="UNKNOWN_PREFIX_OP",t[t.INVALID_OPERAND=1009]="INVALID_OPERAND",t[t.EMPTY_ATTRIBUTE_NAME=1010]="EMPTY_ATTRIBUTE_NAME",t[t.INVALID_ESCAPE_SEQUENCE=1011]="INVALID_ESCAPE_SEQUENCE",t[t.INVALID_NAME=3e3]="INVALID_NAME",t[t.UNEXPECTED_NAME=3001]="UNEXPECTED_NAME",t[t.NAME_NOT_FOUND=3002]="NAME_NOT_FOUND",t[t.DUPLICATE_NAME=3003]="DUPLICATE_NAME",t[t.INVALID_ALIAS=3004]="INVALID_ALIAS",t[t.UNEXPECTED_ALIAS=3005]="UNEXPECTED_ALIAS",t[t.UNEXPECTED_SETTINGS=3006]="UNEXPECTED_SETTINGS",t[t.INVALID_SETTINGS=3007]="INVALID_SETTINGS",t[t.UNEXPECTED_SIMPLE_BODY=3008]="UNEXPECTED_SIMPLE_BODY",t[t.UNEXPECTED_COMPLEX_BODY=3009]="UNEXPECTED_COMPLEX_BODY",t[t.INVALID_TABLE_CONTEXT=3010]="INVALID_TABLE_CONTEXT",t[t.UNKNOWN_TABLE_SETTING=3011]="UNKNOWN_TABLE_SETTING",t[t.DUPLICATE_TABLE_SETTING=3012]="DUPLICATE_TABLE_SETTING",t[t.INVALID_TABLEGROUP_CONTEXT=3013]="INVALID_TABLEGROUP_CONTEXT",t[t.INVALID_TABLEGROUP_ELEMENT_NAME=3014]="INVALID_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME=3015]="DUPLICATE_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_FIELD_NAME=3016]="DUPLICATE_TABLEGROUP_FIELD_NAME",t[t.INVALID_TABLEGROUP_FIELD=3017]="INVALID_TABLEGROUP_FIELD",t[t.EMPTY_TABLE=3018]="EMPTY_TABLE",t[t.INVALID_COLUMN=3019]="INVALID_COLUMN",t[t.INVALID_COLUMN_NAME=3020]="INVALID_COLUMN_NAME",t[t.UNKNOWN_COLUMN_SETTING=3021]="UNKNOWN_COLUMN_SETTING",t[t.INVALID_COLUMN_TYPE=3022]="INVALID_COLUMN_TYPE",t[t.DUPLICATE_COLUMN_NAME=3023]="DUPLICATE_COLUMN_NAME",t[t.DUPLICATE_COLUMN_SETTING=3024]="DUPLICATE_COLUMN_SETTING",t[t.INVALID_COLUMN_SETTING_VALUE=3025]="INVALID_COLUMN_SETTING_VALUE",t[t.INVALID_ENUM_CONTEXT=3026]="INVALID_ENUM_CONTEXT",t[t.INVALID_ENUM_ELEMENT_NAME=3027]="INVALID_ENUM_ELEMENT_NAME",t[t.INVALID_ENUM_ELEMENT=3028]="INVALID_ENUM_ELEMENT",t[t.DUPLICATE_ENUM_ELEMENT_NAME=3029]="DUPLICATE_ENUM_ELEMENT_NAME",t[t.UNKNOWN_ENUM_ELEMENT_SETTING=3030]="UNKNOWN_ENUM_ELEMENT_SETTING",t[t.DUPLICATE_ENUM_ELEMENT_SETTING=3031]="DUPLICATE_ENUM_ELEMENT_SETTING",t[t.INVALID_ENUM_ELEMENT_SETTING=3032]="INVALID_ENUM_ELEMENT_SETTING",t[t.EMPTY_ENUM=3033]="EMPTY_ENUM",t[t.INVALID_REF_CONTEXT=3034]="INVALID_REF_CONTEXT",t[t.UNKNOWN_REF_SETTING=3035]="UNKNOWN_REF_SETTING",t[t.DUPLICATE_REF_SETTING=3036]="DUPLICATE_REF_SETTING",t[t.INVALID_REF_SETTING_VALUE=3037]="INVALID_REF_SETTING_VALUE",t[t.INVALID_REF_RELATIONSHIP=3038]="INVALID_REF_RELATIONSHIP",t[t.INVALID_REF_FIELD=3039]="INVALID_REF_FIELD",t[t.EMPTY_REF=3040]="EMPTY_REF",t[t.REF_REDEFINED=3041]="REF_REDEFINED",t[t.INVALID_NOTE_CONTEXT=3042]="INVALID_NOTE_CONTEXT",t[t.INVALID_NOTE=3043]="INVALID_NOTE",t[t.NOTE_REDEFINED=3044]="NOTE_REDEFINED",t[t.NOTE_CONTENT_REDEFINED=3045]="NOTE_CONTENT_REDEFINED",t[t.EMPTY_NOTE=3046]="EMPTY_NOTE",t[t.INVALID_INDEXES_CONTEXT=3047]="INVALID_INDEXES_CONTEXT",t[t.INVALID_INDEXES_FIELD=3048]="INVALID_INDEXES_FIELD",t[t.INVALID_INDEX=3049]="INVALID_INDEX",t[t.UNKNOWN_INDEX_SETTING=3050]="UNKNOWN_INDEX_SETTING",t[t.DUPLICATE_INDEX_SETTING=3051]="DUPLICATE_INDEX_SETTING",t[t.UNEXPECTED_INDEX_SETTING_VALUE=3052]="UNEXPECTED_INDEX_SETTING_VALUE",t[t.INVALID_INDEX_SETTING_VALUE=3053]="INVALID_INDEX_SETTING_VALUE",t[t.INVALID_PROJECT_CONTEXT=3054]="INVALID_PROJECT_CONTEXT",t[t.PROJECT_REDEFINED=3055]="PROJECT_REDEFINED",t[t.INVALID_PROJECT_FIELD=3056]="INVALID_PROJECT_FIELD",t[t.INVALID_CUSTOM_CONTEXT=3057]="INVALID_CUSTOM_CONTEXT",t[t.INVALID_CUSTOM_ELEMENT_VALUE=3058]="INVALID_CUSTOM_ELEMENT_VALUE",t[t.INVALID_ELEMENT_IN_SIMPLE_BODY=3059]="INVALID_ELEMENT_IN_SIMPLE_BODY",t[t.INVALID_TABLE_PARTIAL_CONTEXT=3060]="INVALID_TABLE_PARTIAL_CONTEXT",t[t.INVALID_TABLE_PARTIAL_ELEMENT_NAME=3061]="INVALID_TABLE_PARTIAL_ELEMENT_NAME",t[t.INVALID_TABLE_PARTIAL_SETTING_VALUE=3062]="INVALID_TABLE_PARTIAL_SETTING_VALUE",t[t.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME=3063]="DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME",t[t.DUPLICATE_TABLE_PARTIAL_SETTING=3064]="DUPLICATE_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_PARTIAL_INJECTION=3065]="INVALID_TABLE_PARTIAL_INJECTION",t[t.INVALID_TABLE_PARTIAL_INJECTION_OP=3066]="INVALID_TABLE_PARTIAL_INJECTION_OP",t[t.INVALID_TABLE_PARTIAL_INJECTION_NAME=3067]="INVALID_TABLE_PARTIAL_INJECTION_NAME",t[t.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME=3068]="DUPLICATE_TABLE_PARTIAL_INJECTION_NAME",t[t.UNKNOWN_TABLE_PARTIAL_SETTING=3069]="UNKNOWN_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_SETTING_VALUE=3070]="INVALID_TABLE_SETTING_VALUE",t[t.INVALID_CHECKS_CONTEXT=3071]="INVALID_CHECKS_CONTEXT",t[t.INVALID_CHECKS_FIELD=3072]="INVALID_CHECKS_FIELD",t[t.INVALID_CHECK=3073]="INVALID_CHECK",t[t.UNKNOWN_CHECK_SETTING=3074]="UNKNOWN_CHECK_SETTING",t[t.DUPLICATE_CHECK_SETTING=3075]="DUPLICATE_CHECK_SETTING",t[t.INVALID_CHECK_SETTING_VALUE=3076]="INVALID_CHECK_SETTING_VALUE",t[t.BINDING_ERROR=4e3]="BINDING_ERROR",t[t.UNSUPPORTED=5e3]="UNSUPPORTED",t[t.CIRCULAR_REF=5001]="CIRCULAR_REF",t[t.SAME_ENDPOINT=5002]="SAME_ENDPOINT",t[t.UNEQUAL_FIELDS_BINARY_REF=5003]="UNEQUAL_FIELDS_BINARY_REF",t[t.CONFLICTING_SETTING=5004]="CONFLICTING_SETTING",t[t.TABLE_REAPPEAR_IN_TABLEGROUP=5005]="TABLE_REAPPEAR_IN_TABLEGROUP",t))(_||{});class g extends Error{constructor(r,i,s){super(i),this.code=r,this.diagnostic=i,this.nodeOrToken=s,this.start=s.start,this.end=s.end,this.name=this.constructor.name,Object.setPrototypeOf(this,g.prototype)}}class lt{constructor(r,i){this.value=r,this.errors=i===void 0?[]:i}getValue(){return this.value}getErrors(){return this.errors}chain(r){const i=r(this.value),s=[...this.errors,...i.errors];return new lt(i.value,s)}map(r){return new lt(r(this.value),this.errors)}}function Yr(t){return!!t.match(new RegExp("(\\p{L}|_|\\p{M})","gu"))}function or(t){if(!t)return!1;const r=t[0];return r>="0"&&r<="9"}function MI(t){const[r]=t;return or(r)||Yr(r)&&r.toLowerCase()>="a"&&r.toLowerCase()<="f"}function Un(t){return Yr(t)||or(t)}function UI(t){return t.split("").every(Un)?t:`"${t}"`}function bc(t,r){const i=[],s=Math.min(t.length,r.length);for(let o=0;o<s;o+=1)i.push(t[o],r[o]);return i.push(...t.slice(s),...r.slice(s)),i}function $r(t,r){return t>=r.start&&t<r.end}function Wa(t){return t instanceof je?`${t.op?.value}${Wa(t.expression)}`:t.expression.literal.value}function Xa(t){return t instanceof je?t.op?.value==="-"?-Xa(t.expression):Xa(t.expression):Number.parseFloat(t.expression.literal.value)}class ye{constructor(r){this.value=r}unwrap(){return this.value}unwrap_or(r){return this.value}and_then(r){return r(this.value)}map(r){return new ye(r(this.value))}isOk(){return!0}}class pe{constructor(){this.value=void 0}unwrap(){throw new Error("Trying to unwrap a None value")}unwrap_or(r){return r}and_then(r){return new pe}map(r){return new pe}isOk(){return!1}}const kI=["null","true","false"],Nf=["-","+"],$t="public";var F=(t=>(t.Table="table",t.Enum="enum",t.Ref="ref",t.Note="note",t.Project="project",t.Indexes="indexes",t.TableGroup="tablegroup",t.TablePartial="tablepartial",t.Check="checks",t))(F||{}),P=(t=>(t.Color="color",t.HeaderColor="headercolor",t.Note="note",t.PK="pk",t.PrimaryKey="primary key",t.Unique="unique",t.Ref="ref",t.NotNull="not null",t.Null="null",t.Increment="increment",t.Default="default",t.Name="name",t.Type="type",t.Check="check",t.Update="update",t.Delete="delete",t))(P||{});class FI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof qe||cn(this.declarationNode.parent).unwrap_or(void 0)!==F.Project?[new g(_.INVALID_CUSTOM_CONTEXT,"A Custom element can only appear in a Project",this.declarationNode)]:[]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"A Custom element shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_NAME,"A Custom element shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Custom element shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof ke)return[new g(_.UNEXPECTED_COMPLEX_BODY,"A Custom element can only have an inline field",r)];const i=[];return Fe(r.callee)||i.push(new g(_.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",r)),r.args.length>0&&i.push(...r.args.map(s=>new g(_.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",s))),i}}var U=(t=>(t.Schema="Schema",t.Table="Table",t.Column="Column",t.TableGroup="TableGroup",t.TableGroupField="TableGroup field",t.Enum="Enum",t.EnumField="Enum field",t.Note="Note",t.TablePartial="TablePartial",t.PartialInjection="PartialInjection",t))(U||{});function Jr(t){return`Schema:${t}`}function ur(t){return`Table:${t}`}function fr(t){return`Column:${t}`}function no(t){return`Enum:${t}`}function ro(t){return`Enum field:${t}`}function io(t){return`TableGroup:${t}`}function so(t){return`TableGroup field:${t}`}function CI(t){return`Note:${t}`}function ao(t){return`TablePartial:${t}`}function oo(t){return`PartialInjection:${t}`}function BI(t,r){switch(r){case"Column":return fr(t);case"Enum":return no(t);case"Enum field":return ro(t);case"Schema":return Jr(t);case"Table":return ur(t);case"TableGroup":return io(t);case"TableGroup field":return so(t);case"TablePartial":return ao(t);case"PartialInjection":return oo(t);default:throw new Error("Unreachable")}}function Qr(t){const[r,i]=t.split(":");return Object.values(U).includes(r)?new ye({name:i,kind:r}):new pe}class Bn{constructor(){this.table=new Map}has(r){return this.table.has(r)}set(r,i){this.table.set(r,i)}get(r,i){return this.table.get(r)||i!==void 0&&this.set(r,i)||i}entries(){return this.table.entries()}forEach(r){return this.table.forEach(r)}}class GI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_PROJECT_CONTEXT,"An Enum can only appear top-level",this.declarationNode)]:[]}validateName(r){return r?Tf(r)?[]:[new g(_.INVALID_NAME,"An Enum name must be of the form <enum> or <schema>.<enum>",r)]:[new g(_.NAME_NOT_FOUND,"An Enum must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"An Enum shouldn't have an alias",r)]:[]}registerElement(){const r=[];this.declarationNode.symbol=this.symbolFactory.create(ff,{declaration:this.declarationNode,symbolTable:new Bn});const{name:i}=this.declarationNode,s=Ge(i);if(s.isOk()){const o=s.unwrap(),l=o.pop(),f=us(o,this.publicSymbolTable,this.symbolFactory),d=no(l);f.has(d)&&r.push(new g(_.DUPLICATE_NAME,`Enum name ${l} already exists in schema '${o.join(".")||$t}'`,i)),f.set(d,this.declarationNode.symbol)}return r}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"An Enum shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.length===0?[new g(_.EMPTY_ENUM,"An Enum must have at least one element",this.declarationNode)]:r.flatMap(i=>{const s=[];i.callee&&!we(i.callee)&&s.push(new g(_.INVALID_ENUM_ELEMENT_NAME,"An enum field must be an identifier or a quoted identifier",i.callee));const o=[...i.args];return me(o)instanceof _e?(s.push(...this.validateFieldSettings(me(o))),o.pop()):o[0]instanceof _e&&(s.push(...this.validateFieldSettings(o[0])),o.shift()),o.length>0&&s.push(...o.map(l=>new g(_.INVALID_ENUM_ELEMENT,"An Enum must have only a field and optionally a setting list",l))),s.push(...this.registerField(i)),s})}validateFieldSettings(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"note":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_ENUM_ELEMENT_SETTING,"'note' can only appear once",d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_ENUM_ELEMENT_SETTING,"'note' must be a string",d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_ENUM_ELEMENT_SETTING,`Unknown enum field setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=ro(i),o=this.symbolFactory.create(hf,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${i}`,f.declaration)]}l.set(s,o)}return[]}}class VI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const r=new g(_.INVALID_INDEXES_CONTEXT,"An Indexes can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof qe)return[r];const i=cn(this.declarationNode.parent).unwrap_or(void 0);return i&&[F.Table,F.TablePartial].includes(i)?[]:[r]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"An Indexes shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"An Indexes shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"An Indexes shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"An Indexes must have a complex body",r)];const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];return me(o)instanceof _e&&s.push(...this.validateFieldSetting(o.pop())),o.forEach(l=>{for(;l instanceof He;)l.argumentList&&!Qi(l.argumentList).isOk()&&s.push(new g(_.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",l.argumentList)),l=l.callee;Qi(l).isOk()||s.push(new g(_.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",l))}),s})}validateFieldSetting(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"note":case"name":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'${l}' must be a string`,d))});break;case"unique":case"pk":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{ot(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'${l}' must not have a value`,d))});break;case"type":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,"'type' can only appear once",d))),f.forEach(d=>{we(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'type' must be "btree" or "hash"`,d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_INDEX_SETTING,`Unknown index setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class $I{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return!(this.declarationNode.parent instanceof qe)&&![F.Table,F.TableGroup,F.TablePartial,F.Project].includes(cn(this.declarationNode.parent).unwrap_or(void 0))?[new g(_.INVALID_NOTE_CONTEXT,"A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",this.declarationNode)]:[]}validateName(r){if(!(this.declarationNode.parent instanceof qe))return r?[new g(_.UNEXPECTED_NAME,"A Note shouldn't have a name",r)]:[];if(!r)return[new g(_.INVALID_NAME,"Sticky note must have a name",this.declarationNode)];const i=Ge(r);if(!i.isOk())return[new g(_.INVALID_NAME,"Invalid name for sticky note ",this.declarationNode)];const o=i.unwrap().join("."),l=CI(o);return this.publicSymbolTable.has(l)?[new g(_.DUPLICATE_NAME,`Sticky note "${o}" has already been defined`,r)]:(this.publicSymbolTable.set(l,this.declarationNode.symbol),[])}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Note shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){const i=[];return r.length===0?[new g(_.EMPTY_NOTE,"A Note must have a content",this.declarationNode)]:(r.length>1&&r.slice(1).forEach(s=>i.push(new g(_.NOTE_CONTENT_REDEFINED,"A Note can only contain one string",s))),Fe(r[0].callee)||i.push(new g(_.INVALID_NOTE,"A Note content must be a quoted string",r[0])),r[0].args.length>0&&i.push(...r[0].args.map(s=>new g(_.INVALID_NOTE,"A Note can only contain one quoted string",s))),i)}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class WI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_PROJECT_CONTEXT,"A Project can only appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A Project's name is optional or must be an identifier or a quoted identifer",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Project shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Project shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Project's body must be a block",r)];const[i,s]=ct(r.body,o=>o instanceof W);return[...i.map(o=>new g(_.INVALID_PROJECT_FIELD,"A Project can not have inline fields",o)),...this.validateSubElements(s)]}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class XI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof qe?[]:[new g(_.INVALID_REF_CONTEXT,"A Ref must appear top-level",this.declarationNode)]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A Ref's name is optional or must be an identifier or a quoted identifer",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Ref shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){if(r.length===0)return[new g(_.EMPTY_REF,"A Ref must have at least one field",this.declarationNode)];const i=[];return r.length>1&&i.push(...r.slice(1).map(s=>new g(_.REF_REDEFINED,"A Ref can only contain one binary relationship",s))),r.forEach(s=>{s.callee&&!jI(s.callee)&&i.push(new g(_.INVALID_REF_FIELD,"A Ref field must be a binary relationship",s.callee)),s.callee&&!eA(s.callee)&&i.push(new g(_.UNEQUAL_FIELDS_BINARY_REF,"Unequal fields in ref endpoints",s.callee));const o=[...s.args];if(me(o)instanceof _e){const l=this.validateFieldSettings(me(o));i.push(...l),o.pop()}else o[0]instanceof _e&&(i.push(...this.validateFieldSettings(o[0])),o.shift());o.length>0&&i.push(...o.map(l=>new g(_.INVALID_REF_FIELD,"A Ref field should only have a single binary relationship",l)))}),i}validateFieldSettings(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"delete":case"update":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_REF_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{HI(d.value)||s.push(new g(_.INVALID_REF_SETTING_VALUE,`'${l}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`,d))});break;case"color":f.length>1&&s.push(...f.map(d=>new g(_.DUPLICATE_REF_SETTING,"'color' can only appear once",d))),f.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_REF_SETTING_VALUE,"'color' must be a color literal",d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_REF_SETTING,`Unknown ref setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}function HI(t){if(!(we(t)&&t.expression.variable.kind!==A.QUOTED_STRING)&&!(t instanceof yt))return!1;let r;if(t instanceof yt?r=zr(t).unwrap_or(""):r=t.expression.variable.value,r)switch(r.toLowerCase()){case"cascade":case"no action":case"set null":case"set default":case"restrict":return!0;default:return!1}return!1}class qI{constructor(r,i,s){this.declarationNode=r,this.symbolFactory=s,this.publicSymbolTable=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLE_CONTEXT,"Table must appear top-level",this.declarationNode)]:[]}validateName(r){return r?r instanceof Bt?[new g(_.INVALID_NAME,"Invalid array as Table name, maybe you forget to add a space between the name and the setting list?",r)]:Tf(r)?[]:[new g(_.INVALID_NAME,"A Table name must be of the form <table> or <schema>.<table>",r)]:[new g(_.NAME_NOT_FOUND,"A Table must have a name",this.declarationNode)]}validateAlias(r){return r?QI(r)?[]:[new g(_.INVALID_ALIAS,"Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes",r)]:[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case P.HeaderColor:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'headercolor' can only appear once",d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'headercolor' must be a color literal",d.value||d.name))});break;case P.Note:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'note' can only appear once",d))),l.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_SETTING,`Unknown '${f}' setting`,d)))}}),s}registerElement(){const r=[];this.declarationNode.symbol=this.symbolFactory.create(qr,{declaration:this.declarationNode,symbolTable:new Bn});const{name:i,alias:s}=this.declarationNode,o=Ge(i);if(o.isOk()){const l=[...o.unwrap()],f=l.pop(),d=us(l,this.publicSymbolTable,this.symbolFactory),m=ur(f);d.has(m)&&r.push(new g(_.DUPLICATE_NAME,`Table name '${f}' already exists in schema '${l.join(".")||$t}'`,i)),d.set(m,this.declarationNode.symbol)}if(s&&hr(s)&&!zI(s.expression.variable.value,o.unwrap_or([]))){const l=Me(s).unwrap(),f=ur(l);this.publicSymbolTable.has(f)&&r.push(new g(_.DUPLICATE_NAME,`Table name '${l}' already exists`,i)),this.publicSymbolTable.set(f,this.declarationNode.symbol)}return r}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Table's body must be a block",r)];const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){const i=o=>{const l=[];if(!o.callee)return[];o.args.length===0&&l.push(new g(_.INVALID_COLUMN,"A column must have a type",o.callee)),we(o.callee)||l.push(new g(_.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",o.callee)),o.args[0]&&!If(o.args[0])&&l.push(new g(_.INVALID_COLUMN_TYPE,"Invalid column type",o.args[0]));const f=o.args.slice(1);return l.push(...this.validateFieldSetting(f)),l.push(...this.registerField(o)),l},s=o=>{const l=[];if(!o.callee)return[];if(!Ji(o.callee))l.push(new g(_.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection should be of the form ~<table-partial>",o.callee));else{const f=Pe(o.callee.expression).unwrap_or(""),d=this.symbolFactory.create(_f,{symbolTable:new Bn,declaration:o}),m=oo(f),I=this.declarationNode.symbol.symbolTable;if(I.has(m)){const T=I.get(m);return[new g(_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${f}'`,o),new g(_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${f}'`,T.declaration)]}I.set(m,d)}return o.args.length&&l.push(...o.args.map(f=>new g(_.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection does not have any trailing attributes",f))),l};return r.flatMap(o=>o.callee instanceof je&&o.callee.op?.value==="~"?s(o):i(o))}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=fr(i),o=this.symbolFactory.create(to,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,f.declaration)]}l.set(s,o)}return[]}validateFieldSetting(r){if(!r.slice(0,-1).every(In)||!r.slice(-1).every(m=>In(m)||m instanceof _e))return[...r.map(m=>new g(_.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",m))];if(r.length===0)return[];let i;me(r)instanceof _e&&(i=r.pop());const s=Ne(i),o=s.getErrors(),l=s.getValue();r.forEach(m=>{const I=Me(m).unwrap_or("").toLowerCase();if(I!=="pk"&&I!=="unique"){o.push(new g(_.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",m));return}l[I]===void 0?l[I]=[m]:l[I].push(m)});const f=l[P.PK]||[],d=l[P.PrimaryKey]||[];return f.length>=1&&d.length>=1&&o.push(...[...f,...d].map(m=>new g(_.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",m))),Hr(l,(m,I)=>{switch(I){case P.Note:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"note can only appear once",T))),m.forEach(T=>{Fe(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'note' must be a quoted string",T.value||T.name))});break;case P.Ref:m.forEach(T=>{mf(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'ref' must be a valid unary relationship",T.value||T.name))});break;case P.PrimaryKey:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"primary key can only appear once",T))),m.forEach(T=>{ot(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'primary key' must not have a value",T.value||T.name))});break;case P.PK:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'pk' can only appear once",T))),m.forEach(T=>{T instanceof xt&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'pk' must not have a value",T.value||T.name))});break;case P.NotNull:{m.length>1&&o.push(...m.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,"'not null' can only appear once",y)));const T=l[P.Null]||[];m.length>=1&&T.length>=1&&o.push(...[...m,...T].map(y=>new g(_.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",y))),m.forEach(y=>{ot(y.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'not null' must not have a value",y.value||y.name))});break}case P.Null:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'null' can only appear once",T))),m.forEach(T=>{ot(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'null' must not have a value",T.value||T.name))});break;case P.Unique:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'unique' can only appear once",T))),m.forEach(T=>{T instanceof xt&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'unique' must not have a value",T.value||T.name))});break;case P.Increment:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'increment' can only appear once",T))),m.forEach(T=>{T instanceof xt&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'increment' must not have a value",T.value||T.name))});break;case P.Default:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'default' can only appear once",T))),m.forEach(T=>{bf(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'default' must be an enum value, a string literal, number literal, function expression, true, false or null",T.value||T.name))});break;case P.Check:m.forEach(T=>{T.value instanceof vt||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",T.value||T.name))});break;default:m.forEach(T=>o.push(new g(_.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${I}'`,T)))}}),o}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()==="note");return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}}function zI(t,r){return r.length===1&&t===r[0]}class KI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLEGROUP_CONTEXT,"TableGroup must appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A TableGroup name must be a single identifier",r)]:[new g(_.NAME_NOT_FOUND,"A TableGroup must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A TableGroup shouldn't have an alias",r)]:[]}registerElement(){const{name:r}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(pf,{declaration:this.declarationNode,symbolTable:new Bn});const i=Ge(r);if(i.isOk()){const s=i.unwrap(),o=s.pop(),l=us(s,this.publicSymbolTable,this.symbolFactory),f=io(o);if(l.has(f))return[new g(_.DUPLICATE_NAME,`TableGroup name '${o}' already exists`,r)];l.set(f,this.declarationNode.symbol)}return[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case"color":l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'color' can only appear once",d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'color' must be a color literal",d.value||d.name))});break;case"note":l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'note' can only appear once",d))),l.filter(d=>!Fe(d.value)).forEach(d=>{s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_SETTING,`Unknown '${f}' setting`,d)));break}}),s}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A TableGroup's body must be a block",r)];const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{const s=[];return i.callee&&!Ge(i.callee).isOk()&&s.push(new g(_.INVALID_TABLEGROUP_FIELD,"A TableGroup field must be of the form <table> or <schema>.<table>",i.callee)),this.registerField(i),i.args.length>0&&s.push(...i.args.map(o=>new g(_.INVALID_TABLEGROUP_FIELD,"A TableGroup field should only have a single Table name",o))),s})}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()==="note");return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=so(i),o=this.symbolFactory.create(df,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_TABLEGROUP_FIELD_NAME,`${i} already exists in the group`,r),new g(_.DUPLICATE_TABLEGROUP_FIELD_NAME,`${i} already exists in the group`,f.declaration)]}l.set(s,o)}return[]}}class YI{constructor(r,i,s){this.declarationNode=r,this.symbolFactory=s,this.publicSymbolTable=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLE_PARTIAL_CONTEXT,"TablePartial must appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A TablePartial name must be an identifier or a quoted identifer",r)]:[new g(_.NAME_NOT_FOUND,"A TablePartial must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A TablePartial shouldn't have an alias",r)]:[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case P.HeaderColor:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_PARTIAL_SETTING,`'${f}' can only appear once`,d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${f}' must be a color literal`,d.value||d.name))});break;case P.Note:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_PARTIAL_SETTING,`'${f}' can only appear once`,d))),l.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${f}' must be a string literal`,d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_PARTIAL_SETTING,`Unknown '${f}' setting`,d)))}}),s}registerElement(){const{name:r}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(Ef,{declaration:this.declarationNode,symbolTable:new Bn});const i=Ge(r);if(!i.isOk())return[];const s=i.unwrap(),o=s.pop(),l=us(s,this.publicSymbolTable,this.symbolFactory),f=ao(o);return l.has(f)?[new g(_.DUPLICATE_NAME,`TablePartial name '${o}' already exists`,r)]:(l.set(f,this.declarationNode.symbol),[])}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A TablePartial's body must be a block",r)];const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[];i.args.length===0&&s.push(new g(_.INVALID_COLUMN,"A column must have a type",i.callee)),we(i.callee)||s.push(new g(_.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",i.callee)),i.args[0]&&!If(i.args[0])&&s.push(new g(_.INVALID_COLUMN_TYPE,"Invalid column type",i.args[0]));const o=i.args.slice(1);return s.push(...this.validateFieldSetting(o),...this.registerField(i)),s})}registerField(r){if(!r.callee||!we(r.callee))return[];const i=Me(r.callee).unwrap(),s=fr(i),o=this.symbolFactory.create(to,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,f.declaration)]}return l.set(s,o),[]}validateFieldSetting(r){const i=me(r);if(!r.slice(0,-1).every(In)||!(In(i)||i instanceof _e))return[...r.map(I=>new g(_.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",I))];if(r.length===0)return[];let s;me(r)instanceof _e&&(s=r.pop());const o=Ne(s),l=o.getErrors(),f=o.getValue();r.forEach(I=>{const T=Me(I).unwrap_or("").toLowerCase();if(T!==P.PK&&T!==P.Unique){l.push(new g(_.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",I));return}f[T]===void 0?f[T]=[I]:f[T].push(I)});const d=f[P.PK]||[],m=f[P.PrimaryKey]||[];return d.length>=1&&m.length>=1&&l.push(...[...d,...m].map(I=>new g(_.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",I))),Hr(f,(I,T)=>{switch(T){case P.Note:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{Fe(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a quoted string`,y.value||y.name))});break;case P.Ref:I.forEach(y=>{mf(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a valid unary relationship`,y.value||y.name))});break;case P.PrimaryKey:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{ot(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.PK:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof xt&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.NotNull:{I.length>1&&l.push(...I.map($=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,$)));const y=f[P.Null]||[];I.length>=1&&y.length>=1&&l.push(...[...I,...y].map($=>new g(_.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",$))),I.forEach($=>{ot($.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,$.value||$.name))});break}case P.Null:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{ot(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Unique:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof xt&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Increment:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof xt&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Default:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{bf(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a string literal, number literal, function expression, true, false or null`,y.value||y.name))});break;case P.Check:I.forEach(y=>{y.value instanceof vt||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",y.value||y.name))});break;default:I.forEach(y=>l.push(new g(_.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${T}'`,y)))}}),l}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()===F.Note);return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}}class JI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const r=new g(_.INVALID_CHECKS_CONTEXT,"A Checks can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof qe)return[r];const i=cn(this.declarationNode.parent).unwrap_or(void 0);return i&&[F.Table,F.TablePartial].includes(i)?[]:[r]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"A Checks shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Checks shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Checks shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Checks must have a complex body",r)];const[i,s]=ct(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];return me(o)instanceof _e&&s.push(...this.validateFieldSetting(o.pop())),(o.length>1||!(o[0]instanceof vt))&&s.push(new g(_.INVALID_CHECKS_FIELD,"A check field must be a function expression",i)),s})}validateFieldSetting(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"name":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_CHECK_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_CHECK_SETTING_VALUE,`'${l}' must be a string`,d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_CHECK_SETTING,`Unknown check setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}function Xt(t){switch(t.type.value.toLowerCase()){case F.Enum:return GI;case F.Table:return qI;case F.TableGroup:return KI;case F.Project:return WI;case F.Ref:return XI;case F.Note:return $I;case F.Indexes:return VI;case F.TablePartial:return YI;case F.Check:return JI;default:return FI}}function Tf(t){return!!Ge(t).unwrap_or(!1)}function QI(t){return hr(t)}function hr(t){return t instanceof ut&&t.expression instanceof ln}function Ji(t){return t instanceof je&&t.op?.value==="~"&&we(t.expression)}function us(t,r,i){t[0]===$t&&(t=t.slice(1));let s=r;for(const o of t){let l;const f=Jr(o);if(s.has(f)){if(l=s.get(f)?.symbolTable,!l)throw new Error("Expect a symbol table in a schema symbol")}else{l=new Bn;const d=i.create(eo,{symbolTable:l});s.set(f,d)}s=l}return s}function vf(t){return t==="-"||t==="<>"||t===">"||t==="<"}function ls(t){if(!(t instanceof ut)||!(t.expression instanceof cr)||t.expression.literal?.kind!==A.COLOR_LITERAL)return!1;const r=t.expression.literal.value;if(r.length!==4&&r.length!==7||r[0]!=="#")return!1;for(let i=1;i<r.length;i+=1)if(!MI(r[i]))return!1;return!0}function ot(t){return t===void 0}function bf(t){if(Fe(t)||mn(t)||In(t)&&["true","false","null"].includes(t.expression.variable.value.toLowerCase())||t instanceof je&&Nf.includes(t.op?.value)&&mn(t.expression)||t instanceof vt)return!0;if(!t||!lo(t))return!1;const r=An(t).unwrap();return r.length===2||r.length===3}function mn(t){return t instanceof je?Nf.includes(t.op.value)?mn(t.expression):!1:t instanceof ut&&t.expression instanceof cr&&t.expression.literal?.kind===A.NUMERIC_LITERAL}function mf(t){if(!(t instanceof je)||!vf(t.op?.value))return!1;const r=Ge(t.expression).unwrap_or(void 0);return r!==void 0&&r.length>0}function ZI(t){return t instanceof Wt&&t.elementList.every(we)}function If(t){if(!(t instanceof He||uo(t)||t instanceof ut||t instanceof Bt))return!1;for(;t instanceof He||t instanceof Bt;)if(t instanceof He){if(t.callee===void 0||t.argumentList===void 0||!t.argumentList.elementList.every(i=>mn(i)||Fe(i)||In(i)))return!1;t=t.callee}else if(t instanceof Bt){if(t.array===void 0||t.indexer===void 0||!t.indexer.elementList.every(i=>!i.colon&&!i.value&&mn(i.name)))return!1;t=t.array}const r=Ge(t).unwrap_or(void 0);return r!==void 0&&r.length>0}function Ne(t){const r={},i=[];return t?(t.elementList.forEach(s=>{if(!s.name)return;if(s.name instanceof ut){i.push(new g(_.INVALID_SETTINGS,"A setting name must be a stream of identifiers",s.name));return}const o=zr(s.name).unwrap_or(void 0)?.toLowerCase();o&&(r[o]===void 0?r[o]=[s]:r[o].push(s))}),new lt(r,i)):new lt({})}function cn(t){const r=t?.type?.value.toLowerCase();switch(r){case F.Enum:case F.Table:case F.Indexes:case F.Note:case F.Project:case F.Ref:case F.TableGroup:case F.TablePartial:case F.Check:return new ye(r);default:return new pe}}function An(t){if(!t)return new pe;if(!uo(t))return new ye([t]);const r=An(t.leftExpression).unwrap_or(void 0);return r?(r.push(t.rightExpression),new ye(r)):new pe}function Ge(t){if(t===void 0)return new pe;const r=An(t).unwrap_or(void 0);if(!r)return new pe;const i=[];for(const s of r){const o=Pe(s).unwrap_or(void 0);if(typeof o!="string")return new pe;i.push(o)}return new ye(i)}function St(t){if(t===void 0)return new pe;const r=An(t).unwrap_or(void 0);if(!r||r.length===0)return new pe;let i=[];if(!we(me(r))){const o=r.pop();if(ZI(o))i=o.elementList;else return new pe}const s=r;return s.every(we)?new ye({variables:s,tupleElements:i}):new pe}function Pe(t){return we(t)?new ye(t.expression.variable.value):new pe}function Qi(t){if(mc(t))return t instanceof vt?new ye({functional:[t],nonFunctional:[]}):new ye({functional:[],nonFunctional:[t]});if(t instanceof Wt&&t.elementList.every(mc)){const r=t.elementList.filter(s=>s instanceof vt),i=t.elementList.filter(we);return new ye({functional:r,nonFunctional:i})}return new pe}function Me(t){const r=t?.expression.variable?.value;return r===void 0?new pe:new ye(r)}function Le(t){return Fe(t)?t.expression instanceof ln?new ye(t.expression.variable.value):new ye(t.expression.literal.value):new pe}function jI(t){return!(t instanceof Vt)||!vf(t.op?.value)?!1:St(t.leftExpression).and_then(()=>St(t.rightExpression)).unwrap_or(void 0)!==void 0}function eA(t){const r=St(t.leftExpression),i=St(t.rightExpression);if(!r.isOk()||!i.isOk())return!1;const{tupleElements:s}=r.unwrap(),{tupleElements:o}=i.unwrap();return s?.length===o?.length}function mc(t){return t instanceof ut&&t.expression instanceof ln||t instanceof vt}function tA(t,r,i){if(!t||!In(t)||r.length===0)return new pe;const s=[...r],o=Ic(t).unwrap(),l=s.pop();if(!(l instanceof ke))return new pe;const f=me(s)instanceof _e?s.pop():void 0;if(s.length===3){const d=Ic(s[1]).value;return!d||!Ha(d)?new pe:new ye(i.create(se,{type:o,name:s[0],as:d,alias:s[2],attributeList:f,body:l}))}return s.length===1?new ye(i.create(se,{type:o,name:s[0],attributeList:f,body:l})):s.length===0?new ye(i.create(se,{type:o,attributeList:f,body:l})):new pe}function Ha(t){return t?.kind===A.IDENTIFIER&&t.value.toLowerCase()==="as"}function C(t){t&&(t instanceof Ze?nA(t):rA(t))}function nA(t){t.kind!==A.EOF&&(t.isInvalid=!0)}function rA(t){if(t instanceof se)C(t.type),C(t.name),C(t.as),C(t.alias),C(t.bodyColon),C(t.attributeList),C(t.body);else if(t instanceof yt)t.identifiers.forEach(C);else if(t instanceof xt)C(t.name),C(t.colon),C(t.value);else if(t instanceof je)C(t.op),C(t.expression);else if(t instanceof Vt)C(t.leftExpression),C(t.op),C(t.rightExpression);else if(t instanceof os)C(t.op),C(t.expression);else if(t instanceof ke)C(t.blockOpenBrace),t.body.forEach(C),C(t.blockCloseBrace);else if(t instanceof _e)C(t.listOpenBracket),t.commaList.forEach(C),t.elementList.forEach(C),C(t.listCloseBracket);else if(t instanceof Wt)C(t.tupleOpenParen),t.commaList.forEach(C),t.elementList.forEach(C),C(t.tupleCloseParen);else if(t instanceof He)C(t.callee),C(t.argumentList);else if(t instanceof W)C(t.callee),t.args.forEach(C);else if(t instanceof ut)C(t.expression);else if(t instanceof vt)C(t.value);else if(t instanceof ln)C(t.variable);else if(t instanceof cr)C(t.literal);else{if(t instanceof ja)throw new Error("This case is handled by the TupleExpressionNode case");if(t instanceof Bt)C(t.array),C(t.indexer);else if(t instanceof qe)t.body.forEach(C),C(t.eof);else if(!(t instanceof Br))throw new Error("Unreachable case in markInvalidNode")}}function qa(t){return!!t?.isInvalid}function Xe(...t){return t.filter(r=>r!==void 0)}function iA(t){if(t instanceof qe)return Xe(...t.body,t.eof);if(t instanceof se)return Xe(t.type,t.name,t.as,t.alias,t.attributeList,t.bodyColon,t.body);if(t instanceof xt)return Xe(t.name,t.colon,t.value);if(t instanceof yt)return t.identifiers;if(t instanceof cr)return t.literal?[t.literal]:[];if(t instanceof ln)return Xe(t.variable);if(t instanceof je)return Xe(t.op,t.expression);if(t instanceof Vt)return Xe(t.leftExpression,t.op,t.rightExpression);if(t instanceof os)return Xe(t.expression,t.op);if(t instanceof vt)return Xe(t.value);if(t instanceof W)return Xe(t.callee,...t.args);if(t instanceof ke)return Xe(t.blockOpenBrace,...t.body,t.blockCloseBrace);if(t instanceof _e)return Xe(t.listOpenBracket,...bc(t.elementList,t.commaList),t.listCloseBracket);if(t instanceof Wt)return Xe(t.tupleOpenParen,...bc(t.elementList,t.commaList),t.tupleCloseParen);if(t instanceof He)return Xe(t.callee,t.argumentList);if(t instanceof ut)return Xe(t.expression);if(t instanceof Bt)return Xe(t.array,t.indexer);throw t instanceof ja?new Error("This case is already handled by TupleExpressionNode"):new Error("Unreachable - no other possible cases")}function Ic(t){return we(t)?new ye(t.expression.variable):new pe}function Fe(t){return t instanceof ut&&(t.expression instanceof ln&&t.expression.variable instanceof Ze&&t.expression.variable.kind===A.QUOTED_STRING||t.expression instanceof cr&&t.expression.literal?.kind===A.STRING_LITERAL)}function we(t){return t instanceof ut&&t.expression instanceof ln&&t.expression.variable instanceof Ze}function In(t){return t instanceof ut&&t.expression instanceof ln&&t.expression.variable?.kind===A.IDENTIFIER}function uo(t){return t instanceof Vt&&t.leftExpression instanceof Te&&t.rightExpression instanceof Te&&t.op?.value==="."}function lo(t){return we(t)?!0:uo(t)&&we(t.rightExpression)&&lo(t.leftExpression)}function zr(t){if(t===void 0)return new pe;const r=t.identifiers.map(i=>i.value).join(" ");return r===""?new pe:new ye(r)}function sA(t){return Ge(t.name).map(r=>r.join("."))}class aA{constructor(r){this.start={offset:0,line:0,column:0},this.current={offset:0,line:0,column:0},this.tokens=[],this.errors=[],this.text=r}isAtEnd(){return this.current.offset>=this.text.length}advance(){const r=this.peek();return this.current={...this.current},r===`
2
- `?(this.current.line+=1,this.current.column=0):this.current.column+=1,this.current.offset+=1,r}peek(r=0){if(!(this.current.offset+r>=this.text.length))return this.text[this.current.offset+r]}check(r){for(let i=0;i<r.length;i+=1)if(r[i]!==this.peek(i))return!1;return!0}match(r){return this.check(r)?(r.split("").forEach(()=>this.advance()),!0):!1}addToken(r,i=!1){this.tokens.push(this.createToken(r,i))}createToken(r,i=!1){return Ze.create(r,this.start,this.current,this.text.substring(this.start.offset,this.current.offset),i)}lex(){return this.scanTokens(),this.tokens.push(Ze.create(A.EOF,this.start,this.current,"",!1)),this.gatherTrivia(),this.gatherInvalid(),new lt(this.tokens,this.errors)}scanTokens(){for(;!this.isAtEnd();){const r=this.advance();switch(r){case" ":this.addToken(A.SPACE);break;case"\r":break;case`
3
- `:this.addToken(A.NEWLINE);break;case" ":this.addToken(A.TAB);break;case",":this.addToken(A.COMMA);break;case"(":this.addToken(A.LPAREN);break;case")":this.addToken(A.RPAREN);break;case"[":this.addToken(A.LBRACKET);break;case"]":this.addToken(A.RBRACKET);break;case"{":this.addToken(A.LBRACE);break;case"}":this.addToken(A.RBRACE);break;case";":this.addToken(A.SEMICOLON);break;case":":this.addToken(A.COLON);break;case"'":this.match("''")?this.multilineStringLiteral():this.singleLineStringLiteral();break;case'"':this.quotedVariable();break;case"`":this.functionExpression();break;case"#":this.colorLiteral();break;case"/":this.match("/")?this.singleLineComment():this.match("*")?this.multilineComment():this.operator(r);break;default:if(SI(r)){this.operator(r);break}if(Yr(r)){this.identifier();break}if(or(r)){this.numericLiteralOrIdentifier();break}this.addToken(A.OP,!0),this.errors.push(new g(_.UNKNOWN_SYMBOL,`Unexpected token '${r}'`,this.createToken(A.OP,!0)));break}this.start={...this.current}}}gatherTrivia(){let r=!0,i=[],s;const o=[];for(const l of this.tokens)xI(l)?(i.push(l),l.kind===A.NEWLINE&&s&&(s.trailingTrivia=i,r=!0,s=void 0,i=[])):(r?l.leadingTrivia=i:s.trailingTrivia=i,o.push(l),i=[],s=l,r=!1);this.tokens=o}gatherInvalid(){let r;const i=[],s=[];for(r=0;r<this.tokens.length&&qa(this.tokens[r]);r+=1)s.push(this.tokens[r]);let o=this.tokens[r];for(o.leadingInvalid=[...s,...o.leadingInvalid];r<this.tokens.length;r+=1){const l=this.tokens[r];qa(l)?o.trailingInvalid.push(l):(o=l,i.push(l))}this.tokens=i}consumeUntil(r,i,{allowNewline:s,allowEof:o,raw:l,consumeStopSequence:f=!0}){let d="";for(;!this.isAtEnd()&&(s||!this.check(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var kc=typeof global=="object"&&global&&global.Object===Object&&global,FT=typeof self=="object"&&self&&self.Object===Object&&self,an=kc||FT||Function("return this")(),Gt=an.Symbol,Fc=Object.prototype,CT=Fc.hasOwnProperty,BT=Fc.toString,Cr=Gt?Gt.toStringTag:void 0;function GT(t){var r=CT.call(t,Cr),i=t[Cr];try{t[Cr]=void 0;var s=!0}catch{}var o=BT.call(t);return s&&(r?t[Cr]=i:delete t[Cr]),o}var VT=Object.prototype,$T=VT.toString;function WT(t){return $T.call(t)}var XT="[object Null]",HT="[object Undefined]",ql=Gt?Gt.toStringTag:void 0;function lr(t){return t==null?t===void 0?HT:XT:ql&&ql in Object(t)?GT(t):WT(t)}function Fn(t){return t!=null&&typeof t=="object"}var qT="[object Symbol]";function ts(t){return typeof t=="symbol"||Fn(t)&&lr(t)==qT}function Cc(t,r){for(var i=-1,s=t==null?0:t.length,o=Array(s);++i<s;)o[i]=r(t[i],i,t);return o}var Pt=Array.isArray,zl=Gt?Gt.prototype:void 0,Kl=zl?zl.toString:void 0;function Bc(t){if(typeof t=="string")return t;if(Pt(t))return Cc(t,Bc)+"";if(ts(t))return Kl?Kl.call(t):"";var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}var zT=/\s/;function KT(t){for(var r=t.length;r--&&zT.test(t.charAt(r)););return r}var YT=/^\s+/;function JT(t){return t&&t.slice(0,KT(t)+1).replace(YT,"")}function ar(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}var Yl=NaN,QT=/^[-+]0x[0-9a-f]+$/i,ZT=/^0b[01]+$/i,jT=/^0o[0-7]+$/i,ev=parseInt;function tv(t){if(typeof t=="number")return t;if(ts(t))return Yl;if(ar(t)){var r=typeof t.valueOf=="function"?t.valueOf():t;t=ar(r)?r+"":r}if(typeof t!="string")return t===0?t:+t;t=JT(t);var i=ZT.test(t);return i||jT.test(t)?ev(t.slice(2),i?2:8):QT.test(t)?Yl:+t}var Jl=1/0,nv=17976931348623157e292;function rv(t){if(!t)return t===0?t:0;if(t=tv(t),t===Jl||t===-Jl){var r=t<0?-1:1;return r*nv}return t===t?t:0}function iv(t){var r=rv(t),i=r%1;return r===r?i?r-i:r:0}function ns(t){return t}var sv="[object AsyncFunction]",av="[object Function]",ov="[object GeneratorFunction]",uv="[object Proxy]";function Gc(t){if(!ar(t))return!1;var r=lr(t);return r==av||r==ov||r==sv||r==uv}var Da=an["__core-js_shared__"],Ql=function(){var t=/[^.]+$/.exec(Da&&Da.keys&&Da.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function lv(t){return!!Ql&&Ql in t}var cv=Function.prototype,fv=cv.toString;function Gn(t){if(t!=null){try{return fv.call(t)}catch{}try{return t+""}catch{}}return""}var hv=/[\\^$.*+?()[\]{}|]/g,pv=/^\[object .+?Constructor\]$/,dv=Function.prototype,Ev=Object.prototype,_v=dv.toString,gv=Ev.hasOwnProperty,Nv=RegExp("^"+_v.call(gv).replace(hv,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Tv(t){if(!ar(t)||lv(t))return!1;var r=Gc(t)?Nv:pv;return r.test(Gn(t))}function vv(t,r){return t?.[r]}function Vn(t,r){var i=vv(t,r);return Tv(i)?i:void 0}var ka=Vn(an,"WeakMap");function bv(t,r,i){switch(i.length){case 0:return t.call(r);case 1:return t.call(r,i[0]);case 2:return t.call(r,i[0],i[1]);case 3:return t.call(r,i[0],i[1],i[2])}return t.apply(r,i)}var mv=800,Iv=16,Av=Date.now;function wv(t){var r=0,i=0;return function(){var s=Av(),o=Iv-(s-i);if(i=s,o>0){if(++r>=mv)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}function Lv(t){return function(){return t}}var Zl=function(){try{var t=Vn(Object,"defineProperty");return t({},"",{}),t}catch{}}(),yv=Zl?function(t,r){return Zl(t,"toString",{configurable:!0,enumerable:!1,value:Lv(r),writable:!0})}:ns,xv=wv(yv);function Sv(t,r,i,s){t.length;for(var o=i+1;o--;)if(r(t[o],o,t))return o;return-1}var Ov=9007199254740991,Pv=/^(?:0|[1-9]\d*)$/;function Vc(t,r){var i=typeof t;return r=r??Ov,!!r&&(i=="number"||i!="symbol"&&Pv.test(t))&&t>-1&&t%1==0&&t<r}function $c(t,r){return t===r||t!==t&&r!==r}var jl=Math.max;function Rv(t,r,i){return r=jl(r===void 0?t.length-1:r,0),function(){for(var s=arguments,o=-1,l=jl(s.length-r,0),f=Array(l);++o<l;)f[o]=s[r+o];o=-1;for(var d=Array(r+1);++o<r;)d[o]=s[o];return d[r]=i(f),bv(t,this,d)}}function Dv(t,r){return xv(Rv(t,r,ns),t+"")}var Mv=9007199254740991;function za(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Mv}function rs(t){return t!=null&&za(t.length)&&!Gc(t)}var Uv=Object.prototype;function Wc(t){var r=t&&t.constructor,i=typeof r=="function"&&r.prototype||Uv;return t===i}function Xc(t,r){for(var i=-1,s=Array(t);++i<t;)s[i]=r(i);return s}var kv="[object Arguments]";function ec(t){return Fn(t)&&lr(t)==kv}var Hc=Object.prototype,Fv=Hc.hasOwnProperty,Cv=Hc.propertyIsEnumerable,Ka=ec(function(){return arguments}())?ec:function(t){return Fn(t)&&Fv.call(t,"callee")&&!Cv.call(t,"callee")};function Bv(){return!1}var qc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tc=qc&&typeof module=="object"&&module&&!module.nodeType&&module,Gv=tc&&tc.exports===qc,nc=Gv?an.Buffer:void 0,Vv=nc?nc.isBuffer:void 0,Fa=Vv||Bv,$v="[object Arguments]",Wv="[object Array]",Xv="[object Boolean]",Hv="[object Date]",qv="[object Error]",zv="[object Function]",Kv="[object Map]",Yv="[object Number]",Jv="[object Object]",Qv="[object RegExp]",Zv="[object Set]",jv="[object String]",eb="[object WeakMap]",tb="[object ArrayBuffer]",nb="[object DataView]",rb="[object Float32Array]",ib="[object Float64Array]",sb="[object Int8Array]",ab="[object Int16Array]",ob="[object Int32Array]",ub="[object Uint8Array]",lb="[object Uint8ClampedArray]",cb="[object Uint16Array]",fb="[object Uint32Array]",he={};he[rb]=he[ib]=he[sb]=he[ab]=he[ob]=he[ub]=he[lb]=he[cb]=he[fb]=!0;he[$v]=he[Wv]=he[tb]=he[Xv]=he[nb]=he[Hv]=he[qv]=he[zv]=he[Kv]=he[Yv]=he[Jv]=he[Qv]=he[Zv]=he[jv]=he[eb]=!1;function hb(t){return Fn(t)&&za(t.length)&&!!he[lr(t)]}function pb(t){return function(r){return t(r)}}var zc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vr=zc&&typeof module=="object"&&module&&!module.nodeType&&module,db=Vr&&Vr.exports===zc,Ma=db&&kc.process,rc=function(){try{var t=Vr&&Vr.require&&Vr.require("util").types;return t||Ma&&Ma.binding&&Ma.binding("util")}catch{}}(),ic=rc&&rc.isTypedArray,Kc=ic?pb(ic):hb,Eb=Object.prototype,_b=Eb.hasOwnProperty;function Yc(t,r){var i=Pt(t),s=!i&&Ka(t),o=!i&&!s&&Fa(t),l=!i&&!s&&!o&&Kc(t),f=i||s||o||l,d=f?Xc(t.length,String):[],m=d.length;for(var I in t)(r||_b.call(t,I))&&!(f&&(I=="length"||o&&(I=="offset"||I=="parent")||l&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||Vc(I,m)))&&d.push(I);return d}function gb(t,r){return function(i){return t(r(i))}}var Nb=gb(Object.keys,Object),Tb=Object.prototype,vb=Tb.hasOwnProperty;function bb(t){if(!Wc(t))return Nb(t);var r=[];for(var i in Object(t))vb.call(t,i)&&i!="constructor"&&r.push(i);return r}function Ya(t){return rs(t)?Yc(t):bb(t)}function mb(t){var r=[];if(t!=null)for(var i in Object(t))r.push(i);return r}var Ib=Object.prototype,Ab=Ib.hasOwnProperty;function wb(t){if(!ar(t))return mb(t);var r=Wc(t),i=[];for(var s in t)s=="constructor"&&(r||!Ab.call(t,s))||i.push(s);return i}function Lb(t){return rs(t)?Yc(t,!0):wb(t)}var yb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xb=/^\w*$/;function Ja(t,r){if(Pt(t))return!1;var i=typeof t;return i=="number"||i=="symbol"||i=="boolean"||t==null||ts(t)?!0:xb.test(t)||!yb.test(t)||r!=null&&t in Object(r)}var Wr=Vn(Object,"create");function Sb(){this.__data__=Wr?Wr(null):{},this.size=0}function Ob(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}var Pb="__lodash_hash_undefined__",Rb=Object.prototype,Db=Rb.hasOwnProperty;function Mb(t){var r=this.__data__;if(Wr){var i=r[t];return i===Pb?void 0:i}return Db.call(r,t)?r[t]:void 0}var Ub=Object.prototype,kb=Ub.hasOwnProperty;function Fb(t){var r=this.__data__;return Wr?r[t]!==void 0:kb.call(r,t)}var Cb="__lodash_hash_undefined__";function Bb(t,r){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Wr&&r===void 0?Cb:r,this}function Cn(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}Cn.prototype.clear=Sb;Cn.prototype.delete=Ob;Cn.prototype.get=Mb;Cn.prototype.has=Fb;Cn.prototype.set=Bb;function Gb(){this.__data__=[],this.size=0}function is(t,r){for(var i=t.length;i--;)if($c(t[i][0],r))return i;return-1}var Vb=Array.prototype,$b=Vb.splice;function Wb(t){var r=this.__data__,i=is(r,t);if(i<0)return!1;var s=r.length-1;return i==s?r.pop():$b.call(r,i,1),--this.size,!0}function Xb(t){var r=this.__data__,i=is(r,t);return i<0?void 0:r[i][1]}function Hb(t){return is(this.__data__,t)>-1}function qb(t,r){var i=this.__data__,s=is(i,t);return s<0?(++this.size,i.push([t,r])):i[s][1]=r,this}function on(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}on.prototype.clear=Gb;on.prototype.delete=Wb;on.prototype.get=Xb;on.prototype.has=Hb;on.prototype.set=qb;var Xr=Vn(an,"Map");function zb(){this.size=0,this.__data__={hash:new Cn,map:new(Xr||on),string:new Cn}}function Kb(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}function ss(t,r){var i=t.__data__;return Kb(r)?i[typeof r=="string"?"string":"hash"]:i.map}function Yb(t){var r=ss(this,t).delete(t);return this.size-=r?1:0,r}function Jb(t){return ss(this,t).get(t)}function Qb(t){return ss(this,t).has(t)}function Zb(t,r){var i=ss(this,t),s=i.size;return i.set(t,r),this.size+=i.size==s?0:1,this}function un(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}un.prototype.clear=zb;un.prototype.delete=Yb;un.prototype.get=Jb;un.prototype.has=Qb;un.prototype.set=Zb;var jb="Expected a function";function Qa(t,r){if(typeof t!="function"||r!=null&&typeof r!="function")throw new TypeError(jb);var i=function(){var s=arguments,o=r?r.apply(this,s):s[0],l=i.cache;if(l.has(o))return l.get(o);var f=t.apply(this,s);return i.cache=l.set(o,f)||l,f};return i.cache=new(Qa.Cache||un),i}Qa.Cache=un;var em=500;function tm(t){var r=Qa(t,function(s){return i.size===em&&i.clear(),s}),i=r.cache;return r}var nm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rm=/\\(\\)?/g,im=tm(function(t){var r=[];return t.charCodeAt(0)===46&&r.push(""),t.replace(nm,function(i,s,o,l){r.push(o?l.replace(rm,"$1"):s||i)}),r});function sm(t){return t==null?"":Bc(t)}function Jc(t,r){return Pt(t)?t:Ja(t,r)?[t]:im(sm(t))}function as(t){if(typeof t=="string"||ts(t))return t;var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Qc(t,r){r=Jc(r,t);for(var i=0,s=r.length;t!=null&&i<s;)t=t[as(r[i++])];return i&&i==s?t:void 0}function Zc(t,r,i){var s=t==null?void 0:Qc(t,r);return s===void 0?i:s}function jc(t,r){for(var i=-1,s=r.length,o=t.length;++i<s;)t[o+i]=r[i];return t}var sc=Gt?Gt.isConcatSpreadable:void 0;function am(t){return Pt(t)||Ka(t)||!!(sc&&t&&t[sc])}function om(t,r,i,s,o){var l=-1,f=t.length;for(i||(i=am),o||(o=[]);++l<f;){var d=t[l];i(d)?jc(o,d):o[o.length]=d}return o}function ac(t){var r=t==null?0:t.length;return r?om(t):[]}function um(){this.__data__=new on,this.size=0}function lm(t){var r=this.__data__,i=r.delete(t);return this.size=r.size,i}function cm(t){return this.__data__.get(t)}function fm(t){return this.__data__.has(t)}var hm=200;function pm(t,r){var i=this.__data__;if(i instanceof on){var s=i.__data__;if(!Xr||s.length<hm-1)return s.push([t,r]),this.size=++i.size,this;i=this.__data__=new un(s)}return i.set(t,r),this.size=i.size,this}function rn(t){var r=this.__data__=new on(t);this.size=r.size}rn.prototype.clear=um;rn.prototype.delete=lm;rn.prototype.get=cm;rn.prototype.has=fm;rn.prototype.set=pm;function ef(t,r){for(var i=-1,s=t==null?0:t.length,o=0,l=[];++i<s;){var f=t[i];r(f,i,t)&&(l[o++]=f)}return l}function dm(){return[]}var Em=Object.prototype,_m=Em.propertyIsEnumerable,oc=Object.getOwnPropertySymbols,gm=oc?function(t){return t==null?[]:(t=Object(t),ef(oc(t),function(r){return _m.call(t,r)}))}:dm;function Nm(t,r,i){var s=r(t);return Pt(t)?s:jc(s,i(t))}function uc(t){return Nm(t,Ya,gm)}var Ca=Vn(an,"DataView"),Ba=Vn(an,"Promise"),Ga=Vn(an,"Set"),lc="[object Map]",Tm="[object Object]",cc="[object Promise]",fc="[object Set]",hc="[object WeakMap]",pc="[object DataView]",vm=Gn(Ca),bm=Gn(Xr),mm=Gn(Ba),Im=Gn(Ga),Am=Gn(ka),bn=lr;(Ca&&bn(new Ca(new ArrayBuffer(1)))!=pc||Xr&&bn(new Xr)!=lc||Ba&&bn(Ba.resolve())!=cc||Ga&&bn(new Ga)!=fc||ka&&bn(new ka)!=hc)&&(bn=function(t){var r=lr(t),i=r==Tm?t.constructor:void 0,s=i?Gn(i):"";if(s)switch(s){case vm:return pc;case bm:return lc;case mm:return cc;case Im:return fc;case Am:return hc}return r});var dc=an.Uint8Array,wm="__lodash_hash_undefined__";function Lm(t){return this.__data__.set(t,wm),this}function ym(t){return this.__data__.has(t)}function Yi(t){var r=-1,i=t==null?0:t.length;for(this.__data__=new un;++r<i;)this.add(t[r])}Yi.prototype.add=Yi.prototype.push=Lm;Yi.prototype.has=ym;function xm(t,r){for(var i=-1,s=t==null?0:t.length;++i<s;)if(r(t[i],i,t))return!0;return!1}function Sm(t,r){return t.has(r)}var Om=1,Pm=2;function tf(t,r,i,s,o,l){var f=i&Om,d=t.length,m=r.length;if(d!=m&&!(f&&m>d))return!1;var I=l.get(t),T=l.get(r);if(I&&T)return I==r&&T==t;var y=-1,$=!0,J=i&Pm?new Yi:void 0;for(l.set(t,r),l.set(r,t);++y<d;){var ne=t[y],re=r[y];if(s)var j=f?s(re,ne,y,r,t,l):s(ne,re,y,t,r,l);if(j!==void 0){if(j)continue;$=!1;break}if(J){if(!xm(r,function(de,et){if(!Sm(J,et)&&(ne===de||o(ne,de,i,s,l)))return J.push(et)})){$=!1;break}}else if(!(ne===re||o(ne,re,i,s,l))){$=!1;break}}return l.delete(t),l.delete(r),$}function Rm(t){var r=-1,i=Array(t.size);return t.forEach(function(s,o){i[++r]=[o,s]}),i}function Dm(t){var r=-1,i=Array(t.size);return t.forEach(function(s){i[++r]=s}),i}var Mm=1,Um=2,km="[object Boolean]",Fm="[object Date]",Cm="[object Error]",Bm="[object Map]",Gm="[object Number]",Vm="[object RegExp]",$m="[object Set]",Wm="[object String]",Xm="[object Symbol]",Hm="[object ArrayBuffer]",qm="[object DataView]",Ec=Gt?Gt.prototype:void 0,Ua=Ec?Ec.valueOf:void 0;function zm(t,r,i,s,o,l,f){switch(i){case qm:if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case Hm:return!(t.byteLength!=r.byteLength||!l(new dc(t),new dc(r)));case km:case Fm:case Gm:return $c(+t,+r);case Cm:return t.name==r.name&&t.message==r.message;case Vm:case Wm:return t==r+"";case Bm:var d=Rm;case $m:var m=s&Mm;if(d||(d=Dm),t.size!=r.size&&!m)return!1;var I=f.get(t);if(I)return I==r;s|=Um,f.set(t,r);var T=tf(d(t),d(r),s,o,l,f);return f.delete(t),T;case Xm:if(Ua)return Ua.call(t)==Ua.call(r)}return!1}var Km=1,Ym=Object.prototype,Jm=Ym.hasOwnProperty;function Qm(t,r,i,s,o,l){var f=i&Km,d=uc(t),m=d.length,I=uc(r),T=I.length;if(m!=T&&!f)return!1;for(var y=m;y--;){var $=d[y];if(!(f?$ in r:Jm.call(r,$)))return!1}var J=l.get(t),ne=l.get(r);if(J&&ne)return J==r&&ne==t;var re=!0;l.set(t,r),l.set(r,t);for(var j=f;++y<m;){$=d[y];var de=t[$],et=r[$];if(s)var ht=f?s(et,de,$,r,t,l):s(de,et,$,t,r,l);if(!(ht===void 0?de===et||o(de,et,i,s,l):ht)){re=!1;break}j||(j=$=="constructor")}if(re&&!j){var Rt=t.constructor,ze=r.constructor;Rt!=ze&&"constructor"in t&&"constructor"in r&&!(typeof Rt=="function"&&Rt instanceof Rt&&typeof ze=="function"&&ze instanceof ze)&&(re=!1)}return l.delete(t),l.delete(r),re}var Zm=1,_c="[object Arguments]",gc="[object Array]",qi="[object Object]",jm=Object.prototype,Nc=jm.hasOwnProperty;function eI(t,r,i,s,o,l){var f=Pt(t),d=Pt(r),m=f?gc:bn(t),I=d?gc:bn(r);m=m==_c?qi:m,I=I==_c?qi:I;var T=m==qi,y=I==qi,$=m==I;if($&&Fa(t)){if(!Fa(r))return!1;f=!0,T=!1}if($&&!T)return l||(l=new rn),f||Kc(t)?tf(t,r,i,s,o,l):zm(t,r,m,i,s,o,l);if(!(i&Zm)){var J=T&&Nc.call(t,"__wrapped__"),ne=y&&Nc.call(r,"__wrapped__");if(J||ne){var re=J?t.value():t,j=ne?r.value():r;return l||(l=new rn),o(re,j,i,s,l)}}return $?(l||(l=new rn),Qm(t,r,i,s,o,l)):!1}function Za(t,r,i,s,o){return t===r?!0:t==null||r==null||!Fn(t)&&!Fn(r)?t!==t&&r!==r:eI(t,r,i,s,Za,o)}var tI=1,nI=2;function rI(t,r,i,s){var o=i.length,l=o;if(t==null)return!l;for(t=Object(t);o--;){var f=i[o];if(f[2]?f[1]!==t[f[0]]:!(f[0]in t))return!1}for(;++o<l;){f=i[o];var d=f[0],m=t[d],I=f[1];if(f[2]){if(m===void 0&&!(d in t))return!1}else{var T=new rn,y;if(!(y===void 0?Za(I,m,tI|nI,s,T):y))return!1}}return!0}function nf(t){return t===t&&!ar(t)}function iI(t){for(var r=Ya(t),i=r.length;i--;){var s=r[i],o=t[s];r[i]=[s,o,nf(o)]}return r}function rf(t,r){return function(i){return i==null?!1:i[t]===r&&(r!==void 0||t in Object(i))}}function sI(t){var r=iI(t);return r.length==1&&r[0][2]?rf(r[0][0],r[0][1]):function(i){return i===t||rI(i,t,r)}}function aI(t,r){return t!=null&&r in Object(t)}function oI(t,r,i){r=Jc(r,t);for(var s=-1,o=r.length,l=!1;++s<o;){var f=as(r[s]);if(!(l=t!=null&&i(t,f)))break;t=t[f]}return l||++s!=o?l:(o=t==null?0:t.length,!!o&&za(o)&&Vc(f,o)&&(Pt(t)||Ka(t)))}function uI(t,r){return t!=null&&oI(t,r,aI)}var lI=1,cI=2;function fI(t,r){return Ja(t)&&nf(r)?rf(as(t),r):function(i){var s=Zc(i,t);return s===void 0&&s===r?uI(i,t):Za(r,s,lI|cI)}}function sf(t){return function(r){return r?.[t]}}function hI(t){return function(r){return Qc(r,t)}}function pI(t){return Ja(t)?sf(as(t)):hI(t)}function af(t){return typeof t=="function"?t:t==null?ns:typeof t=="object"?Pt(t)?fI(t[0],t[1]):sI(t):pI(t)}function dI(t,r,i,s){for(var o=-1,l=t==null?0:t.length;++o<l;){var f=t[o];r(s,f,i(f),t)}return s}function EI(t){return function(r,i,s){for(var o=-1,l=Object(r),f=s(r),d=f.length;d--;){var m=f[++o];if(i(l[m],m,l)===!1)break}return r}}var of=EI();function _I(t,r){return t&&of(t,r,Ya)}function gI(t,r){return function(i,s){if(i==null)return i;if(!rs(i))return t(i,s);for(var o=i.length,l=-1,f=Object(i);++l<o&&s(f[l],l,f)!==!1;);return i}}var NI=gI(_I);function TI(t,r,i,s){return NI(t,function(o,l,f){r(s,o,i(o),f)}),s}function vI(t,r){return function(i,s){var o=Pt(i)?dI:TI,l=r?r():{};return o(i,t,af(s),l)}}function bI(t){return Fn(t)&&rs(t)}function me(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}function mI(t){return typeof t=="function"?t:ns}var II=Math.max,AI=Math.min;function wI(t,r,i){var s=t==null?0:t.length;if(!s)return-1;var o=s-1;return i!==void 0&&(o=iv(i),o=i<0?II(s+o,0):AI(o,s-1)),Sv(t,af(r),o)}function LI(t){return t&&t.length?t[0]:void 0}function Hr(t,r){return t==null?t:of(t,mI(r),Lb)}var ft=vI(function(t,r,i){t[i?0:1].push(r)},function(){return[[],[]]}),yI=Math.max;function xI(t){if(!(t&&t.length))return[];var r=0;return t=ef(t,function(i){if(bI(i))return r=yI(i.length,r),!0}),Xc(r,function(i){return Cc(t,sf(i))})}var Va=Dv(xI),A=(t=>(t.SPACE="<space>",t.TAB="<tab>",t.NEWLINE="<newline>",t.COMMA="<comma>",t.LPAREN="<lparen>",t.RPAREN="<rparen>",t.LBRACE="<lbrace>",t.RBRACE="<rbrace>",t.LBRACKET="<lbracket>",t.RBRACKET="<rbracket>",t.LANGLE="<langle>",t.RANGLE="<rangle>",t.OP="<op>",t.EOF="<eof>",t.NUMERIC_LITERAL="<number>",t.STRING_LITERAL="<string>",t.COLOR_LITERAL="<color>",t.FUNCTION_EXPRESSION="<function-expression>",t.QUOTED_STRING="<variable>",t.IDENTIFIER="<identifier>",t.SEMICOLON="<semicolon>",t.COLON="<colon>",t.SINGLE_LINE_COMMENT="<single-line-comment>",t.MULTILINE_COMMENT="<multiline-comment>",t))(A||{});function SI(t){switch(t.kind){case"<newline>":case"<space>":case"<tab>":case"<single-line-comment>":case"<multiline-comment>":return!0;default:return!1}}function OI(t){if(!t)return!1;switch(t){case"+":case"-":case"*":case"/":case"%":case"<":case">":case"=":case"!":case".":case"&":case"|":case"~":return!0;default:return!1}}function Tc(t){return t!==void 0&&t.kind==="<op>"}class Ze{constructor(r,i,s,o,l){this.kind=r,this.startPos=i,this.endPos=s,this.value=o,this.leadingTrivia=[],this.trailingTrivia=[],this.leadingInvalid=[],this.trailingInvalid=[],this.isInvalid=l,this.start=i.offset,this.end=s.offset}static create(r,i,s,o,l){return new Ze(r,i,s,o,l)}}function uf(t){return t.trailingTrivia.find(({kind:r})=>r===A.NEWLINE)!==void 0}function vc(t,r){return r.leadingTrivia.find(({kind:s})=>s===A.NEWLINE)!==void 0||uf(t)}function $a(t){return t.trailingTrivia.find(({kind:r})=>[A.SPACE,A.TAB].includes(r))!==void 0}function lf(t){return t.trailingTrivia.length===0?t.end:lf(me(t.trailingTrivia))}function cf(t){return t.leadingTrivia.length===0?t.start:cf(t.leadingTrivia[0])}function PI(t){return[A.SINGLE_LINE_COMMENT,A.MULTILINE_COMMENT].includes(t.kind)}class RI{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class Te{constructor(r,i,s){this.id=r,this.kind=i;const o=s.find(f=>f!==void 0&&!Number.isNaN(f.start));o?(this.startPos=o.startPos,this.fullStart=o instanceof Ze?cf(o):o.fullStart):(this.startPos={offset:NaN,column:NaN,line:NaN},this.fullStart=NaN);const l=[...s].reverse().find(f=>f!==void 0&&!Number.isNaN(f.end));l?(this.endPos=l.endPos,this.fullEnd=l instanceof Ze?lf(l):l.fullEnd):(this.endPos={offset:NaN,column:NaN,line:NaN},this.fullEnd=NaN),this.start=this.startPos.offset,this.end=this.endPos.offset}}var kn=(t=>(t.PROGRAM="<program>",t.ELEMENT_DECLARATION="<element-declaration>",t.ATTRIBUTE="<attribute>",t.IDENTIFIER_STREAM="<identifer-stream>",t.LITERAL="<literal>",t.VARIABLE="<variable>",t.PREFIX_EXPRESSION="<prefix-expression>",t.INFIX_EXPRESSION="<infix-expression>",t.POSTFIX_EXPRESSION="<postfix-expression>",t.FUNCTION_EXPRESSION="<function-expression>",t.FUNCTION_APPLICATION="<function-application>",t.BLOCK_EXPRESSION="<block-expression>",t.LIST_EXPRESSION="<list-expression>",t.TUPLE_EXPRESSION="<tuple-expression>",t.CALL_EXPRESSION="<call-expression>",t.PRIMARY_EXPRESSION="<primary-expression>",t.GROUP_EXPRESSION="<group-expression>",t.DUMMY="<dummy>",t.ARRAY="<array>",t))(kn||{});class qe extends Te{constructor({body:r=[],eof:i},s){super(s,"<program>",[...r,i]),this.body=r,this.eof=i}}class se extends Te{constructor({type:r,name:i,as:s,alias:o,attributeList:l,bodyColon:f,body:d},m){if(super(m,"<element-declaration>",[r,i,s,o,l,f,d]),d&&f&&!(d instanceof W||d instanceof se))throw new Error("If an element has a simple body, it must be a function application node");this.type=r,this.name=i,this.as=s,this.alias=o,this.attributeList=l,this.bodyColon=f,this.body=d}}class xt extends Te{constructor({identifiers:r=[]},i){super(i,"<identifer-stream>",r||[]),this.identifiers=r}}class St extends Te{constructor({name:r,colon:i,value:s},o){super(o,"<attribute>",[r,i,s]),this.name=r,this.value=s,this.colon=i}}class je extends Te{constructor({op:r,expression:i},s){super(s,"<prefix-expression>",[r,i]),this.op=r,this.expression=i}}class Vt extends Te{constructor({op:r,leftExpression:i,rightExpression:s},o){super(o,"<infix-expression>",[i,r,s]),this.op=r,this.leftExpression=i,this.rightExpression=s}}class os extends Te{constructor({op:r,expression:i},s){super(s,"<postfix-expression>",[i,r]),this.op=r,this.expression=i}}class bt extends Te{constructor({value:r},i){super(i,"<function-expression>",[r]),this.value=r}}class W extends Te{constructor({callee:r,args:i=[]},s){super(s,"<function-application>",[r,...i]),this.callee=r,this.args=i}}class ke extends Te{constructor({blockOpenBrace:r,body:i=[],blockCloseBrace:s},o){super(o,"<block-expression>",[r,...i,s]),this.blockOpenBrace=r,this.body=i,this.blockCloseBrace=s}}class _e extends Te{constructor({listOpenBracket:r,elementList:i=[],commaList:s=[],listCloseBracket:o},l){super(l,"<list-expression>",[r,...ff(i,s),o]),this.listOpenBracket=r,this.elementList=i,this.commaList=s,this.listCloseBracket=o}}class Wt extends Te{constructor({tupleOpenParen:r,elementList:i=[],commaList:s=[],tupleCloseParen:o},l){super(l,"<tuple-expression>",[r,...ff(i,s),o]),this.tupleOpenParen=r,this.elementList=i,this.commaList=s,this.tupleCloseParen=o}}class ja extends Wt{constructor({groupOpenParen:r,expression:i,groupCloseParen:s},o){super({tupleOpenParen:r,elementList:i&&[i],commaList:[],tupleCloseParen:s},o),this.kind="<group-expression>"}}class He extends Te{constructor({callee:r,argumentList:i},s){super(s,"<call-expression>",[r,i]),this.callee=r,this.argumentList=i}}class cr extends Te{constructor({literal:r},i){super(i,"<literal>",[r]),this.literal=r}}class ln extends Te{constructor({variable:r},i){super(i,"<variable>",[r]),this.variable=r}}class lt extends Te{constructor({expression:r},i){super(i,"<primary-expression>",[r]),this.expression=r}}class Br extends Te{constructor({pre:r},i){const s=Ze.create(A.SPACE,r.endPos,r.endPos," ",!1);super(i,"<dummy>",[s])}}class Bt extends Te{constructor({expression:r,indexer:i},s){super(s,"<array>",[r,i]),this.array=r,this.indexer=i}}function ff(t,r){if(!t||t.length===0)return r||[];if(!r||r.length===0)return t||[];const[i]=t,[s]=r;return(i.start<s.start?ac(Va(t,r)):ac(Va(r,t))).filter(o=>o!==null)}function DI(t,r=!1){return JSON.stringify(t,function(i,s){return!(this instanceof qe)&&i==="symbol"?s?.id:i==="symbol"?{symbolTable:s?.symbolTable,id:s?.id,references:s?.references.map(o=>o.id),declaration:s?.declaration?.id}:i==="referee"||i==="parent"||i==="declaration"?s?.id:i==="symbolTable"?Object.fromEntries(s.table):s},r?2:0)}class MI{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class eo{constructor({symbolTable:r},i){this.references=[],this.id=i,this.symbolTable=r}}class hf{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class pf{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class qr{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class to{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class df{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class Ef{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class _f{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class gf{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class Nf{constructor({declaration:r,tablePartialSymbol:i},s){this.references=[],this.id=s,this.declaration=r,this.tablePartialSymbol=i}}var _=(t=>(t[t.UNKNOWN_SYMBOL=1e3]="UNKNOWN_SYMBOL",t[t.UNEXPECTED_SYMBOL=1001]="UNEXPECTED_SYMBOL",t[t.UNEXPECTED_EOF=1002]="UNEXPECTED_EOF",t[t.UNEXPECTED_NEWLINE=1003]="UNEXPECTED_NEWLINE",t[t.UNKNOWN_TOKEN=1004]="UNKNOWN_TOKEN",t[t.UNEXPECTED_TOKEN=1005]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_ELEMENT_DECLARATION=1006]="UNEXPECTED_ELEMENT_DECLARATION",t[t.MISSING_SPACES=1007]="MISSING_SPACES",t[t.UNKNOWN_PREFIX_OP=1008]="UNKNOWN_PREFIX_OP",t[t.INVALID_OPERAND=1009]="INVALID_OPERAND",t[t.EMPTY_ATTRIBUTE_NAME=1010]="EMPTY_ATTRIBUTE_NAME",t[t.INVALID_ESCAPE_SEQUENCE=1011]="INVALID_ESCAPE_SEQUENCE",t[t.INVALID_NAME=3e3]="INVALID_NAME",t[t.UNEXPECTED_NAME=3001]="UNEXPECTED_NAME",t[t.NAME_NOT_FOUND=3002]="NAME_NOT_FOUND",t[t.DUPLICATE_NAME=3003]="DUPLICATE_NAME",t[t.INVALID_ALIAS=3004]="INVALID_ALIAS",t[t.UNEXPECTED_ALIAS=3005]="UNEXPECTED_ALIAS",t[t.UNEXPECTED_SETTINGS=3006]="UNEXPECTED_SETTINGS",t[t.INVALID_SETTINGS=3007]="INVALID_SETTINGS",t[t.UNEXPECTED_SIMPLE_BODY=3008]="UNEXPECTED_SIMPLE_BODY",t[t.UNEXPECTED_COMPLEX_BODY=3009]="UNEXPECTED_COMPLEX_BODY",t[t.INVALID_TABLE_CONTEXT=3010]="INVALID_TABLE_CONTEXT",t[t.UNKNOWN_TABLE_SETTING=3011]="UNKNOWN_TABLE_SETTING",t[t.DUPLICATE_TABLE_SETTING=3012]="DUPLICATE_TABLE_SETTING",t[t.INVALID_TABLEGROUP_CONTEXT=3013]="INVALID_TABLEGROUP_CONTEXT",t[t.INVALID_TABLEGROUP_ELEMENT_NAME=3014]="INVALID_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME=3015]="DUPLICATE_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_FIELD_NAME=3016]="DUPLICATE_TABLEGROUP_FIELD_NAME",t[t.INVALID_TABLEGROUP_FIELD=3017]="INVALID_TABLEGROUP_FIELD",t[t.EMPTY_TABLE=3018]="EMPTY_TABLE",t[t.INVALID_COLUMN=3019]="INVALID_COLUMN",t[t.INVALID_COLUMN_NAME=3020]="INVALID_COLUMN_NAME",t[t.UNKNOWN_COLUMN_SETTING=3021]="UNKNOWN_COLUMN_SETTING",t[t.INVALID_COLUMN_TYPE=3022]="INVALID_COLUMN_TYPE",t[t.DUPLICATE_COLUMN_NAME=3023]="DUPLICATE_COLUMN_NAME",t[t.DUPLICATE_COLUMN_SETTING=3024]="DUPLICATE_COLUMN_SETTING",t[t.INVALID_COLUMN_SETTING_VALUE=3025]="INVALID_COLUMN_SETTING_VALUE",t[t.INVALID_ENUM_CONTEXT=3026]="INVALID_ENUM_CONTEXT",t[t.INVALID_ENUM_ELEMENT_NAME=3027]="INVALID_ENUM_ELEMENT_NAME",t[t.INVALID_ENUM_ELEMENT=3028]="INVALID_ENUM_ELEMENT",t[t.DUPLICATE_ENUM_ELEMENT_NAME=3029]="DUPLICATE_ENUM_ELEMENT_NAME",t[t.UNKNOWN_ENUM_ELEMENT_SETTING=3030]="UNKNOWN_ENUM_ELEMENT_SETTING",t[t.DUPLICATE_ENUM_ELEMENT_SETTING=3031]="DUPLICATE_ENUM_ELEMENT_SETTING",t[t.INVALID_ENUM_ELEMENT_SETTING=3032]="INVALID_ENUM_ELEMENT_SETTING",t[t.EMPTY_ENUM=3033]="EMPTY_ENUM",t[t.INVALID_REF_CONTEXT=3034]="INVALID_REF_CONTEXT",t[t.UNKNOWN_REF_SETTING=3035]="UNKNOWN_REF_SETTING",t[t.DUPLICATE_REF_SETTING=3036]="DUPLICATE_REF_SETTING",t[t.INVALID_REF_SETTING_VALUE=3037]="INVALID_REF_SETTING_VALUE",t[t.INVALID_REF_RELATIONSHIP=3038]="INVALID_REF_RELATIONSHIP",t[t.INVALID_REF_FIELD=3039]="INVALID_REF_FIELD",t[t.EMPTY_REF=3040]="EMPTY_REF",t[t.REF_REDEFINED=3041]="REF_REDEFINED",t[t.INVALID_NOTE_CONTEXT=3042]="INVALID_NOTE_CONTEXT",t[t.INVALID_NOTE=3043]="INVALID_NOTE",t[t.NOTE_REDEFINED=3044]="NOTE_REDEFINED",t[t.NOTE_CONTENT_REDEFINED=3045]="NOTE_CONTENT_REDEFINED",t[t.EMPTY_NOTE=3046]="EMPTY_NOTE",t[t.INVALID_INDEXES_CONTEXT=3047]="INVALID_INDEXES_CONTEXT",t[t.INVALID_INDEXES_FIELD=3048]="INVALID_INDEXES_FIELD",t[t.INVALID_INDEX=3049]="INVALID_INDEX",t[t.UNKNOWN_INDEX_SETTING=3050]="UNKNOWN_INDEX_SETTING",t[t.DUPLICATE_INDEX_SETTING=3051]="DUPLICATE_INDEX_SETTING",t[t.UNEXPECTED_INDEX_SETTING_VALUE=3052]="UNEXPECTED_INDEX_SETTING_VALUE",t[t.INVALID_INDEX_SETTING_VALUE=3053]="INVALID_INDEX_SETTING_VALUE",t[t.INVALID_PROJECT_CONTEXT=3054]="INVALID_PROJECT_CONTEXT",t[t.PROJECT_REDEFINED=3055]="PROJECT_REDEFINED",t[t.INVALID_PROJECT_FIELD=3056]="INVALID_PROJECT_FIELD",t[t.INVALID_CUSTOM_CONTEXT=3057]="INVALID_CUSTOM_CONTEXT",t[t.INVALID_CUSTOM_ELEMENT_VALUE=3058]="INVALID_CUSTOM_ELEMENT_VALUE",t[t.INVALID_ELEMENT_IN_SIMPLE_BODY=3059]="INVALID_ELEMENT_IN_SIMPLE_BODY",t[t.INVALID_TABLE_PARTIAL_CONTEXT=3060]="INVALID_TABLE_PARTIAL_CONTEXT",t[t.INVALID_TABLE_PARTIAL_ELEMENT_NAME=3061]="INVALID_TABLE_PARTIAL_ELEMENT_NAME",t[t.INVALID_TABLE_PARTIAL_SETTING_VALUE=3062]="INVALID_TABLE_PARTIAL_SETTING_VALUE",t[t.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME=3063]="DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME",t[t.DUPLICATE_TABLE_PARTIAL_SETTING=3064]="DUPLICATE_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_PARTIAL_INJECTION=3065]="INVALID_TABLE_PARTIAL_INJECTION",t[t.INVALID_TABLE_PARTIAL_INJECTION_OP=3066]="INVALID_TABLE_PARTIAL_INJECTION_OP",t[t.INVALID_TABLE_PARTIAL_INJECTION_NAME=3067]="INVALID_TABLE_PARTIAL_INJECTION_NAME",t[t.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME=3068]="DUPLICATE_TABLE_PARTIAL_INJECTION_NAME",t[t.UNKNOWN_TABLE_PARTIAL_SETTING=3069]="UNKNOWN_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_SETTING_VALUE=3070]="INVALID_TABLE_SETTING_VALUE",t[t.INVALID_CHECKS_CONTEXT=3071]="INVALID_CHECKS_CONTEXT",t[t.INVALID_CHECKS_FIELD=3072]="INVALID_CHECKS_FIELD",t[t.INVALID_CHECK=3073]="INVALID_CHECK",t[t.UNKNOWN_CHECK_SETTING=3074]="UNKNOWN_CHECK_SETTING",t[t.DUPLICATE_CHECK_SETTING=3075]="DUPLICATE_CHECK_SETTING",t[t.INVALID_CHECK_SETTING_VALUE=3076]="INVALID_CHECK_SETTING_VALUE",t[t.BINDING_ERROR=4e3]="BINDING_ERROR",t[t.UNSUPPORTED=5e3]="UNSUPPORTED",t[t.CIRCULAR_REF=5001]="CIRCULAR_REF",t[t.SAME_ENDPOINT=5002]="SAME_ENDPOINT",t[t.UNEQUAL_FIELDS_BINARY_REF=5003]="UNEQUAL_FIELDS_BINARY_REF",t[t.CONFLICTING_SETTING=5004]="CONFLICTING_SETTING",t[t.TABLE_REAPPEAR_IN_TABLEGROUP=5005]="TABLE_REAPPEAR_IN_TABLEGROUP",t))(_||{});class g extends Error{constructor(r,i,s){super(i),this.code=r,this.diagnostic=i,this.nodeOrToken=s,this.start=s.start,this.end=s.end,this.name=this.constructor.name,Object.setPrototypeOf(this,g.prototype)}}class ct{constructor(r,i){this.value=r,this.errors=i===void 0?[]:i}getValue(){return this.value}getErrors(){return this.errors}chain(r){const i=r(this.value),s=[...this.errors,...i.errors];return new ct(i.value,s)}map(r){return new ct(r(this.value),this.errors)}}function Yr(t){return!!t.match(new RegExp("(\\p{L}|_|\\p{M})","gu"))}function or(t){if(!t)return!1;const r=t[0];return r>="0"&&r<="9"}function UI(t){const[r]=t;return or(r)||Yr(r)&&r.toLowerCase()>="a"&&r.toLowerCase()<="f"}function Un(t){return Yr(t)||or(t)}function kI(t){return t.split("").every(Un)?t:`"${t}"`}function bc(t,r){const i=[],s=Math.min(t.length,r.length);for(let o=0;o<s;o+=1)i.push(t[o],r[o]);return i.push(...t.slice(s),...r.slice(s)),i}function $r(t,r){return t>=r.start&&t<r.end}function Wa(t){return t instanceof je?`${t.op?.value}${Wa(t.expression)}`:t.expression.literal.value}function Xa(t){return t instanceof je?t.op?.value==="-"?-Xa(t.expression):Xa(t.expression):Number.parseFloat(t.expression.literal.value)}class ye{constructor(r){this.value=r}unwrap(){return this.value}unwrap_or(r){return this.value}and_then(r){return r(this.value)}map(r){return new ye(r(this.value))}isOk(){return!0}}class pe{constructor(){this.value=void 0}unwrap(){throw new Error("Trying to unwrap a None value")}unwrap_or(r){return r}and_then(r){return new pe}map(r){return new pe}isOk(){return!1}}const FI=["null","true","false"],Tf=["-","+"],$t="public";var F=(t=>(t.Table="table",t.Enum="enum",t.Ref="ref",t.Note="note",t.Project="project",t.Indexes="indexes",t.TableGroup="tablegroup",t.TablePartial="tablepartial",t.Check="checks",t))(F||{}),P=(t=>(t.Color="color",t.HeaderColor="headercolor",t.Note="note",t.PK="pk",t.PrimaryKey="primary key",t.Unique="unique",t.Ref="ref",t.NotNull="not null",t.Null="null",t.Increment="increment",t.Default="default",t.Name="name",t.Type="type",t.Check="check",t.Update="update",t.Delete="delete",t))(P||{});class CI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof qe||cn(this.declarationNode.parent).unwrap_or(void 0)!==F.Project?[new g(_.INVALID_CUSTOM_CONTEXT,"A Custom element can only appear in a Project",this.declarationNode)]:[]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"A Custom element shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_NAME,"A Custom element shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Custom element shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof ke)return[new g(_.UNEXPECTED_COMPLEX_BODY,"A Custom element can only have an inline field",r)];const i=[];return Fe(r.callee)||i.push(new g(_.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",r)),r.args.length>0&&i.push(...r.args.map(s=>new g(_.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",s))),i}}var U=(t=>(t.Schema="Schema",t.Table="Table",t.Column="Column",t.TableGroup="TableGroup",t.TableGroupField="TableGroup field",t.Enum="Enum",t.EnumField="Enum field",t.Note="Note",t.TablePartial="TablePartial",t.PartialInjection="PartialInjection",t))(U||{});function Jr(t){return`Schema:${t}`}function ur(t){return`Table:${t}`}function fr(t){return`Column:${t}`}function no(t){return`Enum:${t}`}function ro(t){return`Enum field:${t}`}function io(t){return`TableGroup:${t}`}function so(t){return`TableGroup field:${t}`}function BI(t){return`Note:${t}`}function ao(t){return`TablePartial:${t}`}function oo(t){return`PartialInjection:${t}`}function GI(t,r){switch(r){case"Column":return fr(t);case"Enum":return no(t);case"Enum field":return ro(t);case"Schema":return Jr(t);case"Table":return ur(t);case"TableGroup":return io(t);case"TableGroup field":return so(t);case"TablePartial":return ao(t);case"PartialInjection":return oo(t);default:throw new Error("Unreachable")}}function Qr(t){const[r,i]=t.split(":");return Object.values(U).includes(r)?new ye({name:i,kind:r}):new pe}class Bn{constructor(){this.table=new Map}has(r){return this.table.has(r)}set(r,i){this.table.set(r,i)}get(r,i){return this.table.get(r)||i!==void 0&&this.set(r,i)||i}entries(){return this.table.entries()}forEach(r){return this.table.forEach(r)}}class VI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_PROJECT_CONTEXT,"An Enum can only appear top-level",this.declarationNode)]:[]}validateName(r){return r?vf(r)?[]:[new g(_.INVALID_NAME,"An Enum name must be of the form <enum> or <schema>.<enum>",r)]:[new g(_.NAME_NOT_FOUND,"An Enum must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"An Enum shouldn't have an alias",r)]:[]}registerElement(){const r=[];this.declarationNode.symbol=this.symbolFactory.create(hf,{declaration:this.declarationNode,symbolTable:new Bn});const{name:i}=this.declarationNode,s=Ge(i);if(s.isOk()){const o=s.unwrap(),l=o.pop(),f=us(o,this.publicSymbolTable,this.symbolFactory),d=no(l);f.has(d)&&r.push(new g(_.DUPLICATE_NAME,`Enum name ${l} already exists in schema '${o.join(".")||$t}'`,i)),f.set(d,this.declarationNode.symbol)}return r}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"An Enum shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.length===0?[new g(_.EMPTY_ENUM,"An Enum must have at least one element",this.declarationNode)]:r.flatMap(i=>{const s=[];i.callee&&!we(i.callee)&&s.push(new g(_.INVALID_ENUM_ELEMENT_NAME,"An enum field must be an identifier or a quoted identifier",i.callee));const o=[...i.args];return me(o)instanceof _e?(s.push(...this.validateFieldSettings(me(o))),o.pop()):o[0]instanceof _e&&(s.push(...this.validateFieldSettings(o[0])),o.shift()),o.length>0&&s.push(...o.map(l=>new g(_.INVALID_ENUM_ELEMENT,"An Enum must have only a field and optionally a setting list",l))),s.push(...this.registerField(i)),s})}validateFieldSettings(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"note":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_ENUM_ELEMENT_SETTING,"'note' can only appear once",d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_ENUM_ELEMENT_SETTING,"'note' must be a string",d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_ENUM_ELEMENT_SETTING,`Unknown enum field setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=ro(i),o=this.symbolFactory.create(pf,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${i}`,f.declaration)]}l.set(s,o)}return[]}}class $I{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const r=new g(_.INVALID_INDEXES_CONTEXT,"An Indexes can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof qe)return[r];const i=cn(this.declarationNode.parent).unwrap_or(void 0);return i&&[F.Table,F.TablePartial].includes(i)?[]:[r]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"An Indexes shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"An Indexes shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"An Indexes shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"An Indexes must have a complex body",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];return me(o)instanceof _e&&s.push(...this.validateFieldSetting(o.pop())),o.forEach(l=>{for(;l instanceof He;)l.argumentList&&!Qi(l.argumentList).isOk()&&s.push(new g(_.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",l.argumentList)),l=l.callee;Qi(l).isOk()||s.push(new g(_.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",l))}),s})}validateFieldSetting(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"note":case"name":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'${l}' must be a string`,d))});break;case"unique":case"pk":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{ot(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'${l}' must not have a value`,d))});break;case"type":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,"'type' can only appear once",d))),f.forEach(d=>{we(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'type' must be "btree" or "hash"`,d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_INDEX_SETTING,`Unknown index setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class WI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return!(this.declarationNode.parent instanceof qe)&&![F.Table,F.TableGroup,F.TablePartial,F.Project].includes(cn(this.declarationNode.parent).unwrap_or(void 0))?[new g(_.INVALID_NOTE_CONTEXT,"A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",this.declarationNode)]:[]}validateName(r){if(!(this.declarationNode.parent instanceof qe))return r?[new g(_.UNEXPECTED_NAME,"A Note shouldn't have a name",r)]:[];if(!r)return[new g(_.INVALID_NAME,"Sticky note must have a name",this.declarationNode)];const i=Ge(r);if(!i.isOk())return[new g(_.INVALID_NAME,"Invalid name for sticky note ",this.declarationNode)];const o=i.unwrap().join("."),l=BI(o);return this.publicSymbolTable.has(l)?[new g(_.DUPLICATE_NAME,`Sticky note "${o}" has already been defined`,r)]:(this.publicSymbolTable.set(l,this.declarationNode.symbol),[])}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Note shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){const i=[];return r.length===0?[new g(_.EMPTY_NOTE,"A Note must have a content",this.declarationNode)]:(r.length>1&&r.slice(1).forEach(s=>i.push(new g(_.NOTE_CONTENT_REDEFINED,"A Note can only contain one string",s))),Fe(r[0].callee)||i.push(new g(_.INVALID_NOTE,"A Note content must be a quoted string",r[0])),r[0].args.length>0&&i.push(...r[0].args.map(s=>new g(_.INVALID_NOTE,"A Note can only contain one quoted string",s))),i)}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class XI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_PROJECT_CONTEXT,"A Project can only appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A Project's name is optional or must be an identifier or a quoted identifer",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Project shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Project shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Project's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...i.map(o=>new g(_.INVALID_PROJECT_FIELD,"A Project can not have inline fields",o)),...this.validateSubElements(s)]}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class HI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof qe?[]:[new g(_.INVALID_REF_CONTEXT,"A Ref must appear top-level",this.declarationNode)]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A Ref's name is optional or must be an identifier or a quoted identifer",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Ref shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){if(r.length===0)return[new g(_.EMPTY_REF,"A Ref must have at least one field",this.declarationNode)];const i=[];return r.length>1&&i.push(...r.slice(1).map(s=>new g(_.REF_REDEFINED,"A Ref can only contain one binary relationship",s))),r.forEach(s=>{if(s.callee&&!mc(s.callee)&&i.push(new g(_.INVALID_REF_FIELD,"A Ref field must be a binary relationship",s.callee)),s.callee&&mc(s.callee)){const l=ut(s.callee.leftExpression).unwrap_or({variables:[],tupleElements:[]}),f=l.variables.length+Math.min(l.tupleElements.length,1),d=ut(s.callee.rightExpression).unwrap_or({variables:[],tupleElements:[]}),m=d.variables.length+Math.min(d.tupleElements.length,1);f<2&&i.push(new g(_.INVALID_REF_FIELD,"Invalid column reference",s.callee.leftExpression||s.callee)),m<2&&i.push(new g(_.INVALID_REF_FIELD,"Invalid column reference",s.callee.rightExpression||s.callee))}s.callee&&!eA(s.callee)&&i.push(new g(_.UNEQUAL_FIELDS_BINARY_REF,"Unequal fields in ref endpoints",s.callee));const o=[...s.args];if(me(o)instanceof _e){const l=this.validateFieldSettings(me(o));i.push(...l),o.pop()}else o[0]instanceof _e&&(i.push(...this.validateFieldSettings(o[0])),o.shift());o.length>0&&i.push(...o.map(l=>new g(_.INVALID_REF_FIELD,"A Ref field should only have a single binary relationship",l)))}),i}validateFieldSettings(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"delete":case"update":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_REF_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{qI(d.value)||s.push(new g(_.INVALID_REF_SETTING_VALUE,`'${l}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`,d))});break;case"color":f.length>1&&s.push(...f.map(d=>new g(_.DUPLICATE_REF_SETTING,"'color' can only appear once",d))),f.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_REF_SETTING_VALUE,"'color' must be a color literal",d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_REF_SETTING,`Unknown ref setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}function qI(t){if(!(we(t)&&t.expression.variable.kind!==A.QUOTED_STRING)&&!(t instanceof xt))return!1;let r;if(t instanceof xt?r=zr(t).unwrap_or(""):r=t.expression.variable.value,r)switch(r.toLowerCase()){case"cascade":case"no action":case"set null":case"set default":case"restrict":return!0;default:return!1}return!1}class zI{constructor(r,i,s){this.declarationNode=r,this.symbolFactory=s,this.publicSymbolTable=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLE_CONTEXT,"Table must appear top-level",this.declarationNode)]:[]}validateName(r){return r?r instanceof Bt?[new g(_.INVALID_NAME,"Invalid array as Table name, maybe you forget to add a space between the name and the setting list?",r)]:vf(r)?[]:[new g(_.INVALID_NAME,"A Table name must be of the form <table> or <schema>.<table>",r)]:[new g(_.NAME_NOT_FOUND,"A Table must have a name",this.declarationNode)]}validateAlias(r){return r?ZI(r)?[]:[new g(_.INVALID_ALIAS,"Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes",r)]:[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case P.HeaderColor:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'headercolor' can only appear once",d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'headercolor' must be a color literal",d.value||d.name))});break;case P.Note:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'note' can only appear once",d))),l.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_SETTING,`Unknown '${f}' setting`,d)))}}),s}registerElement(){const r=[];this.declarationNode.symbol=this.symbolFactory.create(qr,{declaration:this.declarationNode,symbolTable:new Bn});const{name:i,alias:s}=this.declarationNode,o=Ge(i);if(o.isOk()){const l=[...o.unwrap()],f=l.pop(),d=us(l,this.publicSymbolTable,this.symbolFactory),m=ur(f);d.has(m)&&r.push(new g(_.DUPLICATE_NAME,`Table name '${f}' already exists in schema '${l.join(".")||$t}'`,i)),d.set(m,this.declarationNode.symbol)}if(s&&hr(s)&&!KI(s.expression.variable.value,o.unwrap_or([]))){const l=Me(s).unwrap(),f=ur(l);this.publicSymbolTable.has(f)&&r.push(new g(_.DUPLICATE_NAME,`Table name '${l}' already exists`,i)),this.publicSymbolTable.set(f,this.declarationNode.symbol)}return r}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Table's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){const i=o=>{const l=[];if(!o.callee)return[];o.args.length===0&&l.push(new g(_.INVALID_COLUMN,"A column must have a type",o.callee)),we(o.callee)||l.push(new g(_.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",o.callee)),o.args[0]&&!Af(o.args[0])&&l.push(new g(_.INVALID_COLUMN_TYPE,"Invalid column type",o.args[0]));const f=o.args.slice(1);return l.push(...this.validateFieldSetting(f)),l.push(...this.registerField(o)),l},s=o=>{const l=[];if(!o.callee)return[];if(!Ji(o.callee))l.push(new g(_.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection should be of the form ~<table-partial>",o.callee));else{const f=Pe(o.callee.expression).unwrap_or(""),d=this.symbolFactory.create(gf,{symbolTable:new Bn,declaration:o}),m=oo(f),I=this.declarationNode.symbol.symbolTable;if(I.has(m)){const T=I.get(m);return[new g(_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${f}'`,o),new g(_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${f}'`,T.declaration)]}I.set(m,d)}return o.args.length&&l.push(...o.args.map(f=>new g(_.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection does not have any trailing attributes",f))),l};return r.flatMap(o=>o.callee instanceof je&&o.callee.op?.value==="~"?s(o):i(o))}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=fr(i),o=this.symbolFactory.create(to,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,f.declaration)]}l.set(s,o)}return[]}validateFieldSetting(r){if(!r.slice(0,-1).every(In)||!r.slice(-1).every(m=>In(m)||m instanceof _e))return[...r.map(m=>new g(_.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",m))];if(r.length===0)return[];let i;me(r)instanceof _e&&(i=r.pop());const s=Ne(i),o=s.getErrors(),l=s.getValue();r.forEach(m=>{const I=Me(m).unwrap_or("").toLowerCase();if(I!=="pk"&&I!=="unique"){o.push(new g(_.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",m));return}l[I]===void 0?l[I]=[m]:l[I].push(m)});const f=l[P.PK]||[],d=l[P.PrimaryKey]||[];return f.length>=1&&d.length>=1&&o.push(...[...f,...d].map(m=>new g(_.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",m))),Hr(l,(m,I)=>{switch(I){case P.Note:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"note can only appear once",T))),m.forEach(T=>{Fe(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'note' must be a quoted string",T.value||T.name))});break;case P.Ref:m.forEach(T=>{If(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'ref' must be a valid unary relationship",T.value||T.name))});break;case P.PrimaryKey:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"primary key can only appear once",T))),m.forEach(T=>{ot(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'primary key' must not have a value",T.value||T.name))});break;case P.PK:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'pk' can only appear once",T))),m.forEach(T=>{T instanceof St&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'pk' must not have a value",T.value||T.name))});break;case P.NotNull:{m.length>1&&o.push(...m.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,"'not null' can only appear once",y)));const T=l[P.Null]||[];m.length>=1&&T.length>=1&&o.push(...[...m,...T].map(y=>new g(_.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",y))),m.forEach(y=>{ot(y.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'not null' must not have a value",y.value||y.name))});break}case P.Null:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'null' can only appear once",T))),m.forEach(T=>{ot(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'null' must not have a value",T.value||T.name))});break;case P.Unique:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'unique' can only appear once",T))),m.forEach(T=>{T instanceof St&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'unique' must not have a value",T.value||T.name))});break;case P.Increment:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'increment' can only appear once",T))),m.forEach(T=>{T instanceof St&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'increment' must not have a value",T.value||T.name))});break;case P.Default:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'default' can only appear once",T))),m.forEach(T=>{mf(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'default' must be an enum value, a string literal, number literal, function expression, true, false or null",T.value||T.name))});break;case P.Check:m.forEach(T=>{T.value instanceof bt||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",T.value||T.name))});break;default:m.forEach(T=>o.push(new g(_.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${I}'`,T)))}}),o}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()==="note");return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}}function KI(t,r){return r.length===1&&t===r[0]}class YI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLEGROUP_CONTEXT,"TableGroup must appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A TableGroup name must be a single identifier",r)]:[new g(_.NAME_NOT_FOUND,"A TableGroup must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A TableGroup shouldn't have an alias",r)]:[]}registerElement(){const{name:r}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(df,{declaration:this.declarationNode,symbolTable:new Bn});const i=Ge(r);if(i.isOk()){const s=i.unwrap(),o=s.pop(),l=us(s,this.publicSymbolTable,this.symbolFactory),f=io(o);if(l.has(f))return[new g(_.DUPLICATE_NAME,`TableGroup name '${o}' already exists`,r)];l.set(f,this.declarationNode.symbol)}return[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case"color":l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'color' can only appear once",d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'color' must be a color literal",d.value||d.name))});break;case"note":l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'note' can only appear once",d))),l.filter(d=>!Fe(d.value)).forEach(d=>{s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_SETTING,`Unknown '${f}' setting`,d)));break}}),s}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A TableGroup's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{const s=[];return i.callee&&!Ge(i.callee).isOk()&&s.push(new g(_.INVALID_TABLEGROUP_FIELD,"A TableGroup field must be of the form <table> or <schema>.<table>",i.callee)),this.registerField(i),i.args.length>0&&s.push(...i.args.map(o=>new g(_.INVALID_TABLEGROUP_FIELD,"A TableGroup field should only have a single Table name",o))),s})}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()==="note");return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=so(i),o=this.symbolFactory.create(Ef,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_TABLEGROUP_FIELD_NAME,`${i} already exists in the group`,r),new g(_.DUPLICATE_TABLEGROUP_FIELD_NAME,`${i} already exists in the group`,f.declaration)]}l.set(s,o)}return[]}}class JI{constructor(r,i,s){this.declarationNode=r,this.symbolFactory=s,this.publicSymbolTable=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLE_PARTIAL_CONTEXT,"TablePartial must appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A TablePartial name must be an identifier or a quoted identifer",r)]:[new g(_.NAME_NOT_FOUND,"A TablePartial must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A TablePartial shouldn't have an alias",r)]:[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case P.HeaderColor:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_PARTIAL_SETTING,`'${f}' can only appear once`,d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${f}' must be a color literal`,d.value||d.name))});break;case P.Note:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_PARTIAL_SETTING,`'${f}' can only appear once`,d))),l.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${f}' must be a string literal`,d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_PARTIAL_SETTING,`Unknown '${f}' setting`,d)))}}),s}registerElement(){const{name:r}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(_f,{declaration:this.declarationNode,symbolTable:new Bn});const i=Ge(r);if(!i.isOk())return[];const s=i.unwrap(),o=s.pop(),l=us(s,this.publicSymbolTable,this.symbolFactory),f=ao(o);return l.has(f)?[new g(_.DUPLICATE_NAME,`TablePartial name '${o}' already exists`,r)]:(l.set(f,this.declarationNode.symbol),[])}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A TablePartial's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[];i.args.length===0&&s.push(new g(_.INVALID_COLUMN,"A column must have a type",i.callee)),we(i.callee)||s.push(new g(_.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",i.callee)),i.args[0]&&!Af(i.args[0])&&s.push(new g(_.INVALID_COLUMN_TYPE,"Invalid column type",i.args[0]));const o=i.args.slice(1);return s.push(...this.validateFieldSetting(o),...this.registerField(i)),s})}registerField(r){if(!r.callee||!we(r.callee))return[];const i=Me(r.callee).unwrap(),s=fr(i),o=this.symbolFactory.create(to,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,f.declaration)]}return l.set(s,o),[]}validateFieldSetting(r){const i=me(r);if(!r.slice(0,-1).every(In)||!(In(i)||i instanceof _e))return[...r.map(I=>new g(_.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",I))];if(r.length===0)return[];let s;me(r)instanceof _e&&(s=r.pop());const o=Ne(s),l=o.getErrors(),f=o.getValue();r.forEach(I=>{const T=Me(I).unwrap_or("").toLowerCase();if(T!==P.PK&&T!==P.Unique){l.push(new g(_.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",I));return}f[T]===void 0?f[T]=[I]:f[T].push(I)});const d=f[P.PK]||[],m=f[P.PrimaryKey]||[];return d.length>=1&&m.length>=1&&l.push(...[...d,...m].map(I=>new g(_.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",I))),Hr(f,(I,T)=>{switch(T){case P.Note:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{Fe(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a quoted string`,y.value||y.name))});break;case P.Ref:I.forEach(y=>{If(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a valid unary relationship`,y.value||y.name))});break;case P.PrimaryKey:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{ot(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.PK:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof St&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.NotNull:{I.length>1&&l.push(...I.map($=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,$)));const y=f[P.Null]||[];I.length>=1&&y.length>=1&&l.push(...[...I,...y].map($=>new g(_.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",$))),I.forEach($=>{ot($.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,$.value||$.name))});break}case P.Null:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{ot(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Unique:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof St&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Increment:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof St&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Default:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{mf(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a string literal, number literal, function expression, true, false or null`,y.value||y.name))});break;case P.Check:I.forEach(y=>{y.value instanceof bt||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",y.value||y.name))});break;default:I.forEach(y=>l.push(new g(_.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${T}'`,y)))}}),l}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()===F.Note);return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}}class QI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const r=new g(_.INVALID_CHECKS_CONTEXT,"A Checks can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof qe)return[r];const i=cn(this.declarationNode.parent).unwrap_or(void 0);return i&&[F.Table,F.TablePartial].includes(i)?[]:[r]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"A Checks shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Checks shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Checks shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Checks must have a complex body",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];return me(o)instanceof _e&&s.push(...this.validateFieldSetting(o.pop())),(o.length>1||!(o[0]instanceof bt))&&s.push(new g(_.INVALID_CHECKS_FIELD,"A check field must be a function expression",i)),s})}validateFieldSetting(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"name":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_CHECK_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_CHECK_SETTING_VALUE,`'${l}' must be a string`,d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_CHECK_SETTING,`Unknown check setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}function Xt(t){switch(t.type.value.toLowerCase()){case F.Enum:return VI;case F.Table:return zI;case F.TableGroup:return YI;case F.Project:return XI;case F.Ref:return HI;case F.Note:return WI;case F.Indexes:return $I;case F.TablePartial:return JI;case F.Check:return QI;default:return CI}}function vf(t){return!!Ge(t).unwrap_or(!1)}function ZI(t){return hr(t)}function hr(t){return t instanceof lt&&t.expression instanceof ln}function Ji(t){return t instanceof je&&t.op?.value==="~"&&we(t.expression)}function us(t,r,i){t[0]===$t&&(t=t.slice(1));let s=r;for(const o of t){let l;const f=Jr(o);if(s.has(f)){if(l=s.get(f)?.symbolTable,!l)throw new Error("Expect a symbol table in a schema symbol")}else{l=new Bn;const d=i.create(eo,{symbolTable:l});s.set(f,d)}s=l}return s}function bf(t){return t==="-"||t==="<>"||t===">"||t==="<"}function ls(t){if(!(t instanceof lt)||!(t.expression instanceof cr)||t.expression.literal?.kind!==A.COLOR_LITERAL)return!1;const r=t.expression.literal.value;if(r.length!==4&&r.length!==7||r[0]!=="#")return!1;for(let i=1;i<r.length;i+=1)if(!UI(r[i]))return!1;return!0}function ot(t){return t===void 0}function mf(t){if(Fe(t)||mn(t)||In(t)&&["true","false","null"].includes(t.expression.variable.value.toLowerCase())||t instanceof je&&Tf.includes(t.op?.value)&&mn(t.expression)||t instanceof bt)return!0;if(!t||!lo(t))return!1;const r=An(t).unwrap();return r.length===2||r.length===3}function mn(t){return t instanceof je?Tf.includes(t.op.value)?mn(t.expression):!1:t instanceof lt&&t.expression instanceof cr&&t.expression.literal?.kind===A.NUMERIC_LITERAL}function If(t){if(!(t instanceof je)||!bf(t.op?.value))return!1;const r=Ge(t.expression).unwrap_or(void 0);return r!==void 0&&r.length>0}function jI(t){return t instanceof Wt&&t.elementList.every(we)}function Af(t){if(!(t instanceof He||uo(t)||t instanceof lt||t instanceof Bt))return!1;for(;t instanceof He||t instanceof Bt;)if(t instanceof He){if(t.callee===void 0||t.argumentList===void 0||!t.argumentList.elementList.every(i=>mn(i)||Fe(i)||In(i)))return!1;t=t.callee}else if(t instanceof Bt){if(t.array===void 0||t.indexer===void 0||!t.indexer.elementList.every(i=>!i.colon&&!i.value&&mn(i.name)))return!1;t=t.array}const r=Ge(t).unwrap_or(void 0);return r!==void 0&&r.length>0}function Ne(t){const r={},i=[];return t?(t.elementList.forEach(s=>{if(!s.name)return;if(s.name instanceof lt){i.push(new g(_.INVALID_SETTINGS,"A setting name must be a stream of identifiers",s.name));return}const o=zr(s.name).unwrap_or(void 0)?.toLowerCase();o&&(r[o]===void 0?r[o]=[s]:r[o].push(s))}),new ct(r,i)):new ct({})}function cn(t){const r=t?.type?.value.toLowerCase();switch(r){case F.Enum:case F.Table:case F.Indexes:case F.Note:case F.Project:case F.Ref:case F.TableGroup:case F.TablePartial:case F.Check:return new ye(r);default:return new pe}}function An(t){if(!t)return new pe;if(!uo(t))return new ye([t]);const r=An(t.leftExpression).unwrap_or(void 0);return r?(r.push(t.rightExpression),new ye(r)):new pe}function Ge(t){if(t===void 0)return new pe;const r=An(t).unwrap_or(void 0);if(!r)return new pe;const i=[];for(const s of r){const o=Pe(s).unwrap_or(void 0);if(typeof o!="string")return new pe;i.push(o)}return new ye(i)}function ut(t){if(t===void 0)return new pe;const r=An(t).unwrap_or(void 0);if(!r||r.length===0)return new pe;let i=[];if(!we(me(r))){const o=r.pop();if(jI(o))i=o.elementList;else return new pe}const s=r;return s.every(we)?new ye({variables:s,tupleElements:i}):new pe}function Pe(t){return we(t)?new ye(t.expression.variable.value):new pe}function Qi(t){if(Ic(t))return t instanceof bt?new ye({functional:[t],nonFunctional:[]}):new ye({functional:[],nonFunctional:[t]});if(t instanceof Wt&&t.elementList.every(Ic)){const r=t.elementList.filter(s=>s instanceof bt),i=t.elementList.filter(we);return new ye({functional:r,nonFunctional:i})}return new pe}function Me(t){const r=t?.expression.variable?.value;return r===void 0?new pe:new ye(r)}function Le(t){return Fe(t)?t.expression instanceof ln?new ye(t.expression.variable.value):new ye(t.expression.literal.value):new pe}function mc(t){return!(t instanceof Vt)||!bf(t.op?.value)?!1:ut(t.leftExpression).and_then(()=>ut(t.rightExpression)).unwrap_or(void 0)!==void 0}function eA(t){const r=ut(t.leftExpression),i=ut(t.rightExpression);if(!r.isOk()||!i.isOk())return!1;const{tupleElements:s}=r.unwrap(),{tupleElements:o}=i.unwrap();return s?.length===o?.length}function Ic(t){return t instanceof lt&&t.expression instanceof ln||t instanceof bt}function tA(t,r,i){if(!t||!In(t)||r.length===0)return new pe;const s=[...r],o=Ac(t).unwrap(),l=s.pop();if(!(l instanceof ke))return new pe;const f=me(s)instanceof _e?s.pop():void 0;if(s.length===3){const d=Ac(s[1]).value;return!d||!Ha(d)?new pe:new ye(i.create(se,{type:o,name:s[0],as:d,alias:s[2],attributeList:f,body:l}))}return s.length===1?new ye(i.create(se,{type:o,name:s[0],attributeList:f,body:l})):s.length===0?new ye(i.create(se,{type:o,attributeList:f,body:l})):new pe}function Ha(t){return t?.kind===A.IDENTIFIER&&t.value.toLowerCase()==="as"}function C(t){t&&(t instanceof Ze?nA(t):rA(t))}function nA(t){t.kind!==A.EOF&&(t.isInvalid=!0)}function rA(t){if(t instanceof se)C(t.type),C(t.name),C(t.as),C(t.alias),C(t.bodyColon),C(t.attributeList),C(t.body);else if(t instanceof xt)t.identifiers.forEach(C);else if(t instanceof St)C(t.name),C(t.colon),C(t.value);else if(t instanceof je)C(t.op),C(t.expression);else if(t instanceof Vt)C(t.leftExpression),C(t.op),C(t.rightExpression);else if(t instanceof os)C(t.op),C(t.expression);else if(t instanceof ke)C(t.blockOpenBrace),t.body.forEach(C),C(t.blockCloseBrace);else if(t instanceof _e)C(t.listOpenBracket),t.commaList.forEach(C),t.elementList.forEach(C),C(t.listCloseBracket);else if(t instanceof Wt)C(t.tupleOpenParen),t.commaList.forEach(C),t.elementList.forEach(C),C(t.tupleCloseParen);else if(t instanceof He)C(t.callee),C(t.argumentList);else if(t instanceof W)C(t.callee),t.args.forEach(C);else if(t instanceof lt)C(t.expression);else if(t instanceof bt)C(t.value);else if(t instanceof ln)C(t.variable);else if(t instanceof cr)C(t.literal);else{if(t instanceof ja)throw new Error("This case is handled by the TupleExpressionNode case");if(t instanceof Bt)C(t.array),C(t.indexer);else if(t instanceof qe)t.body.forEach(C),C(t.eof);else if(!(t instanceof Br))throw new Error("Unreachable case in markInvalidNode")}}function qa(t){return!!t?.isInvalid}function Xe(...t){return t.filter(r=>r!==void 0)}function iA(t){if(t instanceof qe)return Xe(...t.body,t.eof);if(t instanceof se)return Xe(t.type,t.name,t.as,t.alias,t.attributeList,t.bodyColon,t.body);if(t instanceof St)return Xe(t.name,t.colon,t.value);if(t instanceof xt)return t.identifiers;if(t instanceof cr)return t.literal?[t.literal]:[];if(t instanceof ln)return Xe(t.variable);if(t instanceof je)return Xe(t.op,t.expression);if(t instanceof Vt)return Xe(t.leftExpression,t.op,t.rightExpression);if(t instanceof os)return Xe(t.expression,t.op);if(t instanceof bt)return Xe(t.value);if(t instanceof W)return Xe(t.callee,...t.args);if(t instanceof ke)return Xe(t.blockOpenBrace,...t.body,t.blockCloseBrace);if(t instanceof _e)return Xe(t.listOpenBracket,...bc(t.elementList,t.commaList),t.listCloseBracket);if(t instanceof Wt)return Xe(t.tupleOpenParen,...bc(t.elementList,t.commaList),t.tupleCloseParen);if(t instanceof He)return Xe(t.callee,t.argumentList);if(t instanceof lt)return Xe(t.expression);if(t instanceof Bt)return Xe(t.array,t.indexer);throw t instanceof ja?new Error("This case is already handled by TupleExpressionNode"):new Error("Unreachable - no other possible cases")}function Ac(t){return we(t)?new ye(t.expression.variable):new pe}function Fe(t){return t instanceof lt&&(t.expression instanceof ln&&t.expression.variable instanceof Ze&&t.expression.variable.kind===A.QUOTED_STRING||t.expression instanceof cr&&t.expression.literal?.kind===A.STRING_LITERAL)}function we(t){return t instanceof lt&&t.expression instanceof ln&&t.expression.variable instanceof Ze}function In(t){return t instanceof lt&&t.expression instanceof ln&&t.expression.variable?.kind===A.IDENTIFIER}function uo(t){return t instanceof Vt&&t.leftExpression instanceof Te&&t.rightExpression instanceof Te&&t.op?.value==="."}function lo(t){return we(t)?!0:uo(t)&&we(t.rightExpression)&&lo(t.leftExpression)}function zr(t){if(t===void 0)return new pe;const r=t.identifiers.map(i=>i.value).join(" ");return r===""?new pe:new ye(r)}function sA(t){return Ge(t.name).map(r=>r.join("."))}class aA{constructor(r){this.start={offset:0,line:0,column:0},this.current={offset:0,line:0,column:0},this.tokens=[],this.errors=[],this.text=r}isAtEnd(){return this.current.offset>=this.text.length}advance(){const r=this.peek();return this.current={...this.current},r===`
2
+ `?(this.current.line+=1,this.current.column=0):this.current.column+=1,this.current.offset+=1,r}peek(r=0){if(!(this.current.offset+r>=this.text.length))return this.text[this.current.offset+r]}check(r){for(let i=0;i<r.length;i+=1)if(r[i]!==this.peek(i))return!1;return!0}match(r){return this.check(r)?(r.split("").forEach(()=>this.advance()),!0):!1}addToken(r,i=!1){this.tokens.push(this.createToken(r,i))}createToken(r,i=!1){return Ze.create(r,this.start,this.current,this.text.substring(this.start.offset,this.current.offset),i)}lex(){return this.scanTokens(),this.tokens.push(Ze.create(A.EOF,this.start,this.current,"",!1)),this.gatherTrivia(),this.gatherInvalid(),new ct(this.tokens,this.errors)}scanTokens(){for(;!this.isAtEnd();){const r=this.advance();switch(r){case" ":this.addToken(A.SPACE);break;case"\r":break;case`
3
+ `:this.addToken(A.NEWLINE);break;case" ":this.addToken(A.TAB);break;case",":this.addToken(A.COMMA);break;case"(":this.addToken(A.LPAREN);break;case")":this.addToken(A.RPAREN);break;case"[":this.addToken(A.LBRACKET);break;case"]":this.addToken(A.RBRACKET);break;case"{":this.addToken(A.LBRACE);break;case"}":this.addToken(A.RBRACE);break;case";":this.addToken(A.SEMICOLON);break;case":":this.addToken(A.COLON);break;case"'":this.match("''")?this.multilineStringLiteral():this.singleLineStringLiteral();break;case'"':this.quotedVariable();break;case"`":this.functionExpression();break;case"#":this.colorLiteral();break;case"/":this.match("/")?this.singleLineComment():this.match("*")?this.multilineComment():this.operator(r);break;default:if(OI(r)){this.operator(r);break}if(Yr(r)){this.identifier();break}if(or(r)){this.numericLiteralOrIdentifier();break}this.addToken(A.OP,!0),this.errors.push(new g(_.UNKNOWN_SYMBOL,`Unexpected token '${r}'`,this.createToken(A.OP,!0)));break}this.start={...this.current}}}gatherTrivia(){let r=!0,i=[],s;const o=[];for(const l of this.tokens)SI(l)?(i.push(l),l.kind===A.NEWLINE&&s&&(s.trailingTrivia=i,r=!0,s=void 0,i=[])):(r?l.leadingTrivia=i:s.trailingTrivia=i,o.push(l),i=[],s=l,r=!1);this.tokens=o}gatherInvalid(){let r;const i=[],s=[];for(r=0;r<this.tokens.length&&qa(this.tokens[r]);r+=1)s.push(this.tokens[r]);let o=this.tokens[r];for(o.leadingInvalid=[...s,...o.leadingInvalid];r<this.tokens.length;r+=1){const l=this.tokens[r];qa(l)?o.trailingInvalid.push(l):(o=l,i.push(l))}this.tokens=i}consumeUntil(r,i,{allowNewline:s,allowEof:o,raw:l,consumeStopSequence:f=!0}){let d="";for(;!this.isAtEnd()&&(s||!this.check(`
4
4
  `))&&!this.check(i);)this.peek()==="\\"&&!l?(this.advance(),d+=this.escapedString()):d+=this.advance();if(this.isAtEnd()&&!o){const m=this.createToken(r,!0);this.tokens.push(m),this.errors.push(new g(_.UNEXPECTED_EOF,"EOF reached while parsing",m));return}if(this.check(`
5
5
  `)&&!s){const m=this.createToken(r,!0);this.tokens.push(m),this.errors.push(new g(_.UNEXPECTED_NEWLINE,"Invalid newline encountered while parsing",m));return}f&&this.match(i),this.tokens.push(Ze.create(r,this.start,this.current,d,!1))}singleLineStringLiteral(){this.consumeUntil(A.STRING_LITERAL,"'",{allowNewline:!1,allowEof:!1,raw:!1})}multilineStringLiteral(){this.consumeUntil(A.STRING_LITERAL,"'''",{allowNewline:!0,allowEof:!1,raw:!1})}functionExpression(){this.consumeUntil(A.FUNCTION_EXPRESSION,"`",{allowNewline:!0,allowEof:!1,raw:!0})}quotedVariable(){this.consumeUntil(A.QUOTED_STRING,'"',{allowNewline:!1,allowEof:!1,raw:!1})}singleLineComment(){this.consumeUntil(A.SINGLE_LINE_COMMENT,`
6
6
  `,{allowNewline:!0,allowEof:!0,raw:!0,consumeStopSequence:!1})}multilineComment(){this.consumeUntil(A.MULTILINE_COMMENT,"*/",{allowNewline:!0,allowEof:!1,raw:!0})}identifier(){for(;!this.isAtEnd()&&Un(this.peek());)this.advance();this.addToken(A.IDENTIFIER)}operator(r){switch(r){case"<":[">","="].includes(this.peek())&&this.advance();break;case">":this.peek()==="="&&this.advance();break;case"=":this.peek()==="="&&this.advance();break;case"!":this.peek()==="="&&this.advance();break}this.addToken(A.OP)}numericLiteralOrIdentifier(){let r=0;if(this.isAtEnd())return this.addToken(A.NUMERIC_LITERAL);for(;!this.isAtEnd();){const i=this.check(".");if(r+=i?1:0,r>1)break;if(!i&&this.current.offset===this.text.length-1)return this.advance(),this.addToken(A.NUMERIC_LITERAL);if(!i&&!Un(this.peek()))return this.addToken(A.NUMERIC_LITERAL);if(!i&&!or(this.peek()))break;this.advance()}if(r>0){for(;!this.isAtEnd()&&(this.check(".")||Un(this.peek()));)this.advance();const i=this.createToken(A.NUMERIC_LITERAL,!0);this.tokens.push(i),this.errors.push(new g(_.UNKNOWN_TOKEN,"Invalid number",i))}else{for(;!this.isAtEnd()&&Un(this.peek());)this.advance();const i=this.createToken(A.IDENTIFIER,!1);this.tokens.push(i)}}colorLiteral(){for(;!this.isAtEnd()&&Un(this.peek());)this.advance();this.addToken(A.COLOR_LITERAL)}escapedString(){const r={column:this.current.column-1,offset:this.current.offset-1,line:this.current.line};if(this.isAtEnd())return"\\";switch(this.advance()){case"\r":return this.check(`
7
7
  `)&&this.advance(),"";case`
8
8
  `:return"";case"t":return" ";case"n":return`
9
- `;case"\\":return"\\";case"r":return"\r";case"'":return"'";case'"':return'"';case"`":return"`";case"0":return"\0";case"b":return"\b";case"v":return"\v";case"f":return"\f";case" ":return"\\ ";case"u":{let i="";for(let s=0;s<=3;s+=1){if(this.isAtEnd()||!Un(this.peek()))return this.errors.push(new g(_.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${i}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Ze.create(A.STRING_LITERAL,r,this.current,`\\u${i}`,!0))),`\\u${i}`;i+=this.advance()}return String.fromCharCode(parseInt(i,16))}default:return this.text[this.current.offset-1]}}}var Ki=(t=>(t[t.ListExpression=0]="ListExpression",t[t.GroupExpression=1]="GroupExpression",t[t.BlockExpression=2]="BlockExpression",t))(Ki||{});class oA{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(r){this.stack.push(r),r===0&&(this.numberOfNestedLBrackets+=1),r===1&&(this.numberOfNestedLParens+=1),r===2&&(this.numberOfNestedLBraces+=1)}pop(){const r=this.stack.pop();return r===0&&(this.numberOfNestedLBrackets-=1),r===1&&(this.numberOfNestedLParens-=1),r===2&&(this.numberOfNestedLBraces-=1),r}top(){return me(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(r,i){return()=>{this.push(r);try{return i()}finally{this.pop()}}}findHandlerContext(r,i){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let s=i;s<r.length-1;s+=1)switch(r[s].kind){case A.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(l=>[1,0].includes(l));break;case A.RPAREN:if(this.isWithinGroupExpressionContext())return 1;break;case A.RBRACE:if(this.isWithinBlockExpressionContext())return 2;break;case A.RBRACKET:if(this.isWithinListExpressionContext())return 0;break}}}class uA{constructor(r){this.generator=r}create(r,i){return new r(i,this.generator.nextId())}}class M{constructor(r,i,s){this.token=r,this.partialNode=i,this.handlerContext=s}}class lA{constructor(r,i){this.current=0,this.errors=[],this.contextStack=new oA,this.synchronizeProgram=()=>{const s=this.peek();s.kind!==A.EOF?C(this.advance()):this.logError(s,_.UNEXPECTED_EOF,"Unexpected EOF")},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){const s=this.peek();if(Ha(s)||this.check(A.COLON,A.LBRACE,A.LBRACKET))break;C(s),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COLON,A.LBRACE,A.LBRACKET))break;C(s),this.advance()}},this.blockExpression=this.contextStack.withContextDo(Ki.BlockExpression,()=>{const s={body:[]},o=()=>this.nodeFactory.create(ke,s);try{this.consume("Expect an opening brace '{'",A.LBRACE),s.blockOpenBrace=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(A.RBRACE);)try{s.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(l){if(!(l instanceof M))throw l;if(s.body.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}try{this.consume("Expect a closing brace '}'",A.RBRACE),s.blockCloseBrace=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}return o()}),this.synchronizeBlock=()=>{if(!this.check(A.RBRACE))for(C(this.advance());!this.isAtEnd();){const s=this.peek();if(this.check(A.RBRACE)||vc(this.previous(),s))break;C(s),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(Ki.GroupExpression,()=>{const s={elementList:[],commaList:[]},o=()=>this.nodeFactory.create(ja,{groupOpenParen:s.tupleOpenParen,groupCloseParen:s.tupleCloseParen,expression:s.elementList[0]}),l=()=>this.nodeFactory.create(Wt,s);try{this.consume("Expect an opening parenthesis '('",A.LPAREN),s.tupleOpenParen=this.previous()}catch(f){if(!(f instanceof M))throw f;if(!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(A.RPAREN))try{s.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof M))throw f;if(s.elementList.push(f.partialNode),!this.canHandle(f))throw new M(f.token,o(),f.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(A.RPAREN);)try{this.consume("Expect a comma ','",A.COMMA),s.commaList.push(this.previous()),s.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof M))throw f;if(f.partialNode instanceof Te&&s.elementList.push(f.partialNode),!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}try{this.consume("Expect a closing parenthesis ')'",A.RPAREN),s.tupleCloseParen=this.previous()}catch(f){if(!(f instanceof M))throw f;if(!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}return s.elementList.length===1?o():l()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.RPAREN,A.COMMA))break;C(s),this.advance()}},this.listExpression=this.contextStack.withContextDo(Ki.ListExpression,()=>{const s={elementList:[],commaList:[]},o=()=>this.nodeFactory.create(_e,s);try{this.consume("Expect an opening bracket '['",A.LBRACKET),s.listOpenBracket=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(A.RBRACKET))try{s.elementList.push(this.attribute())}catch(l){if(!(l instanceof M))throw l;if(s.elementList.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(A.RBRACKET);)try{this.consume("Expect a comma ','",A.COMMA),s.commaList.push(this.previous()),s.elementList.push(this.attribute())}catch(l){if(!(l instanceof M))throw l;if(l.partialNode instanceof Te&&s.elementList.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}try{this.consume("Expect a closing bracket ']'",A.RBRACKET),s.listCloseBracket=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}return o()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET))break;C(s),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET,A.COLON))break;C(s),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET))break;C(s),this.advance()}},this.tokens=r,this.nodeFactory=new uA(i)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===A.EOF}advance(){return this.isAtEnd()?me(this.tokens):this.tokens[this.current++]}peek(r=0){return r+this.current>=this.tokens.length?me(this.tokens):this.tokens[this.current+r]}match(...r){const i=this.check(...r);return i&&this.advance(),i}check(...r){const i=this.peek();return r.includes(i.kind)}previous(){return this.tokens[this.current-1]}canHandle(r){return r.handlerContext===void 0||r.handlerContext===this.contextStack.top()}consume(r,...i){if(!this.match(...i))throw this.logError(this.peek(),_.UNEXPECTED_TOKEN,r),new M(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(r,...i){if(this.isAtEnd()||!this.check(...i)){for(C(this.peek()),this.logError(this.advance(),_.UNEXPECTED_TOKEN,r);!this.isAtEnd()&&!this.check(...i);)C(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){const r=[],i=[];let s,o=0;for(;o<this.tokens.length&&this.tokens[o].isInvalid;o+=1)i.push(this.tokens[o]);for(s=this.tokens[o],s.leadingInvalid=[...i,...s.leadingInvalid],r.push(s),o+=1;o<this.tokens.length;o+=1){const l=this.tokens[o];l.isInvalid?s.trailingInvalid.push(l):(s=l,r.push(s))}this.tokens=r}parse(){const r=this.program(),i=this.advance(),s=this.nodeFactory.create(qe,{body:r,eof:i});return this.gatherInvalid(),new lt({ast:s,tokens:this.tokens},this.errors)}program(){const r=[];for(;!this.isAtEnd();)try{const i=this.elementDeclaration();r.push(i)}catch(i){if(!(i instanceof M))throw i;r.push(i.partialNode),this.synchronizeProgram()}return r}elementDeclaration(){const r={},i=()=>this.nodeFactory.create(se,r);try{this.consume("Expect an identifier",A.IDENTIFIER),r.type=this.previous()}catch(s){throw s instanceof M?new M(s.token,i(),s.handlerContext):s}if(!this.check(A.COLON,A.LBRACE,A.LBRACKET))try{r.name=this.normalExpression()}catch(s){if(!(s instanceof M))throw s;if(r.name=s.partialNode,!this.canHandle(s))throw new M(s.token,i(),s.handlerContext);this.synchronizeElementDeclarationName()}if(Ha(this.peek()))if(r.as=this.advance(),this.check(A.COLON,A.LBRACE,A.LBRACKET))this.logError(this.peek(),_.UNEXPECTED_TOKEN,"Expect an alias");else try{r.alias=this.normalExpression()}catch(s){if(!(s instanceof M))throw s;if(r.alias=s.partialNode,!this.canHandle(s))throw new M(s.token,i(),s.handlerContext);this.synchronizeElementDeclarationAlias()}try{r.attributeList=this.check(A.LBRACKET)?this.listExpression():void 0}catch(s){throw s instanceof M?(r.attributeList=s.partialNode,new M(s.token,i(),s.handlerContext)):s}if(!this.discardUntil("Expect an opening brace '{' or a colon ':'",A.LBRACE,A.COLON))return i();try{if(this.match(A.COLON)){r.bodyColon=this.previous();const s=this.expression();s instanceof se?(C(s),this.logError(s,_.UNEXPECTED_ELEMENT_DECLARATION,"An element's simple body must not be an element declaration")):r.body=s}else r.body=this.blockExpression()}catch(s){throw s instanceof M?(r.body=s.partialNode,new M(s.token,i(),s.handlerContext)):s}return this.nodeFactory.create(se,r)}fieldDeclaration(){const r={},i=()=>this.nodeFactory.create(se,r);try{this.consume("Expect an identifier",A.IDENTIFIER),r.type=this.previous()}catch(s){throw s instanceof M?(r.type=s.partialNode,new M(s.token,i(),s.handlerContext)):s}try{this.consume("Expect a colon ':'",A.COLON),r.bodyColon=this.previous()}catch(s){throw s instanceof M?(r.bodyColon=s.partialNode,new M(s.token,i(),s.handlerContext)):s}try{const s=this.expression();s instanceof se?this.errors.push(new g(_.INVALID_ELEMENT_IN_SIMPLE_BODY,"Simple body cannot be an element declaration",s)):r.body=s}catch(s){throw s instanceof M?(r.body=s.partialNode,new M(s.token,i(),s.handlerContext)):s}return this.nodeFactory.create(se,r)}expression(){const r={args:[]},i=()=>tA(r.callee,r.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(W,r));try{r.callee=this.normalExpression()}catch(o){throw o instanceof M?(r.callee=o.partialNode,new M(o.token,i(),o.handlerContext)):o}if(this.shouldStopExpression())return i();let s=r.callee;for(;!this.shouldStopExpression();){$a(this.previous())||this.logError(s,_.MISSING_SPACES,"Expect a following space");try{s=this.normalExpression(),r.args.push(s)}catch(o){throw o instanceof M?(s=o.partialNode,r.args.push(s),new M(o.token,i(),o.handlerContext)):o}}return i()}shouldStopExpression(){if(this.isAtEnd()||of(this.previous()))return!0;const r=this.peek().kind;return r===A.RBRACE||r===A.RBRACKET||r===A.RPAREN||r===A.COMMA||r===A.COLON}normalExpression(){return this.expression_bp(0)}expression_bp(r){let i=this.leftExpression_bp();for(;!this.isAtEnd();){const s=this.peek();if(s.kind===A.LPAREN){const{left:o}=Ac(s);if(o<r||vc(this.previous(),s)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{i=this.nodeFactory.create(He,{callee:i,argumentList:this.tupleExpression()})}catch(l){throw l instanceof M?(i=this.nodeFactory.create(He,{callee:i,argumentList:l.partialNode}),new M(l.token,i,l.handlerContext)):l}}else if(s.kind===A.LBRACKET){if($a(this.previous()))break;try{i=this.nodeFactory.create(Bt,{expression:i,indexer:this.listExpression()})}catch(o){throw o instanceof M?(i=this.nodeFactory.create(Bt,{expression:i,indexer:o.partialNode}),new M(o.token,i,o.handlerContext)):o}}else if(Tc(s)){const o=s,l=Ac(o);if(l.left!==null){if(l.left<=r)break;this.advance(),i=this.nodeFactory.create(os,{expression:i,op:o})}else{const f=fA(o);if(f.left===null||f.left<=r)break;this.advance();try{i=this.nodeFactory.create(Vt,{leftExpression:i,op:o,rightExpression:o.value==="."?this.extractOperand():this.expression_bp(f.right)})}catch(d){throw d instanceof M?(i=this.nodeFactory.create(Vt,{leftExpression:i,op:o,rightExpression:d.partialNode}),new M(d.token,i,d.handlerContext)):d}}}else break}return i}leftExpression_bp(){let r;if(Tc(this.peek())){const i={};i.op=this.peek();const s=pA(i.op);if(s.right===null)throw this.logError(i.op,_.UNKNOWN_PREFIX_OP,`Unexpected '${i.op.value}' in an expression`),new M(i.op,this.nodeFactory.create(Br,{pre:i.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{i.expression=this.expression_bp(s.right)}catch(o){throw o instanceof M?(i.expression=o.partialNode,new M(o.token,this.nodeFactory.create(je,i),o.handlerContext)):o}r=this.nodeFactory.create(je,i)}else if(r=this.extractOperand(),r instanceof Br)throw new M(this.peek(),this.nodeFactory.create(Br,{pre:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return r}extractOperand(){return this.check(A.NUMERIC_LITERAL,A.STRING_LITERAL,A.COLOR_LITERAL,A.QUOTED_STRING,A.IDENTIFIER)?this.primaryExpression():this.check(A.FUNCTION_EXPRESSION)?this.functionExpression():this.check(A.LBRACKET)?this.listExpression():this.check(A.LBRACE)?this.blockExpression():this.check(A.LPAREN)?this.tupleExpression():(this.peek().kind===A.EOF?this.logError(this.peek(),_.UNEXPECTED_EOF,"Unexpected EOF"):this.logError(this.peek(),_.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(Br,{pre:this.previous()}))}functionExpression(){const r={};try{this.consume("Expect a function expression",A.FUNCTION_EXPRESSION),r.value=this.previous()}catch(i){throw i instanceof M?new M(i.token,this.nodeFactory.create(vt,r),i.handlerContext):i}return this.nodeFactory.create(vt,r)}canBeField(){return this.peek().kind===A.IDENTIFIER&&this.peek(1).kind===A.COLON}primaryExpression(){if(this.match(A.COLOR_LITERAL,A.STRING_LITERAL,A.NUMERIC_LITERAL))return this.nodeFactory.create(ut,{expression:this.nodeFactory.create(cr,{literal:this.previous()})});if(this.match(A.QUOTED_STRING,A.IDENTIFIER))return this.nodeFactory.create(ut,{expression:this.nodeFactory.create(ln,{variable:this.previous()})});throw this.logError(this.peek(),_.UNEXPECTED_TOKEN,"Expect a variable or literal"),new M(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){const r={};if(this.check(A.COLON,A.RBRACKET,A.COMMA)){const i=this.peek();this.logError(i,_.EMPTY_ATTRIBUTE_NAME,"Expect a non-empty attribute name"),r.name=this.nodeFactory.create(yt,{identifiers:[]})}else try{r.name=this.attributeName()}catch(i){if(!(i instanceof M))throw i;if(r.name=i.partialNode,!this.canHandle(i))throw new M(i.token,this.nodeFactory.create(xt,r),i.handlerContext);this.synchronizeAttributeName()}return this.match(A.COLON)&&(r.colon=this.previous(),r.value=this.attributeValue()),this.nodeFactory.create(xt,r)}attributeValue(){let r;try{r=this.peek().kind===A.IDENTIFIER&&this.peek(1).kind===A.IDENTIFIER?this.attributeName():this.normalExpression()}catch(i){if(!(i instanceof M)||!this.canHandle(i))throw i;r=i.partialNode,this.synchronizeAttributeValue()}return r}attributeName(){const r=[];if(this.peek().kind!==A.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(A.COLON,A.COMMA,A.RBRACKET);)try{this.consume("Expect an identifier",A.IDENTIFIER),r.push(this.previous())}catch(i){throw i instanceof M?new M(i.token,this.nodeFactory.create(yt,{identifiers:r}),i.handlerContext):i}return this.nodeFactory.create(yt,{identifiers:r})}logError(r,i,s){this.errors.push(new g(i,s,r))}}const cA={"+":{left:9,right:10},"*":{left:11,right:12},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function fA(t){return cA[t.value]||{left:null,right:null}}const hA={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function pA(t){return hA[t.value]||{left:null,right:null}}const dA={"(":{left:14,right:null}};function Ac(t){return dA[t.value]||{left:null,right:null}}class wc{constructor(r,i){this.ast=r,this.symbolFactory=i,this.publicSchemaSymbol=this.symbolFactory.create(eo,{symbolTable:new Bn}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){const r=[];this.ast.body.forEach(s=>{if(s.parent=this.ast,s.type===void 0)return;const o=Xt(s),l=new o(s,this.publicSchemaSymbol.symbolTable,this.symbolFactory);r.push(...l.validate())});const i=this.ast.body.filter(s=>cn(s).unwrap_or(void 0)===F.Project);return i.length>1&&i.forEach(s=>r.push(new g(_.PROJECT_REDEFINED,"Only one project can exist",s))),new lt(this.ast,r)}}class EA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return[]}}class _A{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class gA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof W);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}var zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Gr={exports:{}};var NA=Gr.exports,Lc;function TA(){return Lc||(Lc=1,function(t,r){(function(){var i,s="4.17.21",o=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",d="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",I=500,T="__lodash_placeholder__",y=1,$=2,J=4,ne=1,re=2,j=1,de=2,et=4,ft=8,Rt=16,ze=32,dr=64,qt=128,Er=256,fs=512,Vf=30,$f="...",Wf=800,Xf=16,po=1,Hf=2,qf=3,wn=1/0,fn=9007199254740991,zf=17976931348623157e292,jr=NaN,Dt=4294967295,Kf=Dt-1,Yf=Dt>>>1,Jf=[["ary",qt],["bind",j],["bindKey",de],["curry",ft],["curryRight",Rt],["flip",fs],["partial",ze],["partialRight",dr],["rearg",Er]],Wn="[object Arguments]",ei="[object Array]",Qf="[object AsyncFunction]",_r="[object Boolean]",gr="[object Date]",Zf="[object DOMException]",ti="[object Error]",ni="[object Function]",Eo="[object GeneratorFunction]",bt="[object Map]",Nr="[object Number]",jf="[object Null]",zt="[object Object]",_o="[object Promise]",eh="[object Proxy]",Tr="[object RegExp]",mt="[object Set]",vr="[object String]",ri="[object Symbol]",th="[object Undefined]",br="[object WeakMap]",nh="[object WeakSet]",mr="[object ArrayBuffer]",Xn="[object DataView]",hs="[object Float32Array]",ps="[object Float64Array]",ds="[object Int8Array]",Es="[object Int16Array]",_s="[object Int32Array]",gs="[object Uint8Array]",Ns="[object Uint8ClampedArray]",Ts="[object Uint16Array]",vs="[object Uint32Array]",rh=/\b__p \+= '';/g,ih=/\b(__p \+=) '' \+/g,sh=/(__e\(.*?\)|\b__t\)) \+\n'';/g,go=/&(?:amp|lt|gt|quot|#39);/g,No=/[&<>"']/g,ah=RegExp(go.source),oh=RegExp(No.source),uh=/<%-([\s\S]+?)%>/g,lh=/<%([\s\S]+?)%>/g,To=/<%=([\s\S]+?)%>/g,ch=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,fh=/^\w*$/,hh=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bs=/[\\^$.*+?()[\]{}|]/g,ph=RegExp(bs.source),ms=/^\s+/,dh=/\s/,Eh=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,_h=/\{\n\/\* \[wrapped with (.+)\] \*/,gh=/,? & /,Nh=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Th=/[()=,{}\[\]\/\s]/,vh=/\\(\\)?/g,bh=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vo=/\w*$/,mh=/^[-+]0x[0-9a-f]+$/i,Ih=/^0b[01]+$/i,Ah=/^\[object .+?Constructor\]$/,wh=/^0o[0-7]+$/i,Lh=/^(?:0|[1-9]\d*)$/,yh=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ii=/($^)/,xh=/['\n\r\u2028\u2029\\]/g,si="\\ud800-\\udfff",Sh="\\u0300-\\u036f",Oh="\\ufe20-\\ufe2f",Ph="\\u20d0-\\u20ff",bo=Sh+Oh+Ph,mo="\\u2700-\\u27bf",Io="a-z\\xdf-\\xf6\\xf8-\\xff",Rh="\\xac\\xb1\\xd7\\xf7",Dh="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Mh="\\u2000-\\u206f",Uh=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ao="A-Z\\xc0-\\xd6\\xd8-\\xde",wo="\\ufe0e\\ufe0f",Lo=Rh+Dh+Mh+Uh,Is="['’]",kh="["+si+"]",yo="["+Lo+"]",ai="["+bo+"]",xo="\\d+",Fh="["+mo+"]",So="["+Io+"]",Oo="[^"+si+Lo+xo+mo+Io+Ao+"]",As="\\ud83c[\\udffb-\\udfff]",Ch="(?:"+ai+"|"+As+")",Po="[^"+si+"]",ws="(?:\\ud83c[\\udde6-\\uddff]){2}",Ls="[\\ud800-\\udbff][\\udc00-\\udfff]",Hn="["+Ao+"]",Ro="\\u200d",Do="(?:"+So+"|"+Oo+")",Bh="(?:"+Hn+"|"+Oo+")",Mo="(?:"+Is+"(?:d|ll|m|re|s|t|ve))?",Uo="(?:"+Is+"(?:D|LL|M|RE|S|T|VE))?",ko=Ch+"?",Fo="["+wo+"]?",Gh="(?:"+Ro+"(?:"+[Po,ws,Ls].join("|")+")"+Fo+ko+")*",Vh="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",$h="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Co=Fo+ko+Gh,Wh="(?:"+[Fh,ws,Ls].join("|")+")"+Co,Xh="(?:"+[Po+ai+"?",ai,ws,Ls,kh].join("|")+")",Hh=RegExp(Is,"g"),qh=RegExp(ai,"g"),ys=RegExp(As+"(?="+As+")|"+Xh+Co,"g"),zh=RegExp([Hn+"?"+So+"+"+Mo+"(?="+[yo,Hn,"$"].join("|")+")",Bh+"+"+Uo+"(?="+[yo,Hn+Do,"$"].join("|")+")",Hn+"?"+Do+"+"+Mo,Hn+"+"+Uo,$h,Vh,xo,Wh].join("|"),"g"),Kh=RegExp("["+Ro+si+bo+wo+"]"),Yh=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Jh=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Qh=-1,fe={};fe[hs]=fe[ps]=fe[ds]=fe[Es]=fe[_s]=fe[gs]=fe[Ns]=fe[Ts]=fe[vs]=!0,fe[Wn]=fe[ei]=fe[mr]=fe[_r]=fe[Xn]=fe[gr]=fe[ti]=fe[ni]=fe[bt]=fe[Nr]=fe[zt]=fe[Tr]=fe[mt]=fe[vr]=fe[br]=!1;var ce={};ce[Wn]=ce[ei]=ce[mr]=ce[Xn]=ce[_r]=ce[gr]=ce[hs]=ce[ps]=ce[ds]=ce[Es]=ce[_s]=ce[bt]=ce[Nr]=ce[zt]=ce[Tr]=ce[mt]=ce[vr]=ce[ri]=ce[gs]=ce[Ns]=ce[Ts]=ce[vs]=!0,ce[ti]=ce[ni]=ce[br]=!1;var Zh={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},jh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ep={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},tp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},np=parseFloat,rp=parseInt,Bo=typeof zi=="object"&&zi&&zi.Object===Object&&zi,ip=typeof self=="object"&&self&&self.Object===Object&&self,Re=Bo||ip||Function("return this")(),xs=r&&!r.nodeType&&r,Ln=xs&&!0&&t&&!t.nodeType&&t,Go=Ln&&Ln.exports===xs,Ss=Go&&Bo.process,ht=function(){try{var v=Ln&&Ln.require&&Ln.require("util").types;return v||Ss&&Ss.binding&&Ss.binding("util")}catch{}}(),Vo=ht&&ht.isArrayBuffer,$o=ht&&ht.isDate,Wo=ht&&ht.isMap,Xo=ht&&ht.isRegExp,Ho=ht&&ht.isSet,qo=ht&&ht.isTypedArray;function tt(v,L,w){switch(w.length){case 0:return v.call(L);case 1:return v.call(L,w[0]);case 2:return v.call(L,w[0],w[1]);case 3:return v.call(L,w[0],w[1],w[2])}return v.apply(L,w)}function sp(v,L,w,D){for(var X=-1,ie=v==null?0:v.length;++X<ie;){var xe=v[X];L(D,xe,w(xe),v)}return D}function pt(v,L){for(var w=-1,D=v==null?0:v.length;++w<D&&L(v[w],w,v)!==!1;);return v}function ap(v,L){for(var w=v==null?0:v.length;w--&&L(v[w],w,v)!==!1;);return v}function zo(v,L){for(var w=-1,D=v==null?0:v.length;++w<D;)if(!L(v[w],w,v))return!1;return!0}function hn(v,L){for(var w=-1,D=v==null?0:v.length,X=0,ie=[];++w<D;){var xe=v[w];L(xe,w,v)&&(ie[X++]=xe)}return ie}function oi(v,L){var w=v==null?0:v.length;return!!w&&qn(v,L,0)>-1}function Os(v,L,w){for(var D=-1,X=v==null?0:v.length;++D<X;)if(w(L,v[D]))return!0;return!1}function Ee(v,L){for(var w=-1,D=v==null?0:v.length,X=Array(D);++w<D;)X[w]=L(v[w],w,v);return X}function pn(v,L){for(var w=-1,D=L.length,X=v.length;++w<D;)v[X+w]=L[w];return v}function Ps(v,L,w,D){var X=-1,ie=v==null?0:v.length;for(D&&ie&&(w=v[++X]);++X<ie;)w=L(w,v[X],X,v);return w}function op(v,L,w,D){var X=v==null?0:v.length;for(D&&X&&(w=v[--X]);X--;)w=L(w,v[X],X,v);return w}function Rs(v,L){for(var w=-1,D=v==null?0:v.length;++w<D;)if(L(v[w],w,v))return!0;return!1}var up=Ds("length");function lp(v){return v.split("")}function cp(v){return v.match(Nh)||[]}function Ko(v,L,w){var D;return w(v,function(X,ie,xe){if(L(X,ie,xe))return D=ie,!1}),D}function ui(v,L,w,D){for(var X=v.length,ie=w+(D?1:-1);D?ie--:++ie<X;)if(L(v[ie],ie,v))return ie;return-1}function qn(v,L,w){return L===L?mp(v,L,w):ui(v,Yo,w)}function fp(v,L,w,D){for(var X=w-1,ie=v.length;++X<ie;)if(D(v[X],L))return X;return-1}function Yo(v){return v!==v}function Jo(v,L){var w=v==null?0:v.length;return w?Us(v,L)/w:jr}function Ds(v){return function(L){return L==null?i:L[v]}}function Ms(v){return function(L){return v==null?i:v[L]}}function Qo(v,L,w,D,X){return X(v,function(ie,xe,ue){w=D?(D=!1,ie):L(w,ie,xe,ue)}),w}function hp(v,L){var w=v.length;for(v.sort(L);w--;)v[w]=v[w].value;return v}function Us(v,L){for(var w,D=-1,X=v.length;++D<X;){var ie=L(v[D]);ie!==i&&(w=w===i?ie:w+ie)}return w}function ks(v,L){for(var w=-1,D=Array(v);++w<v;)D[w]=L(w);return D}function pp(v,L){return Ee(L,function(w){return[w,v[w]]})}function Zo(v){return v&&v.slice(0,nu(v)+1).replace(ms,"")}function nt(v){return function(L){return v(L)}}function Fs(v,L){return Ee(L,function(w){return v[w]})}function Ir(v,L){return v.has(L)}function jo(v,L){for(var w=-1,D=v.length;++w<D&&qn(L,v[w],0)>-1;);return w}function eu(v,L){for(var w=v.length;w--&&qn(L,v[w],0)>-1;);return w}function dp(v,L){for(var w=v.length,D=0;w--;)v[w]===L&&++D;return D}var Ep=Ms(Zh),_p=Ms(jh);function gp(v){return"\\"+tp[v]}function Np(v,L){return v==null?i:v[L]}function zn(v){return Kh.test(v)}function Tp(v){return Yh.test(v)}function vp(v){for(var L,w=[];!(L=v.next()).done;)w.push(L.value);return w}function Cs(v){var L=-1,w=Array(v.size);return v.forEach(function(D,X){w[++L]=[X,D]}),w}function tu(v,L){return function(w){return v(L(w))}}function dn(v,L){for(var w=-1,D=v.length,X=0,ie=[];++w<D;){var xe=v[w];(xe===L||xe===T)&&(v[w]=T,ie[X++]=w)}return ie}function li(v){var L=-1,w=Array(v.size);return v.forEach(function(D){w[++L]=D}),w}function bp(v){var L=-1,w=Array(v.size);return v.forEach(function(D){w[++L]=[D,D]}),w}function mp(v,L,w){for(var D=w-1,X=v.length;++D<X;)if(v[D]===L)return D;return-1}function Ip(v,L,w){for(var D=w+1;D--;)if(v[D]===L)return D;return D}function Kn(v){return zn(v)?wp(v):up(v)}function It(v){return zn(v)?Lp(v):lp(v)}function nu(v){for(var L=v.length;L--&&dh.test(v.charAt(L)););return L}var Ap=Ms(ep);function wp(v){for(var L=ys.lastIndex=0;ys.test(v);)++L;return L}function Lp(v){return v.match(ys)||[]}function yp(v){return v.match(zh)||[]}var xp=function v(L){L=L==null?Re:Yn.defaults(Re.Object(),L,Yn.pick(Re,Jh));var w=L.Array,D=L.Date,X=L.Error,ie=L.Function,xe=L.Math,ue=L.Object,Bs=L.RegExp,Sp=L.String,dt=L.TypeError,ci=w.prototype,Op=ie.prototype,Jn=ue.prototype,fi=L["__core-js_shared__"],hi=Op.toString,oe=Jn.hasOwnProperty,Pp=0,ru=function(){var e=/[^.]+$/.exec(fi&&fi.keys&&fi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),pi=Jn.toString,Rp=hi.call(ue),Dp=Re._,Mp=Bs("^"+hi.call(oe).replace(bs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),di=Go?L.Buffer:i,En=L.Symbol,Ei=L.Uint8Array,iu=di?di.allocUnsafe:i,_i=tu(ue.getPrototypeOf,ue),su=ue.create,au=Jn.propertyIsEnumerable,gi=ci.splice,ou=En?En.isConcatSpreadable:i,Ar=En?En.iterator:i,yn=En?En.toStringTag:i,Ni=function(){try{var e=Rn(ue,"defineProperty");return e({},"",{}),e}catch{}}(),Up=L.clearTimeout!==Re.clearTimeout&&L.clearTimeout,kp=D&&D.now!==Re.Date.now&&D.now,Fp=L.setTimeout!==Re.setTimeout&&L.setTimeout,Ti=xe.ceil,vi=xe.floor,Gs=ue.getOwnPropertySymbols,Cp=di?di.isBuffer:i,uu=L.isFinite,Bp=ci.join,Gp=tu(ue.keys,ue),Se=xe.max,Ce=xe.min,Vp=D.now,$p=L.parseInt,lu=xe.random,Wp=ci.reverse,Vs=Rn(L,"DataView"),wr=Rn(L,"Map"),$s=Rn(L,"Promise"),Qn=Rn(L,"Set"),Lr=Rn(L,"WeakMap"),yr=Rn(ue,"create"),bi=Lr&&new Lr,Zn={},Xp=Dn(Vs),Hp=Dn(wr),qp=Dn($s),zp=Dn(Qn),Kp=Dn(Lr),mi=En?En.prototype:i,xr=mi?mi.valueOf:i,cu=mi?mi.toString:i;function h(e){if(ve(e)&&!H(e)&&!(e instanceof Z)){if(e instanceof Et)return e;if(oe.call(e,"__wrapped__"))return fl(e)}return new Et(e)}var jn=function(){function e(){}return function(n){if(!ge(n))return{};if(su)return su(n);e.prototype=n;var a=new e;return e.prototype=i,a}}();function Ii(){}function Et(e,n){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}h.templateSettings={escape:uh,evaluate:lh,interpolate:To,variable:"",imports:{_:h}},h.prototype=Ii.prototype,h.prototype.constructor=h,Et.prototype=jn(Ii.prototype),Et.prototype.constructor=Et;function Z(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Dt,this.__views__=[]}function Yp(){var e=new Z(this.__wrapped__);return e.__actions__=Ke(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ke(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ke(this.__views__),e}function Jp(){if(this.__filtered__){var e=new Z(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Qp(){var e=this.__wrapped__.value(),n=this.__dir__,a=H(e),u=n<0,c=a?e.length:0,p=lE(0,c,this.__views__),E=p.start,N=p.end,b=N-E,x=u?N:E-1,S=this.__iteratees__,O=S.length,R=0,k=Ce(b,this.__takeCount__);if(!a||!u&&c==b&&k==b)return Mu(e,this.__actions__);var G=[];e:for(;b--&&R<k;){x+=n;for(var K=-1,V=e[x];++K<O;){var Q=S[K],ee=Q.iteratee,st=Q.type,We=ee(V);if(st==Hf)V=We;else if(!We){if(st==po)continue e;break e}}G[R++]=V}return G}Z.prototype=jn(Ii.prototype),Z.prototype.constructor=Z;function xn(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function Zp(){this.__data__=yr?yr(null):{},this.size=0}function jp(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function ed(e){var n=this.__data__;if(yr){var a=n[e];return a===m?i:a}return oe.call(n,e)?n[e]:i}function td(e){var n=this.__data__;return yr?n[e]!==i:oe.call(n,e)}function nd(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=yr&&n===i?m:n,this}xn.prototype.clear=Zp,xn.prototype.delete=jp,xn.prototype.get=ed,xn.prototype.has=td,xn.prototype.set=nd;function Kt(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function rd(){this.__data__=[],this.size=0}function id(e){var n=this.__data__,a=Ai(n,e);if(a<0)return!1;var u=n.length-1;return a==u?n.pop():gi.call(n,a,1),--this.size,!0}function sd(e){var n=this.__data__,a=Ai(n,e);return a<0?i:n[a][1]}function ad(e){return Ai(this.__data__,e)>-1}function od(e,n){var a=this.__data__,u=Ai(a,e);return u<0?(++this.size,a.push([e,n])):a[u][1]=n,this}Kt.prototype.clear=rd,Kt.prototype.delete=id,Kt.prototype.get=sd,Kt.prototype.has=ad,Kt.prototype.set=od;function Yt(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function ud(){this.size=0,this.__data__={hash:new xn,map:new(wr||Kt),string:new xn}}function ld(e){var n=ki(this,e).delete(e);return this.size-=n?1:0,n}function cd(e){return ki(this,e).get(e)}function fd(e){return ki(this,e).has(e)}function hd(e,n){var a=ki(this,e),u=a.size;return a.set(e,n),this.size+=a.size==u?0:1,this}Yt.prototype.clear=ud,Yt.prototype.delete=ld,Yt.prototype.get=cd,Yt.prototype.has=fd,Yt.prototype.set=hd;function Sn(e){var n=-1,a=e==null?0:e.length;for(this.__data__=new Yt;++n<a;)this.add(e[n])}function pd(e){return this.__data__.set(e,m),this}function dd(e){return this.__data__.has(e)}Sn.prototype.add=Sn.prototype.push=pd,Sn.prototype.has=dd;function At(e){var n=this.__data__=new Kt(e);this.size=n.size}function Ed(){this.__data__=new Kt,this.size=0}function _d(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function gd(e){return this.__data__.get(e)}function Nd(e){return this.__data__.has(e)}function Td(e,n){var a=this.__data__;if(a instanceof Kt){var u=a.__data__;if(!wr||u.length<o-1)return u.push([e,n]),this.size=++a.size,this;a=this.__data__=new Yt(u)}return a.set(e,n),this.size=a.size,this}At.prototype.clear=Ed,At.prototype.delete=_d,At.prototype.get=gd,At.prototype.has=Nd,At.prototype.set=Td;function fu(e,n){var a=H(e),u=!a&&Mn(e),c=!a&&!u&&vn(e),p=!a&&!u&&!c&&rr(e),E=a||u||c||p,N=E?ks(e.length,Sp):[],b=N.length;for(var x in e)(n||oe.call(e,x))&&!(E&&(x=="length"||c&&(x=="offset"||x=="parent")||p&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||jt(x,b)))&&N.push(x);return N}function hu(e){var n=e.length;return n?e[js(0,n-1)]:i}function vd(e,n){return Fi(Ke(e),On(n,0,e.length))}function bd(e){return Fi(Ke(e))}function Ws(e,n,a){(a!==i&&!wt(e[n],a)||a===i&&!(n in e))&&Jt(e,n,a)}function Sr(e,n,a){var u=e[n];(!(oe.call(e,n)&&wt(u,a))||a===i&&!(n in e))&&Jt(e,n,a)}function Ai(e,n){for(var a=e.length;a--;)if(wt(e[a][0],n))return a;return-1}function md(e,n,a,u){return _n(e,function(c,p,E){n(u,c,a(c),E)}),u}function pu(e,n){return e&&Ut(n,Oe(n),e)}function Id(e,n){return e&&Ut(n,Je(n),e)}function Jt(e,n,a){n=="__proto__"&&Ni?Ni(e,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[n]=a}function Xs(e,n){for(var a=-1,u=n.length,c=w(u),p=e==null;++a<u;)c[a]=p?i:Aa(e,n[a]);return c}function On(e,n,a){return e===e&&(a!==i&&(e=e<=a?e:a),n!==i&&(e=e>=n?e:n)),e}function _t(e,n,a,u,c,p){var E,N=n&y,b=n&$,x=n&J;if(a&&(E=c?a(e,u,c,p):a(e)),E!==i)return E;if(!ge(e))return e;var S=H(e);if(S){if(E=fE(e),!N)return Ke(e,E)}else{var O=Be(e),R=O==ni||O==Eo;if(vn(e))return Fu(e,N);if(O==zt||O==Wn||R&&!c){if(E=b||R?{}:nl(e),!N)return b?eE(e,Id(E,e)):jd(e,pu(E,e))}else{if(!ce[O])return c?e:{};E=hE(e,O,N)}}p||(p=new At);var k=p.get(e);if(k)return k;p.set(e,E),Pl(e)?e.forEach(function(V){E.add(_t(V,n,a,V,e,p))}):Sl(e)&&e.forEach(function(V,Q){E.set(Q,_t(V,n,a,Q,e,p))});var G=x?b?ca:la:b?Je:Oe,K=S?i:G(e);return pt(K||e,function(V,Q){K&&(Q=V,V=e[Q]),Sr(E,Q,_t(V,n,a,Q,e,p))}),E}function Ad(e){var n=Oe(e);return function(a){return du(a,e,n)}}function du(e,n,a){var u=a.length;if(e==null)return!u;for(e=ue(e);u--;){var c=a[u],p=n[c],E=e[c];if(E===i&&!(c in e)||!p(E))return!1}return!0}function Eu(e,n,a){if(typeof e!="function")throw new dt(f);return kr(function(){e.apply(i,a)},n)}function Or(e,n,a,u){var c=-1,p=oi,E=!0,N=e.length,b=[],x=n.length;if(!N)return b;a&&(n=Ee(n,nt(a))),u?(p=Os,E=!1):n.length>=o&&(p=Ir,E=!1,n=new Sn(n));e:for(;++c<N;){var S=e[c],O=a==null?S:a(S);if(S=u||S!==0?S:0,E&&O===O){for(var R=x;R--;)if(n[R]===O)continue e;b.push(S)}else p(n,O,u)||b.push(S)}return b}var _n=$u(Mt),_u=$u(qs,!0);function wd(e,n){var a=!0;return _n(e,function(u,c,p){return a=!!n(u,c,p),a}),a}function wi(e,n,a){for(var u=-1,c=e.length;++u<c;){var p=e[u],E=n(p);if(E!=null&&(N===i?E===E&&!it(E):a(E,N)))var N=E,b=p}return b}function Ld(e,n,a,u){var c=e.length;for(a=z(a),a<0&&(a=-a>c?0:c+a),u=u===i||u>c?c:z(u),u<0&&(u+=c),u=a>u?0:Dl(u);a<u;)e[a++]=n;return e}function gu(e,n){var a=[];return _n(e,function(u,c,p){n(u,c,p)&&a.push(u)}),a}function De(e,n,a,u,c){var p=-1,E=e.length;for(a||(a=dE),c||(c=[]);++p<E;){var N=e[p];n>0&&a(N)?n>1?De(N,n-1,a,u,c):pn(c,N):u||(c[c.length]=N)}return c}var Hs=Wu(),Nu=Wu(!0);function Mt(e,n){return e&&Hs(e,n,Oe)}function qs(e,n){return e&&Nu(e,n,Oe)}function Li(e,n){return hn(n,function(a){return en(e[a])})}function Pn(e,n){n=Nn(n,e);for(var a=0,u=n.length;e!=null&&a<u;)e=e[kt(n[a++])];return a&&a==u?e:i}function Tu(e,n,a){var u=n(e);return H(e)?u:pn(u,a(e))}function Ve(e){return e==null?e===i?th:jf:yn&&yn in ue(e)?uE(e):bE(e)}function zs(e,n){return e>n}function yd(e,n){return e!=null&&oe.call(e,n)}function xd(e,n){return e!=null&&n in ue(e)}function Sd(e,n,a){return e>=Ce(n,a)&&e<Se(n,a)}function Ks(e,n,a){for(var u=a?Os:oi,c=e[0].length,p=e.length,E=p,N=w(p),b=1/0,x=[];E--;){var S=e[E];E&&n&&(S=Ee(S,nt(n))),b=Ce(S.length,b),N[E]=!a&&(n||c>=120&&S.length>=120)?new Sn(E&&S):i}S=e[0];var O=-1,R=N[0];e:for(;++O<c&&x.length<b;){var k=S[O],G=n?n(k):k;if(k=a||k!==0?k:0,!(R?Ir(R,G):u(x,G,a))){for(E=p;--E;){var K=N[E];if(!(K?Ir(K,G):u(e[E],G,a)))continue e}R&&R.push(G),x.push(k)}}return x}function Od(e,n,a,u){return Mt(e,function(c,p,E){n(u,a(c),p,E)}),u}function Pr(e,n,a){n=Nn(n,e),e=al(e,n);var u=e==null?e:e[kt(Nt(n))];return u==null?i:tt(u,e,a)}function vu(e){return ve(e)&&Ve(e)==Wn}function Pd(e){return ve(e)&&Ve(e)==mr}function Rd(e){return ve(e)&&Ve(e)==gr}function Rr(e,n,a,u,c){return e===n?!0:e==null||n==null||!ve(e)&&!ve(n)?e!==e&&n!==n:Dd(e,n,a,u,Rr,c)}function Dd(e,n,a,u,c,p){var E=H(e),N=H(n),b=E?ei:Be(e),x=N?ei:Be(n);b=b==Wn?zt:b,x=x==Wn?zt:x;var S=b==zt,O=x==zt,R=b==x;if(R&&vn(e)){if(!vn(n))return!1;E=!0,S=!1}if(R&&!S)return p||(p=new At),E||rr(e)?ju(e,n,a,u,c,p):aE(e,n,b,a,u,c,p);if(!(a&ne)){var k=S&&oe.call(e,"__wrapped__"),G=O&&oe.call(n,"__wrapped__");if(k||G){var K=k?e.value():e,V=G?n.value():n;return p||(p=new At),c(K,V,a,u,p)}}return R?(p||(p=new At),oE(e,n,a,u,c,p)):!1}function Md(e){return ve(e)&&Be(e)==bt}function Ys(e,n,a,u){var c=a.length,p=c,E=!u;if(e==null)return!p;for(e=ue(e);c--;){var N=a[c];if(E&&N[2]?N[1]!==e[N[0]]:!(N[0]in e))return!1}for(;++c<p;){N=a[c];var b=N[0],x=e[b],S=N[1];if(E&&N[2]){if(x===i&&!(b in e))return!1}else{var O=new At;if(u)var R=u(x,S,b,e,n,O);if(!(R===i?Rr(S,x,ne|re,u,O):R))return!1}}return!0}function bu(e){if(!ge(e)||_E(e))return!1;var n=en(e)?Mp:Ah;return n.test(Dn(e))}function Ud(e){return ve(e)&&Ve(e)==Tr}function kd(e){return ve(e)&&Be(e)==mt}function Fd(e){return ve(e)&&Wi(e.length)&&!!fe[Ve(e)]}function mu(e){return typeof e=="function"?e:e==null?Qe:typeof e=="object"?H(e)?wu(e[0],e[1]):Au(e):Xl(e)}function Js(e){if(!Ur(e))return Gp(e);var n=[];for(var a in ue(e))oe.call(e,a)&&a!="constructor"&&n.push(a);return n}function Cd(e){if(!ge(e))return vE(e);var n=Ur(e),a=[];for(var u in e)u=="constructor"&&(n||!oe.call(e,u))||a.push(u);return a}function Qs(e,n){return e<n}function Iu(e,n){var a=-1,u=Ye(e)?w(e.length):[];return _n(e,function(c,p,E){u[++a]=n(c,p,E)}),u}function Au(e){var n=ha(e);return n.length==1&&n[0][2]?il(n[0][0],n[0][1]):function(a){return a===e||Ys(a,e,n)}}function wu(e,n){return da(e)&&rl(n)?il(kt(e),n):function(a){var u=Aa(a,e);return u===i&&u===n?wa(a,e):Rr(n,u,ne|re)}}function yi(e,n,a,u,c){e!==n&&Hs(n,function(p,E){if(c||(c=new At),ge(p))Bd(e,n,E,a,yi,u,c);else{var N=u?u(_a(e,E),p,E+"",e,n,c):i;N===i&&(N=p),Ws(e,E,N)}},Je)}function Bd(e,n,a,u,c,p,E){var N=_a(e,a),b=_a(n,a),x=E.get(b);if(x){Ws(e,a,x);return}var S=p?p(N,b,a+"",e,n,E):i,O=S===i;if(O){var R=H(b),k=!R&&vn(b),G=!R&&!k&&rr(b);S=b,R||k||G?H(N)?S=N:Ie(N)?S=Ke(N):k?(O=!1,S=Fu(b,!0)):G?(O=!1,S=Cu(b,!0)):S=[]:Fr(b)||Mn(b)?(S=N,Mn(N)?S=Ml(N):(!ge(N)||en(N))&&(S=nl(b))):O=!1}O&&(E.set(b,S),c(S,b,u,p,E),E.delete(b)),Ws(e,a,S)}function Lu(e,n){var a=e.length;if(a)return n+=n<0?a:0,jt(n,a)?e[n]:i}function yu(e,n,a){n.length?n=Ee(n,function(p){return H(p)?function(E){return Pn(E,p.length===1?p[0]:p)}:p}):n=[Qe];var u=-1;n=Ee(n,nt(B()));var c=Iu(e,function(p,E,N){var b=Ee(n,function(x){return x(p)});return{criteria:b,index:++u,value:p}});return hp(c,function(p,E){return Zd(p,E,a)})}function Gd(e,n){return xu(e,n,function(a,u){return wa(e,u)})}function xu(e,n,a){for(var u=-1,c=n.length,p={};++u<c;){var E=n[u],N=Pn(e,E);a(N,E)&&Dr(p,Nn(E,e),N)}return p}function Vd(e){return function(n){return Pn(n,e)}}function Zs(e,n,a,u){var c=u?fp:qn,p=-1,E=n.length,N=e;for(e===n&&(n=Ke(n)),a&&(N=Ee(e,nt(a)));++p<E;)for(var b=0,x=n[p],S=a?a(x):x;(b=c(N,S,b,u))>-1;)N!==e&&gi.call(N,b,1),gi.call(e,b,1);return e}function Su(e,n){for(var a=e?n.length:0,u=a-1;a--;){var c=n[a];if(a==u||c!==p){var p=c;jt(c)?gi.call(e,c,1):na(e,c)}}return e}function js(e,n){return e+vi(lu()*(n-e+1))}function $d(e,n,a,u){for(var c=-1,p=Se(Ti((n-e)/(a||1)),0),E=w(p);p--;)E[u?p:++c]=e,e+=a;return E}function ea(e,n){var a="";if(!e||n<1||n>fn)return a;do n%2&&(a+=e),n=vi(n/2),n&&(e+=e);while(n);return a}function Y(e,n){return ga(sl(e,n,Qe),e+"")}function Wd(e){return hu(ir(e))}function Xd(e,n){var a=ir(e);return Fi(a,On(n,0,a.length))}function Dr(e,n,a,u){if(!ge(e))return e;n=Nn(n,e);for(var c=-1,p=n.length,E=p-1,N=e;N!=null&&++c<p;){var b=kt(n[c]),x=a;if(b==="__proto__"||b==="constructor"||b==="prototype")return e;if(c!=E){var S=N[b];x=u?u(S,b,N):i,x===i&&(x=ge(S)?S:jt(n[c+1])?[]:{})}Sr(N,b,x),N=N[b]}return e}var Ou=bi?function(e,n){return bi.set(e,n),e}:Qe,Hd=Ni?function(e,n){return Ni(e,"toString",{configurable:!0,enumerable:!1,value:ya(n),writable:!0})}:Qe;function qd(e){return Fi(ir(e))}function gt(e,n,a){var u=-1,c=e.length;n<0&&(n=-n>c?0:c+n),a=a>c?c:a,a<0&&(a+=c),c=n>a?0:a-n>>>0,n>>>=0;for(var p=w(c);++u<c;)p[u]=e[u+n];return p}function zd(e,n){var a;return _n(e,function(u,c,p){return a=n(u,c,p),!a}),!!a}function xi(e,n,a){var u=0,c=e==null?u:e.length;if(typeof n=="number"&&n===n&&c<=Yf){for(;u<c;){var p=u+c>>>1,E=e[p];E!==null&&!it(E)&&(a?E<=n:E<n)?u=p+1:c=p}return c}return ta(e,n,Qe,a)}function ta(e,n,a,u){var c=0,p=e==null?0:e.length;if(p===0)return 0;n=a(n);for(var E=n!==n,N=n===null,b=it(n),x=n===i;c<p;){var S=vi((c+p)/2),O=a(e[S]),R=O!==i,k=O===null,G=O===O,K=it(O);if(E)var V=u||G;else x?V=G&&(u||R):N?V=G&&R&&(u||!k):b?V=G&&R&&!k&&(u||!K):k||K?V=!1:V=u?O<=n:O<n;V?c=S+1:p=S}return Ce(p,Kf)}function Pu(e,n){for(var a=-1,u=e.length,c=0,p=[];++a<u;){var E=e[a],N=n?n(E):E;if(!a||!wt(N,b)){var b=N;p[c++]=E===0?0:E}}return p}function Ru(e){return typeof e=="number"?e:it(e)?jr:+e}function rt(e){if(typeof e=="string")return e;if(H(e))return Ee(e,rt)+"";if(it(e))return cu?cu.call(e):"";var n=e+"";return n=="0"&&1/e==-wn?"-0":n}function gn(e,n,a){var u=-1,c=oi,p=e.length,E=!0,N=[],b=N;if(a)E=!1,c=Os;else if(p>=o){var x=n?null:iE(e);if(x)return li(x);E=!1,c=Ir,b=new Sn}else b=n?[]:N;e:for(;++u<p;){var S=e[u],O=n?n(S):S;if(S=a||S!==0?S:0,E&&O===O){for(var R=b.length;R--;)if(b[R]===O)continue e;n&&b.push(O),N.push(S)}else c(b,O,a)||(b!==N&&b.push(O),N.push(S))}return N}function na(e,n){return n=Nn(n,e),e=al(e,n),e==null||delete e[kt(Nt(n))]}function Du(e,n,a,u){return Dr(e,n,a(Pn(e,n)),u)}function Si(e,n,a,u){for(var c=e.length,p=u?c:-1;(u?p--:++p<c)&&n(e[p],p,e););return a?gt(e,u?0:p,u?p+1:c):gt(e,u?p+1:0,u?c:p)}function Mu(e,n){var a=e;return a instanceof Z&&(a=a.value()),Ps(n,function(u,c){return c.func.apply(c.thisArg,pn([u],c.args))},a)}function ra(e,n,a){var u=e.length;if(u<2)return u?gn(e[0]):[];for(var c=-1,p=w(u);++c<u;)for(var E=e[c],N=-1;++N<u;)N!=c&&(p[c]=Or(p[c]||E,e[N],n,a));return gn(De(p,1),n,a)}function Uu(e,n,a){for(var u=-1,c=e.length,p=n.length,E={};++u<c;){var N=u<p?n[u]:i;a(E,e[u],N)}return E}function ia(e){return Ie(e)?e:[]}function sa(e){return typeof e=="function"?e:Qe}function Nn(e,n){return H(e)?e:da(e,n)?[e]:cl(ae(e))}var Kd=Y;function Tn(e,n,a){var u=e.length;return a=a===i?u:a,!n&&a>=u?e:gt(e,n,a)}var ku=Up||function(e){return Re.clearTimeout(e)};function Fu(e,n){if(n)return e.slice();var a=e.length,u=iu?iu(a):new e.constructor(a);return e.copy(u),u}function aa(e){var n=new e.constructor(e.byteLength);return new Ei(n).set(new Ei(e)),n}function Yd(e,n){var a=n?aa(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.byteLength)}function Jd(e){var n=new e.constructor(e.source,vo.exec(e));return n.lastIndex=e.lastIndex,n}function Qd(e){return xr?ue(xr.call(e)):{}}function Cu(e,n){var a=n?aa(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.length)}function Bu(e,n){if(e!==n){var a=e!==i,u=e===null,c=e===e,p=it(e),E=n!==i,N=n===null,b=n===n,x=it(n);if(!N&&!x&&!p&&e>n||p&&E&&b&&!N&&!x||u&&E&&b||!a&&b||!c)return 1;if(!u&&!p&&!x&&e<n||x&&a&&c&&!u&&!p||N&&a&&c||!E&&c||!b)return-1}return 0}function Zd(e,n,a){for(var u=-1,c=e.criteria,p=n.criteria,E=c.length,N=a.length;++u<E;){var b=Bu(c[u],p[u]);if(b){if(u>=N)return b;var x=a[u];return b*(x=="desc"?-1:1)}}return e.index-n.index}function Gu(e,n,a,u){for(var c=-1,p=e.length,E=a.length,N=-1,b=n.length,x=Se(p-E,0),S=w(b+x),O=!u;++N<b;)S[N]=n[N];for(;++c<E;)(O||c<p)&&(S[a[c]]=e[c]);for(;x--;)S[N++]=e[c++];return S}function Vu(e,n,a,u){for(var c=-1,p=e.length,E=-1,N=a.length,b=-1,x=n.length,S=Se(p-N,0),O=w(S+x),R=!u;++c<S;)O[c]=e[c];for(var k=c;++b<x;)O[k+b]=n[b];for(;++E<N;)(R||c<p)&&(O[k+a[E]]=e[c++]);return O}function Ke(e,n){var a=-1,u=e.length;for(n||(n=w(u));++a<u;)n[a]=e[a];return n}function Ut(e,n,a,u){var c=!a;a||(a={});for(var p=-1,E=n.length;++p<E;){var N=n[p],b=u?u(a[N],e[N],N,a,e):i;b===i&&(b=e[N]),c?Jt(a,N,b):Sr(a,N,b)}return a}function jd(e,n){return Ut(e,pa(e),n)}function eE(e,n){return Ut(e,el(e),n)}function Oi(e,n){return function(a,u){var c=H(a)?sp:md,p=n?n():{};return c(a,e,B(u,2),p)}}function er(e){return Y(function(n,a){var u=-1,c=a.length,p=c>1?a[c-1]:i,E=c>2?a[2]:i;for(p=e.length>3&&typeof p=="function"?(c--,p):i,E&&$e(a[0],a[1],E)&&(p=c<3?i:p,c=1),n=ue(n);++u<c;){var N=a[u];N&&e(n,N,u,p)}return n})}function $u(e,n){return function(a,u){if(a==null)return a;if(!Ye(a))return e(a,u);for(var c=a.length,p=n?c:-1,E=ue(a);(n?p--:++p<c)&&u(E[p],p,E)!==!1;);return a}}function Wu(e){return function(n,a,u){for(var c=-1,p=ue(n),E=u(n),N=E.length;N--;){var b=E[e?N:++c];if(a(p[b],b,p)===!1)break}return n}}function tE(e,n,a){var u=n&j,c=Mr(e);function p(){var E=this&&this!==Re&&this instanceof p?c:e;return E.apply(u?a:this,arguments)}return p}function Xu(e){return function(n){n=ae(n);var a=zn(n)?It(n):i,u=a?a[0]:n.charAt(0),c=a?Tn(a,1).join(""):n.slice(1);return u[e]()+c}}function tr(e){return function(n){return Ps($l(Vl(n).replace(Hh,"")),e,"")}}function Mr(e){return function(){var n=arguments;switch(n.length){case 0:return new e;case 1:return new e(n[0]);case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[1],n[2]);case 4:return new e(n[0],n[1],n[2],n[3]);case 5:return new e(n[0],n[1],n[2],n[3],n[4]);case 6:return new e(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new e(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var a=jn(e.prototype),u=e.apply(a,n);return ge(u)?u:a}}function nE(e,n,a){var u=Mr(e);function c(){for(var p=arguments.length,E=w(p),N=p,b=nr(c);N--;)E[N]=arguments[N];var x=p<3&&E[0]!==b&&E[p-1]!==b?[]:dn(E,b);if(p-=x.length,p<a)return Yu(e,n,Pi,c.placeholder,i,E,x,i,i,a-p);var S=this&&this!==Re&&this instanceof c?u:e;return tt(S,this,E)}return c}function Hu(e){return function(n,a,u){var c=ue(n);if(!Ye(n)){var p=B(a,3);n=Oe(n),a=function(N){return p(c[N],N,c)}}var E=e(n,a,u);return E>-1?c[p?n[E]:E]:i}}function qu(e){return Zt(function(n){var a=n.length,u=a,c=Et.prototype.thru;for(e&&n.reverse();u--;){var p=n[u];if(typeof p!="function")throw new dt(f);if(c&&!E&&Ui(p)=="wrapper")var E=new Et([],!0)}for(u=E?u:a;++u<a;){p=n[u];var N=Ui(p),b=N=="wrapper"?fa(p):i;b&&Ea(b[0])&&b[1]==(qt|ft|ze|Er)&&!b[4].length&&b[9]==1?E=E[Ui(b[0])].apply(E,b[3]):E=p.length==1&&Ea(p)?E[N]():E.thru(p)}return function(){var x=arguments,S=x[0];if(E&&x.length==1&&H(S))return E.plant(S).value();for(var O=0,R=a?n[O].apply(this,x):S;++O<a;)R=n[O].call(this,R);return R}})}function Pi(e,n,a,u,c,p,E,N,b,x){var S=n&qt,O=n&j,R=n&de,k=n&(ft|Rt),G=n&fs,K=R?i:Mr(e);function V(){for(var Q=arguments.length,ee=w(Q),st=Q;st--;)ee[st]=arguments[st];if(k)var We=nr(V),at=dp(ee,We);if(u&&(ee=Gu(ee,u,c,k)),p&&(ee=Vu(ee,p,E,k)),Q-=at,k&&Q<x){var Ae=dn(ee,We);return Yu(e,n,Pi,V.placeholder,a,ee,Ae,N,b,x-Q)}var Lt=O?a:this,nn=R?Lt[e]:e;return Q=ee.length,N?ee=mE(ee,N):G&&Q>1&&ee.reverse(),S&&b<Q&&(ee.length=b),this&&this!==Re&&this instanceof V&&(nn=K||Mr(nn)),nn.apply(Lt,ee)}return V}function zu(e,n){return function(a,u){return Od(a,e,n(u),{})}}function Ri(e,n){return function(a,u){var c;if(a===i&&u===i)return n;if(a!==i&&(c=a),u!==i){if(c===i)return u;typeof a=="string"||typeof u=="string"?(a=rt(a),u=rt(u)):(a=Ru(a),u=Ru(u)),c=e(a,u)}return c}}function oa(e){return Zt(function(n){return n=Ee(n,nt(B())),Y(function(a){var u=this;return e(n,function(c){return tt(c,u,a)})})})}function Di(e,n){n=n===i?" ":rt(n);var a=n.length;if(a<2)return a?ea(n,e):n;var u=ea(n,Ti(e/Kn(n)));return zn(n)?Tn(It(u),0,e).join(""):u.slice(0,e)}function rE(e,n,a,u){var c=n&j,p=Mr(e);function E(){for(var N=-1,b=arguments.length,x=-1,S=u.length,O=w(S+b),R=this&&this!==Re&&this instanceof E?p:e;++x<S;)O[x]=u[x];for(;b--;)O[x++]=arguments[++N];return tt(R,c?a:this,O)}return E}function Ku(e){return function(n,a,u){return u&&typeof u!="number"&&$e(n,a,u)&&(a=u=i),n=tn(n),a===i?(a=n,n=0):a=tn(a),u=u===i?n<a?1:-1:tn(u),$d(n,a,u,e)}}function Mi(e){return function(n,a){return typeof n=="string"&&typeof a=="string"||(n=Tt(n),a=Tt(a)),e(n,a)}}function Yu(e,n,a,u,c,p,E,N,b,x){var S=n&ft,O=S?E:i,R=S?i:E,k=S?p:i,G=S?i:p;n|=S?ze:dr,n&=~(S?dr:ze),n&et||(n&=-4);var K=[e,n,c,k,O,G,R,N,b,x],V=a.apply(i,K);return Ea(e)&&ol(V,K),V.placeholder=u,ul(V,e,n)}function ua(e){var n=xe[e];return function(a,u){if(a=Tt(a),u=u==null?0:Ce(z(u),292),u&&uu(a)){var c=(ae(a)+"e").split("e"),p=n(c[0]+"e"+(+c[1]+u));return c=(ae(p)+"e").split("e"),+(c[0]+"e"+(+c[1]-u))}return n(a)}}var iE=Qn&&1/li(new Qn([,-0]))[1]==wn?function(e){return new Qn(e)}:Oa;function Ju(e){return function(n){var a=Be(n);return a==bt?Cs(n):a==mt?bp(n):pp(n,e(n))}}function Qt(e,n,a,u,c,p,E,N){var b=n&de;if(!b&&typeof e!="function")throw new dt(f);var x=u?u.length:0;if(x||(n&=-97,u=c=i),E=E===i?E:Se(z(E),0),N=N===i?N:z(N),x-=c?c.length:0,n&dr){var S=u,O=c;u=c=i}var R=b?i:fa(e),k=[e,n,a,u,c,S,O,p,E,N];if(R&&TE(k,R),e=k[0],n=k[1],a=k[2],u=k[3],c=k[4],N=k[9]=k[9]===i?b?0:e.length:Se(k[9]-x,0),!N&&n&(ft|Rt)&&(n&=-25),!n||n==j)var G=tE(e,n,a);else n==ft||n==Rt?G=nE(e,n,N):(n==ze||n==(j|ze))&&!c.length?G=rE(e,n,a,u):G=Pi.apply(i,k);var K=R?Ou:ol;return ul(K(G,k),e,n)}function Qu(e,n,a,u){return e===i||wt(e,Jn[a])&&!oe.call(u,a)?n:e}function Zu(e,n,a,u,c,p){return ge(e)&&ge(n)&&(p.set(n,e),yi(e,n,i,Zu,p),p.delete(n)),e}function sE(e){return Fr(e)?i:e}function ju(e,n,a,u,c,p){var E=a&ne,N=e.length,b=n.length;if(N!=b&&!(E&&b>N))return!1;var x=p.get(e),S=p.get(n);if(x&&S)return x==n&&S==e;var O=-1,R=!0,k=a&re?new Sn:i;for(p.set(e,n),p.set(n,e);++O<N;){var G=e[O],K=n[O];if(u)var V=E?u(K,G,O,n,e,p):u(G,K,O,e,n,p);if(V!==i){if(V)continue;R=!1;break}if(k){if(!Rs(n,function(Q,ee){if(!Ir(k,ee)&&(G===Q||c(G,Q,a,u,p)))return k.push(ee)})){R=!1;break}}else if(!(G===K||c(G,K,a,u,p))){R=!1;break}}return p.delete(e),p.delete(n),R}function aE(e,n,a,u,c,p,E){switch(a){case Xn:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case mr:return!(e.byteLength!=n.byteLength||!p(new Ei(e),new Ei(n)));case _r:case gr:case Nr:return wt(+e,+n);case ti:return e.name==n.name&&e.message==n.message;case Tr:case vr:return e==n+"";case bt:var N=Cs;case mt:var b=u&ne;if(N||(N=li),e.size!=n.size&&!b)return!1;var x=E.get(e);if(x)return x==n;u|=re,E.set(e,n);var S=ju(N(e),N(n),u,c,p,E);return E.delete(e),S;case ri:if(xr)return xr.call(e)==xr.call(n)}return!1}function oE(e,n,a,u,c,p){var E=a&ne,N=la(e),b=N.length,x=la(n),S=x.length;if(b!=S&&!E)return!1;for(var O=b;O--;){var R=N[O];if(!(E?R in n:oe.call(n,R)))return!1}var k=p.get(e),G=p.get(n);if(k&&G)return k==n&&G==e;var K=!0;p.set(e,n),p.set(n,e);for(var V=E;++O<b;){R=N[O];var Q=e[R],ee=n[R];if(u)var st=E?u(ee,Q,R,n,e,p):u(Q,ee,R,e,n,p);if(!(st===i?Q===ee||c(Q,ee,a,u,p):st)){K=!1;break}V||(V=R=="constructor")}if(K&&!V){var We=e.constructor,at=n.constructor;We!=at&&"constructor"in e&&"constructor"in n&&!(typeof We=="function"&&We instanceof We&&typeof at=="function"&&at instanceof at)&&(K=!1)}return p.delete(e),p.delete(n),K}function Zt(e){return ga(sl(e,i,dl),e+"")}function la(e){return Tu(e,Oe,pa)}function ca(e){return Tu(e,Je,el)}var fa=bi?function(e){return bi.get(e)}:Oa;function Ui(e){for(var n=e.name+"",a=Zn[n],u=oe.call(Zn,n)?a.length:0;u--;){var c=a[u],p=c.func;if(p==null||p==e)return c.name}return n}function nr(e){var n=oe.call(h,"placeholder")?h:e;return n.placeholder}function B(){var e=h.iteratee||xa;return e=e===xa?mu:e,arguments.length?e(arguments[0],arguments[1]):e}function ki(e,n){var a=e.__data__;return EE(n)?a[typeof n=="string"?"string":"hash"]:a.map}function ha(e){for(var n=Oe(e),a=n.length;a--;){var u=n[a],c=e[u];n[a]=[u,c,rl(c)]}return n}function Rn(e,n){var a=Np(e,n);return bu(a)?a:i}function uE(e){var n=oe.call(e,yn),a=e[yn];try{e[yn]=i;var u=!0}catch{}var c=pi.call(e);return u&&(n?e[yn]=a:delete e[yn]),c}var pa=Gs?function(e){return e==null?[]:(e=ue(e),hn(Gs(e),function(n){return au.call(e,n)}))}:Pa,el=Gs?function(e){for(var n=[];e;)pn(n,pa(e)),e=_i(e);return n}:Pa,Be=Ve;(Vs&&Be(new Vs(new ArrayBuffer(1)))!=Xn||wr&&Be(new wr)!=bt||$s&&Be($s.resolve())!=_o||Qn&&Be(new Qn)!=mt||Lr&&Be(new Lr)!=br)&&(Be=function(e){var n=Ve(e),a=n==zt?e.constructor:i,u=a?Dn(a):"";if(u)switch(u){case Xp:return Xn;case Hp:return bt;case qp:return _o;case zp:return mt;case Kp:return br}return n});function lE(e,n,a){for(var u=-1,c=a.length;++u<c;){var p=a[u],E=p.size;switch(p.type){case"drop":e+=E;break;case"dropRight":n-=E;break;case"take":n=Ce(n,e+E);break;case"takeRight":e=Se(e,n-E);break}}return{start:e,end:n}}function cE(e){var n=e.match(_h);return n?n[1].split(gh):[]}function tl(e,n,a){n=Nn(n,e);for(var u=-1,c=n.length,p=!1;++u<c;){var E=kt(n[u]);if(!(p=e!=null&&a(e,E)))break;e=e[E]}return p||++u!=c?p:(c=e==null?0:e.length,!!c&&Wi(c)&&jt(E,c)&&(H(e)||Mn(e)))}function fE(e){var n=e.length,a=new e.constructor(n);return n&&typeof e[0]=="string"&&oe.call(e,"index")&&(a.index=e.index,a.input=e.input),a}function nl(e){return typeof e.constructor=="function"&&!Ur(e)?jn(_i(e)):{}}function hE(e,n,a){var u=e.constructor;switch(n){case mr:return aa(e);case _r:case gr:return new u(+e);case Xn:return Yd(e,a);case hs:case ps:case ds:case Es:case _s:case gs:case Ns:case Ts:case vs:return Cu(e,a);case bt:return new u;case Nr:case vr:return new u(e);case Tr:return Jd(e);case mt:return new u;case ri:return Qd(e)}}function pE(e,n){var a=n.length;if(!a)return e;var u=a-1;return n[u]=(a>1?"& ":"")+n[u],n=n.join(a>2?", ":" "),e.replace(Eh,`{
9
+ `;case"\\":return"\\";case"r":return"\r";case"'":return"'";case'"':return'"';case"`":return"`";case"0":return"\0";case"b":return"\b";case"v":return"\v";case"f":return"\f";case" ":return"\\ ";case"u":{let i="";for(let s=0;s<=3;s+=1){if(this.isAtEnd()||!Un(this.peek()))return this.errors.push(new g(_.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${i}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Ze.create(A.STRING_LITERAL,r,this.current,`\\u${i}`,!0))),`\\u${i}`;i+=this.advance()}return String.fromCharCode(parseInt(i,16))}default:return this.text[this.current.offset-1]}}}var Ki=(t=>(t[t.ListExpression=0]="ListExpression",t[t.GroupExpression=1]="GroupExpression",t[t.BlockExpression=2]="BlockExpression",t))(Ki||{});class oA{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(r){this.stack.push(r),r===0&&(this.numberOfNestedLBrackets+=1),r===1&&(this.numberOfNestedLParens+=1),r===2&&(this.numberOfNestedLBraces+=1)}pop(){const r=this.stack.pop();return r===0&&(this.numberOfNestedLBrackets-=1),r===1&&(this.numberOfNestedLParens-=1),r===2&&(this.numberOfNestedLBraces-=1),r}top(){return me(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(r,i){return()=>{this.push(r);try{return i()}finally{this.pop()}}}findHandlerContext(r,i){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let s=i;s<r.length-1;s+=1)switch(r[s].kind){case A.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(l=>[1,0].includes(l));break;case A.RPAREN:if(this.isWithinGroupExpressionContext())return 1;break;case A.RBRACE:if(this.isWithinBlockExpressionContext())return 2;break;case A.RBRACKET:if(this.isWithinListExpressionContext())return 0;break}}}class uA{constructor(r){this.generator=r}create(r,i){return new r(i,this.generator.nextId())}}class M{constructor(r,i,s){this.token=r,this.partialNode=i,this.handlerContext=s}}class lA{constructor(r,i){this.current=0,this.errors=[],this.contextStack=new oA,this.synchronizeProgram=()=>{const s=this.peek();s.kind!==A.EOF?C(this.advance()):this.logError(s,_.UNEXPECTED_EOF,"Unexpected EOF")},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){const s=this.peek();if(Ha(s)||this.check(A.COLON,A.LBRACE,A.LBRACKET))break;C(s),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COLON,A.LBRACE,A.LBRACKET))break;C(s),this.advance()}},this.blockExpression=this.contextStack.withContextDo(Ki.BlockExpression,()=>{const s={body:[]},o=()=>this.nodeFactory.create(ke,s);try{this.consume("Expect an opening brace '{'",A.LBRACE),s.blockOpenBrace=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(A.RBRACE);)try{s.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(l){if(!(l instanceof M))throw l;if(s.body.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}try{this.consume("Expect a closing brace '}'",A.RBRACE),s.blockCloseBrace=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}return o()}),this.synchronizeBlock=()=>{if(!this.check(A.RBRACE))for(C(this.advance());!this.isAtEnd();){const s=this.peek();if(this.check(A.RBRACE)||vc(this.previous(),s))break;C(s),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(Ki.GroupExpression,()=>{const s={elementList:[],commaList:[]},o=()=>this.nodeFactory.create(ja,{groupOpenParen:s.tupleOpenParen,groupCloseParen:s.tupleCloseParen,expression:s.elementList[0]}),l=()=>this.nodeFactory.create(Wt,s);try{this.consume("Expect an opening parenthesis '('",A.LPAREN),s.tupleOpenParen=this.previous()}catch(f){if(!(f instanceof M))throw f;if(!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(A.RPAREN))try{s.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof M))throw f;if(s.elementList.push(f.partialNode),!this.canHandle(f))throw new M(f.token,o(),f.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(A.RPAREN);)try{this.consume("Expect a comma ','",A.COMMA),s.commaList.push(this.previous()),s.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof M))throw f;if(f.partialNode instanceof Te&&s.elementList.push(f.partialNode),!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}try{this.consume("Expect a closing parenthesis ')'",A.RPAREN),s.tupleCloseParen=this.previous()}catch(f){if(!(f instanceof M))throw f;if(!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}return s.elementList.length===1?o():l()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.RPAREN,A.COMMA))break;C(s),this.advance()}},this.listExpression=this.contextStack.withContextDo(Ki.ListExpression,()=>{const s={elementList:[],commaList:[]},o=()=>this.nodeFactory.create(_e,s);try{this.consume("Expect an opening bracket '['",A.LBRACKET),s.listOpenBracket=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(A.RBRACKET))try{s.elementList.push(this.attribute())}catch(l){if(!(l instanceof M))throw l;if(s.elementList.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(A.RBRACKET);)try{this.consume("Expect a comma ','",A.COMMA),s.commaList.push(this.previous()),s.elementList.push(this.attribute())}catch(l){if(!(l instanceof M))throw l;if(l.partialNode instanceof Te&&s.elementList.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}try{this.consume("Expect a closing bracket ']'",A.RBRACKET),s.listCloseBracket=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}return o()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET))break;C(s),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET,A.COLON))break;C(s),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET))break;C(s),this.advance()}},this.tokens=r,this.nodeFactory=new uA(i)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===A.EOF}advance(){return this.isAtEnd()?me(this.tokens):this.tokens[this.current++]}peek(r=0){return r+this.current>=this.tokens.length?me(this.tokens):this.tokens[this.current+r]}match(...r){const i=this.check(...r);return i&&this.advance(),i}check(...r){const i=this.peek();return r.includes(i.kind)}previous(){return this.tokens[this.current-1]}canHandle(r){return r.handlerContext===void 0||r.handlerContext===this.contextStack.top()}consume(r,...i){if(!this.match(...i))throw this.logError(this.peek(),_.UNEXPECTED_TOKEN,r),new M(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(r,...i){if(this.isAtEnd()||!this.check(...i)){for(C(this.peek()),this.logError(this.advance(),_.UNEXPECTED_TOKEN,r);!this.isAtEnd()&&!this.check(...i);)C(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){const r=[],i=[];let s,o=0;for(;o<this.tokens.length&&this.tokens[o].isInvalid;o+=1)i.push(this.tokens[o]);for(s=this.tokens[o],s.leadingInvalid=[...i,...s.leadingInvalid],r.push(s),o+=1;o<this.tokens.length;o+=1){const l=this.tokens[o];l.isInvalid?s.trailingInvalid.push(l):(s=l,r.push(s))}this.tokens=r}parse(){const r=this.program(),i=this.advance(),s=this.nodeFactory.create(qe,{body:r,eof:i});return this.gatherInvalid(),new ct({ast:s,tokens:this.tokens},this.errors)}program(){const r=[];for(;!this.isAtEnd();)try{const i=this.elementDeclaration();r.push(i)}catch(i){if(!(i instanceof M))throw i;r.push(i.partialNode),this.synchronizeProgram()}return r}elementDeclaration(){const r={},i=()=>this.nodeFactory.create(se,r);try{this.consume("Expect an identifier",A.IDENTIFIER),r.type=this.previous()}catch(s){throw s instanceof M?new M(s.token,i(),s.handlerContext):s}if(!this.check(A.COLON,A.LBRACE,A.LBRACKET))try{r.name=this.normalExpression()}catch(s){if(!(s instanceof M))throw s;if(r.name=s.partialNode,!this.canHandle(s))throw new M(s.token,i(),s.handlerContext);this.synchronizeElementDeclarationName()}if(Ha(this.peek()))if(r.as=this.advance(),this.check(A.COLON,A.LBRACE,A.LBRACKET))this.logError(this.peek(),_.UNEXPECTED_TOKEN,"Expect an alias");else try{r.alias=this.normalExpression()}catch(s){if(!(s instanceof M))throw s;if(r.alias=s.partialNode,!this.canHandle(s))throw new M(s.token,i(),s.handlerContext);this.synchronizeElementDeclarationAlias()}try{r.attributeList=this.check(A.LBRACKET)?this.listExpression():void 0}catch(s){throw s instanceof M?(r.attributeList=s.partialNode,new M(s.token,i(),s.handlerContext)):s}if(!this.discardUntil("Expect an opening brace '{' or a colon ':'",A.LBRACE,A.COLON))return i();try{if(this.match(A.COLON)){r.bodyColon=this.previous();const s=this.expression();s instanceof se?(C(s),this.logError(s,_.UNEXPECTED_ELEMENT_DECLARATION,"An element's simple body must not be an element declaration")):r.body=s}else r.body=this.blockExpression()}catch(s){throw s instanceof M?(r.body=s.partialNode,new M(s.token,i(),s.handlerContext)):s}return this.nodeFactory.create(se,r)}fieldDeclaration(){const r={},i=()=>this.nodeFactory.create(se,r);try{this.consume("Expect an identifier",A.IDENTIFIER),r.type=this.previous()}catch(s){throw s instanceof M?(r.type=s.partialNode,new M(s.token,i(),s.handlerContext)):s}try{this.consume("Expect a colon ':'",A.COLON),r.bodyColon=this.previous()}catch(s){throw s instanceof M?(r.bodyColon=s.partialNode,new M(s.token,i(),s.handlerContext)):s}try{const s=this.expression();s instanceof se?this.errors.push(new g(_.INVALID_ELEMENT_IN_SIMPLE_BODY,"Simple body cannot be an element declaration",s)):r.body=s}catch(s){throw s instanceof M?(r.body=s.partialNode,new M(s.token,i(),s.handlerContext)):s}return this.nodeFactory.create(se,r)}expression(){const r={args:[]},i=()=>tA(r.callee,r.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(W,r));try{r.callee=this.normalExpression()}catch(o){throw o instanceof M?(r.callee=o.partialNode,new M(o.token,i(),o.handlerContext)):o}if(this.shouldStopExpression())return i();let s=r.callee;for(;!this.shouldStopExpression();){$a(this.previous())||this.logError(s,_.MISSING_SPACES,"Expect a following space");try{s=this.normalExpression(),r.args.push(s)}catch(o){throw o instanceof M?(s=o.partialNode,r.args.push(s),new M(o.token,i(),o.handlerContext)):o}}return i()}shouldStopExpression(){if(this.isAtEnd()||uf(this.previous()))return!0;const r=this.peek().kind;return r===A.RBRACE||r===A.RBRACKET||r===A.RPAREN||r===A.COMMA||r===A.COLON}normalExpression(){return this.expression_bp(0)}expression_bp(r){let i=this.leftExpression_bp();for(;!this.isAtEnd();){const s=this.peek();if(s.kind===A.LPAREN){const{left:o}=wc(s);if(o<r||vc(this.previous(),s)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{i=this.nodeFactory.create(He,{callee:i,argumentList:this.tupleExpression()})}catch(l){throw l instanceof M?(i=this.nodeFactory.create(He,{callee:i,argumentList:l.partialNode}),new M(l.token,i,l.handlerContext)):l}}else if(s.kind===A.LBRACKET){if($a(this.previous()))break;try{i=this.nodeFactory.create(Bt,{expression:i,indexer:this.listExpression()})}catch(o){throw o instanceof M?(i=this.nodeFactory.create(Bt,{expression:i,indexer:o.partialNode}),new M(o.token,i,o.handlerContext)):o}}else if(Tc(s)){const o=s,l=wc(o);if(l.left!==null){if(l.left<=r)break;this.advance(),i=this.nodeFactory.create(os,{expression:i,op:o})}else{const f=fA(o);if(f.left===null||f.left<=r)break;this.advance();try{i=this.nodeFactory.create(Vt,{leftExpression:i,op:o,rightExpression:o.value==="."?this.extractOperand():this.expression_bp(f.right)})}catch(d){throw d instanceof M?(i=this.nodeFactory.create(Vt,{leftExpression:i,op:o,rightExpression:d.partialNode}),new M(d.token,i,d.handlerContext)):d}}}else break}return i}leftExpression_bp(){let r;if(Tc(this.peek())){const i={};i.op=this.peek();const s=pA(i.op);if(s.right===null)throw this.logError(i.op,_.UNKNOWN_PREFIX_OP,`Unexpected '${i.op.value}' in an expression`),new M(i.op,this.nodeFactory.create(Br,{pre:i.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{i.expression=this.expression_bp(s.right)}catch(o){throw o instanceof M?(i.expression=o.partialNode,new M(o.token,this.nodeFactory.create(je,i),o.handlerContext)):o}r=this.nodeFactory.create(je,i)}else if(r=this.extractOperand(),r instanceof Br)throw new M(this.peek(),this.nodeFactory.create(Br,{pre:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return r}extractOperand(){return this.check(A.NUMERIC_LITERAL,A.STRING_LITERAL,A.COLOR_LITERAL,A.QUOTED_STRING,A.IDENTIFIER)?this.primaryExpression():this.check(A.FUNCTION_EXPRESSION)?this.functionExpression():this.check(A.LBRACKET)?this.listExpression():this.check(A.LBRACE)?this.blockExpression():this.check(A.LPAREN)?this.tupleExpression():(this.peek().kind===A.EOF?this.logError(this.peek(),_.UNEXPECTED_EOF,"Unexpected EOF"):this.logError(this.peek(),_.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(Br,{pre:this.previous()}))}functionExpression(){const r={};try{this.consume("Expect a function expression",A.FUNCTION_EXPRESSION),r.value=this.previous()}catch(i){throw i instanceof M?new M(i.token,this.nodeFactory.create(bt,r),i.handlerContext):i}return this.nodeFactory.create(bt,r)}canBeField(){return this.peek().kind===A.IDENTIFIER&&this.peek(1).kind===A.COLON}primaryExpression(){if(this.match(A.COLOR_LITERAL,A.STRING_LITERAL,A.NUMERIC_LITERAL))return this.nodeFactory.create(lt,{expression:this.nodeFactory.create(cr,{literal:this.previous()})});if(this.match(A.QUOTED_STRING,A.IDENTIFIER))return this.nodeFactory.create(lt,{expression:this.nodeFactory.create(ln,{variable:this.previous()})});throw this.logError(this.peek(),_.UNEXPECTED_TOKEN,"Expect a variable or literal"),new M(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){const r={};if(this.check(A.COLON,A.RBRACKET,A.COMMA)){const i=this.peek();this.logError(i,_.EMPTY_ATTRIBUTE_NAME,"Expect a non-empty attribute name"),r.name=this.nodeFactory.create(xt,{identifiers:[]})}else try{r.name=this.attributeName()}catch(i){if(!(i instanceof M))throw i;if(r.name=i.partialNode,!this.canHandle(i))throw new M(i.token,this.nodeFactory.create(St,r),i.handlerContext);this.synchronizeAttributeName()}return this.match(A.COLON)&&(r.colon=this.previous(),r.value=this.attributeValue()),this.nodeFactory.create(St,r)}attributeValue(){let r;try{r=this.peek().kind===A.IDENTIFIER&&this.peek(1).kind===A.IDENTIFIER?this.attributeName():this.normalExpression()}catch(i){if(!(i instanceof M)||!this.canHandle(i))throw i;r=i.partialNode,this.synchronizeAttributeValue()}return r}attributeName(){const r=[];if(this.peek().kind!==A.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(A.COLON,A.COMMA,A.RBRACKET);)try{this.consume("Expect an identifier",A.IDENTIFIER),r.push(this.previous())}catch(i){throw i instanceof M?new M(i.token,this.nodeFactory.create(xt,{identifiers:r}),i.handlerContext):i}return this.nodeFactory.create(xt,{identifiers:r})}logError(r,i,s){this.errors.push(new g(i,s,r))}}const cA={"+":{left:9,right:10},"*":{left:11,right:12},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function fA(t){return cA[t.value]||{left:null,right:null}}const hA={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function pA(t){return hA[t.value]||{left:null,right:null}}const dA={"(":{left:14,right:null}};function wc(t){return dA[t.value]||{left:null,right:null}}class Lc{constructor(r,i){this.ast=r,this.symbolFactory=i,this.publicSchemaSymbol=this.symbolFactory.create(eo,{symbolTable:new Bn}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){const r=[];this.ast.body.forEach(s=>{if(s.parent=this.ast,s.type===void 0)return;const o=Xt(s),l=new o(s,this.publicSchemaSymbol.symbolTable,this.symbolFactory);r.push(...l.validate())});const i=this.ast.body.filter(s=>cn(s).unwrap_or(void 0)===F.Project);return i.length>1&&i.forEach(s=>r.push(new g(_.PROJECT_REDEFINED,"Only one project can exist",s))),new ct(this.ast,r)}}class EA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return[]}}class _A{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class gA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof W);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}var zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Gr={exports:{}};var NA=Gr.exports,yc;function TA(){return yc||(yc=1,function(t,r){(function(){var i,s="4.17.21",o=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",d="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",I=500,T="__lodash_placeholder__",y=1,$=2,J=4,ne=1,re=2,j=1,de=2,et=4,ht=8,Rt=16,ze=32,dr=64,qt=128,Er=256,fs=512,$f=30,Wf="...",Xf=800,Hf=16,po=1,qf=2,zf=3,wn=1/0,fn=9007199254740991,Kf=17976931348623157e292,jr=NaN,Dt=4294967295,Yf=Dt-1,Jf=Dt>>>1,Qf=[["ary",qt],["bind",j],["bindKey",de],["curry",ht],["curryRight",Rt],["flip",fs],["partial",ze],["partialRight",dr],["rearg",Er]],Wn="[object Arguments]",ei="[object Array]",Zf="[object AsyncFunction]",_r="[object Boolean]",gr="[object Date]",jf="[object DOMException]",ti="[object Error]",ni="[object Function]",Eo="[object GeneratorFunction]",mt="[object Map]",Nr="[object Number]",eh="[object Null]",zt="[object Object]",_o="[object Promise]",th="[object Proxy]",Tr="[object RegExp]",It="[object Set]",vr="[object String]",ri="[object Symbol]",nh="[object Undefined]",br="[object WeakMap]",rh="[object WeakSet]",mr="[object ArrayBuffer]",Xn="[object DataView]",hs="[object Float32Array]",ps="[object Float64Array]",ds="[object Int8Array]",Es="[object Int16Array]",_s="[object Int32Array]",gs="[object Uint8Array]",Ns="[object Uint8ClampedArray]",Ts="[object Uint16Array]",vs="[object Uint32Array]",ih=/\b__p \+= '';/g,sh=/\b(__p \+=) '' \+/g,ah=/(__e\(.*?\)|\b__t\)) \+\n'';/g,go=/&(?:amp|lt|gt|quot|#39);/g,No=/[&<>"']/g,oh=RegExp(go.source),uh=RegExp(No.source),lh=/<%-([\s\S]+?)%>/g,ch=/<%([\s\S]+?)%>/g,To=/<%=([\s\S]+?)%>/g,fh=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,hh=/^\w*$/,ph=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bs=/[\\^$.*+?()[\]{}|]/g,dh=RegExp(bs.source),ms=/^\s+/,Eh=/\s/,_h=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,gh=/\{\n\/\* \[wrapped with (.+)\] \*/,Nh=/,? & /,Th=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,vh=/[()=,{}\[\]\/\s]/,bh=/\\(\\)?/g,mh=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vo=/\w*$/,Ih=/^[-+]0x[0-9a-f]+$/i,Ah=/^0b[01]+$/i,wh=/^\[object .+?Constructor\]$/,Lh=/^0o[0-7]+$/i,yh=/^(?:0|[1-9]\d*)$/,xh=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ii=/($^)/,Sh=/['\n\r\u2028\u2029\\]/g,si="\\ud800-\\udfff",Oh="\\u0300-\\u036f",Ph="\\ufe20-\\ufe2f",Rh="\\u20d0-\\u20ff",bo=Oh+Ph+Rh,mo="\\u2700-\\u27bf",Io="a-z\\xdf-\\xf6\\xf8-\\xff",Dh="\\xac\\xb1\\xd7\\xf7",Mh="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Uh="\\u2000-\\u206f",kh=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ao="A-Z\\xc0-\\xd6\\xd8-\\xde",wo="\\ufe0e\\ufe0f",Lo=Dh+Mh+Uh+kh,Is="['’]",Fh="["+si+"]",yo="["+Lo+"]",ai="["+bo+"]",xo="\\d+",Ch="["+mo+"]",So="["+Io+"]",Oo="[^"+si+Lo+xo+mo+Io+Ao+"]",As="\\ud83c[\\udffb-\\udfff]",Bh="(?:"+ai+"|"+As+")",Po="[^"+si+"]",ws="(?:\\ud83c[\\udde6-\\uddff]){2}",Ls="[\\ud800-\\udbff][\\udc00-\\udfff]",Hn="["+Ao+"]",Ro="\\u200d",Do="(?:"+So+"|"+Oo+")",Gh="(?:"+Hn+"|"+Oo+")",Mo="(?:"+Is+"(?:d|ll|m|re|s|t|ve))?",Uo="(?:"+Is+"(?:D|LL|M|RE|S|T|VE))?",ko=Bh+"?",Fo="["+wo+"]?",Vh="(?:"+Ro+"(?:"+[Po,ws,Ls].join("|")+")"+Fo+ko+")*",$h="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Wh="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Co=Fo+ko+Vh,Xh="(?:"+[Ch,ws,Ls].join("|")+")"+Co,Hh="(?:"+[Po+ai+"?",ai,ws,Ls,Fh].join("|")+")",qh=RegExp(Is,"g"),zh=RegExp(ai,"g"),ys=RegExp(As+"(?="+As+")|"+Hh+Co,"g"),Kh=RegExp([Hn+"?"+So+"+"+Mo+"(?="+[yo,Hn,"$"].join("|")+")",Gh+"+"+Uo+"(?="+[yo,Hn+Do,"$"].join("|")+")",Hn+"?"+Do+"+"+Mo,Hn+"+"+Uo,Wh,$h,xo,Xh].join("|"),"g"),Yh=RegExp("["+Ro+si+bo+wo+"]"),Jh=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Qh=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Zh=-1,fe={};fe[hs]=fe[ps]=fe[ds]=fe[Es]=fe[_s]=fe[gs]=fe[Ns]=fe[Ts]=fe[vs]=!0,fe[Wn]=fe[ei]=fe[mr]=fe[_r]=fe[Xn]=fe[gr]=fe[ti]=fe[ni]=fe[mt]=fe[Nr]=fe[zt]=fe[Tr]=fe[It]=fe[vr]=fe[br]=!1;var ce={};ce[Wn]=ce[ei]=ce[mr]=ce[Xn]=ce[_r]=ce[gr]=ce[hs]=ce[ps]=ce[ds]=ce[Es]=ce[_s]=ce[mt]=ce[Nr]=ce[zt]=ce[Tr]=ce[It]=ce[vr]=ce[ri]=ce[gs]=ce[Ns]=ce[Ts]=ce[vs]=!0,ce[ti]=ce[ni]=ce[br]=!1;var jh={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ep={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},tp={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},np={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},rp=parseFloat,ip=parseInt,Bo=typeof zi=="object"&&zi&&zi.Object===Object&&zi,sp=typeof self=="object"&&self&&self.Object===Object&&self,Re=Bo||sp||Function("return this")(),xs=r&&!r.nodeType&&r,Ln=xs&&!0&&t&&!t.nodeType&&t,Go=Ln&&Ln.exports===xs,Ss=Go&&Bo.process,pt=function(){try{var v=Ln&&Ln.require&&Ln.require("util").types;return v||Ss&&Ss.binding&&Ss.binding("util")}catch{}}(),Vo=pt&&pt.isArrayBuffer,$o=pt&&pt.isDate,Wo=pt&&pt.isMap,Xo=pt&&pt.isRegExp,Ho=pt&&pt.isSet,qo=pt&&pt.isTypedArray;function tt(v,L,w){switch(w.length){case 0:return v.call(L);case 1:return v.call(L,w[0]);case 2:return v.call(L,w[0],w[1]);case 3:return v.call(L,w[0],w[1],w[2])}return v.apply(L,w)}function ap(v,L,w,D){for(var X=-1,ie=v==null?0:v.length;++X<ie;){var xe=v[X];L(D,xe,w(xe),v)}return D}function dt(v,L){for(var w=-1,D=v==null?0:v.length;++w<D&&L(v[w],w,v)!==!1;);return v}function op(v,L){for(var w=v==null?0:v.length;w--&&L(v[w],w,v)!==!1;);return v}function zo(v,L){for(var w=-1,D=v==null?0:v.length;++w<D;)if(!L(v[w],w,v))return!1;return!0}function hn(v,L){for(var w=-1,D=v==null?0:v.length,X=0,ie=[];++w<D;){var xe=v[w];L(xe,w,v)&&(ie[X++]=xe)}return ie}function oi(v,L){var w=v==null?0:v.length;return!!w&&qn(v,L,0)>-1}function Os(v,L,w){for(var D=-1,X=v==null?0:v.length;++D<X;)if(w(L,v[D]))return!0;return!1}function Ee(v,L){for(var w=-1,D=v==null?0:v.length,X=Array(D);++w<D;)X[w]=L(v[w],w,v);return X}function pn(v,L){for(var w=-1,D=L.length,X=v.length;++w<D;)v[X+w]=L[w];return v}function Ps(v,L,w,D){var X=-1,ie=v==null?0:v.length;for(D&&ie&&(w=v[++X]);++X<ie;)w=L(w,v[X],X,v);return w}function up(v,L,w,D){var X=v==null?0:v.length;for(D&&X&&(w=v[--X]);X--;)w=L(w,v[X],X,v);return w}function Rs(v,L){for(var w=-1,D=v==null?0:v.length;++w<D;)if(L(v[w],w,v))return!0;return!1}var lp=Ds("length");function cp(v){return v.split("")}function fp(v){return v.match(Th)||[]}function Ko(v,L,w){var D;return w(v,function(X,ie,xe){if(L(X,ie,xe))return D=ie,!1}),D}function ui(v,L,w,D){for(var X=v.length,ie=w+(D?1:-1);D?ie--:++ie<X;)if(L(v[ie],ie,v))return ie;return-1}function qn(v,L,w){return L===L?Ip(v,L,w):ui(v,Yo,w)}function hp(v,L,w,D){for(var X=w-1,ie=v.length;++X<ie;)if(D(v[X],L))return X;return-1}function Yo(v){return v!==v}function Jo(v,L){var w=v==null?0:v.length;return w?Us(v,L)/w:jr}function Ds(v){return function(L){return L==null?i:L[v]}}function Ms(v){return function(L){return v==null?i:v[L]}}function Qo(v,L,w,D,X){return X(v,function(ie,xe,ue){w=D?(D=!1,ie):L(w,ie,xe,ue)}),w}function pp(v,L){var w=v.length;for(v.sort(L);w--;)v[w]=v[w].value;return v}function Us(v,L){for(var w,D=-1,X=v.length;++D<X;){var ie=L(v[D]);ie!==i&&(w=w===i?ie:w+ie)}return w}function ks(v,L){for(var w=-1,D=Array(v);++w<v;)D[w]=L(w);return D}function dp(v,L){return Ee(L,function(w){return[w,v[w]]})}function Zo(v){return v&&v.slice(0,nu(v)+1).replace(ms,"")}function nt(v){return function(L){return v(L)}}function Fs(v,L){return Ee(L,function(w){return v[w]})}function Ir(v,L){return v.has(L)}function jo(v,L){for(var w=-1,D=v.length;++w<D&&qn(L,v[w],0)>-1;);return w}function eu(v,L){for(var w=v.length;w--&&qn(L,v[w],0)>-1;);return w}function Ep(v,L){for(var w=v.length,D=0;w--;)v[w]===L&&++D;return D}var _p=Ms(jh),gp=Ms(ep);function Np(v){return"\\"+np[v]}function Tp(v,L){return v==null?i:v[L]}function zn(v){return Yh.test(v)}function vp(v){return Jh.test(v)}function bp(v){for(var L,w=[];!(L=v.next()).done;)w.push(L.value);return w}function Cs(v){var L=-1,w=Array(v.size);return v.forEach(function(D,X){w[++L]=[X,D]}),w}function tu(v,L){return function(w){return v(L(w))}}function dn(v,L){for(var w=-1,D=v.length,X=0,ie=[];++w<D;){var xe=v[w];(xe===L||xe===T)&&(v[w]=T,ie[X++]=w)}return ie}function li(v){var L=-1,w=Array(v.size);return v.forEach(function(D){w[++L]=D}),w}function mp(v){var L=-1,w=Array(v.size);return v.forEach(function(D){w[++L]=[D,D]}),w}function Ip(v,L,w){for(var D=w-1,X=v.length;++D<X;)if(v[D]===L)return D;return-1}function Ap(v,L,w){for(var D=w+1;D--;)if(v[D]===L)return D;return D}function Kn(v){return zn(v)?Lp(v):lp(v)}function At(v){return zn(v)?yp(v):cp(v)}function nu(v){for(var L=v.length;L--&&Eh.test(v.charAt(L)););return L}var wp=Ms(tp);function Lp(v){for(var L=ys.lastIndex=0;ys.test(v);)++L;return L}function yp(v){return v.match(ys)||[]}function xp(v){return v.match(Kh)||[]}var Sp=function v(L){L=L==null?Re:Yn.defaults(Re.Object(),L,Yn.pick(Re,Qh));var w=L.Array,D=L.Date,X=L.Error,ie=L.Function,xe=L.Math,ue=L.Object,Bs=L.RegExp,Op=L.String,Et=L.TypeError,ci=w.prototype,Pp=ie.prototype,Jn=ue.prototype,fi=L["__core-js_shared__"],hi=Pp.toString,oe=Jn.hasOwnProperty,Rp=0,ru=function(){var e=/[^.]+$/.exec(fi&&fi.keys&&fi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),pi=Jn.toString,Dp=hi.call(ue),Mp=Re._,Up=Bs("^"+hi.call(oe).replace(bs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),di=Go?L.Buffer:i,En=L.Symbol,Ei=L.Uint8Array,iu=di?di.allocUnsafe:i,_i=tu(ue.getPrototypeOf,ue),su=ue.create,au=Jn.propertyIsEnumerable,gi=ci.splice,ou=En?En.isConcatSpreadable:i,Ar=En?En.iterator:i,yn=En?En.toStringTag:i,Ni=function(){try{var e=Rn(ue,"defineProperty");return e({},"",{}),e}catch{}}(),kp=L.clearTimeout!==Re.clearTimeout&&L.clearTimeout,Fp=D&&D.now!==Re.Date.now&&D.now,Cp=L.setTimeout!==Re.setTimeout&&L.setTimeout,Ti=xe.ceil,vi=xe.floor,Gs=ue.getOwnPropertySymbols,Bp=di?di.isBuffer:i,uu=L.isFinite,Gp=ci.join,Vp=tu(ue.keys,ue),Se=xe.max,Ce=xe.min,$p=D.now,Wp=L.parseInt,lu=xe.random,Xp=ci.reverse,Vs=Rn(L,"DataView"),wr=Rn(L,"Map"),$s=Rn(L,"Promise"),Qn=Rn(L,"Set"),Lr=Rn(L,"WeakMap"),yr=Rn(ue,"create"),bi=Lr&&new Lr,Zn={},Hp=Dn(Vs),qp=Dn(wr),zp=Dn($s),Kp=Dn(Qn),Yp=Dn(Lr),mi=En?En.prototype:i,xr=mi?mi.valueOf:i,cu=mi?mi.toString:i;function h(e){if(ve(e)&&!H(e)&&!(e instanceof Z)){if(e instanceof _t)return e;if(oe.call(e,"__wrapped__"))return fl(e)}return new _t(e)}var jn=function(){function e(){}return function(n){if(!ge(n))return{};if(su)return su(n);e.prototype=n;var a=new e;return e.prototype=i,a}}();function Ii(){}function _t(e,n){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}h.templateSettings={escape:lh,evaluate:ch,interpolate:To,variable:"",imports:{_:h}},h.prototype=Ii.prototype,h.prototype.constructor=h,_t.prototype=jn(Ii.prototype),_t.prototype.constructor=_t;function Z(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Dt,this.__views__=[]}function Jp(){var e=new Z(this.__wrapped__);return e.__actions__=Ke(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ke(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ke(this.__views__),e}function Qp(){if(this.__filtered__){var e=new Z(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Zp(){var e=this.__wrapped__.value(),n=this.__dir__,a=H(e),u=n<0,c=a?e.length:0,p=cE(0,c,this.__views__),E=p.start,N=p.end,b=N-E,x=u?N:E-1,S=this.__iteratees__,O=S.length,R=0,k=Ce(b,this.__takeCount__);if(!a||!u&&c==b&&k==b)return Mu(e,this.__actions__);var G=[];e:for(;b--&&R<k;){x+=n;for(var K=-1,V=e[x];++K<O;){var Q=S[K],ee=Q.iteratee,st=Q.type,We=ee(V);if(st==qf)V=We;else if(!We){if(st==po)continue e;break e}}G[R++]=V}return G}Z.prototype=jn(Ii.prototype),Z.prototype.constructor=Z;function xn(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function jp(){this.__data__=yr?yr(null):{},this.size=0}function ed(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function td(e){var n=this.__data__;if(yr){var a=n[e];return a===m?i:a}return oe.call(n,e)?n[e]:i}function nd(e){var n=this.__data__;return yr?n[e]!==i:oe.call(n,e)}function rd(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=yr&&n===i?m:n,this}xn.prototype.clear=jp,xn.prototype.delete=ed,xn.prototype.get=td,xn.prototype.has=nd,xn.prototype.set=rd;function Kt(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function id(){this.__data__=[],this.size=0}function sd(e){var n=this.__data__,a=Ai(n,e);if(a<0)return!1;var u=n.length-1;return a==u?n.pop():gi.call(n,a,1),--this.size,!0}function ad(e){var n=this.__data__,a=Ai(n,e);return a<0?i:n[a][1]}function od(e){return Ai(this.__data__,e)>-1}function ud(e,n){var a=this.__data__,u=Ai(a,e);return u<0?(++this.size,a.push([e,n])):a[u][1]=n,this}Kt.prototype.clear=id,Kt.prototype.delete=sd,Kt.prototype.get=ad,Kt.prototype.has=od,Kt.prototype.set=ud;function Yt(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function ld(){this.size=0,this.__data__={hash:new xn,map:new(wr||Kt),string:new xn}}function cd(e){var n=ki(this,e).delete(e);return this.size-=n?1:0,n}function fd(e){return ki(this,e).get(e)}function hd(e){return ki(this,e).has(e)}function pd(e,n){var a=ki(this,e),u=a.size;return a.set(e,n),this.size+=a.size==u?0:1,this}Yt.prototype.clear=ld,Yt.prototype.delete=cd,Yt.prototype.get=fd,Yt.prototype.has=hd,Yt.prototype.set=pd;function Sn(e){var n=-1,a=e==null?0:e.length;for(this.__data__=new Yt;++n<a;)this.add(e[n])}function dd(e){return this.__data__.set(e,m),this}function Ed(e){return this.__data__.has(e)}Sn.prototype.add=Sn.prototype.push=dd,Sn.prototype.has=Ed;function wt(e){var n=this.__data__=new Kt(e);this.size=n.size}function _d(){this.__data__=new Kt,this.size=0}function gd(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function Nd(e){return this.__data__.get(e)}function Td(e){return this.__data__.has(e)}function vd(e,n){var a=this.__data__;if(a instanceof Kt){var u=a.__data__;if(!wr||u.length<o-1)return u.push([e,n]),this.size=++a.size,this;a=this.__data__=new Yt(u)}return a.set(e,n),this.size=a.size,this}wt.prototype.clear=_d,wt.prototype.delete=gd,wt.prototype.get=Nd,wt.prototype.has=Td,wt.prototype.set=vd;function fu(e,n){var a=H(e),u=!a&&Mn(e),c=!a&&!u&&vn(e),p=!a&&!u&&!c&&rr(e),E=a||u||c||p,N=E?ks(e.length,Op):[],b=N.length;for(var x in e)(n||oe.call(e,x))&&!(E&&(x=="length"||c&&(x=="offset"||x=="parent")||p&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||jt(x,b)))&&N.push(x);return N}function hu(e){var n=e.length;return n?e[js(0,n-1)]:i}function bd(e,n){return Fi(Ke(e),On(n,0,e.length))}function md(e){return Fi(Ke(e))}function Ws(e,n,a){(a!==i&&!Lt(e[n],a)||a===i&&!(n in e))&&Jt(e,n,a)}function Sr(e,n,a){var u=e[n];(!(oe.call(e,n)&&Lt(u,a))||a===i&&!(n in e))&&Jt(e,n,a)}function Ai(e,n){for(var a=e.length;a--;)if(Lt(e[a][0],n))return a;return-1}function Id(e,n,a,u){return _n(e,function(c,p,E){n(u,c,a(c),E)}),u}function pu(e,n){return e&&Ut(n,Oe(n),e)}function Ad(e,n){return e&&Ut(n,Je(n),e)}function Jt(e,n,a){n=="__proto__"&&Ni?Ni(e,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[n]=a}function Xs(e,n){for(var a=-1,u=n.length,c=w(u),p=e==null;++a<u;)c[a]=p?i:Aa(e,n[a]);return c}function On(e,n,a){return e===e&&(a!==i&&(e=e<=a?e:a),n!==i&&(e=e>=n?e:n)),e}function gt(e,n,a,u,c,p){var E,N=n&y,b=n&$,x=n&J;if(a&&(E=c?a(e,u,c,p):a(e)),E!==i)return E;if(!ge(e))return e;var S=H(e);if(S){if(E=hE(e),!N)return Ke(e,E)}else{var O=Be(e),R=O==ni||O==Eo;if(vn(e))return Fu(e,N);if(O==zt||O==Wn||R&&!c){if(E=b||R?{}:nl(e),!N)return b?tE(e,Ad(E,e)):eE(e,pu(E,e))}else{if(!ce[O])return c?e:{};E=pE(e,O,N)}}p||(p=new wt);var k=p.get(e);if(k)return k;p.set(e,E),Pl(e)?e.forEach(function(V){E.add(gt(V,n,a,V,e,p))}):Sl(e)&&e.forEach(function(V,Q){E.set(Q,gt(V,n,a,Q,e,p))});var G=x?b?ca:la:b?Je:Oe,K=S?i:G(e);return dt(K||e,function(V,Q){K&&(Q=V,V=e[Q]),Sr(E,Q,gt(V,n,a,Q,e,p))}),E}function wd(e){var n=Oe(e);return function(a){return du(a,e,n)}}function du(e,n,a){var u=a.length;if(e==null)return!u;for(e=ue(e);u--;){var c=a[u],p=n[c],E=e[c];if(E===i&&!(c in e)||!p(E))return!1}return!0}function Eu(e,n,a){if(typeof e!="function")throw new Et(f);return kr(function(){e.apply(i,a)},n)}function Or(e,n,a,u){var c=-1,p=oi,E=!0,N=e.length,b=[],x=n.length;if(!N)return b;a&&(n=Ee(n,nt(a))),u?(p=Os,E=!1):n.length>=o&&(p=Ir,E=!1,n=new Sn(n));e:for(;++c<N;){var S=e[c],O=a==null?S:a(S);if(S=u||S!==0?S:0,E&&O===O){for(var R=x;R--;)if(n[R]===O)continue e;b.push(S)}else p(n,O,u)||b.push(S)}return b}var _n=$u(Mt),_u=$u(qs,!0);function Ld(e,n){var a=!0;return _n(e,function(u,c,p){return a=!!n(u,c,p),a}),a}function wi(e,n,a){for(var u=-1,c=e.length;++u<c;){var p=e[u],E=n(p);if(E!=null&&(N===i?E===E&&!it(E):a(E,N)))var N=E,b=p}return b}function yd(e,n,a,u){var c=e.length;for(a=z(a),a<0&&(a=-a>c?0:c+a),u=u===i||u>c?c:z(u),u<0&&(u+=c),u=a>u?0:Dl(u);a<u;)e[a++]=n;return e}function gu(e,n){var a=[];return _n(e,function(u,c,p){n(u,c,p)&&a.push(u)}),a}function De(e,n,a,u,c){var p=-1,E=e.length;for(a||(a=EE),c||(c=[]);++p<E;){var N=e[p];n>0&&a(N)?n>1?De(N,n-1,a,u,c):pn(c,N):u||(c[c.length]=N)}return c}var Hs=Wu(),Nu=Wu(!0);function Mt(e,n){return e&&Hs(e,n,Oe)}function qs(e,n){return e&&Nu(e,n,Oe)}function Li(e,n){return hn(n,function(a){return en(e[a])})}function Pn(e,n){n=Nn(n,e);for(var a=0,u=n.length;e!=null&&a<u;)e=e[kt(n[a++])];return a&&a==u?e:i}function Tu(e,n,a){var u=n(e);return H(e)?u:pn(u,a(e))}function Ve(e){return e==null?e===i?nh:eh:yn&&yn in ue(e)?lE(e):mE(e)}function zs(e,n){return e>n}function xd(e,n){return e!=null&&oe.call(e,n)}function Sd(e,n){return e!=null&&n in ue(e)}function Od(e,n,a){return e>=Ce(n,a)&&e<Se(n,a)}function Ks(e,n,a){for(var u=a?Os:oi,c=e[0].length,p=e.length,E=p,N=w(p),b=1/0,x=[];E--;){var S=e[E];E&&n&&(S=Ee(S,nt(n))),b=Ce(S.length,b),N[E]=!a&&(n||c>=120&&S.length>=120)?new Sn(E&&S):i}S=e[0];var O=-1,R=N[0];e:for(;++O<c&&x.length<b;){var k=S[O],G=n?n(k):k;if(k=a||k!==0?k:0,!(R?Ir(R,G):u(x,G,a))){for(E=p;--E;){var K=N[E];if(!(K?Ir(K,G):u(e[E],G,a)))continue e}R&&R.push(G),x.push(k)}}return x}function Pd(e,n,a,u){return Mt(e,function(c,p,E){n(u,a(c),p,E)}),u}function Pr(e,n,a){n=Nn(n,e),e=al(e,n);var u=e==null?e:e[kt(Tt(n))];return u==null?i:tt(u,e,a)}function vu(e){return ve(e)&&Ve(e)==Wn}function Rd(e){return ve(e)&&Ve(e)==mr}function Dd(e){return ve(e)&&Ve(e)==gr}function Rr(e,n,a,u,c){return e===n?!0:e==null||n==null||!ve(e)&&!ve(n)?e!==e&&n!==n:Md(e,n,a,u,Rr,c)}function Md(e,n,a,u,c,p){var E=H(e),N=H(n),b=E?ei:Be(e),x=N?ei:Be(n);b=b==Wn?zt:b,x=x==Wn?zt:x;var S=b==zt,O=x==zt,R=b==x;if(R&&vn(e)){if(!vn(n))return!1;E=!0,S=!1}if(R&&!S)return p||(p=new wt),E||rr(e)?ju(e,n,a,u,c,p):oE(e,n,b,a,u,c,p);if(!(a&ne)){var k=S&&oe.call(e,"__wrapped__"),G=O&&oe.call(n,"__wrapped__");if(k||G){var K=k?e.value():e,V=G?n.value():n;return p||(p=new wt),c(K,V,a,u,p)}}return R?(p||(p=new wt),uE(e,n,a,u,c,p)):!1}function Ud(e){return ve(e)&&Be(e)==mt}function Ys(e,n,a,u){var c=a.length,p=c,E=!u;if(e==null)return!p;for(e=ue(e);c--;){var N=a[c];if(E&&N[2]?N[1]!==e[N[0]]:!(N[0]in e))return!1}for(;++c<p;){N=a[c];var b=N[0],x=e[b],S=N[1];if(E&&N[2]){if(x===i&&!(b in e))return!1}else{var O=new wt;if(u)var R=u(x,S,b,e,n,O);if(!(R===i?Rr(S,x,ne|re,u,O):R))return!1}}return!0}function bu(e){if(!ge(e)||gE(e))return!1;var n=en(e)?Up:wh;return n.test(Dn(e))}function kd(e){return ve(e)&&Ve(e)==Tr}function Fd(e){return ve(e)&&Be(e)==It}function Cd(e){return ve(e)&&Wi(e.length)&&!!fe[Ve(e)]}function mu(e){return typeof e=="function"?e:e==null?Qe:typeof e=="object"?H(e)?wu(e[0],e[1]):Au(e):Xl(e)}function Js(e){if(!Ur(e))return Vp(e);var n=[];for(var a in ue(e))oe.call(e,a)&&a!="constructor"&&n.push(a);return n}function Bd(e){if(!ge(e))return bE(e);var n=Ur(e),a=[];for(var u in e)u=="constructor"&&(n||!oe.call(e,u))||a.push(u);return a}function Qs(e,n){return e<n}function Iu(e,n){var a=-1,u=Ye(e)?w(e.length):[];return _n(e,function(c,p,E){u[++a]=n(c,p,E)}),u}function Au(e){var n=ha(e);return n.length==1&&n[0][2]?il(n[0][0],n[0][1]):function(a){return a===e||Ys(a,e,n)}}function wu(e,n){return da(e)&&rl(n)?il(kt(e),n):function(a){var u=Aa(a,e);return u===i&&u===n?wa(a,e):Rr(n,u,ne|re)}}function yi(e,n,a,u,c){e!==n&&Hs(n,function(p,E){if(c||(c=new wt),ge(p))Gd(e,n,E,a,yi,u,c);else{var N=u?u(_a(e,E),p,E+"",e,n,c):i;N===i&&(N=p),Ws(e,E,N)}},Je)}function Gd(e,n,a,u,c,p,E){var N=_a(e,a),b=_a(n,a),x=E.get(b);if(x){Ws(e,a,x);return}var S=p?p(N,b,a+"",e,n,E):i,O=S===i;if(O){var R=H(b),k=!R&&vn(b),G=!R&&!k&&rr(b);S=b,R||k||G?H(N)?S=N:Ie(N)?S=Ke(N):k?(O=!1,S=Fu(b,!0)):G?(O=!1,S=Cu(b,!0)):S=[]:Fr(b)||Mn(b)?(S=N,Mn(N)?S=Ml(N):(!ge(N)||en(N))&&(S=nl(b))):O=!1}O&&(E.set(b,S),c(S,b,u,p,E),E.delete(b)),Ws(e,a,S)}function Lu(e,n){var a=e.length;if(a)return n+=n<0?a:0,jt(n,a)?e[n]:i}function yu(e,n,a){n.length?n=Ee(n,function(p){return H(p)?function(E){return Pn(E,p.length===1?p[0]:p)}:p}):n=[Qe];var u=-1;n=Ee(n,nt(B()));var c=Iu(e,function(p,E,N){var b=Ee(n,function(x){return x(p)});return{criteria:b,index:++u,value:p}});return pp(c,function(p,E){return jd(p,E,a)})}function Vd(e,n){return xu(e,n,function(a,u){return wa(e,u)})}function xu(e,n,a){for(var u=-1,c=n.length,p={};++u<c;){var E=n[u],N=Pn(e,E);a(N,E)&&Dr(p,Nn(E,e),N)}return p}function $d(e){return function(n){return Pn(n,e)}}function Zs(e,n,a,u){var c=u?hp:qn,p=-1,E=n.length,N=e;for(e===n&&(n=Ke(n)),a&&(N=Ee(e,nt(a)));++p<E;)for(var b=0,x=n[p],S=a?a(x):x;(b=c(N,S,b,u))>-1;)N!==e&&gi.call(N,b,1),gi.call(e,b,1);return e}function Su(e,n){for(var a=e?n.length:0,u=a-1;a--;){var c=n[a];if(a==u||c!==p){var p=c;jt(c)?gi.call(e,c,1):na(e,c)}}return e}function js(e,n){return e+vi(lu()*(n-e+1))}function Wd(e,n,a,u){for(var c=-1,p=Se(Ti((n-e)/(a||1)),0),E=w(p);p--;)E[u?p:++c]=e,e+=a;return E}function ea(e,n){var a="";if(!e||n<1||n>fn)return a;do n%2&&(a+=e),n=vi(n/2),n&&(e+=e);while(n);return a}function Y(e,n){return ga(sl(e,n,Qe),e+"")}function Xd(e){return hu(ir(e))}function Hd(e,n){var a=ir(e);return Fi(a,On(n,0,a.length))}function Dr(e,n,a,u){if(!ge(e))return e;n=Nn(n,e);for(var c=-1,p=n.length,E=p-1,N=e;N!=null&&++c<p;){var b=kt(n[c]),x=a;if(b==="__proto__"||b==="constructor"||b==="prototype")return e;if(c!=E){var S=N[b];x=u?u(S,b,N):i,x===i&&(x=ge(S)?S:jt(n[c+1])?[]:{})}Sr(N,b,x),N=N[b]}return e}var Ou=bi?function(e,n){return bi.set(e,n),e}:Qe,qd=Ni?function(e,n){return Ni(e,"toString",{configurable:!0,enumerable:!1,value:ya(n),writable:!0})}:Qe;function zd(e){return Fi(ir(e))}function Nt(e,n,a){var u=-1,c=e.length;n<0&&(n=-n>c?0:c+n),a=a>c?c:a,a<0&&(a+=c),c=n>a?0:a-n>>>0,n>>>=0;for(var p=w(c);++u<c;)p[u]=e[u+n];return p}function Kd(e,n){var a;return _n(e,function(u,c,p){return a=n(u,c,p),!a}),!!a}function xi(e,n,a){var u=0,c=e==null?u:e.length;if(typeof n=="number"&&n===n&&c<=Jf){for(;u<c;){var p=u+c>>>1,E=e[p];E!==null&&!it(E)&&(a?E<=n:E<n)?u=p+1:c=p}return c}return ta(e,n,Qe,a)}function ta(e,n,a,u){var c=0,p=e==null?0:e.length;if(p===0)return 0;n=a(n);for(var E=n!==n,N=n===null,b=it(n),x=n===i;c<p;){var S=vi((c+p)/2),O=a(e[S]),R=O!==i,k=O===null,G=O===O,K=it(O);if(E)var V=u||G;else x?V=G&&(u||R):N?V=G&&R&&(u||!k):b?V=G&&R&&!k&&(u||!K):k||K?V=!1:V=u?O<=n:O<n;V?c=S+1:p=S}return Ce(p,Yf)}function Pu(e,n){for(var a=-1,u=e.length,c=0,p=[];++a<u;){var E=e[a],N=n?n(E):E;if(!a||!Lt(N,b)){var b=N;p[c++]=E===0?0:E}}return p}function Ru(e){return typeof e=="number"?e:it(e)?jr:+e}function rt(e){if(typeof e=="string")return e;if(H(e))return Ee(e,rt)+"";if(it(e))return cu?cu.call(e):"";var n=e+"";return n=="0"&&1/e==-wn?"-0":n}function gn(e,n,a){var u=-1,c=oi,p=e.length,E=!0,N=[],b=N;if(a)E=!1,c=Os;else if(p>=o){var x=n?null:sE(e);if(x)return li(x);E=!1,c=Ir,b=new Sn}else b=n?[]:N;e:for(;++u<p;){var S=e[u],O=n?n(S):S;if(S=a||S!==0?S:0,E&&O===O){for(var R=b.length;R--;)if(b[R]===O)continue e;n&&b.push(O),N.push(S)}else c(b,O,a)||(b!==N&&b.push(O),N.push(S))}return N}function na(e,n){return n=Nn(n,e),e=al(e,n),e==null||delete e[kt(Tt(n))]}function Du(e,n,a,u){return Dr(e,n,a(Pn(e,n)),u)}function Si(e,n,a,u){for(var c=e.length,p=u?c:-1;(u?p--:++p<c)&&n(e[p],p,e););return a?Nt(e,u?0:p,u?p+1:c):Nt(e,u?p+1:0,u?c:p)}function Mu(e,n){var a=e;return a instanceof Z&&(a=a.value()),Ps(n,function(u,c){return c.func.apply(c.thisArg,pn([u],c.args))},a)}function ra(e,n,a){var u=e.length;if(u<2)return u?gn(e[0]):[];for(var c=-1,p=w(u);++c<u;)for(var E=e[c],N=-1;++N<u;)N!=c&&(p[c]=Or(p[c]||E,e[N],n,a));return gn(De(p,1),n,a)}function Uu(e,n,a){for(var u=-1,c=e.length,p=n.length,E={};++u<c;){var N=u<p?n[u]:i;a(E,e[u],N)}return E}function ia(e){return Ie(e)?e:[]}function sa(e){return typeof e=="function"?e:Qe}function Nn(e,n){return H(e)?e:da(e,n)?[e]:cl(ae(e))}var Yd=Y;function Tn(e,n,a){var u=e.length;return a=a===i?u:a,!n&&a>=u?e:Nt(e,n,a)}var ku=kp||function(e){return Re.clearTimeout(e)};function Fu(e,n){if(n)return e.slice();var a=e.length,u=iu?iu(a):new e.constructor(a);return e.copy(u),u}function aa(e){var n=new e.constructor(e.byteLength);return new Ei(n).set(new Ei(e)),n}function Jd(e,n){var a=n?aa(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.byteLength)}function Qd(e){var n=new e.constructor(e.source,vo.exec(e));return n.lastIndex=e.lastIndex,n}function Zd(e){return xr?ue(xr.call(e)):{}}function Cu(e,n){var a=n?aa(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.length)}function Bu(e,n){if(e!==n){var a=e!==i,u=e===null,c=e===e,p=it(e),E=n!==i,N=n===null,b=n===n,x=it(n);if(!N&&!x&&!p&&e>n||p&&E&&b&&!N&&!x||u&&E&&b||!a&&b||!c)return 1;if(!u&&!p&&!x&&e<n||x&&a&&c&&!u&&!p||N&&a&&c||!E&&c||!b)return-1}return 0}function jd(e,n,a){for(var u=-1,c=e.criteria,p=n.criteria,E=c.length,N=a.length;++u<E;){var b=Bu(c[u],p[u]);if(b){if(u>=N)return b;var x=a[u];return b*(x=="desc"?-1:1)}}return e.index-n.index}function Gu(e,n,a,u){for(var c=-1,p=e.length,E=a.length,N=-1,b=n.length,x=Se(p-E,0),S=w(b+x),O=!u;++N<b;)S[N]=n[N];for(;++c<E;)(O||c<p)&&(S[a[c]]=e[c]);for(;x--;)S[N++]=e[c++];return S}function Vu(e,n,a,u){for(var c=-1,p=e.length,E=-1,N=a.length,b=-1,x=n.length,S=Se(p-N,0),O=w(S+x),R=!u;++c<S;)O[c]=e[c];for(var k=c;++b<x;)O[k+b]=n[b];for(;++E<N;)(R||c<p)&&(O[k+a[E]]=e[c++]);return O}function Ke(e,n){var a=-1,u=e.length;for(n||(n=w(u));++a<u;)n[a]=e[a];return n}function Ut(e,n,a,u){var c=!a;a||(a={});for(var p=-1,E=n.length;++p<E;){var N=n[p],b=u?u(a[N],e[N],N,a,e):i;b===i&&(b=e[N]),c?Jt(a,N,b):Sr(a,N,b)}return a}function eE(e,n){return Ut(e,pa(e),n)}function tE(e,n){return Ut(e,el(e),n)}function Oi(e,n){return function(a,u){var c=H(a)?ap:Id,p=n?n():{};return c(a,e,B(u,2),p)}}function er(e){return Y(function(n,a){var u=-1,c=a.length,p=c>1?a[c-1]:i,E=c>2?a[2]:i;for(p=e.length>3&&typeof p=="function"?(c--,p):i,E&&$e(a[0],a[1],E)&&(p=c<3?i:p,c=1),n=ue(n);++u<c;){var N=a[u];N&&e(n,N,u,p)}return n})}function $u(e,n){return function(a,u){if(a==null)return a;if(!Ye(a))return e(a,u);for(var c=a.length,p=n?c:-1,E=ue(a);(n?p--:++p<c)&&u(E[p],p,E)!==!1;);return a}}function Wu(e){return function(n,a,u){for(var c=-1,p=ue(n),E=u(n),N=E.length;N--;){var b=E[e?N:++c];if(a(p[b],b,p)===!1)break}return n}}function nE(e,n,a){var u=n&j,c=Mr(e);function p(){var E=this&&this!==Re&&this instanceof p?c:e;return E.apply(u?a:this,arguments)}return p}function Xu(e){return function(n){n=ae(n);var a=zn(n)?At(n):i,u=a?a[0]:n.charAt(0),c=a?Tn(a,1).join(""):n.slice(1);return u[e]()+c}}function tr(e){return function(n){return Ps($l(Vl(n).replace(qh,"")),e,"")}}function Mr(e){return function(){var n=arguments;switch(n.length){case 0:return new e;case 1:return new e(n[0]);case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[1],n[2]);case 4:return new e(n[0],n[1],n[2],n[3]);case 5:return new e(n[0],n[1],n[2],n[3],n[4]);case 6:return new e(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new e(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var a=jn(e.prototype),u=e.apply(a,n);return ge(u)?u:a}}function rE(e,n,a){var u=Mr(e);function c(){for(var p=arguments.length,E=w(p),N=p,b=nr(c);N--;)E[N]=arguments[N];var x=p<3&&E[0]!==b&&E[p-1]!==b?[]:dn(E,b);if(p-=x.length,p<a)return Yu(e,n,Pi,c.placeholder,i,E,x,i,i,a-p);var S=this&&this!==Re&&this instanceof c?u:e;return tt(S,this,E)}return c}function Hu(e){return function(n,a,u){var c=ue(n);if(!Ye(n)){var p=B(a,3);n=Oe(n),a=function(N){return p(c[N],N,c)}}var E=e(n,a,u);return E>-1?c[p?n[E]:E]:i}}function qu(e){return Zt(function(n){var a=n.length,u=a,c=_t.prototype.thru;for(e&&n.reverse();u--;){var p=n[u];if(typeof p!="function")throw new Et(f);if(c&&!E&&Ui(p)=="wrapper")var E=new _t([],!0)}for(u=E?u:a;++u<a;){p=n[u];var N=Ui(p),b=N=="wrapper"?fa(p):i;b&&Ea(b[0])&&b[1]==(qt|ht|ze|Er)&&!b[4].length&&b[9]==1?E=E[Ui(b[0])].apply(E,b[3]):E=p.length==1&&Ea(p)?E[N]():E.thru(p)}return function(){var x=arguments,S=x[0];if(E&&x.length==1&&H(S))return E.plant(S).value();for(var O=0,R=a?n[O].apply(this,x):S;++O<a;)R=n[O].call(this,R);return R}})}function Pi(e,n,a,u,c,p,E,N,b,x){var S=n&qt,O=n&j,R=n&de,k=n&(ht|Rt),G=n&fs,K=R?i:Mr(e);function V(){for(var Q=arguments.length,ee=w(Q),st=Q;st--;)ee[st]=arguments[st];if(k)var We=nr(V),at=Ep(ee,We);if(u&&(ee=Gu(ee,u,c,k)),p&&(ee=Vu(ee,p,E,k)),Q-=at,k&&Q<x){var Ae=dn(ee,We);return Yu(e,n,Pi,V.placeholder,a,ee,Ae,N,b,x-Q)}var yt=O?a:this,nn=R?yt[e]:e;return Q=ee.length,N?ee=IE(ee,N):G&&Q>1&&ee.reverse(),S&&b<Q&&(ee.length=b),this&&this!==Re&&this instanceof V&&(nn=K||Mr(nn)),nn.apply(yt,ee)}return V}function zu(e,n){return function(a,u){return Pd(a,e,n(u),{})}}function Ri(e,n){return function(a,u){var c;if(a===i&&u===i)return n;if(a!==i&&(c=a),u!==i){if(c===i)return u;typeof a=="string"||typeof u=="string"?(a=rt(a),u=rt(u)):(a=Ru(a),u=Ru(u)),c=e(a,u)}return c}}function oa(e){return Zt(function(n){return n=Ee(n,nt(B())),Y(function(a){var u=this;return e(n,function(c){return tt(c,u,a)})})})}function Di(e,n){n=n===i?" ":rt(n);var a=n.length;if(a<2)return a?ea(n,e):n;var u=ea(n,Ti(e/Kn(n)));return zn(n)?Tn(At(u),0,e).join(""):u.slice(0,e)}function iE(e,n,a,u){var c=n&j,p=Mr(e);function E(){for(var N=-1,b=arguments.length,x=-1,S=u.length,O=w(S+b),R=this&&this!==Re&&this instanceof E?p:e;++x<S;)O[x]=u[x];for(;b--;)O[x++]=arguments[++N];return tt(R,c?a:this,O)}return E}function Ku(e){return function(n,a,u){return u&&typeof u!="number"&&$e(n,a,u)&&(a=u=i),n=tn(n),a===i?(a=n,n=0):a=tn(a),u=u===i?n<a?1:-1:tn(u),Wd(n,a,u,e)}}function Mi(e){return function(n,a){return typeof n=="string"&&typeof a=="string"||(n=vt(n),a=vt(a)),e(n,a)}}function Yu(e,n,a,u,c,p,E,N,b,x){var S=n&ht,O=S?E:i,R=S?i:E,k=S?p:i,G=S?i:p;n|=S?ze:dr,n&=~(S?dr:ze),n&et||(n&=-4);var K=[e,n,c,k,O,G,R,N,b,x],V=a.apply(i,K);return Ea(e)&&ol(V,K),V.placeholder=u,ul(V,e,n)}function ua(e){var n=xe[e];return function(a,u){if(a=vt(a),u=u==null?0:Ce(z(u),292),u&&uu(a)){var c=(ae(a)+"e").split("e"),p=n(c[0]+"e"+(+c[1]+u));return c=(ae(p)+"e").split("e"),+(c[0]+"e"+(+c[1]-u))}return n(a)}}var sE=Qn&&1/li(new Qn([,-0]))[1]==wn?function(e){return new Qn(e)}:Oa;function Ju(e){return function(n){var a=Be(n);return a==mt?Cs(n):a==It?mp(n):dp(n,e(n))}}function Qt(e,n,a,u,c,p,E,N){var b=n&de;if(!b&&typeof e!="function")throw new Et(f);var x=u?u.length:0;if(x||(n&=-97,u=c=i),E=E===i?E:Se(z(E),0),N=N===i?N:z(N),x-=c?c.length:0,n&dr){var S=u,O=c;u=c=i}var R=b?i:fa(e),k=[e,n,a,u,c,S,O,p,E,N];if(R&&vE(k,R),e=k[0],n=k[1],a=k[2],u=k[3],c=k[4],N=k[9]=k[9]===i?b?0:e.length:Se(k[9]-x,0),!N&&n&(ht|Rt)&&(n&=-25),!n||n==j)var G=nE(e,n,a);else n==ht||n==Rt?G=rE(e,n,N):(n==ze||n==(j|ze))&&!c.length?G=iE(e,n,a,u):G=Pi.apply(i,k);var K=R?Ou:ol;return ul(K(G,k),e,n)}function Qu(e,n,a,u){return e===i||Lt(e,Jn[a])&&!oe.call(u,a)?n:e}function Zu(e,n,a,u,c,p){return ge(e)&&ge(n)&&(p.set(n,e),yi(e,n,i,Zu,p),p.delete(n)),e}function aE(e){return Fr(e)?i:e}function ju(e,n,a,u,c,p){var E=a&ne,N=e.length,b=n.length;if(N!=b&&!(E&&b>N))return!1;var x=p.get(e),S=p.get(n);if(x&&S)return x==n&&S==e;var O=-1,R=!0,k=a&re?new Sn:i;for(p.set(e,n),p.set(n,e);++O<N;){var G=e[O],K=n[O];if(u)var V=E?u(K,G,O,n,e,p):u(G,K,O,e,n,p);if(V!==i){if(V)continue;R=!1;break}if(k){if(!Rs(n,function(Q,ee){if(!Ir(k,ee)&&(G===Q||c(G,Q,a,u,p)))return k.push(ee)})){R=!1;break}}else if(!(G===K||c(G,K,a,u,p))){R=!1;break}}return p.delete(e),p.delete(n),R}function oE(e,n,a,u,c,p,E){switch(a){case Xn:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case mr:return!(e.byteLength!=n.byteLength||!p(new Ei(e),new Ei(n)));case _r:case gr:case Nr:return Lt(+e,+n);case ti:return e.name==n.name&&e.message==n.message;case Tr:case vr:return e==n+"";case mt:var N=Cs;case It:var b=u&ne;if(N||(N=li),e.size!=n.size&&!b)return!1;var x=E.get(e);if(x)return x==n;u|=re,E.set(e,n);var S=ju(N(e),N(n),u,c,p,E);return E.delete(e),S;case ri:if(xr)return xr.call(e)==xr.call(n)}return!1}function uE(e,n,a,u,c,p){var E=a&ne,N=la(e),b=N.length,x=la(n),S=x.length;if(b!=S&&!E)return!1;for(var O=b;O--;){var R=N[O];if(!(E?R in n:oe.call(n,R)))return!1}var k=p.get(e),G=p.get(n);if(k&&G)return k==n&&G==e;var K=!0;p.set(e,n),p.set(n,e);for(var V=E;++O<b;){R=N[O];var Q=e[R],ee=n[R];if(u)var st=E?u(ee,Q,R,n,e,p):u(Q,ee,R,e,n,p);if(!(st===i?Q===ee||c(Q,ee,a,u,p):st)){K=!1;break}V||(V=R=="constructor")}if(K&&!V){var We=e.constructor,at=n.constructor;We!=at&&"constructor"in e&&"constructor"in n&&!(typeof We=="function"&&We instanceof We&&typeof at=="function"&&at instanceof at)&&(K=!1)}return p.delete(e),p.delete(n),K}function Zt(e){return ga(sl(e,i,dl),e+"")}function la(e){return Tu(e,Oe,pa)}function ca(e){return Tu(e,Je,el)}var fa=bi?function(e){return bi.get(e)}:Oa;function Ui(e){for(var n=e.name+"",a=Zn[n],u=oe.call(Zn,n)?a.length:0;u--;){var c=a[u],p=c.func;if(p==null||p==e)return c.name}return n}function nr(e){var n=oe.call(h,"placeholder")?h:e;return n.placeholder}function B(){var e=h.iteratee||xa;return e=e===xa?mu:e,arguments.length?e(arguments[0],arguments[1]):e}function ki(e,n){var a=e.__data__;return _E(n)?a[typeof n=="string"?"string":"hash"]:a.map}function ha(e){for(var n=Oe(e),a=n.length;a--;){var u=n[a],c=e[u];n[a]=[u,c,rl(c)]}return n}function Rn(e,n){var a=Tp(e,n);return bu(a)?a:i}function lE(e){var n=oe.call(e,yn),a=e[yn];try{e[yn]=i;var u=!0}catch{}var c=pi.call(e);return u&&(n?e[yn]=a:delete e[yn]),c}var pa=Gs?function(e){return e==null?[]:(e=ue(e),hn(Gs(e),function(n){return au.call(e,n)}))}:Pa,el=Gs?function(e){for(var n=[];e;)pn(n,pa(e)),e=_i(e);return n}:Pa,Be=Ve;(Vs&&Be(new Vs(new ArrayBuffer(1)))!=Xn||wr&&Be(new wr)!=mt||$s&&Be($s.resolve())!=_o||Qn&&Be(new Qn)!=It||Lr&&Be(new Lr)!=br)&&(Be=function(e){var n=Ve(e),a=n==zt?e.constructor:i,u=a?Dn(a):"";if(u)switch(u){case Hp:return Xn;case qp:return mt;case zp:return _o;case Kp:return It;case Yp:return br}return n});function cE(e,n,a){for(var u=-1,c=a.length;++u<c;){var p=a[u],E=p.size;switch(p.type){case"drop":e+=E;break;case"dropRight":n-=E;break;case"take":n=Ce(n,e+E);break;case"takeRight":e=Se(e,n-E);break}}return{start:e,end:n}}function fE(e){var n=e.match(gh);return n?n[1].split(Nh):[]}function tl(e,n,a){n=Nn(n,e);for(var u=-1,c=n.length,p=!1;++u<c;){var E=kt(n[u]);if(!(p=e!=null&&a(e,E)))break;e=e[E]}return p||++u!=c?p:(c=e==null?0:e.length,!!c&&Wi(c)&&jt(E,c)&&(H(e)||Mn(e)))}function hE(e){var n=e.length,a=new e.constructor(n);return n&&typeof e[0]=="string"&&oe.call(e,"index")&&(a.index=e.index,a.input=e.input),a}function nl(e){return typeof e.constructor=="function"&&!Ur(e)?jn(_i(e)):{}}function pE(e,n,a){var u=e.constructor;switch(n){case mr:return aa(e);case _r:case gr:return new u(+e);case Xn:return Jd(e,a);case hs:case ps:case ds:case Es:case _s:case gs:case Ns:case Ts:case vs:return Cu(e,a);case mt:return new u;case Nr:case vr:return new u(e);case Tr:return Qd(e);case It:return new u;case ri:return Zd(e)}}function dE(e,n){var a=n.length;if(!a)return e;var u=a-1;return n[u]=(a>1?"& ":"")+n[u],n=n.join(a>2?", ":" "),e.replace(_h,`{
10
10
  /* [wrapped with `+n+`] */
11
- `)}function dE(e){return H(e)||Mn(e)||!!(ou&&e&&e[ou])}function jt(e,n){var a=typeof e;return n=n??fn,!!n&&(a=="number"||a!="symbol"&&Lh.test(e))&&e>-1&&e%1==0&&e<n}function $e(e,n,a){if(!ge(a))return!1;var u=typeof n;return(u=="number"?Ye(a)&&jt(n,a.length):u=="string"&&n in a)?wt(a[n],e):!1}function da(e,n){if(H(e))return!1;var a=typeof e;return a=="number"||a=="symbol"||a=="boolean"||e==null||it(e)?!0:fh.test(e)||!ch.test(e)||n!=null&&e in ue(n)}function EE(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function Ea(e){var n=Ui(e),a=h[n];if(typeof a!="function"||!(n in Z.prototype))return!1;if(e===a)return!0;var u=fa(a);return!!u&&e===u[0]}function _E(e){return!!ru&&ru in e}var gE=fi?en:Ra;function Ur(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||Jn;return e===a}function rl(e){return e===e&&!ge(e)}function il(e,n){return function(a){return a==null?!1:a[e]===n&&(n!==i||e in ue(a))}}function NE(e){var n=Vi(e,function(u){return a.size===I&&a.clear(),u}),a=n.cache;return n}function TE(e,n){var a=e[1],u=n[1],c=a|u,p=c<(j|de|qt),E=u==qt&&a==ft||u==qt&&a==Er&&e[7].length<=n[8]||u==(qt|Er)&&n[7].length<=n[8]&&a==ft;if(!(p||E))return e;u&j&&(e[2]=n[2],c|=a&j?0:et);var N=n[3];if(N){var b=e[3];e[3]=b?Gu(b,N,n[4]):N,e[4]=b?dn(e[3],T):n[4]}return N=n[5],N&&(b=e[5],e[5]=b?Vu(b,N,n[6]):N,e[6]=b?dn(e[5],T):n[6]),N=n[7],N&&(e[7]=N),u&qt&&(e[8]=e[8]==null?n[8]:Ce(e[8],n[8])),e[9]==null&&(e[9]=n[9]),e[0]=n[0],e[1]=c,e}function vE(e){var n=[];if(e!=null)for(var a in ue(e))n.push(a);return n}function bE(e){return pi.call(e)}function sl(e,n,a){return n=Se(n===i?e.length-1:n,0),function(){for(var u=arguments,c=-1,p=Se(u.length-n,0),E=w(p);++c<p;)E[c]=u[n+c];c=-1;for(var N=w(n+1);++c<n;)N[c]=u[c];return N[n]=a(E),tt(e,this,N)}}function al(e,n){return n.length<2?e:Pn(e,gt(n,0,-1))}function mE(e,n){for(var a=e.length,u=Ce(n.length,a),c=Ke(e);u--;){var p=n[u];e[u]=jt(p,a)?c[p]:i}return e}function _a(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var ol=ll(Ou),kr=Fp||function(e,n){return Re.setTimeout(e,n)},ga=ll(Hd);function ul(e,n,a){var u=n+"";return ga(e,pE(u,IE(cE(u),a)))}function ll(e){var n=0,a=0;return function(){var u=Vp(),c=Xf-(u-a);if(a=u,c>0){if(++n>=Wf)return arguments[0]}else n=0;return e.apply(i,arguments)}}function Fi(e,n){var a=-1,u=e.length,c=u-1;for(n=n===i?u:n;++a<n;){var p=js(a,c),E=e[p];e[p]=e[a],e[a]=E}return e.length=n,e}var cl=NE(function(e){var n=[];return e.charCodeAt(0)===46&&n.push(""),e.replace(hh,function(a,u,c,p){n.push(c?p.replace(vh,"$1"):u||a)}),n});function kt(e){if(typeof e=="string"||it(e))return e;var n=e+"";return n=="0"&&1/e==-wn?"-0":n}function Dn(e){if(e!=null){try{return hi.call(e)}catch{}try{return e+""}catch{}}return""}function IE(e,n){return pt(Jf,function(a){var u="_."+a[0];n&a[1]&&!oi(e,u)&&e.push(u)}),e.sort()}function fl(e){if(e instanceof Z)return e.clone();var n=new Et(e.__wrapped__,e.__chain__);return n.__actions__=Ke(e.__actions__),n.__index__=e.__index__,n.__values__=e.__values__,n}function AE(e,n,a){(a?$e(e,n,a):n===i)?n=1:n=Se(z(n),0);var u=e==null?0:e.length;if(!u||n<1)return[];for(var c=0,p=0,E=w(Ti(u/n));c<u;)E[p++]=gt(e,c,c+=n);return E}function wE(e){for(var n=-1,a=e==null?0:e.length,u=0,c=[];++n<a;){var p=e[n];p&&(c[u++]=p)}return c}function LE(){var e=arguments.length;if(!e)return[];for(var n=w(e-1),a=arguments[0],u=e;u--;)n[u-1]=arguments[u];return pn(H(a)?Ke(a):[a],De(n,1))}var yE=Y(function(e,n){return Ie(e)?Or(e,De(n,1,Ie,!0)):[]}),xE=Y(function(e,n){var a=Nt(n);return Ie(a)&&(a=i),Ie(e)?Or(e,De(n,1,Ie,!0),B(a,2)):[]}),SE=Y(function(e,n){var a=Nt(n);return Ie(a)&&(a=i),Ie(e)?Or(e,De(n,1,Ie,!0),i,a):[]});function OE(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),gt(e,n<0?0:n,u)):[]}function PE(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),n=u-n,gt(e,0,n<0?0:n)):[]}function RE(e,n){return e&&e.length?Si(e,B(n,3),!0,!0):[]}function DE(e,n){return e&&e.length?Si(e,B(n,3),!0):[]}function ME(e,n,a,u){var c=e==null?0:e.length;return c?(a&&typeof a!="number"&&$e(e,n,a)&&(a=0,u=c),Ld(e,n,a,u)):[]}function hl(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=a==null?0:z(a);return c<0&&(c=Se(u+c,0)),ui(e,B(n,3),c)}function pl(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=u-1;return a!==i&&(c=z(a),c=a<0?Se(u+c,0):Ce(c,u-1)),ui(e,B(n,3),c,!0)}function dl(e){var n=e==null?0:e.length;return n?De(e,1):[]}function UE(e){var n=e==null?0:e.length;return n?De(e,wn):[]}function kE(e,n){var a=e==null?0:e.length;return a?(n=n===i?1:z(n),De(e,n)):[]}function FE(e){for(var n=-1,a=e==null?0:e.length,u={};++n<a;){var c=e[n];u[c[0]]=c[1]}return u}function El(e){return e&&e.length?e[0]:i}function CE(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=a==null?0:z(a);return c<0&&(c=Se(u+c,0)),qn(e,n,c)}function BE(e){var n=e==null?0:e.length;return n?gt(e,0,-1):[]}var GE=Y(function(e){var n=Ee(e,ia);return n.length&&n[0]===e[0]?Ks(n):[]}),VE=Y(function(e){var n=Nt(e),a=Ee(e,ia);return n===Nt(a)?n=i:a.pop(),a.length&&a[0]===e[0]?Ks(a,B(n,2)):[]}),$E=Y(function(e){var n=Nt(e),a=Ee(e,ia);return n=typeof n=="function"?n:i,n&&a.pop(),a.length&&a[0]===e[0]?Ks(a,i,n):[]});function WE(e,n){return e==null?"":Bp.call(e,n)}function Nt(e){var n=e==null?0:e.length;return n?e[n-1]:i}function XE(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=u;return a!==i&&(c=z(a),c=c<0?Se(u+c,0):Ce(c,u-1)),n===n?Ip(e,n,c):ui(e,Yo,c,!0)}function HE(e,n){return e&&e.length?Lu(e,z(n)):i}var qE=Y(_l);function _l(e,n){return e&&e.length&&n&&n.length?Zs(e,n):e}function zE(e,n,a){return e&&e.length&&n&&n.length?Zs(e,n,B(a,2)):e}function KE(e,n,a){return e&&e.length&&n&&n.length?Zs(e,n,i,a):e}var YE=Zt(function(e,n){var a=e==null?0:e.length,u=Xs(e,n);return Su(e,Ee(n,function(c){return jt(c,a)?+c:c}).sort(Bu)),u});function JE(e,n){var a=[];if(!(e&&e.length))return a;var u=-1,c=[],p=e.length;for(n=B(n,3);++u<p;){var E=e[u];n(E,u,e)&&(a.push(E),c.push(u))}return Su(e,c),a}function Na(e){return e==null?e:Wp.call(e)}function QE(e,n,a){var u=e==null?0:e.length;return u?(a&&typeof a!="number"&&$e(e,n,a)?(n=0,a=u):(n=n==null?0:z(n),a=a===i?u:z(a)),gt(e,n,a)):[]}function ZE(e,n){return xi(e,n)}function jE(e,n,a){return ta(e,n,B(a,2))}function e_(e,n){var a=e==null?0:e.length;if(a){var u=xi(e,n);if(u<a&&wt(e[u],n))return u}return-1}function t_(e,n){return xi(e,n,!0)}function n_(e,n,a){return ta(e,n,B(a,2),!0)}function r_(e,n){var a=e==null?0:e.length;if(a){var u=xi(e,n,!0)-1;if(wt(e[u],n))return u}return-1}function i_(e){return e&&e.length?Pu(e):[]}function s_(e,n){return e&&e.length?Pu(e,B(n,2)):[]}function a_(e){var n=e==null?0:e.length;return n?gt(e,1,n):[]}function o_(e,n,a){return e&&e.length?(n=a||n===i?1:z(n),gt(e,0,n<0?0:n)):[]}function u_(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),n=u-n,gt(e,n<0?0:n,u)):[]}function l_(e,n){return e&&e.length?Si(e,B(n,3),!1,!0):[]}function c_(e,n){return e&&e.length?Si(e,B(n,3)):[]}var f_=Y(function(e){return gn(De(e,1,Ie,!0))}),h_=Y(function(e){var n=Nt(e);return Ie(n)&&(n=i),gn(De(e,1,Ie,!0),B(n,2))}),p_=Y(function(e){var n=Nt(e);return n=typeof n=="function"?n:i,gn(De(e,1,Ie,!0),i,n)});function d_(e){return e&&e.length?gn(e):[]}function E_(e,n){return e&&e.length?gn(e,B(n,2)):[]}function __(e,n){return n=typeof n=="function"?n:i,e&&e.length?gn(e,i,n):[]}function Ta(e){if(!(e&&e.length))return[];var n=0;return e=hn(e,function(a){if(Ie(a))return n=Se(a.length,n),!0}),ks(n,function(a){return Ee(e,Ds(a))})}function gl(e,n){if(!(e&&e.length))return[];var a=Ta(e);return n==null?a:Ee(a,function(u){return tt(n,i,u)})}var g_=Y(function(e,n){return Ie(e)?Or(e,n):[]}),N_=Y(function(e){return ra(hn(e,Ie))}),T_=Y(function(e){var n=Nt(e);return Ie(n)&&(n=i),ra(hn(e,Ie),B(n,2))}),v_=Y(function(e){var n=Nt(e);return n=typeof n=="function"?n:i,ra(hn(e,Ie),i,n)}),b_=Y(Ta);function m_(e,n){return Uu(e||[],n||[],Sr)}function I_(e,n){return Uu(e||[],n||[],Dr)}var A_=Y(function(e){var n=e.length,a=n>1?e[n-1]:i;return a=typeof a=="function"?(e.pop(),a):i,gl(e,a)});function Nl(e){var n=h(e);return n.__chain__=!0,n}function w_(e,n){return n(e),e}function Ci(e,n){return n(e)}var L_=Zt(function(e){var n=e.length,a=n?e[0]:0,u=this.__wrapped__,c=function(p){return Xs(p,e)};return n>1||this.__actions__.length||!(u instanceof Z)||!jt(a)?this.thru(c):(u=u.slice(a,+a+(n?1:0)),u.__actions__.push({func:Ci,args:[c],thisArg:i}),new Et(u,this.__chain__).thru(function(p){return n&&!p.length&&p.push(i),p}))});function y_(){return Nl(this)}function x_(){return new Et(this.value(),this.__chain__)}function S_(){this.__values__===i&&(this.__values__=Rl(this.value()));var e=this.__index__>=this.__values__.length,n=e?i:this.__values__[this.__index__++];return{done:e,value:n}}function O_(){return this}function P_(e){for(var n,a=this;a instanceof Ii;){var u=fl(a);u.__index__=0,u.__values__=i,n?c.__wrapped__=u:n=u;var c=u;a=a.__wrapped__}return c.__wrapped__=e,n}function R_(){var e=this.__wrapped__;if(e instanceof Z){var n=e;return this.__actions__.length&&(n=new Z(this)),n=n.reverse(),n.__actions__.push({func:Ci,args:[Na],thisArg:i}),new Et(n,this.__chain__)}return this.thru(Na)}function D_(){return Mu(this.__wrapped__,this.__actions__)}var M_=Oi(function(e,n,a){oe.call(e,a)?++e[a]:Jt(e,a,1)});function U_(e,n,a){var u=H(e)?zo:wd;return a&&$e(e,n,a)&&(n=i),u(e,B(n,3))}function k_(e,n){var a=H(e)?hn:gu;return a(e,B(n,3))}var F_=Hu(hl),C_=Hu(pl);function B_(e,n){return De(Bi(e,n),1)}function G_(e,n){return De(Bi(e,n),wn)}function V_(e,n,a){return a=a===i?1:z(a),De(Bi(e,n),a)}function Tl(e,n){var a=H(e)?pt:_n;return a(e,B(n,3))}function vl(e,n){var a=H(e)?ap:_u;return a(e,B(n,3))}var $_=Oi(function(e,n,a){oe.call(e,a)?e[a].push(n):Jt(e,a,[n])});function W_(e,n,a,u){e=Ye(e)?e:ir(e),a=a&&!u?z(a):0;var c=e.length;return a<0&&(a=Se(c+a,0)),Xi(e)?a<=c&&e.indexOf(n,a)>-1:!!c&&qn(e,n,a)>-1}var X_=Y(function(e,n,a){var u=-1,c=typeof n=="function",p=Ye(e)?w(e.length):[];return _n(e,function(E){p[++u]=c?tt(n,E,a):Pr(E,n,a)}),p}),H_=Oi(function(e,n,a){Jt(e,a,n)});function Bi(e,n){var a=H(e)?Ee:Iu;return a(e,B(n,3))}function q_(e,n,a,u){return e==null?[]:(H(n)||(n=n==null?[]:[n]),a=u?i:a,H(a)||(a=a==null?[]:[a]),yu(e,n,a))}var z_=Oi(function(e,n,a){e[a?0:1].push(n)},function(){return[[],[]]});function K_(e,n,a){var u=H(e)?Ps:Qo,c=arguments.length<3;return u(e,B(n,4),a,c,_n)}function Y_(e,n,a){var u=H(e)?op:Qo,c=arguments.length<3;return u(e,B(n,4),a,c,_u)}function J_(e,n){var a=H(e)?hn:gu;return a(e,$i(B(n,3)))}function Q_(e){var n=H(e)?hu:Wd;return n(e)}function Z_(e,n,a){(a?$e(e,n,a):n===i)?n=1:n=z(n);var u=H(e)?vd:Xd;return u(e,n)}function j_(e){var n=H(e)?bd:qd;return n(e)}function eg(e){if(e==null)return 0;if(Ye(e))return Xi(e)?Kn(e):e.length;var n=Be(e);return n==bt||n==mt?e.size:Js(e).length}function tg(e,n,a){var u=H(e)?Rs:zd;return a&&$e(e,n,a)&&(n=i),u(e,B(n,3))}var ng=Y(function(e,n){if(e==null)return[];var a=n.length;return a>1&&$e(e,n[0],n[1])?n=[]:a>2&&$e(n[0],n[1],n[2])&&(n=[n[0]]),yu(e,De(n,1),[])}),Gi=kp||function(){return Re.Date.now()};function rg(e,n){if(typeof n!="function")throw new dt(f);return e=z(e),function(){if(--e<1)return n.apply(this,arguments)}}function bl(e,n,a){return n=a?i:n,n=e&&n==null?e.length:n,Qt(e,qt,i,i,i,i,n)}function ml(e,n){var a;if(typeof n!="function")throw new dt(f);return e=z(e),function(){return--e>0&&(a=n.apply(this,arguments)),e<=1&&(n=i),a}}var va=Y(function(e,n,a){var u=j;if(a.length){var c=dn(a,nr(va));u|=ze}return Qt(e,u,n,a,c)}),Il=Y(function(e,n,a){var u=j|de;if(a.length){var c=dn(a,nr(Il));u|=ze}return Qt(n,u,e,a,c)});function Al(e,n,a){n=a?i:n;var u=Qt(e,ft,i,i,i,i,i,n);return u.placeholder=Al.placeholder,u}function wl(e,n,a){n=a?i:n;var u=Qt(e,Rt,i,i,i,i,i,n);return u.placeholder=wl.placeholder,u}function Ll(e,n,a){var u,c,p,E,N,b,x=0,S=!1,O=!1,R=!0;if(typeof e!="function")throw new dt(f);n=Tt(n)||0,ge(a)&&(S=!!a.leading,O="maxWait"in a,p=O?Se(Tt(a.maxWait)||0,n):p,R="trailing"in a?!!a.trailing:R);function k(Ae){var Lt=u,nn=c;return u=c=i,x=Ae,E=e.apply(nn,Lt),E}function G(Ae){return x=Ae,N=kr(Q,n),S?k(Ae):E}function K(Ae){var Lt=Ae-b,nn=Ae-x,Hl=n-Lt;return O?Ce(Hl,p-nn):Hl}function V(Ae){var Lt=Ae-b,nn=Ae-x;return b===i||Lt>=n||Lt<0||O&&nn>=p}function Q(){var Ae=Gi();if(V(Ae))return ee(Ae);N=kr(Q,K(Ae))}function ee(Ae){return N=i,R&&u?k(Ae):(u=c=i,E)}function st(){N!==i&&ku(N),x=0,u=b=c=N=i}function We(){return N===i?E:ee(Gi())}function at(){var Ae=Gi(),Lt=V(Ae);if(u=arguments,c=this,b=Ae,Lt){if(N===i)return G(b);if(O)return ku(N),N=kr(Q,n),k(b)}return N===i&&(N=kr(Q,n)),E}return at.cancel=st,at.flush=We,at}var ig=Y(function(e,n){return Eu(e,1,n)}),sg=Y(function(e,n,a){return Eu(e,Tt(n)||0,a)});function ag(e){return Qt(e,fs)}function Vi(e,n){if(typeof e!="function"||n!=null&&typeof n!="function")throw new dt(f);var a=function(){var u=arguments,c=n?n.apply(this,u):u[0],p=a.cache;if(p.has(c))return p.get(c);var E=e.apply(this,u);return a.cache=p.set(c,E)||p,E};return a.cache=new(Vi.Cache||Yt),a}Vi.Cache=Yt;function $i(e){if(typeof e!="function")throw new dt(f);return function(){var n=arguments;switch(n.length){case 0:return!e.call(this);case 1:return!e.call(this,n[0]);case 2:return!e.call(this,n[0],n[1]);case 3:return!e.call(this,n[0],n[1],n[2])}return!e.apply(this,n)}}function og(e){return ml(2,e)}var ug=Kd(function(e,n){n=n.length==1&&H(n[0])?Ee(n[0],nt(B())):Ee(De(n,1),nt(B()));var a=n.length;return Y(function(u){for(var c=-1,p=Ce(u.length,a);++c<p;)u[c]=n[c].call(this,u[c]);return tt(e,this,u)})}),ba=Y(function(e,n){var a=dn(n,nr(ba));return Qt(e,ze,i,n,a)}),yl=Y(function(e,n){var a=dn(n,nr(yl));return Qt(e,dr,i,n,a)}),lg=Zt(function(e,n){return Qt(e,Er,i,i,i,n)});function cg(e,n){if(typeof e!="function")throw new dt(f);return n=n===i?n:z(n),Y(e,n)}function fg(e,n){if(typeof e!="function")throw new dt(f);return n=n==null?0:Se(z(n),0),Y(function(a){var u=a[n],c=Tn(a,0,n);return u&&pn(c,u),tt(e,this,c)})}function hg(e,n,a){var u=!0,c=!0;if(typeof e!="function")throw new dt(f);return ge(a)&&(u="leading"in a?!!a.leading:u,c="trailing"in a?!!a.trailing:c),Ll(e,n,{leading:u,maxWait:n,trailing:c})}function pg(e){return bl(e,1)}function dg(e,n){return ba(sa(n),e)}function Eg(){if(!arguments.length)return[];var e=arguments[0];return H(e)?e:[e]}function _g(e){return _t(e,J)}function gg(e,n){return n=typeof n=="function"?n:i,_t(e,J,n)}function Ng(e){return _t(e,y|J)}function Tg(e,n){return n=typeof n=="function"?n:i,_t(e,y|J,n)}function vg(e,n){return n==null||du(e,n,Oe(n))}function wt(e,n){return e===n||e!==e&&n!==n}var bg=Mi(zs),mg=Mi(function(e,n){return e>=n}),Mn=vu(function(){return arguments}())?vu:function(e){return ve(e)&&oe.call(e,"callee")&&!au.call(e,"callee")},H=w.isArray,Ig=Vo?nt(Vo):Pd;function Ye(e){return e!=null&&Wi(e.length)&&!en(e)}function Ie(e){return ve(e)&&Ye(e)}function Ag(e){return e===!0||e===!1||ve(e)&&Ve(e)==_r}var vn=Cp||Ra,wg=$o?nt($o):Rd;function Lg(e){return ve(e)&&e.nodeType===1&&!Fr(e)}function yg(e){if(e==null)return!0;if(Ye(e)&&(H(e)||typeof e=="string"||typeof e.splice=="function"||vn(e)||rr(e)||Mn(e)))return!e.length;var n=Be(e);if(n==bt||n==mt)return!e.size;if(Ur(e))return!Js(e).length;for(var a in e)if(oe.call(e,a))return!1;return!0}function xg(e,n){return Rr(e,n)}function Sg(e,n,a){a=typeof a=="function"?a:i;var u=a?a(e,n):i;return u===i?Rr(e,n,i,a):!!u}function ma(e){if(!ve(e))return!1;var n=Ve(e);return n==ti||n==Zf||typeof e.message=="string"&&typeof e.name=="string"&&!Fr(e)}function Og(e){return typeof e=="number"&&uu(e)}function en(e){if(!ge(e))return!1;var n=Ve(e);return n==ni||n==Eo||n==Qf||n==eh}function xl(e){return typeof e=="number"&&e==z(e)}function Wi(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=fn}function ge(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function ve(e){return e!=null&&typeof e=="object"}var Sl=Wo?nt(Wo):Md;function Pg(e,n){return e===n||Ys(e,n,ha(n))}function Rg(e,n,a){return a=typeof a=="function"?a:i,Ys(e,n,ha(n),a)}function Dg(e){return Ol(e)&&e!=+e}function Mg(e){if(gE(e))throw new X(l);return bu(e)}function Ug(e){return e===null}function kg(e){return e==null}function Ol(e){return typeof e=="number"||ve(e)&&Ve(e)==Nr}function Fr(e){if(!ve(e)||Ve(e)!=zt)return!1;var n=_i(e);if(n===null)return!0;var a=oe.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&hi.call(a)==Rp}var Ia=Xo?nt(Xo):Ud;function Fg(e){return xl(e)&&e>=-fn&&e<=fn}var Pl=Ho?nt(Ho):kd;function Xi(e){return typeof e=="string"||!H(e)&&ve(e)&&Ve(e)==vr}function it(e){return typeof e=="symbol"||ve(e)&&Ve(e)==ri}var rr=qo?nt(qo):Fd;function Cg(e){return e===i}function Bg(e){return ve(e)&&Be(e)==br}function Gg(e){return ve(e)&&Ve(e)==nh}var Vg=Mi(Qs),$g=Mi(function(e,n){return e<=n});function Rl(e){if(!e)return[];if(Ye(e))return Xi(e)?It(e):Ke(e);if(Ar&&e[Ar])return vp(e[Ar]());var n=Be(e),a=n==bt?Cs:n==mt?li:ir;return a(e)}function tn(e){if(!e)return e===0?e:0;if(e=Tt(e),e===wn||e===-wn){var n=e<0?-1:1;return n*zf}return e===e?e:0}function z(e){var n=tn(e),a=n%1;return n===n?a?n-a:n:0}function Dl(e){return e?On(z(e),0,Dt):0}function Tt(e){if(typeof e=="number")return e;if(it(e))return jr;if(ge(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=ge(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=Zo(e);var a=Ih.test(e);return a||wh.test(e)?rp(e.slice(2),a?2:8):mh.test(e)?jr:+e}function Ml(e){return Ut(e,Je(e))}function Wg(e){return e?On(z(e),-fn,fn):e===0?e:0}function ae(e){return e==null?"":rt(e)}var Xg=er(function(e,n){if(Ur(n)||Ye(n)){Ut(n,Oe(n),e);return}for(var a in n)oe.call(n,a)&&Sr(e,a,n[a])}),Ul=er(function(e,n){Ut(n,Je(n),e)}),Hi=er(function(e,n,a,u){Ut(n,Je(n),e,u)}),Hg=er(function(e,n,a,u){Ut(n,Oe(n),e,u)}),qg=Zt(Xs);function zg(e,n){var a=jn(e);return n==null?a:pu(a,n)}var Kg=Y(function(e,n){e=ue(e);var a=-1,u=n.length,c=u>2?n[2]:i;for(c&&$e(n[0],n[1],c)&&(u=1);++a<u;)for(var p=n[a],E=Je(p),N=-1,b=E.length;++N<b;){var x=E[N],S=e[x];(S===i||wt(S,Jn[x])&&!oe.call(e,x))&&(e[x]=p[x])}return e}),Yg=Y(function(e){return e.push(i,Zu),tt(kl,i,e)});function Jg(e,n){return Ko(e,B(n,3),Mt)}function Qg(e,n){return Ko(e,B(n,3),qs)}function Zg(e,n){return e==null?e:Hs(e,B(n,3),Je)}function jg(e,n){return e==null?e:Nu(e,B(n,3),Je)}function eN(e,n){return e&&Mt(e,B(n,3))}function tN(e,n){return e&&qs(e,B(n,3))}function nN(e){return e==null?[]:Li(e,Oe(e))}function rN(e){return e==null?[]:Li(e,Je(e))}function Aa(e,n,a){var u=e==null?i:Pn(e,n);return u===i?a:u}function iN(e,n){return e!=null&&tl(e,n,yd)}function wa(e,n){return e!=null&&tl(e,n,xd)}var sN=zu(function(e,n,a){n!=null&&typeof n.toString!="function"&&(n=pi.call(n)),e[n]=a},ya(Qe)),aN=zu(function(e,n,a){n!=null&&typeof n.toString!="function"&&(n=pi.call(n)),oe.call(e,n)?e[n].push(a):e[n]=[a]},B),oN=Y(Pr);function Oe(e){return Ye(e)?fu(e):Js(e)}function Je(e){return Ye(e)?fu(e,!0):Cd(e)}function uN(e,n){var a={};return n=B(n,3),Mt(e,function(u,c,p){Jt(a,n(u,c,p),u)}),a}function lN(e,n){var a={};return n=B(n,3),Mt(e,function(u,c,p){Jt(a,c,n(u,c,p))}),a}var cN=er(function(e,n,a){yi(e,n,a)}),kl=er(function(e,n,a,u){yi(e,n,a,u)}),fN=Zt(function(e,n){var a={};if(e==null)return a;var u=!1;n=Ee(n,function(p){return p=Nn(p,e),u||(u=p.length>1),p}),Ut(e,ca(e),a),u&&(a=_t(a,y|$|J,sE));for(var c=n.length;c--;)na(a,n[c]);return a});function hN(e,n){return Fl(e,$i(B(n)))}var pN=Zt(function(e,n){return e==null?{}:Gd(e,n)});function Fl(e,n){if(e==null)return{};var a=Ee(ca(e),function(u){return[u]});return n=B(n),xu(e,a,function(u,c){return n(u,c[0])})}function dN(e,n,a){n=Nn(n,e);var u=-1,c=n.length;for(c||(c=1,e=i);++u<c;){var p=e==null?i:e[kt(n[u])];p===i&&(u=c,p=a),e=en(p)?p.call(e):p}return e}function EN(e,n,a){return e==null?e:Dr(e,n,a)}function _N(e,n,a,u){return u=typeof u=="function"?u:i,e==null?e:Dr(e,n,a,u)}var Cl=Ju(Oe),Bl=Ju(Je);function gN(e,n,a){var u=H(e),c=u||vn(e)||rr(e);if(n=B(n,4),a==null){var p=e&&e.constructor;c?a=u?new p:[]:ge(e)?a=en(p)?jn(_i(e)):{}:a={}}return(c?pt:Mt)(e,function(E,N,b){return n(a,E,N,b)}),a}function NN(e,n){return e==null?!0:na(e,n)}function TN(e,n,a){return e==null?e:Du(e,n,sa(a))}function vN(e,n,a,u){return u=typeof u=="function"?u:i,e==null?e:Du(e,n,sa(a),u)}function ir(e){return e==null?[]:Fs(e,Oe(e))}function bN(e){return e==null?[]:Fs(e,Je(e))}function mN(e,n,a){return a===i&&(a=n,n=i),a!==i&&(a=Tt(a),a=a===a?a:0),n!==i&&(n=Tt(n),n=n===n?n:0),On(Tt(e),n,a)}function IN(e,n,a){return n=tn(n),a===i?(a=n,n=0):a=tn(a),e=Tt(e),Sd(e,n,a)}function AN(e,n,a){if(a&&typeof a!="boolean"&&$e(e,n,a)&&(n=a=i),a===i&&(typeof n=="boolean"?(a=n,n=i):typeof e=="boolean"&&(a=e,e=i)),e===i&&n===i?(e=0,n=1):(e=tn(e),n===i?(n=e,e=0):n=tn(n)),e>n){var u=e;e=n,n=u}if(a||e%1||n%1){var c=lu();return Ce(e+c*(n-e+np("1e-"+((c+"").length-1))),n)}return js(e,n)}var wN=tr(function(e,n,a){return n=n.toLowerCase(),e+(a?Gl(n):n)});function Gl(e){return La(ae(e).toLowerCase())}function Vl(e){return e=ae(e),e&&e.replace(yh,Ep).replace(qh,"")}function LN(e,n,a){e=ae(e),n=rt(n);var u=e.length;a=a===i?u:On(z(a),0,u);var c=a;return a-=n.length,a>=0&&e.slice(a,c)==n}function yN(e){return e=ae(e),e&&oh.test(e)?e.replace(No,_p):e}function xN(e){return e=ae(e),e&&ph.test(e)?e.replace(bs,"\\$&"):e}var SN=tr(function(e,n,a){return e+(a?"-":"")+n.toLowerCase()}),ON=tr(function(e,n,a){return e+(a?" ":"")+n.toLowerCase()}),PN=Xu("toLowerCase");function RN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;if(!n||u>=n)return e;var c=(n-u)/2;return Di(vi(c),a)+e+Di(Ti(c),a)}function DN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;return n&&u<n?e+Di(n-u,a):e}function MN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;return n&&u<n?Di(n-u,a)+e:e}function UN(e,n,a){return a||n==null?n=0:n&&(n=+n),$p(ae(e).replace(ms,""),n||0)}function kN(e,n,a){return(a?$e(e,n,a):n===i)?n=1:n=z(n),ea(ae(e),n)}function FN(){var e=arguments,n=ae(e[0]);return e.length<3?n:n.replace(e[1],e[2])}var CN=tr(function(e,n,a){return e+(a?"_":"")+n.toLowerCase()});function BN(e,n,a){return a&&typeof a!="number"&&$e(e,n,a)&&(n=a=i),a=a===i?Dt:a>>>0,a?(e=ae(e),e&&(typeof n=="string"||n!=null&&!Ia(n))&&(n=rt(n),!n&&zn(e))?Tn(It(e),0,a):e.split(n,a)):[]}var GN=tr(function(e,n,a){return e+(a?" ":"")+La(n)});function VN(e,n,a){return e=ae(e),a=a==null?0:On(z(a),0,e.length),n=rt(n),e.slice(a,a+n.length)==n}function $N(e,n,a){var u=h.templateSettings;a&&$e(e,n,a)&&(n=i),e=ae(e),n=Hi({},n,u,Qu);var c=Hi({},n.imports,u.imports,Qu),p=Oe(c),E=Fs(c,p),N,b,x=0,S=n.interpolate||ii,O="__p += '",R=Bs((n.escape||ii).source+"|"+S.source+"|"+(S===To?bh:ii).source+"|"+(n.evaluate||ii).source+"|$","g"),k="//# sourceURL="+(oe.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Qh+"]")+`
12
- `;e.replace(R,function(V,Q,ee,st,We,at){return ee||(ee=st),O+=e.slice(x,at).replace(xh,gp),Q&&(N=!0,O+=`' +
11
+ `)}function EE(e){return H(e)||Mn(e)||!!(ou&&e&&e[ou])}function jt(e,n){var a=typeof e;return n=n??fn,!!n&&(a=="number"||a!="symbol"&&yh.test(e))&&e>-1&&e%1==0&&e<n}function $e(e,n,a){if(!ge(a))return!1;var u=typeof n;return(u=="number"?Ye(a)&&jt(n,a.length):u=="string"&&n in a)?Lt(a[n],e):!1}function da(e,n){if(H(e))return!1;var a=typeof e;return a=="number"||a=="symbol"||a=="boolean"||e==null||it(e)?!0:hh.test(e)||!fh.test(e)||n!=null&&e in ue(n)}function _E(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function Ea(e){var n=Ui(e),a=h[n];if(typeof a!="function"||!(n in Z.prototype))return!1;if(e===a)return!0;var u=fa(a);return!!u&&e===u[0]}function gE(e){return!!ru&&ru in e}var NE=fi?en:Ra;function Ur(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||Jn;return e===a}function rl(e){return e===e&&!ge(e)}function il(e,n){return function(a){return a==null?!1:a[e]===n&&(n!==i||e in ue(a))}}function TE(e){var n=Vi(e,function(u){return a.size===I&&a.clear(),u}),a=n.cache;return n}function vE(e,n){var a=e[1],u=n[1],c=a|u,p=c<(j|de|qt),E=u==qt&&a==ht||u==qt&&a==Er&&e[7].length<=n[8]||u==(qt|Er)&&n[7].length<=n[8]&&a==ht;if(!(p||E))return e;u&j&&(e[2]=n[2],c|=a&j?0:et);var N=n[3];if(N){var b=e[3];e[3]=b?Gu(b,N,n[4]):N,e[4]=b?dn(e[3],T):n[4]}return N=n[5],N&&(b=e[5],e[5]=b?Vu(b,N,n[6]):N,e[6]=b?dn(e[5],T):n[6]),N=n[7],N&&(e[7]=N),u&qt&&(e[8]=e[8]==null?n[8]:Ce(e[8],n[8])),e[9]==null&&(e[9]=n[9]),e[0]=n[0],e[1]=c,e}function bE(e){var n=[];if(e!=null)for(var a in ue(e))n.push(a);return n}function mE(e){return pi.call(e)}function sl(e,n,a){return n=Se(n===i?e.length-1:n,0),function(){for(var u=arguments,c=-1,p=Se(u.length-n,0),E=w(p);++c<p;)E[c]=u[n+c];c=-1;for(var N=w(n+1);++c<n;)N[c]=u[c];return N[n]=a(E),tt(e,this,N)}}function al(e,n){return n.length<2?e:Pn(e,Nt(n,0,-1))}function IE(e,n){for(var a=e.length,u=Ce(n.length,a),c=Ke(e);u--;){var p=n[u];e[u]=jt(p,a)?c[p]:i}return e}function _a(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var ol=ll(Ou),kr=Cp||function(e,n){return Re.setTimeout(e,n)},ga=ll(qd);function ul(e,n,a){var u=n+"";return ga(e,dE(u,AE(fE(u),a)))}function ll(e){var n=0,a=0;return function(){var u=$p(),c=Hf-(u-a);if(a=u,c>0){if(++n>=Xf)return arguments[0]}else n=0;return e.apply(i,arguments)}}function Fi(e,n){var a=-1,u=e.length,c=u-1;for(n=n===i?u:n;++a<n;){var p=js(a,c),E=e[p];e[p]=e[a],e[a]=E}return e.length=n,e}var cl=TE(function(e){var n=[];return e.charCodeAt(0)===46&&n.push(""),e.replace(ph,function(a,u,c,p){n.push(c?p.replace(bh,"$1"):u||a)}),n});function kt(e){if(typeof e=="string"||it(e))return e;var n=e+"";return n=="0"&&1/e==-wn?"-0":n}function Dn(e){if(e!=null){try{return hi.call(e)}catch{}try{return e+""}catch{}}return""}function AE(e,n){return dt(Qf,function(a){var u="_."+a[0];n&a[1]&&!oi(e,u)&&e.push(u)}),e.sort()}function fl(e){if(e instanceof Z)return e.clone();var n=new _t(e.__wrapped__,e.__chain__);return n.__actions__=Ke(e.__actions__),n.__index__=e.__index__,n.__values__=e.__values__,n}function wE(e,n,a){(a?$e(e,n,a):n===i)?n=1:n=Se(z(n),0);var u=e==null?0:e.length;if(!u||n<1)return[];for(var c=0,p=0,E=w(Ti(u/n));c<u;)E[p++]=Nt(e,c,c+=n);return E}function LE(e){for(var n=-1,a=e==null?0:e.length,u=0,c=[];++n<a;){var p=e[n];p&&(c[u++]=p)}return c}function yE(){var e=arguments.length;if(!e)return[];for(var n=w(e-1),a=arguments[0],u=e;u--;)n[u-1]=arguments[u];return pn(H(a)?Ke(a):[a],De(n,1))}var xE=Y(function(e,n){return Ie(e)?Or(e,De(n,1,Ie,!0)):[]}),SE=Y(function(e,n){var a=Tt(n);return Ie(a)&&(a=i),Ie(e)?Or(e,De(n,1,Ie,!0),B(a,2)):[]}),OE=Y(function(e,n){var a=Tt(n);return Ie(a)&&(a=i),Ie(e)?Or(e,De(n,1,Ie,!0),i,a):[]});function PE(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),Nt(e,n<0?0:n,u)):[]}function RE(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),n=u-n,Nt(e,0,n<0?0:n)):[]}function DE(e,n){return e&&e.length?Si(e,B(n,3),!0,!0):[]}function ME(e,n){return e&&e.length?Si(e,B(n,3),!0):[]}function UE(e,n,a,u){var c=e==null?0:e.length;return c?(a&&typeof a!="number"&&$e(e,n,a)&&(a=0,u=c),yd(e,n,a,u)):[]}function hl(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=a==null?0:z(a);return c<0&&(c=Se(u+c,0)),ui(e,B(n,3),c)}function pl(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=u-1;return a!==i&&(c=z(a),c=a<0?Se(u+c,0):Ce(c,u-1)),ui(e,B(n,3),c,!0)}function dl(e){var n=e==null?0:e.length;return n?De(e,1):[]}function kE(e){var n=e==null?0:e.length;return n?De(e,wn):[]}function FE(e,n){var a=e==null?0:e.length;return a?(n=n===i?1:z(n),De(e,n)):[]}function CE(e){for(var n=-1,a=e==null?0:e.length,u={};++n<a;){var c=e[n];u[c[0]]=c[1]}return u}function El(e){return e&&e.length?e[0]:i}function BE(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=a==null?0:z(a);return c<0&&(c=Se(u+c,0)),qn(e,n,c)}function GE(e){var n=e==null?0:e.length;return n?Nt(e,0,-1):[]}var VE=Y(function(e){var n=Ee(e,ia);return n.length&&n[0]===e[0]?Ks(n):[]}),$E=Y(function(e){var n=Tt(e),a=Ee(e,ia);return n===Tt(a)?n=i:a.pop(),a.length&&a[0]===e[0]?Ks(a,B(n,2)):[]}),WE=Y(function(e){var n=Tt(e),a=Ee(e,ia);return n=typeof n=="function"?n:i,n&&a.pop(),a.length&&a[0]===e[0]?Ks(a,i,n):[]});function XE(e,n){return e==null?"":Gp.call(e,n)}function Tt(e){var n=e==null?0:e.length;return n?e[n-1]:i}function HE(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=u;return a!==i&&(c=z(a),c=c<0?Se(u+c,0):Ce(c,u-1)),n===n?Ap(e,n,c):ui(e,Yo,c,!0)}function qE(e,n){return e&&e.length?Lu(e,z(n)):i}var zE=Y(_l);function _l(e,n){return e&&e.length&&n&&n.length?Zs(e,n):e}function KE(e,n,a){return e&&e.length&&n&&n.length?Zs(e,n,B(a,2)):e}function YE(e,n,a){return e&&e.length&&n&&n.length?Zs(e,n,i,a):e}var JE=Zt(function(e,n){var a=e==null?0:e.length,u=Xs(e,n);return Su(e,Ee(n,function(c){return jt(c,a)?+c:c}).sort(Bu)),u});function QE(e,n){var a=[];if(!(e&&e.length))return a;var u=-1,c=[],p=e.length;for(n=B(n,3);++u<p;){var E=e[u];n(E,u,e)&&(a.push(E),c.push(u))}return Su(e,c),a}function Na(e){return e==null?e:Xp.call(e)}function ZE(e,n,a){var u=e==null?0:e.length;return u?(a&&typeof a!="number"&&$e(e,n,a)?(n=0,a=u):(n=n==null?0:z(n),a=a===i?u:z(a)),Nt(e,n,a)):[]}function jE(e,n){return xi(e,n)}function e_(e,n,a){return ta(e,n,B(a,2))}function t_(e,n){var a=e==null?0:e.length;if(a){var u=xi(e,n);if(u<a&&Lt(e[u],n))return u}return-1}function n_(e,n){return xi(e,n,!0)}function r_(e,n,a){return ta(e,n,B(a,2),!0)}function i_(e,n){var a=e==null?0:e.length;if(a){var u=xi(e,n,!0)-1;if(Lt(e[u],n))return u}return-1}function s_(e){return e&&e.length?Pu(e):[]}function a_(e,n){return e&&e.length?Pu(e,B(n,2)):[]}function o_(e){var n=e==null?0:e.length;return n?Nt(e,1,n):[]}function u_(e,n,a){return e&&e.length?(n=a||n===i?1:z(n),Nt(e,0,n<0?0:n)):[]}function l_(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),n=u-n,Nt(e,n<0?0:n,u)):[]}function c_(e,n){return e&&e.length?Si(e,B(n,3),!1,!0):[]}function f_(e,n){return e&&e.length?Si(e,B(n,3)):[]}var h_=Y(function(e){return gn(De(e,1,Ie,!0))}),p_=Y(function(e){var n=Tt(e);return Ie(n)&&(n=i),gn(De(e,1,Ie,!0),B(n,2))}),d_=Y(function(e){var n=Tt(e);return n=typeof n=="function"?n:i,gn(De(e,1,Ie,!0),i,n)});function E_(e){return e&&e.length?gn(e):[]}function __(e,n){return e&&e.length?gn(e,B(n,2)):[]}function g_(e,n){return n=typeof n=="function"?n:i,e&&e.length?gn(e,i,n):[]}function Ta(e){if(!(e&&e.length))return[];var n=0;return e=hn(e,function(a){if(Ie(a))return n=Se(a.length,n),!0}),ks(n,function(a){return Ee(e,Ds(a))})}function gl(e,n){if(!(e&&e.length))return[];var a=Ta(e);return n==null?a:Ee(a,function(u){return tt(n,i,u)})}var N_=Y(function(e,n){return Ie(e)?Or(e,n):[]}),T_=Y(function(e){return ra(hn(e,Ie))}),v_=Y(function(e){var n=Tt(e);return Ie(n)&&(n=i),ra(hn(e,Ie),B(n,2))}),b_=Y(function(e){var n=Tt(e);return n=typeof n=="function"?n:i,ra(hn(e,Ie),i,n)}),m_=Y(Ta);function I_(e,n){return Uu(e||[],n||[],Sr)}function A_(e,n){return Uu(e||[],n||[],Dr)}var w_=Y(function(e){var n=e.length,a=n>1?e[n-1]:i;return a=typeof a=="function"?(e.pop(),a):i,gl(e,a)});function Nl(e){var n=h(e);return n.__chain__=!0,n}function L_(e,n){return n(e),e}function Ci(e,n){return n(e)}var y_=Zt(function(e){var n=e.length,a=n?e[0]:0,u=this.__wrapped__,c=function(p){return Xs(p,e)};return n>1||this.__actions__.length||!(u instanceof Z)||!jt(a)?this.thru(c):(u=u.slice(a,+a+(n?1:0)),u.__actions__.push({func:Ci,args:[c],thisArg:i}),new _t(u,this.__chain__).thru(function(p){return n&&!p.length&&p.push(i),p}))});function x_(){return Nl(this)}function S_(){return new _t(this.value(),this.__chain__)}function O_(){this.__values__===i&&(this.__values__=Rl(this.value()));var e=this.__index__>=this.__values__.length,n=e?i:this.__values__[this.__index__++];return{done:e,value:n}}function P_(){return this}function R_(e){for(var n,a=this;a instanceof Ii;){var u=fl(a);u.__index__=0,u.__values__=i,n?c.__wrapped__=u:n=u;var c=u;a=a.__wrapped__}return c.__wrapped__=e,n}function D_(){var e=this.__wrapped__;if(e instanceof Z){var n=e;return this.__actions__.length&&(n=new Z(this)),n=n.reverse(),n.__actions__.push({func:Ci,args:[Na],thisArg:i}),new _t(n,this.__chain__)}return this.thru(Na)}function M_(){return Mu(this.__wrapped__,this.__actions__)}var U_=Oi(function(e,n,a){oe.call(e,a)?++e[a]:Jt(e,a,1)});function k_(e,n,a){var u=H(e)?zo:Ld;return a&&$e(e,n,a)&&(n=i),u(e,B(n,3))}function F_(e,n){var a=H(e)?hn:gu;return a(e,B(n,3))}var C_=Hu(hl),B_=Hu(pl);function G_(e,n){return De(Bi(e,n),1)}function V_(e,n){return De(Bi(e,n),wn)}function $_(e,n,a){return a=a===i?1:z(a),De(Bi(e,n),a)}function Tl(e,n){var a=H(e)?dt:_n;return a(e,B(n,3))}function vl(e,n){var a=H(e)?op:_u;return a(e,B(n,3))}var W_=Oi(function(e,n,a){oe.call(e,a)?e[a].push(n):Jt(e,a,[n])});function X_(e,n,a,u){e=Ye(e)?e:ir(e),a=a&&!u?z(a):0;var c=e.length;return a<0&&(a=Se(c+a,0)),Xi(e)?a<=c&&e.indexOf(n,a)>-1:!!c&&qn(e,n,a)>-1}var H_=Y(function(e,n,a){var u=-1,c=typeof n=="function",p=Ye(e)?w(e.length):[];return _n(e,function(E){p[++u]=c?tt(n,E,a):Pr(E,n,a)}),p}),q_=Oi(function(e,n,a){Jt(e,a,n)});function Bi(e,n){var a=H(e)?Ee:Iu;return a(e,B(n,3))}function z_(e,n,a,u){return e==null?[]:(H(n)||(n=n==null?[]:[n]),a=u?i:a,H(a)||(a=a==null?[]:[a]),yu(e,n,a))}var K_=Oi(function(e,n,a){e[a?0:1].push(n)},function(){return[[],[]]});function Y_(e,n,a){var u=H(e)?Ps:Qo,c=arguments.length<3;return u(e,B(n,4),a,c,_n)}function J_(e,n,a){var u=H(e)?up:Qo,c=arguments.length<3;return u(e,B(n,4),a,c,_u)}function Q_(e,n){var a=H(e)?hn:gu;return a(e,$i(B(n,3)))}function Z_(e){var n=H(e)?hu:Xd;return n(e)}function j_(e,n,a){(a?$e(e,n,a):n===i)?n=1:n=z(n);var u=H(e)?bd:Hd;return u(e,n)}function eg(e){var n=H(e)?md:zd;return n(e)}function tg(e){if(e==null)return 0;if(Ye(e))return Xi(e)?Kn(e):e.length;var n=Be(e);return n==mt||n==It?e.size:Js(e).length}function ng(e,n,a){var u=H(e)?Rs:Kd;return a&&$e(e,n,a)&&(n=i),u(e,B(n,3))}var rg=Y(function(e,n){if(e==null)return[];var a=n.length;return a>1&&$e(e,n[0],n[1])?n=[]:a>2&&$e(n[0],n[1],n[2])&&(n=[n[0]]),yu(e,De(n,1),[])}),Gi=Fp||function(){return Re.Date.now()};function ig(e,n){if(typeof n!="function")throw new Et(f);return e=z(e),function(){if(--e<1)return n.apply(this,arguments)}}function bl(e,n,a){return n=a?i:n,n=e&&n==null?e.length:n,Qt(e,qt,i,i,i,i,n)}function ml(e,n){var a;if(typeof n!="function")throw new Et(f);return e=z(e),function(){return--e>0&&(a=n.apply(this,arguments)),e<=1&&(n=i),a}}var va=Y(function(e,n,a){var u=j;if(a.length){var c=dn(a,nr(va));u|=ze}return Qt(e,u,n,a,c)}),Il=Y(function(e,n,a){var u=j|de;if(a.length){var c=dn(a,nr(Il));u|=ze}return Qt(n,u,e,a,c)});function Al(e,n,a){n=a?i:n;var u=Qt(e,ht,i,i,i,i,i,n);return u.placeholder=Al.placeholder,u}function wl(e,n,a){n=a?i:n;var u=Qt(e,Rt,i,i,i,i,i,n);return u.placeholder=wl.placeholder,u}function Ll(e,n,a){var u,c,p,E,N,b,x=0,S=!1,O=!1,R=!0;if(typeof e!="function")throw new Et(f);n=vt(n)||0,ge(a)&&(S=!!a.leading,O="maxWait"in a,p=O?Se(vt(a.maxWait)||0,n):p,R="trailing"in a?!!a.trailing:R);function k(Ae){var yt=u,nn=c;return u=c=i,x=Ae,E=e.apply(nn,yt),E}function G(Ae){return x=Ae,N=kr(Q,n),S?k(Ae):E}function K(Ae){var yt=Ae-b,nn=Ae-x,Hl=n-yt;return O?Ce(Hl,p-nn):Hl}function V(Ae){var yt=Ae-b,nn=Ae-x;return b===i||yt>=n||yt<0||O&&nn>=p}function Q(){var Ae=Gi();if(V(Ae))return ee(Ae);N=kr(Q,K(Ae))}function ee(Ae){return N=i,R&&u?k(Ae):(u=c=i,E)}function st(){N!==i&&ku(N),x=0,u=b=c=N=i}function We(){return N===i?E:ee(Gi())}function at(){var Ae=Gi(),yt=V(Ae);if(u=arguments,c=this,b=Ae,yt){if(N===i)return G(b);if(O)return ku(N),N=kr(Q,n),k(b)}return N===i&&(N=kr(Q,n)),E}return at.cancel=st,at.flush=We,at}var sg=Y(function(e,n){return Eu(e,1,n)}),ag=Y(function(e,n,a){return Eu(e,vt(n)||0,a)});function og(e){return Qt(e,fs)}function Vi(e,n){if(typeof e!="function"||n!=null&&typeof n!="function")throw new Et(f);var a=function(){var u=arguments,c=n?n.apply(this,u):u[0],p=a.cache;if(p.has(c))return p.get(c);var E=e.apply(this,u);return a.cache=p.set(c,E)||p,E};return a.cache=new(Vi.Cache||Yt),a}Vi.Cache=Yt;function $i(e){if(typeof e!="function")throw new Et(f);return function(){var n=arguments;switch(n.length){case 0:return!e.call(this);case 1:return!e.call(this,n[0]);case 2:return!e.call(this,n[0],n[1]);case 3:return!e.call(this,n[0],n[1],n[2])}return!e.apply(this,n)}}function ug(e){return ml(2,e)}var lg=Yd(function(e,n){n=n.length==1&&H(n[0])?Ee(n[0],nt(B())):Ee(De(n,1),nt(B()));var a=n.length;return Y(function(u){for(var c=-1,p=Ce(u.length,a);++c<p;)u[c]=n[c].call(this,u[c]);return tt(e,this,u)})}),ba=Y(function(e,n){var a=dn(n,nr(ba));return Qt(e,ze,i,n,a)}),yl=Y(function(e,n){var a=dn(n,nr(yl));return Qt(e,dr,i,n,a)}),cg=Zt(function(e,n){return Qt(e,Er,i,i,i,n)});function fg(e,n){if(typeof e!="function")throw new Et(f);return n=n===i?n:z(n),Y(e,n)}function hg(e,n){if(typeof e!="function")throw new Et(f);return n=n==null?0:Se(z(n),0),Y(function(a){var u=a[n],c=Tn(a,0,n);return u&&pn(c,u),tt(e,this,c)})}function pg(e,n,a){var u=!0,c=!0;if(typeof e!="function")throw new Et(f);return ge(a)&&(u="leading"in a?!!a.leading:u,c="trailing"in a?!!a.trailing:c),Ll(e,n,{leading:u,maxWait:n,trailing:c})}function dg(e){return bl(e,1)}function Eg(e,n){return ba(sa(n),e)}function _g(){if(!arguments.length)return[];var e=arguments[0];return H(e)?e:[e]}function gg(e){return gt(e,J)}function Ng(e,n){return n=typeof n=="function"?n:i,gt(e,J,n)}function Tg(e){return gt(e,y|J)}function vg(e,n){return n=typeof n=="function"?n:i,gt(e,y|J,n)}function bg(e,n){return n==null||du(e,n,Oe(n))}function Lt(e,n){return e===n||e!==e&&n!==n}var mg=Mi(zs),Ig=Mi(function(e,n){return e>=n}),Mn=vu(function(){return arguments}())?vu:function(e){return ve(e)&&oe.call(e,"callee")&&!au.call(e,"callee")},H=w.isArray,Ag=Vo?nt(Vo):Rd;function Ye(e){return e!=null&&Wi(e.length)&&!en(e)}function Ie(e){return ve(e)&&Ye(e)}function wg(e){return e===!0||e===!1||ve(e)&&Ve(e)==_r}var vn=Bp||Ra,Lg=$o?nt($o):Dd;function yg(e){return ve(e)&&e.nodeType===1&&!Fr(e)}function xg(e){if(e==null)return!0;if(Ye(e)&&(H(e)||typeof e=="string"||typeof e.splice=="function"||vn(e)||rr(e)||Mn(e)))return!e.length;var n=Be(e);if(n==mt||n==It)return!e.size;if(Ur(e))return!Js(e).length;for(var a in e)if(oe.call(e,a))return!1;return!0}function Sg(e,n){return Rr(e,n)}function Og(e,n,a){a=typeof a=="function"?a:i;var u=a?a(e,n):i;return u===i?Rr(e,n,i,a):!!u}function ma(e){if(!ve(e))return!1;var n=Ve(e);return n==ti||n==jf||typeof e.message=="string"&&typeof e.name=="string"&&!Fr(e)}function Pg(e){return typeof e=="number"&&uu(e)}function en(e){if(!ge(e))return!1;var n=Ve(e);return n==ni||n==Eo||n==Zf||n==th}function xl(e){return typeof e=="number"&&e==z(e)}function Wi(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=fn}function ge(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function ve(e){return e!=null&&typeof e=="object"}var Sl=Wo?nt(Wo):Ud;function Rg(e,n){return e===n||Ys(e,n,ha(n))}function Dg(e,n,a){return a=typeof a=="function"?a:i,Ys(e,n,ha(n),a)}function Mg(e){return Ol(e)&&e!=+e}function Ug(e){if(NE(e))throw new X(l);return bu(e)}function kg(e){return e===null}function Fg(e){return e==null}function Ol(e){return typeof e=="number"||ve(e)&&Ve(e)==Nr}function Fr(e){if(!ve(e)||Ve(e)!=zt)return!1;var n=_i(e);if(n===null)return!0;var a=oe.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&hi.call(a)==Dp}var Ia=Xo?nt(Xo):kd;function Cg(e){return xl(e)&&e>=-fn&&e<=fn}var Pl=Ho?nt(Ho):Fd;function Xi(e){return typeof e=="string"||!H(e)&&ve(e)&&Ve(e)==vr}function it(e){return typeof e=="symbol"||ve(e)&&Ve(e)==ri}var rr=qo?nt(qo):Cd;function Bg(e){return e===i}function Gg(e){return ve(e)&&Be(e)==br}function Vg(e){return ve(e)&&Ve(e)==rh}var $g=Mi(Qs),Wg=Mi(function(e,n){return e<=n});function Rl(e){if(!e)return[];if(Ye(e))return Xi(e)?At(e):Ke(e);if(Ar&&e[Ar])return bp(e[Ar]());var n=Be(e),a=n==mt?Cs:n==It?li:ir;return a(e)}function tn(e){if(!e)return e===0?e:0;if(e=vt(e),e===wn||e===-wn){var n=e<0?-1:1;return n*Kf}return e===e?e:0}function z(e){var n=tn(e),a=n%1;return n===n?a?n-a:n:0}function Dl(e){return e?On(z(e),0,Dt):0}function vt(e){if(typeof e=="number")return e;if(it(e))return jr;if(ge(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=ge(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=Zo(e);var a=Ah.test(e);return a||Lh.test(e)?ip(e.slice(2),a?2:8):Ih.test(e)?jr:+e}function Ml(e){return Ut(e,Je(e))}function Xg(e){return e?On(z(e),-fn,fn):e===0?e:0}function ae(e){return e==null?"":rt(e)}var Hg=er(function(e,n){if(Ur(n)||Ye(n)){Ut(n,Oe(n),e);return}for(var a in n)oe.call(n,a)&&Sr(e,a,n[a])}),Ul=er(function(e,n){Ut(n,Je(n),e)}),Hi=er(function(e,n,a,u){Ut(n,Je(n),e,u)}),qg=er(function(e,n,a,u){Ut(n,Oe(n),e,u)}),zg=Zt(Xs);function Kg(e,n){var a=jn(e);return n==null?a:pu(a,n)}var Yg=Y(function(e,n){e=ue(e);var a=-1,u=n.length,c=u>2?n[2]:i;for(c&&$e(n[0],n[1],c)&&(u=1);++a<u;)for(var p=n[a],E=Je(p),N=-1,b=E.length;++N<b;){var x=E[N],S=e[x];(S===i||Lt(S,Jn[x])&&!oe.call(e,x))&&(e[x]=p[x])}return e}),Jg=Y(function(e){return e.push(i,Zu),tt(kl,i,e)});function Qg(e,n){return Ko(e,B(n,3),Mt)}function Zg(e,n){return Ko(e,B(n,3),qs)}function jg(e,n){return e==null?e:Hs(e,B(n,3),Je)}function eN(e,n){return e==null?e:Nu(e,B(n,3),Je)}function tN(e,n){return e&&Mt(e,B(n,3))}function nN(e,n){return e&&qs(e,B(n,3))}function rN(e){return e==null?[]:Li(e,Oe(e))}function iN(e){return e==null?[]:Li(e,Je(e))}function Aa(e,n,a){var u=e==null?i:Pn(e,n);return u===i?a:u}function sN(e,n){return e!=null&&tl(e,n,xd)}function wa(e,n){return e!=null&&tl(e,n,Sd)}var aN=zu(function(e,n,a){n!=null&&typeof n.toString!="function"&&(n=pi.call(n)),e[n]=a},ya(Qe)),oN=zu(function(e,n,a){n!=null&&typeof n.toString!="function"&&(n=pi.call(n)),oe.call(e,n)?e[n].push(a):e[n]=[a]},B),uN=Y(Pr);function Oe(e){return Ye(e)?fu(e):Js(e)}function Je(e){return Ye(e)?fu(e,!0):Bd(e)}function lN(e,n){var a={};return n=B(n,3),Mt(e,function(u,c,p){Jt(a,n(u,c,p),u)}),a}function cN(e,n){var a={};return n=B(n,3),Mt(e,function(u,c,p){Jt(a,c,n(u,c,p))}),a}var fN=er(function(e,n,a){yi(e,n,a)}),kl=er(function(e,n,a,u){yi(e,n,a,u)}),hN=Zt(function(e,n){var a={};if(e==null)return a;var u=!1;n=Ee(n,function(p){return p=Nn(p,e),u||(u=p.length>1),p}),Ut(e,ca(e),a),u&&(a=gt(a,y|$|J,aE));for(var c=n.length;c--;)na(a,n[c]);return a});function pN(e,n){return Fl(e,$i(B(n)))}var dN=Zt(function(e,n){return e==null?{}:Vd(e,n)});function Fl(e,n){if(e==null)return{};var a=Ee(ca(e),function(u){return[u]});return n=B(n),xu(e,a,function(u,c){return n(u,c[0])})}function EN(e,n,a){n=Nn(n,e);var u=-1,c=n.length;for(c||(c=1,e=i);++u<c;){var p=e==null?i:e[kt(n[u])];p===i&&(u=c,p=a),e=en(p)?p.call(e):p}return e}function _N(e,n,a){return e==null?e:Dr(e,n,a)}function gN(e,n,a,u){return u=typeof u=="function"?u:i,e==null?e:Dr(e,n,a,u)}var Cl=Ju(Oe),Bl=Ju(Je);function NN(e,n,a){var u=H(e),c=u||vn(e)||rr(e);if(n=B(n,4),a==null){var p=e&&e.constructor;c?a=u?new p:[]:ge(e)?a=en(p)?jn(_i(e)):{}:a={}}return(c?dt:Mt)(e,function(E,N,b){return n(a,E,N,b)}),a}function TN(e,n){return e==null?!0:na(e,n)}function vN(e,n,a){return e==null?e:Du(e,n,sa(a))}function bN(e,n,a,u){return u=typeof u=="function"?u:i,e==null?e:Du(e,n,sa(a),u)}function ir(e){return e==null?[]:Fs(e,Oe(e))}function mN(e){return e==null?[]:Fs(e,Je(e))}function IN(e,n,a){return a===i&&(a=n,n=i),a!==i&&(a=vt(a),a=a===a?a:0),n!==i&&(n=vt(n),n=n===n?n:0),On(vt(e),n,a)}function AN(e,n,a){return n=tn(n),a===i?(a=n,n=0):a=tn(a),e=vt(e),Od(e,n,a)}function wN(e,n,a){if(a&&typeof a!="boolean"&&$e(e,n,a)&&(n=a=i),a===i&&(typeof n=="boolean"?(a=n,n=i):typeof e=="boolean"&&(a=e,e=i)),e===i&&n===i?(e=0,n=1):(e=tn(e),n===i?(n=e,e=0):n=tn(n)),e>n){var u=e;e=n,n=u}if(a||e%1||n%1){var c=lu();return Ce(e+c*(n-e+rp("1e-"+((c+"").length-1))),n)}return js(e,n)}var LN=tr(function(e,n,a){return n=n.toLowerCase(),e+(a?Gl(n):n)});function Gl(e){return La(ae(e).toLowerCase())}function Vl(e){return e=ae(e),e&&e.replace(xh,_p).replace(zh,"")}function yN(e,n,a){e=ae(e),n=rt(n);var u=e.length;a=a===i?u:On(z(a),0,u);var c=a;return a-=n.length,a>=0&&e.slice(a,c)==n}function xN(e){return e=ae(e),e&&uh.test(e)?e.replace(No,gp):e}function SN(e){return e=ae(e),e&&dh.test(e)?e.replace(bs,"\\$&"):e}var ON=tr(function(e,n,a){return e+(a?"-":"")+n.toLowerCase()}),PN=tr(function(e,n,a){return e+(a?" ":"")+n.toLowerCase()}),RN=Xu("toLowerCase");function DN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;if(!n||u>=n)return e;var c=(n-u)/2;return Di(vi(c),a)+e+Di(Ti(c),a)}function MN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;return n&&u<n?e+Di(n-u,a):e}function UN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;return n&&u<n?Di(n-u,a)+e:e}function kN(e,n,a){return a||n==null?n=0:n&&(n=+n),Wp(ae(e).replace(ms,""),n||0)}function FN(e,n,a){return(a?$e(e,n,a):n===i)?n=1:n=z(n),ea(ae(e),n)}function CN(){var e=arguments,n=ae(e[0]);return e.length<3?n:n.replace(e[1],e[2])}var BN=tr(function(e,n,a){return e+(a?"_":"")+n.toLowerCase()});function GN(e,n,a){return a&&typeof a!="number"&&$e(e,n,a)&&(n=a=i),a=a===i?Dt:a>>>0,a?(e=ae(e),e&&(typeof n=="string"||n!=null&&!Ia(n))&&(n=rt(n),!n&&zn(e))?Tn(At(e),0,a):e.split(n,a)):[]}var VN=tr(function(e,n,a){return e+(a?" ":"")+La(n)});function $N(e,n,a){return e=ae(e),a=a==null?0:On(z(a),0,e.length),n=rt(n),e.slice(a,a+n.length)==n}function WN(e,n,a){var u=h.templateSettings;a&&$e(e,n,a)&&(n=i),e=ae(e),n=Hi({},n,u,Qu);var c=Hi({},n.imports,u.imports,Qu),p=Oe(c),E=Fs(c,p),N,b,x=0,S=n.interpolate||ii,O="__p += '",R=Bs((n.escape||ii).source+"|"+S.source+"|"+(S===To?mh:ii).source+"|"+(n.evaluate||ii).source+"|$","g"),k="//# sourceURL="+(oe.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Zh+"]")+`
12
+ `;e.replace(R,function(V,Q,ee,st,We,at){return ee||(ee=st),O+=e.slice(x,at).replace(Sh,Np),Q&&(N=!0,O+=`' +
13
13
  __e(`+Q+`) +
14
14
  '`),We&&(b=!0,O+=`';
15
15
  `+We+`;
@@ -19,13 +19,13 @@ __p += '`),ee&&(O+=`' +
19
19
  `;var G=oe.call(n,"variable")&&n.variable;if(!G)O=`with (obj) {
20
20
  `+O+`
21
21
  }
22
- `;else if(Th.test(G))throw new X(d);O=(b?O.replace(rh,""):O).replace(ih,"$1").replace(sh,"$1;"),O="function("+(G||"obj")+`) {
22
+ `;else if(vh.test(G))throw new X(d);O=(b?O.replace(ih,""):O).replace(sh,"$1").replace(ah,"$1;"),O="function("+(G||"obj")+`) {
23
23
  `+(G?"":`obj || (obj = {});
24
24
  `)+"var __t, __p = ''"+(N?", __e = _.escape":"")+(b?`, __j = Array.prototype.join;
25
25
  function print() { __p += __j.call(arguments, '') }
26
26
  `:`;
27
27
  `)+O+`return __p
28
- }`;var K=Wl(function(){return ie(p,k+"return "+O).apply(i,E)});if(K.source=O,ma(K))throw K;return K}function WN(e){return ae(e).toLowerCase()}function XN(e){return ae(e).toUpperCase()}function HN(e,n,a){if(e=ae(e),e&&(a||n===i))return Zo(e);if(!e||!(n=rt(n)))return e;var u=It(e),c=It(n),p=jo(u,c),E=eu(u,c)+1;return Tn(u,p,E).join("")}function qN(e,n,a){if(e=ae(e),e&&(a||n===i))return e.slice(0,nu(e)+1);if(!e||!(n=rt(n)))return e;var u=It(e),c=eu(u,It(n))+1;return Tn(u,0,c).join("")}function zN(e,n,a){if(e=ae(e),e&&(a||n===i))return e.replace(ms,"");if(!e||!(n=rt(n)))return e;var u=It(e),c=jo(u,It(n));return Tn(u,c).join("")}function KN(e,n){var a=Vf,u=$f;if(ge(n)){var c="separator"in n?n.separator:c;a="length"in n?z(n.length):a,u="omission"in n?rt(n.omission):u}e=ae(e);var p=e.length;if(zn(e)){var E=It(e);p=E.length}if(a>=p)return e;var N=a-Kn(u);if(N<1)return u;var b=E?Tn(E,0,N).join(""):e.slice(0,N);if(c===i)return b+u;if(E&&(N+=b.length-N),Ia(c)){if(e.slice(N).search(c)){var x,S=b;for(c.global||(c=Bs(c.source,ae(vo.exec(c))+"g")),c.lastIndex=0;x=c.exec(S);)var O=x.index;b=b.slice(0,O===i?N:O)}}else if(e.indexOf(rt(c),N)!=N){var R=b.lastIndexOf(c);R>-1&&(b=b.slice(0,R))}return b+u}function YN(e){return e=ae(e),e&&ah.test(e)?e.replace(go,Ap):e}var JN=tr(function(e,n,a){return e+(a?" ":"")+n.toUpperCase()}),La=Xu("toUpperCase");function $l(e,n,a){return e=ae(e),n=a?i:n,n===i?Tp(e)?yp(e):cp(e):e.match(n)||[]}var Wl=Y(function(e,n){try{return tt(e,i,n)}catch(a){return ma(a)?a:new X(a)}}),QN=Zt(function(e,n){return pt(n,function(a){a=kt(a),Jt(e,a,va(e[a],e))}),e});function ZN(e){var n=e==null?0:e.length,a=B();return e=n?Ee(e,function(u){if(typeof u[1]!="function")throw new dt(f);return[a(u[0]),u[1]]}):[],Y(function(u){for(var c=-1;++c<n;){var p=e[c];if(tt(p[0],this,u))return tt(p[1],this,u)}})}function jN(e){return Ad(_t(e,y))}function ya(e){return function(){return e}}function eT(e,n){return e==null||e!==e?n:e}var tT=qu(),nT=qu(!0);function Qe(e){return e}function xa(e){return mu(typeof e=="function"?e:_t(e,y))}function rT(e){return Au(_t(e,y))}function iT(e,n){return wu(e,_t(n,y))}var sT=Y(function(e,n){return function(a){return Pr(a,e,n)}}),aT=Y(function(e,n){return function(a){return Pr(e,a,n)}});function Sa(e,n,a){var u=Oe(n),c=Li(n,u);a==null&&!(ge(n)&&(c.length||!u.length))&&(a=n,n=e,e=this,c=Li(n,Oe(n)));var p=!(ge(a)&&"chain"in a)||!!a.chain,E=en(e);return pt(c,function(N){var b=n[N];e[N]=b,E&&(e.prototype[N]=function(){var x=this.__chain__;if(p||x){var S=e(this.__wrapped__),O=S.__actions__=Ke(this.__actions__);return O.push({func:b,args:arguments,thisArg:e}),S.__chain__=x,S}return b.apply(e,pn([this.value()],arguments))})}),e}function oT(){return Re._===this&&(Re._=Dp),this}function Oa(){}function uT(e){return e=z(e),Y(function(n){return Lu(n,e)})}var lT=oa(Ee),cT=oa(zo),fT=oa(Rs);function Xl(e){return da(e)?Ds(kt(e)):Vd(e)}function hT(e){return function(n){return e==null?i:Pn(e,n)}}var pT=Ku(),dT=Ku(!0);function Pa(){return[]}function Ra(){return!1}function ET(){return{}}function _T(){return""}function gT(){return!0}function NT(e,n){if(e=z(e),e<1||e>fn)return[];var a=Dt,u=Ce(e,Dt);n=B(n),e-=Dt;for(var c=ks(u,n);++a<e;)n(a);return c}function TT(e){return H(e)?Ee(e,kt):it(e)?[e]:Ke(cl(ae(e)))}function vT(e){var n=++Pp;return ae(e)+n}var bT=Ri(function(e,n){return e+n},0),mT=ua("ceil"),IT=Ri(function(e,n){return e/n},1),AT=ua("floor");function wT(e){return e&&e.length?wi(e,Qe,zs):i}function LT(e,n){return e&&e.length?wi(e,B(n,2),zs):i}function yT(e){return Jo(e,Qe)}function xT(e,n){return Jo(e,B(n,2))}function ST(e){return e&&e.length?wi(e,Qe,Qs):i}function OT(e,n){return e&&e.length?wi(e,B(n,2),Qs):i}var PT=Ri(function(e,n){return e*n},1),RT=ua("round"),DT=Ri(function(e,n){return e-n},0);function MT(e){return e&&e.length?Us(e,Qe):0}function UT(e,n){return e&&e.length?Us(e,B(n,2)):0}return h.after=rg,h.ary=bl,h.assign=Xg,h.assignIn=Ul,h.assignInWith=Hi,h.assignWith=Hg,h.at=qg,h.before=ml,h.bind=va,h.bindAll=QN,h.bindKey=Il,h.castArray=Eg,h.chain=Nl,h.chunk=AE,h.compact=wE,h.concat=LE,h.cond=ZN,h.conforms=jN,h.constant=ya,h.countBy=M_,h.create=zg,h.curry=Al,h.curryRight=wl,h.debounce=Ll,h.defaults=Kg,h.defaultsDeep=Yg,h.defer=ig,h.delay=sg,h.difference=yE,h.differenceBy=xE,h.differenceWith=SE,h.drop=OE,h.dropRight=PE,h.dropRightWhile=RE,h.dropWhile=DE,h.fill=ME,h.filter=k_,h.flatMap=B_,h.flatMapDeep=G_,h.flatMapDepth=V_,h.flatten=dl,h.flattenDeep=UE,h.flattenDepth=kE,h.flip=ag,h.flow=tT,h.flowRight=nT,h.fromPairs=FE,h.functions=nN,h.functionsIn=rN,h.groupBy=$_,h.initial=BE,h.intersection=GE,h.intersectionBy=VE,h.intersectionWith=$E,h.invert=sN,h.invertBy=aN,h.invokeMap=X_,h.iteratee=xa,h.keyBy=H_,h.keys=Oe,h.keysIn=Je,h.map=Bi,h.mapKeys=uN,h.mapValues=lN,h.matches=rT,h.matchesProperty=iT,h.memoize=Vi,h.merge=cN,h.mergeWith=kl,h.method=sT,h.methodOf=aT,h.mixin=Sa,h.negate=$i,h.nthArg=uT,h.omit=fN,h.omitBy=hN,h.once=og,h.orderBy=q_,h.over=lT,h.overArgs=ug,h.overEvery=cT,h.overSome=fT,h.partial=ba,h.partialRight=yl,h.partition=z_,h.pick=pN,h.pickBy=Fl,h.property=Xl,h.propertyOf=hT,h.pull=qE,h.pullAll=_l,h.pullAllBy=zE,h.pullAllWith=KE,h.pullAt=YE,h.range=pT,h.rangeRight=dT,h.rearg=lg,h.reject=J_,h.remove=JE,h.rest=cg,h.reverse=Na,h.sampleSize=Z_,h.set=EN,h.setWith=_N,h.shuffle=j_,h.slice=QE,h.sortBy=ng,h.sortedUniq=i_,h.sortedUniqBy=s_,h.split=BN,h.spread=fg,h.tail=a_,h.take=o_,h.takeRight=u_,h.takeRightWhile=l_,h.takeWhile=c_,h.tap=w_,h.throttle=hg,h.thru=Ci,h.toArray=Rl,h.toPairs=Cl,h.toPairsIn=Bl,h.toPath=TT,h.toPlainObject=Ml,h.transform=gN,h.unary=pg,h.union=f_,h.unionBy=h_,h.unionWith=p_,h.uniq=d_,h.uniqBy=E_,h.uniqWith=__,h.unset=NN,h.unzip=Ta,h.unzipWith=gl,h.update=TN,h.updateWith=vN,h.values=ir,h.valuesIn=bN,h.without=g_,h.words=$l,h.wrap=dg,h.xor=N_,h.xorBy=T_,h.xorWith=v_,h.zip=b_,h.zipObject=m_,h.zipObjectDeep=I_,h.zipWith=A_,h.entries=Cl,h.entriesIn=Bl,h.extend=Ul,h.extendWith=Hi,Sa(h,h),h.add=bT,h.attempt=Wl,h.camelCase=wN,h.capitalize=Gl,h.ceil=mT,h.clamp=mN,h.clone=_g,h.cloneDeep=Ng,h.cloneDeepWith=Tg,h.cloneWith=gg,h.conformsTo=vg,h.deburr=Vl,h.defaultTo=eT,h.divide=IT,h.endsWith=LN,h.eq=wt,h.escape=yN,h.escapeRegExp=xN,h.every=U_,h.find=F_,h.findIndex=hl,h.findKey=Jg,h.findLast=C_,h.findLastIndex=pl,h.findLastKey=Qg,h.floor=AT,h.forEach=Tl,h.forEachRight=vl,h.forIn=Zg,h.forInRight=jg,h.forOwn=eN,h.forOwnRight=tN,h.get=Aa,h.gt=bg,h.gte=mg,h.has=iN,h.hasIn=wa,h.head=El,h.identity=Qe,h.includes=W_,h.indexOf=CE,h.inRange=IN,h.invoke=oN,h.isArguments=Mn,h.isArray=H,h.isArrayBuffer=Ig,h.isArrayLike=Ye,h.isArrayLikeObject=Ie,h.isBoolean=Ag,h.isBuffer=vn,h.isDate=wg,h.isElement=Lg,h.isEmpty=yg,h.isEqual=xg,h.isEqualWith=Sg,h.isError=ma,h.isFinite=Og,h.isFunction=en,h.isInteger=xl,h.isLength=Wi,h.isMap=Sl,h.isMatch=Pg,h.isMatchWith=Rg,h.isNaN=Dg,h.isNative=Mg,h.isNil=kg,h.isNull=Ug,h.isNumber=Ol,h.isObject=ge,h.isObjectLike=ve,h.isPlainObject=Fr,h.isRegExp=Ia,h.isSafeInteger=Fg,h.isSet=Pl,h.isString=Xi,h.isSymbol=it,h.isTypedArray=rr,h.isUndefined=Cg,h.isWeakMap=Bg,h.isWeakSet=Gg,h.join=WE,h.kebabCase=SN,h.last=Nt,h.lastIndexOf=XE,h.lowerCase=ON,h.lowerFirst=PN,h.lt=Vg,h.lte=$g,h.max=wT,h.maxBy=LT,h.mean=yT,h.meanBy=xT,h.min=ST,h.minBy=OT,h.stubArray=Pa,h.stubFalse=Ra,h.stubObject=ET,h.stubString=_T,h.stubTrue=gT,h.multiply=PT,h.nth=HE,h.noConflict=oT,h.noop=Oa,h.now=Gi,h.pad=RN,h.padEnd=DN,h.padStart=MN,h.parseInt=UN,h.random=AN,h.reduce=K_,h.reduceRight=Y_,h.repeat=kN,h.replace=FN,h.result=dN,h.round=RT,h.runInContext=v,h.sample=Q_,h.size=eg,h.snakeCase=CN,h.some=tg,h.sortedIndex=ZE,h.sortedIndexBy=jE,h.sortedIndexOf=e_,h.sortedLastIndex=t_,h.sortedLastIndexBy=n_,h.sortedLastIndexOf=r_,h.startCase=GN,h.startsWith=VN,h.subtract=DT,h.sum=MT,h.sumBy=UT,h.template=$N,h.times=NT,h.toFinite=tn,h.toInteger=z,h.toLength=Dl,h.toLower=WN,h.toNumber=Tt,h.toSafeInteger=Wg,h.toString=ae,h.toUpper=XN,h.trim=HN,h.trimEnd=qN,h.trimStart=zN,h.truncate=KN,h.unescape=YN,h.uniqueId=vT,h.upperCase=JN,h.upperFirst=La,h.each=Tl,h.eachRight=vl,h.first=El,Sa(h,function(){var e={};return Mt(h,function(n,a){oe.call(h.prototype,a)||(e[a]=n)}),e}(),{chain:!1}),h.VERSION=s,pt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){h[e].placeholder=h}),pt(["drop","take"],function(e,n){Z.prototype[e]=function(a){a=a===i?1:Se(z(a),0);var u=this.__filtered__&&!n?new Z(this):this.clone();return u.__filtered__?u.__takeCount__=Ce(a,u.__takeCount__):u.__views__.push({size:Ce(a,Dt),type:e+(u.__dir__<0?"Right":"")}),u},Z.prototype[e+"Right"]=function(a){return this.reverse()[e](a).reverse()}}),pt(["filter","map","takeWhile"],function(e,n){var a=n+1,u=a==po||a==qf;Z.prototype[e]=function(c){var p=this.clone();return p.__iteratees__.push({iteratee:B(c,3),type:a}),p.__filtered__=p.__filtered__||u,p}}),pt(["head","last"],function(e,n){var a="take"+(n?"Right":"");Z.prototype[e]=function(){return this[a](1).value()[0]}}),pt(["initial","tail"],function(e,n){var a="drop"+(n?"":"Right");Z.prototype[e]=function(){return this.__filtered__?new Z(this):this[a](1)}}),Z.prototype.compact=function(){return this.filter(Qe)},Z.prototype.find=function(e){return this.filter(e).head()},Z.prototype.findLast=function(e){return this.reverse().find(e)},Z.prototype.invokeMap=Y(function(e,n){return typeof e=="function"?new Z(this):this.map(function(a){return Pr(a,e,n)})}),Z.prototype.reject=function(e){return this.filter($i(B(e)))},Z.prototype.slice=function(e,n){e=z(e);var a=this;return a.__filtered__&&(e>0||n<0)?new Z(a):(e<0?a=a.takeRight(-e):e&&(a=a.drop(e)),n!==i&&(n=z(n),a=n<0?a.dropRight(-n):a.take(n-e)),a)},Z.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Z.prototype.toArray=function(){return this.take(Dt)},Mt(Z.prototype,function(e,n){var a=/^(?:filter|find|map|reject)|While$/.test(n),u=/^(?:head|last)$/.test(n),c=h[u?"take"+(n=="last"?"Right":""):n],p=u||/^find/.test(n);c&&(h.prototype[n]=function(){var E=this.__wrapped__,N=u?[1]:arguments,b=E instanceof Z,x=N[0],S=b||H(E),O=function(Q){var ee=c.apply(h,pn([Q],N));return u&&R?ee[0]:ee};S&&a&&typeof x=="function"&&x.length!=1&&(b=S=!1);var R=this.__chain__,k=!!this.__actions__.length,G=p&&!R,K=b&&!k;if(!p&&S){E=K?E:new Z(this);var V=e.apply(E,N);return V.__actions__.push({func:Ci,args:[O],thisArg:i}),new Et(V,R)}return G&&K?e.apply(this,N):(V=this.thru(O),G?u?V.value()[0]:V.value():V)})}),pt(["pop","push","shift","sort","splice","unshift"],function(e){var n=ci[e],a=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",u=/^(?:pop|shift)$/.test(e);h.prototype[e]=function(){var c=arguments;if(u&&!this.__chain__){var p=this.value();return n.apply(H(p)?p:[],c)}return this[a](function(E){return n.apply(H(E)?E:[],c)})}}),Mt(Z.prototype,function(e,n){var a=h[n];if(a){var u=a.name+"";oe.call(Zn,u)||(Zn[u]=[]),Zn[u].push({name:n,func:a})}}),Zn[Pi(i,de).name]=[{name:"wrapper",func:i}],Z.prototype.clone=Yp,Z.prototype.reverse=Jp,Z.prototype.value=Qp,h.prototype.at=L_,h.prototype.chain=y_,h.prototype.commit=x_,h.prototype.next=S_,h.prototype.plant=P_,h.prototype.reverse=R_,h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=D_,h.prototype.first=h.prototype.head,Ar&&(h.prototype[Ar]=O_),h},Yn=xp();Ln?((Ln.exports=Yn)._=Yn,xs._=Yn):Re._=Yn}).call(NA)}(Gr,Gr.exports)),Gr.exports}var sn=TA();class vA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return!(this.declarationNode.parent instanceof se)||cn(this.declarationNode.parent).unwrap()!==F.Table?[]:this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=Ge(this.declarationNode.parent.name).map(d=>d.join(".")).unwrap_or("<unnamed>"),o=this.declarationNode.parent.symbol.symbolTable;return[i.callee,...i.args].flatMap(Ft).flatMap(d=>d.variables.length+d.tupleElements.length>1?[]:d.variables.length?d.variables[0]:d.tupleElements).flatMap(d=>{const m=Me(d).unwrap(),I=fr(m),T=o.get(I);return T?(d.referee=T,T.references.push(d),[]):new g(_.BINDING_ERROR,`No column named '${m}' inside Table '${s}'`,d)})})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class bA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class mA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class IA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return!(this.declarationNode.parent instanceof qe)&&cn(this.declarationNode.parent).unwrap()!==F.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>i.callee?[i.callee,...i.args].flatMap(Ft).flatMap(l=>{let f=l.tupleElements.length?l.tupleElements:l.variables.pop();const d=l.variables.pop();if(!f||!d)return[];Array.isArray(f)||(f=[f]);const m=l.variables;return f.flatMap(I=>Ct(this.ast,[...m.map(T=>({node:T,kind:U.Schema})),{node:d,kind:U.Table},{node:I,kind:U.Column}]))}):[])}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class Af{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){const{body:r}=this.declarationNode;return(r?r instanceof ke?r.body:[r]:[]).filter(s=>s instanceof W&&Ji(s.callee)).reverse().flatMap(s=>{const o=St(s.callee.expression).unwrap(),l=o.variables.pop(),f=o.variables;if(!l)return[];const d=Ct(this.ast,[...f.map(m=>({node:m,kind:U.Schema})),{node:l,kind:U.TablePartial}]);return d.length?d:(l.referee?.symbolTable?.forEach(m=>{const I=Pe(m.declaration.callee).unwrap_or(void 0);if(I===void 0)return;const T=this.symbolFactory.create(gf,{declaration:s,tablePartialSymbol:l.referee}),y=fr(I),$=this.declarationNode.symbol?.symbolTable;$?.has(y)||$?.set(y,T)}),[])})}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){const i=r.filter(o=>!Ji(o.callee));return(o=>o.flatMap(l=>{if(!l.callee)return[];const f=[],d=[l.callee,...l.args];if(sn.last(d)instanceof _e){const m=sn.last(d),I=Ne(m).getValue();f.push(...I.ref?.flatMap(T=>T.value?this.bindInlineRef(T.value):[])||[]),f.push(...I.default?.flatMap(T=>T.value?this.tryToBindEnumFieldRef(T.value):[])||[]),d.pop()}return d[1]&&this.tryToBindColumnType(d[1]),f}))(i)}tryToBindColumnType(r){const i=St(r).unwrap_or(void 0);if(!i)return;const s=i.variables.pop(),o=i.variables;s&&Ct(this.ast,[...o.map(l=>({node:l,kind:U.Schema})),{node:s,kind:U.Enum}])}tryToBindEnumFieldRef(r){if(Fe(r))return[];if(we(r)){const f=r.expression.variable?.value?.toLowerCase();if(f&&kI.includes(f))return[]}const i=St(r).unwrap_or(void 0);if(!i)return[];const s=i.variables.pop(),o=i.variables.pop();if(!s||!o)return[];const l=i.variables;return Ct(this.ast,[...l.map(f=>({node:f,kind:U.Schema})),{node:o,kind:U.Enum},{node:s,kind:U.EnumField}])}bindInlineRef(r){return Ft(r).flatMap(s=>{const o=s.variables.pop(),l=s.variables.pop();if(!o)return[];const f=s.variables;return l?Ct(this.ast,[...f.map(d=>({node:d,kind:U.Schema})),{node:l,kind:U.Table},{node:o,kind:U.Column}]):Ct(this.declarationNode,[{node:o,kind:U.Column}])})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class AA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>i.callee?[i.callee,...i.args].flatMap(Ft).flatMap(l=>{const f=l.variables.pop();if(!f)return[];const d=l.variables;return Ct(this.ast,[...d.map(m=>({node:m,kind:U.Schema})),{node:f,kind:U.Table}])}):[])}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class wA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];if(sn.last(o)instanceof _e){const l=sn.last(o),f=Ne(l).getValue();s.push(...f.ref?.flatMap(d=>d.value?this.bindInlineRef(d.value):[])||[]),o.pop()}return o[1]&&this.tryToBindColumnType(o[1]),s})}tryToBindColumnType(r){const i=St(r).unwrap_or(void 0);if(!i)return;const s=i.variables.pop(),o=i.variables;s&&Ct(this.ast,[...o.map(l=>({node:l,kind:U.Schema})),{node:s,kind:U.Enum}])}bindInlineRef(r){return Ft(r).flatMap(s=>{const o=s.variables.pop(),l=s.variables.pop();if(!o)return[];const f=s.variables;return l?Ct(this.ast,[...f.map(d=>({node:d,kind:U.Schema})),{node:l,kind:U.Table},{node:o,kind:U.Column}]):Ct(this.declarationNode,[{node:o,kind:U.Column}])})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}function LA(t){return[Jr,ur,no,io,fr,ro,so,ao,oo].map(r=>r(t))}function yA(t){if(t instanceof eo)return U.Schema;if(t instanceof qr)return U.Table;if(t instanceof to)return U.Column;if(t instanceof ff)return U.Enum;if(t instanceof hf)return U.EnumField;if(t instanceof pf)return U.TableGroup;if(t instanceof df)return U.TableGroupField;if(t instanceof Ef)return U.TablePartial;if(t instanceof gf)return U.Column;if(t instanceof _f)return U.PartialInjection;throw new Error("No other possible symbol kind in getSymbolKind")}function Ht(t){switch(t.type.value.toLowerCase()){case F.Enum:return gA;case F.Table:return Af;case F.TableGroup:return AA;case F.Project:return mA;case F.Ref:return IA;case F.Note:return bA;case F.Indexes:return vA;case F.TablePartial:return wA;case F.Check:return EA;default:return _A}}function Ft(t){if(!t)return[];if(we(t))return[{variables:[t],tupleElements:[]}];if(t instanceof Vt){const r=St(t).unwrap_or(void 0);return r?[r]:[...Ft(t.leftExpression),...Ft(t.rightExpression)]}if(t instanceof je||t instanceof os)return Ft(t.expression);if(t instanceof Wt){const r=St(t).unwrap_or(void 0);return r?[r]:t.elementList.flatMap(Ft)}return[]}function Ct(t,r){if(!t.symbol?.symbolTable)throw new Error("lookupAndBindInScope should only be called with initial scope having a symbol table");let i=t.symbol.symbolTable,s=yA(t.symbol),o=t instanceof se?sA(t).unwrap_or("<invalid name>"):$t;if(t instanceof qe&&r.length){const{node:l,kind:f}=r[0];Me(l).unwrap_or("<unnamed>")===$t&&f===U.Schema&&r.shift()}for(const l of r){const{node:f,kind:d}=l,m=Me(f).unwrap_or("<unnamed>"),I=BI(m,d),T=i.get(I);if(!T)return[new g(_.BINDING_ERROR,`${d} '${m}' does not exist in ${o===void 0?"global scope":`${s} '${o}'`}`,f)];if(f.referee=T,T.references.push(f),o=m,s=d,!T.symbolTable)return[];i=T.symbolTable}return[]}class xA{constructor(r,i){this.ast=r,this.symbolFactory=i}resolvePartialInjections(){return this.ast.body.filter(r=>cn(r).unwrap_or("")===F.Table).flatMap(r=>new Af(r,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){const r=[];r.push(...this.resolvePartialInjections());for(const i of this.ast.body)if(i.type){const s=Ht(i),o=new s(i,this.ast,this.symbolFactory);r.push(...o.bind())}return new lt(this.ast,r)}}class SA{constructor(r){this.generator=r}create(r,i){return new r(i,this.generator.nextId())}}class OA{constructor(r,i){this.ast=r,this.symbolFactory=new SA(i)}analyze(){return new wc(this.ast,this.symbolFactory).validate().chain(i=>new xA(i,this.symbolFactory).resolve())}validate(){return new wc(this.ast,this.symbolFactory).validate().chain(i=>new lt(i,[]))}}function yc(t,r){const{variables:i,tupleElements:s}=St(t).unwrap(),o=s.map(f=>Me(f).unwrap()),l=i.map(f=>Me(f).unwrap());return s.length?i.length===0?{schemaName:r.schemaName,tableName:r.name,fieldNames:o}:{tableName:l.pop(),schemaName:l.pop()||null,fieldNames:o}:i.length===1?{schemaName:r.schemaName,tableName:r.name,fieldNames:[l[0]]}:{fieldNames:[l.pop()],tableName:l.pop(),schemaName:l.pop()||null}}function wf(t){switch(t){case"<":return["1","*"];case"<>":return["*","*"];case">":return["*","1"];case"-":return["1","1"];default:throw new Error("Invalid relation op")}}function q(t){return{start:{offset:t.startPos.offset,line:t.startPos.line+1,column:t.startPos.column+1},end:{offset:t.endPos.offset,line:t.endPos.line+1,column:t.endPos.column+1}}}function Zi(t){const r=An(t).unwrap_or(void 0)?.pop();return r instanceof Wt?r.elementList.map(i=>i.referee):[r.referee]}function $n(t){const r=Ge(t).unwrap();return{name:r.pop(),schemaName:r}}function Zr(t){return t.expression.literal.value}function Lf(t,r){if(Array.isArray(t)){const o=t.map(({id:f})=>f).sort().join(","),l=r.map(({id:f})=>f).sort().join(",");return o<l?`${o}-${l}`:`${l}-${o}`}const i=t.id.toString(),s=r.id.toString();return i<s?`${i}-${s}`:`${s}-${i}`}function co(t,r){if(Array.isArray(t)){const o=t.map(({id:f})=>f).sort(),l=r.map(({id:f})=>f).sort();return Va(o,l).every(([f,d])=>f===d)}const i=t.id,s=r.id;return i===s}function Ot(t){const r=t.split(`
28
+ }`;var K=Wl(function(){return ie(p,k+"return "+O).apply(i,E)});if(K.source=O,ma(K))throw K;return K}function XN(e){return ae(e).toLowerCase()}function HN(e){return ae(e).toUpperCase()}function qN(e,n,a){if(e=ae(e),e&&(a||n===i))return Zo(e);if(!e||!(n=rt(n)))return e;var u=At(e),c=At(n),p=jo(u,c),E=eu(u,c)+1;return Tn(u,p,E).join("")}function zN(e,n,a){if(e=ae(e),e&&(a||n===i))return e.slice(0,nu(e)+1);if(!e||!(n=rt(n)))return e;var u=At(e),c=eu(u,At(n))+1;return Tn(u,0,c).join("")}function KN(e,n,a){if(e=ae(e),e&&(a||n===i))return e.replace(ms,"");if(!e||!(n=rt(n)))return e;var u=At(e),c=jo(u,At(n));return Tn(u,c).join("")}function YN(e,n){var a=$f,u=Wf;if(ge(n)){var c="separator"in n?n.separator:c;a="length"in n?z(n.length):a,u="omission"in n?rt(n.omission):u}e=ae(e);var p=e.length;if(zn(e)){var E=At(e);p=E.length}if(a>=p)return e;var N=a-Kn(u);if(N<1)return u;var b=E?Tn(E,0,N).join(""):e.slice(0,N);if(c===i)return b+u;if(E&&(N+=b.length-N),Ia(c)){if(e.slice(N).search(c)){var x,S=b;for(c.global||(c=Bs(c.source,ae(vo.exec(c))+"g")),c.lastIndex=0;x=c.exec(S);)var O=x.index;b=b.slice(0,O===i?N:O)}}else if(e.indexOf(rt(c),N)!=N){var R=b.lastIndexOf(c);R>-1&&(b=b.slice(0,R))}return b+u}function JN(e){return e=ae(e),e&&oh.test(e)?e.replace(go,wp):e}var QN=tr(function(e,n,a){return e+(a?" ":"")+n.toUpperCase()}),La=Xu("toUpperCase");function $l(e,n,a){return e=ae(e),n=a?i:n,n===i?vp(e)?xp(e):fp(e):e.match(n)||[]}var Wl=Y(function(e,n){try{return tt(e,i,n)}catch(a){return ma(a)?a:new X(a)}}),ZN=Zt(function(e,n){return dt(n,function(a){a=kt(a),Jt(e,a,va(e[a],e))}),e});function jN(e){var n=e==null?0:e.length,a=B();return e=n?Ee(e,function(u){if(typeof u[1]!="function")throw new Et(f);return[a(u[0]),u[1]]}):[],Y(function(u){for(var c=-1;++c<n;){var p=e[c];if(tt(p[0],this,u))return tt(p[1],this,u)}})}function eT(e){return wd(gt(e,y))}function ya(e){return function(){return e}}function tT(e,n){return e==null||e!==e?n:e}var nT=qu(),rT=qu(!0);function Qe(e){return e}function xa(e){return mu(typeof e=="function"?e:gt(e,y))}function iT(e){return Au(gt(e,y))}function sT(e,n){return wu(e,gt(n,y))}var aT=Y(function(e,n){return function(a){return Pr(a,e,n)}}),oT=Y(function(e,n){return function(a){return Pr(e,a,n)}});function Sa(e,n,a){var u=Oe(n),c=Li(n,u);a==null&&!(ge(n)&&(c.length||!u.length))&&(a=n,n=e,e=this,c=Li(n,Oe(n)));var p=!(ge(a)&&"chain"in a)||!!a.chain,E=en(e);return dt(c,function(N){var b=n[N];e[N]=b,E&&(e.prototype[N]=function(){var x=this.__chain__;if(p||x){var S=e(this.__wrapped__),O=S.__actions__=Ke(this.__actions__);return O.push({func:b,args:arguments,thisArg:e}),S.__chain__=x,S}return b.apply(e,pn([this.value()],arguments))})}),e}function uT(){return Re._===this&&(Re._=Mp),this}function Oa(){}function lT(e){return e=z(e),Y(function(n){return Lu(n,e)})}var cT=oa(Ee),fT=oa(zo),hT=oa(Rs);function Xl(e){return da(e)?Ds(kt(e)):$d(e)}function pT(e){return function(n){return e==null?i:Pn(e,n)}}var dT=Ku(),ET=Ku(!0);function Pa(){return[]}function Ra(){return!1}function _T(){return{}}function gT(){return""}function NT(){return!0}function TT(e,n){if(e=z(e),e<1||e>fn)return[];var a=Dt,u=Ce(e,Dt);n=B(n),e-=Dt;for(var c=ks(u,n);++a<e;)n(a);return c}function vT(e){return H(e)?Ee(e,kt):it(e)?[e]:Ke(cl(ae(e)))}function bT(e){var n=++Rp;return ae(e)+n}var mT=Ri(function(e,n){return e+n},0),IT=ua("ceil"),AT=Ri(function(e,n){return e/n},1),wT=ua("floor");function LT(e){return e&&e.length?wi(e,Qe,zs):i}function yT(e,n){return e&&e.length?wi(e,B(n,2),zs):i}function xT(e){return Jo(e,Qe)}function ST(e,n){return Jo(e,B(n,2))}function OT(e){return e&&e.length?wi(e,Qe,Qs):i}function PT(e,n){return e&&e.length?wi(e,B(n,2),Qs):i}var RT=Ri(function(e,n){return e*n},1),DT=ua("round"),MT=Ri(function(e,n){return e-n},0);function UT(e){return e&&e.length?Us(e,Qe):0}function kT(e,n){return e&&e.length?Us(e,B(n,2)):0}return h.after=ig,h.ary=bl,h.assign=Hg,h.assignIn=Ul,h.assignInWith=Hi,h.assignWith=qg,h.at=zg,h.before=ml,h.bind=va,h.bindAll=ZN,h.bindKey=Il,h.castArray=_g,h.chain=Nl,h.chunk=wE,h.compact=LE,h.concat=yE,h.cond=jN,h.conforms=eT,h.constant=ya,h.countBy=U_,h.create=Kg,h.curry=Al,h.curryRight=wl,h.debounce=Ll,h.defaults=Yg,h.defaultsDeep=Jg,h.defer=sg,h.delay=ag,h.difference=xE,h.differenceBy=SE,h.differenceWith=OE,h.drop=PE,h.dropRight=RE,h.dropRightWhile=DE,h.dropWhile=ME,h.fill=UE,h.filter=F_,h.flatMap=G_,h.flatMapDeep=V_,h.flatMapDepth=$_,h.flatten=dl,h.flattenDeep=kE,h.flattenDepth=FE,h.flip=og,h.flow=nT,h.flowRight=rT,h.fromPairs=CE,h.functions=rN,h.functionsIn=iN,h.groupBy=W_,h.initial=GE,h.intersection=VE,h.intersectionBy=$E,h.intersectionWith=WE,h.invert=aN,h.invertBy=oN,h.invokeMap=H_,h.iteratee=xa,h.keyBy=q_,h.keys=Oe,h.keysIn=Je,h.map=Bi,h.mapKeys=lN,h.mapValues=cN,h.matches=iT,h.matchesProperty=sT,h.memoize=Vi,h.merge=fN,h.mergeWith=kl,h.method=aT,h.methodOf=oT,h.mixin=Sa,h.negate=$i,h.nthArg=lT,h.omit=hN,h.omitBy=pN,h.once=ug,h.orderBy=z_,h.over=cT,h.overArgs=lg,h.overEvery=fT,h.overSome=hT,h.partial=ba,h.partialRight=yl,h.partition=K_,h.pick=dN,h.pickBy=Fl,h.property=Xl,h.propertyOf=pT,h.pull=zE,h.pullAll=_l,h.pullAllBy=KE,h.pullAllWith=YE,h.pullAt=JE,h.range=dT,h.rangeRight=ET,h.rearg=cg,h.reject=Q_,h.remove=QE,h.rest=fg,h.reverse=Na,h.sampleSize=j_,h.set=_N,h.setWith=gN,h.shuffle=eg,h.slice=ZE,h.sortBy=rg,h.sortedUniq=s_,h.sortedUniqBy=a_,h.split=GN,h.spread=hg,h.tail=o_,h.take=u_,h.takeRight=l_,h.takeRightWhile=c_,h.takeWhile=f_,h.tap=L_,h.throttle=pg,h.thru=Ci,h.toArray=Rl,h.toPairs=Cl,h.toPairsIn=Bl,h.toPath=vT,h.toPlainObject=Ml,h.transform=NN,h.unary=dg,h.union=h_,h.unionBy=p_,h.unionWith=d_,h.uniq=E_,h.uniqBy=__,h.uniqWith=g_,h.unset=TN,h.unzip=Ta,h.unzipWith=gl,h.update=vN,h.updateWith=bN,h.values=ir,h.valuesIn=mN,h.without=N_,h.words=$l,h.wrap=Eg,h.xor=T_,h.xorBy=v_,h.xorWith=b_,h.zip=m_,h.zipObject=I_,h.zipObjectDeep=A_,h.zipWith=w_,h.entries=Cl,h.entriesIn=Bl,h.extend=Ul,h.extendWith=Hi,Sa(h,h),h.add=mT,h.attempt=Wl,h.camelCase=LN,h.capitalize=Gl,h.ceil=IT,h.clamp=IN,h.clone=gg,h.cloneDeep=Tg,h.cloneDeepWith=vg,h.cloneWith=Ng,h.conformsTo=bg,h.deburr=Vl,h.defaultTo=tT,h.divide=AT,h.endsWith=yN,h.eq=Lt,h.escape=xN,h.escapeRegExp=SN,h.every=k_,h.find=C_,h.findIndex=hl,h.findKey=Qg,h.findLast=B_,h.findLastIndex=pl,h.findLastKey=Zg,h.floor=wT,h.forEach=Tl,h.forEachRight=vl,h.forIn=jg,h.forInRight=eN,h.forOwn=tN,h.forOwnRight=nN,h.get=Aa,h.gt=mg,h.gte=Ig,h.has=sN,h.hasIn=wa,h.head=El,h.identity=Qe,h.includes=X_,h.indexOf=BE,h.inRange=AN,h.invoke=uN,h.isArguments=Mn,h.isArray=H,h.isArrayBuffer=Ag,h.isArrayLike=Ye,h.isArrayLikeObject=Ie,h.isBoolean=wg,h.isBuffer=vn,h.isDate=Lg,h.isElement=yg,h.isEmpty=xg,h.isEqual=Sg,h.isEqualWith=Og,h.isError=ma,h.isFinite=Pg,h.isFunction=en,h.isInteger=xl,h.isLength=Wi,h.isMap=Sl,h.isMatch=Rg,h.isMatchWith=Dg,h.isNaN=Mg,h.isNative=Ug,h.isNil=Fg,h.isNull=kg,h.isNumber=Ol,h.isObject=ge,h.isObjectLike=ve,h.isPlainObject=Fr,h.isRegExp=Ia,h.isSafeInteger=Cg,h.isSet=Pl,h.isString=Xi,h.isSymbol=it,h.isTypedArray=rr,h.isUndefined=Bg,h.isWeakMap=Gg,h.isWeakSet=Vg,h.join=XE,h.kebabCase=ON,h.last=Tt,h.lastIndexOf=HE,h.lowerCase=PN,h.lowerFirst=RN,h.lt=$g,h.lte=Wg,h.max=LT,h.maxBy=yT,h.mean=xT,h.meanBy=ST,h.min=OT,h.minBy=PT,h.stubArray=Pa,h.stubFalse=Ra,h.stubObject=_T,h.stubString=gT,h.stubTrue=NT,h.multiply=RT,h.nth=qE,h.noConflict=uT,h.noop=Oa,h.now=Gi,h.pad=DN,h.padEnd=MN,h.padStart=UN,h.parseInt=kN,h.random=wN,h.reduce=Y_,h.reduceRight=J_,h.repeat=FN,h.replace=CN,h.result=EN,h.round=DT,h.runInContext=v,h.sample=Z_,h.size=tg,h.snakeCase=BN,h.some=ng,h.sortedIndex=jE,h.sortedIndexBy=e_,h.sortedIndexOf=t_,h.sortedLastIndex=n_,h.sortedLastIndexBy=r_,h.sortedLastIndexOf=i_,h.startCase=VN,h.startsWith=$N,h.subtract=MT,h.sum=UT,h.sumBy=kT,h.template=WN,h.times=TT,h.toFinite=tn,h.toInteger=z,h.toLength=Dl,h.toLower=XN,h.toNumber=vt,h.toSafeInteger=Xg,h.toString=ae,h.toUpper=HN,h.trim=qN,h.trimEnd=zN,h.trimStart=KN,h.truncate=YN,h.unescape=JN,h.uniqueId=bT,h.upperCase=QN,h.upperFirst=La,h.each=Tl,h.eachRight=vl,h.first=El,Sa(h,function(){var e={};return Mt(h,function(n,a){oe.call(h.prototype,a)||(e[a]=n)}),e}(),{chain:!1}),h.VERSION=s,dt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){h[e].placeholder=h}),dt(["drop","take"],function(e,n){Z.prototype[e]=function(a){a=a===i?1:Se(z(a),0);var u=this.__filtered__&&!n?new Z(this):this.clone();return u.__filtered__?u.__takeCount__=Ce(a,u.__takeCount__):u.__views__.push({size:Ce(a,Dt),type:e+(u.__dir__<0?"Right":"")}),u},Z.prototype[e+"Right"]=function(a){return this.reverse()[e](a).reverse()}}),dt(["filter","map","takeWhile"],function(e,n){var a=n+1,u=a==po||a==zf;Z.prototype[e]=function(c){var p=this.clone();return p.__iteratees__.push({iteratee:B(c,3),type:a}),p.__filtered__=p.__filtered__||u,p}}),dt(["head","last"],function(e,n){var a="take"+(n?"Right":"");Z.prototype[e]=function(){return this[a](1).value()[0]}}),dt(["initial","tail"],function(e,n){var a="drop"+(n?"":"Right");Z.prototype[e]=function(){return this.__filtered__?new Z(this):this[a](1)}}),Z.prototype.compact=function(){return this.filter(Qe)},Z.prototype.find=function(e){return this.filter(e).head()},Z.prototype.findLast=function(e){return this.reverse().find(e)},Z.prototype.invokeMap=Y(function(e,n){return typeof e=="function"?new Z(this):this.map(function(a){return Pr(a,e,n)})}),Z.prototype.reject=function(e){return this.filter($i(B(e)))},Z.prototype.slice=function(e,n){e=z(e);var a=this;return a.__filtered__&&(e>0||n<0)?new Z(a):(e<0?a=a.takeRight(-e):e&&(a=a.drop(e)),n!==i&&(n=z(n),a=n<0?a.dropRight(-n):a.take(n-e)),a)},Z.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Z.prototype.toArray=function(){return this.take(Dt)},Mt(Z.prototype,function(e,n){var a=/^(?:filter|find|map|reject)|While$/.test(n),u=/^(?:head|last)$/.test(n),c=h[u?"take"+(n=="last"?"Right":""):n],p=u||/^find/.test(n);c&&(h.prototype[n]=function(){var E=this.__wrapped__,N=u?[1]:arguments,b=E instanceof Z,x=N[0],S=b||H(E),O=function(Q){var ee=c.apply(h,pn([Q],N));return u&&R?ee[0]:ee};S&&a&&typeof x=="function"&&x.length!=1&&(b=S=!1);var R=this.__chain__,k=!!this.__actions__.length,G=p&&!R,K=b&&!k;if(!p&&S){E=K?E:new Z(this);var V=e.apply(E,N);return V.__actions__.push({func:Ci,args:[O],thisArg:i}),new _t(V,R)}return G&&K?e.apply(this,N):(V=this.thru(O),G?u?V.value()[0]:V.value():V)})}),dt(["pop","push","shift","sort","splice","unshift"],function(e){var n=ci[e],a=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",u=/^(?:pop|shift)$/.test(e);h.prototype[e]=function(){var c=arguments;if(u&&!this.__chain__){var p=this.value();return n.apply(H(p)?p:[],c)}return this[a](function(E){return n.apply(H(E)?E:[],c)})}}),Mt(Z.prototype,function(e,n){var a=h[n];if(a){var u=a.name+"";oe.call(Zn,u)||(Zn[u]=[]),Zn[u].push({name:n,func:a})}}),Zn[Pi(i,de).name]=[{name:"wrapper",func:i}],Z.prototype.clone=Jp,Z.prototype.reverse=Qp,Z.prototype.value=Zp,h.prototype.at=y_,h.prototype.chain=x_,h.prototype.commit=S_,h.prototype.next=O_,h.prototype.plant=R_,h.prototype.reverse=D_,h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=M_,h.prototype.first=h.prototype.head,Ar&&(h.prototype[Ar]=P_),h},Yn=Sp();Ln?((Ln.exports=Yn)._=Yn,xs._=Yn):Re._=Yn}).call(NA)}(Gr,Gr.exports)),Gr.exports}var sn=TA();class vA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return!(this.declarationNode.parent instanceof se)||cn(this.declarationNode.parent).unwrap()!==F.Table?[]:this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=Ge(this.declarationNode.parent.name).map(d=>d.join(".")).unwrap_or("<unnamed>"),o=this.declarationNode.parent.symbol.symbolTable;return[i.callee,...i.args].flatMap(Ft).flatMap(d=>d.variables.length+d.tupleElements.length>1?[]:d.variables.length?d.variables[0]:d.tupleElements).flatMap(d=>{const m=Me(d).unwrap(),I=fr(m),T=o.get(I);return T?(d.referee=T,T.references.push(d),[]):new g(_.BINDING_ERROR,`No column named '${m}' inside Table '${s}'`,d)})})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class bA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class mA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class IA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return!(this.declarationNode.parent instanceof qe)&&cn(this.declarationNode.parent).unwrap()!==F.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>i.callee?[i.callee,...i.args].flatMap(Ft).flatMap(l=>{let f=l.tupleElements.length?l.tupleElements:l.variables.pop();const d=l.variables.pop();if(!f||!d)return[];Array.isArray(f)||(f=[f]);const m=l.variables;return f.flatMap(I=>Ct(this.ast,[...m.map(T=>({node:T,kind:U.Schema})),{node:d,kind:U.Table},{node:I,kind:U.Column}]))}):[])}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class wf{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){const{body:r}=this.declarationNode;return(r?r instanceof ke?r.body:[r]:[]).filter(s=>s instanceof W&&Ji(s.callee)).reverse().flatMap(s=>{const o=ut(s.callee.expression).unwrap(),l=o.variables.pop(),f=o.variables;if(!l)return[];const d=Ct(this.ast,[...f.map(m=>({node:m,kind:U.Schema})),{node:l,kind:U.TablePartial}]);return d.length?d:(l.referee?.symbolTable?.forEach(m=>{const I=Pe(m.declaration.callee).unwrap_or(void 0);if(I===void 0)return;const T=this.symbolFactory.create(Nf,{declaration:s,tablePartialSymbol:l.referee}),y=fr(I),$=this.declarationNode.symbol?.symbolTable;$?.has(y)||$?.set(y,T)}),[])})}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){const i=r.filter(o=>!Ji(o.callee));return(o=>o.flatMap(l=>{if(!l.callee)return[];const f=[],d=[l.callee,...l.args];if(sn.last(d)instanceof _e){const m=sn.last(d),I=Ne(m).getValue();f.push(...I.ref?.flatMap(T=>T.value?this.bindInlineRef(T.value):[])||[]),f.push(...I.default?.flatMap(T=>T.value?this.tryToBindEnumFieldRef(T.value):[])||[]),d.pop()}return d[1]&&this.tryToBindColumnType(d[1]),f}))(i)}tryToBindColumnType(r){const i=ut(r).unwrap_or(void 0);if(!i)return;const s=i.variables.pop(),o=i.variables;s&&Ct(this.ast,[...o.map(l=>({node:l,kind:U.Schema})),{node:s,kind:U.Enum}])}tryToBindEnumFieldRef(r){if(Fe(r))return[];if(we(r)){const f=r.expression.variable?.value?.toLowerCase();if(f&&FI.includes(f))return[]}const i=ut(r).unwrap_or(void 0);if(!i)return[];const s=i.variables.pop(),o=i.variables.pop();if(!s||!o)return[];const l=i.variables;return Ct(this.ast,[...l.map(f=>({node:f,kind:U.Schema})),{node:o,kind:U.Enum},{node:s,kind:U.EnumField}])}bindInlineRef(r){return Ft(r).flatMap(s=>{const o=s.variables.pop(),l=s.variables.pop();if(!o)return[];const f=s.variables;return l?Ct(this.ast,[...f.map(d=>({node:d,kind:U.Schema})),{node:l,kind:U.Table},{node:o,kind:U.Column}]):Ct(this.declarationNode,[{node:o,kind:U.Column}])})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class AA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>i.callee?[i.callee,...i.args].flatMap(Ft).flatMap(l=>{const f=l.variables.pop();if(!f)return[];const d=l.variables;return Ct(this.ast,[...d.map(m=>({node:m,kind:U.Schema})),{node:f,kind:U.Table}])}):[])}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class wA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];if(sn.last(o)instanceof _e){const l=sn.last(o),f=Ne(l).getValue();s.push(...f.ref?.flatMap(d=>d.value?this.bindInlineRef(d.value):[])||[]),o.pop()}return o[1]&&this.tryToBindColumnType(o[1]),s})}tryToBindColumnType(r){const i=ut(r).unwrap_or(void 0);if(!i)return;const s=i.variables.pop(),o=i.variables;s&&Ct(this.ast,[...o.map(l=>({node:l,kind:U.Schema})),{node:s,kind:U.Enum}])}bindInlineRef(r){return Ft(r).flatMap(s=>{const o=s.variables.pop(),l=s.variables.pop();if(!o)return[];const f=s.variables;return l?Ct(this.ast,[...f.map(d=>({node:d,kind:U.Schema})),{node:l,kind:U.Table},{node:o,kind:U.Column}]):Ct(this.declarationNode,[{node:o,kind:U.Column}])})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}function LA(t){return[Jr,ur,no,io,fr,ro,so,ao,oo].map(r=>r(t))}function yA(t){if(t instanceof eo)return U.Schema;if(t instanceof qr)return U.Table;if(t instanceof to)return U.Column;if(t instanceof hf)return U.Enum;if(t instanceof pf)return U.EnumField;if(t instanceof df)return U.TableGroup;if(t instanceof Ef)return U.TableGroupField;if(t instanceof _f)return U.TablePartial;if(t instanceof Nf)return U.Column;if(t instanceof gf)return U.PartialInjection;throw new Error("No other possible symbol kind in getSymbolKind")}function Ht(t){switch(t.type.value.toLowerCase()){case F.Enum:return gA;case F.Table:return wf;case F.TableGroup:return AA;case F.Project:return mA;case F.Ref:return IA;case F.Note:return bA;case F.Indexes:return vA;case F.TablePartial:return wA;case F.Check:return EA;default:return _A}}function Ft(t){if(!t)return[];if(we(t))return[{variables:[t],tupleElements:[]}];if(t instanceof Vt){const r=ut(t).unwrap_or(void 0);return r?[r]:[...Ft(t.leftExpression),...Ft(t.rightExpression)]}if(t instanceof je||t instanceof os)return Ft(t.expression);if(t instanceof Wt){const r=ut(t).unwrap_or(void 0);return r?[r]:t.elementList.flatMap(Ft)}return[]}function Ct(t,r){if(!t.symbol?.symbolTable)throw new Error("lookupAndBindInScope should only be called with initial scope having a symbol table");let i=t.symbol.symbolTable,s=yA(t.symbol),o=t instanceof se?sA(t).unwrap_or("<invalid name>"):$t;if(t instanceof qe&&r.length){const{node:l,kind:f}=r[0];Me(l).unwrap_or("<unnamed>")===$t&&f===U.Schema&&r.shift()}for(const l of r){const{node:f,kind:d}=l,m=Me(f).unwrap_or("<unnamed>"),I=GI(m,d),T=i.get(I);if(!T)return[new g(_.BINDING_ERROR,`${d} '${m}' does not exist in ${o===void 0?"global scope":`${s} '${o}'`}`,f)];if(f.referee=T,T.references.push(f),o=m,s=d,!T.symbolTable)return[];i=T.symbolTable}return[]}class xA{constructor(r,i){this.ast=r,this.symbolFactory=i}resolvePartialInjections(){return this.ast.body.filter(r=>cn(r).unwrap_or("")===F.Table).flatMap(r=>new wf(r,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){const r=[];r.push(...this.resolvePartialInjections());for(const i of this.ast.body)if(i.type){const s=Ht(i),o=new s(i,this.ast,this.symbolFactory);r.push(...o.bind())}return new ct(this.ast,r)}}class SA{constructor(r){this.generator=r}create(r,i){return new r(i,this.generator.nextId())}}class OA{constructor(r,i){this.ast=r,this.symbolFactory=new SA(i)}analyze(){return new Lc(this.ast,this.symbolFactory).validate().chain(i=>new xA(i,this.symbolFactory).resolve())}validate(){return new Lc(this.ast,this.symbolFactory).validate().chain(i=>new ct(i,[]))}}function xc(t,r){const{variables:i,tupleElements:s}=ut(t).unwrap(),o=s.map(f=>Me(f).unwrap()),l=i.map(f=>Me(f).unwrap());return s.length?i.length===0?{schemaName:r.schemaName,tableName:r.name,fieldNames:o}:{tableName:l.pop(),schemaName:l.pop()||null,fieldNames:o}:i.length===1?{schemaName:r.schemaName,tableName:r.name,fieldNames:[l[0]]}:{fieldNames:[l.pop()],tableName:l.pop(),schemaName:l.pop()||null}}function Lf(t){switch(t){case"<":return["1","*"];case"<>":return["*","*"];case">":return["*","1"];case"-":return["1","1"];default:throw new Error("Invalid relation op")}}function q(t){return{start:{offset:t.startPos.offset,line:t.startPos.line+1,column:t.startPos.column+1},end:{offset:t.endPos.offset,line:t.endPos.line+1,column:t.endPos.column+1}}}function Zi(t){const r=An(t).unwrap_or(void 0)?.pop();return r instanceof Wt?r.elementList.map(i=>i.referee):[r.referee]}function $n(t){const r=Ge(t).unwrap();return{name:r.pop(),schemaName:r}}function Zr(t){return t.expression.literal.value}function yf(t,r){if(Array.isArray(t)){const o=t.map(({id:f})=>f).sort().join(","),l=r.map(({id:f})=>f).sort().join(",");return o<l?`${o}-${l}`:`${l}-${o}`}const i=t.id.toString(),s=r.id.toString();return i<s?`${i}-${s}`:`${s}-${i}`}function co(t,r){if(Array.isArray(t)){const o=t.map(({id:f})=>f).sort(),l=r.map(({id:f})=>f).sort();return Va(o,l).every(([f,d])=>f===d)}const i=t.id,s=r.id;return i===s}function Ot(t){const r=t.split(`
29
29
  `),i=r.slice(r.findIndex(l=>l.trimStart()!=="")),s=i.filter(l=>l.trimStart()),o=Math.min(...s.map(l=>l.length-l.trimStart().length));return i.map(l=>l.slice(o)).join(`
30
- `)}function yf(t){if(t){if(Fe(t))return{value:Le(t).unwrap(),type:"string"};if(mn(t))return{type:"number",value:Xa(t)};if(In(t))return{value:t.expression.variable.value.toLowerCase(),type:"boolean"};if(t instanceof vt&&t.value)return{value:t.value.value,type:"expression"};if(lo(t))return{value:An(t).map(me).and_then(Pe).unwrap(),type:"string"};throw new Error("Unreachable")}}function xf(t){let r="",i=null;for(t instanceof He&&(i=t.argumentList.elementList.map(l=>mn(l)?Wa(l):Fe(l)?Le(l).unwrap():Pe(l).unwrap()).join(","),r=`(${i})`,t=t.callee);t instanceof He||t instanceof Bt;)t instanceof He?(r=`(${t.argumentList.elementList.map(f=>mn(f)?Wa(f):Fe(f)?Le(f).unwrap():Pe(f).unwrap()).join(",")})${r}`,t=t.callee):t instanceof Bt&&(r=`${`[${t.indexer.elementList.map(f=>f.name.expression.literal.value).join(",")}]`}${r}`,t=t.array);const{name:s,schemaName:o}=$n(t);return o.length>1?new lt({schemaName:o.length===0?null:o[0],type_name:`${s}${r}`,args:i},[new g(_.UNSUPPORTED,"Nested schema is not supported",t)]):new lt({schemaName:o.length===0?null:o[0],type_name:`${s}${r}`,args:i})}class Sf{constructor(r,i){this.declarationNode=r,this.env=i,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=q(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);const r=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:i,token:s})=>({value:i,type:"column",token:s})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(i=>{i.pk=!1})),r}interpretName(r){const{name:i,schemaName:s}=$n(r);return s.length>1?(this.table.name=i,this.table.schemaName=s.join("."),[new g(_.UNSUPPORTED,"Nested schema is not supported",r)]):(this.table.name=i,this.table.schemaName=s.length?s[0]:null,[])}interpretAlias(r){if(!r)return[];const i=Me(r).unwrap_or(null);return i&&(this.env.aliases.push({name:i,kind:"table",value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=i),[]}interpretSettingList(r){const i=Ne(r).getValue();this.table.headerColor=i[P.HeaderColor]?.length?Zr(i[P.HeaderColor]?.at(0)?.value):void 0;const[s]=i[P.Note]||[];return this.table.note=s&&{value:Le(s?.value).map(Ot).unwrap(),token:q(s)},[]}interpretBody(r){const[i,s]=ct(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case F.Note:return this.table.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)},[];case F.Indexes:return this.interpretIndexes(i);case F.Check:return this.interpretChecks(i);default:return[]}})}interpretInjection(r,i){const s={order:i,token:q(r)};return s.name=Pe(r.expression).unwrap_or(""),this.table.partials.push(s),[]}interpretFields(r){const o=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([f])=>Qr(f).unwrap_or(null)?.kind===U.Column).length?[]:[new g(_.EMPTY_TABLE,"A Table must have at least one column",this.declarationNode)],l=r.flatMap((f,d)=>Ji(f.callee)?this.interpretInjection(f.callee,d):this.interpretColumn(f));return[...o,...l]}interpretColumn(r){const i=[],s={};s.name=Me(r.callee).unwrap();const o=xf(r.args[0]);s.type=o.getValue(),i.push(...o.getErrors()),s.token=q(r),s.inline_refs=[];const l=r.args.slice(1);if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length||!!f[P.PrimaryKey]?.length,s.increment=!!f[P.Increment]?.length,s.unique=!!f[P.Unique]?.length,s.not_null=f[P.NotNull]?.length?!0:f[P.Null]?.length?!1:void 0,s.dbdefault=yf(f[P.Default]?.at(0)?.value);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).map(Ot).unwrap(),token:q(d)};const m=f[P.Ref]||[];s.inline_refs=m.flatMap(T=>{const[y]=Zi(T.value.expression);if(co(y,r.symbol))return i.push(new g(_.SAME_ENDPOINT,"Two endpoints are the same",T)),[];const $=T.value.op,J=Ge(T.value.expression).unwrap();let ne;if(J.length===1){const[j]=J;ne={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[j],relation:$.value,token:q(T)}}else if(J.length===2){const[j,de]=J;ne={schemaName:null,tableName:j,fieldNames:[de],relation:$.value,token:q(T)}}else if(J.length===3){const[j,de,et]=J;ne={schemaName:j,tableName:de,fieldNames:[et],relation:$.value,token:q(T)}}else{i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",T));const j=J.pop(),de=J.pop();ne={schemaName:J.join("."),tableName:de,fieldNames:[j],relation:$.value,token:q(T)}}const re=this.registerInlineRefToEnv(r,y,ne,T);return i.push(...re),re.length===0?ne:[]});const I=f[P.Check]||[];s.checks=I.map(T=>{const y=q(T),$=T.value.value.value;return{token:y,expression:$}})}return s.pk||=l.some(f=>Pe(f).unwrap().toLowerCase()==="pk"),s.unique||=l.some(f=>Pe(f).unwrap().toLowerCase()==="unique"),this.table.fields.push(s),s.pk&&this.pkColumns.push(s),i}interpretIndexes(r){return this.table.indexes.push(...r.body.body.map(i=>{const s={columns:[]},o=i;s.token=q(o);const l=[o.callee,...o.args];if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length,s.unique=!!f[P.Unique]?.length,s.name=Le(f[P.Name]?.at(0)?.value).unwrap_or(void 0);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).unwrap(),token:q(d)},s.type=Pe(f[P.Type]?.at(0)?.value).unwrap_or(void 0)}return l.flatMap(f=>{if(!(f instanceof He))return f;const d=[];for(;f instanceof He;)d.push(f.argumentList),f=f.callee;return d.push(f),d}).forEach(f=>{const{functional:d,nonFunctional:m}=Qi(f).unwrap();s.columns.push(...d.map(I=>({value:I.value.value,type:"expression",token:q(I)})),...m.map(I=>({value:Me(I).unwrap(),type:"column",token:q(I)})))}),s})),[]}interpretChecks(r){return this.table.checks.push(...r.body.body.map(i=>{const s={},o=i;if(s.token=q(o),o.args[0]instanceof _e){const l=Ne(o.args[0]).getValue();s.name=Le(l[P.Name]?.at(0)?.value).unwrap_or(void 0)}return s.expression=o.callee.value.value,s})),[]}registerInlineRefToEnv(r,i,s,o){const l=Lf(r.symbol,i);if(this.env.refIds[l])return[new g(_.CIRCULAR_REF,"References with same endpoints exist",o),new g(_.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[l])];const f=wf(s.relation);return this.env.refIds[l]=o,this.env.ref.set(o,{name:null,schemaName:null,token:s.token,endpoints:[{...s,relation:f[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[Pe(r.callee).unwrap()],token:q(r),relation:f[0]}]}),[]}}class PA{constructor(r,i){this.declarationNode=r,this.env=i,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=q(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const{name:i}=$n(r);return this.note.name=i,[]}interpretSettingList(r){const i=Ne(r).getValue();return this.note.headerColor=i.headercolor?.length?Zr(i.headercolor?.at(0)?.value):void 0,[]}interpretBody(r){const[i,s]=ct(r.body,o=>o instanceof W);return i.length!==1||s.length>0?[new g(_.INVALID_NOTE,"Invalid note syntax",r)]:[...this.interpretNote(i[0])]}interpretNote(r){const i=Qc(r,"callee.expression.literal.value","");return this.note.content=Ot(i),[]}}class Of{constructor(r,i){this.declarationNode=r,this.env=i,this.container=this.declarationNode.parent instanceof se?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=q(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const i=[],s=Ge(this.declarationNode.name).unwrap_or([]);return this.ref.name=s.pop()||null,s.length>1&&i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name)),this.ref.schemaName=s.join(".")||null,i}interpretBody(r){return r instanceof W?this.interpretField(r):this.interpretField(r.body[0])}interpretField(r){const i=r.callee.op.value,{leftExpression:s,rightExpression:o}=r.callee,l=Zi(s),f=Zi(o);if(co(l,f))return[new g(_.SAME_ENDPOINT,"Two endpoints are the same",r)];const d=Lf(l,f);if(this.env.refIds[d])return[new g(_.CIRCULAR_REF,"References with same endpoints exist",this.declarationNode),new g(_.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[d])];if(r.args[0]){const I=Ne(r.args[0]).getValue(),T=I.delete?.at(0)?.value;this.ref.onDelete=T instanceof yt?zr(T).unwrap_or(void 0):Pe(T).unwrap_or(void 0);const y=I.update?.at(0)?.value;this.ref.onUpdate=y instanceof yt?zr(y).unwrap_or(void 0):Pe(y).unwrap_or(void 0),this.ref.color=I.color?.length?Zr(I.color?.at(0)?.value):void 0}const m=wf(i);return this.ref.endpoints=[{...yc(s,this.container),relation:m[0],token:q(s)},{...yc(o,this.container),relation:m[1],token:q(o)}],this.env.refIds[d]=this.declarationNode,[]}}class Pf{constructor(r,i){this.declarationNode=r,this.env=i,this.tableGroup={tables:[]}}interpret(){const r=[];return this.tableGroup.token=q(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),r.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),r}interpretName(r){const i=[],{name:s,schemaName:o}=$n(r);return o.length>=2&&(this.tableGroup.name=s,this.tableGroup.schemaName=o.join("."),i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name))),this.tableGroup.name=s,this.tableGroup.schemaName=o[0]||null,i}interpretBody(r){const[i,s]=ct(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case"note":this.tableGroup.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)};break}return[]})}interpretFields(r){const i=[];return this.tableGroup.tables=r.map(s=>{const o=Ge(s.callee).unwrap();o.length>2&&i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",s));const l=An(s.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[l]){const f=this.env.tableOwnerGroup[l],{schemaName:d,name:m}=this.env.tableGroups.get(f),I=d?`${d}.${m}`:m;i.push(new g(_.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${o.join(".")}" already appears in group "${I}"`,s))}else this.env.tableOwnerGroup[l]=this.declarationNode;return{name:o.pop(),schemaName:o.join(".")}}),i}interpretSettingList(r){const i=Ne(r).getValue();this.tableGroup.color=i.color?.length?Zr(i.color?.at(0)?.value):void 0;const[s]=i.note||[];return this.tableGroup.note=s&&{value:Le(s?.value).map(Ot).unwrap(),token:q(s)},[]}}class Rf{constructor(r,i){this.declarationNode=r,this.env=i,this.enum={values:[]}}interpret(){return this.enum.token=q(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const{name:i,schemaName:s}=$n(r);return s.length>1?(this.enum.name=i,this.enum.schemaName=s.join("."),[new g(_.UNSUPPORTED,"Nested schema is not supported",r)]):(this.enum.name=i,this.enum.schemaName=s.length?s[0]:null,[])}interpretBody(r){return r.body.flatMap(i=>{const s=i,o={};o.token=q(s),o.name=Pe(s.callee).unwrap();const f=Ne(s.args[0]).getValue().note?.at(0);return o.note=f&&{value:Le(f.value).map(Ot).unwrap(),token:q(f)},this.enum.values.push(o),[]})}}class Df{constructor(r,i){this.declarationNode=r,this.env=i,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=q(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);const r=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:i,token:s})=>({value:i,type:"column",token:s})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(i=>{i.pk=!1})),r}interpretName(r){const{name:i}=$n(r);return this.tablePartial.name=i,[]}interpretSettingList(r){const i=Ne(r).getValue(),s=wI(i[P.HeaderColor]);this.tablePartial.headerColor=s?Zr(s.value):void 0;const[o]=i[P.Note]||[];return this.tablePartial.note=o&&{value:Le(o?.value).map(Ot).unwrap(),token:q(o)},[]}interpretBody(r){const[i,s]=ct(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case F.Note:return this.tablePartial.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)},[];case F.Indexes:return this.interpretIndexes(i);case F.Check:return this.interpretChecks(i);default:return[]}})}interpretFields(r){return r.flatMap(i=>this.interpretColumn(i))}interpretColumn(r){const i=[],s={};s.name=Me(r.callee).unwrap();const o=xf(r.args[0]);s.type=o.getValue(),i.push(...o.getErrors()),s.token=q(r),s.inline_refs=[];const l=r.args.slice(1);if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length||!!f[P.PrimaryKey]?.length,s.increment=!!f[P.Increment]?.length,s.unique=!!f[P.Unique]?.length,s.not_null=f[P.NotNull]?.length?!0:f[P.Null]?.length?!1:void 0,s.dbdefault=yf(f[P.Default]?.at(0)?.value);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).map(Ot).unwrap(),token:q(d)};const m=f[P.Ref]||[];s.inline_refs=m.flatMap(T=>{const[y]=Zi(T.value.expression);if(co(y,r.symbol))return i.push(new g(_.SAME_ENDPOINT,"Two endpoints are the same",T)),[];const $=T.value.op,J=Ge(T.value.expression).unwrap();let ne;if(J.length===2){const[re,j]=J;ne={schemaName:null,tableName:re,fieldNames:[j],relation:$.value,token:q(T)}}else if(J.length===3){const[re,j,de]=J;ne={schemaName:re,tableName:j,fieldNames:[de],relation:$.value,token:q(T)}}else{i.push(new g(_.UNSUPPORTED,"Unsupported",T));const re=J.pop(),j=J.pop();ne={schemaName:J.join("."),tableName:j,fieldNames:[re],relation:$.value,token:q(T)}}return ne});const I=f[P.Check]||[];s.checks=I.map(T=>{const y=q(T),$=T.value.value.value;return{token:y,expression:$}})}return s.pk||=l.some(f=>Pe(f).unwrap().toLowerCase()==="pk"),s.unique||=l.some(f=>Pe(f).unwrap().toLowerCase()==="unique"),this.tablePartial.fields.push(s),s.pk&&this.pkColumns.push(s),i}interpretIndexes(r){return this.tablePartial.indexes.push(...r.body.body.map(i=>{const s={columns:[]},o=i;s.token=q(o);const l=[o.callee,...o.args];if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length,s.unique=!!f[P.Unique]?.length,s.name=Le(f[P.Name]?.at(0)?.value).unwrap_or(void 0);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).unwrap(),token:q(d)},s.type=Pe(f[P.Type]?.at(0)?.value).unwrap_or(void 0)}return l.flatMap(f=>{if(!(f instanceof He))return f;const d=[];let m=f;for(;m instanceof He;)d.push(m.argumentList),m=m.callee;return d.push(m),d}).forEach(f=>{const{functional:d,nonFunctional:m}=Qi(f).unwrap();s.columns.push(...d.map(I=>({value:I.value.value,type:"expression",token:q(I)})),...m.map(I=>({value:Me(I).unwrap(),type:"column",token:q(I)})))}),s})),[]}interpretChecks(r){return this.tablePartial.checks.push(...r.body.body.map(i=>{const s={},o=i;if(s.token=q(o),o.args[0]instanceof _e){const l=Ne(o.args[0]).getValue();s.name=Le(l[P.Name]?.at(0)?.value).unwrap_or(void 0)}return s.expression=o.callee.value.value,s})),[]}}class RA{constructor(r,i){this.declarationNode=r,this.env=i,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=q(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){if(!r)return this.project.name=null,[];const{name:i}=$n(r);return this.project.name=i,[]}interpretBody(r){return r.body.flatMap(i=>{const s=i;switch(s.type?.value.toLowerCase()){case"table":{const o=new Sf(s,this.env).interpret();return this.project.tables.push(this.env.tables.get(s)),o}case"ref":{const o=new Of(s,this.env).interpret();return this.project.refs.push(this.env.ref.get(s)),o}case"tablegroup":{const o=new Pf(s,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(s)),o}case"enum":{const o=new Rf(s,this.env).interpret();return this.project.enums.push(this.env.enums.get(s)),o}case"note":return this.project.note={value:Le(s.body instanceof ke?s.body.body[0].callee:s.body.callee).map(Ot).unwrap(),token:q(s)},[];case"tablepartial":{const o=new Df(s,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(s)),o}default:return this.project[s.type.value.toLowerCase()]=Le(s.body.callee).unwrap(),[]}})}}function DA(t){return{schemas:[],tables:Array.from(t.tables.values()),notes:Array.from(t.notes.values()),refs:Array.from(t.ref.values()),enums:Array.from(t.enums.values()),tableGroups:Array.from(t.tableGroups.values()),aliases:t.aliases,project:Array.from(t.project.values())[0]||{},tablePartials:Array.from(t.tablePartials.values())}}class MA{constructor(r){this.ast=r,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map}}interpret(){const r=this.ast.body.flatMap(i=>{switch(cn(i).unwrap_or(void 0)){case F.Table:return new Sf(i,this.env).interpret();case F.Note:return new PA(i,this.env).interpret();case F.Ref:return new Of(i,this.env).interpret();case F.TableGroup:return new Pf(i,this.env).interpret();case F.TablePartial:return new Df(i,this.env).interpret();case F.Enum:return new Rf(i,this.env).interpret();case F.Project:return new RA(i,this.env).interpret();default:return[]}});return new lt(DA(this.env),r)}}var le=(t=>(t[t.Function=1]="Function",t[t.Constructor=2]="Constructor",t[t.Field=3]="Field",t[t.Variable=4]="Variable",t[t.Class=5]="Class",t[t.Struct=6]="Struct",t[t.Interface=7]="Interface",t[t.Module=8]="Module",t[t.Property=9]="Property",t[t.Event=10]="Event",t[t.Operator=11]="Operator",t[t.Unit=12]="Unit",t[t.Value=13]="Value",t[t.Constant=14]="Constant",t[t.Enum=15]="Enum",t[t.EnumMember=16]="EnumMember",t[t.Keyword=17]="Keyword",t[t.Text=18]="Text",t[t.Color=19]="Color",t[t.File=20]="File",t[t.Reference=21]="Reference",t[t.Customcolor=22]="Customcolor",t[t.Folder=23]="Folder",t[t.TypeParameter=24]="TypeParameter",t[t.User=25]="User",t[t.Issue=26]="Issue",t[t.Snippet=27]="Snippet",t))(le||{}),be=(t=>(t[t.None=0]="None",t[t.KeepWhitespace=1]="KeepWhitespace",t[t.InsertAsSnippet=4]="InsertAsSnippet",t))(be||{});function Kr(t){switch(t){case U.Schema:return le.Module;case U.Table:case U.TablePartial:return le.Class;case U.Column:case U.TableGroupField:return le.Field;case U.Enum:return le.Enum;case U.EnumField:return le.EnumMember;case U.TableGroup:return le.Struct;default:return le.Text}}function ji(t,r){if(!t||$a(t))return!1;for(const i of t.trailingTrivia){if(i.start>r)break;if(i.kind===A.NEWLINE&&i.end<=r)return!1}return!0}function Ue(){return{suggestions:[]}}function es(t){return{...t,suggestions:t.suggestions.map(r=>({...r,insertText:` ${r.insertText}`}))}}function cs(t){return{...t,suggestions:t.suggestions.map(r=>({...r,insertText:!r.insertText||!r.insertText.split("").every(Yr)?`"${r.insertText??""}"`:r.insertText}))}}function fo(t,r){return t.getOffsetAt(r)}class Mf{constructor(r,i=[]){this.compiler=r,this.triggerCharacters=i}provideCompletionItems(r,i){const s=fo(r,i),o=this.compiler.token.flatStream(),{token:l,index:f}=this.compiler.container.token(s),d=f===void 0?o[0]:o[f+1];if([...l?.trailingTrivia||[],...l?.leadingTrivia||[],...d?.leadingTrivia||[]].find(T=>OI(T)&&$r(s,T)))return Ue();if(f===void 0)return Rc();if([A.STRING_LITERAL,A.QUOTED_STRING].includes(l.kind)&&$r(s,l))return Ue();const m=this.compiler.container.element(s);if(this.compiler.container.scopeKind(s)===te.TOPLEVEL||m instanceof se&&m.type&&m.type.start<=s&&m.type.end>=s)return Rc();const I=[...this.compiler.container.stack(s)].reverse();for(const T of I)if(T instanceof je)switch(T.op?.value){case">":case"<":case"<>":case"-":return xc(this.compiler,s,T);case"~":return UA(this.compiler,s)}else if(T instanceof Vt)switch(T.op?.value){case">":case"<":case"<>":case"-":return xc(this.compiler,s,T);case".":return Uf(this.compiler,s,T)}else{if(T instanceof xt)return Sc(this.compiler,s,T);if(T instanceof _e)return Sc(this.compiler,s,T);if(T instanceof Wt)return kA(this.compiler,s);if(T instanceof W)return Pc(this.compiler,s,T);if(T instanceof se&&(T.bodyColon&&s>=T.bodyColon.end||T.body&&$r(s,T.body)))return Pc(this.compiler,s,void 0)}return Ue()}}function UA(t,r){return pr(t,r,t.parse.ast(),[U.TablePartial])}function xc(t,r,i){const s=t.container.scopeKind(r);if([te.REF,te.TABLE,te.TABLEPARTIAL].includes(s)){const o=pr(t,r,t.container.element(r),[U.Table,U.Schema,U.Column]);return ji(i.op,r)?es(o):o}return Ue()}function pr(t,r,i,s){if(i===void 0)return Ue();let o=i;const l={suggestions:[]};for(;o;){if(o?.symbol?.symbolTable){const{symbol:f}=o;l.suggestions.push(...t.symbol.members(f).filter(({kind:d})=>s.includes(d)).map(({name:d,kind:m})=>({label:d,insertText:d,insertTextRules:be.KeepWhitespace,kind:Kr(m),sortText:Kr(m).toString().padStart(2,"0"),range:void 0})))}o=o instanceof se?o.parent:void 0}return cs(l)}function kA(t,r){switch(t.container.scopeKind(r)){case te.INDEXES:return Ff(t,r);case te.REF:{const s=[...t.container.stack(r)];for(;s.length>0;){const o=s.pop();if(o instanceof Vt&&o.op?.value===".")return Uf(t,r,o)}}return kf(t,r)}return Ue()}function Sc(t,r,i){const{token:s}=t.container.token(r);if([A.COMMA,A.LBRACKET].includes(s?.kind)){const o=Oc(t,r);return s?.kind===A.COMMA&&ji(s,r)?es(o):o}if(i.name&&i.name.start<=r&&i.name.end>=r)return Oc(t,r);if(i.name instanceof yt){const o=FA(t,r,zr(i.name).unwrap_or(""));return s?.kind===A.COLON&&ji(s,r)?es(o):o}return Ue()}function Oc(t,r){const i=t.container.element(r);if(i instanceof qe)return Ue();const s=t.container.scopeKind(r);if(i.body&&!$r(r,i.body)){let o;switch(s){case te.TABLE:case te.TABLEPARTIAL:o=[P.HeaderColor,P.Note];break;case te.TABLEGROUP:o=[P.Color,P.Note];break;default:o=[]}return{suggestions:o.map(l=>({label:l,insertText:`${l}: `,kind:le.Field,insertTextRules:be.KeepWhitespace,range:void 0}))}}switch(s){case te.TABLE:case te.TABLEPARTIAL:return{suggestions:[...[P.PK,P.PrimaryKey,P.Null,P.NotNull,P.Increment,P.Unique].map(o=>({label:o,insertText:o,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0})),...[P.Ref,P.Default,P.Note,P.Check].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.ENUM:return{suggestions:[...[P.Note].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.INDEXES:return{suggestions:[...[P.Unique,P.PK].map(o=>({label:o,insertText:o,insertTextRules:be.KeepWhitespace,kind:le.Property,range:void 0})),...[P.Note,P.Name,P.Type].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.REF:return{suggestions:[P.Update,P.Delete,P.Color].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))};case te.CHECKS:return{suggestions:[P.Name].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))}}return Ue()}function FA(t,r,i){switch(i?.toLowerCase()){case"update":case"delete":return{suggestions:["cascade","set default","set null","restrict"].map(s=>({label:s,insertText:s,kind:le.Value,insertTextRules:be.KeepWhitespace,range:void 0}))};case"type":return{suggestions:["btree","hash"].map(s=>({label:s,insertText:`${s}`,kind:le.Value,insertTextRules:be.KeepWhitespace,range:void 0}))};case"default":return pr(t,r,t.container.element(r),[U.Schema,U.Enum])}return Ue()}function Uf(t,r,i){const s=An(i).unwrap_or([]);if(s.pop(),s.some(l=>!we(l)))return Ue();const o=s.map(l=>Pe(l).unwrap());return cs({suggestions:t.symbol.ofName(o,t.container.element(r)).flatMap(({symbol:l})=>t.symbol.members(l)).map(({kind:l,name:f})=>({label:f,insertText:f,kind:Kr(l),range:void 0}))})}function Pc(t,r,i){switch(t.container.scopeKind(r)){case te.TABLE:case te.TABLEPARTIAL:return BA(t,r,i);case te.PROJECT:return GA(t,r,i);case te.INDEXES:return $A(t,r);case te.ENUM:return CA(t,r,i);case te.REF:{const o=kf(t,r);return t.container.token(r).token?.kind===A.COLON&&ji(t.container.token(r).token,r)?es(o):o}case te.TABLEGROUP:return VA(t);default:return Ue()}}function Rc(){return{suggestions:["Table","TableGroup","Enum","Project","Ref","TablePartial"].map(t=>({label:t,insertText:t,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}}function CA(t,r,i){return i?.callee&&ho(r,i)===1?pr(t,r,t.container.element(r),[U.Schema,U.Table,U.Column]):Ue()}function BA(t,r,i){const s=["Note","indexes","checks"];if(!i?.callee)return{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))};const o=ho(r,i);return o===0?{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}:o===1?WA(t,r):Ue()}function GA(t,r,i){const s=["Table","TableGroup","Enum","Note","Ref","TablePartial"];return i?.callee?ho(r,i)===0?{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}:Ue():{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}}function kf(t,r){return pr(t,r,t.container.element(r),[U.Schema,U.Table,U.Column])}function VA(t){return{suggestions:[...cs({suggestions:[...t.parse.publicSymbolTable().entries()].flatMap(([r])=>{const i=Qr(r).unwrap_or(void 0);if(i===void 0)return[];const{kind:s,name:o}=i;return s!==U.Table&&s!==U.Schema?[]:{label:o,insertText:o,insertTextRules:be.KeepWhitespace,kind:Kr(s),range:void 0}})}).suggestions,...["Note"].map(r=>({label:r,insertText:r,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))]}}function $A(t,r){return Ff(t,r)}function WA(t,r){return{suggestions:[...["integer","int","tinyint","smallint","mediumint","bigint","bit","bool","binary","varbinary","logical","char","nchar","varchar","varchar2","nvarchar","nvarchar2","binary_float","binary_double","float","double","decimal","dec","real","money","smallmoney","enum","tinyblob","tinytext","blob","text","mediumblob","mediumtext","longblob","longtext","ntext","set","inet6","uuid","image","date","time","datetime","datetime2","timestamp","year","smalldatetime","datetimeoffset","XML","sql_variant","uniqueidentifier","CURSOR","BFILE","CLOB","NCLOB","RAW"].map(i=>({label:i,insertText:i,insertTextRules:be.KeepWhitespace,kind:le.TypeParameter,sortText:le.TypeParameter.toString().padStart(2,"0"),range:void 0})),...pr(t,r,t.container.element(r),[U.Enum,U.Schema]).suggestions]}}function Ff(t,r){const s=t.container.element(r)?.parent;if(!(s?.symbol instanceof qr))return Ue();const{symbolTable:o}=s.symbol;return cs({suggestions:[...o.entries()].flatMap(([l])=>{const f=Qr(l).unwrap_or(void 0);if(f===void 0)return[];const{name:d}=f;return{label:d,insertText:d,insertTextRules:be.KeepWhitespace,kind:Kr(U.Column),range:void 0}})})}function ho(t,r){if(!r.callee)return-1;const i=[r.callee,...r.args],s=i.findIndex(o=>t<=o.end);return s===-1?i.length:s}class Cf{constructor(r){this.compiler=r}provideDefinition(r,i){const{uri:s}=r,o=fo(r,i),l=[...this.compiler.container.stack(o)];for(;l.length!==0;){const f=l.pop();if(!f?.referee)continue;let d;if(f.referee?.declaration&&[kn.PRIMARY_EXPRESSION,kn.VARIABLE].includes(f?.kind)&&({declaration:d}=f.referee),d){const{startPos:m,endPos:I}=d;return[{range:{startColumn:m.column+1,startLineNumber:m.line+1,endColumn:I.column+1,endLineNumber:I.line+1},uri:s}]}}return[]}}class Bf{constructor(r){this.compiler=r}provideReferences(r,i){const{uri:s}=r,o=fo(r,i),l=[...this.compiler.container.stack(o)];for(;l.length!==0;){const f=l.pop();if(f&&[kn.ELEMENT_DECLARATION,kn.FUNCTION_APPLICATION,kn.PRIMARY_EXPRESSION].includes(f?.kind)){const{symbol:d}=f;if(d?.references.length)return d.references.map(({startPos:m,endPos:I})=>({range:{startColumn:m.column+1,startLineNumber:m.line+1,endColumn:I.column+1,endLineNumber:I.line+1},uri:s}))}}return[]}}const XA=Object.freeze(Object.defineProperty({__proto__:null,CompletionItemInsertTextRule:be,CompletionItemKind:le,DBMLCompletionItemProvider:Mf,DBMLDefinitionProvider:Cf,DBMLReferencesProvider:Bf},Symbol.toStringTag,{value:"Module"}));function HA(){return this.parse._().getValue().ast}function qA(){return this.parse._().getErrors()}function zA(){return this.parse._().getValue().tokens}function KA(){return this.parse._().getValue().rawDb}function YA(){return this.parse._().getValue().ast.symbol.symbolTable}function JA(){return this.parse.tokens().flatMap(t=>[...t.leadingInvalid,t,...t.trailingInvalid])}function QA(){return this.parse.tokens().filter(qa)}function ZA(t){return t.symbolTable?[...t.symbolTable.entries()].map(([r,i])=>({...Qr(r).unwrap(),symbol:i})):[]}function jA(t,r){if(t.length===0)return[];const i=[];for(let s=r;s;s=s instanceof se?s.parent:void 0){if(!s.symbol?.symbolTable)continue;const{symbolTable:o}=s.symbol;let l=[o],f=[];for(const d of t)f=l.flatMap(m=>LA(d).flatMap(I=>{const T=m.get(I),y=Qr(I).unwrap_or(void 0);return!T||!y?[]:{...y,symbol:T}})),l=f.flatMap(m=>m.symbol.symbolTable?m.symbol.symbolTable:[]);i.push(...f)}return i}function ew(t,r){return`${t.join(".")}@${r.id}`}function tw(t){const r=this.token.flatStream(),{index:i,token:s}=this.container.token(t),o=i===void 0?-1:AI(r,m=>!m.isInvalid,i);if(o===-1)return[this.parse.ast()];const l=r[o].start;let f=this.parse.ast();const d=[f];for(;;){const I=iA(f).find(T=>$r(l,T));if(I===void 0||I instanceof Ze)break;d.push(I),f=I}if(s?.kind===A.COLON)return d;for(;d.length>0;){let m=!1;const I=me(d);if(I instanceof W){const T=this.parse.source();for(let y=I.end;y<t;y+=1)T[y]===`
31
- `&&(d.pop(),m=!0)}else I instanceof je||I instanceof Vt?this.container.token(t).token!==I.op&&(d.pop(),m=!0):I instanceof _e?I.listCloseBracket&&I.end<=t&&(d.pop(),m=!0):I instanceof Wt?I.tupleCloseParen&&I.end<=t&&(d.pop(),m=!0):I instanceof ke?I.blockCloseBrace&&I.end<=t&&(d.pop(),m=!0):I instanceof yt||I.end<t&&(d.pop(),m=!0);if(m){const T=me(d);T instanceof se&&T.end<=t&&d.pop()}if(!m)break}return d}function nw(t){const r=this.token.flatStream().findIndex(i=>i.start>=t);return r===void 0?{token:void 0,index:void 0}:r<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[r-1],index:r-1}}function rw(t){const r=this.container.stack(t);for(let i=r.length-1;i>=0;i-=1)if(r[i]instanceof se)return r[i];return this.parse.ast()}function iw(t){return this.container.element(t)?.symbol?.symbolTable}var te=(t=>(t[t.TABLE=0]="TABLE",t[t.ENUM=1]="ENUM",t[t.TABLEGROUP=2]="TABLEGROUP",t[t.INDEXES=3]="INDEXES",t[t.NOTE=4]="NOTE",t[t.REF=5]="REF",t[t.PROJECT=6]="PROJECT",t[t.CUSTOM=7]="CUSTOM",t[t.TOPLEVEL=8]="TOPLEVEL",t[t.TABLEPARTIAL=9]="TABLEPARTIAL",t[t.CHECKS=10]="CHECKS",t))(te||{});function sw(t){const r=this.container.element(t);if(r instanceof qe)return te.TOPLEVEL;switch(r.type?.value.toLowerCase()){case"table":return te.TABLE;case"enum":return te.ENUM;case"ref":return te.REF;case"tablegroup":return te.TABLEGROUP;case"indexes":return te.INDEXES;case"note":return te.NOTE;case"project":return te.PROJECT;case"tablepartial":return te.TABLEPARTIAL;case"checks":return te.CHECKS;default:return te.CUSTOM}}function Gf(t,r){const i=[...r].sort((o,l)=>l.start-o.start);let s=t;for(const{start:o,end:l,newText:f}of i)s=s.substring(0,o)+f+s.substring(l);return s}function sr(t){return t.startsWith('"')&&t.endsWith('"')&&t.length>=2?t.slice(1,-1):t}function Dc(t){if(typeof t!="string")return{schema:t.schema??$t,table:t.table};const r=t.split(".");if(r.length===1)return{schema:$t,table:sr(r[0])};if(r.length===2)return{schema:sr(r[0]),table:sr(r[1])};const i=r.pop();return{schema:sr(r.join(".")),table:sr(i)}}function Mc(t){return t?t.split("").every(r=>Yr(r)||or(r))&&!or(t[0]):!1}function aw(t,r){if(!t.declaration)return!1;const i=t.declaration;if(!i.name)return!1;const s=i.name;return r.substring(s.start,s.end).includes('"')}function ow(t,r,i){const s=!Mc(r),o=!Mc(t),l=i||s,f=i||o;return{schema:t,table:r,formattedSchema:f?`"${t}"`:t,formattedTable:l?`"${r}"`:r,shouldQuoteSchema:f,shouldQuoteTable:l}}function uw(t,r,i){const s=ur(i);if(r===$t){const d=t.get(s);return d instanceof qr?d:null}const o=Jr(r),l=t.get(o);if(!l||!l.symbolTable)return null;const f=l.symbolTable.get(s);return f instanceof qr?f:null}function lw(t,r,i,s,o){const l=ur(o);let f;if(s===$t)f=t.get(l);else{const d=Jr(s),m=t.get(d);if(!m||!m.symbolTable)return!1;f=m.symbolTable.get(l)}return!(!f||r===s&&i===o)}function cw(t,r,i){let s=t.start-1;for(;s>=0&&/\s/.test(i[s]);)s--;if(s<0||i[s]!==".")return null;for(s--;s>=0&&/\s/.test(i[s]);)s--;if(s<0)return null;let o,l;if(i[s]==='"'){for(l=s+1,s--;s>=0&&i[s]!=='"';)s--;if(s<0)return null;o=s}else{for(l=s+1;s>=0&&/[a-zA-Z0-9_]/.test(i[s]);)s--;o=s+1}const f=i.substring(o,l);return sr(f)===r?{start:o,end:t.end}:null}function fw(t,r,i,s){const o=[],l=new Set;for(const f of t){const m=cw(f,r,s)??{start:f.start,end:f.end},I=`${m.start}-${m.end}`;if(l.has(I))continue;l.add(I);const T=i.schema!==$t?`${i.formattedSchema}.${i.formattedTable}`:i.formattedTable;o.push({start:m.start,end:m.end,newText:T})}return o}function hw(t,r){const i=this.parse.source(),s=this.parse.publicSymbolTable(),o=Dc(t),l=Dc(r),f=o.schema,d=o.table,m=l.schema,I=l.table,T=uw(s,f,d);if(!T||lw(s,f,d,m,I))return i;const y=aw(T,i),$=ow(m,I,y),J=[];if(T.declaration){const re=T.declaration;re.name&&J.push(re.name)}for(const re of T.references)i.substring(re.start,re.end).replace(/"/g,"")===d&&J.push(re);const ne=fw(J,f,$,i);return Gf(i,ne)}class pw{constructor(){this.source="",this.cache=new Map,this.nodeIdGenerator=new PI,this.symbolIdGenerator=new DI,this.token={invalidStream:this.query(QA),flatStream:this.query(JA)},this.parse={source:()=>this.source,_:this.query(this.interpret),ast:this.query(HA),errors:this.query(qA),tokens:this.query(zA),rawDb:this.query(KA),publicSymbolTable:this.query(YA)},this.container={stack:this.query(tw),token:this.query(nw),element:this.query(rw),scope:this.query(iw),scopeKind:this.query(sw)},this.symbol={ofName:this.query(jA,ew),members:this.query(ZA)}}setSource(r){this.source=r,this.cache.clear(),this.nodeIdGenerator.reset(),this.symbolIdGenerator.reset()}query(r,i){const s=Symbol();return(...o)=>{if(o.length===0){if(this.cache.has(s))return this.cache.get(s);const m=r.apply(this,o);return this.cache.set(s,m),m}const l=i?i(...o):o[0];let f=this.cache.get(s);if(f instanceof Map&&f.has(l))return f.get(l);const d=r.apply(this,o);return f instanceof Map||(f=new Map,this.cache.set(s,f)),f.set(l,d),d}}interpret(){const r=new aA(this.source).lex().chain(i=>new lA(i,this.nodeIdGenerator).parse()).chain(({ast:i,tokens:s})=>new OA(i,this.symbolIdGenerator).analyze().map(()=>({ast:i,tokens:s})));return r.getErrors().length>0?r:r.chain(({ast:i,tokens:s})=>new MA(i).interpret().map(o=>({ast:i,tokens:s,rawDb:o})))}renameTable(r,i){return hw.call(this,r,i)}applyTextEdits(r){return Gf(this.parse.source(),r)}initMonacoServices(){return{definitionProvider:new Cf(this),referenceProvider:new Bf(this),autocompletionProvider:new Mf(this)}}}exports.CompileError=g;exports.CompileErrorCode=_;exports.Compiler=pw;exports.ElementDeclarationNode=se;exports.ElementKind=F;exports.ProgramNode=qe;exports.ScopeKind=te;exports.SyntaxNode=Te;exports.SyntaxNodeKind=kn;exports.SyntaxToken=Ze;exports.SyntaxTokenKind=A;exports.addQuoteIfNeeded=UI;exports.serialize=RI;exports.services=XA;
30
+ `)}function xf(t){if(t){if(Fe(t))return{value:Le(t).unwrap(),type:"string"};if(mn(t))return{type:"number",value:Xa(t)};if(In(t))return{value:t.expression.variable.value.toLowerCase(),type:"boolean"};if(t instanceof bt&&t.value)return{value:t.value.value,type:"expression"};if(lo(t))return{value:An(t).map(me).and_then(Pe).unwrap(),type:"string"};throw new Error("Unreachable")}}function Sf(t){let r="",i=null;for(t instanceof He&&(i=t.argumentList.elementList.map(l=>mn(l)?Wa(l):Fe(l)?Le(l).unwrap():Pe(l).unwrap()).join(","),r=`(${i})`,t=t.callee);t instanceof He||t instanceof Bt;)t instanceof He?(r=`(${t.argumentList.elementList.map(f=>mn(f)?Wa(f):Fe(f)?Le(f).unwrap():Pe(f).unwrap()).join(",")})${r}`,t=t.callee):t instanceof Bt&&(r=`${`[${t.indexer.elementList.map(f=>f.name.expression.literal.value).join(",")}]`}${r}`,t=t.array);const{name:s,schemaName:o}=$n(t);return o.length>1?new ct({schemaName:o.length===0?null:o[0],type_name:`${s}${r}`,args:i},[new g(_.UNSUPPORTED,"Nested schema is not supported",t)]):new ct({schemaName:o.length===0?null:o[0],type_name:`${s}${r}`,args:i})}class Of{constructor(r,i){this.declarationNode=r,this.env=i,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=q(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);const r=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:i,token:s})=>({value:i,type:"column",token:s})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(i=>{i.pk=!1})),r}interpretName(r){const{name:i,schemaName:s}=$n(r);return s.length>1?(this.table.name=i,this.table.schemaName=s.join("."),[new g(_.UNSUPPORTED,"Nested schema is not supported",r)]):(this.table.name=i,this.table.schemaName=s.length?s[0]:null,[])}interpretAlias(r){if(!r)return[];const i=Me(r).unwrap_or(null);return i&&(this.env.aliases.push({name:i,kind:"table",value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=i),[]}interpretSettingList(r){const i=Ne(r).getValue();this.table.headerColor=i[P.HeaderColor]?.length?Zr(i[P.HeaderColor]?.at(0)?.value):void 0;const[s]=i[P.Note]||[];return this.table.note=s&&{value:Le(s?.value).map(Ot).unwrap(),token:q(s)},[]}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case F.Note:return this.table.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)},[];case F.Indexes:return this.interpretIndexes(i);case F.Check:return this.interpretChecks(i);default:return[]}})}interpretInjection(r,i){const s={order:i,token:q(r)};return s.name=Pe(r.expression).unwrap_or(""),this.table.partials.push(s),[]}interpretFields(r){const o=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([f])=>Qr(f).unwrap_or(null)?.kind===U.Column).length?[]:[new g(_.EMPTY_TABLE,"A Table must have at least one column",this.declarationNode)],l=r.flatMap((f,d)=>Ji(f.callee)?this.interpretInjection(f.callee,d):this.interpretColumn(f));return[...o,...l]}interpretColumn(r){const i=[],s={};s.name=Me(r.callee).unwrap();const o=Sf(r.args[0]);s.type=o.getValue(),i.push(...o.getErrors()),s.token=q(r),s.inline_refs=[];const l=r.args.slice(1);if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length||!!f[P.PrimaryKey]?.length,s.increment=!!f[P.Increment]?.length,s.unique=!!f[P.Unique]?.length,s.not_null=f[P.NotNull]?.length?!0:f[P.Null]?.length?!1:void 0,s.dbdefault=xf(f[P.Default]?.at(0)?.value);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).map(Ot).unwrap(),token:q(d)};const m=f[P.Ref]||[];s.inline_refs=m.flatMap(T=>{const[y]=Zi(T.value.expression);if(co(y,r.symbol))return i.push(new g(_.SAME_ENDPOINT,"Two endpoints are the same",T)),[];const $=T.value.op,J=Ge(T.value.expression).unwrap();let ne;if(J.length===1){const[j]=J;ne={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[j],relation:$.value,token:q(T)}}else if(J.length===2){const[j,de]=J;ne={schemaName:null,tableName:j,fieldNames:[de],relation:$.value,token:q(T)}}else if(J.length===3){const[j,de,et]=J;ne={schemaName:j,tableName:de,fieldNames:[et],relation:$.value,token:q(T)}}else{i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",T));const j=J.pop(),de=J.pop();ne={schemaName:J.join("."),tableName:de,fieldNames:[j],relation:$.value,token:q(T)}}const re=this.registerInlineRefToEnv(r,y,ne,T);return i.push(...re),re.length===0?ne:[]});const I=f[P.Check]||[];s.checks=I.map(T=>{const y=q(T),$=T.value.value.value;return{token:y,expression:$}})}return s.pk||=l.some(f=>Pe(f).unwrap().toLowerCase()==="pk"),s.unique||=l.some(f=>Pe(f).unwrap().toLowerCase()==="unique"),this.table.fields.push(s),s.pk&&this.pkColumns.push(s),i}interpretIndexes(r){return this.table.indexes.push(...r.body.body.map(i=>{const s={columns:[]},o=i;s.token=q(o);const l=[o.callee,...o.args];if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length,s.unique=!!f[P.Unique]?.length,s.name=Le(f[P.Name]?.at(0)?.value).unwrap_or(void 0);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).unwrap(),token:q(d)},s.type=Pe(f[P.Type]?.at(0)?.value).unwrap_or(void 0)}return l.flatMap(f=>{if(!(f instanceof He))return f;const d=[];for(;f instanceof He;)d.push(f.argumentList),f=f.callee;return d.push(f),d}).forEach(f=>{const{functional:d,nonFunctional:m}=Qi(f).unwrap();s.columns.push(...d.map(I=>({value:I.value.value,type:"expression",token:q(I)})),...m.map(I=>({value:Me(I).unwrap(),type:"column",token:q(I)})))}),s})),[]}interpretChecks(r){return this.table.checks.push(...r.body.body.map(i=>{const s={},o=i;if(s.token=q(o),o.args[0]instanceof _e){const l=Ne(o.args[0]).getValue();s.name=Le(l[P.Name]?.at(0)?.value).unwrap_or(void 0)}return s.expression=o.callee.value.value,s})),[]}registerInlineRefToEnv(r,i,s,o){const l=yf(r.symbol,i);if(this.env.refIds[l])return[new g(_.CIRCULAR_REF,"References with same endpoints exist",o),new g(_.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[l])];const f=Lf(s.relation);return this.env.refIds[l]=o,this.env.ref.set(o,{name:null,schemaName:null,token:s.token,endpoints:[{...s,relation:f[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[Pe(r.callee).unwrap()],token:q(r),relation:f[0]}]}),[]}}class PA{constructor(r,i){this.declarationNode=r,this.env=i,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=q(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const{name:i}=$n(r);return this.note.name=i,[]}interpretSettingList(r){const i=Ne(r).getValue();return this.note.headerColor=i.headercolor?.length?Zr(i.headercolor?.at(0)?.value):void 0,[]}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return i.length!==1||s.length>0?[new g(_.INVALID_NOTE,"Invalid note syntax",r)]:[...this.interpretNote(i[0])]}interpretNote(r){const i=Zc(r,"callee.expression.literal.value","");return this.note.content=Ot(i),[]}}class Pf{constructor(r,i){this.declarationNode=r,this.env=i,this.container=this.declarationNode.parent instanceof se?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=q(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const i=[],s=Ge(this.declarationNode.name).unwrap_or([]);return this.ref.name=s.pop()||null,s.length>1&&i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name)),this.ref.schemaName=s.join(".")||null,i}interpretBody(r){return r instanceof W?this.interpretField(r):this.interpretField(r.body[0])}interpretField(r){const i=r.callee.op.value,{leftExpression:s,rightExpression:o}=r.callee,l=Zi(s),f=Zi(o);if(co(l,f))return[new g(_.SAME_ENDPOINT,"Two endpoints are the same",r)];const d=yf(l,f);if(this.env.refIds[d])return[new g(_.CIRCULAR_REF,"References with same endpoints exist",this.declarationNode),new g(_.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[d])];if(r.args[0]){const I=Ne(r.args[0]).getValue(),T=I.delete?.at(0)?.value;this.ref.onDelete=T instanceof xt?zr(T).unwrap_or(void 0):Pe(T).unwrap_or(void 0);const y=I.update?.at(0)?.value;this.ref.onUpdate=y instanceof xt?zr(y).unwrap_or(void 0):Pe(y).unwrap_or(void 0),this.ref.color=I.color?.length?Zr(I.color?.at(0)?.value):void 0}const m=Lf(i);return this.ref.endpoints=[{...xc(s,this.container),relation:m[0],token:q(s)},{...xc(o,this.container),relation:m[1],token:q(o)}],this.env.refIds[d]=this.declarationNode,[]}}class Rf{constructor(r,i){this.declarationNode=r,this.env=i,this.tableGroup={tables:[]}}interpret(){const r=[];return this.tableGroup.token=q(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),r.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),r}interpretName(r){const i=[],{name:s,schemaName:o}=$n(r);return o.length>=2&&(this.tableGroup.name=s,this.tableGroup.schemaName=o.join("."),i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name))),this.tableGroup.name=s,this.tableGroup.schemaName=o[0]||null,i}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case"note":this.tableGroup.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)};break}return[]})}interpretFields(r){const i=[];return this.tableGroup.tables=r.map(s=>{const o=Ge(s.callee).unwrap();o.length>2&&i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",s));const l=An(s.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[l]){const f=this.env.tableOwnerGroup[l],{schemaName:d,name:m}=this.env.tableGroups.get(f),I=d?`${d}.${m}`:m;i.push(new g(_.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${o.join(".")}" already appears in group "${I}"`,s))}else this.env.tableOwnerGroup[l]=this.declarationNode;return{name:o.pop(),schemaName:o.join(".")}}),i}interpretSettingList(r){const i=Ne(r).getValue();this.tableGroup.color=i.color?.length?Zr(i.color?.at(0)?.value):void 0;const[s]=i.note||[];return this.tableGroup.note=s&&{value:Le(s?.value).map(Ot).unwrap(),token:q(s)},[]}}class Df{constructor(r,i){this.declarationNode=r,this.env=i,this.enum={values:[]}}interpret(){return this.enum.token=q(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const{name:i,schemaName:s}=$n(r);return s.length>1?(this.enum.name=i,this.enum.schemaName=s.join("."),[new g(_.UNSUPPORTED,"Nested schema is not supported",r)]):(this.enum.name=i,this.enum.schemaName=s.length?s[0]:null,[])}interpretBody(r){return r.body.flatMap(i=>{const s=i,o={};o.token=q(s),o.name=Pe(s.callee).unwrap();const f=Ne(s.args[0]).getValue().note?.at(0);return o.note=f&&{value:Le(f.value).map(Ot).unwrap(),token:q(f)},this.enum.values.push(o),[]})}}class Mf{constructor(r,i){this.declarationNode=r,this.env=i,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=q(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);const r=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:i,token:s})=>({value:i,type:"column",token:s})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(i=>{i.pk=!1})),r}interpretName(r){const{name:i}=$n(r);return this.tablePartial.name=i,[]}interpretSettingList(r){const i=Ne(r).getValue(),s=LI(i[P.HeaderColor]);this.tablePartial.headerColor=s?Zr(s.value):void 0;const[o]=i[P.Note]||[];return this.tablePartial.note=o&&{value:Le(o?.value).map(Ot).unwrap(),token:q(o)},[]}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case F.Note:return this.tablePartial.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)},[];case F.Indexes:return this.interpretIndexes(i);case F.Check:return this.interpretChecks(i);default:return[]}})}interpretFields(r){return r.flatMap(i=>this.interpretColumn(i))}interpretColumn(r){const i=[],s={};s.name=Me(r.callee).unwrap();const o=Sf(r.args[0]);s.type=o.getValue(),i.push(...o.getErrors()),s.token=q(r),s.inline_refs=[];const l=r.args.slice(1);if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length||!!f[P.PrimaryKey]?.length,s.increment=!!f[P.Increment]?.length,s.unique=!!f[P.Unique]?.length,s.not_null=f[P.NotNull]?.length?!0:f[P.Null]?.length?!1:void 0,s.dbdefault=xf(f[P.Default]?.at(0)?.value);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).map(Ot).unwrap(),token:q(d)};const m=f[P.Ref]||[];s.inline_refs=m.flatMap(T=>{const[y]=Zi(T.value.expression);if(co(y,r.symbol))return i.push(new g(_.SAME_ENDPOINT,"Two endpoints are the same",T)),[];const $=T.value.op,J=Ge(T.value.expression).unwrap();let ne;if(J.length===2){const[re,j]=J;ne={schemaName:null,tableName:re,fieldNames:[j],relation:$.value,token:q(T)}}else if(J.length===3){const[re,j,de]=J;ne={schemaName:re,tableName:j,fieldNames:[de],relation:$.value,token:q(T)}}else{i.push(new g(_.UNSUPPORTED,"Unsupported",T));const re=J.pop(),j=J.pop();ne={schemaName:J.join("."),tableName:j,fieldNames:[re],relation:$.value,token:q(T)}}return ne});const I=f[P.Check]||[];s.checks=I.map(T=>{const y=q(T),$=T.value.value.value;return{token:y,expression:$}})}return s.pk||=l.some(f=>Pe(f).unwrap().toLowerCase()==="pk"),s.unique||=l.some(f=>Pe(f).unwrap().toLowerCase()==="unique"),this.tablePartial.fields.push(s),s.pk&&this.pkColumns.push(s),i}interpretIndexes(r){return this.tablePartial.indexes.push(...r.body.body.map(i=>{const s={columns:[]},o=i;s.token=q(o);const l=[o.callee,...o.args];if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length,s.unique=!!f[P.Unique]?.length,s.name=Le(f[P.Name]?.at(0)?.value).unwrap_or(void 0);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).unwrap(),token:q(d)},s.type=Pe(f[P.Type]?.at(0)?.value).unwrap_or(void 0)}return l.flatMap(f=>{if(!(f instanceof He))return f;const d=[];let m=f;for(;m instanceof He;)d.push(m.argumentList),m=m.callee;return d.push(m),d}).forEach(f=>{const{functional:d,nonFunctional:m}=Qi(f).unwrap();s.columns.push(...d.map(I=>({value:I.value.value,type:"expression",token:q(I)})),...m.map(I=>({value:Me(I).unwrap(),type:"column",token:q(I)})))}),s})),[]}interpretChecks(r){return this.tablePartial.checks.push(...r.body.body.map(i=>{const s={},o=i;if(s.token=q(o),o.args[0]instanceof _e){const l=Ne(o.args[0]).getValue();s.name=Le(l[P.Name]?.at(0)?.value).unwrap_or(void 0)}return s.expression=o.callee.value.value,s})),[]}}class RA{constructor(r,i){this.declarationNode=r,this.env=i,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=q(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){if(!r)return this.project.name=null,[];const{name:i}=$n(r);return this.project.name=i,[]}interpretBody(r){return r.body.flatMap(i=>{const s=i;switch(s.type?.value.toLowerCase()){case"table":{const o=new Of(s,this.env).interpret();return this.project.tables.push(this.env.tables.get(s)),o}case"ref":{const o=new Pf(s,this.env).interpret();return this.project.refs.push(this.env.ref.get(s)),o}case"tablegroup":{const o=new Rf(s,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(s)),o}case"enum":{const o=new Df(s,this.env).interpret();return this.project.enums.push(this.env.enums.get(s)),o}case"note":return this.project.note={value:Le(s.body instanceof ke?s.body.body[0].callee:s.body.callee).map(Ot).unwrap(),token:q(s)},[];case"tablepartial":{const o=new Mf(s,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(s)),o}default:return this.project[s.type.value.toLowerCase()]=Le(s.body.callee).unwrap(),[]}})}}function DA(t){return{schemas:[],tables:Array.from(t.tables.values()),notes:Array.from(t.notes.values()),refs:Array.from(t.ref.values()),enums:Array.from(t.enums.values()),tableGroups:Array.from(t.tableGroups.values()),aliases:t.aliases,project:Array.from(t.project.values())[0]||{},tablePartials:Array.from(t.tablePartials.values())}}class MA{constructor(r){this.ast=r,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map}}interpret(){const r=this.ast.body.flatMap(i=>{switch(cn(i).unwrap_or(void 0)){case F.Table:return new Of(i,this.env).interpret();case F.Note:return new PA(i,this.env).interpret();case F.Ref:return new Pf(i,this.env).interpret();case F.TableGroup:return new Rf(i,this.env).interpret();case F.TablePartial:return new Mf(i,this.env).interpret();case F.Enum:return new Df(i,this.env).interpret();case F.Project:return new RA(i,this.env).interpret();default:return[]}});return new ct(DA(this.env),r)}}var le=(t=>(t[t.Function=1]="Function",t[t.Constructor=2]="Constructor",t[t.Field=3]="Field",t[t.Variable=4]="Variable",t[t.Class=5]="Class",t[t.Struct=6]="Struct",t[t.Interface=7]="Interface",t[t.Module=8]="Module",t[t.Property=9]="Property",t[t.Event=10]="Event",t[t.Operator=11]="Operator",t[t.Unit=12]="Unit",t[t.Value=13]="Value",t[t.Constant=14]="Constant",t[t.Enum=15]="Enum",t[t.EnumMember=16]="EnumMember",t[t.Keyword=17]="Keyword",t[t.Text=18]="Text",t[t.Color=19]="Color",t[t.File=20]="File",t[t.Reference=21]="Reference",t[t.Customcolor=22]="Customcolor",t[t.Folder=23]="Folder",t[t.TypeParameter=24]="TypeParameter",t[t.User=25]="User",t[t.Issue=26]="Issue",t[t.Snippet=27]="Snippet",t))(le||{}),be=(t=>(t[t.None=0]="None",t[t.KeepWhitespace=1]="KeepWhitespace",t[t.InsertAsSnippet=4]="InsertAsSnippet",t))(be||{});function Kr(t){switch(t){case U.Schema:return le.Module;case U.Table:case U.TablePartial:return le.Class;case U.Column:case U.TableGroupField:return le.Field;case U.Enum:return le.Enum;case U.EnumField:return le.EnumMember;case U.TableGroup:return le.Struct;default:return le.Text}}function ji(t,r){if(!t||$a(t))return!1;for(const i of t.trailingTrivia){if(i.start>r)break;if(i.kind===A.NEWLINE&&i.end<=r)return!1}return!0}function Ue(){return{suggestions:[]}}function es(t){return{...t,suggestions:t.suggestions.map(r=>({...r,insertText:` ${r.insertText}`}))}}function cs(t){return{...t,suggestions:t.suggestions.map(r=>({...r,insertText:!r.insertText||!r.insertText.split("").every(Yr)?`"${r.insertText??""}"`:r.insertText}))}}function fo(t,r){return t.getOffsetAt(r)}class Uf{constructor(r,i=[]){this.compiler=r,this.triggerCharacters=i}provideCompletionItems(r,i){const s=fo(r,i),o=this.compiler.token.flatStream(),{token:l,index:f}=this.compiler.container.token(s),d=f===void 0?o[0]:o[f+1];if([...l?.trailingTrivia||[],...l?.leadingTrivia||[],...d?.leadingTrivia||[]].find(T=>PI(T)&&$r(s,T)))return Ue();if(f===void 0)return Dc();if([A.STRING_LITERAL,A.QUOTED_STRING].includes(l.kind)&&$r(s,l))return Ue();const m=this.compiler.container.element(s);if(this.compiler.container.scopeKind(s)===te.TOPLEVEL||m instanceof se&&m.type&&m.type.start<=s&&m.type.end>=s)return Dc();const I=[...this.compiler.container.stack(s)].reverse();for(const T of I)if(T instanceof je)switch(T.op?.value){case">":case"<":case"<>":case"-":return Sc(this.compiler,s,T);case"~":return UA(this.compiler,s)}else if(T instanceof Vt)switch(T.op?.value){case">":case"<":case"<>":case"-":return Sc(this.compiler,s,T);case".":return kf(this.compiler,s,T)}else{if(T instanceof St)return Oc(this.compiler,s,T);if(T instanceof _e)return Oc(this.compiler,s,T);if(T instanceof Wt)return kA(this.compiler,s);if(T instanceof W)return Rc(this.compiler,s,T);if(T instanceof se&&(T.bodyColon&&s>=T.bodyColon.end||T.body&&$r(s,T.body)))return Rc(this.compiler,s,void 0)}return Ue()}}function UA(t,r){return pr(t,r,t.parse.ast(),[U.TablePartial])}function Sc(t,r,i){const s=t.container.scopeKind(r);if([te.REF,te.TABLE,te.TABLEPARTIAL].includes(s)){const o=pr(t,r,t.container.element(r),[U.Table,U.Schema,U.Column]);return ji(i.op,r)?es(o):o}return Ue()}function pr(t,r,i,s){if(i===void 0)return Ue();let o=i;const l={suggestions:[]};for(;o;){if(o?.symbol?.symbolTable){const{symbol:f}=o;l.suggestions.push(...t.symbol.members(f).filter(({kind:d})=>s.includes(d)).map(({name:d,kind:m})=>({label:d,insertText:d,insertTextRules:be.KeepWhitespace,kind:Kr(m),sortText:Kr(m).toString().padStart(2,"0"),range:void 0})))}o=o instanceof se?o.parent:void 0}return cs(l)}function kA(t,r){switch(t.container.scopeKind(r)){case te.INDEXES:return Cf(t,r);case te.REF:{const s=[...t.container.stack(r)];for(;s.length>0;){const o=s.pop();if(o instanceof Vt&&o.op?.value===".")return kf(t,r,o)}}return Ff(t,r)}return Ue()}function Oc(t,r,i){const{token:s}=t.container.token(r);if([A.COMMA,A.LBRACKET].includes(s?.kind)){const o=Pc(t,r);return s?.kind===A.COMMA&&ji(s,r)?es(o):o}if(i.name&&i.name.start<=r&&i.name.end>=r)return Pc(t,r);if(i.name instanceof xt){const o=FA(t,r,zr(i.name).unwrap_or(""));return s?.kind===A.COLON&&ji(s,r)?es(o):o}return Ue()}function Pc(t,r){const i=t.container.element(r);if(i instanceof qe)return Ue();const s=t.container.scopeKind(r);if(i.body&&!$r(r,i.body)){let o;switch(s){case te.TABLE:case te.TABLEPARTIAL:o=[P.HeaderColor,P.Note];break;case te.TABLEGROUP:o=[P.Color,P.Note];break;default:o=[]}return{suggestions:o.map(l=>({label:l,insertText:`${l}: `,kind:le.Field,insertTextRules:be.KeepWhitespace,range:void 0}))}}switch(s){case te.TABLE:case te.TABLEPARTIAL:return{suggestions:[...[P.PK,P.PrimaryKey,P.Null,P.NotNull,P.Increment,P.Unique].map(o=>({label:o,insertText:o,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0})),...[P.Ref,P.Default,P.Note,P.Check].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.ENUM:return{suggestions:[...[P.Note].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.INDEXES:return{suggestions:[...[P.Unique,P.PK].map(o=>({label:o,insertText:o,insertTextRules:be.KeepWhitespace,kind:le.Property,range:void 0})),...[P.Note,P.Name,P.Type].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.REF:return{suggestions:[P.Update,P.Delete,P.Color].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))};case te.CHECKS:return{suggestions:[P.Name].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))}}return Ue()}function FA(t,r,i){switch(i?.toLowerCase()){case"update":case"delete":return{suggestions:["cascade","set default","set null","restrict"].map(s=>({label:s,insertText:s,kind:le.Value,insertTextRules:be.KeepWhitespace,range:void 0}))};case"type":return{suggestions:["btree","hash"].map(s=>({label:s,insertText:`${s}`,kind:le.Value,insertTextRules:be.KeepWhitespace,range:void 0}))};case"default":return pr(t,r,t.container.element(r),[U.Schema,U.Enum])}return Ue()}function kf(t,r,i){const s=An(i).unwrap_or([]);if(s.pop(),s.some(l=>!we(l)))return Ue();const o=s.map(l=>Pe(l).unwrap());return cs({suggestions:t.symbol.ofName(o,t.container.element(r)).flatMap(({symbol:l})=>t.symbol.members(l)).map(({kind:l,name:f})=>({label:f,insertText:f,kind:Kr(l),range:void 0}))})}function Rc(t,r,i){switch(t.container.scopeKind(r)){case te.TABLE:case te.TABLEPARTIAL:return BA(t,r,i);case te.PROJECT:return GA(t,r,i);case te.INDEXES:return $A(t,r);case te.ENUM:return CA(t,r,i);case te.REF:{const o=Ff(t,r);return t.container.token(r).token?.kind===A.COLON&&ji(t.container.token(r).token,r)?es(o):o}case te.TABLEGROUP:return VA(t);default:return Ue()}}function Dc(){return{suggestions:["Table","TableGroup","Enum","Project","Ref","TablePartial"].map(t=>({label:t,insertText:t,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}}function CA(t,r,i){return i?.callee&&ho(r,i)===1?pr(t,r,t.container.element(r),[U.Schema,U.Table,U.Column]):Ue()}function BA(t,r,i){const s=["Note","indexes","checks"];if(!i?.callee)return{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))};const o=ho(r,i);return o===0?{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}:o===1?WA(t,r):Ue()}function GA(t,r,i){const s=["Table","TableGroup","Enum","Note","Ref","TablePartial"];return i?.callee?ho(r,i)===0?{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}:Ue():{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}}function Ff(t,r){return pr(t,r,t.container.element(r),[U.Schema,U.Table,U.Column])}function VA(t){return{suggestions:[...cs({suggestions:[...t.parse.publicSymbolTable().entries()].flatMap(([r])=>{const i=Qr(r).unwrap_or(void 0);if(i===void 0)return[];const{kind:s,name:o}=i;return s!==U.Table&&s!==U.Schema?[]:{label:o,insertText:o,insertTextRules:be.KeepWhitespace,kind:Kr(s),range:void 0}})}).suggestions,...["Note"].map(r=>({label:r,insertText:r,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))]}}function $A(t,r){return Cf(t,r)}function WA(t,r){return{suggestions:[...["integer","int","tinyint","smallint","mediumint","bigint","bit","bool","binary","varbinary","logical","char","nchar","varchar","varchar2","nvarchar","nvarchar2","binary_float","binary_double","float","double","decimal","dec","real","money","smallmoney","enum","tinyblob","tinytext","blob","text","mediumblob","mediumtext","longblob","longtext","ntext","set","inet6","uuid","image","date","time","datetime","datetime2","timestamp","year","smalldatetime","datetimeoffset","XML","sql_variant","uniqueidentifier","CURSOR","BFILE","CLOB","NCLOB","RAW"].map(i=>({label:i,insertText:i,insertTextRules:be.KeepWhitespace,kind:le.TypeParameter,sortText:le.TypeParameter.toString().padStart(2,"0"),range:void 0})),...pr(t,r,t.container.element(r),[U.Enum,U.Schema]).suggestions]}}function Cf(t,r){const s=t.container.element(r)?.parent;if(!(s?.symbol instanceof qr))return Ue();const{symbolTable:o}=s.symbol;return cs({suggestions:[...o.entries()].flatMap(([l])=>{const f=Qr(l).unwrap_or(void 0);if(f===void 0)return[];const{name:d}=f;return{label:d,insertText:d,insertTextRules:be.KeepWhitespace,kind:Kr(U.Column),range:void 0}})})}function ho(t,r){if(!r.callee)return-1;const i=[r.callee,...r.args],s=i.findIndex(o=>t<=o.end);return s===-1?i.length:s}class Bf{constructor(r){this.compiler=r}provideDefinition(r,i){const{uri:s}=r,o=fo(r,i),l=[...this.compiler.container.stack(o)];for(;l.length!==0;){const f=l.pop();if(!f?.referee)continue;let d;if(f.referee?.declaration&&[kn.PRIMARY_EXPRESSION,kn.VARIABLE].includes(f?.kind)&&({declaration:d}=f.referee),d){const{startPos:m,endPos:I}=d;return[{range:{startColumn:m.column+1,startLineNumber:m.line+1,endColumn:I.column+1,endLineNumber:I.line+1},uri:s}]}}return[]}}class Gf{constructor(r){this.compiler=r}provideReferences(r,i){const{uri:s}=r,o=fo(r,i),l=[...this.compiler.container.stack(o)];for(;l.length!==0;){const f=l.pop();if(f&&[kn.ELEMENT_DECLARATION,kn.FUNCTION_APPLICATION,kn.PRIMARY_EXPRESSION].includes(f?.kind)){const{symbol:d}=f;if(d?.references.length)return d.references.map(({startPos:m,endPos:I})=>({range:{startColumn:m.column+1,startLineNumber:m.line+1,endColumn:I.column+1,endLineNumber:I.line+1},uri:s}))}}return[]}}const XA=Object.freeze(Object.defineProperty({__proto__:null,CompletionItemInsertTextRule:be,CompletionItemKind:le,DBMLCompletionItemProvider:Uf,DBMLDefinitionProvider:Bf,DBMLReferencesProvider:Gf},Symbol.toStringTag,{value:"Module"}));function HA(){return this.parse._().getValue().ast}function qA(){return this.parse._().getErrors()}function zA(){return this.parse._().getValue().tokens}function KA(){return this.parse._().getValue().rawDb}function YA(){return this.parse._().getValue().ast.symbol.symbolTable}function JA(){return this.parse.tokens().flatMap(t=>[...t.leadingInvalid,t,...t.trailingInvalid])}function QA(){return this.parse.tokens().filter(qa)}function ZA(t){return t.symbolTable?[...t.symbolTable.entries()].map(([r,i])=>({...Qr(r).unwrap(),symbol:i})):[]}function jA(t,r){if(t.length===0)return[];const i=[];for(let s=r;s;s=s instanceof se?s.parent:void 0){if(!s.symbol?.symbolTable)continue;const{symbolTable:o}=s.symbol;let l=[o],f=[];for(const d of t)f=l.flatMap(m=>LA(d).flatMap(I=>{const T=m.get(I),y=Qr(I).unwrap_or(void 0);return!T||!y?[]:{...y,symbol:T}})),l=f.flatMap(m=>m.symbol.symbolTable?m.symbol.symbolTable:[]);i.push(...f)}return i}function ew(t,r){return`${t.join(".")}@${r.id}`}function tw(t){const r=this.token.flatStream(),{index:i,token:s}=this.container.token(t),o=i===void 0?-1:wI(r,m=>!m.isInvalid,i);if(o===-1)return[this.parse.ast()];const l=r[o].start;let f=this.parse.ast();const d=[f];for(;;){const I=iA(f).find(T=>$r(l,T));if(I===void 0||I instanceof Ze)break;d.push(I),f=I}if(s?.kind===A.COLON)return d;for(;d.length>0;){let m=!1;const I=me(d);if(I instanceof W){const T=this.parse.source();for(let y=I.end;y<t;y+=1)T[y]===`
31
+ `&&(d.pop(),m=!0)}else I instanceof je||I instanceof Vt?this.container.token(t).token!==I.op&&(d.pop(),m=!0):I instanceof _e?I.listCloseBracket&&I.end<=t&&(d.pop(),m=!0):I instanceof Wt?I.tupleCloseParen&&I.end<=t&&(d.pop(),m=!0):I instanceof ke?I.blockCloseBrace&&I.end<=t&&(d.pop(),m=!0):I instanceof xt||I.end<t&&(d.pop(),m=!0);if(m){const T=me(d);T instanceof se&&T.end<=t&&d.pop()}if(!m)break}return d}function nw(t){const r=this.token.flatStream().findIndex(i=>i.start>=t);return r===void 0?{token:void 0,index:void 0}:r<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[r-1],index:r-1}}function rw(t){const r=this.container.stack(t);for(let i=r.length-1;i>=0;i-=1)if(r[i]instanceof se)return r[i];return this.parse.ast()}function iw(t){return this.container.element(t)?.symbol?.symbolTable}var te=(t=>(t[t.TABLE=0]="TABLE",t[t.ENUM=1]="ENUM",t[t.TABLEGROUP=2]="TABLEGROUP",t[t.INDEXES=3]="INDEXES",t[t.NOTE=4]="NOTE",t[t.REF=5]="REF",t[t.PROJECT=6]="PROJECT",t[t.CUSTOM=7]="CUSTOM",t[t.TOPLEVEL=8]="TOPLEVEL",t[t.TABLEPARTIAL=9]="TABLEPARTIAL",t[t.CHECKS=10]="CHECKS",t))(te||{});function sw(t){const r=this.container.element(t);if(r instanceof qe)return te.TOPLEVEL;switch(r.type?.value.toLowerCase()){case"table":return te.TABLE;case"enum":return te.ENUM;case"ref":return te.REF;case"tablegroup":return te.TABLEGROUP;case"indexes":return te.INDEXES;case"note":return te.NOTE;case"project":return te.PROJECT;case"tablepartial":return te.TABLEPARTIAL;case"checks":return te.CHECKS;default:return te.CUSTOM}}function Vf(t,r){const i=[...r].sort((o,l)=>l.start-o.start);let s=t;for(const{start:o,end:l,newText:f}of i)s=s.substring(0,o)+f+s.substring(l);return s}function sr(t){return t.startsWith('"')&&t.endsWith('"')&&t.length>=2?t.slice(1,-1):t}function Mc(t){if(typeof t!="string")return{schema:t.schema??$t,table:t.table};const r=t.split(".");if(r.length===1)return{schema:$t,table:sr(r[0])};if(r.length===2)return{schema:sr(r[0]),table:sr(r[1])};const i=r.pop();return{schema:sr(r.join(".")),table:sr(i)}}function Uc(t){return t?t.split("").every(r=>Yr(r)||or(r))&&!or(t[0]):!1}function aw(t,r){if(!t.declaration)return!1;const i=t.declaration;if(!i.name)return!1;const s=i.name;return r.substring(s.start,s.end).includes('"')}function ow(t,r,i){const s=!Uc(r),o=!Uc(t),l=i||s,f=i||o;return{schema:t,table:r,formattedSchema:f?`"${t}"`:t,formattedTable:l?`"${r}"`:r,shouldQuoteSchema:f,shouldQuoteTable:l}}function uw(t,r,i){const s=ur(i);if(r===$t){const d=t.get(s);return d instanceof qr?d:null}const o=Jr(r),l=t.get(o);if(!l||!l.symbolTable)return null;const f=l.symbolTable.get(s);return f instanceof qr?f:null}function lw(t,r,i,s,o){const l=ur(o);let f;if(s===$t)f=t.get(l);else{const d=Jr(s),m=t.get(d);if(!m||!m.symbolTable)return!1;f=m.symbolTable.get(l)}return!(!f||r===s&&i===o)}function cw(t,r,i){let s=t.start-1;for(;s>=0&&/\s/.test(i[s]);)s--;if(s<0||i[s]!==".")return null;for(s--;s>=0&&/\s/.test(i[s]);)s--;if(s<0)return null;let o,l;if(i[s]==='"'){for(l=s+1,s--;s>=0&&i[s]!=='"';)s--;if(s<0)return null;o=s}else{for(l=s+1;s>=0&&/[a-zA-Z0-9_]/.test(i[s]);)s--;o=s+1}const f=i.substring(o,l);return sr(f)===r?{start:o,end:t.end}:null}function fw(t,r,i,s){const o=[],l=new Set;for(const f of t){const m=cw(f,r,s)??{start:f.start,end:f.end},I=`${m.start}-${m.end}`;if(l.has(I))continue;l.add(I);const T=i.schema!==$t?`${i.formattedSchema}.${i.formattedTable}`:i.formattedTable;o.push({start:m.start,end:m.end,newText:T})}return o}function hw(t,r){const i=this.parse.source(),s=this.parse.publicSymbolTable(),o=Mc(t),l=Mc(r),f=o.schema,d=o.table,m=l.schema,I=l.table,T=uw(s,f,d);if(!T||lw(s,f,d,m,I))return i;const y=aw(T,i),$=ow(m,I,y),J=[];if(T.declaration){const re=T.declaration;re.name&&J.push(re.name)}for(const re of T.references)i.substring(re.start,re.end).replace(/"/g,"")===d&&J.push(re);const ne=fw(J,f,$,i);return Vf(i,ne)}class pw{constructor(){this.source="",this.cache=new Map,this.nodeIdGenerator=new RI,this.symbolIdGenerator=new MI,this.token={invalidStream:this.query(QA),flatStream:this.query(JA)},this.parse={source:()=>this.source,_:this.query(this.interpret),ast:this.query(HA),errors:this.query(qA),tokens:this.query(zA),rawDb:this.query(KA),publicSymbolTable:this.query(YA)},this.container={stack:this.query(tw),token:this.query(nw),element:this.query(rw),scope:this.query(iw),scopeKind:this.query(sw)},this.symbol={ofName:this.query(jA,ew),members:this.query(ZA)}}setSource(r){this.source=r,this.cache.clear(),this.nodeIdGenerator.reset(),this.symbolIdGenerator.reset()}query(r,i){const s=Symbol();return(...o)=>{if(o.length===0){if(this.cache.has(s))return this.cache.get(s);const m=r.apply(this,o);return this.cache.set(s,m),m}const l=i?i(...o):o[0];let f=this.cache.get(s);if(f instanceof Map&&f.has(l))return f.get(l);const d=r.apply(this,o);return f instanceof Map||(f=new Map,this.cache.set(s,f)),f.set(l,d),d}}interpret(){const r=new aA(this.source).lex().chain(i=>new lA(i,this.nodeIdGenerator).parse()).chain(({ast:i,tokens:s})=>new OA(i,this.symbolIdGenerator).analyze().map(()=>({ast:i,tokens:s})));return r.getErrors().length>0?r:r.chain(({ast:i,tokens:s})=>new MA(i).interpret().map(o=>({ast:i,tokens:s,rawDb:o})))}renameTable(r,i){return hw.call(this,r,i)}applyTextEdits(r){return Vf(this.parse.source(),r)}initMonacoServices(){return{definitionProvider:new Bf(this),referenceProvider:new Gf(this),autocompletionProvider:new Uf(this)}}}exports.CompileError=g;exports.CompileErrorCode=_;exports.Compiler=pw;exports.ElementDeclarationNode=se;exports.ElementKind=F;exports.ProgramNode=qe;exports.ScopeKind=te;exports.SyntaxNode=Te;exports.SyntaxNodeKind=kn;exports.SyntaxToken=Ze;exports.SyntaxTokenKind=A;exports.addQuoteIfNeeded=kI;exports.serialize=DI;exports.services=XA;