text: /*!
   * Pusher JavaScript Library v5.0.2
   * https://pusher.com/
   *
   * Copyright 2017, Pusher
   * Released under the MIT licence.
   */
  !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Pusher=n():t.Pusher=n()}(window,(function(){return function(t){var n={};function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:i})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(e.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(i,o,function(n){return t[n]}.bind(null,o));return i},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=0)}([function(t,n,e){t.exports=e(1).default},function(t,n,e){"use strict";e.r(n);var i=function(){function t(t,n){this.lastId=0,this.prefix=t,this.name=n}return t.prototype.create=function(t){this.lastId++;var n=this.lastId,e=this.prefix+n,i=this.name+"["+n+"]",o=!1,r=function(){o||(t.apply(null,arguments),o=!0)};return this[n]=r,{number:n,id:e,name:i,callback:r}},t.prototype.remove=function(t){delete this[t.number]},t}(),o=new i("_pusher_script_","Pusher.ScriptReceivers"),r={VERSION:"5.0.2",PROTOCOL:7,host:"ws.pusherapp.com",ws_port:80,wss_port:443,ws_path:"",sockjs_host:"sockjs.pusher.com",sockjs_http_port:80,sockjs_https_port:443,sockjs_path:"/pusher",stats_host:"stats.pusher.com",channel_auth_endpoint:"/pusher/auth",channel_auth_transport:"ajax",activity_timeout:12e4,pong_timeout:3e4,unavailable_timeout:1e4,cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""},s=function(){function t(t){this.options=t,this.receivers=t.receivers||o,this.loading={}}return t.prototype.load=function(t,n,e){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(e);else{i.loading[t]=[e];var o=vn.createScriptRequest(i.getPath(t,n)),r=i.receivers.create((function(n){if(i.receivers.remove(r),i.loading[t]){var e=i.loading[t];delete i.loading[t];for(var s=function(t){t||o.cleanup()},c=0;c<e.length;c++)e[c](n,s)}}));o.send(r)}},t.prototype.getRoot=function(t){var n=vn.getDocument().location.protocol;return(t&&t.useTLS||"https:"===n?this.options.cdn_https:this.options.cdn_http).replace(/\/*$/,"")+"/"+this.options.version},t.prototype.getPath=function(t,n){return this.getRoot(n)+"/"+t+this.options.suffix+".js"},t}(),c=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new s({cdn_http:r.cdn_http,cdn_https:r.cdn_https,version:r.VERSION,suffix:r.dependency_suffix,receivers:c});for(var u=String.fromCharCode,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p={},l=0,f=h.length;l<f;l++)p[h.charAt(l)]=l;var d,y=function(t){var n=t.charCodeAt(0);return n<128?t:n<2048?u(192|n>>>6)+u(128|63&n):u(224|n>>>12&15)+u(128|n>>>6&63)+u(128|63&n)},v=function(t){return t.replace(/[^\x00-\x7F]/g,y)},g=function(t){var n=[0,2,1][t.length%3],e=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[h.charAt(e>>>18),h.charAt(e>>>12&63),n>=2?"=":h.charAt(e>>>6&63),n>=1?"=":h.charAt(63&e)].join("")},m=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,g)},b=function(){function t(t,n,e,i){var o=this;this.clear=n,this.timer=t((function(){o.timer&&(o.timer=i(o.timer))}),e)}return t.prototype.isRunning=function(){return null!==this.timer},t.prototype.ensureAborted=function(){this.timer&&(this.clear(this.timer),this.timer=null)},t}(),_=(d=function(t,n){return(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}d(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});function w(t){window.clearTimeout(t)}function S(t){window.clearInterval(t)}var k=function(t){function n(n,e){return t.call(this,setTimeout,w,n,(function(t){return e(),null}))||this}return _(n,t),n}(b),T=function(t){function n(n,e){return t.call(this,setInterval,S,n,(function(t){return e(),t}))||this}return _(n,t),n}(b),C={now:function(){return Date.now?Date.now():(new Date).valueOf()},defer:function(t){return new k(0,t)},method:function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var i=Array.prototype.slice.call(arguments,1);return function(n){return n[t].apply(n,i.concat(arguments))}}};function P(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];for(var i=0;i<n.length;i++){var o=n[i];for(var r in o)o[r]&&o[r].constructor&&o[r].constructor===Object?t[r]=P(t[r]||{},o[r]):t[r]=o[r]}return t}function O(){for(var t=["Pusher"],n=0;n<arguments.length;n++)"string"==typeof arguments[n]?t.push(arguments[n]):t.push(H(arguments[n]));return t.join(" : ")}function E(t,n){var e=Array.prototype.indexOf;if(null===t)return-1;if(e&&t.indexOf===e)return t.indexOf(n);for(var i=0,o=t.length;i<o;i++)if(t[i]===n)return i;return-1}function L(t,n){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&n(t[e],e,t)}function R(t){var n=[];return L(t,(function(t,e){n.push(e)})),n}function x(t,n,e){for(var i=0;i<t.length;i++)n.call(e||window,t[i],i,t)}function A(t,n){for(var e=[],i=0;i<t.length;i++)e.push(n(t[i],i,t,e));return e}function j(t,n){n=n||function(t){return!!t};for(var e=[],i=0;i<t.length;i++)n(t[i],i,t,e)&&e.push(t[i]);return e}function I(t,n){var e={};return L(t,(function(i,o){(n&&n(i,o,t,e)||Boolean(i))&&(e[o]=i)})),e}function D(t,n){for(var e=0;e<t.length;e++)if(n(t[e],e,t))return!0;return!1}function N(t){return n=function(t){return"object"==typeof t&&(t=H(t)),encodeURIComponent((n=t.toString(),m(v(n))));var n},e={},L(t,(function(t,i){e[i]=n(t)})),e;var n,e}function M(t){var n,e,i=I(t,(function(t){return void 0!==t}));return A((n=N(i),e=[],L(n,(function(t,n){e.push([n,t])})),e),C.method("join","=")).join("&")}function H(t){try{return JSON.stringify(t)}catch(i){return JSON.stringify((n=[],e=[],function t(i,o){var r,s,c;switch(typeof i){case"object":if(!i)return null;for(r=0;r<n.length;r+=1)if(n[r]===i)return{$ref:e[r]};if(n.push(i),e.push(o),"[object Array]"===Object.prototype.toString.apply(i))for(c=[],r=0;r<i.length;r+=1)c[r]=t(i[r],o+"["+r+"]");else for(s in c={},i)Object.prototype.hasOwnProperty.call(i,s)&&(c[s]=t(i[s],o+"["+JSON.stringify(s)+"]"));return c;case"number":case"string":case"boolean":return i}}(t,"$")))}var n,e}var q={debug:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];On.log&&On.log(O.apply(this,arguments))},warn:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=O.apply(this,arguments);On.log?On.log(e):window.console&&(window.console.warn?window.console.warn(e):window.console.log&&window.console.log(e))}},z={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/authenticating_users"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"}}},U={buildLogSuffix:function(t){var n,e=z.urls[t];return e?(e.fullUrl?n=e.fullUrl:e.path&&(n=z.baseUrl+e.path),n?"See: "+n:""):""}},B=function(t,n,e){var i,o=this;for(var r in(i=vn.createXHR()).open("POST",o.options.authEndpoint,!0),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),this.authOptions.headers)i.setRequestHeader(r,this.authOptions.headers[r]);return i.onreadystatechange=function(){if(4===i.readyState)if(200===i.status){var t,n=!1;try{t=JSON.parse(i.responseText),n=!0}catch(t){e(!0,"JSON returned from webapp was invalid, yet status code was 200. Data was: "+i.responseText)}n&&e(!1,t)}else{var r=U.buildLogSuffix("authenticationEndpoint");q.warn("Unable to retrieve auth string from auth endpoint - received status "+i.status+" from "+o.options.authEndpoint+". Clients must be authenticated to join private or presence channels. "+r),e(!0,i.status)}},i.send(this.composeQuery(n)),i},X=function(t,n,e){void 0!==this.authOptions.headers&&q.warn("Warn","To send headers with the auth request, you must use AJAX, rather than JSONP.");var i=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),r=o.createElement("script");t.auth_callbacks[i]=function(t){e(!1,t)};var s="Pusher.auth_callbacks['"+i+"']";r.src=this.options.authEndpoint+"?callback="+encodeURIComponent(s)+"&"+this.composeQuery(n);var c=o.getElementsByTagName("head")[0]||o.documentElement;c.insertBefore(r,c.firstChild)},F=function(){function t(t){this.src=t}return t.prototype.send=function(t){var n=this,e="Error loading "+n.src;n.script=document.createElement("script"),n.script.id=t.id,n.script.src=n.src,n.script.type="text/javascript",n.script.charset="UTF-8",n.script.addEventListener?(n.script.onerror=function(){t.callback(e)},n.script.onload=function(){t.callback(null)}):n.script.onreadystatechange=function(){"loaded"!==n.script.readyState&&"complete"!==n.script.readyState||t.callback(null)},void 0===n.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(n.errorScript=document.createElement("script"),n.errorScript.id=t.id+"_error",n.errorScript.text=t.name+"('"+e+"');",n.script.async=n.errorScript.async=!1):n.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(n.script,i.firstChild),n.errorScript&&i.insertBefore(n.errorScript,n.script.nextSibling)},t.prototype.cleanup=function(){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},t}(),J=function(){function t(t,n){this.url=t,this.data=n}return t.prototype.send=function(t){if(!this.request){var n=M(this.data),e=this.url+"/"+t.number+"?"+n;this.request=vn.createScriptRequest(e),this.request.send(t)}},t.prototype.cleanup=function(){this.request&&this.request.cleanup()},t}(),W={name:"jsonp",getAgent:function(t,n){return function(e,i){var r="http"+(n?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=vn.createJSONPRequest(r,e),c=vn.ScriptReceivers.create((function(n,e){o.remove(c),s.cleanup(),e&&e.host&&(t.host=e.host),i&&i(n,e)}));s.send(c)}}};function G(t,n,e){return t+(n.useTLS?"s":"")+"://"+(n.useTLS?n.hostTLS:n.hostNonTLS)+e}function Q(t,n){return"/app/"+t+("?protocol="+r.PROTOCOL+"&client=js&version="+r.VERSION+(n?"&"+n:""))}var V={getInitial:function(t,n){return G("ws",n,(n.httpPath||"")+Q(t,"flash=false"))}},Y={getInitial:function(t,n){return G("http",n,(n.httpPath||"/pusher")+Q(t))}},$={getInitial:function(t,n){return G("http",n,n.httpPath||"/pusher")},getPath:function(t,n){return Q(t)}},K=function(){function t(){this._callbacks={}}return t.prototype.get=function(t){return this._callbacks[Z(t)]},t.prototype.add=function(t,n,e){var i=Z(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:n,context:e})},t.prototype.remove=function(t,n,e){if(t||n||e){var i=t?[Z(t)]:R(this._callbacks);n||e?this.removeCallback(i,n,e):this.removeAllCallbacks(i)}else this._callbacks={}},t.prototype.removeCallback=function(t,n,e){x(t,(function(t){this._callbacks[t]=j(this._callbacks[t]||[],(function(t){return n&&n!==t.fn||e&&e!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)},t.prototype.removeAllCallbacks=function(t){x(t,(function(t){delete this._callbacks[t]}),this)},t}();function Z(t){return"_"+t}var tt=function(){function t(t){this.callbacks=new K,this.global_callbacks=[],this.failThrough=t}return t.prototype.bind=function(t,n,e){return this.callbacks.add(t,n,e),this},t.prototype.bind_global=function(t){return this.global_callbacks.push(t),this},t.prototype.unbind=function(t,n,e){return this.callbacks.remove(t,n,e),this},t.prototype.unbind_global=function(t){return t?(this.global_callbacks=j(this.global_callbacks||[],(function(n){return n!==t})),this):(this.global_callbacks=[],this)},t.prototype.unbind_all=function(){return this.unbind(),this.unbind_global(),this},t.prototype.emit=function(t,n,e){for(var i=0;i<this.global_callbacks.length;i++)this.global_callbacks[i](t,n);var o=this.callbacks.get(t),r=[];if(e?r.push(n,e):n&&r.push(n),o&&o.length>0)for(i=0;i<o.length;i++)o[i].fn.apply(o[i].context||window,r);else this.failThrough&&this.failThrough(t,n);return this},t}(),nt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),et=function(t){function n(n,e,i,o,r){var s=t.call(this)||this;return s.initialize=vn.transportConnectionInitializer,s.hooks=n,s.name=e,s.priority=i,s.key=o,s.options=r,s.state="new",s.timeline=r.timeline,s.activityTimeout=r.activityTimeout,s.id=s.timeline.generateUniqueID(),s}return nt(n,t),n.prototype.handlesActivityChecks=function(){return Boolean(this.hooks.handlesActivityChecks)},n.prototype.supportsPing=function(){return Boolean(this.hooks.supportsPing)},n.prototype.connect=function(){var t=this;if(this.socket||"initialized"!==this.state)return!1;var n=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(n,this.options)}catch(n){return C.defer((function(){t.onError(n),t.changeState("closed")})),!1}return this.bindListeners(),q.debug("Connecting",{transport:this.name,url:n}),this.changeState("connecting"),!0},n.prototype.close=function(){return!!this.socket&&(this.socket.close(),!0)},n.prototype.send=function(t){var n=this;return"open"===this.state&&(C.defer((function(){n.socket&&n.socket.send(t)})),!0)},n.prototype.ping=function(){"open"===this.state&&this.supportsPing()&&this.socket.ping()},n.prototype.onOpen=function(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0},n.prototype.onError=function(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))},n.prototype.onClose=function(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0},n.prototype.onMessage=function(t){this.emit("message",t)},n.prototype.onActivity=function(){this.emit("activity")},n.prototype.bindListeners=function(){var t=this;this.socket.onopen=function(){t.onOpen()},this.socket.onerror=function(n){t.onError(n)},this.socket.onclose=function(n){t.onClose(n)},this.socket.onmessage=function(n){t.onMessage(n)},this.supportsPing()&&(this.socket.onactivity=function(){t.onActivity()})},n.prototype.unbindListeners=function(){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))},n.prototype.changeState=function(t,n){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:n})),this.emit(t,n)},n.prototype.buildTimelineMessage=function(t){return P({cid:this.id},t)},n}(tt),it=function(){function t(t){this.hooks=t}return t.prototype.isSupported=function(t){return this.hooks.isSupported(t)},t.prototype.createConnection=function(t,n,e,i){return new et(this.hooks,t,n,e,i)},t}(),ot=new it({urls:V,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(vn.getWebSocketAPI())},isSupported:function(){return Boolean(vn.getWebSocketAPI())},getSocket:function(t){return vn.createWebSocket(t)}}),rt={urls:Y,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},st=P({getSocket:function(t){return vn.HTTPFactory.createStreamingSocket(t)}},rt),ct=P({getSocket:function(t){return vn.HTTPFactory.createPollingSocket(t)}},rt),at={isSupported:function(){return vn.isXHRSupported()}},ut={ws:ot,xhr_streaming:new it(P({},st,at)),xhr_polling:new it(P({},ct,at))},ht=new it({file:"sockjs",urls:$,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,n){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:n.useTLS}),ignore_null_origin:n.ignoreNullOrigin})},beforeOpen:function(t,n){t.send(JSON.stringify({path:n}))}}),pt={isSupported:function(t){return vn.isXDRSupported(t.useTLS)}},lt=new it(P({},st,pt)),ft=new it(P({},ct,pt));ut.xdr_streaming=lt,ut.xdr_polling=ft,ut.sockjs=ht;var dt=ut,yt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),vt=new(function(t){function n(){var n=t.call(this)||this,e=n;return void 0!==window.addEventListener&&(window.addEventListener("online",(function(){e.emit("online")}),!1),window.addEventListener("offline",(function(){e.emit("offline")}),!1)),n}return yt(n,t),n.prototype.isOnline=function(){return void 0===window.navigator.onLine||window.navigator.onLine},n}(tt)),gt=function(){function t(t,n,e){this.manager=t,this.transport=n,this.minPingDelay=e.minPingDelay,this.maxPingDelay=e.maxPingDelay,this.pingDelay=void 0}return t.prototype.createConnection=function(t,n,e,i){var o=this;i=P({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,n,e,i),s=null,c=function(){r.unbind("open",c),r.bind("closed",a),s=C.now()},a=function(t){if(r.unbind("closed",a),1002===t.code||1003===t.code)o.manager.reportDeath();else if(!t.wasClean&&s){var n=C.now()-s;n<2*o.maxPingDelay&&(o.manager.reportDeath(),o.pingDelay=Math.max(n/2,o.minPingDelay))}};return r.bind("open",c),r},t.prototype.isSupported=function(t){return this.manager.isAlive()&&this.transport.isSupported(t)},t}(),mt={decodeMessage:function(t){try{var n=JSON.parse(t.data),e=n.data;if("string"==typeof e)try{e=JSON.parse(n.data)}catch(t){}var i={event:n.event,channel:n.channel,data:e};return n.user_id&&(i.user_id=n.user_id),i}catch(n){throw{type:"MessageParseError",error:n,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var n=mt.decodeMessage(t);if("pusher:connection_established"===n.event){if(!n.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:n.data.socket_id,activityTimeout:1e3*n.data.activity_timeout}}if("pusher:error"===n.event)return{action:this.getCloseAction(n.data),error:this.getCloseError(n.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}},bt=mt,_t=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),wt=function(t){function n(n,e){var i=t.call(this)||this;return i.id=n,i.transport=e,i.activityTimeout=e.activityTimeout,i.bindListeners(),i}return _t(n,t),n.prototype.handlesActivityChecks=function(){return this.transport.handlesActivityChecks()},n.prototype.send=function(t){return this.transport.send(t)},n.prototype.send_event=function(t,n,e){var i={event:t,data:n};return e&&(i.channel=e),q.debug("Event sent",i),this.send(bt.encodeMessage(i))},n.prototype.ping=function(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})},n.prototype.close=function(){this.transport.close()},n.prototype.bindListeners=function(){var t=this,n={message:function(n){var e;try{e=bt.decodeMessage(n)}catch(e){t.emit("error",{type:"MessageParseError",error:e,data:n.data})}if(void 0!==e){switch(q.debug("Event recd",e),e.event){case"pusher:error":t.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":t.emit("ping");break;case"pusher:pong":t.emit("pong")}t.emit("message",e)}},activity:function(){t.emit("activity")},error:function(n){t.emit("error",{type:"WebSocketError",error:n})},closed:function(n){e(),n&&n.code&&t.handleCloseEvent(n),t.transport=null,t.emit("closed")}},e=function(){L(n,(function(n,e){t.transport.unbind(e,n)}))};L(n,(function(n,e){t.transport.bind(e,n)}))},n.prototype.handleCloseEvent=function(t){var n=bt.getCloseAction(t),e=bt.getCloseError(t);e&&this.emit("error",e),n&&this.emit(n,{action:n,error:e})},n}(tt),St=function(){function t(t,n){this.transport=t,this.callback=n,this.bindListeners()}return t.prototype.close=function(){this.unbindListeners(),this.transport.close()},t.prototype.bindListeners=function(){var t=this;this.onMessage=function(n){var e;t.unbindListeners();try{e=bt.processHandshake(n)}catch(n){return t.finish("error",{error:n}),void t.transport.close()}"connected"===e.action?t.finish("connected",{connection:new wt(e.id,t.transport),activityTimeout:e.activityTimeout}):(t.finish(e.action,{error:e.error}),t.transport.close())},this.onClosed=function(n){t.unbindListeners();var e=bt.getCloseAction(n)||"backoff",i=bt.getCloseError(n);t.finish(e,{error:i})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)},t.prototype.unbindListeners=function(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)},t.prototype.finish=function(t,n){this.callback(P({transport:this.transport,action:t},n))},t}(),kt=function(){function t(t,n){this.channel=t;var e=n.authTransport;if(void 0===vn.getAuthorizers()[e])throw"'"+e+"' is not a recognized auth transport";this.type=e,this.options=n,this.authOptions=(n||{}).auth||{}}return t.prototype.composeQuery=function(t){var n="socket_id="+encodeURIComponent(t)+"&channel_name="+encodeURIComponent(this.channel.name);for(var e in this.authOptions.params)n+="&"+encodeURIComponent(e)+"="+encodeURIComponent(this.authOptions.params[e]);return n},t.prototype.authorize=function(n,e){return t.authorizers=t.authorizers||vn.getAuthorizers(),t.authorizers[this.type].call(this,vn,n,e)},t}(),Tt=function(){function t(t,n){this.timeline=t,this.options=n||{}}return t.prototype.send=function(t,n){this.timeline.isEmpty()||this.timeline.send(vn.TimelineTransport.getAgent(this,t),n)},t}(),Ct=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),Pt=function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}return Ct(n,t),n}(Error),Ot=function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}return Ct(n,t),n}(Error),Et=function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}return Ct(n,t),n}(Error),Lt=function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}return Ct(n,t),n}(Error),Rt=(function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}Ct(n,t)}(Error),function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}return Ct(n,t),n}(Error)),xt=function(t){function n(n){var e=this.constructor,i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i}return Ct(n,t),n}(Error),At=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),jt=function(t){function n(n,e){var i=t.call(this,(function(t,e){q.debug("No callbacks on "+n+" for "+t)}))||this;return i.name=n,i.pusher=e,i.subscribed=!1,i.subscriptionPending=!1,i.subscriptionCancelled=!1,i}return At(n,t),n.prototype.authorize=function(t,n){return n(!1,{})},n.prototype.trigger=function(t,n){if(0!==t.indexOf("client-"))throw new Pt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var e=U.buildLogSuffix("triggeringClientEvents");q.warn("Client event triggered before channel 'subscription_succeeded' event . "+e)}return this.pusher.send_event(t,n,this.name)},n.prototype.disconnect=function(){this.subscribed=!1,this.subscriptionPending=!1},n.prototype.handleEvent=function(t){var n=t.event,e=t.data;if("pusher_internal:subscription_succeeded"===n)this.handleSubscriptionSucceededEvent(t);else if(0!==n.indexOf("pusher_internal:")){this.emit(n,e,{})}},n.prototype.handleSubscriptionSucceededEvent=function(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)},n.prototype.subscribe=function(){var t=this;this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(function(n,e){n?t.emit("pusher:subscription_error",e):t.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:t.name})})))},n.prototype.unsubscribe=function(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})},n.prototype.cancelSubscription=function(){this.subscriptionCancelled=!0},n.prototype.reinstateSubscription=function(){this.subscriptionCancelled=!1},n}(tt),It=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),Dt=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return It(n,t),n.prototype.authorize=function(t,n){return Bt.createAuthorizer(this,this.pusher.config).authorize(t,n)},n}(jt),Nt=function(){function t(){this.reset()}return t.prototype.get=function(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null},t.prototype.each=function(t){var n=this;L(this.members,(function(e,i){t(n.get(i))}))},t.prototype.setMyID=function(t){this.myID=t},t.prototype.onSubscription=function(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)},t.prototype.addMember=function(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)},t.prototype.removeMember=function(t){var n=this.get(t.user_id);return n&&(delete this.members[t.user_id],this.count--),n},t.prototype.reset=function(){this.members={},this.count=0,this.myID=null,this.me=null},t}(),Mt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),Ht=function(t){function n(n,e){var i=t.call(this,n,e)||this;return i.members=new Nt,i}return Mt(n,t),n.prototype.authorize=function(n,e){var i=this;t.prototype.authorize.call(this,n,(function(t,n){if(!t){if(void 0===n.channel_data){var o=U.buildLogSuffix("authenticationEndpoint");return q.warn("Invalid auth response for channel '"+i.name+"',expected 'channel_data' field. "+o),void e("Invalid auth response")}var r=JSON.parse(n.channel_data);i.members.setMyID(r.user_id)}e(t,n)}))},n.prototype.handleEvent=function(t){var n=t.event;if(0===n.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var e=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(n,e,i)}},n.prototype.handleInternalEvent=function(t){var n=t.event,e=t.data;switch(n){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(e);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var o=this.members.removeMember(e);o&&this.emit("pusher:member_removed",o)}},n.prototype.handleSubscriptionSucceededEvent=function(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))},n.prototype.disconnect=function(){this.members.reset(),t.prototype.disconnect.call(this)},n}(Dt),qt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),zt=function(t){function n(n,e){var i=t.call(this)||this;i.key=n,i.options=e||{},i.state="initialized",i.connection=null,i.usingTLS=!!e.useTLS,i.timeline=i.options.timeline,i.errorCallbacks=i.buildErrorCallbacks(),i.connectionCallbacks=i.buildConnectionCallbacks(i.errorCallbacks),i.handshakeCallbacks=i.buildHandshakeCallbacks(i.errorCallbacks);var o=vn.getNetwork();return o.bind("online",(function(){i.timeline.info({netinfo:"online"}),"connecting"!==i.state&&"unavailable"!==i.state||i.retryIn(0)})),o.bind("offline",(function(){i.timeline.info({netinfo:"offline"}),i.connection&&i.sendActivityCheck()})),i.updateStrategy(),i}return qt(n,t),n.prototype.connect=function(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))},n.prototype.send=function(t){return!!this.connection&&this.connection.send(t)},n.prototype.send_event=function(t,n,e){return!!this.connection&&this.connection.send_event(t,n,e)},n.prototype.disconnect=function(){this.disconnectInternally(),this.updateState("disconnected")},n.prototype.isUsingTLS=function(){return this.usingTLS},n.prototype.startConnecting=function(){var t=this,n=function(e,i){e?t.runner=t.strategy.connect(0,n):"error"===i.action?(t.emit("error",{type:"HandshakeError",error:i.error}),t.timeline.error({handshakeError:i.error})):(t.abortConnecting(),t.handshakeCallbacks[i.action](i))};this.runner=this.strategy.connect(0,n)},n.prototype.abortConnecting=function(){this.runner&&(this.runner.abort(),this.runner=null)},n.prototype.disconnectInternally=function(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()},n.prototype.updateStrategy=function(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})},n.prototype.retryIn=function(t){var n=this;this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new k(t||0,(function(){n.disconnectInternally(),n.connect()}))},n.prototype.clearRetryTimer=function(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)},n.prototype.setUnavailableTimer=function(){var t=this;this.unavailableTimer=new k(this.options.unavailableTimeout,(function(){t.updateState("unavailable")}))},n.prototype.clearUnavailableTimer=function(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()},n.prototype.sendActivityCheck=function(){var t=this;this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new k(this.options.pongTimeout,(function(){t.timeline.error({pong_timed_out:t.options.pongTimeout}),t.retryIn(0)}))},n.prototype.resetActivityCheck=function(){var t=this;this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new k(this.activityTimeout,(function(){t.sendActivityCheck()})))},n.prototype.stopActivityCheck=function(){this.activityTimer&&this.activityTimer.ensureAborted()},n.prototype.buildConnectionCallbacks=function(t){var n=this;return P({},t,{message:function(t){n.resetActivityCheck(),n.emit("message",t)},ping:function(){n.send_event("pusher:pong",{})},activity:function(){n.resetActivityCheck()},error:function(t){n.emit("error",{type:"WebSocketError",error:t})},closed:function(){n.abandonConnection(),n.shouldRetry()&&n.retryIn(1e3)}})},n.prototype.buildHandshakeCallbacks=function(t){var n=this;return P({},t,{connected:function(t){n.activityTimeout=Math.min(n.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),n.clearUnavailableTimer(),n.setConnection(t.connection),n.socket_id=n.connection.id,n.updateState("connected",{socket_id:n.socket_id})}})},n.prototype.buildErrorCallbacks=function(){var t=this,n=function(n){return function(e){e.error&&t.emit("error",{type:"WebSocketError",error:e.error}),n(e)}};return{tls_only:n((function(){t.usingTLS=!0,t.updateStrategy(),t.retryIn(0)})),refused:n((function(){t.disconnect()})),backoff:n((function(){t.retryIn(1e3)})),retry:n((function(){t.retryIn(0)}))}},n.prototype.setConnection=function(t){for(var n in this.connection=t,this.connectionCallbacks)this.connection.bind(n,this.connectionCallbacks[n]);this.resetActivityCheck()},n.prototype.abandonConnection=function(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var n=this.connection;return this.connection=null,n}},n.prototype.updateState=function(t,n){var e=this.state;if(this.state=t,e!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+n.socket_id),q.debug("State changed",e+" -> "+i),this.timeline.info({state:t,params:n}),this.emit("state_change",{previous:e,current:t}),this.emit(t,n)}},n.prototype.shouldRetry=function(){return"connecting"===this.state||"connected"===this.state},n}(tt),Ut=function(){function t(){this.channels={}}return t.prototype.add=function(t,n){return this.channels[t]||(this.channels[t]=function(t,n){return 0===t.indexOf("private-")?Bt.createPrivateChannel(t,n):0===t.indexOf("presence-")?Bt.createPresenceChannel(t,n):Bt.createChannel(t,n)}(t,n)),this.channels[t]},t.prototype.all=function(){return function(t){var n=[];return L(t,(function(t){n.push(t)})),n}(this.channels)},t.prototype.find=function(t){return this.channels[t]},t.prototype.remove=function(t){var n=this.channels[t];return delete this.channels[t],n},t.prototype.disconnect=function(){L(this.channels,(function(t){t.disconnect()}))},t}();var Bt={createChannels:function(){return new Ut},createConnectionManager:function(t,n){return new zt(t,n)},createChannel:function(t,n){return new jt(t,n)},createPrivateChannel:function(t,n){return new Dt(t,n)},createPresenceChannel:function(t,n){return new Ht(t,n)},createTimelineSender:function(t,n){return new Tt(t,n)},createAuthorizer:function(t,n){return n.authorizer?n.authorizer(t,n):new kt(t,n)},createHandshake:function(t,n){return new St(t,n)},createAssistantToTheTransportManager:function(t,n,e){return new gt(t,n,e)}},Xt=function(){function t(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}return t.prototype.getAssistant=function(t){return Bt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})},t.prototype.isAlive=function(){return this.livesLeft>0},t.prototype.reportDeath=function(){this.livesLeft-=1},t}(),Ft=function(){function t(t,n){this.strategies=t,this.loop=Boolean(n.loop),this.failFast=Boolean(n.failFast),this.timeout=n.timeout,this.timeoutLimit=n.timeoutLimit}return t.prototype.isSupported=function(){return D(this.strategies,C.method("isSupported"))},t.prototype.connect=function(t,n){var e=this,i=this.strategies,o=0,r=this.timeout,s=null,c=function(a,u){u?n(null,u):(o+=1,e.loop&&(o%=i.length),o<i.length?(r&&(r*=2,e.timeoutLimit&&(r=Math.min(r,e.timeoutLimit))),s=e.tryStrategy(i[o],t,{timeout:r,failFast:e.failFast},c)):n(!0))};return s=this.tryStrategy(i[o],t,{timeout:r,failFast:this.failFast},c),{abort:function(){s.abort()},forceMinPriority:function(n){t=n,s&&s.forceMinPriority(n)}}},t.prototype.tryStrategy=function(t,n,e,i){var o=null,r=null;return e.timeout>0&&(o=new k(e.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(n,(function(t,n){t&&o&&o.isRunning()&&!e.failFast||(o&&o.ensureAborted(),i(t,n))})),{abort:function(){o&&o.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}},t}(),Jt=function(){function t(t){this.strategies=t}return t.prototype.isSupported=function(){return D(this.strategies,C.method("isSupported"))},t.prototype.connect=function(t,n){return function(t,n,e){var i=A(t,(function(t,i,o,r){return t.connect(n,e(i,r))}));return{abort:function(){x(i,Wt)},forceMinPriority:function(t){x(i,(function(n){n.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,e){return function(i,o){e[t].error=i,i?function(t){return function(t,n){for(var e=0;e<t.length;e++)if(!n(t[e],e,t))return!1;return!0}(t,(function(t){return Boolean(t.error)}))}(e)&&n(!0):(x(e,(function(t){t.forceMinPriority(o.transport.priority)})),n(null,o))}}))},t}();function Wt(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}var Gt=function(){function t(t,n,e){this.strategy=t,this.transports=n,this.ttl=e.ttl||18e5,this.usingTLS=e.useTLS,this.timeline=e.timeline}return t.prototype.isSupported=function(){return this.strategy.isSupported()},t.prototype.connect=function(t,n){var e=this.usingTLS,i=function(t){var n=vn.getLocalStorage();if(n)try{var e=n[Qt(t)];if(e)return JSON.parse(e)}catch(n){Vt(t)}return null}(e),o=[this.strategy];if(i&&i.timestamp+this.ttl>=C.now()){var r=this.transports[i.transport];r&&(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new Ft([r],{timeout:2*i.latency+1e3,failFast:!0})))}var s=C.now(),c=o.pop().connect(t,(function i(r,a){r?(Vt(e),o.length>0?(s=C.now(),c=o.pop().connect(t,i)):n(r)):(!function(t,n,e){var i=vn.getLocalStorage();if(i)try{i[Qt(t)]=H({timestamp:C.now(),transport:n,latency:e})}catch(t){}}(e,a.transport.name,C.now()-s),n(null,a))}));return{abort:function(){c.abort()},forceMinPriority:function(n){t=n,c&&c.forceMinPriority(n)}}},t}();function Qt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Vt(t){var n=vn.getLocalStorage();if(n)try{delete n[Qt(t)]}catch(t){}}var Yt=function(){function t(t,n){var e=n.delay;this.strategy=t,this.options={delay:e}}return t.prototype.isSupported=function(){return this.strategy.isSupported()},t.prototype.connect=function(t,n){var e,i=this.strategy,o=new k(this.options.delay,(function(){e=i.connect(t,n)}));return{abort:function(){o.ensureAborted(),e&&e.abort()},forceMinPriority:function(n){t=n,e&&e.forceMinPriority(n)}}},t}(),$t=function(){function t(t,n,e){this.test=t,this.trueBranch=n,this.falseBranch=e}return t.prototype.isSupported=function(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()},t.prototype.connect=function(t,n){return(this.test()?this.trueBranch:this.falseBranch).connect(t,n)},t}(),Kt=function(){function t(t){this.strategy=t}return t.prototype.isSupported=function(){return this.strategy.isSupported()},t.prototype.connect=function(t,n){var e=this.strategy.connect(t,(function(t,i){i&&e.abort(),n(t,i)}));return e},t}();function Zt(t){return function(){return t.isSupported()}}var tn,nn=function(t,n){var e={};function i(i,o,r,s,c){var a=n(t,i,o,r,s,c);return e[i]=a,a}var o,r={hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath},s=P({},r,{useTLS:!0}),c={hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath},a={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Xt({lives:2,minPingDelay:1e4,maxPingDelay:t.activity_timeout}),h=new Xt({lives:2,minPingDelay:1e4,maxPingDelay:t.activity_timeout}),p=i("ws","ws",3,r,u),l=i("wss","ws",3,s,u),f=i("sockjs","sockjs",1,c),d=i("xhr_streaming","xhr_streaming",1,c,h),y=i("xdr_streaming","xdr_streaming",1,c,h),v=i("xhr_polling","xhr_polling",1,c),g=i("xdr_polling","xdr_polling",1,c),m=new Ft([p],a),b=new Ft([l],a),_=new Ft([f],a),w=new Ft([new $t(Zt(d),d,y)],a),S=new Ft([new $t(Zt(v),v,g)],a),k=new Ft([new $t(Zt(w),new Jt([w,new Yt(S,{delay:4e3})]),S)],a),T=new $t(Zt(k),k,_);return o=t.useTLS?new Jt([m,new Yt(T,{delay:2e3})]):new Jt([m,new Yt(b,{delay:2e3}),new Yt(T,{delay:5e3})]),new Gt(new Kt(new $t(Zt(p),o,T)),e,{ttl:18e5,timeline:t.timeline,useTLS:t.useTLS})},en={getRequest:function(t){var n=new window.XDomainRequest;return n.ontimeout=function(){t.emit("error",new Ot),t.close()},n.onerror=function(n){t.emit("error",n),t.close()},n.onprogress=function(){n.responseText&&n.responseText.length>0&&t.onChunk(200,n.responseText)},n.onload=function(){n.responseText&&n.responseText.length>0&&t.onChunk(200,n.responseText),t.emit("finished",200),t.close()},n},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}},on=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),rn=function(t){function n(n,e,i){var o=t.call(this)||this;return o.hooks=n,o.method=e,o.url=i,o}return on(n,t),n.prototype.start=function(t){var n=this;this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=function(){n.close()},vn.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)},n.prototype.close=function(){this.unloader&&(vn.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)},n.prototype.onChunk=function(t,n){for(;;){var e=this.advanceBuffer(n);if(!e)break;this.emit("chunk",{status:t,data:e})}this.isBufferTooLong(n)&&this.emit("buffer_too_long")},n.prototype.advanceBuffer=function(t){var n=t.slice(this.position),e=n.indexOf("\n");return-1!==e?(this.position+=e+1,n.slice(0,e)):null},n.prototype.isBufferTooLong=function(t){return this.position===t.length&&t.length>262144},n}(tt);!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(tn||(tn={}));var sn=tn,cn=1;function an(t){var n=-1===t.indexOf("?")?"?":"&";return t+n+"t="+ +new Date+"&n="+cn++}function un(t){return Math.floor(Math.random()*t)}var hn,pn=function(){function t(t,n){this.hooks=t,this.session=un(1e3)+"/"+function(t){for(var n=[],e=0;e<t;e++)n.push(un(32).toString(32));return n.join("")}(8),this.location=function(t){var n=/([^\?]*)\/*(\??.*)/.exec(t);return{base:n[1],queryString:n[2]}}(n),this.readyState=sn.CONNECTING,this.openStream()}return t.prototype.send=function(t){return this.sendRaw(JSON.stringify([t]))},t.prototype.ping=function(){this.hooks.sendHeartbeat(this)},t.prototype.close=function(t,n){this.onClose(t,n,!0)},t.prototype.sendRaw=function(t){if(this.readyState!==sn.OPEN)return!1;try{return vn.createSocketRequest("POST",an((n=this.location,e=this.session,n.base+"/"+e+"/xhr_send"))).start(t),!0}catch(t){return!1}var n,e},t.prototype.reconnect=function(){this.closeStream(),this.openStream()},t.prototype.onClose=function(t,n,e){this.closeStream(),this.readyState=sn.CLOSED,this.onclose&&this.onclose({code:t,reason:n,wasClean:e})},t.prototype.onChunk=function(t){var n;if(200===t.status)switch(this.readyState===sn.OPEN&&this.onActivity(),t.data.slice(0,1)){case"o":n=JSON.parse(t.data.slice(1)||"{}"),this.onOpen(n);break;case"a":n=JSON.parse(t.data.slice(1)||"[]");for(var e=0;e<n.length;e++)this.onEvent(n[e]);break;case"m":n=JSON.parse(t.data.slice(1)||"null"),this.onEvent(n);break;case"h":this.hooks.onHeartbeat(this);break;case"c":n=JSON.parse(t.data.slice(1)||"[]"),this.onClose(n[0],n[1],!0)}},t.prototype.onOpen=function(t){var n,e,i;this.readyState===sn.CONNECTING?(t&&t.hostname&&(this.location.base=(n=this.location.base,e=t.hostname,(i=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(n))[1]+e+i[3])),this.readyState=sn.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)},t.prototype.onEvent=function(t){this.readyState===sn.OPEN&&this.onmessage&&this.onmessage({data:t})},t.prototype.onActivity=function(){this.onactivity&&this.onactivity()},t.prototype.onError=function(t){this.onerror&&this.onerror(t)},t.prototype.openStream=function(){var t=this;this.stream=vn.createSocketRequest("POST",an(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",(function(n){t.onChunk(n)})),this.stream.bind("finished",(function(n){t.hooks.onFinished(t,n)})),this.stream.bind("buffer_too_long",(function(){t.reconnect()}));try{this.stream.start()}catch(n){C.defer((function(){t.onError(n),t.onClose(1006,"Could not start streaming",!1)}))}},t.prototype.closeStream=function(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)},t}(),ln={getReceiveURL:function(t,n){return t.base+"/"+n+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,n){t.onClose(1006,"Connection interrupted ("+n+")",!1)}},fn={getReceiveURL:function(t,n){return t.base+"/"+n+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,n){200===n?t.reconnect():t.onClose(1006,"Connection interrupted ("+n+")",!1)}},dn={getRequest:function(t){var n=new(vn.getXHRAPI());return n.onreadystatechange=n.onprogress=function(){switch(n.readyState){case 3:n.responseText&&n.responseText.length>0&&t.onChunk(n.status,n.responseText);break;case 4:n.responseText&&n.responseText.length>0&&t.onChunk(n.status,n.responseText),t.emit("finished",n.status),t.close()}},n},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},yn={createStreamingSocket:function(t){return this.createSocket(ln,t)},createPollingSocket:function(t){return this.createSocket(fn,t)},createSocket:function(t,n){return new pn(t,n)},createXHR:function(t,n){return this.createRequest(dn,t,n)},createRequest:function(t,n,e){return new rn(t,n,e)},createXDR:function(t,n){return this.createRequest(en,t,n)}},vn={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:o,DependenciesReceivers:c,getDefaultStrategy:nn,Transports:dt,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(n,e){t.hooks.isInitialized()?(t.changeState("initialized"),e(!0)):(n&&t.onError(n),t.onClose(),e(!1))}))):t.onClose()},HTTPFactory:yn,TimelineTransport:W,getXHRAPI:function(){return window.XMLHttpRequest},getWebSocketAPI:function(){return window.WebSocket||window.MozWebSocket},setup:function(t){var n=this;window.Pusher=t;var e=function(){n.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:function(){return document},getProtocol:function(){return this.getDocument().location.protocol},getAuthorizers:function(){return{ajax:B,jsonp:X}},onDocumentBody:function(t){var n=this;document.body?t():setTimeout((function(){n.onDocumentBody(t)}),0)},createJSONPRequest:function(t,n){return new J(t,n)},createScriptRequest:function(t){return new F(t)},getLocalStorage:function(){try{return window.localStorage}catch(t){return}},createXHR:function(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest:function(){return new(this.getXHRAPI())},createMicrosoftXHR:function(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork:function(){return vt},createWebSocket:function(t){return new(this.getWebSocketAPI())(t)},createSocketRequest:function(t,n){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,n);if(this.isXDRSupported(0===n.indexOf("https:")))return this.HTTPFactory.createXDR(t,n);throw"Cross-origin HTTP requests are not supported"},isXHRSupported:function(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported:function(t){var n=t?"https:":"http:",e=this.getProtocol();return Boolean(window.XDomainRequest)&&e===n},addUnloadListener:function(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener:function(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)}};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(hn||(hn={}));var gn=hn,mn=function(){function t(t,n,e){this.key=t,this.session=n,this.events=[],this.options=e||{},this.sent=0,this.uniqueID=0}return t.prototype.log=function(t,n){t<=this.options.level&&(this.events.push(P({},n,{timestamp:C.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())},t.prototype.error=function(t){this.log(gn.ERROR,t)},t.prototype.info=function(t){this.log(gn.INFO,t)},t.prototype.debug=function(t){this.log(gn.DEBUG,t)},t.prototype.isEmpty=function(){return 0===this.events.length},t.prototype.send=function(t,n){var e=this,i=P({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(i,(function(t,i){t||e.sent++,n&&n(t,i)})),!0},t.prototype.generateUniqueID=function(){return this.uniqueID++,this.uniqueID},t}(),bn=function(){function t(t,n,e,i){this.name=t,this.priority=n,this.transport=e,this.options=i||{}}return t.prototype.isSupported=function(){return this.transport.isSupported({useTLS:this.options.useTLS})},t.prototype.connect=function(t,n){var e=this;if(!this.isSupported())return _n(new xt,n);if(this.priority<t)return _n(new Et,n);var i=!1,o=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),r=null,s=function(){o.unbind("initialized",s),o.connect()},c=function(){r=Bt.createHandshake(o,(function(t){i=!0,h(),n(null,t)}))},a=function(t){h(),n(t)},u=function(){var t;h(),t=H(o),n(new Lt(t))},h=function(){o.unbind("initialized",s),o.unbind("open",c),o.unbind("error",a),o.unbind("closed",u)};return o.bind("initialized",s),o.bind("open",c),o.bind("error",a),o.bind("closed",u),o.initialize(),{abort:function(){i||(h(),r?r.close():o.close())},forceMinPriority:function(t){i||e.priority<t&&(r?r.close():o.close())}}},t}();function _n(t,n){return C.defer((function(){n(t)})),{abort:function(){},forceMinPriority:function(){}}}var wn=vn.Transports,Sn=function(t,n,e,i,o,r){var s=wn[e];if(!s)throw new Rt(e);return!(t.enabledTransports&&-1===E(t.enabledTransports,n)||t.disabledTransports&&-1!==E(t.disabledTransports,n))?new bn(n,i,r?r.getAssistant(s):s,P({key:t.key,useTLS:t.useTLS,timeline:t.timeline,ignoreNullOrigin:t.ignoreNullOrigin},o)):kn},kn={isSupported:function(){return!1},connect:function(t,n){var e=C.defer((function(){n(new xt)}));return{abort:function(){e.ensureAborted()},forceMinPriority:function(){}}}},Tn=function(){return{wsHost:r.host,wsPort:r.ws_port,wssPort:r.wss_port,wsPath:r.ws_path,httpHost:r.sockjs_host,httpPort:r.sockjs_http_port,httpsPort:r.sockjs_https_port,httpPath:r.sockjs_path,statsHost:r.stats_host,authEndpoint:r.channel_auth_endpoint,authTransport:r.channel_auth_transport,activity_timeout:r.activity_timeout,pong_timeout:r.pong_timeout,unavailable_timeout:r.unavailable_timeout}},Cn=function(t){return{wsHost:"ws-"+t+".pusher.com",httpHost:"sockjs-"+t+".pusher.com"}},Pn=function(){function t(n,e){var i=this;if(function(t){if(null==t)throw"You must pass your app key when you instantiate Pusher."}(n),!(e=e||{}).cluster&&!e.wsHost&&!e.httpHost){var o=U.buildLogSuffix("javascriptQuickStart");q.warn("You should always specify a cluster when connecting. "+o)}this.key=n,this.config=P(Tn(),e.cluster?Cn(e.cluster):{},e),this.channels=Bt.createChannels(),this.global_emitter=new tt,this.sessionID=Math.floor(1e9*Math.random()),this.timeline=new mn(this.key,this.sessionID,{cluster:this.config.cluster,features:t.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:gn.INFO,version:r.VERSION}),this.config.disableStats||(this.timelineSender=Bt.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+vn.TimelineTransport.name}));this.connection=Bt.createConnectionManager(this.key,P({getStrategy:function(t){var n=P({},i.config,t);return vn.getDefaultStrategy(n,Sn)},timeline:this.timeline,activityTimeout:this.config.activity_timeout,pongTimeout:this.config.pong_timeout,unavailableTimeout:this.config.unavailable_timeout},this.config,{useTLS:this.shouldUseTLS()})),this.connection.bind("connected",(function(){i.subscribeAll(),i.timelineSender&&i.timelineSender.send(i.connection.isUsingTLS())})),this.connection.bind("message",(function(t){var n=0===t.event.indexOf("pusher_internal:");if(t.channel){var e=i.channel(t.channel);e&&e.handleEvent(t)}n||i.global_emitter.emit(t.event,t.data)})),this.connection.bind("connecting",(function(){i.channels.disconnect()})),this.connection.bind("disconnected",(function(){i.channels.disconnect()})),this.connection.bind("error",(function(t){q.warn("Error",t)})),t.instances.push(this),this.timeline.info({instances:t.instances.length}),t.isReady&&this.connect()}return t.ready=function(){t.isReady=!0;for(var n=0,e=t.instances.length;n<e;n++)t.instances[n].connect()},t.log=function(n){t.logToConsole&&window.console&&window.console.log&&window.console.log(n)},t.getClientFeatures=function(){return R(I({ws:vn.Transports.ws},(function(t){return t.isSupported({})})))},t.prototype.channel=function(t){return this.channels.find(t)},t.prototype.allChannels=function(){return this.channels.all()},t.prototype.connect=function(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),n=this.timelineSender;this.timelineSenderTimer=new T(6e4,(function(){n.send(t)}))}},t.prototype.disconnect=function(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)},t.prototype.bind=function(t,n,e){return this.global_emitter.bind(t,n,e),this},t.prototype.unbind=function(t,n,e){return this.global_emitter.unbind(t,n,e),this},t.prototype.bind_global=function(t){return this.global_emitter.bind_global(t),this},t.prototype.unbind_global=function(t){return this.global_emitter.unbind_global(t),this},t.prototype.unbind_all=function(t){return this.global_emitter.unbind_all(),this},t.prototype.subscribeAll=function(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)},t.prototype.subscribe=function(t){var n=this.channels.add(t,this);return n.subscriptionPending&&n.subscriptionCancelled?n.reinstateSubscription():n.subscriptionPending||"connected"!==this.connection.state||n.subscribe(),n},t.prototype.unsubscribe=function(t){var n=this.channels.find(t);n&&n.subscriptionPending?n.cancelSubscription():(n=this.channels.remove(t))&&"connected"===this.connection.state&&n.unsubscribe()},t.prototype.send_event=function(t,n,e){return this.connection.send_event(t,n,e)},t.prototype.shouldUseTLS=function(){return"https:"===vn.getProtocol()||(!0===this.config.forceTLS||Boolean(this.config.encrypted))},t.instances=[],t.isReady=!1,t.logToConsole=!1,t.Runtime=vn,t.ScriptReceivers=vn.ScriptReceivers,t.DependenciesReceivers=vn.DependenciesReceivers,t.auth_callbacks=vn.auth_callbacks,t}(),On=n.default=Pn;vn.setup(Pn)}])}));