UNPKG

dev3-sdk

Version:

SDK for interacting with the 0xDev3 platform.

46 lines (41 loc) 524 kB
'use strict'; var polycodeChainlinkFeeds = require('polycode-chainlink-feeds'); var dkg_js = require('dkg.js'); var Wf = require('axios'); var $A = require('http'); var qA = require('https'); var zlib = require('zlib'); var i1 = require('crypto'); var net = require('net'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var dkg_js__default = /*#__PURE__*/_interopDefault(dkg_js); var Wf__default = /*#__PURE__*/_interopDefault(Wf); var $A__default = /*#__PURE__*/_interopDefault($A); var qA__default = /*#__PURE__*/_interopDefault(qA); var i1__namespace = /*#__PURE__*/_interopNamespace(i1); var IA=Object.create;var ru=Object.defineProperty,BA=Object.defineProperties,PA=Object.getOwnPropertyDescriptor,OA=Object.getOwnPropertyDescriptors,FA=Object.getOwnPropertyNames,cp=Object.getOwnPropertySymbols,lp=Object.getPrototypeOf,up=Object.prototype.hasOwnProperty,kA=Object.prototype.propertyIsEnumerable,UA=Reflect.get;var jf=(n,e,t)=>e in n?ru(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Oe=(n,e)=>{for(var t in e||(e={}))up.call(e,t)&&jf(n,t,e[t]);if(cp)for(var t of cp(e))kA.call(e,t)&&jf(n,t,e[t]);return n},bt=(n,e)=>BA(n,OA(e));var ue=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+n+'" is not supported')});var MA=(n,e)=>()=>(n&&(e=n(n=0)),e);var Le=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),DA=(n,e)=>{for(var t in e)ru(n,t,{get:e[t],enumerable:!0});},JA=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of FA(e))!up.call(n,s)&&s!==t&&ru(n,s,{get:()=>e[s],enumerable:!(r=PA(e,s))||r.enumerable});return n};var gc=(n,e,t)=>(t=n!=null?IA(lp(n)):{},JA(e||!n||!n.__esModule?ru(t,"default",{value:n,enumerable:!0}):t,n));var b=(n,e,t)=>(jf(n,typeof e!="symbol"?e+"":e,t),t),Yf=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>(Yf(n,e,"read from private field"),t?t.call(n):e.get(n)),A=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t);},g=(n,e,t,r)=>(Yf(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),nn=(n,e,t,r)=>({set _(s){g(n,e,s,t);},get _(){return u(n,e,r)}}),C=(n,e,t)=>(Yf(n,e,"access private method"),t),Ne=(n,e,t)=>UA(lp(n),t,e);var f=(n,e,t)=>new Promise((r,s)=>{var i=c=>{try{a(t.next(c));}catch(l){s(l);}},o=c=>{try{a(t.throw(c));}catch(l){s(l);}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);a((t=t.apply(n,e)).next());});var h=MA(()=>{});var Mx=Le((JI,Ux)=>{h();var{Duplex:N2}=ue("stream");function Fx(n){n.emit("close");}function I2(){!this.destroyed&&this._writableState.finished&&this.destroy();}function kx(n){this.removeListener("error",kx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n);}function B2(n,e){let t=!0,r=new N2(bt(Oe({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return n.on("message",function(i,o){let a=!o&&r._readableState.objectMode?i.toString():i;r.push(a)||n.pause();}),n.once("error",function(i){r.destroyed||(t=!1,r.destroy(i));}),n.once("close",function(){r.destroyed||r.push(null);}),r._destroy=function(s,i){if(n.readyState===n.CLOSED){i(s),process.nextTick(Fx,r);return}let o=!1;n.once("error",function(c){o=!0,i(c);}),n.once("close",function(){o||i(s),process.nextTick(Fx,r);}),t&&n.terminate();},r._final=function(s){if(n.readyState===n.CONNECTING){n.once("open",function(){r._final(s);});return}n._socket!==null&&(n._socket._writableState.finished?(s(),r._readableState.endEmitted&&r.destroy()):(n._socket.once("finish",function(){s();}),n.close()));},r._read=function(){n.isPaused&&n.resume();},r._write=function(s,i,o){if(n.readyState===n.CONNECTING){n.once("open",function(){r._write(s,i,o);});return}n.send(s,o);},r.on("end",I2),r.on("error",kx),r}Ux.exports=B2;});var Is=Le((XI,Dx)=>{h();Dx.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}};});var eb=Le((VI,Wx)=>{h();var Xx=ue("fs"),Dn=ue("path"),Hx=ue("os"),Vx=typeof __webpack_require__=="function"?__non_webpack_require__:ue,P2=process.config&&process.config.variables||{},O2=!!process.env.PREBUILDS_ONLY,Jx=process.versions.modules,D0=U2()?"electron":k2()?"node-webkit":"node",J0=process.env.npm_config_arch||Hx.arch(),_0=process.env.npm_config_platform||Hx.platform(),zx=process.env.LIBC||(M2(_0)?"musl":"glibc"),G0=process.env.ARM_VERSION||(J0==="arm64"?"8":P2.arm_version)||"",Zx=(process.versions.uv||"").split(".")[0];Wx.exports=zr;function zr(n){return Vx(zr.resolve(n))}zr.resolve=zr.path=function(n){n=Dn.resolve(n||".");try{var e=Vx(Dn.join(n,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[e+"_PREBUILD"]&&(n=process.env[e+"_PREBUILD"]);}catch(c){}if(!O2){var t=_x(Dn.join(n,"build/Release"),Gx);if(t)return t;var r=_x(Dn.join(n,"build/Debug"),Gx);if(r)return r}var s=a(n);if(s)return s;var i=a(Dn.dirname(process.execPath));if(i)return i;var o=["platform="+_0,"arch="+J0,"runtime="+D0,"abi="+Jx,"uv="+Zx,G0?"armv="+G0:"","libc="+zx,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+o+` loaded from: `+n+` `);function a(c){var l=X0(Dn.join(c,"prebuilds")).map(Qx),d=l.filter($x(_0,J0)).sort(qx)[0];if(d){var p=Dn.join(c,"prebuilds",d.name),x=X0(p).map(Kx),y=x.filter(jx(D0,Jx)),R=y.sort(Yx(D0))[0];if(R)return Dn.join(p,R.file)}}};function X0(n){try{return Xx.readdirSync(n)}catch(e){return []}}function _x(n,e){var t=X0(n).filter(e);return t[0]&&Dn.join(n,t[0])}function Gx(n){return /\.node$/.test(n)}function Qx(n){var e=n.split("-");if(e.length===2){var t=e[0],r=e[1].split("+");if(t&&r.length&&r.every(Boolean))return {name:n,platform:t,architectures:r}}}function $x(n,e){return function(t){return t==null||t.platform!==n?!1:t.architectures.includes(e)}}function qx(n,e){return n.architectures.length-e.architectures.length}function Kx(n){var e=n.split("."),t=e.pop(),r={file:n,specificity:0};if(t==="node"){for(var s=0;s<e.length;s++){var i=e[s];if(i==="node"||i==="electron"||i==="node-webkit")r.runtime=i;else if(i==="napi")r.napi=!0;else if(i.slice(0,3)==="abi")r.abi=i.slice(3);else if(i.slice(0,2)==="uv")r.uv=i.slice(2);else if(i.slice(0,4)==="armv")r.armv=i.slice(4);else if(i==="glibc"||i==="musl")r.libc=i;else continue;r.specificity++;}return r}}function jx(n,e){return function(t){return !(t==null||t.runtime!==n&&!F2(t)||t.abi!==e&&!t.napi||t.uv&&t.uv!==Zx||t.armv&&t.armv!==G0||t.libc&&t.libc!==zx)}}function F2(n){return n.runtime==="node"&&n.napi}function Yx(n){return function(e,t){return e.runtime!==t.runtime?e.runtime===n?-1:1:e.abi!==t.abi?e.abi?-1:1:e.specificity!==t.specificity?e.specificity>t.specificity?-1:1:0}}function k2(){return !!(process.versions&&process.versions.nw)}function U2(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window!="undefined"&&window.process&&window.process.type==="renderer"}function M2(n){return n==="linux"&&Xx.existsSync("/etc/alpine-release")}zr.parseTags=Kx;zr.matchTags=jx;zr.compareTags=Yx;zr.parseTuple=Qx;zr.matchTuple=$x;zr.compareTuples=qx;});var V0=Le((QI,H0)=>{h();typeof process.addon=="function"?H0.exports=process.addon.bind(process):H0.exports=eb();});var rb=Le((qI,tb)=>{h();var D2=(n,e,t,r,s)=>{for(var i=0;i<s;i++)t[r+i]=n[i]^e[i&3];},J2=(n,e)=>{let t=n.length;for(var r=0;r<t;r++)n[r]^=e[r&3];};tb.exports={mask:D2,unmask:J2};});var nb=Le((jI,z0)=>{h();try{z0.exports=V0()(__dirname);}catch(n){z0.exports=rb();}});var Rl=Le((WI,Z0)=>{h();var{EMPTY_BUFFER:_2}=Is();function sb(n,e){if(n.length===0)return _2;if(n.length===1)return n[0];let t=Buffer.allocUnsafe(e),r=0;for(let s=0;s<n.length;s++){let i=n[s];t.set(i,r),r+=i.length;}return r<e?t.slice(0,r):t}function ib(n,e,t,r,s){for(let i=0;i<s;i++)t[r+i]=n[i]^e[i&3];}function ob(n,e){for(let t=0;t<n.length;t++)n[t]^=e[t&3];}function ab(n){return n.byteLength===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}function Ef(n){if(Ef.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=Buffer.from(n):ArrayBuffer.isView(n)?e=Buffer.from(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Ef.readOnly=!1),e}try{let n=nb();Z0.exports={concat:sb,mask(e,t,r,s,i){i<48?ib(e,t,r,s,i):n.mask(e,t,r,s,i);},toArrayBuffer:ab,toBuffer:Ef,unmask(e,t){e.length<32?ob(e,t):n.unmask(e,t);}};}catch(n){Z0.exports={concat:sb,mask:ib,toArrayBuffer:ab,toBuffer:Ef,unmask:ob};}});var ub=Le((t5,lb)=>{h();var cb=Symbol("kDone"),Q0=Symbol("kRun"),$0=class{constructor(e){this[cb]=()=>{this.pending--,this[Q0]();},this.concurrency=e||1/0,this.jobs=[],this.pending=0;}add(e){this.jobs.push(e),this[Q0]();}[Q0](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[cb]);}}};lb.exports=$0;});var Sl=Le((n5,pb)=>{h();var El=ue("zlib"),fb=Rl(),G2=ub(),{kStatusCode:db}=Is(),X2=Buffer.from([0,0,255,255]),vf=Symbol("permessage-deflate"),Jn=Symbol("total-length"),Cl=Symbol("callback"),Bs=Symbol("buffers"),Sf=Symbol("error"),Cf,q0=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Cf){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Cf=new G2(s);}}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[Cl];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"));}}acceptAsServer(e){let t=this._options,r=e.find(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let s=t[r];if(s.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(s=s[0],r==="client_max_window_bits"){if(s!==!0){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=i;}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else if(r==="server_max_window_bits"){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=i;}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=s;});}),e}decompress(e,t,r){Cf.add(s=>{this._decompress(e,t,(i,o)=>{s(),r(i,o);});});}compress(e,t,r){Cf.add(s=>{this._compress(e,t,(i,o)=>{s(),r(i,o);});});}_decompress(e,t,r){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?El.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=El.createInflateRaw(bt(Oe({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[vf]=this,this._inflate[Jn]=0,this._inflate[Bs]=[],this._inflate.on("error",V2),this._inflate.on("data",hb);}this._inflate[Cl]=r,this._inflate.write(e),t&&this._inflate.write(X2),this._inflate.flush(()=>{let i=this._inflate[Sf];if(i){this._inflate.close(),this._inflate=null,r(i);return}let o=fb.concat(this._inflate[Bs],this._inflate[Jn]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Jn]=0,this._inflate[Bs]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),r(null,o);});}_compress(e,t,r){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?El.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=El.createDeflateRaw(bt(Oe({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Jn]=0,this._deflate[Bs]=[],this._deflate.on("data",H2);}this._deflate[Cl]=r,this._deflate.write(e),this._deflate.flush(El.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=fb.concat(this._deflate[Bs],this._deflate[Jn]);t&&(i=i.slice(0,i.length-4)),this._deflate[Cl]=null,this._deflate[Jn]=0,this._deflate[Bs]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),r(null,i);});}};pb.exports=q0;function H2(n){this[Bs].push(n),this[Jn]+=n.length;}function hb(n){if(this[Jn]+=n.length,this[vf]._maxPayload<1||this[Jn]<=this[vf]._maxPayload){this[Bs].push(n);return}this[Sf]=new RangeError("Max payload size exceeded"),this[Sf].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Sf][db]=1009,this.removeListener("data",hb),this.reset();}function V2(n){this[vf]._inflate=null,n[db]=1007,this[Cl](n);}});var mb=Le((o5,gb)=>{h();function z2(n){let e=n.length,t=0;for(;t<e;)if(!(n[t]&128))t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return !1;t+=2;}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return !1;t+=3;}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return !1;t+=4;}else return !1;return !0}gb.exports=z2;});var xb=Le((c5,K0)=>{h();try{K0.exports=V0()(__dirname);}catch(n){K0.exports=mb();}});var vl=Le((u5,j0)=>{h();var bb=[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 Ab(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function yb(n){let e=n.length,t=0;for(;t<e;)if(!(n[t]&128))t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return !1;t+=2;}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return !1;t+=3;}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return !1;t+=4;}else return !1;return !0}try{let n=xb();j0.exports={isValidStatusCode:Ab,isValidUTF8(e){return e.length<150?yb(e):n(e)},tokenChars:bb};}catch(n){j0.exports={isValidStatusCode:Ab,isValidUTF8:yb,tokenChars:bb};}});var th=Le((d5,vb)=>{h();var{Writable:Z2}=ue("stream"),wb=Sl(),{BINARY_TYPES:Q2,EMPTY_BUFFER:Tb,kStatusCode:$2,kWebSocket:q2}=Is(),{concat:Y0,toArrayBuffer:K2,unmask:j2}=Rl(),{isValidStatusCode:Y2,isValidUTF8:Rb}=vl(),Ll=0,Eb=1,Cb=2,Sb=3,W0=4,W2=5,eh=class extends Z2{constructor(e={}){super(),this._binaryType=e.binaryType||Q2[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[q2]=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._state=Ll,this._loop=!1;}_write(e,t,r){if(this._opcode===8&&this._state==Ll)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r);}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=r.slice(e),r.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],s=t.length-e;e>=r.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),s),this._buffers[0]=r.slice(e)),e-=r.length;}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case Ll:t=this.getInfo();break;case Eb:t=this.getPayloadLength16();break;case Cb:t=this.getPayloadLength64();break;case Sb:this.getMask();break;case W0:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t);}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,Pe(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[wb.extensionName])return this._loop=!1,Pe(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,Pe(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,Pe(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented;}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,Pe(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t;}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,Pe(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,Pe(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,Pe(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,Pe(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,Pe(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,Pe(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Eb;else if(this._payloadLength===127)this._state=Cb;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,53-32)-1?(this._loop=!1,Pe(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,Pe(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Sb:this._state=W0;}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=W0;}getData(e){let t=Tb;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&j2(t,this._mask);}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=W2,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[wb.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return t(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(Pe(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(i);}let o=this.dataMessage();if(o)return t(o);this.startLoop(t);});}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=Y0(t,e):this._binaryType==="arraybuffer"?r=K2(Y0(t,e)):r=t,this.emit("message",r,!0);}else {let r=Y0(t,e);if(!this._skipUTF8Validation&&!Rb(r))return this._loop=!1,Pe(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1);}}this._state=Ll;}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Tb),this.end();else {if(e.length===1)return Pe(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Y2(t))return Pe(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Rb(r))return Pe(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r),this.end();}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=Ll;}};vb.exports=eh;function Pe(n,e,t,r,s){let i=new n(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(i,Pe),i.code=s,i[$2]=r,i}});var rh=Le((m5,Ib)=>{h();ue("net");ue("tls");var {randomFillSync:e8}=ue("crypto"),Lb=Sl(),{EMPTY_BUFFER:t8}=Is(),{isValidStatusCode:r8}=vl(),{mask:Nb,toBuffer:Da}=Rl(),Lr=Symbol("kByteLength"),n8=Buffer.alloc(4),Zr=class{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[];}static frame(e,t){let r,s=!1,i=2,o=!1;t.mask&&(r=t.maskBuffer||n8,t.generateMask?t.generateMask(r):e8(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,i=6);let a;typeof e=="string"?(!t.mask||o)&&t[Lr]!==void 0?a=t[Lr]:(e=Buffer.from(e),a=e.length):(a=e.length,s=t.mask&&t.readOnly&&!o);let c=a;a>=65536?(i+=8,c=127):a>125&&(i+=2,c=126);let l=Buffer.allocUnsafe(s?a+i:i);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(a,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(a,4,6)),t.mask?(l[1]|=128,l[i-4]=r[0],l[i-3]=r[1],l[i-2]=r[2],l[i-1]=r[3],o?[l,e]:s?(Nb(e,r,l,i,a),[l]):(Nb(e,r,e,0,a),[l,e])):[l,e]}close(e,t,r,s){let i;if(e===void 0)i=t8;else {if(typeof e!="number"||!r8(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else {let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+a),i.writeUInt16BE(e,0),typeof t=="string"?i.write(t,2):i.set(t,2);}}let o={[Lr]:i.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,i,!1,o,s]):this.sendFrame(Zr.frame(i,o),s);}ping(e,t,r){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):(e=Da(e),s=e.length,i=Da.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[Lr]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(Zr.frame(e,o),r);}pong(e,t,r){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):(e=Da(e),s=e.length,i=Da.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[Lr]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(Zr.frame(e,o),r);}send(e,t,r){let s=this._extensions[Lb.extensionName],i=t.binary?2:1,o=t.compress,a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):(e=Da(e),a=e.length,c=Da.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,i=0),t.fin&&(this._firstFragment=!0),s){let l={[Lr]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,l,r]):this.dispatch(e,this._compress,l,r);}else this.sendFrame(Zr.frame(e,{[Lr]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:!1}),r);}dispatch(e,t,r,s){if(!t){this.sendFrame(Zr.frame(e,r),s);return}let i=this._extensions[Lb.extensionName];this._bufferedBytes+=r[Lr],this._deflating=!0,i.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof s=="function"&&s(c);for(let l=0;l<this._queue.length;l++){let d=this._queue[l],p=d[d.length-1];typeof p=="function"&&p(c);}return}this._bufferedBytes-=r[Lr],this._deflating=!1,r.readOnly=!1,this.sendFrame(Zr.frame(a,r),s),this.dequeue();});}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Lr],Reflect.apply(e[0],this,e.slice(1));}}enqueue(e){this._bufferedBytes+=e[3][Lr],this._queue.push(e);}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t);}};Ib.exports=Zr;});var _b=Le((b5,Jb)=>{h();var{kForOnEventAttribute:nh,kListener:Bb}=Is(),Pb=Symbol("kCode"),Ob=Symbol("kData"),Fb=Symbol("kError"),kb=Symbol("kMessage"),Ub=Symbol("kReason"),Ja=Symbol("kTarget"),Mb=Symbol("kType"),Db=Symbol("kWasClean"),_n=class{constructor(e){this[Ja]=null,this[Mb]=e;}get target(){return this[Ja]}get type(){return this[Mb]}};Object.defineProperty(_n.prototype,"target",{enumerable:!0});Object.defineProperty(_n.prototype,"type",{enumerable:!0});var Qi=class extends _n{constructor(e,t={}){super(e),this[Pb]=t.code===void 0?0:t.code,this[Ub]=t.reason===void 0?"":t.reason,this[Db]=t.wasClean===void 0?!1:t.wasClean;}get code(){return this[Pb]}get reason(){return this[Ub]}get wasClean(){return this[Db]}};Object.defineProperty(Qi.prototype,"code",{enumerable:!0});Object.defineProperty(Qi.prototype,"reason",{enumerable:!0});Object.defineProperty(Qi.prototype,"wasClean",{enumerable:!0});var _a=class extends _n{constructor(e,t={}){super(e),this[Fb]=t.error===void 0?null:t.error,this[kb]=t.message===void 0?"":t.message;}get error(){return this[Fb]}get message(){return this[kb]}};Object.defineProperty(_a.prototype,"error",{enumerable:!0});Object.defineProperty(_a.prototype,"message",{enumerable:!0});var Nl=class extends _n{constructor(e,t={}){super(e),this[Ob]=t.data===void 0?null:t.data;}get data(){return this[Ob]}};Object.defineProperty(Nl.prototype,"data",{enumerable:!0});var s8={addEventListener(n,e,t={}){let r;if(n==="message")r=function(i,o){let a=new Nl("message",{data:o?i:i.toString()});a[Ja]=this,e.call(this,a);};else if(n==="close")r=function(i,o){let a=new Qi("close",{code:i,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Ja]=this,e.call(this,a);};else if(n==="error")r=function(i){let o=new _a("error",{error:i,message:i.message});o[Ja]=this,e.call(this,o);};else if(n==="open")r=function(){let i=new _n("open");i[Ja]=this,e.call(this,i);};else return;r[nh]=!!t[nh],r[Bb]=e,t.once?this.once(n,r):this.on(n,r);},removeEventListener(n,e){for(let t of this.listeners(n))if(t[Bb]===e&&!t[nh]){this.removeListener(n,t);break}}};Jb.exports={CloseEvent:Qi,ErrorEvent:_a,Event:_n,EventTarget:s8,MessageEvent:Nl};});var sh=Le((y5,Gb)=>{h();var{tokenChars:Il}=vl();function Qr(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t);}function i8(n){let e=Object.create(null),t=Object.create(null),r=!1,s=!1,i=!1,o,a,c=-1,l=-1,d=-1,p=0;for(;p<n.length;p++)if(l=n.charCodeAt(p),o===void 0)if(d===-1&&Il[l]===1)c===-1&&(c=p);else if(p!==0&&(l===32||l===9))d===-1&&c!==-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let y=n.slice(c,d);l===44?(Qr(e,y,t),t=Object.create(null)):o=y,c=d=-1;}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(d===-1&&Il[l]===1)c===-1&&(c=p);else if(l===32||l===9)d===-1&&c!==-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p),Qr(t,n.slice(c,d),!0),l===44&&(Qr(e,o,t),t=Object.create(null),o=void 0),c=d=-1;}else if(l===61&&c!==-1&&d===-1)a=n.slice(c,p),c=d=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(s){if(Il[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:r||(r=!0),s=!1;}else if(i)if(Il[l]===1)c===-1&&(c=p);else if(l===34&&c!==-1)i=!1,d=p;else if(l===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&n.charCodeAt(p-1)===61)i=!0;else if(d===-1&&Il[l]===1)c===-1&&(c=p);else if(c!==-1&&(l===32||l===9))d===-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let y=n.slice(c,d);r&&(y=y.replace(/\\/g,""),r=!1),Qr(t,a,y),l===44&&(Qr(e,o,t),t=Object.create(null),o=void 0),a=void 0,c=d=-1;}else throw new SyntaxError(`Unexpected character at index ${p}`);if(c===-1||i||l===32||l===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=p);let x=n.slice(c,d);return o===void 0?Qr(e,x,t):(a===void 0?Qr(t,x,!0):r?Qr(t,a,x.replace(/\\/g,"")):Qr(t,a,x),Qr(e,o,t)),e}function o8(n){return Object.keys(n).map(e=>{let t=n[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(s=>{let i=r[s];return Array.isArray(i)||(i=[i]),i.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Gb.exports={format:o8,parse:i8};});var uh=Le((R5,jb)=>{h();var a8=ue("events"),c8=ue("https"),l8=ue("http"),Vb=ue("net"),u8=ue("tls"),{randomBytes:f8,createHash:d8}=ue("crypto");ue("stream");var {URL:ih}=ue("url"),Ps=Sl(),h8=th(),p8=rh(),{BINARY_TYPES:Xb,EMPTY_BUFFER:Lf,GUID:g8,kForOnEventAttribute:oh,kListener:m8,kStatusCode:x8,kWebSocket:We,NOOP:zb}=Is(),{EventTarget:{addEventListener:b8,removeEventListener:A8}}=_b(),{format:y8,parse:w8}=sh(),{toBuffer:T8}=Rl(),Gn=["CONNECTING","OPEN","CLOSING","CLOSED"],R8=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ah=[8,13],E8=30*1e3,G=class extends a8{constructor(e,t,r){super(),this._binaryType=Xb[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Lf,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=G.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),Zb(this,e,t,r)):this._isServer=!0;}get binaryType(){return this._binaryType}set binaryType(e){Xb.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,t,r){let s=new h8({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new p8(e,this._extensions,r.generateMask),this._receiver=s,this._socket=e,s[We]=this,e[We]=this,s.on("conclude",v8),s.on("drain",L8),s.on("error",N8),s.on("message",I8),s.on("ping",B8),s.on("pong",P8),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",$b),e.on("data",Nf),e.on("end",qb),e.on("error",Kb),this._readyState=G.OPEN,this.emit("open");}emitClose(){if(!this._socket){this._readyState=G.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ps.extensionName]&&this._extensions[Ps.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=G.CLOSED,this.emit("close",this._closeCode,this._closeMessage);}close(e,t){if(this.readyState!==G.CLOSED){if(this.readyState===G.CONNECTING){let r="WebSocket was closed before the connection was established";return Yt(this,this._req,r)}if(this.readyState===G.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=G.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end());}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),E8);}}pause(){this.readyState===G.CONNECTING||this.readyState===G.CLOSED||(this._paused=!0,this._socket.pause());}ping(e,t,r){if(this.readyState===G.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==G.OPEN){lh(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Lf,t,r);}pong(e,t,r){if(this.readyState===G.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==G.OPEN){lh(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Lf,t,r);}resume(){this.readyState===G.CONNECTING||this.readyState===G.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume());}send(e,t,r){if(this.readyState===G.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==G.OPEN){lh(this,e,r);return}let s=Oe({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Ps.extensionName]||(s.compress=!1),this._sender.send(e||Lf,s,r);}terminate(){if(this.readyState!==G.CLOSED){if(this.readyState===G.CONNECTING){let e="WebSocket was closed before the connection was established";return Yt(this,this._req,e)}this._socket&&(this._readyState=G.CLOSING,this._socket.destroy());}}};Object.defineProperty(G,"CONNECTING",{enumerable:!0,value:Gn.indexOf("CONNECTING")});Object.defineProperty(G.prototype,"CONNECTING",{enumerable:!0,value:Gn.indexOf("CONNECTING")});Object.defineProperty(G,"OPEN",{enumerable:!0,value:Gn.indexOf("OPEN")});Object.defineProperty(G.prototype,"OPEN",{enumerable:!0,value:Gn.indexOf("OPEN")});Object.defineProperty(G,"CLOSING",{enumerable:!0,value:Gn.indexOf("CLOSING")});Object.defineProperty(G.prototype,"CLOSING",{enumerable:!0,value:Gn.indexOf("CLOSING")});Object.defineProperty(G,"CLOSED",{enumerable:!0,value:Gn.indexOf("CLOSED")});Object.defineProperty(G.prototype,"CLOSED",{enumerable:!0,value:Gn.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(G.prototype,n,{enumerable:!0});});["open","error","close","message"].forEach(n=>{Object.defineProperty(G.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[oh])return e[m8];return null},set(e){for(let t of this.listeners(n))if(t[oh]){this.removeListener(n,t);break}typeof e=="function"&&this.addEventListener(n,e,{[oh]:!0});}});});G.prototype.addEventListener=b8;G.prototype.removeEventListener=A8;jb.exports=G;function Zb(n,e,t,r){let s=bt(Oe({protocolVersion:ah[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0});if(!ah.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${ah.join(", ")})`);let i;if(e instanceof ih)i=e,n._url=e.href;else {try{i=new ih(e);}catch(E){throw new SyntaxError(`Invalid URL: ${e}`)}n._url=e;}let o=i.protocol==="wss:",a=i.protocol==="ws+unix:",c;if(i.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!i.pathname?c="The URL's pathname is empty":i.hash&&(c="The URL contains a fragment identifier"),c){let E=new SyntaxError(c);if(n._redirects===0)throw E;ch(n,E);return}let l=o?443:80,d=f8(16).toString("base64"),p=o?c8.get:l8.get,x=new Set,y;if(s.createConnection=o?S8:C8,s.defaultPort=s.defaultPort||l,s.port=i.port||l,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers=Oe({"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},s.headers),s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(y=new Ps(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=y8({[Ps.extensionName]:y.offer()})),t.length){for(let E of t){if(typeof E!="string"||!R8.test(E)||x.has(E))throw new SyntaxError("An invalid or duplicated subprotocol was specified");x.add(E);}s.headers["Sec-WebSocket-Protocol"]=t.join(",");}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(i.username||i.password)&&(s.auth=`${i.username}:${i.password}`),a){let E=s.path.split(":");s.socketPath=E[0],s.path=E[1];}if(s.followRedirects){if(n._redirects===0){n._originalHost=i.host;let E=r&&r.headers;if(r=bt(Oe({},r),{headers:{}}),E)for(let[N,I]of Object.entries(E))r.headers[N.toLowerCase()]=I;}else i.host!==n._originalHost&&(delete s.headers.authorization,delete s.headers.cookie,delete s.headers.host,s.auth=void 0);s.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64"));}let R=n._req=p(s);s.timeout&&R.on("timeout",()=>{Yt(n,R,"Opening handshake has timed out");}),R.on("error",E=>{R===null||R.aborted||(R=n._req=null,ch(n,E));}),R.on("response",E=>{let N=E.headers.location,I=E.statusCode;if(N&&s.followRedirects&&I>=300&&I<400){if(++n._redirects>s.maxRedirects){Yt(n,R,"Maximum redirects exceeded");return}R.abort();let J;try{J=new ih(N,e);}catch(X){let se=new SyntaxError(`Invalid URL: ${N}`);ch(n,se);return}Zb(n,J,t,r);}else n.emit("unexpected-response",R,E)||Yt(n,R,`Unexpected server response: ${E.statusCode}`);}),R.on("upgrade",(E,N,I)=>{if(n.emit("upgrade",E),n.readyState!==G.CONNECTING)return;R=n._req=null;let J=d8("sha1").update(d+g8).digest("base64");if(E.headers["sec-websocket-accept"]!==J){Yt(n,N,"Invalid Sec-WebSocket-Accept header");return}let X=E.headers["sec-websocket-protocol"],se;if(X!==void 0?x.size?x.has(X)||(se="Server sent an invalid subprotocol"):se="Server sent a subprotocol but none was requested":x.size&&(se="Server sent no subprotocol"),se){Yt(n,N,se);return}X&&(n._protocol=X);let D=E.headers["sec-websocket-extensions"];if(D!==void 0){if(!y){Yt(n,N,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let le;try{le=w8(D);}catch(we){Yt(n,N,"Invalid Sec-WebSocket-Extensions header");return}let ze=Object.keys(le);if(ze.length!==1||ze[0]!==Ps.extensionName){Yt(n,N,"Server indicated an extension that was not requested");return}try{y.accept(le[Ps.extensionName]);}catch(we){Yt(n,N,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[Ps.extensionName]=y;}n.setSocket(N,I,{generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});});}function ch(n,e){n._readyState=G.CLOSING,n.emit("error",e),n.emitClose();}function C8(n){return n.path=n.socketPath,Vb.connect(n)}function S8(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Vb.isIP(n.host)?"":n.host),u8.connect(n)}function Yt(n,e,t){n._readyState=G.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Yt),e.setHeader?(e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),e.once("abort",n.emitClose.bind(n)),n.emit("error",r)):(e.destroy(r),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)));}function lh(n,e,t){if(e){let r=T8(e).length;n._socket?n._sender._bufferedBytes+=r:n._bufferedAmount+=r;}if(t){let r=new Error(`WebSocket is not open: readyState ${n.readyState} (${Gn[n.readyState]})`);t(r);}}function v8(n,e){let t=this[We];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=n,t._socket[We]!==void 0&&(t._socket.removeListener("data",Nf),process.nextTick(Qb,t._socket),n===1005?t.close():t.close(n,e));}function L8(){let n=this[We];n.isPaused||n._socket.resume();}function N8(n){let e=this[We];e._socket[We]!==void 0&&(e._socket.removeListener("data",Nf),process.nextTick(Qb,e._socket),e.close(n[x8])),e.emit("error",n);}function Hb(){this[We].emitClose();}function I8(n,e){this[We].emit("message",n,e);}function B8(n){let e=this[We];e.pong(n,!e._isServer,zb),e.emit("ping",n);}function P8(n){this[We].emit("pong",n);}function Qb(n){n.resume();}function $b(){let n=this[We];this.removeListener("close",$b),this.removeListener("data",Nf),this.removeListener("end",qb),n._readyState=G.CLOSING;let e;!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&(e=n._socket.read())!==null&&n._receiver.write(e),n._receiver.end(),this[We]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Hb),n._receiver.on("finish",Hb));}function Nf(n){this[We]._receiver.write(n)||this.pause();}function qb(){let n=this[We];n._readyState=G.CLOSING,n._receiver.end(),this.end();}function Kb(){let n=this[We];this.removeListener("error",Kb),this.on("error",zb),n&&(n._readyState=G.CLOSING,this.destroy());}});var Wb=Le((S5,Yb)=>{h();var{tokenChars:O8}=vl();function F8(n){let e=new Set,t=-1,r=-1,s=0;for(s;s<n.length;s++){let o=n.charCodeAt(s);if(r===-1&&O8[o]===1)t===-1&&(t=s);else if(s!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=s);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);r===-1&&(r=s);let a=n.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1;}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let i=n.slice(t,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}Yb.exports={parse:F8};});var iA=Le((B5,sA)=>{h();var k8=ue("events"),If=ue("http");ue("https");ue("net");ue("tls");var {createHash:U8}=ue("crypto"),eA=sh(),$i=Sl(),M8=Wb(),D8=uh(),{GUID:J8,kWebSocket:_8}=Is(),G8=/^[+/0-9A-Za-z]{22}==$/,tA=0,rA=1,nA=2,fh=class extends k8{constructor(e,t){if(super(),e=Oe({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:D8},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=If.createServer((r,s)=>{let i=If.STATUS_CODES[426];s.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),s.end(i);}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=X8(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,i,o)=>{this.handleUpgrade(s,i,o,r);}});}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=tA;}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===nA){e&&this.once("close",()=>{e(new Error("The server is not running"));}),process.nextTick(Bl,this);return}if(e&&this.once("close",e),this._state!==rA)if(this._state=rA,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(Bl,this):process.nextTick(Bl,this);else {let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Bl(this);});}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return !1}return !0}handleUpgrade(e,t,r,s){t.on("error",dh);let i=e.headers["sec-websocket-key"]!==void 0?e.headers["sec-websocket-key"]:!1,o=+e.headers["sec-websocket-version"];if(e.method!=="GET"||e.headers.upgrade.toLowerCase()!=="websocket"||!i||!G8.test(i)||o!==8&&o!==13||!this.shouldHandle(e))return Ga(t,400);let a=e.headers["sec-websocket-protocol"],c=new Set;if(a!==void 0)try{c=M8.parse(a);}catch(p){return Ga(t,400)}let l=e.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&l!==void 0){let p=new $i(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let x=eA.parse(l);x[$i.extensionName]&&(p.accept(x[$i.extensionName]),d[$i.extensionName]=p);}catch(x){return Ga(t,400)}}if(this.options.verifyClient){let p={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(x,y,R,E)=>{if(!x)return Ga(t,y||401,R,E);this.completeUpgrade(d,i,c,e,t,r,s);});return}if(!this.options.verifyClient(p))return Ga(t,401)}this.completeUpgrade(d,i,c,e,t,r,s);}completeUpgrade(e,t,r,s,i,o,a){if(!i.readable||!i.writable)return i.destroy();if(i[_8])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>tA)return Ga(i,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${U8("sha1").update(t+J8).digest("base64")}`],d=new this.options.WebSocket(null);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),d._protocol=p);}if(e[$i.extensionName]){let p=e[$i.extensionName].params,x=eA.format({[$i.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${x}`),d._extensions=e;}this.emit("headers",l,s),i.write(l.concat(`\r `).join(`\r `)),i.removeListener("error",dh),d.setSocket(i,o,{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(Bl,this);})),a(d,s);}};sA.exports=fh;function X8(n,e){for(let t of Object.keys(e))n.on(t,e[t]);return function(){for(let r of Object.keys(e))n.removeListener(r,e[r]);}}function Bl(n){n._state=nA,n.emit("close");}function dh(){this.destroy();}function Ga(n,e,t,r){n.writable&&(t=t||If.STATUS_CODES[e],r=Oe({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),n.write(`HTTP/1.1 ${e} ${If.STATUS_CODES[e]}\r `+Object.keys(r).map(s=>`${s}: ${r[s]}`).join(`\r `)+`\r \r `+t)),n.removeListener("error",dh),n.destroy();}});h();h();h();h();h();var nu=class extends Error{constructor(e,t){super(`${e}: ${t}`);}},Te=class extends Error{constructor(e){super(e);}};h();h();h();var su=class{constructor(e,t,r,s){this._initializeResponseInterceptor=()=>{this.instance.interceptors.response.use(this._handleResponse,this._handleError),this.protectedInstance.interceptors.response.use(this._