@gadgetinc/ggt 1.7.0 → 1.7.2

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.
Files changed (42) hide show
  1. package/dist/{add-623ZJFNZ.js → add-BIKODQCS.js} +2 -2
  2. package/dist/{add-623ZJFNZ.js.map → add-BIKODQCS.js.map} +1 -1
  3. package/dist/{chunk-7VB3L2XK.js → chunk-D2R4J557.js} +4 -4
  4. package/dist/{chunk-7VB3L2XK.js.map → chunk-D2R4J557.js.map} +1 -1
  5. package/dist/{chunk-T3XUROKS.js → chunk-FGUWID6B.js} +2 -2
  6. package/dist/{chunk-5AMZWMRB.js → chunk-MBWB2XUY.js} +2 -2
  7. package/dist/{chunk-RV4YYWDE.js → chunk-VJTDX5WL.js} +2 -2
  8. package/dist/{chunk-RV4YYWDE.js.map → chunk-VJTDX5WL.js.map} +1 -1
  9. package/dist/chunk-XQWSZW7K.js +66 -0
  10. package/dist/chunk-XQWSZW7K.js.map +7 -0
  11. package/dist/{deploy-4AVZFDZ4.js → deploy-3H3W42UM.js} +2 -2
  12. package/dist/{deploy-4AVZFDZ4.js.map → deploy-3H3W42UM.js.map} +1 -1
  13. package/dist/{dev-RHG4RVQG.js → dev-O5KGPP2V.js} +2 -2
  14. package/dist/{dev-RHG4RVQG.js.map → dev-O5KGPP2V.js.map} +1 -1
  15. package/dist/list-O5JTZNKN.js +11 -0
  16. package/dist/{list-YXCTVLRH.js.map → list-O5JTZNKN.js.map} +1 -1
  17. package/dist/login-6MLYS6A4.js +2 -0
  18. package/dist/{logs-DMHPRDXZ.js → logs-SS34WQ2K.js} +2 -2
  19. package/dist/{logs-DMHPRDXZ.js.map → logs-SS34WQ2K.js.map} +1 -1
  20. package/dist/main.js +1 -1
  21. package/dist/{open-CYXBST4H.js → open-JQTW6XFM.js} +2 -2
  22. package/dist/{open-CYXBST4H.js.map → open-JQTW6XFM.js.map} +1 -1
  23. package/dist/{pull-57RYWYNZ.js → pull-5HLV3C74.js} +2 -2
  24. package/dist/{pull-57RYWYNZ.js.map → pull-5HLV3C74.js.map} +1 -1
  25. package/dist/push-62ZJ6D3R.js +2 -0
  26. package/dist/{status-C3VTFX7J.js → status-PL7MJVN7.js} +2 -2
  27. package/dist/{status-C3VTFX7J.js.map → status-PL7MJVN7.js.map} +1 -1
  28. package/dist/whoami-3RPUP2PK.js +7 -0
  29. package/dist/{whoami-AA3ISE77.js.map → whoami-3RPUP2PK.js.map} +1 -1
  30. package/package.json +3 -1
  31. package/dist/chunk-FILWLZUN.js +0 -18
  32. package/dist/chunk-FILWLZUN.js.map +0 -7
  33. package/dist/chunk-GCO2TOVZ.js +0 -50
  34. package/dist/chunk-GCO2TOVZ.js.map +0 -7
  35. package/dist/list-YXCTVLRH.js +0 -11
  36. package/dist/login-XIEASAMY.js +0 -2
  37. package/dist/push-464T6F4H.js +0 -2
  38. package/dist/whoami-AA3ISE77.js +0 -7
  39. /package/dist/{chunk-T3XUROKS.js.map → chunk-FGUWID6B.js.map} +0 -0
  40. /package/dist/{chunk-5AMZWMRB.js.map → chunk-MBWB2XUY.js.map} +0 -0
  41. /package/dist/{login-XIEASAMY.js.map → login-6MLYS6A4.js.map} +0 -0
  42. /package/dist/{push-464T6F4H.js.map → push-62ZJ6D3R.js.map} +0 -0
@@ -0,0 +1,66 @@
1
+ import{a as Mn,b as Je,c as Dn}from"./chunk-DYAWQS24.js";import{a as Cn,b as Bn,c as Un}from"./chunk-XGQQOMPO.js";import{K as Ye,L as Pn,N as dr,O as le,P as Nn,Q as Ke,U as ae,V as In,W as G,X as Rn,Z as R,a as Tn,b as Me,ba as pr,c as On,ca as De,d as we,e as $,f as kn,g as Bt,h as Qe,ha as ne,i as cr,ia as Ue,j as lr,ja as fe,k as ur,l as fr,n as hr,p as $n,x as Ln,y as An}from"./chunk-24OT7GHO.js";import{a as Rt}from"./chunk-GFQYFEEH.js";import{a as o,b as j,d as B,f as Z,h}from"./chunk-7DYQUG5M.js";var ti=B((mu,gt)=>{"use strict";h();var jt={decodeValues:!0,map:!1,silent:!1};function Tr(e){return typeof e=="string"&&!!e.trim()}o(Tr,"isNonEmptyString");function Or(e,t){var r=e.split(";").filter(Tr),n=r.shift(),i=Yo(n),s=i.name,a=i.value;t=t?Object.assign({},jt,t):jt;try{a=t.decodeValues?decodeURIComponent(a):a}catch(c){console.error("set-cookie-parser encountered an error while decoding a cookie with value '"+a+"'. Set options.decodeValues to false to disable this feature.",c)}var l={name:s,value:a};return r.forEach(function(c){var f=c.split("="),d=f.shift().trimLeft().toLowerCase(),p=f.join("=");d==="expires"?l.expires=new Date(p):d==="max-age"?l.maxAge=parseInt(p,10):d==="secure"?l.secure=!0:d==="httponly"?l.httpOnly=!0:d==="samesite"?l.sameSite=p:d==="partitioned"?l.partitioned=!0:l[d]=p}),l}o(Or,"parseString");function Yo(e){var t="",r="",n=e.split("=");return n.length>1?(t=n.shift(),r=n.join("=")):r=e,{name:t,value:r}}o(Yo,"parseNameValuePair");function ei(e,t){if(t=t?Object.assign({},jt,t):jt,!e)return t.map?{}:[];if(e.headers)if(typeof e.headers.getSetCookie=="function")e=e.headers.getSetCookie();else if(e.headers["set-cookie"])e=e.headers["set-cookie"];else{var r=e.headers[Object.keys(e.headers).find(function(i){return i.toLowerCase()==="set-cookie"})];!r&&e.headers.cookie&&!t.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),e=r}if(Array.isArray(e)||(e=[e]),t.map){var n={};return e.filter(Tr).reduce(function(i,s){var a=Or(s,t);return i[a.name]=a,i},n)}else return e.filter(Tr).map(function(i){return Or(i,t)})}o(ei,"parse");function Ko(e){if(Array.isArray(e))return e;if(typeof e!="string")return[];var t=[],r=0,n,i,s,a,l;function c(){for(;r<e.length&&/\s/.test(e.charAt(r));)r+=1;return r<e.length}o(c,"skipWhitespace");function f(){return i=e.charAt(r),i!=="="&&i!==";"&&i!==","}for(o(f,"notSpecialChar");r<e.length;){for(n=r,l=!1;c();)if(i=e.charAt(r),i===","){for(s=r,r+=1,c(),a=r;r<e.length&&f();)r+=1;r<e.length&&e.charAt(r)==="="?(l=!0,r=a,t.push(e.substring(n,s)),n=r):r=s+1}else r+=1;(!l||r>=e.length)&&t.push(e.substring(n,e.length))}return t}o(Ko,"splitCookiesString");gt.exports=ei;gt.exports.parse=ei;gt.exports.parseString=Or;gt.exports.splitCookiesString=Ko});var ui=B((kr,$r)=>{h();(function(e,t){typeof kr=="object"&&typeof $r<"u"?$r.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs=t()})(kr,function(){"use strict";var e=1e3,t=6e4,r=36e5,n="millisecond",i="second",s="minute",a="hour",l="day",c="week",f="month",d="quarter",p="year",y="date",u="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,w=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,T={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:o(function(O){var E=["th","st","nd","rd"],v=O%100;return"["+O+(E[(v-20)%10]||E[v]||E[0])+"]"},"ordinal")},P=o(function(O,E,v){var b=String(O);return!b||b.length>=E?O:""+Array(E+1-b.length).join(v)+O},"m"),D={s:P,z:o(function(O){var E=-O.utcOffset(),v=Math.abs(E),b=Math.floor(v/60),g=v%60;return(E<=0?"+":"-")+P(b,2,"0")+":"+P(g,2,"0")},"z"),m:o(function O(E,v){if(E.date()<v.date())return-O(v,E);var b=12*(v.year()-E.year())+(v.month()-E.month()),g=E.clone().add(b,f),_=v-g<0,x=E.clone().add(b+(_?-1:1),f);return+(-(b+(v-g)/(_?g-x:x-g))||0)},"t"),a:o(function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},"a"),p:o(function(O){return{M:f,y:p,w:c,d:l,D:y,h:a,m:s,s:i,ms:n,Q:d}[O]||String(O||"").toLowerCase().replace(/s$/,"")},"p"),u:o(function(O){return O===void 0},"u")},Q="en",k={};k[Q]=T;var z="$isDayjsObject",Y=o(function(O){return O instanceof te||!(!O||!O[z])},"S"),W=o(function O(E,v,b){var g;if(!E)return Q;if(typeof E=="string"){var _=E.toLowerCase();k[_]&&(g=_),v&&(k[_]=v,g=_);var x=E.split("-");if(!g&&x.length>1)return O(x[0])}else{var S=E.name;k[S]=E,g=S}return!b&&g&&(Q=g),g||!b&&Q},"t"),I=o(function(O,E){if(Y(O))return O.clone();var v=typeof E=="object"?E:{};return v.date=O,v.args=arguments,new te(v)},"O"),L=D;L.l=W,L.i=Y,L.w=function(O,E){return I(O,{locale:E.$L,utc:E.$u,x:E.$x,$offset:E.$offset})};var te=function(){function O(v){this.$L=W(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[z]=!0}o(O,"M");var E=O.prototype;return E.parse=function(v){this.$d=function(b){var g=b.date,_=b.utc;if(g===null)return new Date(NaN);if(L.u(g))return new Date;if(g instanceof Date)return new Date(g);if(typeof g=="string"&&!/Z$/i.test(g)){var x=g.match(m);if(x){var S=x[2]-1||0,N=(x[7]||"0").substring(0,3);return _?new Date(Date.UTC(x[1],S,x[3]||1,x[4]||0,x[5]||0,x[6]||0,N)):new Date(x[1],S,x[3]||1,x[4]||0,x[5]||0,x[6]||0,N)}}return new Date(g)}(v),this.init()},E.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},E.$utils=function(){return L},E.isValid=function(){return this.$d.toString()!==u},E.isSame=function(v,b){var g=I(v);return this.startOf(b)<=g&&g<=this.endOf(b)},E.isAfter=function(v,b){return I(v)<this.startOf(b)},E.isBefore=function(v,b){return this.endOf(b)<I(v)},E.$g=function(v,b,g){return L.u(v)?this[b]:this.set(g,v)},E.unix=function(){return Math.floor(this.valueOf()/1e3)},E.valueOf=function(){return this.$d.getTime()},E.startOf=function(v,b){var g=this,_=!!L.u(b)||b,x=L.p(v),S=o(function(F,re){var _e=L.w(g.$u?Date.UTC(g.$y,re,F):new Date(g.$y,re,F),g);return _?_e:_e.endOf(l)},"l"),N=o(function(F,re){return L.w(g.toDate()[F].apply(g.toDate("s"),(_?[0,0,0,0]:[23,59,59,999]).slice(re)),g)},"$"),C=this.$W,U=this.$M,K=this.$D,me="set"+(this.$u?"UTC":"");switch(x){case p:return _?S(1,0):S(31,11);case f:return _?S(1,U):S(0,U+1);case c:var oe=this.$locale().weekStart||0,V=(C<oe?C+7:C)-oe;return S(_?K-V:K+(6-V),U);case l:case y:return N(me+"Hours",0);case a:return N(me+"Minutes",1);case s:return N(me+"Seconds",2);case i:return N(me+"Milliseconds",3);default:return this.clone()}},E.endOf=function(v){return this.startOf(v,!1)},E.$set=function(v,b){var g,_=L.p(v),x="set"+(this.$u?"UTC":""),S=(g={},g[l]=x+"Date",g[y]=x+"Date",g[f]=x+"Month",g[p]=x+"FullYear",g[a]=x+"Hours",g[s]=x+"Minutes",g[i]=x+"Seconds",g[n]=x+"Milliseconds",g)[_],N=_===l?this.$D+(b-this.$W):b;if(_===f||_===p){var C=this.clone().set(y,1);C.$d[S](N),C.init(),this.$d=C.set(y,Math.min(this.$D,C.daysInMonth())).$d}else S&&this.$d[S](N);return this.init(),this},E.set=function(v,b){return this.clone().$set(v,b)},E.get=function(v){return this[L.p(v)]()},E.add=function(v,b){var g,_=this;v=Number(v);var x=L.p(b),S=o(function(U){var K=I(_);return L.w(K.date(K.date()+Math.round(U*v)),_)},"y");if(x===f)return this.set(f,this.$M+v);if(x===p)return this.set(p,this.$y+v);if(x===l)return S(1);if(x===c)return S(7);var N=(g={},g[s]=t,g[a]=r,g[i]=e,g)[x]||1,C=this.$d.getTime()+v*N;return L.w(C,this)},E.subtract=function(v,b){return this.add(-1*v,b)},E.format=function(v){var b=this,g=this.$locale();if(!this.isValid())return g.invalidDate||u;var _=v||"YYYY-MM-DDTHH:mm:ssZ",x=L.z(this),S=this.$H,N=this.$m,C=this.$M,U=g.weekdays,K=g.months,me=g.meridiem,oe=o(function(re,_e,pt,It){return re&&(re[_e]||re(b,_))||pt[_e].slice(0,It)},"h"),V=o(function(re){return L.s(S%12||12,re,"0")},"d"),F=me||function(re,_e,pt){var It=re<12?"AM":"PM";return pt?It.toLowerCase():It};return _.replace(w,function(re,_e){return _e||function(pt){switch(pt){case"YY":return String(b.$y).slice(-2);case"YYYY":return L.s(b.$y,4,"0");case"M":return C+1;case"MM":return L.s(C+1,2,"0");case"MMM":return oe(g.monthsShort,C,K,3);case"MMMM":return oe(K,C);case"D":return b.$D;case"DD":return L.s(b.$D,2,"0");case"d":return String(b.$W);case"dd":return oe(g.weekdaysMin,b.$W,U,2);case"ddd":return oe(g.weekdaysShort,b.$W,U,3);case"dddd":return U[b.$W];case"H":return String(S);case"HH":return L.s(S,2,"0");case"h":return V(1);case"hh":return V(2);case"a":return F(S,N,!0);case"A":return F(S,N,!1);case"m":return String(N);case"mm":return L.s(N,2,"0");case"s":return String(b.$s);case"ss":return L.s(b.$s,2,"0");case"SSS":return L.s(b.$ms,3,"0");case"Z":return x}return null}(re)||x.replace(":","")})},E.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},E.diff=function(v,b,g){var _,x=this,S=L.p(b),N=I(v),C=(N.utcOffset()-this.utcOffset())*t,U=this-N,K=o(function(){return L.m(x,N)},"D");switch(S){case p:_=K()/12;break;case f:_=K();break;case d:_=K()/3;break;case c:_=(U-C)/6048e5;break;case l:_=(U-C)/864e5;break;case a:_=U/r;break;case s:_=U/t;break;case i:_=U/e;break;default:_=U}return g?_:L.a(_)},E.daysInMonth=function(){return this.endOf(f).$D},E.$locale=function(){return k[this.$L]},E.locale=function(v,b){if(!v)return this.$L;var g=this.clone(),_=W(v,b,!0);return _&&(g.$L=_),g},E.clone=function(){return L.w(this.$d,this)},E.toDate=function(){return new Date(this.valueOf())},E.toJSON=function(){return this.isValid()?this.toISOString():null},E.toISOString=function(){return this.$d.toISOString()},E.toString=function(){return this.$d.toUTCString()},O}(),dt=te.prototype;return I.prototype=dt,[["$ms",n],["$s",i],["$m",s],["$H",a],["$W",l],["$M",f],["$y",p],["$D",y]].forEach(function(O){dt[O[1]]=function(E){return this.$g(E,O[0],O[1])}}),I.extend=function(O,E){return O.$i||(O(E,te,I),O.$i=!0),I},I.locale=W,I.isDayjs=Y,I.unix=function(O){return I(1e3*O)},I.en=k[Q],I.Ls=k,I.p={},I})});var Lr=B((Iu,fi)=>{"use strict";h();fi.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}});var pi=B((Bu,di)=>{"use strict";h();var Jo=j("os"),hi=j("tty"),he=Lr(),{env:J}=process,Ae;he("no-color")||he("no-colors")||he("color=false")||he("color=never")?Ae=0:(he("color")||he("colors")||he("color=true")||he("color=always"))&&(Ae=1);"FORCE_COLOR"in J&&(J.FORCE_COLOR==="true"?Ae=1:J.FORCE_COLOR==="false"?Ae=0:Ae=J.FORCE_COLOR.length===0?1:Math.min(parseInt(J.FORCE_COLOR,10),3));function Ar(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}o(Ar,"translateLevel");function Pr(e,t){if(Ae===0)return 0;if(he("color=16m")||he("color=full")||he("color=truecolor"))return 3;if(he("color=256"))return 2;if(e&&!t&&Ae===void 0)return 0;let r=Ae||0;if(J.TERM==="dumb")return r;if(process.platform==="win32"){let n=Jo.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in J)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in J)||J.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in J)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(J.TEAMCITY_VERSION)?1:0;if(J.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in J){let n=parseInt((J.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(J.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(J.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(J.TERM)||"COLORTERM"in J?1:r}o(Pr,"supportsColor");function Xo(e){let t=Pr(e,e&&e.isTTY);return Ar(t)}o(Xo,"getSupportLevel");di.exports={supportsColor:Xo,stdout:Ar(Pr(!0,hi.isatty(1))),stderr:Ar(Pr(!0,hi.isatty(2)))}});var yi=B((Uu,gi)=>{"use strict";h();var Zo=pi(),tt=Lr();function mi(e){if(/^\d{3,4}$/.test(e)){let r=/(\d{1,2})(\d{2})/.exec(e)||[];return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let t=(e||"").split(".").map(r=>parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}o(mi,"parseVersion");function Nr(e){let{CI:t,FORCE_HYPERLINK:r,NETLIFY:n,TEAMCITY_VERSION:i,TERM_PROGRAM:s,TERM_PROGRAM_VERSION:a,VTE_VERSION:l,TERM:c}=process.env;if(r)return!(r.length>0&&parseInt(r,10)===0);if(tt("no-hyperlink")||tt("no-hyperlinks")||tt("hyperlink=false")||tt("hyperlink=never"))return!1;if(tt("hyperlink=true")||tt("hyperlink=always")||n)return!0;if(!Zo.supportsColor(e)||e&&!e.isTTY)return!1;if("WT_SESSION"in process.env)return!0;if(process.platform==="win32"||t||i)return!1;if(s){let f=mi(a||"");switch(s){case"iTerm.app":return f.major===3?f.minor>=1:f.major>3;case"WezTerm":return f.major>=20200620;case"vscode":return f.major>1||f.major===1&&f.minor>=72;case"ghostty":return!0}}if(l){if(l==="0.50.0")return!1;let f=mi(l);return f.major>0||f.minor>=50}switch(c){case"alacritty":return!0}return!1}o(Nr,"supportsHyperlink");gi.exports={supportsHyperlink:Nr,stdout:Nr(process.stdout),stderr:Nr(process.stderr)}});var Si=B((of,Br)=>{"use strict";h();var na=Object.prototype.hasOwnProperty,se="~";function yt(){}o(yt,"Events");Object.create&&(yt.prototype=Object.create(null),new yt().__proto__||(se=!1));function ia(e,t,r){this.fn=e,this.context=t,this.once=r||!1}o(ia,"EE");function Ei(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new ia(r,n||e,i),a=se?se+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],s]:e._events[a].push(s):(e._events[a]=s,e._eventsCount++),e}o(Ei,"addListener");function Wt(e,t){--e._eventsCount===0?e._events=new yt:delete e._events[t]}o(Wt,"clearEvent");function ee(){this._events=new yt,this._eventsCount=0}o(ee,"EventEmitter");ee.prototype.eventNames=o(function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)na.call(r,n)&&t.push(se?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t},"eventNames");ee.prototype.listeners=o(function(t){var r=se?se+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a},"listeners");ee.prototype.listenerCount=o(function(t){var r=se?se+t:t,n=this._events[r];return n?n.fn?1:n.length:0},"listenerCount");ee.prototype.emit=o(function(t,r,n,i,s,a){var l=se?se+t:t;if(!this._events[l])return!1;var c=this._events[l],f=arguments.length,d,p;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,s),!0;case 6:return c.fn.call(c.context,r,n,i,s,a),!0}for(p=1,d=new Array(f-1);p<f;p++)d[p-1]=arguments[p];c.fn.apply(c.context,d)}else{var y=c.length,u;for(p=0;p<y;p++)switch(c[p].once&&this.removeListener(t,c[p].fn,void 0,!0),f){case 1:c[p].fn.call(c[p].context);break;case 2:c[p].fn.call(c[p].context,r);break;case 3:c[p].fn.call(c[p].context,r,n);break;case 4:c[p].fn.call(c[p].context,r,n,i);break;default:if(!d)for(u=1,d=new Array(f-1);u<f;u++)d[u-1]=arguments[u];c[p].fn.apply(c[p].context,d)}}return!0},"emit");ee.prototype.on=o(function(t,r,n){return Ei(this,t,r,n,!1)},"on");ee.prototype.once=o(function(t,r,n){return Ei(this,t,r,n,!0)},"once");ee.prototype.removeListener=o(function(t,r,n,i){var s=se?se+t:t;if(!this._events[s])return this;if(!r)return Wt(this,s),this;var a=this._events[s];if(a.fn)a.fn===r&&(!i||a.once)&&(!n||a.context===n)&&Wt(this,s);else{for(var l=0,c=[],f=a.length;l<f;l++)(a[l].fn!==r||i&&!a[l].once||n&&a[l].context!==n)&&c.push(a[l]);c.length?this._events[s]=c.length===1?c[0]:c:Wt(this,s)}return this},"removeListener");ee.prototype.removeAllListeners=o(function(t){var r;return t?(r=se?se+t:t,this._events[r]&&Wt(this,r)):(this._events=new yt,this._eventsCount=0),this},"removeAllListeners");ee.prototype.off=ee.prototype.removeListener;ee.prototype.addListener=ee.prototype.on;ee.prefixed=se;ee.EventEmitter=ee;typeof Br<"u"&&(Br.exports=ee)});var Li=B((Cf,$i)=>{"use strict";h();var{Duplex:sa}=j("stream");function Ci(e){e.emit("close")}o(Ci,"emitClose");function oa(){!this.destroyed&&this._writableState.finished&&this.destroy()}o(oa,"duplexOnEnd");function ki(e){this.removeListener("error",ki),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}o(ki,"duplexOnError");function aa(e,t){let r=!0,n=new sa({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",o(function(s,a){let l=!a&&n._readableState.objectMode?s.toString():s;n.push(l)||e.pause()},"message")),e.once("error",o(function(s){n.destroyed||(r=!1,n.destroy(s))},"error")),e.once("close",o(function(){n.destroyed||n.push(null)},"close")),n._destroy=function(i,s){if(e.readyState===e.CLOSED){s(i),process.nextTick(Ci,n);return}let a=!1;e.once("error",o(function(c){a=!0,s(c)},"error")),e.once("close",o(function(){a||s(i),process.nextTick(Ci,n)},"close")),r&&e.terminate()},n._final=function(i){if(e.readyState===e.CONNECTING){e.once("open",o(function(){n._final(i)},"open"));return}e._socket!==null&&(e._socket._writableState.finished?(i(),n._readableState.endEmitted&&n.destroy()):(e._socket.once("finish",o(function(){i()},"finish")),e.close()))},n._read=function(){e.isPaused&&e.resume()},n._write=function(i,s,a){if(e.readyState===e.CONNECTING){e.once("open",o(function(){n._write(i,s,a)},"open"));return}e.send(i,a)},n.on("end",oa),n.on("error",ki),n}o(aa,"createWebSocketStream");$i.exports=aa});var Se=B((Lf,Ni)=>{"use strict";h();var Ai=["nodebuffer","arraybuffer","fragments"],Pi=typeof Blob<"u";Pi&&Ai.push("blob");Ni.exports={BINARY_TYPES:Ai,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Pi,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:o(()=>{},"NOOP")}});var vt=B((Nf,zt)=>{"use strict";h();var{EMPTY_BUFFER:ca}=Se(),jr=Buffer[Symbol.species];function la(e,t){if(e.length===0)return ca;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let i=0;i<e.length;i++){let s=e[i];r.set(s,n),n+=s.length}return n<t?new jr(r.buffer,r.byteOffset,n):r}o(la,"concat");function Ii(e,t,r,n,i){for(let s=0;s<i;s++)r[n+s]=e[s]^t[s&3]}o(Ii,"_mask");function Ri(e,t){for(let r=0;r<e.length;r++)e[r]^=t[r&3]}o(Ri,"_unmask");function ua(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}o(ua,"toArrayBuffer");function Gr(e){if(Gr.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new jr(e):ArrayBuffer.isView(e)?t=new jr(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Gr.readOnly=!1),t}o(Gr,"toBuffer");zt.exports={concat:la,mask:Ii,toArrayBuffer:ua,toBuffer:Gr,unmask:Ri};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=j("bufferutil");zt.exports.mask=function(t,r,n,i,s){s<48?Ii(t,r,n,i,s):e.mask(t,r,n,i,s)},zt.exports.unmask=function(t,r){t.length<32?Ri(t,r):e.unmask(t,r)}}catch{}});var Di=B((Bf,Mi)=>{"use strict";h();var Bi=Symbol("kDone"),qr=Symbol("kRun"),Wr=class{static{o(this,"Limiter")}constructor(t){this[Bi]=()=>{this.pending--,this[qr]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[qr]()}[qr](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[Bi])}}};Mi.exports=Wr});var St=B((Uf,Gi)=>{"use strict";h();var wt=j("zlib"),Ui=vt(),fa=Di(),{kStatusCode:Fi}=Se(),ha=Buffer[Symbol.species],da=Buffer.from([0,0,255,255]),Qt=Symbol("permessage-deflate"),Te=Symbol("total-length"),Et=Symbol("callback"),Pe=Symbol("buffers"),Ht=Symbol("error"),Vt,zr=class{static{o(this,"PerMessageDeflate")}constructor(t,r,n){if(this._maxPayload=n|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!Vt){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Vt=new fa(i)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[Et];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let r=this._options,n=t.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(t){let r=t[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(t){return t.forEach(r=>{Object.keys(r).forEach(n=>{let i=r[n];if(i.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(i=i[0],n==="client_max_window_bits"){if(i!==!0){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else if(n==="server_max_window_bits"){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=s}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=i})}),t}decompress(t,r,n){Vt.add(i=>{this._decompress(t,r,(s,a)=>{i(),n(s,a)})})}compress(t,r,n){Vt.add(i=>{this._compress(t,r,(s,a)=>{i(),n(s,a)})})}_decompress(t,r,n){let i=this._isServer?"client":"server";if(!this._inflate){let s=`${i}_max_window_bits`,a=typeof this.params[s]!="number"?wt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=wt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Qt]=this,this._inflate[Te]=0,this._inflate[Pe]=[],this._inflate.on("error",ma),this._inflate.on("data",ji)}this._inflate[Et]=n,this._inflate.write(t),r&&this._inflate.write(da),this._inflate.flush(()=>{let s=this._inflate[Ht];if(s){this._inflate.close(),this._inflate=null,n(s);return}let a=Ui.concat(this._inflate[Pe],this._inflate[Te]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Te]=0,this._inflate[Pe]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,a)})}_compress(t,r,n){let i=this._isServer?"server":"client";if(!this._deflate){let s=`${i}_max_window_bits`,a=typeof this.params[s]!="number"?wt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=wt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Te]=0,this._deflate[Pe]=[],this._deflate.on("data",pa)}this._deflate[Et]=n,this._deflate.write(t),this._deflate.flush(wt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ui.concat(this._deflate[Pe],this._deflate[Te]);r&&(s=new ha(s.buffer,s.byteOffset,s.length-4)),this._deflate[Et]=null,this._deflate[Te]=0,this._deflate[Pe]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,s)})}};Gi.exports=zr;function pa(e){this[Pe].push(e),this[Te]+=e.length}o(pa,"deflateOnData");function ji(e){if(this[Te]+=e.length,this[Qt]._maxPayload<1||this[Te]<=this[Qt]._maxPayload){this[Pe].push(e);return}this[Ht]=new RangeError("Max payload size exceeded"),this[Ht].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ht][Fi]=1009,this.removeListener("data",ji),this.reset()}o(ji,"inflateOnData");function ma(e){this[Qt]._inflate=null,e[Fi]=1007,this[Et](e)}o(ma,"inflateOnError")});var it=B((Gf,Yt)=>{"use strict";h();var{isUtf8:qi}=j("buffer"),{hasBlob:ga}=Se(),ya=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function ba(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}o(ba,"isValidStatusCode");function Vr(e){let t=e.length,r=0;for(;r<t;)if((e[r]&128)===0)r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return!1;r+=2}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return!1;r+=3}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return!1;r+=4}else return!1;return!0}o(Vr,"_isValidUTF8");function _a(e){return ga&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}o(_a,"isBlob");Yt.exports={isBlob:_a,isValidStatusCode:ba,isValidUTF8:Vr,tokenChars:ya};if(qi)Yt.exports.isValidUTF8=function(e){return e.length<24?Vr(e):qi(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=j("utf-8-validate");Yt.exports.isValidUTF8=function(t){return t.length<32?Vr(t):e(t)}}catch{}});var Jr=B((zf,Ki)=>{"use strict";h();var{Writable:xa}=j("stream"),Wi=St(),{BINARY_TYPES:va,EMPTY_BUFFER:zi,kStatusCode:wa,kWebSocket:Ea}=Se(),{concat:Hr,toArrayBuffer:Sa,unmask:Ta}=vt(),{isValidStatusCode:Oa,isValidUTF8:Vi}=it(),Kt=Buffer[Symbol.species],de=0,Hi=1,Qi=2,Yi=3,Qr=4,Yr=5,Jt=6,Kr=class extends xa{static{o(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||va[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[Ea]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=de}_write(t,r,n){if(this._opcode===8&&this._state==de)return n();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(n)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new Kt(n.buffer,n.byteOffset+t,n.length-t),new Kt(n.buffer,n.byteOffset,t)}let r=Buffer.allocUnsafe(t);do{let n=this._buffers[0],i=r.length-t;t>=n.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(n.buffer,n.byteOffset,t),i),this._buffers[0]=new Kt(n.buffer,n.byteOffset+t,n.length-t)),t-=n.length}while(t>0);return r}startLoop(t){this._loop=!0;do switch(this._state){case de:this.getInfo(t);break;case Hi:this.getPayloadLength16(t);break;case Qi:this.getPayloadLength64(t);break;case Yi:this.getMask();break;case Qr:this.getData(t);break;case Yr:case Jt:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(i);return}let n=(r[0]&64)===64;if(n&&!this._extensions[Wi.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(i);return}if(n){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(i);return}this._payloadLength===126?this._state=Hi:this._payloadLength===127?this._state=Qi:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(i);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(r);return}this._masked?this._state=Yi:this._state=Qr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Qr}getData(t){let r=zi;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Ta(r,this._mask)}if(this._opcode>7){this.controlMessage(r,t);return}if(this._compressed){this._state=Yr,this.decompress(r,t);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(t)}decompress(t,r){this._extensions[Wi.extensionName].decompress(t,this._fin,(i,s)=>{if(i)return r(i);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(a);return}this._fragments.push(s)}this.dataMessage(r),this._state===de&&this.startLoop(r)})}dataMessage(t){if(!this._fin){this._state=de;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Hr(n,r):this._binaryType==="arraybuffer"?i=Sa(Hr(n,r)):this._binaryType==="blob"?i=new Blob(n):i=n,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=de):(this._state=Jt,setImmediate(()=>{this.emit("message",i,!0),this._state=de,this.startLoop(t)}))}else{let i=Hr(n,r);if(!this._skipUTF8Validation&&!Vi(i)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._state===Yr||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=de):(this._state=Jt,setImmediate(()=>{this.emit("message",i,!1),this._state=de,this.startLoop(t)}))}}controlMessage(t,r){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,zi),this.end();else{let n=t.readUInt16BE(0);if(!Oa(n)){let s=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let i=new Kt(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!Vi(i)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(s);return}this._loop=!1,this.emit("conclude",n,i),this.end()}this._state=de;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=de):(this._state=Jt,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=de,this.startLoop(r)}))}createError(t,r,n,i,s){this._loop=!1,this._errored=!0;let a=new t(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(a,this.createError),a.code=s,a[wa]=i,a}};Ki.exports=Kr});var en=B((Yf,Zi)=>{"use strict";h();var{Duplex:Qf}=j("stream"),{randomFillSync:Ca}=j("crypto"),Ji=St(),{EMPTY_BUFFER:ka,kWebSocket:$a,NOOP:La}=Se(),{isBlob:st,isValidStatusCode:Aa}=it(),{mask:Xi,toBuffer:Ge}=vt(),pe=Symbol("kByteLength"),Pa=Buffer.alloc(4),Xt=8*1024,qe,ot=Xt,be=0,Na=1,Ia=2,Xr=class e{static{o(this,"Sender")}constructor(t,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=be,this.onerror=La,this[$a]=void 0}static frame(t,r){let n,i=!1,s=2,a=!1;r.mask&&(n=r.maskBuffer||Pa,r.generateMask?r.generateMask(n):(ot===Xt&&(qe===void 0&&(qe=Buffer.alloc(Xt)),Ca(qe,0,Xt),ot=0),n[0]=qe[ot++],n[1]=qe[ot++],n[2]=qe[ot++],n[3]=qe[ot++]),a=(n[0]|n[1]|n[2]|n[3])===0,s=6);let l;typeof t=="string"?(!r.mask||a)&&r[pe]!==void 0?l=r[pe]:(t=Buffer.from(t),l=t.length):(l=t.length,i=r.mask&&r.readOnly&&!a);let c=l;l>=65536?(s+=8,c=127):l>125&&(s+=2,c=126);let f=Buffer.allocUnsafe(i?l+s:s);return f[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(f[0]|=64),f[1]=c,c===126?f.writeUInt16BE(l,2):c===127&&(f[2]=f[3]=0,f.writeUIntBE(l,4,6)),r.mask?(f[1]|=128,f[s-4]=n[0],f[s-3]=n[1],f[s-2]=n[2],f[s-1]=n[3],a?[f,t]:i?(Xi(t,n,f,s,l),[f]):(Xi(t,n,t,0,l),[f,t])):[f,t]}close(t,r,n,i){let s;if(t===void 0)s=ka;else{if(typeof t!="number"||!Aa(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else{let l=Buffer.byteLength(r);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+l),s.writeUInt16BE(t,0),typeof r=="string"?s.write(r,2):s.set(r,2)}}let a={[pe]:s.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==be?this.enqueue([this.dispatch,s,!1,a,i]):this.sendFrame(e.frame(s,a),i)}ping(t,r,n){let i,s;if(typeof t=="string"?(i=Buffer.byteLength(t),s=!1):st(t)?(i=t.size,s=!1):(t=Ge(t),i=t.length,s=Ge.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[pe]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};st(t)?this._state!==be?this.enqueue([this.getBlobData,t,!1,a,n]):this.getBlobData(t,!1,a,n):this._state!==be?this.enqueue([this.dispatch,t,!1,a,n]):this.sendFrame(e.frame(t,a),n)}pong(t,r,n){let i,s;if(typeof t=="string"?(i=Buffer.byteLength(t),s=!1):st(t)?(i=t.size,s=!1):(t=Ge(t),i=t.length,s=Ge.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[pe]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};st(t)?this._state!==be?this.enqueue([this.getBlobData,t,!1,a,n]):this.getBlobData(t,!1,a,n):this._state!==be?this.enqueue([this.dispatch,t,!1,a,n]):this.sendFrame(e.frame(t,a),n)}send(t,r,n){let i=this._extensions[Ji.extensionName],s=r.binary?2:1,a=r.compress,l,c;typeof t=="string"?(l=Buffer.byteLength(t),c=!1):st(t)?(l=t.size,c=!1):(t=Ge(t),l=t.length,c=Ge.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=l>=i._threshold),this._compress=a):(a=!1,s=0),r.fin&&(this._firstFragment=!0);let f={[pe]:l,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:a};st(t)?this._state!==be?this.enqueue([this.getBlobData,t,this._compress,f,n]):this.getBlobData(t,this._compress,f,n):this._state!==be?this.enqueue([this.dispatch,t,this._compress,f,n]):this.dispatch(t,this._compress,f,n)}getBlobData(t,r,n,i){this._bufferedBytes+=n[pe],this._state=Ia,t.arrayBuffer().then(s=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(Zr,this,l,i);return}this._bufferedBytes-=n[pe];let a=Ge(s);r?this.dispatch(a,r,n,i):(this._state=be,this.sendFrame(e.frame(a,n),i),this.dequeue())}).catch(s=>{process.nextTick(Ra,this,s,i)})}dispatch(t,r,n,i){if(!r){this.sendFrame(e.frame(t,n),i);return}let s=this._extensions[Ji.extensionName];this._bufferedBytes+=n[pe],this._state=Na,s.compress(t,n.fin,(a,l)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");Zr(this,c,i);return}this._bufferedBytes-=n[pe],this._state=be,n.readOnly=!1,this.sendFrame(e.frame(l,n),i),this.dequeue()})}dequeue(){for(;this._state===be&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][pe],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][pe],this._queue.push(t)}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r)}};Zi.exports=Xr;function Zr(e,t,r){typeof r=="function"&&r(t);for(let n=0;n<e._queue.length;n++){let i=e._queue[n],s=i[i.length-1];typeof s=="function"&&s(t)}}o(Zr,"callCallbacks");function Ra(e,t,r){Zr(e,t,r),e.onerror(t)}o(Ra,"onError")});var cs=B((Xf,as)=>{"use strict";h();var{kForOnEventAttribute:Tt,kListener:tn}=Se(),es=Symbol("kCode"),ts=Symbol("kData"),rs=Symbol("kError"),ns=Symbol("kMessage"),is=Symbol("kReason"),at=Symbol("kTarget"),ss=Symbol("kType"),os=Symbol("kWasClean"),Oe=class{static{o(this,"Event")}constructor(t){this[at]=null,this[ss]=t}get target(){return this[at]}get type(){return this[ss]}};Object.defineProperty(Oe.prototype,"target",{enumerable:!0});Object.defineProperty(Oe.prototype,"type",{enumerable:!0});var We=class extends Oe{static{o(this,"CloseEvent")}constructor(t,r={}){super(t),this[es]=r.code===void 0?0:r.code,this[is]=r.reason===void 0?"":r.reason,this[os]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[es]}get reason(){return this[is]}get wasClean(){return this[os]}};Object.defineProperty(We.prototype,"code",{enumerable:!0});Object.defineProperty(We.prototype,"reason",{enumerable:!0});Object.defineProperty(We.prototype,"wasClean",{enumerable:!0});var ct=class extends Oe{static{o(this,"ErrorEvent")}constructor(t,r={}){super(t),this[rs]=r.error===void 0?null:r.error,this[ns]=r.message===void 0?"":r.message}get error(){return this[rs]}get message(){return this[ns]}};Object.defineProperty(ct.prototype,"error",{enumerable:!0});Object.defineProperty(ct.prototype,"message",{enumerable:!0});var Ot=class extends Oe{static{o(this,"MessageEvent")}constructor(t,r={}){super(t),this[ts]=r.data===void 0?null:r.data}get data(){return this[ts]}};Object.defineProperty(Ot.prototype,"data",{enumerable:!0});var Ba={addEventListener(e,t,r={}){for(let i of this.listeners(e))if(!r[Tt]&&i[tn]===t&&!i[Tt])return;let n;if(e==="message")n=o(function(s,a){let l=new Ot("message",{data:a?s:s.toString()});l[at]=this,Zt(t,this,l)},"onMessage");else if(e==="close")n=o(function(s,a){let l=new We("close",{code:s,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[at]=this,Zt(t,this,l)},"onClose");else if(e==="error")n=o(function(s){let a=new ct("error",{error:s,message:s.message});a[at]=this,Zt(t,this,a)},"onError");else if(e==="open")n=o(function(){let s=new Oe("open");s[at]=this,Zt(t,this,s)},"onOpen");else return;n[Tt]=!!r[Tt],n[tn]=t,r.once?this.once(e,n):this.on(e,n)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[tn]===t&&!r[Tt]){this.removeListener(e,r);break}}};as.exports={CloseEvent:We,ErrorEvent:ct,Event:Oe,EventTarget:Ba,MessageEvent:Ot};function Zt(e,t,r){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}o(Zt,"callListener")});var rn=B((th,ls)=>{"use strict";h();var{tokenChars:Ct}=it();function xe(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}o(xe,"push");function Ma(e){let t=Object.create(null),r=Object.create(null),n=!1,i=!1,s=!1,a,l,c=-1,f=-1,d=-1,p=0;for(;p<e.length;p++)if(f=e.charCodeAt(p),a===void 0)if(d===-1&&Ct[f]===1)c===-1&&(c=p);else if(p!==0&&(f===32||f===9))d===-1&&c!==-1&&(d=p);else if(f===59||f===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let u=e.slice(c,d);f===44?(xe(t,u,r),r=Object.create(null)):a=u,c=d=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(d===-1&&Ct[f]===1)c===-1&&(c=p);else if(f===32||f===9)d===-1&&c!==-1&&(d=p);else if(f===59||f===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p),xe(r,e.slice(c,d),!0),f===44&&(xe(t,a,r),r=Object.create(null),a=void 0),c=d=-1}else if(f===61&&c!==-1&&d===-1)l=e.slice(c,p),c=d=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(i){if(Ct[f]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:n||(n=!0),i=!1}else if(s)if(Ct[f]===1)c===-1&&(c=p);else if(f===34&&c!==-1)s=!1,d=p;else if(f===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(f===34&&e.charCodeAt(p-1)===61)s=!0;else if(d===-1&&Ct[f]===1)c===-1&&(c=p);else if(c!==-1&&(f===32||f===9))d===-1&&(d=p);else if(f===59||f===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let u=e.slice(c,d);n&&(u=u.replace(/\\/g,""),n=!1),xe(r,l,u),f===44&&(xe(t,a,r),r=Object.create(null),a=void 0),l=void 0,c=d=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(c===-1||s||f===32||f===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=p);let y=e.slice(c,d);return a===void 0?xe(t,y,r):(l===void 0?xe(r,y,!0):n?xe(r,l,y.replace(/\\/g,"")):xe(r,l,y),xe(t,a,r)),t}o(Ma,"parse");function Da(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(i=>{let s=n[i];return Array.isArray(s)||(s=[s]),s.map(a=>a===!0?i:`${i}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}o(Da,"format");ls.exports={format:Da,parse:Ma}});var cn=B((oh,vs)=>{"use strict";h();var Ua=j("events"),Fa=j("https"),ja=j("http"),hs=j("net"),Ga=j("tls"),{randomBytes:qa,createHash:Wa}=j("crypto"),{Duplex:ih,Readable:sh}=j("stream"),{URL:nn}=j("url"),Ne=St(),za=Jr(),Va=en(),{isBlob:Ha}=it(),{BINARY_TYPES:us,EMPTY_BUFFER:er,GUID:Qa,kForOnEventAttribute:sn,kListener:Ya,kStatusCode:Ka,kWebSocket:X,NOOP:ds}=Se(),{EventTarget:{addEventListener:Ja,removeEventListener:Xa}}=cs(),{format:Za,parse:ec}=rn(),{toBuffer:tc}=vt(),rc=30*1e3,ps=Symbol("kAborted"),on=[8,13],Ce=["CONNECTING","OPEN","CLOSING","CLOSED"],nc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,q=class e extends Ua{static{o(this,"WebSocket")}constructor(t,r,n){super(),this._binaryType=us[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=er,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),ms(this,t,r,n)):(this._autoPong=n.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){us.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,r,n){let i=new za({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),s=new Va(t,this._extensions,n.generateMask);this._receiver=i,this._sender=s,this._socket=t,i[X]=this,s[X]=this,t[X]=this,i.on("conclude",oc),i.on("drain",ac),i.on("error",cc),i.on("message",lc),i.on("ping",uc),i.on("pong",fc),s.onerror=hc,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",bs),t.on("data",rr),t.on("end",_s),t.on("error",xs),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ne.extensionName]&&this._extensions[Ne.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){ue(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ys(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){an(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||er,r,n)}pong(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){an(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||er,r,n)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){an(this,t,n);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Ne.extensionName]||(i.compress=!1),this._sender.send(t||er,i,n)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){ue(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(q,"CONNECTING",{enumerable:!0,value:Ce.indexOf("CONNECTING")});Object.defineProperty(q.prototype,"CONNECTING",{enumerable:!0,value:Ce.indexOf("CONNECTING")});Object.defineProperty(q,"OPEN",{enumerable:!0,value:Ce.indexOf("OPEN")});Object.defineProperty(q.prototype,"OPEN",{enumerable:!0,value:Ce.indexOf("OPEN")});Object.defineProperty(q,"CLOSING",{enumerable:!0,value:Ce.indexOf("CLOSING")});Object.defineProperty(q.prototype,"CLOSING",{enumerable:!0,value:Ce.indexOf("CLOSING")});Object.defineProperty(q,"CLOSED",{enumerable:!0,value:Ce.indexOf("CLOSED")});Object.defineProperty(q.prototype,"CLOSED",{enumerable:!0,value:Ce.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(q.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(q.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[sn])return t[Ya];return null},set(t){for(let r of this.listeners(e))if(r[sn]){this.removeListener(e,r);break}typeof t=="function"&&this.addEventListener(e,t,{[sn]:!0})}})});q.prototype.addEventListener=Ja;q.prototype.removeEventListener=Xa;vs.exports=q;function ms(e,t,r,n){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:on[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!on.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${on.join(", ")})`);let s;if(t instanceof nn)s=t;else try{s=new nn(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),e._url=s.href;let a=s.protocol==="wss:",l=s.protocol==="ws+unix:",c;if(s.protocol!=="ws:"&&!a&&!l?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`:l&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let w=new SyntaxError(c);if(e._redirects===0)throw w;tr(e,w);return}let f=a?443:80,d=qa(16).toString("base64"),p=a?Fa.request:ja.request,y=new Set,u;if(i.createConnection=i.createConnection||(a?sc:ic),i.defaultPort=i.defaultPort||f,i.port=s.port||f,i.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},i.path=s.pathname+s.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new Ne(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=Za({[Ne.extensionName]:u.offer()})),r.length){for(let w of r){if(typeof w!="string"||!nc.test(w)||y.has(w))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(w)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(s.username||s.password)&&(i.auth=`${s.username}:${s.password}`),l){let w=i.path.split(":");i.socketPath=w[0],i.path=w[1]}let m;if(i.followRedirects){if(e._redirects===0){e._originalIpc=l,e._originalSecure=a,e._originalHostOrSocketPath=l?i.socketPath:s.host;let w=n&&n.headers;if(n={...n,headers:{}},w)for(let[T,P]of Object.entries(w))n.headers[T.toLowerCase()]=P}else if(e.listenerCount("redirect")===0){let w=l?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!w||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,w||delete i.headers.host,i.auth=void 0)}i.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=e._req=p(i),e._redirects&&e.emit("redirect",e.url,m)}else m=e._req=p(i);i.timeout&&m.on("timeout",()=>{ue(e,m,"Opening handshake has timed out")}),m.on("error",w=>{m===null||m[ps]||(m=e._req=null,tr(e,w))}),m.on("response",w=>{let T=w.headers.location,P=w.statusCode;if(T&&i.followRedirects&&P>=300&&P<400){if(++e._redirects>i.maxRedirects){ue(e,m,"Maximum redirects exceeded");return}m.abort();let D;try{D=new nn(T,t)}catch{let k=new SyntaxError(`Invalid URL: ${T}`);tr(e,k);return}ms(e,D,r,n)}else e.emit("unexpected-response",m,w)||ue(e,m,`Unexpected server response: ${w.statusCode}`)}),m.on("upgrade",(w,T,P)=>{if(e.emit("upgrade",w),e.readyState!==q.CONNECTING)return;m=e._req=null;let D=w.headers.upgrade;if(D===void 0||D.toLowerCase()!=="websocket"){ue(e,T,"Invalid Upgrade header");return}let Q=Wa("sha1").update(d+Qa).digest("base64");if(w.headers["sec-websocket-accept"]!==Q){ue(e,T,"Invalid Sec-WebSocket-Accept header");return}let k=w.headers["sec-websocket-protocol"],z;if(k!==void 0?y.size?y.has(k)||(z="Server sent an invalid subprotocol"):z="Server sent a subprotocol but none was requested":y.size&&(z="Server sent no subprotocol"),z){ue(e,T,z);return}k&&(e._protocol=k);let Y=w.headers["sec-websocket-extensions"];if(Y!==void 0){if(!u){ue(e,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let W;try{W=ec(Y)}catch{ue(e,T,"Invalid Sec-WebSocket-Extensions header");return}let I=Object.keys(W);if(I.length!==1||I[0]!==Ne.extensionName){ue(e,T,"Server indicated an extension that was not requested");return}try{u.accept(W[Ne.extensionName])}catch{ue(e,T,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Ne.extensionName]=u}e.setSocket(T,P,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,e):m.end()}o(ms,"initAsClient");function tr(e,t){e._readyState=q.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}o(tr,"emitErrorAndClose");function ic(e){return e.path=e.socketPath,hs.connect(e)}o(ic,"netConnect");function sc(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=hs.isIP(e.host)?"":e.host),Ga.connect(e)}o(sc,"tlsConnect");function ue(e,t,r){e._readyState=q.CLOSING;let n=new Error(r);Error.captureStackTrace(n,ue),t.setHeader?(t[ps]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(tr,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}o(ue,"abortHandshake");function an(e,t,r){if(t){let n=Ha(t)?t.size:tc(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${e.readyState} (${Ce[e.readyState]})`);process.nextTick(r,n)}}o(an,"sendAfterClose");function oc(e,t){let r=this[X];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[X]!==void 0&&(r._socket.removeListener("data",rr),process.nextTick(gs,r._socket),e===1005?r.close():r.close(e,t))}o(oc,"receiverOnConclude");function ac(){let e=this[X];e.isPaused||e._socket.resume()}o(ac,"receiverOnDrain");function cc(e){let t=this[X];t._socket[X]!==void 0&&(t._socket.removeListener("data",rr),process.nextTick(gs,t._socket),t.close(e[Ka])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}o(cc,"receiverOnError");function fs(){this[X].emitClose()}o(fs,"receiverOnFinish");function lc(e,t){this[X].emit("message",e,t)}o(lc,"receiverOnMessage");function uc(e){let t=this[X];t._autoPong&&t.pong(e,!this._isServer,ds),t.emit("ping",e)}o(uc,"receiverOnPing");function fc(e){this[X].emit("pong",e)}o(fc,"receiverOnPong");function gs(e){e.resume()}o(gs,"resume");function hc(e){let t=this[X];t.readyState!==q.CLOSED&&(t.readyState===q.OPEN&&(t._readyState=q.CLOSING,ys(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}o(hc,"senderOnError");function ys(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),rc)}o(ys,"setCloseTimer");function bs(){let e=this[X];this.removeListener("close",bs),this.removeListener("data",rr),this.removeListener("end",_s),e._readyState=q.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[X]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",fs),e._receiver.on("finish",fs))}o(bs,"socketOnClose");function rr(e){this[X]._receiver.write(e)||this.pause()}o(rr,"socketOnData");function _s(){let e=this[X];e._readyState=q.CLOSING,e._receiver.end(),this.end()}o(_s,"socketOnEnd");function xs(){let e=this[X];this.removeListener("error",xs),this.on("error",ds),e&&(e._readyState=q.CLOSING,this.destroy())}o(xs,"socketOnError")});var Es=B((lh,ws)=>{"use strict";h();var{tokenChars:dc}=it();function pc(e){let t=new Set,r=-1,n=-1,i=0;for(i;i<e.length;i++){let a=e.charCodeAt(i);if(n===-1&&dc[a]===1)r===-1&&(r=i);else if(i!==0&&(a===32||a===9))n===-1&&r!==-1&&(n=i);else if(a===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${i}`);n===-1&&(n=i);let l=e.slice(r,n);if(t.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);t.add(l),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let s=e.slice(r,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}o(pc,"parse");ws.exports={parse:pc}});var Ls=B((dh,$s)=>{"use strict";h();var mc=j("events"),nr=j("http"),{Duplex:hh}=j("stream"),{createHash:gc}=j("crypto"),Ss=rn(),ze=St(),yc=Es(),bc=cn(),{GUID:_c,kWebSocket:xc}=Se(),vc=/^[+/0-9A-Za-z]{22}==$/,Ts=0,Os=1,ks=2,ln=class extends mc{static{o(this,"WebSocketServer")}constructor(t,r){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:bc,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=nr.createServer((n,i)=>{let s=nr.STATUS_CODES[426];i.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),i.end(s)}),this._server.listen(t.port,t.host,t.backlog,r)):t.server&&(this._server=t.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=wc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:o((i,s,a)=>{this.handleUpgrade(i,s,a,n)},"upgrade")})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=Ts}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===ks){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(kt,this);return}if(t&&this.once("close",t),this._state!==Os)if(this._state=Os,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(kt,this):process.nextTick(kt,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{kt(this)})}}shouldHandle(t){if(this.options.path){let r=t.url.indexOf("?");if((r!==-1?t.url.slice(0,r):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,r,n,i){r.on("error",Cs);let s=t.headers["sec-websocket-key"],a=t.headers.upgrade,l=+t.headers["sec-websocket-version"];if(t.method!=="GET"){Ve(this,t,r,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){Ve(this,t,r,400,"Invalid Upgrade header");return}if(s===void 0||!vc.test(s)){Ve(this,t,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==8&&l!==13){Ve(this,t,r,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(t)){$t(r,400);return}let c=t.headers["sec-websocket-protocol"],f=new Set;if(c!==void 0)try{f=yc.parse(c)}catch{Ve(this,t,r,400,"Invalid Sec-WebSocket-Protocol header");return}let d=t.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&d!==void 0){let y=new ze(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=Ss.parse(d);u[ze.extensionName]&&(y.accept(u[ze.extensionName]),p[ze.extensionName]=y)}catch{Ve(this,t,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let y={origin:t.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(y,(u,m,w,T)=>{if(!u)return $t(r,m||401,w,T);this.completeUpgrade(p,s,f,t,r,n,i)});return}if(!this.options.verifyClient(y))return $t(r,401)}this.completeUpgrade(p,s,f,t,r,n,i)}completeUpgrade(t,r,n,i,s,a,l){if(!s.readable||!s.writable)return s.destroy();if(s[xc])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ts)return $t(s,503);let f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${gc("sha1").update(r+_c).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){let p=this.options.handleProtocols?this.options.handleProtocols(n,i):n.values().next().value;p&&(f.push(`Sec-WebSocket-Protocol: ${p}`),d._protocol=p)}if(t[ze.extensionName]){let p=t[ze.extensionName].params,y=Ss.format({[ze.extensionName]:[p]});f.push(`Sec-WebSocket-Extensions: ${y}`),d._extensions=t}this.emit("headers",f,i),s.write(f.concat(`\r
2
+ `).join(`\r
3
+ `)),s.removeListener("error",Cs),d.setSocket(s,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(kt,this)})),l(d,i)}};$s.exports=ln;function wc(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return o(function(){for(let n of Object.keys(t))e.removeListener(n,t[n])},"removeListeners")}o(wc,"addListeners");function kt(e){e._state=ks,e.emit("close")}o(kt,"emitClose");function Cs(){this.destroy()}o(Cs,"socketOnError");function $t(e,t,r,n){r=r||nr.STATUS_CODES[t],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${nr.STATUS_CODES[t]}\r
4
+ `+Object.keys(n).map(i=>`${i}: ${n[i]}`).join(`\r
5
+ `)+`\r
6
+ \r
7
+ `+r)}o($t,"abortHandshake");function Ve(e,t,r,n,i){if(e.listenerCount("wsClientError")){let s=new Error(i);Error.captureStackTrace(s,Ve),e.emit("wsClientError",s,r,t)}else $t(r,n,i)}o(Ve,"abortHandshakeOrEmitwsClientError")});var Ns=B((un,fn)=>{h();(function(e,t){typeof j=="function"&&typeof un=="object"&&typeof fn=="object"?fn.exports=t():typeof define=="function"&&define.amd?define(function(){return t()}):e.pluralize=t()})(un,function(){var e=[],t=[],r={},n={},i={};function s(u){return typeof u=="string"?new RegExp("^"+u+"$","i"):u}o(s,"sanitizeRule");function a(u,m){return u===m?m:u===u.toLowerCase()?m.toLowerCase():u===u.toUpperCase()?m.toUpperCase():u[0]===u[0].toUpperCase()?m.charAt(0).toUpperCase()+m.substr(1).toLowerCase():m.toLowerCase()}o(a,"restoreCase");function l(u,m){return u.replace(/\$(\d{1,2})/g,function(w,T){return m[T]||""})}o(l,"interpolate");function c(u,m){return u.replace(m[0],function(w,T){var P=l(m[1],arguments);return a(w===""?u[T-1]:w,P)})}o(c,"replace");function f(u,m,w){if(!u.length||r.hasOwnProperty(u))return m;for(var T=w.length;T--;){var P=w[T];if(P[0].test(m))return c(m,P)}return m}o(f,"sanitizeWord");function d(u,m,w){return function(T){var P=T.toLowerCase();return m.hasOwnProperty(P)?a(T,P):u.hasOwnProperty(P)?a(T,u[P]):f(P,T,w)}}o(d,"replaceWord");function p(u,m,w,T){return function(P){var D=P.toLowerCase();return m.hasOwnProperty(D)?!0:u.hasOwnProperty(D)?!1:f(D,D,w)===D}}o(p,"checkWord");function y(u,m,w){var T=m===1?y.singular(u):y.plural(u);return(w?m+" ":"")+T}return o(y,"pluralize"),y.plural=d(i,n,e),y.isPlural=p(i,n,e),y.singular=d(n,i,t),y.isSingular=p(n,i,t),y.addPluralRule=function(u,m){e.push([s(u),m])},y.addSingularRule=function(u,m){t.push([s(u),m])},y.addUncountableRule=function(u){if(typeof u=="string"){r[u.toLowerCase()]=!0;return}y.addPluralRule(u,"$0"),y.addSingularRule(u,"$0")},y.addIrregularRule=function(u,m){m=m.toLowerCase(),u=u.toLowerCase(),i[u]=m,n[m]=u},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(u){return y.addIrregularRule(u[0],u[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(u){return y.addPluralRule(u[0],u[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(u){return y.addSingularRule(u[0],u[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(y.addUncountableRule),y})});var Bs=B(lt=>{"use strict";h();lt.__esModule=!0;lt.distance=lt.closest=void 0;var ke=new Uint32Array(65536),$c=o(function(e,t){for(var r=e.length,n=t.length,i=1<<r-1,s=-1,a=0,l=r,c=r;c--;)ke[e.charCodeAt(c)]|=1<<c;for(c=0;c<n;c++){var f=ke[t.charCodeAt(c)],d=f|a;f|=(f&s)+s^s,a|=~(f|s),s&=f,a&i&&l++,s&i&&l--,a=a<<1|1,s=s<<1|~(d|a),a&=d}for(c=r;c--;)ke[e.charCodeAt(c)]=0;return l},"myers_32"),Lc=o(function(e,t){for(var r=t.length,n=e.length,i=[],s=[],a=Math.ceil(r/32),l=Math.ceil(n/32),c=0;c<a;c++)s[c]=-1,i[c]=0;for(var f=0;f<l-1;f++){for(var d=0,p=-1,y=f*32,u=Math.min(32,n)+y,m=y;m<u;m++)ke[e.charCodeAt(m)]|=1<<m;for(var c=0;c<r;c++){var w=ke[t.charCodeAt(c)],T=s[c/32|0]>>>c&1,P=i[c/32|0]>>>c&1,D=w|d,Q=((w|P)&p)+p^p|w|P,k=d|~(Q|p),z=p&Q;k>>>31^T&&(s[c/32|0]^=1<<c),z>>>31^P&&(i[c/32|0]^=1<<c),k=k<<1|T,z=z<<1|P,p=z|~(D|k),d=k&D}for(var m=y;m<u;m++)ke[e.charCodeAt(m)]=0}for(var Y=0,W=-1,I=f*32,L=Math.min(32,n-I)+I,m=I;m<L;m++)ke[e.charCodeAt(m)]|=1<<m;for(var te=n,c=0;c<r;c++){var w=ke[t.charCodeAt(c)],T=s[c/32|0]>>>c&1,P=i[c/32|0]>>>c&1,D=w|Y,Q=((w|P)&W)+W^W|w|P,k=Y|~(Q|W),z=W&Q;te+=k>>>n-1&1,te-=z>>>n-1&1,k>>>31^T&&(s[c/32|0]^=1<<c),z>>>31^P&&(i[c/32|0]^=1<<c),k=k<<1|T,z=z<<1|P,W=z|~(D|k),Y=k&D}for(var m=I;m<L;m++)ke[e.charCodeAt(m)]=0;return te},"myers_x"),Rs=o(function(e,t){if(e.length<t.length){var r=t;t=e,e=r}return t.length===0?e.length:e.length<=32?$c(e,t):Lc(e,t)},"distance");lt.distance=Rs;var Ac=o(function(e,t){for(var r=1/0,n=0,i=0;i<t.length;i++){var s=Rs(e,t[i]);s<r&&(r=s,n=i)}return t[n]},"closest");lt.closest=Ac});var Ms=B((dn,Lt)=>{h();(function(){"use strict";var e;try{e=typeof Intl<"u"&&typeof Intl.Collator<"u"?Intl.Collator("generic",{sensitivity:"base"}):null}catch{console.log("Collator could not be initialized and wouldn't be used")}var t=Bs(),r=[],n=[],i={get:o(function(s,a,l){var c=l&&e&&l.useCollator;if(c){var f=s.length,d=a.length;if(f===0)return d;if(d===0)return f;var p,y,u,m,w;for(u=0;u<d;++u)r[u]=u,n[u]=a.charCodeAt(u);r[d]=d;var T;for(u=0;u<f;++u){for(y=u+1,m=0;m<d;++m)p=y,T=e.compare(s.charAt(u),String.fromCharCode(n[m]))===0,y=r[m]+(T?0:1),w=p+1,y>w&&(y=w),w=r[m+1]+1,y>w&&(y=w),r[m]=p;r[m]=y}return y}return t.distance(s,a)},"get")};typeof define<"u"&&define!==null&&define.amd?define(function(){return i}):typeof Lt<"u"&&Lt!==null&&typeof dn<"u"&&Lt.exports===dn?Lt.exports=i:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=i:typeof window<"u"&&window!==null&&(window.Levenshtein=i)})()});var zs=B((Ud,Ws)=>{"use strict";h();var Gs=12,Dc=0,gn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function Uc(e){var t=e.indexOf("%");if(t===-1)return e;for(var r=e.length,n="",i=0,s=0,a=t,l=Gs;t>-1&&t<r;){var c=qs(e[t+1],4),f=qs(e[t+2],0),d=c|f,p=gn[d];if(l=gn[256+l+p],s=s<<6|d&gn[364+p],l===Gs)n+=e.slice(i,a),n+=s<=65535?String.fromCharCode(s):String.fromCharCode(55232+(s>>10),56320+(s&1023)),s=0,i=t+3,t=a=e.indexOf("%",i);else{if(l===Dc)return null;if(t+=3,t<r&&e.charCodeAt(t)===37)continue;return null}}return n+e.slice(i)}o(Uc,"decodeURIComponent");var Fc={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function qs(e,t){var r=Fc[e];return r===void 0?255:r<<t}o(qs,"hexCodeToInt");Ws.exports=Uc});var Ks=B((Gd,Ys)=>{"use strict";h();var Vs=zs(),Hs=/\+/g,Qs=o(function(){},"Empty");Qs.prototype=Object.create(null);function jc(e){let t=new Qs;if(typeof e!="string")return t;let r=e.length,n="",i="",s=-1,a=-1,l=!1,c=!1,f=!1,d=!1,p=!1,y=0;for(let u=0;u<r+1;u++)if(y=u!==r?e.charCodeAt(u):38,y===38){if(p=a>s,p||(a=u),n=e.slice(s+1,a),p||n.length>0){f&&(n=n.replace(Hs," ")),l&&(n=Vs(n)||n),p&&(i=e.slice(a+1,u),d&&(i=i.replace(Hs," ")),c&&(i=Vs(i)||i));let m=t[n];m===void 0?t[n]=i:m.pop?m.push(i):t[n]=[m,i]}i="",s=u,a=u,l=!1,c=!1,f=!1,d=!1}else y===61?a<=s?a=u:c=!0:y===43?a>s?d=!0:f=!0:y===37&&(a>s?c=!0:l=!0);return t}o(jc,"parse");Ys.exports=jc});var Xs=B((zd,Js)=>{h();var ve=Array.from({length:256},(e,t)=>"%"+((t<16?"0":"")+t.toString(16)).toUpperCase()),Gc=new Int8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0]);function qc(e){let t=e.length;if(t===0)return"";let r="",n=0,i=0;e:for(;i<t;i++){let s=e.charCodeAt(i);for(;s<128;){if(Gc[s]!==1&&(n<i&&(r+=e.slice(n,i)),n=i+1,r+=ve[s]),++i===t)break e;s=e.charCodeAt(i)}if(n<i&&(r+=e.slice(n,i)),s<2048){n=i+1,r+=ve[192|s>>6]+ve[128|s&63];continue}if(s<55296||s>=57344){n=i+1,r+=ve[224|s>>12]+ve[128|s>>6&63]+ve[128|s&63];continue}if(++i,i>=t)throw new Error("URI malformed");let a=e.charCodeAt(i)&1023;n=i+1,s=65536+((s&1023)<<10|a),r+=ve[240|s>>18]+ve[128|s>>12&63]+ve[128|s>>6&63]+ve[128|s&63]}return n===0?e:n<t?r+e.slice(n):r}o(qc,"encodeString");Js.exports={encodeString:qc}});var to=B((Qd,eo)=>{"use strict";h();var{encodeString:yn}=Xs();function Zs(e){let t=typeof e;return t==="string"?yn(e):t==="bigint"?e.toString():t==="boolean"?e?"true":"false":t==="number"&&Number.isFinite(e)?e<1e21?""+e:yn(""+e):""}o(Zs,"getAsPrimitive");function Wc(e){let t="";if(e===null||typeof e!="object")return t;let r="&",n=Object.keys(e),i=n.length,s=0;for(let a=0;a<i;a++){let l=n[a],c=e[l],f=yn(l)+"=";if(a&&(t+=r),Array.isArray(c)){s=c.length;for(let d=0;d<s;d++)d&&(t+=r),t+=f,t+=Zs(c[d])}else t+=f,t+=Zs(c)}return t}o(Wc,"stringify");eo.exports=Wc});var so=B((Jd,Pt)=>{"use strict";h();var ro=Ks(),no=to(),io={parse:ro,stringify:no};Pt.exports=io;Pt.exports.default=io;Pt.exports.parse=ro;Pt.exports.stringify=no});h();h();import _o from"node:net";import xo from"node:os";var Mt=class extends Error{static{o(this,"Locked")}constructor(t){super(`${t} is locked`)}},Xe={old:new Set,young:new Set},vo=1e3*15;var mt,wo=o(()=>{let e=xo.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let n of r)t.add(n.address);return t},"getLocalHosts"),Fn=o(e=>new Promise((t,r)=>{let n=_o.createServer();n.unref(),n.on("error",r),n.listen(e,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),"checkAvailablePort"),jn=o(async(e,t)=>{if(e.host||e.port===0)return Fn(e);for(let r of t)try{await Fn({port:e.port,host:r})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return e.port},"getAvailablePort"),Eo=o(function*(e){e&&(yield*e),yield 0},"portCheckSequence");async function mr(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let i=e.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let s of i){if(typeof s!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(s))throw new TypeError(`Number ${s} in the exclude option is not a safe integer and can't be used`)}r=new Set(i)}mt===void 0&&(mt=setTimeout(()=>{mt=void 0,Xe.old=Xe.young,Xe.young=new Set},vo),mt.unref&&mt.unref());let n=wo();for(let i of Eo(t))try{if(r.has(i))continue;let s=await jn({...e,port:i},n);for(;Xe.old.has(s)||Xe.young.has(s);){if(i!==0)throw new Mt(i);s=await jn({...e,port:i},n)}return Xe.young.add(s),s}catch(s){if(!["EADDRINUSE","EACCES"].includes(s.code)&&!(s instanceof Mt))throw s}throw new Error("No available ports found")}o(mr,"getPorts");import Sn from"node:assert";import al from"node:http";h();import Ut from"node:process";import{Buffer as Hn}from"node:buffer";import Qn from"node:path";import{fileURLToPath as Fo}from"node:url";import jo from"node:util";import Yn from"node:child_process";import vr,{constants as Kn}from"node:fs/promises";h();function Fe(e,t,r){let n=o(i=>Object.defineProperty(e,t,{value:i,enumerable:!0,writable:!0}),"define");return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let i=r();return n(i),i},set(i){n(i)}}),e}o(Fe,"defineLazyProperty");h();import{promisify as Bo}from"node:util";import _r from"node:process";import{execFile as Mo}from"node:child_process";h();import{promisify as So}from"node:util";import To from"node:process";import{execFile as Oo}from"node:child_process";var Co=So(Oo);async function gr(){if(To.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await Co("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]);return/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari"}o(gr,"defaultBrowserId");h();h();import ko from"node:process";import{promisify as $o}from"node:util";import{execFile as Lo,execFileSync as Ol}from"node:child_process";var Ao=$o(Lo);async function Gn(e,{humanReadableOutput:t=!0}={}){if(ko.platform!=="darwin")throw new Error("macOS only");let r=t?[]:["-ss"],{stdout:n}=await Ao("osascript",["-e",e,r]);return n.trim()}o(Gn,"runAppleScript");async function yr(e){return Gn(`tell application "Finder" to set app_path to application file id "${e}" as string
8
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}o(yr,"bundleName");h();import{promisify as Po}from"node:util";import{execFile as No}from"node:child_process";var Io=Po(No),Ro={AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},MSEdgeDHTML:{name:"Edge",id:"com.microsoft.edge"},MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"}},Dt=class extends Error{static{o(this,"UnknownBrowserError")}};async function br(e=Io){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!r)throw new Dt(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,i=Ro[n];if(!i)throw new Dt(`Unknown browser ID: ${n}`);return i}o(br,"defaultBrowser");var Do=Bo(Mo),Uo=o(e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase()),"titleize");async function xr(){if(_r.platform==="darwin"){let e=await gr();return{name:await yr(e),id:e}}if(_r.platform==="linux"){let{stdout:e}=await Do("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:Uo(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(_r.platform==="win32")return br();throw new Error("Only macOS, Linux, and Windows are supported")}o(xr,"defaultBrowser");var Go=jo.promisify(Yn.execFile),wr=Qn.dirname(Fo(import.meta.url)),qn=Qn.join(wr,"xdg-open"),{platform:Ze,arch:Wn}=Ut,qo=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let r="/etc/wsl.conf",n=!1;try{await vr.access(r,Kn.F_OK),n=!0}catch{}if(!n)return e;let i=await vr.readFile(r,{encoding:"utf8"}),s=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return s?(t=s.groups.mountPoint.trim(),t=t.endsWith("/")?t:`${t}/`,t):e}})(),Jn=o(async()=>`${await qo()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,"getPowershellPathFromWsl");async function Wo(){let e=await Jn(),r=Hn.from('(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',"utf16le").toString("base64"),{stdout:n}=await Go(e,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",r],{encoding:"utf8"}),i=n.trim(),s={ChromeHTML:"com.google.chrome",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return s[i]?{id:s[i]}:{}}o(Wo,"getWindowsDefaultBrowserFromWsl");var zn=o(async(e,t)=>{let r;for(let n of e)try{return await t(n)}catch(i){r=i}throw r},"pTryEach"),Ft=o(async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return zn(e.app,l=>Ft({...e,app:l}));let{name:t,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(t))return zn(t,l=>Ft({...e,app:{name:l,arguments:r}}));if(t==="browser"||t==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},c={chrome:"--incognito",firefox:"--private-window",edge:"--inPrivate"},f=Ke?await Wo():await xr();if(f.id in l){let d=l[f.id];return t==="browserPrivate"&&r.push(c[d]),Ft({...e,app:{name:et[d],arguments:r}})}throw new Error(`${f.name} is not supported as a default browser`)}let n,i=[],s={};if(Ze==="darwin")n="open",e.wait&&i.push("--wait-apps"),e.background&&i.push("--background"),e.newInstance&&i.push("--new"),t&&i.push("-a",t);else if(Ze==="win32"||Ke&&!Nn()&&!t){n=Ke?await Jn():`${Ut.env.SYSTEMROOT||Ut.env.windir||"C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`,i.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),Ke||(s.windowsVerbatimArguments=!0);let l=["Start"];e.wait&&l.push("-Wait"),t?(l.push(`"\`"${t}\`""`),e.target&&r.push(e.target)):e.target&&l.push(`"${e.target}"`),r.length>0&&(r=r.map(c=>`"\`"${c}\`""`),l.push("-ArgumentList",r.join(","))),e.target=Hn.from(l.join(" "),"utf16le").toString("base64")}else{if(t)n=t;else{let l=!wr||wr==="/",c=!1;try{await vr.access(qn,Kn.X_OK),c=!0}catch{}n=Ut.versions.electron??(Ze==="android"||l||!c)?"xdg-open":qn}r.length>0&&i.push(...r),e.wait||(s.stdio="ignore",s.detached=!0)}Ze==="darwin"&&r.length>0&&i.push("--args",...r),e.target&&i.push(e.target);let a=Yn.spawn(n,i,s);return e.wait?new Promise((l,c)=>{a.once("error",c),a.once("close",f=>{if(!e.allowNonzeroExitCode&&f>0){c(new Error(`Exited with code ${f}`));return}l(a)})}):(a.unref(),a)},"baseOpen"),zo=o((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return Ft({...t,target:e})},"open");function Vn(e){if(typeof e=="string"||Array.isArray(e))return e;let{[Wn]:t}=e;if(!t)throw new Error(`${Wn} is not supported`);return t}o(Vn,"detectArchBinary");function Er({[Ze]:e},{wsl:t}){if(t&&Ke)return Vn(t);if(!e)throw new Error(`${Ze} is not supported`);return Vn(e)}o(Er,"detectPlatformBinary");var et={};Fe(et,"chrome",()=>Er({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Fe(et,"firefox",()=>Er({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Fe(et,"edge",()=>Er({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Fe(et,"browser",()=>"browser");Fe(et,"browserPrivate",()=>"browserPrivate");var Xn=zo;h();import sl from"node:assert";h();import Vo from"node:assert";var Ho=o(e=>{let t=Mn(e);return t&&`session=${encodeURIComponent(t)};`},"loadCookie"),Sr=o(e=>{let t=je(e);return Vo(t,"missing auth headers"),t},"loadAuthHeaders"),je=o(e=>{let t=Ho(e);if(t)return e.log.trace("using cookie as auth header",{},{cookie:t}),{cookie:t};let r=Dn(e);if(r)return e.log.trace("using token as auth header",{},{token:r}),{"x-platform-access-token":r}},"maybeLoadAuthHeaders"),Qo=o(e=>e instanceof Ln&&e.response.statusCode===401,"isUnauthorizedError"),Zn=o((e,t)=>{if(Qo(t)){e.log.warn("swallowing unauthorized error",{error:t});return}throw t},"swallowUnauthorized");h();var mo=Z(Rt(),1),go=Z(ti(),1);import rl from"node:assert";import{Agent as nl}from"node:http";import{Agent as il}from"node:https";h();h();h();import Zc from"node:assert";h();var ri=Z(Rt(),1);import Cr from"node:os";var ge,ni=o(async(e,t)=>{t["--telemetry"]&&(ge=await import("./esm-PLVGBDRY.js"),ge.init({dsn:"https://0c26e0d8afd94e77a88ee1c3aa9e7065@o250689.ingest.sentry.io/6703266",enabled:we.productionLike&&(t["--telemetry"]??!1),release:Ye.version,environment:Ye.version.includes("experimental")?"experimental":"production"}))},"initSentry"),ii=o(async e=>{ge&&(ge.captureException(e,{event_id:e.id,captureContext:{tags:{arch:R.arch,bug:e.isBug,environment:we.value,platform:R.platform,shell:R.shell,version:Ye.version},contexts:{ctx:{argv:process.argv},cause:e.cause?le(e.cause):void 0,app:{app_name:Ye.name,app_version:Ye.version},device:{name:Cr.hostname(),family:Cr.type(),arch:Cr.arch()},runtime:{name:process.release.name,version:process.version}}}}),await ge.flush((0,ri.default)("2s")))},"sendErrorToSentry"),si=o(e=>{ge&&ge.addBreadcrumb(e)},"addSentryBreadcrumb"),oi=o(e=>{ge&&ge.setUser(e)},"setSentryUser"),Eu=o(e=>{ge&&ge.setTags(e)},"setSentryTags");h();h();var ai=o((e,t,r,n)=>(r?r=pr(r).trim():r="",JSON.stringify({level:e,name:t,msg:r,fields:ci(n)})+`
9
+ `),"formatJson"),ci=o(e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=li(n);return t},"serializeFields"),li=o(e=>(e instanceof Set&&(e=Array.from(e)),Array.isArray(e)?e.map(li):(e instanceof Map&&(e=Object.fromEntries(e.entries())),Qe(e)?ci(e):Bt(e)?pr(e).trim():e)),"serializeValue");h();var bn=Z(ui(),1);import zc from"node:assert";h();var Gt=Z(yi(),1);function ye(e,t,{target:r="stdout",...n}={}){return Gt.default[r]?Cn.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}o(ye,"terminalLink");ye.isSupported=Gt.default.stdout;ye.stderr=(e,t,r={})=>ye(e,t,{target:"stderr",...r});ye.stderr.isSupported=Gt.default.stderr;h();h();import Ic from"node:assert";h();h();h();h();function ie(e){return e===null?"null":Array.isArray(e)?"array":typeof e}o(ie,"extendedTypeof");function Ee(e){return ie(e)==="object"}o(Ee,"isObject");function bi(e){return Array.isArray(e)&&e.length>0&&e.every(t=>"message"in t)}o(bi,"areGraphQLErrors");function Ir(e,t){return e.length<124?e:t}o(Ir,"limitCloseReason");var _i="graphql-transport-ws";var ce;(function(e){e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(ce||(ce={}));var H;(function(e){e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete"})(H||(H={}));function xi(e){if(!Ee(e))throw new Error(`Message is expected to be an object, but got ${ie(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if(typeof e.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${ie(e.type)}`);switch(e.type){case H.ConnectionInit:case H.ConnectionAck:case H.Ping:case H.Pong:{if(e.payload!=null&&!Ee(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break}case H.Subscribe:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ie(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!Ee(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${ie(e.payload)}`);if(typeof e.payload.query!="string")throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${ie(e.payload.query)}`);if(e.payload.variables!=null&&!Ee(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${ie(e.payload.variables)}`);if(e.payload.operationName!=null&&ie(e.payload.operationName)!=="string")throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${ie(e.payload.operationName)}`);if(e.payload.extensions!=null&&!Ee(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${ie(e.payload.extensions)}`);break}case H.Next:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ie(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!Ee(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${ie(e.payload)}`);break}case H.Error:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ie(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!bi(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break}case H.Complete:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ie(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${e.type}"`)}return e}o(xi,"validateMessage");function vi(e,t){return xi(typeof e=="string"?JSON.parse(e,t):e)}o(vi,"parseMessage");function rt(e,t){return xi(e),JSON.stringify(e,t)}o(rt,"stringifyMessage");var nt=function(e){return this instanceof nt?(this.v=e,this):new nt(e)},ea=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(u){return function(m){return Promise.resolve(m).then(u,p)}}function l(u,m){n[u]&&(i[u]=function(w){return new Promise(function(T,P){s.push([u,w,T,P])>1||c(u,w)})},m&&(i[u]=m(i[u])))}function c(u,m){try{f(n[u](m))}catch(w){y(s[0][3],w)}}function f(u){u.value instanceof nt?Promise.resolve(u.value.v).then(d,p):y(s[0][2],u)}function d(u){c("next",u)}function p(u){c("throw",u)}function y(u,m){u(m),s.shift(),s.length&&c(s[0][0],s[0][1])}};function wi(e){let{url:t,connectionParams:r,lazy:n=!0,onNonLazyError:i=console.error,lazyCloseTimeout:s=0,keepAlive:a=0,disablePong:l,connectionAckWaitTimeout:c=0,retryAttempts:f=5,retryWait:d=o(async function(g){let _=1e3;for(let x=0;x<g;x++)_*=2;await new Promise(x=>setTimeout(x,_+Math.floor(Math.random()*2700+300)))},"randomisedExponentialBackoff"),shouldRetry:p=Rr,isFatalConnectionProblem:y,on:u,webSocketImpl:m,generateID:w=o(function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,g=>{let _=Math.random()*16|0;return(g=="x"?_:_&3|8).toString(16)})},"generateUUID"),jsonMessageReplacer:T,jsonMessageReviver:P}=e,D;if(m){if(!ra(m))throw new Error("Invalid WebSocket implementation provided");D=m}else typeof WebSocket<"u"?D=WebSocket:typeof global<"u"?D=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(D=window.WebSocket||window.MozWebSocket);if(!D)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let Q=D,k=(()=>{let b=(()=>{let _={};return{on(x,S){return _[x]=S,()=>{delete _[x]}},emit(x){var S;"id"in x&&((S=_[x.id])===null||S===void 0||S.call(_,x))}}})(),g={connecting:u?.connecting?[u.connecting]:[],opened:u?.opened?[u.opened]:[],connected:u?.connected?[u.connected]:[],ping:u?.ping?[u.ping]:[],pong:u?.pong?[u.pong]:[],message:u?.message?[b.emit,u.message]:[b.emit],closed:u?.closed?[u.closed]:[],error:u?.error?[u.error]:[]};return{onMessage:b.on,on(_,x){let S=g[_];return S.push(x),()=>{S.splice(S.indexOf(x),1)}},emit(_,...x){for(let S of[...g[_]])S(...x)}}})();function z(b){let g=[k.on("error",_=>{g.forEach(x=>x()),b(_)}),k.on("closed",_=>{g.forEach(x=>x()),b(_)})]}o(z,"errorOrClosed");let Y,W=0,I,L=!1,te=0,dt=!1;async function O(){clearTimeout(I);let[b,g]=await(Y??(Y=new Promise((S,N)=>(async()=>{if(L){if(await d(te),!W)return Y=void 0,N({code:1e3,reason:"All Subscriptions Gone"});te++}k.emit("connecting",L);let C=new Q(typeof t=="function"?await t():t,_i),U,K;function me(){isFinite(a)&&a>0&&(clearTimeout(K),K=setTimeout(()=>{C.readyState===Q.OPEN&&(C.send(rt({type:H.Ping})),k.emit("ping",!1,void 0))},a))}o(me,"enqueuePing"),z(V=>{Y=void 0,clearTimeout(U),clearTimeout(K),N(V),V instanceof qt&&(C.close(4499,"Terminated"),C.onerror=null,C.onclose=null)}),C.onerror=V=>k.emit("error",V),C.onclose=V=>k.emit("closed",V),C.onopen=async()=>{try{k.emit("opened",C);let V=typeof r=="function"?await r():r;if(C.readyState!==Q.OPEN)return;C.send(rt(V?{type:H.ConnectionInit,payload:V}:{type:H.ConnectionInit},T)),isFinite(c)&&c>0&&(U=setTimeout(()=>{C.close(ce.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),me()}catch(V){k.emit("error",V),C.close(ce.InternalClientError,Ir(V instanceof Error?V.message:new Error(V).message,"Internal client error"))}};let oe=!1;C.onmessage=({data:V})=>{try{let F=vi(V,P);if(k.emit("message",F),F.type==="ping"||F.type==="pong"){k.emit(F.type,!0,F.payload),F.type==="pong"?me():l||(C.send(rt(F.payload?{type:H.Pong,payload:F.payload}:{type:H.Pong})),k.emit("pong",!1,F.payload));return}if(oe)return;if(F.type!==H.ConnectionAck)throw new Error(`First message cannot be of type ${F.type}`);clearTimeout(U),oe=!0,k.emit("connected",C,F.payload,L),L=!1,te=0,S([C,new Promise((re,_e)=>z(_e))])}catch(F){C.onmessage=null,k.emit("error",F),C.close(ce.BadResponse,Ir(F instanceof Error?F.message:new Error(F).message,"Bad response"))}}})())));b.readyState===Q.CLOSING&&await g;let _=o(()=>{},"release"),x=new Promise(S=>_=S);return[b,_,Promise.race([x.then(()=>{if(!W){let S=o(()=>b.close(1e3,"Normal Closure"),"complete");isFinite(s)&&s>0?I=setTimeout(()=>{b.readyState===Q.OPEN&&S()},s):S()}}),g])]}o(O,"connect");function E(b){if(Rr(b)&&(ta(b.code)||[ce.InternalServerError,ce.InternalClientError,ce.BadRequest,ce.BadResponse,ce.Unauthorized,ce.SubprotocolNotAcceptable,ce.SubscriberAlreadyExists,ce.TooManyInitialisationRequests].includes(b.code)))throw b;if(dt)return!1;if(Rr(b)&&b.code===1e3)return W>0;if(!f||te>=f||!p(b)||y?.(b))throw b;return L=!0}o(E,"shouldRetryConnectOrThrow"),n||(async()=>{for(W++;;)try{let[,,b]=await O();await b}catch(b){try{if(!E(b))return}catch(g){return i?.(g)}}})();function v(b,g){let _=w(b),x=!1,S=!1,N=o(()=>{W--,x=!0},"releaser");return(async()=>{for(W++;;)try{let[C,U,K]=await O();if(x)return U();let me=k.onMessage(_,oe=>{switch(oe.type){case H.Next:{g.next(oe.payload);return}case H.Error:{S=!0,x=!0,g.error(oe.payload),N();return}case H.Complete:{x=!0,N();return}}});C.send(rt({id:_,type:H.Subscribe,payload:b},T)),N=o(()=>{!x&&C.readyState===Q.OPEN&&C.send(rt({id:_,type:H.Complete},T)),W--,x=!0,U()},"releaser"),await K.finally(me);return}catch(C){if(!E(C))return}})().then(()=>{S||g.complete()}).catch(C=>{g.error(C)}),()=>{x||N()}}return o(v,"subscribe"),{on:k.on,subscribe:v,iterate(b){let g=[],_={done:!1,error:null,resolve:o(()=>{},"resolve")},x=v(b,{next(N){g.push(N),_.resolve()},error(N){_.done=!0,_.error=N,_.resolve()},complete(){_.done=!0,_.resolve()}}),S=o(function(){return ea(this,arguments,o(function*(){for(;;){for(g.length||(yield nt(new Promise(U=>_.resolve=U)));g.length;)yield yield nt(g.shift());if(_.error)throw _.error;if(_.done)return yield nt(void 0)}},"iterator_1"))},"iterator")();return S.throw=async N=>(_.done||(_.done=!0,_.error=N,_.resolve()),{done:!0,value:void 0}),S.return=async()=>(x(),{done:!0,value:void 0}),S},async dispose(){if(dt=!0,Y){let[b]=await Y;b.close(1e3,"Normal Closure")}},terminate(){Y&&k.emit("closed",new qt)}}}o(wi,"createClient");var qt=class extends Error{static{o(this,"TerminatedCloseEvent")}constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}};function Rr(e){return Ee(e)&&"code"in e&&"reason"in e}o(Rr,"isLikeCloseEvent");function ta(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}o(ta,"isFatalInternalCloseCode");function ra(e){return typeof e=="function"&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}o(ra,"isWebSocket");var mn=Z(Rt(),1);h();h();var Mr=Z(Si(),1);h();var bt=class extends Error{static{o(this,"TimeoutError")}constructor(t){super(t),this.name="TimeoutError"}},Dr=class extends Error{static{o(this,"AbortError")}constructor(t){super(),this.name="AbortError",this.message=t}},Ti=o(e=>globalThis.DOMException===void 0?new Dr(e):new DOMException(e),"getDOMException"),Oi=o(e=>{let t=e.reason===void 0?Ti("This operation was aborted."):e.reason;return t instanceof Error?t:Ti(t)},"getAbortedReason");function Ur(e,t){let{milliseconds:r,fallback:n,message:i,customTimers:s={setTimeout,clearTimeout}}=t,a,l,f=new Promise((d,p)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:u}=t;u.aborted&&p(Oi(u)),l=o(()=>{p(Oi(u))},"abortHandler"),u.addEventListener("abort",l,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(d,p);return}let y=new bt;a=s.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(u){p(u)}return}typeof e.cancel=="function"&&e.cancel(),i===!1?d():i instanceof Error?p(i):(y.message=i??`Promise timed out after ${r} milliseconds`,p(y))},r),(async()=>{try{d(await e)}catch(u){p(u)}})()}).finally(()=>{f.clear(),l&&t.signal&&t.signal.removeEventListener("abort",l)});return f.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},f}o(Ur,"pTimeout");h();h();function Fr(e,t,r){let n=0,i=e.length;for(;i>0;){let s=Math.trunc(i/2),a=n+s;r(e[a],t)<=0?(n=++a,i-=s+1):i=s}return n}o(Fr,"lowerBound");var _t=class{static{o(this,"PriorityQueue")}#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let i=Fr(this.#e,n,(s,a)=>a.priority-s.priority);this.#e.splice(i,0,n)}setPriority(t,r){let n=this.#e.findIndex(s=>s.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[i]=this.#e.splice(n,1);this.enqueue(i.run,{priority:r,id:t})}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var xt=class extends Mr.default{static{o(this,"PQueue")}#e;#i;#o=0;#d;#a;#p=0;#r;#c;#t;#m;#n=0;#l;#s;#g;#_=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:_t,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#i=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#d=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#g=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#x(){return this.#i||this.#o<this.#d}get#v(){return this.#n<this.#l}#w(){this.#n--,this.#u(),this.emit("next")}#E(){this.#b(),this.#y(),this.#c=void 0}get#S(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#o=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#u(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#S;if(this.#x&&this.#v){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#y(),!0):!1}}return!1}#y(){this.#i||this.#r!==void 0||(this.#r=setInterval(()=>{this.#b()},this.#a),this.#p=Date.now()+this.#a)}#b(){this.#o===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#o=this.#e?this.#n:0,this.#f()}#f(){for(;this.#u(););}get concurrency(){return this.#l}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#l=t,this.#f()}async#T(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#t.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#_++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#g,...r},new Promise((n,i)=>{this.#t.enqueue(async()=>{this.#n++,this.#o++;try{r.signal?.throwIfAborted();let s=t({signal:r.signal});r.timeout&&(s=Ur(Promise.resolve(s),{milliseconds:r.timeout})),r.signal&&(s=Promise.race([s,this.#T(r.signal)]));let a=await s;n(a),this.emit("completed",a)}catch(s){if(s instanceof bt&&!r.throwOnTimeout){n();return}i(s),this.emit("error",s)}finally{this.#w()}},r),this.emit("add"),this.#u()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#f(),this):this}pause(){this.#s=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#h("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#h("idle")}async#h(t,r){return new Promise(n=>{let i=o(()=>{r&&!r()||(this.off(t,i),n())},"listener");this.on(t,i)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#s}};h();var Ec=Z(Li(),1),Sc=Z(Jr(),1),Tc=Z(en(),1),As=Z(cn(),1),Oc=Z(Ls(),1);var Ps=As.default;h();var Us=Z(Ns(),1);import Nc from"node:assert";h();import{randomUUID as Cc}from"node:crypto";var kc=o(async(e,t)=>{if($n(t))return e.log.debug("aborting without reporting error",{error:t}),process.exit(1);e.log.error("reporting error and exiting",{error:t});try{let r=He.from(t);if(r.print(),r.isBug===Ie.NO)return;await ii(r)}finally{process.exit(1)}},"reportErrorAndExit"),Lh=o(async(e,t)=>{e.log.debug("installing error handlers"),await ni(e,t);let r=o(n=>void kc(e,n),"handleError");process.once("uncaughtException",r),process.once("unhandledRejection",r)},"installErrorHandlers"),Ie=Object.freeze({YES:"yes",NO:"no",MAYBE:"maybe"}),He=class e extends Error{static{o(this,"GGTError")}id=we.testLike?"00000000-0000-0000-0000-000000000000":Cc();cause;stack;constructor(t){super(t),Error.captureStackTrace(this,this.constructor),this.stack=On(this.stack,{pretty:!0,basePath:Pn})}static from(t){return t instanceof e?t:new hn(t)}sprint(){let t=this.render();if(this.isBug!==Ie.NO){t=Ue(t);let r=this.isBug===Ie.YES?"This is a bug":"If you think this is a bug",n=`https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml&error-id=${this.id}`;ye.isSupported?t+=Ue({ensureEmptyLineAbove:!0,content:ne`
10
+ ${r}, ${ye("click here",n)} to create an issue on GitHub.
11
+ `}):t+=Ue({ensureEmptyLineAbove:!0,content:ne`
12
+ ${r}, use the link below to create an issue on GitHub.
13
+
14
+ ${n}
15
+ `})}return t}print(t){fe({ensureEmptyLineAbove:!0,...t,content:this.sprint()})}},hn=class extends He{constructor(r){super("An unexpected error occurred");this.cause=r}static{o(this,"UnexpectedError")}isBug=Ie.YES;render(){let r=le(this.cause),n=r.stack||r.message||this.stack;return this.message+`.
16
+
17
+ `+n}},Is=class extends He{constructor(r,n){super(r);this.cause=n}static{o(this,"EdgeCaseError")}isBug=Ie.MAYBE;render(){return this.message}};h();var pn=Z(Ms(),1);import Pc from"node:assert";var Fh=o(e=>e.filter(t=>!!t),"compact"),Ds=o(e=>[...new Set(e)],"uniq"),jh=o((e,t)=>(Pc(t.length>0,"options must not be empty"),[...t].sort((r,n)=>pn.default.get(r,e)-pn.default.get(n,e))),"sortBySimilar");var $e=class extends He{constructor(r,n,i){super("An error occurred while communicating with Gadget");this.request=r;i?this.isBug=i:this.isBug=Ie.MAYBE,fr(n)?this.cause={type:n.type,message:n.message,error:le(n.error)}:ur(n)?this.cause={type:n.type,code:n.code,reason:n.reason,wasClean:n.wasClean}:(Nc(Bt(n)||cr(n)||lr(n)||hr(n),"cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent"),this.cause=n)}static{o(this,"ClientError")}isBug;cause;render(){let r;switch(!0){case hr(this.cause):{let n=Ds(this.cause.map(i=>i.message));r=ne`
18
+ Gadget responded with the following ${(0,Us.default)("error",n.length,!1)}:
19
+
20
+ • ${n.join(`
21
+ \u2022 `)}
22
+ `;break}case ur(this.cause):r="The connection to Gadget closed unexpectedly.";break;case(fr(this.cause)||lr(this.cause)):r=this.cause.message;break;case cr(this.cause):this.cause.length===1?r=String(this.cause[0]):r=this.cause.join(", ");break;default:r=this.cause;break}return this.message+`
23
+
24
+ `+r}},ir=class extends $e{static{o(this,"AuthenticationError")}constructor(t){super(t,"Request authentication failed due to the session expiring while running the command. Please sign-in again.",Ie.NO)}};var sr=class{constructor(t,r,n){this.environment=r;this.endpoint=n;this.ctx=t.child({name:"client"}),this._graphqlWsClient=wi({url:`wss://${r.application.slug}.${R.domains.app}/edit/api/graphql-ws`,keepAlive:(0,mn.default)("10s"),shouldRetry:o(()=>!0,"shouldRetry"),connectionParams:{environment:r.name},webSocketImpl:class extends Ps{static{o(this,"webSocketImpl")}constructor(i,s,a){super(i,s,{signal:t.signal,...a,headers:{...a?.headers,"user-agent":R.versionFull,...Sr(t)}})}},on:{opened:o(()=>{this.ctx.log.trace("opened")},"opened"),ping:o(i=>{this.ctx.log.trace("ping",{received:i})},"ping"),pong:o(i=>{this.ctx.log.trace("pong",{received:i})},"pong"),connecting:o(()=>{switch(this.status){case 1:this.status=2,this.ctx.log.info("reconnecting");break;case 2:this.ctx.log.info("retrying");break;default:this.ctx.log.debug("connecting");break}},"connecting"),connected:o(()=>{this.status===2?this.ctx.log.info("reconnected"):this.ctx.log.debug("connected"),setImmediate(()=>this.status=0)},"connected"),closed:o(()=>{this.status=1,this.ctx.log.debug("disconnected")},"closed"),error:o(i=>{this.status===2?this.ctx.log.error("failed to reconnect",{error:i}):this.ctx.log.error("connection error",{error:i})},"error")}})}static{o(this,"Client")}status=0;ctx;_graphqlWsClient;_sessionUpdateInterval;subscribe(t,{subscription:r,variables:n,onResponse:i,onError:s,onComplete:a=In}){let l={query:r,variables:ae(n)},c=this._graphqlWsClient.on("connected",()=>{this.status===2&&(l.variables=ae(n),t.log.info("re-subscribing to graphql subscription")),this._sessionUpdateInterval=setInterval(()=>{ut(this.ctx).catch(y=>this.ctx.abort(y)).then(y=>{y||this.ctx.abort(new ir(void 0))})},(0,mn.default)("30m")).unref(),this.ctx.done.finally(()=>{this._sessionUpdateInterval&&clearInterval(this._sessionUpdateInterval)})}),f=new xt({concurrency:1}),d=o(y=>s(new $e(r,y)),"onError"),p=this._graphqlWsClient.subscribe(l,{next:o(y=>void f.add(()=>i(y)).catch(d),"next"),error:o(y=>void f.add(()=>d(y)),"error"),complete:o(()=>void f.add(()=>a()).catch(d),"complete")});return()=>{t.log.trace("unsubscribing from graphql subscription"),c(),f.clear(),p()}}async execute(t,r){let n=this.environment.application.slug;this.environment.application.multiEnvironmentEnabled?this.environment.type!=="production"&&(n+=`--${this.environment.name}`):this.environment.application.hasSplitEnvironments&&(n+="--development");try{let i=await ft({context:{ctx:t},method:"POST",url:`https://${n}.${R.domains.app}${this.endpoint}`,headers:{...Sr(t),"x-gadget-environment":this.environment.name},json:{query:r.operation,variables:ae(r.variables)},responseType:"json",resolveBodyOnly:!0,throwHttpErrors:!1,...r.http});if(!Qe(i)||!("data"in i)&&!("errors"in i))throw t.log.error("received invalid graphql response",{error:i}),i;return i}catch(i){throw new $e(r.operation,i)}}async dispose(){await this._graphqlWsClient.dispose()}};var At=class{static{o(this,"Api")}ctx;#e;constructor(t,r){this.ctx=t.child({name:"api"}),this.#e=new sr(this.ctx,r,"/api/graphql")}async query({query:t,variables:r,...n}){let i=/query (\w+)/.exec(t)?.[1];Ic(i,"query name not found");let s=this.ctx.child({name:"api",fields:{edit:{query:i}},devFields:{edit:{query:i,variables:ae(r)}}});s.log.info("executing graphql query");let a=await this.#e.execute(s,{operation:t,variables:r,...n,http:{retry:{methods:["POST"]},...n.http}});if(a.errors)throw new $e(t,a.errors);if(!a.data)throw new $e(t,"Query response did not contain data");return a.data}async dispose(){await this.#e.dispose()}};h();var Fs=ne(`
25
+ query GadgetMetaModels {
26
+ gadgetMeta {
27
+ models {
28
+ apiIdentifier
29
+ namespace
30
+ }
31
+ }
32
+ }
33
+ `),js=ne(`
34
+ query GadgetMetaGlobalActions {
35
+ gadgetMeta {
36
+ globalActions {
37
+ apiIdentifier
38
+ namespace
39
+ }
40
+ }
41
+ }
42
+ `);var Rc=Object.freeze({Development:"development",Production:"production",Test:"test"}),Bc=$.object({id:$.union([$.string(),$.number(),$.bigint()]).transform(e=>BigInt(e)),name:$.string().transform(e=>e.toLowerCase()),type:$.nativeEnum(Rc)}),Mc=$.object({id:$.union([$.string(),$.number(),$.bigint()]).transform(e=>BigInt(e)),slug:$.string(),primaryDomain:$.string(),hasSplitEnvironments:$.boolean(),multiEnvironmentEnabled:$.boolean(),environments:$.array(Bc),team:$.object({id:$.union([$.string(),$.number(),$.bigint()]).transform(e=>BigInt(e)),name:$.string()})}),Ld=$.object({apiIdentifier:$.string(),namespace:$.nullable($.array($.string())).optional()}),Ad=$.object({apiIdentifier:$.string(),namespace:$.nullable($.array($.string())).optional()}),Pd=o(async e=>{let t=je(e);if(!t)return[];let r=await ft({context:{ctx:e},url:`https://${R.domains.services}/auth/api/apps`,headers:{...t},responseType:"json",resolveBodyOnly:!0});return $.array(Mc).parse(r)},"getApplications"),Nd=o(e=>{let t=new Map;for(let r of e){let n=r.team.name,i=t.get(n)??[];i.push(r),t.set(n,i)}return t},"groupByTeam"),Id=o(async(e,t)=>{if(!je(e))return[];let n=new At(e,t),{gadgetMeta:i}=await n.query({query:Fs});return i.models},"getModels"),Rd=o(async(e,t)=>{if(!je(e))return[];let n=new At(e,t),{gadgetMeta:i}=await n.query({query:js});return i.globalActions},"getGlobalActions");h();var oo=Z(so(),1);var ao=o(e=>{let t=oo.default.stringify(e);return t?`?${t}`:""},"serializeObjectToHTTPQuery");h();var A=new Tn({level:we.testLike&&R.logLevel<G.PRINT?3:Me.level}),M={error:A.red,success:A.green,warn:A.yellow,link:A.cyan,highlighted:A.magentaBright,examplesQuestions:A.cyanBright,subdued:A.blackBright,body:A.whiteBright,black:A.black,blackBright:A.blackBright,red:A.red,redBright:A.redBright,green:A.green,greenBright:A.greenBright,yellow:A.yellow,yellowBright:A.yellowBright,blue:A.blue,blueBright:A.blueBright,magenta:A.magenta,magentaBright:A.magentaBright,cyan:A.cyan,cyanBright:A.cyanBright,white:A.white,whiteBright:A.whiteBright,bgBlack:A.bgBlack,bgBlackBright:A.bgBlackBright,bgRed:A.bgRed,bgRedBright:A.bgRedBright,bgGreen:A.bgGreen,bgGreenBright:A.bgGreenBright,bgYellow:A.bgYellow,bgYellowBright:A.bgYellowBright,bgBlue:A.bgBlue,bgBlueBright:A.bgBlueBright,bgMagenta:A.bgMagenta,bgMagentaBright:A.bgMagentaBright,bgCyan:A.bgCyan,bgCyanBright:A.bgCyanBright,bgWhite:A.bgWhite,bgWhiteBright:A.bgWhiteBright,reset:A.reset};var uo=o((e,t,r,n,i,s)=>`${Yc(i)} ${Kc(e)} ${Jc(t)}:${Xc(r)}${fo(n,{indent:2,timestamp:i,environment:s})}${Le}`,"formatPretty"),ht="",Be=" ",Le=`
43
+ `,Vc=":",co="'",lo=o((e,t)=>{let r=e==="error"?M.error:M.subdued,n=[];n.push(Le);for(let i=0;i<t;i++)n.push(Be);return n.push(r(e)),n.push(r(Vc)),n.join("")},"formatKey"),Re=o((e,t,r)=>{if(!e)return ht;let n=e.split(Le);if(n.length===0)return ht;let i=[],s=n.shift();zc(!kn(s),"first line is nil"),i.push(t(s));for(let a of n)if(a){i.push(Le);for(let l=0;l<r;l++)i.push(Be);i.push(t(a))}return i.join(ht)},"formatValue"),Hc=o((e,t)=>{let r="";return t&&(r=ao(t)),`https://${e.application.slug}--${e.name}.${R.domains.app}/edit/logs${r}`},"getEnvironmentLogsUrl"),Qc=o(e=>e?`{environment_id="${e.id.toString()}"} | json | level=~"info|warn|error"`:'{environment_id=~".+"} | json | level=~"info|warn|error"',"defaultLogqlQuery"),fo=o((e,t)=>{let{indent:r,environment:n,timestamp:i}=t;if(Object.keys(e).length===0)return ht;let s=[];"trace_id"in e&&(s.push(lo("trace_id",r)),s.push(Be),n&&i&&ye.isSupported?s.push(ye(M.link(e.trace_id),Hc(n,{timeRange:`${i.toISOString()} to now`,logql:`${Qc(n)} | trace_id="${e.trace_id}"`}))):s.push(M.link(e.trace_id)));for(let[a,l]of Object.entries(e))if(a!=="trace_id"){if(s.push(lo(a,r)),l instanceof Set&&(l=Array.from(l)),Array.isArray(l)){if(l.length===0){s.push(Re(" []",M.subdued,r));continue}l=Object.fromEntries(l.entries())}if(l instanceof Map&&(l=Object.fromEntries(l)),Qe(l)){let c=Object.entries(l);if(c.length===0){s.push(Re(" {}",M.subdued,r));continue}c.length>10&&R.logLevel>G.TRACE&&!n&&(l=Object.fromEntries([...c.slice(0,10),[Bn.ellipsis,`${c.length-10} more`]])),s.push(fo(l,{indent:r+2,environment:n}));continue}if(s.push(Be),n)s.push(Re(String(l),M.reset,r));else switch(typeof l){case"string":s.push(Re(co+l.replaceAll(Le,Le+Be.repeat(r+a.length))+co,M.reset,r));break;case"number":s.push(Re(String(l),M.yellowBright,r));break;case"bigint":s.push(Re(String(l)+"n",M.yellowBright,r));break;case"boolean":s.push(Re(String(l),M.green,r));break;default:s.push(Re(String(l),M.reset,r));break}}return s.join(ht)},"formatFields"),Yc=o(e=>(e?(0,bn.default)(e):(0,bn.default)()).format("hh:mm:ss"),"formatTimestamp"),Kc=o(e=>{switch(e){case G.PRINT:return M.bgBlack(M.body.bold(" PRINT "));case G.TRACE:return M.bgBlue(M.body.bold(" TRACE "));case G.DEBUG:return M.bgMagenta(M.body.bold(" DEBUG "));case G.INFO:return M.bgBlue(M.body.bold(" INFO "));case G.WARN:return M.bgYellow(M.body.bold(" WARN "));case G.ERROR:return M.bgRed(M.body.bold(" ERROR "))}},"formatLevel"),Jc=o(e=>M.body(e),"formatName"),Xc=o(e=>{if(!e)return ht;let t=e.split(Le);return t.length===1?Be+M.body(e):Le+t.map(r=>Be+Be+r).join(Le)},"formatMessage");var _n={pretty:uo,json:ai};var Ip={"--log-level":{type:o(e=>Rn(e,G.INFO),"type"),alias:["-ll"],default:G.INFO},"--my-logs":{type:Boolean}},el={trace:G.TRACE,debug:G.DEBUG,info:G.INFO,warn:G.WARN,error:G.ERROR},Rp=o(e=>(t,r,n,i,s)=>{let a={...i};"error"in a&&(a.error=le(a.error)),"reason"in a&&(a.reason=le(a.reason));let l=_n[R.logFormat],c=el[t.toLowerCase()];Zc(c,`Unknown level: ${t}`),De.writeStdout(l(c,r,n,a,s,e))},"createEnvironmentStructuredLogger"),ho=o(({name:e,fields:t={},devFields:r={}})=>{let n=o(i=>(s,a,l)=>{let c=i>=R.logLevel,f=i>=G.INFO;if(!c&&!f)return;let d={...ae(t),...a};if(we.developmentOrTestLike&&Object.assign(d,ae(r),l),"error"in d&&(d.error=le(d.error)),"reason"in d&&(d.reason=le(d.reason)),c){let p=_n[R.logFormat];De.writeStderr(p(i,e,s,d))}f&&si({level:"log",message:s,data:d})},"createStructuredLog");return{trace:n(G.TRACE),debug:n(G.DEBUG),info:n(G.INFO),warn:n(G.WARN),error:n(G.ERROR)}},"createStructuredLogger");var xn=o(({name:e,fields:t,devFields:r})=>({...ho({name:e,fields:t,devFields:r}),child:o(({name:n,fields:i,devFields:s})=>xn({name:n||e,fields:o(()=>({...ae(t),...ae(i)}),"fields"),devFields:{...ae(r),...ae(s)}}),"child")}),"createLogger");h();var po=Z(Rt(),1);import{setTimeout as tl}from"node:timers/promises";var zp=o((e,t)=>tl((0,po.default)(e),void 0,t),"delay"),vn=class{static{o(this,"PromiseWrapper")}resolution;rejection;pendingPromise;constructor(t){this.pendingPromise=t,t.then(r=>(this.resolution=r,r)).catch(r=>{this.rejection=r}).finally(()=>{delete this.pendingPromise})}async unwrap(){if(this.pendingPromise)return await this.pendingPromise;if(this.rejection)throw this.rejection;return this.resolution}},or=class{static{o(this,"PromiseSignal")}[Symbol.toStringTag];resolve;reject;_promise;constructor(){this._promise=new vn(new Promise((t,r)=>{this.resolve=t,this.reject=r})),this[Symbol.toStringTag]=String(this._promise.pendingPromise)}then(t,r){return this._promise.unwrap().then(t,r)}catch(t){return this._promise.unwrap().catch(t)}finally(t){return this._promise.unwrap().finally(t)}};var ar=class e extends AbortController{static{o(this,"Context")}done=new or;#e;#i=[];constructor({log:t}){super(),this.#e=t,this.abort=this.abort.bind(this),this.child=this.child.bind(this),this.onAbort=this.onAbort.bind(this),this.signal.addEventListener("abort",async()=>{let r;for(let n of this.#i.reverse())try{await n(this.signal.reason)}catch(i){r??=i,this.log.error("error during abort",{error:r})}r?this.done.reject(r):this.done.resolve()})}get log(){return this.#e}static init(t){return new e({log:xn(t)})}child(t){let r=new e({log:this.log.child(t)});return this.onAbort(()=>r.abort()),r}onAbort(t){this.#i.push(t)}};var wn=o(e=>(rl(e.context?.ctx instanceof ar,ne(`
44
+ ctx must be provided to http requests:
45
+
46
+ const response = await http({
47
+ context: { ctx },
48
+ ...options,
49
+ });
50
+ `)),e.context.ctx),"getContext"),ft=An.extend({agent:{http:new nl({keepAlive:!0}),https:new il({keepAlive:!0,minVersion:"TLSv1.1"})},retry:{limit:10,methods:["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],statusCodes:[408,413,429,500,502,503,504,521,522,524],errorCodes:["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN","EADDRNOTAVAIL","EHOSTUNREACH"],maxRetryAfter:void 0,calculateDelay:o(({computedValue:e})=>e,"calculateDelay"),backoffLimit:(0,mo.default)("5s"),noise:100},hooks:{beforeRequest:[e=>{let t=wn(e);e.signal=t.signal,e.headers["user-agent"]=R.versionFull,t.log.debug("http request",{http:{request:{method:e.method,url:e.url?.toString()}}})}],beforeRetry:[(e,t)=>{wn(e.request?.options??e.options.context).log.warn("http request failed, retrying...",{http:{retryCount:t,error:le(e),request:e.request&&{method:e.request.options.method,url:e.request.options.url?.toString()},response:e.response&&{statusCode:e.response.statusCode,traceId:e.response.headers["x-trace-id"],durationMs:e.response.timings.phases.total}}})}],afterResponse:[e=>{let t=wn(e.request.options);if(t.log.debug("http response",{http:{request:{method:e.request.options.method,url:e.request.options.url?.toString()},response:{statusCode:e.statusCode,traceId:e.headers["x-trace-id"],durationMs:e.timings.phases.total}}}),e.statusCode===401&&Je(t,void 0),e.headers["set-cookie"]){let r=e.headers["set-cookie"];(Array.isArray(r)?r:[r]).forEach(i=>{let s=(0,go.parseString)(i);s.name==="session"&&(s.domain==="gadget.dev"||s.domain==="ggt.dev")&&Je(t,s.value)})}return e}]}});h();import Nt from"node:process";var yo=o(e=>{let t;if(typeof e=="string"?t={content:e}:t=e,t=dr(t,{ensureEmptyLineAbove:!0,ensureNewLine:!0,exitWhenNo:!0}),!De.isInteractive){let r=t.whenNotInteractive??(()=>{fe(t),fe({ensureEmptyLineAbove:!0,content:"Aborting because ggt is not running in an interactive terminal."}),Nt.exit(1)});return Promise.resolve(r())}return new Promise(r=>{let n=new En(t);n.on("submit",r),n.on("exit",()=>Nt.exit(0)),n.on("abort",()=>Nt.exit(1))})},"confirm"),En=class extends Un{static{o(this,"Confirm")}value=void 0;defaultValue=!1;options;constructor(t){super(),this.options=dr(t,{exitWhenNo:!0,ensureEmptyLineAbove:!0}),this.render()}reset(){this.value=this.defaultValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=!1,this.done=this.aborted=!0,this.fire(),this.render(!1),this.close(),this.options.exitWhenNo&&Nt.exit(0)}submit(){this.value=this.value??!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.close(),this.options.exitWhenNo&&!this.value&&Nt.exit(0)}_(t,r){if(t.toLowerCase()==="y"){this.value=!0,this.submit();return}if(t.toLowerCase()==="n"){this.value=!1,this.submit();return}this.bell()}render(t=this.value){if(super.render(),this.done){De.persistPrompt(Ue({...this.options,content:`${this.options.content} ${t?Me.bold.greenBright("Yes."):Me.bold.redBright("No.")}`}));return}De.updatePrompt(Ue({...this.options,content:`${this.options.content} ${this.defaultValue?Me.blueBright("[Y/n] "):Me.blueBright("[y/N] ")}`}))}};var ol=$.object({id:$.union([$.string(),$.number()]).transform(Number),name:$.string().nullish(),email:$.string()}),ut=o(async e=>{let t=je(e);if(t)try{let r=await ft({context:{ctx:e},url:`https://${R.domains.services}/auth/api/current-user`,headers:t,responseType:"json",resolveBodyOnly:!0}),n=ol.parse(r);return e.log.info("loaded user",{user:{id:n.id}},{user:n}),oi(n),n}catch(r){Zn(e,r);return}},"getUser"),Am=o(async(e,t)=>{let r=await ut(e);return r||(e.log.info("prompting user to log in"),fe({ensureEmptyLineAbove:!0,content:`You must be logged in to use "ggt ${t}".`}),await yo({ensureEmptyLineAbove:!0,content:"Would you like to log in?"}),await bo(e,{_:[]}),r=await ut(e),sl(r,"missing user after successful login"),r)},"getUserOrLogin");var Wm=o(()=>ne`
51
+ Log in to your account.
52
+
53
+ {bold Usage}
54
+ ggt login
55
+ `,"usage"),cl=o(async e=>{let t;try{let r=await mr(),n=new Promise((s,a)=>{t=al.createServer(async(l,c)=>{let f=new URL(`https://${R.domains.services}/auth/cli`);try{Sn(l.url,"missing url");let d=new URL(l.url,`http://localhost:${r}`).searchParams.get("session");Sn(d,"missing session"),Je(e,d);let p=await ut(e);Sn(p,"missing user after successful login"),p.name?fe({ensureEmptyLineAbove:!0,content:ne`Hello, ${p.name} {gray (${p.email})}`}):fe({ensureEmptyLineAbove:!0,content:`Hello, ${p.email}`}),f.searchParams.set("success","true"),s()}catch(d){Je(e,void 0),f.searchParams.set("success","false"),a(d)}finally{c.writeHead(303,{Location:f.toString()}),c.end()}}),e.log.info("starting login server",{port:r}),t.listen(r)}),i=new URL(`https://${R.domains.services}/auth/login`);i.searchParams.set("returnTo",`https://${R.domains.services}/auth/cli/callback?port=${r}`);try{e.log.info("opening browser",{url:i.toString()}),await Xn(i.toString()),fe({ensureEmptyLineAbove:!0,content:ne`
56
+ We've opened Gadget's login page using your default browser.
57
+
58
+ Please log in and then return to this terminal.
59
+ `})}catch(s){e.log.error("failed to open browser",{error:s}),fe({ensureEmptyLineAbove:!0,content:ne`
60
+ Please open the following URL in your browser and log in:
61
+
62
+ {gray ${i.toString()}}
63
+
64
+ Once logged in, return to this terminal.
65
+ `})}await n}finally{t?.close()}},"run"),bo=cl;export{ye as a,Eu as b,kc as c,Lh as d,Ie as e,He as f,hn as g,Is as h,ui as i,Ns as j,Fh as k,Ds as l,jh as m,$e as n,ir as o,xt as p,Xn as q,Wm as r,cl as s,bo as t,yo as u,ut as v,Am as w,sr as x,Rc as y,Pd as z,Nd as A,Id as B,Rd as C,M as D,Ip as E,Rp as F,zp as G,ar as H,ft as I};
66
+ //# sourceMappingURL=chunk-XQWSZW7K.js.map