class ke{constructor(){this.notificationCreatedEvent=".Illuminate\\Notifications\\Events\\BroadcastNotificationCreated"}listenForWhisper(s,a){return this.listen(".client-"+s,a)}notification(s){return this.listen(this.notificationCreatedEvent,s)}stopListeningForNotification(s){return this.stopListening(this.notificationCreatedEvent,s)}stopListeningForWhisper(s,a){return this.stopListening(".client-"+s,a)}}class nt{constructor(s){this.namespace=s}format(s){return[".","\\"].includes(s.charAt(0))?s.substring(1):(this.namespace&&(s=this.namespace+"."+s),s.replace(/\./g,"\\"))}setNamespace(s){this.namespace=s}}function _r(P){try{new P}catch(s){if(s instanceof Error&&s.message.includes("is not a constructor"))return!1}return!0}class Te extends ke{constructor(s,a,d){super(),this.name=a,this.pusher=s,this.options=d,this.eventFormatter=new nt(this.options.namespace),this.subscribe()}subscribe(){this.subscription=this.pusher.subscribe(this.name)}unsubscribe(){this.pusher.unsubscribe(this.name)}listen(s,a){return this.on(this.eventFormatter.format(s),a),this}listenToAll(s){return this.subscription.bind_global((a,d)=>{if(a.startsWith("pusher:"))return;let C=String(this.options.namespace??"").replace(/\./g,"\\"),v=a.startsWith(C)?a.substring(C.length+1):"."+a;s(v,d)}),this}stopListening(s,a){return a?this.subscription.unbind(this.eventFormatter.format(s),a):this.subscription.unbind(this.eventFormatter.format(s)),this}stopListeningToAll(s){return s?this.subscription.unbind_global(s):this.subscription.unbind_global(),this}subscribed(s){return this.on("pusher:subscription_succeeded",()=>{s()}),this}error(s){return this.on("pusher:subscription_error",a=>{s(a)}),this}on(s,a){return this.subscription.bind(s,a),this}}class rt extends Te{whisper(s,a){return this.pusher.channels.channels[this.name].trigger(`client-${s}`,a),this}}class wr extends Te{whisper(s,a){return this.pusher.channels.channels[this.name].trigger(`client-${s}`,a),this}}class Sr extends rt{here(s){return this.on("pusher:subscription_succeeded",a=>{s(Object.keys(a.members).map(d=>a.members[d]))}),this}joining(s){return this.on("pusher:member_added",a=>{s(a.info)}),this}whisper(s,a){return this.pusher.channels.channels[this.name].trigger(`client-${s}`,a),this}leaving(s){return this.on("pusher:member_removed",a=>{s(a.info)}),this}}class it extends ke{constructor(s,a,d){super(),this.events={},this.listeners={},this.name=a,this.socket=s,this.options=d,this.eventFormatter=new nt(this.options.namespace),this.subscribe()}subscribe(){this.socket.emit("subscribe",{channel:this.name,auth:this.options.auth||{}})}unsubscribe(){this.unbind(),this.socket.emit("unsubscribe",{channel:this.name,auth:this.options.auth||{}})}listen(s,a){return this.on(this.eventFormatter.format(s),a),this}stopListening(s,a){return this.unbindEvent(this.eventFormatter.format(s),a),this}subscribed(s){return this.on("connect",a=>{s(a)}),this}error(s){return this}on(s,a){return this.listeners[s]=this.listeners[s]||[],this.events[s]||(this.events[s]=(d,C)=>{this.name===d&&this.listeners[s]&&this.listeners[s].forEach(v=>v(C))},this.socket.on(s,this.events[s])),this.listeners[s].push(a),this}unbind(){Object.keys(this.events).forEach(s=>{this.unbindEvent(s)})}unbindEvent(s,a){this.listeners[s]=this.listeners[s]||[],a&&(this.listeners[s]=this.listeners[s].filter(d=>d!==a)),(!a||this.listeners[s].length===0)&&(this.events[s]&&(this.socket.removeListener(s,this.events[s]),delete this.events[s]),delete this.listeners[s])}}class st extends it{whisper(s,a){return this.socket.emit("client event",{channel:this.name,event:`client-${s}`,data:a}),this}}class Cr extends st{here(s){return this.on("presence:subscribed",a=>{s(a.map(d=>d.user_info))}),this}joining(s){return this.on("presence:joining",a=>s(a.user_info)),this}whisper(s,a){return this.socket.emit("client event",{channel:this.name,event:`client-${s}`,data:a}),this}leaving(s){return this.on("presence:leaving",a=>s(a.user_info)),this}}class he extends ke{subscribe(){}unsubscribe(){}listen(s,a){return this}listenToAll(s){return this}stopListening(s,a){return this}subscribed(s){return this}error(s){return this}on(s,a){return this}}class ot extends he{whisper(s,a){return this}}class kr extends he{whisper(s,a){return this}}class Tr extends ot{here(s){return this}joining(s){return this}whisper(s,a){return this}leaving(s){return this}}const at=class ct{constructor(s){this.setOptions(s),this.connect()}setOptions(s){this.options={...ct._defaultOptions,...s,broadcaster:s.broadcaster};let a=this.csrfToken();a&&(this.options.auth.headers["X-CSRF-TOKEN"]=a,this.options.userAuthentication.headers["X-CSRF-TOKEN"]=a),a=this.options.bearerToken,a&&(this.options.auth.headers.Authorization="Bearer "+a,this.options.userAuthentication.headers.Authorization="Bearer "+a)}csrfToken(){var s,a;return typeof window<"u"&&(s=window.Laravel)!=null&&s.csrfToken?window.Laravel.csrfToken:this.options.csrfToken?this.options.csrfToken:typeof document<"u"&&typeof document.querySelector=="function"?((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))??null:null}};at._defaultOptions={auth:{headers:{}},authEndpoint:"/broadcasting/auth",userAuthentication:{endpoint:"/broadcasting/user-auth",headers:{}},csrfToken:null,bearerToken:null,host:null,key:null,namespace:"App.Events"};let xe=at;class ce extends xe{constructor(){super(...arguments),this.channels={}}connect(){if(typeof this.options.client<"u")this.pusher=this.options.client;else if(this.options.Pusher)this.pusher=new this.options.Pusher(this.options.key,this.options);else if(typeof window<"u"&&typeof window.Pusher<"u")this.pusher=new window.Pusher(this.options.key,this.options);else throw new Error("Pusher client not found. Should be globally available or passed via options.client")}signin(){this.pusher.signin()}listen(s,a,d){return this.channel(s).listen(a,d)}channel(s){return this.channels[s]||(this.channels[s]=new Te(this.pusher,s,this.options)),this.channels[s]}privateChannel(s){return this.channels["private-"+s]||(this.channels["private-"+s]=new rt(this.pusher,"private-"+s,this.options)),this.channels["private-"+s]}encryptedPrivateChannel(s){return this.channels["private-encrypted-"+s]||(this.channels["private-encrypted-"+s]=new wr(this.pusher,"private-encrypted-"+s,this.options)),this.channels["private-encrypted-"+s]}presenceChannel(s){return this.channels["presence-"+s]||(this.channels["presence-"+s]=new Sr(this.pusher,"presence-"+s,this.options)),this.channels["presence-"+s]}leave(s){[s,"private-"+s,"private-encrypted-"+s,"presence-"+s].forEach(a=>{this.leaveChannel(a)})}leaveChannel(s){this.channels[s]&&(this.channels[s].unsubscribe(),delete this.channels[s])}socketId(){return this.pusher.connection.socket_id}disconnect(){this.pusher.disconnect()}}class xr extends xe{constructor(){super(...arguments),this.channels={}}connect(){let s=this.getSocketIO();this.socket=s(this.options.host??void 0,this.options),this.socket.io.on("reconnect",()=>{Object.values(this.channels).forEach(a=>{a.subscribe()})})}getSocketIO(){if(typeof this.options.client<"u")return this.options.client;if(typeof window<"u"&&typeof window.io<"u")return window.io;throw new Error("Socket.io client not found. Should be globally available or passed via options.client")}listen(s,a,d){return this.channel(s).listen(a,d)}channel(s){return this.channels[s]||(this.channels[s]=new it(this.socket,s,this.options)),this.channels[s]}privateChannel(s){return this.channels["private-"+s]||(this.channels["private-"+s]=new st(this.socket,"private-"+s,this.options)),this.channels["private-"+s]}presenceChannel(s){return this.channels["presence-"+s]||(this.channels["presence-"+s]=new Cr(this.socket,"presence-"+s,this.options)),this.channels["presence-"+s]}leave(s){[s,"private-"+s,"presence-"+s].forEach(a=>{this.leaveChannel(a)})}leaveChannel(s){this.channels[s]&&(this.channels[s].unsubscribe(),delete this.channels[s])}socketId(){return this.socket.id}disconnect(){this.socket.disconnect()}}class et extends xe{constructor(){super(...arguments),this.channels={}}connect(){}listen(s,a,d){return new he}channel(s){return new he}privateChannel(s){return new ot}encryptedPrivateChannel(s){return new kr}presenceChannel(s){return new Tr}leave(s){}leaveChannel(s){}socketId(){return"fake-socket-id"}disconnect(){}}class Rr{constructor(s){this.options=s,this.connect(),this.options.withoutInterceptors||this.registerInterceptors()}channel(s){return this.connector.channel(s)}connect(){if(this.options.broadcaster==="reverb")this.connector=new ce({...this.options,cluster:""});else if(this.options.broadcaster==="pusher")this.connector=new ce(this.options);else if(this.options.broadcaster==="ably")this.connector=new ce({...this.options,cluster:"",broadcaster:"pusher"});else if(this.options.broadcaster==="socket.io")this.connector=new xr(this.options);else if(this.options.broadcaster==="null")this.connector=new et(this.options);else if(typeof this.options.broadcaster=="function"&&_r(this.options.broadcaster))this.connector=new this.options.broadcaster(this.options);else throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} is not supported.`)}disconnect(){this.connector.disconnect()}join(s){return this.connector.presenceChannel(s)}leave(s){this.connector.leave(s)}leaveChannel(s){this.connector.leaveChannel(s)}leaveAllChannels(){for(const s in this.connector.channels)this.leaveChannel(s)}listen(s,a,d){return this.connector.listen(s,a,d)}private(s){return this.connector.privateChannel(s)}encryptedPrivate(s){if(this.connectorSupportsEncryptedPrivateChannels(this.connector))return this.connector.encryptedPrivateChannel(s);throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} does not support encrypted private channels.`)}connectorSupportsEncryptedPrivateChannels(s){return s instanceof ce||s instanceof et}socketId(){return this.connector.socketId()}registerInterceptors(){typeof Vue<"u"&&Vue!=null&&Vue.http&&this.registerVueRequestInterceptor(),typeof axios=="function"&&this.registerAxiosRequestInterceptor(),typeof jQuery=="function"&&this.registerjQueryAjaxSetup(),typeof Turbo=="object"&&this.registerTurboRequestInterceptor()}registerVueRequestInterceptor(){Vue.http.interceptors.push((s,a)=>{this.socketId()&&s.headers.set("X-Socket-ID",this.socketId()),a()})}registerAxiosRequestInterceptor(){axios.interceptors.request.use(s=>(this.socketId()&&(s.headers["X-Socket-Id"]=this.socketId()),s))}registerjQueryAjaxSetup(){typeof jQuery.ajax<"u"&&jQuery.ajaxPrefilter((s,a,d)=>{this.socketId()&&d.setRequestHeader("X-Socket-Id",this.socketId())})}registerTurboRequestInterceptor(){document.addEventListener("turbo:before-fetch-request",s=>{s.detail.fetchOptions.headers["X-Socket-Id"]=this.socketId()})}}function Pr(P){return P&&P.__esModule&&Object.prototype.hasOwnProperty.call(P,"default")?P.default:P}var Ce={exports:{}};/*! * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */var tt;function Er(){return tt||(tt=1,function(P,s){(function(d,C){P.exports=C()})(window,function(){return function(a){var d={};function C(v){if(d[v])return d[v].exports;var f=d[v]={i:v,l:!1,exports:{}};return a[v].call(f.exports,f,f.exports,C),f.l=!0,f.exports}return C.m=a,C.c=d,C.d=function(v,f,I){C.o(v,f)||Object.defineProperty(v,f,{enumerable:!0,get:I})},C.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},C.t=function(v,f){if(f&1&&(v=C(v)),f&8||f&4&&typeof v=="object"&&v&&v.__esModule)return v;var I=Object.create(null);if(C.r(I),Object.defineProperty(I,"default",{enumerable:!0,value:v}),f&2&&typeof v!="string")for(var _ in v)C.d(I,_,(function(J){return v[J]}).bind(null,_));return I},C.n=function(v){var f=v&&v.__esModule?function(){return v.default}:function(){return v};return C.d(f,"a",f),f},C.o=function(v,f){return Object.prototype.hasOwnProperty.call(v,f)},C.p="",C(C.s=2)}([function(a,d,C){var v=this&&this.__extends||function(){var p=function(h,u){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,L){m.__proto__=L}||function(m,L){for(var j in L)L.hasOwnProperty(j)&&(m[j]=L[j])},p(h,u)};return function(h,u){p(h,u);function m(){this.constructor=h}h.prototype=u===null?Object.create(u):(m.prototype=u.prototype,new m)}}();Object.defineProperty(d,"__esModule",{value:!0});var f=256,I=function(){function p(h){h===void 0&&(h="="),this._paddingCharacter=h}return p.prototype.encodedLength=function(h){return this._paddingCharacter?(h+2)/3*4|0:(h*8+5)/6|0},p.prototype.encode=function(h){for(var u="",m=0;m>>3*6&63),u+=this._encodeByte(L>>>2*6&63),u+=this._encodeByte(L>>>1*6&63),u+=this._encodeByte(L>>>0*6&63)}var j=h.length-m;if(j>0){var L=h[m]<<16|(j===2?h[m+1]<<8:0);u+=this._encodeByte(L>>>3*6&63),u+=this._encodeByte(L>>>2*6&63),j===2?u+=this._encodeByte(L>>>1*6&63):u+=this._paddingCharacter||"",u+=this._paddingCharacter||""}return u},p.prototype.maxDecodedLength=function(h){return this._paddingCharacter?h/4*3|0:(h*6+7)/8|0},p.prototype.decodedLength=function(h){return this.maxDecodedLength(h.length-this._getPaddingLength(h))},p.prototype.decode=function(h){if(h.length===0)return new Uint8Array(0);for(var u=this._getPaddingLength(h),m=h.length-u,L=new Uint8Array(this.maxDecodedLength(m)),j=0,N=0,H=0,z=0,q=0,M=0,X=0;N>>4,L[j++]=q<<4|M>>>2,L[j++]=M<<6|X,H|=z&f,H|=q&f,H|=M&f,H|=X&f;if(N>>4,H|=z&f,H|=q&f),N>>2,H|=M&f),N>>8&6,u+=51-h>>>8&-75,u+=61-h>>>8&-15,u+=62-h>>>8&3,String.fromCharCode(u)},p.prototype._decodeChar=function(h){var u=f;return u+=(42-h&h-44)>>>8&-256+h-43+62,u+=(46-h&h-48)>>>8&-256+h-47+63,u+=(47-h&h-58)>>>8&-256+h-48+52,u+=(64-h&h-91)>>>8&-256+h-65+0,u+=(96-h&h-123)>>>8&-256+h-97+26,u},p.prototype._getPaddingLength=function(h){var u=0;if(this._paddingCharacter){for(var m=h.length-1;m>=0&&h[m]===this._paddingCharacter;m--)u++;if(h.length<4||u>2)throw new Error("Base64Coder: incorrect padding")}return u},p}();d.Coder=I;var _=new I;function J(p){return _.encode(p)}d.encode=J;function E(p){return _.decode(p)}d.decode=E;var x=function(p){v(h,p);function h(){return p!==null&&p.apply(this,arguments)||this}return h.prototype._encodeByte=function(u){var m=u;return m+=65,m+=25-u>>>8&6,m+=51-u>>>8&-75,m+=61-u>>>8&-13,m+=62-u>>>8&49,String.fromCharCode(m)},h.prototype._decodeChar=function(u){var m=f;return m+=(44-u&u-46)>>>8&-256+u-45+62,m+=(94-u&u-96)>>>8&-256+u-95+63,m+=(47-u&u-58)>>>8&-256+u-48+52,m+=(64-u&u-91)>>>8&-256+u-65+0,m+=(96-u&u-123)>>>8&-256+u-97+26,m},h}(I);d.URLSafeCoder=x;var y=new x;function w(p){return y.encode(p)}d.encodeURLSafe=w;function k(p){return y.decode(p)}d.decodeURLSafe=k,d.encodedLength=function(p){return _.encodedLength(p)},d.maxDecodedLength=function(p){return _.maxDecodedLength(p)},d.decodedLength=function(p){return _.decodedLength(p)}},function(a,d,C){Object.defineProperty(d,"__esModule",{value:!0});var v="utf8: invalid string",f="utf8: invalid source encoding";function I(E){for(var x=new Uint8Array(_(E)),y=0,w=0;w>6,x[y++]=128|k&63):k<55296?(x[y++]=224|k>>12,x[y++]=128|k>>6&63,x[y++]=128|k&63):(w++,k=(k&1023)<<10,k|=E.charCodeAt(w)&1023,k+=65536,x[y++]=240|k>>18,x[y++]=128|k>>12&63,x[y++]=128|k>>6&63,x[y++]=128|k&63)}return x}d.encode=I;function _(E){for(var x=0,y=0;y=E.length-1)throw new Error(v);y++,x+=4}else throw new Error(v)}return x}d.encodedLength=_;function J(E){for(var x=[],y=0;y=E.length)throw new Error(f);var p=E[++y];if((p&192)!==128)throw new Error(f);w=(w&31)<<6|p&63,k=128}else if(w<240){if(y>=E.length-1)throw new Error(f);var p=E[++y],h=E[++y];if((p&192)!==128||(h&192)!==128)throw new Error(f);w=(w&15)<<12|(p&63)<<6|h&63,k=2048}else if(w<248){if(y>=E.length-2)throw new Error(f);var p=E[++y],h=E[++y],u=E[++y];if((p&192)!==128||(h&192)!==128||(u&192)!==128)throw new Error(f);w=(w&15)<<18|(p&63)<<12|(h&63)<<6|u&63,k=65536}else throw new Error(f);if(w=55296&&w<=57343)throw new Error(f);if(w>=65536){if(w>1114111)throw new Error(f);w-=65536,x.push(String.fromCharCode(55296|w>>10)),w=56320|w&1023}}x.push(String.fromCharCode(w))}return x.join("")}d.decode=J},function(a,d,C){a.exports=C(3).default},function(a,d,C){C.r(d);class v{constructor(e,t){this.lastId=0,this.prefix=e,this.name=t}create(e){this.lastId++;var t=this.lastId,r=this.prefix+t,i=this.name+"["+t+"]",o=!1,c=function(){o||(e.apply(null,arguments),o=!0)};return this[t]=c,{number:t,id:r,name:i,callback:c}}remove(e){delete this[e.number]}}var f=new v("_pusher_script_","Pusher.ScriptReceivers"),I={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:""},_=I;class J{constructor(e){this.options=e,this.receivers=e.receivers||f,this.loading={}}load(e,t,r){var i=this;if(i.loading[e]&&i.loading[e].length>0)i.loading[e].push(r);else{i.loading[e]=[r];var o=b.createScriptRequest(i.getPath(e,t)),c=i.receivers.create(function(l){if(i.receivers.remove(c),i.loading[e]){var g=i.loading[e];delete i.loading[e];for(var S=function(O){O||o.cleanup()},T=0;T>>6)+Y(128|e&63):Y(224|e>>>12&15)+Y(128|e>>>6&63)+Y(128|e&63)},lt=function(n){return n.replace(/[^\x00-\x7F]/g,ut)},dt=function(n){var e=[0,2,1][n.length%3],t=n.charCodeAt(0)<<16|(n.length>1?n.charCodeAt(1):0)<<8|(n.length>2?n.charCodeAt(2):0),r=[ne.charAt(t>>>18),ne.charAt(t>>>12&63),e>=2?"=":ne.charAt(t>>>6&63),e>=1?"=":ne.charAt(t&63)];return r.join("")},pt=window.btoa||function(n){return n.replace(/[\s\S]{1,3}/g,dt)};class ft{constructor(e,t,r,i){this.clear=t,this.timer=e(()=>{this.timer&&(this.timer=i(this.timer))},r)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}var Pe=ft;function gt(n){window.clearTimeout(n)}function vt(n){window.clearInterval(n)}class W extends Pe{constructor(e,t){super(setTimeout,gt,e,function(r){return t(),null})}}class bt extends Pe{constructor(e,t){super(setInterval,vt,e,function(r){return t(),r})}}var mt={now(){return Date.now?Date.now():new Date().valueOf()},defer(n){return new W(0,n)},method(n,...e){var t=Array.prototype.slice.call(arguments,1);return function(r){return r[n].apply(r,t.concat(arguments))}}},U=mt;function D(n,...e){for(var t=0;t{window.console&&window.console.log&&window.console.log(e)}}debug(...e){this.log(this.globalLog,e)}warn(...e){this.log(this.globalLogWarn,e)}error(...e){this.log(this.globalLogError,e)}globalLogWarn(e){window.console&&window.console.warn?window.console.warn(e):this.globalLog(e)}globalLogError(e){window.console&&window.console.error?window.console.error(e):this.globalLogWarn(e)}log(e,...t){var r=yt.apply(this,arguments);_e.log?_e.log(r):_e.logToConsole&&e.bind(this)(r)}}var A=new Pt,Et=function(n,e,t,r,i){(t.headers!==void 0||t.headersProvider!=null)&&A.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var o=n.nextAuthCallbackID.toString();n.nextAuthCallbackID++;var c=n.getDocument(),l=c.createElement("script");n.auth_callbacks[o]=function(T){i(null,T)};var g="Pusher.auth_callbacks['"+o+"']";l.src=t.endpoint+"?callback="+encodeURIComponent(g)+"&"+e;var S=c.getElementsByTagName("head")[0]||c.documentElement;S.insertBefore(l,S.firstChild)},Lt=Et;class At{constructor(e){this.src=e}send(e){var t=this,r="Error loading "+t.src;t.script=document.createElement("script"),t.script.id=e.id,t.script.src=t.src,t.script.type="text/javascript",t.script.charset="UTF-8",t.script.addEventListener?(t.script.onerror=function(){e.callback(r)},t.script.onload=function(){e.callback(null)}):t.script.onreadystatechange=function(){(t.script.readyState==="loaded"||t.script.readyState==="complete")&&e.callback(null)},t.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(t.errorScript=document.createElement("script"),t.errorScript.id=e.id+"_error",t.errorScript.text=e.name+"('"+r+"');",t.script.async=t.errorScript.async=!1):t.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(t.script,i.firstChild),t.errorScript&&i.insertBefore(t.errorScript,t.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 Ot{constructor(e,t){this.url=e,this.data=t}send(e){if(!this.request){var t=Tt(this.data),r=this.url+"/"+e.number+"?"+t;this.request=b.createScriptRequest(r),this.request.send(e)}}cleanup(){this.request&&this.request.cleanup()}}var Rt=function(n,e){return function(t,r){var i="http"+(e?"s":"")+"://",o=i+(n.host||n.options.host)+n.options.path,c=b.createJSONPRequest(o,t),l=b.ScriptReceivers.create(function(g,S){f.remove(l),c.cleanup(),S&&S.host&&(n.host=S.host),r&&r(g,S)});c.send(l)}},It={name:"jsonp",getAgent:Rt},jt=It;function ue(n,e,t){var r=n+(e.useTLS?"s":""),i=e.useTLS?e.hostTLS:e.hostNonTLS;return r+"://"+i+t}function le(n,e){var t="/app/"+n,r="?protocol="+_.PROTOCOL+"&client=js&version="+_.VERSION+(e?"&"+e:"");return t+r}var Nt={getInitial:function(n,e){var t=(e.httpPath||"")+le(n,"flash=false");return ue("ws",e,t)}},Ut={getInitial:function(n,e){var t=(e.httpPath||"/pusher")+le(n);return ue("http",e,t)}},Dt={getInitial:function(n,e){return ue("http",e,e.httpPath||"/pusher")},getPath:function(n,e){return le(n)}};class qt{constructor(){this._callbacks={}}get(e){return this._callbacks[de(e)]}add(e,t,r){var i=de(e);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:t,context:r})}remove(e,t,r){if(!e&&!t&&!r){this._callbacks={};return}var i=e?[de(e)]:Le(this._callbacks);t||r?this.removeCallback(i,t,r):this.removeAllCallbacks(i)}removeCallback(e,t,r){Z(e,function(i){this._callbacks[i]=Oe(this._callbacks[i]||[],function(o){return t&&t!==o.fn||r&&r!==o.context}),this._callbacks[i].length===0&&delete this._callbacks[i]},this)}removeAllCallbacks(e){Z(e,function(t){delete this._callbacks[t]},this)}}function de(n){return"_"+n}class F{constructor(e){this.callbacks=new qt,this.global_callbacks=[],this.failThrough=e}bind(e,t,r){return this.callbacks.add(e,t,r),this}bind_global(e){return this.global_callbacks.push(e),this}unbind(e,t,r){return this.callbacks.remove(e,t,r),this}unbind_global(e){return e?(this.global_callbacks=Oe(this.global_callbacks||[],t=>t!==e),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,t,r){for(var i=0;i0)for(var i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),A.debug("Connecting",{transport:this.name,url:e}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(e){return this.state==="open"?(U.defer(()=>{this.socket&&this.socket.send(e)}),!0):!1}ping(){this.state==="open"&&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(e){this.emit("error",{type:"WebSocketError",error:e}),this.timeline.error(this.buildTimelineMessage({error:e.toString()}))}onClose(e){e?this.changeState("closed",{code:e.code,reason:e.reason,wasClean:e.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(e){this.emit("message",e)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=e=>{this.onError(e)},this.socket.onclose=e=>{this.onClose(e)},this.socket.onmessage=e=>{this.onMessage(e)},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(e,t){this.state=e,this.timeline.info(this.buildTimelineMessage({state:e,params:t})),this.emit(e,t)}buildTimelineMessage(e){return D({cid:this.id},e)}}class K{constructor(e){this.hooks=e}isSupported(e){return this.hooks.isSupported(e)}createConnection(e,t,r,i){return new Ht(this.hooks,e,t,r,i)}}var zt=new K({urls:Nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!b.getWebSocketAPI()},isSupported:function(){return!!b.getWebSocketAPI()},getSocket:function(n){return b.createWebSocket(n)}}),je={urls:Ut,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Ne=D({getSocket:function(n){return b.HTTPFactory.createStreamingSocket(n)}},je),Ue=D({getSocket:function(n){return b.HTTPFactory.createPollingSocket(n)}},je),De={isSupported:function(){return b.isXHRSupported()}},Mt=new K(D({},Ne,De)),Bt=new K(D({},Ue,De)),Ft={ws:zt,xhr_streaming:Mt,xhr_polling:Bt},ie=Ft,$t=new K({file:"sockjs",urls:Dt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(n,e){return new window.SockJS(n,null,{js_path:x.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(n,e){n.send(JSON.stringify({path:e}))}}),qe={isSupported:function(n){var e=b.isXDRSupported(n.useTLS);return e}},Xt=new K(D({},Ne,qe)),Jt=new K(D({},Ue,qe));ie.xdr_streaming=Xt,ie.xdr_polling=Jt,ie.sockjs=$t;var Wt=ie;class Vt extends F{constructor(){super();var e=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){e.emit("online")},!1),window.addEventListener("offline",function(){e.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var Gt=new Vt;class Qt{constructor(e,t,r){this.manager=e,this.transport=t,this.minPingDelay=r.minPingDelay,this.maxPingDelay=r.maxPingDelay,this.pingDelay=void 0}createConnection(e,t,r,i){i=D({},i,{activityTimeout:this.pingDelay});var o=this.transport.createConnection(e,t,r,i),c=null,l=function(){o.unbind("open",l),o.bind("closed",g),c=U.now()},g=S=>{if(o.unbind("closed",g),S.code===1002||S.code===1003)this.manager.reportDeath();else if(!S.wasClean&&c){var T=U.now()-c;T<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(T/2,this.minPingDelay))}};return o.bind("open",l),o}isSupported(e){return this.manager.isAlive()&&this.transport.isSupported(e)}}const He={decodeMessage:function(n){try{var e=JSON.parse(n.data),t=e.data;if(typeof t=="string")try{t=JSON.parse(e.data)}catch{}var r={event:e.event,channel:e.channel,data:t};return e.user_id&&(r.user_id=e.user_id),r}catch(i){throw{type:"MessageParseError",error:i,data:n.data}}},encodeMessage:function(n){return JSON.stringify(n)},processHandshake:function(n){var e=He.decodeMessage(n);if(e.event==="pusher:connection_established"){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:e.data.activity_timeout*1e3}}else{if(e.event==="pusher:error")return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"}},getCloseAction:function(n){return n.code<4e3?n.code>=1002&&n.code<=1004?"backoff":null:n.code===4e3?"tls_only":n.code<4100?"refused":n.code<4200?"backoff":n.code<4300?"retry":"refused"},getCloseError:function(n){return n.code!==1e3&&n.code!==1001?{type:"PusherError",data:{code:n.code,message:n.reason||n.message}}:null}};var V=He;class Kt extends F{constructor(e,t){super(),this.id=e,this.transport=t,this.activityTimeout=t.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(e){return this.transport.send(e)}send_event(e,t,r){var i={event:e,data:t};return r&&(i.channel=r),A.debug("Event sent",i),this.send(V.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var e={message:r=>{var i;try{i=V.decodeMessage(r)}catch(o){this.emit("error",{type:"MessageParseError",error:o,data:r.data})}if(i!==void 0){switch(A.debug("Event recd",i),i.event){case"pusher:error":this.emit("error",{type:"PusherError",data:i.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",i)}},activity:()=>{this.emit("activity")},error:r=>{this.emit("error",r)},closed:r=>{t(),r&&r.code&&this.handleCloseEvent(r),this.transport=null,this.emit("closed")}},t=()=>{B(e,(r,i)=>{this.transport.unbind(i,r)})};B(e,(r,i)=>{this.transport.bind(i,r)})}handleCloseEvent(e){var t=V.getCloseAction(e),r=V.getCloseError(e);r&&this.emit("error",r),t&&this.emit(t,{action:t,error:r})}}class Yt{constructor(e,t){this.transport=e,this.callback=t,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=e=>{this.unbindListeners();var t;try{t=V.processHandshake(e)}catch(r){this.finish("error",{error:r}),this.transport.close();return}t.action==="connected"?this.finish("connected",{connection:new Kt(t.id,this.transport),activityTimeout:t.activityTimeout}):(this.finish(t.action,{error:t.error}),this.transport.close())},this.onClosed=e=>{this.unbindListeners();var t=V.getCloseAction(e)||"backoff",r=V.getCloseError(e);this.finish(t,{error:r})},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(e,t){this.callback(D({transport:this.transport,action:e},t))}}class Zt{constructor(e,t){this.timeline=e,this.options=t||{}}send(e,t){this.timeline.isEmpty()||this.timeline.send(b.TimelineTransport.getAgent(this,e),t)}}class pe extends F{constructor(e,t){super(function(r,i){A.debug("No callbacks on "+e+" for "+r)}),this.name=e,this.pusher=t,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(e,t){return t(null,{auth:""})}trigger(e,t){if(e.indexOf("client-")!==0)throw new h("Event '"+e+"' does not start with 'client-'");if(!this.subscribed){var r=k.buildLogSuffix("triggeringClientEvents");A.warn(`Client event triggered before channel 'subscription_succeeded' event . ${r}`)}return this.pusher.send_event(e,t,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(e){var t=e.event,r=e.data;if(t==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(e);else if(t==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(e);else if(t.indexOf("pusher_internal:")!==0){var i={};this.emit(t,r,i)}}handleSubscriptionSucceededEvent(e){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",e.data)}handleSubscriptionCountEvent(e){e.data.subscription_count&&(this.subscriptionCount=e.data.subscription_count),this.emit("pusher:subscription_count",e.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(e,t)=>{e?(this.subscriptionPending=!1,A.error(e.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:e.message},e instanceof q?{status:e.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:t.auth,channel_data:t.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 fe extends pe{authorize(e,t){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:e},t)}}class en{constructor(){this.reset()}get(e){return Object.prototype.hasOwnProperty.call(this.members,e)?{id:e,info:this.members[e]}:null}each(e){B(this.members,(t,r)=>{e(this.get(r))})}setMyID(e){this.myID=e}onSubscription(e){this.members=e.presence.hash,this.count=e.presence.count,this.me=this.get(this.myID)}addMember(e){return this.get(e.user_id)===null&&this.count++,this.members[e.user_id]=e.user_info,this.get(e.user_id)}removeMember(e){var t=this.get(e.user_id);return t&&(delete this.members[e.user_id],this.count--),t}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var tn=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(c){c(o)})}return new(t||(t=Promise))(function(o,c){function l(T){try{S(r.next(T))}catch(O){c(O)}}function g(T){try{S(r.throw(T))}catch(O){c(O)}}function S(T){T.done?o(T.value):i(T.value).then(l,g)}S((r=r.apply(n,e||[])).next())})};class nn extends fe{constructor(e,t){super(e,t),this.members=new en}authorize(e,t){super.authorize(e,(r,i)=>tn(this,void 0,void 0,function*(){if(!r)if(i=i,i.channel_data!=null){var o=JSON.parse(i.channel_data);this.members.setMyID(o.user_id)}else if(yield this.pusher.user.signinDonePromise,this.pusher.user.user_data!=null)this.members.setMyID(this.pusher.user.user_data.id);else{let c=k.buildLogSuffix("authorizationEndpoint");A.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${c}, or the user should be signed in.`),t("Invalid auth response");return}t(r,i)}))}handleEvent(e){var t=e.event;if(t.indexOf("pusher_internal:")===0)this.handleInternalEvent(e);else{var r=e.data,i={};e.user_id&&(i.user_id=e.user_id),this.emit(t,r,i)}}handleInternalEvent(e){var t=e.event,r=e.data;switch(t){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(e);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(e);break;case"pusher_internal:member_added":var i=this.members.addMember(r);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var o=this.members.removeMember(r);o&&this.emit("pusher:member_removed",o);break}}handleSubscriptionSucceededEvent(e){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(e.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var rn=C(1),ge=C(0);class sn extends fe{constructor(e,t,r){super(e,t),this.key=null,this.nacl=r}authorize(e,t){super.authorize(e,(r,i)=>{if(r){t(r,i);return}let o=i.shared_secret;if(!o){t(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=Object(ge.decode)(o),delete i.shared_secret,t(null,i)})}trigger(e,t){throw new N("Client events are not currently supported for encrypted channels")}handleEvent(e){var t=e.event,r=e.data;if(t.indexOf("pusher_internal:")===0||t.indexOf("pusher:")===0){super.handleEvent(e);return}this.handleEncryptedEvent(t,r)}handleEncryptedEvent(e,t){if(!this.key){A.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!t.ciphertext||!t.nonce){A.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+t);return}let r=Object(ge.decode)(t.ciphertext);if(r.length{if(c){A.error(`Failed to make a request to the authEndpoint: ${l}. Unable to fetch new key, so dropping encrypted event`);return}if(o=this.nacl.secretbox.open(r,i,this.key),o===null){A.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(e,this.getDataToEmit(o))});return}this.emit(e,this.getDataToEmit(o))}getDataToEmit(e){let t=Object(rn.decode)(e);try{return JSON.parse(t)}catch{return t}}}class on extends F{constructor(e,t){super(),this.state="initialized",this.connection=null,this.key=e,this.options=t,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 r=b.getNetwork();r.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),r.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){if(!(this.connection||this.runner)){if(!this.strategy.isSupported()){this.updateState("failed");return}this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()}}send(e){return this.connection?this.connection.send(e):!1}send_event(e,t,r){return this.connection?this.connection.send_event(e,t,r):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var e=(t,r)=>{t?this.runner=this.strategy.connect(0,e):r.action==="error"?(this.emit("error",{type:"HandshakeError",error:r.error}),this.timeline.error({handshakeError:r.error})):(this.abortConnecting(),this.handshakeCallbacks[r.action](r))};this.runner=this.strategy.connect(0,e)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var e=this.abandonConnection();e.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(e){this.timeline.info({action:"retry",delay:e}),e>0&&this.emit("connecting_in",Math.round(e/1e3)),this.retryTimer=new W(e||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new W(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new W(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 W(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(e){return D({},e,{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(e){return D({},e,{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 e=t=>r=>{r.error&&this.emit("error",{type:"WebSocketError",error:r.error}),t(r)};return{tls_only:e(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:e(()=>{this.disconnect()}),backoff:e(()=>{this.retryIn(1e3)}),retry:e(()=>{this.retryIn(0)})}}setConnection(e){this.connection=e;for(var t in this.connectionCallbacks)this.connection.bind(t,this.connectionCallbacks[t]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var e in this.connectionCallbacks)this.connection.unbind(e,this.connectionCallbacks[e]);var t=this.connection;return this.connection=null,t}}updateState(e,t){var r=this.state;if(this.state=e,r!==e){var i=e;i==="connected"&&(i+=" with new socket ID "+t.socket_id),A.debug("State changed",r+" -> "+i),this.timeline.info({state:e,params:t}),this.emit("state_change",{previous:r,current:e}),this.emit(e,t)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class an{constructor(){this.channels={}}add(e,t){return this.channels[e]||(this.channels[e]=cn(e,t)),this.channels[e]}all(){return _t(this.channels)}find(e){return this.channels[e]}remove(e){var t=this.channels[e];return delete this.channels[e],t}disconnect(){B(this.channels,function(e){e.disconnect()})}}function cn(n,e){if(n.indexOf("private-encrypted-")===0){if(e.config.nacl)return $.createEncryptedChannel(n,e,e.config.nacl);let t="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=k.buildLogSuffix("encryptedChannelSupport");throw new N(`${t}. ${r}`)}else{if(n.indexOf("private-")===0)return $.createPrivateChannel(n,e);if(n.indexOf("presence-")===0)return $.createPresenceChannel(n,e);if(n.indexOf("#")===0)throw new u('Cannot create a channel with name "'+n+'".');return $.createChannel(n,e)}}var hn={createChannels(){return new an},createConnectionManager(n,e){return new on(n,e)},createChannel(n,e){return new pe(n,e)},createPrivateChannel(n,e){return new fe(n,e)},createPresenceChannel(n,e){return new nn(n,e)},createEncryptedChannel(n,e,t){return new sn(n,e,t)},createTimelineSender(n,e){return new Zt(n,e)},createHandshake(n,e){return new Yt(n,e)},createAssistantToTheTransportManager(n,e,t){return new Qt(n,e,t)}},$=hn;class ze{constructor(e){this.options=e||{},this.livesLeft=this.options.lives||1/0}getAssistant(e){return $.createAssistantToTheTransportManager(this,e,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class G{constructor(e,t){this.strategies=e,this.loop=!!t.loop,this.failFast=!!t.failFast,this.timeout=t.timeout,this.timeoutLimit=t.timeoutLimit}isSupported(){return Ie(this.strategies,U.method("isSupported"))}connect(e,t){var r=this.strategies,i=0,o=this.timeout,c=null,l=(g,S)=>{S?t(null,S):(i=i+1,this.loop&&(i=i%r.length),i0&&(o=new W(r.timeout,function(){c.abort(),i(!0)})),c=e.connect(t,function(l,g){l&&o&&o.isRunning()&&!r.failFast||(o&&o.ensureAborted(),i(l,g))}),{abort:function(){o&&o.ensureAborted(),c.abort()},forceMinPriority:function(l){c.forceMinPriority(l)}}}}class ve{constructor(e){this.strategies=e}isSupported(){return Ie(this.strategies,U.method("isSupported"))}connect(e,t){return un(this.strategies,e,function(r,i){return function(o,c){if(i[r].error=o,o){ln(i)&&t(!0);return}Z(i,function(l){l.forceMinPriority(c.transport.priority)}),t(null,c)}})}}function un(n,e,t){var r=Ae(n,function(i,o,c,l){return i.connect(e,t(o,l))});return{abort:function(){Z(r,dn)},forceMinPriority:function(i){Z(r,function(o){o.forceMinPriority(i)})}}}function ln(n){return Ct(n,function(e){return!!e.error})}function dn(n){!n.error&&!n.aborted&&(n.abort(),n.aborted=!0)}class pn{constructor(e,t,r){this.strategy=e,this.transports=t,this.ttl=r.ttl||1800*1e3,this.usingTLS=r.useTLS,this.timeline=r.timeline}isSupported(){return this.strategy.isSupported()}connect(e,t){var r=this.usingTLS,i=fn(r),o=i&&i.cacheSkipCount?i.cacheSkipCount:0,c=[this.strategy];if(i&&i.timestamp+this.ttl>=U.now()){var l=this.transports[i.transport];l&&(["ws","wss"].includes(i.transport)||o>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),c.push(new G([l],{timeout:i.latency*2+1e3,failFast:!0}))):o++)}var g=U.now(),S=c.pop().connect(e,function T(O,ae){O?(Me(r),c.length>0?(g=U.now(),S=c.pop().connect(e,T)):t(O)):(gn(r,ae.transport.name,U.now()-g,o),t(null,ae))});return{abort:function(){S.abort()},forceMinPriority:function(T){e=T,S&&S.forceMinPriority(T)}}}}function be(n){return"pusherTransport"+(n?"TLS":"NonTLS")}function fn(n){var e=b.getLocalStorage();if(e)try{var t=e[be(n)];if(t)return JSON.parse(t)}catch{Me(n)}return null}function gn(n,e,t,r){var i=b.getLocalStorage();if(i)try{i[be(n)]=re({timestamp:U.now(),transport:e,latency:t,cacheSkipCount:r})}catch{}}function Me(n){var e=b.getLocalStorage();if(e)try{delete e[be(n)]}catch{}}class se{constructor(e,{delay:t}){this.strategy=e,this.options={delay:t}}isSupported(){return this.strategy.isSupported()}connect(e,t){var r=this.strategy,i,o=new W(this.options.delay,function(){i=r.connect(e,t)});return{abort:function(){o.ensureAborted(),i&&i.abort()},forceMinPriority:function(c){e=c,i&&i.forceMinPriority(c)}}}}class ee{constructor(e,t,r){this.test=e,this.trueBranch=t,this.falseBranch=r}isSupported(){var e=this.test()?this.trueBranch:this.falseBranch;return e.isSupported()}connect(e,t){var r=this.test()?this.trueBranch:this.falseBranch;return r.connect(e,t)}}class vn{constructor(e){this.strategy=e}isSupported(){return this.strategy.isSupported()}connect(e,t){var r=this.strategy.connect(e,function(i,o){o&&r.abort(),t(i,o)});return r}}function te(n){return function(){return n.isSupported()}}var bn=function(n,e,t){var r={};function i(Ye,vr,br,mr,yr){var Ze=t(n,Ye,vr,br,mr,yr);return r[Ye]=Ze,Ze}var o=Object.assign({},e,{hostNonTLS:n.wsHost+":"+n.wsPort,hostTLS:n.wsHost+":"+n.wssPort,httpPath:n.wsPath}),c=Object.assign({},o,{useTLS:!0}),l=Object.assign({},e,{hostNonTLS:n.httpHost+":"+n.httpPort,hostTLS:n.httpHost+":"+n.httpsPort,httpPath:n.httpPath}),g={loop:!0,timeout:15e3,timeoutLimit:6e4},S=new ze({minPingDelay:1e4,maxPingDelay:n.activityTimeout}),T=new ze({lives:2,minPingDelay:1e4,maxPingDelay:n.activityTimeout}),O=i("ws","ws",3,o,S),ae=i("wss","ws",3,c,S),lr=i("sockjs","sockjs",1,l),Je=i("xhr_streaming","xhr_streaming",1,l,T),dr=i("xdr_streaming","xdr_streaming",1,l,T),We=i("xhr_polling","xhr_polling",1,l),pr=i("xdr_polling","xdr_polling",1,l),Ve=new G([O],g),fr=new G([ae],g),gr=new G([lr],g),Ge=new G([new ee(te(Je),Je,dr)],g),Qe=new G([new ee(te(We),We,pr)],g),Ke=new G([new ee(te(Ge),new ve([Ge,new se(Qe,{delay:4e3})]),Qe)],g),we=new ee(te(Ke),Ke,gr),Se;return e.useTLS?Se=new ve([Ve,new se(we,{delay:2e3})]):Se=new ve([Ve,new se(fr,{delay:2e3}),new se(we,{delay:5e3})]),new pn(new vn(new ee(te(O),Se,we)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},mn=bn,yn=function(){var n=this;n.timeline.info(n.buildTimelineMessage({transport:n.name+(n.options.useTLS?"s":"")})),n.hooks.isInitialized()?n.changeState("initialized"):n.hooks.file?(n.changeState("initializing"),x.load(n.hooks.file,{useTLS:n.options.useTLS},function(e,t){n.hooks.isInitialized()?(n.changeState("initialized"),t(!0)):(e&&n.onError(e),n.onClose(),t(!1))})):n.onClose()},_n={getRequest:function(n){var e=new window.XDomainRequest;return e.ontimeout=function(){n.emit("error",new m),n.close()},e.onerror=function(t){n.emit("error",t),n.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&n.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&n.onChunk(200,e.responseText),n.emit("finished",200),n.close()},e},abortRequest:function(n){n.ontimeout=n.onerror=n.onprogress=n.onload=null,n.abort()}},wn=_n;const Sn=256*1024;class Cn extends F{constructor(e,t,r){super(),this.hooks=e,this.method=t,this.url=r}start(e){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},b.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(e)}close(){this.unloader&&(b.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(e,t){for(;;){var r=this.advanceBuffer(t);if(r)this.emit("chunk",{status:e,data:r});else break}this.isBufferTooLong(t)&&this.emit("buffer_too_long")}advanceBuffer(e){var t=e.slice(this.position),r=t.indexOf(` `);return r!==-1?(this.position+=r+1,t.slice(0,r)):null}isBufferTooLong(e){return this.position===e.length&&e.length>Sn}}var me;(function(n){n[n.CONNECTING=0]="CONNECTING",n[n.OPEN=1]="OPEN",n[n.CLOSED=3]="CLOSED"})(me||(me={}));var Q=me,kn=1;class Tn{constructor(e,t){this.hooks=e,this.session=Fe(1e3)+"/"+Ln(8),this.location=xn(t),this.readyState=Q.CONNECTING,this.openStream()}send(e){return this.sendRaw(JSON.stringify([e]))}ping(){this.hooks.sendHeartbeat(this)}close(e,t){this.onClose(e,t,!0)}sendRaw(e){if(this.readyState===Q.OPEN)try{return b.createSocketRequest("POST",Be(Pn(this.location,this.session))).start(e),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(e,t,r){this.closeStream(),this.readyState=Q.CLOSED,this.onclose&&this.onclose({code:e,reason:t,wasClean:r})}onChunk(e){if(e.status===200){this.readyState===Q.OPEN&&this.onActivity();var t,r=e.data.slice(0,1);switch(r){case"o":t=JSON.parse(e.data.slice(1)||"{}"),this.onOpen(t);break;case"a":t=JSON.parse(e.data.slice(1)||"[]");for(var i=0;i{this.onChunk(e)}),this.stream.bind("finished",e=>{this.hooks.onFinished(this,e)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(e){U.defer(()=>{this.onError(e),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}}function xn(n){var e=/([^\?]*)\/*(\??.*)/.exec(n);return{base:e[1],queryString:e[2]}}function Pn(n,e){return n.base+"/"+e+"/xhr_send"}function Be(n){var e=n.indexOf("?")===-1?"?":"&";return n+e+"t="+ +new Date+"&n="+kn++}function En(n,e){var t=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(n);return t[1]+e+t[3]}function Fe(n){return b.randomInt(n)}function Ln(n){for(var e=[],t=0;t0&&n.onChunk(t.status,t.responseText);break;case 4:t.responseText&&t.responseText.length>0&&n.onChunk(t.status,t.responseText),n.emit("finished",t.status),n.close();break}},t},abortRequest:function(n){n.onreadystatechange=null,n.abort()}},Un=Nn,Dn={createStreamingSocket(n){return this.createSocket(Rn,n)},createPollingSocket(n){return this.createSocket(jn,n)},createSocket(n,e){return new An(n,e)},createXHR(n,e){return this.createRequest(Un,n,e)},createRequest(n,e,t){return new Cn(n,e,t)}},$e=Dn;$e.createXDR=function(n,e){return this.createRequest(wn,n,e)};var qn=$e,Hn={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:f,DependenciesReceivers:E,getDefaultStrategy:mn,Transports:Wt,transportConnectionInitializer:yn,HTTPFactory:qn,TimelineTransport:jt,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(n){window.Pusher=n;var e=()=>{this.onDocumentBody(n.ready)};window.JSON?e():x.load("json2",{},e)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:X,jsonp:Lt}},onDocumentBody(n){document.body?n():setTimeout(()=>{this.onDocumentBody(n)},0)},createJSONPRequest(n,e){return new Ot(n,e)},createScriptRequest(n){return new At(n)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){var n=this.getXHRAPI();return new n},createMicrosoftXHR(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork(){return Gt},createWebSocket(n){var e=this.getWebSocketAPI();return new e(n)},createSocketRequest(n,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(n,e);if(this.isXDRSupported(e.indexOf("https:")===0))return this.HTTPFactory.createXDR(n,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var n=this.getXHRAPI();return!!n&&new n().withCredentials!==void 0},isXDRSupported(n){var e=n?"https:":"http:",t=this.getProtocol();return!!window.XDomainRequest&&t===e},addUnloadListener(n){window.addEventListener!==void 0?window.addEventListener("unload",n,!1):window.attachEvent!==void 0&&window.attachEvent("onunload",n)},removeUnloadListener(n){window.addEventListener!==void 0?window.removeEventListener("unload",n,!1):window.detachEvent!==void 0&&window.detachEvent("onunload",n)},randomInt(n){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}()*n)}},b=Hn,ye;(function(n){n[n.ERROR=3]="ERROR",n[n.INFO=6]="INFO",n[n.DEBUG=7]="DEBUG"})(ye||(ye={}));var oe=ye;class zn{constructor(e,t,r){this.key=e,this.session=t,this.events=[],this.options=r||{},this.sent=0,this.uniqueID=0}log(e,t){e<=this.options.level&&(this.events.push(D({},t,{timestamp:U.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(e){this.log(oe.ERROR,e)}info(e){this.log(oe.INFO,e)}debug(e){this.log(oe.DEBUG,e)}isEmpty(){return this.events.length===0}send(e,t){var r=D({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=[],e(r,(i,o)=>{i||this.sent++,t&&t(i,o)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Mn{constructor(e,t,r,i){this.name=e,this.priority=t,this.transport=r,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(e,t){if(this.isSupported()){if(this.priority{r||(T(),o?o.close():i.close())},forceMinPriority:O=>{r||this.priority{var t="socket_id="+encodeURIComponent(n.socketId);for(var r in e.params)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(e.paramsProvider!=null){let i=e.paramsProvider();for(var r in i)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(i[r])}return t};var Wn=n=>{if(typeof b.getAuthorizers()[n.transport]>"u")throw`'${n.transport}' is not a recognized auth transport`;return(e,t)=>{const r=Jn(e,n);b.getAuthorizers()[n.transport](b,r,n,p.UserAuthentication,t)}};const Vn=(n,e)=>{var t="socket_id="+encodeURIComponent(n.socketId);t+="&channel_name="+encodeURIComponent(n.channelName);for(var r in e.params)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(e.paramsProvider!=null){let i=e.paramsProvider();for(var r in i)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(i[r])}return t};var Gn=n=>{if(typeof b.getAuthorizers()[n.transport]>"u")throw`'${n.transport}' is not a recognized auth transport`;return(e,t)=>{const r=Vn(e,n);b.getAuthorizers()[n.transport](b,r,n,p.ChannelAuthorization,t)}};const Qn=(n,e,t)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(i,o)=>{const c=n.channel(i.channelName);t(c,r).authorize(i.socketId,o)}};function Kn(n,e){let t={activityTimeout:n.activityTimeout||_.activityTimeout,cluster:n.cluster,httpPath:n.httpPath||_.httpPath,httpPort:n.httpPort||_.httpPort,httpsPort:n.httpsPort||_.httpsPort,pongTimeout:n.pongTimeout||_.pongTimeout,statsHost:n.statsHost||_.stats_host,unavailableTimeout:n.unavailableTimeout||_.unavailableTimeout,wsPath:n.wsPath||_.wsPath,wsPort:n.wsPort||_.wsPort,wssPort:n.wssPort||_.wssPort,enableStats:nr(n),httpHost:Yn(n),useTLS:tr(n),wsHost:Zn(n),userAuthenticator:rr(n),channelAuthorizer:sr(n,e)};return"disabledTransports"in n&&(t.disabledTransports=n.disabledTransports),"enabledTransports"in n&&(t.enabledTransports=n.enabledTransports),"ignoreNullOrigin"in n&&(t.ignoreNullOrigin=n.ignoreNullOrigin),"timelineParams"in n&&(t.timelineParams=n.timelineParams),"nacl"in n&&(t.nacl=n.nacl),t}function Yn(n){return n.httpHost?n.httpHost:n.cluster?`sockjs-${n.cluster}.pusher.com`:_.httpHost}function Zn(n){return n.wsHost?n.wsHost:er(n.cluster)}function er(n){return`ws-${n}.pusher.com`}function tr(n){return b.getProtocol()==="https:"?!0:n.forceTLS!==!1}function nr(n){return"enableStats"in n?n.enableStats:"disableStats"in n?!n.disableStats:!1}function rr(n){const e=Object.assign(Object.assign({},_.userAuthentication),n.userAuthentication);return"customHandler"in e&&e.customHandler!=null?e.customHandler:Wn(e)}function ir(n,e){let t;return"channelAuthorization"in n?t=Object.assign(Object.assign({},_.channelAuthorization),n.channelAuthorization):(t={transport:n.authTransport||_.authTransport,endpoint:n.authEndpoint||_.authEndpoint},"auth"in n&&("params"in n.auth&&(t.params=n.auth.params),"headers"in n.auth&&(t.headers=n.auth.headers)),"authorizer"in n&&(t.customHandler=Qn(e,t,n.authorizer))),t}function sr(n,e){const t=ir(n,e);return"customHandler"in t&&t.customHandler!=null?t.customHandler:Gn(t)}class or extends F{constructor(e){super(function(t,r){A.debug(`No callbacks on watchlist events for ${t}`)}),this.pusher=e,this.bindWatchlistInternalEvent()}handleEvent(e){e.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",e=>{var t=e.event;t==="pusher_internal:watchlist_events"&&this.handleEvent(e)})}}function ar(){let n,e;return{promise:new Promise((r,i)=>{n=r,e=i}),resolve:n,reject:e}}var cr=ar;class hr extends F{constructor(e){super(function(t,r){A.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,r)=>{if(t){A.warn(`Error during signin: ${t}`),this._cleanup();return}this.pusher.send_event("pusher:signin",{auth:r.auth,user_data:r.user_data})},this.pusher=e,this.pusher.connection.bind("state_change",({previous:t,current:r})=>{t!=="connected"&&r==="connected"&&this._signin(),t==="connected"&&r!=="connected"&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new or(e),this.pusher.connection.bind("message",t=>{var r=t.event;r==="pusher:signin_success"&&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(),this.pusher.connection.state==="connected"&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(e){try{this.user_data=JSON.parse(e.user_data)}catch{A.error(`Failed parsing user data after signin: ${e.user_data}`),this._cleanup();return}if(typeof this.user_data.id!="string"||this.user_data.id===""){A.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){const e=t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():!t.subscriptionPending&&this.pusher.connection.state==="connected"&&t.subscribe()};this.serverToUserChannel=new pe(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((t,r)=>{t.indexOf("pusher_internal:")===0||t.indexOf("pusher:")===0||this.emit(t,r)}),e(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||this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:e,resolve:t}=cr();e.done=!1;const r=()=>{e.done=!0};e.then(r).catch(r),this.signinDonePromise=e,this._signinDoneResolve=t}}class R{static ready(){R.isReady=!0;for(var e=0,t=R.instances.length;eb.getDefaultStrategy(this.config,i,Fn);this.connection=$.createConnectionManager(this.key,{getStrategy:r,timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",i=>{var o=i.event,c=o.indexOf("pusher_internal:")===0;if(i.channel){var l=this.channel(i.channel);l&&l.handleEvent(i)}c||this.global_emitter.emit(i.event,i.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",i=>{A.warn(i)}),R.instances.push(this),this.timeline.info({instances:R.instances.length}),this.user=new hr(this),R.isReady&&this.connect()}channel(e){return this.channels.find(e)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var e=this.connection.isUsingTLS(),t=this.timelineSender;this.timelineSenderTimer=new bt(6e4,function(){t.send(e)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(e,t,r){return this.global_emitter.bind(e,t,r),this}unbind(e,t,r){return this.global_emitter.unbind(e,t,r),this}bind_global(e){return this.global_emitter.bind_global(e),this}unbind_global(e){return this.global_emitter.unbind_global(e),this}unbind_all(e){return this.global_emitter.unbind_all(),this}subscribeAll(){var e;for(e in this.channels.channels)this.channels.channels.hasOwnProperty(e)&&this.subscribe(e)}subscribe(e){var t=this.channels.add(e,this);return t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():!t.subscriptionPending&&this.connection.state==="connected"&&t.subscribe(),t}unsubscribe(e){var t=this.channels.find(e);t&&t.subscriptionPending?t.cancelSubscription():(t=this.channels.remove(e),t&&t.subscribed&&t.unsubscribe())}send_event(e,t,r){return this.connection.send_event(e,t,r)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}R.instances=[],R.isReady=!1,R.logToConsole=!1,R.Runtime=b,R.ScriptReceivers=b.ScriptReceivers,R.DependenciesReceivers=b.DependenciesReceivers,R.auth_callbacks=b.auth_callbacks;var _e=d.default=R;function ur(n){if(n==null)throw"You must pass your app key when you instantiate Pusher."}b.setup(R)}])})}(Ce)),Ce.exports}var Lr=Er();const Ir=Pr(Lr);export{Rr as E,Ir as P};