sys-shim 0.0.1-6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("events"),t=require("https"),r=require("http"),n=require("net"),o=require("tls"),s=require("crypto"),i=require("stream"),a=require("url"),c=require("zlib"),u=require("fs"),l=require("path"),f=require("os"),h=require("buffer"),d=require("util");function p(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var _={},v={exports:{}};!function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports}(v);var m,y=v.exports,g={exports:{}},b={exports:{}},w={exports:{}};function x(){return m||(m=1,function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(w)),w.exports}var E,k,S,O={exports:{}};function N(){return E||(E=1,function(e){var t=x().default;e.exports=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(O)),O.exports}function P(){return k||(k=1,function(e){var t=x().default,r=N();e.exports=function(e){var n=r(e,"string");return"symbol"==t(n)?n:String(n)},e.exports.__esModule=!0,e.exports.default=e.exports}(b)),b.exports}function T(){return S||(S=1,function(e){var t=P();function r(e,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,t(o.key),o)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports}(g)),g.exports}var C,L={exports:{}};function R(){return C||(C=1,function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}(L)),L.exports}var j,I,A={exports:{}},M={exports:{}};function U(){return j||(j=1,function(e){function t(r,n){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(M)),M.exports}function D(){return I||(I=1,function(e){var t=U();e.exports=function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&t(e,r)},e.exports.__esModule=!0,e.exports.default=e.exports}(A)),A.exports}var B,F,$={exports:{}},W={exports:{}};function q(){return B||(B=1,function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}(W)),W.exports}function V(){return F||(F=1,function(e){var t=x().default,r=q();e.exports=function(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports}($)),$.exports}var G,Y={exports:{}};function z(){return G||(G=1,function(e){function t(r){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Y)),Y.exports}var H,K,X={},J={exports:{}};function Z(){return K?H:(K=1,H={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}})}var Q={exports:{}};function ee(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var te,re,ne,oe,se,ie,ae,ce,ue,le,fe,he={exports:{}};function de(){if(ne)return he.exports;ne=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:ee;return"function"==typeof e.addon?he.exports=e.addon.bind(e):he.exports=function(){if(re)return te;re=1;var e=u,t=l,r=f,n="function"==typeof __webpack_require__?__non_webpack_require__:ee,o=process.config&&process.config.variables||{},s=!!process.env.PREBUILDS_ONLY,i=process.versions.modules,a=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",c=process.env.npm_config_arch||r.arch(),h=process.env.npm_config_platform||r.platform(),d=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),p=process.env.ARM_VERSION||("arm64"===c?"8":o.arm_version)||"",_=(process.versions.uv||"").split(".")[0];function v(e){return n(v.resolve(e))}function m(t){try{return e.readdirSync(t)}catch(e){return[]}}function y(e,r){var n=m(e).filter(r);return n[0]&&t.join(e,n[0])}function g(e){return/\.node$/.test(e)}function b(e){var t=e.split("-");if(2===t.length){var r=t[0],n=t[1].split("+");if(r&&n.length&&n.every(Boolean))return{name:e,platform:r,architectures:n}}}function w(e,t){return function(r){return null!=r&&r.platform===e&&r.architectures.includes(t)}}function x(e,t){return e.architectures.length-t.architectures.length}function E(e){var t=e.split("."),r={file:e,specificity:0};if("node"===t.pop()){for(var n=0;n<t.length;n++){var o=t[n];if("node"===o||"electron"===o||"node-webkit"===o)r.runtime=o;else if("napi"===o)r.napi=!0;else if("abi"===o.slice(0,3))r.abi=o.slice(3);else if("uv"===o.slice(0,2))r.uv=o.slice(2);else if("armv"===o.slice(0,4))r.armv=o.slice(4);else{if("glibc"!==o&&"musl"!==o)continue;r.libc=o}r.specificity++}return r}}function k(e,t){return function(r){return!(null==r||r.runtime&&r.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(r)||r.abi&&r.abi!==t&&!r.napi||r.uv&&r.uv!==_||r.armv&&r.armv!==p||r.libc&&r.libc!==d)}}function S(e){return function(t,r){return t.runtime!==r.runtime?t.runtime===e?-1:1:t.abi!==r.abi?t.abi?-1:1:t.specificity!==r.specificity?t.specificity>r.specificity?-1:1:0}}return te=v,v.resolve=v.path=function(e){e=t.resolve(e||".");try{var r=n(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[r+"_PREBUILD"]&&(e=process.env[r+"_PREBUILD"])}catch(e){}if(!s){var o=y(t.join(e,"build/Release"),g);if(o)return o;var u=y(t.join(e,"build/Debug"),g);if(u)return u}var l=O(e);if(l)return l;var f=O(t.dirname(process.execPath));if(f)return f;var v=["platform="+h,"arch="+c,"runtime="+a,"abi="+i,"uv="+_,p?"armv="+p:"","libc="+d,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+v+"\n loaded from: "+e+"\n");function O(e){var r=m(t.join(e,"prebuilds")).map(b).filter(w(h,c)).sort(x)[0];if(r){var n=t.join(e,"prebuilds",r.name),o=m(n).map(E).filter(k(a,i)).sort(S(a))[0];return o?t.join(n,o.file):void 0}}},v.parseTags=E,v.matchTags=k,v.compareTags=S,v.parseTuple=b,v.matchTuple=w,v.compareTuples=x,te}(),he.exports}function pe(){if(ie)return Q.exports;ie=1;try{Q.exports=de()(__dirname)}catch(e){Q.exports=(se||(se=1,oe={mask:(e,t,r,n,o)=>{for(var s=0;s<o;s++)r[n+s]=e[s]^t[3&s]},unmask:(e,t)=>{const r=e.length;for(var n=0;n<r;n++)e[n]^=t[3&n]}}),oe)}return Q.exports}function _e(){if(ae)return J.exports;ae=1;const{EMPTY_BUFFER:e}=Z(),t=Buffer[Symbol.species];function r(e,t,r,n,o){for(let s=0;s<o;s++)r[n+s]=e[s]^t[3&s]}function n(e,t){for(let r=0;r<e.length;r++)e[r]^=t[3&r]}if(J.exports={concat:function(r,n){if(0===r.length)return e;if(1===r.length)return r[0];const o=Buffer.allocUnsafe(n);let s=0;for(let e=0;e<r.length;e++){const t=r[e];o.set(t,s),s+=t.length}return s<n?new t(o.buffer,o.byteOffset,s):o},mask:r,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(r){if(e.readOnly=!0,Buffer.isBuffer(r))return r;let n;return r instanceof ArrayBuffer?n=new t(r):ArrayBuffer.isView(r)?n=new t(r.buffer,r.byteOffset,r.byteLength):(n=Buffer.from(r),e.readOnly=!1),n},unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{const e=pe();J.exports.mask=function(t,n,o,s,i){i<48?r(t,n,o,s,i):e.mask(t,n,o,s,i)},J.exports.unmask=function(t,r){t.length<32?n(t,r):e.unmask(t,r)}}catch(e){}return J.exports}function ve(){if(fe)return le;fe=1;const e=c,t=_e(),r=function(){if(ue)return ce;ue=1;const e=Symbol("kDone"),t=Symbol("kRun");return ce=class{constructor(r){this[e]=()=>{this.pending--,this[t]()},this.concurrency=r||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[t]()}[t](){if(this.pending!==this.concurrency&&this.jobs.length){const t=this.jobs.shift();this.pending++,t(this[e])}}}}(),{kStatusCode:n}=Z(),o=Buffer[Symbol.species],s=Buffer.from([0,0,255,255]),i=Symbol("permessage-deflate"),a=Symbol("total-length"),u=Symbol("callback"),l=Symbol("buffers"),f=Symbol("error");let h;function d(e){this[l].push(e),this[a]+=e.length}function p(e){this[a]+=e.length,this[i]._maxPayload<1||this[a]<=this[i]._maxPayload?this[l].push(e):(this[f]=new RangeError("Max payload size exceeded"),this[f].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[f][n]=1009,this.removeListener("data",p),this.reset())}function _(e){this[i]._inflate=null,e[n]=1007,this[u](e)}return le=class{constructor(e,t,n){if(this._maxPayload=0|n,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!h){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;h=new r(e)}}static get extensionName(){return"permessage-deflate"}offer(){const 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:null==this._options.clientMaxWindowBits&&(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){const e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,r=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(r.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?r.client_max_window_bits=t.clientMaxWindowBits:!0!==r.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete r.client_max_window_bits,r}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let r=e[t];if(r.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(r=r[0],"client_max_window_bits"===t){if(!0!==r){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}else if("server_max_window_bits"===t){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==r)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}e[t]=r}))})),e}decompress(e,t,r){h.add((n=>{this._decompress(e,t,((e,t)=>{n(),r(e,t)}))}))}compress(e,t,r){h.add((n=>{this._compress(e,t,((e,t)=>{n(),r(e,t)}))}))}_decompress(r,n,o){const c=this._isServer?"client":"server";if(!this._inflate){const t=`${c}_max_window_bits`,r="number"!=typeof this.params[t]?e.Z_DEFAULT_WINDOWBITS:this.params[t];this._inflate=e.createInflateRaw({...this._options.zlibInflateOptions,windowBits:r}),this._inflate[i]=this,this._inflate[a]=0,this._inflate[l]=[],this._inflate.on("error",_),this._inflate.on("data",p)}this._inflate[u]=o,this._inflate.write(r),n&&this._inflate.write(s),this._inflate.flush((()=>{const e=this._inflate[f];if(e)return this._inflate.close(),this._inflate=null,void o(e);const r=t.concat(this._inflate[l],this._inflate[a]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[a]=0,this._inflate[l]=[],n&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,r)}))}_compress(r,n,s){const i=this._isServer?"server":"client";if(!this._deflate){const t=`${i}_max_window_bits`,r="number"!=typeof this.params[t]?e.Z_DEFAULT_WINDOWBITS:this.params[t];this._deflate=e.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:r}),this._deflate[a]=0,this._deflate[l]=[],this._deflate.on("data",d)}this._deflate[u]=s,this._deflate.write(r),this._deflate.flush(e.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=t.concat(this._deflate[l],this._deflate[a]);n&&(e=new o(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[a]=0,this._deflate[l]=[],n&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}}}var me,ye,ge,be,we,xe,Ee,ke,Se,Oe,Ne,Pe,Te,Ce,Le,Re,je,Ie,Ae,Me,Ue,De,Be,Fe={exports:{}},$e={exports:{}};function We(){if(ge)return $e.exports;ge=1;try{$e.exports=de()(__dirname)}catch(e){$e.exports=(ye||(ye=1,me=function(e){const t=e.length;let r=0;for(;r<t;)if(0==(128&e[r]))r++;else if(192==(224&e[r])){if(r+1===t||128!=(192&e[r+1])||192==(254&e[r]))return!1;r+=2}else if(224==(240&e[r])){if(r+2>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||224===e[r]&&128==(224&e[r+1])||237===e[r]&&160==(224&e[r+1]))return!1;r+=3}else{if(240!=(248&e[r]))return!1;if(r+3>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||128!=(192&e[r+3])||240===e[r]&&128==(240&e[r+1])||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}return!0}),me)}return $e.exports}function qe(){if(be)return Fe.exports;be=1;const{isUtf8:e}=h;function t(e){const t=e.length;let r=0;for(;r<t;)if(0==(128&e[r]))r++;else if(192==(224&e[r])){if(r+1===t||128!=(192&e[r+1])||192==(254&e[r]))return!1;r+=2}else if(224==(240&e[r])){if(r+2>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||224===e[r]&&128==(224&e[r+1])||237===e[r]&&160==(224&e[r+1]))return!1;r+=3}else{if(240!=(248&e[r]))return!1;if(r+3>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||128!=(192&e[r+3])||240===e[r]&&128==(240&e[r+1])||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}return!0}if(Fe.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:t,tokenChars:[0,0,0,0,0,0,0,0,0,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]},e)Fe.exports.isValidUTF8=function(r){return r.length<24?t(r):e(r)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=We();Fe.exports.isValidUTF8=function(r){return r.length<32?t(r):e(r)}}catch(e){}return Fe.exports}function Ve(){if(xe)return we;xe=1;const{Writable:e}=i,t=ve(),{BINARY_TYPES:r,EMPTY_BUFFER:n,kStatusCode:o,kWebSocket:s}=Z(),{concat:a,toArrayBuffer:c,unmask:u}=_e(),{isValidStatusCode:l,isValidUTF8:f}=qe(),h=Buffer[Symbol.species],d=Promise.resolve(),p="function"==typeof queueMicrotask?queueMicrotask:function(e){d.then(e).catch(v)};function _(e){throw e}function v(e){process.nextTick(_,e)}return we=class extends e{constructor(e={}){super(),this._allowSynchronousEvents=!!e.allowSynchronousEvents,this._binaryType=e.binaryType||r[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[s]=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=0}_write(e,t,r){if(8===this._opcode&&0==this._state)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){const t=this._buffers[0];return this._buffers[0]=new h(t.buffer,t.byteOffset+e,t.length-e),new h(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=new h(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const r=this.consume(2);if(0!=(48&r[0])){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const n=64==(64&r[0]);if(!n||this._extensions[t.extensionName]){if(this._fin=128==(128&r[0]),this._opcode=15&r[0],this._payloadLength=127&r[1],0===this._opcode){if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=n}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&r[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=n;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!=(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&u(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,r){this._extensions[t.extensionName].decompress(e,this._fin,((e,t)=>{if(e)return r(e);if(t.length){if(this._messageLength+=t.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void r(e)}this._fragments.push(t)}this.dataMessage(r),0===this._state&&this.startLoop(r)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let n;n="nodebuffer"===this._binaryType?a(r,t):"arraybuffer"===this._binaryType?c(a(r,t)):r,5===this._state||this._allowSynchronousEvents?(this.emit("message",n,!0),this._state=0):(this._state=6,p((()=>{this.emit("message",n,!0),this._state=0,this.startLoop(e)})))}else{const n=a(r,t);if(!this._skipUTF8Validation&&!f(n)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",n,!1),this._state=0):(this._state=6,p((()=>{this.emit("message",n,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,p((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,n),this.end();else{const r=e.readUInt16BE(0);if(!l(r)){const e=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const n=new h(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!f(n)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",r,n),this.end()}this._state=0}}createError(e,t,r,n,s){this._loop=!1,this._errored=!0;const i=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=s,i[o]=n,i}}}function Ge(){if(ke)return Ee;ke=1;const{randomFillSync:e}=s,t=ve(),{EMPTY_BUFFER:r}=Z(),{isValidStatusCode:n}=qe(),{mask:o,toBuffer:i}=_e(),a=Symbol("kByteLength"),c=Buffer.alloc(4);class u{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(t,r){let n,s,i=!1,u=2,l=!1;r.mask&&(n=r.maskBuffer||c,r.generateMask?r.generateMask(n):e(n,0,4),l=0==(n[0]|n[1]|n[2]|n[3]),u=6),"string"==typeof t?s=r.mask&&!l||void 0===r[a]?(t=Buffer.from(t)).length:r[a]:(s=t.length,i=r.mask&&r.readOnly&&!l);let f=s;s>=65536?(u+=8,f=127):s>125&&(u+=2,f=126);const h=Buffer.allocUnsafe(i?s+u:u);return h[0]=r.fin?128|r.opcode:r.opcode,r.rsv1&&(h[0]|=64),h[1]=f,126===f?h.writeUInt16BE(s,2):127===f&&(h[2]=h[3]=0,h.writeUIntBE(s,4,6)),r.mask?(h[1]|=128,h[u-4]=n[0],h[u-3]=n[1],h[u-2]=n[2],h[u-1]=n[3],l?[h,t]:i?(o(t,n,h,u,s),[h]):(o(t,n,t,0,s),[h,t])):[h,t]}close(e,t,o,s){let i;if(void 0===e)i=r;else{if("number"!=typeof e||!n(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const r=Buffer.byteLength(t);if(r>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+r),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const c={[a]:i.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,i,!1,c,s]):this.sendFrame(u.frame(i,c),s)}ping(e,t,r){let n,o;if("string"==typeof e?(n=Buffer.byteLength(e),o=!1):(n=(e=i(e)).length,o=i.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");const s={[a]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,s,r]):this.sendFrame(u.frame(e,s),r)}pong(e,t,r){let n,o;if("string"==typeof e?(n=Buffer.byteLength(e),o=!1):(n=(e=i(e)).length,o=i.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");const s={[a]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,s,r]):this.sendFrame(u.frame(e,s),r)}send(e,r,n){const o=this._extensions[t.extensionName];let s,c,l=r.binary?2:1,f=r.compress;if("string"==typeof e?(s=Buffer.byteLength(e),c=!1):(s=(e=i(e)).length,c=i.readOnly),this._firstFragment?(this._firstFragment=!1,f&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=s>=o._threshold),this._compress=f):(f=!1,l=0),r.fin&&(this._firstFragment=!0),o){const t={[a]:s,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:l,readOnly:c,rsv1:f};this._deflating?this.enqueue([this.dispatch,e,this._compress,t,n]):this.dispatch(e,this._compress,t,n)}else this.sendFrame(u.frame(e,{[a]:s,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:l,readOnly:c,rsv1:!1}),n)}dispatch(e,r,n,o){if(!r)return void this.sendFrame(u.frame(e,n),o);const s=this._extensions[t.extensionName];this._bufferedBytes+=n[a],this._deflating=!0,s.compress(e,n.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof o&&o(e);for(let t=0;t<this._queue.length;t++){const r=this._queue[t],n=r[r.length-1];"function"==typeof n&&n(e)}}else this._bufferedBytes-=n[a],this._deflating=!1,n.readOnly=!1,this.sendFrame(u.frame(t,n),o),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][a],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][a],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}return Ee=u}function Ye(){if(Pe)return Ne;Pe=1;const{tokenChars:e}=qe();function t(e,t,r){void 0===e[t]?e[t]=[r]:e[t].push(r)}return Ne={format:function(e){return Object.keys(e).map((t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map((e=>[t].concat(Object.keys(e).map((t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(r){const n=Object.create(null);let o,s,i=Object.create(null),a=!1,c=!1,u=!1,l=-1,f=-1,h=-1,d=0;for(;d<r.length;d++)if(f=r.charCodeAt(d),void 0===o)if(-1===h&&1===e[f])-1===l&&(l=d);else if(0===d||32!==f&&9!==f){if(59!==f&&44!==f)throw new SyntaxError(`Unexpected character at index ${d}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===h&&(h=d);const e=r.slice(l,h);44===f?(t(n,e,i),i=Object.create(null)):o=e,l=h=-1}}else-1===h&&-1!==l&&(h=d);else if(void 0===s)if(-1===h&&1===e[f])-1===l&&(l=d);else if(32===f||9===f)-1===h&&-1!==l&&(h=d);else if(59===f||44===f){if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===h&&(h=d),t(i,r.slice(l,h),!0),44===f&&(t(n,o,i),i=Object.create(null),o=void 0),l=h=-1}else{if(61!==f||-1===l||-1!==h)throw new SyntaxError(`Unexpected character at index ${d}`);s=r.slice(l,d),l=h=-1}else if(c){if(1!==e[f])throw new SyntaxError(`Unexpected character at index ${d}`);-1===l?l=d:a||(a=!0),c=!1}else if(u)if(1===e[f])-1===l&&(l=d);else if(34===f&&-1!==l)u=!1,h=d;else{if(92!==f)throw new SyntaxError(`Unexpected character at index ${d}`);c=!0}else if(34===f&&61===r.charCodeAt(d-1))u=!0;else if(-1===h&&1===e[f])-1===l&&(l=d);else if(-1===l||32!==f&&9!==f){if(59!==f&&44!==f)throw new SyntaxError(`Unexpected character at index ${d}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===h&&(h=d);let e=r.slice(l,h);a&&(e=e.replace(/\\/g,""),a=!1),t(i,s,e),44===f&&(t(n,o,i),i=Object.create(null),o=void 0),s=void 0,l=h=-1}}else-1===h&&(h=d);if(-1===l||u||32===f||9===f)throw new SyntaxError("Unexpected end of input");-1===h&&(h=d);const p=r.slice(l,h);return void 0===o?t(n,p,i):(void 0===s?t(i,p,!0):t(i,s,a?p.replace(/\\/g,""):p),t(n,o,i)),n}},Ne}function ze(){if(Ce)return Te;Ce=1;const i=e,c=t,u=r,l=n,f=o,{randomBytes:h,createHash:d}=s,{URL:p}=a,_=ve(),v=Ve(),m=Ge(),{BINARY_TYPES:y,EMPTY_BUFFER:g,GUID:b,kForOnEventAttribute:w,kListener:x,kStatusCode:E,kWebSocket:k,NOOP:S}=Z(),{EventTarget:{addEventListener:O,removeEventListener:N}}=function(){if(Oe)return Se;Oe=1;const{kForOnEventAttribute:e,kListener:t}=Z(),r=Symbol("kCode"),n=Symbol("kData"),o=Symbol("kError"),s=Symbol("kMessage"),i=Symbol("kReason"),a=Symbol("kTarget"),c=Symbol("kType"),u=Symbol("kWasClean");class l{constructor(e){this[a]=null,this[c]=e}get target(){return this[a]}get type(){return this[c]}}Object.defineProperty(l.prototype,"target",{enumerable:!0}),Object.defineProperty(l.prototype,"type",{enumerable:!0});class f extends l{constructor(e,t={}){super(e),this[r]=void 0===t.code?0:t.code,this[i]=void 0===t.reason?"":t.reason,this[u]=void 0!==t.wasClean&&t.wasClean}get code(){return this[r]}get reason(){return this[i]}get wasClean(){return this[u]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class h extends l{constructor(e,t={}){super(e),this[o]=void 0===t.error?null:t.error,this[s]=void 0===t.message?"":t.message}get error(){return this[o]}get message(){return this[s]}}Object.defineProperty(h.prototype,"error",{enumerable:!0}),Object.defineProperty(h.prototype,"message",{enumerable:!0});class d extends l{constructor(e,t={}){super(e),this[n]=void 0===t.data?null:t.data}get data(){return this[n]}}Object.defineProperty(d.prototype,"data",{enumerable:!0});const p={addEventListener(r,n,o={}){for(const s of this.listeners(r))if(!o[e]&&s[t]===n&&!s[e])return;let s;if("message"===r)s=function(e,t){const r=new d("message",{data:t?e:e.toString()});r[a]=this,_(n,this,r)};else if("close"===r)s=function(e,t){const r=new f("close",{code:e,reason:t.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[a]=this,_(n,this,r)};else if("error"===r)s=function(e){const t=new h("error",{error:e,message:e.message});t[a]=this,_(n,this,t)};else{if("open"!==r)return;s=function(){const e=new l("open");e[a]=this,_(n,this,e)}}s[e]=!!o[e],s[t]=n,o.once?this.once(r,s):this.on(r,s)},removeEventListener(r,n){for(const o of this.listeners(r))if(o[t]===n&&!o[e]){this.removeListener(r,o);break}}};function _(e,t,r){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}return Se={CloseEvent:f,ErrorEvent:h,Event:l,EventTarget:p,MessageEvent:d}}(),{format:P,parse:T}=Ye(),{toBuffer:C}=_e(),L=Symbol("kAborted"),R=[8,13],j=["CONNECTING","OPEN","CLOSING","CLOSED"],I=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class A extends i{constructor(e,t,r){super(),this._binaryType=y[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=g,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=A.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(r=t,t=[]):t=[t]),M(this,e,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){y.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){const n=new v({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new m(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[k]=this,e[k]=this,n.on("conclude",W),n.on("drain",q),n.on("error",V),n.on("message",Y),n.on("ping",z),n.on("pong",H),e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",X),e.on("data",J),e.on("end",Q),e.on("error",ee),this._readyState=A.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=A.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[_.extensionName]&&this._extensions[_.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=A.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==A.CLOSED)if(this.readyState!==A.CONNECTING)this.readyState!==A.CLOSING?(this._readyState=A.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";F(this,this._req,e)}}pause(){this.readyState!==A.CONNECTING&&this.readyState!==A.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===A.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===A.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||g,t,r)):$(this,e,r)}pong(e,t,r){if(this.readyState===A.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===A.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||g,t,r)):$(this,e,r)}resume(){this.readyState!==A.CONNECTING&&this.readyState!==A.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===A.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(r=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==A.OPEN)return void $(this,e,r);const n={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[_.extensionName]||(n.compress=!1),this._sender.send(e||g,n,r)}terminate(){if(this.readyState!==A.CLOSED)if(this.readyState!==A.CONNECTING)this._socket&&(this._readyState=A.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";F(this,this._req,e)}}}function M(e,t,r,n){const o={allowSynchronousEvents:!1,autoPong:!0,protocolVersion:R[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,!R.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${R.join(", ")})`);let s;if(t instanceof p)s=t;else try{s=new p(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),e._url=s.href;const i="wss:"===s.protocol,a="ws+unix:"===s.protocol;let l;if("ws:"===s.protocol||i||a?a&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"):l='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',l){const t=new SyntaxError(l);if(0===e._redirects)throw t;return void U(e,t)}const f=i?443:80,v=h(16).toString("base64"),m=i?c.request:u.request,y=new Set;let g,w;if(o.createConnection=i?B:D,o.defaultPort=o.defaultPort||f,o.port=s.port||f,o.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":v,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(g=new _(!0!==o.perMessageDeflate?o.perMessageDeflate:{},!1,o.maxPayload),o.headers["Sec-WebSocket-Extensions"]=P({[_.extensionName]:g.offer()})),r.length){for(const e of r){if("string"!=typeof e||!I.test(e)||y.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(e)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),a){const e=o.path.split(":");o.socketPath=e[0],o.path=e[1]}if(o.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=i,e._originalHostOrSocketPath=a?o.socketPath:s.host;const t=n&&n.headers;if(n={...n,headers:{}},t)for(const[e,r]of Object.entries(t))n.headers[e.toLowerCase()]=r}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&o.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),w=e._req=m(o),e._redirects&&e.emit("redirect",e.url,w)}else w=e._req=m(o);o.timeout&&w.on("timeout",(()=>{F(e,w,"Opening handshake has timed out")})),w.on("error",(t=>{null===w||w[L]||(w=e._req=null,U(e,t))})),w.on("response",(s=>{const i=s.headers.location,a=s.statusCode;if(i&&o.followRedirects&&a>=300&&a<400){if(++e._redirects>o.maxRedirects)return void F(e,w,"Maximum redirects exceeded");let s;w.abort();try{s=new p(i,t)}catch(t){const r=new SyntaxError(`Invalid URL: ${i}`);return void U(e,r)}M(e,s,r,n)}else e.emit("unexpected-response",w,s)||F(e,w,`Unexpected server response: ${s.statusCode}`)})),w.on("upgrade",((t,r,n)=>{if(e.emit("upgrade",t),e.readyState!==A.CONNECTING)return;if(w=e._req=null,"websocket"!==t.headers.upgrade.toLowerCase())return void F(e,r,"Invalid Upgrade header");const s=d("sha1").update(v+b).digest("base64");if(t.headers["sec-websocket-accept"]!==s)return void F(e,r,"Invalid Sec-WebSocket-Accept header");const i=t.headers["sec-websocket-protocol"];let a;if(void 0!==i?y.size?y.has(i)||(a="Server sent an invalid subprotocol"):a="Server sent a subprotocol but none was requested":y.size&&(a="Server sent no subprotocol"),a)return void F(e,r,a);i&&(e._protocol=i);const c=t.headers["sec-websocket-extensions"];if(void 0!==c){if(!g){return void F(e,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=T(c)}catch(t){return void F(e,r,"Invalid Sec-WebSocket-Extensions header")}const n=Object.keys(t);if(1!==n.length||n[0]!==_.extensionName){return void F(e,r,"Server indicated an extension that was not requested")}try{g.accept(t[_.extensionName])}catch(t){return void F(e,r,"Invalid Sec-WebSocket-Extensions header")}e._extensions[_.extensionName]=g}e.setSocket(r,n,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})})),o.finishRequest?o.finishRequest(w,e):w.end()}function U(e,t){e._readyState=A.CLOSING,e.emit("error",t),e.emitClose()}function D(e){return e.path=e.socketPath,l.connect(e)}function B(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=l.isIP(e.host)?"":e.host),f.connect(e)}function F(e,t,r){e._readyState=A.CLOSING;const n=new Error(r);Error.captureStackTrace(n,F),t.setHeader?(t[L]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(U,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function $(e,t,r){if(t){const r=C(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(r){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${j[e.readyState]})`);process.nextTick(r,t)}}function W(e,t){const r=this[k];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,void 0!==r._socket[k]&&(r._socket.removeListener("data",J),process.nextTick(K,r._socket),1005===e?r.close():r.close(e,t))}function q(){const e=this[k];e.isPaused||e._socket.resume()}function V(e){const t=this[k];void 0!==t._socket[k]&&(t._socket.removeListener("data",J),process.nextTick(K,t._socket),t.close(e[E])),t.emit("error",e)}function G(){this[k].emitClose()}function Y(e,t){this[k].emit("message",e,t)}function z(e){const t=this[k];t._autoPong&&t.pong(e,!this._isServer,S),t.emit("ping",e)}function H(e){this[k].emit("pong",e)}function K(e){e.resume()}function X(){const e=this[k];let t;this.removeListener("close",X),this.removeListener("data",J),this.removeListener("end",Q),e._readyState=A.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[k]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",G),e._receiver.on("finish",G))}function J(e){this[k]._receiver.write(e)||this.pause()}function Q(){const e=this[k];e._readyState=A.CLOSING,e._receiver.end(),this.end()}function ee(){const e=this[k];this.removeListener("error",ee),this.on("error",S),e&&(e._readyState=A.CLOSING,this.destroy())}return Object.defineProperty(A,"CONNECTING",{enumerable:!0,value:j.indexOf("CONNECTING")}),Object.defineProperty(A.prototype,"CONNECTING",{enumerable:!0,value:j.indexOf("CONNECTING")}),Object.defineProperty(A,"OPEN",{enumerable:!0,value:j.indexOf("OPEN")}),Object.defineProperty(A.prototype,"OPEN",{enumerable:!0,value:j.indexOf("OPEN")}),Object.defineProperty(A,"CLOSING",{enumerable:!0,value:j.indexOf("CLOSING")}),Object.defineProperty(A.prototype,"CLOSING",{enumerable:!0,value:j.indexOf("CLOSING")}),Object.defineProperty(A,"CLOSED",{enumerable:!0,value:j.indexOf("CLOSED")}),Object.defineProperty(A.prototype,"CLOSED",{enumerable:!0,value:j.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(A.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(A.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[w])return t[x];return null},set(t){for(const t of this.listeners(e))if(t[w]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[w]:!0})}})})),A.prototype.addEventListener=O,A.prototype.removeEventListener=N,Te=A}function He(){if(Ie)return je;Ie=1;const{tokenChars:e}=qe();return je={parse:function(t){const r=new Set;let n=-1,o=-1,s=0;for(;s<t.length;s++){const i=t.charCodeAt(s);if(-1===o&&1===e[i])-1===n&&(n=s);else if(0===s||32!==i&&9!==i){if(44!==i)throw new SyntaxError(`Unexpected character at index ${s}`);{if(-1===n)throw new SyntaxError(`Unexpected character at index ${s}`);-1===o&&(o=s);const e=t.slice(n,o);if(r.has(e))throw new SyntaxError(`The "${e}" subprotocol is duplicated`);r.add(e),n=o=-1}}else-1===o&&-1!==n&&(o=s)}if(-1===n||-1!==o)throw new SyntaxError("Unexpected end of input");const i=t.slice(n,s);if(r.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return r.add(i),r}},je}function Ke(){if(Me)return Ae;Me=1;const t=e,n=r,{createHash:o}=s,i=Ye(),a=ve(),c=He(),u=ze(),{GUID:l,kWebSocket:f}=Z(),h=/^[+/0-9A-Za-z]{22}==$/;function d(e){e._state=2,e.emit("close")}function p(){this.destroy()}function _(e,t,r,o){r=r||n.STATUS_CODES[t],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...o},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${n.STATUS_CODES[t]}\r\n`+Object.keys(o).map((e=>`${e}: ${o[e]}`)).join("\r\n")+"\r\n\r\n"+r)}function v(e,t,r,n,o){if(e.listenerCount("wsClientError")){const n=new Error(o);Error.captureStackTrace(n,v),e.emit("wsClientError",n,r,t)}else _(r,n,o)}return Ae=class extends t{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!1,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:u,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(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(null!=e.port?(this._server=n.createServer(((e,t)=>{const r=n.STATUS_CODES[426];t.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),t.end(r)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const r of Object.keys(t))e.on(r,t[r]);return function(){for(const r of Object.keys(t))e.removeListener(r,t[r])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,r,n)=>{this.handleUpgrade(t,r,n,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}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(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(d,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,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(d,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{d(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,n){t.on("error",p);const o=e.headers["sec-websocket-key"],s=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void v(this,e,t,405,"Invalid HTTP method")}if("websocket"!==e.headers.upgrade.toLowerCase()){return void v(this,e,t,400,"Invalid Upgrade header")}if(!o||!h.test(o)){return void v(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==s&&13!==s){return void v(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void _(t,400);const u=e.headers["sec-websocket-protocol"];let l=new Set;if(void 0!==u)try{l=c.parse(u)}catch(r){return void v(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const f=e.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&void 0!==f){const r=new a(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=i.parse(f);e[a.extensionName]&&(r.accept(e[a.extensionName]),d[a.extensionName]=r)}catch(r){return void v(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const i={origin:e.headers[""+(8===s?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(i,((s,i,a,c)=>{if(!s)return _(t,i||401,a,c);this.completeUpgrade(d,o,l,e,t,r,n)}));if(!this.options.verifyClient(i))return _(t,401)}this.completeUpgrade(d,o,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,c,u){if(!s.readable||!s.writable)return s.destroy();if(s[f])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return _(s,503);const h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o("sha1").update(t+l).digest("base64")}`],v=new this.options.WebSocket(null,void 0,this.options);if(r.size){const e=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;e&&(h.push(`Sec-WebSocket-Protocol: ${e}`),v._protocol=e)}if(e[a.extensionName]){const t=e[a.extensionName].params,r=i.format({[a.extensionName]:[t]});h.push(`Sec-WebSocket-Extensions: ${r}`),v._extensions=e}this.emit("headers",h,n),s.write(h.concat("\r\n").join("\r\n")),s.removeListener("error",p),v.setSocket(s,c,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(v),v.on("close",(()=>{this.clients.delete(v),this._shouldEmitClose&&!this.clients.size&&process.nextTick(d,this)}))),u(v,n)}},Ae}function Xe(){if(De)return Ue;De=1;const e=ze();return e.createWebSocketStream=function(){if(Re)return Le;Re=1;const{Duplex:e}=i;function t(e){e.emit("close")}function r(){!this.destroyed&&this._writableState.finished&&this.destroy()}function n(e){this.removeListener("error",n),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}return Le=function(o,s){let i=!0;const a=new e({...s,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return o.on("message",(function(e,t){const r=!t&&a._readableState.objectMode?e.toString():e;a.push(r)||o.pause()})),o.once("error",(function(e){a.destroyed||(i=!1,a.destroy(e))})),o.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(e,r){if(o.readyState===o.CLOSED)return r(e),void process.nextTick(t,a);let n=!1;o.once("error",(function(e){n=!0,r(e)})),o.once("close",(function(){n||r(e),process.nextTick(t,a)})),i&&o.terminate()},a._final=function(e){o.readyState!==o.CONNECTING?null!==o._socket&&(o._socket._writableState.finished?(e(),a._readableState.endEmitted&&a.destroy()):(o._socket.once("finish",(function(){e()})),o.close())):o.once("open",(function(){a._final(e)}))},a._read=function(){o.isPaused&&o.resume()},a._write=function(e,t,r){o.readyState!==o.CONNECTING?o.send(e,r):o.once("open",(function(){a._write(e,t,r)}))},a.on("end",r),a.on("error",n),a},Le}(),e.Server=Ke(),e.Receiver=Ve(),e.Sender=Ge(),e.WebSocket=e,e.WebSocketServer=e.Server,Ue=e}var Je,Ze,Qe,et={},tt={exports:{}};function rt(){if(Qe)return Ze;Qe=1;var e=(Je||(Je=1,function(e){var t=x().default;function r(){e.exports=r=function(){return o},e.exports.__esModule=!0,e.exports.default=e.exports;var n,o={},s=Object.prototype,i=s.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(n){h=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,s=Object.create(o.prototype),i=new j(n||[]);return a(s,"_invoke",{value:T(e,r,i)}),s}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}o.wrap=d;var _="suspendedStart",v="suspendedYield",m="executing",y="completed",g={};function b(){}function w(){}function x(){}var E={};h(E,u,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(I([])));S&&S!==s&&i.call(S,u)&&(E=S);var O=x.prototype=b.prototype=Object.create(E);function N(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function P(e,r){function n(o,s,a,c){var u=p(e[o],e,s);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==t(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):r.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(e,t){function s(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(s,s):s()}})}function T(e,t,r){var o=_;return function(s,i){if(o===m)throw new Error("Generator is already running");if(o===y){if("throw"===s)throw i;return{value:n,done:!0}}for(r.method=s,r.arg=i;;){var a=r.delegate;if(a){var c=C(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===_)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=m;var u=p(e,t,r);if("normal"===u.type){if(o=r.done?y:v,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=y,r.method="throw",r.arg=u.arg)}}}function C(e,t){var r=t.method,o=e.iterator[r];if(o===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,C(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var s=p(o,e.iterator,t.arg);if("throw"===s.type)return t.method="throw",t.arg=s.arg,t.delegate=null,g;var i=s.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,g):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,s=function t(){for(;++o<e.length;)if(i.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=n,t.done=!0,t};return s.next=s}}throw new TypeError(t(e)+" is not iterable")}return w.prototype=x,a(O,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:w,configurable:!0}),w.displayName=h(x,f,"GeneratorFunction"),o.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,h(e,f,"GeneratorFunction")),e.prototype=Object.create(O),e},o.awrap=function(e){return{__await:e}},N(P.prototype),h(P.prototype,l,(function(){return this})),o.AsyncIterator=P,o.async=function(e,t,r,n,s){void 0===s&&(s=Promise);var i=new P(d(e,t,r,n),s);return o.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},N(O),h(O,f,"Generator"),h(O,u,(function(){return this})),h(O,"toString",(function(){return"[object Generator]"})),o.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},o.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,o){return a.type="throw",a.arg=e,t.next=r,o&&(t.method="next",t.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var c=i.call(s,"catchLoc"),u=i.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return r(s.catchLoc,!0);if(this.prev<s.finallyLoc)return r(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return r(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return r(s.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),g}},o}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(tt)),tt.exports)();Ze=e;try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return Ze}var nt,ot={exports:{}};function st(){return nt||(nt=1,function(e){function t(e,t,r,n,o,s,i){try{var a=e[s](i),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(o,s){var i=e.apply(r,n);function a(e){t(i,o,s,a,c,"next",e)}function c(e){t(i,o,s,a,c,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}(ot)),ot.exports}var it,at={exports:{}};function ct(){return it||(it=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,s||e,i),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,o,s,i){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,o),!0;case 5:return l.fn.call(l.context,t,n,o,s),!0;case 6:return l.fn.call(l.context,t,n,o,s,i),!0}for(u=1,c=new Array(f-1);u<f;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,d=l.length;for(u=0;u<d;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),f){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,o);break;default:if(!c)for(h=1,c=new Array(f-1);h<f;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,o){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return i(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||o&&!a.once||n&&a.context!==n||i(this,s);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&i(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(at)),at.exports}var ut,lt,ft={};function ht(){if(ut)return ft;ut=1;var e=y;Object.defineProperty(ft,"__esModule",{value:!0}),ft.DefaultDataPack=void 0,ft.createError=function(e,t){var r={code:e,message:n.get(e)||"Internal Server Error"};t&&(r.data=t);return r};var t=e(R()),r=e(T()),n=new Map([[-32e3,"Event not provided"],[-32600,"Invalid Request"],[-32601,"Method not found"],[-32602,"Invalid params"],[-32603,"Internal error"],[-32604,"Params not found"],[-32605,"Method forbidden"],[-32606,"Event forbidden"],[-32700,"Parse error"]]),o=function(){function e(){(0,t.default)(this,e)}return(0,r.default)(e,[{key:"encode",value:function(e){return JSON.stringify(e)}},{key:"decode",value:function(e){return JSON.parse(e)}}]),e}();return ft.DefaultDataPack=o,ft}function dt(){return lt||(lt=1,function(e){var t=y;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=t(rt()),n=t(st()),o=t(x()),s=t(R()),i=t(T()),a=t(D()),c=t(V()),u=t(z()),l=ct(),f=ht();function h(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=(0,u.default)(e);if(t){var o=(0,u.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,c.default)(this,r)}}var d=function(e){(0,a.default)(p,e);var t,c,u,l,d=h(p);function p(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;(0,s.default)(this,p);var a=n.autoconnect,c=void 0===a||a,u=n.reconnect,l=void 0===u||u,h=n.reconnect_interval,_=void 0===h?1e3:h,v=n.max_reconnects,m=void 0===v?5:v,y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(t=d.call(this)).webSocketFactory=e,t.queue={},t.rpc_id=0,t.address=r,t.autoconnect=c,t.ready=!1,t.reconnect=l,t.reconnect_timer_id=void 0,t.reconnect_interval=_,t.max_reconnects=m,t.rest_options=y,t.current_reconnects=0,t.generate_request_id=o||function(){return++t.rpc_id},t.dataPack=i||new f.DefaultDataPack,t.autoconnect&&t._connect(t.address,Object.assign({autoconnect:t.autoconnect,reconnect:t.reconnect,reconnect_interval:t.reconnect_interval,max_reconnects:t.max_reconnects},t.rest_options)),t}return(0,i.default)(p,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(e,t,r,n){var s=this;return n||"object"!==(0,o.default)(r)||(n=r,r=null),new Promise((function(o,i){if(!s.ready)return i(new Error("socket not ready"));var a=s.generate_request_id(e,t),c={jsonrpc:"2.0",method:e,params:t||void 0,id:a};s.socket.send(s.dataPack.encode(c),n,(function(e){if(e)return i(e);s.queue[a]={promise:[o,i]},r&&(s.queue[a].timeout=setTimeout((function(){delete s.queue[a],i(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:(l=(0,n.default)(r.default.mark((function e(t){var n;return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("rpc.login",t);case 2:if(n=e.sent){e.next=5;break}throw new Error("authentication failed");case 5:return e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"listMethods",value:(u=(0,n.default)(r.default.mark((function e(){return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("__listMethods");case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"notify",value:function(e,t){var r=this;return new Promise((function(n,o){if(!r.ready)return o(new Error("socket not ready"));var s={jsonrpc:"2.0",method:e,params:t};r.socket.send(r.dataPack.encode(s),(function(e){if(e)return o(e);n()}))}))}},{key:"subscribe",value:(c=(0,n.default)(r.default.mark((function e(t){var n;return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t&&(t=[t]),e.next=3,this.call("rpc.on",t);case 3:if(n=e.sent,"string"!=typeof t||"ok"===n[t]){e.next=6;break}throw new Error("Failed subscribing to an event '"+t+"' with: "+n[t]);case 6:return e.abrupt("return",n);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"unsubscribe",value:(t=(0,n.default)(r.default.mark((function e(t){var n;return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t&&(t=[t]),e.next=3,this.call("rpc.off",t);case 3:if(n=e.sent,"string"!=typeof t||"ok"===n[t]){e.next=6;break}throw new Error("Failed unsubscribing from an event with: "+n);case 6:return e.abrupt("return",n);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"close",value:function(e,t){this.socket.close(e||1e3,t)}},{key:"_connect",value:function(e,t){var r=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",(function(){r.ready=!0,r.emit("open"),r.current_reconnects=0})),this.socket.addEventListener("message",(function(e){var t=e.data;t instanceof ArrayBuffer&&(t=Buffer.from(t).toString());try{t=r.dataPack.decode(t)}catch(e){return}if(t.notification&&r.listeners(t.notification).length){if(!Object.keys(t.params).length)return r.emit(t.notification);var n=[t.notification];if(t.params.constructor===Object)n.push(t.params);else for(var o=0;o<t.params.length;o++)n.push(t.params[o]);return Promise.resolve().then((function(){r.emit.apply(r,n)}))}if(!r.queue[t.id])return t.method?Promise.resolve().then((function(){r.emit(t.method,null==t?void 0:t.params)})):void 0;"error"in t=="result"in t&&r.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),r.queue[t.id].timeout&&clearTimeout(r.queue[t.id].timeout),t.error?r.queue[t.id].promise[1](t.error):r.queue[t.id].promise[0](t.result),delete r.queue[t.id]})),this.socket.addEventListener("error",(function(e){return r.emit("error",e)})),this.socket.addEventListener("close",(function(n){var o=n.code,s=n.reason;r.ready&&setTimeout((function(){return r.emit("close",o,s)}),0),r.ready=!1,r.socket=void 0,1e3!==o&&(r.current_reconnects++,r.reconnect&&(r.max_reconnects>r.current_reconnects||0===r.max_reconnects)&&(r.reconnect_timer_id=setTimeout((function(){return r._connect(e,t)}),r.reconnect_interval)))}))}}]),p}(l.EventEmitter);e.default=d}(et)),et}var pt,_t={},vt={exports:{}};var mt,yt,gt={exports:{}},bt={exports:{}},wt={exports:{}};function xt(){return mt||(mt=1,function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports}(wt)),wt.exports}function Et(){return yt||(yt=1,function(e){var t=xt();e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(bt)),bt.exports}var kt,St={exports:{}};function Ot(){return kt||(kt=1,function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(St)),St.exports}var Nt,Pt={exports:{}};function Tt(){return Nt||(Nt=1,function(e){var t=xt();e.exports=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}(Pt)),Pt.exports}var Ct,Lt,Rt,jt={exports:{}};function It(){return Ct||(Ct=1,function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(jt)),jt.exports}var At=new Uint8Array(16);function Mt(){if(!Rt&&!(Rt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Rt(At)}var Ut=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Dt(e){return"string"==typeof e&&Ut.test(e)}for(var Bt,Ft,$t=[],Wt=0;Wt<256;++Wt)$t.push((Wt+256).toString(16).substr(1));function qt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=($t[e[t+0]]+$t[e[t+1]]+$t[e[t+2]]+$t[e[t+3]]+"-"+$t[e[t+4]]+$t[e[t+5]]+"-"+$t[e[t+6]]+$t[e[t+7]]+"-"+$t[e[t+8]]+$t[e[t+9]]+"-"+$t[e[t+10]]+$t[e[t+11]]+$t[e[t+12]]+$t[e[t+13]]+$t[e[t+14]]+$t[e[t+15]]).toLowerCase();if(!Dt(r))throw TypeError("Stringified UUID is invalid");return r}var Vt=0,Gt=0;function Yt(e){if(!Dt(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}function zt(e,t,r){function n(e,n,o,s){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof n&&(n=Yt(n)),16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var i=new Uint8Array(16+e.length);if(i.set(n),i.set(e,n.length),(i=r(i))[6]=15&i[6]|t,i[8]=63&i[8]|128,o){s=s||0;for(var a=0;a<16;++a)o[s+a]=i[a];return o}return qt(i)}try{n.name=e}catch(e){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function Ht(e){return 14+(e+64>>>9<<4)+1}function Kt(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function Xt(e,t,r,n,o,s){return Kt((i=Kt(Kt(t,e),Kt(n,s)))<<(a=o)|i>>>32-a,r);var i,a}function Jt(e,t,r,n,o,s,i){return Xt(t&r|~t&n,e,t,o,s,i)}function Zt(e,t,r,n,o,s,i){return Xt(t&n|r&~n,e,t,o,s,i)}function Qt(e,t,r,n,o,s,i){return Xt(t^r^n,e,t,o,s,i)}function er(e,t,r,n,o,s,i){return Xt(r^(t|~n),e,t,o,s,i)}var tr=zt("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var r=0;r<t.length;++r)e[r]=t.charCodeAt(r)}return function(e){for(var t=[],r=32*e.length,n="0123456789abcdef",o=0;o<r;o+=8){var s=e[o>>5]>>>o%32&255,i=parseInt(n.charAt(s>>>4&15)+n.charAt(15&s),16);t.push(i)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[Ht(t)-1]=t;for(var r=1732584193,n=-271733879,o=-1732584194,s=271733878,i=0;i<e.length;i+=16){var a=r,c=n,u=o,l=s;r=Jt(r,n,o,s,e[i],7,-680876936),s=Jt(s,r,n,o,e[i+1],12,-389564586),o=Jt(o,s,r,n,e[i+2],17,606105819),n=Jt(n,o,s,r,e[i+3],22,-1044525330),r=Jt(r,n,o,s,e[i+4],7,-176418897),s=Jt(s,r,n,o,e[i+5],12,1200080426),o=Jt(o,s,r,n,e[i+6],17,-1473231341),n=Jt(n,o,s,r,e[i+7],22,-45705983),r=Jt(r,n,o,s,e[i+8],7,1770035416),s=Jt(s,r,n,o,e[i+9],12,-1958414417),o=Jt(o,s,r,n,e[i+10],17,-42063),n=Jt(n,o,s,r,e[i+11],22,-1990404162),r=Jt(r,n,o,s,e[i+12],7,1804603682),s=Jt(s,r,n,o,e[i+13],12,-40341101),o=Jt(o,s,r,n,e[i+14],17,-1502002290),r=Zt(r,n=Jt(n,o,s,r,e[i+15],22,1236535329),o,s,e[i+1],5,-165796510),s=Zt(s,r,n,o,e[i+6],9,-1069501632),o=Zt(o,s,r,n,e[i+11],14,643717713),n=Zt(n,o,s,r,e[i],20,-373897302),r=Zt(r,n,o,s,e[i+5],5,-701558691),s=Zt(s,r,n,o,e[i+10],9,38016083),o=Zt(o,s,r,n,e[i+15],14,-660478335),n=Zt(n,o,s,r,e[i+4],20,-405537848),r=Zt(r,n,o,s,e[i+9],5,568446438),s=Zt(s,r,n,o,e[i+14],9,-1019803690),o=Zt(o,s,r,n,e[i+3],14,-187363961),n=Zt(n,o,s,r,e[i+8],20,1163531501),r=Zt(r,n,o,s,e[i+13],5,-1444681467),s=Zt(s,r,n,o,e[i+2],9,-51403784),o=Zt(o,s,r,n,e[i+7],14,1735328473),r=Qt(r,n=Zt(n,o,s,r,e[i+12],20,-1926607734),o,s,e[i+5],4,-378558),s=Qt(s,r,n,o,e[i+8],11,-2022574463),o=Qt(o,s,r,n,e[i+11],16,1839030562),n=Qt(n,o,s,r,e[i+14],23,-35309556),r=Qt(r,n,o,s,e[i+1],4,-1530992060),s=Qt(s,r,n,o,e[i+4],11,1272893353),o=Qt(o,s,r,n,e[i+7],16,-155497632),n=Qt(n,o,s,r,e[i+10],23,-1094730640),r=Qt(r,n,o,s,e[i+13],4,681279174),s=Qt(s,r,n,o,e[i],11,-358537222),o=Qt(o,s,r,n,e[i+3],16,-722521979),n=Qt(n,o,s,r,e[i+6],23,76029189),r=Qt(r,n,o,s,e[i+9],4,-640364487),s=Qt(s,r,n,o,e[i+12],11,-421815835),o=Qt(o,s,r,n,e[i+15],16,530742520),r=er(r,n=Qt(n,o,s,r,e[i+2],23,-995338651),o,s,e[i],6,-198630844),s=er(s,r,n,o,e[i+7],10,1126891415),o=er(o,s,r,n,e[i+14],15,-1416354905),n=er(n,o,s,r,e[i+5],21,-57434055),r=er(r,n,o,s,e[i+12],6,1700485571),s=er(s,r,n,o,e[i+3],10,-1894986606),o=er(o,s,r,n,e[i+10],15,-1051523),n=er(n,o,s,r,e[i+1],21,-2054922799),r=er(r,n,o,s,e[i+8],6,1873313359),s=er(s,r,n,o,e[i+15],10,-30611744),o=er(o,s,r,n,e[i+6],15,-1560198380),n=er(n,o,s,r,e[i+13],21,1309151649),r=er(r,n,o,s,e[i+4],6,-145523070),s=er(s,r,n,o,e[i+11],10,-1120210379),o=er(o,s,r,n,e[i+2],15,718787259),n=er(n,o,s,r,e[i+9],21,-343485551),r=Kt(r,a),n=Kt(n,c),o=Kt(o,u),s=Kt(s,l)}return[r,n,o,s]}(function(e){if(0===e.length)return[];for(var t=8*e.length,r=new Uint32Array(Ht(t)),n=0;n<t;n+=8)r[n>>5]|=(255&e[n/8])<<n%32;return r}(e),8*e.length))})),rr=tr;function nr(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function or(e,t){return e<<t|e>>>32-t}var sr=zt("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=[];for(var o=0;o<n.length;++o)e.push(n.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var s=e.length/4+2,i=Math.ceil(s/16),a=new Array(i),c=0;c<i;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];a[c]=u}a[i-1][14]=8*(e.length-1)/Math.pow(2,32),a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=8*(e.length-1)&4294967295;for(var f=0;f<i;++f){for(var h=new Uint32Array(80),d=0;d<16;++d)h[d]=a[f][d];for(var p=16;p<80;++p)h[p]=or(h[p-3]^h[p-8]^h[p-14]^h[p-16],1);for(var _=r[0],v=r[1],m=r[2],y=r[3],g=r[4],b=0;b<80;++b){var w=Math.floor(b/20),x=or(_,5)+nr(w,v,m,y)+g+t[w]+h[b]>>>0;g=y,y=m,m=or(v,30)>>>0,v=_,_=x}r[0]=r[0]+_>>>0,r[1]=r[1]+v>>>0,r[2]=r[2]+m>>>0,r[3]=r[3]+y>>>0,r[4]=r[4]+g>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]})),ir=sr;var ar,cr=Object.freeze({__proto__:null,NIL:"00000000-0000-0000-0000-000000000000",parse:Yt,stringify:qt,v1:function(e,t,r){var n=t&&r||0,o=t||new Array(16),s=(e=e||{}).node||Bt,i=void 0!==e.clockseq?e.clockseq:Ft;if(null==s||null==i){var a=e.random||(e.rng||Mt)();null==s&&(s=Bt=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==i&&(i=Ft=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:Gt+1,l=c-Vt+(u-Gt)/1e4;if(l<0&&void 0===e.clockseq&&(i=i+1&16383),(l<0||c>Vt)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Vt=c,Gt=u,Ft=i;var f=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[n++]=f>>>24&255,o[n++]=f>>>16&255,o[n++]=f>>>8&255,o[n++]=255&f;var h=c/4294967296*1e4&268435455;o[n++]=h>>>8&255,o[n++]=255&h,o[n++]=h>>>24&15|16,o[n++]=h>>>16&255,o[n++]=i>>>8|128,o[n++]=255&i;for(var d=0;d<6;++d)o[n+d]=s[d];return t||qt(o)},v3:rr,v4:function(e,t,r){var n=(e=e||{}).random||(e.rng||Mt)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=n[o];return t}return qt(n)},v5:ir,validate:Dt,version:function(e){if(!Dt(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}}),ur=p(cr);function lr(){return ar||(ar=1,function(e){var t=y,r=x();Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(rt()),o=t(x()),s=t(st()),i=t((pt||(pt=1,function(e){var t=P();e.exports=function(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports}(vt)),vt.exports)),c=t((Lt||(Lt=1,function(e){var t=Et(),r=Ot(),n=Tt(),o=It();e.exports=function(e){return t(e)||r(e)||n(e)||o()},e.exports.__esModule=!0,e.exports.default=e.exports}(gt)),gt.exports)),u=t(R()),l=t(T()),f=t(D()),h=t(V()),d=t(z()),p=ct(),_=Xe(),v=ur,m=t(a),g=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var n=b(t);if(n&&n.has(e))return n.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=s?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(o,i,a):o[i]=e[i]}o.default=e,n&&n.set(e,o);return o}(ht());function b(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(b=function(e){return e?r:t})(e)}function w(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){a=!0,s=e},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw s}}}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function k(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=(0,d.default)(e);if(t){var o=(0,d.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,h.default)(this,r)}}var S=function(e){(0,f.default)(a,e);var t,r=k(a);function a(e,t){var n;return(0,u.default)(this,a),(n=r.call(this)).namespaces={},n.dataPack=t||new g.DefaultDataPack,n.wss=new _.Server(e),n.wss.on("listening",(function(){return n.emit("listening")})),n.wss.on("connection",(function(e,t){var r=m.default.parse(t.url,!0),o=r.pathname;return r.query.socket_id?e._id=r.query.socket_id:e._id=(0,v.v1)(),e._authenticated=!1,e.on("error",(function(t){return n.emit("socket-error",e,t)})),e.on("close",(function(){n.namespaces[o].clients.delete(e._id);for(var t=0,r=Object.keys(n.namespaces[o].events);t<r.length;t++){var s=r[t],i=n.namespaces[o].events[s].sockets.indexOf(e._id);i>=0&&n.namespaces[o].events[s].sockets.splice(i,1)}n.emit("disconnection",e)})),n.namespaces[o]||n._generateNamespace(o),n.namespaces[o].clients.set(e._id,e),n.emit("connection",e,t),n._handleRPC(e,o)})),n.wss.on("error",(function(e){return n.emit("error",e)})),n}return(0,l.default)(a,[{key:"register",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"/";return this.namespaces[n]||this._generateNamespace(n),this.namespaces[n].rpc_methods[e]={fn:t,protected:!1},{protected:function(){return r._makeProtectedMethod(e,n)},public:function(){return r._makePublicMethod(e,n)}}}},{key:"setAuth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";this.register("rpc.login",e,t)}},{key:"_makeProtectedMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";this.namespaces[t].rpc_methods[e].protected=!0}},{key:"_makePublicMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";this.namespaces[t].rpc_methods[e].protected=!1}},{key:"_makeProtectedEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";this.namespaces[t].events[e].protected=!0}},{key:"_makePublicEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";this.namespaces[t].events[e].protected=!1}},{key:"closeNamespace",value:function(e){var t=this.namespaces[e];if(t){delete t.rpc_methods,delete t.events;var r,n=w(t.clients.values());try{for(n.s();!(r=n.n()).done;){r.value.close()}}catch(e){n.e(e)}finally{n.f()}delete this.namespaces[e]}}},{key:"event",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";if(this.namespaces[r]){if(void 0!==this.namespaces[r].events[e])throw new Error("Already registered event ".concat(r).concat(e))}else this._generateNamespace(r);return this.namespaces[r].events[e]={sockets:[],protected:!1},this.on(e,(function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];1===o.length&&o[0]instanceof Object&&(o=o[0]);var i,a=w(t.namespaces[r].events[e].sockets);try{for(a.s();!(i=a.n()).done;){var c=i.value,u=t.namespaces[r].clients.get(c);u&&u.send(t.dataPack.encode({notification:e,params:o}))}}catch(e){a.e(e)}finally{a.f()}})),{protected:function(){return t._makeProtectedEvent(e,r)},public:function(){return t._makePublicEvent(e,r)}}}},{key:"of",value:function(e){this.namespaces[e]||this._generateNamespace(e);var t=this;return{register:function(r,n){if(2!==arguments.length)throw new Error("must provide exactly two arguments");if("string"!=typeof r)throw new Error("name must be a string");if("function"!=typeof n)throw new Error("handler must be a function");return t.register(r,n,e)},event:function(r){if(1!==arguments.length)throw new Error("must provide exactly one argument");if("string"!=typeof r)throw new Error("name must be a string");return t.event(r,e)},get eventList(){return Object.keys(t.namespaces[e].events)},emit:function(r){for(var n=(0,c.default)(t.namespaces[e].clients.keys()),o=arguments.length,s=new Array(o>1?o-1:0),i=1;i<o;i++)s[i-1]=arguments[i];for(var a,u=0;a=n[u];++u)t.namespaces[e].clients.get(a).send(t.dataPack.encode({notification:r,params:s||[]}))},get name(){return e},connected:function(){return(0,c.default)(t.namespaces[e].clients.keys()).reduce((function(r,n){return Object.assign(Object.assign({},r),(0,i.default)({},n,t.namespaces[e].clients.get(n)))}),{})},clients:function(){return t.namespaces[e]}}}},{key:"eventList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/";return this.namespaces[e]?Object.keys(this.namespaces[e].events):[]}},{key:"createError",value:function(e,t,r){return{code:e,message:t,data:r||null}}},{key:"close",value:function(){var e=this;return new Promise((function(t,r){try{e.wss.close(),e.emit("close"),t()}catch(e){r(e)}}))}},{key:"_handleRPC",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";e.on("message",function(){var o=(0,s.default)(n.default.mark((function o(s){var i,a,c,u,l,f,h,d;return n.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(i={},s instanceof ArrayBuffer&&(i.binary=!0,s=Buffer.from(s).toString()),1===e.readyState){n.next=4;break}return n.abrupt("return");case 4:n.prev=4,a=t.dataPack.decode(s),n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(4),n.abrupt("return",e.send(t.dataPack.encode({jsonrpc:"2.0",error:g.createError(-32700,n.t0.toString()),id:null}),i));case 11:if(!Array.isArray(a)){n.next=39;break}if(a.length){n.next=14;break}return n.abrupt("return",e.send(t.dataPack.encode({jsonrpc:"2.0",error:g.createError(-32600,"Invalid array"),id:null}),i));case 14:c=[],u=w(a),n.prev=16,u.s();case 18:if((l=u.n()).done){n.next=28;break}return f=l.value,n.next=22,t._runMethod(f,e._id,r);case 22:if(h=n.sent){n.next=25;break}return n.abrupt("continue",26);case 25:c.push(h);case 26:n.next=18;break;case 28:n.next=33;break;case 30:n.prev=30,n.t1=n.catch(16),u.e(n.t1);case 33:return n.prev=33,u.f(),n.finish(33);case 36:if(c.length){n.next=38;break}return n.abrupt("return");case 38:return n.abrupt("return",e.send(t.dataPack.encode(c),i));case 39:return n.next=41,t._runMethod(a,e._id,r);case 41:if(d=n.sent){n.next=44;break}return n.abrupt("return");case 44:return n.abrupt("return",e.send(t.dataPack.encode(d),i));case 45:case"end":return n.stop()}}),o,null,[[4,8],[16,30,33,36]])})));return function(e){return o.apply(this,arguments)}}())}},{key:"_runMethod",value:(t=(0,s.default)(n.default.mark((function e(t,r){var s,i,a,c,u,l,f,h,d,p,_,v,m,y,b,x=arguments;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=x.length>2&&void 0!==x[2]?x[2]:"/","object"===(0,o.default)(t)&&null!==t){e.next=3;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32600),id:null});case 3:if("2.0"===t.jsonrpc){e.next=5;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32600,"Invalid JSON RPC version"),id:t.id||null});case 5:if(t.method){e.next=7;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32602,"Method not specified"),id:t.id||null});case 7:if("string"==typeof t.method){e.next=9;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32600,"Invalid method name"),id:t.id||null});case 9:if(!t.params||"string"!=typeof t.params){e.next=11;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32600),id:t.id||null});case 11:if("rpc.on"!==t.method){e.next=47;break}if(t.params){e.next=14;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32e3),id:t.id||null});case 14:i={},a=Object.keys(this.namespaces[s].events),c=w(t.params),e.prev=17,c.s();case 19:if((u=c.n()).done){e.next=36;break}if(l=u.value,f=a.indexOf(l),h=this.namespaces[s],-1!==f){e.next=26;break}return i[l]="provided event invalid",e.abrupt("continue",34);case 26:if(!0!==h.events[a[f]].protected||!1!==h.clients.get(r)._authenticated){e.next=28;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32606),id:t.id||null});case 28:if(!(h.events[a[f]].sockets.indexOf(r)>=0)){e.next=32;break}return i[l]="socket has already been subscribed to event",e.abrupt("continue",34);case 32:h.events[a[f]].sockets.push(r),i[l]="ok";case 34:e.next=19;break;case 36:e.next=41;break;case 38:e.prev=38,e.t0=e.catch(17),c.e(e.t0);case 41:return e.prev=41,c.f(),e.finish(41);case 44:return e.abrupt("return",{jsonrpc:"2.0",result:i,id:t.id||null});case 47:if("rpc.off"!==t.method){e.next=78;break}if(t.params){e.next=50;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32e3),id:t.id||null});case 50:d={},p=w(t.params),e.prev=52,p.s();case 54:if((_=p.n()).done){e.next=67;break}if(v=_.value,this.namespaces[s].events[v]){e.next=59;break}return d[v]="provided event invalid",e.abrupt("continue",65);case 59:if(-1!==(m=this.namespaces[s].events[v].sockets.indexOf(r))){e.next=63;break}return d[v]="not subscribed",e.abrupt("continue",65);case 63:this.namespaces[s].events[v].sockets.splice(m,1),d[v]="ok";case 65:e.next=54;break;case 67:e.next=72;break;case 69:e.prev=69,e.t1=e.catch(52),p.e(e.t1);case 72:return e.prev=72,p.f(),e.finish(72);case 75:return e.abrupt("return",{jsonrpc:"2.0",result:d,id:t.id||null});case 78:if("rpc.login"!==t.method){e.next=81;break}if(t.params){e.next=81;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32604),id:t.id||null});case 81:if(this.namespaces[s].rpc_methods[t.method]){e.next=83;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32601),id:t.id||null});case 83:if(y=null,!0!==this.namespaces[s].rpc_methods[t.method].protected||!1!==this.namespaces[s].clients.get(r)._authenticated){e.next=86;break}return e.abrupt("return",{jsonrpc:"2.0",error:g.createError(-32605),id:t.id||null});case 86:return e.prev=86,e.next=89,this.namespaces[s].rpc_methods[t.method].fn(t.params,r);case 89:y=e.sent,e.next=99;break;case 92:if(e.prev=92,e.t2=e.catch(86),t.id){e.next=96;break}return e.abrupt("return");case 96:if(!(e.t2 instanceof Error)){e.next=98;break}return e.abrupt("return",{jsonrpc:"2.0",error:{code:-32e3,message:e.t2.name,data:e.t2.message},id:t.id});case 98:return e.abrupt("return",{jsonrpc:"2.0",error:e.t2,id:t.id});case 99:if(t.id){e.next=101;break}return e.abrupt("return");case 101:return"rpc.login"===t.method&&!0===y&&((b=this.namespaces[s].clients.get(r))._authenticated=!0,this.namespaces[s].clients.set(r,b)),e.abrupt("return",{jsonrpc:"2.0",result:y,id:t.id});case 103:case"end":return e.stop()}}),e,this,[[17,38,41,44],[52,69,72,75],[86,92]])}))),function(e,r){return t.apply(this,arguments)})},{key:"_generateNamespace",value:function(e){var t=this;this.namespaces[e]={rpc_methods:{__listMethods:{fn:function(){return Object.keys(t.namespaces[e].rpc_methods)},protected:!1}},clients:new Map,events:{}}}}]),a}(p.EventEmitter);e.default=S}(_t)),_t}function fr(e,t){const r=e.slice();return r.push(t),r}!function(e){var t=y;Object.defineProperty(e,"__esModule",{value:!0}),e.Client=void 0,Object.defineProperty(e,"Server",{enumerable:!0,get:function(){return u.default}});var r=t(T()),n=t(R()),o=t(D()),s=t(V()),i=t(z()),a=t((Be||(Be=1,function(e){var t=y;Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(e,t){return new r.default(e,t)};var r=t(Xe())}(X)),X)),c=t(dt()),u=t(lr());function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=(0,i.default)(e);if(t){var o=(0,i.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,s.default)(this,r)}}var f=function(e){(0,o.default)(s,e);var t=l(s);function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ws://localhost:8080",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;(0,n.default)(this,s);var i=r.autoconnect,c=void 0===i||i,u=r.reconnect,l=void 0===u||u,f=r.reconnect_interval,h=void 0===f?1e3:f,d=r.max_reconnects,p=void 0===d?5:d,_=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(r,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return t.call(this,a.default,e,Object.assign({autoconnect:c,reconnect:l,reconnect_interval:h,max_reconnects:p},_),o)}return(0,r.default)(s)}(c.default);e.Client=f}(_);const hr=["apply","construct","defineProperty","deleteProperty","enumerate","get","getOwnPropertyDescriptor","getPrototypeOf","has","isExtensible","ownKeys","preventExtensions","set","setPrototypeOf"],dr={get:1,set:1,deleteProperty:1,has:1,defineProperty:1,getOwnPropertyDescriptor:1};function pr(e,t,r){let n=[],o={};return void 0!==r&&void 0!==r.path&&(n=r.path.split(".")),void 0!==r&&void 0!==r.userData&&(o=r.userData),function r(n,s,i={}){const a={rootTarget:e,path:s};Object.assign(a,o,i);const c={};for(const n of hr){const o=dr[n],i=t[n];void 0!==i&&(c[n]=void 0!==o?function(){const t=arguments[o];return a.nest=function(n,{userData:o={}}={}){return void 0===n&&(n=e),r(n,fr(s,t),o)},i.apply(a,arguments)}:function(){return a.nest=function(e,{userData:t={}}={}){return void 0===e&&(e={}),r(e,s,t)},i.apply(a,arguments)})}return new Proxy(n,c)}(e,n)}const _r=new Map;function vr([e]){return _r.get(e)||e}function mr(e){const t=e.split("\n"),r=t.filter((e=>e.trim())).map((e=>e.match(/(^\s+)?/)[0].length)).sort(((e,t)=>e-t))[0];return t.map((e=>e.slice(r))).join("\n")}function yr(e){return[NaN,null,void 0,"",[],{}].some((t=>("string"!=typeof e||!e)&&JSON.stringify(e)===JSON.stringify(t)))}const gr="NE_FS_FILWRER",br="NE_FS_DIRCRER",wr="NE_FS_REMVERR",xr="NE_RT_NATPRME";function Er(e,t=""){switch(e){case"NE_ST_OK":return"";case"NE_ST_INVSTKY":return`Invalid storage key format. The key should match regex: ${t}`;case"NE_ST_NOSTKEX":return`Unable to find storage key: ${t}`;case"NE_ST_STKEYWE":return`Unable to write data to key: ${t}`;case"NE_ST_NOSTDIR":return`Unable to read storage directory: ${t}`;case"NE_OS_UNLTOUP":return`Unable to update process id: ${t}`;case"NE_OS_INVNOTA":return`Invalid notification style arguments: ${t}`;case"NE_OS_INVMSGA":return`Invalid message box style arguments: ${t}`;case"NE_OS_TRAYIER":return"Unable to initialize the tray menu";case"NE_OS_INVKNPT":return`Invalid platform path name: ${t}`;case"NE_EX_EXTNOTC":return`${t} is not connected yet`;case gr:return`Unable to write file: ${t}`;case br:return`Cannot create a directory in ${t}`;case wr:return`Cannot remove path: ${t}`;case"NE_FS_FILRDER":return`Unable to open file: ${t}`;case"NE_FS_NOPATHE":return`Unable to open path ${t}`;case"NE_FS_COPYERR":return`Cannot perform copy: ${t}`;case"NE_FS_MOVEERR":return`Cannot perform move: ${t}`;case"NE_FS_FILOPER":return`Unable to open file: ${t}`;case"NE_FS_UNLTOUP":return`Unable to update opened file id: ${t}`;case"NE_FS_UNLTFOP":return`Unable to find storage key: ${t}`;case"NE_FS_UNLCWAT":return`Unable to create watcher for path: ${t}`;case"NE_FS_NOWATID":return`Unable to find watcher: ${t}`;case"NE_CF_UNBLWCF":return`Unable to load the window config file: ${t}`;case"NE_RT_INVTOKN":return"Invalid or expired NL_TOKEN value from client";case"NE_RT_APIPRME":return"Missing permission to access Native API";case xr:return`Missing permission to execute the native method: ${t}`;case"NE_RT_NATRTER":return"Native method execution error occurred. Make sure that you've provided required parameters properly.";case"NE_RT_NATNTIM":return`${t} is not implemented in the Neutralinojs server`;case"NE_RS_TREEGER":return`Resource file tree generation error. ${t}is missing.`;case"NE_RS_UNBLDRE":return`Unable to load application resource file ${t}`;case"NE_SR_UNBSEND":return"Unable to send native message";case"NE_SR_UNBPARS":return"Unable to parse native call payload";case"NE_CF_UNBLDCF":return"Unable to load the config file: ${key}";case"NE_CF_UNSUPMD":return"Unsupported mode: ${key}. The default mode is selected."}}class kr{constructor(e,t=""){return{code:e,message:Er(e,t)}}}class Sr{constructor(e){this.base=e}async writeText(e){const[t,r]=await this.base.native.win.clip.write(e);if(t)throw new kr(xr,"clipboard.writeText");return r}async readText(){const[e,t]=await this.base.native.win.clip.read();if(e)throw new kr(xr,"clipboard.readText");return t}}class Or{constructor(e){this.base=e}async createDirectory(e){const[t,r]=await this.base.native.fsys.createDir(e);if(t)throw new kr(br,e);return r}async remove(e){const[t,r]=await this.base.native.fsys.remove(e);if(t)throw new kr(wr,e);return r}async writeFile(e,t){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, data = ...\n var file = io.open(filename, "w")\n file.write(data)\n file.close()\n return {\n success: true\n }\n ',e,t]);if(r)throw new kr(gr,"filesystem.writeFile");return n}async appendFile(e,t){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, data = ...\n var file = io.open(filename, "a") // a 为追加模式\n file.write(data)\n file.close()\n return {\n success: true\n }\n ',e,t]);if(r)throw new kr(gr,"filesystem.appendFile");return n}async writeBinaryFile(e,t){const r={type:"Buffer",data:[...new Int8Array(t)]};await globalThis.main.ws.call("run",["\n var filename, json = ...\n var buffer = raw.buffer(json)\n string.save(filename, buffer)\n ",e,r])}appendBinaryFile(e,t){console.warn("// todo")}async readFile(e,t={pos:void 0,size:void 0}){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, arg = ...\n var file = io.open(filename, "r")\n file.seek("cur", arg.pos)\n file.setvbuf("full", arg.size)\n var str = file.read()\n file.close()\n return str\n ',e,t]);if(r)throw new kr(gr,"filesystem.readFile");return n}async readBinaryFile(e,t={pos:void 0,size:void 0}){const[r,n]=await globalThis.main.native.string.loadBuffer(e),o=function(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e[t];return t}(n.data);return o}openFile(e){console.warn("// todo")}updateOpenedFile(e,t,r){console.warn("// todo")}}let Nr,Pr=class{constructor(e){this.base=e}async execCommand(e,t={background:void 0,stdIn:void 0,cwd:void 0}){const[r,n]=await globalThis.main.ws.call("run",["\n var cmd, options = ...\n var back = process.workDir\n if(options.cwd) {\n process.workDir = options.cwd\n }\n var proc = process.popen(cmd)\n process.workDir = back\n if(options.background) {\n return {\n stdOut = '',\n stdErr = '',\n pid = proc.process.id,\n exitCode = -1,\n proc = proc,\n }\n } else {\n return {\n stdOut = proc.read(-1),\n stdErr = proc.readErr(-1),\n pid = proc.process.id,\n exitCode = proc.getExitCode(),\n proc = proc,\n }\n }\n ",e,t]);return n}async getEnv(e){return(await this.base.native.string.getenv(e))[1]}async getEnvs(){const{stdOut:e}=await this.execCommand("cmd /c set");return e.split("\r\n").reduce(((e,t)=>{let[r,...n]=t.split("=");return e[r]=n.join(""),e}),{})}async showOpenDialog(e,t={defaultPath:void 0,filters:[]}){const r=(t.filters||[]).map((e=>`${e.name}|${e.extensions.map((e=>`*.${e}`)).join(";")}`)).join("|");return(await this.base.native.fsys.dlg.open(r,e,t.defaultPath))[1]}async showSaveDialog(e,t={defaultPath:void 0,forceOverwrite:void 0,filters:[]}){const r=(t.filters||[]).map((e=>`${e.name}|${e.extensions.map((e=>`*.${e}`)).join(";")}`)).join("|");return(await this.base.native.fsys.dlg[t.forceOverwrite?"save":"saveOp"](r,e,t.defaultPath))[1]}async showFolderDialog(e,t={defaultPath:void 0}){return(await this.base.native.fsys.dlg.dir(t.defaultPath,void 0,e))[1]}async showMessageBox(e,t,r="OK",n="INFO"){const o={OK:0,OK_CANCEL:1,YES_NO:4,YES_NO_CANCEL:3,RETRY_CANCEL:5,ABORT_RETRY_IGNORE:2},s={INFO:64,WARNING:48,ERROR:16,QUESTION:32},i={ABORT:3,CANCEL:2,CONTINUE:11,IGNORE:5,NO:7,OK:1,RETRY:4,TRYAGAIN:10,YES:6},a=(await this.base.native.win.msgbox(t,e,o[r]|s[n]))[1];return Object.entries(i).find((([,e])=>e===a))[0]}async getPath(e){const t={name:{config:"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",data:"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",cache:"F1B32785-6FBA-4FCF-9D55-7B8E7F157091",documents:"FDD39AD0-238F-46AF-ADB4-6C85480369C7",pictures:"33E28130-4E1E-4676-835A-98395C3BC3BB",music:"4BD8D571-6D19-48D3-BE97-422220080E43",video:"18989B1D-99B5-455B-841C-AB7C74E4DDFC",downloads:"374DE290-123F-4565-9164-39C4925E467B",savedGames1:"4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4",savedGames2:"4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4"}},[r,n]=await this.base.native.fsys.knownFolder(t.name[e]);return n}async open(e){const[t,r]=await this.base.native.process.openUrl(e);return r}},Tr=class{constructor(e){this.base=e}async getOSInfo(){return{description:"Microsoft Windows 10 专业版",name:"Windows NT",version:"10.0.19045-4046"}}},Cr=class{constructor(e){this.base=e}async exit(e){this.killProcess()}async killProcess(){this.base.nativeMain.G.killAll()}async restartProcess(){console.warn("// todo")}async getConfig(){return(await this.base.nativeMain.G)[1].config}async broadcast(e,...t){return await this.base.nativeMain.G.rpcServer.publish(e,...t)}async readProcessInput(e){console.warn("// todo")}async writeProcessOutput(e){console.warn("// todo")}async writeProcessError(e){console.warn("// todo")}},Lr=class{constructor(e){this.base=e,this.msg=new this.base.Msg}async on(e,t){this.msg.on(e,t)}async off(e,t){this.msg.off(e,t)}async dispatch(e,t){console.warn("当前封装暂不能根据实例区分事件")}async broadcast(e,t){this.msg.emit(e,{detail:t})}};async function Rr(){Object.assign(globalThis,{NL_OS:"Windows",NL_ARCH:"// tdo",NL_APPID:"// todo",NL_APPVERSION:"NL_APPVERSION",NL_PORT:(await this.app.getConfig()).socket.port,NL_MODE:"// todo",NL_VERSION:await(async()=>{const[,e]=await this.base.ws.call("run",["return fsys.version.getInfo( io._exepath )"]);return[e.productVersion.build,e.productVersion.major,e.productVersion.minor,e.productVersion.revision].join(".")})(),NL_CVERSION:"// todo",NL_CWD:(await this.base.native.fsys.getCurDir())[1],NL_PATH:(await this.base.native.io.fullpath("~"))[1],NL_ARGS:await(async()=>{const[,e]=await this.base.ws.call("run",["return table.concat({io._exepath}, _ARGV)"]);return e})(),NL_PID:(await this.base.native.process.getId())[1],NL_RESMODE:"directory",NL_EXTENABLED:!0,NL_COMMIT:"// todo",NL_CCOMMIT:"// todo",NL_CMETHODS:"// todo",NL_WSAVSTLOADED:"// todo"})}class jr{constructor(e){return this.base=e,this.clipboard=new Sr(e),this.filesystem=new Or(e),this.os=new Pr(e),this.computer=new Tr(e),this.app=new Cr(e),this.events=new Lr(e),new Promise((async e=>{await Rr.apply(this),e(this)}))}}class Ir{constructor(e,{id:t,runType:r="thread"}){let[n,...o]=e;n=mr(n).trim();const s="*".repeat((function(e){const t=e.match(/\/\*{1,}/g);if(!t)return 0;let r=0;for(const e of t){const t=e.length-1;t>r&&(r=t)}return r}(n)||0)+1),i=function(e,t){return e.replace(/#\{(\w+)\}/g,((r,n,o)=>{const s=function(e,t){const r=e.split("\n");for(let e=0;e<r.length;e++){const n=r[e].length;if(t<n)return r[e];t-=n+1}return null}(e,o),i=s.split("\n").filter((e=>e.trim())).map((e=>e.match(/(^\s+)?/)[0].length)).sort(((e,t)=>e-t))[0];return function(e,t={}){t={num:0,space:" ",skip:0,...t};return e.split("\n").map(((e,r)=>r<=t.skip?e:t.space.repeat(t.num)+e)).join("\n")}(t[n]||"",{num:i})}))}(mr({thread:'\n var arg = {...}\n thread.create(function(...){\n import lib;\n var tid = thread.getId()\n var runid = "#{id}"\n var arg = {...}\n var res = null\n var err = false\n try {\n var code = /#{codeLine}\n var tid = thread.getId()\n var runid = "#{id}"\n var arg = {...}\n #{code}\n #{codeLine}/\n fn, err = loadcode(code)\n res = {fn(table.unpack(arg))}\n }\n catch (e) {\n err = err || tostring(e);\n }\n var data = {type: err ? "err" : "return", err: err, res: res, tid: tid}\n thread.command.publish(runid, data)\n }, table.unpack(arg))\n ',main:'\n var tid = thread.getId()\n var runid = "#{id}"\n var arg = {...}\n var res = null\n var err = false\n try {\n var code = /#{codeLine}\n var tid = thread.getId()\n var runid = "#{id}"\n var arg = {...}\n #{code}\n #{codeLine}/\n fn, err = loadcode(code)\n res = {fn(table.unpack(arg))}\n }\n catch (e) {\n err = err || tostring(e);\n }\n var data = {type: err ? "err" : "return", err: err, res: res, tid: tid}\n global.G.rpcServer.publish(runid, data)\n ',raw:n}[r]).trim(),{id:t,code:n,codeLine:s});this.id=t,this.codeClean=n,this.codeWrap=i,this.codeArg=o,this.newArg=[i,...o]}}class Ar{constructor(){const e=(e={})=>function({keys:e=["then","catch"],cb:t=(e=>new Promise((async(t,r)=>{setTimeout((()=>{t(e)}),1e3*Math.random())})))}={}){function r(e={}){return e.records||[]}return e.forEach((e=>{let t=Symbol(e);_r.set(e,t),_r.set(t,e)})),new pr({},{get(n,o,s){let i=r(this);if(e.includes(o)){let e=t(i);return i.hackRun=!0,e[o].bind(e)}{i.push({type:"get",key:vr([o])});let e=function(){};return this.nest(e,{userData:{records:i}})}},apply(e,n,o){let s=r(this);setTimeout((()=>{let e=r(this);!e.hackRun&&t(e)}),0);const i=s[s.length-1].key;return s[s.length-1]={type:"apply",key:i,arg:o},this.nest((function(){}),{userData:{records:s}})},construct(e,t){let n=r(this);return n.push({type:"construct",arg:t}),this.nest((function(){}),{userData:{records:n}})},defineProperty(e,t,n){let o=r(this);return o.push({type:"defineProperty",key:t,arg:n}),this.nest((function(){}),{userData:{records:o}})},deleteProperty(e,t){let n=r(this);return n.push({type:"deleteProperty",key:t}),this.nest((function(){}),{userData:{records:n}})},set(e,t,n){let o=r(this);return o.push({type:"set",key:t,arg:n}),this.nest((function(){}),{userData:{records:o}})},getOwnPropertyDescriptor(e,t){return r(this).push({type:"getOwnPropertyDescriptor",key:t}),{configurable:!0,enumerable:!0,value:this.nest((function(){}))}},getPrototypeOf(e){let t=r(this);return t.push({type:"getPrototypeOf"}),this.nest((function(){}),{userData:{records:t}})},has(e,t){return r(this).push({type:"has",key:t}),!0},isExtensible(e){return r(this).push({type:"isExtensible"}),!0},setPrototypeOf(e,t){return r(this).push({type:"setPrototypeOf",arg:t}),!0},ownKeys(e){return r(this).push({type:"ownKeys"}),Reflect.ownKeys(e)},preventExtensions(e){return r(this).push({type:"preventExtensions"}),Object.preventExtensions(e),!0}})}({cb:t=>new Promise((async r=>{function n(e){return/^\d+$/.test(e)?`[${e}]`:`.${e}`}let o=[],s=-1,i=!1,a=t.reduce(((e,{type:t,key:r,arg:a=[]},c)=>("get"===t&&(e+=n(r)),"apply"===t&&(s+=1,o[s]=a,e+=`${n(r)}(${a.map(((e,t)=>{const r=function(e,t){const r=Object.prototype.toString.call(e).match(/\s(.+)]/)[1].toLowerCase();return t?r===t.toLowerCase():r}(e),n=["object","array"].includes(r);i=i||n;const o=[s,t].join("_");return["function","asyncfunction"].includes(r)?mr(`function(...){\n var arg = {...}\n var argPath = "${o}"\n var cmd = thread.command()\n var id = "cb_arg_" ++ runid ++ "_" ++ tid ++ "_" ++ argPath\n var res\n thread.command.publish(runid, {type: "cb-arg", res: arg, argPath: argPath, id: id, tid: tid});\n cmd[id] = function(...){\n res = ...\n win.quitMessage()\n }\n win.loopMessage() \n cmd[id] = null\n return res\n }`):n?`arg[${s+1}][${t+1}]`:JSON.stringify(e)})).join(", ")})`),e)),"").slice(1);a=mr(`\n return ${a}\n `),e._argList=o,r(await Nr.call("run",[a,...i?o:[]],e))}))});this.native=e(),this.nativeMain=e({runType:"main"})}get api(){return{neutralino:async()=>await new jr(this)}}}class Mr extends Ar{constructor(...e){return super(),this.key="tray",new Promise((async t=>{const r=await Nr.call(`${this.key}.create`,e);this.hwnd=r,t(this)}))}on(e,t){return Nr.call(`${this.key}.on`,[this.hwnd,e]),Nr.on(`${this.hwnd}.${e}`,t)}off(e){Nr.call(`${this.key}.off`,[this.hwnd,e])}}class Ur extends Ar{constructor(...e){return super(),this.key="view",new Promise((async t=>{const r=await Nr.call(`${this.key}.create`,e);this.hwnd=r,t(this)}))}}class Dr extends Ar{constructor(...e){return super(),this}on(e,t){return Nr.on(e,(e=>{t(...e)}))}off(e){return Nr.off(e)}emit(...e){return Nr.call("run",["\n thread.command.publish(...);\n ",...e])}}let Br=class e extends Ar{constructor(t){var r;t.log=!0===t.log?e=>{const t=String(e.id);let[r="",...n]=Array.from(e.reqRaw);var o;if(r=r.trim(),e.startTime&&(console.group(t),console.log(r),o=n,JSON.parse(JSON.stringify(o),((e,t)=>(!1===yr(t)&&Array.isArray(t)&&(t=t.filter((e=>!yr(e)))),yr(t)?void 0:t)))&&console.table(n)),e.endTime){const[r,...n]=Array.from(e.resRaw);r?console.error(r):console.log(...n),console.groupEnd(t)}}:t.log,t.lib,Nr=t.ws,super(),this.ws=t.ws,this.log={all:r=r||new Map,on:function(e,t){var n=r.get(e);n?n.push(t):r.set(e,[t])},off:function(e,t){var n=r.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var n=r.get(e);n&&n.slice().map((function(e){e(t)})),(n=r.get("*"))&&n.slice().map((function(r){r(e,t)}))}},t.log&&this.log.on("log",t.log);const n=Nr.call;return Nr.call=async(e,t=[],r={})=>{r={runType:"thread",...r};const o=(()=>{const e=(t[0]||"").trim(),r=`code_${function(){if("object"==typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues&&"function"==typeof Uint8Array)return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}let e=(new Date).getTime(),t="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(r=>{let n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:3&n|8).toString(16)}))}()}`.replace(/-/g,"_"),n=new String(r);return n.cbTag=e.startsWith("return thread.command.cb_arg_code_")?e.match(/^return thread.command.cb_arg_(.{41})/)[1]:"",n})(),s=new Ir(t,{id:o,...r});let i={id:"",action:"",startTime:"",endTime:"",reqRaw:[],resRaw:[],id:o,action:e,startTime:Date.now(),reqRaw:[s.codeClean,...s.codeArg]};return this.log.emit("log",i),new Promise((async t=>{let i={id:"",action:"",startTime:"",endTime:"",reqRaw:[],resRaw:[],id:o,action:e,endTime:Date.now(),reqRaw:[s.codeClean,...s.codeArg],resRaw:[]};const a=async e=>{let{tid:n,type:s,err:a,res:c=[]}=e;if("cb-arg"===s){const{argPath:t,id:n}=e,o=t.split("_").reduce(((e,t)=>e[t]),r._argList),s=await o(...c);this.native.thread.command[n](s)}c=Array.from(c);const u=[a,...c];i.resRaw=u,["return","err"].includes(s)&&(this.log.emit("log",i),t(u),this.msg.off(o))};n.bind(Nr)(e,s.newArg).then((([e,...t])=>{e&&a({tid:0,type:"err",err:e,res:[]})})),this.msg.on(o,a)}))},new Promise((async(t,r)=>{if("object"==typeof e.instance)return e.instance;e.instance=this,Nr.on("open",(async()=>{this.Tray=Mr,this.View=Ur,this.Msg=Dr,this.msg=await new Dr,this.msg.on("native:log",console.debug),t(this)}))}))}};try{globalThis.ext=globalThis.ext||JSON.parse(globalThis.process.env._ext),delete globalThis.process.env._ext}catch(e){}const Fr={encoder:new d.TextEncoder("utf-8"),decoder:new d.TextDecoder("utf-8")};module.exports=class extends Br{constructor(e={}){return e="string"==typeof e?{wsUrl:e}:e,new Promise((async(t,r)=>{try{e.wsUrl=e.wsUrl||`${globalThis.ext.wsUrl}?token=${globalThis.ext.token}`;const r=new _.Client(e.wsUrl);t(await super({...e,ws:r,lib:Fr}))}catch(e){r(e)}}))}};
2
+ //# sourceMappingURL=main.min.cjs.map