diff --git a/index.js b/index.js index 147b9b2..ccfc0e0 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const AGClientSocket = require('./lib/clientsocket'); const factory = require('./lib/factory'); -const version = '15.1.0'; +const version = '16.0.1'; module.exports.factory = factory; module.exports.AGClientSocket = AGClientSocket; diff --git a/package.json b/package.json index 4e6a0f4..7b5bde8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "socketcluster-client", "description": "SocketCluster JavaScript client", - "version": "16.0.0", + "version": "16.0.1", "homepage": "https://socketcluster.io/", "contributors": [ { diff --git a/socketcluster-client.js b/socketcluster-client.js index c9e45cd..ef0ce11 100644 --- a/socketcluster-client.js +++ b/socketcluster-client.js @@ -1,5 +1,5 @@ /** - * SocketCluster JavaScript client v16.0.0 + * SocketCluster JavaScript client v16.0.1 */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.socketClusterClient = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i{if(this[t]>i)throw new m(`The ${t} value provided exceeded the maximum amount allowed`)};if(u("connectTimeout"),u("ackTimeout"),u("pingTimeout"),this.connectAttempts=0,this.isBatching=!1,this.batchOnHandshake=e.batchOnHandshake,this.batchOnHandshakeDuration=e.batchOnHandshakeDuration,this._batchingIntervalId=null,this._outboundBuffer=new h,this._channelMap={},this._channelEventDemux=new n,this._channelDataDemux=new n,this._receiverDemux=new n,this._procedureDemux=new n,this.options=e,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 s,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=a,this.options.protocol){let t=new m('The "protocol" option does not affect socketcluster-client - If you want to utilize SSL/TLS, use "secure" option instead');this._onError(t)}this.options.query=e.query||{},"string"==typeof this.options.query&&(this.options.query=c.parse(this.options.query)),v&&this.disconnectOnUnload&&r.addEventListener&&r.removeEventListener&&this._handleBrowserUnload(),this.options.autoConnect&&this.connect()}E.prototype=Object.create(o.prototype),E.CONNECTING=E.prototype.CONNECTING=u.prototype.CONNECTING,E.OPEN=E.prototype.OPEN=u.prototype.OPEN,E.CLOSED=E.prototype.CLOSED=u.prototype.CLOSED,E.AUTHENTICATED=E.prototype.AUTHENTICATED="authenticated",E.UNAUTHENTICATED=E.prototype.UNAUTHENTICATED="unauthenticated",E.SUBSCRIBED=E.prototype.SUBSCRIBED=i.SUBSCRIBED,E.PENDING=E.prototype.PENDING=i.PENDING,E.UNSUBSCRIBED=E.prototype.UNSUBSCRIBED=i.UNSUBSCRIBED,E.ignoreStatuses=d.socketProtocolIgnoreStatuses,E.errorStatuses=d.socketProtocolErrorStatuses,Object.defineProperty(E.prototype,"isBufferingBatch",{get:function(){return this.transport.isBufferingBatch}}),E.prototype.getBackpressure=function(){return Math.max(this.getAllListenersBackpressure(),this.getAllReceiversBackpressure(),this.getAllProceduresBackpressure(),this.getAllChannelsBackpressure())},E.prototype._handleBrowserUnload=async function(){let t=()=>{this.disconnect()},e=!1;(async()=>{let n=this.listener("connecting").createConsumer();for(;;){if((await n.next()).done)break;e||(e=!0,r.addEventListener("beforeunload",t,!1))}})(),(async()=>{let n=this.listener("close").createConsumer();for(;;){if((await n.next()).done)break;e&&(e=!1,r.removeEventListener("beforeunload",t,!1))}})()},E.prototype._setAuthToken=function(t){this._changeToAuthenticatedState(t.token),(async()=>{try{await this.auth.saveToken(this.authTokenName,t.token,{})}catch(t){this._onError(t)}})()},E.prototype._removeAuthToken=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._changeToUnauthenticatedStateAndClearTokens()},E.prototype._privateDataHandlerMap={"#publish":function(t){let e=this._undecorateChannelName(t.channel);this.isSubscribed(e,!0)&&this._channelDataDemux.write(e,t.data)},"#kickOut":function(t){let e=this._undecorateChannelName(t.channel),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&&this._setAuthToken(t)},"#removeAuthToken":function(t){this._removeAuthToken(t)}},E.prototype._privateRPCHandlerMap={"#setAuthToken":function(t,e){t?(this._setAuthToken(t),e.end()):e.error(new y("No token data provided by #setAuthToken event"))},"#removeAuthToken":function(t,e){this._removeAuthToken(t),e.end()}},E.prototype.getState=function(){return this.state},E.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},E.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 f(0)},E.prototype.connect=function(){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(),this.transport=new u(this.auth,this.codec,this.options,this.wsOptions,{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)}}))},E.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},E.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new m("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))},E.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})}},E.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})},E.prototype.decodeBase64=function(t){return p.from(t,"base64").toString("utf8")},E.prototype.encodeBase64=function(t){return p.from(t,"utf8").toString("base64")},E.prototype._extractAuthTokenData=function(t){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},E.prototype.getAuthToken=function(){return this.authToken},E.prototype.getSignedAuthToken=function(){return this.signedAuthToken},E.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 f(0),t}return e&&null!=e.isAuthenticated?e.authError&&(e.authError=d.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 f(0),e},E.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)},E.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()},E.prototype._onError=function(t){this.emit("error",{error:t})},E.prototype._suspendSubscriptions=function(){Object.keys(this._channelMap).forEach(t=>{let e=this._channelMap[t];this._triggerChannelUnsubscribe(e,!0)})},E.prototype._abortAllPendingEventsDueToBadConnection=function(t){let e,r=this._outboundBuffer.head;for(;r;){e=r.next;let n=r.data;clearTimeout(n.timeout),delete n.timeout,r.detach(),r=e;let o=n.callback;if(o){delete n.callback;let e=`Event "${n.event}" was aborted due to a bad connection`,r=new k(e,t);o.call(n,r,n)}n.cid&&this.transport.cancelPendingResponse(n.cid)}},E.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}),!E.ignoreStatuses[t]){let r;r=e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;let n=new g(E.errorStatuses[t]||r,t);this._onError(n)}this._abortAllPendingEventsDueToBadConnection(r?"connectAbort":"disconnect"),this.options.autoReconnect&&(4e3===t||4001===t||1005===t?this._tryReconnect(0):1e3!==t&&t<4500&&this._tryReconnect())},E.prototype._onInboundTransmit=function(t,e){let r=this._privateDataHandlerMap[t];r?r.call(this,e):this._receiverDemux.write(t,e)},E.prototype._onInboundInvoke=function(t){let{procedure:e,data:r}=t,n=this._privateRPCHandlerMap[e];n?n.call(this,r,t):this._procedureDemux.write(e,t)},E.prototype.decode=function(t){return this.transport.decode(t)},E.prototype.encode=function(t){return this.transport.encode(t)},E.prototype._flushOutboundBuffer=function(){let t,e=this._outboundBuffer.head;for(;e;){t=e.next;let r=e.data;e.detach(),this.transport.transmitObject(r),e=t}},E.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;let r=t.callback;if(r){delete t.callback;let e=new b(`Event response for "${t.event}" timed out`);r.call(t,e,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},E.prototype._processOutboundEvent=function(t,e,r,n){r=r||{},this.state===this.CLOSED&&this.connect();let o,i={event:t};o=n?new Promise((t,e)=>{i.callback=((r,n)=>{r?e(r):t(n)})}):Promise.resolve();let s=new h.Item;this.options.cloneData?i.data=l(e):i.data=e,s.data=i;let a=null==r.ackTimeout?this.ackTimeout:r.ackTimeout;return i.timeout=setTimeout(()=>{this._handleEventAckTimeout(i,s)},a),this._outboundBuffer.append(s),this.state===this.OPEN&&this._flushOutboundBuffer(),o},E.prototype.send=function(t){this.transport.send(t)},E.prototype.transmit=function(t,e,r){return this._processOutboundEvent(t,e,r)},E.prototype.invoke=function(t,e,r){return this._processOutboundEvent(t,e,r,!0)},E.prototype.transmitPublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.transmit("#publish",r)},E.prototype.invokePublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.invoke("#publish",r)},E.prototype._triggerChannelSubscribe=function(t,e){let r=t.name;if(t.state!==i.SUBSCRIBED){let n=t.state;t.state=i.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})}},E.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}))},E.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},E.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},E.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0===t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},E.prototype.startBatch=function(){this.transport.startBatch()},E.prototype.flushBatch=function(){this.transport.flushBatch()},E.prototype.cancelBatch=function(){this.transport.cancelBatch()},E.prototype._startBatching=function(){null==this._batchingIntervalId&&(this.startBatch(),this._batchingIntervalId=setInterval(()=>{this.flushBatch(),this.startBatch()},this.options.batchInterval))},E.prototype.startBatching=function(){this.isBatching=!0,this._startBatching()},E.prototype._stopBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.flushBatch()},E.prototype.stopBatching=function(){this.isBatching=!1,this._stopBatching()},E.prototype._cancelBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.cancelBatch()},E.prototype.cancelBatching=function(){this.isBatching=!1,this._cancelBatching()},E.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})}},E.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:i.PENDING,options:n},this._channelMap[t]=r,this._trySubscribe(r)),new i(t,this,this._channelEventDemux,this._channelDataDemux)},E.prototype._triggerChannelUnsubscribe=function(t,e){let r=t.name;if(this._cancelPendingSubscribeCallback(t),t.state===i.SUBSCRIBED){let n={oldChannelState:t.state,newChannelState:e?i.PENDING:i.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=i.PENDING:delete this._channelMap[r]},E.prototype._tryUnsubscribe=function(t){if(this.state===this.OPEN){this._cancelPendingSubscribeCallback(t);let e=this._decorateChannelName(t.name);this.transport.transmit("#unsubscribe",e,{noTimeout:!0})}},E.prototype.unsubscribe=function(t){let e=this._channelMap[t];e&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},E.prototype.receiver=function(t){return this._receiverDemux.stream(t)},E.prototype.closeReceiver=function(t){this._receiverDemux.close(t)},E.prototype.closeAllReceivers=function(){this._receiverDemux.closeAll()},E.prototype.killReceiver=function(t){this._receiverDemux.kill(t)},E.prototype.killAllReceivers=function(){this._receiverDemux.killAll()},E.prototype.killReceiverConsumer=function(t){this._receiverDemux.killConsumer(t)},E.prototype.getReceiverConsumerStats=function(t){return this._receiverDemux.getConsumerStats(t)},E.prototype.getReceiverConsumerStatsList=function(t){return this._receiverDemux.getConsumerStatsList(t)},E.prototype.getAllReceiversConsumerStatsList=function(){return this._receiverDemux.getConsumerStatsListAll()},E.prototype.getReceiverBackpressure=function(t){return this._receiverDemux.getBackpressure(t)},E.prototype.getAllReceiversBackpressure=function(){return this._receiverDemux.getBackpressureAll()},E.prototype.getReceiverConsumerBackpressure=function(t){return this._receiverDemux.getConsumerBackpressure(t)},E.prototype.hasReceiverConsumer=function(t,e){return this._receiverDemux.hasConsumer(t,e)},E.prototype.hasAnyReceiverConsumer=function(t){return this._receiverDemux.hasConsumerAll(t)},E.prototype.procedure=function(t){return this._procedureDemux.stream(t)},E.prototype.closeProcedure=function(t){this._procedureDemux.close(t)},E.prototype.closeAllProcedures=function(){this._procedureDemux.closeAll()},E.prototype.killProcedure=function(t){this._procedureDemux.kill(t)},E.prototype.killAllProcedures=function(){this._procedureDemux.killAll()},E.prototype.killProcedureConsumer=function(t){this._procedureDemux.killConsumer(t)},E.prototype.getProcedureConsumerStats=function(t){return this._procedureDemux.getConsumerStats(t)},E.prototype.getProcedureConsumerStatsList=function(t){return this._procedureDemux.getConsumerStatsList(t)},E.prototype.getAllProceduresConsumerStatsList=function(){return this._procedureDemux.getConsumerStatsListAll()},E.prototype.getProcedureBackpressure=function(t){return this._procedureDemux.getBackpressure(t)},E.prototype.getAllProceduresBackpressure=function(){return this._procedureDemux.getBackpressureAll()},E.prototype.getProcedureConsumerBackpressure=function(t){return this._procedureDemux.getConsumerBackpressure(t)},E.prototype.hasProcedureConsumer=function(t,e){return this._procedureDemux.hasConsumer(t,e)},E.prototype.hasAnyProcedureConsumer=function(t){return this._procedureDemux.hasConsumerAll(t)},E.prototype.channel=function(t){return this._channelMap[t],new i(t,this,this._channelEventDemux,this._channelDataDemux)},E.prototype.closeChannel=function(t){this.channelCloseOutput(t),this.channelCloseAllListeners(t)},E.prototype.closeAllChannelOutputs=function(){this._channelDataDemux.closeAll()},E.prototype.closeAllChannelListeners=function(){this._channelEventDemux.closeAll()},E.prototype.closeAllChannels=function(){this.closeAllChannelOutputs(),this.closeAllChannelListeners()},E.prototype.killChannel=function(t){this.channelKillOutput(t),this.channelKillAllListeners(t)},E.prototype.killAllChannelOutputs=function(){this._channelDataDemux.killAll()},E.prototype.killAllChannelListeners=function(){this._channelEventDemux.killAll()},E.prototype.killAllChannels=function(){this.killAllChannelOutputs(),this.killAllChannelListeners()},E.prototype.killChannelOutputConsumer=function(t){this._channelDataDemux.killConsumer(t)},E.prototype.killChannelListenerConsumer=function(t){this._channelEventDemux.killConsumer(t)},E.prototype.getChannelOutputConsumerStats=function(t){return this._channelDataDemux.getConsumerStats(t)},E.prototype.getChannelListenerConsumerStats=function(t){return this._channelEventDemux.getConsumerStats(t)},E.prototype.getAllChannelOutputsConsumerStatsList=function(){return this._channelDataDemux.getConsumerStatsListAll()},E.prototype.getAllChannelListenersConsumerStatsList=function(){return this._channelEventDemux.getConsumerStatsListAll()},E.prototype.getChannelBackpressure=function(t){return Math.max(this.channelGetOutputBackpressure(t),this.channelGetAllListenersBackpressure(t))},E.prototype.getAllChannelOutputsBackpressure=function(){return this._channelDataDemux.getBackpressureAll()},E.prototype.getAllChannelListenersBackpressure=function(){return this._channelEventDemux.getBackpressureAll()},E.prototype.getAllChannelsBackpressure=function(){return Math.max(this.getAllChannelOutputsBackpressure(),this.getAllChannelListenersBackpressure())},E.prototype.getChannelListenerConsumerBackpressure=function(t){return this._channelEventDemux.getConsumerBackpressure(t)},E.prototype.getChannelOutputConsumerBackpressure=function(t){return this._channelDataDemux.getConsumerBackpressure(t)},E.prototype.hasAnyChannelOutputConsumer=function(t){return this._channelDataDemux.hasConsumerAll(t)},E.prototype.hasAnyChannelListenerConsumer=function(t){return this._channelEventDemux.hasConsumerAll(t)},E.prototype.getChannelState=function(t){let e=this._channelMap[t];return e?e.state:i.UNSUBSCRIBED},E.prototype.getChannelOptions=function(t){let e=this._channelMap[t];return e?{...e.options}:{}},E.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)},E.prototype.channelCloseOutput=function(t){this._channelDataDemux.close(t)},E.prototype.channelCloseListener=function(t,e){this._channelEventDemux.close(`${t}/${e}`)},E.prototype.channelCloseAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.close(t)})},E.prototype.channelKillOutput=function(t){this._channelDataDemux.kill(t)},E.prototype.channelKillListener=function(t,e){this._channelEventDemux.kill(`${t}/${e}`)},E.prototype.channelKillAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.kill(t)})},E.prototype.channelGetOutputConsumerStatsList=function(t){return this._channelDataDemux.getConsumerStatsList(t)},E.prototype.channelGetListenerConsumerStatsList=function(t,e){return this._channelEventDemux.getConsumerStatsList(`${t}/${e}`)},E.prototype.channelGetAllListenersConsumerStatsList=function(t){return this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getConsumerStatsList(t)).reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])},E.prototype.channelGetOutputBackpressure=function(t){return this._channelDataDemux.getBackpressure(t)},E.prototype.channelGetListenerBackpressure=function(t,e){return this._channelEventDemux.getBackpressure(`${t}/${e}`)},E.prototype.channelGetAllListenersBackpressure=function(t){let e=this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getBackpressure(t));return Math.max(...e.concat(0))},E.prototype.channelHasOutputConsumer=function(t,e){return this._channelDataDemux.hasConsumer(t,e)},E.prototype.channelHasListenerConsumer=function(t,e,r){return this._channelEventDemux.hasConsumer(`${t}/${e}`,r)},E.prototype.channelHasAnyListenerConsumer=function(t,e){return this._getAllChannelStreamNames(t).some(t=>this._channelEventDemux.hasConsumer(t,e))},E.prototype.subscriptions=function(t){let e=[];return Object.keys(this._channelMap).forEach(r=>{(t||this._channelMap[r].state===i.SUBSCRIBED)&&e.push(r)}),e},E.prototype.isSubscribed=function(t,e){let r=this._channelMap[t];return e?!!r:!!r&&r.state===i.SUBSCRIBED},E.prototype.processPendingSubscriptions=function(){this.preparingPendingSubscriptions=!1;let t=[];Object.keys(this._channelMap).forEach(e=>{let r=this._channelMap[e];r.state===i.PENDING&&t.push(r)}),t.sort((t,e)=>{let r=t.options.priority||0,n=e.options.priority||0;return r>n?-1:r{this._trySubscribe(t)})},e.exports=E}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./auth":1,"./transport":4,"./wait":5,"ag-channel":7,"async-stream-emitter":9,"buffer/":11,"clone-deep":12,"linked-list":19,querystring:22,"sc-errors":24,"sc-formatter":25,"stream-demux":28}],3:[function(t,e){(function(r){const n=t("./clientsocket"),o=t("uuid"),i=t("sc-errors").InvalidArgumentsError;e.exports={create:function(t){if((t=t||{}).host&&!t.host.match(/[^:]+:\d{2,5}/))throw new i('The host option should include both the hostname and the port number in the format "hostname:port"');if(t.host&&t.hostname)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and hostname options together');if(t.host&&t.port)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and port options together');let e=r.location&&"https:"===location.protocol,s={clientId:o.v4(),port:function(t,e){let n=null==t.secure?e:t.secure;return t.port||(r.location&&location.port?location.port:n?443:80)}(t,e),hostname:r.location&&location.hostname||"localhost",secure:e};return Object.assign(s,t),new n(s)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./clientsocket":2,"sc-errors":24,uuid:29}],4:[function(t,e){(function(r){const n=t("ag-request"),o=t("querystring");let i,s;r.WebSocket?(i=r.WebSocket,s=function(t){return new i(t)}):(i=t("ws"),s=function(t,e){return new i(t,null,e)});const a=t("sc-errors"),u=a.TimeoutError,c=a.BadConnectionError;function h(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={},this._batchBuffer=[],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 i=this.uri(),a=s(i,n);a.binaryType=this.options.binaryType,this.socket=a,a.onopen=(()=>{this._onOpen()}),a.onclose=(async t=>{let e;e=null==t.code?1005:t.code,this._destroy(e,t.reason)}),a.onmessage=(t=>{this._onMessage(t.data)}),a.onerror=(()=>{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))}h.CONNECTING=h.prototype.CONNECTING="connecting",h.OPEN=h.prototype.OPEN="open",h.CLOSED=h.prototype.CLOSED="closed",h.prototype.uri=function(){let t,e,r,n=this.options.query||{};if(t=null==this.options.protocolScheme?this.options.secure?"wss":"ws":this.options.protocolScheme,this.options.timestampRequests&&(n[this.options.timestampParam]=(new Date).getTime()),(n=o.encode(n)).length&&(n="?"+n),null==this.options.socketPath){if(this.options.host)e=this.options.host;else{let r="";this.options.port&&("wss"===t&&443!==this.options.port||"ws"===t&&80!==this.options.port)&&(r=":"+this.options.port),e=this.options.hostname+r}r=this.options.path}else e=this.options.socketPath,r=`:${this.options.path}`;return t+"://"+e+r+n},h.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&&(this.pingTimeout=t.pingTimeout),this._resetPingTimeout(),this._onOpenHandler(t)},h.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=a.hydrateError(e.authError))),e},h.prototype._abortAllPendingEventsDueToBadConnection=function(t){Object.keys(this._callbackMap||{}).forEach(e=>{let r=this._callbackMap[e];delete this._callbackMap[e],clearTimeout(r.timeout),delete r.timeout;let n=`Event "${r.event}" was aborted due to a bad connection`,o=new c(n,t),i=r.callback;delete r.callback,i.call(r,o,r)})},h.prototype._destroy=function(t,e){a.socketProtocolErrorStatuses[t],!e&&a.socketProtocolErrorStatuses[t]&&(e=a.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"),this._onCloseHandler({code:t,reason:e})):this.state===this.CONNECTING?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("connectAbort"),this._onOpenAbortHandler({code:t,reason:e})):this.state===this.CLOSED&&this._abortAllPendingEventsDueToBadConnection("connectAbort")},h.prototype._processInboundPacket=function(t,e){if(t&&null!=t.event)if(null==t.cid)this._onInboundTransmitHandler({...t});else{let e=new n(this,t.cid,t.event,t.data);this._onInboundInvokeHandler(e)}else if(t&&null!=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=a.hydrateError(t.error);e.callback(r,t.data)}}else this._onEventHandler({event:"raw",data:{message:e}})},h.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{this._destroy(4e3),this.socket.close(4e3)},this.pingTimeout))},h.prototype.clearAllListeners=function(){this._onOpenHandler=function(){},this._onOpenAbortHandler=function(){},this._onCloseHandler=function(){},this._onEventHandler=function(){},this._onErrorHandler=function(){},this._onInboundInvokeHandler=function(){},this._onInboundTransmitHandler=function(){}},h.prototype.startBatch=function(){this.isBufferingBatch=!0,this._batchBuffer=[]},h.prototype.flushBatch=function(){if(this.isBufferingBatch=!1,!this._batchBuffer.length)return;let t=this.serializeObject(this._batchBuffer);this._batchBuffer=[],this.send(t)},h.prototype.cancelBatch=function(){this.isBufferingBatch=!1,this._batchBuffer=[]},h.prototype.getBytesReceived=function(){return this.socket.bytesReceived},h.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))},h.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},h.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 u(`Event response for "${t.event}" timed out`);e.call(t,r,t)}},h.prototype.transmit=function(t,e,r){return(this.state===this.OPEN||r.force)&&this.transmitObject({event:t,data:e}),Promise.resolve()},h.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 i=null;return(this.state===this.OPEN||r.force)&&(i=this.transmitObject(o)),i},h.prototype.invoke=function(t,e,r){return new Promise((n,o)=>{this.invokeRaw(t,e,r,(t,e)=>{t?o(t):n(e)})})},h.prototype.cancelPendingResponse=function(t){delete this._callbackMap[t]},h.prototype.decode=function(t){return this.codec.decode(t)},h.prototype.encode=function(t){return this.codec.encode(t)},h.prototype.send=function(t){this.socket.readyState!==this.socket.OPEN?this._destroy(1005):this.socket.send(t)},h.prototype.serializeObject=function(t){let e;try{e=this.encode(t)}catch(t){return this._onError(t),null}return e},h.prototype.sendObject=function(t){if(this.isBufferingBatch)return void this._batchBuffer.push(t);let e=this.serializeObject(t);null!=e&&this.send(e)},e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"ag-request":8,querystring:22,"sc-errors":24,ws:6}],5:[function(t,e){e.exports=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}},{}],6:[function(t,e){let r;const n=(r="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}()).WebSocket||r.MozWebSocket;function o(t,e){let r;return r=e?new n(t,e):new n(t)}n&&(o.prototype=n.prototype),e.exports=n?o:null},{}],7:[function(t,e){const r=t("consumable-stream");class n extends r{constructor(t,e,r,o){super(),this.PENDING=n.PENDING,this.SUBSCRIBED=n.SUBSCRIBED,this.UNSUBSCRIBED=n.UNSUBSCRIBED,this.name=t,this.client=e,this._eventDemux=r,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)}}n.PENDING="pending",n.SUBSCRIBED="subscribed",n.UNSUBSCRIBED="unsubscribed",e.exports=n},{"consumable-stream":13}],8:[function(t,e){const r=t("sc-errors"),n=r.InvalidActionError;e.exports=function(t,e,o,i){this.socket=t,this.id=e,this.procedure=o,this.data=i,this.sent=!1,this._respond=((t,e)=>{if(this.sent)throw new n(`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 n={rid:this.id,error:r.dehydrateError(t)};this._respond(n,e)})}},{"sc-errors":24}],9:[function(t,e){const r=t("stream-demux");function n(){this._listenerDemux=new r}n.prototype.emit=function(t,e){this._listenerDemux.write(t,e)},n.prototype.listener=function(t){return this._listenerDemux.stream(t)},n.prototype.closeListener=function(t){this._listenerDemux.close(t)},n.prototype.closeAllListeners=function(){this._listenerDemux.closeAll()},n.prototype.getListenerConsumerStats=function(t){return this._listenerDemux.getConsumerStats(t)},n.prototype.getListenerConsumerStatsList=function(t){return this._listenerDemux.getConsumerStatsList(t)},n.prototype.getAllListenersConsumerStatsList=function(){return this._listenerDemux.getConsumerStatsListAll()},n.prototype.killListener=function(t){this._listenerDemux.kill(t)},n.prototype.killAllListeners=function(){this._listenerDemux.killAll()},n.prototype.killListenerConsumer=function(t){this._listenerDemux.killConsumer(t)},n.prototype.getListenerBackpressure=function(t){return this._listenerDemux.getBackpressure(t)},n.prototype.getAllListenersBackpressure=function(){return this._listenerDemux.getBackpressureAll()},n.prototype.getListenerConsumerBackpressure=function(t){return this._listenerDemux.getConsumerBackpressure(t)},n.prototype.hasListenerConsumer=function(t,e){return this._listenerDemux.hasConsumer(t,e)},n.prototype.hasAnyListenerConsumer=function(t){return this._listenerDemux.hasConsumerAll(t)},e.exports=n},{"stream-demux":28}],10:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,l=a>0?s-4:s;for(r=0;r>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[h++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;sa?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)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 h(t,e,r){for(var o,i,s=[],a=e;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),o=t("ieee754"),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,e.prototype),r}function e(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 h(t)}return u(t,e,r)}function u(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|f(t,r),o=a(n),i=o.write(t,r);i!==n&&(o=o.slice(0,i));return o}(t,r);if(ArrayBuffer.isView(t))return l(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 function(t,r,n){if(r<0||t.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function f(t,r){if(e.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 n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(t).length;default:if(i)return o?-1:U(t).length;r=(""+r).toLowerCase(),i=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,r,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=e.from(r,o)),e.isBuffer(r))return 0===r.length?-1:y(t,r,n,o,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):y(t,[r],n,o,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,s=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;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var l=!0,p=0;po&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function w(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function C(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?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&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<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<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.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 C(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return A(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}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},i&&(e.prototype[i]=e.prototype.inspect),e.prototype.compare=function(t,r,n,o,i){if(M(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),r<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===t)return 0;for(var s=i-o,a=n-r,u=Math.min(s,a),c=this.slice(o,i),h=t.slice(r,n),l=0;l>>=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 i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return k(this,t,e,r);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 _(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function D(t,r,n,o,i,s){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||rt.length)throw new RangeError("Index out of range")}function I(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return e=+e,r>>>=0,i||I(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||I(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},e.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||D(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||D(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,o){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),o||0===o||(o=this.length),r>=t.length&&(r=t.length),r||(r=0),o>0&&o=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-r=0;--s)t[s+r]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,o),r);return i},e.prototype.fill=function(t,r,n,o){if("string"==typeof t){if("string"==typeof r?(o=r,r=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!e.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){var i=t.charCodeAt(0);("utf8"===o&&i<128||"latin1"===o)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=r;s55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function R(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){for(var o=0;o=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=new Array(256),e=0;e<16;++e)for(var r=16*e,n=0;n<16;++n)t[r+n]="0123456789abcdef"[e]+"0123456789abcdef"[n];return t}()}).call(this,t("buffer").Buffer)},{"base64-js":10,buffer:11,ieee754:14}],12:[function(t,e){"use strict";const r=t("shallow-clone"),n=t("kind-of"),o=t("is-plain-object");function i(t,e){switch(n(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const r=new t.constructor;for(let n in t)r[n]=i(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{}),e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}}},{}],14:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,l=r?o-1:0,p=r?-1:1,f=t[e+l];for(l+=p,i=f&(1<<-h)-1,f>>=-h,h+=a;h>0;i=256*i+t[e+l],l+=p,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),i-=c}return(f?-1:1)*s*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:i-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+f]=255&a,f+=d,a/=256,o-=8);for(s=s<0;t[r+f]=255&s,f+=d,s/=256,c-=8);t[r+f-d]|=128*m}},{}],15:[function(t,e){"use strict";var r=t("isobject");function n(t){return!0===r(t)&&"[object Object]"===Object.prototype.toString.call(t)}e.exports=function(t){var e,r;return!1!==n(t)&&("function"==typeof(e=t.constructor)&&(!1!==n(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},{isobject:16}],16:[function(t,e){"use strict";e.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},{}],17:[function(t,e){var r=Object.prototype.toString;function n(t){return"function"==typeof t.constructor?t.constructor.name:null}e.exports=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"===n(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}(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(n(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=r.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,"")}},{}],18:[function(t,e){"use strict";var r="An argument without append, prepend, or detach methods was given to `List";function n(){if(arguments.length)return n.from(arguments)}var o=n.prototype;function i(){}n.of=function(){return n.from.call(this,arguments)},n.from=function(t){var e,r,n,o=new this;if(t&&(e=t.length))for(r=-1;++r0&&c>u&&(c=u);for(var h=0;h=0?(l=m.substr(0,y),p=m.substr(y+1)):(l=m,p=""),f=decodeURIComponent(l),d=decodeURIComponent(p),r(s,f)?n(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],21:[function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,s,a){return e=e||"&",s=s||"=",null===t&&(t=void 0),"object"==typeof t?o(i(t),function(i){var a=encodeURIComponent(r(i))+s;return n(t[i])?o(t[i],function(t){return a+encodeURIComponent(r(t))}).join(e):a+encodeURIComponent(r(t[i]))}).join(e):a?encodeURIComponent(r(a))+s+encodeURIComponent(r(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n>2],o+=r[(3&e[i])<<4|e[i+1]>>4],o+=r[(15&e[i+1])<<2|e[i+2]>>6],o+=r[63&e[i+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(n)};if(t.Buffer){if(n instanceof t.Buffer)return{base64:!0,data:n.toString("base64")};if(n&&"Buffer"===n.type&&Array.isArray(n.data))return{base64:!0,data:(t.Buffer.from?t.Buffer.from(n.data):new t.Buffer(n.data)).toString("base64")}}return n};e.exports.decode=function(t){if(null==t)return null;if("#1"===t||"#2"===t)return t;var e=t.toString();if(!n.test(e))return e;try{return JSON.parse(e)}catch(t){}return e},e.exports.encode=function(t){return"#1"===t||"#2"===t?t:JSON.stringify(t,o)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],26:[function(t,e){(function(r){"use strict";const n=Symbol.prototype.valueOf,o=t("kind-of");e.exports=function(t){switch(o(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,n=r.allocUnsafe?r.allocUnsafe(e):r.from(e);return t.copy(n),n}(t);case"symbol":return function(t){return n?Object(n.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}}}).call(this,t("buffer").Buffer)},{buffer:11,"kind-of":17}],27:[function(t,e){const r=t("consumable-stream");e.exports=class extends r{constructor(t,e){super(),this.name=e,this._streamDemux=t}createConsumer(t){return this._streamDemux.createConsumer(this.name,t)}}},{"consumable-stream":13}],28:[function(t,e){const r=t("writable-consumable-stream"),n=t("./demuxed-consumable-stream");e.exports=class{constructor(){this._mainStream=new r}write(t,e){this._mainStream.write({stream:t,data:{value:e,done:!1}})}close(t,e){this._mainStream.write({stream:t,data:{value:e,done:!0}})}closeAll(t){this._mainStream.close(t)}writeToConsumer(t,e){this._mainStream.writeToConsumer(t,{consumerId:t,data:{value:e,done:!1}})}closeConsumer(t,e){this._mainStream.closeConsumer(t,{consumerId:t,data:{value:e,done:!0}})}getConsumerStats(t){return this._mainStream.getConsumerStats(t)}getConsumerStatsList(t){return this._mainStream.getConsumerStatsList().filter(e=>e.stream===t)}getConsumerStatsListAll(){return this._mainStream.getConsumerStatsList()}kill(t,e){let r=this.getConsumerStatsList(t),n=r.length;for(let t=0;tn&&(n=r.backpressure)}return n}getBackpressureAll(){return this._mainStream.getBackpressure()}getConsumerBackpressure(t){return this._mainStream.getConsumerBackpressure(t)}hasConsumer(t,e){let r=this._mainStream.getConsumerStats(e);return!!r&&r.stream===t}hasConsumerAll(t){return this._mainStream.hasConsumer(t)}createConsumer(t,e){let r=this._mainStream.createConsumer(e),n=r.next;r.next=async function(){for(;;){let e=await n.apply(this,arguments);if(e.value&&(e.value.stream===t||e.value.consumerId===this.id))return e.value.data.done&&this.return(),e.value.data;if(e.done)return e}};let o=r.getStats;r.getStats=function(){let e=o.apply(this,arguments);return e.stream=t,e};let i=r.applyBackpressure;r.applyBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&i.apply(this,arguments):i.apply(this,arguments)};let s=r.releaseBackpressure;return r.releaseBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&s.apply(this,arguments):s.apply(this,arguments)},r}stream(t){return new n(this,t)}}},{"./demuxed-consumable-stream":27,"writable-consumable-stream":35}],29:[function(t,e){var r=t("./v1"),n=t("./v4"),o=n;o.v1=r,o.v4=n,e.exports=o},{"./v1":32,"./v4":33}],30:[function(t,e){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(t,e){var n=e||0,o=r;return[o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]]].join("")}},{}],31:[function(t,e){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var n=new Uint8Array(16);e.exports=function(){return r(n),n}}else{var o=new Array(16);e.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),o[e]=t>>>((3&e)<<3)&255;return o}}},{}],32:[function(t,e){var r,n,o=t("./lib/rng"),i=t("./lib/bytesToUuid"),s=0,a=0;e.exports=function(t,e,u){var c=e&&u||0,h=e||[],l=(t=t||{}).node||r,p=void 0!==t.clockseq?t.clockseq:n;if(null==l||null==p){var f=o();null==l&&(l=r=[1|f[0],f[1],f[2],f[3],f[4],f[5]]),null==p&&(p=n=16383&(f[6]<<8|f[7]))}var d=void 0!==t.msecs?t.msecs:(new Date).getTime(),m=void 0!==t.nsecs?t.nsecs:a+1,y=d-s+(m-a)/1e4;if(y<0&&void 0===t.clockseq&&(p=p+1&16383),(y<0||d>s)&&void 0===t.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=d,a=m,n=p;var g=(1e4*(268435455&(d+=122192928e5))+m)%4294967296;h[c++]=g>>>24&255,h[c++]=g>>>16&255,h[c++]=g>>>8&255,h[c++]=255&g;var b=d/4294967296*1e4&268435455;h[c++]=b>>>8&255,h[c++]=255&b,h[c++]=b>>>24&15|16,h[c++]=b>>>16&255,h[c++]=p>>>8|128,h[c++]=255&p;for(var k=0;k<6;++k)h[c+k]=l[k];return e||i(h)}},{"./lib/bytesToUuid":30,"./lib/rng":31}],33:[function(t,e){var r=t("./lib/rng"),n=t("./lib/bytesToUuid");e.exports=function(t,e,o){var i=e&&o||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var s=(t=t||{}).random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;++a)e[i+a]=s[a];return e||n(s)}},{"./lib/bytesToUuid":30,"./lib/rng":31}],34:[function(t,e){e.exports=class{constructor(t,e,r,n){this.id=e,this._backpressure=0,this.stream=t,this.currentNode=r,this.timeout=n,this.isAlive=!0,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}write(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this.applyBackpressure(t),this._resolve&&(this._resolve(),delete this._resolve)}kill(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this._killPacket={value:t,done:!0},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.currentNode.next)try{await this._waitForNextItem(this.timeout)}catch(t){throw this._destroy(),t}if(this._killPacket){this._destroy();let t=this._killPacket;return delete this._killPacket,t}if(this.currentNode=this.currentNode.next,this.releaseBackpressure(this.currentNode.data),!this.currentNode.consumerId||this.currentNode.consumerId===this.id)return this.currentNode.data.done&&this._destroy(),this.currentNode.data}}return(){return delete this.currentNode,this._destroy(),{}}[Symbol.asyncIterator](){return this}}},{}],35:[function(t,e){const r=t("consumable-stream"),n=t("./consumer");e.exports=class extends r{constructor(){super(),this.nextConsumerId=1,this._consumers={},this._tailNode={next:null,data:{value:void 0,done:!1}}}_write(t,e,r){let n={data:{value:t,done:e},next:null};r&&(n.consumerId=r),this._tailNode.next=n,this._tailNode=n;let o=Object.values(this._consumers),i=o.length;for(let t=0;tr&&(r=e)}return r}getConsumerBackpressure(t){let e=this._consumers[t];return e?e.getBackpressure():0}hasConsumer(t){return!!this._consumers[t]}setConsumer(t,e){this._consumers[t]=e,e.currentNode||(e.currentNode=this._tailNode)}removeConsumer(t){delete this._consumers[t]}getConsumerStats(t){let e=this._consumers[t];if(e)return e.getStats()}getConsumerStatsList(){let t=[],e=Object.values(this._consumers),r=e.length;for(let n=0;n{if(this[t]>i)throw new m(`The ${t} value provided exceeded the maximum amount allowed`)};if(u("connectTimeout"),u("ackTimeout"),u("pingTimeout"),this.connectAttempts=0,this.isBatching=!1,this.batchOnHandshake=e.batchOnHandshake,this.batchOnHandshakeDuration=e.batchOnHandshakeDuration,this._batchingIntervalId=null,this._outboundBuffer=new h,this._channelMap={},this._channelEventDemux=new n,this._channelDataDemux=new n,this._receiverDemux=new n,this._procedureDemux=new n,this.options=e,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 s,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=a,this.options.protocol){let t=new m('The "protocol" option does not affect socketcluster-client - If you want to utilize SSL/TLS, use "secure" option instead');this._onError(t)}this.options.query=e.query||{},"string"==typeof this.options.query&&(this.options.query=c.parse(this.options.query)),v&&this.disconnectOnUnload&&r.addEventListener&&r.removeEventListener&&this._handleBrowserUnload(),this.options.autoConnect&&this.connect()}E.prototype=Object.create(o.prototype),E.CONNECTING=E.prototype.CONNECTING=u.prototype.CONNECTING,E.OPEN=E.prototype.OPEN=u.prototype.OPEN,E.CLOSED=E.prototype.CLOSED=u.prototype.CLOSED,E.AUTHENTICATED=E.prototype.AUTHENTICATED="authenticated",E.UNAUTHENTICATED=E.prototype.UNAUTHENTICATED="unauthenticated",E.SUBSCRIBED=E.prototype.SUBSCRIBED=i.SUBSCRIBED,E.PENDING=E.prototype.PENDING=i.PENDING,E.UNSUBSCRIBED=E.prototype.UNSUBSCRIBED=i.UNSUBSCRIBED,E.ignoreStatuses=d.socketProtocolIgnoreStatuses,E.errorStatuses=d.socketProtocolErrorStatuses,Object.defineProperty(E.prototype,"isBufferingBatch",{get:function(){return this.transport.isBufferingBatch}}),E.prototype.getBackpressure=function(){return Math.max(this.getAllListenersBackpressure(),this.getAllReceiversBackpressure(),this.getAllProceduresBackpressure(),this.getAllChannelsBackpressure())},E.prototype._handleBrowserUnload=async function(){let t=()=>{this.disconnect()},e=!1;(async()=>{let n=this.listener("connecting").createConsumer();for(;;){if((await n.next()).done)break;e||(e=!0,r.addEventListener("beforeunload",t,!1))}})(),(async()=>{let n=this.listener("close").createConsumer();for(;;){if((await n.next()).done)break;e&&(e=!1,r.removeEventListener("beforeunload",t,!1))}})()},E.prototype._setAuthToken=function(t){this._changeToAuthenticatedState(t.token),(async()=>{try{await this.auth.saveToken(this.authTokenName,t.token,{})}catch(t){this._onError(t)}})()},E.prototype._removeAuthToken=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._changeToUnauthenticatedStateAndClearTokens()},E.prototype._privateDataHandlerMap={"#publish":function(t){let e=this._undecorateChannelName(t.channel);this.isSubscribed(e,!0)&&this._channelDataDemux.write(e,t.data)},"#kickOut":function(t){let e=this._undecorateChannelName(t.channel),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&&this._setAuthToken(t)},"#removeAuthToken":function(t){this._removeAuthToken(t)}},E.prototype._privateRPCHandlerMap={"#setAuthToken":function(t,e){t?(this._setAuthToken(t),e.end()):e.error(new y("No token data provided by #setAuthToken event"))},"#removeAuthToken":function(t,e){this._removeAuthToken(t),e.end()}},E.prototype.getState=function(){return this.state},E.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},E.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 f(0)},E.prototype.connect=function(){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(),this.transport=new u(this.auth,this.codec,this.options,this.wsOptions,{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)}}))},E.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},E.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new m("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))},E.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})}},E.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})},E.prototype.decodeBase64=function(t){return p.from(t,"base64").toString("utf8")},E.prototype.encodeBase64=function(t){return p.from(t,"utf8").toString("base64")},E.prototype._extractAuthTokenData=function(t){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},E.prototype.getAuthToken=function(){return this.authToken},E.prototype.getSignedAuthToken=function(){return this.signedAuthToken},E.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 f(0),t}return e&&null!=e.isAuthenticated?e.authError&&(e.authError=d.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 f(0),e},E.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)},E.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()},E.prototype._onError=function(t){this.emit("error",{error:t})},E.prototype._suspendSubscriptions=function(){Object.keys(this._channelMap).forEach(t=>{let e=this._channelMap[t];this._triggerChannelUnsubscribe(e,!0)})},E.prototype._abortAllPendingEventsDueToBadConnection=function(t){let e,r=this._outboundBuffer.head;for(;r;){e=r.next;let n=r.data;clearTimeout(n.timeout),delete n.timeout,r.detach(),r=e;let o=n.callback;if(o){delete n.callback;let e=`Event "${n.event}" was aborted due to a bad connection`,r=new k(e,t);o.call(n,r,n)}n.cid&&this.transport.cancelPendingResponse(n.cid)}},E.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}),!E.ignoreStatuses[t]){let r;r=e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;let n=new g(E.errorStatuses[t]||r,t);this._onError(n)}this._abortAllPendingEventsDueToBadConnection(r?"connectAbort":"disconnect"),this.options.autoReconnect&&(4e3===t||4001===t||1005===t?this._tryReconnect(0):1e3!==t&&t<4500&&this._tryReconnect())},E.prototype._onInboundTransmit=function(t,e){let r=this._privateDataHandlerMap[t];r?r.call(this,e):this._receiverDemux.write(t,e)},E.prototype._onInboundInvoke=function(t){let{procedure:e,data:r}=t,n=this._privateRPCHandlerMap[e];n?n.call(this,r,t):this._procedureDemux.write(e,t)},E.prototype.decode=function(t){return this.transport.decode(t)},E.prototype.encode=function(t){return this.transport.encode(t)},E.prototype._flushOutboundBuffer=function(){let t,e=this._outboundBuffer.head;for(;e;){t=e.next;let r=e.data;e.detach(),this.transport.transmitObject(r),e=t}},E.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;let r=t.callback;if(r){delete t.callback;let e=new b(`Event response for "${t.event}" timed out`);r.call(t,e,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},E.prototype._processOutboundEvent=function(t,e,r,n){r=r||{},this.state===this.CLOSED&&this.connect();let o,i={event:t};o=n?new Promise((t,e)=>{i.callback=((r,n)=>{r?e(r):t(n)})}):Promise.resolve();let s=new h.Item;this.options.cloneData?i.data=l(e):i.data=e,s.data=i;let a=null==r.ackTimeout?this.ackTimeout:r.ackTimeout;return i.timeout=setTimeout(()=>{this._handleEventAckTimeout(i,s)},a),this._outboundBuffer.append(s),this.state===this.OPEN&&this._flushOutboundBuffer(),o},E.prototype.send=function(t){this.transport.send(t)},E.prototype.transmit=function(t,e,r){return this._processOutboundEvent(t,e,r)},E.prototype.invoke=function(t,e,r){return this._processOutboundEvent(t,e,r,!0)},E.prototype.transmitPublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.transmit("#publish",r)},E.prototype.invokePublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.invoke("#publish",r)},E.prototype._triggerChannelSubscribe=function(t,e){let r=t.name;if(t.state!==i.SUBSCRIBED){let n=t.state;t.state=i.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})}},E.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}))},E.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},E.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},E.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0===t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},E.prototype.startBatch=function(){this.transport.startBatch()},E.prototype.flushBatch=function(){this.transport.flushBatch()},E.prototype.cancelBatch=function(){this.transport.cancelBatch()},E.prototype._startBatching=function(){null==this._batchingIntervalId&&(this.startBatch(),this._batchingIntervalId=setInterval(()=>{this.flushBatch(),this.startBatch()},this.options.batchInterval))},E.prototype.startBatching=function(){this.isBatching=!0,this._startBatching()},E.prototype._stopBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.flushBatch()},E.prototype.stopBatching=function(){this.isBatching=!1,this._stopBatching()},E.prototype._cancelBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.cancelBatch()},E.prototype.cancelBatching=function(){this.isBatching=!1,this._cancelBatching()},E.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})}},E.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:i.PENDING,options:n},this._channelMap[t]=r,this._trySubscribe(r)),new i(t,this,this._channelEventDemux,this._channelDataDemux)},E.prototype._triggerChannelUnsubscribe=function(t,e){let r=t.name;if(this._cancelPendingSubscribeCallback(t),t.state===i.SUBSCRIBED){let n={oldChannelState:t.state,newChannelState:e?i.PENDING:i.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=i.PENDING:delete this._channelMap[r]},E.prototype._tryUnsubscribe=function(t){if(this.state===this.OPEN){this._cancelPendingSubscribeCallback(t);let e=this._decorateChannelName(t.name);this.transport.transmit("#unsubscribe",e,{noTimeout:!0})}},E.prototype.unsubscribe=function(t){let e=this._channelMap[t];e&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},E.prototype.receiver=function(t){return this._receiverDemux.stream(t)},E.prototype.closeReceiver=function(t){this._receiverDemux.close(t)},E.prototype.closeAllReceivers=function(){this._receiverDemux.closeAll()},E.prototype.killReceiver=function(t){this._receiverDemux.kill(t)},E.prototype.killAllReceivers=function(){this._receiverDemux.killAll()},E.prototype.killReceiverConsumer=function(t){this._receiverDemux.killConsumer(t)},E.prototype.getReceiverConsumerStats=function(t){return this._receiverDemux.getConsumerStats(t)},E.prototype.getReceiverConsumerStatsList=function(t){return this._receiverDemux.getConsumerStatsList(t)},E.prototype.getAllReceiversConsumerStatsList=function(){return this._receiverDemux.getConsumerStatsListAll()},E.prototype.getReceiverBackpressure=function(t){return this._receiverDemux.getBackpressure(t)},E.prototype.getAllReceiversBackpressure=function(){return this._receiverDemux.getBackpressureAll()},E.prototype.getReceiverConsumerBackpressure=function(t){return this._receiverDemux.getConsumerBackpressure(t)},E.prototype.hasReceiverConsumer=function(t,e){return this._receiverDemux.hasConsumer(t,e)},E.prototype.hasAnyReceiverConsumer=function(t){return this._receiverDemux.hasConsumerAll(t)},E.prototype.procedure=function(t){return this._procedureDemux.stream(t)},E.prototype.closeProcedure=function(t){this._procedureDemux.close(t)},E.prototype.closeAllProcedures=function(){this._procedureDemux.closeAll()},E.prototype.killProcedure=function(t){this._procedureDemux.kill(t)},E.prototype.killAllProcedures=function(){this._procedureDemux.killAll()},E.prototype.killProcedureConsumer=function(t){this._procedureDemux.killConsumer(t)},E.prototype.getProcedureConsumerStats=function(t){return this._procedureDemux.getConsumerStats(t)},E.prototype.getProcedureConsumerStatsList=function(t){return this._procedureDemux.getConsumerStatsList(t)},E.prototype.getAllProceduresConsumerStatsList=function(){return this._procedureDemux.getConsumerStatsListAll()},E.prototype.getProcedureBackpressure=function(t){return this._procedureDemux.getBackpressure(t)},E.prototype.getAllProceduresBackpressure=function(){return this._procedureDemux.getBackpressureAll()},E.prototype.getProcedureConsumerBackpressure=function(t){return this._procedureDemux.getConsumerBackpressure(t)},E.prototype.hasProcedureConsumer=function(t,e){return this._procedureDemux.hasConsumer(t,e)},E.prototype.hasAnyProcedureConsumer=function(t){return this._procedureDemux.hasConsumerAll(t)},E.prototype.channel=function(t){return this._channelMap[t],new i(t,this,this._channelEventDemux,this._channelDataDemux)},E.prototype.closeChannel=function(t){this.channelCloseOutput(t),this.channelCloseAllListeners(t)},E.prototype.closeAllChannelOutputs=function(){this._channelDataDemux.closeAll()},E.prototype.closeAllChannelListeners=function(){this._channelEventDemux.closeAll()},E.prototype.closeAllChannels=function(){this.closeAllChannelOutputs(),this.closeAllChannelListeners()},E.prototype.killChannel=function(t){this.channelKillOutput(t),this.channelKillAllListeners(t)},E.prototype.killAllChannelOutputs=function(){this._channelDataDemux.killAll()},E.prototype.killAllChannelListeners=function(){this._channelEventDemux.killAll()},E.prototype.killAllChannels=function(){this.killAllChannelOutputs(),this.killAllChannelListeners()},E.prototype.killChannelOutputConsumer=function(t){this._channelDataDemux.killConsumer(t)},E.prototype.killChannelListenerConsumer=function(t){this._channelEventDemux.killConsumer(t)},E.prototype.getChannelOutputConsumerStats=function(t){return this._channelDataDemux.getConsumerStats(t)},E.prototype.getChannelListenerConsumerStats=function(t){return this._channelEventDemux.getConsumerStats(t)},E.prototype.getAllChannelOutputsConsumerStatsList=function(){return this._channelDataDemux.getConsumerStatsListAll()},E.prototype.getAllChannelListenersConsumerStatsList=function(){return this._channelEventDemux.getConsumerStatsListAll()},E.prototype.getChannelBackpressure=function(t){return Math.max(this.channelGetOutputBackpressure(t),this.channelGetAllListenersBackpressure(t))},E.prototype.getAllChannelOutputsBackpressure=function(){return this._channelDataDemux.getBackpressureAll()},E.prototype.getAllChannelListenersBackpressure=function(){return this._channelEventDemux.getBackpressureAll()},E.prototype.getAllChannelsBackpressure=function(){return Math.max(this.getAllChannelOutputsBackpressure(),this.getAllChannelListenersBackpressure())},E.prototype.getChannelListenerConsumerBackpressure=function(t){return this._channelEventDemux.getConsumerBackpressure(t)},E.prototype.getChannelOutputConsumerBackpressure=function(t){return this._channelDataDemux.getConsumerBackpressure(t)},E.prototype.hasAnyChannelOutputConsumer=function(t){return this._channelDataDemux.hasConsumerAll(t)},E.prototype.hasAnyChannelListenerConsumer=function(t){return this._channelEventDemux.hasConsumerAll(t)},E.prototype.getChannelState=function(t){let e=this._channelMap[t];return e?e.state:i.UNSUBSCRIBED},E.prototype.getChannelOptions=function(t){let e=this._channelMap[t];return e?{...e.options}:{}},E.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)},E.prototype.channelCloseOutput=function(t){this._channelDataDemux.close(t)},E.prototype.channelCloseListener=function(t,e){this._channelEventDemux.close(`${t}/${e}`)},E.prototype.channelCloseAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.close(t)})},E.prototype.channelKillOutput=function(t){this._channelDataDemux.kill(t)},E.prototype.channelKillListener=function(t,e){this._channelEventDemux.kill(`${t}/${e}`)},E.prototype.channelKillAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.kill(t)})},E.prototype.channelGetOutputConsumerStatsList=function(t){return this._channelDataDemux.getConsumerStatsList(t)},E.prototype.channelGetListenerConsumerStatsList=function(t,e){return this._channelEventDemux.getConsumerStatsList(`${t}/${e}`)},E.prototype.channelGetAllListenersConsumerStatsList=function(t){return this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getConsumerStatsList(t)).reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])},E.prototype.channelGetOutputBackpressure=function(t){return this._channelDataDemux.getBackpressure(t)},E.prototype.channelGetListenerBackpressure=function(t,e){return this._channelEventDemux.getBackpressure(`${t}/${e}`)},E.prototype.channelGetAllListenersBackpressure=function(t){let e=this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getBackpressure(t));return Math.max(...e.concat(0))},E.prototype.channelHasOutputConsumer=function(t,e){return this._channelDataDemux.hasConsumer(t,e)},E.prototype.channelHasListenerConsumer=function(t,e,r){return this._channelEventDemux.hasConsumer(`${t}/${e}`,r)},E.prototype.channelHasAnyListenerConsumer=function(t,e){return this._getAllChannelStreamNames(t).some(t=>this._channelEventDemux.hasConsumer(t,e))},E.prototype.subscriptions=function(t){let e=[];return Object.keys(this._channelMap).forEach(r=>{(t||this._channelMap[r].state===i.SUBSCRIBED)&&e.push(r)}),e},E.prototype.isSubscribed=function(t,e){let r=this._channelMap[t];return e?!!r:!!r&&r.state===i.SUBSCRIBED},E.prototype.processPendingSubscriptions=function(){this.preparingPendingSubscriptions=!1;let t=[];Object.keys(this._channelMap).forEach(e=>{let r=this._channelMap[e];r.state===i.PENDING&&t.push(r)}),t.sort((t,e)=>{let r=t.options.priority||0,n=e.options.priority||0;return r>n?-1:r{this._trySubscribe(t)})},e.exports=E}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./auth":1,"./transport":4,"./wait":5,"ag-channel":7,"async-stream-emitter":9,"buffer/":11,"clone-deep":12,"linked-list":19,querystring:22,"sc-errors":24,"sc-formatter":25,"stream-demux":28}],3:[function(t,e){(function(r){const n=t("./clientsocket"),o=t("uuid"),i=t("sc-errors").InvalidArgumentsError;e.exports={create:function(t){if((t=t||{}).host&&!t.host.match(/[^:]+:\d{2,5}/))throw new i('The host option should include both the hostname and the port number in the format "hostname:port"');if(t.host&&t.hostname)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and hostname options together');if(t.host&&t.port)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and port options together');let e=r.location&&"https:"===location.protocol,s={clientId:o.v4(),port:function(t,e){let n=null==t.secure?e:t.secure;return t.port||(r.location&&location.port?location.port:n?443:80)}(t,e),hostname:r.location&&location.hostname||"localhost",secure:e};return Object.assign(s,t),new n(s)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./clientsocket":2,"sc-errors":24,uuid:29}],4:[function(t,e){(function(r){const n=t("ag-request"),o=t("querystring");let i,s;r.WebSocket?(i=r.WebSocket,s=function(t){return new i(t)}):(i=t("ws"),s=function(t,e){return new i(t,null,e)});const a=t("sc-errors"),u=a.TimeoutError,c=a.BadConnectionError;function h(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={},this._batchBuffer=[],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 i=this.uri(),a=s(i,n);a.binaryType=this.options.binaryType,this.socket=a,a.onopen=(()=>{this._onOpen()}),a.onclose=(async t=>{let e;e=null==t.code?1005:t.code,this._destroy(e,t.reason)}),a.onmessage=(t=>{this._onMessage(t.data)}),a.onerror=(()=>{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))}h.CONNECTING=h.prototype.CONNECTING="connecting",h.OPEN=h.prototype.OPEN="open",h.CLOSED=h.prototype.CLOSED="closed",h.prototype.uri=function(){let t,e,r,n=this.options.query||{};if(t=null==this.options.protocolScheme?this.options.secure?"wss":"ws":this.options.protocolScheme,this.options.timestampRequests&&(n[this.options.timestampParam]=(new Date).getTime()),(n=o.encode(n)).length&&(n="?"+n),null==this.options.socketPath){if(this.options.host)e=this.options.host;else{let r="";this.options.port&&("wss"===t&&443!==this.options.port||"ws"===t&&80!==this.options.port)&&(r=":"+this.options.port),e=this.options.hostname+r}r=this.options.path}else e=this.options.socketPath,r=`:${this.options.path}`;return t+"://"+e+r+n},h.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&&(this.pingTimeout=t.pingTimeout),this._resetPingTimeout(),this._onOpenHandler(t)},h.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=a.hydrateError(e.authError))),e},h.prototype._abortAllPendingEventsDueToBadConnection=function(t){Object.keys(this._callbackMap||{}).forEach(e=>{let r=this._callbackMap[e];delete this._callbackMap[e],clearTimeout(r.timeout),delete r.timeout;let n=`Event "${r.event}" was aborted due to a bad connection`,o=new c(n,t),i=r.callback;delete r.callback,i.call(r,o,r)})},h.prototype._destroy=function(t,e){a.socketProtocolErrorStatuses[t],!e&&a.socketProtocolErrorStatuses[t]&&(e=a.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"),this._onCloseHandler({code:t,reason:e})):this.state===this.CONNECTING?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("connectAbort"),this._onOpenAbortHandler({code:t,reason:e})):this.state===this.CLOSED&&this._abortAllPendingEventsDueToBadConnection("connectAbort")},h.prototype._processInboundPacket=function(t,e){if(t&&null!=t.event)if(null==t.cid)this._onInboundTransmitHandler({...t});else{let e=new n(this,t.cid,t.event,t.data);this._onInboundInvokeHandler(e)}else if(t&&null!=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=a.hydrateError(t.error);e.callback(r,t.data)}}else this._onEventHandler({event:"raw",data:{message:e}})},h.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{this._destroy(4e3),this.socket.close(4e3)},this.pingTimeout))},h.prototype.clearAllListeners=function(){this._onOpenHandler=function(){},this._onOpenAbortHandler=function(){},this._onCloseHandler=function(){},this._onEventHandler=function(){},this._onErrorHandler=function(){},this._onInboundInvokeHandler=function(){},this._onInboundTransmitHandler=function(){}},h.prototype.startBatch=function(){this.isBufferingBatch=!0,this._batchBuffer=[]},h.prototype.flushBatch=function(){if(this.isBufferingBatch=!1,!this._batchBuffer.length)return;let t=this.serializeObject(this._batchBuffer);this._batchBuffer=[],this.send(t)},h.prototype.cancelBatch=function(){this.isBufferingBatch=!1,this._batchBuffer=[]},h.prototype.getBytesReceived=function(){return this.socket.bytesReceived},h.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))},h.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},h.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 u(`Event response for "${t.event}" timed out`);e.call(t,r,t)}},h.prototype.transmit=function(t,e,r){return(this.state===this.OPEN||r.force)&&this.transmitObject({event:t,data:e}),Promise.resolve()},h.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 i=null;return(this.state===this.OPEN||r.force)&&(i=this.transmitObject(o)),i},h.prototype.invoke=function(t,e,r){return new Promise((n,o)=>{this.invokeRaw(t,e,r,(t,e)=>{t?o(t):n(e)})})},h.prototype.cancelPendingResponse=function(t){delete this._callbackMap[t]},h.prototype.decode=function(t){return this.codec.decode(t)},h.prototype.encode=function(t){return this.codec.encode(t)},h.prototype.send=function(t){this.socket.readyState!==this.socket.OPEN?this._destroy(1005):this.socket.send(t)},h.prototype.serializeObject=function(t){let e;try{e=this.encode(t)}catch(t){return this._onError(t),null}return e},h.prototype.sendObject=function(t){if(this.isBufferingBatch)return void this._batchBuffer.push(t);let e=this.serializeObject(t);null!=e&&this.send(e)},e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"ag-request":8,querystring:22,"sc-errors":24,ws:6}],5:[function(t,e){e.exports=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}},{}],6:[function(t,e){let r;const n=(r="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}()).WebSocket||r.MozWebSocket;function o(t,e){let r;return r=e?new n(t,e):new n(t)}n&&(o.prototype=n.prototype),e.exports=n?o:null},{}],7:[function(t,e){const r=t("consumable-stream");class n extends r{constructor(t,e,r,o){super(),this.PENDING=n.PENDING,this.SUBSCRIBED=n.SUBSCRIBED,this.UNSUBSCRIBED=n.UNSUBSCRIBED,this.name=t,this.client=e,this._eventDemux=r,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)}}n.PENDING="pending",n.SUBSCRIBED="subscribed",n.UNSUBSCRIBED="unsubscribed",e.exports=n},{"consumable-stream":13}],8:[function(t,e){const r=t("sc-errors"),n=r.InvalidActionError;e.exports=function(t,e,o,i){this.socket=t,this.id=e,this.procedure=o,this.data=i,this.sent=!1,this._respond=((t,e)=>{if(this.sent)throw new n(`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 n={rid:this.id,error:r.dehydrateError(t)};this._respond(n,e)})}},{"sc-errors":24}],9:[function(t,e){const r=t("stream-demux");function n(){this._listenerDemux=new r}n.prototype.emit=function(t,e){this._listenerDemux.write(t,e)},n.prototype.listener=function(t){return this._listenerDemux.stream(t)},n.prototype.closeListener=function(t){this._listenerDemux.close(t)},n.prototype.closeAllListeners=function(){this._listenerDemux.closeAll()},n.prototype.getListenerConsumerStats=function(t){return this._listenerDemux.getConsumerStats(t)},n.prototype.getListenerConsumerStatsList=function(t){return this._listenerDemux.getConsumerStatsList(t)},n.prototype.getAllListenersConsumerStatsList=function(){return this._listenerDemux.getConsumerStatsListAll()},n.prototype.killListener=function(t){this._listenerDemux.kill(t)},n.prototype.killAllListeners=function(){this._listenerDemux.killAll()},n.prototype.killListenerConsumer=function(t){this._listenerDemux.killConsumer(t)},n.prototype.getListenerBackpressure=function(t){return this._listenerDemux.getBackpressure(t)},n.prototype.getAllListenersBackpressure=function(){return this._listenerDemux.getBackpressureAll()},n.prototype.getListenerConsumerBackpressure=function(t){return this._listenerDemux.getConsumerBackpressure(t)},n.prototype.hasListenerConsumer=function(t,e){return this._listenerDemux.hasConsumer(t,e)},n.prototype.hasAnyListenerConsumer=function(t){return this._listenerDemux.hasConsumerAll(t)},e.exports=n},{"stream-demux":28}],10:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,l=a>0?s-4:s;for(r=0;r>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[h++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;sa?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)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 h(t,e,r){for(var o,i,s=[],a=e;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),o=t("ieee754"),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,e.prototype),r}function e(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 h(t)}return u(t,e,r)}function u(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|f(t,r),o=a(n),i=o.write(t,r);i!==n&&(o=o.slice(0,i));return o}(t,r);if(ArrayBuffer.isView(t))return l(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 function(t,r,n){if(r<0||t.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function f(t,r){if(e.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 n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(t).length;default:if(i)return o?-1:U(t).length;r=(""+r).toLowerCase(),i=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,r,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=e.from(r,o)),e.isBuffer(r))return 0===r.length?-1:y(t,r,n,o,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):y(t,[r],n,o,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,s=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;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var l=!0,p=0;po&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function w(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function C(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?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&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<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<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.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 C(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return A(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}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},i&&(e.prototype[i]=e.prototype.inspect),e.prototype.compare=function(t,r,n,o,i){if(M(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),r<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===t)return 0;for(var s=i-o,a=n-r,u=Math.min(s,a),c=this.slice(o,i),h=t.slice(r,n),l=0;l>>=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 i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return k(this,t,e,r);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 _(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function D(t,r,n,o,i,s){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||rt.length)throw new RangeError("Index out of range")}function I(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return e=+e,r>>>=0,i||I(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||I(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},e.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||D(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||D(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||D(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},e.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,o){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),o||0===o||(o=this.length),r>=t.length&&(r=t.length),r||(r=0),o>0&&o=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-r=0;--s)t[s+r]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,o),r);return i},e.prototype.fill=function(t,r,n,o){if("string"==typeof t){if("string"==typeof r?(o=r,r=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!e.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){var i=t.charCodeAt(0);("utf8"===o&&i<128||"latin1"===o)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=r;s55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function R(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){for(var o=0;o=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=new Array(256),e=0;e<16;++e)for(var r=16*e,n=0;n<16;++n)t[r+n]="0123456789abcdef"[e]+"0123456789abcdef"[n];return t}()}).call(this,t("buffer").Buffer)},{"base64-js":10,buffer:11,ieee754:14}],12:[function(t,e){"use strict";const r=t("shallow-clone"),n=t("kind-of"),o=t("is-plain-object");function i(t,e){switch(n(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const r=new t.constructor;for(let n in t)r[n]=i(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{}),e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}}},{}],14:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,l=r?o-1:0,p=r?-1:1,f=t[e+l];for(l+=p,i=f&(1<<-h)-1,f>>=-h,h+=a;h>0;i=256*i+t[e+l],l+=p,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),i-=c}return(f?-1:1)*s*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:i-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+f]=255&a,f+=d,a/=256,o-=8);for(s=s<0;t[r+f]=255&s,f+=d,s/=256,c-=8);t[r+f-d]|=128*m}},{}],15:[function(t,e){"use strict";var r=t("isobject");function n(t){return!0===r(t)&&"[object Object]"===Object.prototype.toString.call(t)}e.exports=function(t){var e,r;return!1!==n(t)&&("function"==typeof(e=t.constructor)&&(!1!==n(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},{isobject:16}],16:[function(t,e){"use strict";e.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},{}],17:[function(t,e){var r=Object.prototype.toString;function n(t){return"function"==typeof t.constructor?t.constructor.name:null}e.exports=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"===n(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}(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(n(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=r.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,"")}},{}],18:[function(t,e){"use strict";var r="An argument without append, prepend, or detach methods was given to `List";function n(){if(arguments.length)return n.from(arguments)}var o=n.prototype;function i(){}n.of=function(){return n.from.call(this,arguments)},n.from=function(t){var e,r,n,o=new this;if(t&&(e=t.length))for(r=-1;++r0&&c>u&&(c=u);for(var h=0;h=0?(l=m.substr(0,y),p=m.substr(y+1)):(l=m,p=""),f=decodeURIComponent(l),d=decodeURIComponent(p),r(s,f)?n(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],21:[function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,s,a){return e=e||"&",s=s||"=",null===t&&(t=void 0),"object"==typeof t?o(i(t),function(i){var a=encodeURIComponent(r(i))+s;return n(t[i])?o(t[i],function(t){return a+encodeURIComponent(r(t))}).join(e):a+encodeURIComponent(r(t[i]))}).join(e):a?encodeURIComponent(r(a))+s+encodeURIComponent(r(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n>2],o+=r[(3&e[i])<<4|e[i+1]>>4],o+=r[(15&e[i+1])<<2|e[i+2]>>6],o+=r[63&e[i+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(n)};if(t.Buffer){if(n instanceof t.Buffer)return{base64:!0,data:n.toString("base64")};if(n&&"Buffer"===n.type&&Array.isArray(n.data))return{base64:!0,data:(t.Buffer.from?t.Buffer.from(n.data):new t.Buffer(n.data)).toString("base64")}}return n};e.exports.decode=function(t){if(null==t)return null;if("#1"===t||"#2"===t)return t;var e=t.toString();if(!n.test(e))return e;try{return JSON.parse(e)}catch(t){}return e},e.exports.encode=function(t){return"#1"===t||"#2"===t?t:JSON.stringify(t,o)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],26:[function(t,e){(function(r){"use strict";const n=Symbol.prototype.valueOf,o=t("kind-of");e.exports=function(t){switch(o(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,n=r.allocUnsafe?r.allocUnsafe(e):r.from(e);return t.copy(n),n}(t);case"symbol":return function(t){return n?Object(n.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}}}).call(this,t("buffer").Buffer)},{buffer:11,"kind-of":17}],27:[function(t,e){const r=t("consumable-stream");e.exports=class extends r{constructor(t,e){super(),this.name=e,this._streamDemux=t}createConsumer(t){return this._streamDemux.createConsumer(this.name,t)}}},{"consumable-stream":13}],28:[function(t,e){const r=t("writable-consumable-stream"),n=t("./demuxed-consumable-stream");e.exports=class{constructor(){this._mainStream=new r}write(t,e){this._mainStream.write({stream:t,data:{value:e,done:!1}})}close(t,e){this._mainStream.write({stream:t,data:{value:e,done:!0}})}closeAll(t){this._mainStream.close(t)}writeToConsumer(t,e){this._mainStream.writeToConsumer(t,{consumerId:t,data:{value:e,done:!1}})}closeConsumer(t,e){this._mainStream.closeConsumer(t,{consumerId:t,data:{value:e,done:!0}})}getConsumerStats(t){return this._mainStream.getConsumerStats(t)}getConsumerStatsList(t){return this._mainStream.getConsumerStatsList().filter(e=>e.stream===t)}getConsumerStatsListAll(){return this._mainStream.getConsumerStatsList()}kill(t,e){let r=this.getConsumerStatsList(t),n=r.length;for(let t=0;tn&&(n=r.backpressure)}return n}getBackpressureAll(){return this._mainStream.getBackpressure()}getConsumerBackpressure(t){return this._mainStream.getConsumerBackpressure(t)}hasConsumer(t,e){let r=this._mainStream.getConsumerStats(e);return!!r&&r.stream===t}hasConsumerAll(t){return this._mainStream.hasConsumer(t)}createConsumer(t,e){let r=this._mainStream.createConsumer(e),n=r.next;r.next=async function(){for(;;){let e=await n.apply(this,arguments);if(e.value&&(e.value.stream===t||e.value.consumerId===this.id))return e.value.data.done&&this.return(),e.value.data;if(e.done)return e}};let o=r.getStats;r.getStats=function(){let e=o.apply(this,arguments);return e.stream=t,e};let i=r.applyBackpressure;r.applyBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&i.apply(this,arguments):i.apply(this,arguments)};let s=r.releaseBackpressure;return r.releaseBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&s.apply(this,arguments):s.apply(this,arguments)},r}stream(t){return new n(this,t)}}},{"./demuxed-consumable-stream":27,"writable-consumable-stream":35}],29:[function(t,e){var r=t("./v1"),n=t("./v4"),o=n;o.v1=r,o.v4=n,e.exports=o},{"./v1":32,"./v4":33}],30:[function(t,e){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(t,e){var n=e||0,o=r;return[o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]]].join("")}},{}],31:[function(t,e){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var n=new Uint8Array(16);e.exports=function(){return r(n),n}}else{var o=new Array(16);e.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),o[e]=t>>>((3&e)<<3)&255;return o}}},{}],32:[function(t,e){var r,n,o=t("./lib/rng"),i=t("./lib/bytesToUuid"),s=0,a=0;e.exports=function(t,e,u){var c=e&&u||0,h=e||[],l=(t=t||{}).node||r,p=void 0!==t.clockseq?t.clockseq:n;if(null==l||null==p){var f=o();null==l&&(l=r=[1|f[0],f[1],f[2],f[3],f[4],f[5]]),null==p&&(p=n=16383&(f[6]<<8|f[7]))}var d=void 0!==t.msecs?t.msecs:(new Date).getTime(),m=void 0!==t.nsecs?t.nsecs:a+1,y=d-s+(m-a)/1e4;if(y<0&&void 0===t.clockseq&&(p=p+1&16383),(y<0||d>s)&&void 0===t.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=d,a=m,n=p;var g=(1e4*(268435455&(d+=122192928e5))+m)%4294967296;h[c++]=g>>>24&255,h[c++]=g>>>16&255,h[c++]=g>>>8&255,h[c++]=255&g;var b=d/4294967296*1e4&268435455;h[c++]=b>>>8&255,h[c++]=255&b,h[c++]=b>>>24&15|16,h[c++]=b>>>16&255,h[c++]=p>>>8|128,h[c++]=255&p;for(var k=0;k<6;++k)h[c+k]=l[k];return e||i(h)}},{"./lib/bytesToUuid":30,"./lib/rng":31}],33:[function(t,e){var r=t("./lib/rng"),n=t("./lib/bytesToUuid");e.exports=function(t,e,o){var i=e&&o||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var s=(t=t||{}).random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;++a)e[i+a]=s[a];return e||n(s)}},{"./lib/bytesToUuid":30,"./lib/rng":31}],34:[function(t,e){e.exports=class{constructor(t,e,r,n){this.id=e,this._backpressure=0,this.stream=t,this.currentNode=r,this.timeout=n,this.isAlive=!0,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}write(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this.applyBackpressure(t),this._resolve&&(this._resolve(),delete this._resolve)}kill(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this._killPacket={value:t,done:!0},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.currentNode.next)try{await this._waitForNextItem(this.timeout)}catch(t){throw this._destroy(),t}if(this._killPacket){this._destroy();let t=this._killPacket;return delete this._killPacket,t}if(this.currentNode=this.currentNode.next,this.releaseBackpressure(this.currentNode.data),!this.currentNode.consumerId||this.currentNode.consumerId===this.id)return this.currentNode.data.done&&this._destroy(),this.currentNode.data}}return(){return delete this.currentNode,this._destroy(),{}}[Symbol.asyncIterator](){return this}}},{}],35:[function(t,e){const r=t("consumable-stream"),n=t("./consumer");e.exports=class extends r{constructor(){super(),this.nextConsumerId=1,this._consumers={},this._tailNode={next:null,data:{value:void 0,done:!1}}}_write(t,e,r){let n={data:{value:t,done:e},next:null};r&&(n.consumerId=r),this._tailNode.next=n,this._tailNode=n;let o=Object.values(this._consumers),i=o.length;for(let t=0;tr&&(r=e)}return r}getConsumerBackpressure(t){let e=this._consumers[t];return e?e.getBackpressure():0}hasConsumer(t){return!!this._consumers[t]}setConsumer(t,e){this._consumers[t]=e,e.currentNode||(e.currentNode=this._tailNode)}removeConsumer(t){delete this._consumers[t]}getConsumerStats(t){let e=this._consumers[t];if(e)return e.getStats()}getConsumerStatsList(){let t=[],e=Object.values(this._consumers),r=e.length;for(let n=0;n