@gadgetinc/ggt 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +26 -1
  2. package/dist/{add-TWLGKL2T.js → add-7MLI3TCY.js} +8 -8
  3. package/dist/add-7MLI3TCY.js.map +7 -0
  4. package/dist/agent-plugin-543K6WBH.js +11 -0
  5. package/dist/agent-plugin-543K6WBH.js.map +7 -0
  6. package/dist/chunk-2HJS3KFB.js +2 -0
  7. package/dist/{chunk-T6UHSWMT.js.map → chunk-2HJS3KFB.js.map} +2 -2
  8. package/dist/{chunk-3OM5WM7E.js → chunk-3WKH3DJL.js} +2 -2
  9. package/dist/chunk-577KP32Z.js +8 -0
  10. package/dist/chunk-577KP32Z.js.map +7 -0
  11. package/dist/{chunk-R6KJLEKY.js → chunk-6FVHOLT7.js} +2 -2
  12. package/dist/chunk-6FVHOLT7.js.map +7 -0
  13. package/dist/{chunk-HCULGPBH.js → chunk-72J7X5LR.js} +2 -2
  14. package/dist/{chunk-HCULGPBH.js.map → chunk-72J7X5LR.js.map} +2 -2
  15. package/dist/{chunk-JG2QCDK2.js → chunk-ALSXPCRD.js} +5 -5
  16. package/dist/{chunk-JG2QCDK2.js.map → chunk-ALSXPCRD.js.map} +4 -4
  17. package/dist/{chunk-SIR6HLN3.js → chunk-CNNOPE5K.js} +22 -22
  18. package/dist/chunk-CNNOPE5K.js.map +7 -0
  19. package/dist/chunk-ETKWDO4V.js +2 -0
  20. package/dist/chunk-ETKWDO4V.js.map +7 -0
  21. package/dist/{chunk-DR4CXBD6.js → chunk-F6BGQ4LG.js} +2 -2
  22. package/dist/{chunk-DR4CXBD6.js.map → chunk-F6BGQ4LG.js.map} +2 -2
  23. package/dist/{chunk-SVWK2NXG.js → chunk-FE5O5VX4.js} +2 -2
  24. package/dist/chunk-FE5O5VX4.js.map +7 -0
  25. package/dist/{chunk-F255O64V.js → chunk-GZTHIOXS.js} +2 -2
  26. package/dist/chunk-GZTHIOXS.js.map +7 -0
  27. package/dist/chunk-IQSZEOYY.js +283 -0
  28. package/dist/{chunk-442CSROP.js.map → chunk-IQSZEOYY.js.map} +4 -4
  29. package/dist/chunk-N5FFICAP.js +9 -0
  30. package/dist/chunk-N5FFICAP.js.map +7 -0
  31. package/dist/chunk-TGCJ6TMW.js +10 -0
  32. package/dist/chunk-TGCJ6TMW.js.map +7 -0
  33. package/dist/{chunk-XC4F2TLW.js → chunk-ULJYEUQG.js} +19 -19
  34. package/dist/chunk-ULJYEUQG.js.map +7 -0
  35. package/dist/{chunk-2742UPMB.js → chunk-UVVKKUYG.js} +2 -2
  36. package/dist/chunk-UVVKKUYG.js.map +7 -0
  37. package/dist/{chunk-WB6O2V5D.js → chunk-WZ2PO6H2.js} +2 -2
  38. package/dist/{chunk-OUIZQC4D.js → chunk-X4XSYLCE.js} +2 -2
  39. package/dist/{chunk-OUIZQC4D.js.map → chunk-X4XSYLCE.js.map} +2 -2
  40. package/dist/{configure-UJS7V2JX.js → configure-PYRXYNGZ.js} +2 -2
  41. package/dist/configure-PYRXYNGZ.js.map +7 -0
  42. package/dist/{debugger-QN2MCLBL.js → debugger-VKLUEWIN.js} +2 -2
  43. package/dist/debugger-VKLUEWIN.js.map +7 -0
  44. package/dist/{deploy-J74PHPQA.js → deploy-JCREEGBA.js} +3 -3
  45. package/dist/deploy-JCREEGBA.js.map +7 -0
  46. package/dist/{dev-GGUSOOYP.js → dev-Y2GLI7EH.js} +3 -3
  47. package/dist/{dev-GGUSOOYP.js.map → dev-Y2GLI7EH.js.map} +3 -3
  48. package/dist/env-5OPHX3MC.js +135 -0
  49. package/dist/env-5OPHX3MC.js.map +7 -0
  50. package/dist/esm-3JVXH7DT.js +37 -0
  51. package/dist/esm-3JVXH7DT.js.map +7 -0
  52. package/dist/{eval-L6WHUFLU.js → eval-LZPZ6PBQ.js} +3 -3
  53. package/dist/{eval-L6WHUFLU.js.map → eval-LZPZ6PBQ.js.map} +2 -2
  54. package/dist/ggt-KUAF6WUA.js +45 -0
  55. package/dist/ggt-KUAF6WUA.js.map +7 -0
  56. package/dist/{list-756D46N5.js → list-IANT7SNF.js} +2 -2
  57. package/dist/list-IANT7SNF.js.map +7 -0
  58. package/dist/login-TYRZLN5S.js +2 -0
  59. package/dist/{logout-LQABTJFD.js → logout-P75XYYZ6.js} +2 -2
  60. package/dist/logout-P75XYYZ6.js.map +7 -0
  61. package/dist/{logs-AQZB272X.js → logs-SBMD6JSR.js} +2 -2
  62. package/dist/logs-SBMD6JSR.js.map +7 -0
  63. package/dist/main.js +1 -1
  64. package/dist/{open-OMZWPQ66.js → open-JPAMII4K.js} +2 -2
  65. package/dist/open-JPAMII4K.js.map +7 -0
  66. package/dist/problems-EZRSHLZT.js +14 -0
  67. package/dist/problems-EZRSHLZT.js.map +7 -0
  68. package/dist/{pull-XYCYN7QN.js → pull-R3PMBVOT.js} +2 -2
  69. package/dist/pull-R3PMBVOT.js.map +7 -0
  70. package/dist/push-5XEEESQQ.js +2 -0
  71. package/dist/{status-PWAXNK5G.js → status-RJN5ES6S.js} +2 -2
  72. package/dist/status-RJN5ES6S.js.map +7 -0
  73. package/dist/update-X7YS3MNH.js +2 -0
  74. package/dist/{var-N4WGGJXZ.js → var-PC6KQUPF.js} +4 -4
  75. package/dist/var-PC6KQUPF.js.map +7 -0
  76. package/dist/{version-AJKSJJDC.js → version-GZJOU2CV.js} +2 -2
  77. package/dist/version-GZJOU2CV.js.map +7 -0
  78. package/dist/{whoami-KJYDSQSD.js → whoami-GKPGPZ3B.js} +2 -2
  79. package/dist/whoami-GKPGPZ3B.js.map +7 -0
  80. package/package.json +6 -6
  81. package/dist/add-TWLGKL2T.js.map +0 -7
  82. package/dist/agent-plugin-TN24O7FB.js +0 -10
  83. package/dist/agent-plugin-TN24O7FB.js.map +0 -7
  84. package/dist/chunk-2742UPMB.js.map +0 -7
  85. package/dist/chunk-442CSROP.js +0 -66
  86. package/dist/chunk-F255O64V.js.map +0 -7
  87. package/dist/chunk-JKZNSRLU.js +0 -8
  88. package/dist/chunk-JKZNSRLU.js.map +0 -7
  89. package/dist/chunk-JYE5LLIF.js +0 -9
  90. package/dist/chunk-JYE5LLIF.js.map +0 -7
  91. package/dist/chunk-MW6MXMSN.js +0 -2
  92. package/dist/chunk-MW6MXMSN.js.map +0 -7
  93. package/dist/chunk-R6KJLEKY.js.map +0 -7
  94. package/dist/chunk-SIR6HLN3.js.map +0 -7
  95. package/dist/chunk-SVWK2NXG.js.map +0 -7
  96. package/dist/chunk-T6UHSWMT.js +0 -2
  97. package/dist/chunk-XC4F2TLW.js.map +0 -7
  98. package/dist/chunk-YFUOXDPK.js +0 -10
  99. package/dist/chunk-YFUOXDPK.js.map +0 -7
  100. package/dist/chunk-ZSREFZXV.js +0 -211
  101. package/dist/chunk-ZSREFZXV.js.map +0 -7
  102. package/dist/configure-UJS7V2JX.js.map +0 -7
  103. package/dist/debugger-QN2MCLBL.js.map +0 -7
  104. package/dist/deploy-J74PHPQA.js.map +0 -7
  105. package/dist/esm-D77XRR65.js +0 -38
  106. package/dist/esm-D77XRR65.js.map +0 -7
  107. package/dist/ggt-5XNRJZSW.js +0 -44
  108. package/dist/ggt-5XNRJZSW.js.map +0 -7
  109. package/dist/list-756D46N5.js.map +0 -7
  110. package/dist/login-GMWQRH7V.js +0 -2
  111. package/dist/logout-LQABTJFD.js.map +0 -7
  112. package/dist/logs-AQZB272X.js.map +0 -7
  113. package/dist/open-OMZWPQ66.js.map +0 -7
  114. package/dist/problems-FZJKH52E.js +0 -14
  115. package/dist/problems-FZJKH52E.js.map +0 -7
  116. package/dist/pull-XYCYN7QN.js.map +0 -7
  117. package/dist/push-3QM7ZFTC.js +0 -2
  118. package/dist/status-PWAXNK5G.js.map +0 -7
  119. package/dist/update-QIQFJFRQ.js +0 -2
  120. package/dist/var-N4WGGJXZ.js.map +0 -7
  121. package/dist/version-AJKSJJDC.js.map +0 -7
  122. package/dist/whoami-KJYDSQSD.js.map +0 -7
  123. /package/dist/{chunk-3OM5WM7E.js.map → chunk-3WKH3DJL.js.map} +0 -0
  124. /package/dist/{chunk-WB6O2V5D.js.map → chunk-WZ2PO6H2.js.map} +0 -0
  125. /package/dist/{login-GMWQRH7V.js.map → login-TYRZLN5S.js.map} +0 -0
  126. /package/dist/{push-3QM7ZFTC.js.map → push-5XEEESQQ.js.map} +0 -0
  127. /package/dist/{update-QIQFJFRQ.js.map → update-X7YS3MNH.js.map} +0 -0
@@ -0,0 +1,283 @@
1
+ import{a as Jn,b as rt,c as Kn}from"./chunk-GZTHIOXS.js";import{a as Fn,c as zn,d as Xn}from"./chunk-72J7X5LR.js";import{G as qn,U as tt,V as Wn,X as xr,Y as le,Z as Hn,_ as we,a as Bn,b as Ge,c as Dn,ca as ne,d as Se,da as Qn,e as I,ea as G,f as Un,fa as Yn,g as Wt,h as _e,ha as D,i as Vn,j as _t,k as Ze,l as xt,la as vr,m as et,ma as je,o as vt,r as Gn,ra as P,sa as qe,ta as de,x as jn}from"./chunk-ALSXPCRD.js";import{a as qt}from"./chunk-GFQYFEEH.js";import{a as o,b as z,d as Q,f as se,h}from"./chunk-7DYQUG5M.js";var Ri=Q((Dr,Fr)=>{h();(function(e,t){typeof Dr=="object"&&typeof Fr<"u"?Fr.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs=t()})(Dr,(function(){"use strict";var e=1e3,t=6e4,r=36e5,n="millisecond",i="second",s="minute",a="hour",c="day",l="week",u="month",f="quarter",d="year",m="date",p="Invalid Date",E=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,x=/\[([^\]]+)]|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(R){var v=["th","st","nd","rd"],g=R%100;return"["+R+(v[(g-20)%10]||v[g]||v[0])+"]"},"ordinal")},L=o(function(R,v,g){var b=String(R);return!b||b.length>=v?R:""+Array(v+1-b.length).join(g)+R},"m"),B={s:L,z:o(function(R){var v=-R.utcOffset(),g=Math.abs(v),b=Math.floor(g/60),y=g%60;return(v<=0?"+":"-")+L(b,2,"0")+":"+L(y,2,"0")},"z"),m:o(function R(v,g){if(v.date()<g.date())return-R(g,v);var b=12*(g.year()-v.year())+(g.month()-v.month()),y=v.clone().add(b,u),_=g-y<0,S=v.clone().add(b+(_?-1:1),u);return+(-(b+(g-y)/(_?y-S:S-y))||0)},"t"),a:o(function(R){return R<0?Math.ceil(R)||0:Math.floor(R)},"a"),p:o(function(R){return{M:u,y:d,w:l,d:c,D:m,h:a,m:s,s:i,ms:n,Q:f}[R]||String(R||"").toLowerCase().replace(/s$/,"")},"p"),u:o(function(R){return R===void 0},"u")},k="en",$={};$[k]=T;var M="$isDayjsObject",W=o(function(R){return R instanceof K||!(!R||!R[M])},"S"),J=o(function R(v,g,b){var y;if(!v)return k;if(typeof v=="string"){var _=v.toLowerCase();$[_]&&(y=_),g&&($[_]=g,y=_);var S=v.split("-");if(!y&&S.length>1)return R(S[0])}else{var A=v.name;$[A]=v,y=A}return!b&&y&&(k=y),y||!b&&k},"t"),w=o(function(R,v){if(W(R))return R.clone();var g=typeof v=="object"?v:{};return g.date=R,g.args=arguments,new K(g)},"O"),O=B;O.l=J,O.i=W,O.w=function(R,v){return w(R,{locale:v.$L,utc:v.$u,x:v.$x,$offset:v.$offset})};var K=(function(){function R(g){this.$L=J(g.locale,null,!0),this.parse(g),this.$x=this.$x||g.x||{},this[M]=!0}o(R,"M");var v=R.prototype;return v.parse=function(g){this.$d=(function(b){var y=b.date,_=b.utc;if(y===null)return new Date(NaN);if(O.u(y))return new Date;if(y instanceof Date)return new Date(y);if(typeof y=="string"&&!/Z$/i.test(y)){var S=y.match(E);if(S){var A=S[2]-1||0,C=(S[7]||"0").substring(0,3);return _?new Date(Date.UTC(S[1],A,S[3]||1,S[4]||0,S[5]||0,S[6]||0,C)):new Date(S[1],A,S[3]||1,S[4]||0,S[5]||0,S[6]||0,C)}}return new Date(y)})(g),this.init()},v.init=function(){var g=this.$d;this.$y=g.getFullYear(),this.$M=g.getMonth(),this.$D=g.getDate(),this.$W=g.getDay(),this.$H=g.getHours(),this.$m=g.getMinutes(),this.$s=g.getSeconds(),this.$ms=g.getMilliseconds()},v.$utils=function(){return O},v.isValid=function(){return this.$d.toString()!==p},v.isSame=function(g,b){var y=w(g);return this.startOf(b)<=y&&y<=this.endOf(b)},v.isAfter=function(g,b){return w(g)<this.startOf(b)},v.isBefore=function(g,b){return this.endOf(b)<w(g)},v.$g=function(g,b,y){return O.u(g)?this[b]:this.set(y,g)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(g,b){var y=this,_=!!O.u(b)||b,S=O.p(g),A=o(function(Ne,ee){var ke=O.w(y.$u?Date.UTC(y.$y,ee,Ne):new Date(y.$y,ee,Ne),y);return _?ke:ke.endOf(c)},"l"),C=o(function(Ne,ee){return O.w(y.toDate()[Ne].apply(y.toDate("s"),(_?[0,0,0,0]:[23,59,59,999]).slice(ee)),y)},"$"),U=this.$W,Y=this.$M,Z=this.$D,ae="set"+(this.$u?"UTC":"");switch(S){case d:return _?A(1,0):A(31,11);case u:return _?A(1,Y):A(0,Y+1);case l:var V=this.$locale().weekStart||0,H=(U<V?U+7:U)-V;return A(_?Z-H:Z+(6-H),Y);case c:case m:return C(ae+"Hours",0);case a:return C(ae+"Minutes",1);case s:return C(ae+"Seconds",2);case i:return C(ae+"Milliseconds",3);default:return this.clone()}},v.endOf=function(g){return this.startOf(g,!1)},v.$set=function(g,b){var y,_=O.p(g),S="set"+(this.$u?"UTC":""),A=(y={},y[c]=S+"Date",y[m]=S+"Date",y[u]=S+"Month",y[d]=S+"FullYear",y[a]=S+"Hours",y[s]=S+"Minutes",y[i]=S+"Seconds",y[n]=S+"Milliseconds",y)[_],C=_===c?this.$D+(b-this.$W):b;if(_===u||_===d){var U=this.clone().set(m,1);U.$d[A](C),U.init(),this.$d=U.set(m,Math.min(this.$D,U.daysInMonth())).$d}else A&&this.$d[A](C);return this.init(),this},v.set=function(g,b){return this.clone().$set(g,b)},v.get=function(g){return this[O.p(g)]()},v.add=function(g,b){var y,_=this;g=Number(g);var S=O.p(b),A=o(function(Y){var Z=w(_);return O.w(Z.date(Z.date()+Math.round(Y*g)),_)},"y");if(S===u)return this.set(u,this.$M+g);if(S===d)return this.set(d,this.$y+g);if(S===c)return A(1);if(S===l)return A(7);var C=(y={},y[s]=t,y[a]=r,y[i]=e,y)[S]||1,U=this.$d.getTime()+g*C;return O.w(U,this)},v.subtract=function(g,b){return this.add(-1*g,b)},v.format=function(g){var b=this,y=this.$locale();if(!this.isValid())return y.invalidDate||p;var _=g||"YYYY-MM-DDTHH:mm:ssZ",S=O.z(this),A=this.$H,C=this.$m,U=this.$M,Y=y.weekdays,Z=y.months,ae=y.meridiem,V=o(function(ee,ke,bt,jt){return ee&&(ee[ke]||ee(b,_))||bt[ke].slice(0,jt)},"h"),H=o(function(ee){return O.s(A%12||12,ee,"0")},"d"),Ne=ae||function(ee,ke,bt){var jt=ee<12?"AM":"PM";return bt?jt.toLowerCase():jt};return _.replace(x,(function(ee,ke){return ke||(function(bt){switch(bt){case"YY":return String(b.$y).slice(-2);case"YYYY":return O.s(b.$y,4,"0");case"M":return U+1;case"MM":return O.s(U+1,2,"0");case"MMM":return V(y.monthsShort,U,Z,3);case"MMMM":return V(Z,U);case"D":return b.$D;case"DD":return O.s(b.$D,2,"0");case"d":return String(b.$W);case"dd":return V(y.weekdaysMin,b.$W,Y,2);case"ddd":return V(y.weekdaysShort,b.$W,Y,3);case"dddd":return Y[b.$W];case"H":return String(A);case"HH":return O.s(A,2,"0");case"h":return H(1);case"hh":return H(2);case"a":return Ne(A,C,!0);case"A":return Ne(A,C,!1);case"m":return String(C);case"mm":return O.s(C,2,"0");case"s":return String(b.$s);case"ss":return O.s(b.$s,2,"0");case"SSS":return O.s(b.$ms,3,"0");case"Z":return S}return null})(ee)||S.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(g,b,y){var _,S=this,A=O.p(b),C=w(g),U=(C.utcOffset()-this.utcOffset())*t,Y=this-C,Z=o(function(){return O.m(S,C)},"D");switch(A){case d:_=Z()/12;break;case u:_=Z();break;case f:_=Z()/3;break;case l:_=(Y-U)/6048e5;break;case c:_=(Y-U)/864e5;break;case a:_=Y/r;break;case s:_=Y/t;break;case i:_=Y/e;break;default:_=Y}return y?_:O.a(_)},v.daysInMonth=function(){return this.endOf(u).$D},v.$locale=function(){return $[this.$L]},v.locale=function(g,b){if(!g)return this.$L;var y=this.clone(),_=J(g,b,!0);return _&&(y.$L=_),y},v.clone=function(){return O.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},R})(),Et=K.prototype;return w.prototype=Et,[["$ms",n],["$s",i],["$m",s],["$H",a],["$W",c],["$M",u],["$y",d],["$D",m]].forEach((function(R){Et[R[1]]=function(v){return this.$g(v,R[0],R[1])}})),w.extend=function(R,v){return R.$i||(R(v,K,w),R.$i=!0),w},w.locale=J,w.isDayjs=W,w.unix=function(R){return w(1e3*R)},w.en=$[k],w.Ls=$,w.p={},w}))});var Mi=Q((lh,qr)=>{"use strict";h();var Ra=Object.prototype.hasOwnProperty,ie="~";function Rt(){}o(Rt,"Events");Object.create&&(Rt.prototype=Object.create(null),new Rt().__proto__||(ie=!1));function La(e,t,r){this.fn=e,this.context=t,this.once=r||!1}o(La,"EE");function $i(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new La(r,n||e,i),a=ie?ie+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($i,"addListener");function tr(e,t){--e._eventsCount===0?e._events=new Rt:delete e._events[t]}o(tr,"clearEvent");function te(){this._events=new Rt,this._eventsCount=0}o(te,"EventEmitter");te.prototype.eventNames=o(function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Ra.call(r,n)&&t.push(ie?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t},"eventNames");te.prototype.listeners=o(function(t){var r=ie?ie+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");te.prototype.listenerCount=o(function(t){var r=ie?ie+t:t,n=this._events[r];return n?n.fn?1:n.length:0},"listenerCount");te.prototype.emit=o(function(t,r,n,i,s,a){var c=ie?ie+t:t;if(!this._events[c])return!1;var l=this._events[c],u=arguments.length,f,d;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,r),!0;case 3:return l.fn.call(l.context,r,n),!0;case 4:return l.fn.call(l.context,r,n,i),!0;case 5:return l.fn.call(l.context,r,n,i,s),!0;case 6:return l.fn.call(l.context,r,n,i,s,a),!0}for(d=1,f=new Array(u-1);d<u;d++)f[d-1]=arguments[d];l.fn.apply(l.context,f)}else{var m=l.length,p;for(d=0;d<m;d++)switch(l[d].once&&this.removeListener(t,l[d].fn,void 0,!0),u){case 1:l[d].fn.call(l[d].context);break;case 2:l[d].fn.call(l[d].context,r);break;case 3:l[d].fn.call(l[d].context,r,n);break;case 4:l[d].fn.call(l[d].context,r,n,i);break;default:if(!f)for(p=1,f=new Array(u-1);p<u;p++)f[p-1]=arguments[p];l[d].fn.apply(l[d].context,f)}}return!0},"emit");te.prototype.on=o(function(t,r,n){return $i(this,t,r,n,!1)},"on");te.prototype.once=o(function(t,r,n){return $i(this,t,r,n,!0)},"once");te.prototype.removeListener=o(function(t,r,n,i){var s=ie?ie+t:t;if(!this._events[s])return this;if(!r)return tr(this,s),this;var a=this._events[s];if(a.fn)a.fn===r&&(!i||a.once)&&(!n||a.context===n)&&tr(this,s);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==r||i&&!a[c].once||n&&a[c].context!==n)&&l.push(a[c]);l.length?this._events[s]=l.length===1?l[0]:l:tr(this,s)}return this},"removeListener");te.prototype.removeAllListeners=o(function(t){var r;return t?(r=ie?ie+t:t,this._events[r]&&tr(this,r)):(this._events=new Rt,this._eventsCount=0),this},"removeAllListeners");te.prototype.off=te.prototype.removeListener;te.prototype.addListener=te.prototype.on;te.prefixed=ie;te.EventEmitter=te;typeof qr<"u"&&(qr.exports=te)});var Te=Q((Lh,Ui)=>{"use strict";h();var Di=["nodebuffer","arraybuffer","fragments"],Fi=typeof Blob<"u";Fi&&Di.push("blob");Ui.exports={BINARY_TYPES:Di,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Fi,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:o(()=>{},"NOOP")}});var It=Q((Nh,rr)=>{"use strict";h();var{EMPTY_BUFFER:Aa}=Te(),zr=Buffer[Symbol.species];function Ia(e,t){if(e.length===0)return Aa;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 zr(r.buffer,r.byteOffset,n):r}o(Ia,"concat");function Vi(e,t,r,n,i){for(let s=0;s<i;s++)r[n+s]=e[s]^t[s&3]}o(Vi,"_mask");function Gi(e,t){for(let r=0;r<e.length;r++)e[r]^=t[r&3]}o(Gi,"_unmask");function Na(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}o(Na,"toArrayBuffer");function Jr(e){if(Jr.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new zr(e):ArrayBuffer.isView(e)?t=new zr(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Jr.readOnly=!1),t}o(Jr,"toBuffer");rr.exports={concat:Ia,mask:Vi,toArrayBuffer:Na,toBuffer:Jr,unmask:Gi};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=z("bufferutil");rr.exports.mask=function(t,r,n,i,s){s<48?Vi(t,r,n,i,s):e.mask(t,r,n,i,s)},rr.exports.unmask=function(t,r){t.length<32?Gi(t,r):e.unmask(t,r)}}catch{}});var Wi=Q(($h,qi)=>{"use strict";h();var ji=Symbol("kDone"),Kr=Symbol("kRun"),Xr=class{static{o(this,"Limiter")}constructor(t){this[ji]=()=>{this.pending--,this[Kr]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[Kr]()}[Kr](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[ji])}}};qi.exports=Xr});var kt=Q((Dh,zi)=>{"use strict";h();var Nt=z("zlib"),Hi=It(),ka=Wi(),{kStatusCode:Qi}=Te(),Pa=Buffer[Symbol.species],$a=Buffer.from([0,0,255,255]),ir=Symbol("permessage-deflate"),Oe=Symbol("total-length"),lt=Symbol("callback"),Me=Symbol("buffers"),ct=Symbol("error"),nr,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,!nr){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;nr=new ka(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[lt];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){nr.add(i=>{this._decompress(t,r,(s,a)=>{i(),n(s,a)})})}compress(t,r,n){nr.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"?Nt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Nt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[ir]=this,this._inflate[Oe]=0,this._inflate[Me]=[],this._inflate.on("error",Ba),this._inflate.on("data",Yi)}this._inflate[lt]=n,this._inflate.write(t),r&&this._inflate.write($a),this._inflate.flush(()=>{let s=this._inflate[ct];if(s){this._inflate.close(),this._inflate=null,n(s);return}let a=Hi.concat(this._inflate[Me],this._inflate[Oe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Oe]=0,this._inflate[Me]=[],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"?Nt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Nt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Oe]=0,this._deflate[Me]=[],this._deflate.on("data",Ma)}this._deflate[lt]=n,this._deflate.write(t),this._deflate.flush(Nt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Hi.concat(this._deflate[Me],this._deflate[Oe]);r&&(s=new Pa(s.buffer,s.byteOffset,s.length-4)),this._deflate[lt]=null,this._deflate[Oe]=0,this._deflate[Me]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,s)})}};zi.exports=Zr;function Ma(e){this[Me].push(e),this[Oe]+=e.length}o(Ma,"deflateOnData");function Yi(e){if(this[Oe]+=e.length,this[ir]._maxPayload<1||this[Oe]<=this[ir]._maxPayload){this[Me].push(e);return}this[ct]=new RangeError("Max payload size exceeded"),this[ct].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ct][Qi]=1009,this.removeListener("data",Yi),this.reset()}o(Yi,"inflateOnData");function Ba(e){if(this[ir]._inflate=null,this[ct]){this[lt](this[ct]);return}e[Qi]=1007,this[lt](e)}o(Ba,"inflateOnError")});var ut=Q((Vh,sr)=>{"use strict";h();var{isUtf8:Ji}=z("buffer"),{hasBlob:Da}=Te(),Fa=[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 Ua(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}o(Ua,"isValidStatusCode");function en(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(en,"_isValidUTF8");function Va(e){return Da&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}o(Va,"isBlob");sr.exports={isBlob:Va,isValidStatusCode:Ua,isValidUTF8:en,tokenChars:Fa};if(Ji)sr.exports.isValidUTF8=function(e){return e.length<24?en(e):Ji(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=z("utf-8-validate");sr.exports.isValidUTF8=function(t){return t.length<32?en(t):e(t)}}catch{}});var on=Q((qh,ns)=>{"use strict";h();var{Writable:Ga}=z("stream"),Ki=kt(),{BINARY_TYPES:ja,EMPTY_BUFFER:Xi,kStatusCode:qa,kWebSocket:Wa}=Te(),{concat:tn,toArrayBuffer:Ha,unmask:Qa}=It(),{isValidStatusCode:Ya,isValidUTF8:Zi}=ut(),or=Buffer[Symbol.species],me=0,es=1,ts=2,rs=3,rn=4,nn=5,ar=6,sn=class extends Ga{static{o(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||ja[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[Wa]=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=me}_write(t,r,n){if(this._opcode===8&&this._state==me)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 or(n.buffer,n.byteOffset+t,n.length-t),new or(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 or(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 me:this.getInfo(t);break;case es:this.getPayloadLength16(t);break;case ts:this.getPayloadLength64(t);break;case rs:this.getMask();break;case rn:this.getData(t);break;case nn:case ar: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[Ki.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=es:this._payloadLength===127?this._state=ts: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=rs:this._state=rn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=rn}getData(t){let r=Xi;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&&Qa(r,this._mask)}if(this._opcode>7){this.controlMessage(r,t);return}if(this._compressed){this._state=nn,this.decompress(r,t);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(t)}decompress(t,r){this._extensions[Ki.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===me&&this.startLoop(r)})}dataMessage(t){if(!this._fin){this._state=me;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=tn(n,r):this._binaryType==="arraybuffer"?i=Ha(tn(n,r)):this._binaryType==="blob"?i=new Blob(n):i=n,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=me):(this._state=ar,setImmediate(()=>{this.emit("message",i,!0),this._state=me,this.startLoop(t)}))}else{let i=tn(n,r);if(!this._skipUTF8Validation&&!Zi(i)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._state===nn||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=me):(this._state=ar,setImmediate(()=>{this.emit("message",i,!1),this._state=me,this.startLoop(t)}))}}controlMessage(t,r){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,Xi),this.end();else{let n=t.readUInt16BE(0);if(!Ya(n)){let s=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let i=new or(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!Zi(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=me;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=me):(this._state=ar,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=me,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[qa]=i,a}};ns.exports=sn});var cn=Q((Yh,os)=>{"use strict";h();var{Duplex:Qh}=z("stream"),{randomFillSync:za}=z("crypto"),is=kt(),{EMPTY_BUFFER:Ja,kWebSocket:Ka,NOOP:Xa}=Te(),{isBlob:ft,isValidStatusCode:Za}=ut(),{mask:ss,toBuffer:Qe}=It(),ge=Symbol("kByteLength"),el=Buffer.alloc(4),lr=8*1024,Ye,ht=lr,be=0,tl=1,rl=2,an=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=Xa,this[Ka]=void 0}static frame(t,r){let n,i=!1,s=2,a=!1;r.mask&&(n=r.maskBuffer||el,r.generateMask?r.generateMask(n):(ht===lr&&(Ye===void 0&&(Ye=Buffer.alloc(lr)),za(Ye,0,lr),ht=0),n[0]=Ye[ht++],n[1]=Ye[ht++],n[2]=Ye[ht++],n[3]=Ye[ht++]),a=(n[0]|n[1]|n[2]|n[3])===0,s=6);let c;typeof t=="string"?(!r.mask||a)&&r[ge]!==void 0?c=r[ge]:(t=Buffer.from(t),c=t.length):(c=t.length,i=r.mask&&r.readOnly&&!a);let l=c;c>=65536?(s+=8,l=127):c>125&&(s+=2,l=126);let u=Buffer.allocUnsafe(i?c+s:s);return u[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(c,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(c,4,6)),r.mask?(u[1]|=128,u[s-4]=n[0],u[s-3]=n[1],u[s-2]=n[2],u[s-1]=n[3],a?[u,t]:i?(ss(t,n,u,s,c),[u]):(ss(t,n,t,0,c),[u,t])):[u,t]}close(t,r,n,i){let s;if(t===void 0)s=Ja;else{if(typeof t!="number"||!Za(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 c=Buffer.byteLength(r);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(t,0),typeof r=="string"?s.write(r,2):s.set(r,2)}}let a={[ge]: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):ft(t)?(i=t.size,s=!1):(t=Qe(t),i=t.length,s=Qe.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[ge]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};ft(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):ft(t)?(i=t.size,s=!1):(t=Qe(t),i=t.length,s=Qe.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[ge]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};ft(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[is.extensionName],s=r.binary?2:1,a=r.compress,c,l;typeof t=="string"?(c=Buffer.byteLength(t),l=!1):ft(t)?(c=t.size,l=!1):(t=Qe(t),c=t.length,l=Qe.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=c>=i._threshold),this._compress=a):(a=!1,s=0),r.fin&&(this._firstFragment=!0);let u={[ge]:c,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:a};ft(t)?this._state!==be?this.enqueue([this.getBlobData,t,this._compress,u,n]):this.getBlobData(t,this._compress,u,n):this._state!==be?this.enqueue([this.dispatch,t,this._compress,u,n]):this.dispatch(t,this._compress,u,n)}getBlobData(t,r,n,i){this._bufferedBytes+=n[ge],this._state=rl,t.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(ln,this,c,i);return}this._bufferedBytes-=n[ge];let a=Qe(s);r?this.dispatch(a,r,n,i):(this._state=be,this.sendFrame(e.frame(a,n),i),this.dequeue())}).catch(s=>{process.nextTick(nl,this,s,i)})}dispatch(t,r,n,i){if(!r){this.sendFrame(e.frame(t,n),i);return}let s=this._extensions[is.extensionName];this._bufferedBytes+=n[ge],this._state=tl,s.compress(t,n.fin,(a,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");ln(this,l,i);return}this._bufferedBytes-=n[ge],this._state=be,n.readOnly=!1,this.sendFrame(e.frame(c,n),i),this.dequeue()})}dequeue(){for(;this._state===be&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][ge],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][ge],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)}};os.exports=an;function ln(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(ln,"callCallbacks");function nl(e,t,r){ln(e,t,r),e.onerror(t)}o(nl,"onError")});var ms=Q((Kh,ps)=>{"use strict";h();var{kForOnEventAttribute:Pt,kListener:un}=Te(),as=Symbol("kCode"),ls=Symbol("kData"),cs=Symbol("kError"),us=Symbol("kMessage"),fs=Symbol("kReason"),dt=Symbol("kTarget"),hs=Symbol("kType"),ds=Symbol("kWasClean"),Ce=class{static{o(this,"Event")}constructor(t){this[dt]=null,this[hs]=t}get target(){return this[dt]}get type(){return this[hs]}};Object.defineProperty(Ce.prototype,"target",{enumerable:!0});Object.defineProperty(Ce.prototype,"type",{enumerable:!0});var ze=class extends Ce{static{o(this,"CloseEvent")}constructor(t,r={}){super(t),this[as]=r.code===void 0?0:r.code,this[fs]=r.reason===void 0?"":r.reason,this[ds]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[as]}get reason(){return this[fs]}get wasClean(){return this[ds]}};Object.defineProperty(ze.prototype,"code",{enumerable:!0});Object.defineProperty(ze.prototype,"reason",{enumerable:!0});Object.defineProperty(ze.prototype,"wasClean",{enumerable:!0});var pt=class extends Ce{static{o(this,"ErrorEvent")}constructor(t,r={}){super(t),this[cs]=r.error===void 0?null:r.error,this[us]=r.message===void 0?"":r.message}get error(){return this[cs]}get message(){return this[us]}};Object.defineProperty(pt.prototype,"error",{enumerable:!0});Object.defineProperty(pt.prototype,"message",{enumerable:!0});var $t=class extends Ce{static{o(this,"MessageEvent")}constructor(t,r={}){super(t),this[ls]=r.data===void 0?null:r.data}get data(){return this[ls]}};Object.defineProperty($t.prototype,"data",{enumerable:!0});var il={addEventListener(e,t,r={}){for(let i of this.listeners(e))if(!r[Pt]&&i[un]===t&&!i[Pt])return;let n;if(e==="message")n=o(function(s,a){let c=new $t("message",{data:a?s:s.toString()});c[dt]=this,cr(t,this,c)},"onMessage");else if(e==="close")n=o(function(s,a){let c=new ze("close",{code:s,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[dt]=this,cr(t,this,c)},"onClose");else if(e==="error")n=o(function(s){let a=new pt("error",{error:s,message:s.message});a[dt]=this,cr(t,this,a)},"onError");else if(e==="open")n=o(function(){let s=new Ce("open");s[dt]=this,cr(t,this,s)},"onOpen");else return;n[Pt]=!!r[Pt],n[un]=t,r.once?this.once(e,n):this.on(e,n)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[un]===t&&!r[Pt]){this.removeListener(e,r);break}}};ps.exports={CloseEvent:ze,ErrorEvent:pt,Event:Ce,EventTarget:il,MessageEvent:$t};function cr(e,t,r){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}o(cr,"callListener")});var fn=Q((ed,gs)=>{"use strict";h();var{tokenChars:Mt}=ut();function xe(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}o(xe,"push");function sl(e){let t=Object.create(null),r=Object.create(null),n=!1,i=!1,s=!1,a,c,l=-1,u=-1,f=-1,d=0;for(;d<e.length;d++)if(u=e.charCodeAt(d),a===void 0)if(f===-1&&Mt[u]===1)l===-1&&(l=d);else if(d!==0&&(u===32||u===9))f===-1&&l!==-1&&(f=d);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${d}`);f===-1&&(f=d);let p=e.slice(l,f);u===44?(xe(t,p,r),r=Object.create(null)):a=p,l=f=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);else if(c===void 0)if(f===-1&&Mt[u]===1)l===-1&&(l=d);else if(u===32||u===9)f===-1&&l!==-1&&(f=d);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${d}`);f===-1&&(f=d),xe(r,e.slice(l,f),!0),u===44&&(xe(t,a,r),r=Object.create(null),a=void 0),l=f=-1}else if(u===61&&l!==-1&&f===-1)c=e.slice(l,d),l=f=-1;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(i){if(Mt[u]!==1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1?l=d:n||(n=!0),i=!1}else if(s)if(Mt[u]===1)l===-1&&(l=d);else if(u===34&&l!==-1)s=!1,f=d;else if(u===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(u===34&&e.charCodeAt(d-1)===61)s=!0;else if(f===-1&&Mt[u]===1)l===-1&&(l=d);else if(l!==-1&&(u===32||u===9))f===-1&&(f=d);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${d}`);f===-1&&(f=d);let p=e.slice(l,f);n&&(p=p.replace(/\\/g,""),n=!1),xe(r,c,p),u===44&&(xe(t,a,r),r=Object.create(null),a=void 0),c=void 0,l=f=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);if(l===-1||s||u===32||u===9)throw new SyntaxError("Unexpected end of input");f===-1&&(f=d);let m=e.slice(l,f);return a===void 0?xe(t,m,r):(c===void 0?xe(r,m,!0):n?xe(r,c,m.replace(/\\/g,"")):xe(r,c,m),xe(t,a,r)),t}o(sl,"parse");function ol(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(ol,"format");gs.exports={format:ol,parse:sl}});var dr=Q((sd,Rs)=>{"use strict";h();var al=z("events"),ll=z("https"),cl=z("http"),bs=z("net"),ul=z("tls"),{randomBytes:fl,createHash:hl}=z("crypto"),{Duplex:nd,Readable:id}=z("stream"),{URL:hn}=z("url"),Be=kt(),dl=on(),pl=cn(),{isBlob:ml}=ut(),{BINARY_TYPES:ys,CLOSE_TIMEOUT:gl,EMPTY_BUFFER:ur,GUID:yl,kForOnEventAttribute:dn,kListener:El,kStatusCode:bl,kWebSocket:X,NOOP:_s}=Te(),{EventTarget:{addEventListener:_l,removeEventListener:xl}}=ms(),{format:vl,parse:Sl}=fn(),{toBuffer:wl}=It(),xs=Symbol("kAborted"),pn=[8,13],Re=["CONNECTING","OPEN","CLOSING","CLOSED"],Tl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,q=class e extends al{static{o(this,"WebSocket")}constructor(t,r,n){super(),this._binaryType=ys[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ur,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]),vs(this,t,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){ys.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 dl({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),s=new pl(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",Rl),i.on("drain",Ll),i.on("error",Al),i.on("message",Il),i.on("ping",Nl),i.on("pong",kl),s.onerror=Pl,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",Ts),t.on("data",hr),t.on("end",Os),t.on("error",Cs),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[Be.extensionName]&&this._extensions[Be.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){he(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())}),ws(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){mn(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||ur,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){mn(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||ur,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){mn(this,t,n);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Be.extensionName]||(i.compress=!1),this._sender.send(t||ur,i,n)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){he(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:Re.indexOf("CONNECTING")});Object.defineProperty(q.prototype,"CONNECTING",{enumerable:!0,value:Re.indexOf("CONNECTING")});Object.defineProperty(q,"OPEN",{enumerable:!0,value:Re.indexOf("OPEN")});Object.defineProperty(q.prototype,"OPEN",{enumerable:!0,value:Re.indexOf("OPEN")});Object.defineProperty(q,"CLOSING",{enumerable:!0,value:Re.indexOf("CLOSING")});Object.defineProperty(q.prototype,"CLOSING",{enumerable:!0,value:Re.indexOf("CLOSING")});Object.defineProperty(q,"CLOSED",{enumerable:!0,value:Re.indexOf("CLOSED")});Object.defineProperty(q.prototype,"CLOSED",{enumerable:!0,value:Re.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[dn])return t[El];return null},set(t){for(let r of this.listeners(e))if(r[dn]){this.removeListener(e,r);break}typeof t=="function"&&this.addEventListener(e,t,{[dn]:!0})}})});q.prototype.addEventListener=_l;q.prototype.removeEventListener=xl;Rs.exports=q;function vs(e,t,r,n){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:gl,protocolVersion:pn[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,e._closeTimeout=i.closeTimeout,!pn.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${pn.join(", ")})`);let s;if(t instanceof hn)s=t;else try{s=new hn(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:",c=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!a&&!c?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let x=new SyntaxError(l);if(e._redirects===0)throw x;fr(e,x);return}let u=a?443:80,f=fl(16).toString("base64"),d=a?ll.request:cl.request,m=new Set,p;if(i.createConnection=i.createConnection||(a?Cl:Ol),i.defaultPort=i.defaultPort||u,i.port=s.port||u,i.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":f,Connection:"Upgrade",Upgrade:"websocket"},i.path=s.pathname+s.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(p=new Be(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=vl({[Be.extensionName]:p.offer()})),r.length){for(let x of r){if(typeof x!="string"||!Tl.test(x)||m.has(x))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(x)}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}`),c){let x=i.path.split(":");i.socketPath=x[0],i.path=x[1]}let E;if(i.followRedirects){if(e._redirects===0){e._originalIpc=c,e._originalSecure=a,e._originalHostOrSocketPath=c?i.socketPath:s.host;let x=n&&n.headers;if(n={...n,headers:{}},x)for(let[T,L]of Object.entries(x))n.headers[T.toLowerCase()]=L}else if(e.listenerCount("redirect")===0){let x=c?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!x||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,x||delete i.headers.host,i.auth=void 0)}i.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),E=e._req=d(i),e._redirects&&e.emit("redirect",e.url,E)}else E=e._req=d(i);i.timeout&&E.on("timeout",()=>{he(e,E,"Opening handshake has timed out")}),E.on("error",x=>{E===null||E[xs]||(E=e._req=null,fr(e,x))}),E.on("response",x=>{let T=x.headers.location,L=x.statusCode;if(T&&i.followRedirects&&L>=300&&L<400){if(++e._redirects>i.maxRedirects){he(e,E,"Maximum redirects exceeded");return}E.abort();let B;try{B=new hn(T,t)}catch{let $=new SyntaxError(`Invalid URL: ${T}`);fr(e,$);return}vs(e,B,r,n)}else e.emit("unexpected-response",E,x)||he(e,E,`Unexpected server response: ${x.statusCode}`)}),E.on("upgrade",(x,T,L)=>{if(e.emit("upgrade",x),e.readyState!==q.CONNECTING)return;E=e._req=null;let B=x.headers.upgrade;if(B===void 0||B.toLowerCase()!=="websocket"){he(e,T,"Invalid Upgrade header");return}let k=hl("sha1").update(f+yl).digest("base64");if(x.headers["sec-websocket-accept"]!==k){he(e,T,"Invalid Sec-WebSocket-Accept header");return}let $=x.headers["sec-websocket-protocol"],M;if($!==void 0?m.size?m.has($)||(M="Server sent an invalid subprotocol"):M="Server sent a subprotocol but none was requested":m.size&&(M="Server sent no subprotocol"),M){he(e,T,M);return}$&&(e._protocol=$);let W=x.headers["sec-websocket-extensions"];if(W!==void 0){if(!p){he(e,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let J;try{J=Sl(W)}catch{he(e,T,"Invalid Sec-WebSocket-Extensions header");return}let w=Object.keys(J);if(w.length!==1||w[0]!==Be.extensionName){he(e,T,"Server indicated an extension that was not requested");return}try{p.accept(J[Be.extensionName])}catch{he(e,T,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Be.extensionName]=p}e.setSocket(T,L,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(E,e):E.end()}o(vs,"initAsClient");function fr(e,t){e._readyState=q.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}o(fr,"emitErrorAndClose");function Ol(e){return e.path=e.socketPath,bs.connect(e)}o(Ol,"netConnect");function Cl(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=bs.isIP(e.host)?"":e.host),ul.connect(e)}o(Cl,"tlsConnect");function he(e,t,r){e._readyState=q.CLOSING;let n=new Error(r);Error.captureStackTrace(n,he),t.setHeader?(t[xs]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(fr,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}o(he,"abortHandshake");function mn(e,t,r){if(t){let n=ml(t)?t.size:wl(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${e.readyState} (${Re[e.readyState]})`);process.nextTick(r,n)}}o(mn,"sendAfterClose");function Rl(e,t){let r=this[X];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[X]!==void 0&&(r._socket.removeListener("data",hr),process.nextTick(Ss,r._socket),e===1005?r.close():r.close(e,t))}o(Rl,"receiverOnConclude");function Ll(){let e=this[X];e.isPaused||e._socket.resume()}o(Ll,"receiverOnDrain");function Al(e){let t=this[X];t._socket[X]!==void 0&&(t._socket.removeListener("data",hr),process.nextTick(Ss,t._socket),t.close(e[bl])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}o(Al,"receiverOnError");function Es(){this[X].emitClose()}o(Es,"receiverOnFinish");function Il(e,t){this[X].emit("message",e,t)}o(Il,"receiverOnMessage");function Nl(e){let t=this[X];t._autoPong&&t.pong(e,!this._isServer,_s),t.emit("ping",e)}o(Nl,"receiverOnPing");function kl(e){this[X].emit("pong",e)}o(kl,"receiverOnPong");function Ss(e){e.resume()}o(Ss,"resume");function Pl(e){let t=this[X];t.readyState!==q.CLOSED&&(t.readyState===q.OPEN&&(t._readyState=q.CLOSING,ws(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}o(Pl,"senderOnError");function ws(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}o(ws,"setCloseTimer");function Ts(){let e=this[X];if(this.removeListener("close",Ts),this.removeListener("data",hr),this.removeListener("end",Os),e._readyState=q.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);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",Es),e._receiver.on("finish",Es))}o(Ts,"socketOnClose");function hr(e){this[X]._receiver.write(e)||this.pause()}o(hr,"socketOnData");function Os(){let e=this[X];e._readyState=q.CLOSING,e._receiver.end(),this.end()}o(Os,"socketOnEnd");function Cs(){let e=this[X];this.removeListener("error",Cs),this.on("error",_s),e&&(e._readyState=q.CLOSING,this.destroy())}o(Cs,"socketOnError")});var Ns=Q((cd,Is)=>{"use strict";h();var ld=dr(),{Duplex:$l}=z("stream");function Ls(e){e.emit("close")}o(Ls,"emitClose");function Ml(){!this.destroyed&&this._writableState.finished&&this.destroy()}o(Ml,"duplexOnEnd");function As(e){this.removeListener("error",As),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}o(As,"duplexOnError");function Bl(e,t){let r=!0,n=new $l({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",o(function(s,a){let c=!a&&n._readableState.objectMode?s.toString():s;n.push(c)||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(Ls,n);return}let a=!1;e.once("error",o(function(l){a=!0,s(l)},"error")),e.once("close",o(function(){a||s(i),process.nextTick(Ls,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",Ml),n.on("error",As),n}o(Bl,"createWebSocketStream");Is.exports=Bl});var Ps=Q((hd,ks)=>{"use strict";h();var{tokenChars:Dl}=ut();function Fl(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&&Dl[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 c=e.slice(r,n);if(t.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);t.add(c),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(Fl,"parse");ks.exports={parse:Fl}});var Vs=Q((gd,Us)=>{"use strict";h();var Ul=z("events"),pr=z("http"),{Duplex:md}=z("stream"),{createHash:Vl}=z("crypto"),$s=fn(),Je=kt(),Gl=Ps(),jl=dr(),{CLOSE_TIMEOUT:ql,GUID:Wl,kWebSocket:Hl}=Te(),Ql=/^[+/0-9A-Za-z]{22}==$/,Ms=0,Bs=1,Fs=2,gn=class extends Ul{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,closeTimeout:ql,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:jl,...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=pr.createServer((n,i)=>{let s=pr.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=Yl(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=Ms}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===Fs){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Bt,this);return}if(t&&this.once("close",t),this._state!==Bs)if(this._state=Bs,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(Bt,this):process.nextTick(Bt,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Bt(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",Ds);let s=t.headers["sec-websocket-key"],a=t.headers.upgrade,c=+t.headers["sec-websocket-version"];if(t.method!=="GET"){Ke(this,t,r,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){Ke(this,t,r,400,"Invalid Upgrade header");return}if(s===void 0||!Ql.test(s)){Ke(this,t,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){Ke(this,t,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Dt(r,400);return}let l=t.headers["sec-websocket-protocol"],u=new Set;if(l!==void 0)try{u=Gl.parse(l)}catch{Ke(this,t,r,400,"Invalid Sec-WebSocket-Protocol header");return}let f=t.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&f!==void 0){let m=new Je(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let p=$s.parse(f);p[Je.extensionName]&&(m.accept(p[Je.extensionName]),d[Je.extensionName]=m)}catch{Ke(this,t,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:t.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(p,E,x,T)=>{if(!p)return Dt(r,E||401,x,T);this.completeUpgrade(d,s,u,t,r,n,i)});return}if(!this.options.verifyClient(m))return Dt(r,401)}this.completeUpgrade(d,s,u,t,r,n,i)}completeUpgrade(t,r,n,i,s,a,c){if(!s.readable||!s.writable)return s.destroy();if(s[Hl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ms)return Dt(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Vl("sha1").update(r+Wl).digest("base64")}`],f=new this.options.WebSocket(null,void 0,this.options);if(n.size){let d=this.options.handleProtocols?this.options.handleProtocols(n,i):n.values().next().value;d&&(u.push(`Sec-WebSocket-Protocol: ${d}`),f._protocol=d)}if(t[Je.extensionName]){let d=t[Je.extensionName].params,m=$s.format({[Je.extensionName]:[d]});u.push(`Sec-WebSocket-Extensions: ${m}`),f._extensions=t}this.emit("headers",u,i),s.write(u.concat(`\r
2
+ `).join(`\r
3
+ `)),s.removeListener("error",Ds),f.setSocket(s,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Bt,this)})),c(f,i)}};Us.exports=gn;function Yl(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(Yl,"addListeners");function Bt(e){e._state=Fs,e.emit("close")}o(Bt,"emitClose");function Ds(){this.destroy()}o(Ds,"socketOnError");function Dt(e,t,r,n){r=r||pr.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} ${pr.STATUS_CODES[t]}\r
4
+ `+Object.keys(n).map(i=>`${i}: ${n[i]}`).join(`\r
5
+ `)+`\r
6
+ \r
7
+ `+r)}o(Dt,"abortHandshake");function Ke(e,t,r,n,i,s){if(e.listenerCount("wsClientError")){let a=new Error(i);Error.captureStackTrace(a,Ke),e.emit("wsClientError",a,r,t)}else Dt(r,n,i,s)}o(Ke,"abortHandshakeOrEmitwsClientError")});var Js=Q((xn,vn)=>{h();(function(e,t){typeof z=="function"&&typeof xn=="object"&&typeof vn=="object"?vn.exports=t():typeof define=="function"&&define.amd?define(function(){return t()}):e.pluralize=t()})(xn,function(){var e=[],t=[],r={},n={},i={};function s(p){return typeof p=="string"?new RegExp("^"+p+"$","i"):p}o(s,"sanitizeRule");function a(p,E){return p===E?E:p===p.toLowerCase()?E.toLowerCase():p===p.toUpperCase()?E.toUpperCase():p[0]===p[0].toUpperCase()?E.charAt(0).toUpperCase()+E.substr(1).toLowerCase():E.toLowerCase()}o(a,"restoreCase");function c(p,E){return p.replace(/\$(\d{1,2})/g,function(x,T){return E[T]||""})}o(c,"interpolate");function l(p,E){return p.replace(E[0],function(x,T){var L=c(E[1],arguments);return a(x===""?p[T-1]:x,L)})}o(l,"replace");function u(p,E,x){if(!p.length||r.hasOwnProperty(p))return E;for(var T=x.length;T--;){var L=x[T];if(L[0].test(E))return l(E,L)}return E}o(u,"sanitizeWord");function f(p,E,x){return function(T){var L=T.toLowerCase();return E.hasOwnProperty(L)?a(T,L):p.hasOwnProperty(L)?a(T,p[L]):u(L,T,x)}}o(f,"replaceWord");function d(p,E,x,T){return function(L){var B=L.toLowerCase();return E.hasOwnProperty(B)?!0:p.hasOwnProperty(B)?!1:u(B,B,x)===B}}o(d,"checkWord");function m(p,E,x){var T=E===1?m.singular(p):m.plural(p);return(x?E+" ":"")+T}return o(m,"pluralize"),m.plural=f(i,n,e),m.isPlural=d(i,n,e),m.singular=f(n,i,t),m.isSingular=d(n,i,t),m.addPluralRule=function(p,E){e.push([s(p),E])},m.addSingularRule=function(p,E){t.push([s(p),E])},m.addUncountableRule=function(p){if(typeof p=="string"){r[p.toLowerCase()]=!0;return}m.addPluralRule(p,"$0"),m.addSingularRule(p,"$0")},m.addIrregularRule=function(p,E){E=E.toLowerCase(),p=p.toLowerCase(),i[p]=E,n[E]=p},[["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(p){return m.addIrregularRule(p[0],p[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(p){return m.addPluralRule(p[0],p[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(p){return m.addSingularRule(p[0],p[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(m.addUncountableRule),m})});var Zs=Q(mt=>{"use strict";h();mt.__esModule=!0;mt.distance=mt.closest=void 0;var Ae=new Uint32Array(65536),sc=o(function(e,t){for(var r=e.length,n=t.length,i=1<<r-1,s=-1,a=0,c=r,l=r;l--;)Ae[e.charCodeAt(l)]|=1<<l;for(l=0;l<n;l++){var u=Ae[t.charCodeAt(l)],f=u|a;u|=(u&s)+s^s,a|=~(u|s),s&=u,a&i&&c++,s&i&&c--,a=a<<1|1,s=s<<1|~(f|a),a&=f}for(l=r;l--;)Ae[e.charCodeAt(l)]=0;return c},"myers_32"),oc=o(function(e,t){for(var r=t.length,n=e.length,i=[],s=[],a=Math.ceil(r/32),c=Math.ceil(n/32),l=0;l<a;l++)s[l]=-1,i[l]=0;for(var u=0;u<c-1;u++){for(var f=0,d=-1,m=u*32,p=Math.min(32,n)+m,E=m;E<p;E++)Ae[e.charCodeAt(E)]|=1<<E;for(var l=0;l<r;l++){var x=Ae[t.charCodeAt(l)],T=s[l/32|0]>>>l&1,L=i[l/32|0]>>>l&1,B=x|f,k=((x|L)&d)+d^d|x|L,$=f|~(k|d),M=d&k;$>>>31^T&&(s[l/32|0]^=1<<l),M>>>31^L&&(i[l/32|0]^=1<<l),$=$<<1|T,M=M<<1|L,d=M|~(B|$),f=$&B}for(var E=m;E<p;E++)Ae[e.charCodeAt(E)]=0}for(var W=0,J=-1,w=u*32,O=Math.min(32,n-w)+w,E=w;E<O;E++)Ae[e.charCodeAt(E)]|=1<<E;for(var K=n,l=0;l<r;l++){var x=Ae[t.charCodeAt(l)],T=s[l/32|0]>>>l&1,L=i[l/32|0]>>>l&1,B=x|W,k=((x|L)&J)+J^J|x|L,$=W|~(k|J),M=J&k;K+=$>>>n-1&1,K-=M>>>n-1&1,$>>>31^T&&(s[l/32|0]^=1<<l),M>>>31^L&&(i[l/32|0]^=1<<l),$=$<<1|T,M=M<<1|L,J=M|~(B|$),W=$&B}for(var E=w;E<O;E++)Ae[e.charCodeAt(E)]=0;return K},"myers_x"),Xs=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?sc(e,t):oc(e,t)},"distance");mt.distance=Xs;var ac=o(function(e,t){for(var r=1/0,n=0,i=0;i<t.length;i++){var s=Xs(e,t[i]);s<r&&(r=s,n=i)}return t[n]},"closest");mt.closest=ac});var eo=Q((Tn,Ft)=>{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=Zs(),r=[],n=[],i={get:o(function(s,a,c){var l=c&&e&&c.useCollator;if(l){var u=s.length,f=a.length;if(u===0)return f;if(f===0)return u;var d,m,p,E,x;for(p=0;p<f;++p)r[p]=p,n[p]=a.charCodeAt(p);r[f]=f;var T;for(p=0;p<u;++p){for(m=p+1,E=0;E<f;++E)d=m,T=e.compare(s.charAt(p),String.fromCharCode(n[E]))===0,m=r[E]+(T?0:1),x=d+1,m>x&&(m=x),x=r[E+1]+1,m>x&&(m=x),r[E]=d;r[E]=m}return m}return t.distance(s,a)},"get")};typeof define<"u"&&define!==null&&define.amd?define(function(){return i}):typeof Ft<"u"&&Ft!==null&&typeof Tn<"u"&&Ft.exports===Tn?Ft.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 lo=Q((_m,ao)=>{"use strict";h();var so=12,dc=0,Rn=[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 pc(e){var t=e.indexOf("%");if(t===-1)return e;for(var r=e.length,n="",i=0,s=0,a=t,c=so;t>-1&&t<r;){var l=oo(e[t+1],4),u=oo(e[t+2],0),f=l|u,d=Rn[f];if(c=Rn[256+c+d],s=s<<6|f&Rn[364+d],c===so)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(c===dc)return null;if(t+=3,t<r&&e.charCodeAt(t)===37)continue;return null}}return n+e.slice(i)}o(pc,"decodeURIComponent");var mc={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 oo(e,t){var r=mc[e];return r===void 0?255:r<<t}o(oo,"hexCodeToInt");ao.exports=pc});var po=Q((Sm,ho)=>{"use strict";h();var co=lo(),uo=/\+/g,fo=o(function(){},"Empty");fo.prototype=Object.create(null);function gc(e){let t=new fo;if(typeof e!="string")return t;let r=e.length,n="",i="",s=-1,a=-1,c=!1,l=!1,u=!1,f=!1,d=!1,m=0;for(let p=0;p<r+1;p++)if(m=p!==r?e.charCodeAt(p):38,m===38){if(d=a>s,d||(a=p),n=e.slice(s+1,a),d||n.length>0){u&&(n=n.replace(uo," ")),c&&(n=co(n)||n),d&&(i=e.slice(a+1,p),f&&(i=i.replace(uo," ")),l&&(i=co(i)||i));let E=t[n];E===void 0?t[n]=i:E.pop?E.push(i):t[n]=[E,i]}i="",s=p,a=p,c=!1,l=!1,u=!1,f=!1}else m===61?a<=s?a=p:l=!0:m===43?a>s?f=!0:u=!0:m===37&&(a>s?l=!0:c=!0);return t}o(gc,"parse");ho.exports=gc});var go=Q((Om,mo)=>{h();var ve=Array.from({length:256},(e,t)=>"%"+((t<16?"0":"")+t.toString(16)).toUpperCase()),yc=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 Ec(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(yc[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(Ec,"encodeString");mo.exports={encodeString:Ec}});var bo=Q((Lm,Eo)=>{"use strict";h();var{encodeString:Ln}=go();function yo(e){let t=typeof e;return t==="string"?Ln(e):t==="bigint"?e.toString():t==="boolean"?e?"true":"false":t==="number"&&Number.isFinite(e)?e<1e21?""+e:Ln(""+e):""}o(yo,"getAsPrimitive");function bc(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 c=n[a],l=e[c],u=Ln(c)+"=";if(a&&(t+=r),Array.isArray(l)){s=l.length;for(let f=0;f<s;f++)f&&(t+=r),t+=u,t+=yo(l[f])}else t+=u,t+=yo(l)}return t}o(bc,"stringify");Eo.exports=bc});var So=Q((Nm,Vt)=>{"use strict";h();var _o=po(),xo=bo(),vo={parse:_o,stringify:xo};Vt.exports=vo;Vt.exports.default=vo;Vt.exports.parse=_o;Vt.exports.stringify=xo});h();import Mn from"node:assert";import Mc from"node:http";h();import Po from"node:net";import $o from"node:os";var Ht=class extends Error{static{o(this,"Locked")}constructor(t){super(`${t} is locked`)}},nt={old:new Set,young:new Set},Mo=1e3*15;var St,Bo=o(()=>{let e=$o.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"),Zn=o(e=>new Promise((t,r)=>{let n=Po.createServer();n.unref(),n.on("error",r),n.listen(e,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),"checkAvailablePort"),ei=o(async(e,t)=>{if(e.host||e.port===0)return Zn(e);for(let r of t)try{await Zn({port:e.port,host:r})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return e.port},"getAvailablePort"),Do=o(function*(e){e&&(yield*e),yield 0},"portCheckSequence");async function Sr(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)}St===void 0&&(St=setTimeout(()=>{St=void 0,nt.old=nt.young,nt.young=new Set},Mo),St.unref&&St.unref());let n=Bo();for(let i of Do(t))try{if(r.has(i))continue;let s=await ei({...e,port:i},n);for(;nt.old.has(s)||nt.young.has(s);){if(i!==0)throw new Ht(i);s=await ei({...e,port:i},n)}return nt.young.add(s),s}catch(s){if(!["EADDRINUSE","EACCES"].includes(s.code)&&!(s instanceof Ht))throw s}throw new Error("No available ports found")}o(Sr,"getPorts");h();import pi from"node:process";import mi from"node:path";import{fileURLToPath as ua}from"node:url";import fa from"node:child_process";import ha,{constants as da}from"node:fs/promises";h();import{promisify as jo}from"node:util";import qo from"node:child_process";import Tr,{constants as ni}from"node:fs/promises";h();import ti from"node:process";import{Buffer as Fo}from"node:buffer";import{promisify as Uo}from"node:util";import Vo from"node:child_process";var Go=Uo(Vo.execFile),wr=o(()=>`${ti.env.SYSTEMROOT||ti.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,"powerShellPath");var ce=o(async(e,t={})=>{let{powerShellPath:r,...n}=t,i=ce.encodeCommand(e);return Go(r??wr(),[...ce.argumentsPrefix,i],{encoding:"utf8",...n})},"executePowerShell");ce.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];ce.encodeCommand=e=>Fo.from(e,"utf16le").toString("base64");ce.escapeArgument=e=>`'${String(e).replaceAll("'","''")}'`;var Wo=jo(qo.execFile),Ho=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let r="/etc/wsl.conf",n=!1;try{await Tr.access(r,ni.F_OK),n=!0}catch{}if(!n)return e;let i=await Tr.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}})(),Qo=o(async()=>`${await Ho()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,"powerShellPathFromWsl"),Qt=we?Qo:wr,ri,ii=o(async()=>(ri??=(async()=>{try{let e=await Qt();return await Tr.access(e,ni.X_OK),!0}catch{return!1}})(),ri),"canAccessPowerShell"),si=o(async()=>{let e=await Qt(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:r}=await ce(t,{powerShellPath:e});return r.trim()},"wslDefaultBrowser"),oi=o(async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await Wo("wslpath",["-aw",e],{encoding:"utf8"});return t.trim()}catch{return e}},"convertWslPathToWindows");h();function We(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(We,"defineLazyProperty");h();import{promisify as sa}from"node:util";import Ar from"node:process";import{execFile as oa}from"node:child_process";h();import{promisify as Yo}from"node:util";import zo from"node:process";import{execFile as Jo}from"node:child_process";var Ko=Yo(Jo);async function Or(){if(zo.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await Ko("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return r==="com.apple.safari"?"com.apple.Safari":r}o(Or,"defaultBrowserId");h();h();import Xo from"node:process";import{promisify as Zo}from"node:util";import{execFile as ea,execFileSync as yu}from"node:child_process";var ta=Zo(ea);async function ai(e,{humanReadableOutput:t=!0,signal:r}={}){if(Xo.platform!=="darwin")throw new Error("macOS only");let n=t?[]:["-ss"],i={};r&&(i.signal=r);let{stdout:s}=await ta("osascript",["-e",e,n],i);return s.trim()}o(ai,"runAppleScript");async function Cr(e){return ai(`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(Cr,"bundleName");h();import{promisify as ra}from"node:util";import{execFile as na}from"node:child_process";var ia=ra(na),li={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},Rr=new Map(Object.entries(li)),Yt=class extends Error{static{o(this,"UnknownBrowserError")}};async function Lr(e=ia){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 Yt(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,i=li[n];if(!i)throw new Yt(`Unknown browser ID: ${n}`);return i}o(Lr,"defaultBrowser");var aa=sa(oa),la=o(e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase()),"titleize");async function Ir(){if(Ar.platform==="darwin"){let e=await Or();return{name:await Cr(e),id:e}}if(Ar.platform==="linux"){let{stdout:e}=await aa("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:la(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(Ar.platform==="win32")return Lr();throw new Error("Only macOS, Linux, and Windows are supported")}o(Ir,"defaultBrowser");h();import Nr from"node:process";var ca=!!(Nr.env.SSH_CONNECTION||Nr.env.SSH_CLIENT||Nr.env.SSH_TTY),ci=ca;var zt=Symbol("fallbackAttempt"),kr=import.meta.url?mi.dirname(ua(import.meta.url)):"",ui=mi.join(kr,"xdg-open"),{platform:it,arch:fi}=pi,hi=o(async(e,t)=>{if(e.length===0)return;let r=[];for(let n of e)try{return await t(n)}catch(i){r.push(i)}throw new AggregateError(r,"Failed to open in all supported apps")},"tryEachApp"),Jt=o(async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[zt]===!0;if(delete e[zt],Array.isArray(e.app))return hi(e.app,u=>Jt({...e,app:u,[zt]:!0}));let{name:r,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(r))return hi(r,u=>Jt({...e,app:{name:u,arguments:n},[zt]:!0}));if(r==="browser"||r==="browserPrivate"){let u={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},f={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d;if(we){let m=await si();d=Rr.get(m)??{}}else d=await Ir();if(d.id in u){let m=u[d.id.toLowerCase()];if(r==="browserPrivate"){if(m==="safari")throw new Error("Safari doesn't support opening in private mode via command line");n.push(f[m])}return Jt({...e,app:{name:st[m],arguments:n}})}throw new Error(`${d.name} is not supported as a default browser`)}let i,s=[],a={},c=!1;if(we&&!Hn()&&!ci&&!r&&(c=await ii()),it==="darwin")i="open",e.wait&&s.push("--wait-apps"),e.background&&s.push("--background"),e.newInstance&&s.push("--new"),r&&s.push("-a",r);else if(it==="win32"||c){i=await Qt(),s.push(...ce.argumentsPrefix),we||(a.windowsVerbatimArguments=!0),we&&e.target&&(e.target=await oi(e.target));let u=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&u.push("-Wait"),r?(u.push(ce.escapeArgument(r)),e.target&&n.push(e.target)):e.target&&u.push(ce.escapeArgument(e.target)),n.length>0&&(n=n.map(f=>ce.escapeArgument(f)),u.push("-ArgumentList",n.join(","))),e.target=ce.encodeCommand(u.join(" ")),e.wait||(a.stdio="ignore")}else{if(r)i=r;else{let u=!kr||kr==="/",f=!1;try{await ha.access(ui,da.X_OK),f=!0}catch{}i=pi.versions.electron??(it==="android"||u||!f)?"xdg-open":ui}n.length>0&&s.push(...n),e.wait||(a.stdio="ignore",a.detached=!0)}it==="darwin"&&n.length>0&&s.push("--args",...n),e.target&&s.push(e.target);let l=fa.spawn(i,s,a);return e.wait?new Promise((u,f)=>{l.once("error",f),l.once("close",d=>{if(!e.allowNonzeroExitCode&&d!==0){f(new Error(`Exited with code ${d}`));return}u(l)})}):t?new Promise((u,f)=>{l.once("error",f),l.once("spawn",()=>{l.once("close",d=>{if(l.off("error",f),d!==0){f(new Error(`Exited with code ${d}`));return}l.unref(),u(l)})})}):(l.unref(),new Promise((u,f)=>{l.once("error",f),l.once("spawn",()=>{l.off("error",f),u(l)})}))},"baseOpen"),pa=o((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return Jt({...t,target:e})},"open");function di(e){if(typeof e=="string"||Array.isArray(e))return e;let{[fi]:t}=e;if(!t)throw new Error(`${fi} is not supported`);return t}o(di,"detectArchBinary");function wt({[it]:e},{wsl:t}={}){if(t&&we)return di(t);if(!e)throw new Error(`${it} is not supported`);return di(e)}o(wt,"detectPlatformBinary");var st={browser:"browser",browserPrivate:"browserPrivate"};We(st,"chrome",()=>wt({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{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"]}}));We(st,"brave",()=>wt({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));We(st,"firefox",()=>wt({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));We(st,"edge",()=>wt({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));We(st,"safari",()=>wt({darwin:"Safari"}));var gi=pa;h();import Pc from"node:assert";h();import ma from"node:assert";var ga=o(e=>{let t=Jn(e);return t&&`session=${encodeURIComponent(t)};`},"loadCookie"),Pr=o(e=>{let t=He(e);return ma(t,"missing auth headers"),t},"loadAuthHeaders"),He=o(e=>{let t=ga(e);if(t)return e.log.trace("using cookie as auth header",{},{cookie:t}),{cookie:t};let r=Kn(e);if(r)return e.log.trace("using token as auth header",{},{token:r}),{"x-platform-access-token":r}},"maybeLoadAuthHeaders"),ya=o(e=>e instanceof jn&&e.response.statusCode===401,"isUnauthorizedError"),yi=o((e,t)=>{if(ya(t)){e.log.warn("swallowing unauthorized error",{error:t});return}throw t},"swallowUnauthorized");h();import Ic from"node:assert";import{Agent as Nc}from"node:http";import{Agent as kc}from"node:https";h();var Kt={decodeValues:!0,map:!1,silent:!1,split:"auto"};function $r(e){return typeof e!="string"||e in{}}o($r,"isForbiddenKey");function Mr(){return Object.create(null)}o(Mr,"createNullObj");function Ei(e){return typeof e=="string"&&!!e.trim()}o(Ei,"isNonEmptyString");function Tt(e,t){var r=e.split(";").filter(Ei),n=r.shift(),i=Ea(n),s=i.name,a=i.value;if(t=t?Object.assign({},Kt,t):Kt,$r(s))return null;try{a=t.decodeValues?decodeURIComponent(a):a}catch(l){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",l)}var c=Mr();return c.name=s,c.value=a,r.forEach(function(l){var u=l.split("="),f=u.shift().trimLeft().toLowerCase();if(!$r(f)){var d=u.join("=");if(f==="expires")c.expires=new Date(d);else if(f==="max-age"){var m=parseInt(d,10);Number.isNaN(m)||(c.maxAge=m)}else f==="secure"?c.secure=!0:f==="httponly"?c.httpOnly=!0:f==="samesite"?c.sameSite=d:f==="partitioned"?c.partitioned=!0:f&&(c[f]=d)}}),c}o(Tt,"parseString");function Ea(e){var t="",r="",n=e.split("=");return n.length>1?(t=n.shift(),r=n.join("=")):r=e,{name:t,value:r}}o(Ea,"parseNameValuePair");function ot(e,t){if(t=t?Object.assign({},Kt,t):Kt,!e)return t.map?Mr():[];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(a){return a.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}var n=t.split,i=Array.isArray(e);if(n==="auto"&&(n=!i),i||(e=[e]),e=e.filter(Ei),n&&(e=e.map(bi).flat()),t.map){var s=Mr();return e.reduce(function(a,c){var l=Tt(c,t);return l&&!$r(l.name)&&(a[l.name]=l),a},s)}else return e.map(function(a){return Tt(a,t)}).filter(Boolean)}o(ot,"parseSetCookie");function bi(e){if(Array.isArray(e))return e;if(typeof e!="string")return[];var t=[],r=0,n,i,s,a,c;function l(){for(;r<e.length&&/\s/.test(e.charAt(r));)r+=1;return r<e.length}o(l,"skipWhitespace");function u(){return i=e.charAt(r),i!=="="&&i!==";"&&i!==","}for(o(u,"notSpecialChar");r<e.length;){for(n=r,c=!1;l();)if(i=e.charAt(r),i===","){for(s=r,r+=1,l(),a=r;r<e.length&&u();)r+=1;r<e.length&&e.charAt(r)==="="?(c=!0,r=a,t.push(e.substring(n,s)),n=r):r=s+1}else r+=1;(!c||r>=e.length)&&t.push(e.substring(n,e.length))}return t}o(bi,"splitCookiesString");ot.parseSetCookie=ot;ot.parse=ot;ot.parseString=Tt;ot.splitCookiesString=bi;h();h();h();import Rc from"node:assert";h();var _i=se(qt(),1);import Br from"node:os";var ye,xi=o(async(e,t)=>{t["--telemetry"]&&(ye=await import("./esm-3JVXH7DT.js"),ye.init({dsn:"https://0c26e0d8afd94e77a88ee1c3aa9e7065@o250689.ingest.sentry.io/6703266",enabled:Se.productionLike&&(t["--telemetry"]??!1),release:tt.version,environment:tt.version.includes("experimental")?"experimental":"production"}))},"initSentry"),vi=o(async e=>{ye&&(ye.captureException(e,{event_id:e.id,captureContext:{tags:{arch:D.arch,bug:e.isBug,environment:Se.value,platform:D.platform,shell:D.shell,version:tt.version},contexts:{ctx:{argv:process.argv},cause:e.cause?le(e.cause):void 0,app:{app_name:tt.name,app_version:tt.version},device:{name:Br.hostname(),family:Br.type(),arch:Br.arch()},runtime:{name:process.release.name,version:process.version}}}}),await ye.flush((0,_i.default)("2s")))},"sendErrorToSentry"),Si=o(e=>{ye&&ye.addBreadcrumb(e)},"addSentryBreadcrumb"),wi=o(e=>{ye&&ye.setUser(e)},"setSentryUser"),bf=o(e=>{ye&&ye.setTags(e)},"setSentryTags");h();h();var Ti=o((e,t,r,n)=>(r?r=vr(r).trim():r="",JSON.stringify({level:e,name:t,msg:r,fields:Oi(n)})+`
9
+ `),"formatJson"),Oi=o(e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=Ci(n);return t},"serializeFields"),Ci=o(e=>(e instanceof Set&&(e=Array.from(e)),Array.isArray(e)?e.map(Ci):(e instanceof Map&&(e=Object.fromEntries(e.entries())),_e(e)?Oi(e):Wt(e)?vr(e).trim():e)),"serializeValue");h();var An=se(Ri(),1);import _c from"node:assert";h();h();import Ot from"node:process";h();import Ur from"node:process";import ba from"node:os";import Li from"node:tty";function pe(e,t=globalThis.Deno?globalThis.Deno.args:Ur.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}o(pe,"hasFlag");var{env:j}=Ur,Xt;pe("no-color")||pe("no-colors")||pe("color=false")||pe("color=never")?Xt=0:(pe("color")||pe("colors")||pe("color=true")||pe("color=always"))&&(Xt=1);function _a(){if(!("FORCE_COLOR"in j))return;if(j.FORCE_COLOR==="true")return 1;if(j.FORCE_COLOR==="false")return 0;if(j.FORCE_COLOR.length===0)return 1;let e=Math.min(Number.parseInt(j.FORCE_COLOR,10),3);if([0,1,2,3].includes(e))return e}o(_a,"envForceColor");function xa(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}o(xa,"translateLevel");function va(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n=_a();n!==void 0&&(Xt=n);let i=r?Xt:n;if(i===0)return 0;if(r){if(pe("color=16m")||pe("color=full")||pe("color=truecolor"))return 3;if(pe("color=256"))return 2}if("TF_BUILD"in j&&"AGENT_NAME"in j)return 1;if(e&&!t&&i===void 0)return 0;let s=i||0;if(j.TERM==="dumb")return s;if(Ur.platform==="win32"){let a=ba.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in j)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(a=>a in j)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in j)||j.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor"||j.TERM==="xterm-kitty"||j.TERM==="xterm-ghostty"||j.TERM==="wezterm")return 3;if("TERM_PROGRAM"in j){let a=Number.parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return a>=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:s}o(va,"_supportsColor");function Zt(e,t={}){let r=va(e,{streamIsTTY:e&&e.isTTY,...t});return xa(r)}o(Zt,"createSupportsColor");var kf={stdout:Zt({isTTY:Li.isatty(1)}),stderr:Zt({isTTY:Li.isatty(2)})};h();import Sa from"process";function Pe(e,t=Sa.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}o(Pe,"hasFlag");function Ai(e=""){if(/^\d{3,4}$/.test(e)){let r=/(\d{1,2})(\d{2})/.exec(e)??[];return{major:0,minor:Number.parseInt(r[1],10),patch:Number.parseInt(r[2],10)}}let t=(e??"").split(".").map(r=>Number.parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}o(Ai,"parseVersion");function Ii(e){let{CI:t,CURSOR_TRACE_ID:r,FORCE_HYPERLINK:n,NETLIFY:i,TEAMCITY_VERSION:s,TERM_PROGRAM:a,TERM_PROGRAM_VERSION:c,VTE_VERSION:l,TERM:u}=Ot.env;if(n)return!(n.length>0&&Number.parseInt(n,10)===0);if(Pe("no-hyperlink")||Pe("no-hyperlinks")||Pe("hyperlink=false")||Pe("hyperlink=never"))return!1;if(Pe("hyperlink=true")||Pe("hyperlink=always")||i)return!0;if(!Zt(e)||e&&!e.isTTY)return!1;if("WT_SESSION"in Ot.env)return!0;if(Ot.platform==="win32"||t||s)return!1;if(a){let f=Ai(c);switch(a){case"iTerm.app":return f.major===3?f.minor>=1:f.major>3;case"WezTerm":return/^0-unstable-\d{4}-\d{2}-\d{2}$/.test(c)?c.slice(11)>="2020-06-20":f.major>=20200620;case"vscode":return r?!0:f.major>1||f.major===1&&f.minor>=72;case"ghostty":return!0}}if(l){if(l==="0.50.0")return!1;let f=Ai(l);return f.major>0||f.minor>=50}switch(u){case"alacritty":return!0;case"xterm-kitty":return!0}return!1}o(Ii,"createSupportsHyperlinks");var wa={stdout:Ii(Ot.stdout),stderr:Ii(Ot.stderr)},er=wa;function Ee(e,t,{target:r="stdout",...n}={}){return er[r]?Fn.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} ${t}`}o(Ee,"terminalLink");Ee.isSupported=er.stdout;Ee.stderr=(e,t,r={})=>Ee(e,t,{target:"stderr",...r});Ee.stderr.isSupported=er.stderr;h();h();h();h();h();h();function oe(e){return e===null?"null":Array.isArray(e)?"array":typeof e}o(oe,"extendedTypeof");function $e(e){return oe(e)==="object"}o($e,"isObject");function Ta(e){return Array.isArray(e)&&e.length>0&&e.every(t=>"message"in t)}o(Ta,"areGraphQLFormattedErrors");function Vr(e,t){return e.length<124?e:t}o(Vr,"limitCloseReason");var Ni="graphql-transport-ws";var ue=(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",e))(ue||{}),fe=(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",e))(fe||{});function ki(e){if(!$e(e))throw new Error(`Message is expected to be an object, but got ${oe(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 ${oe(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(e.payload!=null&&!$e(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"subscribe":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${oe(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$e(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${oe(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 ${oe(e.payload.query)}`);if(e.payload.variables!=null&&!$e(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 ${oe(e.payload.variables)}`);if(e.payload.operationName!=null&&oe(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 ${oe(e.payload.operationName)}`);if(e.payload.extensions!=null&&!$e(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 ${oe(e.payload.extensions)}`);break}case"next":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${oe(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$e(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${oe(e.payload)}`);break}case"error":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${oe(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!Ta(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"complete":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${oe(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(ki,"validateMessage");function Pi(e,t){return ki(typeof e=="string"?JSON.parse(e,t):e)}o(Pi,"parseMessage");function at(e,t){return ki(e),JSON.stringify(e,t)}o(at,"stringifyMessage");function jr(e){let{url:t,connectionParams:r,lazy:n=!0,onNonLazyError:i=console.error,lazyCloseTimeout:s=0,keepAlive:a=0,disablePong:c,connectionAckWaitTimeout:l=0,retryAttempts:u=5,retryWait:f=o(async function(b){let y=Math.pow(2,b);await new Promise(_=>setTimeout(_,y*1e3+Math.floor(Math.random()*2700+300)))},"randomisedExponentialBackoff"),shouldRetry:d=Gr,on:m,webSocketImpl:p,generateID:E=o(function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,b=>{let y=Math.random()*16|0;return(b=="x"?y:y&3|8).toString(16)})},"generateUUID"),jsonMessageReplacer:x,jsonMessageReviver:T}=e,L;if(p){if(!Ca(p))throw new Error("Invalid WebSocket implementation provided");L=p}else typeof WebSocket<"u"?L=WebSocket:typeof global<"u"?L=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(L=window.WebSocket||window.MozWebSocket);if(!L)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let B=L,k=(()=>{let g=(()=>{let y={};return{on(_,S){return y[_]=S,()=>{delete y[_]}},emit(_){"id"in _&&y[_.id]?.(_)}}})(),b={connecting:m?.connecting?[m.connecting]:[],opened:m?.opened?[m.opened]:[],connected:m?.connected?[m.connected]:[],ping:m?.ping?[m.ping]:[],pong:m?.pong?[m.pong]:[],message:m?.message?[g.emit,m.message]:[g.emit],closed:m?.closed?[m.closed]:[],error:m?.error?[m.error]:[]};return{onMessage:g.on,on(y,_){let S=b[y];return S.push(_),()=>{S.splice(S.indexOf(_),1)}},emit(y,..._){for(let S of[...b[y]])S(..._)}}})();function $(g){let b=[k.on("error",y=>{b.forEach(_=>_()),g(y)}),k.on("closed",y=>{b.forEach(_=>_()),g(y)})]}o($,"errorOrClosed");let M,W=0,J,w=!1,O=0,K=!1;async function Et(){clearTimeout(J);let[g,b]=await(M??(M=new Promise((S,A)=>(async()=>{if(w){if(await f(O),!W)return M=void 0,A({code:1e3,reason:"All Subscriptions Gone"});O++}k.emit("connecting",w);let C=new B(typeof t=="function"?await t():t,Ni),U,Y;function Z(){isFinite(a)&&a>0&&(clearTimeout(Y),Y=setTimeout(()=>{C.readyState===B.OPEN&&(C.send(at({type:fe.Ping})),k.emit("ping",!1,void 0))},a))}o(Z,"enqueuePing"),$(V=>{M=void 0,clearTimeout(U),clearTimeout(Y),A(V),V instanceof Ct&&(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!==B.OPEN)return;C.send(at(V?{type:fe.ConnectionInit,payload:V}:{type:fe.ConnectionInit},x)),isFinite(l)&&l>0&&(U=setTimeout(()=>{C.close(ue.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},l)),Z()}catch(V){k.emit("error",V),C.close(ue.InternalClientError,Vr(V instanceof Error?V.message:String(V),"Internal client error"))}};let ae=!1;C.onmessage=({data:V})=>{try{let H=Pi(V,T);if(k.emit("message",H),H.type==="ping"||H.type==="pong"){k.emit(H.type,!0,H.payload),H.type==="pong"?Z():c||(C.send(at(H.payload?{type:fe.Pong,payload:H.payload}:{type:fe.Pong})),k.emit("pong",!1,H.payload));return}if(ae)return;if(H.type!==fe.ConnectionAck)throw new Error(`First message cannot be of type ${H.type}`);clearTimeout(U),ae=!0,k.emit("connected",C,H.payload,w),w=!1,O=0,S([C,new Promise((Ne,ee)=>$(ee))])}catch(H){C.onmessage=null,k.emit("error",H),C.close(ue.BadResponse,Vr(H instanceof Error?H.message:String(H),"Bad response"))}}})())));g.readyState===B.CLOSING&&await b;let y=o(()=>{},"release"),_=new Promise(S=>y=S);return[g,y,Promise.race([_.then(()=>{if(!W){let S=o(()=>g.close(1e3,"Normal Closure"),"complete");isFinite(s)&&s>0?J=setTimeout(()=>{g.readyState===B.OPEN&&S()},s):S()}}),b])]}o(Et,"connect");function R(g){if(Gr(g)&&(Oa(g.code)||[ue.InternalServerError,ue.InternalClientError,ue.BadRequest,ue.BadResponse,ue.Unauthorized,ue.SubprotocolNotAcceptable,ue.SubscriberAlreadyExists,ue.TooManyInitialisationRequests].includes(g.code)))throw g;if(K)return!1;if(Gr(g)&&g.code===1e3)return W>0;if(!u||O>=u||!d(g))throw g;return w=!0}o(R,"shouldRetryConnectOrThrow"),n||(async()=>{for(W++;;)try{let[,,g]=await Et();await g}catch(g){try{if(!R(g))return}catch(b){return i?.(b)}}})();function v(g,b){let y=E(g),_=!1,S=!1,A=o(()=>{W--,_=!0},"releaser");return(async()=>{for(W++;;)try{let[C,U,Y]=await Et();if(_)return U();let Z=k.onMessage(y,ae=>{switch(ae.type){case fe.Next:{b.next(ae.payload);return}case fe.Error:{S=!0,_=!0,b.error(ae.payload),A();return}case fe.Complete:{_=!0,A();return}}});C.send(at({id:y,type:fe.Subscribe,payload:g},x)),A=o(()=>{!_&&C.readyState===B.OPEN&&C.send(at({id:y,type:fe.Complete},x)),W--,_=!0,U()},"releaser"),await Y.finally(Z);return}catch(C){if(!R(C))return}})().then(()=>{S||b.complete()}).catch(C=>{b.error(C)}),()=>{_||A()}}return o(v,"subscribe"),{on:k.on,subscribe:v,iterate(g){let b=[],y={done:!1,error:null,resolve:o(()=>{},"resolve")},_=v(g,{next(A){b.push(A),y.resolve()},error(A){y.done=!0,y.error=A,y.resolve()},complete(){y.done=!0,y.resolve()}}),S=o(async function*(){for(;;){for(b.length||await new Promise(C=>y.resolve=C);b.length;)yield b.shift();if(y.error)throw y.error;if(y.done)return}},"iterator2")();return S.throw=async A=>(y.done||(y.done=!0,y.error=A,y.resolve()),{done:!0,value:void 0}),S.return=async()=>(_(),{done:!0,value:void 0}),S},async dispose(){if(K=!0,M){let[g]=await M;g.close(1e3,"Normal Closure")}},terminate(){M&&k.emit("closed",new Ct)}}}o(jr,"createClient");var Ct=class extends Error{static{o(this,"TerminatedCloseEvent")}name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1};function Gr(e){return $e(e)&&"code"in e&&"reason"in e}o(Gr,"isLikeCloseEvent");function Oa(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}o(Oa,"isFatalInternalCloseCode");function Ca(e){return typeof e=="function"&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}o(Ca,"isWebSocket");var Cn=se(qt(),1);h();h();var Wr=se(Mi(),1);h();var Hr=class e extends Error{static{o(this,"TimeoutError")}name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},Bi=o(e=>e.reason??new DOMException("This operation was aborted.","AbortError"),"getAbortedReason");function Qr(e,t){let{milliseconds:r,fallback:n,message:i,customTimers:s={setTimeout,clearTimeout},signal:a}=t,c,l,f=new Promise((d,m)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(a?.aborted){m(Bi(a));return}if(a&&(l=o(()=>{m(Bi(a))},"abortHandler"),a.addEventListener("abort",l,{once:!0})),e.then(d,m),r===Number.POSITIVE_INFINITY)return;let p=new Hr;c=s.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(E){m(E)}return}typeof e.cancel=="function"&&e.cancel(),i===!1?d():i instanceof Error?m(i):(p.message=i??`Promise timed out after ${r} milliseconds`,m(p))},r)}).finally(()=>{f.clear(),l&&a&&a.removeEventListener("abort",l)});return f.clear=()=>{s.clearTimeout.call(void 0,c),c=void 0},f}o(Qr,"pTimeout");h();h();function Yr(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(Yr,"lowerBound");var Lt=class{static{o(this,"PriorityQueue")}#e=[];enqueue(t,r){let{priority:n=0,id:i}=r??{},s={priority:n,id:i,run:t};if(this.size===0||this.#e[this.size-1].priority>=n){this.#e.push(s);return}let a=Yr(this.#e,s,(c,l)=>l.priority-c.priority);this.#e.splice(a,0,s)}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 At=class extends Wr.default{static{o(this,"PQueue")}#e;#i;#a=0;#d;#m=!1;#E=!1;#l;#O=0;#b=0;#c;#u;#o;#s=[];#n=0;#t;#C;#r=0;#g;#f;#N=1n;#y=new Map;timeout;constructor(t){if(super(),t={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Lt,strict:!1,...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})`);if(t.strict&&t.interval===0)throw new TypeError("The `strict` option requires a non-zero `interval`");if(t.strict&&t.intervalCap===Number.POSITIVE_INFINITY)throw new TypeError("The `strict` option requires a finite `intervalCap`");if(this.#e=t.carryoverIntervalCount??t.carryoverConcurrencyCount??!1,this.#i=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#d=t.intervalCap,this.#l=t.interval,this.#o=t.strict,this.#t=new t.queueClass,this.#C=t.queueClass,this.concurrency=t.concurrency,t.timeout!==void 0&&!(Number.isFinite(t.timeout)&&t.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${t.timeout}\` (${typeof t.timeout})`);this.timeout=t.timeout,this.#f=t.autoStart===!1,this.#U()}#_(t){for(;this.#n<this.#s.length;){let n=this.#s[this.#n];if(n!==void 0&&t-n>=this.#l)this.#n++;else break}(this.#n>100&&this.#n>this.#s.length/2||this.#n===this.#s.length)&&(this.#s=this.#s.slice(this.#n),this.#n=0)}#k(t){this.#o?this.#s.push(t):this.#a++}#P(){this.#o?this.#s.length>this.#n&&this.#s.pop():this.#a>0&&this.#a--}#x(){return this.#s.length-this.#n}get#$(){return this.#i?!0:this.#o?this.#x()<this.#d:this.#a<this.#d}get#M(){return this.#r<this.#g}#B(){this.#r--,this.#r===0&&this.emit("pendingZero"),this.#w(),this.emit("next")}#D(){this.#u=void 0,this.#A(),this.#L()}#F(t){if(this.#o){if(this.#_(t),this.#x()>=this.#d){let n=this.#s[this.#n],i=this.#l-(t-n);return this.#v(i),!0}return!1}if(this.#c===void 0){let r=this.#O-t;if(r<0){if(this.#b>0){let n=t-this.#b;if(n<this.#l)return this.#v(this.#l-n),!0}this.#a=this.#e?this.#r:0}else return this.#v(r),!0}return!1}#v(t){this.#u===void 0&&(this.#u=setTimeout(()=>{this.#D()},t))}#S(){this.#c&&(clearInterval(this.#c),this.#c=void 0)}#R(){this.#u&&(clearTimeout(this.#u),this.#u=void 0)}#w(){if(this.#t.size===0){if(this.#S(),this.emit("empty"),this.#r===0){if(this.#R(),this.#o&&this.#n>0){let r=Date.now();this.#_(r)}this.emit("idle")}return!1}let t=!1;if(!this.#f){let r=Date.now(),n=!this.#F(r);if(this.#$&&this.#M){let i=this.#t.dequeue();this.#i||(this.#k(r),this.#p()),this.emit("active"),i(),n&&this.#L(),t=!0}}return t}#L(){this.#i||this.#c!==void 0||this.#o||(this.#c=setInterval(()=>{this.#A()},this.#l),this.#O=Date.now()+this.#l)}#A(){this.#o||(this.#a===0&&this.#r===0&&this.#c&&this.#S(),this.#a=this.#e?this.#r:0),this.#T(),this.#p()}#T(){for(;this.#w(););}get concurrency(){return this.#g}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.#g=t,this.#T()}setPriority(t,r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${r}\` (${typeof r})`);this.#t.setPriority(t,r)}async add(t,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#N++).toString()},new Promise((n,i)=>{let s=Symbol(`task-${r.id}`);this.#t.enqueue(async()=>{this.#r++,this.#y.set(s,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let a;try{try{r.signal?.throwIfAborted()}catch(u){throw this.#V(),this.#y.delete(s),u}this.#b=Date.now();let c=t({signal:r.signal});if(r.timeout&&(c=Qr(Promise.resolve(c),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#r} running, ${this.#t.size} waiting)`})),r.signal){let{signal:u}=r;c=Promise.race([c,new Promise((f,d)=>{a=o(()=>{d(u.reason)},"eventListener"),u.addEventListener("abort",a,{once:!0})})])}let l=await c;n(l),this.emit("completed",l)}catch(c){i(c),this.emit("error",c)}finally{a&&r.signal?.removeEventListener("abort",a),this.#y.delete(s),queueMicrotask(()=>{this.#B()})}},r),this.emit("add"),this.#w()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#f?(this.#f=!1,this.#T(),this):this}pause(){this.#f=!0}clear(){this.#t=new this.#C,this.#S(),this.#I(),this.emit("empty"),this.#r===0&&(this.#R(),this.emit("idle")),this.emit("next")}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.#r===0&&this.#t.size===0||await this.#h("idle")}async onPendingZero(){this.#r!==0&&await this.#h("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#h("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#h("rateLimitCleared")}onError(){return new Promise((t,r)=>{let n=o(i=>{this.off("error",n),r(i)},"handleError");this.on("error",n)})}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.#r}get isPaused(){return this.#f}#U(){this.#i||(this.on("add",()=>{this.#t.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#i||this.#E||(this.#E=!0,queueMicrotask(()=>{this.#E=!1,this.#I()}))}#V(){this.#i||(this.#P(),this.#p())}#I(){let t=this.#m;if(this.#i||this.#t.size===0){t&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#o){let i=Date.now();this.#_(i),r=this.#x()}else r=this.#a;let n=r>=this.#d;n!==t&&(this.#m=n,this.emit(n?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#m}get isSaturated(){return this.#r===this.#g&&this.#t.size>0||this.isRateLimited&&this.#t.size>0}get runningTasks(){return[...this.#y.values()].map(t=>({...t}))}};h();var zl=se(Ns(),1),Jl=se(on(),1),Kl=se(cn(),1),Gs=se(dr(),1),Xl=se(Vs(),1);var js=Gs.default;h();var qs=se(qt(),1);var En=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN","EAI_FAIL","EADDRNOTAVAIL","EHOSTUNREACH","ERR_SSL_SSL/TLS_ALERT_BAD_RECORD_MAC","EPROTO"],bn=(0,qs.default)("5s"),_n=100,mr=10,Ws=["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],Hs=[408,413,429,500,502,503,504,521,522,524],Qs=o((e,t=bn,r=_n)=>{let n=Math.min(Math.pow(2,e)*100,t);return Math.max(0,n+(Math.random()*r*2-r))},"calculateBackoffDelay"),De=o(e=>!_e(e)||!("code"in e)?!1:En.includes(e.code),"isRetryableNetworkErrorCode"),yn=[/unauthenticated/i,/unauthorized/i,/forbidden/i,/not allowed/i,/permission denied/i],Zl=[1e3,1008,4401,4403],ec=o(e=>De(e.error),"isRetryableErrorEvent"),tc=o(e=>!Zl.includes(e.code),"isRetryableCloseEvent"),rc=o(e=>!e.some(t=>{let r=t.extensions?.code;return r==="UNAUTHENTICATED"||r==="FORBIDDEN"||r==="UNAUTHORIZED"?!0:yn.some(n=>n.test(t.message))}),"isRetryableGraphQLErrors"),Ys=o(e=>xt(e)?tc(e):et(e)?ec(e):Ze(e)?De(e):vt(e)?rc(e):typeof e=="string"?!yn.some(t=>t.test(e)):_t(e)?!e.some(t=>yn.some(r=>r.test(t))):!1,"isRetryableErrorCause");h();var zs=new Map,gr=o(e=>{if(!e)return;let t=zs.get(e);return t!==void 0||(t=/(?:query|mutation|subscription)\s+(\w+)/.exec(e)?.[1],t&&zs.set(e,t)),t},"getOperationName"),Od=P(`
10
+ subscription EnvironmentLogs($query: String!, $start: DateTime, $limit: Int) {
11
+ logsSearchV2(query: $query, start: $start, limit: $limit) {
12
+ status
13
+ data
14
+ }
15
+ }
16
+ `),Cd=P(`
17
+ subscription RemoteFileSyncEvents($localFilesVersion: String!) {
18
+ remoteFileSyncEvents(localFilesVersion: $localFilesVersion, encoding: base64) {
19
+ remoteFilesVersion
20
+ changed {
21
+ path
22
+ mode
23
+ content
24
+ encoding
25
+ }
26
+ deleted {
27
+ path
28
+ }
29
+ }
30
+ }
31
+ `),Rd=P(`
32
+ query RemoteFilesVersion {
33
+ remoteFilesVersion
34
+ }
35
+ `),Ld=P(`
36
+ mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {
37
+ publishFileSyncEvents(input: $input) {
38
+ remoteFilesVersion
39
+ problems {
40
+ level
41
+ message
42
+ path
43
+ type
44
+ }
45
+ }
46
+ }
47
+ `),Ad=P(`
48
+ query FileSyncFiles($paths: [String!]!, $filesVersion: String, $encoding: FileSyncEncoding) {
49
+ fileSyncFiles(paths: $paths, filesVersion: $filesVersion, encoding: $encoding) {
50
+ filesVersion
51
+ files {
52
+ path
53
+ mode
54
+ content
55
+ encoding
56
+ }
57
+ }
58
+ }
59
+ `),Id=P(`
60
+ query FileSyncHashes($filesVersion: String) {
61
+ fileSyncHashes(filesVersion: $filesVersion) {
62
+ filesVersion
63
+ hashes
64
+ }
65
+ }
66
+ `),Nd=P(`
67
+ query FileSyncComparisonHashes($filesVersion: String!) {
68
+ fileSyncComparisonHashes(filesVersion: $filesVersion) {
69
+ filesVersionHashes {
70
+ filesVersion
71
+ hashes
72
+ }
73
+ latestFilesVersionHashes {
74
+ filesVersion
75
+ hashes
76
+ }
77
+ }
78
+ }
79
+ `),kd=P(`
80
+ subscription PublishStatus($localFilesVersion: String!, $force: Boolean, $allowCharges: Boolean, $allowDeletedData: Boolean) {
81
+ publishStatus(localFilesVersion: $localFilesVersion, force: $force, allowCharges: $allowCharges, allowDeletedData: $allowDeletedData) {
82
+ publishStarted
83
+ remoteFilesVersion
84
+ progress
85
+ issues {
86
+ severity
87
+ message
88
+ node {
89
+ type
90
+ key
91
+ apiIdentifier
92
+ name
93
+ fieldType
94
+ parentKey
95
+ parentApiIdentifier
96
+ }
97
+ nodeLabels {
98
+ type
99
+ identifier
100
+ }
101
+ }
102
+ deletedModelsAndFields {
103
+ deletedModels
104
+ deletedModelFields {
105
+ modelIdentifier
106
+ fields
107
+ }
108
+ }
109
+ status {
110
+ code
111
+ message
112
+ output
113
+ }
114
+ }
115
+ }
116
+ `),Pd=P(`
117
+ mutation createModel($path: String!, $fields: [CreateModelFieldsInput!]) {
118
+ createModel(path: $path, fields: $fields) {
119
+ remoteFilesVersion
120
+ changed {
121
+ path
122
+ mode
123
+ content
124
+ encoding
125
+ }
126
+ }
127
+ }
128
+ `),$d=P(`
129
+ mutation createAction($path: String!) {
130
+ createAction(path: $path) {
131
+ remoteFilesVersion
132
+ changed {
133
+ path
134
+ mode
135
+ content
136
+ encoding
137
+ }
138
+ }
139
+ }
140
+ `),Md=P(`
141
+ mutation createRoute($method: String!, $path: String!) {
142
+ createRoute(method: $method, path: $path) {
143
+ remoteFilesVersion
144
+ changed {
145
+ path
146
+ mode
147
+ content
148
+ encoding
149
+ }
150
+ }
151
+ }
152
+ `),Bd=P(`
153
+ mutation createModelFields($path: String!, $fields: [CreateModelFieldsInput!]!) {
154
+ createModelFields(path: $path, fields: $fields) {
155
+ remoteFilesVersion
156
+ changed {
157
+ path
158
+ mode
159
+ content
160
+ encoding
161
+ }
162
+ }
163
+ }
164
+ `),Dd=P(`
165
+ mutation CreateEnvironment($environment: EnvironmentInput!) {
166
+ createEnvironment(environment: $environment) {
167
+ slug
168
+ status
169
+ }
170
+ }
171
+ `),Fd=P(`
172
+ mutation UnpauseEnvironment {
173
+ unpauseEnvironment {
174
+ success
175
+ alreadyActive
176
+ }
177
+ }
178
+ `),Ud=P(`
179
+ mutation DeleteEnvironment($slug: String!) {
180
+ deleteEnvironment(slug: $slug)
181
+ }
182
+ `),Vd=P(`
183
+ query PublishIssues {
184
+ publishIssues {
185
+ severity
186
+ message
187
+ node {
188
+ type
189
+ key
190
+ apiIdentifier
191
+ name
192
+ fieldType
193
+ parentKey
194
+ parentApiIdentifier
195
+ }
196
+ nodeLabels {
197
+ type
198
+ identifier
199
+ }
200
+ }
201
+ }
202
+ `),Gd=P(`
203
+ query EnvironmentVariables {
204
+ environmentVariables {
205
+ key
206
+ value
207
+ isSecret
208
+ }
209
+ }
210
+ `),jd=P(`
211
+ mutation SetEnvironmentVariable($input: SetEnvironmentVariableInput!) {
212
+ setEnvironmentVariable(input: $input) {
213
+ remoteFilesVersion
214
+ }
215
+ }
216
+ `),qd=P(`
217
+ mutation DeleteEnvironmentVariable($key: String!) {
218
+ deleteEnvironmentVariable(key: $key) {
219
+ remoteFilesVersion
220
+ }
221
+ }
222
+ `);h();var ro=se(Js(),1);import cc from"node:assert";h();import{randomUUID as nc}from"node:crypto";var ic=o(async(e,t)=>{if(Gn(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=Fe.from(t);if(r.print(),r.isBug===Le.NO)return;await vi(r)}finally{process.exit(1)}},"reportErrorAndExit"),ap=o(async(e,t)=>{e.log.debug("installing error handlers"),await xi(e,t);let r=o(n=>{ic(e,n)},"handleError");process.once("uncaughtException",r),process.once("unhandledRejection",r)},"installErrorHandlers"),Le=Object.freeze({YES:"yes",NO:"no",MAYBE:"maybe"}),Fe=class e extends Error{static{o(this,"GGTError")}id=Se.testLike?"00000000-0000-0000-0000-000000000000":nc();cause;stack;constructor(t){super(t),Error.captureStackTrace(this,this.constructor),this.stack=Dn(this.stack,{pretty:!0,basePath:Wn})}static from(t){return t instanceof e?t:De(t)||_e(t)&&"cause"in t&&De(t.cause)?new wn(t):new Sn(t)}sprint(){let t=this.render();if(this.isBug!==Le.NO){t=qe(t);let r=this.isBug===Le.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}`;Ee.isSupported?t+=qe({ensureEmptyLineAbove:!0,content:P`
223
+ ${r}, ${Ee("click here",n)} to create an issue on GitHub.
224
+ `}):t+=qe({ensureEmptyLineAbove:!0,content:P`
225
+ ${r}, use the link below to create an issue on GitHub.
226
+
227
+ ${n}
228
+ `})}return t}print(t){de({ensureEmptyLineAbove:!0,...t,content:this.sprint()})}},Sn=class extends Fe{constructor(r){super("An unexpected error occurred");this.cause=r}static{o(this,"UnexpectedError")}isBug=Le.YES;render(){let r=le(this.cause),n=r.stack||r.message||this.stack;return this.message+`.
229
+
230
+ `+n}},wn=class extends Fe{constructor(r){super("A network error occurred");this.cause=r}static{o(this,"NetworkError")}isBug=Le.MAYBE;render(){return P`
231
+ A network error occurred while communicating with Gadget.
232
+
233
+ Please check your internet connection and try again.
234
+ `}},Ks=class extends Fe{constructor(r,n){super(r);this.cause=n}static{o(this,"EdgeCaseError")}isBug=Le.MAYBE;render(){return this.message}};h();var On=se(eo(),1);import lc from"node:assert";var yp=o(e=>e.filter(t=>!!t),"compact"),to=o(e=>[...new Set(e)],"uniq"),Ep=o((e,t)=>(lc(t.length>0,"options must not be empty"),[...t].sort((r,n)=>On.default.get(r,e)-On.default.get(n,e))),"sortBySimilar");var re=class extends Fe{static{o(this,"ClientError")}isBug;operationName;cause;constructor(t,r,n){super("An error occurred while communicating with Gadget"),this.operationName=gr(t),n?this.isBug=n:this.isBug=Le.MAYBE,et(r)?this.cause={type:r.type,message:r.message,error:le(r.error)}:xt(r)?this.cause={type:r.type,code:r.code,reason:r.reason,wasClean:r.wasClean}:(cc(Wt(r)||_t(r)||Ze(r)||vt(r),"cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent"),this.cause=r)}render(){let t;switch(!0){case vt(this.cause):{let r=to(this.cause.map(n=>n.message));t=P`
235
+ Gadget responded with the following ${(0,ro.default)("error",r.length,!1)}:
236
+
237
+ • ${r.join(`
238
+ \u2022 `)}
239
+ `;break}case xt(this.cause):t="The connection to Gadget closed unexpectedly.";break;case(Ze(this.cause)&&De(this.cause)||et(this.cause)&&De(this.cause.error)):t="Please check your internet connection and try again.";break;case(et(this.cause)||Ze(this.cause)):t=this.cause.message;break;case _t(this.cause):this.cause.length===1?t=String(this.cause[0]):t=this.cause.join(", ");break;default:t=this.cause;break}return this.operationName&&(t+=` (running "${this.operationName}")`),this.message+`
240
+
241
+ `+t}},yr=class extends re{static{o(this,"AuthenticationError")}constructor(t){super(t,"Request authentication failed due to the session expiring while running the command. Please sign-in again.",Le.NO)}};var Er=class{constructor(t,r,n){this.environment=r;this.endpoint=n;this.ctx=t.child({name:"client"}),this._graphqlWsClient=jr({url:`wss://${r.application.slug}.${D.domains.app}/edit/api/graphql-ws`,keepAlive:(0,Cn.default)("10s"),shouldRetry:o(()=>!0,"shouldRetry"),connectionParams:{environment:r.name},webSocketImpl:class extends js{static{o(this,"webSocketImpl")}constructor(i,s,a){let c=Vn(a?.headers)?Object.fromEntries(a.headers.map(l=>l.split(": ",2))):a?.headers;super(i,s,{signal:t.signal,...a,headers:{...c,"user-agent":D.versionFull,...Pr(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,onData:i,onError:s,onComplete:a=Qn,retry:c}){let l=c?.maxAttempts??mr,u=0,f,d=n,m=t,p={query:r,variables:ne(d)},E=o(()=>this._graphqlWsClient.on("connected",()=>{this.status===2&&(p.variables=ne(d),m.log.info("re-subscribing to graphql subscription")),this._sessionUpdateInterval&&clearInterval(this._sessionUpdateInterval),this._sessionUpdateInterval=setInterval(()=>{gt(this.ctx).catch(w=>this.ctx.abort(w)).then(w=>{w||this.ctx.abort(new yr(void 0))})},(0,Cn.default)("30m")).unref(),this.ctx.done.finally(()=>{this._sessionUpdateInterval&&clearInterval(this._sessionUpdateInterval)})}),"addConnectedListener"),x=E(),T=new At({concurrency:1}),L=o((w,O)=>{if(!c||!Ys(w.cause)||u>=l)return!1;f||u++;let K=Qs(u);return m.log.warn("subscription error, retrying...",{retryCount:u,maxAttempts:l,delayMs:Math.round(K),error:O}),c.onRetry?.(u,w),f&&clearTimeout(f),f=setTimeout(()=>{f=void 0,J.resubscribe()},K),!0},"scheduleRetry"),B=o(async w=>{if(w.errors){let O=new re(r,w.errors);if(L(O,w.errors))return;W(),await s(O);return}if(!w.data){W(),await s(new re(r,"Subscription response did not contain data"));return}u>0&&(f&&(clearTimeout(f),f=void 0),m.log.info("subscription recovered",{retriesNeeded:u}),u=0),await i(w.data)},"onResponse"),k=o(async w=>{L(w,w.cause)||(W(),await s(w))},"onError"),$=o(async()=>{f&&(clearTimeout(f),f=void 0),await a()},"onComplete"),M=this._graphqlWsClient.subscribe(p,{next:o(w=>{T.add(()=>B(w)).catch(O=>k(new re(r,O)))},"next"),error:o(w=>{T.add(()=>k(new re(r,w)))},"error"),complete:o(()=>{T.add(()=>$()).catch(w=>k(new re(r,w)))},"complete")}),W=o(()=>{f&&(clearTimeout(f),f=void 0),m.log.trace("unsubscribing from graphql subscription"),x(),T.clear(),M()},"doUnsubscribe"),J={unsubscribe:o(()=>{f&&(clearTimeout(f),f=void 0),W()},"unsubscribe"),resubscribe:o(w=>{f&&(clearTimeout(f),f=void 0),x(),T.clear(),M(),w!==void 0&&(d=w),p.variables=ne(d),m.log.info("re-subscribing to graphql subscription"),x=E(),M=this._graphqlWsClient.subscribe(p,{next:o(O=>{T.add(()=>B(O)).catch(K=>k(new re(r,K)))},"next"),error:o(O=>{T.add(()=>k(new re(r,O)))},"error"),complete:o(()=>{T.add(()=>$()).catch(O=>k(new re(r,O)))},"complete")})},"resubscribe")};return J}async execute(t,r){let n=this.environment.application.slug;this.environment.type!=="production"&&(n+=`--${this.environment.name}`);try{let i=await yt({context:{ctx:t},method:"POST",url:`https://${n}.${D.domains.app}${this.endpoint}`,headers:{...Pr(t),"x-gadget-environment":this.environment.name},json:{query:r.operation,variables:ne(r.variables)},responseType:"json",resolveBodyOnly:!0,throwHttpErrors:!1,...r.http});if(!_e(i)||!("data"in i)&&!("errors"in i))throw t.log.error("received invalid graphql response",{error:i}),i;return i}catch(i){throw new re(r.operation,i)}}async dispose(){await this._graphqlWsClient.dispose()}};var Ut=class{static{o(this,"Api")}ctx;#e;constructor(t,r){this.ctx=t.child({name:"api"}),this.#e=new Er(this.ctx,r,"/api/graphql")}async query({query:t,variables:r,...n}){let i=gr(t),s=this.ctx.child({name:"api",fields:{edit:{query:i}},devFields:{edit:{query:i,variables:ne(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 re(t,a.errors);if(!a.data)throw new re(t,"Query response did not contain data");return a.data}async dispose(){await this.#e.dispose()}};h();var no=P(`
242
+ query GadgetMetaModels {
243
+ gadgetMeta {
244
+ models {
245
+ apiIdentifier
246
+ namespace
247
+ }
248
+ }
249
+ }
250
+ `),io=P(`
251
+ query GadgetMetaGlobalActions {
252
+ gadgetMeta {
253
+ globalActions {
254
+ apiIdentifier
255
+ namespace
256
+ }
257
+ }
258
+ }
259
+ `);var uc=Object.freeze({Development:"development",Production:"production",Test:"test"}),fc=I.object({id:I.union([I.string(),I.number(),I.bigint()]).transform(e=>BigInt(e)),name:I.string().transform(e=>e.toLowerCase()),type:I.nativeEnum(uc),nodeVersion:I.string().optional()}),hc=I.object({id:I.union([I.string(),I.number(),I.bigint()]).transform(e=>BigInt(e)),slug:I.string(),primaryDomain:I.string(),environments:I.array(fc),team:I.object({id:I.union([I.string(),I.number(),I.bigint()]).transform(e=>BigInt(e)),name:I.string()})}),fm=I.object({apiIdentifier:I.string(),namespace:I.nullable(I.array(I.string())).optional()}),hm=I.object({apiIdentifier:I.string(),namespace:I.nullable(I.array(I.string())).optional()}),dm=o(async e=>{let t=He(e);if(!t)return[];let r=await yt({context:{ctx:e},url:`https://${D.domains.services}/auth/api/apps`,headers:{...t},responseType:"json",resolveBodyOnly:!0});return I.array(hc).parse(r)},"getApplications"),pm=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"),mm=o(async(e,t)=>{if(!He(e))return[];let n=new Ut(e,t),{gadgetMeta:i}=await n.query({query:no});return i.models},"getModels"),gm=o(async(e,t)=>{if(!He(e))return[];let n=new Ut(e,t),{gadgetMeta:i}=await n.query({query:io});return i.globalActions},"getGlobalActions");h();var wo=se(So(),1);var To=o(e=>{let t=wo.default.stringify(e);return t?`?${t}`:""},"serializeObjectToHTTPQuery");h();var N=new Bn({level:Se.testLike&&D.logLevel<G.PRINT?3:Ge.level}),F={error:N.red,success:N.green,warn:N.yellow,link:N.cyan,highlighted:N.magentaBright,examplesQuestions:N.cyanBright,subdued:N.blackBright,body:N.whiteBright,black:N.black,blackBright:N.blackBright,red:N.red,redBright:N.redBright,green:N.green,greenBright:N.greenBright,yellow:N.yellow,yellowBright:N.yellowBright,blue:N.blue,blueBright:N.blueBright,magenta:N.magenta,magentaBright:N.magentaBright,cyan:N.cyan,cyanBright:N.cyanBright,white:N.white,whiteBright:N.whiteBright,bgBlack:N.bgBlack,bgBlackBright:N.bgBlackBright,bgRed:N.bgRed,bgRedBright:N.bgRedBright,bgGreen:N.bgGreen,bgGreenBright:N.bgGreenBright,bgYellow:N.bgYellow,bgYellowBright:N.bgYellowBright,bgBlue:N.bgBlue,bgBlueBright:N.bgBlueBright,bgMagenta:N.bgMagenta,bgMagentaBright:N.bgMagentaBright,bgCyan:N.bgCyan,bgCyanBright:N.bgCyanBright,bgWhite:N.bgWhite,bgWhiteBright:N.bgWhiteBright,reset:N.reset};var Ro=o((e,t,r,n,i,s)=>`${wc(i)} ${Tc(e)} ${Oc(t)}:${Cc(r)}${Lo(n,{indent:2,timestamp:i,environment:s})}${Ie}`,"formatPretty"),Xe="",Ve=" ",Ie=`
260
+ `,xc=":",Oo="'",Co=o((e,t)=>{let r=e==="error"?F.error:F.subdued,n=[];n.push(Ie);for(let i=0;i<t;i++)n.push(Ve);return n.push(r(e)),n.push(r(xc)),n.join("")},"formatKey"),Ue=o((e,t,r)=>{if(!e)return Xe;let n=e.split(Ie);if(n.length===0)return Xe;let i=[],s=n.shift();_c(!Un(s),"first line is nil"),i.push(t(s));for(let a of n)if(a){i.push(Ie);for(let c=0;c<r;c++)i.push(Ve);i.push(t(a))}return i.join(Xe)},"formatValue"),vc=o((e,t)=>{let r="";return t&&(r=To(t)),`https://${e.application.slug}--${e.name}.${D.domains.app}/edit/logs${r}`},"getEnvironmentLogsUrl"),Sc=o(e=>e?`{environment_id="${e.id.toString()}"} | json | level=~"info|warn|error"`:'{environment_id=~".+"} | json | level=~"info|warn|error"',"defaultLogqlQuery"),Lo=o((e,t)=>{let{indent:r,environment:n,timestamp:i}=t;if(Object.keys(e).length===0)return Xe;let s=[];"trace_id"in e&&(s.push(Co("trace_id",r)),s.push(Ve),n&&i&&Ee.isSupported?s.push(Ee(F.link(e.trace_id),vc(n,{timeRange:`${i.toISOString()} to now`,logql:`${Sc(n)} | trace_id="${e.trace_id}"`}))):s.push(F.link(e.trace_id)));for(let[a,c]of Object.entries(e))if(a!=="trace_id"){if(s.push(Co(a,r)),c instanceof Set&&(c=Array.from(c)),Array.isArray(c)){if(c.length===0){s.push(Ue(" []",F.subdued,r));continue}c=Object.fromEntries(c.entries())}if(c instanceof Map&&(c=Object.fromEntries(c)),_e(c)){let l=Object.entries(c);if(l.length===0){s.push(Ue(" {}",F.subdued,r));continue}l.length>10&&D.logLevel>G.TRACE&&!n&&(c=Object.fromEntries([...l.slice(0,10),[zn.ellipsis,`${l.length-10} more`]])),s.push(Lo(c,{indent:r+2,environment:n}));continue}if(s.push(Ve),n)s.push(Ue(String(c),F.reset,r));else switch(typeof c){case"string":s.push(Ue(Oo+c.replaceAll(Ie,Ie+Ve.repeat(r+a.length))+Oo,F.reset,r));break;case"number":s.push(Ue(String(c),F.yellowBright,r));break;case"bigint":s.push(Ue(String(c)+"n",F.yellowBright,r));break;case"boolean":s.push(Ue(String(c),F.green,r));break;default:s.push(Ue(String(c),F.reset,r));break}}return s.join(Xe)},"formatFields"),wc=o(e=>(e?(0,An.default)(e):(0,An.default)()).format("hh:mm:ss"),"formatTimestamp"),Tc=o(e=>{switch(e){case G.PRINT:return F.bgBlack(F.body.bold(" PRINT "));case G.TRACE:return F.bgBlue(F.body.bold(" TRACE "));case G.DEBUG:return F.bgMagenta(F.body.bold(" DEBUG "));case G.INFO:return F.bgBlue(F.body.bold(" INFO "));case G.WARN:return F.bgYellow(F.body.bold(" WARN "));case G.ERROR:return F.bgRed(F.body.bold(" ERROR "))}},"formatLevel"),Oc=o(e=>F.body(e),"formatName"),Cc=o(e=>{if(e==null)return Xe;let t=typeof e=="string"?e:String(e);if(t==="")return Xe;let r=t.split(Ie);return r.length===1?Ve+F.body(t):Ie+r.map(n=>Ve+Ve+n).join(Ie)},"formatMessage");var In={pretty:Ro,json:Ti};var mg={"--log-level":{type:o(e=>Yn(e,G.INFO),"type"),alias:["-ll"],default:G.INFO},"--my-logs":{type:Boolean}},Lc={trace:G.TRACE,debug:G.DEBUG,info:G.INFO,warn:G.WARN,error:G.ERROR},gg=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 c=In[D.logFormat],l=Lc[t.toLowerCase()];Rc(l,`Unknown level: ${t}`),je.writeStdout(c(l,r,n,a,s,e))},"createEnvironmentStructuredLogger"),Ao=o(({name:e,fields:t={},devFields:r={}})=>{let n=o(i=>(s,a,c)=>{let l=i>=D.logLevel,u=i>=G.INFO;if(!l&&!u)return;let f={...ne(t),...a};if(Se.developmentOrTestLike&&Object.assign(f,ne(r),c),"error"in f&&(f.error=le(f.error)),"reason"in f&&(f.reason=le(f.reason)),l){let d=In[D.logFormat];je.writeStderr(d(i,e,s,f))}u&&Si({level:"log",message:s,data:f})},"createStructuredLog");return{trace:n(G.TRACE),debug:n(G.DEBUG),info:n(G.INFO),warn:n(G.WARN),error:n(G.ERROR)}},"createStructuredLogger");var Nn=o(({name:e,fields:t,devFields:r})=>({...Ao({name:e,fields:t,devFields:r}),child:o(({name:n,fields:i,devFields:s})=>Nn({name:n||e,fields:o(()=>({...ne(t),...ne(i)}),"fields"),devFields:{...ne(r),...ne(s)}}),"child")}),"createLogger");h();var Io=se(qt(),1);import{setTimeout as Ac}from"node:timers/promises";var Og=o((e,t)=>Ac((0,Io.default)(e),void 0,t),"delay"),kn=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}},br=class{static{o(this,"PromiseSignal")}[Symbol.toStringTag];resolve;reject;_promise;constructor(){this._promise=new kn(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 _r=class e extends AbortController{static{o(this,"Context")}done=new br;#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:Nn(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 Pn=o(e=>(Ic(e.context?.ctx instanceof _r,P(`
261
+ ctx must be provided to http requests:
262
+
263
+ const response = await http({
264
+ context: { ctx },
265
+ ...options,
266
+ });
267
+ `)),e.context.ctx),"getContext"),yt=qn.extend({agent:{http:new Nc({keepAlive:!0}),https:new kc({keepAlive:!0,minVersion:"TLSv1.1"})},retry:{limit:mr,methods:[...Ws],statusCodes:[...Hs],errorCodes:[...En],maxRetryAfter:void 0,calculateDelay:o(({computedValue:e})=>e,"calculateDelay"),backoffLimit:bn,noise:_n},hooks:{beforeRequest:[e=>{let t=Pn(e);e.signal=t.signal,e.headers["user-agent"]=D.versionFull,t.log.debug("http request",{http:{request:{method:e.method,url:e.url?.toString()}}})}],beforeRetry:[(e,t)=>{Pn(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=Pn(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&&rt(t,void 0),e.headers["set-cookie"]){let r=e.headers["set-cookie"];(Array.isArray(r)?r:[r]).forEach(i=>{let s=Tt(i);s.name==="session"&&(s.domain==="gadget.dev"||s.domain==="ggt.dev")&&rt(t,s.value)})}return e}]}});h();import Gt from"node:process";var No=o(async e=>{let t;if(typeof e=="string"?t={content:e}:t=e,t=xr(t,{ensureEmptyLineAbove:!0,ensureNewLine:!0,exitWhenNo:!0}),!je.isInteractive){let r=t.whenNotInteractive??(()=>{de(t),de({ensureEmptyLineAbove:!0,content:"Aborting because ggt is not running in an interactive terminal."}),Gt.exit(1)});return Promise.resolve(r()).then(()=>!1)}return new Promise(r=>{let n=new $n(t);n.on("submit",i=>r(!!i)),n.on("exit",()=>Gt.exit(0)),n.on("abort",()=>Gt.exit(1))})},"confirm"),$n=class extends Xn{static{o(this,"Confirm")}value=void 0;defaultValue=!1;options;constructor(t){super(),this.options=xr(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&&Gt.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&&Gt.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){je.persistPrompt(qe({...this.options,content:`${this.options.content} ${t?Ge.bold.greenBright("Yes."):Ge.bold.redBright("No.")}`}));return}je.updatePrompt(qe({...this.options,content:`${this.options.content} ${this.defaultValue?Ge.blueBright("[Y/n] "):Ge.blueBright("[y/N] ")}`}))}};var $c=I.object({id:I.union([I.string(),I.number()]).transform(Number),name:I.string().nullish(),email:I.string()}),gt=o(async e=>{let t=He(e);if(t)try{let r=await yt({context:{ctx:e},url:`https://${D.domains.services}/auth/api/current-user`,headers:t,responseType:"json",resolveBodyOnly:!0}),n=$c.parse(r);return e.log.info("loaded user",{user:{id:n.id}},{user:n}),wi(n),n}catch(r){yi(e,r);return}},"getUser"),py=o(async(e,t)=>{let r=await gt(e);return r||(e.log.info("prompting user to log in"),de({ensureEmptyLineAbove:!0,content:`You must be logged in to use "ggt ${t}".`}),await No({ensureEmptyLineAbove:!0,content:"Would you like to log in?"}),await ko(e,{_:[]}),r=await gt(e),Pc(r,"missing user after successful login"),r)},"getUserOrLogin");var Cy=o(()=>P`
268
+ Log in to your account.
269
+
270
+ {bold Usage}
271
+ ggt login
272
+ `,"usage"),Bc=o(async e=>{let t;try{let r=await Sr(),n=new Promise((s,a)=>{t=Mc.createServer(async(c,l)=>{let u=new URL(`https://${D.domains.services}/auth/cli`);try{Mn(c.url,"missing url");let f=new URL(c.url,`http://localhost:${r}`).searchParams.get("session");Mn(f,"missing session"),rt(e,f);let d=await gt(e);Mn(d,"missing user after successful login"),d.name?de({ensureEmptyLineAbove:!0,content:P`Hello, ${d.name} {gray (${d.email})}`}):de({ensureEmptyLineAbove:!0,content:`Hello, ${d.email}`}),u.searchParams.set("success","true"),s()}catch(f){rt(e,void 0),u.searchParams.set("success","false"),a(f)}finally{l.writeHead(303,{Location:u.toString()}),l.end()}}),e.log.info("starting login server",{port:r}),t.listen(r)}),i=new URL(`https://${D.domains.services}/auth/login`);i.searchParams.set("returnTo",`https://${D.domains.services}/auth/cli/callback?port=${r}`);try{e.log.info("opening browser",{url:i.toString()}),await gi(i.toString()),de({ensureEmptyLineAbove:!0,content:P`
273
+ We've opened Gadget's login page using your default browser.
274
+
275
+ Please log in and then return to this terminal.
276
+ `})}catch(s){e.log.error("failed to open browser",{error:s}),de({ensureEmptyLineAbove:!0,content:P`
277
+ Please open the following URL in your browser and log in:
278
+
279
+ {gray ${i.toString()}}
280
+
281
+ Once logged in, return to this terminal.
282
+ `})}await n}finally{t?.close()}},"run"),ko=Bc;export{Ee as a,En as b,bf as c,ic as d,ap as e,Le as f,Fe as g,Sn as h,Ks as i,Ri as j,Js as k,yp as l,to as m,Ep as n,gr as o,Od as p,Cd as q,Ld as r,Ad as s,Id as t,Nd as u,kd as v,Pd as w,$d as x,Md as y,Bd as z,Dd as A,Fd as B,Ud as C,Vd as D,Gd as E,jd as F,qd as G,re as H,yr as I,At as J,Pr as K,Gs as L,Xl as M,gi as N,Cy as O,Bc as P,ko as Q,No as R,gt as S,py as T,Er as U,uc as V,dm as W,pm as X,mm as Y,gm as Z,F as _,mg as $,gg as aa,Og as ba,_r as ca,yt as da};
283
+ //# sourceMappingURL=chunk-IQSZEOYY.js.map