Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

centrifuge

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

centrifuge - npm Package Compare versions

Comparing version 2.7.2 to 2.7.3

5

CHANGELOG.md

@@ -0,1 +1,6 @@

2.7.3
=====
* `SubscribeSuccessContext` can contain `data` field if custom data returned from a server in a subscribe result.
2.7.2

@@ -2,0 +7,0 @@ =====

1

dist/centrifuge.d.ts

@@ -134,2 +134,3 @@ // Type definitions for centrifuge 2.*.*

streamPosition?: StreamPosition;
data?: any;
}

@@ -136,0 +137,0 @@

2

dist/centrifuge.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Centrifuge",[],t):"object"==typeof exports?exports.Centrifuge=t():e.Centrifuge=t()}(this,(function(){return function(){"use strict";var e={382:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.Centrifuge=void 0;var s=u(n(187)),r=u(n(471)),i=n(147),o=n(853);function u(e){return e&&e.__esModule?e:{default:e}}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var _="timeout",d="connection closed",v=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(b,e);var t,s,u,v,p=(u=b,v=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=f(u);if(v){var n=f(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return l(this,e)});function b(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,b),(n=p.call(this))._url=e,n._websocket=null,n._sockjs=null,n._isSockjs=!1,n._binary=!1,n._methodType=null,n._pushType=null,n._encoder=null,n._decoder=null,n._status="disconnected",n._reconnect=!0,n._reconnecting=!1,n._transport=null,n._transportName=null,n._transportClosed=!0,n._messageId=0,n._clientID=null,n._refreshRequired=!1,n._subs={},n._serverSubs={},n._lastSeq={},n._lastGen={},n._lastOffset={},n._lastEpoch={},n._messages=[],n._isBatching=!1,n._isSubscribeBatching=!1,n._privateChannels={},n._numRefreshFailed=0,n._refreshTimeout=null,n._pingTimeout=null,n._pongTimeout=null,n._subRefreshTimeouts={},n._retries=0,n._callbacks={},n._latency=null,n._latencyStart=null,n._connectData=null,n._token=null,n._xhrID=0,n._xhrs={},n._dispatchPromise=Promise.resolve(),n._config={debug:!1,name:"",version:"",websocket:null,sockjs:null,minRetry:1e3,maxRetry:2e4,timeout:5e3,ping:!0,pingInterval:25e3,pongWaitTimeout:5e3,privateChannelPrefix:"$",onTransportClose:null,sockjsServer:null,sockjsTransports:["websocket","xdr-streaming","xhr-streaming","eventsource","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"],refreshEndpoint:"/centrifuge/refresh",refreshHeaders:{},refreshParams:{},refreshData:{},refreshAttempts:null,refreshInterval:1e3,onRefreshFailed:null,onRefresh:null,subscribeEndpoint:"/centrifuge/subscribe",subscribeHeaders:{},subscribeParams:{},subRefreshInterval:1e3,onPrivateSubscribe:null},n._configure(t),n}return t=b,(s=[{key:"setToken",value:function(e){this._token=e}},{key:"setConnectData",value:function(e){this._connectData=e}},{key:"setRefreshHeaders",value:function(e){this._config.refreshHeaders=e}},{key:"setRefreshParams",value:function(e){this._config.refreshParams=e}},{key:"setRefreshData",value:function(e){this._config.refreshData=e}},{key:"setSubscribeHeaders",value:function(e){this._config.subscribeHeaders=e}},{key:"setSubscribeParams",value:function(e){this._config.subscribeParams=e}},{key:"_ajax",value:function(e,t,s,r,i){var o=this,u="";this._debug("sending AJAX request to",e,"with data",JSON.stringify(r));var a=n.g.XMLHttpRequest?new n.g.XMLHttpRequest:new n.g.ActiveXObject("Microsoft.XMLHTTP");for(var c in t)t.hasOwnProperty(c)&&(u.length>0&&(u+="&"),u+=encodeURIComponent(c)+"="+encodeURIComponent(t[c]));for(var h in u.length>0&&(u="?"+u),a.open("POST",e+u,!0),"withCredentials"in a&&(a.withCredentials=!0),a.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.setRequestHeader("Content-Type","application/json"),s)s.hasOwnProperty(h)&&a.setRequestHeader(h,s[h]);return a.onreadystatechange=function(){if(4===a.readyState)if(200===a.status){var e,t=!1;try{e=JSON.parse(a.responseText),t=!0}catch(e){i({error:"Invalid JSON. Data was: "+a.responseText,status:200,data:null})}t&&i({data:e,status:200})}else o._log("wrong status code in AJAX response",a.status),i({status:a.status,data:null})},setTimeout((function(){return a.send(JSON.stringify(r))}),20),a}},{key:"_log",value:function(){(0,o.log)("info",arguments)}},{key:"_debug",value:function(){!0===this._config.debug&&(0,o.log)("debug",arguments)}},{key:"_websocketSupported",value:function(){return null!==this._config.websocket||!("function"!=typeof WebSocket&&"object"!==("undefined"==typeof WebSocket?"undefined":a(WebSocket)))}},{key:"_setFormat",value:function(e){if(!this._formatOverride(e)){if("protobuf"===e)throw new Error("not implemented by JSON only Centrifuge client – use client with Protobuf");this._binary=!1,this._methodType=i.JsonMethodType,this._pushType=i.JsonPushType,this._encoder=new i.JsonEncoder,this._decoder=new i.JsonDecoder}}},{key:"_formatOverride",value:function(e){return!1}},{key:"_configure",value:function(e){if(!("Promise"in n.g))throw new Error("Promise polyfill required");if((0,o.extend)(this._config,e||{}),this._debug("centrifuge config",this._config),!this._url)throw new Error("url required");if((0,o.startsWith)(this._url,"ws")&&this._url.indexOf("format=protobuf")>-1?this._setFormat("protobuf"):this._setFormat("json"),(0,o.startsWith)(this._url,"http"))if(this._debug("client will try to connect to SockJS endpoint"),null!==this._config.sockjs)this._debug("SockJS explicitly provided in options"),this._sockjs=this._config.sockjs;else{if(void 0===n.g.SockJS)throw new Error("SockJS not found, use ws:// in url or include SockJS");this._debug("use globally defined SockJS"),this._sockjs=n.g.SockJS}else this._debug("client will connect to websocket endpoint")}},{key:"_setStatus",value:function(e){this._status!==e&&(this._debug("Status",this._status,"->",e),this._status=e)}},{key:"_isDisconnected",value:function(){return"disconnected"===this._status}},{key:"_isConnecting",value:function(){return"connecting"===this._status}},{key:"_isConnected",value:function(){return"connected"===this._status}},{key:"_nextMessageId",value:function(){return++this._messageId}},{key:"_resetRetry",value:function(){this._debug("reset retries count to 0"),this._retries=0}},{key:"_getRetryInterval",value:function(){var e=(0,o.backoff)(this._retries,this._config.minRetry,this._config.maxRetry);return this._retries+=1,e}},{key:"_abortInflightXHRs",value:function(){for(var e in this._xhrs){try{this._xhrs[e].abort()}catch(e){this._debug("error aborting xhr",e)}delete this._xhrs[e]}}},{key:"_clearConnectedState",value:function(e){for(var t in this._clientID=null,this._stopPing(),this._callbacks)if(this._callbacks.hasOwnProperty(t)){var n=this._callbacks[t];clearTimeout(n.timeout);var s=n.errback;if(!s)continue;s({error:this._createErrorObject("disconnected")})}for(var r in this._callbacks={},this._subs)if(this._subs.hasOwnProperty(r)){var i=this._subs[r];e?(i._isSuccess()&&(i._triggerUnsubscribe(),i._recover=!0),i._shouldResubscribe()&&i._setSubscribing()):i._setUnsubscribed()}for(var o in this._abortInflightXHRs(),null!==this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),this._subRefreshTimeouts)this._subRefreshTimeouts.hasOwnProperty(o)&&this._subRefreshTimeouts[o]&&this._clearSubRefreshTimeout(o);this._subRefreshTimeouts={},this._reconnect||(this._subs={})}},{key:"_isTransportOpen",value:function(){return this._isSockjs?this._transport&&this._transport.transport&&this._transport.transport.readyState===this._transport.transport.OPEN:this._transport&&this._transport.readyState===this._transport.OPEN}},{key:"_transportSend",value:function(e){if(!e.length)return!0;if(!this._isTransportOpen()){for(var t in e){var n=t.id;if(n in this._callbacks){var s=this._callbacks[n];clearTimeout(this._callbacks[n].timeout),delete this._callbacks[n],(0,s.errback)({error:this._createErrorObject(d,0)})}}return!1}return this._transport.send(this._encoder.encodeCommands(e)),!0}},{key:"_setupTransport",value:function(){var e=this;if(this._isSockjs=!1,null!==this._sockjs){var t={transports:this._config.sockjsTransports};null!==this._config.sockjsServer&&(t.server=this._config.sockjsServer),this._isSockjs=!0,this._transport=new this._sockjs(this._url,null,t)}else{if(!this._websocketSupported())return void this._debug("No Websocket support and no SockJS configured, can not connect");null!==this._config.websocket?this._websocket=this._config.websocket:this._websocket=WebSocket,this._transport=new this._websocket(this._url),!0===this._binary&&(this._transport.binaryType="arraybuffer")}this._transport.onopen=function(){e._transportClosed=!1,e._isSockjs?(e._transportName="sockjs-"+e._transport.transport,e._transport.onheartbeat=function(){return e._restartPing()}):e._transportName="websocket";var t={};(e._token||e._connectData||e._config.name||e._config.version)&&(t.params={}),e._token&&(t.params.token=e._token),e._connectData&&(t.params.data=e._connectData),e._config.name&&(t.params.name=e._config.name),e._config.version&&(t.params.version=e._config.version);var n={},s=!1;for(var r in e._serverSubs)if(e._serverSubs.hasOwnProperty(r)&&e._serverSubs[r].recoverable){s=!0;var i={recover:!0};e._serverSubs[r].seq||e._serverSubs[r].gen?(e._serverSubs[r].seq&&(i.seq=e._serverSubs[r].seq),e._serverSubs[r].gen&&(i.gen=e._serverSubs[r].gen)):e._serverSubs[r].offset&&(i.offset=e._serverSubs[r].offset),e._serverSubs[r].epoch&&(i.epoch=e._serverSubs[r].epoch),n[r]=i}s&&(t.params||(t.params={}),t.params.subs=n),e._latencyStart=new Date,e._call(t).then((function(t){e._connectResponse(e._decoder.decodeCommandResult(e._methodType.CONNECT,t.result),s),t.next&&t.next()}),(function(t){109===t.error.code&&(e._refreshRequired=!0),e._disconnect("connect error",!0),t.next&&t.next()}))},this._transport.onerror=function(t){e._debug("transport level error",t)},this._transport.onclose=function(t){e._transportClosed=!0;var n=d,s=!0;if(t&&"reason"in t&&t.reason)try{var r=JSON.parse(t.reason);e._debug("reason is an advice object",r),n=r.reason,s=r.reconnect}catch(s){n=t.reason,e._debug("reason is a plain string",n)}if(null!==e._config.onTransportClose&&e._config.onTransportClose({event:t,reason:n,reconnect:s}),e._disconnect(n,s),!0===e._reconnect){e._reconnecting=!0;var i=e._getRetryInterval();e._debug("reconnect after "+i+" milliseconds"),setTimeout((function(){!0===e._reconnect&&(e._refreshRequired?e._refresh():e._connect())}),i)}},this._transport.onmessage=function(t){e._dataReceived(t.data)}}},{key:"rpc",value:function(e){return this._rpc("",e)}},{key:"namedRPC",value:function(e,t){return this._rpc(e,t)}},{key:"_rpc",value:function(e,t){var n={data:t};""!==e&&(n.method=e);var s={method:this._methodType.RPC,params:n};return this._methodCall(s,(function(e){return e}))}},{key:"send",value:function(e){var t={method:this._methodType.SEND,params:{data:e}};return this.isConnected()&&this._transportSend([t])?Promise.resolve({}):Promise.reject(this._createErrorObject(d,0))}},{key:"_getHistoryParams",value:function(e,t){var n={channel:e};return void 0!==t&&(t.since&&(n.use_since=!0,t.since.offset&&(n.offset=t.since.offset),t.since.epoch&&(n.epoch=t.since.epoch)),void 0!==t.limit&&(n.use_limit=!0,n.limit=t.limit)),n}},{key:"_methodCall",value:function(e,t){var n=this;return this.isConnected()?new Promise((function(s,r){n._call(e).then((function(r){s(t(n._decoder.decodeCommandResult(e.method,r.result))),r.next&&r.next()}),(function(e){r(e.error),e.next&&e.next()}))})):Promise.reject(this._createErrorObject(d,0))}},{key:"publish",value:function(e,t){var n={method:this._methodType.PUBLISH,params:{channel:e,data:t}};return this._methodCall(n,(function(){return{}}))}},{key:"history",value:function(e,t){var n=this._getHistoryParams(e,t),s={method:this._methodType.HISTORY,params:n};return this._methodCall(s,(function(e){return{publications:e.publications,epoch:e.epoch||"",offset:e.offset||0}}))}},{key:"presence",value:function(e){var t={method:this._methodType.PRESENCE,params:{channel:e}};return this._methodCall(t,(function(e){return{presence:e.presence}}))}},{key:"presenceStats",value:function(e){var t={method:this._methodType.PRESENCE_STATS,params:{channel:e}};return this._methodCall(t,(function(e){return{num_users:e.num_users,num_clients:e.num_clients}}))}},{key:"_dataReceived",value:function(e){var t=this,n=this._decoder.decodeReplies(e);this._dispatchPromise=this._dispatchPromise.then((function(){var e;t._dispatchPromise=new Promise((function(t){e=t})),t._dispatchSynchronized(n,e)})),this._restartPing()}},{key:"_dispatchSynchronized",value:function(e,t){var n=this,s=Promise.resolve(),r=function(t){e.hasOwnProperty(t)&&(s=s.then((function(){return n._dispatchReply(e[t])})))};for(var i in e)r(i);s=s.then((function(){t()}))}},{key:"_dispatchReply",value:function(e){var t,n=new Promise((function(e){t=e}));if(null==e)return this._debug("dispatch: got undefined or null reply"),t(),n;var s=e.id;return s&&s>0?this._handleReply(e,t):this._handlePush(e.result,t),n}},{key:"_call",value:function(e){var t=this;return new Promise((function(n,s){var r=t._addMessage(e);t._registerCall(r,n,s)}))}},{key:"_connect",value:function(){this.isConnected()?this._debug("connect called when already connected"):"connecting"!==this._status&&(this._debug("start connecting"),this._setStatus("connecting"),this._clientID=null,this._reconnect=!0,this._setupTransport())}},{key:"_disconnect",value:function(e,t){var n=t||!1;if(!1===n&&(this._reconnect=!1),this._isDisconnected())n||this._clearConnectedState(n);else{if(this._clearConnectedState(n),this._debug("disconnected:",e,t),this._setStatus("disconnected"),this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),!1===this._reconnecting){for(var s in this._serverSubs)this._serverSubs.hasOwnProperty(s)&&this.emit("unsubscribe",{channel:s});this.emit("disconnect",{reason:e,reconnect:n})}!1===n&&(this._subs={},this._serverSubs={}),this._transportClosed||this._transport.close()}}},{key:"_refreshFailed",value:function(){this._numRefreshFailed=0,this._isDisconnected()||this._disconnect("refresh failed",!1),null!==this._config.onRefreshFailed&&this._config.onRefreshFailed()}},{key:"_refresh",value:function(){var e=this;if(this._debug("refresh token"),0===this._config.refreshAttempts)return this._debug("refresh attempts set to 0, do not send refresh request at all"),void this._refreshFailed();null!==this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);var t=this._clientID,n=this._newXHRID(),s=function(s){if(n in e._xhrs&&delete e._xhrs[n],e._clientID===t)if(s.error||200!==s.status){if(s.error?e._debug("error refreshing connection token",s.error):e._debug("error refreshing connection token: wrong status code",s.status),e._numRefreshFailed++,null!==e._refreshTimeout&&(clearTimeout(e._refreshTimeout),e._refreshTimeout=null),null!==e._config.refreshAttempts&&e._numRefreshFailed>=e._config.refreshAttempts)return void e._refreshFailed();var r=Math.round(1e3*Math.random()*Math.max(e._numRefreshFailed,20)),i=e._config.refreshInterval+r;e._refreshTimeout=setTimeout((function(){return e._refresh()}),i)}else if(e._numRefreshFailed=0,e._token=s.data.token,e._token)if(e._isDisconnected()&&e._reconnect)e._debug("token refreshed, connect from scratch"),e._connect();else{e._debug("send refreshed token");var o={method:e._methodType.REFRESH,params:{token:e._token}};e._call(o).then((function(t){e._refreshResponse(e._decoder.decodeCommandResult(e._methodType.REFRESH,t.result)),t.next&&t.next()}),(function(t){e._refreshError(t.error),t.next&&t.next()}))}else e._refreshFailed()};if(null!==this._config.onRefresh)this._config.onRefresh({},s);else{var r=this._ajax(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,s);this._xhrs[n]=r}}},{key:"_refreshError",value:function(e){var t=this;this._debug("refresh error",e),this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);var n=this._config.refreshInterval+Math.round(1e3*Math.random());this._refreshTimeout=setTimeout((function(){return t._refresh()}),n)}},{key:"_refreshResponse",value:function(e){var t=this;this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),e.expires&&(this._clientID=e.client,this._refreshTimeout=setTimeout((function(){return t._refresh()}),this._getTTLMilliseconds(e.ttl)))}},{key:"_newXHRID",value:function(){return this._xhrID++,this._xhrID}},{key:"_subRefresh",value:function(e){var t=this;if(this._debug("refresh subscription token for channel",e),void 0!==this._subRefreshTimeouts[e]){this._clearSubRefreshTimeout(e);var n=this._clientID,s=this._newXHRID(),r=function(r){if(s in t._xhrs&&delete t._xhrs[s],!r.error&&200===r.status&&t._clientID===n){var i={};if(r.data.channels)for(var o in r.data.channels){var u=r.data.channels[o];u.channel&&(i[u.channel]=u.token)}var a=i[e];if(a){var c={method:t._methodType.SUB_REFRESH,params:{channel:e,token:a}};null!==t._getSub(e)&&t._call(c).then((function(n){t._subRefreshResponse(e,t._decoder.decodeCommandResult(t._methodType.SUB_REFRESH,n.result)),n.next&&n.next()}),(function(n){t._subRefreshError(e,n.error),n.next&&n.next()}))}}},i={client:this._clientID,channels:[e]};if(null!==this._config.onPrivateSubscribe)this._config.onPrivateSubscribe({data:i},r);else{var o=this._ajax(this._config.subscribeEndpoint,this._config.subscribeParams,this._config.subscribeHeaders,i,r);this._xhrs[s]=o}}}},{key:"_clearSubRefreshTimeout",value:function(e){void 0!==this._subRefreshTimeouts[e]&&(clearTimeout(this._subRefreshTimeouts[e]),delete this._subRefreshTimeouts[e])}},{key:"_subRefreshError",value:function(e,t){var n=this;if(this._debug("subscription refresh error",e,t),this._clearSubRefreshTimeout(e),null!==this._getSub(e)){var s=Math.round(1e3*Math.random()),r=setTimeout((function(){return n._subRefresh(e)}),this._config.subRefreshInterval+s);this._subRefreshTimeouts[e]=r}}},{key:"_subRefreshResponse",value:function(e,t){var n=this;if(this._debug("subscription refresh success",e),this._clearSubRefreshTimeout(e),null!==this._getSub(e)&&!0===t.expires){var s=setTimeout((function(){return n._subRefresh(e)}),this._getTTLMilliseconds(t.ttl));this._subRefreshTimeouts[e]=s}}},{key:"_subscribe",value:function(e,t){var n=this;this._debug("subscribing on",e.channel);var s=e.channel;if(s in this._subs||(this._subs[s]=e),this.isConnected()){e._setSubscribing(t);var r={method:this._methodType.SUBSCRIBE,params:{channel:s}};if((0,o.startsWith)(s,this._config.privateChannelPrefix))this._isSubscribeBatching?this._privateChannels[s]=!0:(this.startSubscribeBatching(),this._subscribe(e),this.stopSubscribeBatching());else{var i=e._needRecover();if(!0===i){r.params.recover=!0;var u=this._getLastSeq(s),a=this._getLastGen(s);if(u||a)u&&(r.params.seq=u),a&&(r.params.gen=a);else{var c=this._getLastOffset(s);c&&(r.params.offset=c)}var h=this._getLastEpoch(s);h&&(r.params.epoch=h)}this._call(r).then((function(e){n._subscribeResponse(s,i,n._decoder.decodeCommandResult(n._methodType.SUBSCRIBE,e.result)),e.next&&e.next()}),(function(e){n._subscribeError(s,e.error),e.next&&e.next()}))}}else e._setNew()}},{key:"_unsubscribe",value:function(e){delete this._subs[e.channel],delete this._lastOffset[e.channel],delete this._lastSeq[e.channel],delete this._lastGen[e.channel],this.isConnected()&&this._addMessage({method:this._methodType.UNSUBSCRIBE,params:{channel:e.channel}})}},{key:"_getTTLMilliseconds",value:function(e){return Math.min(1e3*e,2147483647)}},{key:"getSub",value:function(e){return this._getSub(e)}},{key:"_getSub",value:function(e){return this._subs[e]||null}},{key:"_isServerSub",value:function(e){return void 0!==this._serverSubs[e]}},{key:"_connectResponse",value:function(e,t){var n=this,s=this._reconnecting;if(this._reconnecting=!1,this._resetRetry(),this._refreshRequired=!1,!this.isConnected()){for(var r in null!==this._latencyStart&&(this._latency=(new Date).getTime()-this._latencyStart.getTime(),this._latencyStart=null),this._clientID=e.client,this._setStatus("connected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout),e.expires&&(this._refreshTimeout=setTimeout((function(){return n._refresh()}),this._getTTLMilliseconds(e.ttl))),this.startBatching(),this.startSubscribeBatching(),this._subs)if(this._subs.hasOwnProperty(r)){var i=this._subs[r];i._shouldResubscribe()&&this._subscribe(i,s)}this.stopSubscribeBatching(),this.stopBatching(),this._startPing();var o={client:e.client,transport:this._transportName,latency:this._latency};e.data&&(o.data=e.data),this.emit("connect",o),e.subs&&this._processServerSubs(e.subs)}}},{key:"_processServerSubs",value:function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t],s={channel:t,isResubscribe:void 0!==this._serverSubs[t]};s=this._expandSubscribeContext(s,n),this.emit("subscribe",s)}for(var r in e)if(e.hasOwnProperty(r)){var i=e[r];if(i.recovered){var o=i.publications;if(o&&o.length>0)for(var u in o.length>1&&(!o[0].offset||o[0].offset>o[1].offset)&&(o=o.reverse()),o)o.hasOwnProperty(u)&&this._handlePublication(r,o[u])}this._serverSubs[r]={seq:i.seq,gen:i.gen,offset:i.offset,epoch:i.epoch,recoverable:i.recoverable}}}},{key:"_stopPing",value:function(){null!==this._pongTimeout&&(clearTimeout(this._pongTimeout),this._pongTimeout=null),null!==this._pingTimeout&&(clearTimeout(this._pingTimeout),this._pingTimeout=null)}},{key:"_startPing",value:function(){var e=this;!0!==this._config.ping||this._config.pingInterval<=0||this.isConnected()&&(this._pingTimeout=setTimeout((function(){e.isConnected()?(e.ping(),e._pongTimeout=setTimeout((function(){e._disconnect("no ping",!0)}),e._config.pongWaitTimeout)):e._stopPing()}),this._config.pingInterval))}},{key:"_restartPing",value:function(){this._stopPing(),this._startPing()}},{key:"_subscribeError",value:function(e,t){var n=this._getSub(e);n&&n._isSubscribing()&&(0!==t.code||t.message!==_?n._setSubscribeError(t):this._disconnect("timeout",!0))}},{key:"_expandSubscribeContext",value:function(e,t){var n=!1;"recovered"in t&&(n=t.recovered),e.recovered=n;var s=!1;"positioned"in t&&(s=t.positioned);var r="";"epoch"in t&&(r=t.epoch);var i=0;return"offset"in t&&(i=t.offset),s&&(e.streamPosition={offset:i,epoch:r}),e}},{key:"_subscribeResponse",value:function(e,t,n){var s=this,r=this._getSub(e);if(r&&r._isSubscribing()){r._setSubscribeSuccess(n);var i=n.publications;if(i&&i.length>0)for(var o in i.length>=2&&!i[0].offset&&!i[1].offset&&(i=i.reverse()),i)i.hasOwnProperty(o)&&this._handlePublication(e,i[o]);if(!n.recoverable||t&&n.recovered||(this._lastSeq[e]=n.seq||0,this._lastGen[e]=n.gen||0,this._lastOffset[e]=n.offset||0),this._lastEpoch[e]=n.epoch||"",n.recoverable&&(r._recoverable=!0),!0===n.expires){var u=setTimeout((function(){return s._subRefresh(e)}),this._getTTLMilliseconds(n.ttl));this._subRefreshTimeouts[e]=u}}}},{key:"_handleReply",value:function(e,t){var n=e.id,s=e.result;if(n in this._callbacks){var r=this._callbacks[n];if(clearTimeout(this._callbacks[n].timeout),delete this._callbacks[n],(0,o.errorExists)(e)){var i=r.errback;if(!i)return void t();i({error:e.error,next:t})}else{var u=r.callback;if(!u)return;u({result:s,next:t})}}else t()}},{key:"_handleJoin",value:function(e,t){var n={info:t.info},s=this._getSub(e);s?s.emit("join",n):this._isServerSub(e)&&(n.channel=e,this.emit("join",n))}},{key:"_handleLeave",value:function(e,t){var n={info:t.info},s=this._getSub(e);s?s.emit("leave",n):this._isServerSub(e)&&(n.channel=e,this.emit("leave",n))}},{key:"_handleUnsub",value:function(e,t){var n={},s=this._getSub(e);s?(s.unsubscribe(),!0===t.resubscribe&&s.subscribe()):this._isServerSub(e)&&(delete this._serverSubs[e],n.channel=e,this.emit("unsubscribe",n))}},{key:"_handleSub",value:function(e,t){this._serverSubs[e]={seq:t.seq,gen:t.gen,offset:t.offset,epoch:t.epoch,recoverable:t.recoverable};var n={channel:e,isResubscribe:!1};n=this._expandSubscribeContext(n,t),this.emit("subscribe",n)}},{key:"_handlePublication",value:function(e,t){var n=this._getSub(e),s={data:t.data,seq:t.seq,gen:t.gen,offset:t.offset};t.info&&(s.info=t.info),n?(void 0!==t.seq&&(this._lastSeq[e]=t.seq),void 0!==t.gen&&(this._lastGen[e]=t.gen),void 0!==t.offset&&(this._lastOffset[e]=t.offset),n.emit("publish",s)):this._isServerSub(e)&&(void 0!==t.seq&&(this._serverSubs[e].seq=t.seq),void 0!==t.gen&&(this._serverSubs[e].gen=t.gen),void 0!==t.offset&&(this._serverSubs[e].offset=t.offset),s.channel=e,this.emit("publish",s))}},{key:"_handleMessage",value:function(e){this.emit("message",e.data)}},{key:"_handlePush",value:function(e,t){var n=this._decoder.decodePush(e),s=0;"type"in n&&(s=n.type);var r=n.channel;if(s===this._pushType.PUBLICATION){var i=this._decoder.decodePushData(this._pushType.PUBLICATION,n.data);this._handlePublication(r,i)}else if(s===this._pushType.MESSAGE){var o=this._decoder.decodePushData(this._pushType.MESSAGE,n.data);this._handleMessage(o)}else if(s===this._pushType.JOIN){var u=this._decoder.decodePushData(this._pushType.JOIN,n.data);this._handleJoin(r,u)}else if(s===this._pushType.LEAVE){var a=this._decoder.decodePushData(this._pushType.LEAVE,n.data);this._handleLeave(r,a)}else if(s===this._pushType.UNSUB){var c=this._decoder.decodePushData(this._pushType.UNSUB,n.data);this._handleUnsub(r,c)}else if(s===this._pushType.SUB){var h=this._decoder.decodePushData(this._pushType.SUB,n.data);this._handleSub(r,h)}t()}},{key:"_flush",value:function(){var e=this._messages.slice(0);this._messages=[],this._transportSend(e)}},{key:"_ping",value:function(){var e=this,t={method:this._methodType.PING};this._call(t).then((function(t){e._pingResponse(e._decoder.decodeCommandResult(e._methodType.PING,t.result)),t.next&&t.next()}),(function(t){e._debug("ping error",t.error),t.next&&t.next()}))}},{key:"_pingResponse",value:function(e){this.isConnected()&&(this._stopPing(),this._startPing())}},{key:"_getLastSeq",value:function(e){return this._lastSeq[e]||0}},{key:"_getLastOffset",value:function(e){return this._lastOffset[e]||0}},{key:"_getLastGen",value:function(e){return this._lastGen[e]||0}},{key:"_getLastEpoch",value:function(e){return this._lastEpoch[e]||""}},{key:"_createErrorObject",value:function(e,t){return{message:e,code:t||0}}},{key:"_registerCall",value:function(e,t,n){var s=this;this._callbacks[e]={callback:t,errback:n,timeout:null},this._callbacks[e].timeout=setTimeout((function(){delete s._callbacks[e],(0,o.isFunction)(n)&&n({error:s._createErrorObject(_)})}),this._config.timeout)}},{key:"_addMessage",value:function(e){var t=this._nextMessageId();return e.id=t,!0===this._isBatching?this._messages.push(e):this._transportSend([e]),t}},{key:"isConnected",value:function(){return this._isConnected()}},{key:"connect",value:function(){this._connect()}},{key:"disconnect",value:function(){this._disconnect("client",!1)}},{key:"ping",value:function(){return this._ping()}},{key:"startBatching",value:function(){this._isBatching=!0}},{key:"stopBatching",value:function(){this._isBatching=!1,this._flush()}},{key:"startSubscribeBatching",value:function(){this._isSubscribeBatching=!0}},{key:"stopSubscribeBatching",value:function(){var e=this;this._isSubscribeBatching=!1;var t=this._privateChannels;this._privateChannels={};var n=[];for(var s in t)if(t.hasOwnProperty(s)){if(!this._getSub(s))continue;n.push(s)}if(0!==n.length){var r={client:this._clientID,channels:n},i=this._clientID,o=this._newXHRID(),u=function(t){if(o in e._xhrs&&delete e._xhrs[o],e._clientID===i)if(t.error||200!==t.status){for(var s in e._debug("authorization request failed"),n)if(n.hasOwnProperty(s)){var r=n[s];e._subscribeError(r,e._createErrorObject("authorization request failed"))}}else{var u={};if(t.data.channels)for(var a in t.data.channels){var c=t.data.channels[a];c.channel&&(u[c.channel]=c.token)}var h=!1;for(var l in e._isBatching||(e.startBatching(),h=!0),n)!n.hasOwnProperty(l)||function(){var t=n[l],s=u[t];if(!s)return e._subscribeError(t,e._createErrorObject("permission denied",103)),"continue";var r={method:e._methodType.SUBSCRIBE,params:{channel:t,token:s}},i=e._getSub(t);if(null===i)return"continue";var o=i._needRecover();if(!0===o){r.params.recover=!0;var a=e._getLastSeq(t),c=e._getLastGen(t);if(a||c)a&&(r.params.seq=a),c&&(r.params.gen=c);else{var h=e._getLastOffset(t);h&&(r.params.offset=h)}var f=e._getLastEpoch(t);f&&(r.params.epoch=f)}e._call(r).then((function(n){e._subscribeResponse(t,o,e._decoder.decodeCommandResult(e._methodType.SUBSCRIBE,n.result)),n.next&&n.next()}),(function(n){e._subscribeError(t,n.error),n.next&&n.next()}))}();h&&e.stopBatching()}};if(null!==this._config.onPrivateSubscribe)this._config.onPrivateSubscribe({data:r},u);else{var a=this._ajax(this._config.subscribeEndpoint,this._config.subscribeParams,this._config.subscribeHeaders,r,u);this._xhrs[o]=a}}else this._debug("no private channels found, no need to make request")}},{key:"subscribe",value:function(e,t){var n=this._getSub(e);if(null!==n)return n._setEvents(t),n._isUnsubscribed()&&n.subscribe(),n;var s=new r.default(this,e,t);return this._subs[e]=s,s.subscribe(),s}}])&&c(t.prototype,s),b}(s.default);t.Centrifuge=v},579:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=n(382).Centrifuge;t.default=s,e.exports=t.default},147:function(e,t){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function r(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}Object.defineProperty(t,"__esModule",{value:!0}),t.JsonDecoder=t.JsonEncoder=t.JsonPushType=t.JsonMethodType=void 0,t.JsonMethodType={CONNECT:0,SUBSCRIBE:1,UNSUBSCRIBE:2,PUBLISH:3,PRESENCE:4,PRESENCE_STATS:5,HISTORY:6,PING:7,SEND:8,RPC:9,REFRESH:10,SUB_REFRESH:11},t.JsonPushType={PUBLICATION:0,JOIN:1,LEAVE:2,UNSUB:3,MESSAGE:4,SUB:5};var i=function(){function e(){n(this,e)}return r(e,[{key:"encodeCommands",value:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(JSON.stringify(e[n]));return t.join("\n")}}]),e}();t.JsonEncoder=i;var o=function(){function e(){n(this,e)}return r(e,[{key:"decodeReplies",value:function(e){var t=[],n=e.split("\n");for(var s in n)if(n.hasOwnProperty(s)){if(!n[s])continue;var r=JSON.parse(n[s]);t.push(r)}return t}},{key:"decodeCommandResult",value:function(e,t){return t}},{key:"decodePush",value:function(e){return e}},{key:"decodePushData",value:function(e,t){return t}}]),e}();t.JsonDecoder=o},471:function(e,t,n){function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,i=(r=n(187))&&r.__esModule?r:{default:r},o=n(853);function u(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(l,e);var t,n,s,r,i=(s=l,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=h(s);if(r){var n=h(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return c(this,e)});function l(e,t,n){var s;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(s=i.call(this)).channel=t,s._centrifuge=e,s._status=0,s._error=null,s._isResubscribe=!1,s._ready=!1,s._subscriptionPromise=null,s._noResubscribe=!1,s._recoverable=!1,s._recover=!1,s._setEvents(n),s._initializePromise(),s._promises={},s._promiseId=0,s.on("error",(function(e){this._centrifuge._debug("subscription error",e)})),s}return t=l,(n=[{key:"_nextPromiseId",value:function(){return++this._promiseId}},{key:"_initializePromise",value:function(){var e=this;this._ready=!1,this._subscriptionPromise=new Promise((function(t,n){e._resolve=function(n){e._ready=!0,t(n)},e._reject=function(t){e._ready=!0,n(t)}})).then((function(){}),(function(){}))}},{key:"_needRecover",value:function(){return!0===this._recoverable&&!0===this._recover}},{key:"_setEvents",value:function(e){if(e)if((0,o.isFunction)(e))this.on("publish",e);else if(Object.prototype.toString.call(e)===Object.prototype.toString.call({}))for(var t=["publish","join","leave","unsubscribe","subscribe","error"],n=0,s=t.length;n<s;n++){var r=t[n];r in e&&this.on(r,e[r])}}},{key:"_isNew",value:function(){return 0===this._status}},{key:"_isUnsubscribed",value:function(){return 4===this._status}},{key:"_isSubscribing",value:function(){return 1===this._status}},{key:"_isReady",value:function(){return 2===this._status||3===this._status}},{key:"_isSuccess",value:function(){return 2===this._status}},{key:"_isError",value:function(){return 3===this._status}},{key:"_setNew",value:function(){this._status=0}},{key:"_setSubscribing",value:function(e){this._isResubscribe=e||!1,!0===this._ready&&this._initializePromise(),this._status=1}},{key:"_setSubscribeSuccess",value:function(e){if(2!==this._status){this._status=2;var t=this._getSubscribeSuccessContext(e);for(var n in this._recover=!1,this.emit("subscribe",t),this._resolve(t),this._promises)clearTimeout(this._promises[n].timeout),this._promises[n].resolve(),delete this._promises[n]}}},{key:"_setSubscribeError",value:function(e){if(3!==this._status){this._status=3,this._error=e;var t=this._getSubscribeErrorContext();for(var n in this.emit("error",t),this._reject(t),this._promises)clearTimeout(this._promises[n].timeout),this._promises[n].reject(e),delete this._promises[n]}}},{key:"_triggerUnsubscribe",value:function(){this.emit("unsubscribe",{channel:this.channel})}},{key:"_setUnsubscribed",value:function(e){if(this._centrifuge._clearSubRefreshTimeout(this.channel),4!==this._status){var t=2===this._status;this._status=4,!0===e&&(this._recover=!1,this._noResubscribe=!0,delete this._centrifuge._lastSeq[this.channel],delete this._centrifuge._lastGen[this.channel],delete this._centrifuge._lastEpoch[this.channel]),t&&this._triggerUnsubscribe()}}},{key:"_shouldResubscribe",value:function(){return!this._noResubscribe}},{key:"_getSubscribeSuccessContext",value:function(e){var t={channel:this.channel,isResubscribe:this._isResubscribe};return e&&(t=this._centrifuge._expandSubscribeContext(t,e)),t}},{key:"_getSubscribeErrorContext",value:function(){var e=this._error;return e.channel=this.channel,e.isResubscribe=this._isResubscribe,e}},{key:"ready",value:function(e,t){this._ready&&(this._isSuccess()?e(this._getSubscribeSuccessContext()):t(this._getSubscribeErrorContext()))}},{key:"subscribe",value:function(){2!==this._status&&(this._noResubscribe=!1,this._centrifuge._subscribe(this))}},{key:"unsubscribe",value:function(){this._setUnsubscribed(!0),this._centrifuge._unsubscribe(this)}},{key:"_methodCall",value:function(){var e=this;return this._isSuccess()?Promise.resolve():this._isError()?Promise.reject(this._error):new Promise((function(t,n){var s=setTimeout((function(){n({code:0,message:"timeout"})}),e._centrifuge._config.timeout);e._promises[e._nextPromiseId()]={timeout:s,resolve:t,reject:n}}))}},{key:"publish",value:function(e){var t=this;return this._methodCall().then((function(){return t._centrifuge.publish(t.channel,e)}))}},{key:"presence",value:function(){var e=this;return this._methodCall().then((function(){return e._centrifuge.presence(e.channel)}))}},{key:"presenceStats",value:function(){var e=this;return this._methodCall().then((function(){return e._centrifuge.presenceStats(e.channel)}))}},{key:"history",value:function(e){var t=this;return this._methodCall().then((function(){return t._centrifuge.history(t.channel,e)}))}}])&&u(t.prototype,n),l}(i.default);t.default=l,e.exports=t.default},853:function(e,t,n){function s(e){return null!=e&&"function"==typeof e}Object.defineProperty(t,"__esModule",{value:!0}),t.startsWith=function(e,t){return 0===e.lastIndexOf(t,0)},t.isFunction=s,t.log=function(e,t){if(n.g.console){var r=n.g.console[e];s(r)&&r.apply(n.g.console,t)}},t.backoff=function(e,t,n){var s=.5*Math.random(),r=Math.min(n,t*Math.pow(2,e+1));return Math.floor((1-s)*r)},t.errorExists=function(e){return"error"in e&&null!==e.error},t.extend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}},187:function(e){var t,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(n,s){function r(){void 0!==i&&e.removeListener("error",i),n([].slice.call(arguments))}var i;"error"!==t&&(i=function(n){e.removeListener(t,r),s(n)},e.once("error",i)),e.once(t,r)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,n,s){var r,i,o,c;if(u(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),o=i[t]),void 0===o)o=i[t]=n,++e._eventsCount;else if("function"==typeof o?o=i[t]=s?[n,o]:[o,n]:s?o.unshift(n):o.push(n),(r=a(e))>0&&o.length>r&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,c=h,console&&console.warn&&console.warn(c)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=h.bind(s);return r.listener=n,s.wrapFn=r,r}function f(e,t,n){var s=e._events;if(void 0===s)return[];var r=s[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):d(r,r.length)}function _(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return a(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw u.context=o,u}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)s(a,this,t);else{var c=a.length,h=d(a,c);for(n=0;n<c;++n)s(h[n],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return u(t),this.on(e,l(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,l(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,s,r,i,o;if(u(t),void 0===(s=this._events))return this;if(void 0===(n=s[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){o=n[i].listener,r=i;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(s[e]=n[0]),void 0!==s.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,s;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,i=Object.keys(n);for(s=0;s<i.length;++s)"removeListener"!==(r=i[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},i.prototype.listeners=function(e){return f(this,e,!0)},i.prototype.rawListeners=function(e){return f(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):_.call(e,t)},i.prototype.listenerCount=_,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}},t={};function n(s){if(t[s])return t[s].exports;var r=t[s]={exports:{}};return e[s](r,r.exports,n),r.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(579)}()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Centrifuge",[],t):"object"==typeof exports?exports.Centrifuge=t():e.Centrifuge=t()}(this,(function(){return function(){"use strict";var e={382:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.Centrifuge=void 0;var s=u(n(187)),r=u(n(471)),i=n(147),o=n(853);function u(e){return e&&e.__esModule?e:{default:e}}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var _="timeout",d="connection closed",v=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(b,e);var t,s,u,v,p=(u=b,v=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=f(u);if(v){var n=f(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return l(this,e)});function b(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,b),(n=p.call(this))._url=e,n._websocket=null,n._sockjs=null,n._isSockjs=!1,n._binary=!1,n._methodType=null,n._pushType=null,n._encoder=null,n._decoder=null,n._status="disconnected",n._reconnect=!0,n._reconnecting=!1,n._transport=null,n._transportName=null,n._transportClosed=!0,n._messageId=0,n._clientID=null,n._refreshRequired=!1,n._subs={},n._serverSubs={},n._lastSeq={},n._lastGen={},n._lastOffset={},n._lastEpoch={},n._messages=[],n._isBatching=!1,n._isSubscribeBatching=!1,n._privateChannels={},n._numRefreshFailed=0,n._refreshTimeout=null,n._pingTimeout=null,n._pongTimeout=null,n._subRefreshTimeouts={},n._retries=0,n._callbacks={},n._latency=null,n._latencyStart=null,n._connectData=null,n._token=null,n._xhrID=0,n._xhrs={},n._dispatchPromise=Promise.resolve(),n._config={debug:!1,name:"",version:"",websocket:null,sockjs:null,minRetry:1e3,maxRetry:2e4,timeout:5e3,ping:!0,pingInterval:25e3,pongWaitTimeout:5e3,privateChannelPrefix:"$",onTransportClose:null,sockjsServer:null,sockjsTransports:["websocket","xdr-streaming","xhr-streaming","eventsource","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"],refreshEndpoint:"/centrifuge/refresh",refreshHeaders:{},refreshParams:{},refreshData:{},refreshAttempts:null,refreshInterval:1e3,onRefreshFailed:null,onRefresh:null,subscribeEndpoint:"/centrifuge/subscribe",subscribeHeaders:{},subscribeParams:{},subRefreshInterval:1e3,onPrivateSubscribe:null},n._configure(t),n}return t=b,(s=[{key:"setToken",value:function(e){this._token=e}},{key:"setConnectData",value:function(e){this._connectData=e}},{key:"setRefreshHeaders",value:function(e){this._config.refreshHeaders=e}},{key:"setRefreshParams",value:function(e){this._config.refreshParams=e}},{key:"setRefreshData",value:function(e){this._config.refreshData=e}},{key:"setSubscribeHeaders",value:function(e){this._config.subscribeHeaders=e}},{key:"setSubscribeParams",value:function(e){this._config.subscribeParams=e}},{key:"_ajax",value:function(e,t,s,r,i){var o=this,u="";this._debug("sending AJAX request to",e,"with data",JSON.stringify(r));var a=n.g.XMLHttpRequest?new n.g.XMLHttpRequest:new n.g.ActiveXObject("Microsoft.XMLHTTP");for(var c in t)t.hasOwnProperty(c)&&(u.length>0&&(u+="&"),u+=encodeURIComponent(c)+"="+encodeURIComponent(t[c]));for(var h in u.length>0&&(u="?"+u),a.open("POST",e+u,!0),"withCredentials"in a&&(a.withCredentials=!0),a.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.setRequestHeader("Content-Type","application/json"),s)s.hasOwnProperty(h)&&a.setRequestHeader(h,s[h]);return a.onreadystatechange=function(){if(4===a.readyState)if(200===a.status){var e,t=!1;try{e=JSON.parse(a.responseText),t=!0}catch(e){i({error:"Invalid JSON. Data was: "+a.responseText,status:200,data:null})}t&&i({data:e,status:200})}else o._log("wrong status code in AJAX response",a.status),i({status:a.status,data:null})},setTimeout((function(){return a.send(JSON.stringify(r))}),20),a}},{key:"_log",value:function(){(0,o.log)("info",arguments)}},{key:"_debug",value:function(){!0===this._config.debug&&(0,o.log)("debug",arguments)}},{key:"_websocketSupported",value:function(){return null!==this._config.websocket||!("function"!=typeof WebSocket&&"object"!==("undefined"==typeof WebSocket?"undefined":a(WebSocket)))}},{key:"_setFormat",value:function(e){if(!this._formatOverride(e)){if("protobuf"===e)throw new Error("not implemented by JSON only Centrifuge client – use client with Protobuf");this._binary=!1,this._methodType=i.JsonMethodType,this._pushType=i.JsonPushType,this._encoder=new i.JsonEncoder,this._decoder=new i.JsonDecoder}}},{key:"_formatOverride",value:function(e){return!1}},{key:"_configure",value:function(e){if(!("Promise"in n.g))throw new Error("Promise polyfill required");if((0,o.extend)(this._config,e||{}),this._debug("centrifuge config",this._config),!this._url)throw new Error("url required");if((0,o.startsWith)(this._url,"ws")&&this._url.indexOf("format=protobuf")>-1?this._setFormat("protobuf"):this._setFormat("json"),(0,o.startsWith)(this._url,"http"))if(this._debug("client will try to connect to SockJS endpoint"),null!==this._config.sockjs)this._debug("SockJS explicitly provided in options"),this._sockjs=this._config.sockjs;else{if(void 0===n.g.SockJS)throw new Error("SockJS not found, use ws:// in url or include SockJS");this._debug("use globally defined SockJS"),this._sockjs=n.g.SockJS}else this._debug("client will connect to websocket endpoint")}},{key:"_setStatus",value:function(e){this._status!==e&&(this._debug("Status",this._status,"->",e),this._status=e)}},{key:"_isDisconnected",value:function(){return"disconnected"===this._status}},{key:"_isConnecting",value:function(){return"connecting"===this._status}},{key:"_isConnected",value:function(){return"connected"===this._status}},{key:"_nextMessageId",value:function(){return++this._messageId}},{key:"_resetRetry",value:function(){this._debug("reset retries count to 0"),this._retries=0}},{key:"_getRetryInterval",value:function(){var e=(0,o.backoff)(this._retries,this._config.minRetry,this._config.maxRetry);return this._retries+=1,e}},{key:"_abortInflightXHRs",value:function(){for(var e in this._xhrs){try{this._xhrs[e].abort()}catch(e){this._debug("error aborting xhr",e)}delete this._xhrs[e]}}},{key:"_clearConnectedState",value:function(e){for(var t in this._clientID=null,this._stopPing(),this._callbacks)if(this._callbacks.hasOwnProperty(t)){var n=this._callbacks[t];clearTimeout(n.timeout);var s=n.errback;if(!s)continue;s({error:this._createErrorObject("disconnected")})}for(var r in this._callbacks={},this._subs)if(this._subs.hasOwnProperty(r)){var i=this._subs[r];e?(i._isSuccess()&&(i._triggerUnsubscribe(),i._recover=!0),i._shouldResubscribe()&&i._setSubscribing()):i._setUnsubscribed()}for(var o in this._abortInflightXHRs(),null!==this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),this._subRefreshTimeouts)this._subRefreshTimeouts.hasOwnProperty(o)&&this._subRefreshTimeouts[o]&&this._clearSubRefreshTimeout(o);this._subRefreshTimeouts={},this._reconnect||(this._subs={})}},{key:"_isTransportOpen",value:function(){return this._isSockjs?this._transport&&this._transport.transport&&this._transport.transport.readyState===this._transport.transport.OPEN:this._transport&&this._transport.readyState===this._transport.OPEN}},{key:"_transportSend",value:function(e){if(!e.length)return!0;if(!this._isTransportOpen()){for(var t in e){var n=t.id;if(n in this._callbacks){var s=this._callbacks[n];clearTimeout(this._callbacks[n].timeout),delete this._callbacks[n],(0,s.errback)({error:this._createErrorObject(d,0)})}}return!1}return this._transport.send(this._encoder.encodeCommands(e)),!0}},{key:"_setupTransport",value:function(){var e=this;if(this._isSockjs=!1,null!==this._sockjs){var t={transports:this._config.sockjsTransports};null!==this._config.sockjsServer&&(t.server=this._config.sockjsServer),this._isSockjs=!0,this._transport=new this._sockjs(this._url,null,t)}else{if(!this._websocketSupported())return void this._debug("No Websocket support and no SockJS configured, can not connect");null!==this._config.websocket?this._websocket=this._config.websocket:this._websocket=WebSocket,this._transport=new this._websocket(this._url),!0===this._binary&&(this._transport.binaryType="arraybuffer")}this._transport.onopen=function(){e._transportClosed=!1,e._isSockjs?(e._transportName="sockjs-"+e._transport.transport,e._transport.onheartbeat=function(){return e._restartPing()}):e._transportName="websocket";var t={};(e._token||e._connectData||e._config.name||e._config.version)&&(t.params={}),e._token&&(t.params.token=e._token),e._connectData&&(t.params.data=e._connectData),e._config.name&&(t.params.name=e._config.name),e._config.version&&(t.params.version=e._config.version);var n={},s=!1;for(var r in e._serverSubs)if(e._serverSubs.hasOwnProperty(r)&&e._serverSubs[r].recoverable){s=!0;var i={recover:!0};e._serverSubs[r].seq||e._serverSubs[r].gen?(e._serverSubs[r].seq&&(i.seq=e._serverSubs[r].seq),e._serverSubs[r].gen&&(i.gen=e._serverSubs[r].gen)):e._serverSubs[r].offset&&(i.offset=e._serverSubs[r].offset),e._serverSubs[r].epoch&&(i.epoch=e._serverSubs[r].epoch),n[r]=i}s&&(t.params||(t.params={}),t.params.subs=n),e._latencyStart=new Date,e._call(t).then((function(t){e._connectResponse(e._decoder.decodeCommandResult(e._methodType.CONNECT,t.result),s),t.next&&t.next()}),(function(t){109===t.error.code&&(e._refreshRequired=!0),e._disconnect("connect error",!0),t.next&&t.next()}))},this._transport.onerror=function(t){e._debug("transport level error",t)},this._transport.onclose=function(t){e._transportClosed=!0;var n=d,s=!0;if(t&&"reason"in t&&t.reason)try{var r=JSON.parse(t.reason);e._debug("reason is an advice object",r),n=r.reason,s=r.reconnect}catch(s){n=t.reason,e._debug("reason is a plain string",n)}if(null!==e._config.onTransportClose&&e._config.onTransportClose({event:t,reason:n,reconnect:s}),e._disconnect(n,s),!0===e._reconnect){e._reconnecting=!0;var i=e._getRetryInterval();e._debug("reconnect after "+i+" milliseconds"),setTimeout((function(){!0===e._reconnect&&(e._refreshRequired?e._refresh():e._connect())}),i)}},this._transport.onmessage=function(t){e._dataReceived(t.data)}}},{key:"rpc",value:function(e){return this._rpc("",e)}},{key:"namedRPC",value:function(e,t){return this._rpc(e,t)}},{key:"_rpc",value:function(e,t){var n={data:t};""!==e&&(n.method=e);var s={method:this._methodType.RPC,params:n};return this._methodCall(s,(function(e){return e}))}},{key:"send",value:function(e){var t={method:this._methodType.SEND,params:{data:e}};return this.isConnected()&&this._transportSend([t])?Promise.resolve({}):Promise.reject(this._createErrorObject(d,0))}},{key:"_getHistoryParams",value:function(e,t){var n={channel:e};return void 0!==t&&(t.since&&(n.use_since=!0,t.since.offset&&(n.offset=t.since.offset),t.since.epoch&&(n.epoch=t.since.epoch)),void 0!==t.limit&&(n.use_limit=!0,n.limit=t.limit)),n}},{key:"_methodCall",value:function(e,t){var n=this;return this.isConnected()?new Promise((function(s,r){n._call(e).then((function(r){s(t(n._decoder.decodeCommandResult(e.method,r.result))),r.next&&r.next()}),(function(e){r(e.error),e.next&&e.next()}))})):Promise.reject(this._createErrorObject(d,0))}},{key:"publish",value:function(e,t){var n={method:this._methodType.PUBLISH,params:{channel:e,data:t}};return this._methodCall(n,(function(){return{}}))}},{key:"history",value:function(e,t){var n=this._getHistoryParams(e,t),s={method:this._methodType.HISTORY,params:n};return this._methodCall(s,(function(e){return{publications:e.publications,epoch:e.epoch||"",offset:e.offset||0}}))}},{key:"presence",value:function(e){var t={method:this._methodType.PRESENCE,params:{channel:e}};return this._methodCall(t,(function(e){return{presence:e.presence}}))}},{key:"presenceStats",value:function(e){var t={method:this._methodType.PRESENCE_STATS,params:{channel:e}};return this._methodCall(t,(function(e){return{num_users:e.num_users,num_clients:e.num_clients}}))}},{key:"_dataReceived",value:function(e){var t=this,n=this._decoder.decodeReplies(e);this._dispatchPromise=this._dispatchPromise.then((function(){var e;t._dispatchPromise=new Promise((function(t){e=t})),t._dispatchSynchronized(n,e)})),this._restartPing()}},{key:"_dispatchSynchronized",value:function(e,t){var n=this,s=Promise.resolve(),r=function(t){e.hasOwnProperty(t)&&(s=s.then((function(){return n._dispatchReply(e[t])})))};for(var i in e)r(i);s=s.then((function(){t()}))}},{key:"_dispatchReply",value:function(e){var t,n=new Promise((function(e){t=e}));if(null==e)return this._debug("dispatch: got undefined or null reply"),t(),n;var s=e.id;return s&&s>0?this._handleReply(e,t):this._handlePush(e.result,t),n}},{key:"_call",value:function(e){var t=this;return new Promise((function(n,s){var r=t._addMessage(e);t._registerCall(r,n,s)}))}},{key:"_connect",value:function(){this.isConnected()?this._debug("connect called when already connected"):"connecting"!==this._status&&(this._debug("start connecting"),this._setStatus("connecting"),this._clientID=null,this._reconnect=!0,this._setupTransport())}},{key:"_disconnect",value:function(e,t){var n=t||!1;if(!1===n&&(this._reconnect=!1),this._isDisconnected())n||this._clearConnectedState(n);else{if(this._clearConnectedState(n),this._debug("disconnected:",e,t),this._setStatus("disconnected"),this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),!1===this._reconnecting){for(var s in this._serverSubs)this._serverSubs.hasOwnProperty(s)&&this.emit("unsubscribe",{channel:s});this.emit("disconnect",{reason:e,reconnect:n})}!1===n&&(this._subs={},this._serverSubs={}),this._transportClosed||this._transport.close()}}},{key:"_refreshFailed",value:function(){this._numRefreshFailed=0,this._isDisconnected()||this._disconnect("refresh failed",!1),null!==this._config.onRefreshFailed&&this._config.onRefreshFailed()}},{key:"_refresh",value:function(){var e=this;if(this._debug("refresh token"),0===this._config.refreshAttempts)return this._debug("refresh attempts set to 0, do not send refresh request at all"),void this._refreshFailed();null!==this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);var t=this._clientID,n=this._newXHRID(),s=function(s){if(n in e._xhrs&&delete e._xhrs[n],e._clientID===t)if(s.error||200!==s.status){if(s.error?e._debug("error refreshing connection token",s.error):e._debug("error refreshing connection token: wrong status code",s.status),e._numRefreshFailed++,null!==e._refreshTimeout&&(clearTimeout(e._refreshTimeout),e._refreshTimeout=null),null!==e._config.refreshAttempts&&e._numRefreshFailed>=e._config.refreshAttempts)return void e._refreshFailed();var r=Math.round(1e3*Math.random()*Math.max(e._numRefreshFailed,20)),i=e._config.refreshInterval+r;e._refreshTimeout=setTimeout((function(){return e._refresh()}),i)}else if(e._numRefreshFailed=0,e._token=s.data.token,e._token)if(e._isDisconnected()&&e._reconnect)e._debug("token refreshed, connect from scratch"),e._connect();else{e._debug("send refreshed token");var o={method:e._methodType.REFRESH,params:{token:e._token}};e._call(o).then((function(t){e._refreshResponse(e._decoder.decodeCommandResult(e._methodType.REFRESH,t.result)),t.next&&t.next()}),(function(t){e._refreshError(t.error),t.next&&t.next()}))}else e._refreshFailed()};if(null!==this._config.onRefresh)this._config.onRefresh({},s);else{var r=this._ajax(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,s);this._xhrs[n]=r}}},{key:"_refreshError",value:function(e){var t=this;this._debug("refresh error",e),this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);var n=this._config.refreshInterval+Math.round(1e3*Math.random());this._refreshTimeout=setTimeout((function(){return t._refresh()}),n)}},{key:"_refreshResponse",value:function(e){var t=this;this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),e.expires&&(this._clientID=e.client,this._refreshTimeout=setTimeout((function(){return t._refresh()}),this._getTTLMilliseconds(e.ttl)))}},{key:"_newXHRID",value:function(){return this._xhrID++,this._xhrID}},{key:"_subRefresh",value:function(e){var t=this;if(this._debug("refresh subscription token for channel",e),void 0!==this._subRefreshTimeouts[e]){this._clearSubRefreshTimeout(e);var n=this._clientID,s=this._newXHRID(),r=function(r){if(s in t._xhrs&&delete t._xhrs[s],!r.error&&200===r.status&&t._clientID===n){var i={};if(r.data.channels)for(var o in r.data.channels){var u=r.data.channels[o];u.channel&&(i[u.channel]=u.token)}var a=i[e];if(a){var c={method:t._methodType.SUB_REFRESH,params:{channel:e,token:a}};null!==t._getSub(e)&&t._call(c).then((function(n){t._subRefreshResponse(e,t._decoder.decodeCommandResult(t._methodType.SUB_REFRESH,n.result)),n.next&&n.next()}),(function(n){t._subRefreshError(e,n.error),n.next&&n.next()}))}}},i={client:this._clientID,channels:[e]};if(null!==this._config.onPrivateSubscribe)this._config.onPrivateSubscribe({data:i},r);else{var o=this._ajax(this._config.subscribeEndpoint,this._config.subscribeParams,this._config.subscribeHeaders,i,r);this._xhrs[s]=o}}}},{key:"_clearSubRefreshTimeout",value:function(e){void 0!==this._subRefreshTimeouts[e]&&(clearTimeout(this._subRefreshTimeouts[e]),delete this._subRefreshTimeouts[e])}},{key:"_subRefreshError",value:function(e,t){var n=this;if(this._debug("subscription refresh error",e,t),this._clearSubRefreshTimeout(e),null!==this._getSub(e)){var s=Math.round(1e3*Math.random()),r=setTimeout((function(){return n._subRefresh(e)}),this._config.subRefreshInterval+s);this._subRefreshTimeouts[e]=r}}},{key:"_subRefreshResponse",value:function(e,t){var n=this;if(this._debug("subscription refresh success",e),this._clearSubRefreshTimeout(e),null!==this._getSub(e)&&!0===t.expires){var s=setTimeout((function(){return n._subRefresh(e)}),this._getTTLMilliseconds(t.ttl));this._subRefreshTimeouts[e]=s}}},{key:"_subscribe",value:function(e,t){var n=this;this._debug("subscribing on",e.channel);var s=e.channel;if(s in this._subs||(this._subs[s]=e),this.isConnected()){e._setSubscribing(t);var r={method:this._methodType.SUBSCRIBE,params:{channel:s}};if((0,o.startsWith)(s,this._config.privateChannelPrefix))this._isSubscribeBatching?this._privateChannels[s]=!0:(this.startSubscribeBatching(),this._subscribe(e),this.stopSubscribeBatching());else{var i=e._needRecover();if(!0===i){r.params.recover=!0;var u=this._getLastSeq(s),a=this._getLastGen(s);if(u||a)u&&(r.params.seq=u),a&&(r.params.gen=a);else{var c=this._getLastOffset(s);c&&(r.params.offset=c)}var h=this._getLastEpoch(s);h&&(r.params.epoch=h)}this._call(r).then((function(e){n._subscribeResponse(s,i,n._decoder.decodeCommandResult(n._methodType.SUBSCRIBE,e.result)),e.next&&e.next()}),(function(e){n._subscribeError(s,e.error),e.next&&e.next()}))}}else e._setNew()}},{key:"_unsubscribe",value:function(e){delete this._subs[e.channel],delete this._lastOffset[e.channel],delete this._lastSeq[e.channel],delete this._lastGen[e.channel],this.isConnected()&&this._addMessage({method:this._methodType.UNSUBSCRIBE,params:{channel:e.channel}})}},{key:"_getTTLMilliseconds",value:function(e){return Math.min(1e3*e,2147483647)}},{key:"getSub",value:function(e){return this._getSub(e)}},{key:"_getSub",value:function(e){return this._subs[e]||null}},{key:"_isServerSub",value:function(e){return void 0!==this._serverSubs[e]}},{key:"_connectResponse",value:function(e,t){var n=this,s=this._reconnecting;if(this._reconnecting=!1,this._resetRetry(),this._refreshRequired=!1,!this.isConnected()){for(var r in null!==this._latencyStart&&(this._latency=(new Date).getTime()-this._latencyStart.getTime(),this._latencyStart=null),this._clientID=e.client,this._setStatus("connected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout),e.expires&&(this._refreshTimeout=setTimeout((function(){return n._refresh()}),this._getTTLMilliseconds(e.ttl))),this.startBatching(),this.startSubscribeBatching(),this._subs)if(this._subs.hasOwnProperty(r)){var i=this._subs[r];i._shouldResubscribe()&&this._subscribe(i,s)}this.stopSubscribeBatching(),this.stopBatching(),this._startPing();var o={client:e.client,transport:this._transportName,latency:this._latency};e.data&&(o.data=e.data),this.emit("connect",o),e.subs&&this._processServerSubs(e.subs)}}},{key:"_processServerSubs",value:function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t],s={channel:t,isResubscribe:void 0!==this._serverSubs[t]};s=this._expandSubscribeContext(s,n),this.emit("subscribe",s)}for(var r in e)if(e.hasOwnProperty(r)){var i=e[r];if(i.recovered){var o=i.publications;if(o&&o.length>0)for(var u in o.length>1&&(!o[0].offset||o[0].offset>o[1].offset)&&(o=o.reverse()),o)o.hasOwnProperty(u)&&this._handlePublication(r,o[u])}this._serverSubs[r]={seq:i.seq,gen:i.gen,offset:i.offset,epoch:i.epoch,recoverable:i.recoverable}}}},{key:"_stopPing",value:function(){null!==this._pongTimeout&&(clearTimeout(this._pongTimeout),this._pongTimeout=null),null!==this._pingTimeout&&(clearTimeout(this._pingTimeout),this._pingTimeout=null)}},{key:"_startPing",value:function(){var e=this;!0!==this._config.ping||this._config.pingInterval<=0||this.isConnected()&&(this._pingTimeout=setTimeout((function(){e.isConnected()?(e.ping(),e._pongTimeout=setTimeout((function(){e._disconnect("no ping",!0)}),e._config.pongWaitTimeout)):e._stopPing()}),this._config.pingInterval))}},{key:"_restartPing",value:function(){this._stopPing(),this._startPing()}},{key:"_subscribeError",value:function(e,t){var n=this._getSub(e);n&&n._isSubscribing()&&(0!==t.code||t.message!==_?n._setSubscribeError(t):this._disconnect("timeout",!0))}},{key:"_expandSubscribeContext",value:function(e,t){var n=!1;"recovered"in t&&(n=t.recovered),e.recovered=n;var s=!1;"positioned"in t&&(s=t.positioned);var r="";"epoch"in t&&(r=t.epoch);var i=0;return"offset"in t&&(i=t.offset),s&&(e.streamPosition={offset:i,epoch:r}),t.data&&(e.data=t.data),e}},{key:"_subscribeResponse",value:function(e,t,n){var s=this,r=this._getSub(e);if(r&&r._isSubscribing()){r._setSubscribeSuccess(n);var i=n.publications;if(i&&i.length>0)for(var o in i.length>=2&&!i[0].offset&&!i[1].offset&&(i=i.reverse()),i)i.hasOwnProperty(o)&&this._handlePublication(e,i[o]);if(!n.recoverable||t&&n.recovered||(this._lastSeq[e]=n.seq||0,this._lastGen[e]=n.gen||0,this._lastOffset[e]=n.offset||0),this._lastEpoch[e]=n.epoch||"",n.recoverable&&(r._recoverable=!0),!0===n.expires){var u=setTimeout((function(){return s._subRefresh(e)}),this._getTTLMilliseconds(n.ttl));this._subRefreshTimeouts[e]=u}}}},{key:"_handleReply",value:function(e,t){var n=e.id,s=e.result;if(n in this._callbacks){var r=this._callbacks[n];if(clearTimeout(this._callbacks[n].timeout),delete this._callbacks[n],(0,o.errorExists)(e)){var i=r.errback;if(!i)return void t();i({error:e.error,next:t})}else{var u=r.callback;if(!u)return;u({result:s,next:t})}}else t()}},{key:"_handleJoin",value:function(e,t){var n={info:t.info},s=this._getSub(e);s?s.emit("join",n):this._isServerSub(e)&&(n.channel=e,this.emit("join",n))}},{key:"_handleLeave",value:function(e,t){var n={info:t.info},s=this._getSub(e);s?s.emit("leave",n):this._isServerSub(e)&&(n.channel=e,this.emit("leave",n))}},{key:"_handleUnsub",value:function(e,t){var n={},s=this._getSub(e);s?(s.unsubscribe(),!0===t.resubscribe&&s.subscribe()):this._isServerSub(e)&&(delete this._serverSubs[e],n.channel=e,this.emit("unsubscribe",n))}},{key:"_handleSub",value:function(e,t){this._serverSubs[e]={seq:t.seq,gen:t.gen,offset:t.offset,epoch:t.epoch,recoverable:t.recoverable};var n={channel:e,isResubscribe:!1};n=this._expandSubscribeContext(n,t),this.emit("subscribe",n)}},{key:"_handlePublication",value:function(e,t){var n=this._getSub(e),s={data:t.data,seq:t.seq,gen:t.gen,offset:t.offset};t.info&&(s.info=t.info),n?(void 0!==t.seq&&(this._lastSeq[e]=t.seq),void 0!==t.gen&&(this._lastGen[e]=t.gen),void 0!==t.offset&&(this._lastOffset[e]=t.offset),n.emit("publish",s)):this._isServerSub(e)&&(void 0!==t.seq&&(this._serverSubs[e].seq=t.seq),void 0!==t.gen&&(this._serverSubs[e].gen=t.gen),void 0!==t.offset&&(this._serverSubs[e].offset=t.offset),s.channel=e,this.emit("publish",s))}},{key:"_handleMessage",value:function(e){this.emit("message",e.data)}},{key:"_handlePush",value:function(e,t){var n=this._decoder.decodePush(e),s=0;"type"in n&&(s=n.type);var r=n.channel;if(s===this._pushType.PUBLICATION){var i=this._decoder.decodePushData(this._pushType.PUBLICATION,n.data);this._handlePublication(r,i)}else if(s===this._pushType.MESSAGE){var o=this._decoder.decodePushData(this._pushType.MESSAGE,n.data);this._handleMessage(o)}else if(s===this._pushType.JOIN){var u=this._decoder.decodePushData(this._pushType.JOIN,n.data);this._handleJoin(r,u)}else if(s===this._pushType.LEAVE){var a=this._decoder.decodePushData(this._pushType.LEAVE,n.data);this._handleLeave(r,a)}else if(s===this._pushType.UNSUB){var c=this._decoder.decodePushData(this._pushType.UNSUB,n.data);this._handleUnsub(r,c)}else if(s===this._pushType.SUB){var h=this._decoder.decodePushData(this._pushType.SUB,n.data);this._handleSub(r,h)}t()}},{key:"_flush",value:function(){var e=this._messages.slice(0);this._messages=[],this._transportSend(e)}},{key:"_ping",value:function(){var e=this,t={method:this._methodType.PING};this._call(t).then((function(t){e._pingResponse(e._decoder.decodeCommandResult(e._methodType.PING,t.result)),t.next&&t.next()}),(function(t){e._debug("ping error",t.error),t.next&&t.next()}))}},{key:"_pingResponse",value:function(e){this.isConnected()&&(this._stopPing(),this._startPing())}},{key:"_getLastSeq",value:function(e){return this._lastSeq[e]||0}},{key:"_getLastOffset",value:function(e){return this._lastOffset[e]||0}},{key:"_getLastGen",value:function(e){return this._lastGen[e]||0}},{key:"_getLastEpoch",value:function(e){return this._lastEpoch[e]||""}},{key:"_createErrorObject",value:function(e,t){return{message:e,code:t||0}}},{key:"_registerCall",value:function(e,t,n){var s=this;this._callbacks[e]={callback:t,errback:n,timeout:null},this._callbacks[e].timeout=setTimeout((function(){delete s._callbacks[e],(0,o.isFunction)(n)&&n({error:s._createErrorObject(_)})}),this._config.timeout)}},{key:"_addMessage",value:function(e){var t=this._nextMessageId();return e.id=t,!0===this._isBatching?this._messages.push(e):this._transportSend([e]),t}},{key:"isConnected",value:function(){return this._isConnected()}},{key:"connect",value:function(){this._connect()}},{key:"disconnect",value:function(){this._disconnect("client",!1)}},{key:"ping",value:function(){return this._ping()}},{key:"startBatching",value:function(){this._isBatching=!0}},{key:"stopBatching",value:function(){this._isBatching=!1,this._flush()}},{key:"startSubscribeBatching",value:function(){this._isSubscribeBatching=!0}},{key:"stopSubscribeBatching",value:function(){var e=this;this._isSubscribeBatching=!1;var t=this._privateChannels;this._privateChannels={};var n=[];for(var s in t)if(t.hasOwnProperty(s)){if(!this._getSub(s))continue;n.push(s)}if(0!==n.length){var r={client:this._clientID,channels:n},i=this._clientID,o=this._newXHRID(),u=function(t){if(o in e._xhrs&&delete e._xhrs[o],e._clientID===i)if(t.error||200!==t.status){for(var s in e._debug("authorization request failed"),n)if(n.hasOwnProperty(s)){var r=n[s];e._subscribeError(r,e._createErrorObject("authorization request failed"))}}else{var u={};if(t.data.channels)for(var a in t.data.channels){var c=t.data.channels[a];c.channel&&(u[c.channel]=c.token)}var h=!1;for(var l in e._isBatching||(e.startBatching(),h=!0),n)!n.hasOwnProperty(l)||function(){var t=n[l],s=u[t];if(!s)return e._subscribeError(t,e._createErrorObject("permission denied",103)),"continue";var r={method:e._methodType.SUBSCRIBE,params:{channel:t,token:s}},i=e._getSub(t);if(null===i)return"continue";var o=i._needRecover();if(!0===o){r.params.recover=!0;var a=e._getLastSeq(t),c=e._getLastGen(t);if(a||c)a&&(r.params.seq=a),c&&(r.params.gen=c);else{var h=e._getLastOffset(t);h&&(r.params.offset=h)}var f=e._getLastEpoch(t);f&&(r.params.epoch=f)}e._call(r).then((function(n){e._subscribeResponse(t,o,e._decoder.decodeCommandResult(e._methodType.SUBSCRIBE,n.result)),n.next&&n.next()}),(function(n){e._subscribeError(t,n.error),n.next&&n.next()}))}();h&&e.stopBatching()}};if(null!==this._config.onPrivateSubscribe)this._config.onPrivateSubscribe({data:r},u);else{var a=this._ajax(this._config.subscribeEndpoint,this._config.subscribeParams,this._config.subscribeHeaders,r,u);this._xhrs[o]=a}}else this._debug("no private channels found, no need to make request")}},{key:"subscribe",value:function(e,t){var n=this._getSub(e);if(null!==n)return n._setEvents(t),n._isUnsubscribed()&&n.subscribe(),n;var s=new r.default(this,e,t);return this._subs[e]=s,s.subscribe(),s}}])&&c(t.prototype,s),b}(s.default);t.Centrifuge=v},579:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=n(382).Centrifuge;t.default=s,e.exports=t.default},147:function(e,t){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function r(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}Object.defineProperty(t,"__esModule",{value:!0}),t.JsonDecoder=t.JsonEncoder=t.JsonPushType=t.JsonMethodType=void 0,t.JsonMethodType={CONNECT:0,SUBSCRIBE:1,UNSUBSCRIBE:2,PUBLISH:3,PRESENCE:4,PRESENCE_STATS:5,HISTORY:6,PING:7,SEND:8,RPC:9,REFRESH:10,SUB_REFRESH:11},t.JsonPushType={PUBLICATION:0,JOIN:1,LEAVE:2,UNSUB:3,MESSAGE:4,SUB:5};var i=function(){function e(){n(this,e)}return r(e,[{key:"encodeCommands",value:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(JSON.stringify(e[n]));return t.join("\n")}}]),e}();t.JsonEncoder=i;var o=function(){function e(){n(this,e)}return r(e,[{key:"decodeReplies",value:function(e){var t=[],n=e.split("\n");for(var s in n)if(n.hasOwnProperty(s)){if(!n[s])continue;var r=JSON.parse(n[s]);t.push(r)}return t}},{key:"decodeCommandResult",value:function(e,t){return t}},{key:"decodePush",value:function(e){return e}},{key:"decodePushData",value:function(e,t){return t}}]),e}();t.JsonDecoder=o},471:function(e,t,n){function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,i=(r=n(187))&&r.__esModule?r:{default:r},o=n(853);function u(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(l,e);var t,n,s,r,i=(s=l,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=h(s);if(r){var n=h(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return c(this,e)});function l(e,t,n){var s;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(s=i.call(this)).channel=t,s._centrifuge=e,s._status=0,s._error=null,s._isResubscribe=!1,s._ready=!1,s._subscriptionPromise=null,s._noResubscribe=!1,s._recoverable=!1,s._recover=!1,s._setEvents(n),s._initializePromise(),s._promises={},s._promiseId=0,s.on("error",(function(e){this._centrifuge._debug("subscription error",e)})),s}return t=l,(n=[{key:"_nextPromiseId",value:function(){return++this._promiseId}},{key:"_initializePromise",value:function(){var e=this;this._ready=!1,this._subscriptionPromise=new Promise((function(t,n){e._resolve=function(n){e._ready=!0,t(n)},e._reject=function(t){e._ready=!0,n(t)}})).then((function(){}),(function(){}))}},{key:"_needRecover",value:function(){return!0===this._recoverable&&!0===this._recover}},{key:"_setEvents",value:function(e){if(e)if((0,o.isFunction)(e))this.on("publish",e);else if(Object.prototype.toString.call(e)===Object.prototype.toString.call({}))for(var t=["publish","join","leave","unsubscribe","subscribe","error"],n=0,s=t.length;n<s;n++){var r=t[n];r in e&&this.on(r,e[r])}}},{key:"_isNew",value:function(){return 0===this._status}},{key:"_isUnsubscribed",value:function(){return 4===this._status}},{key:"_isSubscribing",value:function(){return 1===this._status}},{key:"_isReady",value:function(){return 2===this._status||3===this._status}},{key:"_isSuccess",value:function(){return 2===this._status}},{key:"_isError",value:function(){return 3===this._status}},{key:"_setNew",value:function(){this._status=0}},{key:"_setSubscribing",value:function(e){this._isResubscribe=e||!1,!0===this._ready&&this._initializePromise(),this._status=1}},{key:"_setSubscribeSuccess",value:function(e){if(2!==this._status){this._status=2;var t=this._getSubscribeSuccessContext(e);for(var n in this._recover=!1,this.emit("subscribe",t),this._resolve(t),this._promises)clearTimeout(this._promises[n].timeout),this._promises[n].resolve(),delete this._promises[n]}}},{key:"_setSubscribeError",value:function(e){if(3!==this._status){this._status=3,this._error=e;var t=this._getSubscribeErrorContext();for(var n in this.emit("error",t),this._reject(t),this._promises)clearTimeout(this._promises[n].timeout),this._promises[n].reject(e),delete this._promises[n]}}},{key:"_triggerUnsubscribe",value:function(){this.emit("unsubscribe",{channel:this.channel})}},{key:"_setUnsubscribed",value:function(e){if(this._centrifuge._clearSubRefreshTimeout(this.channel),4!==this._status){var t=2===this._status;this._status=4,!0===e&&(this._recover=!1,this._noResubscribe=!0,delete this._centrifuge._lastSeq[this.channel],delete this._centrifuge._lastGen[this.channel],delete this._centrifuge._lastEpoch[this.channel]),t&&this._triggerUnsubscribe()}}},{key:"_shouldResubscribe",value:function(){return!this._noResubscribe}},{key:"_getSubscribeSuccessContext",value:function(e){var t={channel:this.channel,isResubscribe:this._isResubscribe};return e&&(t=this._centrifuge._expandSubscribeContext(t,e)),t}},{key:"_getSubscribeErrorContext",value:function(){var e=this._error;return e.channel=this.channel,e.isResubscribe=this._isResubscribe,e}},{key:"ready",value:function(e,t){this._ready&&(this._isSuccess()?e(this._getSubscribeSuccessContext()):t(this._getSubscribeErrorContext()))}},{key:"subscribe",value:function(){2!==this._status&&(this._noResubscribe=!1,this._centrifuge._subscribe(this))}},{key:"unsubscribe",value:function(){this._setUnsubscribed(!0),this._centrifuge._unsubscribe(this)}},{key:"_methodCall",value:function(){var e=this;return this._isSuccess()?Promise.resolve():this._isError()?Promise.reject(this._error):new Promise((function(t,n){var s=setTimeout((function(){n({code:0,message:"timeout"})}),e._centrifuge._config.timeout);e._promises[e._nextPromiseId()]={timeout:s,resolve:t,reject:n}}))}},{key:"publish",value:function(e){var t=this;return this._methodCall().then((function(){return t._centrifuge.publish(t.channel,e)}))}},{key:"presence",value:function(){var e=this;return this._methodCall().then((function(){return e._centrifuge.presence(e.channel)}))}},{key:"presenceStats",value:function(){var e=this;return this._methodCall().then((function(){return e._centrifuge.presenceStats(e.channel)}))}},{key:"history",value:function(e){var t=this;return this._methodCall().then((function(){return t._centrifuge.history(t.channel,e)}))}}])&&u(t.prototype,n),l}(i.default);t.default=l,e.exports=t.default},853:function(e,t,n){function s(e){return null!=e&&"function"==typeof e}Object.defineProperty(t,"__esModule",{value:!0}),t.startsWith=function(e,t){return 0===e.lastIndexOf(t,0)},t.isFunction=s,t.log=function(e,t){if(n.g.console){var r=n.g.console[e];s(r)&&r.apply(n.g.console,t)}},t.backoff=function(e,t,n){var s=.5*Math.random(),r=Math.min(n,t*Math.pow(2,e+1));return Math.floor((1-s)*r)},t.errorExists=function(e){return"error"in e&&null!==e.error},t.extend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}},187:function(e){var t,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(n,s){function r(){void 0!==i&&e.removeListener("error",i),n([].slice.call(arguments))}var i;"error"!==t&&(i=function(n){e.removeListener(t,r),s(n)},e.once("error",i)),e.once(t,r)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,n,s){var r,i,o,c;if(u(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),o=i[t]),void 0===o)o=i[t]=n,++e._eventsCount;else if("function"==typeof o?o=i[t]=s?[n,o]:[o,n]:s?o.unshift(n):o.push(n),(r=a(e))>0&&o.length>r&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,c=h,console&&console.warn&&console.warn(c)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=h.bind(s);return r.listener=n,s.wrapFn=r,r}function f(e,t,n){var s=e._events;if(void 0===s)return[];var r=s[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):d(r,r.length)}function _(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return a(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw u.context=o,u}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)s(a,this,t);else{var c=a.length,h=d(a,c);for(n=0;n<c;++n)s(h[n],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return u(t),this.on(e,l(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,l(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,s,r,i,o;if(u(t),void 0===(s=this._events))return this;if(void 0===(n=s[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){o=n[i].listener,r=i;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(s[e]=n[0]),void 0!==s.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,s;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,i=Object.keys(n);for(s=0;s<i.length;++s)"removeListener"!==(r=i[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},i.prototype.listeners=function(e){return f(this,e,!0)},i.prototype.rawListeners=function(e){return f(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):_.call(e,t)},i.prototype.listenerCount=_,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}},t={};function n(s){if(t[s])return t[s].exports;var r=t[s]={exports:{}};return e[s](r,r.exports,n),r.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(579)}()}));
//# sourceMappingURL=centrifuge.min.js.map
{
"name": "centrifuge",
"version": "2.7.2",
"version": "2.7.3",
"description": "Centrifuge and Centrifugo client for NodeJS and browser",

@@ -5,0 +5,0 @@ "main": "dist/centrifuge.js",

@@ -1372,2 +1372,5 @@ import EventEmitter from 'events';

};
if (result.data) {
ctx.data = result.data;
}
return ctx;

@@ -1374,0 +1377,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc