Repository navigation
Expand file tree
/
Copy pathsocketcluster-client.min.js
More file actions
21 lines (21 loc) · 95.9 KB
/
Copy pathsocketcluster-client.min.js
File metadata and controls
21 lines (21 loc) · 95.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function t(t,e){return e.forEach(function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(function(r){if("default"!==r&&!(r in t)){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})}),Object.freeze(t)}function e(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),r}var r={};var n=class{async next(t){let e=this.createConsumer(t),r=await e.next();return e.return(),r}async once(t){let e=await this.next(t);if(e.done){if(null!=t){let t=new Error("Stream consumer operation timed out early because stream ended");throw t.name="TimeoutError",t}await new Promise(()=>{})}return e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}};let o=class{constructor(t,e,r,n){this.id=e,this._backpressure=0,this.currentNode=r,this.timeout=n,this.isAlive=!0,this.stream=t,this.stream.setConsumer(this.id,this)}getStats(){let t={id:this.id,backpressure:this._backpressure};return null!=this.timeout&&(t.timeout=this.timeout),t}_resetBackpressure(){this._backpressure=0}applyBackpressure(t){this._backpressure++}releaseBackpressure(t){this._backpressure--}getBackpressure(){return this._backpressure}getQueueDepth(){return this.currentNode?this.stream.tailNode.seq-this.currentNode.seq:0}clearActiveTimeout(){clearTimeout(this._timeoutId),delete this._timeoutId}skipNode(t){this._resolve&&(this.currentNode=t)}write(t){void 0!==this._timeoutId&&this.clearActiveTimeout(t),this.applyBackpressure(t),this._resolve&&(this._resolve(),delete this._resolve)}kill(t){this._killPacket={value:t,done:!0},void 0!==this._timeoutId&&this.clearActiveTimeout(this._killPacket),this._destroy(),this._resolve&&(this._resolve(),delete this._resolve)}_destroy(){this.isAlive=!1,this._resetBackpressure(),this.stream.removeConsumer(this.id)}async _waitForNextItem(t){return new Promise((e,r)=>{let n;if(this._resolve=e,void 0!==t){let e=new Error("Stream consumer iteration timed out");(async()=>{let o=function(t){let e,r=new Promise(r=>{e=setTimeout(r,t)});return{timeoutId:e,promise:r}}(t);n=o.timeoutId,await o.promise,e.name="TimeoutError",delete this._resolve,r(e)})()}this._timeoutId=n})}async next(){for(this.stream.setConsumer(this.id,this);;){if(this._killPacket){this._destroy();let t=this._killPacket;return delete this._killPacket,t}if(!this.currentNode)return this._destroy(),{value:void 0,done:!0};if(this.currentNode.next){if(this.currentNode=this.currentNode.next,void 0===this.currentNode.consumerId||this.currentNode.consumerId===this.id)return this.releaseBackpressure(this.currentNode.data),this.currentNode.data.done&&this._destroy(),this.currentNode.data}else try{await this._waitForNextItem(this.timeout)}catch(t){throw this._destroy(),t}}}return(){return delete this.currentNode,this.clearActiveTimeout(),this._destroy(),this._resolve&&(this._killPacket={value:void 0,done:!0},this._resolve(),delete this._resolve),{}}[Symbol.asyncIterator](){return this}};const s=n,i=o;var a=class extends s{constructor(t){super(),t=t||{},this._nextConsumerId=1,this.generateConsumerId=t.generateConsumerId,this.generateConsumerId||(this.generateConsumerId=()=>this._nextConsumerId++),this.removeConsumerCallback=t.removeConsumerCallback,this._consumers=new Map,this.tailNode={next:null,seq:0,data:{value:void 0,done:!1}}}_write(t,e,r){let n={data:{value:t,done:e},next:null,seq:this.tailNode.seq+1};void 0!==r&&(n.consumerId=r),this.tailNode.next=n,this.tailNode=n;for(let t of this._consumers.values())void 0!==n.consumerId&&n.consumerId!==t.id?t.skipNode(n):t.write(n.data)}write(t){this._write(t,!1)}close(t){this._write(t,!0)}writeToConsumer(t,e){if(null==t)throw new TypeError("Cannot write to a consumer without a valid consumer id");this._write(e,!1,t)}closeConsumer(t,e){if(null==t)throw new TypeError("Cannot close a consumer without a valid consumer id");this._write(e,!0,t)}kill(t){for(let e of this._consumers.keys())this.killConsumer(e,t)}killConsumer(t,e){let r=this._consumers.get(t);r&&r.kill(e)}getBackpressure(){return this.getQueueDepth()}getQueueDepth(){let t=0;for(let e of this._consumers.values()){let r=e.getQueueDepth();r>t&&(t=r)}return t}getConsumerQueueDepth(t){let e=this._consumers.get(t);return e?e.getQueueDepth():0}getConsumerBackpressure(t){let e=this._consumers.get(t);return e?e.getBackpressure():0}hasConsumer(t){return this._consumers.has(t)}setConsumer(t,e){this._consumers.set(t,e),e.isAlive=!0,e.currentNode||(e.currentNode=this.tailNode)}removeConsumer(t){let e=this._consumers.delete(t);return e&&this.removeConsumerCallback&&this.removeConsumerCallback(t),e}getConsumerStats(t){let e=this._consumers.get(t);if(e)return e.getStats()}getConsumerStatsList(){let t=[];for(let e of this._consumers.values())t.push(e.getStats());return t}createConsumer(t){return new i(this,this.generateConsumerId(),this.tailNode,t)}getConsumerList(){return[...this._consumers.values()]}getConsumerCount(){return this._consumers.size}};const u=class{async next(t){let e=this.createConsumer(t),r=await e.next();return e.return(),r}async once(t){let e=await this.next(t);if(e.done){if(null!=t){let t=new Error("Stream consumer operation timed out early because stream ended");throw t.name="TimeoutError",t}await new Promise(()=>{})}return e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}};var c=class extends u{constructor(t,e){super(),this._streamDemux=t,this.name=e}createConsumer(t){return this._streamDemux.createConsumer(this.name,t)}};const h=a,l=c;var p=class{constructor(){this.streams=Object.create(null),this._nextConsumerId=1,this.generateConsumerId=()=>this._nextConsumerId++}write(t,e){this.streams[t]&&this.streams[t].write(e)}close(t,e){this.streams[t]&&this.streams[t].close(e)}closeAll(t){for(let e of Object.values(this.streams))e.close(t)}writeToConsumer(t,e){for(let r of Object.values(this.streams))if(r.hasConsumer(t))return r.writeToConsumer(t,e)}closeConsumer(t,e){for(let r of Object.values(this.streams))if(r.hasConsumer(t))return r.closeConsumer(t,e)}getConsumerStats(t){for(let[e,r]of Object.entries(this.streams))if(r.hasConsumer(t))return{...r.getConsumerStats(t),stream:e}}getConsumerStatsList(t){return this.streams[t]?this.streams[t].getConsumerStatsList().map(e=>({...e,stream:t})):[]}getConsumerStatsListAll(){let t=[];for(let e of Object.keys(this.streams)){let r=this.getConsumerStatsList(e);for(let e of r)t.push(e)}return t}kill(t,e){this.streams[t]&&this.streams[t].kill(e)}killAll(t){for(let e of Object.values(this.streams))e.kill(t)}killConsumer(t,e){for(let r of Object.values(this.streams))if(r.hasConsumer(t))return r.killConsumer(t,e)}getBackpressure(t){return this.streams[t]?this.streams[t].getBackpressure():0}getBackpressureAll(){return Object.values(this.streams).reduce((t,e)=>Math.max(t,e.getBackpressure()),0)}getConsumerBackpressure(t){for(let e of Object.values(this.streams))if(e.hasConsumer(t))return e.getConsumerBackpressure(t);return 0}getQueueDepth(t){return this.streams[t]?this.streams[t].getQueueDepth():0}getQueueDepthAll(){return Object.values(this.streams).reduce((t,e)=>Math.max(t,e.getQueueDepth()),0)}getConsumerQueueDepth(t){for(let e of Object.values(this.streams))if(e.hasConsumer(t))return e.getConsumerQueueDepth(t);return 0}hasConsumer(t,e){return!!this.streams[t]&&this.streams[t].hasConsumer(e)}hasConsumerAll(t){return Object.values(this.streams).some(e=>e.hasConsumer(t))}getConsumerCount(t){return this.streams[t]?this.streams[t].getConsumerCount():0}getConsumerCountAll(){return Object.values(this.streams).reduce((t,e)=>t+e.getConsumerCount(),0)}createConsumer(t,e){if(!this.streams[t]){let e=new h({generateConsumerId:this.generateConsumerId,removeConsumerCallback:()=>{this.streams[t]!==e||e.getConsumerCount()||delete this.streams[t]}});this.streams[t]=e}return this.streams[t].createConsumer(e)}stream(t){return new l(this,t)}unstream(t){let e=this.streams[t];e&&e.kill(),delete this.streams[t]}};const f=p;function m(t){this._listenerDemux=new f}m.prototype.emit=function(t,e){this._listenerDemux.write(t,e)},m.prototype.listener=function(t){return this._listenerDemux.stream(t)},m.prototype.closeListener=function(t){this._listenerDemux.close(t)},m.prototype.closeAllListeners=function(){this._listenerDemux.closeAll()},m.prototype.removeListener=function(t){this._listenerDemux.unstream(t)},m.prototype.getListenerConsumerStats=function(t){return this._listenerDemux.getConsumerStats(t)},m.prototype.getListenerConsumerStatsList=function(t){return this._listenerDemux.getConsumerStatsList(t)},m.prototype.getAllListenersConsumerStatsList=function(){return this._listenerDemux.getConsumerStatsListAll()},m.prototype.getListenerConsumerCount=function(t){return this._listenerDemux.getConsumerCount(t)},m.prototype.getAllListenersConsumerCount=function(){return this._listenerDemux.getConsumerCountAll()},m.prototype.killListener=function(t){this._listenerDemux.kill(t)},m.prototype.killAllListeners=function(){this._listenerDemux.killAll()},m.prototype.killListenerConsumer=function(t){this._listenerDemux.killConsumer(t)},m.prototype.getListenerBackpressure=function(t){return this._listenerDemux.getBackpressure(t)},m.prototype.getAllListenersBackpressure=function(){return this._listenerDemux.getBackpressureAll()},m.prototype.getListenerConsumerBackpressure=function(t){return this._listenerDemux.getConsumerBackpressure(t)},m.prototype.hasListenerConsumer=function(t,e){return this._listenerDemux.hasConsumer(t,e)},m.prototype.hasAnyListenerConsumer=function(t){return this._listenerDemux.hasConsumerAll(t)};var d=m;const y=class{async next(t){let e=this.createConsumer(t),r=await e.next();return e.return(),r}async once(t){let e=await this.next(t);return e.done&&await new Promise(()=>{}),e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}};let g=class t extends y{constructor(e,r,n,o){super(),this.PENDING=t.PENDING,this.SUBSCRIBED=t.SUBSCRIBED,this.UNSUBSCRIBED=t.UNSUBSCRIBED,this.name=e,this.client=r,this._eventDemux=n,this._dataStream=o.stream(this.name)}createConsumer(t){return this._dataStream.createConsumer(t)}listener(t){return this._eventDemux.stream(`${this.name}/${t}`)}close(){this.client.closeChannel(this.name)}kill(){this.client.killChannel(this.name)}killOutputConsumer(t){this.hasOutputConsumer(t)&&this.client.killChannelOutputConsumer(t)}killListenerConsumer(t){this.hasAnyListenerConsumer(t)&&this.client.killChannelListenerConsumer(t)}getOutputConsumerStats(t){if(this.hasOutputConsumer(t))return this.client.getChannelOutputConsumerStats(t)}getListenerConsumerStats(t){if(this.hasAnyListenerConsumer(t))return this.client.getChannelListenerConsumerStats(t)}getBackpressure(){return this.client.getChannelBackpressure(this.name)}getListenerConsumerBackpressure(t){return this.hasAnyListenerConsumer(t)?this.client.getChannelListenerConsumerBackpressure(t):0}getOutputConsumerBackpressure(t){return this.hasOutputConsumer(t)?this.client.getChannelOutputConsumerBackpressure(t):0}closeOutput(){this.client.channelCloseOutput(this.name)}closeListener(t){this.client.channelCloseListener(this.name,t)}closeAllListeners(){this.client.channelCloseAllListeners(this.name)}killOutput(){this.client.channelKillOutput(this.name)}killListener(t){this.client.channelKillListener(this.name,t)}killAllListeners(){this.client.channelKillAllListeners(this.name)}getOutputConsumerStatsList(){return this.client.channelGetOutputConsumerStatsList(this.name)}getListenerConsumerStatsList(t){return this.client.channelGetListenerConsumerStatsList(this.name,t)}getAllListenersConsumerStatsList(){return this.client.channelGetAllListenersConsumerStatsList(this.name)}getOutputBackpressure(){return this.client.channelGetOutputBackpressure(this.name)}getListenerBackpressure(t){return this.client.channelGetListenerBackpressure(this.name,t)}getAllListenersBackpressure(){return this.client.channelGetAllListenersBackpressure(this.name)}hasOutputConsumer(t){return this.client.channelHasOutputConsumer(this.name,t)}hasListenerConsumer(t,e){return this.client.channelHasListenerConsumer(this.name,t,e)}hasAnyListenerConsumer(t){return this.client.channelHasAnyListenerConsumer(this.name,t)}get state(){return this.client.getChannelState(this.name)}set state(t){throw new Error("Cannot directly set channel state")}get options(){return this.client.getChannelOptions(this.name)}set options(t){throw new Error("Cannot directly set channel options")}subscribe(t){this.client.subscribe(this.name,t)}unsubscribe(){this.client.unsubscribe(this.name)}isSubscribed(t){return this.client.isSubscribed(this.name,t)}transmitPublish(t){return this.client.transmitPublish(this.name,t)}invokePublish(t){return this.client.invokePublish(this.name,t)}};g.PENDING="pending",g.SUBSCRIBED="subscribed",g.UNSUBSCRIBED="unsubscribed";var b=g;function k(){this._internalStorage=Object.create(null),this.isLocalStorageEnabled=this._checkLocalStorageEnabled()}k.prototype._checkLocalStorageEnabled=function(){let t;try{localStorage.setItem("__scLocalStorageTest",1),localStorage.removeItem("__scLocalStorageTest")}catch(e){t=e}return!t},k.prototype.saveToken=function(t,e,r){return this.isLocalStorageEnabled?localStorage.setItem(t,e):this._internalStorage[t]=e,Promise.resolve(e)},k.prototype.removeToken=function(t){let e=this.loadToken(t);return this.isLocalStorageEnabled?localStorage.removeItem(t):delete this._internalStorage[t],e},k.prototype.loadToken=function(t){let e;return e=this.isLocalStorageEnabled?localStorage.getItem(t):this._internalStorage[t]||null,Promise.resolve(e)};var v=k,E={};const C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=/^[ \n\r\t]*[{\[]/;let _=function(t){let e=new Uint8Array(t),r=e.length,n="";for(let t=0;t<r;t+=3)n+=C[e[t]>>2],n+=C[(3&e[t])<<4|e[t+1]>>4],n+=C[(15&e[t+1])<<2|e[t+2]>>6],n+=C[63&e[t+2]];return r%3==2?n=n.substring(0,n.length-1)+"=":r%3==1&&(n=n.substring(0,n.length-2)+"=="),n},A=function(t,e){if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer)return{base64:!0,data:_(e)};if("undefined"!=typeof Buffer){if(e instanceof Buffer)return{base64:!0,data:e.toString("base64")};if(e&&"Buffer"===e.type&&Array.isArray(e.data)){let t;return t=Buffer.from?Buffer.from(e.data):new Buffer(e.data),{base64:!0,data:t.toString("base64")}}}return e};E.decode=function(t){if(null==t)return null;if("#1"===t||"#2"===t)return t;let e=t.toString();if(!w.test(e))return e;try{return JSON.parse(e)}catch(t){}return e},E.encode=function(t){return"#1"===t||"#2"===t?t:JSON.stringify(t,A)};var T={exports:{}};const S=function(t){var e=[],r=[];return function t(n,o){var s,i,a;if(!("object"!=typeof n||null===n||n instanceof Boolean||n instanceof Date||n instanceof Number||n instanceof RegExp||n instanceof String)){for(s=0;s<e.length;s+=1)if(e[s]===n)return{$ref:r[s]};if(e.push(n),r.push(o),"[object Array]"===Object.prototype.toString.apply(n))for(a=[],s=0;s<n.length;s+=1)a[s]=t(n[s],o+"["+s+"]");else for(i in a={},n)Object.prototype.hasOwnProperty.call(n,i)&&(a[i]=t(n[i],o+"["+JSON.stringify(i)+"]"));return a}return n}(t,"$")},B=function(){return!this}();function O(t,e){this.name="AuthTokenExpiredError",this.message=t,this.expiry=e,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function D(t){this.name="AuthTokenInvalidError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function I(t,e){this.name="AuthTokenNotBeforeError",this.message=t,this.date=e,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function x(t){this.name="AuthTokenError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function N(t){this.name="AuthError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function L(t,e){this.name="SilentMiddlewareBlockedError",this.message=t,this.type=e,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function U(t){this.name="InvalidActionError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function P(t){this.name="InvalidArgumentsError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function R(t){this.name="InvalidOptionsError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function j(t){this.name="InvalidMessageError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function M(t,e){this.name="SocketProtocolError",this.message=t,this.code=e,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function H(t){this.name="ServerProtocolError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function G(t){this.name="HTTPServerError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function $(t){this.name="ResourceLimitError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function F(t){this.name="TimeoutError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function q(t,e,r,n){this.name="BadConnectionError",this.message=t,this.type=e,this.code=r||1001,this.reason=n||W[this.code]||"",Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function z(t){this.name="BrokerError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Q(t,e){this.name="ProcessExitError",this.message=t,this.code=e,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function V(t){this.name="UnknownError",this.message=t,Error.captureStackTrace&&!B?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}O.prototype=Object.create(Error.prototype),D.prototype=Object.create(Error.prototype),I.prototype=Object.create(Error.prototype),x.prototype=Object.create(Error.prototype),N.prototype=Object.create(Error.prototype),L.prototype=Object.create(Error.prototype),U.prototype=Object.create(Error.prototype),P.prototype=Object.create(Error.prototype),R.prototype=Object.create(Error.prototype),j.prototype=Object.create(Error.prototype),M.prototype=Object.create(Error.prototype),H.prototype=Object.create(Error.prototype),G.prototype=Object.create(Error.prototype),$.prototype=Object.create(Error.prototype),F.prototype=Object.create(Error.prototype),q.prototype=Object.create(Error.prototype),z.prototype=Object.create(Error.prototype),Q.prototype=Object.create(Error.prototype),V.prototype=Object.create(Error.prototype),T.exports={AuthTokenExpiredError:O,AuthTokenInvalidError:D,AuthTokenNotBeforeError:I,AuthTokenError:x,AuthError:N,SilentMiddlewareBlockedError:L,InvalidActionError:U,InvalidArgumentsError:P,InvalidOptionsError:R,InvalidMessageError:j,SocketProtocolError:M,ServerProtocolError:H,HTTPServerError:G,ResourceLimitError:$,TimeoutError:F,BadConnectionError:q,BrokerError:z,ProcessExitError:Q,UnknownError:V};const K={1001:"Socket was disconnected",1002:"A WebSocket protocol error was encountered",1003:"Server terminated socket because it received invalid data",1005:"Socket closed without status code",1006:"Socket hung up",1007:"Message format was incorrect",1008:"Encountered a policy violation",1009:"Message was too big to process",1010:"Client ended the connection because the server did not comply with extension requirements",1011:"Server encountered an unexpected fatal condition",4e3:"Server ping timed out",4001:"Client pong timed out",4002:"Server failed to sign auth token",4003:"Failed to complete handshake",4004:"Client failed to save auth token",4005:"Did not receive #handshake from client before timeout",4006:"Failed to bind socket to message broker",4007:"Client connection establishment timed out",4008:"Server rejected handshake from client",4009:"Server received a message before the client handshake"},W={1e3:"Socket closed normally",1001:K[1001]};T.exports.socketProtocolErrorStatuses=K,T.exports.socketProtocolIgnoreStatuses=W,T.exports.dehydrateError=function(t){let e;if(t&&"object"==typeof t){e={message:t.message};for(let r of Object.keys(t))e[r]=t[r]}else e="function"==typeof t?"[function "+("string"==typeof t.name?t.name:"anonymous")+"]":t;return S(e)},T.exports.hydrateError=function(t){let e=null;if(null!=t)if("object"==typeof t){e=new Error("string"==typeof t.message?t.message:"Invalid error message format"),"string"==typeof t.name&&(e.name=t.name);for(let r of Object.keys(t))void 0===e[r]&&(e[r]=t[r])}else e=t;return e},T.exports.decycle=S;var Y=T.exports;const J=Y,X=J.InvalidActionError;var Z=function(t,e,r,n){this.socket=t,this.id=e,this.procedure=r,this.data=n,this.sent=!1,this._respond=(t,e)=>{if(this.sent)throw new X(`Response to request ${this.id} has already been sent`);this.sent=!0,this.socket.sendObject(t,e)},this.end=(t,e)=>{let r={rid:this.id};void 0!==t&&(r.data=t),this._respond(r,e)},this.error=(t,e)=>{let r={rid:this.id,error:J.dehydrateError(t)};this._respond(r,e)}};let tt;tt="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}();const et=tt.WebSocket||tt.MozWebSocket;function rt(t,e,r){let n;return n=e?new et(t,e):new et(t),n}et&&(rt.prototype=et.prototype);const nt=Z,ot=et?rt:null,st=Y,it=st.TimeoutError,at=st.BadConnectionError,ut=st.InvalidMessageError,ct=Math.pow(2,31)-1;function ht(t,e,r,n,o){this.state=this.CLOSED,this.auth=t,this.codec=e,this.options=r,this.wsOptions=n,this.protocolVersion=r.protocolVersion,this.connectTimeout=r.connectTimeout,this.pingTimeout=r.pingTimeout,this.pingTimeoutDisabled=!!r.pingTimeoutDisabled,this.callIdGenerator=r.callIdGenerator,this.authTokenName=r.authTokenName,this.isBufferingBatch=!1,this._pingTimeoutTicker=null,this._callbackMap=Object.create(null),this._batchBuffer=[],this.lastPingTimestamp=Date.now(),o||(o={}),this._onOpenHandler=o.onOpen||function(){},this._onOpenAbortHandler=o.onOpenAbort||function(){},this._onCloseHandler=o.onClose||function(){},this._onEventHandler=o.onEvent||function(){},this._onErrorHandler=o.onError||function(){},this._onInboundInvokeHandler=o.onInboundInvoke||function(){},this._onInboundTransmitHandler=o.onInboundTransmit||function(){},this.state=this.CONNECTING;let s=function(t,e){return new ot(t,[],e)}(this.uri(),n);s.binaryType=this.options.binaryType,this.socket=s,s.onopen=()=>{this._onOpen()},s.onclose=async t=>{let e;e=null==t.code?1005:t.code,this._destroy(e,t.reason)},s.onmessage=(t,e)=>{this._onMessage(t.data)},s.onerror=t=>{this.state===this.CONNECTING&&this._destroy(1006)},this._connectTimeoutRef=setTimeout(()=>{this._destroy(4007),this.socket.close(4007)},this.connectTimeout),1===this.protocolVersion?this._handlePing=t=>"#1"===t&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send("#2"),!0):this._handlePing=t=>""===t&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send(""),!0)}ht.CONNECTING=ht.prototype.CONNECTING="connecting",ht.OPEN=ht.prototype.OPEN="open",ht.CLOSED=ht.prototype.CLOSED="closed",ht.computeURI=function(t){let e,r=t.query||{};e=null==t.protocolScheme?t.secure?"wss":"ws":t.protocolScheme,t.timestampRequests&&(r[t.timestampParam]=(new Date).getTime());let n,o,s=new URLSearchParams;for(let[t,e]of Object.entries(r))if(Array.isArray(e))for(let r of e)s.append(t,r);else s.set(t,e);if(r=s.toString(),r.length&&(r="?"+r),null==t.socketPath){if(t.host)n=t.host;else{let r="";t.port&&("wss"===e&&443!==t.port||"ws"===e&&80!==t.port)&&(r=":"+t.port),n=t.hostname+r}o=t.path}else n=t.socketPath,o=`:${t.path}`;return e+"://"+n+o+r},ht.prototype.uri=function(){return ht.computeURI(this.options)},ht.prototype._onOpen=async function(){let t;clearTimeout(this._connectTimeoutRef),this._resetPingTimeout();try{t=await this._handshake()}catch(t){return null==t.statusCode&&(t.statusCode=4003),this._onError(t),this._destroy(t.statusCode,t.toString()),void this.socket.close(t.statusCode)}this.state=this.OPEN,t&&(t.pingTimeout=this._applyPingTimeout(t.pingTimeout)),this._resetPingTimeout(),this._onOpenHandler(t)},ht.prototype._applyPingTimeout=function(t){var e;return"number"==typeof(e=t)&&Number.isFinite(e)&&e>0&&e<=ct?this.pingTimeout=t:this._onError(new ut(`The pingTimeout value ${t} sent by the server was invalid - Keeping the previous value of ${this.pingTimeout}`)),this.pingTimeout},ht.prototype._handshake=async function(){let t=await this.auth.loadToken(this.authTokenName),e=await this.invoke("#handshake",{authToken:t},{force:!0});return e&&(e.authToken=t,e.authError&&(e.authError=st.hydrateError(e.authError))),e},ht.prototype._abortAllPendingEventsDueToBadConnection=function(t,e,r){Object.keys(this._callbackMap||{}).forEach(n=>{let o=this._callbackMap[n];delete this._callbackMap[n],clearTimeout(o.timeout),delete o.timeout;let s=`Event ${o.event} was aborted due to a bad connection`,i=new at(s,t,e,r),a=o.callback;a&&(delete o.callback,a.call(o,i,o))})},ht.prototype._destroy=function(t,e){!e&&st.socketProtocolErrorStatuses[t]&&(e=st.socketProtocolErrorStatuses[t]),delete this.socket.onopen,delete this.socket.onclose,delete this.socket.onmessage,delete this.socket.onerror,clearTimeout(this._connectTimeoutRef),clearTimeout(this._pingTimeoutTicker),this.state===this.OPEN?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("disconnect",t,e),this._onCloseHandler({code:t,reason:e})):this.state===this.CONNECTING?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("connectAbort",t,e),this._onOpenAbortHandler({code:t,reason:e})):this.state===this.CLOSED&&this._abortAllPendingEventsDueToBadConnection("connectAbort",t,e)},ht.prototype._processInboundPacket=function(t,e){if(t&&"string"==typeof t.event)if("number"==typeof t.cid){let e=new nt(this,t.cid,t.event,t.data);this._onInboundInvokeHandler(e)}else this._onInboundTransmitHandler({...t});else if(t&&"number"==typeof t.rid){let e=this._callbackMap[t.rid];if(e&&(clearTimeout(e.timeout),delete e.timeout,delete this._callbackMap[t.rid],e.callback)){let r=st.hydrateError(t.error);e.callback(r,t.data)}}else this._onEventHandler({event:"raw",data:{message:e}})},ht.prototype._onMessage=function(t){if(this._onEventHandler({event:"message",data:{message:t}}),this._handlePing(t))return;let e=this.decode(t);if(Array.isArray(e)){let r=e.length;for(let n=0;n<r;n++)this._processInboundPacket(e[n],t)}else this._processInboundPacket(e,t)},ht.prototype._onError=function(t){this._onErrorHandler({error:t})},ht.prototype.isStale=function(){return!this.pingTimeoutDisabled&&Date.now()-this.lastPingTimestamp>=this.pingTimeout},ht.prototype._resetPingTimeout=function(){this.lastPingTimestamp=Date.now(),this.pingTimeoutDisabled||(clearTimeout(this._pingTimeoutTicker),this._pingTimeoutTicker=setTimeout(()=>{this._destroy(4e3),this.socket.close(4e3)},this.pingTimeout))},ht.prototype.clearAllListeners=function(){this._onOpenHandler=function(){},this._onOpenAbortHandler=function(){},this._onCloseHandler=function(){},this._onEventHandler=function(){},this._onErrorHandler=function(){},this._onInboundInvokeHandler=function(){},this._onInboundTransmitHandler=function(){}},ht.prototype.startBatch=function(){this.isBufferingBatch=!0,this._batchBuffer=[]},ht.prototype.flushBatch=function(){if(this.isBufferingBatch=!1,!this._batchBuffer.length)return;let t=this.serializeObject(this._batchBuffer);this._batchBuffer=[],this.send(t)},ht.prototype.cancelBatch=function(){this.isBufferingBatch=!1,this._batchBuffer=[]},ht.prototype.getBytesReceived=function(){return this.socket.bytesReceived},ht.prototype.close=function(t,e){this.state!==this.OPEN&&this.state!==this.CONNECTING||(t=t||1e3,this._destroy(t,e),this.socket.close(t,e))},ht.prototype.transmitObject=function(t){let e={event:t.event,data:t.data};return t.callback&&(e.cid=t.cid=this.callIdGenerator(),this._callbackMap[t.cid]=t),this.sendObject(e),t.cid||null},ht.prototype._handleEventAckTimeout=function(t){t.cid&&delete this._callbackMap[t.cid],delete t.timeout;let e=t.callback;if(e){delete t.callback;let r=new it(`Event response for ${t.event} event timed out`);e.call(t,r,t)}},ht.prototype.transmit=function(t,e,r){let n={event:t,data:e};return(this.state===this.OPEN||r.force)&&this.transmitObject(n),Promise.resolve()},ht.prototype.invokeRaw=function(t,e,r,n){let o={event:t,data:e,callback:n};r.noTimeout||(o.timeout=setTimeout(()=>{this._handleEventAckTimeout(o)},this.options.ackTimeout));let s=null;return(this.state===this.OPEN||r.force)&&(s=this.transmitObject(o)),s},ht.prototype.invoke=function(t,e,r){return new Promise((n,o)=>{this.invokeRaw(t,e,r,(t,e)=>{t?o(t):n(e)})})},ht.prototype.cancelPendingResponse=function(t){delete this._callbackMap[t]},ht.prototype.decode=function(t){return this.codec.decode(t)},ht.prototype.encode=function(t){return this.codec.encode(t)},ht.prototype.send=function(t){this.socket.readyState!==this.socket.OPEN?this._destroy(1005):this.socket.send(t)},ht.prototype.serializeObject=function(t){let e;try{e=this.encode(t)}catch(t){return this._onError(t),null}return e},ht.prototype.sendObject=function(t){if(this.isBufferingBatch)return void this._batchBuffer.push(t);let e=this.serializeObject(t);null!=e&&this.send(e)};var lt=ht,pt=bt;bt.Item=vt;var ft=bt.prototype,mt=vt.prototype,dt=Et.prototype,yt="undefined"==typeof Symbol?void 0:Symbol.iterator;ft.tail=ft.head=null,bt.of=function(){return kt(new this,arguments)},bt.from=function(t){return kt(new this,t)},ft.toArray=function(){var t=this.head,e=[];for(;t;)e.push(t),t=t.next;return e},ft.prepend=function(t){var e=this,r=e.head;if(!t)return!1;if(!t.append||!t.prepend||!t.detach)throw new Error(gt+"#prepend`.");if(r)return r.prepend(t);return t.detach(),t.list=e,e.head=t,e.size++,t},ft.append=function(t){if(!t)return!1;if(!t.append||!t.prepend||!t.detach)throw new Error(gt+"#append`.");var e=this,r=e.head,n=e.tail;if(n)return n.append(t);if(r)return r.append(t);return t.detach(),t.list=e,e.head=t,e.size++,t},void 0!==yt&&(ft[yt]=function(){return new Et(this.head)}),mt.next=mt.prev=mt.list=null,mt.prepend=function(t){if(!(t&&t.append&&t.prepend&&t.detach))throw new Error(gt+"Item#prepend`.");var e=this,r=e.list,n=e.prev;if(!r)return!1;t.detach(),n&&(t.prev=n,n.next=t);t.next=e,t.list=r,e.prev=t,e===r.head&&(r.head=t);r.tail||(r.tail=e);return r.size++,t},mt.append=function(t){if(!(t&&t.append&&t.prepend&&t.detach))throw new Error(gt+"Item#append`.");var e=this,r=e.list,n=e.next;if(!r)return!1;t.detach(),n&&(t.next=n,n.prev=t);t.prev=e,t.list=r,e.next=t,e!==r.tail&&r.tail||(r.tail=t);return r.size++,t},mt.detach=function(){var t=this,e=t.list,r=t.prev,n=t.next;if(!e)return t;e.tail===t&&(e.tail=r);e.head===t&&(e.head=n);e.tail===e.head&&(e.tail=null);r&&(r.next=n);n&&(n.prev=r);return t.prev=t.next=t.list=null,e.size--,t},dt.next=function(){var t=this.item;return this.value=t,this.done=!t,this.item=t?t.next:void 0,this};var gt="An argument without append, prepend, or detach methods was given to `List";function bt(){this.size=0,0!==arguments.length&&kt(this,arguments)}function kt(t,e){var r,n,o,s;if(!e)return t;if(void 0!==yt&&e[yt])for(s=e[yt](),o={};!o.done;)o=s.next(),t.append(o&&o.value);else for(r=e.length,n=-1;++n<r;)t.append(e[n]);return t}function vt(){}function Et(t){this.item=t}var Ct=Object.prototype.toString,wt=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return"GeneratorFunction"===_t(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){if(t.constructor&&"function"==typeof t.constructor.isBuffer)return t.constructor.isBuffer(t);return!1}
/*!
* shallow-clone <https://github.com/jonschlinkert/shallow-clone>
*
* Copyright (c) 2015-present, Jon Schlinkert.
* Released under the MIT License.
*/(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(_t(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(t))return"generator";switch(e=Ct.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return e.slice(8,-1).toLowerCase().replace(/\s/g,"")};function _t(t){return"function"==typeof t.constructor?t.constructor.name:null}const At=Symbol.prototype.valueOf,Tt=wt;var St=function(t,e){switch(Tt(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return function(t){const e=t.length,r=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return t.copy(r),r}(t);case"symbol":return function(t){return At?Object(At.call(t)):{}}(t);case"arraybuffer":return function(t){const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(t){return new t.constructor(t.buffer,t.byteOffset,t.length)}(t);case"regexp":return function(t){const e=void 0!==t.flags?t.flags:/\w+$/.exec(t)||void 0,r=new t.constructor(t.source,e);return r.lastIndex=t.lastIndex,r}(t);case"error":return Object.create(t);default:return t}},Bt=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)};
/*!
* isobject <https://github.com/jonschlinkert/isobject>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/function Ot(t){return!0===Bt(t)&&"[object Object]"===Object.prototype.toString.call(t)}const Dt=St,It=wt,xt=function(t){var e,r;return!1!==Ot(t)&&("function"==typeof(e=t.constructor)&&(!1!==Ot(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))};function Nt(t,e){switch(It(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||xt(t)){const r=new t.constructor;for(let n in t)r[n]=Nt(t[n],e);return r}return t}(t,e);case"array":return function(t,e){const r=new t.constructor(t.length);for(let n=0;n<t.length;n++)r[n]=Nt(t[n],e);return r}(t,e);default:return Dt(t)}}for(var Lt=Nt,Ut={},Pt={byteLength:function(t){var e=$t(t),r=e[0],n=e[1];return 3*(r+n)/4-n},toByteArray:function(t){var e,r,n=$t(t),o=n[0],s=n[1],i=new Mt(function(t,e,r){return 3*(e+r)/4-r}(0,o,s)),a=0,u=s>0?o-4:o;for(r=0;r<u;r+=4)e=jt[t.charCodeAt(r)]<<18|jt[t.charCodeAt(r+1)]<<12|jt[t.charCodeAt(r+2)]<<6|jt[t.charCodeAt(r+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=255&e;2===s&&(e=jt[t.charCodeAt(r)]<<2|jt[t.charCodeAt(r+1)]>>4,i[a++]=255&e);1===s&&(e=jt[t.charCodeAt(r)]<<10|jt[t.charCodeAt(r+1)]<<4|jt[t.charCodeAt(r+2)]>>2,i[a++]=e>>8&255,i[a++]=255&e);return i},fromByteArray:function(t){for(var e,r=t.length,n=r%3,o=[],s=16383,i=0,a=r-n;i<a;i+=s)o.push(qt(t,i,i+s>a?a:i+s));1===n?(e=t[r-1],o.push(Rt[e>>2]+Rt[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(Rt[e>>10]+Rt[e>>4&63]+Rt[e<<2&63]+"="));return o.join("")}},Rt=[],jt=[],Mt="undefined"!=typeof Uint8Array?Uint8Array:Array,Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gt=0;Gt<64;++Gt)Rt[Gt]=Ht[Gt],jt[Ht.charCodeAt(Gt)]=Gt;function $t(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function Ft(t){return Rt[t>>18&63]+Rt[t>>12&63]+Rt[t>>6&63]+Rt[63&t]}function qt(t,e,r){for(var n,o=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),o.push(Ft(n));return o.join("")}jt["-".charCodeAt(0)]=62,jt["_".charCodeAt(0)]=63;var zt={};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */zt.read=function(t,e,r,n,o){var s,i,a=8*o-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?o-1:0,p=r?-1:1,f=t[e+l];for(l+=p,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+t[e+l],l+=p,h-=8);for(i=s&(1<<-h)-1,s>>=-h,h+=n;h>0;i=256*i+t[e+l],l+=p,h-=8);if(0===s)s=1-c;else{if(s===u)return i?NaN:1/0*(f?-1:1);i+=Math.pow(2,n),s-=c}return(f?-1:1)*i*Math.pow(2,s-n)},zt.write=function(t,e,r,n,o,s){var i,a,u,c=8*s-o-1,h=(1<<c)-1,l=h>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,m=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=h):(i=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-i))<1&&(i--,u*=2),(e+=i+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(i++,u/=2),i+l>=h?(a=0,i=h):i+l>=1?(a=(e*u-1)*Math.pow(2,o),i+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),i=0));o>=8;t[r+f]=255&a,f+=m,a/=256,o-=8);for(i=i<<o|a,c+=o;c>0;t[r+f]=255&i,f+=m,i/=256,c-=8);t[r+f-m]|=128*d},
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
function(t){var e=Pt,r=zt,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=i,t.SlowBuffer=function(t){+t!=t&&(t=0);return i.alloc(+t)},t.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|f(t,e),n=s(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(M(t,Uint8Array)){var e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(M(t,ArrayBuffer)||t&&M(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(M(t,SharedArrayBuffer)||t&&M(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return i.from(n,e,r);var o=function(t){if(i.isBuffer(t)){var e=0|p(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||H(t.length)?s(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return u(t),s(t<0?0:0|p(t))}function h(t){for(var e=t.length<0?0:0|p(t.length),r=s(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,i.prototype),n}function p(t){if(t>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function f(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||M(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return P(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return R(t).length;default:if(o)return n?-1:P(t).length;e=(""+e).toLowerCase(),o=!0}}function m(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return _(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return S(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,o){var s,i=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;i=2,a/=2,u/=2,r/=2}function c(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o){var h=-1;for(s=r;s<a;s++)if(c(t,s)===c(e,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===u)return h*i}else-1!==h&&(s-=s-h),h=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){for(var l=!0,p=0;p<u;p++)if(c(t,s+p)!==c(e,p)){l=!1;break}if(l)return s}return-1}function b(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var s=e.length;n>s/2&&(n=s/2);for(var i=0;i<n;++i){var a=parseInt(e.substr(2*i,2),16);if(H(a))return i;t[r+i]=a}return i}function k(t,e,r,n){return j(P(e,t.length-r),t,r,n)}function v(t,e,r,n){return j(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return j(R(e),t,r,n)}function C(t,e,r,n){return j(function(t,e){for(var r,n,o,s=[],i=0;i<t.length&&!((e-=2)<0);++i)n=(r=t.charCodeAt(i))>>8,o=r%256,s.push(o),s.push(n);return s}(e,t.length-r),t,r,n)}function w(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function _(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var s,i,a,u,c=t[o],h=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(s=t[o+1]))&&(u=(31&c)<<6|63&s)>127&&(h=u);break;case 3:s=t[o+1],i=t[o+2],128==(192&s)&&128==(192&i)&&(u=(15&c)<<12|(63&s)<<6|63&i)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:s=t[o+1],i=t[o+2],a=t[o+3],128==(192&s)&&128==(192&i)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&i)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}t.kMaxLength=o,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},i.allocUnsafe=function(t){return c(t)},i.allocUnsafeSlow=function(t){return c(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),M(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,o=0,s=Math.min(r,n);o<s;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=i.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(M(s,Uint8Array))o+s.length>n.length?i.from(s).copy(n,o):Uint8Array.prototype.set.call(n,s,o);else{if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o)}o+=s.length}return n},i.byteLength=f,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?_(this,0,t):m.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,r,n,o){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),u=Math.min(s,a),c=this.slice(n,o),h=t.slice(e,r),l=0;l<u;++l)if(c[l]!==h[l]){s=c[l],a=h[l];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},i.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},i.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},i.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return k(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function B(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",s=e;s<r;++s)o+=G[t[s]];return o}function O(t,e,r){for(var n=t.slice(e,r),o="",s=0;s<n.length-1;s+=2)o+=String.fromCharCode(n[s]+256*n[s+1]);return o}function D(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,o,s){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,o,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,n,o,s){return e=+e,n>>>=0,s||x(t,0,n,4),r.write(t,e,n,o,23,4),n+4}function L(t,e,n,o,s){return e=+e,n>>>=0,s||x(t,0,n,8),r.write(t,e,n,o,52,8),n+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,i.prototype),n},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||D(t,e,this.length);for(var n=this[t],o=1,s=0;++s<e&&(o*=256);)n+=this[t+s]*o;return n},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||D(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||D(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||D(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||D(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||D(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||D(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||D(t,e,this.length);for(var n=this[t],o=1,s=0;++s<e&&(o*=256);)n+=this[t+s]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||D(t,e,this.length);for(var n=e,o=1,s=this[t+--n];n>0&&(o*=256);)s+=this[t+--n]*o;return s>=(o*=128)&&(s-=Math.pow(2,8*e)),s},i.prototype.readInt8=function(t,e){return t>>>=0,e||D(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||D(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){t>>>=0,e||D(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||D(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||D(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||D(t,4,this.length),r.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||D(t,4,this.length),r.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||D(t,8,this.length),r.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||D(t,8,this.length),r.read(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,s=0;for(this[e]=255&t;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,s=1;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var s=0,i=1,a=0;for(this[e]=255&t;++s<r&&(i*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/i|0)-a&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var s=r-1,i=1,a=0;for(this[e+s]=255&t;--s>=0&&(i*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/i|0)-a&255;return e+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var a=i.isBuffer(t)?t:i.from(t,n),u=a.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<r-e;++s)this[s+e]=a[s%u]}return this};var U=/[^+/0-9A-Za-z-_]/g;function P(t,e){var r;e=e||1/0;for(var n=t.length,o=null,s=[],i=0;i<n;++i){if((r=t.charCodeAt(i))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(i+1===n){(e-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function R(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function M(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}var G=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()}(Ut);const Qt=p,Vt=d,Kt=b,Wt=v,Yt=E,Jt=lt,Xt=pt,Zt=Lt,te=Ut.Buffer,ee=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})},re=Y,ne=re.InvalidArgumentsError,oe=re.InvalidMessageError,se=re.SocketProtocolError,ie=re.TimeoutError,ae=re.BadConnectionError;function ue(t){return"string"!=typeof t||t in Object.prototype}function ce(t){Vt.call(this);let e=Object.assign({path:"/socketcluster/",secure:!1,protocolScheme:null,socketPath:null,autoConnect:!0,autoReconnect:!0,autoSubscribeOnConnect:!0,connectTimeout:2e4,ackTimeout:1e4,timestampRequests:!1,timestampParam:"t",binaryType:"arraybuffer",batchOnHandshake:!1,batchOnHandshakeDuration:100,batchInterval:50,protocolVersion:2,wsOptions:{},cloneData:!1},t);this.options=e,this._isAuthTokenNameAutoGenerated=null==e.authTokenName,this._isAuthTokenNameAutoGenerated&&(e.authTokenName=this._generateAuthTokenNameFromURI(e)),this.id=null,this.version=e.version||null,this.protocolVersion=e.protocolVersion,this.state=this.CLOSED,this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null,this.pendingReconnect=!1,this.pendingReconnectTimeout=null,this.preparingPendingSubscriptions=!1,this.clientId=e.clientId,this.wsOptions=e.wsOptions,this.connectTimeout=e.connectTimeout,this.ackTimeout=e.ackTimeout,this.channelPrefix=e.channelPrefix||null,e.pingTimeout=e.connectTimeout,this.pingTimeout=e.pingTimeout,this.pingTimeoutDisabled=!!e.pingTimeoutDisabled;let r=Math.pow(2,31)-1,n=t=>{if(this[t]>r)throw new ne(`The ${t} value provided exceeded the maximum amount allowed`)};if(n("connectTimeout"),n("ackTimeout"),n("pingTimeout"),this.connectAttempts=0,this.isBatching=!1,this.batchOnHandshake=e.batchOnHandshake,this.batchOnHandshakeDuration=e.batchOnHandshakeDuration,this._batchingIntervalId=null,this._outboundBuffer=new Xt,this._channelMap=Object.create(null),this._channelEventDemux=new Qt,this._channelDataDemux=new Qt,this._receiverDemux=new Qt,this._procedureDemux=new Qt,this._cid=1,this.options.callIdGenerator=()=>this._cid++,this.options.autoReconnect){null==this.options.autoReconnectOptions&&(this.options.autoReconnectOptions={});let t=this.options.autoReconnectOptions;null==t.initialDelay&&(t.initialDelay=1e4),null==t.randomness&&(t.randomness=1e4),null==t.multiplier&&(t.multiplier=1.5),null==t.maxDelay&&(t.maxDelay=6e4)}if(null==this.options.subscriptionRetryOptions&&(this.options.subscriptionRetryOptions={}),this.options.authEngine?this.auth=this.options.authEngine:this.auth=new Wt,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=Yt,this.options.protocol){let t=new ne("The protocol option does not affect socketcluster-client - If you want to utilize SSL/TLS, use the secure option instead");this._onError(t)}if(this.options.query=e.query||{},"string"==typeof this.options.query){let t=new URLSearchParams(this.options.query),e={};for(let[r,n]of t.entries()){let t=e[r];null==t?e[r]=n:(Array.isArray(t)||(e[r]=[t]),e[r].push(n))}this.options.query=e}this.options.autoConnect&&this.connect()}ce.prototype=Object.create(Vt.prototype),ce.CONNECTING=ce.prototype.CONNECTING=Jt.prototype.CONNECTING,ce.OPEN=ce.prototype.OPEN=Jt.prototype.OPEN,ce.CLOSED=ce.prototype.CLOSED=Jt.prototype.CLOSED,ce.AUTHENTICATED=ce.prototype.AUTHENTICATED="authenticated",ce.UNAUTHENTICATED=ce.prototype.UNAUTHENTICATED="unauthenticated",ce.SUBSCRIBED=ce.prototype.SUBSCRIBED=Kt.SUBSCRIBED,ce.PENDING=ce.prototype.PENDING=Kt.PENDING,ce.UNSUBSCRIBED=ce.prototype.UNSUBSCRIBED=Kt.UNSUBSCRIBED,ce.ignoreStatuses=re.socketProtocolIgnoreStatuses,ce.errorStatuses=re.socketProtocolErrorStatuses,Object.defineProperty(ce.prototype,"isBufferingBatch",{get:function(){return this.transport.isBufferingBatch}}),Object.defineProperty(ce.prototype,"authTokenName",{get:function(){return this.options.authTokenName},set:function(t){this._isAuthTokenNameAutoGenerated=null==t,this.options.authTokenName=this._isAuthTokenNameAutoGenerated?this._generateAuthTokenNameFromURI(this.options):t}}),ce.prototype.uri=function(){return Jt.computeURI(this.options)},ce.prototype.getBackpressure=function(){return Math.max(this.getAllListenersBackpressure(),this.getAllReceiversBackpressure(),this.getAllProceduresBackpressure(),this.getAllChannelsBackpressure())},ce.prototype._generateAuthTokenNameFromURI=function(t){return`socketcluster.authToken${t.host?`.${t.host}`:`.${t.hostname||"localhost"}${t.port?`:${t.port}`:""}`}`},ce.prototype._setAuthToken=function(t){this._changeToAuthenticatedState(t.token),(async()=>{try{await this.auth.saveToken(this.authTokenName,t.token,{})}catch(t){this._onError(t)}})()},ce.prototype._removeAuthToken=function(t){(async()=>{let t;try{t=await this.auth.removeToken(this.authTokenName)}catch(t){return void this._onError(t)}this.emit("removeAuthToken",{oldAuthToken:t})})(),this._changeToUnauthenticatedStateAndClearTokens()},ce.prototype._privateDataHandlerMap=Object.assign(Object.create(null),{"#publish":function(t){if("string"!=typeof t.channel)return;let e=this._undecorateChannelName(t.channel);ue(e)||this.isSubscribed(e,!0)&&this._channelDataDemux.write(e,t.data)},"#kickOut":function(t){if("string"!=typeof t.channel)return;let e=this._undecorateChannelName(t.channel);if(ue(e))return;let r=this._channelMap[e];r&&(this.emit("kickOut",{channel:e,message:t.message}),this._channelEventDemux.write(`${e}/kickOut`,{message:t.message}),this._triggerChannelUnsubscribe(r))},"#setAuthToken":function(t){t&&"string"==typeof t.token?this._setAuthToken(t):this._onError(new oe("No valid token data provided by #setAuthToken event"))},"#removeAuthToken":function(t){this._removeAuthToken(t)}}),ce.prototype._privateRPCHandlerMap=Object.assign(Object.create(null),{"#setAuthToken":function(t,e){if(t&&"string"==typeof t.token)this._setAuthToken(t),e.end();else{let t=new oe("No valid token data provided by #setAuthToken event");delete t.stack,e.error(t)}},"#removeAuthToken":function(t,e){this._removeAuthToken(t),e.end()}}),ce.prototype.getState=function(){return this.state},ce.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},ce.prototype.deauthenticate=async function(){(async()=>{let t;try{t=await this.auth.removeToken(this.authTokenName)}catch(t){return void this._onError(t)}this.emit("removeAuthToken",{oldAuthToken:t})})(),this.state!==this.CLOSED&&this.transmit("#removeAuthToken"),this._changeToUnauthenticatedStateAndClearTokens(),await ee(0)},ce.prototype.connect=function(t){if(t){this.state!==this.CLOSED&&this.disconnect(1e3,"Socket was disconnected by the client to initiate a new connection");let e=Object.prototype.hasOwnProperty.call(t,"authTokenName");this.options={...this.options,...t},e&&(this._isAuthTokenNameAutoGenerated=null==this.options.authTokenName),this._isAuthTokenNameAutoGenerated&&(this.options.authTokenName=this._generateAuthTokenNameFromURI(this.options))}if(this.state===this.CLOSED){this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this.state=this.CONNECTING,this.emit("connecting",{}),this.transport&&this.transport.clearAllListeners();let t={onOpen:t=>{this.state=this.OPEN,this._onOpen(t)},onOpenAbort:t=>{this.state!==this.CLOSED&&(this.state=this.CLOSED,this._destroy(t.code,t.reason,!0))},onClose:t=>{this.state!==this.CLOSED&&(this.state=this.CLOSED,this._destroy(t.code,t.reason))},onEvent:t=>{this.emit(t.event,t.data)},onError:t=>{this._onError(t.error)},onInboundInvoke:t=>{this._onInboundInvoke(t)},onInboundTransmit:t=>{this._onInboundTransmit(t.event,t.data)}};this.transport=new Jt(this.auth,this.codec,this.options,this.wsOptions,t)}},ce.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},ce.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new ne("If specified, the code argument must be a number");let r=this.state===this.CONNECTING;r||this.state===this.OPEN?(this.state=this.CLOSED,this._destroy(t,e,r),this.transport.close(t,e)):(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef))},ce.prototype._changeToUnauthenticatedStateAndClearTokens=function(){if(this.authState!==this.UNAUTHENTICATED){let t=this.authState,e=this.authToken,r=this.signedAuthToken;this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null;let n={oldAuthState:t,newAuthState:this.authState};this.emit("authStateChange",n),this.emit("deauthenticate",{oldSignedAuthToken:r,oldAuthToken:e})}},ce.prototype._changeToAuthenticatedState=function(t){if(this.signedAuthToken=t,this.authToken=this._extractAuthTokenData(t),this.authState!==this.AUTHENTICATED){let e=this.authState;this.authState=this.AUTHENTICATED;let r={oldAuthState:e,newAuthState:this.authState,signedAuthToken:t,authToken:this.authToken};this.preparingPendingSubscriptions||this.processPendingSubscriptions(),this.emit("authStateChange",r)}this.emit("authenticate",{signedAuthToken:t,authToken:this.authToken})},ce.prototype.decodeBase64=function(t){return te.from(t,"base64").toString("utf8")},ce.prototype.encodeBase64=function(t){return te.from(t,"utf8").toString("base64")},ce.prototype._extractAuthTokenData=function(t){if("string"!=typeof t)return null;let e=t.split(".")[1];if(null!=e){let t=e;try{return t=this.decodeBase64(t),JSON.parse(t)}catch(e){return t}}return null},ce.prototype.getAuthToken=function(){return this.authToken},ce.prototype.getSignedAuthToken=function(){return this.signedAuthToken},ce.prototype.authenticate=async function(t){let e;try{e=await this.invoke("#authenticate",t)}catch(t){throw"BadConnectionError"!==t.name&&"TimeoutError"!==t.name&&this._changeToUnauthenticatedStateAndClearTokens(),await ee(0),t}return e&&null!=e.isAuthenticated?e.authError&&(e.authError=re.hydrateError(e.authError)):e={isAuthenticated:this.authState,authError:null},e.isAuthenticated?this._changeToAuthenticatedState(t):this._changeToUnauthenticatedStateAndClearTokens(),(async()=>{try{await this.auth.saveToken(this.authTokenName,t,{})}catch(t){this._onError(t)}})(),await ee(0),e},ce.prototype._tryReconnect=function(t){let e,r=this.connectAttempts++,n=this.options.autoReconnectOptions;if(null==t||r>0){let t=Math.round(n.initialDelay+(n.randomness||0)*Math.random());e=Math.round(t*Math.pow(n.multiplier,r))}else e=t;e>n.maxDelay&&(e=n.maxDelay),clearTimeout(this._reconnectTimeoutRef),this.pendingReconnect=!0,this.pendingReconnectTimeout=e,this._reconnectTimeoutRef=setTimeout(()=>{this.connect()},e)},ce.prototype._onOpen=function(t){this.isBatching?this._startBatching():this.batchOnHandshake&&(this._startBatching(),setTimeout(()=>{this.isBatching||this._stopBatching()},this.batchOnHandshakeDuration)),this.preparingPendingSubscriptions=!0,t?(this.id=t.id,this.pingTimeout=t.pingTimeout,t.isAuthenticated?this._changeToAuthenticatedState(t.authToken):this._changeToUnauthenticatedStateAndClearTokens()):this._changeToUnauthenticatedStateAndClearTokens(),this.connectAttempts=0,this.options.autoSubscribeOnConnect&&this.processPendingSubscriptions(),this.emit("connect",{...t,processPendingSubscriptions:()=>{this.processPendingSubscriptions()}}),this.state===this.OPEN&&this._flushOutboundBuffer()},ce.prototype._onError=function(t){this.emit("error",{error:t})},ce.prototype._suspendSubscriptions=function(){Object.keys(this._channelMap).forEach(t=>{let e=this._channelMap[t];this._triggerChannelUnsubscribe(e,!0)})},ce.prototype._abortAllPendingEventsDueToBadConnection=function(t,e,r){let n,o=this._outboundBuffer.head;for(;o;){n=o.next;let s=o.data;clearTimeout(s.timeout),delete s.timeout,o.detach(),o=n;let i=s.callback;if(i){delete s.callback;let n=`Event ${s.event} was aborted due to a bad connection`,o=new ae(n,t,e,r);i.call(s,o,s)}s.cid&&this.transport.cancelPendingResponse(s.cid)}},ce.prototype._destroy=function(t,e,r){if(this.id=null,this._cancelBatching(),this.transport&&this.transport.clearAllListeners(),this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this._suspendSubscriptions(),r?this.emit("connectAbort",{code:t,reason:e}):this.emit("disconnect",{code:t,reason:e}),this.emit("close",{code:t,reason:e}),!ce.ignoreStatuses[t]){let r;r="string"==typeof e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;let n=new se(ce.errorStatuses[t]||r,t);this._onError(n)}this._abortAllPendingEventsDueToBadConnection(r?"connectAbort":"disconnect",t,e),this.options.autoReconnect&&(4e3===t||4001===t||1005===t?this._tryReconnect(0):1e3!==t&&t<4500&&this._tryReconnect())},ce.prototype._onInboundTransmit=function(t,e){let r=this._privateDataHandlerMap[t];r?r.call(this,e||{}):ue(t)?this._onError(new oe(`The ${t} event name is reserved and cannot be received`)):this._receiverDemux.write(t,e)},ce.prototype._onInboundInvoke=function(t){let{procedure:e,data:r}=t,n=this._privateRPCHandlerMap[e];if(n)n.call(this,r,t);else if(ue(e)){let r=new oe(`The ${e} procedure name is reserved and cannot be invoked`);delete r.stack,t.error(r)}else this._procedureDemux.write(e,t)},ce.prototype.decode=function(t){return this.transport.decode(t)},ce.prototype.encode=function(t){return this.transport.encode(t)},ce.prototype._flushOutboundBuffer=function(){let t,e=this._outboundBuffer.head;for(;e;){t=e.next;let r=e.data;r.callback||(clearTimeout(r.timeout),delete r.timeout),e.detach(),this.transport.transmitObject(r),e=t}},ce.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;let r=t.callback;if(r){delete t.callback;let e=new ie(`Event response for ${t.event} event timed out`);r.call(t,e,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},ce.prototype._processOutboundEvent=function(t,e,r,n){r=r||{},this.transport&&this.transport.isStale()&&this.disconnect(1e3,"Stale socket was disconnected by the client to initiate a new connection"),this.state===this.CLOSED&&this.connect();let o,s={event:t};o=n?new Promise((t,e)=>{s.callback=(r,n)=>{r?e(r):t(n)}}):Promise.resolve();let i=new Xt.Item;this.options.cloneData?s.data=Zt(e):s.data=e,i.data=s;let a=null==r.ackTimeout?this.ackTimeout:r.ackTimeout;return s.timeout=setTimeout(()=>{this._handleEventAckTimeout(s,i)},a),this._outboundBuffer.append(i),this.state===this.OPEN&&this._flushOutboundBuffer(),o},ce.prototype.send=function(t){this.transport.send(t)},ce.prototype.transmit=function(t,e,r){return this._processOutboundEvent(t,e,r)},ce.prototype.invoke=function(t,e,r){return this._processOutboundEvent(t,e,r,!0)},ce.prototype.transmitPublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.transmit("#publish",r)},ce.prototype.invokePublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.invoke("#publish",r)},ce.prototype._triggerChannelSubscribe=function(t,e){let r=t.name;if(t.state!==Kt.SUBSCRIBED){let n=t.state;t.state=Kt.SUBSCRIBED;let o={oldChannelState:n,newChannelState:t.state,subscriptionOptions:e};this._channelEventDemux.write(`${r}/subscribeStateChange`,o),this._channelEventDemux.write(`${r}/subscribe`,{subscriptionOptions:e}),this.emit("subscribeStateChange",{channel:r,...o}),this.emit("subscribe",{channel:r,subscriptionOptions:e})}},ce.prototype._triggerChannelSubscribeFail=function(t,e,r){let n=e.name,o=!e.options.waitForAuth||this.authState===this.AUTHENTICATED;!!this._channelMap[n]&&o&&(delete this._channelMap[n],this._channelEventDemux.write(`${n}/subscribeFail`,{error:t,subscriptionOptions:r}),this.emit("subscribeFail",{error:t,channel:n,subscriptionOptions:r}))},ce.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},ce.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},ce.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0===t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},ce.prototype.startBatch=function(){this.transport.startBatch()},ce.prototype.flushBatch=function(){this.transport.flushBatch()},ce.prototype.cancelBatch=function(){this.transport.cancelBatch()},ce.prototype._startBatching=function(){null==this._batchingIntervalId&&(this.startBatch(),this._batchingIntervalId=setInterval(()=>{this.flushBatch(),this.startBatch()},this.options.batchInterval))},ce.prototype.startBatching=function(){this.isBatching=!0,this._startBatching()},ce.prototype._stopBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.flushBatch()},ce.prototype.stopBatching=function(){this.isBatching=!1,this._stopBatching()},ce.prototype._cancelBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.cancelBatch()},ce.prototype.cancelBatching=function(){this.isBatching=!1,this._cancelBatching()},ce.prototype._trySubscribe=function(t){let e=!t.options.waitForAuth||this.authState===this.AUTHENTICATED;if(this.state===this.OPEN&&!this.preparingPendingSubscriptions&&null==t._pendingSubscriptionCid&&e){let e={noTimeout:!0},r={};t.options.waitForAuth&&(e.waitForAuth=!0,r.waitForAuth=e.waitForAuth),t.options.data&&(r.data=t.options.data),t._pendingSubscriptionCid=this.transport.invokeRaw("#subscribe",{channel:this._decorateChannelName(t.name),...r},e,e=>{if(e){if("BadConnectionError"===e.name)return;delete t._pendingSubscriptionCid,this._triggerChannelSubscribeFail(e,t,r)}else delete t._pendingSubscriptionCid,this._triggerChannelSubscribe(t,r)}),this.emit("subscribeRequest",{channel:t.name,subscriptionOptions:r})}},ce.prototype.subscribe=function(t,e){e=e||{};let r=this._channelMap[t],n={waitForAuth:!!e.waitForAuth};return null!=e.priority&&(n.priority=e.priority),void 0!==e.data&&(n.data=e.data),r?e&&(r.options=n):(r={name:t,state:Kt.PENDING,options:n},this._channelMap[t]=r,this._trySubscribe(r)),new Kt(t,this,this._channelEventDemux,this._channelDataDemux)},ce.prototype._triggerChannelUnsubscribe=function(t,e){let r=t.name;if(this._cancelPendingSubscribeCallback(t),t.state===Kt.SUBSCRIBED){let n={oldChannelState:t.state,newChannelState:e?Kt.PENDING:Kt.UNSUBSCRIBED};this._channelEventDemux.write(`${r}/subscribeStateChange`,n),this._channelEventDemux.write(`${r}/unsubscribe`,{}),this.emit("subscribeStateChange",{channel:r,...n}),this.emit("unsubscribe",{channel:r})}e?t.state=Kt.PENDING:delete this._channelMap[r]},ce.prototype._tryUnsubscribe=function(t){if(this.state===this.OPEN){let e={noTimeout:!0};this._cancelPendingSubscribeCallback(t);let r=this._decorateChannelName(t.name);this.transport.transmit("#unsubscribe",r,e)}},ce.prototype.unsubscribe=function(t){let e=this._channelMap[t];e&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},ce.prototype.receiver=function(t){return this._receiverDemux.stream(t)},ce.prototype.closeReceiver=function(t){this._receiverDemux.close(t)},ce.prototype.closeAllReceivers=function(){this._receiverDemux.closeAll()},ce.prototype.killReceiver=function(t){this._receiverDemux.kill(t)},ce.prototype.killAllReceivers=function(){this._receiverDemux.killAll()},ce.prototype.killReceiverConsumer=function(t){this._receiverDemux.killConsumer(t)},ce.prototype.getReceiverConsumerStats=function(t){return this._receiverDemux.getConsumerStats(t)},ce.prototype.getReceiverConsumerStatsList=function(t){return this._receiverDemux.getConsumerStatsList(t)},ce.prototype.getAllReceiversConsumerStatsList=function(){return this._receiverDemux.getConsumerStatsListAll()},ce.prototype.getReceiverBackpressure=function(t){return this._receiverDemux.getBackpressure(t)},ce.prototype.getAllReceiversBackpressure=function(){return this._receiverDemux.getBackpressureAll()},ce.prototype.getReceiverConsumerBackpressure=function(t){return this._receiverDemux.getConsumerBackpressure(t)},ce.prototype.hasReceiverConsumer=function(t,e){return this._receiverDemux.hasConsumer(t,e)},ce.prototype.hasAnyReceiverConsumer=function(t){return this._receiverDemux.hasConsumerAll(t)},ce.prototype.procedure=function(t){return this._procedureDemux.stream(t)},ce.prototype.closeProcedure=function(t){this._procedureDemux.close(t)},ce.prototype.closeAllProcedures=function(){this._procedureDemux.closeAll()},ce.prototype.killProcedure=function(t){this._procedureDemux.kill(t)},ce.prototype.killAllProcedures=function(){this._procedureDemux.killAll()},ce.prototype.killProcedureConsumer=function(t){this._procedureDemux.killConsumer(t)},ce.prototype.getProcedureConsumerStats=function(t){return this._procedureDemux.getConsumerStats(t)},ce.prototype.getProcedureConsumerStatsList=function(t){return this._procedureDemux.getConsumerStatsList(t)},ce.prototype.getAllProceduresConsumerStatsList=function(){return this._procedureDemux.getConsumerStatsListAll()},ce.prototype.getProcedureBackpressure=function(t){return this._procedureDemux.getBackpressure(t)},ce.prototype.getAllProceduresBackpressure=function(){return this._procedureDemux.getBackpressureAll()},ce.prototype.getProcedureConsumerBackpressure=function(t){return this._procedureDemux.getConsumerBackpressure(t)},ce.prototype.hasProcedureConsumer=function(t,e){return this._procedureDemux.hasConsumer(t,e)},ce.prototype.hasAnyProcedureConsumer=function(t){return this._procedureDemux.hasConsumerAll(t)},ce.prototype.channel=function(t){return this._channelMap[t],new Kt(t,this,this._channelEventDemux,this._channelDataDemux)},ce.prototype.closeChannel=function(t){this.channelCloseOutput(t),this.channelCloseAllListeners(t)},ce.prototype.closeAllChannelOutputs=function(){this._channelDataDemux.closeAll()},ce.prototype.closeAllChannelListeners=function(){this._channelEventDemux.closeAll()},ce.prototype.closeAllChannels=function(){this.closeAllChannelOutputs(),this.closeAllChannelListeners()},ce.prototype.killChannel=function(t){this.channelKillOutput(t),this.channelKillAllListeners(t)},ce.prototype.killAllChannelOutputs=function(){this._channelDataDemux.killAll()},ce.prototype.killAllChannelListeners=function(){this._channelEventDemux.killAll()},ce.prototype.killAllChannels=function(){this.killAllChannelOutputs(),this.killAllChannelListeners()},ce.prototype.killChannelOutputConsumer=function(t){this._channelDataDemux.killConsumer(t)},ce.prototype.killChannelListenerConsumer=function(t){this._channelEventDemux.killConsumer(t)},ce.prototype.getChannelOutputConsumerStats=function(t){return this._channelDataDemux.getConsumerStats(t)},ce.prototype.getChannelListenerConsumerStats=function(t){return this._channelEventDemux.getConsumerStats(t)},ce.prototype.getAllChannelOutputsConsumerStatsList=function(){return this._channelDataDemux.getConsumerStatsListAll()},ce.prototype.getAllChannelListenersConsumerStatsList=function(){return this._channelEventDemux.getConsumerStatsListAll()},ce.prototype.getChannelBackpressure=function(t){return Math.max(this.channelGetOutputBackpressure(t),this.channelGetAllListenersBackpressure(t))},ce.prototype.getAllChannelOutputsBackpressure=function(){return this._channelDataDemux.getBackpressureAll()},ce.prototype.getAllChannelListenersBackpressure=function(){return this._channelEventDemux.getBackpressureAll()},ce.prototype.getAllChannelsBackpressure=function(){return Math.max(this.getAllChannelOutputsBackpressure(),this.getAllChannelListenersBackpressure())},ce.prototype.getChannelListenerConsumerBackpressure=function(t){return this._channelEventDemux.getConsumerBackpressure(t)},ce.prototype.getChannelOutputConsumerBackpressure=function(t){return this._channelDataDemux.getConsumerBackpressure(t)},ce.prototype.hasAnyChannelOutputConsumer=function(t){return this._channelDataDemux.hasConsumerAll(t)},ce.prototype.hasAnyChannelListenerConsumer=function(t){return this._channelEventDemux.hasConsumerAll(t)},ce.prototype.getChannelState=function(t){let e=this._channelMap[t];return e?e.state:Kt.UNSUBSCRIBED},ce.prototype.getChannelOptions=function(t){let e=this._channelMap[t];return e?{...e.options}:{}},ce.prototype._getAllChannelStreamNames=function(t){let e=this._channelEventDemux.getConsumerStatsListAll().filter(e=>0===e.stream.indexOf(`${t}/`)).reduce((t,e)=>(t[e.stream]=!0,t),{});return Object.keys(e)},ce.prototype.channelCloseOutput=function(t){this._channelDataDemux.close(t)},ce.prototype.channelCloseListener=function(t,e){this._channelEventDemux.close(`${t}/${e}`)},ce.prototype.channelCloseAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.close(t)})},ce.prototype.channelKillOutput=function(t){this._channelDataDemux.kill(t)},ce.prototype.channelKillListener=function(t,e){this._channelEventDemux.kill(`${t}/${e}`)},ce.prototype.channelKillAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.kill(t)})},ce.prototype.channelGetOutputConsumerStatsList=function(t){return this._channelDataDemux.getConsumerStatsList(t)},ce.prototype.channelGetListenerConsumerStatsList=function(t,e){return this._channelEventDemux.getConsumerStatsList(`${t}/${e}`)},ce.prototype.channelGetAllListenersConsumerStatsList=function(t){return this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getConsumerStatsList(t)).reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])},ce.prototype.channelGetOutputBackpressure=function(t){return this._channelDataDemux.getBackpressure(t)},ce.prototype.channelGetListenerBackpressure=function(t,e){return this._channelEventDemux.getBackpressure(`${t}/${e}`)},ce.prototype.channelGetAllListenersBackpressure=function(t){let e=this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getBackpressure(t));return Math.max(...e.concat(0))},ce.prototype.channelHasOutputConsumer=function(t,e){return this._channelDataDemux.hasConsumer(t,e)},ce.prototype.channelHasListenerConsumer=function(t,e,r){return this._channelEventDemux.hasConsumer(`${t}/${e}`,r)},ce.prototype.channelHasAnyListenerConsumer=function(t,e){return this._getAllChannelStreamNames(t).some(t=>this._channelEventDemux.hasConsumer(t,e))},ce.prototype.subscriptions=function(t){let e=[];return Object.keys(this._channelMap).forEach(r=>{(t||this._channelMap[r].state===Kt.SUBSCRIBED)&&e.push(r)}),e},ce.prototype.isSubscribed=function(t,e){let r=this._channelMap[t];return e?!!r:!!r&&r.state===Kt.SUBSCRIBED},ce.prototype.processPendingSubscriptions=function(){this.preparingPendingSubscriptions=!1;let t=[];Object.keys(this._channelMap).forEach(e=>{let r=this._channelMap[e];r.state===Kt.PENDING&&t.push(r)}),t.sort((t,e)=>{let r=t.options.priority||0,n=e.options.priority||0;return r>n?-1:r<n?1:0}),t.forEach(t=>{this._trySubscribe(t)})};var he=ce,le=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function pe(t){return"string"==typeof t&&le.test(t)}function fe(t){if(!pe(t))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(t.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,255&e,(e=parseInt(t.slice(9,13),16))>>>8,255&e,(e=parseInt(t.slice(14,18),16))>>>8,255&e,(e=parseInt(t.slice(19,23),16))>>>8,255&e,(e=parseInt(t.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,255&e)}const me=[];for(let t=0;t<256;++t)me.push((t+256).toString(16).slice(1));function de(t,e=0){return(me[t[e+0]]+me[t[e+1]]+me[t[e+2]]+me[t[e+3]]+"-"+me[t[e+4]]+me[t[e+5]]+"-"+me[t[e+6]]+me[t[e+7]]+"-"+me[t[e+8]]+me[t[e+9]]+"-"+me[t[e+10]]+me[t[e+11]]+me[t[e+12]]+me[t[e+13]]+me[t[e+14]]+me[t[e+15]]).toLowerCase()}const ye=new Uint8Array(16);function ge(){return crypto.getRandomValues(ye)}const be={};function ke(t,e,r){let n;const o=t?._v6??!1;if(t){const e=Object.keys(t);1===e.length&&"_v6"===e[0]&&(t=void 0)}if(t)n=ve(t.random??t.rng?.()??ge(),t.msecs,t.nsecs,t.clockseq,t.node,e,r);else{const t=Date.now(),s=ge();!function(t,e,r){t.msecs??=-1/0,t.nsecs??=0,e===t.msecs?(t.nsecs++,t.nsecs>=1e4&&(t.node=void 0,t.nsecs=0)):e>t.msecs?t.nsecs=0:e<t.msecs&&(t.node=void 0);t.node||(t.node=r.slice(10,16),t.node[0]|=1,t.clockseq=16383&(r[8]<<8|r[9]));t.msecs=e}(be,t,s),n=ve(s,be.msecs,be.nsecs,o?void 0:be.clockseq,o?void 0:be.node,e,r)}return e??de(n)}function ve(t,e,r,n,o,s,i=0){if(t.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(i<0||i+16>s.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else s=new Uint8Array(16),i=0;e??=Date.now(),r??=0,n??=16383&(t[8]<<8|t[9]),null==o&&((o=t.slice(10,16))[0]|=1);const a=1e4*(268435455&(e+=122192928e5))+r,u=a>>>0;s[i++]=u>>>24&255,s[i++]=u>>>16&255,s[i++]=u>>>8&255,s[i++]=255&u;const c=625*(e/268435456|0)+(a/4294967296|0)&268435455;s[i++]=c>>>8&255,s[i++]=255&c,s[i++]=c>>>24&15|16,s[i++]=c>>>16&255,s[i++]=n>>>8|128,s[i++]=255&n;for(let t=0;t<6;++t)s[i++]=o[t];return s}function Ee(t){const e=function(t){return Uint8Array.of((15&t[6])<<4|t[7]>>4&15,(15&t[7])<<4|(240&t[4])>>4,(15&t[4])<<4|(240&t[5])>>4,(15&t[5])<<4|(240&t[0])>>4,(15&t[0])<<4|(240&t[1])>>4,(15&t[1])<<4|(240&t[2])>>4,96|15&t[2],t[3],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}("string"==typeof t?fe(t):t);return"string"==typeof t?de(e):e}function Ce(t){const e=function(t){if(0===t.length)return new Uint32Array;const e=new Uint32Array(we(8*t.length)).fill(0);for(let r=0;r<t.length;r++)e[r>>2]|=(255&t[r])<<r%4*8;return e}(t),r=function(t,e){const r=new Uint32Array(we(e)).fill(0);r.set(t),r[e>>5]|=128<<e%32,r[r.length-1]=e,t=r;let n=1732584193,o=-271733879,s=-1732584194,i=271733878;for(let e=0;e<t.length;e+=16){const r=n,a=o,u=s,c=i;n=Te(n,o,s,i,t[e],7,-680876936),i=Te(i,n,o,s,t[e+1],12,-389564586),s=Te(s,i,n,o,t[e+2],17,606105819),o=Te(o,s,i,n,t[e+3],22,-1044525330),n=Te(n,o,s,i,t[e+4],7,-176418897),i=Te(i,n,o,s,t[e+5],12,1200080426),s=Te(s,i,n,o,t[e+6],17,-1473231341),o=Te(o,s,i,n,t[e+7],22,-45705983),n=Te(n,o,s,i,t[e+8],7,1770035416),i=Te(i,n,o,s,t[e+9],12,-1958414417),s=Te(s,i,n,o,t[e+10],17,-42063),o=Te(o,s,i,n,t[e+11],22,-1990404162),n=Te(n,o,s,i,t[e+12],7,1804603682),i=Te(i,n,o,s,t[e+13],12,-40341101),s=Te(s,i,n,o,t[e+14],17,-1502002290),o=Te(o,s,i,n,t[e+15],22,1236535329),n=Se(n,o,s,i,t[e+1],5,-165796510),i=Se(i,n,o,s,t[e+6],9,-1069501632),s=Se(s,i,n,o,t[e+11],14,643717713),o=Se(o,s,i,n,t[e],20,-373897302),n=Se(n,o,s,i,t[e+5],5,-701558691),i=Se(i,n,o,s,t[e+10],9,38016083),s=Se(s,i,n,o,t[e+15],14,-660478335),o=Se(o,s,i,n,t[e+4],20,-405537848),n=Se(n,o,s,i,t[e+9],5,568446438),i=Se(i,n,o,s,t[e+14],9,-1019803690),s=Se(s,i,n,o,t[e+3],14,-187363961),o=Se(o,s,i,n,t[e+8],20,1163531501),n=Se(n,o,s,i,t[e+13],5,-1444681467),i=Se(i,n,o,s,t[e+2],9,-51403784),s=Se(s,i,n,o,t[e+7],14,1735328473),o=Se(o,s,i,n,t[e+12],20,-1926607734),n=Be(n,o,s,i,t[e+5],4,-378558),i=Be(i,n,o,s,t[e+8],11,-2022574463),s=Be(s,i,n,o,t[e+11],16,1839030562),o=Be(o,s,i,n,t[e+14],23,-35309556),n=Be(n,o,s,i,t[e+1],4,-1530992060),i=Be(i,n,o,s,t[e+4],11,1272893353),s=Be(s,i,n,o,t[e+7],16,-155497632),o=Be(o,s,i,n,t[e+10],23,-1094730640),n=Be(n,o,s,i,t[e+13],4,681279174),i=Be(i,n,o,s,t[e],11,-358537222),s=Be(s,i,n,o,t[e+3],16,-722521979),o=Be(o,s,i,n,t[e+6],23,76029189),n=Be(n,o,s,i,t[e+9],4,-640364487),i=Be(i,n,o,s,t[e+12],11,-421815835),s=Be(s,i,n,o,t[e+15],16,530742520),o=Be(o,s,i,n,t[e+2],23,-995338651),n=Oe(n,o,s,i,t[e],6,-198630844),i=Oe(i,n,o,s,t[e+7],10,1126891415),s=Oe(s,i,n,o,t[e+14],15,-1416354905),o=Oe(o,s,i,n,t[e+5],21,-57434055),n=Oe(n,o,s,i,t[e+12],6,1700485571),i=Oe(i,n,o,s,t[e+3],10,-1894986606),s=Oe(s,i,n,o,t[e+10],15,-1051523),o=Oe(o,s,i,n,t[e+1],21,-2054922799),n=Oe(n,o,s,i,t[e+8],6,1873313359),i=Oe(i,n,o,s,t[e+15],10,-30611744),s=Oe(s,i,n,o,t[e+6],15,-1560198380),o=Oe(o,s,i,n,t[e+13],21,1309151649),n=Oe(n,o,s,i,t[e+4],6,-145523070),i=Oe(i,n,o,s,t[e+11],10,-1120210379),s=Oe(s,i,n,o,t[e+2],15,718787259),o=Oe(o,s,i,n,t[e+9],21,-343485551),n=_e(n,r),o=_e(o,a),s=_e(s,u),i=_e(i,c)}return Uint32Array.of(n,o,s,i)}(e,8*t.length);return function(t){const e=new Uint8Array(4*t.length);for(let r=0;r<4*t.length;r++)e[r]=t[r>>2]>>>r%4*8&255;return e}(r)}function we(t){return 14+(t+64>>>9<<4)+1}function _e(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function Ae(t,e,r,n,o,s){return _e((i=_e(_e(e,t),_e(n,s)))<<(a=o)|i>>>32-a,r);var i,a}function Te(t,e,r,n,o,s,i){return Ae(e&r|~e&n,t,e,o,s,i)}function Se(t,e,r,n,o,s,i){return Ae(e&n|r&~n,t,e,o,s,i)}function Be(t,e,r,n,o,s,i){return Ae(e^r^n,t,e,o,s,i)}function Oe(t,e,r,n,o,s,i){return Ae(r^(e|~n),t,e,o,s,i)}const De="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ie="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function xe(t,e,r,n,o,s){const i="string"==typeof r?function(t){t=unescape(encodeURIComponent(t));const e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r);return e}(r):r,a="string"==typeof n?fe(n):n;if("string"==typeof n&&(n=fe(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+i.length);if(u.set(a),u.set(i,a.length),u=e(u),u[6]=15&u[6]|t,u[8]=63&u[8]|128,o){if(s??=0,s<0||s+16>o.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`);for(let t=0;t<16;++t)o[s+t]=u[t];return o}return de(u)}function Ne(t,e,r,n){return xe(48,Ce,t,e,r,n)}function Le(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function Ue(t,e){return t<<e|t>>>32-e}function Pe(t){const e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(t.length+1);n.set(t),n[t.length]=128;const o=(t=n).length/4+2,s=Math.ceil(o/16),i=new Array(s);for(let e=0;e<s;++e){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=t[64*e+4*n]<<24|t[64*e+4*n+1]<<16|t[64*e+4*n+2]<<8|t[64*e+4*n+3];i[e]=r}i[s-1][14]=8*(t.length-1)/2**32,i[s-1][14]=Math.floor(i[s-1][14]),i[s-1][15]=8*(t.length-1)&4294967295;for(let t=0;t<s;++t){const n=new Uint32Array(80);for(let e=0;e<16;++e)n[e]=i[t][e];for(let t=16;t<80;++t)n[t]=Ue(n[t-3]^n[t-8]^n[t-14]^n[t-16],1);let o=r[0],s=r[1],a=r[2],u=r[3],c=r[4];for(let t=0;t<80;++t){const r=Math.floor(t/20),i=Ue(o,5)+Le(r,s,a,u)+c+e[r]+n[t]>>>0;c=u,u=a,a=Ue(s,30)>>>0,s=o,o=i}r[0]=r[0]+o>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+u>>>0,r[4]=r[4]+c>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function Re(t,e,r,n){return xe(80,Pe,t,e,r,n)}Ne.DNS=De,Ne.URL=Ie,Re.DNS=De,Re.URL=Ie;const je={};function Me(t,e,r,n,o=0){if(t.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(o<0||o+16>n.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else n=new Uint8Array(16),o=0;return e??=Date.now(),r??=He(t),n[o++]=e/1099511627776&255,n[o++]=e/4294967296&255,n[o++]=e/16777216&255,n[o++]=e/65536&255,n[o++]=e/256&255,n[o++]=255&e,n[o++]=112|r>>>28&15,n[o++]=r>>>20&255,n[o++]=128|r>>>14&63,n[o++]=r>>>6&255,n[o++]=r<<2&255|3&t[10],n[o++]=t[11],n[o++]=t[12],n[o++]=t[13],n[o++]=t[14],n[o++]=t[15],n}function He(t){return(127&t[6])<<24|t[7]<<16|t[8]<<8|t[9]}var Ge=Object.freeze({__proto__:null,MAX:"ffffffff-ffff-ffff-ffff-ffffffffffff",NIL:"00000000-0000-0000-0000-000000000000",parse:fe,stringify:function(t,e=0){const r=de(t,e);if(!pe(r))throw TypeError("Stringified UUID is invalid");return r},v1:ke,v1ToV6:Ee,v3:Ne,v4:function(t,e,r){return e||t||!crypto.randomUUID?function(t,e,r){t=t||{};const n=t.random??t.rng?.()??ge();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){if((r=r||0)<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[r+t]=n[t];return e}return de(n)}(t,e,r):crypto.randomUUID()},v5:Re,v6:function(t,e,r){t??={},r??=0;let n=ke({...t,_v6:!0},new Uint8Array(16));if(n=Ee(n),e){if(r<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;t++)e[r+t]=n[t];return e}return de(n)},v6ToV1:function(t){const e=function(t){return Uint8Array.of((15&t[3])<<4|t[4]>>4&15,(15&t[4])<<4|(240&t[5])>>4,(15&t[5])<<4|15&t[6],t[7],(15&t[1])<<4|(240&t[2])>>4,(15&t[2])<<4|(240&t[3])>>4,16|(240&t[0])>>4,(15&t[0])<<4|(240&t[1])>>4,t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}("string"==typeof t?fe(t):t);return"string"==typeof t?de(e):e},v7:function(t,e,r){let n;if(t)n=Me(t.random??t.rng?.()??ge(),t.msecs,t.seq,e,r);else{const t=Date.now(),o=ge();!function(t,e,r){t.msecs??=-1/0,t.seq??=0,e>t.msecs?(t.seq=He(r),t.msecs=e):(t.seq=t.seq+1|0,0===t.seq&&t.msecs++)}(je,t,o),n=Me(o,je.msecs,je.seq,e,r)}return e??de(n)},validate:pe,version:function(t){if(!pe(t))throw TypeError("Invalid UUID");return parseInt(t.slice(14,15),16)}});const $e=he,Fe=e(Ge),qe=Y.InvalidArgumentsError,ze=/^(\[[0-9A-Fa-f:.]+\]|[^:/?#@[\]]+):(\d{1,5})$/;function Qe(t,e){let r=null==t.secure?e:t.secure;return t.port||("undefined"!=typeof location&&location.port?location.port:r?443:80)}const Ve=he,Ke={create:function(t){if((t=t||{}).host&&!function(t){let e=`${t}`.match(ze);return!!e&&Number(e[2])<=65535}(t.host))throw new qe("The host option should include both the hostname and the port number in the hostname:port format and must not contain any other characters");if(t.host&&t.hostname)throw new qe("The host option should already include the hostname and the port number in the hostname:port format - Because of this, you should never use host and hostname options together");if(t.host&&t.port)throw new qe("The host option should already include the hostname and the port number in the hostname:port format - Because of this, you should never use host and port options together");let e="undefined"!=typeof location&&"https:"===location.protocol,r={clientId:Fe.v4(),port:Qe(t,e),hostname:"undefined"!=typeof location&&location.hostname||"localhost",secure:e};return Object.assign(r,t),new $e(r)}},We="21.0.0";var Ye=r.factory=Ke,Je=r.AGClientSocket=Ve,Xe=r.create=function(t){return Ke.create({...t,version:We})},Ze=r.version=We,tr=t({__proto__:null,AGClientSocket:Je,create:Xe,default:r,factory:Ye,version:Ze},[r]);const{factory:er,AGClientSocket:rr,create:nr,version:or}=tr;export{rr as AGClientSocket,nr as create,er as factory,or as version};