tempest.games 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # tempest.games
2
2
 
3
+ ## 0.1.23
4
+
5
+ ### Patch Changes
6
+
7
+ - 71de843: ✏ Fix a typo in the ready log.
8
+
3
9
  ## 0.1.22
4
10
 
5
11
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
  var g4=Object.create;var{getPrototypeOf:d4,defineProperty:Sf,getOwnPropertyNames:e4}=Object;var n8=Object.prototype.hasOwnProperty;var Ff=(n,i,o)=>{o=n!=null?g4(d4(n)):{};let c=i||!n||!n.__esModule?Sf(o,"default",{value:n,enumerable:!0}):o;for(let p of e4(n))if(!n8.call(c,p))Sf(c,p,{get:()=>n[p],enumerable:!0});return c};var h=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);var i8=(n,i)=>{for(var o in i)Sf(n,o,{get:i[o],enumerable:!0,configurable:!0,set:(c)=>i[o]=()=>c})};var cT=h((oT)=>{Object.defineProperty(oT,"__esModule",{value:!0});class xc extends Error{}class dv extends xc{constructor(n){super(`Invalid DateTime: ${n.toMessage()}`)}}class ev extends xc{constructor(n){super(`Invalid Interval: ${n.toMessage()}`)}}class n1 extends xc{constructor(n){super(`Invalid Duration: ${n.toMessage()}`)}}class Qc extends xc{}class cl extends xc{constructor(n){super(`Invalid unit ${n}`)}}class li extends xc{}class Bo extends xc{constructor(){super("Zone is an abstract class")}}var j="numeric",vo="short",yi="long",jm={year:j,month:j,day:j},i1={year:j,month:vo,day:j},T8={year:j,month:vo,day:j,weekday:vo},o1={year:j,month:yi,day:j},c1={year:j,month:yi,day:j,weekday:yi},p1={hour:j,minute:j},x1={hour:j,minute:j,second:j},m1={hour:j,minute:j,second:j,timeZoneName:vo},a1={hour:j,minute:j,second:j,timeZoneName:yi},f1={hour:j,minute:j,hourCycle:"h23"},l1={hour:j,minute:j,second:j,hourCycle:"h23"},$1={hour:j,minute:j,second:j,hourCycle:"h23",timeZoneName:vo},v1={hour:j,minute:j,second:j,hourCycle:"h23",timeZoneName:yi},T1={year:j,month:j,day:j,hour:j,minute:j},J1={year:j,month:j,day:j,hour:j,minute:j,second:j},w1={year:j,month:vo,day:j,hour:j,minute:j},A1={year:j,month:vo,day:j,hour:j,minute:j,second:j},J8={year:j,month:vo,day:j,weekday:vo,hour:j,minute:j},S1={year:j,month:yi,day:j,hour:j,minute:j,timeZoneName:vo},F1={year:j,month:yi,day:j,hour:j,minute:j,second:j,timeZoneName:vo},M1={year:j,month:yi,day:j,weekday:yi,hour:j,minute:j,timeZoneName:yi},R1={year:j,month:yi,day:j,weekday:yi,hour:j,minute:j,second:j,timeZoneName:yi};class Ec{get type(){throw new Bo}get name(){throw new Bo}get ianaName(){return this.name}get isUniversal(){throw new Bo}offsetName(n,i){throw new Bo}formatOffset(n,i){throw new Bo}offset(n){throw new Bo}equals(n){throw new Bo}get isValid(){throw new Bo}}var If=null;class Xx extends Ec{static get instance(){if(If===null)If=new Xx;return If}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(n,{format:i,locale:o}){return V1(n,i,o)}formatOffset(n,i){return Wx(this.offset(n),i)}offset(n){return-new Date(n).getTimezoneOffset()}equals(n){return n.type==="system"}get isValid(){return!0}}var Vm={};function w8(n){if(!Vm[n])Vm[n]=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"});return Vm[n]}var A8={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function S8(n,i){let o=n.format(i).replace(/\u200E/g,""),c=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(o),[,p,x,m,a,f,l,$]=c;return[m,p,x,a,f,l,$]}function F8(n,i){let o=n.formatToParts(i),c=[];for(let p=0;p<o.length;p++){let{type:x,value:m}=o[p],a=A8[x];if(x==="era")c[a]=m;else if(!pn(a))c[a]=parseInt(m,10)}return c}var Hm={};class Yo extends Ec{static create(n){if(!Hm[n])Hm[n]=new Yo(n);return Hm[n]}static resetCache(){Hm={},Vm={}}static isValidSpecifier(n){return this.isValidZone(n)}static isValidZone(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}).format(),!0}catch(i){return!1}}constructor(n){super();this.zoneName=n,this.valid=Yo.isValidZone(n)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(n,{format:i,locale:o}){return V1(n,i,o,this.name)}formatOffset(n,i){return Wx(this.offset(n),i)}offset(n){let i=new Date(n);if(isNaN(i))return NaN;let o=w8(this.name),[c,p,x,m,a,f,l]=o.formatToParts?F8(o,i):S8(o,i);if(m==="BC")c=-Math.abs(c)+1;let v=Dm({year:c,month:p,day:x,hour:a===24?0:a,minute:f,second:l,millisecond:0}),T=+i,F=T%1000;return T-=F>=0?F:1000+F,(v-T)/60000}equals(n){return n.type==="iana"&&n.name===this.name}get isValid(){return this.valid}}var Xv={};function M8(n,i={}){let o=JSON.stringify([n,i]),c=Xv[o];if(!c)c=new Intl.ListFormat(n,i),Xv[o]=c;return c}var gf={};function df(n,i={}){let o=JSON.stringify([n,i]),c=gf[o];if(!c)c=new Intl.DateTimeFormat(n,i),gf[o]=c;return c}var ef={};function R8(n,i={}){let o=JSON.stringify([n,i]),c=ef[o];if(!c)c=new Intl.NumberFormat(n,i),ef[o]=c;return c}var nl={};function W8(n,i={}){let{base:o,...c}=i,p=JSON.stringify([n,c]),x=nl[p];if(!x)x=new Intl.RelativeTimeFormat(n,i),nl[p]=x;return x}var Mx=null;function K8(){if(Mx)return Mx;else return Mx=new Intl.DateTimeFormat().resolvedOptions().locale,Mx}var Gv={};function X8(n){let i=Gv[n];if(!i){let o=new Intl.Locale(n);i="getWeekInfo"in o?o.getWeekInfo():o.weekInfo,Gv[n]=i}return i}function G8(n){let i=n.indexOf("-x-");if(i!==-1)n=n.substring(0,i);let o=n.indexOf("-u-");if(o===-1)return[n];else{let c,p;try{c=df(n).resolvedOptions(),p=n}catch(a){let f=n.substring(0,o);c=df(f).resolvedOptions(),p=f}let{numberingSystem:x,calendar:m}=c;return[p,x,m]}}function Y8(n,i,o){if(o||i){if(!n.includes("-u-"))n+="-u";if(o)n+=`-ca-${o}`;if(i)n+=`-nu-${i}`;return n}else return n}function z8(n){let i=[];for(let o=1;o<=12;o++){let c=cn.utc(2009,o,1);i.push(n(c))}return i}function H8(n){let i=[];for(let o=1;o<=7;o++){let c=cn.utc(2016,11,13+o);i.push(n(c))}return i}function Qm(n,i,o,c){let p=n.listingMode();if(p==="error")return null;else if(p==="en")return o(i);else return c(i)}function Q8(n){if(n.numberingSystem&&n.numberingSystem!=="latn")return!1;else return n.numberingSystem==="latn"||!n.locale||n.locale.startsWith("en")||new Intl.DateTimeFormat(n.intl).resolvedOptions().numberingSystem==="latn"}class W1{constructor(n,i,o){this.padTo=o.padTo||0,this.floor=o.floor||!1;let{padTo:c,floor:p,...x}=o;if(!i||Object.keys(x).length>0){let m={useGrouping:!1,...o};if(o.padTo>0)m.minimumIntegerDigits=o.padTo;this.inf=R8(n,m)}}format(n){if(this.inf){let i=this.floor?Math.floor(n):n;return this.inf.format(i)}else{let i=this.floor?Math.floor(n):ll(n,3);return gn(i,this.padTo)}}}class K1{constructor(n,i,o){this.opts=o,this.originalZone=void 0;let c=void 0;if(this.opts.timeZone)this.dt=n;else if(n.zone.type==="fixed"){let x=-1*(n.offset/60),m=x>=0?`Etc/GMT+${x}`:`Etc/GMT${x}`;if(n.offset!==0&&Yo.create(m).valid)c=m,this.dt=n;else c="UTC",this.dt=n.offset===0?n:n.setZone("UTC").plus({minutes:n.offset}),this.originalZone=n.zone}else if(n.zone.type==="system")this.dt=n;else if(n.zone.type==="iana")this.dt=n,c=n.zone.name;else c="UTC",this.dt=n.setZone("UTC").plus({minutes:n.offset}),this.originalZone=n.zone;let p={...this.opts};p.timeZone=p.timeZone||c,this.dtf=df(i,p)}format(){if(this.originalZone)return this.formatToParts().map(({value:n})=>n).join("");return this.dtf.format(this.dt.toJSDate())}formatToParts(){let n=this.dtf.formatToParts(this.dt.toJSDate());if(this.originalZone)return n.map((i)=>{if(i.type==="timeZoneName"){let o=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...i,value:o}}else return i});return n}resolvedOptions(){return this.dtf.resolvedOptions()}}class X1{constructor(n,i,o){if(this.opts={style:"long",...o},!i&&E1())this.rtf=W8(n,o)}format(n,i){if(this.rtf)return this.rtf.format(n,i);else return t8(i,n,this.opts.numeric,this.opts.style!=="long")}formatToParts(n,i){if(this.rtf)return this.rtf.formatToParts(n,i);else return[]}}var O8={firstDay:1,minimalDays:4,weekend:[6,7]};class Gn{static fromOpts(n){return Gn.create(n.locale,n.numberingSystem,n.outputCalendar,n.weekSettings,n.defaultToEN)}static create(n,i,o,c,p=!1){let x=n||Nn.defaultLocale,m=x||(p?"en-US":K8()),a=i||Nn.defaultNumberingSystem,f=o||Nn.defaultOutputCalendar,l=il(c)||Nn.defaultWeekSettings;return new Gn(m,a,f,l,x)}static resetCache(){Mx=null,gf={},ef={},nl={}}static fromObject({locale:n,numberingSystem:i,outputCalendar:o,weekSettings:c}={}){return Gn.create(n,i,o,c)}constructor(n,i,o,c,p){let[x,m,a]=G8(n);this.locale=x,this.numberingSystem=i||m||null,this.outputCalendar=o||a||null,this.weekSettings=c,this.intl=Y8(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=p,this.fastNumbersCached=null}get fastNumbers(){if(this.fastNumbersCached==null)this.fastNumbersCached=Q8(this);return this.fastNumbersCached}listingMode(){let n=this.isEnglish(),i=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return n&&i?"en":"intl"}clone(n){if(!n||Object.getOwnPropertyNames(n).length===0)return this;else return Gn.create(n.locale||this.specifiedLocale,n.numberingSystem||this.numberingSystem,n.outputCalendar||this.outputCalendar,il(n.weekSettings)||this.weekSettings,n.defaultToEN||!1)}redefaultToEN(n={}){return this.clone({...n,defaultToEN:!0})}redefaultToSystem(n={}){return this.clone({...n,defaultToEN:!1})}months(n,i=!1){return Qm(this,n,b1,()=>{let o=i?{month:n,day:"numeric"}:{month:n},c=i?"format":"standalone";if(!this.monthsCache[c][n])this.monthsCache[c][n]=z8((p)=>this.extract(p,o,"month"));return this.monthsCache[c][n]})}weekdays(n,i=!1){return Qm(this,n,y1,()=>{let o=i?{weekday:n,year:"numeric",month:"long",day:"numeric"}:{weekday:n},c=i?"format":"standalone";if(!this.weekdaysCache[c][n])this.weekdaysCache[c][n]=H8((p)=>this.extract(p,o,"weekday"));return this.weekdaysCache[c][n]})}meridiems(){return Qm(this,void 0,()=>L1,()=>{if(!this.meridiemCache){let n={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[cn.utc(2016,11,13,9),cn.utc(2016,11,13,19)].map((i)=>this.extract(i,n,"dayperiod"))}return this.meridiemCache})}eras(n){return Qm(this,n,N1,()=>{let i={era:n};if(!this.eraCache[n])this.eraCache[n]=[cn.utc(-40,1,1),cn.utc(2017,1,1)].map((o)=>this.extract(o,i,"era"));return this.eraCache[n]})}extract(n,i,o){let c=this.dtFormatter(n,i),p=c.formatToParts(),x=p.find((m)=>m.type.toLowerCase()===o);return x?x.value:null}numberFormatter(n={}){return new W1(this.intl,n.forceSimple||this.fastNumbers,n)}dtFormatter(n,i={}){return new K1(n,this.intl,i)}relFormatter(n={}){return new X1(this.intl,this.isEnglish(),n)}listFormatter(n={}){return M8(this.intl,n)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")}getWeekSettings(){if(this.weekSettings)return this.weekSettings;else if(!U1())return O8;else return X8(this.locale)}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(n){return this.locale===n.locale&&this.numberingSystem===n.numberingSystem&&this.outputCalendar===n.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}var kf=null;class Ri extends Ec{static get utcInstance(){if(kf===null)kf=new Ri(0);return kf}static instance(n){return n===0?Ri.utcInstance:new Ri(n)}static parseSpecifier(n){if(n){let i=n.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(i)return new Ri(Cm(i[1],i[2]))}return null}constructor(n){super();this.fixed=n}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Wx(this.fixed,"narrow")}`}get ianaName(){if(this.fixed===0)return"Etc/UTC";else return`Etc/GMT${Wx(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(n,i){return Wx(this.fixed,i)}get isUniversal(){return!0}offset(){return this.fixed}equals(n){return n.type==="fixed"&&n.fixed===this.fixed}get isValid(){return!0}}class pl extends Ec{constructor(n){super();this.zoneName=n}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function cc(n,i){if(pn(n)||n===null)return i;else if(n instanceof Ec)return n;else if(b8(n)){let o=n.toLowerCase();if(o==="default")return i;else if(o==="local"||o==="system")return Xx.instance;else if(o==="utc"||o==="gmt")return Ri.utcInstance;else return Ri.parseSpecifier(o)||Yo.create(n)}else if(pc(n))return Ri.instance(n);else if(typeof n==="object"&&"offset"in n&&typeof n.offset==="function")return n;else return new pl(n)}var xl={arab:"[\u0660-\u0669]",arabext:"[\u06F0-\u06F9]",bali:"[\u1B50-\u1B59]",beng:"[\u09E6-\u09EF]",deva:"[\u0966-\u096F]",fullwide:"[\uFF10-\uFF19]",gujr:"[\u0AE6-\u0AEF]",hanidec:"[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",khmr:"[\u17E0-\u17E9]",knda:"[\u0CE6-\u0CEF]",laoo:"[\u0ED0-\u0ED9]",limb:"[\u1946-\u194F]",mlym:"[\u0D66-\u0D6F]",mong:"[\u1810-\u1819]",mymr:"[\u1040-\u1049]",orya:"[\u0B66-\u0B6F]",tamldec:"[\u0BE6-\u0BEF]",telu:"[\u0C66-\u0C6F]",thai:"[\u0E50-\u0E59]",tibt:"[\u0F20-\u0F29]",latn:"\\d"},Yv={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},E8=xl.hanidec.replace(/[\[|\]]/g,"").split("");function U8(n){let i=parseInt(n,10);if(isNaN(i)){i="";for(let o=0;o<n.length;o++){let c=n.charCodeAt(o);if(n[o].search(xl.hanidec)!==-1)i+=E8.indexOf(n[o]);else for(let p in Yv){let[x,m]=Yv[p];if(c>=x&&c<=m)i+=c-x}}return parseInt(i,10)}else return i}var lp={};function V8(){lp={}}function lo({numberingSystem:n},i=""){let o=n||"latn";if(!lp[o])lp[o]={};if(!lp[o][i])lp[o][i]=new RegExp(`${xl[o]}${i}`);return lp[o][i]}var zv=()=>Date.now(),Hv="system",Qv=null,Ov=null,Ev=null,Uv=60,Vv,_v=null;class Nn{static get now(){return zv}static set now(n){zv=n}static set defaultZone(n){Hv=n}static get defaultZone(){return cc(Hv,Xx.instance)}static get defaultLocale(){return Qv}static set defaultLocale(n){Qv=n}static get defaultNumberingSystem(){return Ov}static set defaultNumberingSystem(n){Ov=n}static get defaultOutputCalendar(){return Ev}static set defaultOutputCalendar(n){Ev=n}static get defaultWeekSettings(){return _v}static set defaultWeekSettings(n){_v=il(n)}static get twoDigitCutoffYear(){return Uv}static set twoDigitCutoffYear(n){Uv=n%100}static get throwOnInvalid(){return Vv}static set throwOnInvalid(n){Vv=n}static resetCaches(){Gn.resetCache(),Yo.resetCache(),cn.resetCache(),V8()}}class ti{constructor(n,i){this.reason=n,this.explanation=i}toMessage(){if(this.explanation)return`${this.reason}: ${this.explanation}`;else return this.reason}}var G1=[0,31,59,90,120,151,181,212,243,273,304,334],Y1=[0,31,60,91,121,152,182,213,244,274,305,335];function ri(n,i){return new ti("unit out of range",`you specified ${i} (of type ${typeof i}) as a ${n}, which is invalid`)}function ml(n,i,o){let c=new Date(Date.UTC(n,i-1,o));if(n<100&&n>=0)c.setUTCFullYear(c.getUTCFullYear()-1900);let p=c.getUTCDay();return p===0?7:p}function z1(n,i,o){return o+(Gx(n)?Y1:G1)[i-1]}function H1(n,i){let o=Gx(n)?Y1:G1,c=o.findIndex((x)=>x<i),p=i-o[c];return{month:c+1,day:p}}function al(n,i){return(n-i+7)%7+1}function Bm(n,i=4,o=1){let{year:c,month:p,day:x}=n,m=z1(c,p,x),a=al(ml(c,p,x),o),f=Math.floor((m-a+14-i)/7),l;if(f<1)l=c-1,f=Kx(l,i,o);else if(f>Kx(c,i,o))l=c+1,f=1;else l=c;return{weekYear:l,weekNumber:f,weekday:a,...hm(n)}}function uv(n,i=4,o=1){let{weekYear:c,weekNumber:p,weekday:x}=n,m=al(ml(c,1,i),o),a=vp(c),f=p*7+x-m-7+i,l;if(f<1)l=c-1,f+=vp(l);else if(f>a)l=c+1,f-=vp(c);else l=c;let{month:$,day:v}=H1(l,f);return{year:l,month:$,day:v,...hm(n)}}function sf(n){let{year:i,month:o,day:c}=n,p=z1(i,o,c);return{year:i,ordinal:p,...hm(n)}}function bv(n){let{year:i,ordinal:o}=n,{month:c,day:p}=H1(i,o);return{year:i,month:c,day:p,...hm(n)}}function jv(n,i){if(!pn(n.localWeekday)||!pn(n.localWeekNumber)||!pn(n.localWeekYear)){if(!pn(n.weekday)||!pn(n.weekNumber)||!pn(n.weekYear))throw new Qc("Cannot mix locale-based week fields with ISO-based week fields");if(!pn(n.localWeekday))n.weekday=n.localWeekday;if(!pn(n.localWeekNumber))n.weekNumber=n.localWeekNumber;if(!pn(n.localWeekYear))n.weekYear=n.localWeekYear;return delete n.localWeekday,delete n.localWeekNumber,delete n.localWeekYear,{minDaysInFirstWeek:i.getMinDaysInFirstWeek(),startOfWeek:i.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function _8(n,i=4,o=1){let c=Nm(n.weekYear),p=gi(n.weekNumber,1,Kx(n.weekYear,i,o)),x=gi(n.weekday,1,7);if(!c)return ri("weekYear",n.weekYear);else if(!p)return ri("week",n.weekNumber);else if(!x)return ri("weekday",n.weekday);else return!1}function u8(n){let i=Nm(n.year),o=gi(n.ordinal,1,vp(n.year));if(!i)return ri("year",n.year);else if(!o)return ri("ordinal",n.ordinal);else return!1}function Q1(n){let i=Nm(n.year),o=gi(n.month,1,12),c=gi(n.day,1,ym(n.year,n.month));if(!i)return ri("year",n.year);else if(!o)return ri("month",n.month);else if(!c)return ri("day",n.day);else return!1}function O1(n){let{hour:i,minute:o,second:c,millisecond:p}=n,x=gi(i,0,23)||i===24&&o===0&&c===0&&p===0,m=gi(o,0,59),a=gi(c,0,59),f=gi(p,0,999);if(!x)return ri("hour",i);else if(!m)return ri("minute",o);else if(!a)return ri("second",c);else if(!f)return ri("millisecond",p);else return!1}function pn(n){return typeof n==="undefined"}function pc(n){return typeof n==="number"}function Nm(n){return typeof n==="number"&&n%1===0}function b8(n){return typeof n==="string"}function j8(n){return Object.prototype.toString.call(n)==="[object Date]"}function E1(){try{return typeof Intl!=="undefined"&&!!Intl.RelativeTimeFormat}catch(n){return!1}}function U1(){try{return typeof Intl!=="undefined"&&!!Intl.Locale&&(("weekInfo"in Intl.Locale.prototype)||("getWeekInfo"in Intl.Locale.prototype))}catch(n){return!1}}function B8(n){return Array.isArray(n)?n:[n]}function Bv(n,i,o){if(n.length===0)return;return n.reduce((c,p)=>{let x=[i(p),p];if(!c)return x;else if(o(c[0],x[0])===c[0])return c;else return x},null)[1]}function y8(n,i){return i.reduce((o,c)=>{return o[c]=n[c],o},{})}function Jp(n,i){return Object.prototype.hasOwnProperty.call(n,i)}function il(n){if(n==null)return null;else if(typeof n!=="object")throw new li("Week settings must be an object");else{if(!gi(n.firstDay,1,7)||!gi(n.minimalDays,1,7)||!Array.isArray(n.weekend)||n.weekend.some((i)=>!gi(i,1,7)))throw new li("Invalid week settings");return{firstDay:n.firstDay,minimalDays:n.minimalDays,weekend:Array.from(n.weekend)}}}function gi(n,i,o){return Nm(n)&&n>=i&&n<=o}function L8(n,i){return n-i*Math.floor(n/i)}function gn(n,i=2){let o=n<0,c;if(o)c="-"+(""+-n).padStart(i,"0");else c=(""+n).padStart(i,"0");return c}function oc(n){if(pn(n)||n===null||n==="")return;else return parseInt(n,10)}function zc(n){if(pn(n)||n===null||n==="")return;else return parseFloat(n)}function fl(n){if(pn(n)||n===null||n==="")return;else{let i=parseFloat("0."+n)*1000;return Math.floor(i)}}function ll(n,i,o=!1){let c=10**i;return(o?Math.trunc:Math.round)(n*c)/c}function Gx(n){return n%4===0&&(n%100!==0||n%400===0)}function vp(n){return Gx(n)?366:365}function ym(n,i){let o=L8(i-1,12)+1,c=n+(i-o)/12;if(o===2)return Gx(c)?29:28;else return[31,null,31,30,31,30,31,31,30,31,30,31][o-1]}function Dm(n){let i=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second,n.millisecond);if(n.year<100&&n.year>=0)i=new Date(i),i.setUTCFullYear(n.year,n.month-1,n.day);return+i}function yv(n,i,o){return-al(ml(n,1,i),o)+i-1}function Kx(n,i=4,o=1){let c=yv(n,i,o),p=yv(n+1,i,o);return(vp(n)-c+p)/7}function ol(n){if(n>99)return n;else return n>Nn.twoDigitCutoffYear?1900+n:2000+n}function V1(n,i,o,c=null){let p=new Date(n),x={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};if(c)x.timeZone=c;let m={timeZoneName:i,...x},a=new Intl.DateTimeFormat(o,m).formatToParts(p).find((f)=>f.type.toLowerCase()==="timezonename");return a?a.value:null}function Cm(n,i){let o=parseInt(n,10);if(Number.isNaN(o))o=0;let c=parseInt(i,10)||0,p=o<0||Object.is(o,-0)?-c:c;return o*60+p}function _1(n){let i=Number(n);if(typeof n==="boolean"||n===""||Number.isNaN(i))throw new li(`Invalid unit value ${n}`);return i}function Lm(n,i){let o={};for(let c in n)if(Jp(n,c)){let p=n[c];if(p===void 0||p===null)continue;o[i(c)]=_1(p)}return o}function Wx(n,i){let o=Math.trunc(Math.abs(n/60)),c=Math.trunc(Math.abs(n%60)),p=n>=0?"+":"-";switch(i){case"short":return`${p}${gn(o,2)}:${gn(c,2)}`;case"narrow":return`${p}${o}${c>0?`:${c}`:""}`;case"techie":return`${p}${gn(o,2)}${gn(c,2)}`;default:throw new RangeError(`Value format ${i} is out of range for property format`)}}function hm(n){return y8(n,["hour","minute","second","millisecond"])}var N8=["January","February","March","April","May","June","July","August","September","October","November","December"],u1=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],D8=["J","F","M","A","M","J","J","A","S","O","N","D"];function b1(n){switch(n){case"narrow":return[...D8];case"short":return[...u1];case"long":return[...N8];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}var j1=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],B1=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],C8=["M","T","W","T","F","S","S"];function y1(n){switch(n){case"narrow":return[...C8];case"short":return[...B1];case"long":return[...j1];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var L1=["AM","PM"],h8=["Before Christ","Anno Domini"],I8=["BC","AD"],k8=["B","A"];function N1(n){switch(n){case"narrow":return[...k8];case"short":return[...I8];case"long":return[...h8];default:return null}}function s8(n){return L1[n.hour<12?0:1]}function Z8(n,i){return y1(i)[n.weekday-1]}function q8(n,i){return b1(i)[n.month-1]}function P8(n,i){return N1(i)[n.year<0?0:1]}function t8(n,i,o="always",c=!1){let p={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},x=["hours","minutes","seconds"].indexOf(n)===-1;if(o==="auto"&&x){let v=n==="days";switch(i){case 1:return v?"tomorrow":`next ${p[n][0]}`;case-1:return v?"yesterday":`last ${p[n][0]}`;case 0:return v?"today":`this ${p[n][0]}`}}let m=Object.is(i,-0)||i<0,a=Math.abs(i),f=a===1,l=p[n],$=c?f?l[1]:l[2]||l[1]:f?p[n][0]:n;return m?`${a} ${$} ago`:`in ${a} ${$}`}function Lv(n,i){let o="";for(let c of n)if(c.literal)o+=c.val;else o+=i(c.val);return o}var r8={D:jm,DD:i1,DDD:o1,DDDD:c1,t:p1,tt:x1,ttt:m1,tttt:a1,T:f1,TT:l1,TTT:$1,TTTT:v1,f:T1,ff:w1,fff:S1,ffff:M1,F:J1,FF:A1,FFF:F1,FFFF:R1};class Mi{static create(n,i={}){return new Mi(n,i)}static parseFormat(n){let i=null,o="",c=!1,p=[];for(let x=0;x<n.length;x++){let m=n.charAt(x);if(m==="'"){if(o.length>0)p.push({literal:c||/^\s+$/.test(o),val:o});i=null,o="",c=!c}else if(c)o+=m;else if(m===i)o+=m;else{if(o.length>0)p.push({literal:/^\s+$/.test(o),val:o});o=m,i=m}}if(o.length>0)p.push({literal:c||/^\s+$/.test(o),val:o});return p}static macroTokenToFormatOpts(n){return r8[n]}constructor(n,i){this.opts=i,this.loc=n,this.systemLoc=null}formatWithSystemDefault(n,i){if(this.systemLoc===null)this.systemLoc=this.loc.redefaultToSystem();return this.systemLoc.dtFormatter(n,{...this.opts,...i}).format()}dtFormatter(n,i={}){return this.loc.dtFormatter(n,{...this.opts,...i})}formatDateTime(n,i){return this.dtFormatter(n,i).format()}formatDateTimeParts(n,i){return this.dtFormatter(n,i).formatToParts()}formatInterval(n,i){return this.dtFormatter(n.start,i).dtf.formatRange(n.start.toJSDate(),n.end.toJSDate())}resolvedOptions(n,i){return this.dtFormatter(n,i).resolvedOptions()}num(n,i=0){if(this.opts.forceSimple)return gn(n,i);let o={...this.opts};if(i>0)o.padTo=i;return this.loc.numberFormatter(o).format(n)}formatDateTimeFromString(n,i){let o=this.loc.listingMode()==="en",c=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",p=(T,F)=>this.loc.extract(n,T,F),x=(T)=>{if(n.isOffsetFixed&&n.offset===0&&T.allowZ)return"Z";return n.isValid?n.zone.formatOffset(n.ts,T.format):""},m=()=>o?s8(n):p({hour:"numeric",hourCycle:"h12"},"dayperiod"),a=(T,F)=>o?q8(n,T):p(F?{month:T}:{month:T,day:"numeric"},"month"),f=(T,F)=>o?Z8(n,T):p(F?{weekday:T}:{weekday:T,month:"long",day:"numeric"},"weekday"),l=(T)=>{let F=Mi.macroTokenToFormatOpts(T);if(F)return this.formatWithSystemDefault(n,F);else return T},$=(T)=>o?P8(n,T):p({era:T},"era"),v=(T)=>{switch(T){case"S":return this.num(n.millisecond);case"u":case"SSS":return this.num(n.millisecond,3);case"s":return this.num(n.second);case"ss":return this.num(n.second,2);case"uu":return this.num(Math.floor(n.millisecond/10),2);case"uuu":return this.num(Math.floor(n.millisecond/100));case"m":return this.num(n.minute);case"mm":return this.num(n.minute,2);case"h":return this.num(n.hour%12===0?12:n.hour%12);case"hh":return this.num(n.hour%12===0?12:n.hour%12,2);case"H":return this.num(n.hour);case"HH":return this.num(n.hour,2);case"Z":return x({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return x({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return x({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return n.zone.offsetName(n.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return n.zone.offsetName(n.ts,{format:"long",locale:this.loc.locale});case"z":return n.zoneName;case"a":return m();case"d":return c?p({day:"numeric"},"day"):this.num(n.day);case"dd":return c?p({day:"2-digit"},"day"):this.num(n.day,2);case"c":return this.num(n.weekday);case"ccc":return f("short",!0);case"cccc":return f("long",!0);case"ccccc":return f("narrow",!0);case"E":return this.num(n.weekday);case"EEE":return f("short",!1);case"EEEE":return f("long",!1);case"EEEEE":return f("narrow",!1);case"L":return c?p({month:"numeric",day:"numeric"},"month"):this.num(n.month);case"LL":return c?p({month:"2-digit",day:"numeric"},"month"):this.num(n.month,2);case"LLL":return a("short",!0);case"LLLL":return a("long",!0);case"LLLLL":return a("narrow",!0);case"M":return c?p({month:"numeric"},"month"):this.num(n.month);case"MM":return c?p({month:"2-digit"},"month"):this.num(n.month,2);case"MMM":return a("short",!1);case"MMMM":return a("long",!1);case"MMMMM":return a("narrow",!1);case"y":return c?p({year:"numeric"},"year"):this.num(n.year);case"yy":return c?p({year:"2-digit"},"year"):this.num(n.year.toString().slice(-2),2);case"yyyy":return c?p({year:"numeric"},"year"):this.num(n.year,4);case"yyyyyy":return c?p({year:"numeric"},"year"):this.num(n.year,6);case"G":return $("short");case"GG":return $("long");case"GGGGG":return $("narrow");case"kk":return this.num(n.weekYear.toString().slice(-2),2);case"kkkk":return this.num(n.weekYear,4);case"W":return this.num(n.weekNumber);case"WW":return this.num(n.weekNumber,2);case"n":return this.num(n.localWeekNumber);case"nn":return this.num(n.localWeekNumber,2);case"ii":return this.num(n.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(n.localWeekYear,4);case"o":return this.num(n.ordinal);case"ooo":return this.num(n.ordinal,3);case"q":return this.num(n.quarter);case"qq":return this.num(n.quarter,2);case"X":return this.num(Math.floor(n.ts/1000));case"x":return this.num(n.ts);default:return l(T)}};return Lv(Mi.parseFormat(i),v)}formatDurationFromString(n,i){let o=(a)=>{switch(a[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},c=(a)=>(f)=>{let l=o(f);if(l)return this.num(a.get(l),f.length);else return f},p=Mi.parseFormat(i),x=p.reduce((a,{literal:f,val:l})=>f?a:a.concat(l),[]),m=n.shiftTo(...x.map(o).filter((a)=>a));return Lv(p,c(m))}}var D1=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function wp(...n){let i=n.reduce((o,c)=>o+c.source,"");return RegExp(`^${i}$`)}function Ap(...n){return(i)=>n.reduce(([o,c,p],x)=>{let[m,a,f]=x(i,p);return[{...o,...m},a||c,f]},[{},null,1]).slice(0,2)}function Sp(n,...i){if(n==null)return[null,null];for(let[o,c]of i){let p=o.exec(n);if(p)return c(p)}return[null,null]}function C1(...n){return(i,o)=>{let c={},p;for(p=0;p<n.length;p++)c[n[p]]=oc(i[o+p]);return[c,null,o+p]}}var h1=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,g8=`(?:${h1.source}?(?:\\[(${D1.source})\\])?)?`,$l=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,I1=RegExp(`${$l.source}${g8}`),vl=RegExp(`(?:T${I1.source})?`),d8=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,e8=/(\d{4})-?W(\d\d)(?:-?(\d))?/,n6=/(\d{4})-?(\d{3})/,i6=C1("weekYear","weekNumber","weekDay"),o6=C1("year","ordinal"),c6=/(\d{4})-(\d\d)-(\d\d)/,k1=RegExp(`${$l.source} ?(?:${h1.source}|(${D1.source}))?`),p6=RegExp(`(?: ${k1.source})?`);function Tp(n,i,o){let c=n[i];return pn(c)?o:oc(c)}function x6(n,i){return[{year:Tp(n,i),month:Tp(n,i+1,1),day:Tp(n,i+2,1)},null,i+3]}function Fp(n,i){return[{hours:Tp(n,i,0),minutes:Tp(n,i+1,0),seconds:Tp(n,i+2,0),milliseconds:fl(n[i+3])},null,i+4]}function Yx(n,i){let o=!n[i]&&!n[i+1],c=Cm(n[i+1],n[i+2]),p=o?null:Ri.instance(c);return[{},p,i+3]}function zx(n,i){let o=n[i]?Yo.create(n[i]):null;return[{},o,i+1]}var m6=RegExp(`^T?${$l.source}$`),a6=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function f6(n){let[i,o,c,p,x,m,a,f,l]=n,$=i[0]==="-",v=f&&f[0]==="-",T=(F,R=!1)=>F!==void 0&&(R||F&&$)?-F:F;return[{years:T(zc(o)),months:T(zc(c)),weeks:T(zc(p)),days:T(zc(x)),hours:T(zc(m)),minutes:T(zc(a)),seconds:T(zc(f),f==="-0"),milliseconds:T(fl(l),v)}]}var l6={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Tl(n,i,o,c,p,x,m){let a={year:i.length===2?ol(oc(i)):oc(i),month:u1.indexOf(o)+1,day:oc(c),hour:oc(p),minute:oc(x)};if(m)a.second=oc(m);if(n)a.weekday=n.length>3?j1.indexOf(n)+1:B1.indexOf(n)+1;return a}var $6=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function v6(n){let[,i,o,c,p,x,m,a,f,l,$,v]=n,T=Tl(i,p,c,o,x,m,a),F;if(f)F=l6[f];else if(l)F=0;else F=Cm($,v);return[T,new Ri(F)]}function T6(n){return n.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var J6=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,w6=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,A6=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Nv(n){let[,i,o,c,p,x,m,a]=n;return[Tl(i,p,c,o,x,m,a),Ri.utcInstance]}function S6(n){let[,i,o,c,p,x,m,a]=n;return[Tl(i,a,o,c,p,x,m),Ri.utcInstance]}var F6=wp(d8,vl),M6=wp(e8,vl),R6=wp(n6,vl),W6=wp(I1),s1=Ap(x6,Fp,Yx,zx),K6=Ap(i6,Fp,Yx,zx),X6=Ap(o6,Fp,Yx,zx),G6=Ap(Fp,Yx,zx);function Y6(n){return Sp(n,[F6,s1],[M6,K6],[R6,X6],[W6,G6])}function z6(n){return Sp(T6(n),[$6,v6])}function H6(n){return Sp(n,[J6,Nv],[w6,Nv],[A6,S6])}function Q6(n){return Sp(n,[a6,f6])}var O6=Ap(Fp);function E6(n){return Sp(n,[m6,O6])}var U6=wp(c6,p6),V6=wp(k1),_6=Ap(Fp,Yx,zx);function u6(n){return Sp(n,[U6,s1],[V6,_6])}var Dv="Invalid Duration",Z1={weeks:{days:7,hours:168,minutes:10080,seconds:604800,milliseconds:604800000},days:{hours:24,minutes:1440,seconds:86400,milliseconds:86400000},hours:{minutes:60,seconds:3600,milliseconds:3600000},minutes:{seconds:60,milliseconds:60000},seconds:{milliseconds:1000}},b6={years:{quarters:4,months:12,weeks:52,days:365,hours:8760,minutes:525600,seconds:31536000,milliseconds:31536000000},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:131040,seconds:7862400,milliseconds:7862400000},months:{weeks:4,days:30,hours:720,minutes:43200,seconds:2592000,milliseconds:2592000000},...Z1},Pi=365.2425,mp=30.436875,j6={years:{quarters:4,months:12,weeks:Pi/7,days:Pi,hours:Pi*24,minutes:Pi*24*60,seconds:Pi*24*60*60,milliseconds:Pi*24*60*60*1000},quarters:{months:3,weeks:Pi/28,days:Pi/4,hours:Pi*24/4,minutes:Pi*24*60/4,seconds:Pi*24*60*60/4,milliseconds:Pi*24*60*60*1000/4},months:{weeks:mp/7,days:mp,hours:mp*24,minutes:mp*24*60,seconds:mp*24*60*60,milliseconds:mp*24*60*60*1000},...Z1},Oc=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],B6=Oc.slice(0).reverse();function ic(n,i,o=!1){let c={values:o?i.values:{...n.values,...i.values||{}},loc:n.loc.clone(i.loc),conversionAccuracy:i.conversionAccuracy||n.conversionAccuracy,matrix:i.matrix||n.matrix};return new Sn(c)}function q1(n,i){var o;let c=(o=i.milliseconds)!=null?o:0;for(let p of B6.slice(1))if(i[p])c+=i[p]*n[p].milliseconds;return c}function Cv(n,i){let o=q1(n,i)<0?-1:1;Oc.reduceRight((c,p)=>{if(!pn(i[p])){if(c){let x=i[c]*o,m=n[p][c],a=Math.floor(x/m);i[p]+=a*o,i[c]-=a*m*o}return p}else return c},null),Oc.reduce((c,p)=>{if(!pn(i[p])){if(c){let x=i[c]%1;i[c]-=x,i[p]+=x*n[c][p]}return p}else return c},null)}function y6(n){let i={};for(let[o,c]of Object.entries(n))if(c!==0)i[o]=c;return i}class Sn{constructor(n){let i=n.conversionAccuracy==="longterm"||!1,o=i?j6:b6;if(n.matrix)o=n.matrix;this.values=n.values,this.loc=n.loc||Gn.create(),this.conversionAccuracy=i?"longterm":"casual",this.invalid=n.invalid||null,this.matrix=o,this.isLuxonDuration=!0}static fromMillis(n,i){return Sn.fromObject({milliseconds:n},i)}static fromObject(n,i={}){if(n==null||typeof n!=="object")throw new li(`Duration.fromObject: argument expected to be an object, got ${n===null?"null":typeof n}`);return new Sn({values:Lm(n,Sn.normalizeUnit),loc:Gn.fromObject(i),conversionAccuracy:i.conversionAccuracy,matrix:i.matrix})}static fromDurationLike(n){if(pc(n))return Sn.fromMillis(n);else if(Sn.isDuration(n))return n;else if(typeof n==="object")return Sn.fromObject(n);else throw new li(`Unknown duration argument ${n} of type ${typeof n}`)}static fromISO(n,i){let[o]=Q6(n);if(o)return Sn.fromObject(o,i);else return Sn.invalid("unparsable",`the input "${n}" can't be parsed as ISO 8601`)}static fromISOTime(n,i){let[o]=E6(n);if(o)return Sn.fromObject(o,i);else return Sn.invalid("unparsable",`the input "${n}" can't be parsed as ISO 8601`)}static invalid(n,i=null){if(!n)throw new li("need to specify a reason the Duration is invalid");let o=n instanceof ti?n:new ti(n,i);if(Nn.throwOnInvalid)throw new n1(o);else return new Sn({invalid:o})}static normalizeUnit(n){let i={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[n?n.toLowerCase():n];if(!i)throw new cl(n);return i}static isDuration(n){return n&&n.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(n,i={}){let o={...i,floor:i.round!==!1&&i.floor!==!1};return this.isValid?Mi.create(this.loc,o).formatDurationFromString(this,n):Dv}toHuman(n={}){if(!this.isValid)return Dv;let i=Oc.map((o)=>{let c=this.values[o];if(pn(c))return null;return this.loc.numberFormatter({style:"unit",unitDisplay:"long",...n,unit:o.slice(0,-1)}).format(c)}).filter((o)=>o);return this.loc.listFormatter({type:"conjunction",style:n.listStyle||"narrow",...n}).format(i)}toObject(){if(!this.isValid)return{};return{...this.values}}toISO(){if(!this.isValid)return null;let n="P";if(this.years!==0)n+=this.years+"Y";if(this.months!==0||this.quarters!==0)n+=this.months+this.quarters*3+"M";if(this.weeks!==0)n+=this.weeks+"W";if(this.days!==0)n+=this.days+"D";if(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)n+="T";if(this.hours!==0)n+=this.hours+"H";if(this.minutes!==0)n+=this.minutes+"M";if(this.seconds!==0||this.milliseconds!==0)n+=ll(this.seconds+this.milliseconds/1000,3)+"S";if(n==="P")n+="T0S";return n}toISOTime(n={}){if(!this.isValid)return null;let i=this.toMillis();if(i<0||i>=86400000)return null;return n={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...n,includeOffset:!1},cn.fromMillis(i,{zone:"UTC"}).toISOTime(n)}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid)return`Duration { values: ${JSON.stringify(this.values)} }`;else return`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){if(!this.isValid)return NaN;return q1(this.matrix,this.values)}valueOf(){return this.toMillis()}plus(n){if(!this.isValid)return this;let i=Sn.fromDurationLike(n),o={};for(let c of Oc)if(Jp(i.values,c)||Jp(this.values,c))o[c]=i.get(c)+this.get(c);return ic(this,{values:o},!0)}minus(n){if(!this.isValid)return this;let i=Sn.fromDurationLike(n);return this.plus(i.negate())}mapUnits(n){if(!this.isValid)return this;let i={};for(let o of Object.keys(this.values))i[o]=_1(n(this.values[o],o));return ic(this,{values:i},!0)}get(n){return this[Sn.normalizeUnit(n)]}set(n){if(!this.isValid)return this;let i={...this.values,...Lm(n,Sn.normalizeUnit)};return ic(this,{values:i})}reconfigure({locale:n,numberingSystem:i,conversionAccuracy:o,matrix:c}={}){let x={loc:this.loc.clone({locale:n,numberingSystem:i}),matrix:c,conversionAccuracy:o};return ic(this,x)}as(n){return this.isValid?this.shiftTo(n).get(n):NaN}normalize(){if(!this.isValid)return this;let n=this.toObject();return Cv(this.matrix,n),ic(this,{values:n},!0)}rescale(){if(!this.isValid)return this;let n=y6(this.normalize().shiftToAll().toObject());return ic(this,{values:n},!0)}shiftTo(...n){if(!this.isValid)return this;if(n.length===0)return this;n=n.map((x)=>Sn.normalizeUnit(x));let i={},o={},c=this.toObject(),p;for(let x of Oc)if(n.indexOf(x)>=0){p=x;let m=0;for(let f in o)m+=this.matrix[f][x]*o[f],o[f]=0;if(pc(c[x]))m+=c[x];let a=Math.trunc(m);i[x]=a,o[x]=(m*1000-a*1000)/1000}else if(pc(c[x]))o[x]=c[x];for(let x in o)if(o[x]!==0)i[p]+=x===p?o[x]:o[x]/this.matrix[p][x];return Cv(this.matrix,i),ic(this,{values:i},!0)}shiftToAll(){if(!this.isValid)return this;return this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds")}negate(){if(!this.isValid)return this;let n={};for(let i of Object.keys(this.values))n[i]=this.values[i]===0?0:-this.values[i];return ic(this,{values:n},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(n){if(!this.isValid||!n.isValid)return!1;if(!this.loc.equals(n.loc))return!1;function i(o,c){if(o===void 0||o===0)return c===void 0||c===0;return o===c}for(let o of Oc)if(!i(this.values[o],n.values[o]))return!1;return!0}}var ap="Invalid Interval";function L6(n,i){if(!n||!n.isValid)return Cn.invalid("missing or invalid start");else if(!i||!i.isValid)return Cn.invalid("missing or invalid end");else if(i<n)return Cn.invalid("end before start",`The end of an interval must be after its start, but you had start=${n.toISO()} and end=${i.toISO()}`);else return null}class Cn{constructor(n){this.s=n.start,this.e=n.end,this.invalid=n.invalid||null,this.isLuxonInterval=!0}static invalid(n,i=null){if(!n)throw new li("need to specify a reason the Interval is invalid");let o=n instanceof ti?n:new ti(n,i);if(Nn.throwOnInvalid)throw new ev(o);else return new Cn({invalid:o})}static fromDateTimes(n,i){let o=Fx(n),c=Fx(i),p=L6(o,c);if(p==null)return new Cn({start:o,end:c});else return p}static after(n,i){let o=Sn.fromDurationLike(i),c=Fx(n);return Cn.fromDateTimes(c,c.plus(o))}static before(n,i){let o=Sn.fromDurationLike(i),c=Fx(n);return Cn.fromDateTimes(c.minus(o),c)}static fromISO(n,i){let[o,c]=(n||"").split("/",2);if(o&&c){let p,x;try{p=cn.fromISO(o,i),x=p.isValid}catch(f){x=!1}let m,a;try{m=cn.fromISO(c,i),a=m.isValid}catch(f){a=!1}if(x&&a)return Cn.fromDateTimes(p,m);if(x){let f=Sn.fromISO(c,i);if(f.isValid)return Cn.after(p,f)}else if(a){let f=Sn.fromISO(o,i);if(f.isValid)return Cn.before(m,f)}}return Cn.invalid("unparsable",`the input "${n}" can't be parsed as ISO 8601`)}static isInterval(n){return n&&n.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(n="milliseconds"){return this.isValid?this.toDuration(...[n]).get(n):NaN}count(n="milliseconds",i){if(!this.isValid)return NaN;let o=this.start.startOf(n,i),c;if(i!=null&&i.useLocaleWeeks)c=this.end.reconfigure({locale:o.locale});else c=this.end;return c=c.startOf(n,i),Math.floor(c.diff(o,n).get(n))+(c.valueOf()!==this.end.valueOf())}hasSame(n){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,n):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(n){if(!this.isValid)return!1;return this.s>n}isBefore(n){if(!this.isValid)return!1;return this.e<=n}contains(n){if(!this.isValid)return!1;return this.s<=n&&this.e>n}set({start:n,end:i}={}){if(!this.isValid)return this;return Cn.fromDateTimes(n||this.s,i||this.e)}splitAt(...n){if(!this.isValid)return[];let i=n.map(Fx).filter((x)=>this.contains(x)).sort((x,m)=>x.toMillis()-m.toMillis()),o=[],{s:c}=this,p=0;while(c<this.e){let x=i[p]||this.e,m=+x>+this.e?this.e:x;o.push(Cn.fromDateTimes(c,m)),c=m,p+=1}return o}splitBy(n){let i=Sn.fromDurationLike(n);if(!this.isValid||!i.isValid||i.as("milliseconds")===0)return[];let{s:o}=this,c=1,p,x=[];while(o<this.e){let m=this.start.plus(i.mapUnits((a)=>a*c));p=+m>+this.e?this.e:m,x.push(Cn.fromDateTimes(o,p)),o=p,c+=1}return x}divideEqually(n){if(!this.isValid)return[];return this.splitBy(this.length()/n).slice(0,n)}overlaps(n){return this.e>n.s&&this.s<n.e}abutsStart(n){if(!this.isValid)return!1;return+this.e===+n.s}abutsEnd(n){if(!this.isValid)return!1;return+n.e===+this.s}engulfs(n){if(!this.isValid)return!1;return this.s<=n.s&&this.e>=n.e}equals(n){if(!this.isValid||!n.isValid)return!1;return this.s.equals(n.s)&&this.e.equals(n.e)}intersection(n){if(!this.isValid)return this;let i=this.s>n.s?this.s:n.s,o=this.e<n.e?this.e:n.e;if(i>=o)return null;else return Cn.fromDateTimes(i,o)}union(n){if(!this.isValid)return this;let i=this.s<n.s?this.s:n.s,o=this.e>n.e?this.e:n.e;return Cn.fromDateTimes(i,o)}static merge(n){let[i,o]=n.sort((c,p)=>c.s-p.s).reduce(([c,p],x)=>{if(!p)return[c,x];else if(p.overlaps(x)||p.abutsStart(x))return[c,p.union(x)];else return[c.concat([p]),x]},[[],null]);if(o)i.push(o);return i}static xor(n){let i=null,o=0,c=[],p=n.map((a)=>[{time:a.s,type:"s"},{time:a.e,type:"e"}]),x=Array.prototype.concat(...p),m=x.sort((a,f)=>a.time-f.time);for(let a of m)if(o+=a.type==="s"?1:-1,o===1)i=a.time;else{if(i&&+i!==+a.time)c.push(Cn.fromDateTimes(i,a.time));i=null}return Cn.merge(c)}difference(...n){return Cn.xor([this].concat(n)).map((i)=>this.intersection(i)).filter((i)=>i&&!i.isEmpty())}toString(){if(!this.isValid)return ap;return`[${this.s.toISO()} \u2013 ${this.e.toISO()})`}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid)return`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`;else return`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(n=jm,i={}){return this.isValid?Mi.create(this.s.loc.clone(i),n).formatInterval(this):ap}toISO(n){if(!this.isValid)return ap;return`${this.s.toISO(n)}/${this.e.toISO(n)}`}toISODate(){if(!this.isValid)return ap;return`${this.s.toISODate()}/${this.e.toISODate()}`}toISOTime(n){if(!this.isValid)return ap;return`${this.s.toISOTime(n)}/${this.e.toISOTime(n)}`}toFormat(n,{separator:i=" \u2013 "}={}){if(!this.isValid)return ap;return`${this.s.toFormat(n)}${i}${this.e.toFormat(n)}`}toDuration(n,i){if(!this.isValid)return Sn.invalid(this.invalidReason);return this.e.diff(this.s,n,i)}mapEndpoints(n){return Cn.fromDateTimes(n(this.s),n(this.e))}}class $p{static hasDST(n=Nn.defaultZone){let i=cn.now().setZone(n).set({month:12});return!n.isUniversal&&i.offset!==i.set({month:6}).offset}static isValidIANAZone(n){return Yo.isValidZone(n)}static normalizeZone(n){return cc(n,Nn.defaultZone)}static getStartOfWeek({locale:n=null,locObj:i=null}={}){return(i||Gn.create(n)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:n=null,locObj:i=null}={}){return(i||Gn.create(n)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:n=null,locObj:i=null}={}){return(i||Gn.create(n)).getWeekendDays().slice()}static months(n="long",{locale:i=null,numberingSystem:o=null,locObj:c=null,outputCalendar:p="gregory"}={}){return(c||Gn.create(i,o,p)).months(n)}static monthsFormat(n="long",{locale:i=null,numberingSystem:o=null,locObj:c=null,outputCalendar:p="gregory"}={}){return(c||Gn.create(i,o,p)).months(n,!0)}static weekdays(n="long",{locale:i=null,numberingSystem:o=null,locObj:c=null}={}){return(c||Gn.create(i,o,null)).weekdays(n)}static weekdaysFormat(n="long",{locale:i=null,numberingSystem:o=null,locObj:c=null}={}){return(c||Gn.create(i,o,null)).weekdays(n,!0)}static meridiems({locale:n=null}={}){return Gn.create(n).meridiems()}static eras(n="short",{locale:i=null}={}){return Gn.create(i,null,"gregory").eras(n)}static features(){return{relative:E1(),localeWeek:U1()}}}function hv(n,i){let o=(p)=>p.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),c=o(i)-o(n);return Math.floor(Sn.fromMillis(c).as("days"))}function N6(n,i,o){let c=[["years",(f,l)=>l.year-f.year],["quarters",(f,l)=>l.quarter-f.quarter+(l.year-f.year)*4],["months",(f,l)=>l.month-f.month+(l.year-f.year)*12],["weeks",(f,l)=>{let $=hv(f,l);return($-$%7)/7}],["days",hv]],p={},x=n,m,a;for(let[f,l]of c)if(o.indexOf(f)>=0)if(m=f,p[f]=l(n,i),a=x.plus(p),a>i){if(p[f]--,n=x.plus(p),n>i)a=n,p[f]--,n=x.plus(p)}else n=a;return[n,p,a,m]}function D6(n,i,o,c){let[p,x,m,a]=N6(n,i,o),f=i-p,l=o.filter((v)=>["hours","minutes","seconds","milliseconds"].indexOf(v)>=0);if(l.length===0){if(m<i)m=p.plus({[a]:1});if(m!==p)x[a]=(x[a]||0)+f/(m-p)}let $=Sn.fromObject(x,c);if(l.length>0)return Sn.fromMillis(f,c).shiftTo(...l).plus($);else return $}var C6="missing Intl.DateTimeFormat.formatToParts support";function Wn(n,i=(o)=>o){return{regex:n,deser:([o])=>i(U8(o))}}var h6=String.fromCharCode(160),P1=`[ ${h6}]`,t1=new RegExp(P1,"g");function I6(n){return n.replace(/\./g,"\\.?").replace(t1,P1)}function Iv(n){return n.replace(/\./g,"").replace(t1," ").toLowerCase()}function $o(n,i){if(n===null)return null;else return{regex:RegExp(n.map(I6).join("|")),deser:([o])=>n.findIndex((c)=>Iv(o)===Iv(c))+i}}function kv(n,i){return{regex:n,deser:([,o,c])=>Cm(o,c),groups:i}}function Om(n){return{regex:n,deser:([i])=>i}}function k6(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function s6(n,i){let o=lo(i),c=lo(i,"{2}"),p=lo(i,"{3}"),x=lo(i,"{4}"),m=lo(i,"{6}"),a=lo(i,"{1,2}"),f=lo(i,"{1,3}"),l=lo(i,"{1,6}"),$=lo(i,"{1,9}"),v=lo(i,"{2,4}"),T=lo(i,"{4,6}"),F=(M)=>({regex:RegExp(k6(M.val)),deser:([G])=>G,literal:!0}),S=((M)=>{if(n.literal)return F(M);switch(M.val){case"G":return $o(i.eras("short"),0);case"GG":return $o(i.eras("long"),0);case"y":return Wn(l);case"yy":return Wn(v,ol);case"yyyy":return Wn(x);case"yyyyy":return Wn(T);case"yyyyyy":return Wn(m);case"M":return Wn(a);case"MM":return Wn(c);case"MMM":return $o(i.months("short",!0),1);case"MMMM":return $o(i.months("long",!0),1);case"L":return Wn(a);case"LL":return Wn(c);case"LLL":return $o(i.months("short",!1),1);case"LLLL":return $o(i.months("long",!1),1);case"d":return Wn(a);case"dd":return Wn(c);case"o":return Wn(f);case"ooo":return Wn(p);case"HH":return Wn(c);case"H":return Wn(a);case"hh":return Wn(c);case"h":return Wn(a);case"mm":return Wn(c);case"m":return Wn(a);case"q":return Wn(a);case"qq":return Wn(c);case"s":return Wn(a);case"ss":return Wn(c);case"S":return Wn(f);case"SSS":return Wn(p);case"u":return Om($);case"uu":return Om(a);case"uuu":return Wn(o);case"a":return $o(i.meridiems(),0);case"kkkk":return Wn(x);case"kk":return Wn(v,ol);case"W":return Wn(a);case"WW":return Wn(c);case"E":case"c":return Wn(o);case"EEE":return $o(i.weekdays("short",!1),1);case"EEEE":return $o(i.weekdays("long",!1),1);case"ccc":return $o(i.weekdays("short",!0),1);case"cccc":return $o(i.weekdays("long",!0),1);case"Z":case"ZZ":return kv(new RegExp(`([+-]${a.source})(?::(${c.source}))?`),2);case"ZZZ":return kv(new RegExp(`([+-]${a.source})(${c.source})?`),2);case"z":return Om(/[a-z_+-/]{1,256}?/i);case" ":return Om(/[^\S\n\r]/);default:return F(M)}})(n)||{invalidReason:C6};return S.token=n,S}var Z6={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function q6(n,i,o){let{type:c,value:p}=n;if(c==="literal"){let f=/^\s+$/.test(p);return{literal:!f,val:f?" ":p}}let x=i[c],m=c;if(c==="hour")if(i.hour12!=null)m=i.hour12?"hour12":"hour24";else if(i.hourCycle!=null)if(i.hourCycle==="h11"||i.hourCycle==="h12")m="hour12";else m="hour24";else m=o.hour12?"hour12":"hour24";let a=Z6[m];if(typeof a==="object")a=a[x];if(a)return{literal:!1,val:a};return}function P6(n){return[`^${n.map((o)=>o.regex).reduce((o,c)=>`${o}(${c.source})`,"")}$`,n]}function t6(n,i,o){let c=n.match(i);if(c){let p={},x=1;for(let m in o)if(Jp(o,m)){let a=o[m],f=a.groups?a.groups+1:1;if(!a.literal&&a.token)p[a.token.val[0]]=a.deser(c.slice(x,x+f));x+=f}return[c,p]}else return[c,{}]}function r6(n){let i=(x)=>{switch(x){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}},o=null,c;if(!pn(n.z))o=Yo.create(n.z);if(!pn(n.Z)){if(!o)o=new Ri(n.Z);c=n.Z}if(!pn(n.q))n.M=(n.q-1)*3+1;if(!pn(n.h)){if(n.h<12&&n.a===1)n.h+=12;else if(n.h===12&&n.a===0)n.h=0}if(n.G===0&&n.y)n.y=-n.y;if(!pn(n.u))n.S=fl(n.u);return[Object.keys(n).reduce((x,m)=>{let a=i(m);if(a)x[a]=n[m];return x},{}),o,c]}var Zf=null;function g6(){if(!Zf)Zf=cn.fromMillis(1555555555555);return Zf}function d6(n,i){if(n.literal)return n;let o=Mi.macroTokenToFormatOpts(n.val),c=d1(o,i);if(c==null||c.includes(void 0))return n;return c}function r1(n,i){return Array.prototype.concat(...n.map((o)=>d6(o,i)))}class Jl{constructor(n,i){if(this.locale=n,this.format=i,this.tokens=r1(Mi.parseFormat(i),n),this.units=this.tokens.map((o)=>s6(o,n)),this.disqualifyingUnit=this.units.find((o)=>o.invalidReason),!this.disqualifyingUnit){let[o,c]=P6(this.units);this.regex=RegExp(o,"i"),this.handlers=c}}explainFromTokens(n){if(!this.isValid)return{input:n,tokens:this.tokens,invalidReason:this.invalidReason};else{let[i,o]=t6(n,this.regex,this.handlers),[c,p,x]=o?r6(o):[null,null,void 0];if(Jp(o,"a")&&Jp(o,"H"))throw new Qc("Can't include meridiem when specifying 24-hour format");return{input:n,tokens:this.tokens,regex:this.regex,rawMatches:i,matches:o,result:c,zone:p,specificOffset:x}}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function g1(n,i,o){return new Jl(n,o).explainFromTokens(i)}function e6(n,i,o){let{result:c,zone:p,specificOffset:x,invalidReason:m}=g1(n,i,o);return[c,p,x,m]}function d1(n,i){if(!n)return null;let c=Mi.create(i,n).dtFormatter(g6()),p=c.formatToParts(),x=c.resolvedOptions();return p.map((m)=>q6(m,n,x))}var qf="Invalid DateTime",sv=8640000000000000;function Rx(n){return new ti("unsupported zone",`the zone "${n.name}" is not supported`)}function Pf(n){if(n.weekData===null)n.weekData=Bm(n.c);return n.weekData}function tf(n){if(n.localWeekData===null)n.localWeekData=Bm(n.c,n.loc.getMinDaysInFirstWeek(),n.loc.getStartOfWeek());return n.localWeekData}function Hc(n,i){let o={ts:n.ts,zone:n.zone,c:n.c,o:n.o,loc:n.loc,invalid:n.invalid};return new cn({...o,...i,old:o})}function e1(n,i,o){let c=n-i*60*1000,p=o.offset(c);if(i===p)return[c,i];c-=(p-i)*60*1000;let x=o.offset(c);if(p===x)return[c,p];return[n-Math.min(p,x)*60*1000,Math.max(p,x)]}function Em(n,i){n+=i*60*1000;let o=new Date(n);return{year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate(),hour:o.getUTCHours(),minute:o.getUTCMinutes(),second:o.getUTCSeconds(),millisecond:o.getUTCMilliseconds()}}function _m(n,i,o){return e1(Dm(n),i,o)}function Zv(n,i){let o=n.o,c=n.c.year+Math.trunc(i.years),p=n.c.month+Math.trunc(i.months)+Math.trunc(i.quarters)*3,x={...n.c,year:c,month:p,day:Math.min(n.c.day,ym(c,p))+Math.trunc(i.days)+Math.trunc(i.weeks)*7},m=Sn.fromObject({years:i.years-Math.trunc(i.years),quarters:i.quarters-Math.trunc(i.quarters),months:i.months-Math.trunc(i.months),weeks:i.weeks-Math.trunc(i.weeks),days:i.days-Math.trunc(i.days),hours:i.hours,minutes:i.minutes,seconds:i.seconds,milliseconds:i.milliseconds}).as("milliseconds"),a=Dm(x),[f,l]=e1(a,o,n.zone);if(m!==0)f+=m,l=n.zone.offset(f);return{ts:f,o:l}}function fp(n,i,o,c,p,x){let{setZone:m,zone:a}=o;if(n&&Object.keys(n).length!==0||i){let f=i||a,l=cn.fromObject(n,{...o,zone:f,specificOffset:x});return m?l:l.setZone(a)}else return cn.invalid(new ti("unparsable",`the input "${p}" can't be parsed as ${c}`))}function Um(n,i,o=!0){return n.isValid?Mi.create(Gn.create("en-US"),{allowZ:o,forceSimple:!0}).formatDateTimeFromString(n,i):null}function rf(n,i){let o=n.c.year>9999||n.c.year<0,c="";if(o&&n.c.year>=0)c+="+";if(c+=gn(n.c.year,o?6:4),i)c+="-",c+=gn(n.c.month),c+="-",c+=gn(n.c.day);else c+=gn(n.c.month),c+=gn(n.c.day);return c}function qv(n,i,o,c,p,x){let m=gn(n.c.hour);if(i){if(m+=":",m+=gn(n.c.minute),n.c.millisecond!==0||n.c.second!==0||!o)m+=":"}else m+=gn(n.c.minute);if(n.c.millisecond!==0||n.c.second!==0||!o){if(m+=gn(n.c.second),n.c.millisecond!==0||!c)m+=".",m+=gn(n.c.millisecond,3)}if(p)if(n.isOffsetFixed&&n.offset===0&&!x)m+="Z";else if(n.o<0)m+="-",m+=gn(Math.trunc(-n.o/60)),m+=":",m+=gn(Math.trunc(-n.o%60));else m+="+",m+=gn(Math.trunc(n.o/60)),m+=":",m+=gn(Math.trunc(n.o%60));if(x)m+="["+n.zone.ianaName+"]";return m}var nT={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},nW={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},iW={ordinal:1,hour:0,minute:0,second:0,millisecond:0},iT=["year","month","day","hour","minute","second","millisecond"],oW=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],cW=["year","ordinal","hour","minute","second","millisecond"];function pW(n){let i={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[n.toLowerCase()];if(!i)throw new cl(n);return i}function Pv(n){switch(n.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return pW(n)}}function xW(n){if(!bm[n]){if(um===void 0)um=Nn.now();bm[n]=n.offset(um)}return bm[n]}function tv(n,i){let o=cc(i.zone,Nn.defaultZone);if(!o.isValid)return cn.invalid(Rx(o));let c=Gn.fromObject(i),p,x;if(!pn(n.year)){for(let f of iT)if(pn(n[f]))n[f]=nT[f];let m=Q1(n)||O1(n);if(m)return cn.invalid(m);let a=xW(o);[p,x]=_m(n,a,o)}else p=Nn.now();return new cn({ts:p,zone:o,loc:c,o:x})}function rv(n,i,o){let c=pn(o.round)?!0:o.round,p=(m,a)=>{return m=ll(m,c||o.calendary?0:2,!0),i.loc.clone(o).relFormatter(o).format(m,a)},x=(m)=>{if(o.calendary)if(!i.hasSame(n,m))return i.startOf(m).diff(n.startOf(m),m).get(m);else return 0;else return i.diff(n,m).get(m)};if(o.unit)return p(x(o.unit),o.unit);for(let m of o.units){let a=x(m);if(Math.abs(a)>=1)return p(a,m)}return p(n>i?-0:0,o.units[o.units.length-1])}function gv(n){let i={},o;if(n.length>0&&typeof n[n.length-1]==="object")i=n[n.length-1],o=Array.from(n).slice(0,n.length-1);else o=Array.from(n);return[i,o]}var um,bm={};class cn{constructor(n){let i=n.zone||Nn.defaultZone,o=n.invalid||(Number.isNaN(n.ts)?new ti("invalid input"):null)||(!i.isValid?Rx(i):null);this.ts=pn(n.ts)?Nn.now():n.ts;let c=null,p=null;if(!o)if(n.old&&n.old.ts===this.ts&&n.old.zone.equals(i))[c,p]=[n.old.c,n.old.o];else{let m=pc(n.o)&&!n.old?n.o:i.offset(this.ts);c=Em(this.ts,m),o=Number.isNaN(c.year)?new ti("invalid input"):null,c=o?null:c,p=o?null:m}this._zone=i,this.loc=n.loc||Gn.create(),this.invalid=o,this.weekData=null,this.localWeekData=null,this.c=c,this.o=p,this.isLuxonDateTime=!0}static now(){return new cn({})}static local(){let[n,i]=gv(arguments),[o,c,p,x,m,a,f]=i;return tv({year:o,month:c,day:p,hour:x,minute:m,second:a,millisecond:f},n)}static utc(){let[n,i]=gv(arguments),[o,c,p,x,m,a,f]=i;return n.zone=Ri.utcInstance,tv({year:o,month:c,day:p,hour:x,minute:m,second:a,millisecond:f},n)}static fromJSDate(n,i={}){let o=j8(n)?n.valueOf():NaN;if(Number.isNaN(o))return cn.invalid("invalid input");let c=cc(i.zone,Nn.defaultZone);if(!c.isValid)return cn.invalid(Rx(c));return new cn({ts:o,zone:c,loc:Gn.fromObject(i)})}static fromMillis(n,i={}){if(!pc(n))throw new li(`fromMillis requires a numerical input, but received a ${typeof n} with value ${n}`);else if(n<-sv||n>sv)return cn.invalid("Timestamp out of range");else return new cn({ts:n,zone:cc(i.zone,Nn.defaultZone),loc:Gn.fromObject(i)})}static fromSeconds(n,i={}){if(!pc(n))throw new li("fromSeconds requires a numerical input");else return new cn({ts:n*1000,zone:cc(i.zone,Nn.defaultZone),loc:Gn.fromObject(i)})}static fromObject(n,i={}){n=n||{};let o=cc(i.zone,Nn.defaultZone);if(!o.isValid)return cn.invalid(Rx(o));let c=Gn.fromObject(i),p=Lm(n,Pv),{minDaysInFirstWeek:x,startOfWeek:m}=jv(p,c),a=Nn.now(),f=!pn(i.specificOffset)?i.specificOffset:o.offset(a),l=!pn(p.ordinal),$=!pn(p.year),v=!pn(p.month)||!pn(p.day),T=$||v,F=p.weekYear||p.weekNumber;if((T||l)&&F)throw new Qc("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(v&&l)throw new Qc("Can't mix ordinal dates with month/day");let R=F||p.weekday&&!T,S,M,G=Em(a,f);if(R)S=oW,M=nW,G=Bm(G,x,m);else if(l)S=cW,M=iW,G=sf(G);else S=iT,M=nT;let H=!1;for(let V of S){let X=p[V];if(!pn(X))H=!0;else if(H)p[V]=M[V];else p[V]=G[V]}let y=R?_8(p,x,m):l?u8(p):Q1(p),k=y||O1(p);if(k)return cn.invalid(k);let Y=R?uv(p,x,m):l?bv(p):p,[K,Q]=_m(Y,f,o),u=new cn({ts:K,zone:o,o:Q,loc:c});if(p.weekday&&T&&n.weekday!==u.weekday)return cn.invalid("mismatched weekday",`you can't specify both a weekday of ${p.weekday} and a date of ${u.toISO()}`);if(!u.isValid)return cn.invalid(u.invalid);return u}static fromISO(n,i={}){let[o,c]=Y6(n);return fp(o,c,i,"ISO 8601",n)}static fromRFC2822(n,i={}){let[o,c]=z6(n);return fp(o,c,i,"RFC 2822",n)}static fromHTTP(n,i={}){let[o,c]=H6(n);return fp(o,c,i,"HTTP",i)}static fromFormat(n,i,o={}){if(pn(n)||pn(i))throw new li("fromFormat requires an input string and a format");let{locale:c=null,numberingSystem:p=null}=o,x=Gn.fromOpts({locale:c,numberingSystem:p,defaultToEN:!0}),[m,a,f,l]=e6(x,n,i);if(l)return cn.invalid(l);else return fp(m,a,o,`format ${i}`,n,f)}static fromString(n,i,o={}){return cn.fromFormat(n,i,o)}static fromSQL(n,i={}){let[o,c]=u6(n);return fp(o,c,i,"SQL",n)}static invalid(n,i=null){if(!n)throw new li("need to specify a reason the DateTime is invalid");let o=n instanceof ti?n:new ti(n,i);if(Nn.throwOnInvalid)throw new dv(o);else return new cn({invalid:o})}static isDateTime(n){return n&&n.isLuxonDateTime||!1}static parseFormatForOpts(n,i={}){let o=d1(n,Gn.fromObject(i));return!o?null:o.map((c)=>c?c.val:null).join("")}static expandFormat(n,i={}){return r1(Mi.parseFormat(n),Gn.fromObject(i)).map((c)=>c.val).join("")}static resetCache(){um=void 0,bm={}}get(n){return this[n]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Pf(this).weekYear:NaN}get weekNumber(){return this.isValid?Pf(this).weekNumber:NaN}get weekday(){return this.isValid?Pf(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?tf(this).weekday:NaN}get localWeekNumber(){return this.isValid?tf(this).weekNumber:NaN}get localWeekYear(){return this.isValid?tf(this).weekYear:NaN}get ordinal(){return this.isValid?sf(this.c).ordinal:NaN}get monthShort(){return this.isValid?$p.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?$p.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?$p.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?$p.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){if(this.isValid)return this.zone.offsetName(this.ts,{format:"short",locale:this.locale});else return null}get offsetNameLong(){if(this.isValid)return this.zone.offsetName(this.ts,{format:"long",locale:this.locale});else return null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){if(this.isOffsetFixed)return!1;else return this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let n=86400000,i=60000,o=Dm(this.c),c=this.zone.offset(o-n),p=this.zone.offset(o+n),x=this.zone.offset(o-c*i),m=this.zone.offset(o-p*i);if(x===m)return[this];let a=o-x*i,f=o-m*i,l=Em(a,x),$=Em(f,m);if(l.hour===$.hour&&l.minute===$.minute&&l.second===$.second&&l.millisecond===$.millisecond)return[Hc(this,{ts:a}),Hc(this,{ts:f})];return[this]}get isInLeapYear(){return Gx(this.year)}get daysInMonth(){return ym(this.year,this.month)}get daysInYear(){return this.isValid?vp(this.year):NaN}get weeksInWeekYear(){return this.isValid?Kx(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Kx(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(n={}){let{locale:i,numberingSystem:o,calendar:c}=Mi.create(this.loc.clone(n),n).resolvedOptions(this);return{locale:i,numberingSystem:o,outputCalendar:c}}toUTC(n=0,i={}){return this.setZone(Ri.instance(n),i)}toLocal(){return this.setZone(Nn.defaultZone)}setZone(n,{keepLocalTime:i=!1,keepCalendarTime:o=!1}={}){if(n=cc(n,Nn.defaultZone),n.equals(this.zone))return this;else if(!n.isValid)return cn.invalid(Rx(n));else{let c=this.ts;if(i||o){let p=n.offset(this.ts),x=this.toObject();[c]=_m(x,p,n)}return Hc(this,{ts:c,zone:n})}}reconfigure({locale:n,numberingSystem:i,outputCalendar:o}={}){let c=this.loc.clone({locale:n,numberingSystem:i,outputCalendar:o});return Hc(this,{loc:c})}setLocale(n){return this.reconfigure({locale:n})}set(n){if(!this.isValid)return this;let i=Lm(n,Pv),{minDaysInFirstWeek:o,startOfWeek:c}=jv(i,this.loc),p=!pn(i.weekYear)||!pn(i.weekNumber)||!pn(i.weekday),x=!pn(i.ordinal),m=!pn(i.year),a=!pn(i.month)||!pn(i.day),f=m||a,l=i.weekYear||i.weekNumber;if((f||x)&&l)throw new Qc("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(a&&x)throw new Qc("Can't mix ordinal dates with month/day");let $;if(p)$=uv({...Bm(this.c,o,c),...i},o,c);else if(!pn(i.ordinal))$=bv({...sf(this.c),...i});else if($={...this.toObject(),...i},pn(i.day))$.day=Math.min(ym($.year,$.month),$.day);let[v,T]=_m($,this.o,this.zone);return Hc(this,{ts:v,o:T})}plus(n){if(!this.isValid)return this;let i=Sn.fromDurationLike(n);return Hc(this,Zv(this,i))}minus(n){if(!this.isValid)return this;let i=Sn.fromDurationLike(n).negate();return Hc(this,Zv(this,i))}startOf(n,{useLocaleWeeks:i=!1}={}){if(!this.isValid)return this;let o={},c=Sn.normalizeUnit(n);switch(c){case"years":o.month=1;case"quarters":case"months":o.day=1;case"weeks":case"days":o.hour=0;case"hours":o.minute=0;case"minutes":o.second=0;case"seconds":o.millisecond=0;break}if(c==="weeks")if(i){let p=this.loc.getStartOfWeek(),{weekday:x}=this;if(x<p)o.weekNumber=this.weekNumber-1;o.weekday=p}else o.weekday=1;if(c==="quarters"){let p=Math.ceil(this.month/3);o.month=(p-1)*3+1}return this.set(o)}endOf(n,i){return this.isValid?this.plus({[n]:1}).startOf(n,i).minus(1):this}toFormat(n,i={}){return this.isValid?Mi.create(this.loc.redefaultToEN(i)).formatDateTimeFromString(this,n):qf}toLocaleString(n=jm,i={}){return this.isValid?Mi.create(this.loc.clone(i),n).formatDateTime(this):qf}toLocaleParts(n={}){return this.isValid?Mi.create(this.loc.clone(n),n).formatDateTimeParts(this):[]}toISO({format:n="extended",suppressSeconds:i=!1,suppressMilliseconds:o=!1,includeOffset:c=!0,extendedZone:p=!1}={}){if(!this.isValid)return null;let x=n==="extended",m=rf(this,x);return m+="T",m+=qv(this,x,i,o,c,p),m}toISODate({format:n="extended"}={}){if(!this.isValid)return null;return rf(this,n==="extended")}toISOWeekDate(){return Um(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:n=!1,suppressSeconds:i=!1,includeOffset:o=!0,includePrefix:c=!1,extendedZone:p=!1,format:x="extended"}={}){if(!this.isValid)return null;return(c?"T":"")+qv(this,x==="extended",i,n,o,p)}toRFC2822(){return Um(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Um(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){if(!this.isValid)return null;return rf(this,!0)}toSQLTime({includeOffset:n=!0,includeZone:i=!1,includeOffsetSpace:o=!0}={}){let c="HH:mm:ss.SSS";if(i||n){if(o)c+=" ";if(i)c+="z";else if(n)c+="ZZ"}return Um(this,c,!0)}toSQL(n={}){if(!this.isValid)return null;return`${this.toSQLDate()} ${this.toSQLTime(n)}`}toString(){return this.isValid?this.toISO():qf}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid)return`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`;else return`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1000:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1000):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(n={}){if(!this.isValid)return{};let i={...this.c};if(n.includeConfig)i.outputCalendar=this.outputCalendar,i.numberingSystem=this.loc.numberingSystem,i.locale=this.loc.locale;return i}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(n,i="milliseconds",o={}){if(!this.isValid||!n.isValid)return Sn.invalid("created by diffing an invalid DateTime");let c={locale:this.locale,numberingSystem:this.numberingSystem,...o},p=B8(i).map(Sn.normalizeUnit),x=n.valueOf()>this.valueOf(),m=x?this:n,a=x?n:this,f=D6(m,a,p,c);return x?f.negate():f}diffNow(n="milliseconds",i={}){return this.diff(cn.now(),n,i)}until(n){return this.isValid?Cn.fromDateTimes(this,n):this}hasSame(n,i,o){if(!this.isValid)return!1;let c=n.valueOf(),p=this.setZone(n.zone,{keepLocalTime:!0});return p.startOf(i,o)<=c&&c<=p.endOf(i,o)}equals(n){return this.isValid&&n.isValid&&this.valueOf()===n.valueOf()&&this.zone.equals(n.zone)&&this.loc.equals(n.loc)}toRelative(n={}){if(!this.isValid)return null;let i=n.base||cn.fromObject({},{zone:this.zone}),o=n.padding?this<i?-n.padding:n.padding:0,c=["years","months","days","hours","minutes","seconds"],p=n.unit;if(Array.isArray(n.unit))c=n.unit,p=void 0;return rv(i,this.plus(o),{...n,numeric:"always",units:c,unit:p})}toRelativeCalendar(n={}){if(!this.isValid)return null;return rv(n.base||cn.fromObject({},{zone:this.zone}),this,{...n,numeric:"auto",units:["years","months","days"],calendary:!0})}static min(...n){if(!n.every(cn.isDateTime))throw new li("min requires all arguments be DateTimes");return Bv(n,(i)=>i.valueOf(),Math.min)}static max(...n){if(!n.every(cn.isDateTime))throw new li("max requires all arguments be DateTimes");return Bv(n,(i)=>i.valueOf(),Math.max)}static fromFormatExplain(n,i,o={}){let{locale:c=null,numberingSystem:p=null}=o,x=Gn.fromOpts({locale:c,numberingSystem:p,defaultToEN:!0});return g1(x,n,i)}static fromStringExplain(n,i,o={}){return cn.fromFormatExplain(n,i,o)}static buildFormatParser(n,i={}){let{locale:o=null,numberingSystem:c=null}=i,p=Gn.fromOpts({locale:o,numberingSystem:c,defaultToEN:!0});return new Jl(p,n)}static fromFormatParser(n,i,o={}){if(pn(n)||pn(i))throw new li("fromFormatParser requires an input string and a format parser");let{locale:c=null,numberingSystem:p=null}=o,x=Gn.fromOpts({locale:c,numberingSystem:p,defaultToEN:!0});if(!x.equals(i.locale))throw new li(`fromFormatParser called with a locale of ${x}, but the format parser was created for ${i.locale}`);let{result:m,zone:a,specificOffset:f,invalidReason:l}=i.explainFromTokens(n);if(l)return cn.invalid(l);else return fp(m,a,o,`format ${i.format}`,n,f)}static get DATE_SHORT(){return jm}static get DATE_MED(){return i1}static get DATE_MED_WITH_WEEKDAY(){return T8}static get DATE_FULL(){return o1}static get DATE_HUGE(){return c1}static get TIME_SIMPLE(){return p1}static get TIME_WITH_SECONDS(){return x1}static get TIME_WITH_SHORT_OFFSET(){return m1}static get TIME_WITH_LONG_OFFSET(){return a1}static get TIME_24_SIMPLE(){return f1}static get TIME_24_WITH_SECONDS(){return l1}static get TIME_24_WITH_SHORT_OFFSET(){return $1}static get TIME_24_WITH_LONG_OFFSET(){return v1}static get DATETIME_SHORT(){return T1}static get DATETIME_SHORT_WITH_SECONDS(){return J1}static get DATETIME_MED(){return w1}static get DATETIME_MED_WITH_SECONDS(){return A1}static get DATETIME_MED_WITH_WEEKDAY(){return J8}static get DATETIME_FULL(){return S1}static get DATETIME_FULL_WITH_SECONDS(){return F1}static get DATETIME_HUGE(){return M1}static get DATETIME_HUGE_WITH_SECONDS(){return R1}}function Fx(n){if(cn.isDateTime(n))return n;else if(n&&n.valueOf&&pc(n.valueOf()))return cn.fromJSDate(n);else if(n&&typeof n==="object")return cn.fromObject(n);else throw new li(`Unknown datetime argument: ${n}, of type ${typeof n}`)}var mW="3.5.0";oT.DateTime=cn;oT.Duration=Sn;oT.FixedOffsetZone=Ri;oT.IANAZone=Yo;oT.Info=$p;oT.Interval=Cn;oT.InvalidZone=pl;oT.Settings=Nn;oT.SystemZone=Xx;oT.VERSION=mW;oT.Zone=Ec});var fT=h((pT)=>{Object.defineProperty(pT,"__esModule",{value:!0});pT.RE_RANGE=pT.RE_WILDCARDS=pT.PRESETS=pT.TIME_UNITS_LEN=pT.TIME_UNITS=pT.TIME_UNITS_MAP=pT.ALIASES=pT.PARSE_DEFAULTS=pT.MONTH_CONSTRAINTS=pT.CONSTRAINTS=void 0;pT.CONSTRAINTS=Object.freeze({second:[0,59],minute:[0,59],hour:[0,23],dayOfMonth:[1,31],month:[1,12],dayOfWeek:[0,7]});pT.MONTH_CONSTRAINTS=Object.freeze({1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31});pT.PARSE_DEFAULTS=Object.freeze({second:"0",minute:"*",hour:"*",dayOfMonth:"*",month:"*",dayOfWeek:"*"});pT.ALIASES=Object.freeze({jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12,sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6});pT.TIME_UNITS_MAP=Object.freeze({SECOND:"second",MINUTE:"minute",HOUR:"hour",DAY_OF_MONTH:"dayOfMonth",MONTH:"month",DAY_OF_WEEK:"dayOfWeek"});pT.TIME_UNITS=Object.freeze(Object.values(pT.TIME_UNITS_MAP));pT.TIME_UNITS_LEN=pT.TIME_UNITS.length;pT.PRESETS=Object.freeze({"@yearly":"0 0 0 1 1 *","@monthly":"0 0 0 1 * *","@weekly":"0 0 0 * * 0","@daily":"0 0 0 * * *","@hourly":"0 0 * * * *","@minutely":"0 * * * * *","@secondly":"* * * * * *","@weekdays":"0 0 0 * * 1-5","@weekends":"0 0 0 * * 0,6"});pT.RE_WILDCARDS=/\*/g;pT.RE_RANGE=/^(\d+)(?:-(\d+))?(?:\/(\d+))?$/g});var Al=h(($T)=>{Object.defineProperty($T,"__esModule",{value:!0});$T.ExclusiveParametersError=$T.CronError=void 0;class wl extends Error{}$T.CronError=wl;class lT extends wl{constructor(n,i){super(`You can't specify both ${n} and ${i}`)}}$T.ExclusiveParametersError=lT});var wT=h((TT)=>{Object.defineProperty(TT,"__esModule",{value:!0});TT.getRecordKeys=void 0;var HW=(n)=>{return Object.keys(n)};TT.getRecordKeys=HW});var Im=h((FT)=>{Object.defineProperty(FT,"__esModule",{value:!0});FT.CronTime=void 0;var zo=cT(),xi=fT(),Wi=Al(),AT=wT();class ST{constructor(n,i,o){if(this.realDate=!1,this.second={},this.minute={},this.hour={},this.dayOfMonth={},this.month={},this.dayOfWeek={},i!=null&&o!=null)throw new Wi.ExclusiveParametersError("timeZone","utcOffset");if(i){if(!zo.DateTime.fromObject({},{zone:i}).isValid)throw new Wi.CronError("Invalid timezone.");this.timeZone=i}if(o!=null)this.utcOffset=o;if(n instanceof Date||n instanceof zo.DateTime)this.source=n instanceof Date?zo.DateTime.fromJSDate(n):n,this.realDate=!0;else this.source=n,this._parse(this.source),this._verifyParse()}_getWeekDay(n){return n.weekday===7?0:n.weekday}_verifyParse(){let n=AT.getRecordKeys(this.month),i=AT.getRecordKeys(this.dayOfMonth),o=!1,c=null;for(let p of n){let x=xi.MONTH_CONSTRAINTS[p];for(let m of i)if(m<=x)o=!0;if(!o)c=p,console.warn(`Month '${p}' is limited to '${x}' days.`)}if(!o&&c!==null){let p=xi.MONTH_CONSTRAINTS[c];for(let x of i)if(x>p){delete this.dayOfMonth[x];let m=x%p;this.dayOfMonth[m]=!0}}}sendAt(n){let i=this.realDate&&this.source instanceof zo.DateTime?this.source:zo.DateTime.local();if(this.timeZone)i=i.setZone(this.timeZone);if(this.utcOffset!==void 0){let o=this.utcOffset<0?"-":"+",c=Math.trunc(this.utcOffset/60),p=String(Math.abs(c)).padStart(2,"0"),x=Math.abs(this.utcOffset-c*60),m=String(x).padStart(2,"0"),a=`UTC${o}${p}:${m}`;if(i=i.setZone(a),!i.isValid)throw new Wi.CronError("ERROR: You specified an invalid UTC offset.")}if(this.realDate){if(zo.DateTime.local()>i)throw new Wi.CronError("WARNING: Date in past. Will never be fired.");return i}if(n===void 0||isNaN(n)||n<0)return this.getNextDateFrom(i);else{let o=[];for(;n>0;n--)i=this.getNextDateFrom(i),o.push(i);return o}}getTimeout(){return Math.max(-1,this.sendAt().toMillis()-zo.DateTime.local().toMillis())}toString(){return this.toJSON().join(" ")}toJSON(){return xi.TIME_UNITS.map((n)=>{return this._wcOrAll(n)})}getNextDateFrom(n,i){var o;if(n instanceof Date)n=zo.DateTime.fromJSDate(n);let c=n,p=n.toMillis();if(i)c=c.setZone(i);if(!this.realDate){if(c.millisecond>0)c=c.set({millisecond:0,second:c.second+1})}if(!c.isValid)throw new Wi.CronError("ERROR: You specified an invalid date.");let x=zo.DateTime.now().plus({years:8});while(!0){let m=c.toMillis()-n.toMillis();if(c>x)throw new Wi.CronError(`Something went wrong. No execution date was found in the next 8 years.
4
4
  \t\t\t\t\t\t\tPlease provide the following string if you would like to help debug:
5
- \t\t\t\t\t\t\tTime Zone: ${(o=i===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:'""'} - Cron String: ${this.source.toString()} - UTC offset: ${c.offset} - current Date: ${zo.DateTime.local().toString()}`);if(!(c.month in this.month)&&Object.keys(this.month).length!==12){if(c=c.plus({months:1}),c=c.set({day:1,hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,c)){let[a,f]=this._findPreviousDSTJump(c);if(c=f,a)break}continue}if(!(c.day in this.dayOfMonth)&&Object.keys(this.dayOfMonth).length!==31&&!((this._getWeekDay(c)in this.dayOfWeek)&&Object.keys(this.dayOfWeek).length!==7)){if(c=c.plus({days:1}),c=c.set({hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,c)){let[a,f]=this._findPreviousDSTJump(c);if(c=f,a)break}continue}if(!(this._getWeekDay(c)in this.dayOfWeek)&&Object.keys(this.dayOfWeek).length!==7&&!((c.day in this.dayOfMonth)&&Object.keys(this.dayOfMonth).length!==31)){if(c=c.plus({days:1}),c=c.set({hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,c)){let[a,f]=this._findPreviousDSTJump(c);if(c=f,a)break}continue}if(!(c.hour in this.hour)&&Object.keys(this.hour).length!==24){let a=c.hour===23&&m>86400000?0:c.hour+1,f=c.minute;if(c=c.set({hour:a}),c=c.set({minute:0,second:0}),this._forwardDSTJump(a,f,c)){let[l,$]=this._findPreviousDSTJump(c);if(c=$,l)break}continue}if(!(c.minute in this.minute)&&Object.keys(this.minute).length!==60){let a=c.minute===59&&m>3600000?0:c.minute+1,f=c.hour+(a===60?1:0);if(c=c.set({minute:a}),c=c.set({second:0}),this._forwardDSTJump(f,a,c)){let[l,$]=this._findPreviousDSTJump(c);if(c=$,l)break}continue}if(!(c.second in this.second)&&Object.keys(this.second).length!==60){let a=c.second===59&&m>60000?0:c.second+1,f=c.minute+(a===60?1:0),l=c.hour+(f===60?1:0);if(c=c.set({second:a}),this._forwardDSTJump(l,f,c)){let[$,v]=this._findPreviousDSTJump(c);if(c=v,$)break}continue}if(c.toMillis()===p){let a=c.second+1,f=c.minute+(a===60?1:0),l=c.hour+(f===60?1:0);if(c=c.set({second:a}),this._forwardDSTJump(l,f,c)){let[$,v]=this._findPreviousDSTJump(c);if(c=v,$)break}continue}break}return c}_findPreviousDSTJump(n){var i;let o,c,p,x,m=n,a=1440,f=0;do{if(++f>a)throw new Wi.CronError(`ERROR: This DST checking related function assumes the input DateTime (${(i=n.toISO())!==null&&i!==void 0?i:n.toMillis()}) is within 24 hours of a DST jump.`);if(o=m.minute-1,c=m.hour,o<0)o+=60,c=(c+24-1)%24;m=m.minus({minute:1}),p=m.minute,x=m.hour}while(o===p&&c===x);let l=m.plus({minute:1}).set({second:0,millisecond:0}),$=l.minus({second:1});if(n.month+1 in this.month&&n.day in this.dayOfMonth&&this._getWeekDay(n)in this.dayOfWeek)return[this._checkTimeInSkippedRange($,l),l];return[!1,l]}_checkTimeInSkippedRange(n,i){let o=(n.minute+1)%60,c=(n.hour+(o===0?1:0))%24,p=i.hour-c+1,x=o===0&&i.minute===0;if(p===2&&x)return c in this.hour;else if(p===1)return c in this.hour&&this._checkTimeInSkippedRangeSingleHour(o,i.minute);else return this._checkTimeInSkippedRangeMultiHour(c,o,i.hour,i.minute)}_checkTimeInSkippedRangeSingleHour(n,i){for(let o=n;o<i;++o)if(o in this.minute)return!0;return i in this.minute&&0 in this.second}_checkTimeInSkippedRangeMultiHour(n,i,o,c){if(n>=o)throw new Wi.CronError(`ERROR: This DST checking related function assumes the forward jump starting hour (${n}) is less than the end hour (${o})`);let p=Array.from({length:60-i},(f,l)=>i+l),x=Array.from({length:c},(f,l)=>l),m=Array.from({length:60},(f,l)=>l),a=(f)=>{if(f===n)return p;else if(f===o)return x;else return m};for(let f=n;f<=o;++f){if(!(f in this.hour))continue;let l=a(f);for(let $ of l)if($ in this.minute)return!0}return o in this.hour&&c in this.minute&&0 in this.second}_forwardDSTJump(n,i,o){let{hour:c,minute:p}=o,x=n%24<c,m=i%60<p;return x||m}_wcOrAll(n){if(this._hasAll(n))return"*";let i=[];for(let o in this[n])i.push(o);return i.join(",")}_hasAll(n){let i=xi.CONSTRAINTS[n],o=i[0],c=n===xi.TIME_UNITS_MAP.DAY_OF_WEEK?i[1]-1:i[1];for(let p=o,x=c;p<x;p++)if(!(p in this[n]))return!1;return!0}_parse(n){var i;if(n=n.toLowerCase(),Object.keys(xi.PRESETS).includes(n))n=xi.PRESETS[n];n=n.replace(/[a-z]{1,3}/gi,(p)=>{if(Object.keys(xi.ALIASES).includes(p))return xi.ALIASES[p].toString();throw new Wi.CronError(`Unknown alias: ${p}`)});let o=n.trim().split(/\s+/);if(o.length<xi.TIME_UNITS_LEN-1)throw new Wi.CronError("Too few fields");if(o.length>xi.TIME_UNITS_LEN)throw new Wi.CronError("Too many fields");let c=o.length;for(let p of xi.TIME_UNITS){let x=xi.TIME_UNITS.indexOf(p),m=(i=o[x-(xi.TIME_UNITS_LEN-c)])!==null&&i!==void 0?i:xi.PARSE_DEFAULTS[p];this._parseField(m,p)}}_parseField(n,i){let o=this[i],c,p=xi.CONSTRAINTS[i],x=p[0],m=p[1];n.split(",").forEach((l)=>{let $=l.indexOf("*");if($!==-1&&$!==0)throw new Wi.CronError(`Field (${l}) has an invalid wildcard expression`)}),n=n.replace(xi.RE_WILDCARDS,`${x}-${m}`);let f=n.split(",");for(let l of f){let $=[...l.matchAll(xi.RE_RANGE)][0];if(($===null||$===void 0?void 0:$[1])!==void 0){let[,v,T,F]=$,R=parseInt(v,10),S=T!==void 0?parseInt(T,10):void 0,M=F!==void 0,G=parseInt(F!==null&&F!==void 0?F:"1",10);if(G===0)throw new Wi.CronError(`Field (${i}) has a step of zero`);if(S!==void 0&&R>S)throw new Wi.CronError(`Field (${i}) has an invalid range`);if(R<x||S!==void 0&&S>m||S===void 0&&R>m)throw new Wi.CronError(`Field value (${n}) is out of range`);if(R=Math.min(Math.max(x,~~Math.abs(R)),m),S!==void 0)S=Math.min(m,~~Math.abs(S));else S=M?m:R;c=R;do o[c]=!0,c+=G;while(c<=S);if(i==="dayOfWeek"){if(!o[0]&&!!o[7])o[0]=o[7];delete o[7]}}else throw new Wi.CronError(`Field (${i}) cannot be parsed`)}}}FT.CronTime=ST});var WT=h((Mp)=>{var km=Mp&&Mp.__awaiter||function(n,i,o,c){function p(x){return x instanceof o?x:new o(function(m){m(x)})}return new(o||(o=Promise))(function(x,m){function a($){try{l(c.next($))}catch(v){m(v)}}function f($){try{l(c.throw($))}catch(v){m(v)}}function l($){$.done?x($.value):p($.value).then(a,f)}l((c=c.apply(n,i||[])).next())})};Object.defineProperty(Mp,"__esModule",{value:!0});Mp.CronJob=void 0;var RT=import.meta.require("child_process"),Sl=Al(),sm=Im();class Hx{get isCallbackRunning(){return this._isCallbackRunning}constructor(n,i,o,c,p,x,m,a,f,l){if(this.running=!1,this.unrefTimeout=!1,this.lastExecution=null,this.runOnce=!1,this.waitForCompletion=!1,this._isCallbackRunning=!1,this._callbacks=[],this.context=x!==null&&x!==void 0?x:this,this.waitForCompletion=Boolean(l),p!=null&&a!=null)throw new Sl.ExclusiveParametersError("timeZone","utcOffset");if(p!=null)this.cronTime=new sm.CronTime(n,p,null);else if(a!=null)this.cronTime=new sm.CronTime(n,null,a);else this.cronTime=new sm.CronTime(n,p,a);if(f!=null)this.unrefTimeout=f;if(o!=null)this.onComplete=this._fnWrap(o);if(this.cronTime.realDate)this.runOnce=!0;if(this.addCallback(this._fnWrap(i)),m)this.lastExecution=new Date,this.fireOnTick();if(c)this.start()}static from(n){if(n.timeZone!=null&&n.utcOffset!=null)throw new Sl.ExclusiveParametersError("timeZone","utcOffset");if(n.timeZone!=null)return new Hx(n.cronTime,n.onTick,n.onComplete,n.start,n.timeZone,n.context,n.runOnInit,n.utcOffset,n.unrefTimeout,n.waitForCompletion);else if(n.utcOffset!=null)return new Hx(n.cronTime,n.onTick,n.onComplete,n.start,null,n.context,n.runOnInit,n.utcOffset,n.unrefTimeout,n.waitForCompletion);else return new Hx(n.cronTime,n.onTick,n.onComplete,n.start,n.timeZone,n.context,n.runOnInit,n.utcOffset,n.unrefTimeout,n.waitForCompletion)}_fnWrap(n){var i,o;switch(typeof n){case"function":return n;case"string":{let[c,...p]=n.split(" ");return RT.spawn.bind(void 0,c!==null&&c!==void 0?c:n,p,{})}case"object":return RT.spawn.bind(void 0,n.command,(i=n.args)!==null&&i!==void 0?i:[],(o=n.options)!==null&&o!==void 0?o:{})}}addCallback(n){if(typeof n==="function")this._callbacks.push(n)}setTime(n){if(!(n instanceof sm.CronTime))throw new Sl.CronError("time must be an instance of CronTime.");let i=this.running;if(this.stop(),this.cronTime=n,n.realDate)this.runOnce=!0;if(i)this.start()}nextDate(){return this.cronTime.sendAt()}fireOnTick(){return km(this,void 0,void 0,function*(){if(this.waitForCompletion&&this._isCallbackRunning)return;this._isCallbackRunning=!0;try{for(let n of this._callbacks){let i=n.call(this.context,this.onComplete);if(this.waitForCompletion)yield i}}catch(n){console.error("[Cron] error in callback",n)}finally{this._isCallbackRunning=!1}})}nextDates(n){return this.cronTime.sendAt(n!==null&&n!==void 0?n:0)}start(){if(this.running)return;let n=2147483647,i=this.cronTime.getTimeout(),o=0,c,p=(m)=>{if(c=Date.now(),this._timeout=setTimeout(x,m),this.unrefTimeout&&typeof this._timeout.unref==="function")this._timeout.unref()},x=()=>{let m=c+i-Date.now();if(m>0){let a=this.cronTime.getTimeout();if(a>m)a=m;o+=a}if(o){if(o>n)o-=n,i=n;else i=o,o=0;p(i)}else{if(this.lastExecution=new Date,this.running=!1,!this.runOnce)this.start();this.fireOnTick()}};if(i>=0){if(this.running=!0,i>n)o=i-n,i=n;p(i)}else this.stop()}lastDate(){return this.lastExecution}_executeOnComplete(){return km(this,void 0,void 0,function*(){if(typeof this.onComplete!=="function")return;try{yield this.onComplete.call(this.context)}catch(n){console.error("[Cron] error in onComplete callback:",n)}})}_waitForJobCompletion(){return km(this,void 0,void 0,function*(){while(this._isCallbackRunning)yield new Promise((n)=>setTimeout(n,100))})}stop(){if(this._timeout)clearTimeout(this._timeout);if(this.running=!1,!this.waitForCompletion){this._executeOnComplete();return}Promise.resolve().then(()=>km(this,void 0,void 0,function*(){yield this._waitForJobCompletion(),yield this._executeOnComplete()}))}}Mp.CronJob=Hx});var Fl=h((Zm)=>{Object.defineProperty(Zm,"__esModule",{value:!0});Zm.timeout=Zm.sendAt=Zm.CronTime=Zm.CronJob=void 0;var KT=Im(),QW=WT();Object.defineProperty(Zm,"CronJob",{enumerable:!0,get:function(){return QW.CronJob}});var OW=Im();Object.defineProperty(Zm,"CronTime",{enumerable:!0,get:function(){return OW.CronTime}});var EW=(n)=>new KT.CronTime(n).sendAt();Zm.sendAt=EW;var UW=(n)=>new KT.CronTime(n).getTimeout();Zm.timeout=UW});var TA=h((cL,Bl)=>{Bl.exports=vA;Bl.exports.preferredCharsets=vA;var DW=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function CW(n){var i=n.split(",");for(var o=0,c=0;o<i.length;o++){var p=hW(i[o].trim(),o);if(p)i[c++]=p}return i.length=c,i}function hW(n,i){var o=DW.exec(n);if(!o)return null;var c=o[1],p=1;if(o[2]){var x=o[2].split(";");for(var m=0;m<x.length;m++){var a=x[m].trim().split("=");if(a[0]==="q"){p=parseFloat(a[1]);break}}}return{charset:c,q:p,i}}function IW(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=kW(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function kW(n,i,o){var c=0;if(i.charset.toLowerCase()===n.toLowerCase())c|=1;else if(i.charset!=="*")return null;return{i:o,o:i.i,q:i.q,s:c}}function vA(n,i){var o=CW(n===void 0?"*":n||"");if(!i)return o.filter($A).sort(lA).map(sW);var c=i.map(function p(x,m){return IW(x,o,m)});return c.filter($A).sort(lA).map(function p(x){return i[c.indexOf(x)]})}function lA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function sW(n){return n.charset}function $A(n){return n.q>0}});var FA=h((pL,yl)=>{yl.exports=SA;yl.exports.preferredEncodings=SA;var ZW=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function qW(n){var i=n.split(","),o=!1,c=1;for(var p=0,x=0;p<i.length;p++){var m=PW(i[p].trim(),p);if(m)i[x++]=m,o=o||AA("identity",m),c=Math.min(c,m.q||1)}if(!o)i[x++]={encoding:"identity",q:c,i:p};return i.length=x,i}function PW(n,i){var o=ZW.exec(n);if(!o)return null;var c=o[1],p=1;if(o[2]){var x=o[2].split(";");for(var m=0;m<x.length;m++){var a=x[m].trim().split("=");if(a[0]==="q"){p=parseFloat(a[1]);break}}}return{encoding:c,q:p,i}}function tW(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=AA(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function AA(n,i,o){var c=0;if(i.encoding.toLowerCase()===n.toLowerCase())c|=1;else if(i.encoding!=="*")return null;return{i:o,o:i.i,q:i.q,s:c}}function SA(n,i){var o=qW(n||"");if(!i)return o.filter(wA).sort(JA).map(rW);var c=i.map(function p(x,m){return tW(x,o,m)});return c.filter(wA).sort(JA).map(function p(x){return i[c.indexOf(x)]})}function JA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function rW(n){return n.encoding}function wA(n){return n.q>0}});var XA=h((xL,Ll)=>{Ll.exports=KA;Ll.exports.preferredLanguages=KA;var gW=/^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;function dW(n){var i=n.split(",");for(var o=0,c=0;o<i.length;o++){var p=WA(i[o].trim(),o);if(p)i[c++]=p}return i.length=c,i}function WA(n,i){var o=gW.exec(n);if(!o)return null;var c=o[1],p=o[2],x=c;if(p)x+="-"+p;var m=1;if(o[3]){var a=o[3].split(";");for(var f=0;f<a.length;f++){var l=a[f].split("=");if(l[0]==="q")m=parseFloat(l[1])}}return{prefix:c,suffix:p,q:m,i,full:x}}function eW(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=n3(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function n3(n,i,o){var c=WA(n);if(!c)return null;var p=0;if(i.full.toLowerCase()===c.full.toLowerCase())p|=4;else if(i.prefix.toLowerCase()===c.full.toLowerCase())p|=2;else if(i.full.toLowerCase()===c.prefix.toLowerCase())p|=1;else if(i.full!=="*")return null;return{i:o,o:i.i,q:i.q,s:p}}function KA(n,i){var o=dW(n===void 0?"*":n||"");if(!i)return o.filter(RA).sort(MA).map(i3);var c=i.map(function p(x,m){return eW(x,o,m)});return c.filter(RA).sort(MA).map(function p(x){return i[c.indexOf(x)]})}function MA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function i3(n){return n.full}function RA(n){return n.q>0}});var OA=h((mL,Nl)=>{Nl.exports=HA;Nl.exports.preferredMediaTypes=HA;var o3=/^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;function c3(n){var i=f3(n);for(var o=0,c=0;o<i.length;o++){var p=zA(i[o].trim(),o);if(p)i[c++]=p}return i.length=c,i}function zA(n,i){var o=o3.exec(n);if(!o)return null;var c=Object.create(null),p=1,x=o[2],m=o[1];if(o[3]){var a=l3(o[3]).map(a3);for(var f=0;f<a.length;f++){var l=a[f],$=l[0].toLowerCase(),v=l[1],T=v&&v[0]==='"'&&v[v.length-1]==='"'?v.substr(1,v.length-2):v;if($==="q"){p=parseFloat(T);break}c[$]=T}}return{type:m,subtype:x,params:c,q:p,i}}function p3(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=x3(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function x3(n,i,o){var c=zA(n),p=0;if(!c)return null;if(i.type.toLowerCase()==c.type.toLowerCase())p|=4;else if(i.type!="*")return null;if(i.subtype.toLowerCase()==c.subtype.toLowerCase())p|=2;else if(i.subtype!="*")return null;var x=Object.keys(i.params);if(x.length>0)if(x.every(function(m){return i.params[m]=="*"||(i.params[m]||"").toLowerCase()==(c.params[m]||"").toLowerCase()}))p|=1;else return null;return{i:o,o:i.i,q:i.q,s:p}}function HA(n,i){var o=c3(n===void 0?"*/*":n||"");if(!i)return o.filter(YA).sort(GA).map(m3);var c=i.map(function p(x,m){return p3(x,o,m)});return c.filter(YA).sort(GA).map(function p(x){return i[c.indexOf(x)]})}function GA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function m3(n){return n.type+"/"+n.subtype}function YA(n){return n.q>0}function QA(n){var i=0,o=0;while((o=n.indexOf('"',o))!==-1)i++,o++;return i}function a3(n){var i=n.indexOf("="),o,c;if(i===-1)o=n;else o=n.substr(0,i),c=n.substr(i+1);return[o,c]}function f3(n){var i=n.split(",");for(var o=1,c=0;o<i.length;o++)if(QA(i[c])%2==0)i[++c]=i[o];else i[c]+=","+i[o];return i.length=c+1,i}function l3(n){var i=n.split(";");for(var o=1,c=0;o<i.length;o++)if(QA(i[c])%2==0)i[++c]=i[o];else i[c]+=";"+i[o];i.length=c+1;for(var o=0;o<i.length;o++)i[o]=i[o].trim();return i}});var EA=h((aL,Dl)=>{/*!
5
+ \t\t\t\t\t\t\tTime Zone: ${(o=i===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:'""'} - Cron String: ${this.source.toString()} - UTC offset: ${c.offset} - current Date: ${zo.DateTime.local().toString()}`);if(!(c.month in this.month)&&Object.keys(this.month).length!==12){if(c=c.plus({months:1}),c=c.set({day:1,hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,c)){let[a,f]=this._findPreviousDSTJump(c);if(c=f,a)break}continue}if(!(c.day in this.dayOfMonth)&&Object.keys(this.dayOfMonth).length!==31&&!((this._getWeekDay(c)in this.dayOfWeek)&&Object.keys(this.dayOfWeek).length!==7)){if(c=c.plus({days:1}),c=c.set({hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,c)){let[a,f]=this._findPreviousDSTJump(c);if(c=f,a)break}continue}if(!(this._getWeekDay(c)in this.dayOfWeek)&&Object.keys(this.dayOfWeek).length!==7&&!((c.day in this.dayOfMonth)&&Object.keys(this.dayOfMonth).length!==31)){if(c=c.plus({days:1}),c=c.set({hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,c)){let[a,f]=this._findPreviousDSTJump(c);if(c=f,a)break}continue}if(!(c.hour in this.hour)&&Object.keys(this.hour).length!==24){let a=c.hour===23&&m>86400000?0:c.hour+1,f=c.minute;if(c=c.set({hour:a}),c=c.set({minute:0,second:0}),this._forwardDSTJump(a,f,c)){let[l,$]=this._findPreviousDSTJump(c);if(c=$,l)break}continue}if(!(c.minute in this.minute)&&Object.keys(this.minute).length!==60){let a=c.minute===59&&m>3600000?0:c.minute+1,f=c.hour+(a===60?1:0);if(c=c.set({minute:a}),c=c.set({second:0}),this._forwardDSTJump(f,a,c)){let[l,$]=this._findPreviousDSTJump(c);if(c=$,l)break}continue}if(!(c.second in this.second)&&Object.keys(this.second).length!==60){let a=c.second===59&&m>60000?0:c.second+1,f=c.minute+(a===60?1:0),l=c.hour+(f===60?1:0);if(c=c.set({second:a}),this._forwardDSTJump(l,f,c)){let[$,v]=this._findPreviousDSTJump(c);if(c=v,$)break}continue}if(c.toMillis()===p){let a=c.second+1,f=c.minute+(a===60?1:0),l=c.hour+(f===60?1:0);if(c=c.set({second:a}),this._forwardDSTJump(l,f,c)){let[$,v]=this._findPreviousDSTJump(c);if(c=v,$)break}continue}break}return c}_findPreviousDSTJump(n){var i;let o,c,p,x,m=n,a=1440,f=0;do{if(++f>a)throw new Wi.CronError(`ERROR: This DST checking related function assumes the input DateTime (${(i=n.toISO())!==null&&i!==void 0?i:n.toMillis()}) is within 24 hours of a DST jump.`);if(o=m.minute-1,c=m.hour,o<0)o+=60,c=(c+24-1)%24;m=m.minus({minute:1}),p=m.minute,x=m.hour}while(o===p&&c===x);let l=m.plus({minute:1}).set({second:0,millisecond:0}),$=l.minus({second:1});if(n.month in this.month&&n.day in this.dayOfMonth&&this._getWeekDay(n)in this.dayOfWeek)return[this._checkTimeInSkippedRange($,l),l];return[!1,l]}_checkTimeInSkippedRange(n,i){let o=(n.minute+1)%60,c=(n.hour+(o===0?1:0))%24,p=i.hour-c+1,x=o===0&&i.minute===0;if(p===2&&x)return c in this.hour;else if(p===1)return c in this.hour&&this._checkTimeInSkippedRangeSingleHour(o,i.minute);else return this._checkTimeInSkippedRangeMultiHour(c,o,i.hour,i.minute)}_checkTimeInSkippedRangeSingleHour(n,i){for(let o=n;o<i;++o)if(o in this.minute)return!0;return i in this.minute&&0 in this.second}_checkTimeInSkippedRangeMultiHour(n,i,o,c){if(n>=o)throw new Wi.CronError(`ERROR: This DST checking related function assumes the forward jump starting hour (${n}) is less than the end hour (${o})`);let p=Array.from({length:60-i},(f,l)=>i+l),x=Array.from({length:c},(f,l)=>l),m=Array.from({length:60},(f,l)=>l),a=(f)=>{if(f===n)return p;else if(f===o)return x;else return m};for(let f=n;f<=o;++f){if(!(f in this.hour))continue;let l=a(f);for(let $ of l)if($ in this.minute)return!0}return o in this.hour&&c in this.minute&&0 in this.second}_forwardDSTJump(n,i,o){let{hour:c,minute:p}=o,x=n%24<c,m=i%60<p;return x||m}_wcOrAll(n){if(this._hasAll(n))return"*";let i=[];for(let o in this[n])i.push(o);return i.join(",")}_hasAll(n){let i=xi.CONSTRAINTS[n],o=i[0],c=n===xi.TIME_UNITS_MAP.DAY_OF_WEEK?i[1]-1:i[1];for(let p=o,x=c;p<x;p++)if(!(p in this[n]))return!1;return!0}_parse(n){var i;if(n=n.toLowerCase(),Object.keys(xi.PRESETS).includes(n))n=xi.PRESETS[n];n=n.replace(/[a-z]{1,3}/gi,(p)=>{if(Object.keys(xi.ALIASES).includes(p))return xi.ALIASES[p].toString();throw new Wi.CronError(`Unknown alias: ${p}`)});let o=n.trim().split(/\s+/);if(o.length<xi.TIME_UNITS_LEN-1)throw new Wi.CronError("Too few fields");if(o.length>xi.TIME_UNITS_LEN)throw new Wi.CronError("Too many fields");let c=o.length;for(let p of xi.TIME_UNITS){let x=xi.TIME_UNITS.indexOf(p),m=(i=o[x-(xi.TIME_UNITS_LEN-c)])!==null&&i!==void 0?i:xi.PARSE_DEFAULTS[p];this._parseField(m,p)}}_parseField(n,i){let o=this[i],c,p=xi.CONSTRAINTS[i],x=p[0],m=p[1];n.split(",").forEach((l)=>{let $=l.indexOf("*");if($!==-1&&$!==0)throw new Wi.CronError(`Field (${l}) has an invalid wildcard expression`)}),n=n.replace(xi.RE_WILDCARDS,`${x}-${m}`);let f=n.split(",");for(let l of f){let $=[...l.matchAll(xi.RE_RANGE)][0];if(($===null||$===void 0?void 0:$[1])!==void 0){let[,v,T,F]=$,R=parseInt(v,10),S=T!==void 0?parseInt(T,10):void 0,M=F!==void 0,G=parseInt(F!==null&&F!==void 0?F:"1",10);if(G===0)throw new Wi.CronError(`Field (${i}) has a step of zero`);if(S!==void 0&&R>S)throw new Wi.CronError(`Field (${i}) has an invalid range`);if(R<x||S!==void 0&&S>m||S===void 0&&R>m)throw new Wi.CronError(`Field value (${n}) is out of range`);if(R=Math.min(Math.max(x,~~Math.abs(R)),m),S!==void 0)S=Math.min(m,~~Math.abs(S));else S=M?m:R;c=R;do o[c]=!0,c+=G;while(c<=S);if(i==="dayOfWeek"){if(!o[0]&&!!o[7])o[0]=o[7];delete o[7]}}else throw new Wi.CronError(`Field (${i}) cannot be parsed`)}}}FT.CronTime=ST});var WT=h((Mp)=>{var km=Mp&&Mp.__awaiter||function(n,i,o,c){function p(x){return x instanceof o?x:new o(function(m){m(x)})}return new(o||(o=Promise))(function(x,m){function a($){try{l(c.next($))}catch(v){m(v)}}function f($){try{l(c.throw($))}catch(v){m(v)}}function l($){$.done?x($.value):p($.value).then(a,f)}l((c=c.apply(n,i||[])).next())})};Object.defineProperty(Mp,"__esModule",{value:!0});Mp.CronJob=void 0;var RT=import.meta.require("child_process"),Sl=Al(),sm=Im();class Hx{get isCallbackRunning(){return this._isCallbackRunning}constructor(n,i,o,c,p,x,m,a,f,l){if(this.running=!1,this.unrefTimeout=!1,this.lastExecution=null,this.runOnce=!1,this.waitForCompletion=!1,this._isCallbackRunning=!1,this._callbacks=[],this.context=x!==null&&x!==void 0?x:this,this.waitForCompletion=Boolean(l),p!=null&&a!=null)throw new Sl.ExclusiveParametersError("timeZone","utcOffset");if(p!=null)this.cronTime=new sm.CronTime(n,p,null);else if(a!=null)this.cronTime=new sm.CronTime(n,null,a);else this.cronTime=new sm.CronTime(n,p,a);if(f!=null)this.unrefTimeout=f;if(o!=null)this.onComplete=this._fnWrap(o);if(this.cronTime.realDate)this.runOnce=!0;if(this.addCallback(this._fnWrap(i)),m)this.lastExecution=new Date,this.fireOnTick();if(c)this.start()}static from(n){if(n.timeZone!=null&&n.utcOffset!=null)throw new Sl.ExclusiveParametersError("timeZone","utcOffset");if(n.timeZone!=null)return new Hx(n.cronTime,n.onTick,n.onComplete,n.start,n.timeZone,n.context,n.runOnInit,n.utcOffset,n.unrefTimeout,n.waitForCompletion);else if(n.utcOffset!=null)return new Hx(n.cronTime,n.onTick,n.onComplete,n.start,null,n.context,n.runOnInit,n.utcOffset,n.unrefTimeout,n.waitForCompletion);else return new Hx(n.cronTime,n.onTick,n.onComplete,n.start,n.timeZone,n.context,n.runOnInit,n.utcOffset,n.unrefTimeout,n.waitForCompletion)}_fnWrap(n){var i,o;switch(typeof n){case"function":return n;case"string":{let[c,...p]=n.split(" ");return RT.spawn.bind(void 0,c!==null&&c!==void 0?c:n,p,{})}case"object":return RT.spawn.bind(void 0,n.command,(i=n.args)!==null&&i!==void 0?i:[],(o=n.options)!==null&&o!==void 0?o:{})}}addCallback(n){if(typeof n==="function")this._callbacks.push(n)}setTime(n){if(!(n instanceof sm.CronTime))throw new Sl.CronError("time must be an instance of CronTime.");let i=this.running;if(this.stop(),this.cronTime=n,n.realDate)this.runOnce=!0;if(i)this.start()}nextDate(){return this.cronTime.sendAt()}fireOnTick(){return km(this,void 0,void 0,function*(){if(this.waitForCompletion&&this._isCallbackRunning)return;this._isCallbackRunning=!0;try{for(let n of this._callbacks){let i=n.call(this.context,this.onComplete);if(this.waitForCompletion)yield i}}catch(n){console.error("[Cron] error in callback",n)}finally{this._isCallbackRunning=!1}})}nextDates(n){return this.cronTime.sendAt(n!==null&&n!==void 0?n:0)}start(){if(this.running)return;let n=2147483647,i=this.cronTime.getTimeout(),o=0,c,p=(m)=>{if(c=Date.now(),this._timeout=setTimeout(x,m),this.unrefTimeout&&typeof this._timeout.unref==="function")this._timeout.unref()},x=()=>{let m=c+i-Date.now();if(m>0){let a=this.cronTime.getTimeout();if(a>m)a=m;o+=a}if(o){if(o>n)o-=n,i=n;else i=o,o=0;p(i)}else{if(this.lastExecution=new Date,this.running=!1,!this.runOnce)this.start();this.fireOnTick()}};if(i>=0){if(this.running=!0,i>n)o=i-n,i=n;p(i)}else this.stop()}lastDate(){return this.lastExecution}_executeOnComplete(){return km(this,void 0,void 0,function*(){if(typeof this.onComplete!=="function")return;try{yield this.onComplete.call(this.context)}catch(n){console.error("[Cron] error in onComplete callback:",n)}})}_waitForJobCompletion(){return km(this,void 0,void 0,function*(){while(this._isCallbackRunning)yield new Promise((n)=>setTimeout(n,100))})}stop(){if(this._timeout)clearTimeout(this._timeout);if(this.running=!1,!this.waitForCompletion){this._executeOnComplete();return}Promise.resolve().then(()=>km(this,void 0,void 0,function*(){yield this._waitForJobCompletion(),yield this._executeOnComplete()}))}}Mp.CronJob=Hx});var Fl=h((Zm)=>{Object.defineProperty(Zm,"__esModule",{value:!0});Zm.timeout=Zm.sendAt=Zm.CronTime=Zm.CronJob=void 0;var KT=Im(),QW=WT();Object.defineProperty(Zm,"CronJob",{enumerable:!0,get:function(){return QW.CronJob}});var OW=Im();Object.defineProperty(Zm,"CronTime",{enumerable:!0,get:function(){return OW.CronTime}});var EW=(n)=>new KT.CronTime(n).sendAt();Zm.sendAt=EW;var UW=(n)=>new KT.CronTime(n).getTimeout();Zm.timeout=UW});var TA=h((cL,Bl)=>{Bl.exports=vA;Bl.exports.preferredCharsets=vA;var DW=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function CW(n){var i=n.split(",");for(var o=0,c=0;o<i.length;o++){var p=hW(i[o].trim(),o);if(p)i[c++]=p}return i.length=c,i}function hW(n,i){var o=DW.exec(n);if(!o)return null;var c=o[1],p=1;if(o[2]){var x=o[2].split(";");for(var m=0;m<x.length;m++){var a=x[m].trim().split("=");if(a[0]==="q"){p=parseFloat(a[1]);break}}}return{charset:c,q:p,i}}function IW(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=kW(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function kW(n,i,o){var c=0;if(i.charset.toLowerCase()===n.toLowerCase())c|=1;else if(i.charset!=="*")return null;return{i:o,o:i.i,q:i.q,s:c}}function vA(n,i){var o=CW(n===void 0?"*":n||"");if(!i)return o.filter($A).sort(lA).map(sW);var c=i.map(function p(x,m){return IW(x,o,m)});return c.filter($A).sort(lA).map(function p(x){return i[c.indexOf(x)]})}function lA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function sW(n){return n.charset}function $A(n){return n.q>0}});var FA=h((pL,yl)=>{yl.exports=SA;yl.exports.preferredEncodings=SA;var ZW=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function qW(n){var i=n.split(","),o=!1,c=1;for(var p=0,x=0;p<i.length;p++){var m=PW(i[p].trim(),p);if(m)i[x++]=m,o=o||AA("identity",m),c=Math.min(c,m.q||1)}if(!o)i[x++]={encoding:"identity",q:c,i:p};return i.length=x,i}function PW(n,i){var o=ZW.exec(n);if(!o)return null;var c=o[1],p=1;if(o[2]){var x=o[2].split(";");for(var m=0;m<x.length;m++){var a=x[m].trim().split("=");if(a[0]==="q"){p=parseFloat(a[1]);break}}}return{encoding:c,q:p,i}}function tW(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=AA(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function AA(n,i,o){var c=0;if(i.encoding.toLowerCase()===n.toLowerCase())c|=1;else if(i.encoding!=="*")return null;return{i:o,o:i.i,q:i.q,s:c}}function SA(n,i){var o=qW(n||"");if(!i)return o.filter(wA).sort(JA).map(rW);var c=i.map(function p(x,m){return tW(x,o,m)});return c.filter(wA).sort(JA).map(function p(x){return i[c.indexOf(x)]})}function JA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function rW(n){return n.encoding}function wA(n){return n.q>0}});var XA=h((xL,Ll)=>{Ll.exports=KA;Ll.exports.preferredLanguages=KA;var gW=/^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;function dW(n){var i=n.split(",");for(var o=0,c=0;o<i.length;o++){var p=WA(i[o].trim(),o);if(p)i[c++]=p}return i.length=c,i}function WA(n,i){var o=gW.exec(n);if(!o)return null;var c=o[1],p=o[2],x=c;if(p)x+="-"+p;var m=1;if(o[3]){var a=o[3].split(";");for(var f=0;f<a.length;f++){var l=a[f].split("=");if(l[0]==="q")m=parseFloat(l[1])}}return{prefix:c,suffix:p,q:m,i,full:x}}function eW(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=n3(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function n3(n,i,o){var c=WA(n);if(!c)return null;var p=0;if(i.full.toLowerCase()===c.full.toLowerCase())p|=4;else if(i.prefix.toLowerCase()===c.full.toLowerCase())p|=2;else if(i.full.toLowerCase()===c.prefix.toLowerCase())p|=1;else if(i.full!=="*")return null;return{i:o,o:i.i,q:i.q,s:p}}function KA(n,i){var o=dW(n===void 0?"*":n||"");if(!i)return o.filter(RA).sort(MA).map(i3);var c=i.map(function p(x,m){return eW(x,o,m)});return c.filter(RA).sort(MA).map(function p(x){return i[c.indexOf(x)]})}function MA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function i3(n){return n.full}function RA(n){return n.q>0}});var OA=h((mL,Nl)=>{Nl.exports=HA;Nl.exports.preferredMediaTypes=HA;var o3=/^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;function c3(n){var i=f3(n);for(var o=0,c=0;o<i.length;o++){var p=zA(i[o].trim(),o);if(p)i[c++]=p}return i.length=c,i}function zA(n,i){var o=o3.exec(n);if(!o)return null;var c=Object.create(null),p=1,x=o[2],m=o[1];if(o[3]){var a=l3(o[3]).map(a3);for(var f=0;f<a.length;f++){var l=a[f],$=l[0].toLowerCase(),v=l[1],T=v&&v[0]==='"'&&v[v.length-1]==='"'?v.substr(1,v.length-2):v;if($==="q"){p=parseFloat(T);break}c[$]=T}}return{type:m,subtype:x,params:c,q:p,i}}function p3(n,i,o){var c={o:-1,q:0,s:0};for(var p=0;p<i.length;p++){var x=x3(n,i[p],o);if(x&&(c.s-x.s||c.q-x.q||c.o-x.o)<0)c=x}return c}function x3(n,i,o){var c=zA(n),p=0;if(!c)return null;if(i.type.toLowerCase()==c.type.toLowerCase())p|=4;else if(i.type!="*")return null;if(i.subtype.toLowerCase()==c.subtype.toLowerCase())p|=2;else if(i.subtype!="*")return null;var x=Object.keys(i.params);if(x.length>0)if(x.every(function(m){return i.params[m]=="*"||(i.params[m]||"").toLowerCase()==(c.params[m]||"").toLowerCase()}))p|=1;else return null;return{i:o,o:i.i,q:i.q,s:p}}function HA(n,i){var o=c3(n===void 0?"*/*":n||"");if(!i)return o.filter(YA).sort(GA).map(m3);var c=i.map(function p(x,m){return p3(x,o,m)});return c.filter(YA).sort(GA).map(function p(x){return i[c.indexOf(x)]})}function GA(n,i){return i.q-n.q||i.s-n.s||n.o-i.o||n.i-i.i||0}function m3(n){return n.type+"/"+n.subtype}function YA(n){return n.q>0}function QA(n){var i=0,o=0;while((o=n.indexOf('"',o))!==-1)i++,o++;return i}function a3(n){var i=n.indexOf("="),o,c;if(i===-1)o=n;else o=n.substr(0,i),c=n.substr(i+1);return[o,c]}function f3(n){var i=n.split(",");for(var o=1,c=0;o<i.length;o++)if(QA(i[c])%2==0)i[++c]=i[o];else i[c]+=","+i[o];return i.length=c+1,i}function l3(n){var i=n.split(";");for(var o=1,c=0;o<i.length;o++)if(QA(i[c])%2==0)i[++c]=i[o];else i[c]+=";"+i[o];i.length=c+1;for(var o=0;o<i.length;o++)i[o]=i[o].trim();return i}});var EA=h((aL,Dl)=>{/*!
6
6
  * negotiator
7
7
  * Copyright(c) 2012 Federico Romero
8
8
  * Copyright(c) 2012-2014 Isaac Z. Schlueter
@@ -33,4 +33,4 @@ ${y.trace}`:"No previous disposal trace was found.");return}switch(T.type){case"
33
33
  hash text NOT NULL,
34
34
  created_at bigint
35
35
  )
36
- `;await n.execute(R`CREATE SCHEMA IF NOT EXISTS ${R.identifier(S)}`),await n.execute(f);let A=(await n.all(R`select id, hash, created_at from ${R.identifier(S)}.${R.identifier(t)} order by created_at desc limit 1`))[0];await n.transaction(async(M)=>{for await(let F of o)if(!A||Number(A.created_at)<F.folderMillis){for(let $ of F.sql)await M.execute(R.raw($));await M.execute(R`insert into ${R.identifier(S)}.${R.identifier(t)} ("hash", "created_at") values(${F.hash}, ${F.folderMillis})`)}})}escapeName(o){return`"${o}"`}escapeParam(o){return`$${o+1}`}escapeString(o){return`'${o.replace(/'/g,"''")}'`}buildWithCTE(o){if(!o?.length)return;let n=[R`with `];for(let[T,t]of o.entries())if(n.push(R`${R.identifier(t._.alias)} as (${t._.sql})`),T<o.length-1)n.push(R`, `);return n.push(R` `),R.join(n)}buildDeleteQuery({table:o,where:n,returning:T,withList:t}){let S=this.buildWithCTE(t),f=T?R` returning ${this.buildSelection(T,{isSingleTable:!0})}`:void 0,y=n?R` where ${n}`:void 0;return R`${S}delete from ${o}${y}${f}`}buildUpdateSet(o,n){let T=o[I.Symbol.Columns],t=Object.keys(T).filter((f)=>n[f]!==void 0||T[f]?.onUpdateFn!==void 0),S=t.length;return R.join(t.flatMap((f,y)=>{let A=T[f],M=n[f]??R.param(A.onUpdateFn(),A),F=R`${R.identifier(this.casing.getColumnCasing(A))} = ${M}`;if(y<S-1)return[F,R.raw(", ")];return[F]}))}buildUpdateQuery({table:o,set:n,where:T,returning:t,withList:S,from:f,joins:y}){let A=this.buildWithCTE(S),M=o[vo.Symbol.Name],F=o[vo.Symbol.Schema],$=o[vo.Symbol.OriginalName],W=M===$?void 0:M,O=R`${F?R`${R.identifier(F)}.`:void 0}${R.identifier($)}${W&&R` ${R.identifier(W)}`}`,G=this.buildUpdateSet(o,n),D=f&&R.join([R.raw(" from "),this.buildFromTable(f)]),z=this.buildJoins(y),Y=t?R` returning ${this.buildSelection(t,{isSingleTable:!f})}`:void 0,B=T?R` where ${T}`:void 0;return R`${A}update ${O} set ${G}${D}${z}${B}${Y}`}buildSelection(o,{isSingleTable:n=!1}={}){let T=o.length,t=o.flatMap(({field:S},f)=>{let y=[];if(X(S,j.Aliased)&&S.isSelectionField)y.push(R.identifier(S.fieldAlias));else if(X(S,j.Aliased)||X(S,j)){let A=X(S,j.Aliased)?S.sql:S;if(n)y.push(new j(A.queryChunks.map((M)=>{if(X(M,V))return R.identifier(this.casing.getColumnCasing(M));return M})));else y.push(A);if(X(S,j.Aliased))y.push(R` as ${R.identifier(S.fieldAlias)}`)}else if(X(S,Ro))if(n)y.push(R.identifier(this.casing.getColumnCasing(S)));else y.push(S);if(f<T-1)y.push(R`, `);return y});return R.join(t)}buildJoins(o){if(!o||o.length===0)return;let n=[];for(let[T,t]of o.entries()){if(T===0)n.push(R` `);let S=t.table,f=t.lateral?R` lateral`:void 0;if(X(S,vo)){let y=S[vo.Symbol.Name],A=S[vo.Symbol.Schema],M=S[vo.Symbol.OriginalName],F=y===M?void 0:t.alias;n.push(R`${R.raw(t.joinType)} join${f} ${A?R`${R.identifier(A)}.`:void 0}${R.identifier(M)}${F&&R` ${R.identifier(F)}`} on ${t.on}`)}else if(X(S,An)){let y=S[Yo].name,A=S[Yo].schema,M=S[Yo].originalName,F=y===M?void 0:t.alias;n.push(R`${R.raw(t.joinType)} join${f} ${A?R`${R.identifier(A)}.`:void 0}${R.identifier(M)}${F&&R` ${R.identifier(F)}`} on ${t.on}`)}else n.push(R`${R.raw(t.joinType)} join${f} ${S} on ${t.on}`);if(T<o.length-1)n.push(R` `)}return R.join(n)}buildFromTable(o){if(X(o,I)&&o[I.Symbol.OriginalName]!==o[I.Symbol.Name]){let n=R`${R.identifier(o[I.Symbol.OriginalName])}`;if(o[I.Symbol.Schema])n=R`${R.identifier(o[I.Symbol.Schema])}.${n}`;return R`${n} ${R.identifier(o[I.Symbol.Name])}`}return o}buildSelectQuery({withList:o,fields:n,fieldsFlat:T,where:t,having:S,table:f,joins:y,orderBy:A,groupBy:M,limit:F,offset:$,lockingClause:W,distinct:O,setOperators:G}){let D=T??wn(n);for(let q of D)if(X(q.field,Ro)&&_n(q.field.table)!==(X(f,bo)?f._.alias:X(f,vt)?f[Yo].name:X(f,j)?void 0:_n(f))&&!((Jo)=>y?.some(({alias:Oo})=>Oo===(Jo[I.Symbol.IsAlias]?_n(Jo):Jo[I.Symbol.BaseName])))(q.field.table)){let Jo=_n(q.field.table);throw new Error(`Your "${q.path.join("->")}" field references a column "${Jo}"."${q.field.name}", but the table "${Jo}" is not part of the query! Did you forget to join it?`)}let z=!y||y.length===0,Y=this.buildWithCTE(o),B;if(O)B=O===!0?R` distinct`:R` distinct on (${R.join(O.on,R`, `)})`;let p=this.buildSelection(D,{isSingleTable:z}),c=this.buildFromTable(f),a=this.buildJoins(y),E=t?R` where ${t}`:void 0,K=S?R` having ${S}`:void 0,Q;if(A&&A.length>0)Q=R` order by ${R.join(A,R`, `)}`;let x;if(M&&M.length>0)x=R` group by ${R.join(M,R`, `)}`;let h=typeof F==="object"||typeof F==="number"&&F>=0?R` limit ${F}`:void 0,w=$?R` offset ${$}`:void 0,v=R.empty();if(W){let q=R` for ${R.raw(W.strength)}`;if(W.config.of)q.append(R` of ${R.join(Array.isArray(W.config.of)?W.config.of:[W.config.of],R`, `)}`);if(W.config.noWait)q.append(R` no wait`);else if(W.config.skipLocked)q.append(R` skip locked`);v.append(q)}let N=R`${Y}select${B} ${p} from ${c}${a}${E}${x}${K}${Q}${h}${w}${v}`;if(G.length>0)return this.buildSetOperations(N,G);return N}buildSetOperations(o,n){let[T,...t]=n;if(!T)throw new Error("Cannot pass undefined values to any set operator");if(t.length===0)return this.buildSetOperationQuery({leftSelect:o,setOperator:T});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:o,setOperator:T}),t)}buildSetOperationQuery({leftSelect:o,setOperator:{type:n,isAll:T,rightSelect:t,limit:S,orderBy:f,offset:y}}){let A=R`(${o.getSQL()}) `,M=R`(${t.getSQL()})`,F;if(f&&f.length>0){let G=[];for(let D of f)if(X(D,V))G.push(R.identifier(D.name));else if(X(D,j)){for(let z=0;z<D.queryChunks.length;z++){let Y=D.queryChunks[z];if(X(Y,V))D.queryChunks[z]=R.identifier(Y.name)}G.push(R`${D}`)}else G.push(R`${D}`);F=R` order by ${R.join(G,R`, `)} `}let $=typeof S==="object"||typeof S==="number"&&S>=0?R` limit ${S}`:void 0,W=R.raw(`${n} ${T?"all ":""}`),O=y?R` offset ${y}`:void 0;return R`${A}${W}${M}${F}${$}${O}`}buildInsertQuery({table:o,values:n,onConflict:T,returning:t,withList:S,select:f,overridingSystemValue_:y}){let A=[],M=o[I.Symbol.Columns],F=Object.entries(M).filter(([Y,B])=>!B.shouldDisableInsert()),$=F.map(([,Y])=>R.identifier(this.casing.getColumnCasing(Y)));if(f){let Y=n;if(X(Y,j))A.push(Y);else A.push(Y.getSQL())}else{let Y=n;A.push(R.raw("values "));for(let[B,p]of Y.entries()){let c=[];for(let[a,E]of F){let K=p[a];if(K===void 0||X(K,$n)&&K.value===void 0)if(E.defaultFn!==void 0){let Q=E.defaultFn(),x=X(Q,j)?Q:R.param(Q,E);c.push(x)}else if(!E.default&&E.onUpdateFn!==void 0){let Q=E.onUpdateFn(),x=X(Q,j)?Q:R.param(Q,E);c.push(x)}else c.push(R`default`);else c.push(K)}if(A.push(c),B<Y.length-1)A.push(R`, `)}}let W=this.buildWithCTE(S),O=R.join(A),G=t?R` returning ${this.buildSelection(t,{isSingleTable:!0})}`:void 0,D=T?R` on conflict ${T}`:void 0,z=y===!0?R`overriding system value `:void 0;return R`${W}insert into ${o} ${$} ${z}${O}${D}${G}`}buildRefreshMaterializedViewQuery({view:o,concurrently:n,withNoData:T}){let t=n?R` concurrently`:void 0,S=T?R` with no data`:void 0;return R`refresh materialized view${t} ${o}${S}`}prepareTyping(o){if(X(o,QS)||X(o,mS))return"json";else if(X(o,DS))return"decimal";else if(X(o,US))return"time";else if(X(o,VS)||X(o,BS))return"timestamp";else if(X(o,GS)||X(o,zS))return"date";else if(X(o,CS))return"uuid";else return"none"}sqlToQuery(o,n){return o.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:n})}buildRelationalQueryWithoutPK({fullSchema:o,schema:n,tableNamesMap:T,table:t,tableConfig:S,queryConfig:f,tableAlias:y,nestedQueryRelation:A,joinOn:M}){let F=[],$,W,O=[],G,D=[];if(f===!0)F=Object.entries(S.columns).map(([B,p])=>({dbKey:p.name,tsKey:B,field:rn(p,y),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let Y=Object.fromEntries(Object.entries(S.columns).map(([K,Q])=>[K,rn(Q,y)]));if(f.where){let K=typeof f.where==="function"?f.where(Y,I$()):f.where;G=K&&Et(K,y)}let B=[],p=[];if(f.columns){let K=!1;for(let[Q,x]of Object.entries(f.columns)){if(x===void 0)continue;if(Q in S.columns){if(!K&&x===!0)K=!0;p.push(Q)}}if(p.length>0)p=K?p.filter((Q)=>f.columns?.[Q]===!0):Object.keys(S.columns).filter((Q)=>!p.includes(Q))}else p=Object.keys(S.columns);for(let K of p){let Q=S.columns[K];B.push({tsKey:K,value:Q})}let c=[];if(f.with)c=Object.entries(f.with).filter((K)=>!!K[1]).map(([K,Q])=>({tsKey:K,queryConfig:Q,relation:S.relations[K]}));let a;if(f.extras){a=typeof f.extras==="function"?f.extras(Y,{sql:R}):f.extras;for(let[K,Q]of Object.entries(a))B.push({tsKey:K,value:uf(Q,y)})}for(let{tsKey:K,value:Q}of B)F.push({dbKey:X(Q,j.Aliased)?Q.fieldAlias:S.columns[K].name,tsKey:K,field:X(Q,Ro)?rn(Q,y):Q,relationTableTsKey:void 0,isJson:!1,selection:[]});let E=typeof f.orderBy==="function"?f.orderBy(Y,j$()):f.orderBy??[];if(!Array.isArray(E))E=[E];O=E.map((K)=>{if(X(K,Ro))return rn(K,y);return Et(K,y)}),$=f.limit,W=f.offset;for(let{tsKey:K,queryConfig:Q,relation:x}of c){let h=N$(n,T,x),w=JT(x.referencedTable),v=T[w],N=`${y}_${K}`,q=Yt(...h.fields.map((Sn,xn)=>jT(rn(h.references[xn],N),rn(Sn,y)))),Jo=this.buildRelationalQueryWithoutPK({fullSchema:o,schema:n,tableNamesMap:T,table:o[v],tableConfig:n[v],queryConfig:X(x,ST)?Q===!0?{limit:1}:{...Q,limit:1}:Q,tableAlias:N,joinOn:q,nestedQueryRelation:x}),Oo=R`${R.identifier(N)}.${R.identifier("data")}`.as(K);D.push({on:R`true`,table:new bo(Jo.sql,{},N),alias:N,joinType:"left",lateral:!0}),F.push({dbKey:K,tsKey:K,field:Oo,relationTableTsKey:v,isJson:!0,selection:Jo.selection})}}if(F.length===0)throw new ES({message:`No fields selected for table "${S.tsName}" ("${y}")`});let z;if(G=Yt(M,G),A){let Y=R`json_build_array(${R.join(F.map(({field:c,tsKey:a,isJson:E})=>E?R`${R.identifier(`${y}_${a}`)}.${R.identifier("data")}`:X(c,j.Aliased)?c.sql:c),R`, `)})`;if(X(A,mt))Y=R`coalesce(json_agg(${Y}${O.length>0?R` order by ${R.join(O,R`, `)}`:void 0}), '[]'::json)`;let B=[{dbKey:"data",tsKey:"data",field:Y.as("data"),isJson:!0,relationTableTsKey:S.tsName,selection:F}];if($!==void 0||W!==void 0||O.length>0)z=this.buildSelectQuery({table:XS(t,y),fields:{},fieldsFlat:[{path:[],field:R.raw("*")}],where:G,limit:$,offset:W,orderBy:O,setOperators:[]}),G=void 0,$=void 0,W=void 0,O=[];else z=XS(t,y);z=this.buildSelectQuery({table:X(z,vo)?z:new bo(z,{},y),fields:{},fieldsFlat:B.map(({field:c})=>({path:[],field:X(c,Ro)?rn(c,y):c})),joins:D,where:G,limit:$,offset:W,orderBy:O,setOperators:[]})}else z=this.buildSelectQuery({table:XS(t,y),fields:{},fieldsFlat:F.map(({field:Y})=>({path:[],field:X(Y,Ro)?rn(Y,y):Y})),joins:D,where:G,limit:$,offset:W,orderBy:O,setOperators:[]});return{tableTsKey:S.tsName,sql:z,selection:F}}}class io{static[k]="SelectionProxyHandler";config;constructor(o){this.config={...o}}get(o,n){if(n==="_")return{...o._,selectedFields:new Proxy(o._.selectedFields,this)};if(n===Yo)return{...o[Yo],selectedFields:new Proxy(o[Yo].selectedFields,this)};if(typeof n==="symbol")return o[n];let t=(X(o,bo)?o._.selectedFields:X(o,An)?o[Yo].selectedFields:o)[n];if(X(t,j.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!t.isSelectionField)return t.sql;let S=t.clone();return S.isSelectionField=!0,S}if(X(t,j)){if(this.config.sqlBehavior==="sql")return t;throw new Error(`You tried to reference "${n}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(X(t,Ro)){if(this.config.alias)return new Proxy(t,new IT(new Proxy(t.table,new Xt(this.config.alias,this.config.replaceOriginalName??!1))));return t}if(typeof t!=="object"||t===null)return t;return new Proxy(t,new io(this.config))}}class Vy{static[k]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class Tn{static[k]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor(o){if(this.fields=o.fields,this.session=o.session,this.dialect=o.dialect,o.withList)this.withList=o.withList;this.distinct=o.distinct}authToken;setToken(o){return this.authToken=o,this}from(o){let n=!!this.fields,T;if(this.fields)T=this.fields;else if(X(o,bo))T=Object.fromEntries(Object.keys(o._.selectedFields).map((t)=>[t,o[t]]));else if(X(o,vt))T=o[Yo].selectedFields;else if(X(o,j))T={};else T=bM(o);return new By({table:o,fields:T,isPartialSelect:n,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class EJ extends Vy{static[k]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:o,fields:n,isPartialSelect:T,session:t,dialect:S,withList:f,distinct:y}){super();this.config={withList:f,table:o,fields:{...n},distinct:y,setOperators:[]},this.isPartialSelect=T,this.session=t,this.dialect=S,this._={selectedFields:n},this.tableName=Zn(o),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin(o){return(n,T)=>{let t=this.tableName,S=Zn(n);if(typeof S==="string"&&this.config.joins?.some((f)=>f.alias===S))throw new Error(`Alias "${S}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof t==="string")this.config.fields={[t]:this.config.fields};if(typeof S==="string"&&!X(n,j)){let f=X(n,bo)?n._.selectedFields:X(n,An)?n[Yo].selectedFields:n[I.Symbol.Columns];this.config.fields[S]=f}}if(typeof T==="function")T=T(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:T,table:n,joinType:o,alias:S}),typeof S==="string")switch(o){case"left":{this.joinsNotNullableMap[S]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([f])=>[f,!1])),this.joinsNotNullableMap[S]=!0;break}case"inner":{this.joinsNotNullableMap[S]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([f])=>[f,!1])),this.joinsNotNullableMap[S]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator(o,n){return(T)=>{let t=typeof T==="function"?T(q0()):T;if(!Gt(this.getSelectedFields(),t.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:o,isAll:n,rightSelect:t}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators(o){return this.config.setOperators.push(...o),this}where(o){if(typeof o==="function")o=o(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=o,this}having(o){if(typeof o==="function")o=o(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=o,this}groupBy(...o){if(typeof o[0]==="function"){let n=o[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(n)?n:[n]}else this.config.groupBy=o;return this}orderBy(...o){if(typeof o[0]==="function"){let n=o[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),T=Array.isArray(n)?n:[n];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=T;else this.config.orderBy=T}else{let n=o;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=n;else this.config.orderBy=n}return this}limit(o){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=o;else this.config.limit=o;return this}offset(o){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=o;else this.config.offset=o;return this}for(o,n={}){return this.config.lockingClause={strength:o,config:n},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}as(o){return new Proxy(new bo(this.getSQL(),this.config.fields,o),new io({alias:o,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new io({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class By extends EJ{static[k]="PgSelect";_prepare(o){let{session:n,config:T,dialect:t,joinsNotNullableMap:S,authToken:f}=this;if(!n)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return Wo.startActiveSpan("drizzle.prepareQuery",()=>{let y=wn(T.fields),A=n.prepareQuery(t.sqlToQuery(this.getSQL()),y,o,!0);return A.joinsNotNullableMap=S,A.setToken(f)})}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(o,this.authToken)})}}NM(By,[on]);function ot(o,n){return(T,t,...S)=>{let f=[t,...S].map((y)=>({type:o,isAll:n,rightSelect:y}));for(let y of f)if(!Gt(T.getSelectedFields(),y.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return T.addSetOperators(f)}}var q0=()=>({union:Z0,unionAll:P0,intersect:g0,intersectAll:l0,except:e0,exceptAll:d0}),Z0=ot("union",!1),P0=ot("union",!0),g0=ot("intersect",!1),l0=ot("intersect",!0),e0=ot("except",!1),d0=ot("except",!0);class it{static[k]="PgQueryBuilder";dialect;dialectConfig;constructor(o){this.dialect=X(o,YT)?o:void 0,this.dialectConfig=X(o,YT)?void 0:o}$with(o){let n=this;return{as(T){if(typeof T==="function")T=T(n);return new Proxy(new Kt(T.getSQL(),T.getSelectedFields(),o,!0),new io({alias:o,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}}with(...o){let n=this;function T(f){return new Tn({fields:f??void 0,session:void 0,dialect:n.getDialect(),withList:o})}function t(f){return new Tn({fields:f??void 0,session:void 0,dialect:n.getDialect(),distinct:!0})}function S(f,y){return new Tn({fields:y??void 0,session:void 0,dialect:n.getDialect(),distinct:{on:f}})}return{select:T,selectDistinct:t,selectDistinctOn:S}}select(o){return new Tn({fields:o??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(o){return new Tn({fields:o??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(o,n){return new Tn({fields:n??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:o}})}getDialect(){if(!this.dialect)this.dialect=new YT(this.dialectConfig);return this.dialect}}class dS{constructor(o,n,T,t,S){this.table=o,this.session=n,this.dialect=T,this.withList=t,this.overridingSystemValue_=S}static[k]="PgInsertBuilder";authToken;setToken(o){return this.authToken=o,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(o){if(o=Array.isArray(o)?o:[o],o.length===0)throw new Error("values() must be called with at least one value");let n=o.map((T)=>{let t={},S=this.table[I.Symbol.Columns];for(let f of Object.keys(T)){let y=T[f];t[f]=X(y,j)?y:new $n(y,S[f])}return t});return new Cy(this.table,n,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(o){let n=typeof o==="function"?o(new it):o;if(!X(n,j)&&!Gt(this.table[_S],n._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new Cy(this.table,n,this.session,this.dialect,this.withList,!0)}}class Cy extends on{constructor(o,n,T,t,S,f,y){super();this.session=T,this.dialect=t,this.config={table:o,values:n,withList:S,select:f,overridingSystemValue_:y}}static[k]="PgInsert";config;returning(o=this.config.table[I.Symbol.Columns]){return this.config.returning=wn(o),this}onConflictDoNothing(o={}){if(o.target===void 0)this.config.onConflict=R`do nothing`;else{let n="";n=Array.isArray(o.target)?o.target.map((t)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(t))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(o.target));let T=o.where?R` where ${o.where}`:void 0;this.config.onConflict=R`(${R.raw(n)})${T} do nothing`}return this}onConflictDoUpdate(o){if(o.where&&(o.targetWhere||o.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let n=o.where?R` where ${o.where}`:void 0,T=o.targetWhere?R` where ${o.targetWhere}`:void 0,t=o.setWhere?R` where ${o.setWhere}`:void 0,S=this.dialect.buildUpdateSet(this.config.table,YS(this.config.table,o.set)),f="";return f=Array.isArray(o.target)?o.target.map((y)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(y))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(o.target)),this.config.onConflict=R`(${R.raw(f)})${T} do update set ${S}${n}${t}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(o){return Wo.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,o,!0)})}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(o,this.authToken)})};$dynamic(){return this}}class Ly extends on{constructor(o,n,T){super();this.session=n,this.dialect=T,this.config={view:o}}static[k]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(o){return Wo.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,o,!0)})}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(o,this.authToken)})}}class uS{constructor(o,n,T,t){this.table=o,this.session=n,this.dialect=T,this.withList=t}static[k]="PgUpdateBuilder";authToken;setToken(o){return this.authToken=o,this}set(o){return new YJ(this.table,YS(this.table,o),this.session,this.dialect,this.withList).setToken(this.authToken)}}class YJ extends on{constructor(o,n,T,t,S){super();this.session=T,this.dialect=t,this.config={set:n,table:o,withList:S,joins:[]},this.tableName=Zn(o),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[k]="PgUpdate";config;tableName;joinsNotNullableMap;from(o){let n=Zn(o);if(typeof n==="string")this.joinsNotNullableMap[n]=!0;return this.config.from=o,this}getTableLikeFields(o){if(X(o,vo))return o[I.Symbol.Columns];else if(X(o,bo))return o._.selectedFields;return o[Yo].selectedFields}createJoin(o){return(n,T)=>{let t=Zn(n);if(typeof t==="string"&&this.config.joins.some((S)=>S.alias===t))throw new Error(`Alias "${t}" is already used in this query`);if(typeof T==="function"){let S=this.config.from&&!X(this.config.from,j)?this.getTableLikeFields(this.config.from):void 0;T=T(new Proxy(this.config.table[I.Symbol.Columns],new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),S&&new Proxy(S,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:T,table:n,joinType:o,alias:t}),typeof t==="string")switch(o){case"left":{this.joinsNotNullableMap[t]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([S])=>[S,!1])),this.joinsNotNullableMap[t]=!0;break}case"inner":{this.joinsNotNullableMap[t]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([S])=>[S,!1])),this.joinsNotNullableMap[t]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(o){return this.config.where=o,this}returning(o){if(!o){if(o=Object.assign({},this.config.table[I.Symbol.Columns]),this.config.from){let n=Zn(this.config.from);if(typeof n==="string"&&this.config.from&&!X(this.config.from,j)){let T=this.getTableLikeFields(this.config.from);o[n]=T}for(let T of this.config.joins){let t=Zn(T.table);if(typeof t==="string"&&!X(T.table,j)){let S=this.getTableLikeFields(T.table);o[t]=S}}}}return this.config.returning=wn(o),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(o){let n=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,o,!0);return n.joinsNotNullableMap=this.joinsNotNullableMap,n}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return this._prepare().execute(o,this.authToken)};$dynamic(){return this}}class pt extends j{constructor(o){super(pt.buildEmbeddedCount(o.source,o.filters).queryChunks);this.params=o,this.mapWith(Number),this.session=o.session,this.sql=pt.buildCount(o.source,o.filters)}sql;token;static[k]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount(o,n){return R`(select count(*) from ${o}${R.raw(" where ").if(n)}${n})`}static buildCount(o,n){return R`select count(*) as count from ${o}${R.raw(" where ").if(n)}${n};`}setToken(o){return this.token=o,this}then(o,n){return Promise.resolve(this.session.count(this.sql,this.token)).then(o,n)}catch(o){return this.then(void 0,o)}finally(o){return this.then((n)=>{return o?.(),n},(n)=>{throw o?.(),n})}}class jy{constructor(o,n,T,t,S,f,y){this.fullSchema=o,this.schema=n,this.tableNamesMap=T,this.table=t,this.tableConfig=S,this.dialect=f,this.session=y}static[k]="PgRelationalQueryBuilder";findMany(o){return new Iy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,o?o:{},"many")}findFirst(o){return new Iy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,o?{...o,limit:1}:{limit:1},"first")}}class Iy extends on{constructor(o,n,T,t,S,f,y,A,M){super();this.fullSchema=o,this.schema=n,this.tableNamesMap=T,this.table=t,this.tableConfig=S,this.dialect=f,this.session=y,this.config=A,this.mode=M}static[k]="PgRelationalQuery";_prepare(o){return Wo.startActiveSpan("drizzle.prepareQuery",()=>{let{query:n,builtQuery:T}=this._toSQL();return this.session.prepareQuery(T,void 0,o,!0,(t,S)=>{let f=t.map((y)=>LS(this.schema,this.tableConfig,y,n.selection,S));if(this.mode==="first")return f[0];return f})})}prepare(o){return this._prepare(o)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let o=this._getQuery(),n=this.dialect.sqlToQuery(o.sql);return{query:o,builtQuery:n}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(o){return this.authToken=o,this}execute(){return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class ry extends on{constructor(o,n,T,t){super();this.execute=o,this.sql=n,this.query=T,this.mapBatchResult=t}static[k]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult(o,n){return n?this.mapBatchResult(o):o}_prepare(){return this}isResponseInArrayMode(){return!1}}class qt{constructor(o,n,T){if(this.dialect=o,this.session=n,this._=T?{schema:T.schema,fullSchema:T.fullSchema,tableNamesMap:T.tableNamesMap,session:n}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:n},this.query={},this._.schema)for(let[t,S]of Object.entries(this._.schema))this.query[t]=new jy(T.fullSchema,this._.schema,this._.tableNamesMap,T.fullSchema[t],S,o,n)}static[k]="PgDatabase";query;$with(o){let n=this;return{as(T){if(typeof T==="function")T=T(new it(n.dialect));return new Proxy(new Kt(T.getSQL(),T.getSelectedFields(),o,!0),new io({alias:o,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}}$count(o,n){return new pt({source:o,filters:n,session:this.session})}with(...o){let n=this;function T(M){return new Tn({fields:M??void 0,session:n.session,dialect:n.dialect,withList:o})}function t(M){return new Tn({fields:M??void 0,session:n.session,dialect:n.dialect,withList:o,distinct:!0})}function S(M,F){return new Tn({fields:F??void 0,session:n.session,dialect:n.dialect,withList:o,distinct:{on:M}})}function f(M){return new uS(M,n.session,n.dialect,o)}function y(M){return new dS(M,n.session,n.dialect,o)}function A(M){return new eS(M,n.session,n.dialect,o)}return{select:T,selectDistinct:t,selectDistinctOn:S,update:f,insert:y,delete:A}}select(o){return new Tn({fields:o??void 0,session:this.session,dialect:this.dialect})}selectDistinct(o){return new Tn({fields:o??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(o,n){return new Tn({fields:n??void 0,session:this.session,dialect:this.dialect,distinct:{on:o}})}update(o){return new uS(o,this.session,this.dialect)}insert(o){return new dS(o,this.session,this.dialect)}delete(o){return new eS(o,this.session,this.dialect)}refreshMaterializedView(o){return new Ly(o,this.session,this.dialect)}authToken;execute(o){let n=typeof o==="string"?R.raw(o):o.getSQL(),T=this.dialect.sqlToQuery(n),t=this.session.prepareQuery(T,void 0,void 0,!1);return new ry(()=>t.execute(void 0,this.authToken),n,T,(S)=>t.mapResult(S,!0))}transaction(o,n){return this.session.transaction(o,n)}}class GJ{constructor(o,n){this.unique=o,this.name=n}static[k]="PgIndexBuilderOn";on(...o){return new aS(o.map((n)=>{if(X(n,j))return n;n=n;let T=new wt(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=JSON.parse(JSON.stringify(n.defaultConfig)),T}),this.unique,!1,this.name)}onOnly(...o){return new aS(o.map((n)=>{if(X(n,j))return n;n=n;let T=new wt(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=n.defaultConfig,T}),this.unique,!0,this.name)}using(o,...n){return new aS(n.map((T)=>{if(X(T,j))return T;T=T;let t=new wt(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=JSON.parse(JSON.stringify(T.defaultConfig)),t}),this.unique,!0,this.name,o)}}class aS{static[k]="PgIndexBuilder";config;constructor(o,n,T,t,S="btree"){this.config={name:t,columns:o,unique:n,only:T,method:S}}concurrently(){return this.config.concurrently=!0,this}with(o){return this.config.with=o,this}where(o){return this.config.where=o,this}build(o){return new zJ(this.config,o)}}class zJ{static[k]="PgIndex";config;constructor(o,n){this.config={...o,table:n}}}function Ny(o){return new GJ(!0,o)}class by{constructor(o){this.query=o}authToken;getQuery(){return this.query}mapResult(o,n){return o}setToken(o){return this.authToken=o,this}static[k]="PgPreparedQuery";joinsNotNullableMap}class hy{constructor(o){this.dialect=o}static[k]="PgSession";execute(o,n){return Wo.startActiveSpan("drizzle.operation",()=>{return Wo.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery(o),void 0,void 0,!1)}).setToken(n).execute(void 0,n)})}all(o){return this.prepareQuery(this.dialect.sqlToQuery(o),void 0,void 0,!1).all()}async count(o,n){let T=await this.execute(o,n);return Number(T[0].count)}}class xy extends qt{constructor(o,n,T,t=0){super(o,n,T);this.schema=T,this.nestedIndex=t}static[k]="PgTransaction";rollback(){throw new af}getTransactionConfigSQL(o){let n=[];if(o.isolationLevel)n.push(`isolation level ${o.isolationLevel}`);if(o.accessMode)n.push(o.accessMode);if(typeof o.deferrable==="boolean")n.push(o.deferrable?"deferrable":"not deferrable");return R.raw(n.join(" "))}setTransaction(o){return this.session.execute(R`set transaction ${this.getTransactionConfigSQL(o)}`)}}class HJ extends by{constructor(o,n,T,t,S,f,y){super({sql:n,params:T});this.client=o,this.queryString=n,this.params=T,this.logger=t,this.fields=S,this._isResponseInArrayMode=f,this.customResultMapper=y}static[k]="PostgresJsPreparedQuery";async execute(o={}){return Wo.startActiveSpan("drizzle.execute",async(n)=>{let T=df(this.params,o);n?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(T)}),this.logger.logQuery(this.queryString,T);let{fields:t,queryString:S,client:f,joinsNotNullableMap:y,customResultMapper:A}=this;if(!t&&!A)return Wo.startActiveSpan("drizzle.driver.execute",()=>{return f.unsafe(S,T)});let M=await Wo.startActiveSpan("drizzle.driver.execute",()=>{return n?.setAttributes({"drizzle.query.text":S,"drizzle.query.params":JSON.stringify(T)}),f.unsafe(S,T).values()});return Wo.startActiveSpan("drizzle.mapResponse",()=>{return A?A(M):M.map((F)=>rM(t,F,y))})})}all(o={}){return Wo.startActiveSpan("drizzle.execute",async(n)=>{let T=df(this.params,o);return n?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(T)}),this.logger.logQuery(this.queryString,T),Wo.startActiveSpan("drizzle.driver.execute",()=>{return n?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(T)}),this.client.unsafe(this.queryString,T)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class Zt extends hy{constructor(o,n,T,t={}){super(n);this.client=o,this.schema=T,this.options=t,this.logger=t.logger??new oy}static[k]="PostgresJsSession";logger;prepareQuery(o,n,T,t,S){return new HJ(this.client,o.sql,o.params,this.logger,n,t,S)}query(o,n){return this.logger.logQuery(o,n),this.client.unsafe(o,n).values()}queryObjects(o,n){return this.client.unsafe(o,n)}transaction(o,n){return this.client.begin(async(T)=>{let t=new Zt(T,this.dialect,this.schema,this.options),S=new cy(this.dialect,t,this.schema);if(n)await S.setTransaction(n);return o(S)})}}class cy extends xy{constructor(o,n,T,t=0){super(o,n,T,t);this.session=n}static[k]="PostgresJsTransaction";transaction(o){return this.session.client.savepoint((n)=>{let T=new Zt(n,this.dialect,this.schema,this.session.options),t=new cy(this.dialect,T,this.schema);return o(t)})}}class mJ extends qt{static[k]="PostgresJsDatabase"}function nt(o,n={}){let T=(M)=>M;for(let M of["1184","1082","1083","1114"])o.options.parsers[M]=T,o.options.serializers[M]=T;o.options.serializers["114"]=T,o.options.serializers["3802"]=T;let t=new YT({casing:n.casing}),S;if(n.logger===!0)S=new sf;else if(n.logger!==!1)S=n.logger;let f;if(n.schema){let M=r$(n.schema,b$);f={fullSchema:n.schema,schema:M.tables,tableNamesMap:M.tableNamesMap}}let y=new Zt(o,t,f,{logger:S}),A=new mJ(t,y,f);return A.$client=o,A}function sS(...o){if(typeof o[0]==="string"){let n=sT(o[0]);return nt(n,o[1])}if(hM(o[0])){let{connection:n,client:T,...t}=o[0];if(T)return nt(T,t);if(typeof n==="object"&&n.url!==void 0){let{url:f,...y}=n,A=sT(f,y);return nt(A,t)}let S=sT(n);return nt(S,t)}return nt(o[0],o[1])}((o)=>{function n(T){return nt({options:{parsers:{},serializers:{}}},T)}o.mock=n})(sS||(sS={}));var iy={};Bk(iy,{users:()=>GT,userChanges:()=>a0,untrackedUserColumnNames:()=>u0,twoFactorMethod:()=>BJ,trackedUserColumnName:()=>VJ,trackableUserColumnNames:()=>UJ,role:()=>DJ,players:()=>vy,passwordResetAttempts:()=>oW,loginHistory:()=>s0,games:()=>of,banishedIps:()=>Pt});function QJ(o){return R`lower(${o})`}var DJ=WS("role",["admin","user"]),GT=tT("users",{id:Jn().primaryKey().defaultRandom(),username:co({length:16}).notNull(),email:co({length:254}).notNull(),hash:co({length:64}).notNull(),salt:co({length:36}).notNull(),createdAt:Qn({withTimezone:!0}).notNull().defaultNow(),createdIp:co({length:45}).notNull(),isActive:zt().notNull().default(!1),verifiedAt:Qn({withTimezone:!0}),userRole:DJ().default("user")},(o)=>[Ny("usernameUniqueIndex").on(QJ(o.username)),Ny("emailUniqueIndex").on(QJ(o.email))]),u0=["id","createdAt","createdIp","isActive","salt","verifiedAt"],UJ=["username","email","hash","userRole"],VJ=WS("trackedUserColumnName",UJ),a0=tT("userChanges",{id:Jn().primaryKey().defaultRandom(),userId:Jn().notNull().references(()=>GT.id),changedAt:Qn({withTimezone:!0}).notNull().defaultNow(),changedIp:co({length:45}).notNull(),changedColumn:VJ().notNull(),oldValue:co({length:255}),newValue:co({length:255})}),of=tT("games",{id:Jn().primaryKey().defaultRandom()}),vy=tT("players",{userId:Jn().notNull().references(()=>GT.id),gameId:Jn().notNull().references(()=>of.id),score:HS().notNull()},(o)=>[B$({name:"players_userId_gameId_pk",columns:[o.userId,o.gameId]})]),s0=tT("loginHistory",{id:Jn().primaryKey().defaultRandom(),userId:Jn().references(()=>GT.id),loginTime:Qn({withTimezone:!0}).notNull().defaultNow(),ipAddress:co({length:45}).notNull(),userAgent:co({length:1024}),successful:zt().notNull().default(!1)}),BJ=WS("twoFactorMethod",["email","phone"]),oW=tT("passwordResetAttempts",{id:Jn().primaryKey().defaultRandom(),userId:Jn().notNull().references(()=>GT.id),requestedIp:co({length:45}).notNull(),requestedAt:Qn({withTimezone:!0}).notNull().defaultNow(),succeededIp:co({length:45}),succeededAt:Qn({withTimezone:!0}),verificationMethod:BJ().notNull()}),Pt=tT("banishedIps",{ip:co({length:45}).primaryKey(),reason:co({length:2048}).notNull(),banishedAt:Qn({withTimezone:!0}).notNull().defaultNow(),banishedUntil:Qn({withTimezone:!0})});var __dirname="/home/runner/work/wayforge/wayforge/apps/tempest.games/src/database";class py{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(nW.resolve(__dirname,"notify_update.sql"));let o=[_n(GT),_n(of),_n(vy)];await this.sql`SELECT create_notify_triggers(${this.sql.array(o)})`,await this.sql.listen("table_update",(n)=>{let T=n.split(","),t=T[0],S=T[1],f=`${t}("${S}")`;if(this.observers.has(f))this.observers.get(f).next(f)})}constructor(o=!1,n={host:Cn.POSTGRES_HOST,port:Cn.POSTGRES_PORT,user:Cn.POSTGRES_USER,password:Cn.POSTGRES_PASSWORD,database:Cn.POSTGRES_DATABASE}){this.options=n,this.sql=sT(n),this.drizzle=sS(this.sql,{schema:iy,logger:o})}observe(o,n){if(!this.observers.has(o))this.observers.set(o,new s);this.observers.get(o).subscribe("SINGLETON",n)}}var nf={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},qy=tA(nf).map(([o])=>Go.literal(Number(o))),TW=Go.union([qy[0],qy[1],...qy]),CJ=Go.tuple([TW,Go.string()]);var Py=new rf,{logger:tn}=Py;Object.assign(console,tn,{log:tn.info});tn.info(" ready");var Zy=IJ(import.meta.dir,"..","app"),yW=new py({logQuery(o,n){tn.info("\uD83D\uDCDD query",o,n)}});fW({hostname:"0.0.0.0",port:Cn.FRONTEND_PORT??3333,...s$??void 0,async fetch(o,n){try{let T=new Date,t=new URL(o.url),S=n.requestIP(o)?.address??"??";tn.info(T,S,o.method,t.pathname);let[f]=await yW.drizzle.select({banishedUntil:Pt.banishedUntil}).from(Pt).where(jT(Pt.ip,S)).limit(1),y=f?.banishedUntil===null,A=f?.banishedUntil&&f.banishedUntil>T;if(y||A)throw tn.info(`\uD83D\uDE45 request from banned ip ${S}`),[403,S];if(t.pathname==="/")return new Response(Bun.file(IJ(Zy,"index.html")));if(t.pathname==="/index.html")return Response.redirect("/");let M=tW(Zy,t.pathname),F=SW(M);if(!F.startsWith(Zy))throw[403,"Access Denied"];if(!await LJ(F).exists())return Response.redirect("/");return new Response(LJ(F))}catch(T){let t=CJ.safeParse(T);if(t.success){let[S,f]=t.data,A=`${nf[S]}. ${f}`;return tn.info(`\u274C ${S}: ${A}`),new Response(A,{status:S})}if(T instanceof Error)tn.error(T.message);else{let S=BT(T);tn.error("frontend server threw",S)}return new Response(nf[500],{status:500})}}});function Tf(){tn.info("\uD83D\uDEEC frontend server exiting"),process.exit(0)}process.on("SIGINT",()=>{tn.info("\u2757 received SIGINT; exiting gracefully"),Tf()});process.on("SIGTERM",()=>{tn.info("\u2757 received SIGTERM; exiting gracefully"),Tf()});process.on("exit",()=>{tn.info("\u2757 received exit; exiting gracefully"),Tf()});Py.on("timeToStop",()=>{tn.info('\u2757 backend server received signal "timeToStop"; exiting gracefully'),Tf()});tn.info(`\uD83D\uDEEB frontend server running at http://localhost:${Cn.FRONTEND_PORT}/`);Py.emit("alive");
36
+ `;await n.execute(R`CREATE SCHEMA IF NOT EXISTS ${R.identifier(S)}`),await n.execute(f);let A=(await n.all(R`select id, hash, created_at from ${R.identifier(S)}.${R.identifier(t)} order by created_at desc limit 1`))[0];await n.transaction(async(M)=>{for await(let F of o)if(!A||Number(A.created_at)<F.folderMillis){for(let $ of F.sql)await M.execute(R.raw($));await M.execute(R`insert into ${R.identifier(S)}.${R.identifier(t)} ("hash", "created_at") values(${F.hash}, ${F.folderMillis})`)}})}escapeName(o){return`"${o}"`}escapeParam(o){return`$${o+1}`}escapeString(o){return`'${o.replace(/'/g,"''")}'`}buildWithCTE(o){if(!o?.length)return;let n=[R`with `];for(let[T,t]of o.entries())if(n.push(R`${R.identifier(t._.alias)} as (${t._.sql})`),T<o.length-1)n.push(R`, `);return n.push(R` `),R.join(n)}buildDeleteQuery({table:o,where:n,returning:T,withList:t}){let S=this.buildWithCTE(t),f=T?R` returning ${this.buildSelection(T,{isSingleTable:!0})}`:void 0,y=n?R` where ${n}`:void 0;return R`${S}delete from ${o}${y}${f}`}buildUpdateSet(o,n){let T=o[I.Symbol.Columns],t=Object.keys(T).filter((f)=>n[f]!==void 0||T[f]?.onUpdateFn!==void 0),S=t.length;return R.join(t.flatMap((f,y)=>{let A=T[f],M=n[f]??R.param(A.onUpdateFn(),A),F=R`${R.identifier(this.casing.getColumnCasing(A))} = ${M}`;if(y<S-1)return[F,R.raw(", ")];return[F]}))}buildUpdateQuery({table:o,set:n,where:T,returning:t,withList:S,from:f,joins:y}){let A=this.buildWithCTE(S),M=o[vo.Symbol.Name],F=o[vo.Symbol.Schema],$=o[vo.Symbol.OriginalName],W=M===$?void 0:M,O=R`${F?R`${R.identifier(F)}.`:void 0}${R.identifier($)}${W&&R` ${R.identifier(W)}`}`,G=this.buildUpdateSet(o,n),D=f&&R.join([R.raw(" from "),this.buildFromTable(f)]),z=this.buildJoins(y),Y=t?R` returning ${this.buildSelection(t,{isSingleTable:!f})}`:void 0,B=T?R` where ${T}`:void 0;return R`${A}update ${O} set ${G}${D}${z}${B}${Y}`}buildSelection(o,{isSingleTable:n=!1}={}){let T=o.length,t=o.flatMap(({field:S},f)=>{let y=[];if(X(S,j.Aliased)&&S.isSelectionField)y.push(R.identifier(S.fieldAlias));else if(X(S,j.Aliased)||X(S,j)){let A=X(S,j.Aliased)?S.sql:S;if(n)y.push(new j(A.queryChunks.map((M)=>{if(X(M,V))return R.identifier(this.casing.getColumnCasing(M));return M})));else y.push(A);if(X(S,j.Aliased))y.push(R` as ${R.identifier(S.fieldAlias)}`)}else if(X(S,Ro))if(n)y.push(R.identifier(this.casing.getColumnCasing(S)));else y.push(S);if(f<T-1)y.push(R`, `);return y});return R.join(t)}buildJoins(o){if(!o||o.length===0)return;let n=[];for(let[T,t]of o.entries()){if(T===0)n.push(R` `);let S=t.table,f=t.lateral?R` lateral`:void 0;if(X(S,vo)){let y=S[vo.Symbol.Name],A=S[vo.Symbol.Schema],M=S[vo.Symbol.OriginalName],F=y===M?void 0:t.alias;n.push(R`${R.raw(t.joinType)} join${f} ${A?R`${R.identifier(A)}.`:void 0}${R.identifier(M)}${F&&R` ${R.identifier(F)}`} on ${t.on}`)}else if(X(S,An)){let y=S[Yo].name,A=S[Yo].schema,M=S[Yo].originalName,F=y===M?void 0:t.alias;n.push(R`${R.raw(t.joinType)} join${f} ${A?R`${R.identifier(A)}.`:void 0}${R.identifier(M)}${F&&R` ${R.identifier(F)}`} on ${t.on}`)}else n.push(R`${R.raw(t.joinType)} join${f} ${S} on ${t.on}`);if(T<o.length-1)n.push(R` `)}return R.join(n)}buildFromTable(o){if(X(o,I)&&o[I.Symbol.OriginalName]!==o[I.Symbol.Name]){let n=R`${R.identifier(o[I.Symbol.OriginalName])}`;if(o[I.Symbol.Schema])n=R`${R.identifier(o[I.Symbol.Schema])}.${n}`;return R`${n} ${R.identifier(o[I.Symbol.Name])}`}return o}buildSelectQuery({withList:o,fields:n,fieldsFlat:T,where:t,having:S,table:f,joins:y,orderBy:A,groupBy:M,limit:F,offset:$,lockingClause:W,distinct:O,setOperators:G}){let D=T??wn(n);for(let q of D)if(X(q.field,Ro)&&_n(q.field.table)!==(X(f,bo)?f._.alias:X(f,vt)?f[Yo].name:X(f,j)?void 0:_n(f))&&!((Jo)=>y?.some(({alias:Oo})=>Oo===(Jo[I.Symbol.IsAlias]?_n(Jo):Jo[I.Symbol.BaseName])))(q.field.table)){let Jo=_n(q.field.table);throw new Error(`Your "${q.path.join("->")}" field references a column "${Jo}"."${q.field.name}", but the table "${Jo}" is not part of the query! Did you forget to join it?`)}let z=!y||y.length===0,Y=this.buildWithCTE(o),B;if(O)B=O===!0?R` distinct`:R` distinct on (${R.join(O.on,R`, `)})`;let p=this.buildSelection(D,{isSingleTable:z}),c=this.buildFromTable(f),a=this.buildJoins(y),E=t?R` where ${t}`:void 0,K=S?R` having ${S}`:void 0,Q;if(A&&A.length>0)Q=R` order by ${R.join(A,R`, `)}`;let x;if(M&&M.length>0)x=R` group by ${R.join(M,R`, `)}`;let h=typeof F==="object"||typeof F==="number"&&F>=0?R` limit ${F}`:void 0,w=$?R` offset ${$}`:void 0,v=R.empty();if(W){let q=R` for ${R.raw(W.strength)}`;if(W.config.of)q.append(R` of ${R.join(Array.isArray(W.config.of)?W.config.of:[W.config.of],R`, `)}`);if(W.config.noWait)q.append(R` no wait`);else if(W.config.skipLocked)q.append(R` skip locked`);v.append(q)}let N=R`${Y}select${B} ${p} from ${c}${a}${E}${x}${K}${Q}${h}${w}${v}`;if(G.length>0)return this.buildSetOperations(N,G);return N}buildSetOperations(o,n){let[T,...t]=n;if(!T)throw new Error("Cannot pass undefined values to any set operator");if(t.length===0)return this.buildSetOperationQuery({leftSelect:o,setOperator:T});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:o,setOperator:T}),t)}buildSetOperationQuery({leftSelect:o,setOperator:{type:n,isAll:T,rightSelect:t,limit:S,orderBy:f,offset:y}}){let A=R`(${o.getSQL()}) `,M=R`(${t.getSQL()})`,F;if(f&&f.length>0){let G=[];for(let D of f)if(X(D,V))G.push(R.identifier(D.name));else if(X(D,j)){for(let z=0;z<D.queryChunks.length;z++){let Y=D.queryChunks[z];if(X(Y,V))D.queryChunks[z]=R.identifier(Y.name)}G.push(R`${D}`)}else G.push(R`${D}`);F=R` order by ${R.join(G,R`, `)} `}let $=typeof S==="object"||typeof S==="number"&&S>=0?R` limit ${S}`:void 0,W=R.raw(`${n} ${T?"all ":""}`),O=y?R` offset ${y}`:void 0;return R`${A}${W}${M}${F}${$}${O}`}buildInsertQuery({table:o,values:n,onConflict:T,returning:t,withList:S,select:f,overridingSystemValue_:y}){let A=[],M=o[I.Symbol.Columns],F=Object.entries(M).filter(([Y,B])=>!B.shouldDisableInsert()),$=F.map(([,Y])=>R.identifier(this.casing.getColumnCasing(Y)));if(f){let Y=n;if(X(Y,j))A.push(Y);else A.push(Y.getSQL())}else{let Y=n;A.push(R.raw("values "));for(let[B,p]of Y.entries()){let c=[];for(let[a,E]of F){let K=p[a];if(K===void 0||X(K,$n)&&K.value===void 0)if(E.defaultFn!==void 0){let Q=E.defaultFn(),x=X(Q,j)?Q:R.param(Q,E);c.push(x)}else if(!E.default&&E.onUpdateFn!==void 0){let Q=E.onUpdateFn(),x=X(Q,j)?Q:R.param(Q,E);c.push(x)}else c.push(R`default`);else c.push(K)}if(A.push(c),B<Y.length-1)A.push(R`, `)}}let W=this.buildWithCTE(S),O=R.join(A),G=t?R` returning ${this.buildSelection(t,{isSingleTable:!0})}`:void 0,D=T?R` on conflict ${T}`:void 0,z=y===!0?R`overriding system value `:void 0;return R`${W}insert into ${o} ${$} ${z}${O}${D}${G}`}buildRefreshMaterializedViewQuery({view:o,concurrently:n,withNoData:T}){let t=n?R` concurrently`:void 0,S=T?R` with no data`:void 0;return R`refresh materialized view${t} ${o}${S}`}prepareTyping(o){if(X(o,QS)||X(o,mS))return"json";else if(X(o,DS))return"decimal";else if(X(o,US))return"time";else if(X(o,VS)||X(o,BS))return"timestamp";else if(X(o,GS)||X(o,zS))return"date";else if(X(o,CS))return"uuid";else return"none"}sqlToQuery(o,n){return o.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:n})}buildRelationalQueryWithoutPK({fullSchema:o,schema:n,tableNamesMap:T,table:t,tableConfig:S,queryConfig:f,tableAlias:y,nestedQueryRelation:A,joinOn:M}){let F=[],$,W,O=[],G,D=[];if(f===!0)F=Object.entries(S.columns).map(([B,p])=>({dbKey:p.name,tsKey:B,field:rn(p,y),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let Y=Object.fromEntries(Object.entries(S.columns).map(([K,Q])=>[K,rn(Q,y)]));if(f.where){let K=typeof f.where==="function"?f.where(Y,I$()):f.where;G=K&&Et(K,y)}let B=[],p=[];if(f.columns){let K=!1;for(let[Q,x]of Object.entries(f.columns)){if(x===void 0)continue;if(Q in S.columns){if(!K&&x===!0)K=!0;p.push(Q)}}if(p.length>0)p=K?p.filter((Q)=>f.columns?.[Q]===!0):Object.keys(S.columns).filter((Q)=>!p.includes(Q))}else p=Object.keys(S.columns);for(let K of p){let Q=S.columns[K];B.push({tsKey:K,value:Q})}let c=[];if(f.with)c=Object.entries(f.with).filter((K)=>!!K[1]).map(([K,Q])=>({tsKey:K,queryConfig:Q,relation:S.relations[K]}));let a;if(f.extras){a=typeof f.extras==="function"?f.extras(Y,{sql:R}):f.extras;for(let[K,Q]of Object.entries(a))B.push({tsKey:K,value:uf(Q,y)})}for(let{tsKey:K,value:Q}of B)F.push({dbKey:X(Q,j.Aliased)?Q.fieldAlias:S.columns[K].name,tsKey:K,field:X(Q,Ro)?rn(Q,y):Q,relationTableTsKey:void 0,isJson:!1,selection:[]});let E=typeof f.orderBy==="function"?f.orderBy(Y,j$()):f.orderBy??[];if(!Array.isArray(E))E=[E];O=E.map((K)=>{if(X(K,Ro))return rn(K,y);return Et(K,y)}),$=f.limit,W=f.offset;for(let{tsKey:K,queryConfig:Q,relation:x}of c){let h=N$(n,T,x),w=JT(x.referencedTable),v=T[w],N=`${y}_${K}`,q=Yt(...h.fields.map((Sn,xn)=>jT(rn(h.references[xn],N),rn(Sn,y)))),Jo=this.buildRelationalQueryWithoutPK({fullSchema:o,schema:n,tableNamesMap:T,table:o[v],tableConfig:n[v],queryConfig:X(x,ST)?Q===!0?{limit:1}:{...Q,limit:1}:Q,tableAlias:N,joinOn:q,nestedQueryRelation:x}),Oo=R`${R.identifier(N)}.${R.identifier("data")}`.as(K);D.push({on:R`true`,table:new bo(Jo.sql,{},N),alias:N,joinType:"left",lateral:!0}),F.push({dbKey:K,tsKey:K,field:Oo,relationTableTsKey:v,isJson:!0,selection:Jo.selection})}}if(F.length===0)throw new ES({message:`No fields selected for table "${S.tsName}" ("${y}")`});let z;if(G=Yt(M,G),A){let Y=R`json_build_array(${R.join(F.map(({field:c,tsKey:a,isJson:E})=>E?R`${R.identifier(`${y}_${a}`)}.${R.identifier("data")}`:X(c,j.Aliased)?c.sql:c),R`, `)})`;if(X(A,mt))Y=R`coalesce(json_agg(${Y}${O.length>0?R` order by ${R.join(O,R`, `)}`:void 0}), '[]'::json)`;let B=[{dbKey:"data",tsKey:"data",field:Y.as("data"),isJson:!0,relationTableTsKey:S.tsName,selection:F}];if($!==void 0||W!==void 0||O.length>0)z=this.buildSelectQuery({table:XS(t,y),fields:{},fieldsFlat:[{path:[],field:R.raw("*")}],where:G,limit:$,offset:W,orderBy:O,setOperators:[]}),G=void 0,$=void 0,W=void 0,O=[];else z=XS(t,y);z=this.buildSelectQuery({table:X(z,vo)?z:new bo(z,{},y),fields:{},fieldsFlat:B.map(({field:c})=>({path:[],field:X(c,Ro)?rn(c,y):c})),joins:D,where:G,limit:$,offset:W,orderBy:O,setOperators:[]})}else z=this.buildSelectQuery({table:XS(t,y),fields:{},fieldsFlat:F.map(({field:Y})=>({path:[],field:X(Y,Ro)?rn(Y,y):Y})),joins:D,where:G,limit:$,offset:W,orderBy:O,setOperators:[]});return{tableTsKey:S.tsName,sql:z,selection:F}}}class io{static[k]="SelectionProxyHandler";config;constructor(o){this.config={...o}}get(o,n){if(n==="_")return{...o._,selectedFields:new Proxy(o._.selectedFields,this)};if(n===Yo)return{...o[Yo],selectedFields:new Proxy(o[Yo].selectedFields,this)};if(typeof n==="symbol")return o[n];let t=(X(o,bo)?o._.selectedFields:X(o,An)?o[Yo].selectedFields:o)[n];if(X(t,j.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!t.isSelectionField)return t.sql;let S=t.clone();return S.isSelectionField=!0,S}if(X(t,j)){if(this.config.sqlBehavior==="sql")return t;throw new Error(`You tried to reference "${n}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(X(t,Ro)){if(this.config.alias)return new Proxy(t,new IT(new Proxy(t.table,new Xt(this.config.alias,this.config.replaceOriginalName??!1))));return t}if(typeof t!=="object"||t===null)return t;return new Proxy(t,new io(this.config))}}class Vy{static[k]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class Tn{static[k]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor(o){if(this.fields=o.fields,this.session=o.session,this.dialect=o.dialect,o.withList)this.withList=o.withList;this.distinct=o.distinct}authToken;setToken(o){return this.authToken=o,this}from(o){let n=!!this.fields,T;if(this.fields)T=this.fields;else if(X(o,bo))T=Object.fromEntries(Object.keys(o._.selectedFields).map((t)=>[t,o[t]]));else if(X(o,vt))T=o[Yo].selectedFields;else if(X(o,j))T={};else T=bM(o);return new By({table:o,fields:T,isPartialSelect:n,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class EJ extends Vy{static[k]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:o,fields:n,isPartialSelect:T,session:t,dialect:S,withList:f,distinct:y}){super();this.config={withList:f,table:o,fields:{...n},distinct:y,setOperators:[]},this.isPartialSelect=T,this.session=t,this.dialect=S,this._={selectedFields:n},this.tableName=Zn(o),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin(o){return(n,T)=>{let t=this.tableName,S=Zn(n);if(typeof S==="string"&&this.config.joins?.some((f)=>f.alias===S))throw new Error(`Alias "${S}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof t==="string")this.config.fields={[t]:this.config.fields};if(typeof S==="string"&&!X(n,j)){let f=X(n,bo)?n._.selectedFields:X(n,An)?n[Yo].selectedFields:n[I.Symbol.Columns];this.config.fields[S]=f}}if(typeof T==="function")T=T(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:T,table:n,joinType:o,alias:S}),typeof S==="string")switch(o){case"left":{this.joinsNotNullableMap[S]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([f])=>[f,!1])),this.joinsNotNullableMap[S]=!0;break}case"inner":{this.joinsNotNullableMap[S]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([f])=>[f,!1])),this.joinsNotNullableMap[S]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator(o,n){return(T)=>{let t=typeof T==="function"?T(q0()):T;if(!Gt(this.getSelectedFields(),t.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:o,isAll:n,rightSelect:t}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators(o){return this.config.setOperators.push(...o),this}where(o){if(typeof o==="function")o=o(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=o,this}having(o){if(typeof o==="function")o=o(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=o,this}groupBy(...o){if(typeof o[0]==="function"){let n=o[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(n)?n:[n]}else this.config.groupBy=o;return this}orderBy(...o){if(typeof o[0]==="function"){let n=o[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),T=Array.isArray(n)?n:[n];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=T;else this.config.orderBy=T}else{let n=o;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=n;else this.config.orderBy=n}return this}limit(o){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=o;else this.config.limit=o;return this}offset(o){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=o;else this.config.offset=o;return this}for(o,n={}){return this.config.lockingClause={strength:o,config:n},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}as(o){return new Proxy(new bo(this.getSQL(),this.config.fields,o),new io({alias:o,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new io({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class By extends EJ{static[k]="PgSelect";_prepare(o){let{session:n,config:T,dialect:t,joinsNotNullableMap:S,authToken:f}=this;if(!n)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return Wo.startActiveSpan("drizzle.prepareQuery",()=>{let y=wn(T.fields),A=n.prepareQuery(t.sqlToQuery(this.getSQL()),y,o,!0);return A.joinsNotNullableMap=S,A.setToken(f)})}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(o,this.authToken)})}}NM(By,[on]);function ot(o,n){return(T,t,...S)=>{let f=[t,...S].map((y)=>({type:o,isAll:n,rightSelect:y}));for(let y of f)if(!Gt(T.getSelectedFields(),y.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return T.addSetOperators(f)}}var q0=()=>({union:Z0,unionAll:P0,intersect:g0,intersectAll:l0,except:e0,exceptAll:d0}),Z0=ot("union",!1),P0=ot("union",!0),g0=ot("intersect",!1),l0=ot("intersect",!0),e0=ot("except",!1),d0=ot("except",!0);class it{static[k]="PgQueryBuilder";dialect;dialectConfig;constructor(o){this.dialect=X(o,YT)?o:void 0,this.dialectConfig=X(o,YT)?void 0:o}$with(o){let n=this;return{as(T){if(typeof T==="function")T=T(n);return new Proxy(new Kt(T.getSQL(),T.getSelectedFields(),o,!0),new io({alias:o,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}}with(...o){let n=this;function T(f){return new Tn({fields:f??void 0,session:void 0,dialect:n.getDialect(),withList:o})}function t(f){return new Tn({fields:f??void 0,session:void 0,dialect:n.getDialect(),distinct:!0})}function S(f,y){return new Tn({fields:y??void 0,session:void 0,dialect:n.getDialect(),distinct:{on:f}})}return{select:T,selectDistinct:t,selectDistinctOn:S}}select(o){return new Tn({fields:o??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(o){return new Tn({fields:o??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(o,n){return new Tn({fields:n??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:o}})}getDialect(){if(!this.dialect)this.dialect=new YT(this.dialectConfig);return this.dialect}}class dS{constructor(o,n,T,t,S){this.table=o,this.session=n,this.dialect=T,this.withList=t,this.overridingSystemValue_=S}static[k]="PgInsertBuilder";authToken;setToken(o){return this.authToken=o,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(o){if(o=Array.isArray(o)?o:[o],o.length===0)throw new Error("values() must be called with at least one value");let n=o.map((T)=>{let t={},S=this.table[I.Symbol.Columns];for(let f of Object.keys(T)){let y=T[f];t[f]=X(y,j)?y:new $n(y,S[f])}return t});return new Cy(this.table,n,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(o){let n=typeof o==="function"?o(new it):o;if(!X(n,j)&&!Gt(this.table[_S],n._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new Cy(this.table,n,this.session,this.dialect,this.withList,!0)}}class Cy extends on{constructor(o,n,T,t,S,f,y){super();this.session=T,this.dialect=t,this.config={table:o,values:n,withList:S,select:f,overridingSystemValue_:y}}static[k]="PgInsert";config;returning(o=this.config.table[I.Symbol.Columns]){return this.config.returning=wn(o),this}onConflictDoNothing(o={}){if(o.target===void 0)this.config.onConflict=R`do nothing`;else{let n="";n=Array.isArray(o.target)?o.target.map((t)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(t))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(o.target));let T=o.where?R` where ${o.where}`:void 0;this.config.onConflict=R`(${R.raw(n)})${T} do nothing`}return this}onConflictDoUpdate(o){if(o.where&&(o.targetWhere||o.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let n=o.where?R` where ${o.where}`:void 0,T=o.targetWhere?R` where ${o.targetWhere}`:void 0,t=o.setWhere?R` where ${o.setWhere}`:void 0,S=this.dialect.buildUpdateSet(this.config.table,YS(this.config.table,o.set)),f="";return f=Array.isArray(o.target)?o.target.map((y)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(y))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(o.target)),this.config.onConflict=R`(${R.raw(f)})${T} do update set ${S}${n}${t}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(o){return Wo.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,o,!0)})}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(o,this.authToken)})};$dynamic(){return this}}class Ly extends on{constructor(o,n,T){super();this.session=n,this.dialect=T,this.config={view:o}}static[k]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(o){return Wo.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,o,!0)})}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(o,this.authToken)})}}class uS{constructor(o,n,T,t){this.table=o,this.session=n,this.dialect=T,this.withList=t}static[k]="PgUpdateBuilder";authToken;setToken(o){return this.authToken=o,this}set(o){return new YJ(this.table,YS(this.table,o),this.session,this.dialect,this.withList).setToken(this.authToken)}}class YJ extends on{constructor(o,n,T,t,S){super();this.session=T,this.dialect=t,this.config={set:n,table:o,withList:S,joins:[]},this.tableName=Zn(o),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[k]="PgUpdate";config;tableName;joinsNotNullableMap;from(o){let n=Zn(o);if(typeof n==="string")this.joinsNotNullableMap[n]=!0;return this.config.from=o,this}getTableLikeFields(o){if(X(o,vo))return o[I.Symbol.Columns];else if(X(o,bo))return o._.selectedFields;return o[Yo].selectedFields}createJoin(o){return(n,T)=>{let t=Zn(n);if(typeof t==="string"&&this.config.joins.some((S)=>S.alias===t))throw new Error(`Alias "${t}" is already used in this query`);if(typeof T==="function"){let S=this.config.from&&!X(this.config.from,j)?this.getTableLikeFields(this.config.from):void 0;T=T(new Proxy(this.config.table[I.Symbol.Columns],new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),S&&new Proxy(S,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:T,table:n,joinType:o,alias:t}),typeof t==="string")switch(o){case"left":{this.joinsNotNullableMap[t]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([S])=>[S,!1])),this.joinsNotNullableMap[t]=!0;break}case"inner":{this.joinsNotNullableMap[t]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([S])=>[S,!1])),this.joinsNotNullableMap[t]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(o){return this.config.where=o,this}returning(o){if(!o){if(o=Object.assign({},this.config.table[I.Symbol.Columns]),this.config.from){let n=Zn(this.config.from);if(typeof n==="string"&&this.config.from&&!X(this.config.from,j)){let T=this.getTableLikeFields(this.config.from);o[n]=T}for(let T of this.config.joins){let t=Zn(T.table);if(typeof t==="string"&&!X(T.table,j)){let S=this.getTableLikeFields(T.table);o[t]=S}}}}return this.config.returning=wn(o),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:o,...n}=this.dialect.sqlToQuery(this.getSQL());return n}_prepare(o){let n=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,o,!0);return n.joinsNotNullableMap=this.joinsNotNullableMap,n}prepare(o){return this._prepare(o)}authToken;setToken(o){return this.authToken=o,this}execute=(o)=>{return this._prepare().execute(o,this.authToken)};$dynamic(){return this}}class pt extends j{constructor(o){super(pt.buildEmbeddedCount(o.source,o.filters).queryChunks);this.params=o,this.mapWith(Number),this.session=o.session,this.sql=pt.buildCount(o.source,o.filters)}sql;token;static[k]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount(o,n){return R`(select count(*) from ${o}${R.raw(" where ").if(n)}${n})`}static buildCount(o,n){return R`select count(*) as count from ${o}${R.raw(" where ").if(n)}${n};`}setToken(o){return this.token=o,this}then(o,n){return Promise.resolve(this.session.count(this.sql,this.token)).then(o,n)}catch(o){return this.then(void 0,o)}finally(o){return this.then((n)=>{return o?.(),n},(n)=>{throw o?.(),n})}}class jy{constructor(o,n,T,t,S,f,y){this.fullSchema=o,this.schema=n,this.tableNamesMap=T,this.table=t,this.tableConfig=S,this.dialect=f,this.session=y}static[k]="PgRelationalQueryBuilder";findMany(o){return new Iy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,o?o:{},"many")}findFirst(o){return new Iy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,o?{...o,limit:1}:{limit:1},"first")}}class Iy extends on{constructor(o,n,T,t,S,f,y,A,M){super();this.fullSchema=o,this.schema=n,this.tableNamesMap=T,this.table=t,this.tableConfig=S,this.dialect=f,this.session=y,this.config=A,this.mode=M}static[k]="PgRelationalQuery";_prepare(o){return Wo.startActiveSpan("drizzle.prepareQuery",()=>{let{query:n,builtQuery:T}=this._toSQL();return this.session.prepareQuery(T,void 0,o,!0,(t,S)=>{let f=t.map((y)=>LS(this.schema,this.tableConfig,y,n.selection,S));if(this.mode==="first")return f[0];return f})})}prepare(o){return this._prepare(o)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let o=this._getQuery(),n=this.dialect.sqlToQuery(o.sql);return{query:o,builtQuery:n}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(o){return this.authToken=o,this}execute(){return Wo.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class ry extends on{constructor(o,n,T,t){super();this.execute=o,this.sql=n,this.query=T,this.mapBatchResult=t}static[k]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult(o,n){return n?this.mapBatchResult(o):o}_prepare(){return this}isResponseInArrayMode(){return!1}}class qt{constructor(o,n,T){if(this.dialect=o,this.session=n,this._=T?{schema:T.schema,fullSchema:T.fullSchema,tableNamesMap:T.tableNamesMap,session:n}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:n},this.query={},this._.schema)for(let[t,S]of Object.entries(this._.schema))this.query[t]=new jy(T.fullSchema,this._.schema,this._.tableNamesMap,T.fullSchema[t],S,o,n)}static[k]="PgDatabase";query;$with(o){let n=this;return{as(T){if(typeof T==="function")T=T(new it(n.dialect));return new Proxy(new Kt(T.getSQL(),T.getSelectedFields(),o,!0),new io({alias:o,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}}$count(o,n){return new pt({source:o,filters:n,session:this.session})}with(...o){let n=this;function T(M){return new Tn({fields:M??void 0,session:n.session,dialect:n.dialect,withList:o})}function t(M){return new Tn({fields:M??void 0,session:n.session,dialect:n.dialect,withList:o,distinct:!0})}function S(M,F){return new Tn({fields:F??void 0,session:n.session,dialect:n.dialect,withList:o,distinct:{on:M}})}function f(M){return new uS(M,n.session,n.dialect,o)}function y(M){return new dS(M,n.session,n.dialect,o)}function A(M){return new eS(M,n.session,n.dialect,o)}return{select:T,selectDistinct:t,selectDistinctOn:S,update:f,insert:y,delete:A}}select(o){return new Tn({fields:o??void 0,session:this.session,dialect:this.dialect})}selectDistinct(o){return new Tn({fields:o??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(o,n){return new Tn({fields:n??void 0,session:this.session,dialect:this.dialect,distinct:{on:o}})}update(o){return new uS(o,this.session,this.dialect)}insert(o){return new dS(o,this.session,this.dialect)}delete(o){return new eS(o,this.session,this.dialect)}refreshMaterializedView(o){return new Ly(o,this.session,this.dialect)}authToken;execute(o){let n=typeof o==="string"?R.raw(o):o.getSQL(),T=this.dialect.sqlToQuery(n),t=this.session.prepareQuery(T,void 0,void 0,!1);return new ry(()=>t.execute(void 0,this.authToken),n,T,(S)=>t.mapResult(S,!0))}transaction(o,n){return this.session.transaction(o,n)}}class GJ{constructor(o,n){this.unique=o,this.name=n}static[k]="PgIndexBuilderOn";on(...o){return new aS(o.map((n)=>{if(X(n,j))return n;n=n;let T=new wt(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=JSON.parse(JSON.stringify(n.defaultConfig)),T}),this.unique,!1,this.name)}onOnly(...o){return new aS(o.map((n)=>{if(X(n,j))return n;n=n;let T=new wt(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=n.defaultConfig,T}),this.unique,!0,this.name)}using(o,...n){return new aS(n.map((T)=>{if(X(T,j))return T;T=T;let t=new wt(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=JSON.parse(JSON.stringify(T.defaultConfig)),t}),this.unique,!0,this.name,o)}}class aS{static[k]="PgIndexBuilder";config;constructor(o,n,T,t,S="btree"){this.config={name:t,columns:o,unique:n,only:T,method:S}}concurrently(){return this.config.concurrently=!0,this}with(o){return this.config.with=o,this}where(o){return this.config.where=o,this}build(o){return new zJ(this.config,o)}}class zJ{static[k]="PgIndex";config;constructor(o,n){this.config={...o,table:n}}}function Ny(o){return new GJ(!0,o)}class by{constructor(o){this.query=o}authToken;getQuery(){return this.query}mapResult(o,n){return o}setToken(o){return this.authToken=o,this}static[k]="PgPreparedQuery";joinsNotNullableMap}class hy{constructor(o){this.dialect=o}static[k]="PgSession";execute(o,n){return Wo.startActiveSpan("drizzle.operation",()=>{return Wo.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery(o),void 0,void 0,!1)}).setToken(n).execute(void 0,n)})}all(o){return this.prepareQuery(this.dialect.sqlToQuery(o),void 0,void 0,!1).all()}async count(o,n){let T=await this.execute(o,n);return Number(T[0].count)}}class xy extends qt{constructor(o,n,T,t=0){super(o,n,T);this.schema=T,this.nestedIndex=t}static[k]="PgTransaction";rollback(){throw new af}getTransactionConfigSQL(o){let n=[];if(o.isolationLevel)n.push(`isolation level ${o.isolationLevel}`);if(o.accessMode)n.push(o.accessMode);if(typeof o.deferrable==="boolean")n.push(o.deferrable?"deferrable":"not deferrable");return R.raw(n.join(" "))}setTransaction(o){return this.session.execute(R`set transaction ${this.getTransactionConfigSQL(o)}`)}}class HJ extends by{constructor(o,n,T,t,S,f,y){super({sql:n,params:T});this.client=o,this.queryString=n,this.params=T,this.logger=t,this.fields=S,this._isResponseInArrayMode=f,this.customResultMapper=y}static[k]="PostgresJsPreparedQuery";async execute(o={}){return Wo.startActiveSpan("drizzle.execute",async(n)=>{let T=df(this.params,o);n?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(T)}),this.logger.logQuery(this.queryString,T);let{fields:t,queryString:S,client:f,joinsNotNullableMap:y,customResultMapper:A}=this;if(!t&&!A)return Wo.startActiveSpan("drizzle.driver.execute",()=>{return f.unsafe(S,T)});let M=await Wo.startActiveSpan("drizzle.driver.execute",()=>{return n?.setAttributes({"drizzle.query.text":S,"drizzle.query.params":JSON.stringify(T)}),f.unsafe(S,T).values()});return Wo.startActiveSpan("drizzle.mapResponse",()=>{return A?A(M):M.map((F)=>rM(t,F,y))})})}all(o={}){return Wo.startActiveSpan("drizzle.execute",async(n)=>{let T=df(this.params,o);return n?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(T)}),this.logger.logQuery(this.queryString,T),Wo.startActiveSpan("drizzle.driver.execute",()=>{return n?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(T)}),this.client.unsafe(this.queryString,T)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class Zt extends hy{constructor(o,n,T,t={}){super(n);this.client=o,this.schema=T,this.options=t,this.logger=t.logger??new oy}static[k]="PostgresJsSession";logger;prepareQuery(o,n,T,t,S){return new HJ(this.client,o.sql,o.params,this.logger,n,t,S)}query(o,n){return this.logger.logQuery(o,n),this.client.unsafe(o,n).values()}queryObjects(o,n){return this.client.unsafe(o,n)}transaction(o,n){return this.client.begin(async(T)=>{let t=new Zt(T,this.dialect,this.schema,this.options),S=new cy(this.dialect,t,this.schema);if(n)await S.setTransaction(n);return o(S)})}}class cy extends xy{constructor(o,n,T,t=0){super(o,n,T,t);this.session=n}static[k]="PostgresJsTransaction";transaction(o){return this.session.client.savepoint((n)=>{let T=new Zt(n,this.dialect,this.schema,this.session.options),t=new cy(this.dialect,T,this.schema);return o(t)})}}class mJ extends qt{static[k]="PostgresJsDatabase"}function nt(o,n={}){let T=(M)=>M;for(let M of["1184","1082","1083","1114"])o.options.parsers[M]=T,o.options.serializers[M]=T;o.options.serializers["114"]=T,o.options.serializers["3802"]=T;let t=new YT({casing:n.casing}),S;if(n.logger===!0)S=new sf;else if(n.logger!==!1)S=n.logger;let f;if(n.schema){let M=r$(n.schema,b$);f={fullSchema:n.schema,schema:M.tables,tableNamesMap:M.tableNamesMap}}let y=new Zt(o,t,f,{logger:S}),A=new mJ(t,y,f);return A.$client=o,A}function sS(...o){if(typeof o[0]==="string"){let n=sT(o[0]);return nt(n,o[1])}if(hM(o[0])){let{connection:n,client:T,...t}=o[0];if(T)return nt(T,t);if(typeof n==="object"&&n.url!==void 0){let{url:f,...y}=n,A=sT(f,y);return nt(A,t)}let S=sT(n);return nt(S,t)}return nt(o[0],o[1])}((o)=>{function n(T){return nt({options:{parsers:{},serializers:{}}},T)}o.mock=n})(sS||(sS={}));var iy={};Bk(iy,{users:()=>GT,userChanges:()=>a0,untrackedUserColumnNames:()=>u0,twoFactorMethod:()=>BJ,trackedUserColumnName:()=>VJ,trackableUserColumnNames:()=>UJ,role:()=>DJ,players:()=>vy,passwordResetAttempts:()=>oW,loginHistory:()=>s0,games:()=>of,banishedIps:()=>Pt});function QJ(o){return R`lower(${o})`}var DJ=WS("role",["admin","user"]),GT=tT("users",{id:Jn().primaryKey().defaultRandom(),username:co({length:16}).notNull(),email:co({length:254}).notNull(),hash:co({length:64}).notNull(),salt:co({length:36}).notNull(),createdAt:Qn({withTimezone:!0}).notNull().defaultNow(),createdIp:co({length:45}).notNull(),isActive:zt().notNull().default(!1),verifiedAt:Qn({withTimezone:!0}),userRole:DJ().default("user")},(o)=>[Ny("usernameUniqueIndex").on(QJ(o.username)),Ny("emailUniqueIndex").on(QJ(o.email))]),u0=["id","createdAt","createdIp","isActive","salt","verifiedAt"],UJ=["username","email","hash","userRole"],VJ=WS("trackedUserColumnName",UJ),a0=tT("userChanges",{id:Jn().primaryKey().defaultRandom(),userId:Jn().notNull().references(()=>GT.id),changedAt:Qn({withTimezone:!0}).notNull().defaultNow(),changedIp:co({length:45}).notNull(),changedColumn:VJ().notNull(),oldValue:co({length:255}),newValue:co({length:255})}),of=tT("games",{id:Jn().primaryKey().defaultRandom()}),vy=tT("players",{userId:Jn().notNull().references(()=>GT.id),gameId:Jn().notNull().references(()=>of.id),score:HS().notNull()},(o)=>[B$({name:"players_userId_gameId_pk",columns:[o.userId,o.gameId]})]),s0=tT("loginHistory",{id:Jn().primaryKey().defaultRandom(),userId:Jn().references(()=>GT.id),loginTime:Qn({withTimezone:!0}).notNull().defaultNow(),ipAddress:co({length:45}).notNull(),userAgent:co({length:1024}),successful:zt().notNull().default(!1)}),BJ=WS("twoFactorMethod",["email","phone"]),oW=tT("passwordResetAttempts",{id:Jn().primaryKey().defaultRandom(),userId:Jn().notNull().references(()=>GT.id),requestedIp:co({length:45}).notNull(),requestedAt:Qn({withTimezone:!0}).notNull().defaultNow(),succeededIp:co({length:45}),succeededAt:Qn({withTimezone:!0}),verificationMethod:BJ().notNull()}),Pt=tT("banishedIps",{ip:co({length:45}).primaryKey(),reason:co({length:2048}).notNull(),banishedAt:Qn({withTimezone:!0}).notNull().defaultNow(),banishedUntil:Qn({withTimezone:!0})});var __dirname="/home/runner/work/wayforge/wayforge/apps/tempest.games/src/database";class py{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(nW.resolve(__dirname,"notify_update.sql"));let o=[_n(GT),_n(of),_n(vy)];await this.sql`SELECT create_notify_triggers(${this.sql.array(o)})`,await this.sql.listen("table_update",(n)=>{let T=n.split(","),t=T[0],S=T[1],f=`${t}("${S}")`;if(this.observers.has(f))this.observers.get(f).next(f)})}constructor(o=!1,n={host:Cn.POSTGRES_HOST,port:Cn.POSTGRES_PORT,user:Cn.POSTGRES_USER,password:Cn.POSTGRES_PASSWORD,database:Cn.POSTGRES_DATABASE}){this.options=n,this.sql=sT(n),this.drizzle=sS(this.sql,{schema:iy,logger:o})}observe(o,n){if(!this.observers.has(o))this.observers.set(o,new s);this.observers.get(o).subscribe("SINGLETON",n)}}var nf={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},qy=tA(nf).map(([o])=>Go.literal(Number(o))),TW=Go.union([qy[0],qy[1],...qy]),CJ=Go.tuple([TW,Go.string()]);var Py=new rf,{logger:tn}=Py;Object.assign(console,tn,{log:tn.info});tn.info("ready");var Zy=IJ(import.meta.dir,"..","app"),yW=new py({logQuery(o,n){tn.info("\uD83D\uDCDD query",o,n)}});fW({hostname:"0.0.0.0",port:Cn.FRONTEND_PORT??3333,...s$??void 0,async fetch(o,n){try{let T=new Date,t=new URL(o.url),S=n.requestIP(o)?.address??"??";tn.info(T,S,o.method,t.pathname);let[f]=await yW.drizzle.select({banishedUntil:Pt.banishedUntil}).from(Pt).where(jT(Pt.ip,S)).limit(1),y=f?.banishedUntil===null,A=f?.banishedUntil&&f.banishedUntil>T;if(y||A)throw tn.info(`\uD83D\uDE45 request from banned ip ${S}`),[403,S];if(t.pathname==="/")return new Response(Bun.file(IJ(Zy,"index.html")));if(t.pathname==="/index.html")return Response.redirect("/");let M=tW(Zy,t.pathname),F=SW(M);if(!F.startsWith(Zy))throw[403,"Access Denied"];if(!await LJ(F).exists())return Response.redirect("/");return new Response(LJ(F))}catch(T){let t=CJ.safeParse(T);if(t.success){let[S,f]=t.data,A=`${nf[S]}. ${f}`;return tn.info(`\u274C ${S}: ${A}`),new Response(A,{status:S})}if(T instanceof Error)tn.error(T.message);else{let S=BT(T);tn.error("frontend server threw",S)}return new Response(nf[500],{status:500})}}});function Tf(){tn.info("\uD83D\uDEEC frontend server exiting"),process.exit(0)}process.on("SIGINT",()=>{tn.info("\u2757 received SIGINT; exiting gracefully"),Tf()});process.on("SIGTERM",()=>{tn.info("\u2757 received SIGTERM; exiting gracefully"),Tf()});process.on("exit",()=>{tn.info("\u2757 received exit; exiting gracefully"),Tf()});Py.on("timeToStop",()=>{tn.info('\u2757 backend server received signal "timeToStop"; exiting gracefully'),Tf()});tn.info(`\uD83D\uDEEB frontend server running at http://localhost:${Cn.FRONTEND_PORT}/`);Py.emit("alive");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tempest.games",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@t3-oss/env-core": "0.11.1",
24
- "cron": "3.3.1",
24
+ "cron": "3.3.2",
25
25
  "drizzle-orm": "0.38.3",
26
26
  "openai": "4.77.0",
27
27
  "postgres": "3.4.5",
@@ -32,17 +32,17 @@
32
32
  "socket.io-client": "4.8.1",
33
33
  "zod": "3.24.1",
34
34
  "zod-to-json-schema": "3.24.1",
35
- "treetrunks": "0.0.3",
36
- "atom.io": "0.30.6"
35
+ "atom.io": "0.30.6",
36
+ "treetrunks": "0.0.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@eslint/js": "9.17.0",
40
- "@types/node": "22.10.2",
40
+ "@types/node": "22.10.4",
41
41
  "@types/react": "19.0.2",
42
42
  "@types/react-dom": "19.0.2",
43
43
  "@vitejs/plugin-react-swc": "3.7.2",
44
44
  "bun-types": "1.1.42",
45
- "concurrently": "9.1.1",
45
+ "concurrently": "9.1.2",
46
46
  "cross-env": "7.0.3",
47
47
  "dotenv": "16.4.7",
48
48
  "dotenv-cli": "8.0.0",
@@ -54,8 +54,8 @@
54
54
  "sass-embedded": "1.83.0",
55
55
  "tsx": "4.19.2",
56
56
  "typescript": "5.7.2",
57
- "typescript-eslint": "8.18.2",
58
- "vite": "6.0.6",
57
+ "typescript-eslint": "8.19.0",
58
+ "vite": "6.0.7",
59
59
  "vite-tsconfig-paths": "5.1.4",
60
60
  "vitest": "3.0.0-beta.3",
61
61
  "varmint": "0.3.4"