New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pusher-js

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pusher-js - npm Package Compare versions

Comparing version 8.4.0-rc2 to 8.4.0

src/runtimes/web/dom/sockjs/bin/render.coffee

9

CHANGELOG.md
# Changelog
## 8.4.0-rc2
## 8.4.0
- [FIXED] Persist Initial Pusher Options
- [FIXED] Authorization Custom Handler typing https://github.com/pusher/pusher-js/issues/715
- [CHANGED] Dependencies minor versions updated to latest versions
## 8.4.0-rc1
- [Added] Introduce a new method to switch the Pusher client to a different cluster and re-establish all existing subscriptions and channel bindings.
## 8.3.0

@@ -13,0 +8,0 @@

/*!
* Pusher JavaScript Library v8.4.0-rc2
* Pusher JavaScript Library v8.4.0
* https://pusher.com/

@@ -8,3 +8,3 @@ *

*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n<t.length-2;n+=3){var i=t[n]<<16|t[n+1]<<8|t[n+2];e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s<n-4;s+=4)a=this._decodeChar(t.charCodeAt(s+0)),c=this._decodeChar(t.charCodeAt(s+1)),h=this._decodeChar(t.charCodeAt(s+2)),u=this._decodeChar(t.charCodeAt(s+3)),i[r++]=a<<2|c>>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s<n-1&&(a=this._decodeChar(t.charCodeAt(s)),c=this._decodeChar(t.charCodeAt(s+1)),i[r++]=a<<2|c>>>4,o|=256&a,o|=256&c),s<n-2&&(h=this._decodeChar(t.charCodeAt(s+2)),i[r++]=c<<4|h>>>2,o|=256&h),s<n-3&&(u=this._decodeChar(t.charCodeAt(s+3)),i[r++]=h<<6|u,o|=256&u),0!==o)throw new Error("Base64Coder: incorrect characters for decoding");return i},t.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);if(i<128)e+=1;else if(i<2048)e+=2;else if(i<55296)e+=3;else{if(!(i<=57343))throw new Error("utf8: invalid string");if(n>=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?e[n++]=s:s<2048?(e[n++]=192|s>>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];if(128&r){var s=void 0;if(r<224){if(n>=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r<s||r>=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0-rc2",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a<n.length;a++)n[a](e,o)}}));r.send(s)}}getRoot(t){var e=ue.getDocument().location.protocol;return(t&&t.useTLS||"https:"===e?this.options.cdn_https:this.options.cdn_http).replace(/\/*$/,"")+"/"+this.options.version}getPath(t,e){return this.getRoot(e)+"/"+t+this.options.suffix+".js"}}({cdn_http:s.cdn_http,cdn_https:s.cdn_https,version:s.VERSION,suffix:s.dependency_suffix,receivers:o});const c={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var h,u=function(t){const e=c.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=c.baseUrl+e.path),n?"See: "+n:""};!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(h||(h={}));class l extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class d extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class p extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class f extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class g extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class v extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class b extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class m extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class y extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}var w=function(t,e,n,i,r){const s=ue.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){r(new y(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&r(null,t)}else{let t="";switch(i){case h.UserAuthentication:t=u("authenticationEndpoint");break;case h.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+u("authorizationEndpoint")}r(new y(s.status,`Unable to retrieve auth string from ${i.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s};for(var S=String.fromCharCode,_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k={},C=0,T=_.length;C<T;C++)k[_.charAt(C)]=C;var P=function(t){var e=t.charCodeAt(0);return e<128?t:e<2048?S(192|e>>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n<e.length;n++){var i=e[n];for(var r in i)i[r]&&i[r].constructor&&i[r].constructor===Object?t[r]=N(t[r]||{},i[r]):t[r]=i[r]}return t}function U(){for(var t=["Pusher"],e=0;e<arguments.length;e++)"string"==typeof arguments[e]?t.push(arguments[e]):t.push(G(arguments[e]));return t.join(" : ")}function H(t,e){var n=Array.prototype.indexOf;if(null===t)return-1;if(n&&t.indexOf===n)return t.indexOf(e);for(var i=0,r=t.length;i<r;i++)if(t[i]===e)return i;return-1}function M(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(t[n],n,t)}function z(t){var e=[];return M(t,(function(t,n){e.push(n)})),e}function q(t,e,n){for(var i=0;i<t.length;i++)e.call(n||window,t[i],i,t)}function B(t,e){for(var n=[],i=0;i<t.length;i++)n.push(e(t[i],i,t,n));return n}function F(t,e){e=e||function(t){return!!t};for(var n=[],i=0;i<t.length;i++)e(t[i],i,t,n)&&n.push(t[i]);return n}function X(t,e){var n={};return M(t,(function(i,r){(e&&e(i,r,t,n)||Boolean(i))&&(n[r]=i)})),n}function J(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1}function $(t){return e=function(t){return"object"==typeof t&&(t=G(t)),encodeURIComponent((e=t.toString(),x(E(e))));var e},n={},M(t,(function(t,i){n[i]=e(t)})),n;var e,n}function W(t){var e,n,i=X(t,(function(t){return void 0!==t}));return B((e=$(i),n=[],M(e,(function(t,e){n.push([e,t])})),n),j.method("join","=")).join("&")}function G(t){try{return JSON.stringify(t)}catch(i){return JSON.stringify((e=[],n=[],function t(i,r){var s,o,a;switch(typeof i){case"object":if(!i)return null;for(s=0;s<e.length;s+=1)if(e[s]===i)return{$ref:n[s]};if(e.push(i),n.push(r),"[object Array]"===Object.prototype.toString.apply(i))for(a=[],s=0;s<i.length;s+=1)a[s]=t(i[s],r+"["+s+"]");else for(o in a={},i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=t(i[o],r+"["+JSON.stringify(o)+"]"));return a;case"number":case"string":case"boolean":return i}}(t,"$")))}var e,n}var V=new class{constructor(){this.globalLog=t=>{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=U.apply(this,arguments);if(Ie.log)Ie.log(n);else if(Ie.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class K{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Q{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i<this.global_callbacks.length;i++)this.global_callbacks[i](t,e);var r=this.callbacks.get(t),s=[];if(n?s.push(e,n):e&&s.push(e),r&&r.length>0)for(i=0;i<r.length;i++)r[i].fn.apply(r[i].context||window,s);else this.failThrough&&this.failThrough(t,e);return this}}class ct extends at{constructor(t,e,n,i,r){super(),this.initialize=ue.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=r,this.state="new",this.timeline=r.timeline,this.activityTimeout=r.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return j.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},mt=new ht(N({},dt,bt)),yt=new ht(N({},pt,bt));gt.xdr_streaming=mt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length<this.nacl.secretbox.overheadLength)return void V.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${n.length}`);let i=Object(Dt.decode)(e.nonce);if(i.length<this.nacl.secretbox.nonceLength)return void V.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${i.length}`);let r=this.nacl.secretbox.open(n,i,this.key);if(null===r)return V.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),void this.authorize(this.pusher.connection.socket_id,(e,s)=>{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ut{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ht.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ht.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ht.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ht.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ht={createChannels:()=>new Ut,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ht.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i<n.length?(r&&(r*=2,this.timeoutLimit&&(r=Math.min(r,this.timeoutLimit))),s=this.tryStrategy(n[i],t,{timeout:r,failFast:this.failFast},o)):e(!0))};return s=this.tryStrategy(n[i],t,{timeout:r,failFast:this.failFast},o),{abort:function(){s.abort()},forceMinPriority:function(e){t=e,s&&s.forceMinPriority(e)}}}tryStrategy(t,e,n,i){var r=null,s=null;return n.timeout>0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0}(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(q(n,(function(t){t.forceMinPriority(r.transport.priority)})),e(null,r))}}))}}function Bt(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Ft{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=ue.getLocalStorage();if(e)try{var n=e[Xt(t)];if(n)return JSON.parse(n)}catch(e){Jt(t)}return null}(n),r=i&&i.cacheSkipCount?i.cacheSkipCount:0,s=[this.strategy];if(i&&i.timestamp+this.ttl>=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),b=r("xhr_polling","xhr_polling",1,c),m=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(b),b,m)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Kt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Qt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n<t;n++)e.push(ie(32).toString(32));return e.join("")}(8),this.location=function(t){var e=/([^\?]*)\/*(\??.*)/.exec(t);return{base:e[1],queryString:e[2]}}(e),this.readyState=te.CONNECTING,this.openStream()}send(t){return this.sendRaw(JSON.stringify([t]))}ping(){this.hooks.sendHeartbeat(this)}close(t,e){this.onClose(t,e,!0)}sendRaw(t){if(this.readyState!==te.OPEN)return!1;try{return ue.createSocketRequest("POST",ne((e=this.location,n=this.session,e.base+"/"+n+"/xhr_send"))).start(t),!0}catch(t){return!1}var e,n}reconnect(){this.closeStream(),this.openStream()}onClose(t,e,n){this.closeStream(),this.readyState=te.CLOSED,this.onclose&&this.onclose({code:t,reason:e,wasClean:n})}onChunk(t){var e;if(200===t.status)switch(this.readyState===te.OPEN&&this.onActivity(),t.data.slice(0,1)){case"o":e=JSON.parse(t.data.slice(1)||"{}"),this.onOpen(e);break;case"a":e=JSON.parse(t.data.slice(1)||"[]");for(var n=0;n<e.length;n++)this.onEvent(e[n]);break;case"m":e=JSON.parse(t.data.slice(1)||"null"),this.onEvent(e);break;case"h":this.hooks.onHeartbeat(this);break;case"c":e=JSON.parse(t.data.slice(1)||"[]"),this.onClose(e[0],e[1],!0)}}onOpen(t){var e,n,i;this.readyState===te.CONNECTING?(t&&t.hostname&&(this.location.base=(e=this.location.base,n=t.hostname,(i=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(e))[1]+n+i[3])),this.readyState=te.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(t){this.readyState===te.OPEN&&this.onmessage&&this.onmessage({data:t})}onActivity(){this.onactivity&&this.onactivity()}onError(t){this.onerror&&this.onerror(t)}openStream(){this.stream=ue.createSocketRequest("POST",ne(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",t=>{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Qt(t,e,n),createXDR:function(t,e){return this.createRequest(Kt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Q(t,e),createScriptRequest:t=>new K(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new m,e);if(this.priority<t)return fe(new f,e);var n=!1,i=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),r=null,s=function(){i.unbind("initialized",s),i.connect()},o=function(){r=Ht.createHandshake(i,(function(t){n=!0,h(),e(null,t)}))},a=function(t){h(),e(t)},c=function(){var t;h(),t=G(i),e(new g(t))},h=function(){i.unbind("initialized",s),i.unbind("open",o),i.unbind("error",a),i.unbind("closed",c)};return i.bind("initialized",s),i.bind("open",o),i.bind("error",a),i.bind("closed",c),i.initialize(),{abort:()=>{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority<t&&(r?r.close():i.close())}}}}function fe(t,e){return j.defer((function(){e(t)})),{abort:function(){},forceMinPriority:function(){}}}const{Transports:ge}=ue;var ve=function(t,e,n,i,r,s){var o,a=ge[n];if(!a)throw new b(n);return!(t.enabledTransports&&-1===H(t.enabledTransports,e)||t.disabledTransports&&-1!==H(t.disabledTransports,e))?(r=Object.assign({ignoreNullOrigin:t.ignoreNullOrigin},r),o=new pe(e,i,s?s.getAssistant(a):a,r)):o=be,o},be={isSupported:function(){return!1},connect:function(t,e){var n=j.defer((function(){e(new m)}));return{abort:function(){n.ensureAborted()},forceMinPriority:function(){}}}};var me=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};const we=(t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}};function Se(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Te(t),httpHost:_e(t),useTLS:Ce(t),wsHost:ke(t),userAuthenticator:Ee(t),channelAuthorizer:Oe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function _e(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function ke(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Ce(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const Pe=t=>"customHandler"in t&&null!=t.customHandler;function Ee(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return Pe(e)?e.customHandler:me(e)}function Oe(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:we(e,n,t.authorizer)};return n}(t,e);return Pe(n)?n.customHandler:ye(n)}class xe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Le=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Ae extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new xe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Le();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Re{static ready(){Re.isReady=!0;for(var t=0,e=Re.instances.length;t<e;t++)Re.instances[t].connect()}static getClientFeatures(){return z(X({ws:ue.Transports.ws},(function(t){return t.isSupported({})})))}constructor(t,e){!function(t){if(null==t)throw"You must pass your app key when you instantiate Pusher."}(t),function(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&V.warn("The disableStats option is deprecated in favor of enableStats")}(e),this.key=t,this.options=e,this.config=Se(this.options,this),this.channels=Ht.createChannels(),this.global_emitter=new at,this.sessionID=ue.randomInt(1e9),this.timeline=new de(this.key,this.sessionID,{cluster:this.config.cluster,features:Re.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:le.INFO,version:s.VERSION}),this.config.enableStats&&(this.timelineSender=Ht.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+ue.TimelineTransport.name}));this.connection=Ht.createConnectionManager(this.key,{getStrategy:t=>ue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),Re.instances.push(this),this.timeline.info({instances:Re.instances.length}),this.user=new Ae(this),Re.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Se(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Re.instances=[],Re.isReady=!1,Re.logToConsole=!1,Re.Runtime=ue,Re.ScriptReceivers=ue.ScriptReceivers,Re.DependenciesReceivers=ue.DependenciesReceivers,Re.auth_callbacks=ue.auth_callbacks;var Ie=e.default=Re;ue.setup(Re)}])}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n<t.length-2;n+=3){var i=t[n]<<16|t[n+1]<<8|t[n+2];e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s<n-4;s+=4)a=this._decodeChar(t.charCodeAt(s+0)),c=this._decodeChar(t.charCodeAt(s+1)),h=this._decodeChar(t.charCodeAt(s+2)),u=this._decodeChar(t.charCodeAt(s+3)),i[r++]=a<<2|c>>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s<n-1&&(a=this._decodeChar(t.charCodeAt(s)),c=this._decodeChar(t.charCodeAt(s+1)),i[r++]=a<<2|c>>>4,o|=256&a,o|=256&c),s<n-2&&(h=this._decodeChar(t.charCodeAt(s+2)),i[r++]=c<<4|h>>>2,o|=256&h),s<n-3&&(u=this._decodeChar(t.charCodeAt(s+3)),i[r++]=h<<6|u,o|=256&u),0!==o)throw new Error("Base64Coder: incorrect characters for decoding");return i},t.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);if(i<128)e+=1;else if(i<2048)e+=2;else if(i<55296)e+=3;else{if(!(i<=57343))throw new Error("utf8: invalid string");if(n>=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?e[n++]=s:s<2048?(e[n++]=192|s>>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];if(128&r){var s=void 0;if(r<224){if(n>=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r<s||r>=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a<n.length;a++)n[a](e,o)}}));r.send(s)}}getRoot(t){var e=ue.getDocument().location.protocol;return(t&&t.useTLS||"https:"===e?this.options.cdn_https:this.options.cdn_http).replace(/\/*$/,"")+"/"+this.options.version}getPath(t,e){return this.getRoot(e)+"/"+t+this.options.suffix+".js"}}({cdn_http:s.cdn_http,cdn_https:s.cdn_https,version:s.VERSION,suffix:s.dependency_suffix,receivers:o});const c={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var h,u=function(t){const e=c.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=c.baseUrl+e.path),n?"See: "+n:""};!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(h||(h={}));class l extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class d extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class p extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class f extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class g extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class v extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class m extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class b extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class y extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}var w=function(t,e,n,i,r){const s=ue.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){r(new y(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&r(null,t)}else{let t="";switch(i){case h.UserAuthentication:t=u("authenticationEndpoint");break;case h.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+u("authorizationEndpoint")}r(new y(s.status,`Unable to retrieve auth string from ${i.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s};for(var S=String.fromCharCode,_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k={},C=0,T=_.length;C<T;C++)k[_.charAt(C)]=C;var P=function(t){var e=t.charCodeAt(0);return e<128?t:e<2048?S(192|e>>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n<e.length;n++){var i=e[n];for(var r in i)i[r]&&i[r].constructor&&i[r].constructor===Object?t[r]=N(t[r]||{},i[r]):t[r]=i[r]}return t}function H(){for(var t=["Pusher"],e=0;e<arguments.length;e++)"string"==typeof arguments[e]?t.push(arguments[e]):t.push(G(arguments[e]));return t.join(" : ")}function U(t,e){var n=Array.prototype.indexOf;if(null===t)return-1;if(n&&t.indexOf===n)return t.indexOf(e);for(var i=0,r=t.length;i<r;i++)if(t[i]===e)return i;return-1}function M(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(t[n],n,t)}function z(t){var e=[];return M(t,(function(t,n){e.push(n)})),e}function q(t,e,n){for(var i=0;i<t.length;i++)e.call(n||window,t[i],i,t)}function B(t,e){for(var n=[],i=0;i<t.length;i++)n.push(e(t[i],i,t,n));return n}function F(t,e){e=e||function(t){return!!t};for(var n=[],i=0;i<t.length;i++)e(t[i],i,t,n)&&n.push(t[i]);return n}function X(t,e){var n={};return M(t,(function(i,r){(e&&e(i,r,t,n)||Boolean(i))&&(n[r]=i)})),n}function J(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1}function $(t){return e=function(t){return"object"==typeof t&&(t=G(t)),encodeURIComponent((e=t.toString(),x(E(e))));var e},n={},M(t,(function(t,i){n[i]=e(t)})),n;var e,n}function W(t){var e,n,i=X(t,(function(t){return void 0!==t}));return B((e=$(i),n=[],M(e,(function(t,e){n.push([e,t])})),n),j.method("join","=")).join("&")}function G(t){try{return JSON.stringify(t)}catch(i){return JSON.stringify((e=[],n=[],function t(i,r){var s,o,a;switch(typeof i){case"object":if(!i)return null;for(s=0;s<e.length;s+=1)if(e[s]===i)return{$ref:n[s]};if(e.push(i),n.push(r),"[object Array]"===Object.prototype.toString.apply(i))for(a=[],s=0;s<i.length;s+=1)a[s]=t(i[s],r+"["+s+"]");else for(o in a={},i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=t(i[o],r+"["+JSON.stringify(o)+"]"));return a;case"number":case"string":case"boolean":return i}}(t,"$")))}var e,n}var V=new class{constructor(){this.globalLog=t=>{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=H.apply(this,arguments);if(Le.log)Le.log(n);else if(Le.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class Q{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class K{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i<this.global_callbacks.length;i++)this.global_callbacks[i](t,e);var r=this.callbacks.get(t),s=[];if(n?s.push(e,n):e&&s.push(e),r&&r.length>0)for(i=0;i<r.length;i++)r[i].fn.apply(r[i].context||window,s);else this.failThrough&&this.failThrough(t,e);return this}}class ct extends at{constructor(t,e,n,i,r){super(),this.initialize=ue.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=r,this.state="new",this.timeline=r.timeline,this.activityTimeout=r.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return j.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),mt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},bt=new ht(N({},dt,mt)),yt=new ht(N({},pt,mt));gt.xdr_streaming=bt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length<this.nacl.secretbox.overheadLength)return void V.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${n.length}`);let i=Object(Dt.decode)(e.nonce);if(i.length<this.nacl.secretbox.nonceLength)return void V.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${i.length}`);let r=this.nacl.secretbox.open(n,i,this.key);if(null===r)return V.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),void this.authorize(this.pusher.connection.socket_id,(e,s)=>{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ht{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ut.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ut.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ut.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ut.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ut={createChannels:()=>new Ht,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ut.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i<n.length?(r&&(r*=2,this.timeoutLimit&&(r=Math.min(r,this.timeoutLimit))),s=this.tryStrategy(n[i],t,{timeout:r,failFast:this.failFast},o)):e(!0))};return s=this.tryStrategy(n[i],t,{timeout:r,failFast:this.failFast},o),{abort:function(){s.abort()},forceMinPriority:function(e){t=e,s&&s.forceMinPriority(e)}}}tryStrategy(t,e,n,i){var r=null,s=null;return n.timeout>0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0}(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(q(n,(function(t){t.forceMinPriority(r.transport.priority)})),e(null,r))}}))}}function Bt(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Ft{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=ue.getLocalStorage();if(e)try{var n=e[Xt(t)];if(n)return JSON.parse(n)}catch(e){Jt(t)}return null}(n),r=i&&i.cacheSkipCount?i.cacheSkipCount:0,s=[this.strategy];if(i&&i.timestamp+this.ttl>=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),m=r("xhr_polling","xhr_polling",1,c),b=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(m),m,b)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Qt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Kt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n<t;n++)e.push(ie(32).toString(32));return e.join("")}(8),this.location=function(t){var e=/([^\?]*)\/*(\??.*)/.exec(t);return{base:e[1],queryString:e[2]}}(e),this.readyState=te.CONNECTING,this.openStream()}send(t){return this.sendRaw(JSON.stringify([t]))}ping(){this.hooks.sendHeartbeat(this)}close(t,e){this.onClose(t,e,!0)}sendRaw(t){if(this.readyState!==te.OPEN)return!1;try{return ue.createSocketRequest("POST",ne((e=this.location,n=this.session,e.base+"/"+n+"/xhr_send"))).start(t),!0}catch(t){return!1}var e,n}reconnect(){this.closeStream(),this.openStream()}onClose(t,e,n){this.closeStream(),this.readyState=te.CLOSED,this.onclose&&this.onclose({code:t,reason:e,wasClean:n})}onChunk(t){var e;if(200===t.status)switch(this.readyState===te.OPEN&&this.onActivity(),t.data.slice(0,1)){case"o":e=JSON.parse(t.data.slice(1)||"{}"),this.onOpen(e);break;case"a":e=JSON.parse(t.data.slice(1)||"[]");for(var n=0;n<e.length;n++)this.onEvent(e[n]);break;case"m":e=JSON.parse(t.data.slice(1)||"null"),this.onEvent(e);break;case"h":this.hooks.onHeartbeat(this);break;case"c":e=JSON.parse(t.data.slice(1)||"[]"),this.onClose(e[0],e[1],!0)}}onOpen(t){var e,n,i;this.readyState===te.CONNECTING?(t&&t.hostname&&(this.location.base=(e=this.location.base,n=t.hostname,(i=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(e))[1]+n+i[3])),this.readyState=te.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(t){this.readyState===te.OPEN&&this.onmessage&&this.onmessage({data:t})}onActivity(){this.onactivity&&this.onactivity()}onError(t){this.onerror&&this.onerror(t)}openStream(){this.stream=ue.createSocketRequest("POST",ne(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",t=>{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Kt(t,e,n),createXDR:function(t,e){return this.createRequest(Qt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new K(t,e),createScriptRequest:t=>new Q(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new b,e);if(this.priority<t)return fe(new f,e);var n=!1,i=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),r=null,s=function(){i.unbind("initialized",s),i.connect()},o=function(){r=Ut.createHandshake(i,(function(t){n=!0,h(),e(null,t)}))},a=function(t){h(),e(t)},c=function(){var t;h(),t=G(i),e(new g(t))},h=function(){i.unbind("initialized",s),i.unbind("open",o),i.unbind("error",a),i.unbind("closed",c)};return i.bind("initialized",s),i.bind("open",o),i.bind("error",a),i.bind("closed",c),i.initialize(),{abort:()=>{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority<t&&(r?r.close():i.close())}}}}function fe(t,e){return j.defer((function(){e(t)})),{abort:function(){},forceMinPriority:function(){}}}const{Transports:ge}=ue;var ve=function(t,e,n,i,r,s){var o,a=ge[n];if(!a)throw new m(n);return!(t.enabledTransports&&-1===U(t.enabledTransports,e)||t.disabledTransports&&-1!==U(t.disabledTransports,e))?(r=Object.assign({ignoreNullOrigin:t.ignoreNullOrigin},r),o=new pe(e,i,s?s.getAssistant(a):a,r)):o=me,o},me={isSupported:function(){return!1},connect:function(t,e){var n=j.defer((function(){e(new b)}));return{abort:function(){n.ensureAborted()},forceMinPriority:function(){}}}};var be=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};function we(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function ke(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Te(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Pe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ee=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Oe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ee();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class xe{static ready(){xe.isReady=!0;for(var t=0,e=xe.instances.length;t<e;t++)xe.instances[t].connect()}static getClientFeatures(){return z(X({ws:ue.Transports.ws},(function(t){return t.isSupported({})})))}constructor(t,e){!function(t){if(null==t)throw"You must pass your app key when you instantiate Pusher."}(t),function(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&V.warn("The disableStats option is deprecated in favor of enableStats")}(e),this.key=t,this.config=function(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:ke(t),httpHost:we(t),useTLS:_e(t),wsHost:Se(t),userAuthenticator:Ce(t),channelAuthorizer:Te(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}(e,this),this.channels=Ut.createChannels(),this.global_emitter=new at,this.sessionID=ue.randomInt(1e9),this.timeline=new de(this.key,this.sessionID,{cluster:this.config.cluster,features:xe.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:le.INFO,version:s.VERSION}),this.config.enableStats&&(this.timelineSender=Ut.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+ue.TimelineTransport.name}));this.connection=Ut.createConnectionManager(this.key,{getStrategy:t=>ue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),xe.instances.push(this),this.timeline.info({instances:xe.instances.length}),this.user=new Oe(this),xe.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}xe.instances=[],xe.isReady=!1,xe.logToConsole=!1,xe.Runtime=ue,xe.ScriptReceivers=ue.ScriptReceivers,xe.DependenciesReceivers=ue.DependenciesReceivers,xe.auth_callbacks=ue.auth_callbacks;var Le=e.default=xe;ue.setup(xe)}])}));
//# sourceMappingURL=pusher.min.js.map
/*!
* Pusher JavaScript Library v8.4.0-rc2
* Pusher JavaScript Library v8.4.0
* https://pusher.com/

@@ -8,3 +8,3 @@ *

*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n<t.length-2;n+=3){var i=t[n]<<16|t[n+1]<<8|t[n+2];e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r<n-4;r+=4)a=this._decodeChar(t.charCodeAt(r+0)),c=this._decodeChar(t.charCodeAt(r+1)),h=this._decodeChar(t.charCodeAt(r+2)),u=this._decodeChar(t.charCodeAt(r+3)),i[s++]=a<<2|c>>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r<n-1&&(a=this._decodeChar(t.charCodeAt(r)),c=this._decodeChar(t.charCodeAt(r+1)),i[s++]=a<<2|c>>>4,o|=256&a,o|=256&c),r<n-2&&(h=this._decodeChar(t.charCodeAt(r+2)),i[s++]=c<<4|h>>>2,o|=256&h),r<n-3&&(u=this._decodeChar(t.charCodeAt(r+3)),i[s++]=h<<6|u,o|=256&u),0!==o)throw new Error("Base64Coder: incorrect characters for decoding");return i},t.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);if(i<128)e+=1;else if(i<2048)e+=2;else if(i<55296)e+=3;else{if(!(i<=57343))throw new Error("utf8: invalid string");if(n>=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i<t.length;i++){var r=t.charCodeAt(i);r<128?e[n++]=r:r<2048?(e[n++]=192|r>>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n<t.length;n++){var s=t[n];if(128&s){var r=void 0;if(s<224){if(n>=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s<r||s>=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o<a;o++)r[s.charAt(o)]=o;var c=function(t){var e=t.charCodeAt(0);return e<128?t:e<2048?i(192|e>>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;n<e.length;n++){var i=e[n];for(var s in i)i[s]&&i[s].constructor&&i[s].constructor===Object?t[s]=v(t[s]||{},i[s]):t[s]=i[s]}return t}function y(){for(var t=["Pusher"],e=0;e<arguments.length;e++)"string"==typeof arguments[e]?t.push(arguments[e]):t.push(L(arguments[e]));return t.join(" : ")}function S(t,e){var n=Array.prototype.indexOf;if(null===t)return-1;if(n&&t.indexOf===n)return t.indexOf(e);for(var i=0,s=t.length;i<s;i++)if(t[i]===e)return i;return-1}function _(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(t[n],n,t)}function w(t){var e=[];return _(t,(function(t,n){e.push(n)})),e}function C(t,e,n){for(var i=0;i<t.length;i++)e.call(n||self,t[i],i,t)}function k(t,e){for(var n=[],i=0;i<t.length;i++)n.push(e(t[i],i,t,n));return n}function T(t,e){e=e||function(t){return!!t};for(var n=[],i=0;i<t.length;i++)e(t[i],i,t,n)&&n.push(t[i]);return n}function P(t,e){var n={};return _(t,(function(i,s){(e&&e(i,s,t,n)||Boolean(i))&&(n[s]=i)})),n}function O(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1}function E(t){return e=function(t){return"object"==typeof t&&(t=L(t)),encodeURIComponent((e=t.toString(),l(h(e))));var e},n={},_(t,(function(t,i){n[i]=e(t)})),n;var e,n}function x(t){var e,n,i=P(t,(function(t){return void 0!==t}));return k((e=E(i),n=[],_(e,(function(t,e){n.push([e,t])})),n),m.method("join","=")).join("&")}function L(t){try{return JSON.stringify(t)}catch(i){return JSON.stringify((e=[],n=[],function t(i,s){var r,o,a;switch(typeof i){case"object":if(!i)return null;for(r=0;r<e.length;r+=1)if(e[r]===i)return{$ref:n[r]};if(e.push(i),n.push(s),"[object Array]"===Object.prototype.toString.apply(i))for(a=[],r=0;r<i.length;r+=1)a[r]=t(i[r],s+"["+r+"]");else for(o in a={},i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=t(i[o],s+"["+JSON.stringify(o)+"]"));return a;case"number":case"string":case"boolean":return i}}(t,"$")))}var e,n}var A={VERSION:"8.4.0-rc2",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};function R(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function I(t,e){return"/app/"+t+("?protocol="+A.PROTOCOL+"&client=js&version="+A.VERSION+(e?"&"+e:""))}var j={getInitial:function(t,e){return R("ws",e,(e.httpPath||"")+I(t,"flash=false"))}},D={getInitial:function(t,e){return R("http",e,(e.httpPath||"/pusher")+I(t))}};class N{constructor(){this._callbacks={}}get(t){return this._callbacks[U(t)]}add(t,e,n){var i=U(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[U(t)]:w(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){C(t,(function(t){this._callbacks[t]=T(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){C(t,(function(t){delete this._callbacks[t]}),this)}}function U(t){return"_"+t}class H{constructor(t){this.callbacks=new N,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=T(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i<this.global_callbacks.length;i++)this.global_callbacks[i](t,e);var s=this.callbacks.get(t),r=[];if(n?r.push(e,n):e&&r.push(e),s&&s.length>0)for(i=0;i<s.length;i++)s[i].fn.apply(s[i].context||self,r);else this.failThrough&&this.failThrough(t,e);return this}}var M=new class{constructor(){this.globalLog=t=>{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(Ae.log)Ae.log(n);else if(Ae.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:j,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:D,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class K extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Q{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new K(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length<this.nacl.secretbox.overheadLength)return void M.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${n.length}`);let i=Object(bt.decode)(e.nonce);if(i.length<this.nacl.secretbox.nonceLength)return void M.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${i.length}`);let s=this.nacl.secretbox.open(n,i,this.key);if(null===s)return M.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),void this.authorize(this.pusher.connection.socket_id,(e,r)=>{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new Q(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i<n.length?(s&&(s*=2,this.timeoutLimit&&(s=Math.min(s,this.timeoutLimit))),r=this.tryStrategy(n[i],t,{timeout:s,failFast:this.failFast},o)):e(!0))};return r=this.tryStrategy(n[i],t,{timeout:s,failFast:this.failFast},o),{abort:function(){r.abort()},forceMinPriority:function(e){t=e,r&&r.forceMinPriority(e)}}}tryStrategy(t,e,n,i){var s=null,r=null;return n.timeout>0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0}(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(C(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function kt(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Tt{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=ae.getLocalStorage();if(e)try{var n=e[Pt(t)];if(n)return JSON.parse(n)}catch(e){Ot(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,r=[this.strategy];if(i&&i.timestamp+this.ttl>=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var jt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(jt||(jt={}));var Dt=jt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n<t;n++)e.push(Ht(32).toString(32));return e.join("")}(8),this.location=function(t){var e=/([^\?]*)\/*(\??.*)/.exec(t);return{base:e[1],queryString:e[2]}}(e),this.readyState=Dt.CONNECTING,this.openStream()}send(t){return this.sendRaw(JSON.stringify([t]))}ping(){this.hooks.sendHeartbeat(this)}close(t,e){this.onClose(t,e,!0)}sendRaw(t){if(this.readyState!==Dt.OPEN)return!1;try{return ae.createSocketRequest("POST",Ut((e=this.location,n=this.session,e.base+"/"+n+"/xhr_send"))).start(t),!0}catch(t){return!1}var e,n}reconnect(){this.closeStream(),this.openStream()}onClose(t,e,n){this.closeStream(),this.readyState=Dt.CLOSED,this.onclose&&this.onclose({code:t,reason:e,wasClean:n})}onChunk(t){var e;if(200===t.status)switch(this.readyState===Dt.OPEN&&this.onActivity(),t.data.slice(0,1)){case"o":e=JSON.parse(t.data.slice(1)||"{}"),this.onOpen(e);break;case"a":e=JSON.parse(t.data.slice(1)||"[]");for(var n=0;n<e.length;n++)this.onEvent(e[n]);break;case"m":e=JSON.parse(t.data.slice(1)||"null"),this.onEvent(e);break;case"h":this.hooks.onHeartbeat(this);break;case"c":e=JSON.parse(t.data.slice(1)||"[]"),this.onClose(e[0],e[1],!0)}}onOpen(t){var e,n,i;this.readyState===Dt.CONNECTING?(t&&t.hostname&&(this.location.base=(e=this.location.base,n=t.hostname,(i=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(e))[1]+n+i[3])),this.readyState=Dt.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(t){this.readyState===Dt.OPEN&&this.onmessage&&this.onmessage({data:t})}onActivity(){this.onactivity&&this.onactivity()}onError(t){this.onerror&&this.onerror(t)}openStream(){this.stream=ae.createSocketRequest("POST",Ut(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",t=>{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority<t)return le(new nt,e);var n=!1,i=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),s=null,r=function(){i.unbind("initialized",r),i.connect()},o=function(){s=St.createHandshake(i,(function(t){n=!0,h(),e(null,t)}))},a=function(t){h(),e(t)},c=function(){var t;h(),t=L(i),e(new it(t))},h=function(){i.unbind("initialized",r),i.unbind("open",o),i.unbind("error",a),i.unbind("closed",c)};return i.bind("initialized",r),i.bind("open",o),i.bind("error",a),i.bind("closed",c),i.initialize(),{abort:()=>{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority<t&&(s?s.close():i.close())}}}}function le(t,e){return m.defer((function(){e(t)})),{abort:function(){},forceMinPriority:function(){}}}const{Transports:de}=ae;var pe,fe=function(t,e,n,i,s,r){var o,a=de[n];if(!a)throw new rt(n);return!(t.enabledTransports&&-1===S(t.enabledTransports,e)||t.disabledTransports&&-1!==S(t.disabledTransports,e))?(s=Object.assign({ignoreNullOrigin:t.ignoreNullOrigin},s),o=new ue(e,i,r?r.getAssistant(a):a,s)):o=ge,o},ge={isSupported:function(){return!1},connect:function(t,e){var n=m.defer((function(){e(new ot)}));return{abort:function(){n.ensureAborted()},forceMinPriority:function(){}}}};!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(pe||(pe={}));var be=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};const ve=(t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}};function ye(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:Ce(t),httpHost:Se(t),useTLS:we(t),wsHost:_e(t),userAuthenticator:Te(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function we(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const ke=t=>"customHandler"in t&&null!=t.customHandler;function Te(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return ke(e)?e.customHandler:be(e)}function Pe(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:ve(e,n,t.authorizer)};return n}(t,e);return ke(n)?n.customHandler:me(n)}class Oe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ee=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class xe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Oe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ee();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;t<e;t++)Le.instances[t].connect()}static getClientFeatures(){return w(P({ws:ae.Transports.ws},(function(t){return t.isSupported({})})))}constructor(t,e){!function(t){if(null==t)throw"You must pass your app key when you instantiate Pusher."}(t),function(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&M.warn("The disableStats option is deprecated in favor of enableStats")}(e),this.key=t,this.options=e,this.config=ye(this.options,this),this.channels=St.createChannels(),this.global_emitter=new H,this.sessionID=ae.randomInt(1e9),this.timeline=new he(this.key,this.sessionID,{cluster:this.config.cluster,features:Le.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:ce.INFO,version:A.VERSION}),this.config.enableStats&&(this.timelineSender=St.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+ae.TimelineTransport.name}));this.connection=St.createConnectionManager(this.key,{getStrategy:t=>ae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new xe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=ye(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ae,Le.ScriptReceivers=ae.ScriptReceivers,Le.DependenciesReceivers=ae.DependenciesReceivers,Le.auth_callbacks=ae.auth_callbacks;var Ae=e.default=Le;ae.setup(Le)}])}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n<t.length-2;n+=3){var i=t[n]<<16|t[n+1]<<8|t[n+2];e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r<n-4;r+=4)a=this._decodeChar(t.charCodeAt(r+0)),c=this._decodeChar(t.charCodeAt(r+1)),h=this._decodeChar(t.charCodeAt(r+2)),u=this._decodeChar(t.charCodeAt(r+3)),i[s++]=a<<2|c>>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r<n-1&&(a=this._decodeChar(t.charCodeAt(r)),c=this._decodeChar(t.charCodeAt(r+1)),i[s++]=a<<2|c>>>4,o|=256&a,o|=256&c),r<n-2&&(h=this._decodeChar(t.charCodeAt(r+2)),i[s++]=c<<4|h>>>2,o|=256&h),r<n-3&&(u=this._decodeChar(t.charCodeAt(r+3)),i[s++]=h<<6|u,o|=256&u),0!==o)throw new Error("Base64Coder: incorrect characters for decoding");return i},t.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);if(i<128)e+=1;else if(i<2048)e+=2;else if(i<55296)e+=3;else{if(!(i<=57343))throw new Error("utf8: invalid string");if(n>=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i<t.length;i++){var r=t.charCodeAt(i);r<128?e[n++]=r:r<2048?(e[n++]=192|r>>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n<t.length;n++){var s=t[n];if(128&s){var r=void 0;if(s<224){if(n>=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s<r||s>=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o<a;o++)r[s.charAt(o)]=o;var c=function(t){var e=t.charCodeAt(0);return e<128?t:e<2048?i(192|e>>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;n<e.length;n++){var i=e[n];for(var s in i)i[s]&&i[s].constructor&&i[s].constructor===Object?t[s]=v(t[s]||{},i[s]):t[s]=i[s]}return t}function y(){for(var t=["Pusher"],e=0;e<arguments.length;e++)"string"==typeof arguments[e]?t.push(arguments[e]):t.push(L(arguments[e]));return t.join(" : ")}function S(t,e){var n=Array.prototype.indexOf;if(null===t)return-1;if(n&&t.indexOf===n)return t.indexOf(e);for(var i=0,s=t.length;i<s;i++)if(t[i]===e)return i;return-1}function _(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(t[n],n,t)}function w(t){var e=[];return _(t,(function(t,n){e.push(n)})),e}function C(t,e,n){for(var i=0;i<t.length;i++)e.call(n||self,t[i],i,t)}function k(t,e){for(var n=[],i=0;i<t.length;i++)n.push(e(t[i],i,t,n));return n}function T(t,e){e=e||function(t){return!!t};for(var n=[],i=0;i<t.length;i++)e(t[i],i,t,n)&&n.push(t[i]);return n}function P(t,e){var n={};return _(t,(function(i,s){(e&&e(i,s,t,n)||Boolean(i))&&(n[s]=i)})),n}function O(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1}function E(t){return e=function(t){return"object"==typeof t&&(t=L(t)),encodeURIComponent((e=t.toString(),l(h(e))));var e},n={},_(t,(function(t,i){n[i]=e(t)})),n;var e,n}function x(t){var e,n,i=P(t,(function(t){return void 0!==t}));return k((e=E(i),n=[],_(e,(function(t,e){n.push([e,t])})),n),m.method("join","=")).join("&")}function L(t){try{return JSON.stringify(t)}catch(i){return JSON.stringify((e=[],n=[],function t(i,s){var r,o,a;switch(typeof i){case"object":if(!i)return null;for(r=0;r<e.length;r+=1)if(e[r]===i)return{$ref:n[r]};if(e.push(i),n.push(s),"[object Array]"===Object.prototype.toString.apply(i))for(a=[],r=0;r<i.length;r+=1)a[r]=t(i[r],s+"["+r+"]");else for(o in a={},i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=t(i[o],s+"["+JSON.stringify(o)+"]"));return a;case"number":case"string":case"boolean":return i}}(t,"$")))}var e,n}var A={VERSION:"8.4.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};function R(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function I(t,e){return"/app/"+t+("?protocol="+A.PROTOCOL+"&client=js&version="+A.VERSION+(e?"&"+e:""))}var D={getInitial:function(t,e){return R("ws",e,(e.httpPath||"")+I(t,"flash=false"))}},j={getInitial:function(t,e){return R("http",e,(e.httpPath||"/pusher")+I(t))}};class N{constructor(){this._callbacks={}}get(t){return this._callbacks[U(t)]}add(t,e,n){var i=U(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[U(t)]:w(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){C(t,(function(t){this._callbacks[t]=T(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){C(t,(function(t){delete this._callbacks[t]}),this)}}function U(t){return"_"+t}class H{constructor(t){this.callbacks=new N,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=T(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i<this.global_callbacks.length;i++)this.global_callbacks[i](t,e);var s=this.callbacks.get(t),r=[];if(n?r.push(e,n):e&&r.push(e),s&&s.length>0)for(i=0;i<s.length;i++)s[i].fn.apply(s[i].context||self,r);else this.failThrough&&this.failThrough(t,e);return this}}var M=new class{constructor(){this.globalLog=t=>{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(Ee.log)Ee.log(n);else if(Ee.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:D,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:j,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class Q extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class K{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Q(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length<this.nacl.secretbox.overheadLength)return void M.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${n.length}`);let i=Object(bt.decode)(e.nonce);if(i.length<this.nacl.secretbox.nonceLength)return void M.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${i.length}`);let s=this.nacl.secretbox.open(n,i,this.key);if(null===s)return M.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),void this.authorize(this.pusher.connection.socket_id,(e,r)=>{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new K(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i<n.length?(s&&(s*=2,this.timeoutLimit&&(s=Math.min(s,this.timeoutLimit))),r=this.tryStrategy(n[i],t,{timeout:s,failFast:this.failFast},o)):e(!0))};return r=this.tryStrategy(n[i],t,{timeout:s,failFast:this.failFast},o),{abort:function(){r.abort()},forceMinPriority:function(e){t=e,r&&r.forceMinPriority(e)}}}tryStrategy(t,e,n,i){var s=null,r=null;return n.timeout>0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0}(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(C(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function kt(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Tt{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=ae.getLocalStorage();if(e)try{var n=e[Pt(t)];if(n)return JSON.parse(n)}catch(e){Ot(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,r=[this.strategy];if(i&&i.timestamp+this.ttl>=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Dt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Dt||(Dt={}));var jt=Dt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n<t;n++)e.push(Ht(32).toString(32));return e.join("")}(8),this.location=function(t){var e=/([^\?]*)\/*(\??.*)/.exec(t);return{base:e[1],queryString:e[2]}}(e),this.readyState=jt.CONNECTING,this.openStream()}send(t){return this.sendRaw(JSON.stringify([t]))}ping(){this.hooks.sendHeartbeat(this)}close(t,e){this.onClose(t,e,!0)}sendRaw(t){if(this.readyState!==jt.OPEN)return!1;try{return ae.createSocketRequest("POST",Ut((e=this.location,n=this.session,e.base+"/"+n+"/xhr_send"))).start(t),!0}catch(t){return!1}var e,n}reconnect(){this.closeStream(),this.openStream()}onClose(t,e,n){this.closeStream(),this.readyState=jt.CLOSED,this.onclose&&this.onclose({code:t,reason:e,wasClean:n})}onChunk(t){var e;if(200===t.status)switch(this.readyState===jt.OPEN&&this.onActivity(),t.data.slice(0,1)){case"o":e=JSON.parse(t.data.slice(1)||"{}"),this.onOpen(e);break;case"a":e=JSON.parse(t.data.slice(1)||"[]");for(var n=0;n<e.length;n++)this.onEvent(e[n]);break;case"m":e=JSON.parse(t.data.slice(1)||"null"),this.onEvent(e);break;case"h":this.hooks.onHeartbeat(this);break;case"c":e=JSON.parse(t.data.slice(1)||"[]"),this.onClose(e[0],e[1],!0)}}onOpen(t){var e,n,i;this.readyState===jt.CONNECTING?(t&&t.hostname&&(this.location.base=(e=this.location.base,n=t.hostname,(i=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(e))[1]+n+i[3])),this.readyState=jt.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(t){this.readyState===jt.OPEN&&this.onmessage&&this.onmessage({data:t})}onActivity(){this.onactivity&&this.onactivity()}onError(t){this.onerror&&this.onerror(t)}openStream(){this.stream=ae.createSocketRequest("POST",Ut(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",t=>{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Qt,getLocalStorage:Kt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Qt,getLocalStorage:Kt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority<t)return le(new nt,e);var n=!1,i=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),s=null,r=function(){i.unbind("initialized",r),i.connect()},o=function(){s=St.createHandshake(i,(function(t){n=!0,h(),e(null,t)}))},a=function(t){h(),e(t)},c=function(){var t;h(),t=L(i),e(new it(t))},h=function(){i.unbind("initialized",r),i.unbind("open",o),i.unbind("error",a),i.unbind("closed",c)};return i.bind("initialized",r),i.bind("open",o),i.bind("error",a),i.bind("closed",c),i.initialize(),{abort:()=>{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority<t&&(s?s.close():i.close())}}}}function le(t,e){return m.defer((function(){e(t)})),{abort:function(){},forceMinPriority:function(){}}}const{Transports:de}=ae;var pe,fe=function(t,e,n,i,s,r){var o,a=de[n];if(!a)throw new rt(n);return!(t.enabledTransports&&-1===S(t.enabledTransports,e)||t.disabledTransports&&-1!==S(t.disabledTransports,e))?(s=Object.assign({ignoreNullOrigin:t.ignoreNullOrigin},s),o=new ue(e,i,r?r.getAssistant(a):a,s)):o=ge,o},ge={isSupported:function(){return!1},connect:function(t,e){var n=m.defer((function(){e(new ot)}));return{abort:function(){n.ensureAborted()},forceMinPriority:function(){}}}};!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(pe||(pe={}));var be=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};function ve(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function ye(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Se(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function _e(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function we(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Ce(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:me(n)}class ke extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Te=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Pe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new ke(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Te();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Oe{static ready(){Oe.isReady=!0;for(var t=0,e=Oe.instances.length;t<e;t++)Oe.instances[t].connect()}static getClientFeatures(){return w(P({ws:ae.Transports.ws},(function(t){return t.isSupported({})})))}constructor(t,e){!function(t){if(null==t)throw"You must pass your app key when you instantiate Pusher."}(t),function(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&M.warn("The disableStats option is deprecated in favor of enableStats")}(e),this.key=t,this.config=function(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:_e(t),httpHost:ve(t),useTLS:Se(t),wsHost:ye(t),userAuthenticator:we(t),channelAuthorizer:Ce(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}(e,this),this.channels=St.createChannels(),this.global_emitter=new H,this.sessionID=ae.randomInt(1e9),this.timeline=new he(this.key,this.sessionID,{cluster:this.config.cluster,features:Oe.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:ce.INFO,version:A.VERSION}),this.config.enableStats&&(this.timelineSender=St.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+ae.TimelineTransport.name}));this.connection=St.createConnectionManager(this.key,{getStrategy:t=>ae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Oe.instances.push(this),this.timeline.info({instances:Oe.instances.length}),this.user=new Pe(this),Oe.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Oe.instances=[],Oe.isReady=!1,Oe.logToConsole=!1,Oe.Runtime=ae,Oe.ScriptReceivers=ae.ScriptReceivers,Oe.DependenciesReceivers=ae.DependenciesReceivers,Oe.auth_callbacks=ae.auth_callbacks;var Ee=e.default=Oe;ae.setup(Oe)}])}));
//# sourceMappingURL=pusher.worker.min.js.map

@@ -23,3 +23,3 @@ export {

// The following types are provided for backward compatability
// The following types are provided for backward compatibility
export {

@@ -26,0 +26,0 @@ DeprecatedAuthOptions as AuthOptions,

{
"name": "pusher-js",
"version": "8.4.0-rc2",
"version": "8.4.0",
"description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers",

@@ -43,6 +43,6 @@ "main": "dist/node/pusher.js",

"jasmine-spec-reporter": "^7.0.0",
"karma": "^6.4.1",
"karma": "^6.4.4",
"karma-browserstack-launcher": "^1.6.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.1",
"karma-firefox-launcher": "^2.1.3",
"karma-jasmine": "^4.0.1",

@@ -55,3 +55,3 @@ "karma-jasmine-web-worker": "git+https://git@github.com/pusher/karma-jasmine-web-worker.git#jasmine_3",

"karma-webpack": "^4.0.2",
"prettier": "^1.19.1",
"prettier": "^3.4.2",
"source-map-loader": "^1.1.3",

@@ -58,0 +58,0 @@ "ts-loader": "^6.0.4",

@@ -23,3 +23,3 @@ export {

// The following types are provided for backward compatability
// The following types are provided for backward compatibility
export {

@@ -26,0 +26,0 @@ DeprecatedAuthOptions as AuthOptions,

@@ -13,2 +13,4 @@ # Pusher Channels Javascript Client

For reporting issues, bugs, and feature requests, please feel free to open a pull request or open an issue. If you do not receive a timely response, feel free to check our [support portal](https://docs.bird.com/pusher).
## Usage Overview

@@ -15,0 +17,0 @@

@@ -248,3 +248,2 @@ var EventsDispatcher = require('core/events/dispatcher').default;

manager.isUsingTLS = jasmine.createSpy("isUsingTLS").and.returnValue(false);
manager.switchCluster = jasmine.createSpy("switchCluster");
return manager;

@@ -251,0 +250,0 @@ },

@@ -62,17 +62,3 @@ // the webpack context API uses Object.keys and Array.prototype.forEach

}
// Test all forceTLS: false before forceTLS: true
// Because browsers prevent a URL from downgrading from HTTPS to HTTP
// This is probably the result of Strict-Transport-Security header returned when calling the HTTPS endpoint.
testConfigs.sort((a, b) => {
if (a.forceTLS == false && b.forceTLS == true) {
return -1;
} else if (a.forceTLS == true && b.forceTLS == false) {
return 1;
} else {
return 0;
}
})
return testConfigs
}

@@ -119,45 +119,2 @@ var ConnectionManager = require('core/connection/connection_manager').default;

describe("#switchCluster", function() {
it("should update cluster key", function() {
expect(manager.key).toEqual("foo");
manager.switchCluster("bar");
expect(manager.key).toEqual("bar");
});
it("should re-build the strategy", function() {
expect(managerOptions.getStrategy.calls.count()).toEqual(1);
manager.switchCluster("bar");
expect(managerOptions.getStrategy.calls.count()).toEqual(2);
expect(managerOptions.getStrategy).toHaveBeenCalledWith({
key: "bar",
useTLS: false,
timeline: timeline
});
});
it("should try to connect using the strategy", function() {
manager.switchCluster("bar");
// connection is retried with a zero delay
jasmine.clock().tick(0);
expect(strategy.connect).toHaveBeenCalled();
});
it("should transition to connecting", function() {
var onConnecting = jasmine.createSpy("onConnecting");
var onStateChange = jasmine.createSpy("onStateChange");
manager.bind("connecting", onConnecting);
manager.bind("state_change", onStateChange);
manager.switchCluster("bar");// connection is retried with a zero delay
jasmine.clock().tick(0);
expect(manager.state).toEqual("connecting");
expect(onConnecting).toHaveBeenCalled();
expect(onStateChange).toHaveBeenCalledWith({
previous: "initialized",
current: "connecting"
});
});
});
describe("before establishing a connection", function() {

@@ -164,0 +121,0 @@ beforeEach(function() {

@@ -310,60 +310,2 @@ var TestEnv = require("testenv");

describe("switch cluster", function() {
var pusher;
var subscribedChannels
beforeEach(function() {
pusher = new Pusher("foo", {cluster: "mt1"});
subscribedChannels = {
channel1: pusher.subscribe("channel1"),
channel2: pusher.subscribe("channel2")
};
pusher.connect();
pusher.connection.state = "connected";
pusher.connection.emit("connected");
});
it("should resubscribe to all channels", function() {
expect(subscribedChannels.channel1.subscribe).toHaveBeenCalledTimes(1);
expect(subscribedChannels.channel2.subscribe).toHaveBeenCalledTimes(1);
pusher.switchCluster({ appKey: 'bar', cluster: 'us3' });
pusher.connect();
pusher.connection.state = 'connected';
pusher.connection.emit('connected');
expect(subscribedChannels.channel1.subscribe).toHaveBeenCalledTimes(2);
expect(subscribedChannels.channel2.subscribe).toHaveBeenCalledTimes(2);
});
it("should send events via the connection manager", function() {
pusher.switchCluster({ appKey: 'bar', cluster: 'us3' });
pusher.send_event("event", { key: "value" }, "channel");
expect(pusher.connection.send_event).toHaveBeenCalledWith(
"event",
{ key: "value" },
"channel"
);
});
it('should keep the persist the previous options', () => {
var authorizeSpy = jasmine.createSpy("authorizeSpy");
const options = {
cluster: "mt1",
enableStats: true,
channelAuthorization: {
customHandler: authorizeSpy
}
};
var pusher = new Pusher("foo", options);
pusher.connect();
pusher.switchCluster({ appKey: 'bar', cluster: 'us3' });
expect(pusher.options).toEqual({ ...options, cluster: 'us3' });
})
})
describe("#unsubscribe", function() {

@@ -370,0 +312,0 @@ it("should unsubscribe the channel if subscription is not pending", function() {

@@ -10,3 +10,3 @@ import AbstractRuntime from '../../runtimes/interface';

authRequestType: AuthRequestType,
callback: Function
callback: Function,
): void;

@@ -13,0 +13,0 @@ }

@@ -6,3 +6,3 @@ import {

ChannelAuthorizationRequestParams,
ChannelAuthorizationCallback
ChannelAuthorizationCallback,
} from './options';

@@ -14,3 +14,3 @@

params: ChannelAuthorizationRequestParams,
authOptions: InternalAuthOptions
authOptions: InternalAuthOptions,
) => {

@@ -44,3 +44,3 @@ var query = 'socket_id=' + encodeURIComponent(params.socketId);

const ChannelAuthorizer = (
authOptions: InternalAuthOptions
authOptions: InternalAuthOptions,
): ChannelAuthorizationHandler => {

@@ -53,3 +53,3 @@ if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {

params: ChannelAuthorizationRequestParams,
callback: ChannelAuthorizationCallback
callback: ChannelAuthorizationCallback,
) => {

@@ -63,3 +63,3 @@ const query = composeChannelQuery(params, authOptions);

AuthRequestType.ChannelAuthorization,
callback
callback,
);

@@ -66,0 +66,0 @@ };

@@ -6,3 +6,3 @@ import Channel from '../channels/channel';

ChannelAuthorizationRequestParams,
InternalAuthOptions
InternalAuthOptions,
} from './options';

@@ -17,3 +17,3 @@

channel: Channel,
options: DeprecatedAuthorizerOptions
options: DeprecatedAuthorizerOptions,
): DeprecatedChannelAuthorizer;

@@ -36,3 +36,3 @@ }

authOptions: InternalAuthOptions,
channelAuthorizerGenerator: ChannelAuthorizerGenerator
channelAuthorizerGenerator: ChannelAuthorizerGenerator,
): ChannelAuthorizationHandler => {

@@ -44,8 +44,8 @@ const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {

params: authOptions.params,
headers: authOptions.headers
}
headers: authOptions.headers,
},
};
return (
params: ChannelAuthorizationRequestParams,
callback: ChannelAuthorizationCallback
callback: ChannelAuthorizationCallback,
) => {

@@ -56,8 +56,6 @@ const channel = pusher.channel(params.channelName);

// We can do that again if we want to keep this behavior intact.
const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(
channel,
deprecatedAuthorizerOptions
);
const channelAuthorizer: DeprecatedChannelAuthorizer =
channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
channelAuthorizer.authorize(params.socketId, callback);
};
};
export enum AuthRequestType {
UserAuthentication = 'user-authentication',
ChannelAuthorization = 'channel-authorization'
ChannelAuthorization = 'channel-authorization',
}

@@ -14,3 +14,3 @@

error: Error | null,
authData: ChannelAuthorizationData | null
authData: ChannelAuthorizationData | null,
) => void;

@@ -26,3 +26,3 @@

params: ChannelAuthorizationRequestParams,
callback: ChannelAuthorizationCallback
callback: ChannelAuthorizationCallback,
): void;

@@ -38,3 +38,3 @@ }

error: Error | null,
authData: UserAuthenticationData | null
authData: UserAuthenticationData | null,
) => void;

@@ -49,3 +49,3 @@

params: UserAuthenticationRequestParams,
callback: UserAuthenticationCallback
callback: UserAuthenticationCallback,
): void;

@@ -58,3 +58,3 @@ }

export interface InternalAuthOptions {
export interface AuthOptionsT<AuthHandler> {
transport: 'ajax' | 'jsonp';

@@ -66,17 +66,17 @@ endpoint: string;

headersProvider?: () => any;
customHandler?: AuthHandler;
}
export type CustomAuthOptions<AuthHandler> = {
customHandler: AuthHandler;
};
export declare type UserAuthenticationOptions =
AuthOptionsT<UserAuthenticationHandler>;
export declare type ChannelAuthorizationOptions =
AuthOptionsT<ChannelAuthorizationHandler>;
export type AuthOptionsT<AuthHandler> =
| InternalAuthOptions
| CustomAuthOptions<AuthHandler>;
export declare type UserAuthenticationOptions = AuthOptionsT<
UserAuthenticationHandler
>;
export declare type ChannelAuthorizationOptions = AuthOptionsT<
ChannelAuthorizationHandler
>;
export interface InternalAuthOptions {
transport: 'ajax' | 'jsonp';
endpoint: string;
params?: any;
headers?: any;
paramsProvider?: () => any;
headersProvider?: () => any;
}

@@ -6,3 +6,3 @@ import {

UserAuthenticationRequestParams,
AuthRequestType
AuthRequestType,
} from './options';

@@ -14,3 +14,3 @@

params: UserAuthenticationRequestParams,
authOptions: InternalAuthOptions
authOptions: InternalAuthOptions,
) => {

@@ -42,3 +42,3 @@ var query = 'socket_id=' + encodeURIComponent(params.socketId);

const UserAuthenticator = (
authOptions: InternalAuthOptions
authOptions: InternalAuthOptions,
): UserAuthenticationHandler => {

@@ -51,3 +51,3 @@ if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {

params: UserAuthenticationRequestParams,
callback: UserAuthenticationCallback
callback: UserAuthenticationCallback,
) => {

@@ -61,3 +61,3 @@ const query = composeChannelQuery(params, authOptions);

AuthRequestType.UserAuthentication,
callback
callback,
);

@@ -64,0 +64,0 @@ };

@@ -15,3 +15,3 @@ export default function encode(s: any): string {

var cb_utob = function(c) {
var cb_utob = function (c) {
var cc = c.charCodeAt(0);

@@ -21,13 +21,13 @@ return cc < 0x80

: cc < 0x800
? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
: fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
fromCharCode(0x80 | (cc & 0x3f));
? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
: fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
fromCharCode(0x80 | (cc & 0x3f));
};
var utob = function(u) {
var utob = function (u) {
return u.replace(/[^\x00-\x7F]/g, cb_utob);
};
var cb_encode = function(ccc) {
var cb_encode = function (ccc) {
var padlen = [0, 2, 1][ccc.length % 3];

@@ -42,3 +42,3 @@ var ord =

padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
padlen >= 1 ? '=' : b64chars.charAt(ord & 63),
];

@@ -50,4 +50,4 @@ return chars.join('');

global.btoa ||
function(b) {
function (b) {
return b.replace(/[\s\S]{1,3}/g, cb_encode);
};

@@ -10,3 +10,3 @@ import { default as EventsDispatcher } from '../events/dispatcher';

ChannelAuthorizationData,
ChannelAuthorizationCallback
ChannelAuthorizationCallback,
} from '../auth/options';

@@ -33,3 +33,3 @@ import { HTTPAuthError } from '../errors';

constructor(name: string, pusher: Pusher) {
super(function(event, data) {
super(function (event, data) {
Logger.debug('No callbacks on ' + name + ' for ' + event);

@@ -57,3 +57,3 @@ });

throw new Errors.BadEventName(
"Event '" + event + "' does not start with 'client-'"
"Event '" + event + "' does not start with 'client-'",
);

@@ -64,3 +64,3 @@ }

Logger.warn(
`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`
`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`,
);

@@ -134,6 +134,6 @@ }

type: 'AuthError',
error: error.message
error: error.message,
},
error instanceof HTTPAuthError ? { status: error.status } : {}
)
error instanceof HTTPAuthError ? { status: error.status } : {},
),
);

@@ -144,6 +144,6 @@ } else {

channel_data: data.channel_data,
channel: this.name
channel: this.name,
});
}
}
},
);

@@ -156,3 +156,3 @@ }

this.pusher.send_event('pusher:unsubscribe', {
channel: this.name
channel: this.name,
});

@@ -159,0 +159,0 @@ }

@@ -60,3 +60,3 @@ import Channel from './channel';

disconnect() {
Collections.objectApply(this.channels, function(channel) {
Collections.objectApply(this.channels, function (channel) {
channel.disconnect();

@@ -82,3 +82,3 @@ });

throw new Errors.BadChannelName(
'Cannot create a channel with name "' + name + '".'
'Cannot create a channel with name "' + name + '".',
);

@@ -85,0 +85,0 @@ } else {

@@ -11,3 +11,3 @@ import PrivateChannel from './private_channel';

ChannelAuthorizationData,
ChannelAuthorizationCallback
ChannelAuthorizationCallback,
} from '../auth/options';

@@ -47,5 +47,5 @@ import * as nacl from 'tweetnacl';

new Error(
`No shared_secret key in auth payload for encrypted channel: ${this.name}`
`No shared_secret key in auth payload for encrypted channel: ${this.name}`,
),
null
null,
);

@@ -57,3 +57,3 @@ return;

callback(null, authData);
}
},
);

@@ -64,3 +64,3 @@ }

throw new Errors.UnsupportedFeature(
'Client events are not currently supported for encrypted channels'
'Client events are not currently supported for encrypted channels',
);

@@ -89,3 +89,3 @@ }

Logger.debug(
'Received encrypted event before key has been retrieved from the authEndpoint'
'Received encrypted event before key has been retrieved from the authEndpoint',
);

@@ -97,3 +97,3 @@ return;

'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +
data
data,
);

@@ -105,3 +105,3 @@ return;

Logger.error(
`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`
`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`,
);

@@ -113,3 +113,3 @@ return;

Logger.error(
`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`
`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`,
);

@@ -122,3 +122,3 @@ return;

Logger.debug(
'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'
'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...',
);

@@ -130,3 +130,3 @@ // Try a single time to retrieve a new auth key and decrypt the event with it

Logger.error(
`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`
`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`,
);

@@ -138,3 +138,3 @@ return;

Logger.error(
`Failed to decrypt event with new key. Dropping encrypted event`
`Failed to decrypt event with new key. Dropping encrypted event`,
);

@@ -141,0 +141,0 @@ return;

@@ -25,3 +25,3 @@ import * as Collections from '../utils/collections';

id: id,
info: this.members[id]
info: this.members[id],
};

@@ -28,0 +28,0 @@ } else {

@@ -46,3 +46,3 @@ import PrivateChannel from './private_channel';

`expected 'channel_data' field. ${suffix}, ` +
`or the user should be signed in.`
`or the user should be signed in.`,
);

@@ -49,0 +49,0 @@ callback('Invalid auth response');

@@ -20,7 +20,7 @@ import Factory from '../utils/factory';

channelName: this.name,
socketId: socketId
socketId: socketId,
},
callback
callback,
);
}
}

@@ -7,4 +7,2 @@ import { Options } from './options';

ChannelAuthorizationOptions,
AuthOptionsT,
CustomAuthOptions
} from './auth/options';

@@ -77,3 +75,3 @@ import UserAuthenticator from './auth/user_authenticator';

userAuthenticator: buildUserAuthenticator(opts),
channelAuthorizer: buildChannelAuthorizer(opts, pusher)
channelAuthorizer: buildChannelAuthorizer(opts, pusher),
};

@@ -138,15 +136,11 @@

const hasCustomHandler = <T>(
auth: AuthOptionsT<T>
): auth is CustomAuthOptions<T> => {
return 'customHandler' in auth && auth['customHandler'] != null;
};
function buildUserAuthenticator(opts: Options): UserAuthenticationHandler {
const userAuthentication = {
...Defaults.userAuthentication,
...opts.userAuthentication
...opts.userAuthentication,
};
if (hasCustomHandler(userAuthentication)) {
if (
'customHandler' in userAuthentication &&
userAuthentication['customHandler'] != null
) {
return userAuthentication['customHandler'];

@@ -163,3 +157,3 @@ }

...Defaults.channelAuthorization,
...opts.channelAuthorization
...opts.channelAuthorization,
};

@@ -169,5 +163,4 @@ } else {

transport: opts.authTransport || Defaults.authTransport,
endpoint: opts.authEndpoint || Defaults.authEndpoint
endpoint: opts.authEndpoint || Defaults.authEndpoint,
};
if ('auth' in opts) {

@@ -178,12 +171,8 @@ if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;

}
if ('authorizer' in opts) {
return {
customHandler: ChannelAuthorizerProxy(
pusher,
channelAuthorization,
opts.authorizer
)
};
}
if ('authorizer' in opts)
channelAuthorization.customHandler = ChannelAuthorizerProxy(
pusher,
channelAuthorization,
opts.authorizer,
);
}

@@ -195,7 +184,9 @@ return channelAuthorization;

opts: Options,
pusher
pusher,
): ChannelAuthorizationHandler {
const channelAuthorization = buildChannelAuth(opts, pusher);
if (hasCustomHandler(channelAuthorization)) {
if (
'customHandler' in channelAuthorization &&
channelAuthorization['customHandler'] != null
) {
return channelAuthorization['customHandler'];

@@ -202,0 +193,0 @@ }

@@ -17,3 +17,3 @@ import { default as EventsDispatcher } from '../events/dispatcher';

HandshakeCallbacks,
ConnectionCallbacks
ConnectionCallbacks,
} from './callbacks';

@@ -78,3 +78,3 @@ import Action from './protocol/action';

this.connectionCallbacks = this.buildConnectionCallbacks(
this.errorCallbacks
this.errorCallbacks,
);

@@ -101,11 +101,2 @@ this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);

switchCluster(key: string) {
this.key = key;
// This ensures that the new config coming from
// pusher instance are taken into account
// such as appKey and cluster
this.updateStrategy();
this.retryIn(0);
}
/** Establishes a connection to Pusher.

@@ -174,3 +165,3 @@ *

type: 'HandshakeError',
error: handshake.error
error: handshake.error,
});

@@ -208,3 +199,3 @@ this.timeline.error({ handshakeError: handshake.error });

timeline: this.timeline,
useTLS: this.usingTLS
useTLS: this.usingTLS,
});

@@ -270,6 +261,6 @@ }

private buildConnectionCallbacks(
errorCallbacks: ErrorCallbacks
errorCallbacks: ErrorCallbacks,
): ConnectionCallbacks {
return Collections.extend<ConnectionCallbacks>({}, errorCallbacks, {
message: message => {
message: (message) => {
// includes pong messages from server

@@ -285,3 +276,3 @@ this.resetActivityCheck();

},
error: error => {
error: (error) => {
// just emit error to user - socket will already be closed by browser

@@ -295,3 +286,3 @@ this.emit('error', error);

}
}
},
});

@@ -301,3 +292,3 @@ }

private buildHandshakeCallbacks(
errorCallbacks: ErrorCallbacks
errorCallbacks: ErrorCallbacks,
): HandshakeCallbacks {

@@ -309,3 +300,3 @@ return Collections.extend<HandshakeCallbacks>({}, errorCallbacks, {

handshake.activityTimeout,
handshake.connection.activityTimeout || Infinity
handshake.connection.activityTimeout || Infinity,
);

@@ -316,3 +307,3 @@ this.clearUnavailableTimer();

this.updateState('connected', { socket_id: this.socket_id });
}
},
});

@@ -322,3 +313,3 @@ }

private buildErrorCallbacks(): ErrorCallbacks {
let withErrorEmitted = callback => {
let withErrorEmitted = (callback) => {
return (result: Action | HandshakePayload) => {

@@ -346,3 +337,3 @@ if (result.error) {

this.retryIn(0);
})
}),
};

@@ -382,3 +373,3 @@ }

'State changed',
previousState + ' -> ' + newStateDescription
previousState + ' -> ' + newStateDescription,
);

@@ -385,0 +376,0 @@ this.timeline.info({ state: newState, params: data });

@@ -97,3 +97,3 @@ import * as Collections from '../utils/collections';

error: e,
data: messageEvent.data
data: messageEvent.data,
});

@@ -109,3 +109,3 @@ }

type: 'PusherError',
data: pusherEvent.data
data: pusherEvent.data,
});

@@ -126,6 +126,6 @@ break;

},
error: error => {
error: (error) => {
this.emit('error', error);
},
closed: closeEvent => {
closed: (closeEvent) => {
unbindListeners();

@@ -139,3 +139,3 @@

this.emit('closed');
}
},
};

@@ -142,0 +142,0 @@

@@ -32,3 +32,3 @@ import Util from '../../util';

transport: TransportConnection,
callback: (HandshakePayload) => void
callback: (HandshakePayload) => void,
) {

@@ -46,3 +46,3 @@ this.transport = transport;

private bindListeners() {
this.onMessage = m => {
this.onMessage = (m) => {
this.unbindListeners();

@@ -62,3 +62,3 @@

connection: new Connection(result.id, this.transport),
activityTimeout: result.activityTimeout
activityTimeout: result.activityTimeout,
});

@@ -71,3 +71,3 @@ } else {

this.onClosed = closeEvent => {
this.onClosed = (closeEvent) => {
this.unbindListeners();

@@ -91,5 +91,5 @@

this.callback(
Collections.extend({ transport: this.transport, action: action }, params)
Collections.extend({ transport: this.transport, action: action }, params),
);
}
}

@@ -23,3 +23,3 @@ import Action from './action';

*/
decodeMessage: function(messageEvent: MessageEvent): PusherEvent {
decodeMessage: function (messageEvent: MessageEvent): PusherEvent {
try {

@@ -36,3 +36,3 @@ var messageData = JSON.parse(messageEvent.data);

channel: messageData.channel,
data: pusherEventData
data: pusherEventData,
};

@@ -54,3 +54,3 @@ if (messageData.user_id) {

*/
encodeMessage: function(event: PusherEvent): string {
encodeMessage: function (event: PusherEvent): string {
return JSON.stringify(event);

@@ -73,3 +73,3 @@ },

*/
processHandshake: function(messageEvent: MessageEvent): Action {
processHandshake: function (messageEvent: MessageEvent): Action {
var message = Protocol.decodeMessage(messageEvent);

@@ -84,3 +84,3 @@

id: message.data.socket_id,
activityTimeout: message.data.activity_timeout * 1000
activityTimeout: message.data.activity_timeout * 1000,
};

@@ -92,3 +92,3 @@ } else if (message.event === 'pusher:error') {

action: this.getCloseAction(message.data),
error: this.getCloseError(message.data)
error: this.getCloseError(message.data),
};

@@ -110,3 +110,3 @@ } else {

*/
getCloseAction: function(closeEvent): string {
getCloseAction: function (closeEvent): string {
if (closeEvent.code < 4000) {

@@ -146,3 +146,3 @@ // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,

*/
getCloseError: function(closeEvent): any {
getCloseError: function (closeEvent): any {
if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {

@@ -153,4 +153,4 @@ return {

code: closeEvent.code,
message: closeEvent.reason || closeEvent.message
}
message: closeEvent.reason || closeEvent.message,
},
};

@@ -160,5 +160,5 @@ } else {

}
}
},
};
export default Protocol;
import {
ChannelAuthorizationOptions,
UserAuthenticationOptions
UserAuthenticationOptions,
} from './auth/options';

@@ -53,7 +53,7 @@ import { AuthTransport } from './config';

endpoint: '/pusher/user-auth',
transport: 'ajax'
transport: 'ajax',
},
channelAuthorization: {
endpoint: '/pusher/auth',
transport: 'ajax'
transport: 'ajax',
},

@@ -64,5 +64,5 @@

cdn_https: CDN_HTTPS,
dependency_suffix: DEPENDENCY_SUFFIX
dependency_suffix: DEPENDENCY_SUFFIX,
};
export default Defaults;

@@ -22,3 +22,3 @@ import Callback from './callback';

fn: callback,
context: context
context: context,
});

@@ -45,6 +45,6 @@ }

names,
function(name) {
function (name) {
this._callbacks[name] = Collections.filter(
this._callbacks[name] || [],
function(binding) {
function (binding) {
return (

@@ -54,3 +54,3 @@ (callback && callback !== binding.fn) ||

);
}
},
);

@@ -61,3 +61,3 @@ if (this._callbacks[name].length === 0) {

},
this
this,
);

@@ -69,6 +69,6 @@ }

names,
function(name) {
function (name) {
delete this._callbacks[name];
},
this
this,
);

@@ -75,0 +75,0 @@ }

@@ -44,3 +44,3 @@ import * as Collections from '../utils/collections';

this.global_callbacks || [],
c => c !== callback
(c) => c !== callback,
);

@@ -47,0 +47,0 @@

@@ -7,3 +7,3 @@ interface Ajax {

user?: string,
password?: string
password?: string,
): void;

@@ -10,0 +10,0 @@ send(payload?: any): void;

@@ -6,12 +6,12 @@ import SocketHooks from './socket_hooks';

var hooks: SocketHooks = {
getReceiveURL: function(url: URLLocation, session: string): string {
getReceiveURL: function (url: URLLocation, session: string): string {
return url.base + '/' + session + '/xhr' + url.queryString;
},
onHeartbeat: function() {
onHeartbeat: function () {
// next HTTP request will reset server's activity timer
},
sendHeartbeat: function(socket) {
sendHeartbeat: function (socket) {
socket.sendRaw('[]');
},
onFinished: function(socket, status) {
onFinished: function (socket, status) {
if (status === 200) {

@@ -22,5 +22,5 @@ socket.reconnect();

}
}
},
};
export default hooks;

@@ -51,3 +51,3 @@ import URLLocation from './url_location';

'POST',
getUniqueURL(getSendURL(this.location, this.session))
getUniqueURL(getSendURL(this.location, this.session)),
).start(payload);

@@ -77,3 +77,3 @@ return true;

reason: reason,
wasClean: wasClean
wasClean: wasClean,
});

@@ -154,9 +154,9 @@ }

'POST',
getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))
getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)),
);
this.stream.bind('chunk', chunk => {
this.stream.bind('chunk', (chunk) => {
this.onChunk(chunk);
});
this.stream.bind('finished', status => {
this.stream.bind('finished', (status) => {
this.hooks.onFinished(this, status);

@@ -191,3 +191,3 @@ });

base: parts[1],
queryString: parts[2]
queryString: parts[2],
};

@@ -194,0 +194,0 @@ }

@@ -5,16 +5,16 @@ import SocketHooks from './socket_hooks';

var hooks: SocketHooks = {
getReceiveURL: function(url, session) {
getReceiveURL: function (url, session) {
return url.base + '/' + session + '/xhr_streaming' + url.queryString;
},
onHeartbeat: function(socket) {
onHeartbeat: function (socket) {
socket.sendRaw('[]');
},
sendHeartbeat: function(socket) {
sendHeartbeat: function (socket) {
socket.sendRaw('[]');
},
onFinished: function(socket, status) {
onFinished: function (socket, status) {
socket.onClose(1006, 'Connection interrupted (' + status + ')', false);
}
},
};
export default hooks;
enum State {
CONNECTING = 0,
OPEN = 1,
CLOSED = 3
CLOSED = 3,
}
export default State;
import ConnectionManager from './connection/connection_manager';
import {
ChannelAuthorizationOptions,
UserAuthenticationOptions
UserAuthenticationOptions,
} from './auth/options';
import {
ChannelAuthorizerGenerator,
DeprecatedAuthOptions
DeprecatedAuthOptions,
} from './auth/deprecated_channel_authorizer';

@@ -47,7 +47,2 @@ import { AuthTransport, Transport } from './config';

export interface ClusterOptions {
appKey: string;
cluster: string;
}
export function validateOptions(options) {

@@ -62,5 +57,5 @@ if (options == null) {

Logger.warn(
'The disableStats option is deprecated in favor of enableStats'
'The disableStats option is deprecated in favor of enableStats',
);
}
}
import AbstractRuntime from '../runtimes/interface';
import Runtime from 'runtime';
import Util from './util';
import * as Collections from './utils/collections';

@@ -12,7 +13,10 @@ import Channels from './channels/channels';

import ConnectionManager from './connection/connection_manager';
import ConnectionManagerOptions from './connection/connection_manager_options';
import { PeriodicTimer } from './utils/timers';
import Defaults from './defaults';
import * as DefaultConfig from './config';
import Logger from './logger';
import Factory from './utils/factory';
import { Options, ClusterOptions, validateOptions } from './options';
import UrlStore from 'core/utils/url_store';
import { Options, validateOptions } from './options';
import { Config, getConfig } from './config';

@@ -45,5 +49,5 @@ import StrategyOptions from './strategies/strategy_options';

return Collections.keys(
Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {
Collections.filterObject({ ws: Runtime.Transports.ws }, function (t) {
return t.isSupported({});
})
}),
);

@@ -54,3 +58,2 @@ }

key: string;
options: Options;
config: Config;

@@ -69,4 +72,3 @@ channels: Channels;

this.key = app_key;
this.options = options;
this.config = getConfig(this.options, this);
this.config = getConfig(options, this);

@@ -83,3 +85,3 @@ this.channels = Factory.createChannels();

level: TimelineLevel.INFO,
version: Defaults.VERSION
version: Defaults.VERSION,
});

@@ -89,3 +91,3 @@ if (this.config.enableStats) {

host: this.config.statsHost,
path: '/timeline/v2/' + Runtime.TimelineTransport.name
path: '/timeline/v2/' + Runtime.TimelineTransport.name,
});

@@ -104,3 +106,3 @@ }

unavailableTimeout: this.config.unavailableTimeout,
useTLS: Boolean(this.config.useTLS)
useTLS: Boolean(this.config.useTLS),
});

@@ -115,3 +117,3 @@

this.connection.bind('message', event => {
this.connection.bind('message', (event) => {
var eventName = event.event;

@@ -136,3 +138,3 @@ var internal = eventName.indexOf('pusher_internal:') === 0;

});
this.connection.bind('error', err => {
this.connection.bind('error', (err) => {
Logger.warn(err);

@@ -151,15 +153,2 @@ });

/**
* Allows you to switch Pusher cluster without
* losing all the channels/subscription binding
* as this is internally managed by the SDK.
*/
switchCluster(options: ClusterOptions) {
const { appKey, cluster } = options;
this.key = appKey;
this.options = { ...this.options, cluster };
this.config = getConfig(this.options, this);
this.connection.switchCluster(this.key);
}
channel(name: string): Channel {

@@ -180,3 +169,3 @@ return this.channels.find(name);

var timelineSender = this.timelineSender;
this.timelineSenderTimer = new PeriodicTimer(60000, function() {
this.timelineSenderTimer = new PeriodicTimer(60000, function () {
timelineSender.send(usingTLS);

@@ -183,0 +172,0 @@ });

@@ -21,4 +21,4 @@ import * as Collections from '../utils/collections';

connect(minPriority: number, callback: Function) {
return connect(this.strategies, minPriority, function(i, runners) {
return function(error, handshake) {
return connect(this.strategies, minPriority, function (i, runners) {
return function (error, handshake) {
runners[i].error = error;

@@ -31,3 +31,3 @@ if (error) {

}
Collections.apply(runners, function(runner) {
Collections.apply(runners, function (runner) {
runner.forceMinPriority(handshake.transport.priority);

@@ -55,16 +55,16 @@ });

minPriority: number,
callbackBuilder: Function
callbackBuilder: Function,
) {
var runners = Collections.map(strategies, function(strategy, i, _, rs) {
var runners = Collections.map(strategies, function (strategy, i, _, rs) {
return strategy.connect(minPriority, callbackBuilder(i, rs));
});
return {
abort: function() {
abort: function () {
Collections.apply(runners, abortRunner);
},
forceMinPriority: function(p) {
Collections.apply(runners, function(runner) {
forceMinPriority: function (p) {
Collections.apply(runners, function (runner) {
runner.forceMinPriority(p);
});
}
},
};

@@ -74,3 +74,3 @@ }

function allRunnersFailed(runners): boolean {
return Collections.all(runners, function(runner) {
return Collections.all(runners, function (runner) {
return Boolean(runner.error);

@@ -77,0 +77,0 @@ });

@@ -29,3 +29,3 @@ import { OneOffTimer as Timer } from '../utils/timers';

var runner;
var timer = new Timer(this.options.delay, function() {
var timer = new Timer(this.options.delay, function () {
runner = strategy.connect(minPriority, callback);

@@ -35,3 +35,3 @@ });

return {
abort: function() {
abort: function () {
timer.ensureAborted();

@@ -42,3 +42,3 @@ if (runner) {

},
forceMinPriority: function(p) {
forceMinPriority: function (p) {
minPriority = p;

@@ -48,5 +48,5 @@ if (runner) {

}
}
},
};
}
}

@@ -20,10 +20,13 @@ import Strategy from './strategy';

connect(minPriority: number, callback: Function): StrategyRunner {
var runner = this.strategy.connect(minPriority, function(error, handshake) {
if (handshake) {
runner.abort();
}
callback(error, handshake);
});
var runner = this.strategy.connect(
minPriority,
function (error, handshake) {
if (handshake) {
runner.abort();
}
callback(error, handshake);
},
);
return runner;
}
}

@@ -18,3 +18,3 @@ import Strategy from './strategy';

trueBranch: Strategy,
falseBranch: Strategy
falseBranch: Strategy,
) {

@@ -21,0 +21,0 @@ this.test = test;

@@ -62,3 +62,3 @@ import * as Collections from '../utils/collections';

{ timeout, failFast: this.failFast },
tryNextStrategy
tryNextStrategy,
);

@@ -75,10 +75,10 @@ } else {

{ timeout: timeout, failFast: this.failFast },
tryNextStrategy
tryNextStrategy,
);
return {
abort: function() {
abort: function () {
runner.abort();
},
forceMinPriority: function(p) {
forceMinPriority: function (p) {
minPriority = p;

@@ -88,3 +88,3 @@ if (runner) {

}
}
},
};

@@ -97,3 +97,3 @@ }

options: StrategyOptions,
callback: Function
callback: Function,
) {

@@ -104,3 +104,3 @@ var timer = null;

if (options.timeout > 0) {
timer = new Timer(options.timeout, function() {
timer = new Timer(options.timeout, function () {
runner.abort();

@@ -111,3 +111,3 @@ callback(true);

runner = strategy.connect(minPriority, function(error, handshake) {
runner = strategy.connect(minPriority, function (error, handshake) {
if (error && timer && timer.isRunning() && !options.failFast) {

@@ -124,3 +124,3 @@ // advance to the next strategy after the timeout

return {
abort: function() {
abort: function () {
if (timer) {

@@ -131,7 +131,7 @@ timer.ensureAborted();

},
forceMinPriority: function(p) {
forceMinPriority: function (p) {
runner.forceMinPriority(p);
}
},
};
}
}

@@ -13,3 +13,3 @@ import * as Collections from '../utils/collections';

export var defineTransport = function(
export var defineTransport = function (
config: Config,

@@ -20,3 +20,3 @@ name: string,

options: StrategyOptions,
manager?: TransportManager
manager?: TransportManager,
): Strategy {

@@ -38,3 +38,3 @@ var transportClass = Transports[type];

{ ignoreNullOrigin: config.ignoreNullOrigin },
options
options,
);

@@ -46,3 +46,3 @@

manager ? manager.getAssistant(transportClass) : transportClass,
options
options,
);

@@ -57,16 +57,16 @@ } else {

var UnsupportedStrategy: Strategy = {
isSupported: function() {
isSupported: function () {
return false;
},
connect: function(_, callback) {
var deferred = Util.defer(function() {
connect: function (_, callback) {
var deferred = Util.defer(function () {
callback(new Errors.UnsupportedStrategy());
});
return {
abort: function() {
abort: function () {
deferred.ensureAborted();
},
forceMinPriority: function() {}
forceMinPriority: function () {},
};
}
},
};

@@ -27,3 +27,3 @@ import Factory from '../utils/factory';

transport: Transport,
options: StrategyOptions
options: StrategyOptions,
) {

@@ -42,3 +42,3 @@ this.name = name;

return this.transport.isSupported({
useTLS: this.options.useTLS
useTLS: this.options.useTLS,
});

@@ -64,12 +64,12 @@ }

this.options.key,
this.options
this.options,
);
var handshake = null;
var onInitialized = function() {
var onInitialized = function () {
transport.unbind('initialized', onInitialized);
transport.connect();
};
var onOpen = function() {
handshake = Factory.createHandshake(transport, function(result) {
var onOpen = function () {
handshake = Factory.createHandshake(transport, function (result) {
connected = true;

@@ -80,7 +80,7 @@ unbindListeners();

};
var onError = function(error) {
var onError = function (error) {
unbindListeners();
callback(error);
};
var onClosed = function() {
var onClosed = function () {
unbindListeners();

@@ -97,3 +97,3 @@ var serializedTransport;

var unbindListeners = function() {
var unbindListeners = function () {
transport.unbind('initialized', onInitialized);

@@ -125,3 +125,3 @@ transport.unbind('open', onOpen);

},
forceMinPriority: p => {
forceMinPriority: (p) => {
if (connected) {

@@ -137,3 +137,3 @@ return;

}
}
},
};

@@ -144,9 +144,9 @@ }

function failAttempt(error: Error, callback: Function) {
Util.defer(function() {
Util.defer(function () {
callback(error);
});
return {
abort: function() {},
forceMinPriority: function() {}
abort: function () {},
forceMinPriority: function () {},
};
}

@@ -31,3 +31,3 @@ import Util from '../util';

transports: TransportStrategyDictionary,
options: StrategyOptions
options: StrategyOptions,
) {

@@ -58,3 +58,3 @@ this.strategy = strategy;

transport: info.transport,
latency: info.latency
latency: info.latency,
});

@@ -64,4 +64,4 @@ strategies.push(

timeout: info.latency * 2 + 1000,
failFast: true
})
failFast: true,
}),
);

@@ -91,3 +91,3 @@ } else {

Util.now() - startTimestamp,
cacheSkipCount
cacheSkipCount,
);

@@ -99,6 +99,6 @@ callback(null, handshake);

return {
abort: function() {
abort: function () {
runner.abort();
},
forceMinPriority: function(p) {
forceMinPriority: function (p) {
minPriority = p;

@@ -108,3 +108,3 @@ if (runner) {

}
}
},
};

@@ -137,3 +137,3 @@ }

latency: number,
cacheSkipCount: number
cacheSkipCount: number,
) {

@@ -147,3 +147,3 @@ var storage = Runtime.getLocalStorage();

latency: latency,
cacheSkipCount: cacheSkipCount
cacheSkipCount: cacheSkipCount,
});

@@ -150,0 +150,0 @@ } catch (e) {

enum TimelineLevel {
ERROR = 3,
INFO = 6,
DEBUG = 7
DEBUG = 7,
}
export default TimelineLevel;

@@ -30,5 +30,5 @@ import * as Collections from '../utils/collections';

Runtime.TimelineTransport.getAgent(this, useTLS),
callback
callback,
);
}
}

@@ -7,3 +7,3 @@ import TimelineSender from '../timeline/timeline_sender';

sender: TimelineSender,
useTLS: boolean
useTLS: boolean,
) => (data: any, callback: Function) => void;

@@ -10,0 +10,0 @@ }

@@ -34,3 +34,3 @@ import * as Collections from '../utils/collections';

this.events.push(
Collections.extend({}, event, { timestamp: Util.now() })
Collections.extend({}, event, { timestamp: Util.now() }),
);

@@ -69,5 +69,5 @@ if (this.options.limit && this.events.length > this.options.limit) {

features: this.options.features,
timeline: this.events
timeline: this.events,
},
this.options.params
this.options.params,
);

@@ -74,0 +74,0 @@

@@ -31,3 +31,3 @@ import Util from '../util';

transport: Transport,
options: PingDelayOptions
options: PingDelayOptions,
) {

@@ -55,6 +55,6 @@ this.manager = manager;

key: string,
options: Object
options: Object,
): TransportConnection {
options = Collections.extend({}, options, {
activityTimeout: this.pingDelay
activityTimeout: this.pingDelay,
});

@@ -65,3 +65,3 @@ var connection = this.transport.createConnection(

key,
options
options,
);

@@ -71,3 +71,3 @@

var onOpen = function() {
var onOpen = function () {
connection.unbind('open', onOpen);

@@ -77,3 +77,3 @@ connection.bind('closed', onClosed);

};
var onClosed = closeEvent => {
var onClosed = (closeEvent) => {
connection.unbind('closed', onClosed);

@@ -80,0 +80,0 @@

@@ -58,3 +58,3 @@ import Util from '../util';

key: string,
options: TransportConnectionOptions
options: TransportConnectionOptions,
) {

@@ -161,3 +161,3 @@ super();

this.socket,
this.hooks.urls.getPath(this.key, this.options)
this.hooks.urls.getPath(this.key, this.options),
);

@@ -179,3 +179,3 @@ }

reason: closeEvent.reason,
wasClean: closeEvent.wasClean
wasClean: closeEvent.wasClean,
});

@@ -201,9 +201,9 @@ } else {

};
this.socket.onerror = error => {
this.socket.onerror = (error) => {
this.onError(error);
};
this.socket.onclose = closeEvent => {
this.socket.onclose = (closeEvent) => {
this.onClose(closeEvent);
};
this.socket.onmessage = message => {
this.socket.onmessage = (message) => {
this.onMessage(message);

@@ -236,4 +236,4 @@ };

state: state,
params: params
})
params: params,
}),
);

@@ -240,0 +240,0 @@ this.emit(state, params);

@@ -36,3 +36,3 @@ import AssistantToTheTransportManager from './assistant_to_the_transport_manager';

minPingDelay: this.options.minPingDelay,
maxPingDelay: this.options.maxPingDelay
maxPingDelay: this.options.maxPingDelay,
});

@@ -39,0 +39,0 @@ }

@@ -50,3 +50,3 @@ import Factory from '../utils/factory';

key: string,
options: any
options: any,
): TransportConnection {

@@ -53,0 +53,0 @@ return new TransportConnection(this.hooks, name, priority, key, options);

@@ -7,3 +7,3 @@ import Defaults from '../defaults';

params: URLSchemeParams,
path: string
path: string,
): string {

@@ -28,22 +28,22 @@ var scheme = baseScheme + (params.useTLS ? 's' : '');

export var ws: URLScheme = {
getInitial: function(key: string, params: URLSchemeParams): string {
getInitial: function (key: string, params: URLSchemeParams): string {
var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');
return getGenericURL('ws', params, path);
}
},
};
export var http: URLScheme = {
getInitial: function(key: string, params: URLSchemeParams): string {
getInitial: function (key: string, params: URLSchemeParams): string {
var path = (params.httpPath || '/pusher') + getGenericPath(key);
return getGenericURL('http', params, path);
}
},
};
export var sockjs: URLScheme = {
getInitial: function(key: string, params: URLSchemeParams): string {
getInitial: function (key: string, params: URLSchemeParams): string {
return getGenericURL('http', params, params.httpPath || '/pusher');
},
getPath: function(key: string, params: URLSchemeParams): string {
getPath: function (key: string, params: URLSchemeParams): string {
return getGenericPath(key);
}
},
};

@@ -5,3 +5,3 @@ import Pusher from './pusher';

UserAuthenticationData,
UserAuthenticationCallback
UserAuthenticationCallback,
} from './auth/options';

@@ -23,3 +23,3 @@ import Channel from './channels/channel';

public constructor(pusher: Pusher) {
super(function(eventName, data) {
super(function (eventName, data) {
Logger.debug('No callbacks on user for ' + eventName);

@@ -40,3 +40,3 @@ });

this.pusher.connection.bind('message', event => {
this.pusher.connection.bind('message', (event) => {
var eventName = event.event;

@@ -78,5 +78,5 @@ if (eventName === 'pusher:signin_success') {

{
socketId: this.pusher.connection.socket_id
socketId: this.pusher.connection.socket_id,
},
this._onAuthorize
this._onAuthorize,
);

@@ -87,3 +87,3 @@ }

err,
authData: UserAuthenticationData
authData: UserAuthenticationData,
) => {

@@ -98,3 +98,3 @@ if (err) {

auth: authData.auth,
user_data: authData.user_data
user_data: authData.user_data,
});

@@ -116,3 +116,3 @@

Logger.error(
`user_data doesn't contain an id. user_data: ${this.user_data}`
`user_data doesn't contain an id. user_data: ${this.user_data}`,
);

@@ -129,3 +129,3 @@ this._cleanup();

private _subscribeChannels() {
const ensure_subscribed = channel => {
const ensure_subscribed = (channel) => {
if (channel.subscriptionPending && channel.subscriptionCancelled) {

@@ -143,3 +143,3 @@ channel.reinstateSubscription();

`#server-to-user-${this.user_data.id}`,
this.pusher
this.pusher,
);

@@ -146,0 +146,0 @@ this.serverToUserChannel.bind_global((eventName, data) => {

@@ -28,8 +28,8 @@ import * as Collections from './utils/collections';

var boundArguments = Array.prototype.slice.call(arguments, 1);
return function(object) {
return function (object) {
return object[name].apply(object, boundArguments.concat(arguments));
};
}
},
};
export default Util;

@@ -90,3 +90,3 @@ import base64encode from '../base64';

var keys = [];
objectApply(object, function(_, key) {
objectApply(object, function (_, key) {
keys.push(key);

@@ -104,3 +104,3 @@ });

var values = [];
objectApply(object, function(value) {
objectApply(object, function (value) {
values.push(value);

@@ -159,3 +159,3 @@ });

var result = {};
objectApply(object, function(value, key) {
objectApply(object, function (value, key) {
result[key] = f(value);

@@ -180,3 +180,3 @@ });

test ||
function(value) {
function (value) {
return !!value;

@@ -207,3 +207,3 @@ };

var result = {};
objectApply(object, function(value, key) {
objectApply(object, function (value, key) {
if ((test && test(value, key, object, result)) || Boolean(value)) {

@@ -223,3 +223,3 @@ result[key] = value;

var result = [];
objectApply(object, function(value, key) {
objectApply(object, function (value, key) {
result.push([key, value]);

@@ -269,3 +269,3 @@ });

export function encodeParamsObject(data): string {
return mapObject(data, function(value) {
return mapObject(data, function (value) {
if (typeof value === 'object') {

@@ -279,3 +279,3 @@ value = safeJSONStringify(value);

export function buildQueryString(data: any): string {
var params = filterObject(data, function(value) {
var params = filterObject(data, function (value) {
return value !== undefined;

@@ -286,3 +286,3 @@ });

flatten(encodeParamsObject(params)),
Util.method('join', '=')
Util.method('join', '='),
).join('&');

@@ -334,3 +334,3 @@

value[name],
path + '[' + JSON.stringify(name) + ']'
path + '[' + JSON.stringify(name) + ']',
);

@@ -337,0 +337,0 @@ }

@@ -13,3 +13,3 @@ import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';

default as TimelineSender,
TimelineSenderOptions
TimelineSenderOptions,
} from '../timeline/timeline_sender';

@@ -35,3 +35,3 @@ import PresenceChannel from '../channels/presence_channel';

key: string,
options: ConnectionManagerOptions
options: ConnectionManagerOptions,
): ConnectionManager {

@@ -56,3 +56,3 @@ return new ConnectionManager(key, options);

pusher: Pusher,
nacl: nacl
nacl: nacl,
): EncryptedChannel {

@@ -68,3 +68,3 @@ return new EncryptedChannel(name, pusher, nacl);

transport: TransportConnection,
callback: (HandshakePayload) => void
callback: (HandshakePayload) => void,
): Handshake {

@@ -77,8 +77,8 @@ return new Handshake(transport, callback);

transport: Transport,
options: PingDelayOptions
options: PingDelayOptions,
): AssistantToTheTransportManager {
return new AssistantToTheTransportManager(manager, transport, options);
}
},
};
export default Factory;

@@ -12,3 +12,3 @@ import TimedCallback from './timed_callback';

delay: Delay,
callback: TimedCallback
callback: TimedCallback,
) {

@@ -15,0 +15,0 @@ this.clear = clear;

@@ -20,3 +20,3 @@ import Timer from './abstract_timer';

constructor(delay: Delay, callback: TimedCallback) {
super(setTimeout, clearTimeout, delay, function(timer) {
super(setTimeout, clearTimeout, delay, function (timer) {
callback();

@@ -35,3 +35,3 @@ return null;

constructor(delay: Delay, callback: TimedCallback) {
super(setInterval, clearInterval, delay, function(timer) {
super(setInterval, clearInterval, delay, function (timer) {
callback();

@@ -38,0 +38,0 @@ return timer;

@@ -9,18 +9,18 @@ /**

authenticationEndpoint: {
path: '/docs/channels/server_api/authenticating_users'
path: '/docs/channels/server_api/authenticating_users',
},
authorizationEndpoint: {
path: '/docs/channels/server_api/authorizing-users/'
path: '/docs/channels/server_api/authorizing-users/',
},
javascriptQuickStart: {
path: '/docs/javascript_quick_start'
path: '/docs/javascript_quick_start',
},
triggeringClientEvents: {
path: '/docs/client_api_guide/client_events#trigger-events'
path: '/docs/client_api_guide/client_events#trigger-events',
},
encryptedChannelSupport: {
fullUrl:
'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'
}
}
'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support',
},
},
};

@@ -33,3 +33,3 @@

*/
const buildLogSuffix = function(key: string): string {
const buildLogSuffix = function (key: string): string {
const urlPrefix = 'See:';

@@ -36,0 +36,0 @@ const urlObj = urlStore.urls[key];

@@ -9,3 +9,3 @@ import Logger from './logger';

public constructor(pusher: Pusher) {
super(function(eventName, data) {
super(function (eventName, data) {
Logger.debug(`No callbacks on watchlist events for ${eventName}`);

@@ -19,3 +19,3 @@ });

handleEvent(pusherEvent) {
pusherEvent.data.events.forEach(watchlistEvent => {
pusherEvent.data.events.forEach((watchlistEvent) => {
this.emit(watchlistEvent.name, watchlistEvent);

@@ -26,3 +26,3 @@ });

private bindWatchlistInternalEvent() {
this.pusher.connection.bind('message', pusherEvent => {
this.pusher.connection.bind('message', (pusherEvent) => {
var eventName = pusherEvent.event;

@@ -29,0 +29,0 @@ if (eventName === 'pusher_internal:watchlist_events') {

@@ -10,4 +10,4 @@ declare var module: {

paths: string[],
callback: (require: <T>(path: string) => T) => void
callback: (require: <T>(path: string) => T) => void,
) => void;
};

@@ -38,3 +38,3 @@ import { AuthTransports } from '../core/auth/auth_transports';

options: StrategyOptions,
defineTransport: Function
defineTransport: Function,
): Strategy;

@@ -41,0 +41,0 @@ Transports: TransportsTable;

@@ -11,7 +11,7 @@ import TimelineSender from 'core/timeline/timeline_sender';

AuthTransportCallback,
InternalAuthOptions
InternalAuthOptions,
} from 'core/auth/options';
import { HTTPAuthError } from 'core/errors';
const ajax: AuthTransport = function(
const ajax: AuthTransport = function (
context: AbstractRuntime,

@@ -21,3 +21,3 @@ query: string,

authRequestType: AuthRequestType,
callback: AuthTransportCallback
callback: AuthTransportCallback,
) {

@@ -39,3 +39,3 @@ const xhr = Runtime.createXHR();

xhr.onreadystatechange = function() {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {

@@ -55,5 +55,5 @@ if (xhr.status === 200) {

xhr.responseText
}`
}`,
),
null
null,
);

@@ -74,3 +74,3 @@ }

suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(
'authorizationEndpoint'
'authorizationEndpoint',
)}`;

@@ -83,5 +83,5 @@ break;

`Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +
`received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`
`received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`,
),
null
null,
);

@@ -88,0 +88,0 @@ }

@@ -7,3 +7,3 @@ import * as Collections from 'core/utils/collections';

import WebSocketPrioritizedCachedStrategy, {
TransportStrategyDictionary
TransportStrategyDictionary,
} from 'core/strategies/websocket_prioritized_cached_strategy';

@@ -17,3 +17,3 @@ import DelayedStrategy from 'core/strategies/delayed_strategy';

function testSupportsStrategy(strategy: Strategy) {
return function() {
return function () {
return strategy.isSupported();

@@ -23,6 +23,6 @@ };

var getDefaultStrategy = function(
var getDefaultStrategy = function (
config: Config,
baseOptions: StrategyOptions,
defineTransport: Function
defineTransport: Function,
): Strategy {

@@ -36,3 +36,3 @@ var definedTransports = <TransportStrategyDictionary>{};

options: StrategyOptions,
manager?: TransportManager
manager?: TransportManager,
) {

@@ -45,3 +45,3 @@ var transport = defineTransport(

options,
manager
manager,
);

@@ -57,6 +57,6 @@

hostTLS: config.wsHost + ':' + config.wssPort,
httpPath: config.wsPath
httpPath: config.wsPath,
});
var wss_options: StrategyOptions = Collections.extend({}, ws_options, {
useTLS: true
useTLS: true,
});

@@ -66,3 +66,3 @@ var http_options: StrategyOptions = Object.assign({}, baseOptions, {

hostTLS: config.httpHost + ':' + config.httpsPort,
httpPath: config.httpPath
httpPath: config.httpPath,
});

@@ -72,3 +72,3 @@ var timeouts = {

timeout: 15000,
timeoutLimit: 60000
timeoutLimit: 60000,
};

@@ -78,3 +78,3 @@

minPingDelay: 10000,
maxPingDelay: config.activityTimeout
maxPingDelay: config.activityTimeout,
});

@@ -84,3 +84,3 @@ var streaming_manager = new TransportManager({

minPingDelay: 10000,
maxPingDelay: config.activityTimeout
maxPingDelay: config.activityTimeout,
});

@@ -93,3 +93,3 @@

ws_options,
ws_manager
ws_manager,
);

@@ -101,3 +101,3 @@ var wss_transport = defineTransportStrategy(

wss_options,
ws_manager
ws_manager,
);

@@ -109,3 +109,3 @@ var xhr_streaming_transport = defineTransportStrategy(

http_options,
streaming_manager
streaming_manager,
);

@@ -116,3 +116,3 @@ var xhr_polling_transport = defineTransportStrategy(

1,
http_options
http_options,
);

@@ -124,3 +124,3 @@

[xhr_streaming_transport],
timeouts
timeouts,
);

@@ -135,8 +135,8 @@ var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);

streaming_loop,
new DelayedStrategy(polling_loop, { delay: 4000 })
new DelayedStrategy(polling_loop, { delay: 4000 }),
]),
polling_loop
)
polling_loop,
),
],
timeouts
timeouts,
);

@@ -148,3 +148,3 @@

ws_loop,
new DelayedStrategy(http_loop, { delay: 2000 })
new DelayedStrategy(http_loop, { delay: 2000 }),
]);

@@ -155,3 +155,3 @@ } else {

new DelayedStrategy(wss_loop, { delay: 2000 }),
new DelayedStrategy(http_loop, { delay: 5000 })
new DelayedStrategy(http_loop, { delay: 5000 }),
]);

@@ -162,3 +162,3 @@ }

new FirstConnectedStrategy(
new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)
new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop),
),

@@ -169,4 +169,4 @@ definedTransports,

timeline: baseOptions.timeline,
useTLS: baseOptions.useTLS
}
useTLS: baseOptions.useTLS,
},
);

@@ -173,0 +173,0 @@ };

@@ -7,6 +7,6 @@ import HTTPRequest from 'core/http/http_request';

var hooks: RequestHooks = {
getRequest: function(socket: HTTPRequest): Ajax {
getRequest: function (socket: HTTPRequest): Ajax {
var Constructor = Runtime.getXHRAPI();
var xhr = new Constructor();
xhr.onreadystatechange = xhr.onprogress = function() {
xhr.onreadystatechange = xhr.onprogress = function () {
switch (xhr.readyState) {

@@ -30,8 +30,8 @@ case 3:

},
abortRequest: function(xhr: Ajax) {
abortRequest: function (xhr: Ajax) {
xhr.onreadystatechange = null;
xhr.abort();
}
},
};
export default hooks;

@@ -29,5 +29,5 @@ import HTTPRequest from 'core/http/http_request';

return new HTTPRequest(hooks, method, url);
}
},
};
export default HTTP;

@@ -26,5 +26,5 @@ import * as Collections from 'core/utils/collections';

return Collections.keys(
Collections.filterObject({ ws: Transports.ws }, function(t) {
Collections.filterObject({ ws: Transports.ws }, function (t) {
return t.isSupported({});
})
}),
);

@@ -60,5 +60,5 @@ },

addUnloadListener(listener: any) {},
removeUnloadListener(listener: any) {}
removeUnloadListener(listener: any) {},
};
export default Isomorphic;

@@ -8,4 +8,4 @@ import Logger from 'core/logger';

var getAgent = function(sender: TimelineSender, useTLS: boolean) {
return function(data: any, callback: Function) {
var getAgent = function (sender: TimelineSender, useTLS: boolean) {
return function (data: any, callback: Function) {
var scheme = 'http' + (useTLS ? 's' : '') + '://';

@@ -21,3 +21,3 @@ var url =

xhr.onreadystatechange = function() {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {

@@ -27,3 +27,3 @@ let { status, responseText } = xhr;

Logger.debug(
`TimelineSender Error: received ${status} from stats.pusher.com`
`TimelineSender Error: received ${status} from stats.pusher.com`,
);

@@ -50,5 +50,5 @@ return;

name: 'xhr',
getAgent
getAgent,
};
export default xhr;

@@ -5,3 +5,3 @@ /** Initializes the transport.

*/
export default function() {
export default function () {
var self = this;

@@ -11,4 +11,4 @@

self.buildTimelineMessage({
transport: self.name + (self.options.useTLS ? 's' : '')
})
transport: self.name + (self.options.useTLS ? 's' : ''),
}),
);

@@ -15,0 +15,0 @@

@@ -20,11 +20,11 @@ import * as URLSchemes from 'core/transports/url_schemes';

isInitialized: function() {
isInitialized: function () {
return Boolean(Runtime.getWebSocketAPI());
},
isSupported: function(): boolean {
isSupported: function (): boolean {
return Boolean(Runtime.getWebSocketAPI());
},
getSocket: function(url) {
getSocket: function (url) {
return Runtime.createWebSocket(url);
}
},
});

@@ -36,5 +36,5 @@

supportsPing: true,
isInitialized: function() {
isInitialized: function () {
return true;
}
},
};

@@ -44,21 +44,21 @@

{
getSocket: function(url) {
getSocket: function (url) {
return Runtime.HTTPFactory.createStreamingSocket(url);
}
},
},
httpConfiguration
httpConfiguration,
);
export var pollingConfiguration = Collections.extend(
{
getSocket: function(url) {
getSocket: function (url) {
return Runtime.HTTPFactory.createPollingSocket(url);
}
},
},
httpConfiguration
httpConfiguration,
);
var xhrConfiguration = {
isSupported: function(): boolean {
isSupported: function (): boolean {
return Runtime.isXHRSupported();
}
},
};

@@ -70,3 +70,3 @@

Collections.extend({}, streamingConfiguration, xhrConfiguration)
)
),
);

@@ -76,3 +76,5 @@

var XHRPollingTransport = new Transport(
<TransportHooks>Collections.extend({}, pollingConfiguration, xhrConfiguration)
<TransportHooks>(
Collections.extend({}, pollingConfiguration, xhrConfiguration)
),
);

@@ -83,5 +85,5 @@

xhr_streaming: XHRStreamingTransport,
xhr_polling: XHRPollingTransport
xhr_polling: XHRPollingTransport,
};
export default Transports;

@@ -27,3 +27,3 @@ import Isomorphic from 'isomorphic/runtime';

createSocketRequest,
HTTPFactory
HTTPFactory,
} = Isomorphic;

@@ -66,5 +66,5 @@

return randomInt(max);
}
},
};
export default NodeJS;

@@ -17,7 +17,7 @@ import { default as NativeNetInfo } from '@react-native-community/netinfo';

NativeNetInfo.fetch().then(connectionState => {
NativeNetInfo.fetch().then((connectionState) => {
this.online = hasOnlineConnectionState(connectionState);
});
NativeNetInfo.addEventListener(connectionState => {
NativeNetInfo.addEventListener((connectionState) => {
var isNowOnline = hasOnlineConnectionState(connectionState);

@@ -24,0 +24,0 @@

@@ -24,3 +24,3 @@ import Isomorphic from 'isomorphic/runtime';

createSocketRequest,
HTTPFactory
HTTPFactory,
} = Isomorphic;

@@ -63,5 +63,5 @@

return Math.floor(Math.random() * max);
}
},
};
export default ReactNative;

@@ -9,6 +9,6 @@ import Browser from '../browser';

AuthTransportCallback,
InternalAuthOptions
InternalAuthOptions,
} from 'core/auth/options';
var jsonp: AuthTransport = function(
var jsonp: AuthTransport = function (
context: Browser,

@@ -18,3 +18,3 @@ query: string,

authRequestType: AuthRequestType,
callback: AuthTransportCallback
callback: AuthTransportCallback,
) {

@@ -26,3 +26,3 @@ if (

Logger.warn(
`To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`
`To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`,
);

@@ -37,3 +37,3 @@ }

// Hacked wrapper.
context.auth_callbacks[callbackName] = function(data) {
context.auth_callbacks[callbackName] = function (data) {
callback(null, data);

@@ -40,0 +40,0 @@ };

@@ -8,3 +8,3 @@ import * as Collections from 'core/utils/collections';

import WebSocketPrioritizedCachedStrategy, {
TransportStrategyDictionary
TransportStrategyDictionary,
} from 'core/strategies/websocket_prioritized_cached_strategy';

@@ -17,3 +17,3 @@ import DelayedStrategy from 'core/strategies/delayed_strategy';

function testSupportsStrategy(strategy: Strategy) {
return function() {
return function () {
return strategy.isSupported();

@@ -23,6 +23,6 @@ };

var getDefaultStrategy = function(
var getDefaultStrategy = function (
config: Config,
baseOptions: StrategyOptions,
defineTransport: Function
defineTransport: Function,
): Strategy {

@@ -36,3 +36,3 @@ var definedTransports = <TransportStrategyDictionary>{};

options: StrategyOptions,
manager?: TransportManager
manager?: TransportManager,
) {

@@ -45,3 +45,3 @@ var transport = defineTransport(

options,
manager
manager,
);

@@ -57,6 +57,6 @@

hostTLS: config.wsHost + ':' + config.wssPort,
httpPath: config.wsPath
httpPath: config.wsPath,
});
var wss_options: StrategyOptions = Object.assign({}, ws_options, {
useTLS: true
useTLS: true,
});

@@ -66,3 +66,3 @@ var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {

hostTLS: config.httpHost + ':' + config.httpsPort,
httpPath: config.httpPath
httpPath: config.httpPath,
});

@@ -73,3 +73,3 @@

timeout: 15000,
timeoutLimit: 60000
timeoutLimit: 60000,
};

@@ -79,3 +79,3 @@

minPingDelay: 10000,
maxPingDelay: config.activityTimeout
maxPingDelay: config.activityTimeout,
});

@@ -85,3 +85,3 @@ var streaming_manager = new TransportManager({

minPingDelay: 10000,
maxPingDelay: config.activityTimeout
maxPingDelay: config.activityTimeout,
});

@@ -94,3 +94,3 @@

ws_options,
ws_manager
ws_manager,
);

@@ -102,3 +102,3 @@ var wss_transport = defineTransportStrategy(

wss_options,
ws_manager
ws_manager,
);

@@ -109,3 +109,3 @@ var sockjs_transport = defineTransportStrategy(

1,
sockjs_options
sockjs_options,
);

@@ -117,3 +117,3 @@ var xhr_streaming_transport = defineTransportStrategy(

sockjs_options,
streaming_manager
streaming_manager,
);

@@ -125,3 +125,3 @@ var xdr_streaming_transport = defineTransportStrategy(

sockjs_options,
streaming_manager
streaming_manager,
);

@@ -132,3 +132,3 @@ var xhr_polling_transport = defineTransportStrategy(

1,
sockjs_options
sockjs_options,
);

@@ -139,3 +139,3 @@ var xdr_polling_transport = defineTransportStrategy(

1,
sockjs_options
sockjs_options,
);

@@ -151,6 +151,6 @@

xhr_streaming_transport,
xdr_streaming_transport
)
xdr_streaming_transport,
),
],
timeouts
timeouts,
);

@@ -162,6 +162,6 @@ var polling_loop = new SequentialStrategy(

xhr_polling_transport,
xdr_polling_transport
)
xdr_polling_transport,
),
],
timeouts
timeouts,
);

@@ -175,8 +175,8 @@

streaming_loop,
new DelayedStrategy(polling_loop, { delay: 4000 })
new DelayedStrategy(polling_loop, { delay: 4000 }),
]),
polling_loop
)
polling_loop,
),
],
timeouts
timeouts,
);

@@ -187,3 +187,3 @@

http_loop,
sockjs_loop
sockjs_loop,
);

@@ -195,3 +195,3 @@

ws_loop,
new DelayedStrategy(http_fallback_loop, { delay: 2000 })
new DelayedStrategy(http_fallback_loop, { delay: 2000 }),
]);

@@ -202,3 +202,3 @@ } else {

new DelayedStrategy(wss_loop, { delay: 2000 }),
new DelayedStrategy(http_fallback_loop, { delay: 5000 })
new DelayedStrategy(http_fallback_loop, { delay: 5000 }),
]);

@@ -212,4 +212,4 @@ }

wsStrategy,
http_fallback_loop
)
http_fallback_loop,
),
),

@@ -220,4 +220,4 @@ definedTransports,

timeline: baseOptions.timeline,
useTLS: baseOptions.useTLS
}
useTLS: baseOptions.useTLS,
},
);

@@ -224,0 +224,0 @@ };

@@ -7,3 +7,3 @@ import { ScriptReceiverFactory } from './script_receiver_factory';

'_pusher_dependencies',
'Pusher.DependenciesReceivers'
'Pusher.DependenciesReceivers',
);

@@ -16,3 +16,3 @@

suffix: Defaults.dependency_suffix,
receivers: DependenciesReceivers
receivers: DependenciesReceivers,
});
import {
ScriptReceivers,
ScriptReceiverFactory
ScriptReceiverFactory,
} from './script_receiver_factory';

@@ -48,3 +48,3 @@ import Runtime from 'runtime';

var request = Runtime.createScriptRequest(self.getPath(name, options));
var receiver = self.receivers.create(function(error) {
var receiver = self.receivers.create(function (error) {
self.receivers.remove(receiver);

@@ -56,3 +56,3 @@

var successCallback = function(wasSuccessful) {
var successCallback = function (wasSuccessful) {
if (!wasSuccessful) {

@@ -59,0 +59,0 @@ request.cleanup();

@@ -38,3 +38,3 @@ import ScriptReceiver from './script_receiver';

var called = false;
var callbackWrapper = function() {
var callbackWrapper = function () {
if (!called) {

@@ -57,3 +57,3 @@ callback.apply(null, arguments);

'_pusher_script_',
'Pusher.ScriptReceivers'
'Pusher.ScriptReceivers',
);

@@ -32,10 +32,10 @@ import ScriptReceiver from './script_receiver';

if (self.script.addEventListener) {
self.script.onerror = function() {
self.script.onerror = function () {
receiver.callback(errorString);
};
self.script.onload = function() {
self.script.onload = function () {
receiver.callback(null);
};
} else {
self.script.onreadystatechange = function() {
self.script.onreadystatechange = function () {
if (

@@ -42,0 +42,0 @@ self.script.readyState === 'loaded' ||

@@ -7,13 +7,13 @@ import HTTPRequest from 'core/http/http_request';

var hooks: RequestHooks = {
getRequest: function(socket: HTTPRequest): Ajax {
getRequest: function (socket: HTTPRequest): Ajax {
var xdr = new (<any>window).XDomainRequest();
xdr.ontimeout = function() {
xdr.ontimeout = function () {
socket.emit('error', new Errors.RequestTimedOut());
socket.close();
};
xdr.onerror = function(e) {
xdr.onerror = function (e) {
socket.emit('error', e);
socket.close();
};
xdr.onprogress = function() {
xdr.onprogress = function () {
if (xdr.responseText && xdr.responseText.length > 0) {

@@ -23,3 +23,3 @@ socket.onChunk(200, xdr.responseText);

};
xdr.onload = function() {
xdr.onload = function () {
if (xdr.responseText && xdr.responseText.length > 0) {

@@ -33,8 +33,8 @@ socket.onChunk(200, xdr.responseText);

},
abortRequest: function(xdr: Ajax) {
abortRequest: function (xdr: Ajax) {
xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
xdr.abort();
}
},
};
export default hooks;
import xdrHooks from './http_xdomain_request';
import HTTP from 'isomorphic/http/http';
HTTP.createXDR = function(method, url) {
HTTP.createXDR = function (method, url) {
return this.createRequest(xdrHooks, method, url);

@@ -6,0 +6,0 @@ };

@@ -18,13 +18,13 @@ import Reachability from 'core/reachability';

'online',
function() {
function () {
self.emit('online');
},
false
false,
);
window.addEventListener(
'offline',
function() {
function () {
self.emit('offline');
},
false
false,
);

@@ -31,0 +31,0 @@ }

@@ -163,3 +163,3 @@ import Browser from './browser';

*/
const random = function() {
const random = function () {
const crypto = window.crypto || window['msCrypto'];

@@ -172,5 +172,5 @@ const random = crypto.getRandomValues(new Uint32Array(1))[0];

return Math.floor(random() * max);
}
},
};
export default Runtime;

@@ -7,4 +7,4 @@ import TimelineSender from 'core/timeline/timeline_sender';

var getAgent = function(sender: TimelineSender, useTLS: boolean) {
return function(data: any, callback: Function) {
var getAgent = function (sender: TimelineSender, useTLS: boolean) {
return function (data: any, callback: Function) {
var scheme = 'http' + (useTLS ? 's' : '') + '://';

@@ -15,3 +15,3 @@ var url =

var receiver = Browser.ScriptReceivers.create(function(error, result) {
var receiver = Browser.ScriptReceivers.create(function (error, result) {
ScriptReceivers.remove(receiver);

@@ -33,5 +33,5 @@ request.cleanup();

name: 'jsonp',
getAgent
getAgent,
};
export default jsonp;

@@ -7,3 +7,3 @@ import { Dependencies } from '../dom/dependencies';

*/
export default function() {
export default function () {
var self = this;

@@ -13,4 +13,4 @@

self.buildTimelineMessage({
transport: self.name + (self.options.useTLS ? 's' : '')
})
transport: self.name + (self.options.useTLS ? 's' : ''),
}),
);

@@ -25,3 +25,3 @@

{ useTLS: self.options.useTLS },
function(error, callback) {
function (error, callback) {
if (self.hooks.isInitialized()) {

@@ -37,3 +37,3 @@ self.changeState('initialized');

}
}
},
);

@@ -40,0 +40,0 @@ } else {

import {
default as Transports,
streamingConfiguration,
pollingConfiguration
pollingConfiguration,
} from 'isomorphic/transports/transports';

@@ -19,30 +19,30 @@ import Transport from 'core/transports/transport';

isSupported: function() {
isSupported: function () {
return true;
},
isInitialized: function() {
isInitialized: function () {
return window.SockJS !== undefined;
},
getSocket: function(url, options) {
getSocket: function (url, options) {
return new window.SockJS(url, null, {
js_path: Dependencies.getPath('sockjs', {
useTLS: options.useTLS
useTLS: options.useTLS,
}),
ignore_null_origin: options.ignoreNullOrigin
ignore_null_origin: options.ignoreNullOrigin,
});
},
beforeOpen: function(socket, path) {
beforeOpen: function (socket, path) {
socket.send(
JSON.stringify({
path: path
})
path: path,
}),
);
}
},
});
var xdrConfiguration = {
isSupported: function(environment): boolean {
isSupported: function (environment): boolean {
var yes = Runtime.isXDRSupported(environment.useTLS);
return yes;
}
},
};

@@ -54,3 +54,3 @@

Collections.extend({}, streamingConfiguration, xdrConfiguration)
)
),
);

@@ -60,3 +60,5 @@

var XDRPollingTransport = new Transport(
<TransportHooks>Collections.extend({}, pollingConfiguration, xdrConfiguration)
<TransportHooks>(
Collections.extend({}, pollingConfiguration, xdrConfiguration)
),
);

@@ -63,0 +65,0 @@

@@ -6,7 +6,7 @@ import AbstractRuntime from 'runtimes/interface';

AuthTransportCallback,
InternalAuthOptions
InternalAuthOptions,
} from 'core/auth/options';
import { HTTPAuthError } from 'core/errors';
var fetchAuth: AuthTransport = function(
var fetchAuth: AuthTransport = function (
context: AbstractRuntime,

@@ -16,3 +16,3 @@ query: string,

authRequestType: AuthRequestType,
callback: AuthTransportCallback
callback: AuthTransportCallback,
) {

@@ -38,7 +38,7 @@ var headers = new Headers();

credentials: 'same-origin',
method: 'POST'
method: 'POST',
});
return fetch(request)
.then(response => {
.then((response) => {
let { status } = response;

@@ -52,6 +52,6 @@ if (status === 200) {

status,
`Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`
`Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`,
);
})
.then(data => {
.then((data) => {
let parsedData;

@@ -63,3 +63,3 @@ try {

200,
`JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`
`JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`,
);

@@ -69,3 +69,3 @@ }

})
.catch(err => {
.catch((err) => {
callback(err, null);

@@ -72,0 +72,0 @@ });

@@ -24,3 +24,3 @@ import Isomorphic from 'isomorphic/runtime';

createSocketRequest,
HTTPFactory
HTTPFactory,
} = Isomorphic;

@@ -65,3 +65,3 @@

*/
const random = function() {
const random = function () {
const crypto = globalThis.crypto || globalThis['msCrypto'];

@@ -74,5 +74,5 @@ const random = crypto.getRandomValues(new Uint32Array(1))[0];

return Math.floor(random() * max);
}
},
};
export default Worker;

@@ -8,4 +8,4 @@ import Logger from 'core/logger';

var getAgent = function(sender: TimelineSender, useTLS: boolean) {
return function(data: any, callback: Function) {
var getAgent = function (sender: TimelineSender, useTLS: boolean) {
return function (data: any, callback: Function) {
var scheme = 'http' + (useTLS ? 's' : '') + '://';

@@ -18,3 +18,3 @@ var url =

fetch(url)
.then(response => {
.then((response) => {
if (response.status !== 200) {

@@ -30,3 +30,3 @@ throw `received ${response.status} from stats.pusher.com`;

})
.catch(err => {
.catch((err) => {
Logger.debug('TimelineSender Error: ', err);

@@ -39,5 +39,5 @@ });

name: 'xhr',
getAgent
getAgent,
};
export default fetchTimeline;

@@ -30,3 +30,3 @@ export declare enum AuthRequestType {

export type AuthTransportCallback = ChannelAuthorizationCallback | UserAuthenticationCallback;
export interface InternalAuthOptions {
export interface AuthOptionsT<AuthHandler> {
transport: 'ajax' | 'jsonp';

@@ -38,8 +38,13 @@ endpoint: string;

headersProvider?: () => any;
customHandler?: AuthHandler;
}
export type CustomAuthOptions<AuthHandler> = {
customHandler: AuthHandler;
};
export type AuthOptionsT<AuthHandler> = InternalAuthOptions | CustomAuthOptions<AuthHandler>;
export declare type UserAuthenticationOptions = AuthOptionsT<UserAuthenticationHandler>;
export declare type ChannelAuthorizationOptions = AuthOptionsT<ChannelAuthorizationHandler>;
export interface InternalAuthOptions {
transport: 'ajax' | 'jsonp';
endpoint: string;
params?: any;
headers?: any;
paramsProvider?: () => any;
headersProvider?: () => any;
}

@@ -27,3 +27,2 @@ import { default as EventsDispatcher } from '../events/dispatcher';

constructor(key: string, options: ConnectionManagerOptions);
switchCluster(key: string): void;
connect(): void;

@@ -30,0 +29,0 @@ send(data: any): boolean;

@@ -34,6 +34,2 @@ import { ChannelAuthorizationOptions, UserAuthenticationOptions } from './auth/options';

}
export interface ClusterOptions {
appKey: string;
cluster: string;
}
export declare function validateOptions(options: any): void;

@@ -9,3 +9,3 @@ import AbstractRuntime from '../runtimes/interface';

import { PeriodicTimer } from './utils/timers';
import { Options, ClusterOptions } from './options';
import { Options } from './options';
import { Config } from './config';

@@ -25,3 +25,2 @@ import UserFacade from './user';

key: string;
options: Options;
config: Config;

@@ -37,3 +36,2 @@ channels: Channels;

constructor(app_key: string, options: Options);
switchCluster(options: ClusterOptions): void;
channel(name: string): Channel;

@@ -40,0 +38,0 @@ allChannels(): Channel[];

@@ -8,3 +8,3 @@ var path = require('path');

entry: {
pusher: './src/core/pusher-with-encryption.js'
pusher: './src/core/pusher-with-encryption.js',
},

@@ -15,3 +15,3 @@ output: {

path: path.join(__dirname, '../dist/node'),
filename: 'pusher.js'
filename: 'pusher.js',
},

@@ -21,9 +21,9 @@ target: 'node',

// in order to import the appropriate runtime.ts
modules: ['src/runtimes/node']
modules: ['src/runtimes/node'],
},
plugins: [
new webpack.DefinePlugin({
RUNTIME: JSON.stringify('node')
})
]
RUNTIME: JSON.stringify('node'),
}),
],
});
var path = require('path');
var NormalModuleReplacementPlugin = require('webpack')
.NormalModuleReplacementPlugin;
var NormalModuleReplacementPlugin =
require('webpack').NormalModuleReplacementPlugin;
var version = require('../package').version;

@@ -12,3 +12,3 @@ const { merge } = require('webpack-merge');

entry: {
pusher: './src/core/pusher-with-encryption.js'
pusher: './src/core/pusher-with-encryption.js',
},

@@ -19,19 +19,19 @@ output: {

path: path.join(__dirname, '../dist/react-native'),
filename: 'pusher.js'
filename: 'pusher.js',
},
externals: {
// our Reachability implementation needs to reference @react-native-community/netinfo.
'@react-native-community/netinfo': '@react-native-community/netinfo'
'@react-native-community/netinfo': '@react-native-community/netinfo',
},
resolve: {
modules: ['src/runtimes/react-native']
modules: ['src/runtimes/react-native'],
},
plugins: [
new webpack.DefinePlugin({
RUNTIME: JSON.stringify('react-native')
RUNTIME: JSON.stringify('react-native'),
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
})
]
Buffer: ['buffer', 'Buffer'],
}),
],
});

@@ -14,6 +14,6 @@ 'use strict';

optimization: {
minimize: minimize
minimize: minimize,
},
entry: {
pusher: './src/core/pusher.js'
pusher: './src/core/pusher.js',
},

@@ -24,3 +24,3 @@ devtool: 'source-map',

// add runtimes for easier importing of isomorphic runtime modules
modules: ['src', 'src/runtimes', 'node_modules']
modules: ['src', 'src/runtimes', 'node_modules'],
},

@@ -33,5 +33,5 @@ module: {

enforce: 'pre',
use: ['source-map-loader']
}
]
use: ['source-map-loader'],
},
],
},

@@ -42,3 +42,3 @@ node: {

// as it won't be used.
Buffer: false
Buffer: false,
},

@@ -51,5 +51,5 @@ plugins: [

CDN_HTTPS: JSON.stringify(Config.cdn_https),
DEPENDENCY_SUFFIX: JSON.stringify(Config.dependency_suffix)
})
]
DEPENDENCY_SUFFIX: JSON.stringify(Config.dependency_suffix),
}),
],
};

@@ -19,3 +19,3 @@ var path = require('path');

entry: {
pusher: entry
pusher: entry,
},

@@ -26,6 +26,6 @@ output: {

filename: filename,
libraryTarget: 'umd'
libraryTarget: 'umd',
},
resolve: {
modules: ['src/runtimes/web']
modules: ['src/runtimes/web'],
},

@@ -35,5 +35,5 @@ plugins: [

global: 'window',
RUNTIME: JSON.stringify('web')
})
]
RUNTIME: JSON.stringify('web'),
}),
],
});
var path = require('path');
var NormalModuleReplacementPlugin = require('webpack')
.NormalModuleReplacementPlugin;
var NormalModuleReplacementPlugin =
require('webpack').NormalModuleReplacementPlugin;
var version = require('../package').version;

@@ -21,3 +21,3 @@ const { merge } = require('webpack-merge');

entry: {
pusher: entry
pusher: entry,
},

@@ -29,7 +29,7 @@ output: {

libraryTarget: 'umd',
globalObject: 'this'
globalObject: 'this',
},
resolve: {
// in order to import the appropriate runtime.ts
modules: ['src/runtimes/worker']
modules: ['src/runtimes/worker'],
},

@@ -39,7 +39,7 @@ plugins: [

global: 'self',
RUNTIME: JSON.stringify('worker')
})
]
RUNTIME: JSON.stringify('worker'),
}),
],
});
module.exports = config;

@@ -9,3 +9,3 @@ var config = require('./config.web');

'webpack-dev-server/client?http://localhost:' + port + '/',
'webpack/hot/dev-server'
'webpack/hot/dev-server',
];

@@ -15,5 +15,5 @@

var server = new WebpackDevServer(compiler, {
hot: true
hot: true,
});
server.listen(port);

@@ -5,3 +5,3 @@ module.exports = {

cdn_https: process.env.CDN_HTTPS || 'https://js.pusher.com',
dependency_suffix: process.env.MINIFY ? '.min' : ''
dependency_suffix: process.env.MINIFY ? '.min' : '',
};

@@ -23,3 +23,3 @@ export {

// The following types are provided for backward compatability
// The following types are provided for backward compatibility
export {

@@ -26,0 +26,0 @@ DeprecatedAuthOptions as AuthOptions,

@@ -23,3 +23,3 @@ export {

// The following types are provided for backward compatability
// The following types are provided for backward compatibility
export {

@@ -26,0 +26,0 @@ DeprecatedAuthOptions as AuthOptions,

@@ -23,3 +23,3 @@ export {

// The following types are provided for backward compatability
// The following types are provided for backward compatibility
export {

@@ -26,0 +26,0 @@ DeprecatedAuthOptions as AuthOptions,

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc