@beachviber/agent 1.10.2 → 1.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var vu=Object.create;var Tr=Object.defineProperty;var Cu=Object.getOwnPropertyDe
4
4
  `:`
5
5
  `)+n,s=r+1,r=t.indexOf(`
6
6
  `,s)}while(r!==-1);return i+=t.slice(s),i}var Li=K(()=>{});function Ut(t){return qu(t)}var Bi,Mi,vr,it,$t,Di,ot,ju,qu,Cr,Ku,Wu,Ir,Sn,Hu,Vu,fy,m,at=K(()=>{Ii();Ai();Li();({stdout:Bi,stderr:Mi}=Pi),vr=Symbol("GENERATOR"),it=Symbol("STYLER"),$t=Symbol("IS_EMPTY"),Di=["ansi","ansi","ansi256","ansi16m"],ot=Object.create(null),ju=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let n=Bi?Bi.level:0;t.level=e.level===void 0?n:e.level},qu=t=>{let e=(...n)=>n.join(" ");return ju(e,t),Object.setPrototypeOf(e,Ut.prototype),e};Object.setPrototypeOf(Ut.prototype,Function.prototype);for(let[t,e]of Object.entries(se))ot[t]={get(){let n=Sn(this,Ir(e.open,e.close,this[it]),this[$t]);return Object.defineProperty(this,t,{value:n}),n}};ot.visible={get(){let t=Sn(this,this[it],!0);return Object.defineProperty(this,"visible",{value:t}),t}};Cr=(t,e,n,...r)=>t==="rgb"?e==="ansi16m"?se[n].ansi16m(...r):e==="ansi256"?se[n].ansi256(se.rgbToAnsi256(...r)):se[n].ansi(se.rgbToAnsi(...r)):t==="hex"?Cr("rgb",e,n,...se.hexToRgb(...r)):se[n][t](...r),Ku=["rgb","hex","ansi256"];for(let t of Ku){ot[t]={get(){let{level:n}=this;return function(...r){let s=Ir(Cr(t,Di[n],"color",...r),se.color.close,this[it]);return Sn(this,s,this[$t])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);ot[e]={get(){let{level:n}=this;return function(...r){let s=Ir(Cr(t,Di[n],"bgColor",...r),se.bgColor.close,this[it]);return Sn(this,s,this[$t])}}}}Wu=Object.defineProperties(()=>{},{...ot,level:{enumerable:!0,get(){return this[vr].level},set(t){this[vr].level=t}}}),Ir=(t,e,n)=>{let r,s;return n===void 0?(r=t,s=e):(r=n.openAll+t,s=e+n.closeAll),{open:t,close:e,openAll:r,closeAll:s,parent:n}},Sn=(t,e,n)=>{let r=(...s)=>Hu(r,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(r,Wu),r[vr]=t,r[it]=e,r[$t]=n,r},Hu=(t,e)=>{if(t.level<=0||!e)return t[$t]?"":e;let n=t[it];if(n===void 0)return e;let{openAll:r,closeAll:s}=n;if(e.includes("\x1B"))for(;n!==void 0;)e=Oi(e,n.close,n.open),n=n.parent;let i=e.indexOf(`
7
- `);return i!==-1&&(e=Ni(e,s,r,i)),r+e+s};Object.defineProperties(Ut.prototype,ot);Vu=Ut(),fy=Ut({level:Mi?Mi.level:0}),m=Vu});var En,$i=K(()=>{"use strict";En=class{state="disconnected";context={consecutiveFailures:0,reconnectDelay:1e3,disconnectReason:"none",wasSleeping:!1};transition(e){let n=this.state,r=this._nextState(n,e);if(r===void 0)throw new Error(`Invalid transition: ${e.type} from state "${n}"`);return this.state=r,r}reset(){this.state="disconnected",this.context={consecutiveFailures:0,reconnectDelay:1e3,disconnectReason:"none",wasSleeping:!1}}get connectionPhase(){switch(this.state){case"disconnected":case"connecting":case"registering":return"registering";case"pairing":case"setup_reconnecting":case"setup_pairing":return"pairing";case"paired":return"paired";case"paired_sleeping":return"paired_sleeping";case"reconnecting":return"paired"}}get inSetupMode(){return this.state==="setup_reconnecting"||this.state==="setup_pairing"}get disconnectedByRemote(){return this.context.disconnectReason==="remote"}_nextState(e,n){switch(e){case"disconnected":return this._fromDisconnected(n);case"connecting":return this._fromConnecting(n);case"registering":return this._fromRegistering(n);case"pairing":return this._fromPairing(n);case"paired":return this._fromPaired(n);case"paired_sleeping":return this._fromPairedSleeping(n);case"reconnecting":return this._fromReconnecting(n);case"setup_reconnecting":return this._fromSetupReconnecting(n);case"setup_pairing":return this._fromSetupPairing(n)}}_fromDisconnected(e){switch(e.type){case"CONNECT":return this.context.disconnectReason="none","connecting";case"ENTER_SETUP":return this.context.disconnectReason="none",e.hasSavedState?"setup_reconnecting":"setup_pairing";case"FORCE_DISCONNECT":return"disconnected"}}_fromConnecting(e){switch(e.type){case"WS_OPEN":return this.context.consecutiveFailures=0,this.context.reconnectDelay=1e3,"registering";case"WS_CLOSE":return"reconnecting"}}_fromRegistering(e){switch(e.type){case"REGISTERED":return e.hasSharedSecret&&this.context.wasSleeping?(this.context.wasSleeping=!1,"paired_sleeping"):e.hasSharedSecret?"paired":"pairing";case"WS_CLOSE":return"reconnecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected"}}_fromPairing(e){switch(e.type){case"PAIRED":return"paired";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected";case"WS_CLOSE":return this.context.disconnectReason="network","disconnected"}}_fromPaired(e){switch(e.type){case"WS_CLOSE":return"reconnecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected";case"SLEEP":return"paired_sleeping"}}_fromPairedSleeping(e){switch(e.type){case"WAKE":return"paired";case"WS_CLOSE":return this.context.wasSleeping=!0,"reconnecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote",this.context.wasSleeping=!1,"disconnected";case"SLEEP":return"paired_sleeping"}}_fromReconnecting(e){switch(e.type){case"RECONNECT_TIMER":return"connecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected"}}_fromSetupReconnecting(e){switch(e.type){case"PAIRED":return"paired";case"SETUP_RECONNECT_FAILED":return"setup_pairing";case"CONNECT":return"setup_reconnecting";case"WS_OPEN":return"setup_reconnecting";case"WS_CLOSE":return"setup_reconnecting";case"REGISTERED":return e.hasSharedSecret&&this.context.wasSleeping?(this.context.wasSleeping=!1,"paired_sleeping"):e.hasSharedSecret?"paired":"setup_pairing"}}_fromSetupPairing(e){switch(e.type){case"PAIRED":return"paired";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected";case"CONNECT":return"setup_pairing";case"WS_OPEN":return"setup_pairing";case"WS_CLOSE":return"setup_pairing";case"REGISTERED":return"setup_pairing"}}}});function Ui(t){xr=t}function ji(){d.machine.reset(),d.ws=null,d.heartbeatTimer=null,d.deviceId="",d.deviceToken="",d.ownKeyPair=null,d.peerPublicKey=null,d.sharedSecret=null,d.peerAppVersion=null,d.peerCapabilities=[],d.lastMessageAt=0,d.verifyCodeResolve=null,d.registeredResolve=null,d.shuttingDown=!1,d.wakeExpiresAt=null,d.wakeTimer=null,d.wakeLockout={failedAttempts:0,lockedUntil:null}}var z,xr,Fi,Rr,d,lt=K(()=>{"use strict";$i();z="1.10.2",xr="wss://relay.beachviber.com";Fi=3e4,Rr=3e4,d={machine:new En,ws:null,heartbeatTimer:null,projects:[],deviceId:"",deviceToken:"",get connectionPhase(){return this.machine.connectionPhase},get inSetupMode(){return this.machine.inSetupMode},get disconnectedByRemote(){return this.machine.disconnectedByRemote},get consecutiveFailures(){return this.machine.context.consecutiveFailures},get reconnectDelay(){return this.machine.context.reconnectDelay},ownKeyPair:null,peerPublicKey:null,sharedSecret:null,peerAppVersion:null,peerCapabilities:[],lastMessageAt:0,verifyCodeResolve:null,registeredResolve:null,enterSetupMode:null,shuttingDown:!1,get wakeState(){return this.machine.state==="paired_sleeping"?"sleeping":"awake"},wakeExpiresAt:null,wakeTimer:null,wakeLockout:{failedAttempts:0,lockedUntil:null},onSleepTransition:null}});var ye=S((yy,Wi)=>{"use strict";var qi=["nodebuffer","arraybuffer","fragments"],Ki=typeof Blob<"u";Ki&&qi.push("blob");Wi.exports={BINARY_TYPES:qi,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Ki,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ft=S((_y,bn)=>{"use strict";var{EMPTY_BUFFER:Gu}=ye(),Pr=Buffer[Symbol.species];function Yu(t,e){if(t.length===0)return Gu;if(t.length===1)return t[0];let n=Buffer.allocUnsafe(e),r=0;for(let s=0;s<t.length;s++){let i=t[s];n.set(i,r),r+=i.length}return r<e?new Pr(n.buffer,n.byteOffset,r):n}function Hi(t,e,n,r,s){for(let i=0;i<s;i++)n[r+i]=t[i]^e[i&3]}function Vi(t,e){for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function zu(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ar(t){if(Ar.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Pr(t):ArrayBuffer.isView(t)?e=new Pr(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ar.readOnly=!1),e}bn.exports={concat:Yu,mask:Hi,toArrayBuffer:zu,toBuffer:Ar,unmask:Vi};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=v("bufferutil");bn.exports.mask=function(e,n,r,s,i){i<48?Hi(e,n,r,s,i):t.mask(e,n,r,s,i)},bn.exports.unmask=function(e,n){e.length<32?Vi(e,n):t.unmask(e,n)}}catch{}});var zi=S((wy,Yi)=>{"use strict";var Gi=Symbol("kDone"),Or=Symbol("kRun"),Nr=class{constructor(e){this[Gi]=()=>{this.pending--,this[Or]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Or]()}[Or](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Gi])}}};Yi.exports=Nr});var qt=S((Sy,Xi)=>{"use strict";var jt=v("zlib"),Ji=Ft(),Ju=zi(),{kStatusCode:Qi}=ye(),Qu=Buffer[Symbol.species],Zu=Buffer.from([0,0,255,255]),kn=Symbol("permessage-deflate"),_e=Symbol("total-length"),ct=Symbol("callback"),ke=Symbol("buffers"),ut=Symbol("error"),Tn,Lr=class{constructor(e,n,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Tn){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Tn=new Ju(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[ct];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let n=this._options,r=e.find(s=>!(n.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>s.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let n=e[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(e){return e.forEach(n=>{Object.keys(n).forEach(r=>{let s=n[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}"`);n[r]=s})}),e}decompress(e,n,r){Tn.add(s=>{this._decompress(e,n,(i,o)=>{s(),r(i,o)})})}compress(e,n,r){Tn.add(s=>{this._compress(e,n,(i,o)=>{s(),r(i,o)})})}_decompress(e,n,r){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?jt.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=jt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[kn]=this,this._inflate[_e]=0,this._inflate[ke]=[],this._inflate.on("error",ed),this._inflate.on("data",Zi)}this._inflate[ct]=r,this._inflate.write(e),n&&this._inflate.write(Zu),this._inflate.flush(()=>{let i=this._inflate[ut];if(i){this._inflate.close(),this._inflate=null,r(i);return}let o=Ji.concat(this._inflate[ke],this._inflate[_e]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[_e]=0,this._inflate[ke]=[],n&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,n,r){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?jt.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=jt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[_e]=0,this._deflate[ke]=[],this._deflate.on("data",Xu)}this._deflate[ct]=r,this._deflate.write(e),this._deflate.flush(jt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=Ji.concat(this._deflate[ke],this._deflate[_e]);n&&(i=new Qu(i.buffer,i.byteOffset,i.length-4)),this._deflate[ct]=null,this._deflate[_e]=0,this._deflate[ke]=[],n&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),r(null,i)})}};Xi.exports=Lr;function Xu(t){this[ke].push(t),this[_e]+=t.length}function Zi(t){if(this[_e]+=t.length,this[kn]._maxPayload<1||this[_e]<=this[kn]._maxPayload){this[ke].push(t);return}this[ut]=new RangeError("Max payload size exceeded"),this[ut].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ut][Qi]=1009,this.removeListener("data",Zi),this.reset()}function ed(t){if(this[kn]._inflate=null,this[ut]){this[ct](this[ut]);return}t[Qi]=1007,this[ct](t)}});var dt=S((Ey,vn)=>{"use strict";var{isUtf8:eo}=v("buffer"),{hasBlob:td}=ye(),nd=[0,0,0,0,0,0,0,0,0,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 rd(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Br(t){let e=t.length,n=0;for(;n<e;)if((t[n]&128)===0)n++;else if((t[n]&224)===192){if(n+1===e||(t[n+1]&192)!==128||(t[n]&254)===192)return!1;n+=2}else if((t[n]&240)===224){if(n+2>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||t[n]===224&&(t[n+1]&224)===128||t[n]===237&&(t[n+1]&224)===160)return!1;n+=3}else if((t[n]&248)===240){if(n+3>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||(t[n+3]&192)!==128||t[n]===240&&(t[n+1]&240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function sd(t){return td&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}vn.exports={isBlob:sd,isValidStatusCode:rd,isValidUTF8:Br,tokenChars:nd};if(eo)vn.exports.isValidUTF8=function(t){return t.length<24?Br(t):eo(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=v("utf-8-validate");vn.exports.isValidUTF8=function(e){return e.length<32?Br(e):t(e)}}catch{}});var Fr=S((by,ao)=>{"use strict";var{Writable:id}=v("stream"),to=qt(),{BINARY_TYPES:od,EMPTY_BUFFER:no,kStatusCode:ad,kWebSocket:ld}=ye(),{concat:Mr,toArrayBuffer:cd,unmask:ud}=Ft(),{isValidStatusCode:dd,isValidUTF8:ro}=dt(),Cn=Buffer[Symbol.species],X=0,so=1,io=2,oo=3,Dr=4,$r=5,In=6,Ur=class extends id{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||od[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ld]=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=X}_write(e,n,r){if(this._opcode===8&&this._state==X)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]=new Cn(r.buffer,r.byteOffset+e,r.length-e),new Cn(r.buffer,r.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let r=this._buffers[0],s=n.length-e;e>=r.length?n.set(this._buffers.shift(),s):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),s),this._buffers[0]=new Cn(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case X:this.getInfo(e);break;case so:this.getPayloadLength16(e);break;case io:this.getPayloadLength64(e);break;case oo:this.getMask();break;case Dr:this.getData(e);break;case $r:case In:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let r=(n[0]&64)===64;if(r&&!this._extensions[to.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(r){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=so:this._payloadLength===127?this._state=io: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 n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=r*Math.pow(2,32)+n.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 n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(n);return}this._masked?this._state=oo:this._state=Dr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Dr}getData(e){let n=no;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ud(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._compressed){this._state=$r,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[to.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return n(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(o);return}this._fragments.push(i)}this.dataMessage(n),this._state===X&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=X;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=Mr(r,n):this._binaryType==="arraybuffer"?s=cd(Mr(r,n)):this._binaryType==="blob"?s=new Blob(r):s=r,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=X):(this._state=In,setImmediate(()=>{this.emit("message",s,!0),this._state=X,this.startLoop(e)}))}else{let s=Mr(r,n);if(!this._skipUTF8Validation&&!ro(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===$r||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=X):(this._state=In,setImmediate(()=>{this.emit("message",s,!1),this._state=X,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,no),this.end();else{let r=e.readUInt16BE(0);if(!dd(r)){let i=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(i);return}let s=new Cn(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ro(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(i);return}this._loop=!1,this.emit("conclude",r,s),this.end()}this._state=X;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=X):(this._state=In,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=X,this.startLoop(n)}))}createError(e,n,r,s,i){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(o,this.createError),o.code=i,o[ad]=s,o}};ao.exports=Ur});var Kr=S((ky,uo)=>{"use strict";var{Duplex:Ty}=v("stream"),{randomFillSync:fd}=v("crypto"),lo=qt(),{EMPTY_BUFFER:pd,kWebSocket:hd,NOOP:gd}=ye(),{isBlob:ft,isValidStatusCode:md}=dt(),{mask:co,toBuffer:qe}=Ft(),ee=Symbol("kByteLength"),yd=Buffer.alloc(4),xn=8*1024,Ke,pt=xn,ie=0,_d=1,wd=2,jr=class t{constructor(e,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=ie,this.onerror=gd,this[hd]=void 0}static frame(e,n){let r,s=!1,i=2,o=!1;n.mask&&(r=n.maskBuffer||yd,n.generateMask?n.generateMask(r):(pt===xn&&(Ke===void 0&&(Ke=Buffer.alloc(xn)),fd(Ke,0,xn),pt=0),r[0]=Ke[pt++],r[1]=Ke[pt++],r[2]=Ke[pt++],r[3]=Ke[pt++]),o=(r[0]|r[1]|r[2]|r[3])===0,i=6);let a;typeof e=="string"?(!n.mask||o)&&n[ee]!==void 0?a=n[ee]:(e=Buffer.from(e),a=e.length):(a=e.length,s=n.mask&&n.readOnly&&!o);let l=a;a>=65536?(i+=8,l=127):a>125&&(i+=2,l=126);let c=Buffer.allocUnsafe(s?a+i:i);return c[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(c[0]|=64),c[1]=l,l===126?c.writeUInt16BE(a,2):l===127&&(c[2]=c[3]=0,c.writeUIntBE(a,4,6)),n.mask?(c[1]|=128,c[i-4]=r[0],c[i-3]=r[1],c[i-2]=r[2],c[i-1]=r[3],o?[c,e]:s?(co(e,r,c,i,a),[c]):(co(e,r,e,0,a),[c,e])):[c,e]}close(e,n,r,s){let i;if(e===void 0)i=pd;else{if(typeof e!="number"||!md(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let a=Buffer.byteLength(n);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 n=="string"?i.write(n,2):i.set(n,2)}}let o={[ee]:i.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ie?this.enqueue([this.dispatch,i,!1,o,s]):this.sendFrame(t.frame(i,o),s)}ping(e,n,r){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ft(e)?(s=e.size,i=!1):(e=qe(e),s=e.length,i=qe.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ee]:s,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};ft(e)?this._state!==ie?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==ie?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,n,r){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ft(e)?(s=e.size,i=!1):(e=qe(e),s=e.length,i=qe.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ee]:s,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};ft(e)?this._state!==ie?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==ie?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,n,r){let s=this._extensions[lo.extensionName],i=n.binary?2:1,o=n.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):ft(e)?(a=e.size,l=!1):(e=qe(e),a=e.length,l=qe.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),n.fin&&(this._firstFragment=!0);let c={[ee]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:l,rsv1:o};ft(e)?this._state!==ie?this.enqueue([this.getBlobData,e,this._compress,c,r]):this.getBlobData(e,this._compress,c,r):this._state!==ie?this.enqueue([this.dispatch,e,this._compress,c,r]):this.dispatch(e,this._compress,c,r)}getBlobData(e,n,r,s){this._bufferedBytes+=r[ee],this._state=wd,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(qr,this,a,s);return}this._bufferedBytes-=r[ee];let o=qe(i);n?this.dispatch(o,n,r,s):(this._state=ie,this.sendFrame(t.frame(o,r),s),this.dequeue())}).catch(i=>{process.nextTick(Sd,this,i,s)})}dispatch(e,n,r,s){if(!n){this.sendFrame(t.frame(e,r),s);return}let i=this._extensions[lo.extensionName];this._bufferedBytes+=r[ee],this._state=_d,i.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");qr(this,l,s);return}this._bufferedBytes-=r[ee],this._state=ie,r.readOnly=!1,this.sendFrame(t.frame(a,r),s),this.dequeue()})}dequeue(){for(;this._state===ie&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ee],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ee],this._queue.push(e)}sendFrame(e,n){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.write(e[0],n)}};uo.exports=jr;function qr(t,e,n){typeof n=="function"&&n(e);for(let r=0;r<t._queue.length;r++){let s=t._queue[r],i=s[s.length-1];typeof i=="function"&&i(e)}}function Sd(t,e,n){qr(t,e,n),t.onerror(e)}});var So=S((vy,wo)=>{"use strict";var{kForOnEventAttribute:Kt,kListener:Wr}=ye(),fo=Symbol("kCode"),po=Symbol("kData"),ho=Symbol("kError"),go=Symbol("kMessage"),mo=Symbol("kReason"),ht=Symbol("kTarget"),yo=Symbol("kType"),_o=Symbol("kWasClean"),we=class{constructor(e){this[ht]=null,this[yo]=e}get target(){return this[ht]}get type(){return this[yo]}};Object.defineProperty(we.prototype,"target",{enumerable:!0});Object.defineProperty(we.prototype,"type",{enumerable:!0});var We=class extends we{constructor(e,n={}){super(e),this[fo]=n.code===void 0?0:n.code,this[mo]=n.reason===void 0?"":n.reason,this[_o]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[fo]}get reason(){return this[mo]}get wasClean(){return this[_o]}};Object.defineProperty(We.prototype,"code",{enumerable:!0});Object.defineProperty(We.prototype,"reason",{enumerable:!0});Object.defineProperty(We.prototype,"wasClean",{enumerable:!0});var gt=class extends we{constructor(e,n={}){super(e),this[ho]=n.error===void 0?null:n.error,this[go]=n.message===void 0?"":n.message}get error(){return this[ho]}get message(){return this[go]}};Object.defineProperty(gt.prototype,"error",{enumerable:!0});Object.defineProperty(gt.prototype,"message",{enumerable:!0});var Wt=class extends we{constructor(e,n={}){super(e),this[po]=n.data===void 0?null:n.data}get data(){return this[po]}};Object.defineProperty(Wt.prototype,"data",{enumerable:!0});var Ed={addEventListener(t,e,n={}){for(let s of this.listeners(t))if(!n[Kt]&&s[Wr]===e&&!s[Kt])return;let r;if(t==="message")r=function(i,o){let a=new Wt("message",{data:o?i:i.toString()});a[ht]=this,Rn(e,this,a)};else if(t==="close")r=function(i,o){let a=new We("close",{code:i,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ht]=this,Rn(e,this,a)};else if(t==="error")r=function(i){let o=new gt("error",{error:i,message:i.message});o[ht]=this,Rn(e,this,o)};else if(t==="open")r=function(){let i=new we("open");i[ht]=this,Rn(e,this,i)};else return;r[Kt]=!!n[Kt],r[Wr]=e,n.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Wr]===e&&!n[Kt]){this.removeListener(t,n);break}}};wo.exports={CloseEvent:We,ErrorEvent:gt,Event:we,EventTarget:Ed,MessageEvent:Wt};function Rn(t,e,n){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Hr=S((Cy,Eo)=>{"use strict";var{tokenChars:Ht}=dt();function ce(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function bd(t){let e=Object.create(null),n=Object.create(null),r=!1,s=!1,i=!1,o,a,l=-1,c=-1,u=-1,p=0;for(;p<t.length;p++)if(c=t.charCodeAt(p),o===void 0)if(u===-1&&Ht[c]===1)l===-1&&(l=p);else if(p!==0&&(c===32||c===9))u===-1&&l!==-1&&(u=p);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=t.slice(l,u);c===44?(ce(e,f,n),n=Object.create(null)):o=f,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(u===-1&&Ht[c]===1)l===-1&&(l=p);else if(c===32||c===9)u===-1&&l!==-1&&(u=p);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p),ce(n,t.slice(l,u),!0),c===44&&(ce(e,o,n),n=Object.create(null),o=void 0),l=u=-1}else if(c===61&&l!==-1&&u===-1)a=t.slice(l,p),l=u=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(s){if(Ht[c]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);l===-1?l=p:r||(r=!0),s=!1}else if(i)if(Ht[c]===1)l===-1&&(l=p);else if(c===34&&l!==-1)i=!1,u=p;else if(c===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(c===34&&t.charCodeAt(p-1)===61)i=!0;else if(u===-1&&Ht[c]===1)l===-1&&(l=p);else if(l!==-1&&(c===32||c===9))u===-1&&(u=p);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=t.slice(l,u);r&&(f=f.replace(/\\/g,""),r=!1),ce(n,a,f),c===44&&(ce(e,o,n),n=Object.create(null),o=void 0),a=void 0,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(l===-1||i||c===32||c===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=p);let g=t.slice(l,u);return o===void 0?ce(e,g,n):(a===void 0?ce(n,g,!0):r?ce(n,a,g.replace(/\\/g,"")):ce(n,a,g),ce(e,o,n)),e}function Td(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(n)||(n=[n]),n.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(", ")}Eo.exports={format:Td,parse:bd}});var Nn=S((Ry,No)=>{"use strict";var kd=v("events"),vd=v("https"),Cd=v("http"),ko=v("net"),Id=v("tls"),{randomBytes:xd,createHash:Rd}=v("crypto"),{Duplex:Iy,Readable:xy}=v("stream"),{URL:Vr}=v("url"),ve=qt(),Pd=Fr(),Ad=Kr(),{isBlob:Od}=dt(),{BINARY_TYPES:bo,CLOSE_TIMEOUT:Nd,EMPTY_BUFFER:Pn,GUID:Ld,kForOnEventAttribute:Gr,kListener:Bd,kStatusCode:Md,kWebSocket:j,NOOP:vo}=ye(),{EventTarget:{addEventListener:Dd,removeEventListener:$d}}=So(),{format:Ud,parse:Fd}=Hr(),{toBuffer:jd}=Ft(),Co=Symbol("kAborted"),Yr=[8,13],Se=["CONNECTING","OPEN","CLOSING","CLOSED"],qd=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,L=class t extends kd{constructor(e,n,r){super(),this._binaryType=bo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Pn,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,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),Io(this,e,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){bo.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,n,r){let s=new Pd({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),i=new Ad(e,this._extensions,r.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[j]=this,i[j]=this,e[j]=this,s.on("conclude",Hd),s.on("drain",Vd),s.on("error",Gd),s.on("message",Yd),s.on("ping",zd),s.on("pong",Jd),i.onerror=Qd,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",Po),e.on("data",On),e.on("end",Ao),e.on("error",Oo),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[ve.extensionName]&&this._extensions[ve.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){J(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,n,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ro(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){zr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Pn,n,r)}pong(e,n,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){zr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(e||Pn,n,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){zr(this,e,r);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[ve.extensionName]||(s.compress=!1),this._sender.send(e||Pn,s,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){J(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(L,"CONNECTING",{enumerable:!0,value:Se.indexOf("CONNECTING")});Object.defineProperty(L.prototype,"CONNECTING",{enumerable:!0,value:Se.indexOf("CONNECTING")});Object.defineProperty(L,"OPEN",{enumerable:!0,value:Se.indexOf("OPEN")});Object.defineProperty(L.prototype,"OPEN",{enumerable:!0,value:Se.indexOf("OPEN")});Object.defineProperty(L,"CLOSING",{enumerable:!0,value:Se.indexOf("CLOSING")});Object.defineProperty(L.prototype,"CLOSING",{enumerable:!0,value:Se.indexOf("CLOSING")});Object.defineProperty(L,"CLOSED",{enumerable:!0,value:Se.indexOf("CLOSED")});Object.defineProperty(L.prototype,"CLOSED",{enumerable:!0,value:Se.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(L.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(L.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Gr])return e[Bd];return null},set(e){for(let n of this.listeners(t))if(n[Gr]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[Gr]:!0})}})});L.prototype.addEventListener=Dd;L.prototype.removeEventListener=$d;No.exports=L;function Io(t,e,n,r){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Nd,protocolVersion:Yr[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,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=s.autoPong,t._closeTimeout=s.closeTimeout,!Yr.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${Yr.join(", ")})`);let i;if(e instanceof Vr)i=e;else try{i=new Vr(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),t._url=i.href;let o=i.protocol==="wss:",a=i.protocol==="ws+unix:",l;if(i.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!i.pathname?l="The URL's pathname is empty":i.hash&&(l="The URL contains a fragment identifier"),l){let y=new SyntaxError(l);if(t._redirects===0)throw y;An(t,y);return}let c=o?443:80,u=xd(16).toString("base64"),p=o?vd.request:Cd.request,g=new Set,f;if(s.createConnection=s.createConnection||(o?Wd:Kd),s.defaultPort=s.defaultPort||c,s.port=i.port||c,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(f=new ve(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=Ud({[ve.extensionName]:f.offer()})),n.length){for(let y of n){if(typeof y!="string"||!qd.test(y)||g.has(y))throw new SyntaxError("An invalid or duplicated subprotocol was specified");g.add(y)}s.headers["Sec-WebSocket-Protocol"]=n.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 y=s.path.split(":");s.socketPath=y[0],s.path=y[1]}let h;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?s.socketPath:i.host;let y=r&&r.headers;if(r={...r,headers:{}},y)for(let[_,w]of Object.entries(y))r.headers[_.toLowerCase()]=w}else if(t.listenerCount("redirect")===0){let y=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:i.host===t._originalHostOrSocketPath;(!y||t._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,y||delete s.headers.host,s.auth=void 0)}s.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),h=t._req=p(s),t._redirects&&t.emit("redirect",t.url,h)}else h=t._req=p(s);s.timeout&&h.on("timeout",()=>{J(t,h,"Opening handshake has timed out")}),h.on("error",y=>{h===null||h[Co]||(h=t._req=null,An(t,y))}),h.on("response",y=>{let _=y.headers.location,w=y.statusCode;if(_&&s.followRedirects&&w>=300&&w<400){if(++t._redirects>s.maxRedirects){J(t,h,"Maximum redirects exceeded");return}h.abort();let R;try{R=new Vr(_,e)}catch{let T=new SyntaxError(`Invalid URL: ${_}`);An(t,T);return}Io(t,R,n,r)}else t.emit("unexpected-response",h,y)||J(t,h,`Unexpected server response: ${y.statusCode}`)}),h.on("upgrade",(y,_,w)=>{if(t.emit("upgrade",y),t.readyState!==L.CONNECTING)return;h=t._req=null;let R=y.headers.upgrade;if(R===void 0||R.toLowerCase()!=="websocket"){J(t,_,"Invalid Upgrade header");return}let B=Rd("sha1").update(u+Ld).digest("base64");if(y.headers["sec-websocket-accept"]!==B){J(t,_,"Invalid Sec-WebSocket-Accept header");return}let T=y.headers["sec-websocket-protocol"],E;if(T!==void 0?g.size?g.has(T)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":g.size&&(E="Server sent no subprotocol"),E){J(t,_,E);return}T&&(t._protocol=T);let b=y.headers["sec-websocket-extensions"];if(b!==void 0){if(!f){J(t,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Fd(b)}catch{J(t,_,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(C);if(A.length!==1||A[0]!==ve.extensionName){J(t,_,"Server indicated an extension that was not requested");return}try{f.accept(C[ve.extensionName])}catch{J(t,_,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ve.extensionName]=f}t.setSocket(_,w,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(h,t):h.end()}function An(t,e){t._readyState=L.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Kd(t){return t.path=t.socketPath,ko.connect(t)}function Wd(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=ko.isIP(t.host)?"":t.host),Id.connect(t)}function J(t,e,n){t._readyState=L.CLOSING;let r=new Error(n);Error.captureStackTrace(r,J),e.setHeader?(e[Co]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(An,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function zr(t,e,n){if(e){let r=Od(e)?e.size:jd(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${Se[t.readyState]})`);process.nextTick(n,r)}}function Hd(t,e){let n=this[j];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[j]!==void 0&&(n._socket.removeListener("data",On),process.nextTick(xo,n._socket),t===1005?n.close():n.close(t,e))}function Vd(){let t=this[j];t.isPaused||t._socket.resume()}function Gd(t){let e=this[j];e._socket[j]!==void 0&&(e._socket.removeListener("data",On),process.nextTick(xo,e._socket),e.close(t[Md])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function To(){this[j].emitClose()}function Yd(t,e){this[j].emit("message",t,e)}function zd(t){let e=this[j];e._autoPong&&e.pong(t,!this._isServer,vo),e.emit("ping",t)}function Jd(t){this[j].emit("pong",t)}function xo(t){t.resume()}function Qd(t){let e=this[j];e.readyState!==L.CLOSED&&(e.readyState===L.OPEN&&(e._readyState=L.CLOSING,Ro(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ro(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Po(){let t=this[j];if(this.removeListener("close",Po),this.removeListener("data",On),this.removeListener("end",Ao),t._readyState=L.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[j]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",To),t._receiver.on("finish",To))}function On(t){this[j]._receiver.write(t)||this.pause()}function Ao(){let t=this[j];t._readyState=L.CLOSING,t._receiver.end(),this.end()}function Oo(){let t=this[j];this.removeListener("error",Oo),this.on("error",vo),t&&(t._readyState=L.CLOSING,this.destroy())}});var Do=S((Ay,Mo)=>{"use strict";var Py=Nn(),{Duplex:Zd}=v("stream");function Lo(t){t.emit("close")}function Xd(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Bo(t){this.removeListener("error",Bo),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function ef(t,e){let n=!0,r=new Zd({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(i,o){let a=!o&&r._readableState.objectMode?i.toString():i;r.push(a)||t.pause()}),t.once("error",function(i){r.destroyed||(n=!1,r.destroy(i))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(s,i){if(t.readyState===t.CLOSED){i(s),process.nextTick(Lo,r);return}let o=!1;t.once("error",function(l){o=!0,i(l)}),t.once("close",function(){o||i(s),process.nextTick(Lo,r)}),n&&t.terminate()},r._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(s,i,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(s,i,o)});return}t.send(s,o)},r.on("end",Xd),r.on("error",Bo),r}Mo.exports=ef});var Uo=S((Oy,$o)=>{"use strict";var{tokenChars:tf}=dt();function nf(t){let e=new Set,n=-1,r=-1,s=0;for(s;s<t.length;s++){let o=t.charCodeAt(s);if(r===-1&&tf[o]===1)n===-1&&(n=s);else if(s!==0&&(o===32||o===9))r===-1&&n!==-1&&(r=s);else if(o===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${s}`);r===-1&&(r=s);let a=t.slice(n,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let i=t.slice(n,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}$o.exports={parse:nf}});var Vo=S((Ly,Ho)=>{"use strict";var rf=v("events"),Ln=v("http"),{Duplex:Ny}=v("stream"),{createHash:sf}=v("crypto"),Fo=Hr(),He=qt(),of=Uo(),af=Nn(),{CLOSE_TIMEOUT:lf,GUID:cf,kWebSocket:uf}=ye(),df=/^[+/0-9A-Za-z]{22}==$/,jo=0,qo=1,Wo=2,Jr=class extends rf{constructor(e,n){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lf,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:af,...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=Ln.createServer((r,s)=>{let i=Ln.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,n)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=ff(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=jo}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===Wo){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Vt,this);return}if(e&&this.once("close",e),this._state!==qo)if(this._state=qo,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(Vt,this):process.nextTick(Vt,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{Vt(this)})}}shouldHandle(e){if(this.options.path){let n=e.url.indexOf("?");if((n!==-1?e.url.slice(0,n):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,n,r,s){n.on("error",Ko);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Ve(this,e,n,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Ve(this,e,n,400,"Invalid Upgrade header");return}if(i===void 0||!df.test(i)){Ve(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Ve(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Gt(n,400);return}let l=e.headers["sec-websocket-protocol"],c=new Set;if(l!==void 0)try{c=of.parse(l)}catch{Ve(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&u!==void 0){let g=new He(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=Fo.parse(u);f[He.extensionName]&&(g.accept(f[He.extensionName]),p[He.extensionName]=g)}catch{Ve(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let g={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(g,(f,h,y,_)=>{if(!f)return Gt(n,h||401,y,_);this.completeUpgrade(p,i,c,e,n,r,s)});return}if(!this.options.verifyClient(g))return Gt(n,401)}this.completeUpgrade(p,i,c,e,n,r,s)}completeUpgrade(e,n,r,s,i,o,a){if(!i.readable||!i.writable)return i.destroy();if(i[uf])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>jo)return Gt(i,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${sf("sha1").update(n+cf).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;p&&(c.push(`Sec-WebSocket-Protocol: ${p}`),u._protocol=p)}if(e[He.extensionName]){let p=e[He.extensionName].params,g=Fo.format({[He.extensionName]:[p]});c.push(`Sec-WebSocket-Extensions: ${g}`),u._extensions=e}this.emit("headers",c,s),i.write(c.concat(`\r
7
+ `);return i!==-1&&(e=Ni(e,s,r,i)),r+e+s};Object.defineProperties(Ut.prototype,ot);Vu=Ut(),fy=Ut({level:Mi?Mi.level:0}),m=Vu});var En,$i=K(()=>{"use strict";En=class{state="disconnected";context={consecutiveFailures:0,reconnectDelay:1e3,disconnectReason:"none",wasSleeping:!1};transition(e){let n=this.state,r=this._nextState(n,e);if(r===void 0)throw new Error(`Invalid transition: ${e.type} from state "${n}"`);return this.state=r,r}reset(){this.state="disconnected",this.context={consecutiveFailures:0,reconnectDelay:1e3,disconnectReason:"none",wasSleeping:!1}}get connectionPhase(){switch(this.state){case"disconnected":case"connecting":case"registering":return"registering";case"pairing":case"setup_reconnecting":case"setup_pairing":return"pairing";case"paired":return"paired";case"paired_sleeping":return"paired_sleeping";case"reconnecting":return"paired"}}get inSetupMode(){return this.state==="setup_reconnecting"||this.state==="setup_pairing"}get disconnectedByRemote(){return this.context.disconnectReason==="remote"}_nextState(e,n){switch(e){case"disconnected":return this._fromDisconnected(n);case"connecting":return this._fromConnecting(n);case"registering":return this._fromRegistering(n);case"pairing":return this._fromPairing(n);case"paired":return this._fromPaired(n);case"paired_sleeping":return this._fromPairedSleeping(n);case"reconnecting":return this._fromReconnecting(n);case"setup_reconnecting":return this._fromSetupReconnecting(n);case"setup_pairing":return this._fromSetupPairing(n)}}_fromDisconnected(e){switch(e.type){case"CONNECT":return this.context.disconnectReason="none","connecting";case"ENTER_SETUP":return this.context.disconnectReason="none",e.hasSavedState?"setup_reconnecting":"setup_pairing";case"FORCE_DISCONNECT":return"disconnected"}}_fromConnecting(e){switch(e.type){case"WS_OPEN":return this.context.consecutiveFailures=0,this.context.reconnectDelay=1e3,"registering";case"WS_CLOSE":return"reconnecting"}}_fromRegistering(e){switch(e.type){case"REGISTERED":return e.hasSharedSecret&&this.context.wasSleeping?(this.context.wasSleeping=!1,"paired_sleeping"):e.hasSharedSecret?"paired":"pairing";case"WS_CLOSE":return"reconnecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected"}}_fromPairing(e){switch(e.type){case"PAIRED":return"paired";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected";case"WS_CLOSE":return this.context.disconnectReason="network","disconnected"}}_fromPaired(e){switch(e.type){case"WS_CLOSE":return"reconnecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected";case"SLEEP":return"paired_sleeping"}}_fromPairedSleeping(e){switch(e.type){case"WAKE":return"paired";case"WS_CLOSE":return this.context.wasSleeping=!0,"reconnecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote",this.context.wasSleeping=!1,"disconnected";case"SLEEP":return"paired_sleeping"}}_fromReconnecting(e){switch(e.type){case"RECONNECT_TIMER":return"connecting";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected"}}_fromSetupReconnecting(e){switch(e.type){case"PAIRED":return"paired";case"SETUP_RECONNECT_FAILED":return"setup_pairing";case"CONNECT":return"setup_reconnecting";case"WS_OPEN":return"setup_reconnecting";case"WS_CLOSE":return"setup_reconnecting";case"REGISTERED":return e.hasSharedSecret&&this.context.wasSleeping?(this.context.wasSleeping=!1,"paired_sleeping"):e.hasSharedSecret?"paired":"setup_pairing"}}_fromSetupPairing(e){switch(e.type){case"PAIRED":return"paired";case"FORCE_DISCONNECT":return this.context.disconnectReason="remote","disconnected";case"CONNECT":return"setup_pairing";case"WS_OPEN":return"setup_pairing";case"WS_CLOSE":return"setup_pairing";case"REGISTERED":return"setup_pairing"}}}});function Ui(t){xr=t}function ji(){d.machine.reset(),d.ws=null,d.heartbeatTimer=null,d.deviceId="",d.deviceToken="",d.ownKeyPair=null,d.peerPublicKey=null,d.sharedSecret=null,d.peerAppVersion=null,d.peerCapabilities=[],d.lastMessageAt=0,d.verifyCodeResolve=null,d.registeredResolve=null,d.shuttingDown=!1,d.wakeExpiresAt=null,d.wakeTimer=null,d.wakeLockout={failedAttempts:0,lockedUntil:null}}var z,xr,Fi,Rr,d,lt=K(()=>{"use strict";$i();z="1.10.4",xr="wss://relay.beachviber.com";Fi=3e4,Rr=3e4,d={machine:new En,ws:null,heartbeatTimer:null,projects:[],deviceId:"",deviceToken:"",get connectionPhase(){return this.machine.connectionPhase},get inSetupMode(){return this.machine.inSetupMode},get disconnectedByRemote(){return this.machine.disconnectedByRemote},get consecutiveFailures(){return this.machine.context.consecutiveFailures},get reconnectDelay(){return this.machine.context.reconnectDelay},ownKeyPair:null,peerPublicKey:null,sharedSecret:null,peerAppVersion:null,peerCapabilities:[],lastMessageAt:0,verifyCodeResolve:null,registeredResolve:null,enterSetupMode:null,shuttingDown:!1,get wakeState(){return this.machine.state==="paired_sleeping"?"sleeping":"awake"},wakeExpiresAt:null,wakeTimer:null,wakeLockout:{failedAttempts:0,lockedUntil:null},onSleepTransition:null}});var ye=S((yy,Wi)=>{"use strict";var qi=["nodebuffer","arraybuffer","fragments"],Ki=typeof Blob<"u";Ki&&qi.push("blob");Wi.exports={BINARY_TYPES:qi,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Ki,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ft=S((_y,bn)=>{"use strict";var{EMPTY_BUFFER:Gu}=ye(),Pr=Buffer[Symbol.species];function Yu(t,e){if(t.length===0)return Gu;if(t.length===1)return t[0];let n=Buffer.allocUnsafe(e),r=0;for(let s=0;s<t.length;s++){let i=t[s];n.set(i,r),r+=i.length}return r<e?new Pr(n.buffer,n.byteOffset,r):n}function Hi(t,e,n,r,s){for(let i=0;i<s;i++)n[r+i]=t[i]^e[i&3]}function Vi(t,e){for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function zu(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ar(t){if(Ar.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Pr(t):ArrayBuffer.isView(t)?e=new Pr(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ar.readOnly=!1),e}bn.exports={concat:Yu,mask:Hi,toArrayBuffer:zu,toBuffer:Ar,unmask:Vi};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=v("bufferutil");bn.exports.mask=function(e,n,r,s,i){i<48?Hi(e,n,r,s,i):t.mask(e,n,r,s,i)},bn.exports.unmask=function(e,n){e.length<32?Vi(e,n):t.unmask(e,n)}}catch{}});var zi=S((wy,Yi)=>{"use strict";var Gi=Symbol("kDone"),Or=Symbol("kRun"),Nr=class{constructor(e){this[Gi]=()=>{this.pending--,this[Or]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Or]()}[Or](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Gi])}}};Yi.exports=Nr});var qt=S((Sy,Xi)=>{"use strict";var jt=v("zlib"),Ji=Ft(),Ju=zi(),{kStatusCode:Qi}=ye(),Qu=Buffer[Symbol.species],Zu=Buffer.from([0,0,255,255]),kn=Symbol("permessage-deflate"),_e=Symbol("total-length"),ct=Symbol("callback"),ke=Symbol("buffers"),ut=Symbol("error"),Tn,Lr=class{constructor(e,n,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Tn){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Tn=new Ju(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[ct];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let n=this._options,r=e.find(s=>!(n.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>s.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let n=e[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(e){return e.forEach(n=>{Object.keys(n).forEach(r=>{let s=n[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}"`);n[r]=s})}),e}decompress(e,n,r){Tn.add(s=>{this._decompress(e,n,(i,o)=>{s(),r(i,o)})})}compress(e,n,r){Tn.add(s=>{this._compress(e,n,(i,o)=>{s(),r(i,o)})})}_decompress(e,n,r){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?jt.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=jt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[kn]=this,this._inflate[_e]=0,this._inflate[ke]=[],this._inflate.on("error",ed),this._inflate.on("data",Zi)}this._inflate[ct]=r,this._inflate.write(e),n&&this._inflate.write(Zu),this._inflate.flush(()=>{let i=this._inflate[ut];if(i){this._inflate.close(),this._inflate=null,r(i);return}let o=Ji.concat(this._inflate[ke],this._inflate[_e]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[_e]=0,this._inflate[ke]=[],n&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,n,r){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?jt.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=jt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[_e]=0,this._deflate[ke]=[],this._deflate.on("data",Xu)}this._deflate[ct]=r,this._deflate.write(e),this._deflate.flush(jt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=Ji.concat(this._deflate[ke],this._deflate[_e]);n&&(i=new Qu(i.buffer,i.byteOffset,i.length-4)),this._deflate[ct]=null,this._deflate[_e]=0,this._deflate[ke]=[],n&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),r(null,i)})}};Xi.exports=Lr;function Xu(t){this[ke].push(t),this[_e]+=t.length}function Zi(t){if(this[_e]+=t.length,this[kn]._maxPayload<1||this[_e]<=this[kn]._maxPayload){this[ke].push(t);return}this[ut]=new RangeError("Max payload size exceeded"),this[ut].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ut][Qi]=1009,this.removeListener("data",Zi),this.reset()}function ed(t){if(this[kn]._inflate=null,this[ut]){this[ct](this[ut]);return}t[Qi]=1007,this[ct](t)}});var dt=S((Ey,vn)=>{"use strict";var{isUtf8:eo}=v("buffer"),{hasBlob:td}=ye(),nd=[0,0,0,0,0,0,0,0,0,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 rd(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Br(t){let e=t.length,n=0;for(;n<e;)if((t[n]&128)===0)n++;else if((t[n]&224)===192){if(n+1===e||(t[n+1]&192)!==128||(t[n]&254)===192)return!1;n+=2}else if((t[n]&240)===224){if(n+2>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||t[n]===224&&(t[n+1]&224)===128||t[n]===237&&(t[n+1]&224)===160)return!1;n+=3}else if((t[n]&248)===240){if(n+3>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||(t[n+3]&192)!==128||t[n]===240&&(t[n+1]&240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function sd(t){return td&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}vn.exports={isBlob:sd,isValidStatusCode:rd,isValidUTF8:Br,tokenChars:nd};if(eo)vn.exports.isValidUTF8=function(t){return t.length<24?Br(t):eo(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=v("utf-8-validate");vn.exports.isValidUTF8=function(e){return e.length<32?Br(e):t(e)}}catch{}});var Fr=S((by,ao)=>{"use strict";var{Writable:id}=v("stream"),to=qt(),{BINARY_TYPES:od,EMPTY_BUFFER:no,kStatusCode:ad,kWebSocket:ld}=ye(),{concat:Mr,toArrayBuffer:cd,unmask:ud}=Ft(),{isValidStatusCode:dd,isValidUTF8:ro}=dt(),Cn=Buffer[Symbol.species],X=0,so=1,io=2,oo=3,Dr=4,$r=5,In=6,Ur=class extends id{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||od[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ld]=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=X}_write(e,n,r){if(this._opcode===8&&this._state==X)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]=new Cn(r.buffer,r.byteOffset+e,r.length-e),new Cn(r.buffer,r.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let r=this._buffers[0],s=n.length-e;e>=r.length?n.set(this._buffers.shift(),s):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),s),this._buffers[0]=new Cn(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case X:this.getInfo(e);break;case so:this.getPayloadLength16(e);break;case io:this.getPayloadLength64(e);break;case oo:this.getMask();break;case Dr:this.getData(e);break;case $r:case In:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let r=(n[0]&64)===64;if(r&&!this._extensions[to.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(r){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=so:this._payloadLength===127?this._state=io: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 n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=r*Math.pow(2,32)+n.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 n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(n);return}this._masked?this._state=oo:this._state=Dr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Dr}getData(e){let n=no;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ud(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._compressed){this._state=$r,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[to.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return n(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(o);return}this._fragments.push(i)}this.dataMessage(n),this._state===X&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=X;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=Mr(r,n):this._binaryType==="arraybuffer"?s=cd(Mr(r,n)):this._binaryType==="blob"?s=new Blob(r):s=r,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=X):(this._state=In,setImmediate(()=>{this.emit("message",s,!0),this._state=X,this.startLoop(e)}))}else{let s=Mr(r,n);if(!this._skipUTF8Validation&&!ro(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===$r||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=X):(this._state=In,setImmediate(()=>{this.emit("message",s,!1),this._state=X,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,no),this.end();else{let r=e.readUInt16BE(0);if(!dd(r)){let i=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(i);return}let s=new Cn(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ro(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(i);return}this._loop=!1,this.emit("conclude",r,s),this.end()}this._state=X;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=X):(this._state=In,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=X,this.startLoop(n)}))}createError(e,n,r,s,i){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(o,this.createError),o.code=i,o[ad]=s,o}};ao.exports=Ur});var Kr=S((ky,uo)=>{"use strict";var{Duplex:Ty}=v("stream"),{randomFillSync:fd}=v("crypto"),lo=qt(),{EMPTY_BUFFER:pd,kWebSocket:hd,NOOP:gd}=ye(),{isBlob:ft,isValidStatusCode:md}=dt(),{mask:co,toBuffer:qe}=Ft(),ee=Symbol("kByteLength"),yd=Buffer.alloc(4),xn=8*1024,Ke,pt=xn,ie=0,_d=1,wd=2,jr=class t{constructor(e,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=ie,this.onerror=gd,this[hd]=void 0}static frame(e,n){let r,s=!1,i=2,o=!1;n.mask&&(r=n.maskBuffer||yd,n.generateMask?n.generateMask(r):(pt===xn&&(Ke===void 0&&(Ke=Buffer.alloc(xn)),fd(Ke,0,xn),pt=0),r[0]=Ke[pt++],r[1]=Ke[pt++],r[2]=Ke[pt++],r[3]=Ke[pt++]),o=(r[0]|r[1]|r[2]|r[3])===0,i=6);let a;typeof e=="string"?(!n.mask||o)&&n[ee]!==void 0?a=n[ee]:(e=Buffer.from(e),a=e.length):(a=e.length,s=n.mask&&n.readOnly&&!o);let l=a;a>=65536?(i+=8,l=127):a>125&&(i+=2,l=126);let c=Buffer.allocUnsafe(s?a+i:i);return c[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(c[0]|=64),c[1]=l,l===126?c.writeUInt16BE(a,2):l===127&&(c[2]=c[3]=0,c.writeUIntBE(a,4,6)),n.mask?(c[1]|=128,c[i-4]=r[0],c[i-3]=r[1],c[i-2]=r[2],c[i-1]=r[3],o?[c,e]:s?(co(e,r,c,i,a),[c]):(co(e,r,e,0,a),[c,e])):[c,e]}close(e,n,r,s){let i;if(e===void 0)i=pd;else{if(typeof e!="number"||!md(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let a=Buffer.byteLength(n);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 n=="string"?i.write(n,2):i.set(n,2)}}let o={[ee]:i.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ie?this.enqueue([this.dispatch,i,!1,o,s]):this.sendFrame(t.frame(i,o),s)}ping(e,n,r){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ft(e)?(s=e.size,i=!1):(e=qe(e),s=e.length,i=qe.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ee]:s,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};ft(e)?this._state!==ie?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==ie?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,n,r){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ft(e)?(s=e.size,i=!1):(e=qe(e),s=e.length,i=qe.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ee]:s,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};ft(e)?this._state!==ie?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==ie?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,n,r){let s=this._extensions[lo.extensionName],i=n.binary?2:1,o=n.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):ft(e)?(a=e.size,l=!1):(e=qe(e),a=e.length,l=qe.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),n.fin&&(this._firstFragment=!0);let c={[ee]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:l,rsv1:o};ft(e)?this._state!==ie?this.enqueue([this.getBlobData,e,this._compress,c,r]):this.getBlobData(e,this._compress,c,r):this._state!==ie?this.enqueue([this.dispatch,e,this._compress,c,r]):this.dispatch(e,this._compress,c,r)}getBlobData(e,n,r,s){this._bufferedBytes+=r[ee],this._state=wd,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(qr,this,a,s);return}this._bufferedBytes-=r[ee];let o=qe(i);n?this.dispatch(o,n,r,s):(this._state=ie,this.sendFrame(t.frame(o,r),s),this.dequeue())}).catch(i=>{process.nextTick(Sd,this,i,s)})}dispatch(e,n,r,s){if(!n){this.sendFrame(t.frame(e,r),s);return}let i=this._extensions[lo.extensionName];this._bufferedBytes+=r[ee],this._state=_d,i.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");qr(this,l,s);return}this._bufferedBytes-=r[ee],this._state=ie,r.readOnly=!1,this.sendFrame(t.frame(a,r),s),this.dequeue()})}dequeue(){for(;this._state===ie&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ee],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ee],this._queue.push(e)}sendFrame(e,n){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.write(e[0],n)}};uo.exports=jr;function qr(t,e,n){typeof n=="function"&&n(e);for(let r=0;r<t._queue.length;r++){let s=t._queue[r],i=s[s.length-1];typeof i=="function"&&i(e)}}function Sd(t,e,n){qr(t,e,n),t.onerror(e)}});var So=S((vy,wo)=>{"use strict";var{kForOnEventAttribute:Kt,kListener:Wr}=ye(),fo=Symbol("kCode"),po=Symbol("kData"),ho=Symbol("kError"),go=Symbol("kMessage"),mo=Symbol("kReason"),ht=Symbol("kTarget"),yo=Symbol("kType"),_o=Symbol("kWasClean"),we=class{constructor(e){this[ht]=null,this[yo]=e}get target(){return this[ht]}get type(){return this[yo]}};Object.defineProperty(we.prototype,"target",{enumerable:!0});Object.defineProperty(we.prototype,"type",{enumerable:!0});var We=class extends we{constructor(e,n={}){super(e),this[fo]=n.code===void 0?0:n.code,this[mo]=n.reason===void 0?"":n.reason,this[_o]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[fo]}get reason(){return this[mo]}get wasClean(){return this[_o]}};Object.defineProperty(We.prototype,"code",{enumerable:!0});Object.defineProperty(We.prototype,"reason",{enumerable:!0});Object.defineProperty(We.prototype,"wasClean",{enumerable:!0});var gt=class extends we{constructor(e,n={}){super(e),this[ho]=n.error===void 0?null:n.error,this[go]=n.message===void 0?"":n.message}get error(){return this[ho]}get message(){return this[go]}};Object.defineProperty(gt.prototype,"error",{enumerable:!0});Object.defineProperty(gt.prototype,"message",{enumerable:!0});var Wt=class extends we{constructor(e,n={}){super(e),this[po]=n.data===void 0?null:n.data}get data(){return this[po]}};Object.defineProperty(Wt.prototype,"data",{enumerable:!0});var Ed={addEventListener(t,e,n={}){for(let s of this.listeners(t))if(!n[Kt]&&s[Wr]===e&&!s[Kt])return;let r;if(t==="message")r=function(i,o){let a=new Wt("message",{data:o?i:i.toString()});a[ht]=this,Rn(e,this,a)};else if(t==="close")r=function(i,o){let a=new We("close",{code:i,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ht]=this,Rn(e,this,a)};else if(t==="error")r=function(i){let o=new gt("error",{error:i,message:i.message});o[ht]=this,Rn(e,this,o)};else if(t==="open")r=function(){let i=new we("open");i[ht]=this,Rn(e,this,i)};else return;r[Kt]=!!n[Kt],r[Wr]=e,n.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Wr]===e&&!n[Kt]){this.removeListener(t,n);break}}};wo.exports={CloseEvent:We,ErrorEvent:gt,Event:we,EventTarget:Ed,MessageEvent:Wt};function Rn(t,e,n){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Hr=S((Cy,Eo)=>{"use strict";var{tokenChars:Ht}=dt();function ce(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function bd(t){let e=Object.create(null),n=Object.create(null),r=!1,s=!1,i=!1,o,a,l=-1,c=-1,u=-1,p=0;for(;p<t.length;p++)if(c=t.charCodeAt(p),o===void 0)if(u===-1&&Ht[c]===1)l===-1&&(l=p);else if(p!==0&&(c===32||c===9))u===-1&&l!==-1&&(u=p);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=t.slice(l,u);c===44?(ce(e,f,n),n=Object.create(null)):o=f,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(u===-1&&Ht[c]===1)l===-1&&(l=p);else if(c===32||c===9)u===-1&&l!==-1&&(u=p);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p),ce(n,t.slice(l,u),!0),c===44&&(ce(e,o,n),n=Object.create(null),o=void 0),l=u=-1}else if(c===61&&l!==-1&&u===-1)a=t.slice(l,p),l=u=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(s){if(Ht[c]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);l===-1?l=p:r||(r=!0),s=!1}else if(i)if(Ht[c]===1)l===-1&&(l=p);else if(c===34&&l!==-1)i=!1,u=p;else if(c===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(c===34&&t.charCodeAt(p-1)===61)i=!0;else if(u===-1&&Ht[c]===1)l===-1&&(l=p);else if(l!==-1&&(c===32||c===9))u===-1&&(u=p);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=t.slice(l,u);r&&(f=f.replace(/\\/g,""),r=!1),ce(n,a,f),c===44&&(ce(e,o,n),n=Object.create(null),o=void 0),a=void 0,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(l===-1||i||c===32||c===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=p);let g=t.slice(l,u);return o===void 0?ce(e,g,n):(a===void 0?ce(n,g,!0):r?ce(n,a,g.replace(/\\/g,"")):ce(n,a,g),ce(e,o,n)),e}function Td(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(n)||(n=[n]),n.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(", ")}Eo.exports={format:Td,parse:bd}});var Nn=S((Ry,No)=>{"use strict";var kd=v("events"),vd=v("https"),Cd=v("http"),ko=v("net"),Id=v("tls"),{randomBytes:xd,createHash:Rd}=v("crypto"),{Duplex:Iy,Readable:xy}=v("stream"),{URL:Vr}=v("url"),ve=qt(),Pd=Fr(),Ad=Kr(),{isBlob:Od}=dt(),{BINARY_TYPES:bo,CLOSE_TIMEOUT:Nd,EMPTY_BUFFER:Pn,GUID:Ld,kForOnEventAttribute:Gr,kListener:Bd,kStatusCode:Md,kWebSocket:j,NOOP:vo}=ye(),{EventTarget:{addEventListener:Dd,removeEventListener:$d}}=So(),{format:Ud,parse:Fd}=Hr(),{toBuffer:jd}=Ft(),Co=Symbol("kAborted"),Yr=[8,13],Se=["CONNECTING","OPEN","CLOSING","CLOSED"],qd=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,L=class t extends kd{constructor(e,n,r){super(),this._binaryType=bo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Pn,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,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),Io(this,e,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){bo.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,n,r){let s=new Pd({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),i=new Ad(e,this._extensions,r.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[j]=this,i[j]=this,e[j]=this,s.on("conclude",Hd),s.on("drain",Vd),s.on("error",Gd),s.on("message",Yd),s.on("ping",zd),s.on("pong",Jd),i.onerror=Qd,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",Po),e.on("data",On),e.on("end",Ao),e.on("error",Oo),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[ve.extensionName]&&this._extensions[ve.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){J(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,n,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ro(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){zr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Pn,n,r)}pong(e,n,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){zr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(e||Pn,n,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){zr(this,e,r);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[ve.extensionName]||(s.compress=!1),this._sender.send(e||Pn,s,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){J(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(L,"CONNECTING",{enumerable:!0,value:Se.indexOf("CONNECTING")});Object.defineProperty(L.prototype,"CONNECTING",{enumerable:!0,value:Se.indexOf("CONNECTING")});Object.defineProperty(L,"OPEN",{enumerable:!0,value:Se.indexOf("OPEN")});Object.defineProperty(L.prototype,"OPEN",{enumerable:!0,value:Se.indexOf("OPEN")});Object.defineProperty(L,"CLOSING",{enumerable:!0,value:Se.indexOf("CLOSING")});Object.defineProperty(L.prototype,"CLOSING",{enumerable:!0,value:Se.indexOf("CLOSING")});Object.defineProperty(L,"CLOSED",{enumerable:!0,value:Se.indexOf("CLOSED")});Object.defineProperty(L.prototype,"CLOSED",{enumerable:!0,value:Se.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(L.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(L.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Gr])return e[Bd];return null},set(e){for(let n of this.listeners(t))if(n[Gr]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[Gr]:!0})}})});L.prototype.addEventListener=Dd;L.prototype.removeEventListener=$d;No.exports=L;function Io(t,e,n,r){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Nd,protocolVersion:Yr[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,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=s.autoPong,t._closeTimeout=s.closeTimeout,!Yr.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${Yr.join(", ")})`);let i;if(e instanceof Vr)i=e;else try{i=new Vr(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),t._url=i.href;let o=i.protocol==="wss:",a=i.protocol==="ws+unix:",l;if(i.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!i.pathname?l="The URL's pathname is empty":i.hash&&(l="The URL contains a fragment identifier"),l){let y=new SyntaxError(l);if(t._redirects===0)throw y;An(t,y);return}let c=o?443:80,u=xd(16).toString("base64"),p=o?vd.request:Cd.request,g=new Set,f;if(s.createConnection=s.createConnection||(o?Wd:Kd),s.defaultPort=s.defaultPort||c,s.port=i.port||c,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(f=new ve(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=Ud({[ve.extensionName]:f.offer()})),n.length){for(let y of n){if(typeof y!="string"||!qd.test(y)||g.has(y))throw new SyntaxError("An invalid or duplicated subprotocol was specified");g.add(y)}s.headers["Sec-WebSocket-Protocol"]=n.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 y=s.path.split(":");s.socketPath=y[0],s.path=y[1]}let h;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?s.socketPath:i.host;let y=r&&r.headers;if(r={...r,headers:{}},y)for(let[_,w]of Object.entries(y))r.headers[_.toLowerCase()]=w}else if(t.listenerCount("redirect")===0){let y=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:i.host===t._originalHostOrSocketPath;(!y||t._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,y||delete s.headers.host,s.auth=void 0)}s.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),h=t._req=p(s),t._redirects&&t.emit("redirect",t.url,h)}else h=t._req=p(s);s.timeout&&h.on("timeout",()=>{J(t,h,"Opening handshake has timed out")}),h.on("error",y=>{h===null||h[Co]||(h=t._req=null,An(t,y))}),h.on("response",y=>{let _=y.headers.location,w=y.statusCode;if(_&&s.followRedirects&&w>=300&&w<400){if(++t._redirects>s.maxRedirects){J(t,h,"Maximum redirects exceeded");return}h.abort();let R;try{R=new Vr(_,e)}catch{let T=new SyntaxError(`Invalid URL: ${_}`);An(t,T);return}Io(t,R,n,r)}else t.emit("unexpected-response",h,y)||J(t,h,`Unexpected server response: ${y.statusCode}`)}),h.on("upgrade",(y,_,w)=>{if(t.emit("upgrade",y),t.readyState!==L.CONNECTING)return;h=t._req=null;let R=y.headers.upgrade;if(R===void 0||R.toLowerCase()!=="websocket"){J(t,_,"Invalid Upgrade header");return}let B=Rd("sha1").update(u+Ld).digest("base64");if(y.headers["sec-websocket-accept"]!==B){J(t,_,"Invalid Sec-WebSocket-Accept header");return}let T=y.headers["sec-websocket-protocol"],E;if(T!==void 0?g.size?g.has(T)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":g.size&&(E="Server sent no subprotocol"),E){J(t,_,E);return}T&&(t._protocol=T);let b=y.headers["sec-websocket-extensions"];if(b!==void 0){if(!f){J(t,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Fd(b)}catch{J(t,_,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(C);if(A.length!==1||A[0]!==ve.extensionName){J(t,_,"Server indicated an extension that was not requested");return}try{f.accept(C[ve.extensionName])}catch{J(t,_,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ve.extensionName]=f}t.setSocket(_,w,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(h,t):h.end()}function An(t,e){t._readyState=L.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Kd(t){return t.path=t.socketPath,ko.connect(t)}function Wd(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=ko.isIP(t.host)?"":t.host),Id.connect(t)}function J(t,e,n){t._readyState=L.CLOSING;let r=new Error(n);Error.captureStackTrace(r,J),e.setHeader?(e[Co]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(An,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function zr(t,e,n){if(e){let r=Od(e)?e.size:jd(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${Se[t.readyState]})`);process.nextTick(n,r)}}function Hd(t,e){let n=this[j];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[j]!==void 0&&(n._socket.removeListener("data",On),process.nextTick(xo,n._socket),t===1005?n.close():n.close(t,e))}function Vd(){let t=this[j];t.isPaused||t._socket.resume()}function Gd(t){let e=this[j];e._socket[j]!==void 0&&(e._socket.removeListener("data",On),process.nextTick(xo,e._socket),e.close(t[Md])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function To(){this[j].emitClose()}function Yd(t,e){this[j].emit("message",t,e)}function zd(t){let e=this[j];e._autoPong&&e.pong(t,!this._isServer,vo),e.emit("ping",t)}function Jd(t){this[j].emit("pong",t)}function xo(t){t.resume()}function Qd(t){let e=this[j];e.readyState!==L.CLOSED&&(e.readyState===L.OPEN&&(e._readyState=L.CLOSING,Ro(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ro(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Po(){let t=this[j];if(this.removeListener("close",Po),this.removeListener("data",On),this.removeListener("end",Ao),t._readyState=L.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[j]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",To),t._receiver.on("finish",To))}function On(t){this[j]._receiver.write(t)||this.pause()}function Ao(){let t=this[j];t._readyState=L.CLOSING,t._receiver.end(),this.end()}function Oo(){let t=this[j];this.removeListener("error",Oo),this.on("error",vo),t&&(t._readyState=L.CLOSING,this.destroy())}});var Do=S((Ay,Mo)=>{"use strict";var Py=Nn(),{Duplex:Zd}=v("stream");function Lo(t){t.emit("close")}function Xd(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Bo(t){this.removeListener("error",Bo),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function ef(t,e){let n=!0,r=new Zd({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(i,o){let a=!o&&r._readableState.objectMode?i.toString():i;r.push(a)||t.pause()}),t.once("error",function(i){r.destroyed||(n=!1,r.destroy(i))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(s,i){if(t.readyState===t.CLOSED){i(s),process.nextTick(Lo,r);return}let o=!1;t.once("error",function(l){o=!0,i(l)}),t.once("close",function(){o||i(s),process.nextTick(Lo,r)}),n&&t.terminate()},r._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(s,i,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(s,i,o)});return}t.send(s,o)},r.on("end",Xd),r.on("error",Bo),r}Mo.exports=ef});var Uo=S((Oy,$o)=>{"use strict";var{tokenChars:tf}=dt();function nf(t){let e=new Set,n=-1,r=-1,s=0;for(s;s<t.length;s++){let o=t.charCodeAt(s);if(r===-1&&tf[o]===1)n===-1&&(n=s);else if(s!==0&&(o===32||o===9))r===-1&&n!==-1&&(r=s);else if(o===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${s}`);r===-1&&(r=s);let a=t.slice(n,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let i=t.slice(n,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}$o.exports={parse:nf}});var Vo=S((Ly,Ho)=>{"use strict";var rf=v("events"),Ln=v("http"),{Duplex:Ny}=v("stream"),{createHash:sf}=v("crypto"),Fo=Hr(),He=qt(),of=Uo(),af=Nn(),{CLOSE_TIMEOUT:lf,GUID:cf,kWebSocket:uf}=ye(),df=/^[+/0-9A-Za-z]{22}==$/,jo=0,qo=1,Wo=2,Jr=class extends rf{constructor(e,n){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lf,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:af,...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=Ln.createServer((r,s)=>{let i=Ln.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,n)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=ff(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=jo}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===Wo){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Vt,this);return}if(e&&this.once("close",e),this._state!==qo)if(this._state=qo,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(Vt,this):process.nextTick(Vt,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{Vt(this)})}}shouldHandle(e){if(this.options.path){let n=e.url.indexOf("?");if((n!==-1?e.url.slice(0,n):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,n,r,s){n.on("error",Ko);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Ve(this,e,n,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Ve(this,e,n,400,"Invalid Upgrade header");return}if(i===void 0||!df.test(i)){Ve(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Ve(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Gt(n,400);return}let l=e.headers["sec-websocket-protocol"],c=new Set;if(l!==void 0)try{c=of.parse(l)}catch{Ve(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&u!==void 0){let g=new He(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=Fo.parse(u);f[He.extensionName]&&(g.accept(f[He.extensionName]),p[He.extensionName]=g)}catch{Ve(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let g={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(g,(f,h,y,_)=>{if(!f)return Gt(n,h||401,y,_);this.completeUpgrade(p,i,c,e,n,r,s)});return}if(!this.options.verifyClient(g))return Gt(n,401)}this.completeUpgrade(p,i,c,e,n,r,s)}completeUpgrade(e,n,r,s,i,o,a){if(!i.readable||!i.writable)return i.destroy();if(i[uf])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>jo)return Gt(i,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${sf("sha1").update(n+cf).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;p&&(c.push(`Sec-WebSocket-Protocol: ${p}`),u._protocol=p)}if(e[He.extensionName]){let p=e[He.extensionName].params,g=Fo.format({[He.extensionName]:[p]});c.push(`Sec-WebSocket-Extensions: ${g}`),u._extensions=e}this.emit("headers",c,s),i.write(c.concat(`\r
8
8
  `).join(`\r
9
9
  `)),i.removeListener("error",Ko),u.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Vt,this)})),a(u,s)}};Ho.exports=Jr;function ff(t,e){for(let n of Object.keys(e))t.on(n,e[n]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function Vt(t){t._state=Wo,t.emit("close")}function Ko(){this.destroy()}function Gt(t,e,n,r){n=n||Ln.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Ln.STATUS_CODES[e]}\r
10
10
  `+Object.keys(r).map(s=>`${s}: ${r[s]}`).join(`\r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beachviber/agent",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "BeachViber Agent — control Claude Code remotely from your phone",
5
5
  "type": "module",
6
6
  "license": "MIT",