{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///centrifuge.min.js","webpack:///webpack/bootstrap f2313d0e76ba939a5a5f","webpack:///./src/centrifuge.js","webpack:///./src/subscription.js","webpack:///./src/json.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/index.js","webpack:///./node_modules/events/events.js","webpack:///./src/utils.js"],"names":["root","factory","exports","module","define","amd","self","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","10","global","_interopRequireDefault","obj","default","_classCallCheck","instance","Constructor","TypeError","_possibleConstructorReturn","ReferenceError","_inherits","subClass","superClass","create","constructor","value","writable","setPrototypeOf","__proto__","Centrifuge","undefined","_typeof","Symbol","iterator","_createClass","defineProperties","target","props","length","descriptor","key","protoProps","staticProps","_events","_events2","_subscription","_subscription2","_json","_utils","_EventEmitter","url","options","_this","getPrototypeOf","_url","_websocket","_sockjs","_isSockjs","_binary","_methodType","_pushType","_encoder","_decoder","_status","_reconnect","_reconnecting","_transport","_transportName","_transportClosed","_messageId","_clientID","_refreshRequired","_subs","_serverSubs","_lastSeq","_lastGen","_lastEpoch","_messages","_isBatching","_isSubscribeBatching","_privateChannels","_numRefreshFailed","_refreshTimeout","_pingTimeout","_pongTimeout","_subRefreshTimeouts","_retries","_callbacks","_latency","_latencyStart","_connectData","_token","_xhrID","_xhrs","_config","debug","websocket","sockjs","promise","minRetry","maxRetry","timeout","ping","pingInterval","pongWaitTimeout","privateChannelPrefix","onTransportClose","sockjsServer","sockjsTransports","refreshEndpoint","refreshHeaders","refreshParams","refreshData","refreshAttempts","refreshInterval","onRefreshFailed","onRefresh","subscribeEndpoint","subscribeHeaders","subscribeParams","subRefreshInterval","onPrivateSubscribe","_configure","token","data","headers","params","callback","_this2","query","_debug","JSON","stringify","xhr","XMLHttpRequest","ActiveXObject","encodeURIComponent","open","withCredentials","setRequestHeader","headerName","onreadystatechange","readyState","status","parsed","parse","responseText","e","error","_log","setTimeout","send","log","arguments","WebSocket","format","_formatOverride","Error","JsonMethodType","JsonPushType","JsonEncoder","JsonDecoder","configuration","extend","startsWith","indexOf","_setFormat","SockJS","newStatus","interval","backoff","xhrID","abort","reconnect","_stopPing","id","callbacks","clearTimeout","errback","_createErrorObject","channel","sub","_isSuccess","_triggerUnsubscribe","_recover","_shouldResubscribe","_setSubscribing","_setUnsubscribed","_abortInflightXHRs","_clearSubRefreshTimeout","transport","OPEN","commands","_isTransportOpen","command","encodeCommands","_this3","sockjsOptions","transports","server","_websocketSupported","binaryType","onopen","onheartbeat","_restartPing","msg","subs","hasSubs","recoverable","recover","seq","gen","epoch","Date","_call","then","resolveCtx","_connectResponse","decodeCommandResult","CONNECT","result","next","rejectCtx","code","_disconnect","onerror","onclose","closeEvent","reason","needReconnect","advice","event","_getRetryInterval","_refresh","_connect","onmessage","_dataReceived","_this4","method","RPC","isConnected","Promise","reject","SEND","_transportSend","resolve","PUBLISH","_this5","replies","decodeReplies","_dispatchReply","_this6","_addMessage","_registerCall","_setStatus","_setupTransport","shouldReconnect","_isDisconnected","_clearConnectedState","emit","close","_this7","_refreshFailed","clientID","_newXHRID","cb","resp","jitter","Math","round","random","max","REFRESH","_refreshResponse","_refreshError","context","_ajax","err","_this8","_this9","expires","client","_getTTLMilliseconds","ttl","_this10","channelsData","channels","channelData","SUB_REFRESH","_getSub","_subRefreshResponse","_subRefreshError","_this11","subRefreshTimeout","_subRefresh","_this12","isResubscribe","_this13","_setNew","SUBSCRIBE","startSubscribeBatching","_subscribe","stopSubscribeBatching","_needRecover","_getLastSeq","_getLastGen","_getLastEpoch","_subscribeResponse","_subscribeError","UNSUBSCRIBE","min","isRecover","_this14","wasReconnecting","_resetRetry","getTime","startBatching","stopBatching","_startPing","ctx","latency","_processServerSubs","recovered","subCtx","pubs","publications","reverse","_handlePublication","_this15","_isSubscribing","message","_setSubscribeError","_this16","_setSubscribeSuccess","_recoverable","reply","errorExists","join","info","leave","unsub","unsubscribe","resubscribe","subscribe","pub","push","decodePush","type","PUBLICATION","decodePushData","MESSAGE","_handleMessage","JOIN","_handleJoin","LEAVE","_handleLeave","UNSUB","_handleUnsub","SUB","_handleSub","_handleReply","_handlePush","messages","slice","_this17","PING","_pingResponse","lastSeq","lastGen","lastEpoch","_this18","isFunction","_nextMessageId","_isConnected","_ping","_flush","_this19","authChannels","batch","_ret2","events","currentSub","_setEvents","_isUnsubscribed","Subscription","EventEmitter","11","_STATE_NEW","centrifuge","_centrifuge","_error","_isResubscribe","_ready","_subscriptionPromise","_noResubscribe","_initializePromise","_promises","_promiseId","on","errContext","_resolve","_reject","toString","knownEvents","ev","successContext","_getSubscribeSuccessContext","_getSubscribeErrorContext","noResubscribe","needTrigger","subscribeErrorContext","_unsubscribe","subPromise","_isError","res","rej","_nextPromiseId","_methodCall","PRESENCE","PRESENCE_STATS","HISTORY","12","encodedCommands","encodedReplies","split","methodType","pushType","3","g","Function","eval","window","31","6","ProcessEmitWarning","warning","console","warn","init","$getMaxListeners","that","_maxListeners","defaultMaxListeners","_addListener","listener","prepend","existing","_eventsCount","newListener","unshift","warned","w","String","emitter","count","onceWrapper","args","fired","removeListener","wrapFn","ReflectApply","_onceWrap","state","wrapped","bind","_listeners","unwrap","evlistener","unwrapListeners","arrayClone","listenerCount","arr","copy","Array","spliceOne","list","index","pop","ret","ReflectOwnKeys","R","Reflect","apply","receiver","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","set","arg","RangeError","setMaxListeners","getMaxListeners","doError","er","handler","len","listeners","addListener","prependListener","once","prependOnceListener","position","originalListener","shift","off","removeAllListeners","keys","rawListeners","eventNames","7","prefix","lastIndexOf","level","logger","step","pow","floor","a","b"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,OAAA,gBAAAH,GACA,gBAAAC,SACAA,QAAA,WAAA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ifuge.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Centrifuge\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Centrifuge\"] = factory();\n\telse\n\t\troot[\"Centrifuge\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Centrifuge\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Centrifuge\"] = factory();\n\telse\n\t\troot[\"Centrifuge\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 31);\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ 10:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n/* WEBPACK VAR INJECTION */(function(global) {\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Centrifuge = undefined;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _events = __webpack_require__(6);\n\nvar _events2 = _interopRequireDefault(_events);\n\nvar _subscription = __webpack_require__(11);\n\nvar _subscription2 = _interopRequireDefault(_subscription);\n\nvar _json = __webpack_require__(12);\n\nvar _utils = __webpack_require__(7);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar _errorTimeout = 'timeout';\nvar _errorConnectionClosed = 'connection closed';\n\nvar Centrifuge = exports.Centrifuge = function (_EventEmitter) {\n _inherits(Centrifuge, _EventEmitter);\n\n function Centrifuge(url, options) {\n _classCallCheck(this, Centrifuge);\n\n var _this = _possibleConstructorReturn(this, (Centrifuge.__proto__ || Object.getPrototypeOf(Centrifuge)).call(this));\n\n _this._url = url;\n _this._websocket = null;\n _this._sockjs = null;\n _this._isSockjs = false;\n _this._binary = false;\n _this._methodType = null;\n _this._pushType = null;\n _this._encoder = null;\n _this._decoder = null;\n _this._status = 'disconnected';\n _this._reconnect = true;\n _this._reconnecting = false;\n _this._transport = null;\n _this._transportName = null;\n _this._transportClosed = true;\n _this._messageId = 0;\n _this._clientID = null;\n _this._refreshRequired = false;\n _this._subs = {};\n _this._serverSubs = {};\n _this._lastSeq = {};\n _this._lastGen = {};\n _this._lastEpoch = {};\n _this._messages = [];\n _this._isBatching = false;\n _this._isSubscribeBatching = false;\n _this._privateChannels = {};\n _this._numRefreshFailed = 0;\n _this._refreshTimeout = null;\n _this._pingTimeout = null;\n _this._pongTimeout = null;\n _this._subRefreshTimeouts = {};\n _this._retries = 0;\n _this._callbacks = {};\n _this._latency = null;\n _this._latencyStart = null;\n _this._connectData = null;\n _this._token = null;\n _this._xhrID = 0;\n _this._xhrs = {};\n _this._config = {\n debug: false,\n websocket: null,\n sockjs: null,\n promise: null,\n minRetry: 1000,\n maxRetry: 20000,\n timeout: 5000,\n ping: true,\n pingInterval: 25000,\n pongWaitTimeout: 5000,\n privateChannelPrefix: '$',\n onTransportClose: null,\n sockjsServer: null,\n sockjsTransports: ['websocket', 'xdr-streaming', 'xhr-streaming', 'eventsource', 'iframe-eventsource', 'iframe-htmlfile', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'],\n refreshEndpoint: '/centrifuge/refresh',\n refreshHeaders: {},\n refreshParams: {},\n refreshData: {},\n refreshAttempts: null,\n refreshInterval: 1000,\n onRefreshFailed: null,\n onRefresh: null,\n subscribeEndpoint: '/centrifuge/subscribe',\n subscribeHeaders: {},\n subscribeParams: {},\n subRefreshInterval: 1000,\n onPrivateSubscribe: null\n };\n _this._configure(options);\n return _this;\n }\n\n _createClass(Centrifuge, [{\n key: 'setToken',\n value: function setToken(token) {\n this._token = token;\n }\n }, {\n key: 'setConnectData',\n value: function setConnectData(data) {\n this._connectData = data;\n }\n }, {\n key: 'setRefreshHeaders',\n value: function setRefreshHeaders(headers) {\n this._config.refreshHeaders = headers;\n }\n }, {\n key: 'setRefreshParams',\n value: function setRefreshParams(params) {\n this._config.refreshParams = params;\n }\n }, {\n key: 'setRefreshData',\n value: function setRefreshData(data) {\n this._config.refreshData = data;\n }\n }, {\n key: 'setSubscribeHeaders',\n value: function setSubscribeHeaders(headers) {\n this._config.subscribeHeaders = headers;\n }\n }, {\n key: 'setSubscribeParams',\n value: function setSubscribeParams(params) {\n this._config.subscribeParams = params;\n }\n }, {\n key: '_ajax',\n value: function _ajax(url, params, headers, data, callback) {\n var _this2 = this;\n\n var query = '';\n this._debug('sending AJAX request to', url, 'with data', JSON.stringify(data));\n\n var xhr = global.XMLHttpRequest ? new global.XMLHttpRequest() : new global.ActiveXObject('Microsoft.XMLHTTP');\n\n for (var i in params) {\n if (params.hasOwnProperty(i)) {\n if (query.length > 0) {\n query += '&';\n }\n query += encodeURIComponent(i) + '=' + encodeURIComponent(params[i]);\n }\n }\n if (query.length > 0) {\n query = '?' + query;\n }\n xhr.open('POST', url + query, true);\n if ('withCredentials' in xhr) {\n xhr.withCredentials = true;\n }\n\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n xhr.setRequestHeader('Content-Type', 'application/json');\n for (var headerName in headers) {\n if (headers.hasOwnProperty(headerName)) {\n xhr.setRequestHeader(headerName, headers[headerName]);\n }\n }\n\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n var _data = void 0,\n parsed = false;\n try {\n _data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback({\n error: 'Invalid JSON. Data was: ' + xhr.responseText,\n status: 200,\n data: null\n });\n }\n if (parsed) {\n // prevents double execution.\n callback({\n data: _data,\n status: 200\n });\n }\n } else {\n _this2._log('wrong status code in AJAX response', xhr.status);\n callback({\n status: xhr.status,\n data: null\n });\n }\n }\n };\n setTimeout(function () {\n return xhr.send(JSON.stringify(data));\n }, 20);\n return xhr;\n }\n }, {\n key: '_log',\n value: function _log() {\n (0, _utils.log)('info', arguments);\n }\n }, {\n key: '_debug',\n value: function _debug() {\n if (this._config.debug === true) {\n (0, _utils.log)('debug', arguments);\n }\n }\n }, {\n key: '_websocketSupported',\n value: function _websocketSupported() {\n if (this._config.websocket !== null) {\n return true;\n }\n return !(typeof WebSocket !== 'function' && (typeof WebSocket === 'undefined' ? 'undefined' : _typeof(WebSocket)) !== 'object');\n }\n }, {\n key: '_setFormat',\n value: function _setFormat(format) {\n if (this._formatOverride(format)) {\n return;\n }\n if (format === 'protobuf') {\n throw new Error('not implemented by JSON only Centrifuge client – use client with Protobuf');\n }\n this._binary = false;\n this._methodType = _json.JsonMethodType;\n this._pushType = _json.JsonPushType;\n this._encoder = new _json.JsonEncoder();\n this._decoder = new _json.JsonDecoder();\n }\n }, {\n key: '_formatOverride',\n value: function _formatOverride(format) {\n return false;\n }\n }, {\n key: '_configure',\n value: function _configure(configuration) {\n if (!('Promise' in global)) {\n throw new Error('Promise polyfill required');\n }\n\n (0, _utils.extend)(this._config, configuration || {});\n this._debug('centrifuge config', this._config);\n\n if (!this._url) {\n throw new Error('url required');\n }\n\n if ((0, _utils.startsWith)(this._url, 'ws') && this._url.indexOf('format=protobuf') > -1) {\n this._setFormat('protobuf');\n } else {\n this._setFormat('json');\n }\n\n if ((0, _utils.startsWith)(this._url, 'http')) {\n this._debug('client will try to connect to SockJS endpoint');\n if (this._config.sockjs !== null) {\n this._debug('SockJS explicitly provided in options');\n this._sockjs = this._config.sockjs;\n } else {\n if (typeof global.SockJS === 'undefined') {\n throw new Error('SockJS not found, use ws:// in url or include SockJS');\n }\n this._debug('use globally defined SockJS');\n this._sockjs = global.SockJS;\n }\n } else {\n this._debug('client will connect to websocket endpoint');\n }\n }\n }, {\n key: '_setStatus',\n value: function _setStatus(newStatus) {\n if (this._status !== newStatus) {\n this._debug('Status', this._status, '->', newStatus);\n this._status = newStatus;\n }\n }\n }, {\n key: '_isDisconnected',\n value: function _isDisconnected() {\n return this._status === 'disconnected';\n }\n }, {\n key: '_isConnecting',\n value: function _isConnecting() {\n return this._status === 'connecting';\n }\n }, {\n key: '_isConnected',\n value: function _isConnected() {\n return this._status === 'connected';\n }\n }, {\n key: '_nextMessageId',\n value: function _nextMessageId() {\n return ++this._messageId;\n }\n }, {\n key: '_resetRetry',\n value: function _resetRetry() {\n this._debug('reset retries count to 0');\n this._retries = 0;\n }\n }, {\n key: '_getRetryInterval',\n value: function _getRetryInterval() {\n var interval = (0, _utils.backoff)(this._retries, this._config.minRetry, this._config.maxRetry);\n\n this._retries += 1;\n return interval;\n }\n }, {\n key: '_abortInflightXHRs',\n value: function _abortInflightXHRs() {\n for (var xhrID in this._xhrs) {\n try {\n this._xhrs[xhrID].abort();\n } catch (e) {\n this._debug('error aborting xhr', e);\n }\n delete this._xhrs[xhrID];\n }\n }\n }, {\n key: '_clearConnectedState',\n value: function _clearConnectedState(reconnect) {\n this._clientID = null;\n this._stopPing();\n\n // fire errbacks of registered outgoing calls.\n for (var id in this._callbacks) {\n if (this._callbacks.hasOwnProperty(id)) {\n var callbacks = this._callbacks[id];\n clearTimeout(callbacks.timeout);\n var errback = callbacks.errback;\n if (!errback) {\n continue;\n }\n errback({ error: this._createErrorObject('disconnected') });\n }\n }\n this._callbacks = {};\n\n // fire unsubscribe events\n for (var channel in this._subs) {\n if (this._subs.hasOwnProperty(channel)) {\n var sub = this._subs[channel];\n\n if (reconnect) {\n if (sub._isSuccess()) {\n sub._triggerUnsubscribe();\n sub._recover = true;\n }\n if (sub._shouldResubscribe()) {\n sub._setSubscribing();\n }\n } else {\n sub._setUnsubscribed();\n }\n }\n }\n\n this._abortInflightXHRs();\n\n // clear refresh timer\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n\n // clear sub refresh timers\n for (var _channel in this._subRefreshTimeouts) {\n if (this._subRefreshTimeouts.hasOwnProperty(_channel) && this._subRefreshTimeouts[_channel]) {\n this._clearSubRefreshTimeout(_channel);\n }\n }\n this._subRefreshTimeouts = {};\n\n if (!this._reconnect) {\n // completely clear subscriptions\n this._subs = {};\n }\n }\n }, {\n key: '_isTransportOpen',\n value: function _isTransportOpen() {\n if (this._isSockjs) {\n return this._transport && this._transport.transport && this._transport.transport.readyState === this._transport.transport.OPEN;\n }\n return this._transport && this._transport.readyState === this._transport.OPEN;\n }\n }, {\n key: '_transportSend',\n value: function _transportSend(commands) {\n if (!commands.length) {\n return true;\n }\n\n if (!this._isTransportOpen()) {\n // resolve pending commands with error if transport is not open\n for (var command in commands) {\n var id = command.id;\n if (!(id in this._callbacks)) {\n continue;\n }\n var callbacks = this._callbacks[id];\n clearTimeout(this._callbacks[id].timeout);\n delete this._callbacks[id];\n var errback = callbacks.errback;\n errback({ error: this._createErrorObject(_errorConnectionClosed, 0) });\n }\n return false;\n }\n this._transport.send(this._encoder.encodeCommands(commands));\n return true;\n }\n }, {\n key: '_setupTransport',\n value: function _setupTransport() {\n var _this3 = this;\n\n this._isSockjs = false;\n\n // detect transport to use - SockJS or Websocket\n if (this._sockjs !== null) {\n var sockjsOptions = {\n transports: this._config.sockjsTransports\n };\n\n if (this._config.sockjsServer !== null) {\n sockjsOptions.server = this._config.sockjsServer;\n }\n this._isSockjs = true;\n this._transport = new this._sockjs(this._url, null, sockjsOptions);\n } else {\n if (!this._websocketSupported()) {\n this._debug('No Websocket support and no SockJS configured, can not connect');\n return;\n }\n if (this._config.websocket !== null) {\n this._websocket = this._config.websocket;\n } else {\n this._websocket = WebSocket;\n }\n this._transport = new this._websocket(this._url);\n if (this._binary === true) {\n this._transport.binaryType = 'arraybuffer';\n }\n }\n\n this._transport.onopen = function () {\n _this3._transportClosed = false;\n\n if (_this3._isSockjs) {\n _this3._transportName = 'sockjs-' + _this3._transport.transport;\n _this3._transport.onheartbeat = function () {\n return _this3._restartPing();\n };\n } else {\n _this3._transportName = 'websocket';\n }\n\n // Can omit method here due to zero value.\n var msg = {\n // method: this._methodType.CONNECT\n };\n\n if (_this3._token || _this3._connectData) {\n msg.params = {};\n }\n\n if (_this3._token) {\n msg.params.token = _this3._token;\n }\n\n if (_this3._connectData) {\n msg.params.data = _this3._connectData;\n }\n\n var subs = {};\n var hasSubs = false;\n for (var channel in _this3._serverSubs) {\n if (_this3._serverSubs.hasOwnProperty(channel) && _this3._serverSubs[channel].recoverable) {\n hasSubs = true;\n var sub = {\n 'recover': true\n };\n if (_this3._serverSubs[channel].seq) {\n sub['seq'] = _this3._serverSubs[channel].seq;\n }\n if (_this3._serverSubs[channel].gen) {\n sub['gen'] = _this3._serverSubs[channel].gen;\n }\n if (_this3._serverSubs[channel].epoch) {\n sub['epoch'] = _this3._serverSubs[channel].epoch;\n }\n subs[channel] = sub;\n }\n }\n if (hasSubs) {\n if (!msg.params) {\n msg.params = {};\n }\n msg.params.subs = subs;\n }\n\n _this3._latencyStart = new Date();\n _this3._call(msg).then(function (resolveCtx) {\n _this3._connectResponse(_this3._decoder.decodeCommandResult(_this3._methodType.CONNECT, resolveCtx.result), hasSubs);\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n var err = rejectCtx.error;\n if (err.code === 109) {\n // token expired.\n _this3._refreshRequired = true;\n }\n _this3._disconnect('connect error', true);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n };\n\n this._transport.onerror = function (error) {\n _this3._debug('transport level error', error);\n };\n\n this._transport.onclose = function (closeEvent) {\n _this3._transportClosed = true;\n var reason = _errorConnectionClosed;\n var needReconnect = true;\n\n if (closeEvent && 'reason' in closeEvent && closeEvent.reason) {\n try {\n var advice = JSON.parse(closeEvent.reason);\n _this3._debug('reason is an advice object', advice);\n reason = advice.reason;\n needReconnect = advice.reconnect;\n } catch (e) {\n reason = closeEvent.reason;\n _this3._debug('reason is a plain string', reason);\n }\n }\n\n // onTransportClose callback should be executed every time transport was closed.\n // This can be helpful to catch failed connection events (because our disconnect\n // event only called once and every future attempts to connect do not fire disconnect\n // event again).\n if (_this3._config.onTransportClose !== null) {\n _this3._config.onTransportClose({\n event: closeEvent,\n reason: reason,\n reconnect: needReconnect\n });\n }\n\n _this3._disconnect(reason, needReconnect);\n\n if (_this3._reconnect === true) {\n _this3._reconnecting = true;\n var interval = _this3._getRetryInterval();\n\n _this3._debug('reconnect after ' + interval + ' milliseconds');\n setTimeout(function () {\n if (_this3._reconnect === true) {\n if (_this3._refreshRequired) {\n _this3._refresh();\n } else {\n _this3._connect();\n }\n }\n }, interval);\n }\n };\n\n this._transport.onmessage = function (event) {\n _this3._dataReceived(event.data);\n };\n }\n }, {\n key: 'rpc',\n value: function rpc(data) {\n var _this4 = this;\n\n var msg = {\n method: this._methodType.RPC,\n params: {\n data: data\n }\n };\n\n if (!this.isConnected()) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n }\n\n return this._call(msg).then(function (resolveCtx) {\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n return _this4._decoder.decodeCommandResult(_this4._methodType.RPC, resolveCtx.result);\n }, function (rejectCtx) {\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n return Promise.reject(rejectCtx.error);\n });\n }\n }, {\n key: 'send',\n value: function send(data) {\n var msg = {\n method: this._methodType.SEND,\n params: {\n data: data\n }\n };\n\n if (!this.isConnected()) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n }\n\n var sent = this._transportSend([msg]); // can send async message to server without id set\n if (!sent) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n };\n return Promise.resolve({});\n }\n }, {\n key: 'publish',\n value: function publish(channel, data) {\n var msg = {\n method: this._methodType.PUBLISH,\n params: {\n channel: channel,\n data: data\n }\n };\n\n if (!this.isConnected()) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n }\n\n return this._call(msg).then(function (result) {\n if (result.next) {\n result.next();\n }\n return {};\n });\n }\n }, {\n key: '_dataReceived',\n value: function _dataReceived(data) {\n var _this5 = this;\n\n var replies = this._decoder.decodeReplies(data);\n // we have to guarantee order of events in replies processing - i.e. start processing\n // next reply only when we finished processing of current one. Without syncing things in\n // this way we could get wrong publication events order as reply promises resolve\n // on next loop tick so for loop continues before we finished emitting all reply events.\n var p = Promise.resolve();\n\n var _loop = function _loop(i) {\n if (replies.hasOwnProperty(i)) {\n p = p.then(function () {\n return _this5._dispatchReply(replies[i]);\n });\n }\n };\n\n for (var i in replies) {\n _loop(i);\n }\n this._restartPing();\n }\n }, {\n key: '_call',\n value: function _call(msg) {\n var _this6 = this;\n\n return new Promise(function (resolve, reject) {\n var id = _this6._addMessage(msg);\n _this6._registerCall(id, resolve, reject);\n });\n }\n }, {\n key: '_connect',\n value: function _connect() {\n if (this.isConnected()) {\n this._debug('connect called when already connected');\n return;\n }\n if (this._status === 'connecting') {\n return;\n }\n\n this._debug('start connecting');\n this._setStatus('connecting');\n this._clientID = null;\n this._reconnect = true;\n this._setupTransport();\n }\n }, {\n key: '_disconnect',\n value: function _disconnect(reason, shouldReconnect) {\n\n var reconnect = shouldReconnect || false;\n if (reconnect === false) {\n this._reconnect = false;\n }\n\n if (this._isDisconnected()) {\n if (!reconnect) {\n this._clearConnectedState(reconnect);\n }\n return;\n }\n\n this._clearConnectedState(reconnect);\n\n this._debug('disconnected:', reason, shouldReconnect);\n this._setStatus('disconnected');\n\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n if (this._reconnecting === false) {\n // fire unsubscribe events for server side subs.\n for (var channel in this._serverSubs) {\n if (this._serverSubs.hasOwnProperty(channel)) {\n this.emit('unsubscribe', { channel: channel });\n }\n }\n this.emit('disconnect', {\n reason: reason,\n reconnect: reconnect\n });\n }\n\n if (reconnect === false) {\n this._subs = {};\n this._serverSubs = {};\n }\n\n if (!this._transportClosed) {\n this._transport.close();\n }\n }\n }, {\n key: '_refreshFailed',\n value: function _refreshFailed() {\n this._numRefreshFailed = 0;\n if (!this._isDisconnected()) {\n this._disconnect('refresh failed', false);\n }\n if (this._config.onRefreshFailed !== null) {\n this._config.onRefreshFailed();\n }\n }\n }, {\n key: '_refresh',\n value: function _refresh() {\n var _this7 = this;\n\n // ask application for new connection token.\n this._debug('refresh token');\n\n if (this._config.refreshAttempts === 0) {\n this._debug('refresh attempts set to 0, do not send refresh request at all');\n this._refreshFailed();\n return;\n }\n\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n\n var clientID = this._clientID;\n var xhrID = this._newXHRID();\n\n var cb = function cb(resp) {\n if (xhrID in _this7._xhrs) {\n delete _this7._xhrs[xhrID];\n }\n if (_this7._clientID !== clientID) {\n return;\n }\n if (resp.error || resp.status !== 200) {\n // We don't perform any connection status related actions here as we are\n // relying on server that must close connection eventually.\n if (resp.error) {\n _this7._debug('error refreshing connection token', resp.error);\n } else {\n _this7._debug('error refreshing connection token: wrong status code', resp.status);\n }\n _this7._numRefreshFailed++;\n if (_this7._refreshTimeout !== null) {\n clearTimeout(_this7._refreshTimeout);\n _this7._refreshTimeout = null;\n }\n if (_this7._config.refreshAttempts !== null && _this7._numRefreshFailed >= _this7._config.refreshAttempts) {\n _this7._refreshFailed();\n return;\n }\n var jitter = Math.round(Math.random() * 1000 * Math.max(_this7._numRefreshFailed, 20));\n var interval = _this7._config.refreshInterval + jitter;\n _this7._refreshTimeout = setTimeout(function () {\n return _this7._refresh();\n }, interval);\n return;\n }\n _this7._numRefreshFailed = 0;\n _this7._token = resp.data.token;\n if (!_this7._token) {\n _this7._refreshFailed();\n return;\n }\n if (_this7._isDisconnected() && _this7._reconnect) {\n _this7._debug('token refreshed, connect from scratch');\n _this7._connect();\n } else {\n _this7._debug('send refreshed token');\n var msg = {\n method: _this7._methodType.REFRESH,\n params: {\n token: _this7._token\n }\n };\n _this7._call(msg).then(function (resolveCtx) {\n _this7._refreshResponse(_this7._decoder.decodeCommandResult(_this7._methodType.REFRESH, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n _this7._refreshError(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n };\n\n if (this._config.onRefresh !== null) {\n var context = {};\n this._config.onRefresh(context, cb);\n } else {\n var xhr = this._ajax(this._config.refreshEndpoint, this._config.refreshParams, this._config.refreshHeaders, this._config.refreshData, cb);\n this._xhrs[xhrID] = xhr;\n }\n }\n }, {\n key: '_refreshError',\n value: function _refreshError(err) {\n var _this8 = this;\n\n this._debug('refresh error', err);\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n var interval = this._config.refreshInterval + Math.round(Math.random() * 1000);\n this._refreshTimeout = setTimeout(function () {\n return _this8._refresh();\n }, interval);\n }\n }, {\n key: '_refreshResponse',\n value: function _refreshResponse(result) {\n var _this9 = this;\n\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n if (result.expires) {\n this._clientID = result.client;\n this._refreshTimeout = setTimeout(function () {\n return _this9._refresh();\n }, this._getTTLMilliseconds(result.ttl));\n }\n }\n }, {\n key: '_newXHRID',\n value: function _newXHRID() {\n this._xhrID++;\n return this._xhrID;\n }\n }, {\n key: '_subRefresh',\n value: function _subRefresh(channel) {\n var _this10 = this;\n\n this._debug('refresh subscription token for channel', channel);\n\n if (this._subRefreshTimeouts[channel] !== undefined) {\n this._clearSubRefreshTimeout(channel);\n } else {\n return;\n }\n\n var clientID = this._clientID;\n var xhrID = this._newXHRID();\n\n var cb = function cb(resp) {\n if (xhrID in _this10._xhrs) {\n delete _this10._xhrs[xhrID];\n }\n if (resp.error || resp.status !== 200 || _this10._clientID !== clientID) {\n return;\n }\n var channelsData = {};\n if (resp.data.channels) {\n for (var i in data.channels) {\n var channelData = resp.data.channels[i];\n if (!channelData.channel) {\n continue;\n }\n channelsData[channelData.channel] = channelData.token;\n }\n }\n\n var token = channelsData[channel];\n if (!token) {\n return;\n }\n var msg = {\n method: _this10._methodType.SUB_REFRESH,\n params: {\n channel: channel,\n token: token\n }\n };\n\n var sub = _this10._getSub(channel);\n if (sub === null) {\n return;\n }\n\n _this10._call(msg).then(function (resolveCtx) {\n _this10._subRefreshResponse(channel, _this10._decoder.decodeCommandResult(_this10._methodType.SUB_REFRESH, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n _this10._subRefreshError(channel, rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n };\n\n var data = {\n client: this._clientID,\n channels: [channel]\n };\n\n if (this._config.onPrivateSubscribe !== null) {\n this._config.onPrivateSubscribe({\n data: data\n }, cb);\n } else {\n var xhr = this._ajax(this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders, data, cb);\n this._xhrs[xhrID] = xhr;\n }\n }\n }, {\n key: '_clearSubRefreshTimeout',\n value: function _clearSubRefreshTimeout(channel) {\n if (this._subRefreshTimeouts[channel] !== undefined) {\n clearTimeout(this._subRefreshTimeouts[channel]);\n delete this._subRefreshTimeouts[channel];\n }\n }\n }, {\n key: '_subRefreshError',\n value: function _subRefreshError(channel, err) {\n var _this11 = this;\n\n this._debug('subscription refresh error', channel, err);\n this._clearSubRefreshTimeout(channel);\n var sub = this._getSub(channel);\n if (sub === null) {\n return;\n }\n var jitter = Math.round(Math.random() * 1000);\n var subRefreshTimeout = setTimeout(function () {\n return _this11._subRefresh(channel);\n }, this._config.subRefreshInterval + jitter);\n this._subRefreshTimeouts[channel] = subRefreshTimeout;\n return;\n }\n }, {\n key: '_subRefreshResponse',\n value: function _subRefreshResponse(channel, result) {\n var _this12 = this;\n\n this._debug('subscription refresh success', channel);\n this._clearSubRefreshTimeout(channel);\n var sub = this._getSub(channel);\n if (sub === null) {\n return;\n }\n if (result.expires === true) {\n var subRefreshTimeout = setTimeout(function () {\n return _this12._subRefresh(channel);\n }, this._getTTLMilliseconds(result.ttl));\n this._subRefreshTimeouts[channel] = subRefreshTimeout;\n }\n return;\n }\n }, {\n key: '_subscribe',\n value: function _subscribe(sub, isResubscribe) {\n var _this13 = this;\n\n this._debug('subscribing on', sub.channel);\n var channel = sub.channel;\n\n if (!(channel in this._subs)) {\n this._subs[channel] = sub;\n }\n\n if (!this.isConnected()) {\n // subscribe will be called later\n sub._setNew();\n return;\n }\n\n sub._setSubscribing(isResubscribe);\n\n var msg = {\n method: this._methodType.SUBSCRIBE,\n params: {\n channel: channel\n }\n };\n\n // If channel name does not start with privateChannelPrefix - then we\n // can just send subscription message to Centrifuge. If channel name\n // starts with privateChannelPrefix - then this is a private channel\n // and we should ask web application backend for permission first.\n if ((0, _utils.startsWith)(channel, this._config.privateChannelPrefix)) {\n // private channel.\n if (this._isSubscribeBatching) {\n this._privateChannels[channel] = true;\n } else {\n this.startSubscribeBatching();\n this._subscribe(sub);\n this.stopSubscribeBatching();\n }\n } else {\n var recover = sub._needRecover();\n\n if (recover === true) {\n msg.params.recover = true;\n var seq = this._getLastSeq(channel);\n if (seq) {\n msg.params.seq = seq;\n }\n var gen = this._getLastGen(channel);\n if (gen) {\n msg.params.gen = gen;\n }\n var epoch = this._getLastEpoch(channel);\n if (epoch) {\n msg.params.epoch = epoch;\n }\n }\n\n this._call(msg).then(function (resolveCtx) {\n _this13._subscribeResponse(channel, recover, _this13._decoder.decodeCommandResult(_this13._methodType.SUBSCRIBE, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n _this13._subscribeError(channel, rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n }\n }, {\n key: '_unsubscribe',\n value: function _unsubscribe(sub) {\n if (this.isConnected()) {\n // No need to unsubscribe in disconnected state - i.e. client already unsubscribed.\n this._addMessage({\n method: this._methodType.UNSUBSCRIBE,\n params: {\n channel: sub.channel\n }\n });\n }\n }\n }, {\n key: '_getTTLMilliseconds',\n value: function _getTTLMilliseconds(ttl) {\n // https://stackoverflow.com/questions/12633405/what-is-the-maximum-delay-for-setinterval\n return Math.min(ttl * 1000, 2147483647);\n }\n }, {\n key: 'getSub',\n value: function getSub(channel) {\n return this._getSub(channel);\n }\n }, {\n key: '_getSub',\n value: function _getSub(channel) {\n var sub = this._subs[channel];\n if (!sub) {\n return null;\n }\n return sub;\n }\n }, {\n key: '_connectResponse',\n value: function _connectResponse(result, isRecover) {\n var _this14 = this;\n\n var wasReconnecting = this._reconnecting;\n this._reconnecting = false;\n this._resetRetry();\n this._refreshRequired = false;\n\n if (this.isConnected()) {\n return;\n }\n\n if (this._latencyStart !== null) {\n this._latency = new Date().getTime() - this._latencyStart.getTime();\n this._latencyStart = null;\n }\n\n this._clientID = result.client;\n this._setStatus('connected');\n\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n }\n\n if (result.expires) {\n this._refreshTimeout = setTimeout(function () {\n return _this14._refresh();\n }, this._getTTLMilliseconds(result.ttl));\n }\n\n this.startBatching();\n this.startSubscribeBatching();\n for (var channel in this._subs) {\n if (this._subs.hasOwnProperty(channel)) {\n var sub = this._subs[channel];\n if (sub._shouldResubscribe()) {\n this._subscribe(sub, wasReconnecting);\n }\n }\n }\n this.stopSubscribeBatching();\n this.stopBatching();\n\n this._startPing();\n\n var ctx = {\n client: result.client,\n transport: this._transportName,\n latency: this._latency\n };\n if (result.data) {\n ctx.data = result.data;\n }\n\n this.emit('connect', ctx);\n\n if (result.subs) {\n this._processServerSubs(result.subs, isRecover);\n }\n }\n }, {\n key: '_processServerSubs',\n value: function _processServerSubs(subs, isRecover) {\n for (var channel in subs) {\n if (subs.hasOwnProperty(channel)) {\n var sub = subs[channel];\n var recovered = sub.recovered === true;\n var subCtx = { channel: channel, isResubscribe: isRecover, recovered: recovered };\n this.emit('subscribe', subCtx);\n }\n }\n for (var _channel2 in subs) {\n if (subs.hasOwnProperty(_channel2)) {\n var _sub = subs[_channel2];\n if (_sub.recovered) {\n var pubs = _sub.publications;\n if (pubs && pubs.length > 0) {\n pubs = pubs.reverse();\n for (var i in pubs) {\n if (pubs.hasOwnProperty(i)) {\n this._handlePublication(_channel2, pubs[i]);\n }\n }\n }\n }\n this._serverSubs[_channel2] = {\n 'seq': _sub.seq,\n 'gen': _sub.gen,\n 'epoch': _sub.epoch,\n 'recoverable': _sub.recoverable\n };\n }\n }\n }\n }, {\n key: '_stopPing',\n value: function _stopPing() {\n if (this._pongTimeout !== null) {\n clearTimeout(this._pongTimeout);\n this._pongTimeout = null;\n }\n if (this._pingTimeout !== null) {\n clearTimeout(this._pingTimeout);\n this._pingTimeout = null;\n }\n }\n }, {\n key: '_startPing',\n value: function _startPing() {\n var _this15 = this;\n\n if (this._config.ping !== true || this._config.pingInterval <= 0) {\n return;\n }\n if (!this.isConnected()) {\n return;\n }\n\n this._pingTimeout = setTimeout(function () {\n if (!_this15.isConnected()) {\n _this15._stopPing();\n return;\n }\n _this15.ping();\n _this15._pongTimeout = setTimeout(function () {\n _this15._disconnect('no ping', true);\n }, _this15._config.pongWaitTimeout);\n }, this._config.pingInterval);\n }\n }, {\n key: '_restartPing',\n value: function _restartPing() {\n this._stopPing();\n this._startPing();\n }\n }, {\n key: '_subscribeError',\n value: function _subscribeError(channel, error) {\n var sub = this._getSub(channel);\n if (!sub) {\n return;\n }\n if (!sub._isSubscribing()) {\n return;\n }\n if (error.code === 0 && error.message === _errorTimeout) {\n // client side timeout.\n this._disconnect('timeout', true);\n return;\n }\n sub._setSubscribeError(error);\n }\n }, {\n key: '_subscribeResponse',\n value: function _subscribeResponse(channel, isRecover, result) {\n var _this16 = this;\n\n var sub = this._getSub(channel);\n if (!sub) {\n return;\n }\n if (!sub._isSubscribing()) {\n return;\n }\n\n var recovered = false;\n if ('recovered' in result) {\n recovered = result.recovered;\n }\n sub._setSubscribeSuccess(recovered);\n\n var pubs = result.publications;\n if (pubs && pubs.length > 0) {\n pubs = pubs.reverse();\n for (var i in pubs) {\n if (pubs.hasOwnProperty(i)) {\n this._handlePublication(channel, pubs[i]);\n }\n }\n }\n\n if (result.recoverable && (!isRecover || !recovered)) {\n this._lastSeq[channel] = result.seq || 0;\n this._lastGen[channel] = result.gen || 0;\n }\n\n this._lastEpoch[channel] = result.epoch || '';\n\n if (result.recoverable) {\n sub._recoverable = true;\n }\n\n if (result.expires === true) {\n var subRefreshTimeout = setTimeout(function () {\n return _this16._subRefresh(channel);\n }, this._getTTLMilliseconds(result.ttl));\n this._subRefreshTimeouts[channel] = subRefreshTimeout;\n }\n }\n }, {\n key: '_handleReply',\n value: function _handleReply(reply, next) {\n var id = reply.id;\n var result = reply.result;\n\n if (!(id in this._callbacks)) {\n next();\n return;\n }\n var callbacks = this._callbacks[id];\n clearTimeout(this._callbacks[id].timeout);\n delete this._callbacks[id];\n\n if (!(0, _utils.errorExists)(reply)) {\n var callback = callbacks.callback;\n if (!callback) {\n return;\n }\n callback({ result: result, next: next });\n } else {\n var errback = callbacks.errback;\n if (!errback) {\n next();\n return;\n }\n var error = reply.error;\n errback({ error: error, next: next });\n }\n }\n }, {\n key: '_handleJoin',\n value: function _handleJoin(channel, join) {\n var ctx = { 'info': join.info };\n var sub = this._getSub(channel);\n if (!sub) {\n ctx.channel = channel;\n this.emit('join', ctx);\n return;\n }\n sub.emit('join', ctx);\n }\n }, {\n key: '_handleLeave',\n value: function _handleLeave(channel, leave) {\n var ctx = { 'info': leave.info };\n var sub = this._getSub(channel);\n if (!sub) {\n ctx.channel = channel;\n this.emit('leave', ctx);\n return;\n }\n sub.emit('leave', ctx);\n }\n }, {\n key: '_handleUnsub',\n value: function _handleUnsub(channel, unsub) {\n var ctx = {};\n var sub = this._getSub(channel);\n if (!sub) {\n delete this._serverSubs[channel];\n ctx.channel = channel;\n this.emit('unsubscribe', ctx);\n return;\n }\n sub.unsubscribe();\n if (unsub.resubscribe === true) {\n sub.subscribe();\n }\n }\n }, {\n key: '_handleSub',\n value: function _handleSub(channel, sub) {\n this._serverSubs[channel] = {\n 'seq': sub.seq,\n 'gen': sub.gen,\n 'epoch': sub.epoch,\n 'recoverable': sub.recoverable\n };\n var ctx = { 'channel': channel, isResubscribe: false, recovered: false };\n this.emit('subscribe', ctx);\n }\n }, {\n key: '_handlePublication',\n value: function _handlePublication(channel, pub) {\n var sub = this._getSub(channel);\n var ctx = {\n 'data': pub.data,\n 'seq': pub.seq,\n 'gen': pub.gen\n };\n if (!sub) {\n if (this._serverSubs[channel] !== undefined) {\n if (pub.seq !== undefined) {\n this._serverSubs[channel].seq = pub.seq;\n }\n if (pub.gen !== undefined) {\n this._serverSubs[channel].gen = pub.gen;\n }\n }\n ctx.channel = channel;\n this.emit('publish', ctx);\n return;\n }\n if (pub.seq !== undefined) {\n this._lastSeq[channel] = pub.seq;\n }\n if (pub.gen !== undefined) {\n this._lastGen[channel] = pub.gen;\n }\n sub.emit('publish', ctx);\n }\n }, {\n key: '_handleMessage',\n value: function _handleMessage(message) {\n this.emit('message', message.data);\n }\n }, {\n key: '_handlePush',\n value: function _handlePush(data, next) {\n var push = this._decoder.decodePush(data);\n var type = 0;\n if ('type' in push) {\n type = push['type'];\n }\n var channel = push.channel;\n\n if (type === this._pushType.PUBLICATION) {\n var pub = this._decoder.decodePushData(this._pushType.PUBLICATION, push.data);\n this._handlePublication(channel, pub);\n } else if (type === this._pushType.MESSAGE) {\n var message = this._decoder.decodePushData(this._pushType.MESSAGE, push.data);\n this._handleMessage(message);\n } else if (type === this._pushType.JOIN) {\n var join = this._decoder.decodePushData(this._pushType.JOIN, push.data);\n this._handleJoin(channel, join);\n } else if (type === this._pushType.LEAVE) {\n var leave = this._decoder.decodePushData(this._pushType.LEAVE, push.data);\n this._handleLeave(channel, leave);\n } else if (type === this._pushType.UNSUB) {\n var unsub = this._decoder.decodePushData(this._pushType.UNSUB, push.data);\n this._handleUnsub(channel, unsub);\n } else if (type === this._pushType.SUB) {\n var sub = this._decoder.decodePushData(this._pushType.SUB, push.data);\n this._handleSub(channel, sub);\n }\n next();\n }\n }, {\n key: '_dispatchReply',\n value: function _dispatchReply(reply) {\n var next;\n var p = new Promise(function (resolve) {\n next = resolve;\n });\n\n if (reply === undefined || reply === null) {\n this._debug('dispatch: got undefined or null reply');\n next();\n return p;\n }\n\n var id = reply.id;\n\n if (id && id > 0) {\n this._handleReply(reply, next);\n } else {\n this._handlePush(reply.result, next);\n }\n\n return p;\n }\n }, {\n key: '_flush',\n value: function _flush() {\n var messages = this._messages.slice(0);\n this._messages = [];\n this._transportSend(messages);\n }\n }, {\n key: '_ping',\n value: function _ping() {\n var _this17 = this;\n\n var msg = {\n method: this._methodType.PING\n };\n this._call(msg).then(function (resolveCtx) {\n _this17._pingResponse(_this17._decoder.decodeCommandResult(_this17._methodType.PING, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n _this17._debug('ping error', rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n }, {\n key: '_pingResponse',\n value: function _pingResponse(result) {\n if (!this.isConnected()) {\n return;\n }\n this._stopPing();\n this._startPing();\n }\n }, {\n key: '_getLastSeq',\n value: function _getLastSeq(channel) {\n var lastSeq = this._lastSeq[channel];\n if (lastSeq) {\n return lastSeq;\n }\n return 0;\n }\n }, {\n key: '_getLastGen',\n value: function _getLastGen(channel) {\n var lastGen = this._lastGen[channel];\n if (lastGen) {\n return lastGen;\n }\n return 0;\n }\n }, {\n key: '_getLastEpoch',\n value: function _getLastEpoch(channel) {\n var lastEpoch = this._lastEpoch[channel];\n if (lastEpoch) {\n return lastEpoch;\n }\n return '';\n }\n }, {\n key: '_createErrorObject',\n value: function _createErrorObject(message, code) {\n var errObject = {\n message: message,\n code: code || 0\n };\n\n return errObject;\n }\n }, {\n key: '_registerCall',\n value: function _registerCall(id, callback, errback) {\n var _this18 = this;\n\n this._callbacks[id] = {\n callback: callback,\n errback: errback,\n timeout: null\n };\n this._callbacks[id].timeout = setTimeout(function () {\n delete _this18._callbacks[id];\n if ((0, _utils.isFunction)(errback)) {\n errback({ error: _this18._createErrorObject(_errorTimeout) });\n }\n }, this._config.timeout);\n }\n }, {\n key: '_addMessage',\n value: function _addMessage(message) {\n var id = this._nextMessageId();\n message.id = id;\n if (this._isBatching === true) {\n this._messages.push(message);\n } else {\n this._transportSend([message]);\n }\n return id;\n }\n }, {\n key: 'isConnected',\n value: function isConnected() {\n return this._isConnected();\n }\n }, {\n key: 'connect',\n value: function connect() {\n this._connect();\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n this._disconnect('client', false);\n }\n }, {\n key: 'ping',\n value: function ping() {\n return this._ping();\n }\n }, {\n key: 'startBatching',\n value: function startBatching() {\n // start collecting messages without sending them to Centrifuge until flush\n // method called\n this._isBatching = true;\n }\n }, {\n key: 'stopBatching',\n value: function stopBatching() {\n this._isBatching = false;\n this._flush();\n }\n }, {\n key: 'startSubscribeBatching',\n value: function startSubscribeBatching() {\n // start collecting private channels to create bulk authentication\n // request to subscribeEndpoint when stopSubscribeBatching will be called\n this._isSubscribeBatching = true;\n }\n }, {\n key: 'stopSubscribeBatching',\n value: function stopSubscribeBatching() {\n var _this19 = this;\n\n // create request to subscribeEndpoint with collected private channels\n // to ask if this client can subscribe on each channel\n this._isSubscribeBatching = false;\n var authChannels = this._privateChannels;\n this._privateChannels = {};\n\n var channels = [];\n\n for (var channel in authChannels) {\n if (authChannels.hasOwnProperty(channel)) {\n var sub = this._getSub(channel);\n if (!sub) {\n continue;\n }\n channels.push(channel);\n }\n }\n\n if (channels.length === 0) {\n this._debug('no private channels found, no need to make request');\n return;\n }\n\n var data = {\n client: this._clientID,\n channels: channels\n };\n\n var clientID = this._clientID;\n var xhrID = this._newXHRID();\n\n var cb = function cb(resp) {\n if (xhrID in _this19._xhrs) {\n delete _this19._xhrs[xhrID];\n }\n if (_this19._clientID !== clientID) {\n return;\n }\n if (resp.error || resp.status !== 200) {\n _this19._debug('authorization request failed');\n for (var i in channels) {\n if (channels.hasOwnProperty(i)) {\n var _channel3 = channels[i];\n _this19._subscribeError(_channel3, _this19._createErrorObject('authorization request failed'));\n }\n }\n return;\n }\n\n var channelsData = {};\n if (resp.data.channels) {\n for (var _i in resp.data.channels) {\n var channelData = resp.data.channels[_i];\n if (!channelData.channel) {\n continue;\n }\n channelsData[channelData.channel] = channelData.token;\n }\n }\n\n // try to send all subscriptions in one request.\n var batch = false;\n\n if (!_this19._isBatching) {\n _this19.startBatching();\n batch = true;\n }\n\n for (var _i2 in channels) {\n if (channels.hasOwnProperty(_i2)) {\n var _ret2 = function () {\n var channel = channels[_i2];\n var token = channelsData[channel];\n\n if (!token) {\n // subscription:error\n _this19._subscribeError(channel, _this19._createErrorObject('permission denied', 103));\n return 'continue';\n } else {\n var msg = {\n method: _this19._methodType.SUBSCRIBE,\n params: {\n channel: channel,\n token: token\n }\n };\n\n var _sub2 = _this19._getSub(channel);\n if (_sub2 === null) {\n return 'continue';\n }\n\n var recover = _sub2._needRecover();\n\n if (recover === true) {\n msg.params.recover = true;\n var seq = _this19._getLastSeq(channel);\n if (seq) {\n msg.params.seq = seq;\n }\n var gen = _this19._getLastGen(channel);\n if (gen) {\n msg.params.gen = gen;\n }\n var epoch = _this19._getLastEpoch(channel);\n if (epoch) {\n msg.params.epoch = epoch;\n }\n }\n _this19._call(msg).then(function (resolveCtx) {\n _this19._subscribeResponse(channel, recover, _this19._decoder.decodeCommandResult(_this19._methodType.SUBSCRIBE, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n _this19._subscribeError(channel, rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n }();\n\n if (_ret2 === 'continue') continue;\n }\n }\n\n if (batch) {\n _this19.stopBatching();\n }\n };\n\n if (this._config.onPrivateSubscribe !== null) {\n this._config.onPrivateSubscribe({\n data: data\n }, cb);\n } else {\n var xhr = this._ajax(this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders, data, cb);\n this._xhrs[xhrID] = xhr;\n }\n }\n }, {\n key: 'subscribe',\n value: function subscribe(channel, events) {\n var currentSub = this._getSub(channel);\n if (currentSub !== null) {\n currentSub._setEvents(events);\n if (currentSub._isUnsubscribed()) {\n currentSub.subscribe();\n }\n return currentSub;\n }\n var sub = new _subscription2.default(this, channel, events);\n this._subs[channel] = sub;\n sub.subscribe();\n return sub;\n }\n }]);\n\n return Centrifuge;\n}(_events2.default);\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))\n\n/***/ }),\n\n/***/ 11:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _events = __webpack_require__(6);\n\nvar _events2 = _interopRequireDefault(_events);\n\nvar _utils = __webpack_require__(7);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar _STATE_NEW = 0;\nvar _STATE_SUBSCRIBING = 1;\nvar _STATE_SUCCESS = 2;\nvar _STATE_ERROR = 3;\nvar _STATE_UNSUBSCRIBED = 4;\n\nvar Subscription = function (_EventEmitter) {\n _inherits(Subscription, _EventEmitter);\n\n function Subscription(centrifuge, channel, events) {\n _classCallCheck(this, Subscription);\n\n var _this = _possibleConstructorReturn(this, (Subscription.__proto__ || Object.getPrototypeOf(Subscription)).call(this));\n\n _this.channel = channel;\n _this._centrifuge = centrifuge;\n _this._status = _STATE_NEW;\n _this._error = null;\n _this._isResubscribe = false;\n _this._ready = false;\n _this._subscriptionPromise = null;\n _this._noResubscribe = false;\n _this._recoverable = false;\n _this._recover = false;\n _this._setEvents(events);\n _this._initializePromise();\n _this._promises = {};\n _this._promiseId = 0;\n _this.on('error', function (errContext) {\n this._centrifuge._debug('subscription error', errContext);\n });\n return _this;\n }\n\n _createClass(Subscription, [{\n key: '_nextPromiseId',\n value: function _nextPromiseId() {\n return ++this._promiseId;\n }\n }, {\n key: '_initializePromise',\n value: function _initializePromise() {\n var _this2 = this;\n\n // this helps us to wait until subscription will successfully\n // subscribe and call actions such as presence, history etc in\n // synchronous way.\n this._ready = false;\n\n this._subscriptionPromise = new Promise(function (resolve, reject) {\n _this2._resolve = function (value) {\n _this2._ready = true;\n resolve(value);\n };\n _this2._reject = function (err) {\n _this2._ready = true;\n reject(err);\n };\n }).then(function () {}, function () {});\n }\n }, {\n key: '_needRecover',\n value: function _needRecover() {\n return this._recoverable === true && this._recover === true;\n }\n }, {\n key: '_setEvents',\n value: function _setEvents(events) {\n if (!events) {\n return;\n }\n if ((0, _utils.isFunction)(events)) {\n // events is just a function to handle publication received from channel.\n this.on('publish', events);\n } else if (Object.prototype.toString.call(events) === Object.prototype.toString.call({})) {\n var knownEvents = ['publish', 'join', 'leave', 'unsubscribe', 'subscribe', 'error'];\n for (var i = 0, l = knownEvents.length; i < l; i++) {\n var ev = knownEvents[i];\n if (ev in events) {\n this.on(ev, events[ev]);\n }\n }\n }\n }\n }, {\n key: '_isNew',\n value: function _isNew() {\n return this._status === _STATE_NEW;\n }\n }, {\n key: '_isUnsubscribed',\n value: function _isUnsubscribed() {\n return this._status === _STATE_UNSUBSCRIBED;\n }\n }, {\n key: '_isSubscribing',\n value: function _isSubscribing() {\n return this._status === _STATE_SUBSCRIBING;\n }\n }, {\n key: '_isReady',\n value: function _isReady() {\n return this._status === _STATE_SUCCESS || this._status === _STATE_ERROR;\n }\n }, {\n key: '_isSuccess',\n value: function _isSuccess() {\n return this._status === _STATE_SUCCESS;\n }\n }, {\n key: '_isError',\n value: function _isError() {\n return this._status === _STATE_ERROR;\n }\n }, {\n key: '_setNew',\n value: function _setNew() {\n this._status = _STATE_NEW;\n }\n }, {\n key: '_setSubscribing',\n value: function _setSubscribing(isResubscribe) {\n this._isResubscribe = isResubscribe || false;\n if (this._ready === true) {\n // new promise for this subscription\n this._initializePromise();\n }\n this._status = _STATE_SUBSCRIBING;\n }\n }, {\n key: '_setSubscribeSuccess',\n value: function _setSubscribeSuccess(recovered) {\n if (this._status === _STATE_SUCCESS) {\n return;\n }\n this._status = _STATE_SUCCESS;\n var successContext = this._getSubscribeSuccessContext(recovered);\n\n this._recover = false;\n this.emit('subscribe', successContext);\n this._resolve(successContext);\n for (var id in this._promises) {\n clearTimeout(this._promises[id].timeout);\n this._promises[id].resolve();\n delete this._promises[id];\n }\n }\n }, {\n key: '_setSubscribeError',\n value: function _setSubscribeError(err) {\n if (this._status === _STATE_ERROR) {\n return;\n }\n this._status = _STATE_ERROR;\n this._error = err;\n var errContext = this._getSubscribeErrorContext();\n this.emit('error', errContext);\n this._reject(errContext);\n for (var id in this._promises) {\n clearTimeout(this._promises[id].timeout);\n this._promises[id].reject(err);\n delete this._promises[id];\n }\n }\n }, {\n key: '_triggerUnsubscribe',\n value: function _triggerUnsubscribe() {\n this.emit('unsubscribe', {\n channel: this.channel\n });\n }\n }, {\n key: '_setUnsubscribed',\n value: function _setUnsubscribed(noResubscribe) {\n this._centrifuge._clearSubRefreshTimeout(this.channel);\n if (this._status === _STATE_UNSUBSCRIBED) {\n return;\n }\n var needTrigger = this._status === _STATE_SUCCESS;\n this._status = _STATE_UNSUBSCRIBED;\n if (noResubscribe === true) {\n this._recover = false;\n this._noResubscribe = true;\n delete this._centrifuge._lastSeq[this.channel];\n delete this._centrifuge._lastGen[this.channel];\n delete this._centrifuge._lastEpoch[this.channel];\n }\n if (needTrigger) {\n this._triggerUnsubscribe();\n }\n }\n }, {\n key: '_shouldResubscribe',\n value: function _shouldResubscribe() {\n return !this._noResubscribe;\n }\n }, {\n key: '_getSubscribeSuccessContext',\n value: function _getSubscribeSuccessContext(recovered) {\n return {\n channel: this.channel,\n isResubscribe: this._isResubscribe,\n recovered: recovered\n };\n }\n }, {\n key: '_getSubscribeErrorContext',\n value: function _getSubscribeErrorContext() {\n var subscribeErrorContext = this._error;\n subscribeErrorContext.channel = this.channel;\n subscribeErrorContext.isResubscribe = this._isResubscribe;\n return subscribeErrorContext;\n }\n }, {\n key: 'ready',\n value: function ready(callback, errback) {\n if (this._ready) {\n if (this._isSuccess()) {\n callback(this._getSubscribeSuccessContext());\n } else {\n errback(this._getSubscribeErrorContext());\n }\n }\n }\n }, {\n key: 'subscribe',\n value: function subscribe() {\n if (this._status === _STATE_SUCCESS) {\n return;\n }\n this._noResubscribe = false;\n this._centrifuge._subscribe(this);\n }\n }, {\n key: 'unsubscribe',\n value: function unsubscribe() {\n this._setUnsubscribed(true);\n this._centrifuge._unsubscribe(this);\n }\n }, {\n key: '_methodCall',\n value: function _methodCall(message, type) {\n var _this3 = this;\n\n var methodCallPromise = new Promise(function (resolve, reject) {\n var subPromise = void 0;\n if (_this3._isSuccess()) {\n subPromise = Promise.resolve();\n } else if (_this3._isError()) {\n subPromise = Promise.reject(_this3._error);\n } else {\n subPromise = new Promise(function (res, rej) {\n var timeout = setTimeout(function () {\n rej({ 'code': 0, 'message': 'timeout' });\n }, _this3._centrifuge._config.timeout);\n _this3._promises[_this3._nextPromiseId()] = {\n timeout: timeout,\n resolve: res,\n reject: rej\n };\n });\n }\n subPromise.then(function () {\n return _this3._centrifuge._call(message).then(function (resolveCtx) {\n resolve(_this3._centrifuge._decoder.decodeCommandResult(type, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, function (rejectCtx) {\n reject(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }, function (error) {\n reject(error);\n });\n });\n return methodCallPromise;\n }\n }, {\n key: 'publish',\n value: function publish(data) {\n return this._methodCall({\n method: this._centrifuge._methodType.PUBLISH,\n params: {\n channel: this.channel,\n data: data\n }\n }, this._centrifuge._methodType.PUBLISH);\n }\n }, {\n key: 'presence',\n value: function presence() {\n return this._methodCall({\n method: this._centrifuge._methodType.PRESENCE,\n params: {\n channel: this.channel\n }\n }, this._centrifuge._methodType.PRESENCE);\n }\n }, {\n key: 'presenceStats',\n value: function presenceStats() {\n return this._methodCall({\n method: this._centrifuge._methodType.PRESENCE_STATS,\n params: {\n channel: this.channel\n }\n }, this._centrifuge._methodType.PRESENCE_STATS);\n }\n }, {\n key: 'history',\n value: function history() {\n return this._methodCall({\n method: this._centrifuge._methodType.HISTORY,\n params: {\n channel: this.channel\n }\n }, this._centrifuge._methodType.HISTORY);\n }\n }]);\n\n return Subscription;\n}(_events2.default);\n\nexports.default = Subscription;\nmodule.exports = exports['default'];\n\n/***/ }),\n\n/***/ 12:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar JsonMethodType = exports.JsonMethodType = {\n CONNECT: 0,\n SUBSCRIBE: 1,\n UNSUBSCRIBE: 2,\n PUBLISH: 3,\n PRESENCE: 4,\n PRESENCE_STATS: 5,\n HISTORY: 6,\n PING: 7,\n SEND: 8,\n RPC: 9,\n REFRESH: 10,\n SUB_REFRESH: 11\n};\n\nvar JsonPushType = exports.JsonPushType = {\n PUBLICATION: 0,\n JOIN: 1,\n LEAVE: 2,\n UNSUB: 3,\n MESSAGE: 4,\n SUB: 5\n};\n\nvar JsonEncoder = exports.JsonEncoder = function () {\n function JsonEncoder() {\n _classCallCheck(this, JsonEncoder);\n }\n\n _createClass(JsonEncoder, [{\n key: 'encodeCommands',\n value: function encodeCommands(commands) {\n var encodedCommands = [];\n for (var i in commands) {\n if (commands.hasOwnProperty(i)) {\n encodedCommands.push(JSON.stringify(commands[i]));\n }\n }\n return encodedCommands.join('\\n');\n }\n }]);\n\n return JsonEncoder;\n}();\n\nvar JsonDecoder = exports.JsonDecoder = function () {\n function JsonDecoder() {\n _classCallCheck(this, JsonDecoder);\n }\n\n _createClass(JsonDecoder, [{\n key: 'decodeReplies',\n value: function decodeReplies(data) {\n var replies = [];\n var encodedReplies = data.split('\\n');\n for (var i in encodedReplies) {\n if (encodedReplies.hasOwnProperty(i)) {\n if (!encodedReplies[i]) {\n continue;\n }\n var reply = JSON.parse(encodedReplies[i]);\n replies.push(reply);\n }\n }\n return replies;\n }\n }, {\n key: 'decodeCommandResult',\n value: function decodeCommandResult(methodType, data) {\n return data;\n }\n }, {\n key: 'decodePush',\n value: function decodePush(data) {\n return data;\n }\n }, {\n key: 'decodePushData',\n value: function decodePushData(pushType, data) {\n return data;\n }\n }]);\n\n return JsonDecoder;\n}();\n\n/***/ }),\n\n/***/ 3:\n/***/ (function(module, exports) {\n\nvar g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n/***/ }),\n\n/***/ 31:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _centrifuge = __webpack_require__(10);\n\nexports.default = _centrifuge.Centrifuge;\nmodule.exports = exports['default'];\n\n/***/ }),\n\n/***/ 6:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction $getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return $getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = $getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n ReflectApply(this.listener, this.target, args);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\n\n/***/ }),\n\n/***/ 7:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n/* WEBPACK VAR INJECTION */(function(global) {\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.startsWith = startsWith;\nexports.isFunction = isFunction;\nexports.log = log;\nexports.backoff = backoff;\nexports.errorExists = errorExists;\nexports.extend = extend;\nfunction startsWith(value, prefix) {\n return value.lastIndexOf(prefix, 0) === 0;\n};\n\nfunction isFunction(value) {\n if (value === undefined || value === null) {\n return false;\n }\n return typeof value === 'function';\n};\n\nfunction log(level, args) {\n if (global.console) {\n var logger = global.console[level];\n\n if (isFunction(logger)) {\n logger.apply(global.console, args);\n }\n }\n};\n\nfunction backoff(step, min, max) {\n var jitter = 0.5 * Math.random();\n var interval = Math.min(max, min * Math.pow(2, step + 1));\n\n return Math.floor((1 - jitter) * interval);\n};\n\nfunction errorExists(data) {\n return 'error' in data && data.error !== null;\n};\n\nfunction extend(a, b) {\n for (var key in b) {\n if (b.hasOwnProperty(key)) {\n a[key] = b[key];\n }\n }\n return a;\n};\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))\n\n/***/ })\n\n/******/ });\n});\n\n\n// WEBPACK FOOTER //\n// centrifuge.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 31);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap f2313d0e76ba939a5a5f","import EventEmitter from 'events';\nimport Subscription from './subscription';\n\nimport {\n JsonEncoder,\n JsonDecoder,\n JsonMethodType,\n JsonPushType\n} from './json';\n\nimport {\n isFunction,\n log,\n startsWith,\n errorExists,\n backoff,\n extend\n} from './utils';\n\nconst _errorTimeout = 'timeout';\nconst _errorConnectionClosed = 'connection closed';\n\nexport class Centrifuge extends EventEmitter {\n\n constructor(url, options) {\n super();\n this._url = url;\n this._websocket = null;\n this._sockjs = null;\n this._isSockjs = false;\n this._binary = false;\n this._methodType = null;\n this._pushType = null;\n this._encoder = null;\n this._decoder = null;\n this._status = 'disconnected';\n this._reconnect = true;\n this._reconnecting = false;\n this._transport = null;\n this._transportName = null;\n this._transportClosed = true;\n this._messageId = 0;\n this._clientID = null;\n this._refreshRequired = false;\n this._subs = {};\n this._serverSubs = {};\n this._lastSeq = {};\n this._lastGen = {};\n this._lastEpoch = {};\n this._messages = [];\n this._isBatching = false;\n this._isSubscribeBatching = false;\n this._privateChannels = {};\n this._numRefreshFailed = 0;\n this._refreshTimeout = null;\n this._pingTimeout = null;\n this._pongTimeout = null;\n this._subRefreshTimeouts = {};\n this._retries = 0;\n this._callbacks = {};\n this._latency = null;\n this._latencyStart = null;\n this._connectData = null;\n this._token = null;\n this._xhrID = 0;\n this._xhrs = {};\n this._config = {\n debug: false,\n websocket: null,\n sockjs: null,\n promise: null,\n minRetry: 1000,\n maxRetry: 20000,\n timeout: 5000,\n ping: true,\n pingInterval: 25000,\n pongWaitTimeout: 5000,\n privateChannelPrefix: '$',\n onTransportClose: null,\n sockjsServer: null,\n sockjsTransports: [\n 'websocket',\n 'xdr-streaming',\n 'xhr-streaming',\n 'eventsource',\n 'iframe-eventsource',\n 'iframe-htmlfile',\n 'xdr-polling',\n 'xhr-polling',\n 'iframe-xhr-polling',\n 'jsonp-polling'\n ],\n refreshEndpoint: '/centrifuge/refresh',\n refreshHeaders: {},\n refreshParams: {},\n refreshData: {},\n refreshAttempts: null,\n refreshInterval: 1000,\n onRefreshFailed: null,\n onRefresh: null,\n subscribeEndpoint: '/centrifuge/subscribe',\n subscribeHeaders: {},\n subscribeParams: {},\n subRefreshInterval: 1000,\n onPrivateSubscribe: null\n };\n this._configure(options);\n }\n\n setToken(token) {\n this._token = token;\n }\n\n setConnectData(data) {\n this._connectData = data;\n }\n\n setRefreshHeaders(headers) {\n this._config.refreshHeaders = headers;\n }\n setRefreshParams(params) {\n this._config.refreshParams = params;\n }\n setRefreshData(data) {\n this._config.refreshData = data;\n }\n\n setSubscribeHeaders(headers) {\n this._config.subscribeHeaders = headers;\n }\n setSubscribeParams(params) {\n this._config.subscribeParams = params;\n }\n\n _ajax(url, params, headers, data, callback) {\n let query = '';\n this._debug('sending AJAX request to', url, 'with data', JSON.stringify(data));\n\n const xhr = (global.XMLHttpRequest ? new global.XMLHttpRequest() : new global.ActiveXObject('Microsoft.XMLHTTP'));\n\n for (const i in params) {\n if (params.hasOwnProperty(i)) {\n if (query.length > 0) {\n query += '&';\n }\n query += encodeURIComponent(i) + '=' + encodeURIComponent(params[i]);\n }\n }\n if (query.length > 0) {\n query = '?' + query;\n }\n xhr.open('POST', url + query, true);\n if ('withCredentials' in xhr) {\n xhr.withCredentials = true;\n }\n\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n xhr.setRequestHeader('Content-Type', 'application/json');\n for (const headerName in headers) {\n if (headers.hasOwnProperty(headerName)) {\n xhr.setRequestHeader(headerName, headers[headerName]);\n }\n }\n\n xhr.onreadystatechange = () => {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data, parsed = false;\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback({\n error: 'Invalid JSON. Data was: ' + xhr.responseText,\n status: 200,\n data: null\n });\n }\n if (parsed) { // prevents double execution.\n callback({\n data: data,\n status: 200\n });\n }\n } else {\n this._log('wrong status code in AJAX response', xhr.status);\n callback({\n status: xhr.status,\n data: null\n });\n }\n }\n };\n setTimeout(() => xhr.send(JSON.stringify(data)), 20);\n return xhr;\n };\n\n _log() {\n log('info', arguments);\n };\n\n _debug() {\n if (this._config.debug === true) {\n log('debug', arguments);\n }\n };\n\n _websocketSupported() {\n if (this._config.websocket !== null) {\n return true;\n }\n return !(typeof WebSocket !== 'function' && typeof WebSocket !== 'object');\n };\n\n _setFormat(format) {\n if (this._formatOverride(format)) {\n return;\n }\n if (format === 'protobuf') {\n throw new Error('not implemented by JSON only Centrifuge client – use client with Protobuf');\n }\n this._binary = false;\n this._methodType = JsonMethodType;\n this._pushType = JsonPushType;\n this._encoder = new JsonEncoder();\n this._decoder = new JsonDecoder();\n }\n\n _formatOverride(format) {\n return false;\n }\n\n _configure(configuration) {\n if (!('Promise' in global)) {\n throw new Error('Promise polyfill required');\n }\n\n extend(this._config, configuration || {});\n this._debug('centrifuge config', this._config);\n\n if (!this._url) {\n throw new Error('url required');\n }\n\n if (startsWith(this._url, 'ws') && this._url.indexOf('format=protobuf') > -1) {\n this._setFormat('protobuf');\n } else {\n this._setFormat('json');\n }\n\n if (startsWith(this._url, 'http')) {\n this._debug('client will try to connect to SockJS endpoint');\n if (this._config.sockjs !== null) {\n this._debug('SockJS explicitly provided in options');\n this._sockjs = this._config.sockjs;\n } else {\n if (typeof global.SockJS === 'undefined') {\n throw new Error('SockJS not found, use ws:// in url or include SockJS');\n }\n this._debug('use globally defined SockJS');\n this._sockjs = global.SockJS;\n }\n } else {\n this._debug('client will connect to websocket endpoint');\n }\n };\n\n _setStatus(newStatus) {\n if (this._status !== newStatus) {\n this._debug('Status', this._status, '->', newStatus);\n this._status = newStatus;\n }\n };\n\n _isDisconnected() {\n return this._status === 'disconnected';\n };\n\n _isConnecting() {\n return this._status === 'connecting';\n };\n\n _isConnected() {\n return this._status === 'connected';\n };\n\n _nextMessageId() {\n return ++this._messageId;\n };\n\n _resetRetry() {\n this._debug('reset retries count to 0');\n this._retries = 0;\n };\n\n _getRetryInterval() {\n const interval = backoff(this._retries, this._config.minRetry, this._config.maxRetry);\n\n this._retries += 1;\n return interval;\n };\n\n _abortInflightXHRs() {\n for (const xhrID in this._xhrs) {\n try {\n this._xhrs[xhrID].abort();\n } catch (e) {\n this._debug('error aborting xhr', e);\n }\n delete this._xhrs[xhrID];\n }\n };\n\n _clearConnectedState(reconnect) {\n this._clientID = null;\n this._stopPing();\n\n // fire errbacks of registered outgoing calls.\n for (const id in this._callbacks) {\n if (this._callbacks.hasOwnProperty(id)) {\n const callbacks = this._callbacks[id];\n clearTimeout(callbacks.timeout);\n const errback = callbacks.errback;\n if (!errback) {\n continue;\n }\n errback({error: this._createErrorObject('disconnected')});\n }\n }\n this._callbacks = {};\n\n // fire unsubscribe events\n for (const channel in this._subs) {\n if (this._subs.hasOwnProperty(channel)) {\n const sub = this._subs[channel];\n\n if (reconnect) {\n if (sub._isSuccess()) {\n sub._triggerUnsubscribe();\n sub._recover = true;\n }\n if (sub._shouldResubscribe()) {\n sub._setSubscribing();\n }\n } else {\n sub._setUnsubscribed();\n }\n }\n }\n\n this._abortInflightXHRs();\n\n // clear refresh timer\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n\n // clear sub refresh timers\n for (const channel in this._subRefreshTimeouts) {\n if (this._subRefreshTimeouts.hasOwnProperty(channel) && this._subRefreshTimeouts[channel]) {\n this._clearSubRefreshTimeout(channel);\n }\n }\n this._subRefreshTimeouts = {};\n\n if (!this._reconnect) {\n // completely clear subscriptions\n this._subs = {};\n }\n };\n\n _isTransportOpen() {\n if (this._isSockjs) {\n return this._transport &&\n this._transport.transport &&\n this._transport.transport.readyState === this._transport.transport.OPEN;\n }\n return this._transport && this._transport.readyState === this._transport.OPEN;\n };\n\n _transportSend(commands) {\n if (!commands.length) {\n return true;\n }\n\n if (!this._isTransportOpen()) {\n // resolve pending commands with error if transport is not open\n for (let command in commands) {\n let id = command.id;\n if (!(id in this._callbacks)) {\n continue;\n }\n const callbacks = this._callbacks[id];\n clearTimeout(this._callbacks[id].timeout);\n delete this._callbacks[id];\n const errback = callbacks.errback;\n errback({error: this._createErrorObject(_errorConnectionClosed, 0)});\n }\n return false;\n }\n this._transport.send(this._encoder.encodeCommands(commands));\n return true;\n }\n\n _setupTransport() {\n this._isSockjs = false;\n\n // detect transport to use - SockJS or Websocket\n if (this._sockjs !== null) {\n const sockjsOptions = {\n transports: this._config.sockjsTransports\n };\n\n if (this._config.sockjsServer !== null) {\n sockjsOptions.server = this._config.sockjsServer;\n }\n this._isSockjs = true;\n this._transport = new this._sockjs(this._url, null, sockjsOptions);\n } else {\n if (!this._websocketSupported()) {\n this._debug('No Websocket support and no SockJS configured, can not connect');\n return;\n }\n if (this._config.websocket !== null) {\n this._websocket = this._config.websocket;\n } else {\n this._websocket = WebSocket;\n }\n this._transport = new this._websocket(this._url);\n if (this._binary === true) {\n this._transport.binaryType = 'arraybuffer';\n }\n }\n\n this._transport.onopen = () => {\n this._transportClosed = false;\n\n if (this._isSockjs) {\n this._transportName = 'sockjs-' + this._transport.transport;\n this._transport.onheartbeat = () => this._restartPing();\n } else {\n this._transportName = 'websocket';\n }\n\n // Can omit method here due to zero value.\n const msg = {\n // method: this._methodType.CONNECT\n };\n\n if (this._token || this._connectData) {\n msg.params = {};\n }\n\n if (this._token) {\n msg.params.token = this._token;\n }\n\n if (this._connectData) {\n msg.params.data = this._connectData;\n }\n\n let subs = {};\n let hasSubs = false;\n for (const channel in this._serverSubs) {\n if (this._serverSubs.hasOwnProperty(channel) && this._serverSubs[channel].recoverable) {\n hasSubs = true;\n let sub = {\n 'recover': true\n };\n if (this._serverSubs[channel].seq) {\n sub['seq'] = this._serverSubs[channel].seq;\n }\n if (this._serverSubs[channel].gen) {\n sub['gen'] = this._serverSubs[channel].gen;\n }\n if (this._serverSubs[channel].epoch) {\n sub['epoch'] = this._serverSubs[channel].epoch;\n }\n subs[channel] = sub;\n }\n }\n if (hasSubs) {\n if (!msg.params) {msg.params = {};}\n msg.params.subs = subs;\n }\n\n this._latencyStart = new Date();\n this._call(msg).then(resolveCtx => {\n this._connectResponse(this._decoder.decodeCommandResult(this._methodType.CONNECT, resolveCtx.result), hasSubs);\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, rejectCtx => {\n const err = rejectCtx.error;\n if (err.code === 109) { // token expired.\n this._refreshRequired = true;\n }\n this._disconnect('connect error', true);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n };\n\n this._transport.onerror = error => {\n this._debug('transport level error', error);\n };\n\n this._transport.onclose = closeEvent => {\n this._transportClosed = true;\n let reason = _errorConnectionClosed;\n let needReconnect = true;\n\n if (closeEvent && 'reason' in closeEvent && closeEvent.reason) {\n try {\n const advice = JSON.parse(closeEvent.reason);\n this._debug('reason is an advice object', advice);\n reason = advice.reason;\n needReconnect = advice.reconnect;\n } catch (e) {\n reason = closeEvent.reason;\n this._debug('reason is a plain string', reason);\n }\n }\n\n // onTransportClose callback should be executed every time transport was closed.\n // This can be helpful to catch failed connection events (because our disconnect\n // event only called once and every future attempts to connect do not fire disconnect\n // event again).\n if (this._config.onTransportClose !== null) {\n this._config.onTransportClose({\n event: closeEvent,\n reason: reason,\n reconnect: needReconnect\n });\n }\n\n this._disconnect(reason, needReconnect);\n\n if (this._reconnect === true) {\n this._reconnecting = true;\n const interval = this._getRetryInterval();\n\n this._debug('reconnect after ' + interval + ' milliseconds');\n setTimeout(() => {\n if (this._reconnect === true) {\n if (this._refreshRequired) {\n this._refresh();\n } else {\n this._connect();\n }\n }\n }, interval);\n }\n };\n\n this._transport.onmessage = event => {\n this._dataReceived(event.data);\n };\n };\n\n rpc(data) {\n const msg = {\n method: this._methodType.RPC,\n params: {\n data: data\n }\n };\n\n if (!this.isConnected()) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n }\n\n return this._call(msg).then(resolveCtx => {\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n return this._decoder.decodeCommandResult(this._methodType.RPC, resolveCtx.result);\n }, rejectCtx => {\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n return Promise.reject(rejectCtx.error);\n });\n }\n\n send(data) {\n const msg = {\n method: this._methodType.SEND,\n params: {\n data: data\n }\n };\n\n if (!this.isConnected()) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n }\n\n const sent = this._transportSend([msg]); // can send async message to server without id set\n if (!sent) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n };\n return Promise.resolve({});\n }\n\n publish(channel, data) {\n const msg = {\n method: this._methodType.PUBLISH,\n params: {\n channel: channel,\n data: data\n }\n };\n\n if (!this.isConnected()) {\n return Promise.reject(this._createErrorObject(_errorConnectionClosed, 0));\n }\n\n return this._call(msg).then(result => {\n if (result.next) {\n result.next();\n }\n return {};\n });\n }\n\n _dataReceived(data) {\n const replies = this._decoder.decodeReplies(data);\n // we have to guarantee order of events in replies processing - i.e. start processing\n // next reply only when we finished processing of current one. Without syncing things in\n // this way we could get wrong publication events order as reply promises resolve\n // on next loop tick so for loop continues before we finished emitting all reply events.\n let p = Promise.resolve();\n for (const i in replies) {\n if (replies.hasOwnProperty(i)) {\n p = p.then(() => {\n return this._dispatchReply(replies[i]);\n });\n }\n }\n this._restartPing();\n }\n\n _call(msg) {\n return new Promise((resolve, reject) => {\n const id = this._addMessage(msg);\n this._registerCall(id, resolve, reject);\n });\n }\n\n _connect() {\n if (this.isConnected()) {\n this._debug('connect called when already connected');\n return;\n }\n if (this._status === 'connecting') {\n return;\n }\n\n this._debug('start connecting');\n this._setStatus('connecting');\n this._clientID = null;\n this._reconnect = true;\n this._setupTransport();\n };\n\n _disconnect(reason, shouldReconnect) {\n\n const reconnect = shouldReconnect || false;\n if (reconnect === false) {\n this._reconnect = false;\n }\n\n if (this._isDisconnected()) {\n if (!reconnect) {\n this._clearConnectedState(reconnect);\n }\n return;\n }\n\n this._clearConnectedState(reconnect);\n\n this._debug('disconnected:', reason, shouldReconnect);\n this._setStatus('disconnected');\n\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n if (this._reconnecting === false) {\n // fire unsubscribe events for server side subs.\n for (const channel in this._serverSubs) {\n if (this._serverSubs.hasOwnProperty(channel)) {\n this.emit('unsubscribe', {channel: channel});\n }\n }\n this.emit('disconnect', {\n reason: reason,\n reconnect: reconnect\n });\n }\n\n if (reconnect === false) {\n this._subs = {};\n this._serverSubs = {};\n }\n\n if (!this._transportClosed) {\n this._transport.close();\n }\n };\n\n _refreshFailed() {\n this._numRefreshFailed = 0;\n if (!this._isDisconnected()) {\n this._disconnect('refresh failed', false);\n }\n if (this._config.onRefreshFailed !== null) {\n this._config.onRefreshFailed();\n }\n };\n\n _refresh() {\n // ask application for new connection token.\n this._debug('refresh token');\n\n if (this._config.refreshAttempts === 0) {\n this._debug('refresh attempts set to 0, do not send refresh request at all');\n this._refreshFailed();\n return;\n }\n\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n\n const clientID = this._clientID;\n const xhrID = this._newXHRID();\n\n const cb = (resp) => {\n if (xhrID in this._xhrs) {\n delete this._xhrs[xhrID];\n }\n if (this._clientID !== clientID) {\n return;\n }\n if (resp.error || resp.status !== 200) {\n // We don't perform any connection status related actions here as we are\n // relying on server that must close connection eventually.\n if (resp.error) {\n this._debug('error refreshing connection token', resp.error);\n } else {\n this._debug('error refreshing connection token: wrong status code', resp.status);\n }\n this._numRefreshFailed++;\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n if (this._config.refreshAttempts !== null && this._numRefreshFailed >= this._config.refreshAttempts) {\n this._refreshFailed();\n return;\n }\n const jitter = Math.round(Math.random() * 1000 * Math.max(this._numRefreshFailed, 20));\n const interval = this._config.refreshInterval + jitter;\n this._refreshTimeout = setTimeout(() => this._refresh(), interval);\n return;\n }\n this._numRefreshFailed = 0;\n this._token = resp.data.token;\n if (!this._token) {\n this._refreshFailed();\n return;\n }\n if (this._isDisconnected() && this._reconnect) {\n this._debug('token refreshed, connect from scratch');\n this._connect();\n } else {\n this._debug('send refreshed token');\n const msg = {\n method: this._methodType.REFRESH,\n params: {\n token: this._token\n }\n };\n this._call(msg).then(resolveCtx => {\n this._refreshResponse(this._decoder.decodeCommandResult(this._methodType.REFRESH, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, rejectCtx => {\n this._refreshError(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n };\n\n if (this._config.onRefresh !== null) {\n const context = {};\n this._config.onRefresh(context, cb);\n } else {\n const xhr = this._ajax(\n this._config.refreshEndpoint,\n this._config.refreshParams,\n this._config.refreshHeaders,\n this._config.refreshData,\n cb\n );\n this._xhrs[xhrID] = xhr;\n }\n };\n\n _refreshError(err) {\n this._debug('refresh error', err);\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n const interval = this._config.refreshInterval + Math.round(Math.random() * 1000);\n this._refreshTimeout = setTimeout(() => this._refresh(), interval);\n }\n\n _refreshResponse(result) {\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n if (result.expires) {\n this._clientID = result.client;\n this._refreshTimeout = setTimeout(() => this._refresh(), this._getTTLMilliseconds(result.ttl));\n }\n };\n\n _newXHRID() {\n this._xhrID++;\n return this._xhrID;\n }\n\n _subRefresh(channel) {\n this._debug('refresh subscription token for channel', channel);\n\n if (this._subRefreshTimeouts[channel] !== undefined) {\n this._clearSubRefreshTimeout(channel);\n } else {\n return;\n }\n\n const clientID = this._clientID;\n const xhrID = this._newXHRID();\n\n const cb = (resp) => {\n if (xhrID in this._xhrs) {\n delete this._xhrs[xhrID];\n }\n if (resp.error || resp.status !== 200 || this._clientID !== clientID) {\n return;\n }\n let channelsData = {};\n if (resp.data.channels) {\n for (const i in data.channels) {\n const channelData = resp.data.channels[i];\n if (!channelData.channel) {\n continue;\n }\n channelsData[channelData.channel] = channelData.token;\n }\n }\n\n const token = channelsData[channel];\n if (!token) {\n return;\n }\n const msg = {\n method: this._methodType.SUB_REFRESH,\n params: {\n channel: channel,\n token: token\n }\n };\n\n const sub = this._getSub(channel);\n if (sub === null) {\n return;\n }\n\n this._call(msg).then(resolveCtx => {\n this._subRefreshResponse(\n channel,\n this._decoder.decodeCommandResult(this._methodType.SUB_REFRESH, resolveCtx.result)\n );\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, rejectCtx => {\n this._subRefreshError(channel, rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n };\n\n const data = {\n client: this._clientID,\n channels: [channel]\n };\n\n if (this._config.onPrivateSubscribe !== null) {\n this._config.onPrivateSubscribe({\n data: data\n }, cb);\n } else {\n const xhr = this._ajax(\n this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders, data, cb);\n this._xhrs[xhrID] = xhr;\n }\n };\n\n _clearSubRefreshTimeout(channel) {\n if (this._subRefreshTimeouts[channel] !== undefined) {\n clearTimeout(this._subRefreshTimeouts[channel]);\n delete this._subRefreshTimeouts[channel];\n }\n }\n\n _subRefreshError(channel, err) {\n this._debug('subscription refresh error', channel, err);\n this._clearSubRefreshTimeout(channel);\n const sub = this._getSub(channel);\n if (sub === null) {\n return;\n }\n const jitter = Math.round(Math.random() * 1000);\n let subRefreshTimeout = setTimeout(() => this._subRefresh(channel), this._config.subRefreshInterval + jitter);\n this._subRefreshTimeouts[channel] = subRefreshTimeout;\n return;\n }\n\n _subRefreshResponse(channel, result) {\n this._debug('subscription refresh success', channel);\n this._clearSubRefreshTimeout(channel);\n const sub = this._getSub(channel);\n if (sub === null) {\n return;\n }\n if (result.expires === true) {\n let subRefreshTimeout = setTimeout(() => this._subRefresh(channel), this._getTTLMilliseconds(result.ttl));\n this._subRefreshTimeouts[channel] = subRefreshTimeout;\n }\n return;\n };\n\n _subscribe(sub, isResubscribe) {\n this._debug('subscribing on', sub.channel);\n const channel = sub.channel;\n\n if (!(channel in this._subs)) {\n this._subs[channel] = sub;\n }\n\n if (!this.isConnected()) {\n // subscribe will be called later\n sub._setNew();\n return;\n }\n\n sub._setSubscribing(isResubscribe);\n\n const msg = {\n method: this._methodType.SUBSCRIBE,\n params: {\n channel: channel\n }\n };\n\n // If channel name does not start with privateChannelPrefix - then we\n // can just send subscription message to Centrifuge. If channel name\n // starts with privateChannelPrefix - then this is a private channel\n // and we should ask web application backend for permission first.\n if (startsWith(channel, this._config.privateChannelPrefix)) {\n // private channel.\n if (this._isSubscribeBatching) {\n this._privateChannels[channel] = true;\n } else {\n this.startSubscribeBatching();\n this._subscribe(sub);\n this.stopSubscribeBatching();\n }\n } else {\n const recover = sub._needRecover();\n\n if (recover === true) {\n msg.params.recover = true;\n const seq = this._getLastSeq(channel);\n if (seq) {\n msg.params.seq = seq;\n }\n const gen = this._getLastGen(channel);\n if (gen) {\n msg.params.gen = gen;\n }\n const epoch = this._getLastEpoch(channel);\n if (epoch) {\n msg.params.epoch = epoch;\n }\n }\n\n this._call(msg).then(resolveCtx => {\n this._subscribeResponse(\n channel,\n recover,\n this._decoder.decodeCommandResult(this._methodType.SUBSCRIBE, resolveCtx.result)\n );\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, rejectCtx => {\n this._subscribeError(channel, rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n };\n\n _unsubscribe(sub) {\n if (this.isConnected()) {\n // No need to unsubscribe in disconnected state - i.e. client already unsubscribed.\n this._addMessage({\n method: this._methodType.UNSUBSCRIBE,\n params: {\n channel: sub.channel\n }\n });\n }\n };\n\n _getTTLMilliseconds(ttl) {\n // https://stackoverflow.com/questions/12633405/what-is-the-maximum-delay-for-setinterval\n return Math.min(ttl * 1000, 2147483647);\n }\n\n getSub(channel) {\n return this._getSub(channel);\n }\n\n _getSub(channel) {\n const sub = this._subs[channel];\n if (!sub) {\n return null;\n }\n return sub;\n };\n\n _connectResponse(result, isRecover) {\n const wasReconnecting = this._reconnecting;\n this._reconnecting = false;\n this._resetRetry();\n this._refreshRequired = false;\n\n if (this.isConnected()) {\n return;\n }\n\n if (this._latencyStart !== null) {\n this._latency = (new Date()).getTime() - this._latencyStart.getTime();\n this._latencyStart = null;\n }\n\n this._clientID = result.client;\n this._setStatus('connected');\n\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n }\n\n if (result.expires) {\n this._refreshTimeout = setTimeout(() => this._refresh(), this._getTTLMilliseconds(result.ttl));\n }\n\n this.startBatching();\n this.startSubscribeBatching();\n for (const channel in this._subs) {\n if (this._subs.hasOwnProperty(channel)) {\n const sub = this._subs[channel];\n if (sub._shouldResubscribe()) {\n this._subscribe(sub, wasReconnecting);\n }\n }\n }\n this.stopSubscribeBatching();\n this.stopBatching();\n\n this._startPing();\n\n const ctx = {\n client: result.client,\n transport: this._transportName,\n latency: this._latency\n };\n if (result.data) {\n ctx.data = result.data;\n }\n\n this.emit('connect', ctx);\n\n if (result.subs) {\n this._processServerSubs(result.subs, isRecover);\n }\n };\n\n _processServerSubs(subs, isRecover) {\n for (const channel in subs) {\n if (subs.hasOwnProperty(channel)) {\n const sub = subs[channel];\n const recovered = sub.recovered === true;\n let subCtx = {channel: channel, isResubscribe: isRecover, recovered: recovered};\n this.emit('subscribe', subCtx);\n }\n }\n for (const channel in subs) {\n if (subs.hasOwnProperty(channel)) {\n const sub = subs[channel];\n if (sub.recovered) {\n let pubs = sub.publications;\n if (pubs && pubs.length > 0) {\n pubs = pubs.reverse();\n for (let i in pubs) {\n if (pubs.hasOwnProperty(i)) {\n this._handlePublication(channel, pubs[i]);\n }\n }\n }\n }\n this._serverSubs[channel] = {\n 'seq': sub.seq,\n 'gen': sub.gen,\n 'epoch': sub.epoch,\n 'recoverable': sub.recoverable\n };\n }\n }\n };\n\n _stopPing() {\n if (this._pongTimeout !== null) {\n clearTimeout(this._pongTimeout);\n this._pongTimeout = null;\n }\n if (this._pingTimeout !== null) {\n clearTimeout(this._pingTimeout);\n this._pingTimeout = null;\n }\n };\n\n _startPing() {\n if (this._config.ping !== true || this._config.pingInterval <= 0) {\n return;\n }\n if (!this.isConnected()) {\n return;\n }\n\n this._pingTimeout = setTimeout(() => {\n if (!this.isConnected()) {\n this._stopPing();\n return;\n }\n this.ping();\n this._pongTimeout = setTimeout(() => {\n this._disconnect('no ping', true);\n }, this._config.pongWaitTimeout);\n }, this._config.pingInterval);\n };\n\n _restartPing() {\n this._stopPing();\n this._startPing();\n };\n\n _subscribeError(channel, error) {\n const sub = this._getSub(channel);\n if (!sub) {\n return;\n }\n if (!sub._isSubscribing()) {\n return;\n }\n if (error.code === 0 && error.message === _errorTimeout) { // client side timeout.\n this._disconnect('timeout', true);\n return;\n }\n sub._setSubscribeError(error);\n };\n\n _subscribeResponse(channel, isRecover, result) {\n const sub = this._getSub(channel);\n if (!sub) {\n return;\n }\n if (!sub._isSubscribing()) {\n return;\n }\n\n let recovered = false;\n if ('recovered' in result) {\n recovered = result.recovered;\n }\n sub._setSubscribeSuccess(recovered);\n\n let pubs = result.publications;\n if (pubs && pubs.length > 0) {\n pubs = pubs.reverse();\n for (let i in pubs) {\n if (pubs.hasOwnProperty(i)) {\n this._handlePublication(channel, pubs[i]);\n }\n }\n }\n\n if (result.recoverable && (!isRecover || !recovered)) {\n this._lastSeq[channel] = result.seq || 0;\n this._lastGen[channel] = result.gen || 0;\n }\n\n this._lastEpoch[channel] = result.epoch || '';\n\n if (result.recoverable) {\n sub._recoverable = true;\n }\n\n if (result.expires === true) {\n let subRefreshTimeout = setTimeout(() => this._subRefresh(channel), this._getTTLMilliseconds(result.ttl));\n this._subRefreshTimeouts[channel] = subRefreshTimeout;\n }\n };\n\n _handleReply(reply, next) {\n const id = reply.id;\n const result = reply.result;\n\n if (!(id in this._callbacks)) {\n next();\n return;\n }\n const callbacks = this._callbacks[id];\n clearTimeout(this._callbacks[id].timeout);\n delete this._callbacks[id];\n\n if (!errorExists(reply)) {\n const callback = callbacks.callback;\n if (!callback) {\n return;\n }\n callback({result, next});\n } else {\n const errback = callbacks.errback;\n if (!errback) {\n next();\n return;\n }\n const error = reply.error;\n errback({error, next});\n }\n }\n\n _handleJoin(channel, join) {\n const ctx = {'info': join.info};\n const sub = this._getSub(channel);\n if (!sub) {\n ctx.channel = channel;\n this.emit('join', ctx);\n return;\n }\n sub.emit('join', ctx);\n };\n\n _handleLeave(channel, leave) {\n const ctx = {'info': leave.info};\n const sub = this._getSub(channel);\n if (!sub) {\n ctx.channel = channel;\n this.emit('leave', ctx);\n return;\n }\n sub.emit('leave', ctx);\n };\n\n _handleUnsub(channel, unsub) {\n const ctx = {};\n const sub = this._getSub(channel);\n if (!sub) {\n delete this._serverSubs[channel];\n ctx.channel = channel;\n this.emit('unsubscribe', ctx);\n return;\n }\n sub.unsubscribe();\n if (unsub.resubscribe === true) {\n sub.subscribe();\n }\n };\n\n _handleSub(channel, sub) {\n this._serverSubs[channel] = {\n 'seq': sub.seq,\n 'gen': sub.gen,\n 'epoch': sub.epoch,\n 'recoverable': sub.recoverable\n };\n const ctx = {'channel': channel, isResubscribe: false, recovered: false};\n this.emit('subscribe', ctx);\n };\n\n _handlePublication(channel, pub) {\n const sub = this._getSub(channel);\n const ctx = {\n 'data': pub.data,\n 'seq': pub.seq,\n 'gen': pub.gen\n };\n if (!sub) {\n if (this._serverSubs[channel] !== undefined) {\n if (pub.seq !== undefined) {\n this._serverSubs[channel].seq = pub.seq;\n }\n if (pub.gen !== undefined) {\n this._serverSubs[channel].gen = pub.gen;\n }\n }\n ctx.channel = channel;\n this.emit('publish', ctx);\n return;\n }\n if (pub.seq !== undefined) {\n this._lastSeq[channel] = pub.seq;\n }\n if (pub.gen !== undefined) {\n this._lastGen[channel] = pub.gen;\n }\n sub.emit('publish', ctx);\n };\n\n _handleMessage(message) {\n this.emit('message', message.data);\n };\n\n _handlePush(data, next) {\n const push = this._decoder.decodePush(data);\n let type = 0;\n if ('type' in push) {\n type = push['type'];\n }\n const channel = push.channel;\n\n if (type === this._pushType.PUBLICATION) {\n const pub = this._decoder.decodePushData(this._pushType.PUBLICATION, push.data);\n this._handlePublication(channel, pub);\n } else if (type === this._pushType.MESSAGE) {\n const message = this._decoder.decodePushData(this._pushType.MESSAGE, push.data);\n this._handleMessage(message);\n } else if (type === this._pushType.JOIN) {\n const join = this._decoder.decodePushData(this._pushType.JOIN, push.data);\n this._handleJoin(channel, join);\n } else if (type === this._pushType.LEAVE) {\n const leave = this._decoder.decodePushData(this._pushType.LEAVE, push.data);\n this._handleLeave(channel, leave);\n } else if (type === this._pushType.UNSUB) {\n const unsub = this._decoder.decodePushData(this._pushType.UNSUB, push.data);\n this._handleUnsub(channel, unsub);\n } else if (type === this._pushType.SUB) {\n const sub = this._decoder.decodePushData(this._pushType.SUB, push.data);\n this._handleSub(channel, sub);\n }\n next();\n }\n\n _dispatchReply(reply) {\n var next;\n const p = new Promise(resolve =>{\n next = resolve;\n });\n\n if (reply === undefined || reply === null) {\n this._debug('dispatch: got undefined or null reply');\n next();\n return p;\n }\n\n const id = reply.id;\n\n if (id && id > 0) {\n this._handleReply(reply, next);\n } else {\n this._handlePush(reply.result, next);\n }\n\n return p;\n };\n\n _flush() {\n const messages = this._messages.slice(0);\n this._messages = [];\n this._transportSend(messages);\n };\n\n _ping() {\n const msg = {\n method: this._methodType.PING\n };\n this._call(msg).then(resolveCtx => {\n this._pingResponse(this._decoder.decodeCommandResult(this._methodType.PING, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, rejectCtx => {\n this._debug('ping error', rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n };\n\n _pingResponse(result) {\n if (!this.isConnected()) {\n return;\n }\n this._stopPing();\n this._startPing();\n }\n\n _getLastSeq(channel) {\n const lastSeq = this._lastSeq[channel];\n if (lastSeq) {\n return lastSeq;\n }\n return 0;\n };\n\n _getLastGen(channel) {\n const lastGen = this._lastGen[channel];\n if (lastGen) {\n return lastGen;\n }\n return 0;\n };\n\n _getLastEpoch(channel) {\n const lastEpoch = this._lastEpoch[channel];\n if (lastEpoch) {\n return lastEpoch;\n }\n return '';\n };\n\n _createErrorObject(message, code) {\n const errObject = {\n message: message,\n code: code || 0\n };\n\n return errObject;\n };\n\n _registerCall(id, callback, errback) {\n this._callbacks[id] = {\n callback: callback,\n errback: errback,\n timeout: null\n };\n this._callbacks[id].timeout = setTimeout(() => {\n delete this._callbacks[id];\n if (isFunction(errback)) {\n errback({error: this._createErrorObject(_errorTimeout)});\n }\n }, this._config.timeout);\n };\n\n _addMessage(message) {\n let id = this._nextMessageId();\n message.id = id;\n if (this._isBatching === true) {\n this._messages.push(message);\n } else {\n this._transportSend([message]);\n }\n return id;\n };\n\n isConnected() {\n return this._isConnected();\n }\n\n connect() {\n this._connect();\n };\n\n disconnect() {\n this._disconnect('client', false);\n };\n\n ping() {\n return this._ping();\n }\n\n startBatching() {\n // start collecting messages without sending them to Centrifuge until flush\n // method called\n this._isBatching = true;\n };\n\n stopBatching() {\n this._isBatching = false;\n this._flush();\n };\n\n startSubscribeBatching() {\n // start collecting private channels to create bulk authentication\n // request to subscribeEndpoint when stopSubscribeBatching will be called\n this._isSubscribeBatching = true;\n };\n\n stopSubscribeBatching() {\n // create request to subscribeEndpoint with collected private channels\n // to ask if this client can subscribe on each channel\n this._isSubscribeBatching = false;\n const authChannels = this._privateChannels;\n this._privateChannels = {};\n\n const channels = [];\n\n for (const channel in authChannels) {\n if (authChannels.hasOwnProperty(channel)) {\n const sub = this._getSub(channel);\n if (!sub) {\n continue;\n }\n channels.push(channel);\n }\n }\n\n if (channels.length === 0) {\n this._debug('no private channels found, no need to make request');\n return;\n }\n\n const data = {\n client: this._clientID,\n channels: channels\n };\n\n const clientID = this._clientID;\n const xhrID = this._newXHRID();\n\n const cb = (resp) => {\n if (xhrID in this._xhrs) {\n delete this._xhrs[xhrID];\n }\n if (this._clientID !== clientID) {\n return;\n }\n if (resp.error || resp.status !== 200) {\n this._debug('authorization request failed');\n for (const i in channels) {\n if (channels.hasOwnProperty(i)) {\n const channel = channels[i];\n this._subscribeError(channel, this._createErrorObject('authorization request failed'));\n }\n }\n return;\n }\n\n let channelsData = {};\n if (resp.data.channels) {\n for (const i in resp.data.channels) {\n const channelData = resp.data.channels[i];\n if (!channelData.channel) {\n continue;\n }\n channelsData[channelData.channel] = channelData.token;\n }\n }\n\n // try to send all subscriptions in one request.\n let batch = false;\n\n if (!this._isBatching) {\n this.startBatching();\n batch = true;\n }\n\n for (const i in channels) {\n if (channels.hasOwnProperty(i)) {\n const channel = channels[i];\n const token = channelsData[channel];\n\n if (!token) {\n // subscription:error\n this._subscribeError(channel, this._createErrorObject('permission denied', 103));\n continue;\n } else {\n const msg = {\n method: this._methodType.SUBSCRIBE,\n params: {\n channel: channel,\n token: token\n }\n };\n\n const sub = this._getSub(channel);\n if (sub === null) {\n continue;\n }\n\n const recover = sub._needRecover();\n\n if (recover === true) {\n msg.params.recover = true;\n const seq = this._getLastSeq(channel);\n if (seq) {\n msg.params.seq = seq;\n }\n const gen = this._getLastGen(channel);\n if (gen) {\n msg.params.gen = gen;\n }\n const epoch = this._getLastEpoch(channel);\n if (epoch) {\n msg.params.epoch = epoch;\n }\n }\n this._call(msg).then(resolveCtx => {\n this._subscribeResponse(\n channel,\n recover,\n this._decoder.decodeCommandResult(this._methodType.SUBSCRIBE, resolveCtx.result)\n );\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n }, rejectCtx => {\n this._subscribeError(channel, rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }\n }\n }\n\n if (batch) {\n this.stopBatching();\n }\n\n };\n\n if (this._config.onPrivateSubscribe !== null) {\n this._config.onPrivateSubscribe({\n data: data\n }, cb);\n } else {\n const xhr = this._ajax(\n this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders, data, cb);\n this._xhrs[xhrID] = xhr;\n }\n };\n\n subscribe(channel, events) {\n const currentSub = this._getSub(channel);\n if (currentSub !== null) {\n currentSub._setEvents(events);\n if (currentSub._isUnsubscribed()) {\n currentSub.subscribe();\n }\n return currentSub;\n }\n const sub = new Subscription(this, channel, events);\n this._subs[channel] = sub;\n sub.subscribe();\n return sub;\n };\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/centrifuge.js","import EventEmitter from 'events';\n\nimport {\n isFunction\n} from './utils';\n\nconst _STATE_NEW = 0;\nconst _STATE_SUBSCRIBING = 1;\nconst _STATE_SUCCESS = 2;\nconst _STATE_ERROR = 3;\nconst _STATE_UNSUBSCRIBED = 4;\n\nexport default class Subscription extends EventEmitter {\n constructor(centrifuge, channel, events) {\n super();\n this.channel = channel;\n this._centrifuge = centrifuge;\n this._status = _STATE_NEW;\n this._error = null;\n this._isResubscribe = false;\n this._ready = false;\n this._subscriptionPromise = null;\n this._noResubscribe = false;\n this._recoverable = false;\n this._recover = false;\n this._setEvents(events);\n this._initializePromise();\n this._promises = {};\n this._promiseId = 0;\n this.on('error', function (errContext) {\n this._centrifuge._debug('subscription error', errContext);\n });\n }\n\n _nextPromiseId() {\n return ++this._promiseId;\n }\n\n _initializePromise() {\n // this helps us to wait until subscription will successfully\n // subscribe and call actions such as presence, history etc in\n // synchronous way.\n this._ready = false;\n\n this._subscriptionPromise = new Promise((resolve, reject) => {\n this._resolve = value => {\n this._ready = true;\n resolve(value);\n };\n this._reject = err => {\n this._ready = true;\n reject(err);\n };\n }).then(function () {}, function () {});\n };\n\n _needRecover() {\n return this._recoverable === true && this._recover === true;\n };\n\n _setEvents(events) {\n if (!events) {\n return;\n }\n if (isFunction(events)) {\n // events is just a function to handle publication received from channel.\n this.on('publish', events);\n } else if (Object.prototype.toString.call(events) === Object.prototype.toString.call({})) {\n const knownEvents = ['publish', 'join', 'leave', 'unsubscribe', 'subscribe', 'error'];\n for (let i = 0, l = knownEvents.length; i < l; i++) {\n const ev = knownEvents[i];\n if (ev in events) {\n this.on(ev, events[ev]);\n }\n }\n }\n };\n\n _isNew() {\n return this._status === _STATE_NEW;\n };\n\n _isUnsubscribed() {\n return this._status === _STATE_UNSUBSCRIBED;\n };\n\n _isSubscribing() {\n return this._status === _STATE_SUBSCRIBING;\n };\n\n _isReady() {\n return this._status === _STATE_SUCCESS || this._status === _STATE_ERROR;\n };\n\n _isSuccess() {\n return this._status === _STATE_SUCCESS;\n };\n\n _isError() {\n return this._status === _STATE_ERROR;\n };\n\n _setNew() {\n this._status = _STATE_NEW;\n };\n\n _setSubscribing(isResubscribe) {\n this._isResubscribe = isResubscribe || false;\n if (this._ready === true) {\n // new promise for this subscription\n this._initializePromise();\n }\n this._status = _STATE_SUBSCRIBING;\n };\n\n _setSubscribeSuccess(recovered) {\n if (this._status === _STATE_SUCCESS) {\n return;\n }\n this._status = _STATE_SUCCESS;\n const successContext = this._getSubscribeSuccessContext(recovered);\n\n this._recover = false;\n this.emit('subscribe', successContext);\n this._resolve(successContext);\n for (const id in this._promises) {\n clearTimeout(this._promises[id].timeout);\n this._promises[id].resolve();\n delete this._promises[id];\n }\n };\n\n _setSubscribeError(err) {\n if (this._status === _STATE_ERROR) {\n return;\n }\n this._status = _STATE_ERROR;\n this._error = err;\n const errContext = this._getSubscribeErrorContext();\n this.emit('error', errContext);\n this._reject(errContext);\n for (const id in this._promises) {\n clearTimeout(this._promises[id].timeout);\n this._promises[id].reject(err);\n delete this._promises[id];\n }\n };\n\n _triggerUnsubscribe() {\n this.emit('unsubscribe', {\n channel: this.channel\n });\n };\n\n _setUnsubscribed(noResubscribe) {\n this._centrifuge._clearSubRefreshTimeout(this.channel);\n if (this._status === _STATE_UNSUBSCRIBED) {\n return;\n }\n const needTrigger = this._status === _STATE_SUCCESS;\n this._status = _STATE_UNSUBSCRIBED;\n if (noResubscribe === true) {\n this._recover = false;\n this._noResubscribe = true;\n delete this._centrifuge._lastSeq[this.channel];\n delete this._centrifuge._lastGen[this.channel];\n delete this._centrifuge._lastEpoch[this.channel];\n }\n if (needTrigger) {\n this._triggerUnsubscribe();\n }\n };\n\n _shouldResubscribe() {\n return !this._noResubscribe;\n };\n\n _getSubscribeSuccessContext(recovered) {\n return {\n channel: this.channel,\n isResubscribe: this._isResubscribe,\n recovered: recovered\n };\n };\n\n _getSubscribeErrorContext() {\n const subscribeErrorContext = this._error;\n subscribeErrorContext.channel = this.channel;\n subscribeErrorContext.isResubscribe = this._isResubscribe;\n return subscribeErrorContext;\n };\n\n ready(callback, errback) {\n if (this._ready) {\n if (this._isSuccess()) {\n callback(this._getSubscribeSuccessContext());\n } else {\n errback(this._getSubscribeErrorContext());\n }\n }\n };\n\n subscribe() {\n if (this._status === _STATE_SUCCESS) {\n return;\n }\n this._noResubscribe = false;\n this._centrifuge._subscribe(this);\n };\n\n unsubscribe() {\n this._setUnsubscribed(true);\n this._centrifuge._unsubscribe(this);\n };\n\n _methodCall(message, type) {\n const methodCallPromise = new Promise((resolve, reject) => {\n let subPromise;\n if (this._isSuccess()) {\n subPromise = Promise.resolve();\n } else if (this._isError()) {\n subPromise = Promise.reject(this._error);\n } else {\n subPromise = new Promise((res, rej) => {\n const timeout = setTimeout(function () {\n rej({'code': 0, 'message': 'timeout'});\n }, this._centrifuge._config.timeout);\n this._promises[this._nextPromiseId()] = {\n timeout: timeout,\n resolve: res,\n reject: rej\n };\n });\n }\n subPromise.then(\n () => {\n return this._centrifuge._call(message).then(\n resolveCtx => {\n resolve(this._centrifuge._decoder.decodeCommandResult(type, resolveCtx.result));\n if (resolveCtx.next) {\n resolveCtx.next();\n }\n },\n rejectCtx => {\n reject(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n }\n );\n },\n error => {\n reject(error);\n }\n );\n });\n return methodCallPromise;\n }\n\n publish(data) {\n return this._methodCall({\n method: this._centrifuge._methodType.PUBLISH,\n params: {\n channel: this.channel,\n data: data\n }\n }, this._centrifuge._methodType.PUBLISH);\n };\n\n presence() {\n return this._methodCall({\n method: this._centrifuge._methodType.PRESENCE,\n params: {\n channel: this.channel\n }\n }, this._centrifuge._methodType.PRESENCE);\n };\n\n presenceStats() {\n return this._methodCall({\n method: this._centrifuge._methodType.PRESENCE_STATS,\n params: {\n channel: this.channel\n }\n }, this._centrifuge._methodType.PRESENCE_STATS);\n };\n\n history() {\n return this._methodCall({\n method: this._centrifuge._methodType.HISTORY,\n params: {\n channel: this.channel\n }\n }, this._centrifuge._methodType.HISTORY);\n };\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/subscription.js","export const JsonMethodType = {\n CONNECT: 0,\n SUBSCRIBE: 1,\n UNSUBSCRIBE: 2,\n PUBLISH: 3,\n PRESENCE: 4,\n PRESENCE_STATS: 5,\n HISTORY: 6,\n PING: 7,\n SEND: 8,\n RPC: 9,\n REFRESH: 10,\n SUB_REFRESH: 11\n};\n\nexport const JsonPushType = {\n PUBLICATION: 0,\n JOIN: 1,\n LEAVE: 2,\n UNSUB: 3,\n MESSAGE: 4,\n SUB: 5\n};\n\nexport class JsonEncoder {\n encodeCommands(commands) {\n const encodedCommands = [];\n for (const i in commands) {\n if (commands.hasOwnProperty(i)) {\n encodedCommands.push(JSON.stringify(commands[i]));\n }\n }\n return encodedCommands.join('\\n');\n }\n}\n\nexport class JsonDecoder {\n decodeReplies(data) {\n const replies = [];\n const encodedReplies = data.split('\\n');\n for (const i in encodedReplies) {\n if (encodedReplies.hasOwnProperty(i)) {\n if (!encodedReplies[i]) {\n continue;\n }\n const reply = JSON.parse(encodedReplies[i]);\n replies.push(reply);\n }\n }\n return replies;\n }\n\n decodeCommandResult(methodType, data) {\n return data;\n }\n\n decodePush(data) {\n return data;\n }\n\n decodePushData(pushType, data) {\n return data;\n }\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/json.js","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 3\n// module chunks = 0 1","import {Centrifuge} from './centrifuge.js';\nexport default Centrifuge;\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction $getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return $getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = $getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n ReflectApply(this.listener, this.target, args);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/events/events.js\n// module id = 6\n// module chunks = 0 1","export function startsWith(value, prefix) {\n return value.lastIndexOf(prefix, 0) === 0;\n};\n\nexport function isFunction(value) {\n if (value === undefined || value === null) {\n return false;\n }\n return typeof value === 'function';\n};\n\nexport function log(level, args) {\n if (global.console) {\n const logger = global.console[level];\n\n if (isFunction(logger)) {\n logger.apply(global.console, args);\n }\n }\n};\n\nexport function backoff(step, min, max) {\n const jitter = 0.5 * Math.random();\n const interval = Math.min(max, min * Math.pow(2, step + 1));\n\n return Math.floor((1 - jitter) * interval);\n};\n\nexport function errorExists(data) {\n return 'error' in data && data.error !== null;\n};\n\nexport function extend(a, b) {\n for (const key in b) {\n if (b.hasOwnProperty(key)) {\n a[key] = b[key];\n }\n }\n return a;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js"],"sourceRoot":""}