@gadgetinc/ggt 1.0.5 → 1.1.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.
- package/dist/add-RDTHYTCK.js +78 -0
- package/dist/add-RDTHYTCK.js.map +7 -0
- package/dist/chunk-3Q3GPB6Z.js +2 -0
- package/dist/chunk-3Q3GPB6Z.js.map +7 -0
- package/dist/chunk-457GEPUN.js +9 -0
- package/dist/chunk-457GEPUN.js.map +7 -0
- package/dist/{chunk-5DLLJX5F.js → chunk-5ONACLO6.js} +8 -8
- package/dist/{chunk-5DLLJX5F.js.map → chunk-5ONACLO6.js.map} +3 -3
- package/dist/chunk-CQLM5U6T.js +67 -0
- package/dist/chunk-CQLM5U6T.js.map +7 -0
- package/dist/chunk-FLXIAZND.js +12 -0
- package/dist/chunk-FLXIAZND.js.map +7 -0
- package/dist/chunk-JKDJXJKF.js +8 -0
- package/dist/{chunk-QEVWPU3D.js.map → chunk-JKDJXJKF.js.map} +3 -3
- package/dist/chunk-LWW4E6P5.js +173 -0
- package/dist/chunk-LWW4E6P5.js.map +7 -0
- package/dist/chunk-M2OJZLL7.js +18 -0
- package/dist/chunk-M2OJZLL7.js.map +7 -0
- package/dist/{chunk-Q5N5L6H3.js → chunk-M4PNFOA5.js} +2 -2
- package/dist/chunk-M4PNFOA5.js.map +7 -0
- package/dist/chunk-NGTOMLDS.js +33 -0
- package/dist/{chunk-G3VNV5Z6.js.map → chunk-NGTOMLDS.js.map} +3 -3
- package/dist/chunk-RYQWS5BH.js +117 -0
- package/dist/chunk-RYQWS5BH.js.map +7 -0
- package/dist/{chunk-IKJVXTZK.js → chunk-TRHAPK2F.js} +4 -6
- package/dist/{chunk-IKJVXTZK.js.map → chunk-TRHAPK2F.js.map} +2 -2
- package/dist/chunk-VICN6LTV.js +12 -0
- package/dist/chunk-VICN6LTV.js.map +7 -0
- package/dist/context-GN36UFJL.js +2 -0
- package/dist/deploy-BAMMI3ZA.js +24 -0
- package/dist/deploy-BAMMI3ZA.js.map +7 -0
- package/dist/{dev-M3WDGK4D.js → dev-5UFCKF4X.js} +9 -11
- package/dist/{dev-M3WDGK4D.js.map → dev-5UFCKF4X.js.map} +3 -3
- package/dist/esm-GJ7RK6IC.js +34 -0
- package/dist/esm-GJ7RK6IC.js.map +7 -0
- package/dist/list-WGRXHV2B.js +11 -0
- package/dist/list-WGRXHV2B.js.map +7 -0
- package/dist/login-5YZOB4XB.js +2 -0
- package/dist/logout-YXDH5ZZI.js +7 -0
- package/dist/{logout-UZBACOIX.js.map → logout-YXDH5ZZI.js.map} +3 -3
- package/dist/main.js +6 -8
- package/dist/main.js.map +3 -3
- package/dist/{open-GWKGQQG3.js → open-EOH3Q5KP.js} +3 -3
- package/dist/{open-GWKGQQG3.js.map → open-EOH3Q5KP.js.map} +2 -2
- package/dist/{pull-7C5A65KB.js → pull-UAKKKJJP.js} +3 -5
- package/dist/{pull-7C5A65KB.js.map → pull-UAKKKJJP.js.map} +2 -2
- package/dist/push-7X4P2364.js +2 -0
- package/dist/push-7X4P2364.js.map +7 -0
- package/dist/status-UJUGP24U.js +14 -0
- package/dist/{status-DFKKSRVB.js.map → status-UJUGP24U.js.map} +1 -1
- package/dist/user-B2RIDVTH.js +2 -0
- package/dist/user-B2RIDVTH.js.map +7 -0
- package/dist/{version-JD42JXWY.js → version-VE55GG37.js} +2 -2
- package/dist/whoami-OAH55L4M.js +7 -0
- package/dist/{whoami-I23R6HOG.js.map → whoami-OAH55L4M.js.map} +2 -2
- package/package.json +22 -22
- package/dist/add-4ME2KTJQ.js +0 -84
- package/dist/add-4ME2KTJQ.js.map +0 -7
- package/dist/chunk-BZY2AIPV.js +0 -57
- package/dist/chunk-BZY2AIPV.js.map +0 -7
- package/dist/chunk-G3VNV5Z6.js +0 -33
- package/dist/chunk-GA7AL463.js +0 -24
- package/dist/chunk-GA7AL463.js.map +0 -7
- package/dist/chunk-KGSSHEEC.js +0 -17
- package/dist/chunk-KGSSHEEC.js.map +0 -7
- package/dist/chunk-KXK37C5D.js +0 -183
- package/dist/chunk-KXK37C5D.js.map +0 -7
- package/dist/chunk-NJIDVM2C.js +0 -27
- package/dist/chunk-NJIDVM2C.js.map +0 -7
- package/dist/chunk-Q5N5L6H3.js.map +0 -7
- package/dist/chunk-QEVWPU3D.js +0 -8
- package/dist/chunk-X36GM74C.js +0 -2
- package/dist/chunk-X36GM74C.js.map +0 -7
- package/dist/chunk-YRP2UZ2I.js +0 -126
- package/dist/chunk-YRP2UZ2I.js.map +0 -7
- package/dist/deploy-6HOBYPE6.js +0 -30
- package/dist/deploy-6HOBYPE6.js.map +0 -7
- package/dist/esm-BL3OM5UJ.js +0 -33
- package/dist/esm-BL3OM5UJ.js.map +0 -7
- package/dist/list-725RHWD5.js +0 -11
- package/dist/list-725RHWD5.js.map +0 -7
- package/dist/login-I4RGMDLE.js +0 -2
- package/dist/logout-UZBACOIX.js +0 -7
- package/dist/push-LPUIR4EO.js +0 -2
- package/dist/status-DFKKSRVB.js +0 -14
- package/dist/whoami-I23R6HOG.js +0 -7
- /package/dist/{login-I4RGMDLE.js.map → context-GN36UFJL.js.map} +0 -0
- /package/dist/{push-LPUIR4EO.js.map → login-5YZOB4XB.js.map} +0 -0
- /package/dist/{version-JD42JXWY.js.map → version-VE55GG37.js.map} +0 -0
package/dist/chunk-G3VNV5Z6.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{b as Zt}from"./chunk-D2K5XPNJ.js";import{e as Kt,f as Xt,k as ae,m as We}from"./chunk-KGSSHEEC.js";import{k as Yt}from"./chunk-GA7AL463.js";import{A as Ht,I as me,T as Ce,e as E,g as Qt,h as Vt,i as nt,j as ot,k as at,m as lt,z as K}from"./chunk-BZY2AIPV.js";import{a as k,c as A,e as oe,g as m}from"./chunk-5WC5D4WL.js";var Jt=A((ct,ut)=>{m();(function(t,e){typeof k=="function"&&typeof ct=="object"&&typeof ut=="object"?ut.exports=e():typeof define=="function"&&define.amd?define(function(){return e()}):t.pluralize=e()})(ct,function(){var t=[],e=[],r={},s={},i={};function n(a){return typeof a=="string"?new RegExp("^"+a+"$","i"):a}function o(a,p){return a===p?p:a===a.toLowerCase()?p.toLowerCase():a===a.toUpperCase()?p.toUpperCase():a[0]===a[0].toUpperCase()?p.charAt(0).toUpperCase()+p.substr(1).toLowerCase():p.toLowerCase()}function c(a,p){return a.replace(/\$(\d{1,2})/g,function(y,b){return p[b]||""})}function l(a,p){return a.replace(p[0],function(y,b){var O=c(p[1],arguments);return o(y===""?a[b-1]:y,O)})}function u(a,p,y){if(!a.length||r.hasOwnProperty(a))return p;for(var b=y.length;b--;){var O=y[b];if(O[0].test(p))return l(p,O)}return p}function d(a,p,y){return function(b){var O=b.toLowerCase();return p.hasOwnProperty(O)?o(b,O):a.hasOwnProperty(O)?o(b,a[O]):u(O,b,y)}}function h(a,p,y,b){return function(O){var L=O.toLowerCase();return p.hasOwnProperty(L)?!0:a.hasOwnProperty(L)?!1:u(L,L,y)===L}}function f(a,p,y){var b=p===1?f.singular(a):f.plural(a);return(y?p+" ":"")+b}return f.plural=d(i,s,t),f.isPlural=h(i,s,t),f.singular=d(s,i,e),f.isSingular=h(s,i,e),f.addPluralRule=function(a,p){t.push([n(a),p])},f.addSingularRule=function(a,p){e.push([n(a),p])},f.addUncountableRule=function(a){if(typeof a=="string"){r[a.toLowerCase()]=!0;return}f.addPluralRule(a,"$0"),f.addSingularRule(a,"$0")},f.addIrregularRule=function(a,p){p=p.toLowerCase(),a=a.toLowerCase(),i[a]=p,s[p]=a},[["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(a){return f.addIrregularRule(a[0],a[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(a){return f.addPluralRule(a[0],a[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(a){return f.addSingularRule(a[0],a[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(f.addUncountableRule),f})});var ar=A((_n,dt)=>{"use strict";m();var Ss=Object.prototype.hasOwnProperty,B="~";function Oe(){}Object.create&&(Oe.prototype=Object.create(null),new Oe().__proto__||(B=!1));function vs(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function or(t,e,r,s,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var n=new vs(r,s||t,i),o=B?B+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],n]:t._events[o].push(n):(t._events[o]=n,t._eventsCount++),t}function je(t,e){--t._eventsCount===0?t._events=new Oe:delete t._events[e]}function R(){this._events=new Oe,this._eventsCount=0}R.prototype.eventNames=function(){var e=[],r,s;if(this._eventsCount===0)return e;for(s in r=this._events)Ss.call(r,s)&&e.push(B?s.slice(1):s);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};R.prototype.listeners=function(e){var r=B?B+e:e,s=this._events[r];if(!s)return[];if(s.fn)return[s.fn];for(var i=0,n=s.length,o=new Array(n);i<n;i++)o[i]=s[i].fn;return o};R.prototype.listenerCount=function(e){var r=B?B+e:e,s=this._events[r];return s?s.fn?1:s.length:0};R.prototype.emit=function(e,r,s,i,n,o){var c=B?B+e:e;if(!this._events[c])return!1;var l=this._events[c],u=arguments.length,d,h;if(l.fn){switch(l.once&&this.removeListener(e,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,s),!0;case 4:return l.fn.call(l.context,r,s,i),!0;case 5:return l.fn.call(l.context,r,s,i,n),!0;case 6:return l.fn.call(l.context,r,s,i,n,o),!0}for(h=1,d=new Array(u-1);h<u;h++)d[h-1]=arguments[h];l.fn.apply(l.context,d)}else{var f=l.length,a;for(h=0;h<f;h++)switch(l[h].once&&this.removeListener(e,l[h].fn,void 0,!0),u){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,r);break;case 3:l[h].fn.call(l[h].context,r,s);break;case 4:l[h].fn.call(l[h].context,r,s,i);break;default:if(!d)for(a=1,d=new Array(u-1);a<u;a++)d[a-1]=arguments[a];l[h].fn.apply(l[h].context,d)}}return!0};R.prototype.on=function(e,r,s){return or(this,e,r,s,!1)};R.prototype.once=function(e,r,s){return or(this,e,r,s,!0)};R.prototype.removeListener=function(e,r,s,i){var n=B?B+e:e;if(!this._events[n])return this;if(!r)return je(this,n),this;var o=this._events[n];if(o.fn)o.fn===r&&(!i||o.once)&&(!s||o.context===s)&&je(this,n);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==r||i&&!o[c].once||s&&o[c].context!==s)&&l.push(o[c]);l.length?this._events[n]=l.length===1?l[0]:l:je(this,n)}return this};R.prototype.removeAllListeners=function(e){var r;return e?(r=B?B+e:e,this._events[r]&&je(this,r)):(this._events=new Oe,this._eventsCount=0),this};R.prototype.off=R.prototype.removeListener;R.prototype.addListener=R.prototype.on;R.prefixed=B;R.EventEmitter=R;typeof dt<"u"&&(dt.exports=R)});var dr=A((Rn,hr)=>{"use strict";m();var{Duplex:Ts}=k("stream");function ur(t){t.emit("close")}function Cs(){!this.destroyed&&this._writableState.finished&&this.destroy()}function fr(t){this.removeListener("error",fr),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Os(t,e){let r=!0,s=new Ts({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let c=!o&&s._readableState.objectMode?n.toString():n;s.push(c)||t.pause()}),t.once("error",function(n){s.destroyed||(r=!1,s.destroy(n))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(ur,s);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(ur,s)}),r&&t.terminate()},s._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(i,n,o)});return}t.send(i,o)},s.on("end",Cs),s.on("error",fr),s}hr.exports=Os});var Z=A((Mn,yr)=>{"use strict";m();var pr=["nodebuffer","arraybuffer","fragments"],mr=typeof Blob<"u";mr&&pr.push("blob");yr.exports={BINARY_TYPES:pr,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:mr,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Pe=A((Dn,ze)=>{"use strict";m();var{EMPTY_BUFFER:ks}=Z(),_t=Buffer[Symbol.species];function Ns(t,e){if(t.length===0)return ks;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let i=0;i<t.length;i++){let n=t[i];r.set(n,s),s+=n.length}return s<e?new _t(r.buffer,r.byteOffset,s):r}function gr(t,e,r,s,i){for(let n=0;n<i;n++)r[s+n]=t[n]^e[n&3]}function _r(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Ls(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function bt(t){if(bt.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new _t(t):ArrayBuffer.isView(t)?e=new _t(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),bt.readOnly=!1),e}ze.exports={concat:Ns,mask:gr,toArrayBuffer:Ls,toBuffer:bt,unmask:_r};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=k("bufferutil");ze.exports.mask=function(e,r,s,i,n){n<48?gr(e,r,s,i,n):t.mask(e,r,s,i,n)},ze.exports.unmask=function(e,r){e.length<32?_r(e,r):t.unmask(e,r)}}catch{}});var Er=A((qn,xr)=>{"use strict";m();var br=Symbol("kDone"),xt=Symbol("kRun"),Et=class{constructor(e){this[br]=()=>{this.pending--,this[xt]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[xt]()}[xt](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[br])}}};xr.exports=Et});var Re=A((Wn,Tr)=>{"use strict";m();var Ie=k("zlib"),wr=Pe(),Ps=Er(),{kStatusCode:Sr}=Z(),Is=Buffer[Symbol.species],$s=Buffer.from([0,0,255,255]),He=Symbol("permessage-deflate"),J=Symbol("total-length"),$e=Symbol("callback"),ie=Symbol("buffers"),Ve=Symbol("error"),Qe,wt=class{constructor(e,r,s){if(this._maxPayload=s|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!Qe){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Qe=new Ps(i)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[$e];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.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(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[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(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let i=r[s];if(i.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(i=i[0],s==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else if(s==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=i})}),e}decompress(e,r,s){Qe.add(i=>{this._decompress(e,r,(n,o)=>{i(),s(n,o)})})}compress(e,r,s){Qe.add(i=>{this._compress(e,r,(n,o)=>{i(),s(n,o)})})}_decompress(e,r,s){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Ie.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Ie.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[He]=this,this._inflate[J]=0,this._inflate[ie]=[],this._inflate.on("error",As),this._inflate.on("data",vr)}this._inflate[$e]=s,this._inflate.write(e),r&&this._inflate.write($s),this._inflate.flush(()=>{let n=this._inflate[Ve];if(n){this._inflate.close(),this._inflate=null,s(n);return}let o=wr.concat(this._inflate[ie],this._inflate[J]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[J]=0,this._inflate[ie]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),s(null,o)})}_compress(e,r,s){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Ie.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Ie.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[J]=0,this._deflate[ie]=[],this._deflate.on("data",Rs)}this._deflate[$e]=s,this._deflate.write(e),this._deflate.flush(Ie.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=wr.concat(this._deflate[ie],this._deflate[J]);r&&(n=new Is(n.buffer,n.byteOffset,n.length-4)),this._deflate[$e]=null,this._deflate[J]=0,this._deflate[ie]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,n)})}};Tr.exports=wt;function Rs(t){this[ie].push(t),this[J]+=t.length}function vr(t){if(this[J]+=t.length,this[He]._maxPayload<1||this[J]<=this[He]._maxPayload){this[ie].push(t);return}this[Ve]=new RangeError("Max payload size exceeded"),this[Ve].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ve][Sr]=1009,this.removeListener("data",vr),this.reset()}function As(t){this[He]._inflate=null,t[Sr]=1007,this[$e](t)}});var _e=A((jn,Ye)=>{"use strict";m();var{isUtf8:Cr}=k("buffer"),{hasBlob:Ms}=Z(),Bs=[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 Ds(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function St(t){let e=t.length,r=0;for(;r<e;)if(!(t[r]&128))r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function Gs(t){return Ms&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Ye.exports={isBlob:Gs,isValidStatusCode:Ds,isValidUTF8:St,tokenChars:Bs};if(Cr)Ye.exports.isValidUTF8=function(t){return t.length<24?St(t):Cr(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=k("utf-8-validate");Ye.exports.isValidUTF8=function(e){return e.length<32?St(e):t(e)}}catch{}});var kt=A((Qn,$r)=>{"use strict";m();var{Writable:qs}=k("stream"),Or=Re(),{BINARY_TYPES:Us,EMPTY_BUFFER:kr,kStatusCode:Ws,kWebSocket:Fs}=Z(),{concat:vt,toArrayBuffer:js,unmask:zs}=Pe(),{isValidStatusCode:Qs,isValidUTF8:Nr}=_e(),Ke=Buffer[Symbol.species],F=0,Lr=1,Pr=2,Ir=3,Tt=4,Ct=5,Xe=6,Ot=class extends qs{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Us[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Fs]=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=F}_write(e,r,s){if(this._opcode===8&&this._state==F)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new Ke(s.buffer,s.byteOffset+e,s.length-e),new Ke(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],i=r.length-e;e>=s.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),i),this._buffers[0]=new Ke(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case F:this.getInfo(e);break;case Lr:this.getPayloadLength16(e);break;case Pr:this.getPayloadLength64(e);break;case Ir:this.getMask();break;case Tt:this.getData(e);break;case Ct:case Xe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if(r[0]&48){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let s=(r[0]&64)===64;if(s&&!this._extensions[Or.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(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");e(i);return}this._compressed=s}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");e(i);return}if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(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");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(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");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=Lr:this._payloadLength===127?this._state=Pr:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>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");e(i);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){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");e(r);return}this._masked?this._state=Ir:this._state=Tt}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Tt}getData(e){let r=kr;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]&&zs(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Ct,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Or.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return r(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}this._fragments.push(n)}this.dataMessage(r),this._state===F&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=F;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=vt(s,r):this._binaryType==="arraybuffer"?i=js(vt(s,r)):this._binaryType==="blob"?i=new Blob(s):i=s,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=F):(this._state=Xe,setImmediate(()=>{this.emit("message",i,!0),this._state=F,this.startLoop(e)}))}else{let i=vt(s,r);if(!this._skipUTF8Validation&&!Nr(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===Ct||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=F):(this._state=Xe,setImmediate(()=>{this.emit("message",i,!1),this._state=F,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,kr),this.end();else{let s=e.readUInt16BE(0);if(!Qs(s)){let n=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(n);return}let i=new Ke(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Nr(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(n);return}this._loop=!1,this.emit("conclude",s,i),this.end()}this._state=F;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=F):(this._state=Xe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=F,this.startLoop(r)}))}createError(e,r,s,i,n){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=n,o[Ws]=i,o}};$r.exports=Ot});var Pt=A((Yn,Mr)=>{"use strict";m();var{Duplex:Hn}=k("stream"),{randomFillSync:Vs}=k("crypto"),Rr=Re(),{EMPTY_BUFFER:Hs,kWebSocket:Ys,NOOP:Ks}=Z(),{isBlob:be,isValidStatusCode:Xs}=_e(),{mask:Ar,toBuffer:le}=Pe(),j=Symbol("kByteLength"),Zs=Buffer.alloc(4),Ze=8*1024,ce,xe=Ze,Q=0,Js=1,ei=2,Nt=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Q,this.onerror=Ks,this[Ys]=void 0}static frame(e,r){let s,i=!1,n=2,o=!1;r.mask&&(s=r.maskBuffer||Zs,r.generateMask?r.generateMask(s):(xe===Ze&&(ce===void 0&&(ce=Buffer.alloc(Ze)),Vs(ce,0,Ze),xe=0),s[0]=ce[xe++],s[1]=ce[xe++],s[2]=ce[xe++],s[3]=ce[xe++]),o=(s[0]|s[1]|s[2]|s[3])===0,n=6);let c;typeof e=="string"?(!r.mask||o)&&r[j]!==void 0?c=r[j]:(e=Buffer.from(e),c=e.length):(c=e.length,i=r.mask&&r.readOnly&&!o);let l=c;c>=65536?(n+=8,l=127):c>125&&(n+=2,l=126);let u=Buffer.allocUnsafe(i?c+n:n);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[n-4]=s[0],u[n-3]=s[1],u[n-2]=s[2],u[n-1]=s[3],o?[u,e]:i?(Ar(e,s,u,n,c),[u]):(Ar(e,s,e,0,c),[u,e])):[u,e]}close(e,r,s,i){let n;if(e===void 0)n=Hs;else{if(typeof e!="number"||!Xs(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let c=Buffer.byteLength(r);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+c),n.writeUInt16BE(e,0),typeof r=="string"?n.write(r,2):n.set(r,2)}}let o={[j]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Q?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):be(e)?(i=e.size,n=!1):(e=le(e),i=e.length,n=le.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[j]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};be(e)?this._state!==Q?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==Q?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}pong(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):be(e)?(i=e.size,n=!1):(e=le(e),i=e.length,n=le.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[j]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};be(e)?this._state!==Q?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==Q?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}send(e,r,s){let i=this._extensions[Rr.extensionName],n=r.binary?2:1,o=r.compress,c,l;typeof e=="string"?(c=Buffer.byteLength(e),l=!1):be(e)?(c=e.size,l=!1):(e=le(e),c=e.length,l=le.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=i._threshold),this._compress=o):(o=!1,n=0),r.fin&&(this._firstFragment=!0);let u={[j]:c,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};be(e)?this._state!==Q?this.enqueue([this.getBlobData,e,this._compress,u,s]):this.getBlobData(e,this._compress,u,s):this._state!==Q?this.enqueue([this.dispatch,e,this._compress,u,s]):this.dispatch(e,this._compress,u,s)}getBlobData(e,r,s,i){this._bufferedBytes+=s[j],this._state=ei,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(Lt,this,c,i);return}this._bufferedBytes-=s[j];let o=le(n);r?this.dispatch(o,r,s,i):(this._state=Q,this.sendFrame(t.frame(o,s),i),this.dequeue())}).catch(n=>{process.nextTick(ti,this,n,i)})}dispatch(e,r,s,i){if(!r){this.sendFrame(t.frame(e,s),i);return}let n=this._extensions[Rr.extensionName];this._bufferedBytes+=s[j],this._state=Js,n.compress(e,s.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Lt(this,l,i);return}this._bufferedBytes-=s[j],this._state=Q,s.readOnly=!1,this.sendFrame(t.frame(c,s),i),this.dequeue()})}dequeue(){for(;this._state===Q&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][j],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][j],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Mr.exports=Nt;function Lt(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let i=t._queue[s],n=i[i.length-1];typeof n=="function"&&n(e)}}function ti(t,e,r){Lt(t,e,r),t.onerror(e)}});var zr=A((Xn,jr)=>{"use strict";m();var{kForOnEventAttribute:Ae,kListener:It}=Z(),Br=Symbol("kCode"),Dr=Symbol("kData"),Gr=Symbol("kError"),qr=Symbol("kMessage"),Ur=Symbol("kReason"),Ee=Symbol("kTarget"),Wr=Symbol("kType"),Fr=Symbol("kWasClean"),ee=class{constructor(e){this[Ee]=null,this[Wr]=e}get target(){return this[Ee]}get type(){return this[Wr]}};Object.defineProperty(ee.prototype,"target",{enumerable:!0});Object.defineProperty(ee.prototype,"type",{enumerable:!0});var ue=class extends ee{constructor(e,r={}){super(e),this[Br]=r.code===void 0?0:r.code,this[Ur]=r.reason===void 0?"":r.reason,this[Fr]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Br]}get reason(){return this[Ur]}get wasClean(){return this[Fr]}};Object.defineProperty(ue.prototype,"code",{enumerable:!0});Object.defineProperty(ue.prototype,"reason",{enumerable:!0});Object.defineProperty(ue.prototype,"wasClean",{enumerable:!0});var we=class extends ee{constructor(e,r={}){super(e),this[Gr]=r.error===void 0?null:r.error,this[qr]=r.message===void 0?"":r.message}get error(){return this[Gr]}get message(){return this[qr]}};Object.defineProperty(we.prototype,"error",{enumerable:!0});Object.defineProperty(we.prototype,"message",{enumerable:!0});var Me=class extends ee{constructor(e,r={}){super(e),this[Dr]=r.data===void 0?null:r.data}get data(){return this[Dr]}};Object.defineProperty(Me.prototype,"data",{enumerable:!0});var ri={addEventListener(t,e,r={}){for(let i of this.listeners(t))if(!r[Ae]&&i[It]===e&&!i[Ae])return;let s;if(t==="message")s=function(n,o){let c=new Me("message",{data:o?n:n.toString()});c[Ee]=this,Je(e,this,c)};else if(t==="close")s=function(n,o){let c=new ue("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[Ee]=this,Je(e,this,c)};else if(t==="error")s=function(n){let o=new we("error",{error:n,message:n.message});o[Ee]=this,Je(e,this,o)};else if(t==="open")s=function(){let n=new ee("open");n[Ee]=this,Je(e,this,n)};else return;s[Ae]=!!r[Ae],s[It]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[It]===e&&!r[Ae]){this.removeListener(t,r);break}}};jr.exports={CloseEvent:ue,ErrorEvent:we,Event:ee,EventTarget:ri,MessageEvent:Me};function Je(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var $t=A((Jn,Qr)=>{"use strict";m();var{tokenChars:Be}=_e();function V(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function si(t){let e=Object.create(null),r=Object.create(null),s=!1,i=!1,n=!1,o,c,l=-1,u=-1,d=-1,h=0;for(;h<t.length;h++)if(u=t.charCodeAt(h),o===void 0)if(d===-1&&Be[u]===1)l===-1&&(l=h);else if(h!==0&&(u===32||u===9))d===-1&&l!==-1&&(d=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);d===-1&&(d=h);let a=t.slice(l,d);u===44?(V(e,a,r),r=Object.create(null)):o=a,l=d=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);else if(c===void 0)if(d===-1&&Be[u]===1)l===-1&&(l=h);else if(u===32||u===9)d===-1&&l!==-1&&(d=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);d===-1&&(d=h),V(r,t.slice(l,d),!0),u===44&&(V(e,o,r),r=Object.create(null),o=void 0),l=d=-1}else if(u===61&&l!==-1&&d===-1)c=t.slice(l,h),l=d=-1;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(i){if(Be[u]!==1)throw new SyntaxError(`Unexpected character at index ${h}`);l===-1?l=h:s||(s=!0),i=!1}else if(n)if(Be[u]===1)l===-1&&(l=h);else if(u===34&&l!==-1)n=!1,d=h;else if(u===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(u===34&&t.charCodeAt(h-1)===61)n=!0;else if(d===-1&&Be[u]===1)l===-1&&(l=h);else if(l!==-1&&(u===32||u===9))d===-1&&(d=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);d===-1&&(d=h);let a=t.slice(l,d);s&&(a=a.replace(/\\/g,""),s=!1),V(r,c,a),u===44&&(V(e,o,r),r=Object.create(null),o=void 0),c=void 0,l=d=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);if(l===-1||n||u===32||u===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=h);let f=t.slice(l,d);return o===void 0?V(e,f,r):(c===void 0?V(r,f,!0):s?V(r,c,f.replace(/\\/g,"")):V(r,c,f),V(e,o,r)),e}function ii(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(i=>{let n=s[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Qr.exports={format:ii,parse:si}});var Dt=A((so,is)=>{"use strict";m();var ni=k("events"),oi=k("https"),ai=k("http"),Yr=k("net"),li=k("tls"),{randomBytes:ci,createHash:ui}=k("crypto"),{Duplex:to,Readable:ro}=k("stream"),{URL:Rt}=k("url"),ne=Re(),fi=kt(),hi=Pt(),{isBlob:di}=_e(),{BINARY_TYPES:Vr,EMPTY_BUFFER:et,GUID:pi,kForOnEventAttribute:At,kListener:mi,kStatusCode:yi,kWebSocket:P,NOOP:Kr}=Z(),{EventTarget:{addEventListener:gi,removeEventListener:_i}}=zr(),{format:bi,parse:xi}=$t(),{toBuffer:Ei}=Pe(),wi=30*1e3,Xr=Symbol("kAborted"),Mt=[8,13],te=["CONNECTING","OPEN","CLOSING","CLOSED"],Si=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,T=class t extends ni{constructor(e,r,s){super(),this._binaryType=Vr[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=et,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,r=[]):r=[r]),Zr(this,e,r,s)):(this._autoPong=s.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Vr.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}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(e,r,s){let i=new fi({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),n=new hi(e,this._extensions,s.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[P]=this,n[P]=this,e[P]=this,i.on("conclude",Ci),i.on("drain",Oi),i.on("error",ki),i.on("message",Ni),i.on("ping",Li),i.on("pong",Pi),n.onerror=Ii,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",ts),e.on("data",rt),e.on("end",rs),e.on("error",ss),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ne.extensionName]&&this._extensions[ne.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){q(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),es(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Bt(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||et,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Bt(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||et,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Bt(this,e,s);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[ne.extensionName]||(i.compress=!1),this._sender.send(e||et,i,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){q(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(T,"CONNECTING",{enumerable:!0,value:te.indexOf("CONNECTING")});Object.defineProperty(T.prototype,"CONNECTING",{enumerable:!0,value:te.indexOf("CONNECTING")});Object.defineProperty(T,"OPEN",{enumerable:!0,value:te.indexOf("OPEN")});Object.defineProperty(T.prototype,"OPEN",{enumerable:!0,value:te.indexOf("OPEN")});Object.defineProperty(T,"CLOSING",{enumerable:!0,value:te.indexOf("CLOSING")});Object.defineProperty(T.prototype,"CLOSING",{enumerable:!0,value:te.indexOf("CLOSING")});Object.defineProperty(T,"CLOSED",{enumerable:!0,value:te.indexOf("CLOSED")});Object.defineProperty(T.prototype,"CLOSED",{enumerable:!0,value:te.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(T.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(T.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[At])return e[mi];return null},set(e){for(let r of this.listeners(t))if(r[At]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[At]:!0})}})});T.prototype.addEventListener=gi;T.prototype.removeEventListener=_i;is.exports=T;function Zr(t,e,r,s){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Mt[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,!Mt.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Mt.join(", ")})`);let n;if(e instanceof Rt)n=e;else try{n=new Rt(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",c=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`:c&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let y=new SyntaxError(l);if(t._redirects===0)throw y;tt(t,y);return}let u=o?443:80,d=ci(16).toString("base64"),h=o?oi.request:ai.request,f=new Set,a;if(i.createConnection=i.createConnection||(o?Ti:vi),i.defaultPort=i.defaultPort||u,i.port=n.port||u,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(a=new ne(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=bi({[ne.extensionName]:a.offer()})),r.length){for(let y of r){if(typeof y!="string"||!Si.test(y)||f.has(y))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(y)}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),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),c){let y=i.path.split(":");i.socketPath=y[0],i.path=y[1]}let p;if(i.followRedirects){if(t._redirects===0){t._originalIpc=c,t._originalSecure=o,t._originalHostOrSocketPath=c?i.socketPath:n.host;let y=s&&s.headers;if(s={...s,headers:{}},y)for(let[b,O]of Object.entries(y))s.headers[b.toLowerCase()]=O}else if(t.listenerCount("redirect")===0){let y=c?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!y||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,y||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),p=t._req=h(i),t._redirects&&t.emit("redirect",t.url,p)}else p=t._req=h(i);i.timeout&&p.on("timeout",()=>{q(t,p,"Opening handshake has timed out")}),p.on("error",y=>{p===null||p[Xr]||(p=t._req=null,tt(t,y))}),p.on("response",y=>{let b=y.headers.location,O=y.statusCode;if(b&&i.followRedirects&&O>=300&&O<400){if(++t._redirects>i.maxRedirects){q(t,p,"Maximum redirects exceeded");return}p.abort();let L;try{L=new Rt(b,e)}catch{let C=new SyntaxError(`Invalid URL: ${b}`);tt(t,C);return}Zr(t,L,r,s)}else t.emit("unexpected-response",p,y)||q(t,p,`Unexpected server response: ${y.statusCode}`)}),p.on("upgrade",(y,b,O)=>{if(t.emit("upgrade",y),t.readyState!==T.CONNECTING)return;p=t._req=null;let L=y.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){q(t,b,"Invalid Upgrade header");return}let H=ui("sha1").update(d+pi).digest("base64");if(y.headers["sec-websocket-accept"]!==H){q(t,b,"Invalid Sec-WebSocket-Accept header");return}let C=y.headers["sec-websocket-protocol"],re;if(C!==void 0?f.size?f.has(C)||(re="Server sent an invalid subprotocol"):re="Server sent a subprotocol but none was requested":f.size&&(re="Server sent no subprotocol"),re){q(t,b,re);return}C&&(t._protocol=C);let U=y.headers["sec-websocket-extensions"];if(U!==void 0){if(!a){q(t,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=xi(U)}catch{q(t,b,"Invalid Sec-WebSocket-Extensions header");return}let ve=Object.keys(z);if(ve.length!==1||ve[0]!==ne.extensionName){q(t,b,"Server indicated an extension that was not requested");return}try{a.accept(z[ne.extensionName])}catch{q(t,b,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ne.extensionName]=a}t.setSocket(b,O,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(p,t):p.end()}function tt(t,e){t._readyState=T.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function vi(t){return t.path=t.socketPath,Yr.connect(t)}function Ti(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Yr.isIP(t.host)?"":t.host),li.connect(t)}function q(t,e,r){t._readyState=T.CLOSING;let s=new Error(r);Error.captureStackTrace(s,q),e.setHeader?(e[Xr]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(tt,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Bt(t,e,r){if(e){let s=di(e)?e.size:Ei(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${te[t.readyState]})`);process.nextTick(r,s)}}function Ci(t,e){let r=this[P];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[P]!==void 0&&(r._socket.removeListener("data",rt),process.nextTick(Jr,r._socket),t===1005?r.close():r.close(t,e))}function Oi(){let t=this[P];t.isPaused||t._socket.resume()}function ki(t){let e=this[P];e._socket[P]!==void 0&&(e._socket.removeListener("data",rt),process.nextTick(Jr,e._socket),e.close(t[yi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Hr(){this[P].emitClose()}function Ni(t,e){this[P].emit("message",t,e)}function Li(t){let e=this[P];e._autoPong&&e.pong(t,!this._isServer,Kr),e.emit("ping",t)}function Pi(t){this[P].emit("pong",t)}function Jr(t){t.resume()}function Ii(t){let e=this[P];e.readyState!==T.CLOSED&&(e.readyState===T.OPEN&&(e._readyState=T.CLOSING,es(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function es(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),wi)}function ts(){let t=this[P];this.removeListener("close",ts),this.removeListener("data",rt),this.removeListener("end",rs),t._readyState=T.CLOSING;let e;!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&(e=t._socket.read())!==null&&t._receiver.write(e),t._receiver.end(),this[P]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Hr),t._receiver.on("finish",Hr))}function rt(t){this[P]._receiver.write(t)||this.pause()}function rs(){let t=this[P];t._readyState=T.CLOSING,t._receiver.end(),this.end()}function ss(){let t=this[P];this.removeListener("error",ss),this.on("error",Kr),t&&(t._readyState=T.CLOSING,this.destroy())}});var os=A((no,ns)=>{"use strict";m();var{tokenChars:$i}=_e();function Ri(t){let e=new Set,r=-1,s=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(s===-1&&$i[o]===1)r===-1&&(r=i);else if(i!==0&&(o===32||o===9))s===-1&&r!==-1&&(s=i);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${i}`);s===-1&&(s=i);let c=t.slice(r,s);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(r,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}ns.exports={parse:Ri}});var ds=A((lo,hs)=>{"use strict";m();var Ai=k("events"),st=k("http"),{Duplex:ao}=k("stream"),{createHash:Mi}=k("crypto"),as=$t(),fe=Re(),Bi=os(),Di=Dt(),{GUID:Gi,kWebSocket:qi}=Z(),Ui=/^[+/0-9A-Za-z]{22}==$/,ls=0,cs=1,fs=2,Gt=class extends Ai{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Di,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=st.createServer((s,i)=>{let n=st.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=Wi(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ls}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===fs){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(De,this);return}if(e&&this.once("close",e),this._state!==cs)if(this._state=cs,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(De,this):process.nextTick(De,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{De(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,i){r.on("error",us);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){he(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){he(this,e,r,400,"Invalid Upgrade header");return}if(n===void 0||!Ui.test(n)){he(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==8&&c!==13){he(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Ge(r,400);return}let l=e.headers["sec-websocket-protocol"],u=new Set;if(l!==void 0)try{u=Bi.parse(l)}catch{he(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&d!==void 0){let f=new fe(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let a=as.parse(d);a[fe.extensionName]&&(f.accept(a[fe.extensionName]),h[fe.extensionName]=f)}catch{he(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(a,p,y,b)=>{if(!a)return Ge(r,p||401,y,b);this.completeUpgrade(h,n,u,e,r,s,i)});return}if(!this.options.verifyClient(f))return Ge(r,401)}this.completeUpgrade(h,n,u,e,r,s,i)}completeUpgrade(e,r,s,i,n,o,c){if(!n.readable||!n.writable)return n.destroy();if(n[qi])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ls)return Ge(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Mi("sha1").update(r+Gi).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(s.size){let h=this.options.handleProtocols?this.options.handleProtocols(s,i):s.values().next().value;h&&(u.push(`Sec-WebSocket-Protocol: ${h}`),d._protocol=h)}if(e[fe.extensionName]){let h=e[fe.extensionName].params,f=as.format({[fe.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${f}`),d._extensions=e}this.emit("headers",u,i),n.write(u.concat(`\r
|
|
2
|
-
`).join(`\r
|
|
3
|
-
`)),n.removeListener("error",us),d.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(De,this)})),c(d,i)}};hs.exports=Gt;function Wi(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function De(t){t._state=fs,t.emit("close")}function us(){this.destroy()}function Ge(t,e,r,s){r=r||st.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${st.STATUS_CODES[e]}\r
|
|
4
|
-
`+Object.keys(s).map(i=>`${i}: ${s[i]}`).join(`\r
|
|
5
|
-
`)+`\r
|
|
6
|
-
\r
|
|
7
|
-
`+r)}function he(t,e,r,s,i){if(t.listenerCount("wsClientError")){let n=new Error(i);Error.captureStackTrace(n,he),t.emit("wsClientError",n,r,e)}else Ge(r,s,i)}});m();var er=oe(Jt(),1);import bs from"node:assert";var W=class extends Xt{constructor(r,s){super("An error occurred while communicating with Gadget");this.request=r;at(s)?this.cause={type:s.type,message:s.message,error:Yt(s.error)}:ot(s)?this.cause={type:s.type,code:s.code,reason:s.reason,wasClean:s.wasClean}:(bs(Qt(s)||nt(s)||lt(s),"cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent"),this.cause=s)}isBug=Kt.MAYBE;cause;render(){let r="";switch(!0){case lt(this.cause):{let s=Zt(this.cause.map(i=>i.message));r=Ce`
|
|
8
|
-
Gadget responded with the following ${(0,er.default)("error",s.length,!1)}:
|
|
9
|
-
|
|
10
|
-
• ${s.join(`
|
|
11
|
-
\u2022 `)}
|
|
12
|
-
`;break}case ot(this.cause):r="The connection to Gadget closed unexpectedly.";break;case(at(this.cause)||nt(this.cause)):r=this.cause.message;break;default:r=this.cause;break}return this.message+`
|
|
13
|
-
|
|
14
|
-
`+r}};m();import Ut from"node:assert";m();import qt from"node:assert";m();m();m();m();function M(t){return t===null?"null":Array.isArray(t)?"array":typeof t}function X(t){return M(t)==="object"}function tr(t){return Array.isArray(t)&&t.length>0&&t.every(e=>"message"in e)}function ft(t,e){return t.length<124?t:e}var rr="graphql-transport-ws";var G;(function(t){t[t.InternalServerError=4500]="InternalServerError",t[t.InternalClientError=4005]="InternalClientError",t[t.BadRequest=4400]="BadRequest",t[t.BadResponse=4004]="BadResponse",t[t.Unauthorized=4401]="Unauthorized",t[t.Forbidden=4403]="Forbidden",t[t.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",t[t.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",t[t.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",t[t.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",t[t.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(G||(G={}));var N;(function(t){t.ConnectionInit="connection_init",t.ConnectionAck="connection_ack",t.Ping="ping",t.Pong="pong",t.Subscribe="subscribe",t.Next="next",t.Error="error",t.Complete="complete"})(N||(N={}));function sr(t){if(!X(t))throw new Error(`Message is expected to be an object, but got ${M(t)}`);if(!t.type)throw new Error("Message is missing the 'type' property");if(typeof t.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${M(t.type)}`);switch(t.type){case N.ConnectionInit:case N.ConnectionAck:case N.Ping:case N.Pong:{if(t.payload!=null&&!X(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${t.payload}"`);break}case N.Subscribe:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);if(!X(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an object, but got ${M(t.payload)}`);if(typeof t.payload.query!="string")throw new Error(`"${t.type}" message payload expects the 'query' property to be a string, but got ${M(t.payload.query)}`);if(t.payload.variables!=null&&!X(t.payload.variables))throw new Error(`"${t.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${M(t.payload.variables)}`);if(t.payload.operationName!=null&&M(t.payload.operationName)!=="string")throw new Error(`"${t.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${M(t.payload.operationName)}`);if(t.payload.extensions!=null&&!X(t.payload.extensions))throw new Error(`"${t.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${M(t.payload.extensions)}`);break}case N.Next:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);if(!X(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an object, but got ${M(t.payload)}`);break}case N.Error:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);if(!tr(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(t.payload)}`);break}case N.Complete:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${t.type}"`)}return t}function ir(t,e){return sr(typeof t=="string"?JSON.parse(t,e):t)}function ye(t,e){return sr(t),JSON.stringify(t,e)}var ge=function(t){return this instanceof ge?(this.v=t,this):new ge(t)},xs=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),i,n=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(f){s[f]&&(i[f]=function(a){return new Promise(function(p,y){n.push([f,a,p,y])>1||c(f,a)})})}function c(f,a){try{l(s[f](a))}catch(p){h(n[0][3],p)}}function l(f){f.value instanceof ge?Promise.resolve(f.value.v).then(u,d):h(n[0][2],f)}function u(f){c("next",f)}function d(f){c("throw",f)}function h(f,a){f(a),n.shift(),n.length&&c(n[0][0],n[0][1])}};function nr(t){let{url:e,connectionParams:r,lazy:s=!0,onNonLazyError:i=console.error,lazyCloseTimeout:n=0,keepAlive:o=0,disablePong:c,connectionAckWaitTimeout:l=0,retryAttempts:u=5,retryWait:d=async function(v){let g=1e3;for(let x=0;x<v;x++)g*=2;await new Promise(x=>setTimeout(x,g+Math.floor(Math.random()*2700+300)))},shouldRetry:h=ht,isFatalConnectionProblem:f,on:a,webSocketImpl:p,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,v=>{let g=Math.random()*16|0;return(v=="x"?g:g&3|8).toString(16)})},jsonMessageReplacer:b,jsonMessageReviver:O}=t,L;if(p){if(!ws(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 H=L,C=(()=>{let _=(()=>{let g={};return{on(x,S){return g[x]=S,()=>{delete g[x]}},emit(x){var S;"id"in x&&((S=g[x.id])===null||S===void 0||S.call(g,x))}}})(),v={connecting:a?.connecting?[a.connecting]:[],opened:a?.opened?[a.opened]:[],connected:a?.connected?[a.connected]:[],ping:a?.ping?[a.ping]:[],pong:a?.pong?[a.pong]:[],message:a?.message?[_.emit,a.message]:[_.emit],closed:a?.closed?[a.closed]:[],error:a?.error?[a.error]:[]};return{onMessage:_.on,on(g,x){let S=v[g];return S.push(x),()=>{S.splice(S.indexOf(x),1)}},emit(g,...x){for(let S of[...v[g]])S(...x)}}})();function re(_){let v=[C.on("error",g=>{v.forEach(x=>x()),_(g)}),C.on("closed",g=>{v.forEach(x=>x()),_(g)})]}let U,z=0,ve,Y=!1,de=0,Wt=!1;async function Ft(){clearTimeout(ve);let[_,v]=await(U??(U=new Promise((S,D)=>(async()=>{if(Y){if(await d(de),!z)return U=void 0,D({code:1e3,reason:"All Subscriptions Gone"});de++}C.emit("connecting",Y);let w=new H(typeof e=="function"?await e():e,rr),se,Te;function Ue(){isFinite(o)&&o>0&&(clearTimeout(Te),Te=setTimeout(()=>{w.readyState===H.OPEN&&(w.send(ye({type:N.Ping})),C.emit("ping",!1,void 0))},o))}re($=>{U=void 0,clearTimeout(se),clearTimeout(Te),D($),$ instanceof Fe&&(w.close(4499,"Terminated"),w.onerror=null,w.onclose=null)}),w.onerror=$=>C.emit("error",$),w.onclose=$=>C.emit("closed",$),w.onopen=async()=>{try{C.emit("opened",w);let $=typeof r=="function"?await r():r;if(w.readyState!==H.OPEN)return;w.send(ye($?{type:N.ConnectionInit,payload:$}:{type:N.ConnectionInit},b)),isFinite(l)&&l>0&&(se=setTimeout(()=>{w.close(G.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},l)),Ue()}catch($){C.emit("error",$),w.close(G.InternalClientError,ft($ instanceof Error?$.message:new Error($).message,"Internal client error"))}};let pe=!1;w.onmessage=({data:$})=>{try{let I=ir($,O);if(C.emit("message",I),I.type==="ping"||I.type==="pong"){C.emit(I.type,!0,I.payload),I.type==="pong"?Ue():c||(w.send(ye(I.payload?{type:N.Pong,payload:I.payload}:{type:N.Pong})),C.emit("pong",!1,I.payload));return}if(pe)return;if(I.type!==N.ConnectionAck)throw new Error(`First message cannot be of type ${I.type}`);clearTimeout(se),pe=!0,C.emit("connected",w,I.payload,Y),Y=!1,de=0,S([w,new Promise((Ki,_s)=>re(_s))])}catch(I){w.onmessage=null,C.emit("error",I),w.close(G.BadResponse,ft(I instanceof Error?I.message:new Error(I).message,"Bad response"))}}})())));_.readyState===H.CLOSING&&await v;let g=()=>{},x=new Promise(S=>g=S);return[_,g,Promise.race([x.then(()=>{if(!z){let S=()=>_.close(1e3,"Normal Closure");isFinite(n)&&n>0?ve=setTimeout(()=>{_.readyState===H.OPEN&&S()},n):S()}}),v])]}function jt(_){if(ht(_)&&(Es(_.code)||[G.InternalServerError,G.InternalClientError,G.BadRequest,G.BadResponse,G.Unauthorized,G.SubprotocolNotAcceptable,G.SubscriberAlreadyExists,G.TooManyInitialisationRequests].includes(_.code)))throw _;if(Wt)return!1;if(ht(_)&&_.code===1e3)return z>0;if(!u||de>=u||!h(_)||f?.(_))throw _;return Y=!0}s||(async()=>{for(z++;;)try{let[,,_]=await Ft();await _}catch(_){try{if(!jt(_))return}catch(v){return i?.(v)}}})();function zt(_,v){let g=y(_),x=!1,S=!1,D=()=>{z--,x=!0};return(async()=>{for(z++;;)try{let[w,se,Te]=await Ft();if(x)return se();let Ue=C.onMessage(g,pe=>{switch(pe.type){case N.Next:{v.next(pe.payload);return}case N.Error:{S=!0,x=!0,v.error(pe.payload),D();return}case N.Complete:{x=!0,D();return}}});w.send(ye({id:g,type:N.Subscribe,payload:_},b)),D=()=>{!x&&w.readyState===H.OPEN&&w.send(ye({id:g,type:N.Complete},b)),z--,x=!0,se()},await Te.finally(Ue);return}catch(w){if(!jt(w))return}})().then(()=>{S||v.complete()}).catch(w=>{v.error(w)}),()=>{x||D()}}return{on:C.on,subscribe:zt,iterate(_){let v=[],g={done:!1,error:null,resolve:()=>{}},x=zt(_,{next(D){v.push(D),g.resolve()},error(D){g.done=!0,g.error=D,g.resolve()},complete(){g.done=!0,g.resolve()}}),S=function(){return xs(this,arguments,function*(){for(;;){for(v.length||(yield ge(new Promise(se=>g.resolve=se)));v.length;)yield yield ge(v.shift());if(g.error)throw g.error;if(g.done)return yield ge(void 0)}})}();return S.throw=async D=>(g.done||(g.done=!0,g.error=D,g.resolve()),{done:!0,value:void 0}),S.return=async()=>(x(),{done:!0,value:void 0}),S},async dispose(){if(Wt=!0,U){let[_]=await U;_.close(1e3,"Normal Closure")}},terminate(){U&&C.emit("closed",new Fe)}}}var Fe=class extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}};function ht(t){return X(t)&&"code"in t&&"reason"in t}function Es(t){return[1e3,1001,1006,1005,1012,1013,1014].includes(t)?!1:t>=1e3&&t<=1999}function ws(t){return typeof t=="function"&&"constructor"in t&&"CLOSED"in t&&"CLOSING"in t&&"CONNECTING"in t&&"OPEN"in t}import Se from"node:assert";m();m();var pt=oe(ar(),1);m();var ke=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},mt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},lr=t=>globalThis.DOMException===void 0?new mt(t):new DOMException(t),cr=t=>{let e=t.reason===void 0?lr("This operation was aborted."):t.reason;return e instanceof Error?e:lr(e)};function yt(t,e){let{milliseconds:r,fallback:s,message:i,customTimers:n={setTimeout,clearTimeout}}=e,o,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:f}=e;f.aborted&&d(cr(f)),f.addEventListener("abort",()=>{d(cr(f))})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let h=new ke;o=n.setTimeout.call(void 0,()=>{if(s){try{u(s())}catch(f){d(f)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(h.message=i??`Promise timed out after ${r} milliseconds`,d(h))},r),(async()=>{try{u(await t)}catch(f){d(f)}})()}).finally(()=>{l.clear()});return l.clear=()=>{n.clearTimeout.call(void 0,o),o=void 0},l}m();m();function gt(t,e,r){let s=0,i=t.length;for(;i>0;){let n=Math.trunc(i/2),o=s+n;r(t[o],e)<=0?(s=++o,i-=n+1):i=n}return s}var Ne=class{#e=[];enqueue(e,r){r={priority:0,...r};let s={priority:r.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(s);return}let i=gt(this.#e,s,(n,o)=>o.priority-n.priority);this.#e.splice(i,0,s)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this.#e.length}};var Le=class extends pt.default{#e;#o;#n=0;#d;#a;#p=0;#r;#l;#t;#m;#s=0;#c;#i;#y;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Ne,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#o=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#y=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#b(){return this.#o||this.#n<this.#d}get#x(){return this.#s<this.#c}#E(){this.#s--,this.#u(),this.emit("next")}#w(){this.#_(),this.#g(),this.#l=void 0}get#S(){let e=Date.now();if(this.#r===void 0){let r=this.#p-e;if(r<0)this.#n=this.#e?this.#s:0;else return this.#l===void 0&&(this.#l=setTimeout(()=>{this.#w()},r)),!0}return!1}#u(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#s===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#S;if(this.#b&&this.#x){let r=this.#t.dequeue();return r?(this.emit("active"),r(),e&&this.#g(),!0):!1}}return!1}#g(){this.#o||this.#r!==void 0||(this.#r=setInterval(()=>{this.#_()},this.#a),this.#p=Date.now()+this.#a)}#_(){this.#n===0&&this.#s===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#n=this.#e?this.#s:0,this.#f()}#f(){for(;this.#u(););}get concurrency(){return this.#c}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#c=e,this.#f()}async#v(e){return new Promise((r,s)=>{e.addEventListener("abort",()=>{s(e.reason)},{once:!0})})}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((s,i)=>{this.#t.enqueue(async()=>{this.#s++,this.#n++;try{r.signal?.throwIfAborted();let n=e({signal:r.signal});r.timeout&&(n=yt(Promise.resolve(n),{milliseconds:r.timeout})),r.signal&&(n=Promise.race([n,this.#v(r.signal)]));let o=await n;s(o),this.emit("completed",o)}catch(n){if(n instanceof ke&&!r.throwOnTimeout){s();return}i(n),this.emit("error",n)}finally{this.#E()}},r),this.emit("add"),this.#u()})}async addAll(e,r){return Promise.all(e.map(async s=>this.add(s,r)))}start(){return this.#i?(this.#i=!1,this.#f(),this):this}pause(){this.#i=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#h("next",()=>this.#t.size<e)}async onIdle(){this.#s===0&&this.#t.size===0||await this.#h("idle")}async#h(e,r){return new Promise(s=>{let i=()=>{r&&!r()||(this.off(e,i),s())};this.on(e,i)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#s}get isPaused(){return this.#i}};m();var Fi=oe(dr(),1),ji=oe(kt(),1),zi=oe(Pt(),1),ps=oe(Dt(),1),Qi=oe(ds(),1);var ms=ps.default;var it=class{status=0;ctx;endpoint;_graphqlWsClient;constructor(e,r){this.ctx=e.child({name:"client"}),Se(e.app,"app must be set on Client context"),Se(e.env,"env must be set on Client context"),this.endpoint=r,this._graphqlWsClient=nr({url:`wss://${e.app.slug}.${me.domains.app}/edit/api/graphql-ws`,shouldRetry:()=>!0,connectionParams:{environment:e.env.name},webSocketImpl:class extends ms{constructor(s,i,n){let o=ae();Se(o,"missing headers when connecting to GraphQL API"),super(s,i,{signal:e.signal,...n,headers:{...n?.headers,"user-agent":me.versionFull,...o}})}},on:{connecting:()=>{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}},connected:()=>{this.status===2?this.ctx.log.info("reconnected"):this.ctx.log.debug("connected"),setImmediate(()=>this.status=0)},closed:()=>{this.status=1,this.ctx.log.debug("disconnected")},error:s=>{this.status===2?this.ctx.log.error("failed to reconnect",{error:s}):this.ctx.log.error("connection error",{error:s})}}})}subscribe(e,{subscription:r,variables:s,onResponse:i,onError:n,onComplete:o=Ht}){let c={query:r,variables:K(s)},l=this._graphqlWsClient.on("connected",()=>{this.status===2&&(c={query:r,variables:K(s)},e.log.info("re-subscribing to graphql subscription"))}),u=new Le({concurrency:1}),d=f=>n(new W(r,f)),h=this._graphqlWsClient.subscribe(c,{next:f=>u.add(()=>i(f)).catch(d),error:f=>u.add(()=>d(f)),complete:()=>u.add(()=>o()).catch(d)});return()=>{l(),h()}}async execute(e,r){Se(e.app,"missing app when executing GraphQL query"),Se(e.env,"missing env when executing GraphQL query");let s=ae();Se(s,"missing headers when executing GraphQL request");let i=e.app.slug;e.app.multiEnvironmentEnabled?i+=`--${e.env.name}`:e.app.hasSplitEnvironments&&(i+="--development");try{let n=await We({context:{ctx:e},method:"POST",url:`https://${i}.${me.domains.app}${this.endpoint}`,headers:{...s,"x-gadget-environment":e.env.name},json:{query:r.operation,variables:K(r.variables)},responseType:"json",resolveBodyOnly:!0,throwHttpErrors:!1,...r.http});if(!Vt(n)||!("data"in n)&&!("errors"in n))throw e.log.error("received invalid graphql response",{error:n}),n;return n}catch(n){throw new W(r.operation,n)}}async dispose(){await this._graphqlWsClient.dispose()}};var qe=class{ctx;#e;constructor(e){this.ctx=e.child({name:"api"}),this.#e=new it(this.ctx,"/api/graphql")}async query({query:e,variables:r,...s}){let i=e.match(/query (\w+)/)?.[1];qt(i,"query name not found");let n=this.ctx.child({fields:{edit:{query:i}},devFields:{edit:{query:i,variables:K(r)}}});n.log.info("executing graphql query");let o=await this.#e.execute(n,{operation:e,variables:r,...s,http:{retry:{methods:["POST"]},...s.http}});if(o.errors)throw new W(e,o.errors);if(!o.data)throw new W(e,"Query response did not contain data");return o.data}async mutate({mutation:e,variables:r,...s}){let i=e.match(/mutation (\w+)/)?.[1];qt(i,"mutation name not found");let n=this.ctx.child({fields:{edit:{mutation:i}},devFields:{edit:{mutation:i,variables:K(r)}}});n.log.info("executing graphql mutation");let o=await this.#e.execute(n,{operation:e,variables:r,...s});if(o.errors)throw new W(e,o.errors);if(!o.data)throw new W(e,"Mutation response did not contain data");return o.data}subscribe({onData:e,...r}){let s=r.subscription.match(/subscription (\w+)/)?.[1];qt(s,"subscription name not found");let i=this.ctx.child({fields:{edit:{subscription:s}},devFields:{edit:{subscription:s,variables:K(r.variables)}}}),n=async c=>{if(c.errors){o(),await r.onError(new W(r.subscription,c.errors));return}if(!c.data){o(),await r.onError(new W(r.subscription,"Subscription response did not contain data"));return}await e(c.data)};i.log.info("subscribing to graphql subscription");let o=this.#e.subscribe(i,{...r,onResponse:n});return{unsubscribe:o,resubscribe:c=>{o(),c!==void 0&&(r.variables=c),i=this.ctx.child({fields:{edit:{subscription:s}},devFields:{edit:{subscription:s,variables:K(r.variables)}}}),i.log.info("re-subscribing to graphql subscription"),o=this.#e.subscribe(i,{...r,onResponse:n})}}}async dispose(){await this.#e.dispose()}};m();var ys=Ce(`
|
|
15
|
-
query GadgetMetaModels {
|
|
16
|
-
gadgetMeta {
|
|
17
|
-
models {
|
|
18
|
-
apiIdentifier
|
|
19
|
-
namespace
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`),gs=Ce(`
|
|
24
|
-
query GadgetMetaGlobalActions {
|
|
25
|
-
gadgetMeta {
|
|
26
|
-
globalActions {
|
|
27
|
-
apiIdentifier
|
|
28
|
-
namespace
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`);var Vi=Object.freeze({Development:"development",Production:"production",Test:"test"}),Hi=E.object({id:E.union([E.string(),E.number(),E.bigint()]).transform(t=>BigInt(t)),name:E.string().transform(t=>t.toLowerCase()),type:E.nativeEnum(Vi)}),Yi=E.object({id:E.union([E.string(),E.number(),E.bigint()]).transform(t=>BigInt(t)),slug:E.string(),primaryDomain:E.string(),hasSplitEnvironments:E.boolean(),multiEnvironmentEnabled:E.boolean(),environments:E.array(Hi)}),Wo=E.object({apiIdentifier:E.string(),namespace:E.nullable(E.array(E.string())).optional()}),Fo=E.object({apiIdentifier:E.string(),namespace:E.nullable(E.array(E.string())).optional()}),jo=async t=>{let e=ae();if(!e)return[];Ut(t.user,"must get user before getting apps");let r=await We({context:{ctx:t},url:`https://${me.domains.services}/auth/api/apps`,headers:{...e},responseType:"json",resolveBodyOnly:!0});return E.array(Yi).parse(r)},zo=async t=>{if(!ae())return[];Ut(t.user,"must get user before getting models");let r=new qe(t),{gadgetMeta:s}=await r.query({query:ys});return s.models},Qo=async t=>{if(!ae())return[];Ut(t.user,"must get user before getting models");let r=new qe(t),{gadgetMeta:s}=await r.query({query:gs});return s.globalActions};export{Jt as a,W as b,Le as c,it as d,Vi as e,jo as f,zo as g,Qo as h};
|
|
33
|
-
//# sourceMappingURL=chunk-G3VNV5Z6.js.map
|