@voicenter-team/events-sdk 0.0.112 → 0.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +337 -337
- package/dist/voicenter-events-sdk.cjs.js +8 -8
- package/dist/voicenter-events-sdk.cjs.js.map +1 -1
- package/dist/voicenter-events-sdk.d.ts +119 -2
- package/dist/voicenter-events-sdk.es.js +982 -964
- package/dist/voicenter-events-sdk.es.js.map +1 -1
- package/dist/voicenter-events-sdk.iife.js +11 -11
- package/dist/voicenter-events-sdk.iife.js.map +1 -1
- package/dist/voicenter-events-sdk.umd.js +11 -11
- package/dist/voicenter-events-sdk.umd.js.map +1 -1
- package/package.json +65 -64
|
@@ -3,17 +3,17 @@ var VoicenterEventsSDK=function(z,Z,F){"use strict";var et=Object.defineProperty
|
|
|
3
3
|
*
|
|
4
4
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
5
|
* @license MIT
|
|
6
|
-
*/var Me=function(a){return a!=null&&(be(a)||Ve(a)||!!a._isBuffer)};function be(a){return!!a.constructor&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function Ve(a){return typeof a.readFloatLE=="function"&&typeof a.slice=="function"&&be(a.slice(0,0))}(function(){var a=Fe,t=we.utf8,e=Me,r=we.bin,o=function(h,f){h.constructor==String?f&&f.encoding==="binary"?h=r.stringToBytes(h):h=t.stringToBytes(h):e(h)?h=Array.prototype.slice.call(h,0):!Array.isArray(h)&&h.constructor!==Uint8Array&&(h=h.toString());for(var l=a.bytesToWords(h),d=h.length*8,i=1732584193,u=-271733879,c=-1732584194,s=271733878,n=0;n<l.length;n++)l[n]=(l[n]<<8|l[n]>>>24)&16711935|(l[n]<<24|l[n]>>>8)&4278255360;l[d>>>5]|=128<<d%32,l[(d+64>>>9<<4)+14]=d;for(var p=o._ff,y=o._gg,v=o._hh,w=o._ii,n=0;n<l.length;n+=16){var j=i,B=u,V=c,O=s;i=p(i,u,c,s,l[n+0],7,-680876936),s=p(s,i,u,c,l[n+1],12,-389564586),c=p(c,s,i,u,l[n+2],17,606105819),u=p(u,c,s,i,l[n+3],22,-1044525330),i=p(i,u,c,s,l[n+4],7,-176418897),s=p(s,i,u,c,l[n+5],12,1200080426),c=p(c,s,i,u,l[n+6],17,-1473231341),u=p(u,c,s,i,l[n+7],22,-45705983),i=p(i,u,c,s,l[n+8],7,1770035416),s=p(s,i,u,c,l[n+9],12,-1958414417),c=p(c,s,i,u,l[n+10],17,-42063),u=p(u,c,s,i,l[n+11],22,-1990404162),i=p(i,u,c,s,l[n+12],7,1804603682),s=p(s,i,u,c,l[n+13],12,-40341101),c=p(c,s,i,u,l[n+14],17,-1502002290),u=p(u,c,s,i,l[n+15],22,1236535329),i=y(i,u,c,s,l[n+1],5,-165796510),s=y(s,i,u,c,l[n+6],9,-1069501632),c=y(c,s,i,u,l[n+11],14,643717713),u=y(u,c,s,i,l[n+0],20,-373897302),i=y(i,u,c,s,l[n+5],5,-701558691),s=y(s,i,u,c,l[n+10],9,38016083),c=y(c,s,i,u,l[n+15],14,-660478335),u=y(u,c,s,i,l[n+4],20,-405537848),i=y(i,u,c,s,l[n+9],5,568446438),s=y(s,i,u,c,l[n+14],9,-1019803690),c=y(c,s,i,u,l[n+3],14,-187363961),u=y(u,c,s,i,l[n+8],20,1163531501),i=y(i,u,c,s,l[n+13],5,-1444681467),s=y(s,i,u,c,l[n+2],9,-51403784),c=y(c,s,i,u,l[n+7],14,1735328473),u=y(u,c,s,i,l[n+12],20,-1926607734),i=v(i,u,c,s,l[n+5],4,-378558),s=v(s,i,u,c,l[n+8],11,-2022574463),c=v(c,s,i,u,l[n+11],16,1839030562),u=v(u,c,s,i,l[n+14],23,-35309556),i=v(i,u,c,s,l[n+1],4,-1530992060),s=v(s,i,u,c,l[n+4],11,1272893353),c=v(c,s,i,u,l[n+7],16,-155497632),u=v(u,c,s,i,l[n+10],23,-1094730640),i=v(i,u,c,s,l[n+13],4,681279174),s=v(s,i,u,c,l[n+0],11,-358537222),c=v(c,s,i,u,l[n+3],16,-722521979),u=v(u,c,s,i,l[n+6],23,76029189),i=v(i,u,c,s,l[n+9],4,-640364487),s=v(s,i,u,c,l[n+12],11,-421815835),c=v(c,s,i,u,l[n+15],16,530742520),u=v(u,c,s,i,l[n+2],23,-995338651),i=w(i,u,c,s,l[n+0],6,-198630844),s=w(s,i,u,c,l[n+7],10,1126891415),c=w(c,s,i,u,l[n+14],15,-1416354905),u=w(u,c,s,i,l[n+5],21,-57434055),i=w(i,u,c,s,l[n+12],6,1700485571),s=w(s,i,u,c,l[n+3],10,-1894986606),c=w(c,s,i,u,l[n+10],15,-1051523),u=w(u,c,s,i,l[n+1],21,-2054922799),i=w(i,u,c,s,l[n+8],6,1873313359),s=w(s,i,u,c,l[n+15],10,-30611744),c=w(c,s,i,u,l[n+6],15,-1560198380),u=w(u,c,s,i,l[n+13],21,1309151649),i=w(i,u,c,s,l[n+4],6,-145523070),s=w(s,i,u,c,l[n+11],10,-1120210379),c=w(c,s,i,u,l[n+2],15,718787259),u=w(u,c,s,i,l[n+9],21,-343485551),i=i+j>>>0,u=u+B>>>0,c=c+V>>>0,s=s+O>>>0}return a.endian([i,u,c,s])};o._ff=function(h,f,l,d,i,u,c){var s=h+(f&l|~f&d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._gg=function(h,f,l,d,i,u,c){var s=h+(f&d|l&~d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._hh=function(h,f,l,d,i,u,c){var s=h+(f^l^d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._ii=function(h,f,l,d,i,u,c){var s=h+(l^(f|~d))+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._blocksize=16,o._digestsize=16,Ee.exports=function(h,f){if(h==null)throw new Error("Illegal argument "+h);var l=a.wordsToBytes(o(h,f));return f&&f.asBytes?l:f&&f.asString?r.bytesToString(l):a.bytesToHex(l)}})();var qe=Ee.exports;const Ke=je(qe);var te=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(te||{}),ne=(a=>(a.MAIN="main",a.NEXT="next",a))(ne||{}),Q=(a=>(a.USER="User",a.TOKEN="Token",a))(Q||{});class re{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const r=await chrome.storage.session.get(t);if(r[t])return e?JSON.parse(r[t]):r[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const r=window.sessionStorage.getItem(t);if(r)return e?JSON.parse(r):r}}static async updateSessionStorageKey(t,e){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[t]:JSON.stringify(e)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(t,JSON.stringify(e))}static clearSessionStorage(){typeof chrome<"u"&&typeof chrome.storage<"u"&&chrome.storage.session.clear(),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.clear=="function"&&window.sessionStorage.clear()}}class Xe{constructor(t){K(this,"delay",1e3);K(this,"lastLoginTimestamp");K(this,"token");K(this,"refreshToken");K(this,"tokenExpiry");K(this,"storageKey");this.eventsSdkClass=t,this.eventsSdkClass=t,this.storageKey=""}async login(){const t={token:this.eventsSdkClass.options.token&&this.eventsSdkClass.options.token,email:this.eventsSdkClass.options.email&&this.eventsSdkClass.options.email,password:this.eventsSdkClass.options.password&&this.eventsSdkClass.options.password};if(this.storageKey=Ke(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const e=await this.checkLoginStatus(this.storageKey);return e||(re.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await re.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,r){let o,h,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),h=await this.getSettings(o.Data.AccessToken),f={...o.Data,...h}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),f={...o.Data.Socket}),await re.updateSessionStorageKey(e,f),f}onLoginResponse(t){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&t.URLList&&(this.eventsSdkClass.URLList=t.URLList),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.URLList.length&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");if(this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");this.eventsSdkClass.server&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${this.eventsSdkClass.server.Version}`),!this.eventsSdkClass.server&&this.eventsSdkClass.URLList.length&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${t.Version}`),t.IdentityCode&&(this.token=t.IdentityCode,this.eventsSdkClass.connect(ne.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(ne.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Q.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Q.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let t;if(this.tokenExpiry)t=new Date(this.tokenExpiry);else return;const e=t.getTime()-new Date().getTime()-5e3,r=Math.min(e,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let o,h;if(this.eventsSdkClass.options.isNewStack){const f=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);o=await this.getSettings(f.Data.AccessToken),h={...f.Data,...o}}else h={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(h),await re.updateSessionStorageKey(this.storageKey,h)}},r)}async externalLogin(t,{password:e,token:r,email:o},h){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?h===Q.TOKEN?f=JSON.stringify({identityType:Q.TOKEN,token:r}):f=JSON.stringify({identityType:Q.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Q.TOKEN?(f=JSON.stringify({token:r}),t=`${t}/${Q.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Q.USER}`);let l;try{const d=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:f});if(!d.ok&&d.status===400)throw l=400,new Error("Bad body request. Login type or isNewStack values not correct or not provided");if(!d.ok&&d.status===401)throw l=401,new Error("Unauthorized. Invalid token provided");if(!d.ok&&d.status===403)throw l=403,new Error("Forbidden. Identity token not provided or not valid");const i=await d.json();if(i.error)throw new Error(i.error);return i}catch(d){throw this.eventsSdkClass.loggerClass.loginError(h,l,r,o),d}}async getSettings(t){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const e=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${t}`}});if(!e.ok&&e.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return e.json()}catch(e){throw this.eventsSdkClass.loggerClass.getSettingsError(t,e),e}}async externalRefreshToken(t,e){try{return(await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}})).json()}catch(r){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,r),r}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Ae={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:5,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",useLogger:!0,loggerServer:"https://socketlog.voicenter.co",loggerConfig:{logToConsole:!0,overloadGlobalConsole:!1,system:"events-sdk",socketEmitInterval:1e4},loggerConnectOptions:{reconnection:!1,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function $e(){return typeof window<"u"&&(typeof window.navigator>"u"||typeof window.navigator.userAgent>"u")&&(window.navigator.userAgent="react-native"),typeof self>"u"&&typeof global=="object"&&(global.self=global,global.WebSocket=Z,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,r){function o(l,d){if(!e[l]){if(!t[l]){var i=typeof require=="function"&&require;if(!d&&i)return i(l,!0);if(h)return h(l,!0);throw new Error("Cannot find module '"+l+"'")}var u=e[l]={exports:{}};t[l][0].call(u.exports,function(c){var s=t[l][1][c];return o(s||c)},u,u.exports,a,t,e,r)}return e[l].exports}for(var h=typeof require=="function"&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function r(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var c,s=o(i),n=s.source,p=s.id;return u.forceNew||u["force new connection"]||u.multiplex===!1?(l("ignoring socket cache for %s",n),c=f(n,u)):(d[p]||(l("new io instance for %s",n),d[p]=f(n,u)),c=d[p]),c.socket(s.path)}var o=a("./url"),h=a("socket.io-parser"),f=a("./manager"),l=a("debug")("socket.io-client");t.exports=e=r;var d=e.managers={};e.protocol=h.protocol,e.connect=r,e.Manager=a("./manager"),e.Socket=a("./socket")},{"./manager":3,"./socket":5,"./url":6,debug:10,"socket.io-parser":44}],3:[function(a,t){function e(s,n){return this instanceof e?(s&&typeof s=="object"&&(n=s,s=void 0),n=n||{},n.path=n.path||"/socket.io",this.nsps={},this.subs=[],this.opts=n,this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor(n.randomizationFactor||.5),this.backoff=new c({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this.readyState="closed",this.uri=s,this.connected=[],this.encoding=!1,this.packetBuffer=[],this.encoder=new f.Encoder,this.decoder=new f.Decoder,this.autoConnect=n.autoConnect!==!1,void(this.autoConnect&&this.open())):new e(s,n)}var r=(a("./url"),a("engine.io-client")),o=a("./socket"),h=a("component-emitter"),f=a("socket.io-parser"),l=a("./on"),d=a("component-bind"),i=(a("object-component"),a("debug")("socket.io-client:manager")),u=a("indexof"),c=a("backo2");t.exports=e,e.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var s in this.nsps)this.nsps[s].emit.apply(this.nsps[s],arguments)},e.prototype.updateSocketIds=function(){for(var s in this.nsps)this.nsps[s].id=this.engine.id},h(e.prototype),e.prototype.reconnection=function(s){return arguments.length?(this._reconnection=!!s,this):this._reconnection},e.prototype.reconnectionAttempts=function(s){return arguments.length?(this._reconnectionAttempts=s,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(s){return arguments.length?(this._reconnectionDelay=s,this.backoff&&this.backoff.setMin(s),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(s){return arguments.length?(this._randomizationFactor=s,this.backoff&&this.backoff.setJitter(s),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(s){return arguments.length?(this._reconnectionDelayMax=s,this.backoff&&this.backoff.setMax(s),this):this._reconnectionDelayMax},e.prototype.timeout=function(s){return arguments.length?(this._timeout=s,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(s){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=r(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var y=l(n,"open",function(){p.onopen(),s&&s()}),v=l(n,"error",function(B){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",B),s){var V=new Error("Connection error");V.data=B,s(V)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var w=this._timeout;i("connect attempt will timeout after %d",w);var j=setTimeout(function(){i("connect attempt timed out after %d",w),y.destroy(),n.close(),n.emit("error","timeout"),p.emitAll("connect_timeout",w)},w);this.subs.push({destroy:function(){clearTimeout(j)}})}return this.subs.push(y),this.subs.push(v),this},e.prototype.onopen=function(){i("open"),this.cleanup(),this.readyState="open",this.emit("open");var s=this.engine;this.subs.push(l(s,"data",d(this,"ondata"))),this.subs.push(l(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(l(s,"error",d(this,"onerror"))),this.subs.push(l(s,"close",d(this,"onclose")))},e.prototype.ondata=function(s){this.decoder.add(s)},e.prototype.ondecoded=function(s){this.emit("packet",s)},e.prototype.onerror=function(s){i("error",s),this.emitAll("error",s)},e.prototype.socket=function(s){var n=this.nsps[s];if(!n){n=new o(this,s),this.nsps[s]=n;var p=this;n.on("connect",function(){n.id=p.engine.id,~u(p.connected,n)||p.connected.push(n)})}return n},e.prototype.destroy=function(s){var n=u(this.connected,s);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(s){i("writing packet %j",s);var n=this;n.encoding?n.packetBuffer.push(s):(n.encoding=!0,this.encoder.encode(s,function(p){for(var y=0;y<p.length;y++)n.engine.write(p[y]);n.encoding=!1,n.processPacketQueue()}))},e.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var s=this.packetBuffer.shift();this.packet(s)}},e.prototype.cleanup=function(){for(var s;s=this.subs.shift();)s.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},e.prototype.close=e.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},e.prototype.onclose=function(s){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",s),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var s=this;if(this.backoff.attempts>=this._reconnectionAttempts)i("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var n=this.backoff.duration();i("will wait %dms before reconnect attempt",n),this.reconnecting=!0;var p=setTimeout(function(){s.skipReconnect||(i("attempting reconnect"),s.emitAll("reconnect_attempt",s.backoff.attempts),s.emitAll("reconnecting",s.backoff.attempts),s.skipReconnect||s.open(function(y){y?(i("reconnect attempt error"),s.reconnecting=!1,s.reconnect(),s.emitAll("reconnect_error",y.data)):(i("reconnect success"),s.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var s=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",s)}},{"./on":4,"./socket":5,"./url":6,backo2:7,"component-bind":8,"component-emitter":9,debug:10,"engine.io-client":11,indexof:40,"object-component":41,"socket.io-parser":44}],4:[function(a,t){function e(r,o,h){return r.on(o,h),{destroy:function(){r.removeListener(o,h)}}}t.exports=e},{}],5:[function(a,t,e){function r(n,p){this.io=n,this.nsp=p,this.json=this,this.ids=0,this.acks={},this.io.autoConnect&&this.open(),this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0}var o=a("socket.io-parser"),h=a("component-emitter"),f=a("to-array"),l=a("./on"),d=a("component-bind"),i=a("debug")("socket.io-client:socket"),u=a("has-binary");t.exports=r;var c={connect:1,connect_error:1,connect_timeout:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1},s=h.prototype.emit;h(r.prototype),r.prototype.subEvents=function(){if(!this.subs){var n=this.io;this.subs=[l(n,"open",d(this,"onopen")),l(n,"packet",d(this,"onpacket")),l(n,"close",d(this,"onclose"))]}},r.prototype.open=r.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},r.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},r.prototype.emit=function(n){if(c.hasOwnProperty(n))return s.apply(this,arguments),this;var p=f(arguments),y=o.EVENT;u(p)&&(y=o.BINARY_EVENT);var v={type:y,data:p};return typeof p[p.length-1]=="function"&&(i("emitting packet with ack id %d",this.ids),this.acks[this.ids]=p.pop(),v.id=this.ids++),this.connected?this.packet(v):this.sendBuffer.push(v),this},r.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},r.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},r.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},r.prototype.onpacket=function(n){if(n.nsp==this.nsp)switch(n.type){case o.CONNECT:this.onconnect();break;case o.EVENT:this.onevent(n);break;case o.BINARY_EVENT:this.onevent(n);break;case o.ACK:this.onack(n);break;case o.BINARY_ACK:this.onack(n);break;case o.DISCONNECT:this.ondisconnect();break;case o.ERROR:this.emit("error",n.data)}},r.prototype.onevent=function(n){var p=n.data||[];i("emitting event %j",p),n.id!=null&&(i("attaching ack callback to event"),p.push(this.ack(n.id))),this.connected?s.apply(this,p):this.receiveBuffer.push(p)},r.prototype.ack=function(n){var p=this,y=!1;return function(){if(!y){y=!0;var v=f(arguments);i("sending ack %j",v);var w=u(v)?o.BINARY_ACK:o.ACK;p.packet({type:w,id:n,data:v})}}},r.prototype.onack=function(n){i("calling ack %s with %j",n.id,n.data);var p=this.acks[n.id];p.apply(this,n.data),delete this.acks[n.id]},r.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},r.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)s.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},r.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},r.prototype.destroy=function(){if(this.subs){for(var n=0;n<this.subs.length;n++)this.subs[n].destroy();this.subs=null}this.io.destroy(this)},r.prototype.close=r.prototype.disconnect=function(){return this.connected&&(i("performing disconnect (%s)",this.nsp),this.packet({type:o.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{"./on":4,"component-bind":8,"component-emitter":9,debug:10,"has-binary":36,"socket.io-parser":44,"to-array":48}],6:[function(a,t){(function(e){function r(f,i){var d=f,i=i||e.location;return f==null&&(f=i.protocol+"//"+i.host),typeof f=="string"&&(f.charAt(0)=="/"&&(f=f.charAt(1)=="/"?i.protocol+f:i.hostname+f),/^(https?|wss?):\/\//.test(f)||(h("protocol-less url %s",f),f=typeof i<"u"?i.protocol+"//"+f:"https://"+f),h("parse %s",f),d=o(f)),d.port||(/^(http|ws)$/.test(d.protocol)?d.port="80":/^(http|ws)s$/.test(d.protocol)&&(d.port="443")),d.path=d.path||"/",d.id=d.protocol+"://"+d.host+":"+d.port,d.href=d.protocol+"://"+d.host+(i&&i.port==d.port?"":":"+d.port),d}var o=a("parseuri"),h=a("debug")("socket.io-client:url");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),h=Math.floor(o*this.jitter*r);r=1&Math.floor(10*o)?r+h:r-h}return 0|Math.min(r,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(r){this.ms=r},e.prototype.setMax=function(r){this.max=r},e.prototype.setJitter=function(r){this.jitter=r}},{}],8:[function(a,t){var e=[].slice;t.exports=function(r,o){if(typeof o=="string"&&(o=r[o]),typeof o!="function")throw new Error("bind() requires a function");var h=e.call(arguments,2);return function(){return o.apply(r,h.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?r(o):void 0}function r(o){for(var h in e.prototype)o[h]=e.prototype[h];return o}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(o,h){return this._callbacks=this._callbacks||{},(this._callbacks[o]=this._callbacks[o]||[]).push(h),this},e.prototype.once=function(o,h){function f(){l.off(o,f),h.apply(this,arguments)}var l=this;return this._callbacks=this._callbacks||{},f.fn=h,this.on(o,f),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(o,h){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var f=this._callbacks[o];if(!f)return this;if(arguments.length==1)return delete this._callbacks[o],this;for(var l,d=0;d<f.length;d++)if(l=f[d],l===h||l.fn===h){f.splice(d,1);break}return this},e.prototype.emit=function(o){this._callbacks=this._callbacks||{};var h=[].slice.call(arguments,1),f=this._callbacks[o];if(f){f=f.slice(0);for(var l=0,d=f.length;d>l;++l)f[l].apply(this,h)}return this},e.prototype.listeners=function(o){return this._callbacks=this._callbacks||{},this._callbacks[o]||[]},e.prototype.hasListeners=function(o){return!!this.listeners(o).length}},{}],10:[function(a,t){function e(o){return e.enabled(o)?function(h){h=r(h);var f=new Date,l=f-(e[o]||f);e[o]=f,h=o+" "+h+" +"+e.humanize(l),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function r(o){return o instanceof Error?o.stack||o.message:o}t.exports=e,e.names=[],e.skips=[],e.enable=function(o){try{localStorage.debug=o}catch{}for(var h=(o||"").split(/[\s,]+/),f=h.length,l=0;f>l;l++)o=h[l].replace("*",".*?"),o[0]==="-"?e.skips.push(new RegExp("^"+o.substr(1)+"$")):e.names.push(new RegExp("^"+o+"$"))},e.disable=function(){e.enable("")},e.humanize=function(o){var h=1e3,f=6e4,l=60*f;return o>=l?(o/l).toFixed(1)+"h":o>=f?(o/f).toFixed(1)+"m":o>=h?(o/h|0)+"s":o+"ms"},e.enabled=function(o){for(var h=0,f=e.skips.length;f>h;h++)if(e.skips[h].test(o))return!1;for(var h=0,f=e.names.length;f>h;h++)if(e.names[h].test(o))return!0;return!1};try{window.localStorage&&e.enable(localStorage.debug)}catch{}},{}],11:[function(a,t){t.exports=a("./lib/")},{"./lib/":12}],12:[function(a,t){t.exports=a("./socket"),t.exports.parser=a("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(a,t){(function(e){function r(n,p){if(!(this instanceof r))return new r(n,p);if(p=p||{},n&&typeof n=="object"&&(p=n,n=null),n&&(n=u(n),p.host=n.host,p.secure=n.protocol=="https"||n.protocol=="wss",p.port=n.port,n.query&&(p.query=n.query)),this.secure=p.secure!=null?p.secure:e.location&&location.protocol=="https:",p.host){var y=p.host.split(":");p.hostname=y.shift(),y.length?p.port=y.pop():p.port||(p.port=this.secure?"443":"80")}this.agent=p.agent||!1,this.hostname=p.hostname||(e.location?location.hostname:"localhost"),this.port=p.port||(e.location&&location.port?location.port:this.secure?443:80),this.query=p.query||{},typeof this.query=="string"&&(this.query=s.decode(this.query)),this.upgrade=p.upgrade!==!1,this.path=(p.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!p.forceJSONP,this.jsonp=p.jsonp!==!1,this.forceBase64=!!p.forceBase64,this.enablesXDR=!!p.enablesXDR,this.timestampParam=p.timestampParam||"t",this.timestampRequests=p.timestampRequests,this.transports=p.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=p.policyPort||843,this.rememberUpgrade=p.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=p.onlyBinaryUpgrades,this.pfx=p.pfx||null,this.key=p.key||null,this.passphrase=p.passphrase||null,this.cert=p.cert||null,this.ca=p.ca||null,this.ciphers=p.ciphers||null,this.rejectUnauthorized=p.rejectUnauthorized||null,this.open()}function o(n){var p={};for(var y in n)n.hasOwnProperty(y)&&(p[y]=n[y]);return p}var h=a("./transports"),f=a("component-emitter"),l=a("debug")("engine.io-client:socket"),d=a("indexof"),i=a("engine.io-parser"),u=a("parseuri"),c=a("parsejson"),s=a("parseqs");t.exports=r,r.priorWebsocketSuccess=!1,f(r.prototype),r.protocol=i.protocol,r.Socket=r,r.Transport=a("./transport"),r.transports=a("./transports"),r.parser=a("engine.io-parser"),r.prototype.createTransport=function(n){l('creating transport "%s"',n);var p=o(this.query);p.EIO=i.protocol,p.transport=n,this.id&&(p.sid=this.id);var y=new h[n]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:p,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized});return y},r.prototype.open=function(){var p;if(this.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)p="websocket";else{if(this.transports.length==0){var n=this;return void setTimeout(function(){n.emit("error","No transports available")},0)}p=this.transports[0]}this.readyState="opening";var p;try{p=this.createTransport(p)}catch{return this.transports.shift(),void this.open()}p.open(),this.setTransport(p)},r.prototype.setTransport=function(n){l("setting transport %s",n.name);var p=this;this.transport&&(l("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=n,n.on("drain",function(){p.onDrain()}).on("packet",function(y){p.onPacket(y)}).on("error",function(y){p.onError(y)}).on("close",function(){p.onClose("transport close")})},r.prototype.probe=function(n){function p(){if(b.onlyBinaryUpgrades){var A=!this.supportsBinary&&b.transport.supportsBinary;C=C||A}C||(l('probe transport "%s" opened',n),O.send([{type:"ping",data:"probe"}]),O.once("packet",function(g){if(!C)if(g.type=="pong"&&g.data=="probe"){if(l('probe transport "%s" pong',n),b.upgrading=!0,b.emit("upgrading",O),!O)return;r.priorWebsocketSuccess=O.name=="websocket",l('pausing current transport "%s"',b.transport.name),b.transport.pause(function(){C||b.readyState!="closed"&&(l("changing transport and sending upgrade packet"),V(),b.setTransport(O),O.send([{type:"upgrade"}]),b.emit("upgrade",O),O=null,b.upgrading=!1,b.flush())})}else{l('probe transport "%s" failed',n);var m=new Error("probe error");m.transport=O.name,b.emit("upgradeError",m)}}))}function y(){C||(C=!0,V(),O.close(),O=null)}function v(A){var g=new Error("probe error: "+A);g.transport=O.name,y(),l('probe transport "%s" failed because of error: %s',n,A),b.emit("upgradeError",g)}function w(){v("transport closed")}function j(){v("socket closed")}function B(A){O&&A.name!=O.name&&(l('"%s" works - aborting "%s"',A.name,O.name),y())}function V(){O.removeListener("open",p),O.removeListener("error",v),O.removeListener("close",w),b.removeListener("close",j),b.removeListener("upgrading",B)}l('probing transport "%s"',n);var O=this.createTransport(n,{probe:1}),C=!1,b=this;r.priorWebsocketSuccess=!1,O.once("open",p),O.once("error",v),O.once("close",w),this.once("close",j),this.once("upgrading",B),O.open()},r.prototype.onOpen=function(){if(l("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name=="websocket",this.emit("open"),this.flush(),this.readyState=="open"&&this.upgrade&&this.transport.pause){l("starting upgrade probes");for(var n=0,p=this.upgrades.length;p>n;n++)this.probe(this.upgrades[n])}},r.prototype.onPacket=function(n){if(this.readyState=="opening"||this.readyState=="open")switch(l('socket receive: type "%s", data "%s"',n.type,n.data),this.emit("packet",n),this.emit("heartbeat"),n.type){case"open":this.onHandshake(c(n.data));break;case"pong":this.setPing();break;case"error":var p=new Error("server error");p.code=n.data,this.emit("error",p);break;case"message":this.emit("data",n.data),this.emit("message",n.data)}else l('packet received with socket readyState "%s"',this.readyState)},r.prototype.onHandshake=function(n){this.emit("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this.upgrades=this.filterUpgrades(n.upgrades),this.pingInterval=n.pingInterval,this.pingTimeout=n.pingTimeout,this.onOpen(),this.readyState!="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},r.prototype.onHeartbeat=function(n){clearTimeout(this.pingTimeoutTimer);var p=this;p.pingTimeoutTimer=setTimeout(function(){p.readyState!="closed"&&p.onClose("ping timeout")},n||p.pingInterval+p.pingTimeout)},r.prototype.setPing=function(){var n=this;clearTimeout(n.pingIntervalTimer),n.pingIntervalTimer=setTimeout(function(){l("writing ping packet - expecting pong within %sms",n.pingTimeout),n.ping(),n.onHeartbeat(n.pingTimeout)},n.pingInterval)},r.prototype.ping=function(){this.sendPacket("ping")},r.prototype.onDrain=function(){for(var n=0;n<this.prevBufferLen;n++)this.callbackBuffer[n]&&this.callbackBuffer[n]();this.writeBuffer.splice(0,this.prevBufferLen),this.callbackBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length==0?this.emit("drain"):this.flush()},r.prototype.flush=function(){this.readyState!="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(l("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},r.prototype.write=r.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},r.prototype.sendPacket=function(n,p,y){if(this.readyState!="closing"&&this.readyState!="closed"){var v={type:n,data:p};this.emit("packetCreate",v),this.writeBuffer.push(v),this.callbackBuffer.push(y),this.flush()}},r.prototype.close=function(){function n(){v.onClose("forced close"),l("socket closing - telling transport to close"),v.transport.close()}function p(){v.removeListener("upgrade",p),v.removeListener("upgradeError",p),n()}function y(){v.once("upgrade",p),v.once("upgradeError",p)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var v=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?y():n()}):this.upgrading?y():n()}return this},r.prototype.onError=function(n){l("socket error %j",n),r.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},r.prototype.onClose=function(n,p){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){l('socket close with reason: "%s"',n);var y=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),setTimeout(function(){y.writeBuffer=[],y.callbackBuffer=[],y.prevBufferLen=0},0),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",n,p)}},r.prototype.filterUpgrades=function(n){for(var p=[],y=0,v=n.length;v>y;y++)~d(this.transports,n[y])&&p.push(n[y]);return p}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./transport":14,"./transports":15,"component-emitter":9,debug:22,"engine.io-parser":25,indexof:40,parsejson:32,parseqs:33,parseuri:34}],14:[function(a,t){function e(h){this.path=h.path,this.hostname=h.hostname,this.port=h.port,this.secure=h.secure,this.query=h.query,this.timestampParam=h.timestampParam,this.timestampRequests=h.timestampRequests,this.readyState="",this.agent=h.agent||!1,this.socket=h.socket,this.enablesXDR=h.enablesXDR,this.pfx=h.pfx,this.key=h.key,this.passphrase=h.passphrase,this.cert=h.cert,this.ca=h.ca,this.ciphers=h.ciphers,this.rejectUnauthorized=h.rejectUnauthorized}var r=a("engine.io-parser"),o=a("component-emitter");t.exports=e,o(e.prototype),e.timestamps=0,e.prototype.onError=function(h,f){var l=new Error(h);return l.type="TransportError",l.description=f,this.emit("error",l),this},e.prototype.open=function(){return(this.readyState=="closed"||this.readyState=="")&&(this.readyState="opening",this.doOpen()),this},e.prototype.close=function(){return(this.readyState=="opening"||this.readyState=="open")&&(this.doClose(),this.onClose()),this},e.prototype.send=function(h){if(this.readyState!="open")throw new Error("Transport not open");this.write(h)},e.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},e.prototype.onData=function(h){var f=r.decodePacket(h,this.socket.binaryType);this.onPacket(f)},e.prototype.onPacket=function(h){this.emit("packet",h)},e.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(a,t,e){(function(r){function o(i){var u,c=!1,s=!1,n=i.jsonp!==!1;if(r.location){var p=location.protocol=="https:",y=location.port;y||(y=p?443:80),c=i.hostname!=location.hostname||y!=i.port,s=i.secure!=p}if(i.xdomain=c,i.xscheme=s,u=new h(i),"open"in u&&!i.forceJSONP)return new f(i);if(!n)throw new Error("JSONP disabled");return new l(i)}var h=a("xmlhttprequest"),f=a("./polling-xhr"),l=a("./polling-jsonp"),d=a("./websocket");e.polling=o,e.websocket=d}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(a,t){(function(e){function r(){}function o(u){h.call(this,u),this.query=this.query||{},l||(e.___eio||(e.___eio=[]),l=e.___eio),this.index=l.length;var c=this;l.push(function(s){c.onData(s)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){c.script&&(c.script.onerror=r)},!1)}var h=a("./polling"),f=a("component-inherit");t.exports=o;var l,d=/\n/g,i=/\\n/g;f(o,h),o.prototype.supportsBinary=!1,o.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),h.prototype.doClose.call(this)},o.prototype.doPoll=function(){var u=this,c=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),c.async=!0,c.src=this.uri(),c.onerror=function(p){u.onError("jsonp poll error",p)};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(c,s),this.script=c;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var p=document.createElement("iframe");document.body.appendChild(p),document.body.removeChild(p)},100)},o.prototype.doWrite=function(u,c){function s(){n(),c()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(V){p.onError("jsonp polling iframe removal error",V)}try{var B='<iframe src="javascript:0" name="'+p.iframeId+'">';y=document.createElement(B)}catch{y=document.createElement("iframe"),y.name=p.iframeId,y.src="javascript:0"}y.id=p.iframeId,p.form.appendChild(y),p.iframe=y}var p=this;if(!this.form){var y,v=document.createElement("form"),w=document.createElement("textarea"),j=this.iframeId="eio_iframe_"+this.index;v.className="socketio",v.style.position="absolute",v.style.top="-1000px",v.style.left="-1000px",v.target=j,v.method="POST",v.setAttribute("accept-charset","utf-8"),w.name="d",v.appendChild(w),document.body.appendChild(v),this.form=v,this.area=w}this.form.action=this.uri(),n(),u=u.replace(i,`\\
|
|
7
|
-
`),this.area.value=u.replace(d,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){p.iframe.readyState=="complete"&&s()}:this.iframe.onload=s}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function r(){}function o(s){if(d.call(this,s),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=s.hostname!=e.location.hostname||p!=s.port,this.xs=s.secure!=n}}function h(s){this.method=s.method||"GET",this.uri=s.uri,this.xd=!!s.xd,this.xs=!!s.xs,this.async=s.async!==!1,this.data=s.data!=null?s.data:null,this.agent=s.agent,this.isBinary=s.isBinary,this.supportsBinary=s.supportsBinary,this.enablesXDR=s.enablesXDR,this.pfx=s.pfx,this.key=s.key,this.passphrase=s.passphrase,this.cert=s.cert,this.ca=s.ca,this.ciphers=s.ciphers,this.rejectUnauthorized=s.rejectUnauthorized,this.create()}function f(){for(var s in h.requests)h.requests.hasOwnProperty(s)&&h.requests[s].abort()}var l=a("xmlhttprequest"),d=a("./polling"),i=a("component-emitter"),u=a("component-inherit"),c=a("debug")("engine.io-client:polling-xhr");t.exports=o,t.exports.Request=h,u(o,d),o.prototype.supportsBinary=!0,o.prototype.request=function(s){return s=s||{},s.uri=this.uri(),s.xd=this.xd,s.xs=this.xs,s.agent=this.agent||!1,s.supportsBinary=this.supportsBinary,s.enablesXDR=this.enablesXDR,s.pfx=this.pfx,s.key=this.key,s.passphrase=this.passphrase,s.cert=this.cert,s.ca=this.ca,s.ciphers=this.ciphers,s.rejectUnauthorized=this.rejectUnauthorized,new h(s)},o.prototype.doWrite=function(s,n){var p=typeof s!="string"&&s!==void 0,y=this.request({method:"POST",data:s,isBinary:p}),v=this;y.on("success",n),y.on("error",function(w){v.onError("xhr post error",w)}),this.sendXhr=y},o.prototype.doPoll=function(){c("xhr poll");var s=this.request(),n=this;s.on("data",function(p){n.onData(p)}),s.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=s},i(h.prototype),h.prototype.create=function(){var s={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};s.pfx=this.pfx,s.key=this.key,s.passphrase=this.passphrase,s.cert=this.cert,s.ca=this.ca,s.ciphers=this.ciphers,s.rejectUnauthorized=this.rejectUnauthorized;var n=this.xhr=new l(s),p=this;try{if(c("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,this.async),this.supportsBinary&&(n.responseType="arraybuffer"),this.method=="POST")try{this.isBinary?n.setRequestHeader("Content-type","application/octet-stream"):n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}"withCredentials"in n&&(n.withCredentials=!0),this.hasXDR()?(n.onload=function(){p.onLoad()},n.onerror=function(){p.onError(n.responseText)}):n.onreadystatechange=function(){n.readyState==4&&(n.status==200||n.status==1223?p.onLoad():setTimeout(function(){p.onError(n.status)},0))},c("xhr data %s",this.data),n.send(this.data)}catch(y){return void setTimeout(function(){p.onError(y)},0)}e.document&&(this.index=h.requestsCount++,h.requests[this.index]=this)},h.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},h.prototype.onData=function(s){this.emit("data",s),this.onSuccess()},h.prototype.onError=function(s){this.emit("error",s),this.cleanup(!0)},h.prototype.cleanup=function(s){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=r:this.xhr.onreadystatechange=r,s)try{this.xhr.abort()}catch{}e.document&&delete h.requests[this.index],this.xhr=null}},h.prototype.onLoad=function(){var s;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}s=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}s!=null&&this.onData(s)},h.prototype.hasXDR=function(){return typeof e.XDomainRequest<"u"&&!this.xs&&this.enablesXDR},h.prototype.abort=function(){this.cleanup()},e.document&&(h.requestsCount=0,h.requests={},e.attachEvent?e.attachEvent("onunload",f):e.addEventListener&&e.addEventListener("beforeunload",f,!1))}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-emitter":9,"component-inherit":21,debug:22,xmlhttprequest:20}],18:[function(a,t){function e(i){var u=i&&i.forceBase64;(!d||u)&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("parseqs"),h=a("engine.io-parser"),f=a("component-inherit"),l=a("debug")("engine.io-client:polling");t.exports=e;var d=function(){var i=a("xmlhttprequest"),u=new i({xdomain:!1});return u.responseType!=null}();f(e,r),e.prototype.name="polling",e.prototype.doOpen=function(){this.poll()},e.prototype.pause=function(i){function u(){l("paused"),c.readyState="paused",i()}var c=this;if(this.readyState="pausing",this.polling||!this.writable){var s=0;this.polling&&(l("we are currently polling - waiting to pause"),s++,this.once("pollComplete",function(){l("pre-pause polling complete"),--s||u()})),this.writable||(l("we are currently writing - waiting to pause"),s++,this.once("drain",function(){l("pre-pause writing complete"),--s||u()}))}else u()},e.prototype.poll=function(){l("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},e.prototype.onData=function(i){var u=this;l("polling got data %s",i);var c=function(s){return u.readyState=="opening"&&u.onOpen(),s.type=="close"?(u.onClose(),!1):void u.onPacket(s)};h.decodePayload(i,this.socket.binaryType,c),this.readyState!="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState=="open"?this.poll():l('ignoring poll - transport state "%s"',this.readyState))},e.prototype.doClose=function(){function i(){l("writing close packet"),u.write([{type:"close"}])}var u=this;this.readyState=="open"?(l("transport open - closing"),i()):(l("transport not open - deferring close"),this.once("open",i))},e.prototype.write=function(i){var c=this;this.writable=!1;var u=function(){c.writable=!0,c.emit("drain")},c=this;h.encodePayload(i,this.supportsBinary,function(s){c.doWrite(s,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",c="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+r.timestamps++),this.supportsBinary||i.sid||(i.b64=1),i=o.encode(i),this.port&&(u=="https"&&this.port!=443||u=="http"&&this.port!=80)&&(c=":"+this.port),i.length&&(i="?"+i),u+"://"+this.hostname+c+this.path+i}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,xmlhttprequest:20}],19:[function(a,t){function e(i){var u=i&&i.forceBase64;u&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("engine.io-parser"),h=a("parseqs"),f=a("component-inherit"),l=a("debug")("engine.io-client:websocket"),d=a("ws");t.exports=e,f(e,r),e.prototype.name="websocket",e.prototype.supportsBinary=!0,e.prototype.doOpen=function(){if(this.check()){var i=this.uri(),u=void 0,c={agent:this.agent};c.pfx=this.pfx,c.key=this.key,c.passphrase=this.passphrase,c.cert=this.cert,c.ca=this.ca,c.ciphers=this.ciphers,c.rejectUnauthorized=this.rejectUnauthorized,this.ws=new d(i,u,c),this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.binaryType="arraybuffer",this.addEventListeners()}},e.prototype.addEventListeners=function(){var i=this;this.ws.onopen=function(){i.onOpen()},this.ws.onclose=function(){i.onClose()},this.ws.onmessage=function(u){i.onData(u.data)},this.ws.onerror=function(u){i.onError("websocket error",u)}},typeof navigator<"u"&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(e.prototype.onData=function(i){var u=this;setTimeout(function(){r.prototype.onData.call(u,i)},0)}),e.prototype.write=function(i){function u(){c.writable=!0,c.emit("drain")}var c=this;this.writable=!1;for(var s=0,n=i.length;n>s;s++)o.encodePacket(i[s],this.supportsBinary,function(p){try{c.ws.send(p)}catch{l("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){r.prototype.onClose.call(this)},e.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"wss":"ws",c="";return this.port&&(u=="wss"&&this.port!=443||u=="ws"&&this.port!=80)&&(c=":"+this.port),this.timestampRequests&&(i[this.timestampParam]=+new Date),this.supportsBinary||(i.b64=1),i=h.encode(i),i.length&&(i="?"+i),u+"://"+this.hostname+c+this.path+i},e.prototype.check=function(){return!(!d||"__initialize"in d&&this.name===e.prototype.name)}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,ws:35}],20:[function(a,t){var e=a("has-cors");t.exports=function(r){var o=r.xdomain,h=r.xscheme,f=r.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!o||e))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!h&&f)return new XDomainRequest}catch{}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}}},{"has-cors":38}],21:[function(a,t){t.exports=function(e,r){var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var d=arguments,i=this.useColors;if(d[0]=(i?"%c":"")+this.namespace+(i?" %c":" ")+d[0]+(i?"%c ":" ")+"+"+e.humanize(this.diff),!i)return d;var u="color: "+this.color;d=[d[0],u,"color: inherit"].concat(Array.prototype.slice.call(d,1));var c=0,s=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(c++,n==="%c"&&(s=c))}),d.splice(s,0,u),d}function h(){return typeof console=="object"&&typeof console.log=="function"&&Function.prototype.apply.call(console.log,console,arguments)}function f(d){try{d==null?localStorage.removeItem("debug"):localStorage.debug=d}catch{}}function l(){var d;try{d=localStorage.debug}catch{}return d}e=t.exports=a("./debug"),e.log=h,e.formatArgs=o,e.save=f,e.load=l,e.useColors=r,e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(d){return JSON.stringify(d)},e.enable(l())},{"./debug":23}],23:[function(a,t,e){function r(){return e.colors[u++%e.colors.length]}function o(c){function s(){}function n(){var y=n,v=+new Date,w=v-(i||v);y.diff=w,y.prev=i,y.curr=v,i=v,y.useColors==null&&(y.useColors=e.useColors()),y.color==null&&y.useColors&&(y.color=r());var j=Array.prototype.slice.call(arguments);j[0]=e.coerce(j[0]),typeof j[0]!="string"&&(j=["%o"].concat(j));var B=0;j[0]=j[0].replace(/%([a-z%])/g,function(O,C){if(O==="%%")return O;B++;var b=e.formatters[C];if(typeof b=="function"){var A=j[B];O=b.call(y,A),j.splice(B,1),B--}return O}),typeof e.formatArgs=="function"&&(j=e.formatArgs.apply(y,j));var V=n.log||e.log||console.log.bind(console);V.apply(y,j)}s.enabled=!1,n.enabled=!0;var p=e.enabled(c)?n:s;return p.namespace=c,p}function h(c){e.save(c);for(var s=(c||"").split(/[\s,]+/),n=s.length,p=0;n>p;p++)s[p]&&(c=s[p].replace(/\*/g,".*?"),c[0]==="-"?e.skips.push(new RegExp("^"+c.substr(1)+"$")):e.names.push(new RegExp("^"+c+"$")))}function f(){e.enable("")}function l(c){var s,n;for(s=0,n=e.skips.length;n>s;s++)if(e.skips[s].test(c))return!1;for(s=0,n=e.names.length;n>s;s++)if(e.names[s].test(c))return!0;return!1}function d(c){return c instanceof Error?c.stack||c.message:c}e=t.exports=o,e.coerce=d,e.disable=f,e.enable=h,e.enabled=l,e.humanize=a("ms"),e.names=[],e.skips=[],e.formatters={};var i,u=0},{ms:24}],24:[function(a,t){function e(c){var s=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(c);if(s){var n=parseFloat(s[1]),p=(s[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"y":return n*u;case"days":case"day":case"d":return n*i;case"hours":case"hour":case"h":return n*d;case"minutes":case"minute":case"m":return n*l;case"seconds":case"second":case"s":return n*f;case"ms":return n}}}function r(c){return c>=i?Math.round(c/i)+"d":c>=d?Math.round(c/d)+"h":c>=l?Math.round(c/l)+"m":c>=f?Math.round(c/f)+"s":c+"ms"}function o(c){return h(c,i,"day")||h(c,d,"hour")||h(c,l,"minute")||h(c,f,"second")||c+" ms"}function h(c,s,n){return s>c?void 0:1.5*s>c?Math.floor(c/s)+" "+n:Math.ceil(c/s)+" "+n+"s"}var f=1e3,l=60*f,d=60*l,i=24*d,u=365.25*i;t.exports=function(c,s){return s=s||{},typeof c=="string"?e(c):s.long?o(c):r(c)}},{}],25:[function(a,t,e){(function(r){function o(C,b){var A="b"+e.packets[C.type]+C.data.data;return b(A)}function h(C,b,A){if(!b)return e.encodeBase64Packet(C,A);var g=C.data,m=new Uint8Array(g),L=new Uint8Array(1+g.byteLength);L[0]=j[C.type];for(var R=0;R<m.length;R++)L[R+1]=m[R];return A(L.buffer)}function f(C,b,A){if(!b)return e.encodeBase64Packet(C,A);var g=new FileReader;return g.onload=function(){C.data=g.result,e.encodePacket(C,b,!0,A)},g.readAsArrayBuffer(C.data)}function l(C,b,A){if(!b)return e.encodeBase64Packet(C,A);if(w)return f(C,b,A);var g=new Uint8Array(1);g[0]=j[C.type];var m=new O([g.buffer,C.data]);return A(m)}function d(C,b,A){for(var g=new Array(C.length),m=n(C.length,A),L=function(I,S,X){b(S,function($,J){g[I]=J,X($,g)})},R=0;R<C.length;R++)L(R,C[R],m)}var i=a("./keys"),u=a("has-binary"),c=a("arraybuffer.slice"),s=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),y=navigator.userAgent.match(/Android/i),v=/PhantomJS/i.test(navigator.userAgent),w=y||v;e.protocol=3;var j=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},B=i(j),V={type:"error",data:"parser error"},O=a("blob");e.encodePacket=function(C,b,A,g){typeof b=="function"&&(g=b,b=!1),typeof A=="function"&&(g=A,A=null);var m=C.data===void 0?void 0:C.data.buffer||C.data;if(r.ArrayBuffer&&m instanceof ArrayBuffer)return h(C,b,g);if(O&&m instanceof r.Blob)return l(C,b,g);if(m&&m.base64)return o(C,g);var L=j[C.type];return C.data!==void 0&&(L+=A?p.encode(String(C.data)):String(C.data)),g(""+L)},e.encodeBase64Packet=function(C,b){var A="b"+e.packets[C.type];if(O&&C.data instanceof O){var g=new FileReader;return g.onload=function(){var S=g.result.split(",")[1];b(A+S)},g.readAsDataURL(C.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(C.data))}catch{for(var L=new Uint8Array(C.data),R=new Array(L.length),I=0;I<L.length;I++)R[I]=L[I];m=String.fromCharCode.apply(null,R)}return A+=r.btoa(m),b(A)},e.decodePacket=function(C,b,A){if(typeof C=="string"||C===void 0){if(C.charAt(0)=="b")return e.decodeBase64Packet(C.substr(1),b);if(A)try{C=p.decode(C)}catch{return V}var m=C.charAt(0);return Number(m)==m&&B[m]?C.length>1?{type:B[m],data:C.substring(1)}:{type:B[m]}:V}var g=new Uint8Array(C),m=g[0],L=c(C,1);return O&&b==="blob"&&(L=new O([L])),{type:B[m],data:L}},e.decodeBase64Packet=function(C,b){var A=B[C.charAt(0)];if(!r.ArrayBuffer)return{type:A,data:{base64:!0,data:C.substr(1)}};var g=s.decode(C.substr(1));return b==="blob"&&O&&(g=new O([g])),{type:A,data:g}},e.encodePayload=function(C,b,A){function g(R){return R.length+":"+R}function m(R,I){e.encodePacket(R,L?b:!1,!0,function(S){I(null,g(S))})}typeof b=="function"&&(A=b,b=null);var L=u(C);return b&&L?O&&!w?e.encodePayloadAsBlob(C,A):e.encodePayloadAsArrayBuffer(C,A):C.length?void d(C,m,function(R,I){return A(I.join(""))}):A("0:")},e.decodePayload=function(C,b,A){if(typeof C!="string")return e.decodePayloadAsBinary(C,b,A);typeof b=="function"&&(A=b,b=null);var g;if(C=="")return A(V,0,1);for(var m,L,R="",I=0,S=C.length;S>I;I++){var X=C.charAt(I);if(X!=":")R+=X;else{if(R==""||R!=(m=Number(R))||(L=C.substr(I+1,m),R!=L.length))return A(V,0,1);if(L.length){if(g=e.decodePacket(L,b,!0),V.type==g.type&&V.data==g.data)return A(V,0,1);var $=A(g,I+m,S);if($===!1)return}I+=m,R=""}}return R!=""?A(V,0,1):void 0},e.encodePayloadAsArrayBuffer=function(C,b){function A(g,m){e.encodePacket(g,!0,!0,function(L){return m(null,L)})}return C.length?void d(C,A,function(g,m){var L=m.reduce(function(S,X){var $;return $=typeof X=="string"?X.length:X.byteLength,S+$.toString().length+$+2},0),R=new Uint8Array(L),I=0;return m.forEach(function(S){var X=typeof S=="string",$=S;if(X){for(var J=new Uint8Array(S.length),q=0;q<S.length;q++)J[q]=S.charCodeAt(q);$=J.buffer}R[I++]=X?0:1;for(var W=$.byteLength.toString(),q=0;q<W.length;q++)R[I++]=parseInt(W[q]);R[I++]=255;for(var J=new Uint8Array($),q=0;q<J.length;q++)R[I++]=J[q]}),b(R.buffer)}):b(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(C,b){function A(g,m){e.encodePacket(g,!0,!0,function(L){var R=new Uint8Array(1);if(R[0]=1,typeof L=="string"){for(var I=new Uint8Array(L.length),S=0;S<L.length;S++)I[S]=L.charCodeAt(S);L=I.buffer,R[0]=0}for(var X=L instanceof ArrayBuffer?L.byteLength:L.size,$=X.toString(),J=new Uint8Array($.length+1),S=0;S<$.length;S++)J[S]=parseInt($[S]);if(J[$.length]=255,O){var q=new O([R.buffer,J.buffer,L]);m(null,q)}})}d(C,A,function(g,m){return b(new O(m))})},e.decodePayloadAsBinary=function(C,b,A){typeof b=="function"&&(A=b,b=null);for(var g=C,m=[],L=!1;g.byteLength>0;){for(var R=new Uint8Array(g),I=R[0]===0,S="",X=1;R[X]!=255;X++){if(S.length>310){L=!0;break}S+=R[X]}if(L)return A(V,0,1);g=c(g,2+S.length),S=parseInt(S);var $=c(g,0,S);if(I)try{$=String.fromCharCode.apply(null,new Uint8Array($))}catch{var J=new Uint8Array($);$="";for(var X=0;X<J.length;X++)$+=String.fromCharCode(J[X])}m.push($),g=c(g,S)}var q=m.length;m.forEach(function(W,oe){A(e.decodePacket(W,b,!0),oe,q)})}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./keys":26,after:27,"arraybuffer.slice":28,"base64-arraybuffer":29,blob:30,"has-binary":36,utf8:31}],26:[function(a,t){t.exports=Object.keys||function(e){var r=[],o=Object.prototype.hasOwnProperty;for(var h in e)o.call(e,h)&&r.push(h);return r}},{}],27:[function(a,t){function e(o,h,f){function l(i,u){if(l.count<=0)throw new Error("after called too many times");--l.count,i?(d=!0,h(i),h=f):l.count!==0||d||h(null,u)}var d=!1;return f=f||r,l.count=o,o===0?h():l}function r(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,r,o){var h=e.byteLength;if(r=r||0,o=o||h,e.slice)return e.slice(r,o);if(0>r&&(r+=h),0>o&&(o+=h),o>h&&(o=h),r>=h||r>=o||h===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),l=new Uint8Array(o-r),d=r,i=0;o>d;d++,i++)l[i]=f[d];return l.buffer}},{}],29:[function(a,t,e){(function(r){e.encode=function(o){var h,f=new Uint8Array(o),l=f.length,d="";for(h=0;l>h;h+=3)d+=r[f[h]>>2],d+=r[(3&f[h])<<4|f[h+1]>>4],d+=r[(15&f[h+1])<<2|f[h+2]>>6],d+=r[63&f[h+2]];return l%3===2?d=d.substring(0,d.length-1)+"=":l%3===1&&(d=d.substring(0,d.length-2)+"=="),d},e.decode=function(o){var h,f,l,d,i,u=.75*o.length,c=o.length,s=0;o[o.length-1]==="="&&(u--,o[o.length-2]==="="&&u--);var n=new ArrayBuffer(u),p=new Uint8Array(n);for(h=0;c>h;h+=4)f=r.indexOf(o[h]),l=r.indexOf(o[h+1]),d=r.indexOf(o[h+2]),i=r.indexOf(o[h+3]),p[s++]=f<<2|l>>4,p[s++]=(15&l)<<4|d>>2,p[s++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function r(u){for(var c=0;c<u.length;c++){var s=u[c];if(s.buffer instanceof ArrayBuffer){var n=s.buffer;if(s.byteLength!==n.byteLength){var p=new Uint8Array(s.byteLength);p.set(new Uint8Array(n,s.byteOffset,s.byteLength)),n=p.buffer}u[c]=n}}}function o(u,c){c=c||{};var s=new f;r(u);for(var n=0;n<u.length;n++)s.append(u[n]);return c.type?s.getBlob(c.type):s.getBlob()}function h(u,c){return r(u),new Blob(u,c||{})}var f=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,l=function(){try{var u=new Blob(["hi"]);return u.size===2}catch{return!1}}(),d=l&&function(){try{var u=new Blob([new Uint8Array([1,2])]);return u.size===2}catch{return!1}}(),i=f&&f.prototype.append&&f.prototype.getBlob;t.exports=function(){return l?d?e.Blob:h:i?o:void 0}()}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],31:[function(a,t,e){(function(r){(function(o){function h(g){for(var m,L,R=[],I=0,S=g.length;S>I;)m=g.charCodeAt(I++),m>=55296&&56319>=m&&S>I?(L=g.charCodeAt(I++),(64512&L)==56320?R.push(((1023&m)<<10)+(1023&L)+65536):(R.push(m),I--)):R.push(m);return R}function f(g){for(var m,L=g.length,R=-1,I="";++R<L;)m=g[R],m>65535&&(m-=65536,I+=V(m>>>10&1023|55296),m=56320|1023&m),I+=V(m);return I}function l(g){if(g>=55296&&57343>=g)throw Error("Lone surrogate U+"+g.toString(16).toUpperCase()+" is not a scalar value")}function d(g,m){return V(g>>m&63|128)}function i(g){if(!(4294967168&g))return V(g);var m="";return 4294965248&g?4294901760&g?!(4292870144&g)&&(m=V(g>>18&7|240),m+=d(g,12),m+=d(g,6)):(l(g),m=V(g>>12&15|224),m+=d(g,6)):m=V(g>>6&31|192),m+=V(63&g|128)}function u(g){for(var m,L=h(g),R=L.length,I=-1,S="";++I<R;)m=L[I],S+=i(m);return S}function c(){if(B>=j)throw Error("Invalid byte index");var g=255&w[B];if(B++,(192&g)==128)return 63&g;throw Error("Invalid continuation byte")}function s(){var g,m,L,R,I;if(B>j)throw Error("Invalid byte index");if(B==j)return!1;if(g=255&w[B],B++,(128&g)==0)return g;if((224&g)==192){var m=c();if(I=(31&g)<<6|m,I>=128)return I;throw Error("Invalid continuation byte")}if((240&g)==224){if(m=c(),L=c(),I=(15&g)<<12|m<<6|L,I>=2048)return l(I),I;throw Error("Invalid continuation byte")}if((248&g)==240&&(m=c(),L=c(),R=c(),I=(15&g)<<18|m<<12|L<<6|R,I>=65536&&1114111>=I))return I;throw Error("Invalid UTF-8 detected")}function n(g){w=h(g),j=w.length,B=0;for(var m,L=[];(m=s())!==!1;)L.push(m);return f(L)}var p=typeof e=="object"&&e,y=typeof t=="object"&&t&&t.exports==p&&t,v=typeof r=="object"&&r;(v.global===v||v.window===v)&&(o=v);var w,j,B,V=String.fromCharCode,O={version:"2.0.0",encode:u,decode:n};if(p&&!p.nodeType)if(y)y.exports=O;else{var C={},b=C.hasOwnProperty;for(var A in O)b.call(O,A)&&(p[A]=O[A])}else o.utf8=O})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(a,t){(function(e){var r=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,h=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,f=/(?:^|:|,)(?:\s*\[)+/g,l=/^\s+/,d=/\s+$/;t.exports=function(i){return typeof i=="string"&&i?(i=i.replace(l,"").replace(d,""),e.JSON&&JSON.parse?JSON.parse(i):r.test(i.replace(o,"@").replace(h,"]").replace(f,""))?new Function("return "+i)():void 0):null}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],33:[function(a,t,e){e.encode=function(r){var o="";for(var h in r)r.hasOwnProperty(h)&&(o.length&&(o+="&"),o+=encodeURIComponent(h)+"="+encodeURIComponent(r[h]));return o},e.decode=function(r){for(var o={},h=r.split("&"),f=0,l=h.length;l>f;f++){var d=h[f].split("=");o[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return o}},{}],34:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(o){var h=o,f=o.indexOf("["),l=o.indexOf("]");f!=-1&&l!=-1&&(o=o.substring(0,f)+o.substring(f,l).replace(/:/g,";")+o.substring(l,o.length));for(var d=e.exec(o||""),i={},u=14;u--;)i[r[u]]=d[u]||"";return f!=-1&&l!=-1&&(i.source=h,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i}},{}],35:[function(a,t){function e(h,f){return f?new o(h,f):new o(h)}var r=function(){return self}(),o=r.WebSocket||r.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function r(h){function f(l){if(!l)return!1;if(e.Buffer&&e.Buffer.isBuffer(l)||e.ArrayBuffer&&l instanceof ArrayBuffer||e.Blob&&l instanceof Blob||e.File&&l instanceof File)return!0;if(o(l)){for(var d=0;d<l.length;d++)if(f(l[d]))return!0}else if(l&&typeof l=="object"){l.toJSON&&(l=l.toJSON());for(var i in l)if(Object.prototype.hasOwnProperty.call(l,i)&&f(l[i]))return!0}return!1}return f(h)}var o=a("isarray");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{isarray:37}],37:[function(a,t){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],38:[function(a,t){var e=a("global");try{t.exports="XMLHttpRequest"in e&&"withCredentials"in new e.XMLHttpRequest}catch{t.exports=!1}},{global:39}],39:[function(a,t){t.exports=function(){return this}()},{}],40:[function(a,t){var e=[].indexOf;t.exports=function(r,o){if(e)return r.indexOf(o);for(var h=0;h<r.length;++h)if(r[h]===o)return h;return-1}},{}],41:[function(a,t,e){var r=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var h=[];for(var f in o)r.call(o,f)&&h.push(f);return h},e.values=function(o){var h=[];for(var f in o)r.call(o,f)&&h.push(o[f]);return h},e.merge=function(o,h){for(var f in h)r.call(h,f)&&(o[f]=h[f]);return o},e.length=function(o){return e.keys(o).length},e.isEmpty=function(o){return e.length(o)==0}},{}],42:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(o){for(var h=e.exec(o||""),f={},l=14;l--;)f[r[l]]=h[l]||"";return f}},{}],43:[function(a,t,e){(function(r){var o=a("isarray"),h=a("./is-buffer");e.deconstructPacket=function(f){function l(c){if(!c)return c;if(h(c)){var s={_placeholder:!0,num:d.length};return d.push(c),s}if(o(c)){for(var n=new Array(c.length),p=0;p<c.length;p++)n[p]=l(c[p]);return n}if(typeof c=="object"&&!(c instanceof Date)){var n={};for(var y in c)n[y]=l(c[y]);return n}return c}var d=[],i=f.data,u=f;return u.data=l(i),u.attachments=d.length,{packet:u,buffers:d}},e.reconstructPacket=function(f,l){function d(i){if(i&&i._placeholder){var u=l[i.num];return u}if(o(i)){for(var c=0;c<i.length;c++)i[c]=d(i[c]);return i}if(i&&typeof i=="object"){for(var s in i)i[s]=d(i[s]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,l){function d(c,s,n){if(!c)return c;if(r.Blob&&c instanceof Blob||r.File&&c instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[s]=this.result:u=this.result,--i||l(u)},p.readAsArrayBuffer(c)}else if(o(c))for(var y=0;y<c.length;y++)d(c[y],y,c);else if(c&&typeof c=="object"&&!h(c))for(var v in c)d(c[v],v,c)}var i=0,u=f;d(u),i||l(u)}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./is-buffer":45,isarray:46}],44:[function(a,t,e){function r(){}function o(y){var v="",w=!1;return v+=y.type,(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)&&(v+=y.attachments,v+="-"),y.nsp&&y.nsp!="/"&&(w=!0,v+=y.nsp),y.id!=null&&(w&&(v+=",",w=!1),v+=y.id),y.data!=null&&(w&&(v+=","),v+=c.stringify(y.data)),u("encoded %j as %s",y,v),v}function h(y,v){function w(j){var B=n.deconstructPacket(j),V=o(B.packet),O=B.buffers;O.unshift(V),v(O)}n.removeBlobs(y,w)}function f(){this.reconstructor=null}function l(y){var v={},w=0;if(v.type=Number(y.charAt(0)),e.types[v.type]==null)return i();if(e.BINARY_EVENT==v.type||e.BINARY_ACK==v.type){for(var j="";y.charAt(++w)!="-"&&(j+=y.charAt(w),w!=y.length););if(j!=Number(j)||y.charAt(w)!="-")throw new Error("Illegal attachments");v.attachments=Number(j)}if(y.charAt(w+1)=="/")for(v.nsp="";++w;){var B=y.charAt(w);if(B==","||(v.nsp+=B,w==y.length))break}else v.nsp="/";var V=y.charAt(w+1);if(V!==""&&Number(V)==V){for(v.id="";++w;){var B=y.charAt(w);if(B==null||Number(B)!=B){--w;break}if(v.id+=y.charAt(w),w==y.length)break}v.id=Number(v.id)}if(y.charAt(++w))try{v.data=c.parse(y.substr(w))}catch{return i()}return u("decoded %s as %j",y,v),v}function d(y){this.reconPack=y,this.buffers=[]}function i(){return{type:e.ERROR,data:"parser error"}}var u=a("debug")("socket.io-parser"),c=a("json3"),s=(a("isarray"),a("component-emitter")),n=a("./binary"),p=a("./is-buffer");e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","BINARY_EVENT","ACK","BINARY_ACK","ERROR"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=f,r.prototype.encode=function(y,v){if(u("encoding packet %j",y),e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)h(y,v);else{var w=o(y);v([w])}},s(f.prototype),f.prototype.add=function(y){var v;if(typeof y=="string")v=l(y),e.BINARY_EVENT==v.type||e.BINARY_ACK==v.type?(this.reconstructor=new d(v),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",v)):this.emit("decoded",v);else{if(!p(y)&&!y.base64)throw new Error("Unknown type: "+y);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");v=this.reconstructor.takeBinaryData(y),v&&(this.reconstructor=null,this.emit("decoded",v))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},d.prototype.takeBinaryData=function(y){if(this.buffers.push(y),this.buffers.length==this.reconPack.attachments){var v=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),v}return null},d.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":43,"./is-buffer":45,"component-emitter":9,debug:10,isarray:46,json3:47}],45:[function(a,t){(function(e){function r(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(r){function o(E){if(o[E]!==l)return o[E];var _;if(E=="bug-string-char-index")_=!1;else if(E=="json")_=o("json-stringify")&&o("json-parse");else{var T,P='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var k=u.stringify,x=typeof k=="function"&&c;if(x){(T=function(){return 1}).toJSON=T;try{x=k(0)==="0"&&k(new Number)==="0"&&k(new String)=='""'&&k(d)===l&&k(l)===l&&k()===l&&k(T)==="1"&&k([T])=="[1]"&&k([l])=="[null]"&&k(null)=="null"&&k([l,d,null])=="[null,null,null]"&&k({a:[T,!0,!1,null,`\0\b
|
|
8
|
-
\f\r `]})==P&&
|
|
6
|
+
*/var Ve=function(a){return a!=null&&(be(a)||Me(a)||!!a._isBuffer)};function be(a){return!!a.constructor&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function Me(a){return typeof a.readFloatLE=="function"&&typeof a.slice=="function"&&be(a.slice(0,0))}(function(){var a=Fe,t=we.utf8,e=Ve,r=we.bin,o=function(h,f){h.constructor==String?f&&f.encoding==="binary"?h=r.stringToBytes(h):h=t.stringToBytes(h):e(h)?h=Array.prototype.slice.call(h,0):!Array.isArray(h)&&h.constructor!==Uint8Array&&(h=h.toString());for(var l=a.bytesToWords(h),d=h.length*8,i=1732584193,u=-271733879,c=-1732584194,s=271733878,n=0;n<l.length;n++)l[n]=(l[n]<<8|l[n]>>>24)&16711935|(l[n]<<24|l[n]>>>8)&4278255360;l[d>>>5]|=128<<d%32,l[(d+64>>>9<<4)+14]=d;for(var p=o._ff,y=o._gg,v=o._hh,w=o._ii,n=0;n<l.length;n+=16){var j=i,x=u,M=c,I=s;i=p(i,u,c,s,l[n+0],7,-680876936),s=p(s,i,u,c,l[n+1],12,-389564586),c=p(c,s,i,u,l[n+2],17,606105819),u=p(u,c,s,i,l[n+3],22,-1044525330),i=p(i,u,c,s,l[n+4],7,-176418897),s=p(s,i,u,c,l[n+5],12,1200080426),c=p(c,s,i,u,l[n+6],17,-1473231341),u=p(u,c,s,i,l[n+7],22,-45705983),i=p(i,u,c,s,l[n+8],7,1770035416),s=p(s,i,u,c,l[n+9],12,-1958414417),c=p(c,s,i,u,l[n+10],17,-42063),u=p(u,c,s,i,l[n+11],22,-1990404162),i=p(i,u,c,s,l[n+12],7,1804603682),s=p(s,i,u,c,l[n+13],12,-40341101),c=p(c,s,i,u,l[n+14],17,-1502002290),u=p(u,c,s,i,l[n+15],22,1236535329),i=y(i,u,c,s,l[n+1],5,-165796510),s=y(s,i,u,c,l[n+6],9,-1069501632),c=y(c,s,i,u,l[n+11],14,643717713),u=y(u,c,s,i,l[n+0],20,-373897302),i=y(i,u,c,s,l[n+5],5,-701558691),s=y(s,i,u,c,l[n+10],9,38016083),c=y(c,s,i,u,l[n+15],14,-660478335),u=y(u,c,s,i,l[n+4],20,-405537848),i=y(i,u,c,s,l[n+9],5,568446438),s=y(s,i,u,c,l[n+14],9,-1019803690),c=y(c,s,i,u,l[n+3],14,-187363961),u=y(u,c,s,i,l[n+8],20,1163531501),i=y(i,u,c,s,l[n+13],5,-1444681467),s=y(s,i,u,c,l[n+2],9,-51403784),c=y(c,s,i,u,l[n+7],14,1735328473),u=y(u,c,s,i,l[n+12],20,-1926607734),i=v(i,u,c,s,l[n+5],4,-378558),s=v(s,i,u,c,l[n+8],11,-2022574463),c=v(c,s,i,u,l[n+11],16,1839030562),u=v(u,c,s,i,l[n+14],23,-35309556),i=v(i,u,c,s,l[n+1],4,-1530992060),s=v(s,i,u,c,l[n+4],11,1272893353),c=v(c,s,i,u,l[n+7],16,-155497632),u=v(u,c,s,i,l[n+10],23,-1094730640),i=v(i,u,c,s,l[n+13],4,681279174),s=v(s,i,u,c,l[n+0],11,-358537222),c=v(c,s,i,u,l[n+3],16,-722521979),u=v(u,c,s,i,l[n+6],23,76029189),i=v(i,u,c,s,l[n+9],4,-640364487),s=v(s,i,u,c,l[n+12],11,-421815835),c=v(c,s,i,u,l[n+15],16,530742520),u=v(u,c,s,i,l[n+2],23,-995338651),i=w(i,u,c,s,l[n+0],6,-198630844),s=w(s,i,u,c,l[n+7],10,1126891415),c=w(c,s,i,u,l[n+14],15,-1416354905),u=w(u,c,s,i,l[n+5],21,-57434055),i=w(i,u,c,s,l[n+12],6,1700485571),s=w(s,i,u,c,l[n+3],10,-1894986606),c=w(c,s,i,u,l[n+10],15,-1051523),u=w(u,c,s,i,l[n+1],21,-2054922799),i=w(i,u,c,s,l[n+8],6,1873313359),s=w(s,i,u,c,l[n+15],10,-30611744),c=w(c,s,i,u,l[n+6],15,-1560198380),u=w(u,c,s,i,l[n+13],21,1309151649),i=w(i,u,c,s,l[n+4],6,-145523070),s=w(s,i,u,c,l[n+11],10,-1120210379),c=w(c,s,i,u,l[n+2],15,718787259),u=w(u,c,s,i,l[n+9],21,-343485551),i=i+j>>>0,u=u+x>>>0,c=c+M>>>0,s=s+I>>>0}return a.endian([i,u,c,s])};o._ff=function(h,f,l,d,i,u,c){var s=h+(f&l|~f&d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._gg=function(h,f,l,d,i,u,c){var s=h+(f&d|l&~d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._hh=function(h,f,l,d,i,u,c){var s=h+(f^l^d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._ii=function(h,f,l,d,i,u,c){var s=h+(l^(f|~d))+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._blocksize=16,o._digestsize=16,Ee.exports=function(h,f){if(h==null)throw new Error("Illegal argument "+h);var l=a.wordsToBytes(o(h,f));return f&&f.asBytes?l:f&&f.asString?r.bytesToString(l):a.bytesToHex(l)}})();var qe=Ee.exports;const Ke=je(qe);var te=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(te||{}),ne=(a=>(a.MAIN="main",a.NEXT="next",a))(ne||{}),Q=(a=>(a.USER="User",a.TOKEN="Token",a))(Q||{});class re{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const r=await chrome.storage.session.get(t);if(r[t])return e?JSON.parse(r[t]):r[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const r=window.sessionStorage.getItem(t);if(r)return e?JSON.parse(r):r}}static async updateSessionStorageKey(t,e){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[t]:JSON.stringify(e)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(t,JSON.stringify(e))}static clearSessionStorage(){typeof chrome<"u"&&typeof chrome.storage<"u"&&chrome.storage.session.clear(),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.clear=="function"&&window.sessionStorage.clear()}}class Xe{constructor(t){K(this,"delay",1e3);K(this,"lastLoginTimestamp");K(this,"token");K(this,"refreshToken");K(this,"tokenExpiry");K(this,"storageKey");this.eventsSdkClass=t,this.eventsSdkClass=t,this.storageKey=""}async login(){const t={token:this.eventsSdkClass.options.token&&this.eventsSdkClass.options.token,email:this.eventsSdkClass.options.email&&this.eventsSdkClass.options.email,password:this.eventsSdkClass.options.password&&this.eventsSdkClass.options.password};if(this.storageKey=Ke(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const e=await this.checkLoginStatus(this.storageKey);return e||(re.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await re.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,r){let o,h,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),h=await this.getSettings(o.Data.AccessToken),f={...o.Data,...h}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),f={...o.Data.Socket}),await re.updateSessionStorageKey(e,f),f}onLoginResponse(t){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&t.URLList&&(this.eventsSdkClass.URLList=t.URLList),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.URLList.length&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");if(this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");this.eventsSdkClass.server&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${this.eventsSdkClass.server.Version}`),!this.eventsSdkClass.server&&this.eventsSdkClass.URLList.length&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${t.Version}`),t.IdentityCode&&(this.token=t.IdentityCode,this.eventsSdkClass.connect(ne.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(ne.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Q.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Q.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let t;if(this.tokenExpiry)t=new Date(this.tokenExpiry);else return;const e=t.getTime()-new Date().getTime()-5e3,r=Math.min(e,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let o,h;if(this.eventsSdkClass.options.isNewStack){const f=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);o=await this.getSettings(f.Data.AccessToken),h={...f.Data,...o}}else h={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(h),await re.updateSessionStorageKey(this.storageKey,h)}},r)}async externalLogin(t,{password:e,token:r,email:o},h){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?h===Q.TOKEN?f=JSON.stringify({identityType:Q.TOKEN,token:r}):f=JSON.stringify({identityType:Q.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Q.TOKEN?(f=JSON.stringify({token:r}),t=`${t}/${Q.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Q.USER}`);let l;try{const d=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:f});if(!d.ok&&d.status===400)throw l=400,new Error("Bad body request. Login type or isNewStack values not correct or not provided");if(!d.ok&&d.status===401)throw l=401,new Error("Unauthorized. Invalid token provided");if(!d.ok&&d.status===403)throw l=403,new Error("Forbidden. Identity token not provided or not valid");const i=await d.json();if(i.error)throw new Error(i.error);return i}catch(d){throw this.eventsSdkClass.loggerClass.loginError(h,l,r,o),d}}async getSettings(t){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const e=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${t}`}});if(!e.ok&&e.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return e.json()}catch(e){throw this.eventsSdkClass.loggerClass.getSettingsError(t,e),e}}async externalRefreshToken(t,e){try{return(await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}})).json()}catch(r){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,r),r}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Ae={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:5,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",useLogger:!0,loggerServer:"https://socketlog.voicenter.co",loggerConfig:{logToConsole:!0,overloadGlobalConsole:!1,system:"events-sdk",socketEmitInterval:1e4},loggerConnectOptions:{reconnection:!1,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function $e(){return typeof window<"u"&&(typeof window.navigator>"u"||typeof window.navigator.userAgent>"u")&&(window.navigator.userAgent="react-native"),typeof self>"u"&&typeof global=="object"&&(global.self=global,global.WebSocket=Z,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,r){function o(l,d){if(!e[l]){if(!t[l]){var i=typeof require=="function"&&require;if(!d&&i)return i(l,!0);if(h)return h(l,!0);throw new Error("Cannot find module '"+l+"'")}var u=e[l]={exports:{}};t[l][0].call(u.exports,function(c){var s=t[l][1][c];return o(s||c)},u,u.exports,a,t,e,r)}return e[l].exports}for(var h=typeof require=="function"&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function r(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var c,s=o(i),n=s.source,p=s.id;return u.forceNew||u["force new connection"]||u.multiplex===!1?(l("ignoring socket cache for %s",n),c=f(n,u)):(d[p]||(l("new io instance for %s",n),d[p]=f(n,u)),c=d[p]),c.socket(s.path)}var o=a("./url"),h=a("socket.io-parser"),f=a("./manager"),l=a("debug")("socket.io-client");t.exports=e=r;var d=e.managers={};e.protocol=h.protocol,e.connect=r,e.Manager=a("./manager"),e.Socket=a("./socket")},{"./manager":3,"./socket":5,"./url":6,debug:10,"socket.io-parser":44}],3:[function(a,t){function e(s,n){return this instanceof e?(s&&typeof s=="object"&&(n=s,s=void 0),n=n||{},n.path=n.path||"/socket.io",this.nsps={},this.subs=[],this.opts=n,this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor(n.randomizationFactor||.5),this.backoff=new c({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this.readyState="closed",this.uri=s,this.connected=[],this.encoding=!1,this.packetBuffer=[],this.encoder=new f.Encoder,this.decoder=new f.Decoder,this.autoConnect=n.autoConnect!==!1,void(this.autoConnect&&this.open())):new e(s,n)}var r=(a("./url"),a("engine.io-client")),o=a("./socket"),h=a("component-emitter"),f=a("socket.io-parser"),l=a("./on"),d=a("component-bind"),i=(a("object-component"),a("debug")("socket.io-client:manager")),u=a("indexof"),c=a("backo2");t.exports=e,e.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var s in this.nsps)this.nsps[s].emit.apply(this.nsps[s],arguments)},e.prototype.updateSocketIds=function(){for(var s in this.nsps)this.nsps[s].id=this.engine.id},h(e.prototype),e.prototype.reconnection=function(s){return arguments.length?(this._reconnection=!!s,this):this._reconnection},e.prototype.reconnectionAttempts=function(s){return arguments.length?(this._reconnectionAttempts=s,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(s){return arguments.length?(this._reconnectionDelay=s,this.backoff&&this.backoff.setMin(s),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(s){return arguments.length?(this._randomizationFactor=s,this.backoff&&this.backoff.setJitter(s),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(s){return arguments.length?(this._reconnectionDelayMax=s,this.backoff&&this.backoff.setMax(s),this):this._reconnectionDelayMax},e.prototype.timeout=function(s){return arguments.length?(this._timeout=s,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(s){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=r(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var y=l(n,"open",function(){p.onopen(),s&&s()}),v=l(n,"error",function(x){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",x),s){var M=new Error("Connection error");M.data=x,s(M)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var w=this._timeout;i("connect attempt will timeout after %d",w);var j=setTimeout(function(){i("connect attempt timed out after %d",w),y.destroy(),n.close(),n.emit("error","timeout"),p.emitAll("connect_timeout",w)},w);this.subs.push({destroy:function(){clearTimeout(j)}})}return this.subs.push(y),this.subs.push(v),this},e.prototype.onopen=function(){i("open"),this.cleanup(),this.readyState="open",this.emit("open");var s=this.engine;this.subs.push(l(s,"data",d(this,"ondata"))),this.subs.push(l(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(l(s,"error",d(this,"onerror"))),this.subs.push(l(s,"close",d(this,"onclose")))},e.prototype.ondata=function(s){this.decoder.add(s)},e.prototype.ondecoded=function(s){this.emit("packet",s)},e.prototype.onerror=function(s){i("error",s),this.emitAll("error",s)},e.prototype.socket=function(s){var n=this.nsps[s];if(!n){n=new o(this,s),this.nsps[s]=n;var p=this;n.on("connect",function(){n.id=p.engine.id,~u(p.connected,n)||p.connected.push(n)})}return n},e.prototype.destroy=function(s){var n=u(this.connected,s);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(s){i("writing packet %j",s);var n=this;n.encoding?n.packetBuffer.push(s):(n.encoding=!0,this.encoder.encode(s,function(p){for(var y=0;y<p.length;y++)n.engine.write(p[y]);n.encoding=!1,n.processPacketQueue()}))},e.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var s=this.packetBuffer.shift();this.packet(s)}},e.prototype.cleanup=function(){for(var s;s=this.subs.shift();)s.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},e.prototype.close=e.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},e.prototype.onclose=function(s){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",s),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var s=this;if(this.backoff.attempts>=this._reconnectionAttempts)i("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var n=this.backoff.duration();i("will wait %dms before reconnect attempt",n),this.reconnecting=!0;var p=setTimeout(function(){s.skipReconnect||(i("attempting reconnect"),s.emitAll("reconnect_attempt",s.backoff.attempts),s.emitAll("reconnecting",s.backoff.attempts),s.skipReconnect||s.open(function(y){y?(i("reconnect attempt error"),s.reconnecting=!1,s.reconnect(),s.emitAll("reconnect_error",y.data)):(i("reconnect success"),s.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var s=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",s)}},{"./on":4,"./socket":5,"./url":6,backo2:7,"component-bind":8,"component-emitter":9,debug:10,"engine.io-client":11,indexof:40,"object-component":41,"socket.io-parser":44}],4:[function(a,t){function e(r,o,h){return r.on(o,h),{destroy:function(){r.removeListener(o,h)}}}t.exports=e},{}],5:[function(a,t,e){function r(n,p){this.io=n,this.nsp=p,this.json=this,this.ids=0,this.acks={},this.io.autoConnect&&this.open(),this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0}var o=a("socket.io-parser"),h=a("component-emitter"),f=a("to-array"),l=a("./on"),d=a("component-bind"),i=a("debug")("socket.io-client:socket"),u=a("has-binary");t.exports=r;var c={connect:1,connect_error:1,connect_timeout:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1},s=h.prototype.emit;h(r.prototype),r.prototype.subEvents=function(){if(!this.subs){var n=this.io;this.subs=[l(n,"open",d(this,"onopen")),l(n,"packet",d(this,"onpacket")),l(n,"close",d(this,"onclose"))]}},r.prototype.open=r.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},r.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},r.prototype.emit=function(n){if(c.hasOwnProperty(n))return s.apply(this,arguments),this;var p=f(arguments),y=o.EVENT;u(p)&&(y=o.BINARY_EVENT);var v={type:y,data:p};return typeof p[p.length-1]=="function"&&(i("emitting packet with ack id %d",this.ids),this.acks[this.ids]=p.pop(),v.id=this.ids++),this.connected?this.packet(v):this.sendBuffer.push(v),this},r.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},r.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},r.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},r.prototype.onpacket=function(n){if(n.nsp==this.nsp)switch(n.type){case o.CONNECT:this.onconnect();break;case o.EVENT:this.onevent(n);break;case o.BINARY_EVENT:this.onevent(n);break;case o.ACK:this.onack(n);break;case o.BINARY_ACK:this.onack(n);break;case o.DISCONNECT:this.ondisconnect();break;case o.ERROR:this.emit("error",n.data)}},r.prototype.onevent=function(n){var p=n.data||[];i("emitting event %j",p),n.id!=null&&(i("attaching ack callback to event"),p.push(this.ack(n.id))),this.connected?s.apply(this,p):this.receiveBuffer.push(p)},r.prototype.ack=function(n){var p=this,y=!1;return function(){if(!y){y=!0;var v=f(arguments);i("sending ack %j",v);var w=u(v)?o.BINARY_ACK:o.ACK;p.packet({type:w,id:n,data:v})}}},r.prototype.onack=function(n){i("calling ack %s with %j",n.id,n.data);var p=this.acks[n.id];p.apply(this,n.data),delete this.acks[n.id]},r.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},r.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)s.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},r.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},r.prototype.destroy=function(){if(this.subs){for(var n=0;n<this.subs.length;n++)this.subs[n].destroy();this.subs=null}this.io.destroy(this)},r.prototype.close=r.prototype.disconnect=function(){return this.connected&&(i("performing disconnect (%s)",this.nsp),this.packet({type:o.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{"./on":4,"component-bind":8,"component-emitter":9,debug:10,"has-binary":36,"socket.io-parser":44,"to-array":48}],6:[function(a,t){(function(e){function r(f,i){var d=f,i=i||e.location;return f==null&&(f=i.protocol+"//"+i.host),typeof f=="string"&&(f.charAt(0)=="/"&&(f=f.charAt(1)=="/"?i.protocol+f:i.hostname+f),/^(https?|wss?):\/\//.test(f)||(h("protocol-less url %s",f),f=typeof i<"u"?i.protocol+"//"+f:"https://"+f),h("parse %s",f),d=o(f)),d.port||(/^(http|ws)$/.test(d.protocol)?d.port="80":/^(http|ws)s$/.test(d.protocol)&&(d.port="443")),d.path=d.path||"/",d.id=d.protocol+"://"+d.host+":"+d.port,d.href=d.protocol+"://"+d.host+(i&&i.port==d.port?"":":"+d.port),d}var o=a("parseuri"),h=a("debug")("socket.io-client:url");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),h=Math.floor(o*this.jitter*r);r=1&Math.floor(10*o)?r+h:r-h}return 0|Math.min(r,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(r){this.ms=r},e.prototype.setMax=function(r){this.max=r},e.prototype.setJitter=function(r){this.jitter=r}},{}],8:[function(a,t){var e=[].slice;t.exports=function(r,o){if(typeof o=="string"&&(o=r[o]),typeof o!="function")throw new Error("bind() requires a function");var h=e.call(arguments,2);return function(){return o.apply(r,h.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?r(o):void 0}function r(o){for(var h in e.prototype)o[h]=e.prototype[h];return o}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(o,h){return this._callbacks=this._callbacks||{},(this._callbacks[o]=this._callbacks[o]||[]).push(h),this},e.prototype.once=function(o,h){function f(){l.off(o,f),h.apply(this,arguments)}var l=this;return this._callbacks=this._callbacks||{},f.fn=h,this.on(o,f),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(o,h){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var f=this._callbacks[o];if(!f)return this;if(arguments.length==1)return delete this._callbacks[o],this;for(var l,d=0;d<f.length;d++)if(l=f[d],l===h||l.fn===h){f.splice(d,1);break}return this},e.prototype.emit=function(o){this._callbacks=this._callbacks||{};var h=[].slice.call(arguments,1),f=this._callbacks[o];if(f){f=f.slice(0);for(var l=0,d=f.length;d>l;++l)f[l].apply(this,h)}return this},e.prototype.listeners=function(o){return this._callbacks=this._callbacks||{},this._callbacks[o]||[]},e.prototype.hasListeners=function(o){return!!this.listeners(o).length}},{}],10:[function(a,t){function e(o){return e.enabled(o)?function(h){h=r(h);var f=new Date,l=f-(e[o]||f);e[o]=f,h=o+" "+h+" +"+e.humanize(l),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function r(o){return o instanceof Error?o.stack||o.message:o}t.exports=e,e.names=[],e.skips=[],e.enable=function(o){try{localStorage.debug=o}catch{}for(var h=(o||"").split(/[\s,]+/),f=h.length,l=0;f>l;l++)o=h[l].replace("*",".*?"),o[0]==="-"?e.skips.push(new RegExp("^"+o.substr(1)+"$")):e.names.push(new RegExp("^"+o+"$"))},e.disable=function(){e.enable("")},e.humanize=function(o){var h=1e3,f=6e4,l=60*f;return o>=l?(o/l).toFixed(1)+"h":o>=f?(o/f).toFixed(1)+"m":o>=h?(o/h|0)+"s":o+"ms"},e.enabled=function(o){for(var h=0,f=e.skips.length;f>h;h++)if(e.skips[h].test(o))return!1;for(var h=0,f=e.names.length;f>h;h++)if(e.names[h].test(o))return!0;return!1};try{window.localStorage&&e.enable(localStorage.debug)}catch{}},{}],11:[function(a,t){t.exports=a("./lib/")},{"./lib/":12}],12:[function(a,t){t.exports=a("./socket"),t.exports.parser=a("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(a,t){(function(e){function r(n,p){if(!(this instanceof r))return new r(n,p);if(p=p||{},n&&typeof n=="object"&&(p=n,n=null),n&&(n=u(n),p.host=n.host,p.secure=n.protocol=="https"||n.protocol=="wss",p.port=n.port,n.query&&(p.query=n.query)),this.secure=p.secure!=null?p.secure:e.location&&location.protocol=="https:",p.host){var y=p.host.split(":");p.hostname=y.shift(),y.length?p.port=y.pop():p.port||(p.port=this.secure?"443":"80")}this.agent=p.agent||!1,this.hostname=p.hostname||(e.location?location.hostname:"localhost"),this.port=p.port||(e.location&&location.port?location.port:this.secure?443:80),this.query=p.query||{},typeof this.query=="string"&&(this.query=s.decode(this.query)),this.upgrade=p.upgrade!==!1,this.path=(p.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!p.forceJSONP,this.jsonp=p.jsonp!==!1,this.forceBase64=!!p.forceBase64,this.enablesXDR=!!p.enablesXDR,this.timestampParam=p.timestampParam||"t",this.timestampRequests=p.timestampRequests,this.transports=p.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=p.policyPort||843,this.rememberUpgrade=p.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=p.onlyBinaryUpgrades,this.pfx=p.pfx||null,this.key=p.key||null,this.passphrase=p.passphrase||null,this.cert=p.cert||null,this.ca=p.ca||null,this.ciphers=p.ciphers||null,this.rejectUnauthorized=p.rejectUnauthorized||null,this.open()}function o(n){var p={};for(var y in n)n.hasOwnProperty(y)&&(p[y]=n[y]);return p}var h=a("./transports"),f=a("component-emitter"),l=a("debug")("engine.io-client:socket"),d=a("indexof"),i=a("engine.io-parser"),u=a("parseuri"),c=a("parsejson"),s=a("parseqs");t.exports=r,r.priorWebsocketSuccess=!1,f(r.prototype),r.protocol=i.protocol,r.Socket=r,r.Transport=a("./transport"),r.transports=a("./transports"),r.parser=a("engine.io-parser"),r.prototype.createTransport=function(n){l('creating transport "%s"',n);var p=o(this.query);p.EIO=i.protocol,p.transport=n,this.id&&(p.sid=this.id);var y=new h[n]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:p,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized});return y},r.prototype.open=function(){var p;if(this.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)p="websocket";else{if(this.transports.length==0){var n=this;return void setTimeout(function(){n.emit("error","No transports available")},0)}p=this.transports[0]}this.readyState="opening";var p;try{p=this.createTransport(p)}catch{return this.transports.shift(),void this.open()}p.open(),this.setTransport(p)},r.prototype.setTransport=function(n){l("setting transport %s",n.name);var p=this;this.transport&&(l("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=n,n.on("drain",function(){p.onDrain()}).on("packet",function(y){p.onPacket(y)}).on("error",function(y){p.onError(y)}).on("close",function(){p.onClose("transport close")})},r.prototype.probe=function(n){function p(){if(b.onlyBinaryUpgrades){var N=!this.supportsBinary&&b.transport.supportsBinary;k=k||N}k||(l('probe transport "%s" opened',n),I.send([{type:"ping",data:"probe"}]),I.once("packet",function(g){if(!k)if(g.type=="pong"&&g.data=="probe"){if(l('probe transport "%s" pong',n),b.upgrading=!0,b.emit("upgrading",I),!I)return;r.priorWebsocketSuccess=I.name=="websocket",l('pausing current transport "%s"',b.transport.name),b.transport.pause(function(){k||b.readyState!="closed"&&(l("changing transport and sending upgrade packet"),M(),b.setTransport(I),I.send([{type:"upgrade"}]),b.emit("upgrade",I),I=null,b.upgrading=!1,b.flush())})}else{l('probe transport "%s" failed',n);var m=new Error("probe error");m.transport=I.name,b.emit("upgradeError",m)}}))}function y(){k||(k=!0,M(),I.close(),I=null)}function v(N){var g=new Error("probe error: "+N);g.transport=I.name,y(),l('probe transport "%s" failed because of error: %s',n,N),b.emit("upgradeError",g)}function w(){v("transport closed")}function j(){v("socket closed")}function x(N){I&&N.name!=I.name&&(l('"%s" works - aborting "%s"',N.name,I.name),y())}function M(){I.removeListener("open",p),I.removeListener("error",v),I.removeListener("close",w),b.removeListener("close",j),b.removeListener("upgrading",x)}l('probing transport "%s"',n);var I=this.createTransport(n,{probe:1}),k=!1,b=this;r.priorWebsocketSuccess=!1,I.once("open",p),I.once("error",v),I.once("close",w),this.once("close",j),this.once("upgrading",x),I.open()},r.prototype.onOpen=function(){if(l("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name=="websocket",this.emit("open"),this.flush(),this.readyState=="open"&&this.upgrade&&this.transport.pause){l("starting upgrade probes");for(var n=0,p=this.upgrades.length;p>n;n++)this.probe(this.upgrades[n])}},r.prototype.onPacket=function(n){if(this.readyState=="opening"||this.readyState=="open")switch(l('socket receive: type "%s", data "%s"',n.type,n.data),this.emit("packet",n),this.emit("heartbeat"),n.type){case"open":this.onHandshake(c(n.data));break;case"pong":this.setPing();break;case"error":var p=new Error("server error");p.code=n.data,this.emit("error",p);break;case"message":this.emit("data",n.data),this.emit("message",n.data)}else l('packet received with socket readyState "%s"',this.readyState)},r.prototype.onHandshake=function(n){this.emit("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this.upgrades=this.filterUpgrades(n.upgrades),this.pingInterval=n.pingInterval,this.pingTimeout=n.pingTimeout,this.onOpen(),this.readyState!="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},r.prototype.onHeartbeat=function(n){clearTimeout(this.pingTimeoutTimer);var p=this;p.pingTimeoutTimer=setTimeout(function(){p.readyState!="closed"&&p.onClose("ping timeout")},n||p.pingInterval+p.pingTimeout)},r.prototype.setPing=function(){var n=this;clearTimeout(n.pingIntervalTimer),n.pingIntervalTimer=setTimeout(function(){l("writing ping packet - expecting pong within %sms",n.pingTimeout),n.ping(),n.onHeartbeat(n.pingTimeout)},n.pingInterval)},r.prototype.ping=function(){this.sendPacket("ping")},r.prototype.onDrain=function(){for(var n=0;n<this.prevBufferLen;n++)this.callbackBuffer[n]&&this.callbackBuffer[n]();this.writeBuffer.splice(0,this.prevBufferLen),this.callbackBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length==0?this.emit("drain"):this.flush()},r.prototype.flush=function(){this.readyState!="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(l("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},r.prototype.write=r.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},r.prototype.sendPacket=function(n,p,y){if(this.readyState!="closing"&&this.readyState!="closed"){var v={type:n,data:p};this.emit("packetCreate",v),this.writeBuffer.push(v),this.callbackBuffer.push(y),this.flush()}},r.prototype.close=function(){function n(){v.onClose("forced close"),l("socket closing - telling transport to close"),v.transport.close()}function p(){v.removeListener("upgrade",p),v.removeListener("upgradeError",p),n()}function y(){v.once("upgrade",p),v.once("upgradeError",p)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var v=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?y():n()}):this.upgrading?y():n()}return this},r.prototype.onError=function(n){l("socket error %j",n),r.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},r.prototype.onClose=function(n,p){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){l('socket close with reason: "%s"',n);var y=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),setTimeout(function(){y.writeBuffer=[],y.callbackBuffer=[],y.prevBufferLen=0},0),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",n,p)}},r.prototype.filterUpgrades=function(n){for(var p=[],y=0,v=n.length;v>y;y++)~d(this.transports,n[y])&&p.push(n[y]);return p}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./transport":14,"./transports":15,"component-emitter":9,debug:22,"engine.io-parser":25,indexof:40,parsejson:32,parseqs:33,parseuri:34}],14:[function(a,t){function e(h){this.path=h.path,this.hostname=h.hostname,this.port=h.port,this.secure=h.secure,this.query=h.query,this.timestampParam=h.timestampParam,this.timestampRequests=h.timestampRequests,this.readyState="",this.agent=h.agent||!1,this.socket=h.socket,this.enablesXDR=h.enablesXDR,this.pfx=h.pfx,this.key=h.key,this.passphrase=h.passphrase,this.cert=h.cert,this.ca=h.ca,this.ciphers=h.ciphers,this.rejectUnauthorized=h.rejectUnauthorized}var r=a("engine.io-parser"),o=a("component-emitter");t.exports=e,o(e.prototype),e.timestamps=0,e.prototype.onError=function(h,f){var l=new Error(h);return l.type="TransportError",l.description=f,this.emit("error",l),this},e.prototype.open=function(){return(this.readyState=="closed"||this.readyState=="")&&(this.readyState="opening",this.doOpen()),this},e.prototype.close=function(){return(this.readyState=="opening"||this.readyState=="open")&&(this.doClose(),this.onClose()),this},e.prototype.send=function(h){if(this.readyState!="open")throw new Error("Transport not open");this.write(h)},e.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},e.prototype.onData=function(h){var f=r.decodePacket(h,this.socket.binaryType);this.onPacket(f)},e.prototype.onPacket=function(h){this.emit("packet",h)},e.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(a,t,e){(function(r){function o(i){var u,c=!1,s=!1,n=i.jsonp!==!1;if(r.location){var p=location.protocol=="https:",y=location.port;y||(y=p?443:80),c=i.hostname!=location.hostname||y!=i.port,s=i.secure!=p}if(i.xdomain=c,i.xscheme=s,u=new h(i),"open"in u&&!i.forceJSONP)return new f(i);if(!n)throw new Error("JSONP disabled");return new l(i)}var h=a("xmlhttprequest"),f=a("./polling-xhr"),l=a("./polling-jsonp"),d=a("./websocket");e.polling=o,e.websocket=d}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(a,t){(function(e){function r(){}function o(u){h.call(this,u),this.query=this.query||{},l||(e.___eio||(e.___eio=[]),l=e.___eio),this.index=l.length;var c=this;l.push(function(s){c.onData(s)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){c.script&&(c.script.onerror=r)},!1)}var h=a("./polling"),f=a("component-inherit");t.exports=o;var l,d=/\n/g,i=/\\n/g;f(o,h),o.prototype.supportsBinary=!1,o.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),h.prototype.doClose.call(this)},o.prototype.doPoll=function(){var u=this,c=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),c.async=!0,c.src=this.uri(),c.onerror=function(p){u.onError("jsonp poll error",p)};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(c,s),this.script=c;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var p=document.createElement("iframe");document.body.appendChild(p),document.body.removeChild(p)},100)},o.prototype.doWrite=function(u,c){function s(){n(),c()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(M){p.onError("jsonp polling iframe removal error",M)}try{var x='<iframe src="javascript:0" name="'+p.iframeId+'">';y=document.createElement(x)}catch{y=document.createElement("iframe"),y.name=p.iframeId,y.src="javascript:0"}y.id=p.iframeId,p.form.appendChild(y),p.iframe=y}var p=this;if(!this.form){var y,v=document.createElement("form"),w=document.createElement("textarea"),j=this.iframeId="eio_iframe_"+this.index;v.className="socketio",v.style.position="absolute",v.style.top="-1000px",v.style.left="-1000px",v.target=j,v.method="POST",v.setAttribute("accept-charset","utf-8"),w.name="d",v.appendChild(w),document.body.appendChild(v),this.form=v,this.area=w}this.form.action=this.uri(),n(),u=u.replace(i,`\\
|
|
7
|
+
`),this.area.value=u.replace(d,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){p.iframe.readyState=="complete"&&s()}:this.iframe.onload=s}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function r(){}function o(s){if(d.call(this,s),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=s.hostname!=e.location.hostname||p!=s.port,this.xs=s.secure!=n}}function h(s){this.method=s.method||"GET",this.uri=s.uri,this.xd=!!s.xd,this.xs=!!s.xs,this.async=s.async!==!1,this.data=s.data!=null?s.data:null,this.agent=s.agent,this.isBinary=s.isBinary,this.supportsBinary=s.supportsBinary,this.enablesXDR=s.enablesXDR,this.pfx=s.pfx,this.key=s.key,this.passphrase=s.passphrase,this.cert=s.cert,this.ca=s.ca,this.ciphers=s.ciphers,this.rejectUnauthorized=s.rejectUnauthorized,this.create()}function f(){for(var s in h.requests)h.requests.hasOwnProperty(s)&&h.requests[s].abort()}var l=a("xmlhttprequest"),d=a("./polling"),i=a("component-emitter"),u=a("component-inherit"),c=a("debug")("engine.io-client:polling-xhr");t.exports=o,t.exports.Request=h,u(o,d),o.prototype.supportsBinary=!0,o.prototype.request=function(s){return s=s||{},s.uri=this.uri(),s.xd=this.xd,s.xs=this.xs,s.agent=this.agent||!1,s.supportsBinary=this.supportsBinary,s.enablesXDR=this.enablesXDR,s.pfx=this.pfx,s.key=this.key,s.passphrase=this.passphrase,s.cert=this.cert,s.ca=this.ca,s.ciphers=this.ciphers,s.rejectUnauthorized=this.rejectUnauthorized,new h(s)},o.prototype.doWrite=function(s,n){var p=typeof s!="string"&&s!==void 0,y=this.request({method:"POST",data:s,isBinary:p}),v=this;y.on("success",n),y.on("error",function(w){v.onError("xhr post error",w)}),this.sendXhr=y},o.prototype.doPoll=function(){c("xhr poll");var s=this.request(),n=this;s.on("data",function(p){n.onData(p)}),s.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=s},i(h.prototype),h.prototype.create=function(){var s={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};s.pfx=this.pfx,s.key=this.key,s.passphrase=this.passphrase,s.cert=this.cert,s.ca=this.ca,s.ciphers=this.ciphers,s.rejectUnauthorized=this.rejectUnauthorized;var n=this.xhr=new l(s),p=this;try{if(c("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,this.async),this.supportsBinary&&(n.responseType="arraybuffer"),this.method=="POST")try{this.isBinary?n.setRequestHeader("Content-type","application/octet-stream"):n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}"withCredentials"in n&&(n.withCredentials=!0),this.hasXDR()?(n.onload=function(){p.onLoad()},n.onerror=function(){p.onError(n.responseText)}):n.onreadystatechange=function(){n.readyState==4&&(n.status==200||n.status==1223?p.onLoad():setTimeout(function(){p.onError(n.status)},0))},c("xhr data %s",this.data),n.send(this.data)}catch(y){return void setTimeout(function(){p.onError(y)},0)}e.document&&(this.index=h.requestsCount++,h.requests[this.index]=this)},h.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},h.prototype.onData=function(s){this.emit("data",s),this.onSuccess()},h.prototype.onError=function(s){this.emit("error",s),this.cleanup(!0)},h.prototype.cleanup=function(s){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=r:this.xhr.onreadystatechange=r,s)try{this.xhr.abort()}catch{}e.document&&delete h.requests[this.index],this.xhr=null}},h.prototype.onLoad=function(){var s;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}s=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}s!=null&&this.onData(s)},h.prototype.hasXDR=function(){return typeof e.XDomainRequest<"u"&&!this.xs&&this.enablesXDR},h.prototype.abort=function(){this.cleanup()},e.document&&(h.requestsCount=0,h.requests={},e.attachEvent?e.attachEvent("onunload",f):e.addEventListener&&e.addEventListener("beforeunload",f,!1))}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-emitter":9,"component-inherit":21,debug:22,xmlhttprequest:20}],18:[function(a,t){function e(i){var u=i&&i.forceBase64;(!d||u)&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("parseqs"),h=a("engine.io-parser"),f=a("component-inherit"),l=a("debug")("engine.io-client:polling");t.exports=e;var d=function(){var i=a("xmlhttprequest"),u=new i({xdomain:!1});return u.responseType!=null}();f(e,r),e.prototype.name="polling",e.prototype.doOpen=function(){this.poll()},e.prototype.pause=function(i){function u(){l("paused"),c.readyState="paused",i()}var c=this;if(this.readyState="pausing",this.polling||!this.writable){var s=0;this.polling&&(l("we are currently polling - waiting to pause"),s++,this.once("pollComplete",function(){l("pre-pause polling complete"),--s||u()})),this.writable||(l("we are currently writing - waiting to pause"),s++,this.once("drain",function(){l("pre-pause writing complete"),--s||u()}))}else u()},e.prototype.poll=function(){l("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},e.prototype.onData=function(i){var u=this;l("polling got data %s",i);var c=function(s){return u.readyState=="opening"&&u.onOpen(),s.type=="close"?(u.onClose(),!1):void u.onPacket(s)};h.decodePayload(i,this.socket.binaryType,c),this.readyState!="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState=="open"?this.poll():l('ignoring poll - transport state "%s"',this.readyState))},e.prototype.doClose=function(){function i(){l("writing close packet"),u.write([{type:"close"}])}var u=this;this.readyState=="open"?(l("transport open - closing"),i()):(l("transport not open - deferring close"),this.once("open",i))},e.prototype.write=function(i){var c=this;this.writable=!1;var u=function(){c.writable=!0,c.emit("drain")},c=this;h.encodePayload(i,this.supportsBinary,function(s){c.doWrite(s,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",c="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+r.timestamps++),this.supportsBinary||i.sid||(i.b64=1),i=o.encode(i),this.port&&(u=="https"&&this.port!=443||u=="http"&&this.port!=80)&&(c=":"+this.port),i.length&&(i="?"+i),u+"://"+this.hostname+c+this.path+i}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,xmlhttprequest:20}],19:[function(a,t){function e(i){var u=i&&i.forceBase64;u&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("engine.io-parser"),h=a("parseqs"),f=a("component-inherit"),l=a("debug")("engine.io-client:websocket"),d=a("ws");t.exports=e,f(e,r),e.prototype.name="websocket",e.prototype.supportsBinary=!0,e.prototype.doOpen=function(){if(this.check()){var i=this.uri(),u=void 0,c={agent:this.agent};c.pfx=this.pfx,c.key=this.key,c.passphrase=this.passphrase,c.cert=this.cert,c.ca=this.ca,c.ciphers=this.ciphers,c.rejectUnauthorized=this.rejectUnauthorized,this.ws=new d(i,u,c),this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.binaryType="arraybuffer",this.addEventListeners()}},e.prototype.addEventListeners=function(){var i=this;this.ws.onopen=function(){i.onOpen()},this.ws.onclose=function(){i.onClose()},this.ws.onmessage=function(u){i.onData(u.data)},this.ws.onerror=function(u){i.onError("websocket error",u)}},typeof navigator<"u"&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(e.prototype.onData=function(i){var u=this;setTimeout(function(){r.prototype.onData.call(u,i)},0)}),e.prototype.write=function(i){function u(){c.writable=!0,c.emit("drain")}var c=this;this.writable=!1;for(var s=0,n=i.length;n>s;s++)o.encodePacket(i[s],this.supportsBinary,function(p){try{c.ws.send(p)}catch{l("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){r.prototype.onClose.call(this)},e.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"wss":"ws",c="";return this.port&&(u=="wss"&&this.port!=443||u=="ws"&&this.port!=80)&&(c=":"+this.port),this.timestampRequests&&(i[this.timestampParam]=+new Date),this.supportsBinary||(i.b64=1),i=h.encode(i),i.length&&(i="?"+i),u+"://"+this.hostname+c+this.path+i},e.prototype.check=function(){return!(!d||"__initialize"in d&&this.name===e.prototype.name)}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,ws:35}],20:[function(a,t){var e=a("has-cors");t.exports=function(r){var o=r.xdomain,h=r.xscheme,f=r.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!o||e))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!h&&f)return new XDomainRequest}catch{}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}}},{"has-cors":38}],21:[function(a,t){t.exports=function(e,r){var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var d=arguments,i=this.useColors;if(d[0]=(i?"%c":"")+this.namespace+(i?" %c":" ")+d[0]+(i?"%c ":" ")+"+"+e.humanize(this.diff),!i)return d;var u="color: "+this.color;d=[d[0],u,"color: inherit"].concat(Array.prototype.slice.call(d,1));var c=0,s=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(c++,n==="%c"&&(s=c))}),d.splice(s,0,u),d}function h(){return typeof console=="object"&&typeof console.log=="function"&&Function.prototype.apply.call(console.log,console,arguments)}function f(d){try{d==null?localStorage.removeItem("debug"):localStorage.debug=d}catch{}}function l(){var d;try{d=localStorage.debug}catch{}return d}e=t.exports=a("./debug"),e.log=h,e.formatArgs=o,e.save=f,e.load=l,e.useColors=r,e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(d){return JSON.stringify(d)},e.enable(l())},{"./debug":23}],23:[function(a,t,e){function r(){return e.colors[u++%e.colors.length]}function o(c){function s(){}function n(){var y=n,v=+new Date,w=v-(i||v);y.diff=w,y.prev=i,y.curr=v,i=v,y.useColors==null&&(y.useColors=e.useColors()),y.color==null&&y.useColors&&(y.color=r());var j=Array.prototype.slice.call(arguments);j[0]=e.coerce(j[0]),typeof j[0]!="string"&&(j=["%o"].concat(j));var x=0;j[0]=j[0].replace(/%([a-z%])/g,function(I,k){if(I==="%%")return I;x++;var b=e.formatters[k];if(typeof b=="function"){var N=j[x];I=b.call(y,N),j.splice(x,1),x--}return I}),typeof e.formatArgs=="function"&&(j=e.formatArgs.apply(y,j));var M=n.log||e.log||console.log.bind(console);M.apply(y,j)}s.enabled=!1,n.enabled=!0;var p=e.enabled(c)?n:s;return p.namespace=c,p}function h(c){e.save(c);for(var s=(c||"").split(/[\s,]+/),n=s.length,p=0;n>p;p++)s[p]&&(c=s[p].replace(/\*/g,".*?"),c[0]==="-"?e.skips.push(new RegExp("^"+c.substr(1)+"$")):e.names.push(new RegExp("^"+c+"$")))}function f(){e.enable("")}function l(c){var s,n;for(s=0,n=e.skips.length;n>s;s++)if(e.skips[s].test(c))return!1;for(s=0,n=e.names.length;n>s;s++)if(e.names[s].test(c))return!0;return!1}function d(c){return c instanceof Error?c.stack||c.message:c}e=t.exports=o,e.coerce=d,e.disable=f,e.enable=h,e.enabled=l,e.humanize=a("ms"),e.names=[],e.skips=[],e.formatters={};var i,u=0},{ms:24}],24:[function(a,t){function e(c){var s=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(c);if(s){var n=parseFloat(s[1]),p=(s[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"y":return n*u;case"days":case"day":case"d":return n*i;case"hours":case"hour":case"h":return n*d;case"minutes":case"minute":case"m":return n*l;case"seconds":case"second":case"s":return n*f;case"ms":return n}}}function r(c){return c>=i?Math.round(c/i)+"d":c>=d?Math.round(c/d)+"h":c>=l?Math.round(c/l)+"m":c>=f?Math.round(c/f)+"s":c+"ms"}function o(c){return h(c,i,"day")||h(c,d,"hour")||h(c,l,"minute")||h(c,f,"second")||c+" ms"}function h(c,s,n){return s>c?void 0:1.5*s>c?Math.floor(c/s)+" "+n:Math.ceil(c/s)+" "+n+"s"}var f=1e3,l=60*f,d=60*l,i=24*d,u=365.25*i;t.exports=function(c,s){return s=s||{},typeof c=="string"?e(c):s.long?o(c):r(c)}},{}],25:[function(a,t,e){(function(r){function o(k,b){var N="b"+e.packets[k.type]+k.data.data;return b(N)}function h(k,b,N){if(!b)return e.encodeBase64Packet(k,N);var g=k.data,m=new Uint8Array(g),_=new Uint8Array(1+g.byteLength);_[0]=j[k.type];for(var B=0;B<m.length;B++)_[B+1]=m[B];return N(_.buffer)}function f(k,b,N){if(!b)return e.encodeBase64Packet(k,N);var g=new FileReader;return g.onload=function(){k.data=g.result,e.encodePacket(k,b,!0,N)},g.readAsArrayBuffer(k.data)}function l(k,b,N){if(!b)return e.encodeBase64Packet(k,N);if(w)return f(k,b,N);var g=new Uint8Array(1);g[0]=j[k.type];var m=new I([g.buffer,k.data]);return N(m)}function d(k,b,N){for(var g=new Array(k.length),m=n(k.length,N),_=function(R,S,X){b(S,function($,J){g[R]=J,X($,g)})},B=0;B<k.length;B++)_(B,k[B],m)}var i=a("./keys"),u=a("has-binary"),c=a("arraybuffer.slice"),s=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),y=navigator.userAgent.match(/Android/i),v=/PhantomJS/i.test(navigator.userAgent),w=y||v;e.protocol=3;var j=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},x=i(j),M={type:"error",data:"parser error"},I=a("blob");e.encodePacket=function(k,b,N,g){typeof b=="function"&&(g=b,b=!1),typeof N=="function"&&(g=N,N=null);var m=k.data===void 0?void 0:k.data.buffer||k.data;if(r.ArrayBuffer&&m instanceof ArrayBuffer)return h(k,b,g);if(I&&m instanceof r.Blob)return l(k,b,g);if(m&&m.base64)return o(k,g);var _=j[k.type];return k.data!==void 0&&(_+=N?p.encode(String(k.data)):String(k.data)),g(""+_)},e.encodeBase64Packet=function(k,b){var N="b"+e.packets[k.type];if(I&&k.data instanceof I){var g=new FileReader;return g.onload=function(){var S=g.result.split(",")[1];b(N+S)},g.readAsDataURL(k.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(k.data))}catch{for(var _=new Uint8Array(k.data),B=new Array(_.length),R=0;R<_.length;R++)B[R]=_[R];m=String.fromCharCode.apply(null,B)}return N+=r.btoa(m),b(N)},e.decodePacket=function(k,b,N){if(typeof k=="string"||k===void 0){if(k.charAt(0)=="b")return e.decodeBase64Packet(k.substr(1),b);if(N)try{k=p.decode(k)}catch{return M}var m=k.charAt(0);return Number(m)==m&&x[m]?k.length>1?{type:x[m],data:k.substring(1)}:{type:x[m]}:M}var g=new Uint8Array(k),m=g[0],_=c(k,1);return I&&b==="blob"&&(_=new I([_])),{type:x[m],data:_}},e.decodeBase64Packet=function(k,b){var N=x[k.charAt(0)];if(!r.ArrayBuffer)return{type:N,data:{base64:!0,data:k.substr(1)}};var g=s.decode(k.substr(1));return b==="blob"&&I&&(g=new I([g])),{type:N,data:g}},e.encodePayload=function(k,b,N){function g(B){return B.length+":"+B}function m(B,R){e.encodePacket(B,_?b:!1,!0,function(S){R(null,g(S))})}typeof b=="function"&&(N=b,b=null);var _=u(k);return b&&_?I&&!w?e.encodePayloadAsBlob(k,N):e.encodePayloadAsArrayBuffer(k,N):k.length?void d(k,m,function(B,R){return N(R.join(""))}):N("0:")},e.decodePayload=function(k,b,N){if(typeof k!="string")return e.decodePayloadAsBinary(k,b,N);typeof b=="function"&&(N=b,b=null);var g;if(k=="")return N(M,0,1);for(var m,_,B="",R=0,S=k.length;S>R;R++){var X=k.charAt(R);if(X!=":")B+=X;else{if(B==""||B!=(m=Number(B))||(_=k.substr(R+1,m),B!=_.length))return N(M,0,1);if(_.length){if(g=e.decodePacket(_,b,!0),M.type==g.type&&M.data==g.data)return N(M,0,1);var $=N(g,R+m,S);if($===!1)return}R+=m,B=""}}return B!=""?N(M,0,1):void 0},e.encodePayloadAsArrayBuffer=function(k,b){function N(g,m){e.encodePacket(g,!0,!0,function(_){return m(null,_)})}return k.length?void d(k,N,function(g,m){var _=m.reduce(function(S,X){var $;return $=typeof X=="string"?X.length:X.byteLength,S+$.toString().length+$+2},0),B=new Uint8Array(_),R=0;return m.forEach(function(S){var X=typeof S=="string",$=S;if(X){for(var J=new Uint8Array(S.length),q=0;q<S.length;q++)J[q]=S.charCodeAt(q);$=J.buffer}B[R++]=X?0:1;for(var W=$.byteLength.toString(),q=0;q<W.length;q++)B[R++]=parseInt(W[q]);B[R++]=255;for(var J=new Uint8Array($),q=0;q<J.length;q++)B[R++]=J[q]}),b(B.buffer)}):b(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(k,b){function N(g,m){e.encodePacket(g,!0,!0,function(_){var B=new Uint8Array(1);if(B[0]=1,typeof _=="string"){for(var R=new Uint8Array(_.length),S=0;S<_.length;S++)R[S]=_.charCodeAt(S);_=R.buffer,B[0]=0}for(var X=_ instanceof ArrayBuffer?_.byteLength:_.size,$=X.toString(),J=new Uint8Array($.length+1),S=0;S<$.length;S++)J[S]=parseInt($[S]);if(J[$.length]=255,I){var q=new I([B.buffer,J.buffer,_]);m(null,q)}})}d(k,N,function(g,m){return b(new I(m))})},e.decodePayloadAsBinary=function(k,b,N){typeof b=="function"&&(N=b,b=null);for(var g=k,m=[],_=!1;g.byteLength>0;){for(var B=new Uint8Array(g),R=B[0]===0,S="",X=1;B[X]!=255;X++){if(S.length>310){_=!0;break}S+=B[X]}if(_)return N(M,0,1);g=c(g,2+S.length),S=parseInt(S);var $=c(g,0,S);if(R)try{$=String.fromCharCode.apply(null,new Uint8Array($))}catch{var J=new Uint8Array($);$="";for(var X=0;X<J.length;X++)$+=String.fromCharCode(J[X])}m.push($),g=c(g,S)}var q=m.length;m.forEach(function(W,oe){N(e.decodePacket(W,b,!0),oe,q)})}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./keys":26,after:27,"arraybuffer.slice":28,"base64-arraybuffer":29,blob:30,"has-binary":36,utf8:31}],26:[function(a,t){t.exports=Object.keys||function(e){var r=[],o=Object.prototype.hasOwnProperty;for(var h in e)o.call(e,h)&&r.push(h);return r}},{}],27:[function(a,t){function e(o,h,f){function l(i,u){if(l.count<=0)throw new Error("after called too many times");--l.count,i?(d=!0,h(i),h=f):l.count!==0||d||h(null,u)}var d=!1;return f=f||r,l.count=o,o===0?h():l}function r(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,r,o){var h=e.byteLength;if(r=r||0,o=o||h,e.slice)return e.slice(r,o);if(0>r&&(r+=h),0>o&&(o+=h),o>h&&(o=h),r>=h||r>=o||h===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),l=new Uint8Array(o-r),d=r,i=0;o>d;d++,i++)l[i]=f[d];return l.buffer}},{}],29:[function(a,t,e){(function(r){e.encode=function(o){var h,f=new Uint8Array(o),l=f.length,d="";for(h=0;l>h;h+=3)d+=r[f[h]>>2],d+=r[(3&f[h])<<4|f[h+1]>>4],d+=r[(15&f[h+1])<<2|f[h+2]>>6],d+=r[63&f[h+2]];return l%3===2?d=d.substring(0,d.length-1)+"=":l%3===1&&(d=d.substring(0,d.length-2)+"=="),d},e.decode=function(o){var h,f,l,d,i,u=.75*o.length,c=o.length,s=0;o[o.length-1]==="="&&(u--,o[o.length-2]==="="&&u--);var n=new ArrayBuffer(u),p=new Uint8Array(n);for(h=0;c>h;h+=4)f=r.indexOf(o[h]),l=r.indexOf(o[h+1]),d=r.indexOf(o[h+2]),i=r.indexOf(o[h+3]),p[s++]=f<<2|l>>4,p[s++]=(15&l)<<4|d>>2,p[s++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function r(u){for(var c=0;c<u.length;c++){var s=u[c];if(s.buffer instanceof ArrayBuffer){var n=s.buffer;if(s.byteLength!==n.byteLength){var p=new Uint8Array(s.byteLength);p.set(new Uint8Array(n,s.byteOffset,s.byteLength)),n=p.buffer}u[c]=n}}}function o(u,c){c=c||{};var s=new f;r(u);for(var n=0;n<u.length;n++)s.append(u[n]);return c.type?s.getBlob(c.type):s.getBlob()}function h(u,c){return r(u),new Blob(u,c||{})}var f=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,l=function(){try{var u=new Blob(["hi"]);return u.size===2}catch{return!1}}(),d=l&&function(){try{var u=new Blob([new Uint8Array([1,2])]);return u.size===2}catch{return!1}}(),i=f&&f.prototype.append&&f.prototype.getBlob;t.exports=function(){return l?d?e.Blob:h:i?o:void 0}()}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],31:[function(a,t,e){(function(r){(function(o){function h(g){for(var m,_,B=[],R=0,S=g.length;S>R;)m=g.charCodeAt(R++),m>=55296&&56319>=m&&S>R?(_=g.charCodeAt(R++),(64512&_)==56320?B.push(((1023&m)<<10)+(1023&_)+65536):(B.push(m),R--)):B.push(m);return B}function f(g){for(var m,_=g.length,B=-1,R="";++B<_;)m=g[B],m>65535&&(m-=65536,R+=M(m>>>10&1023|55296),m=56320|1023&m),R+=M(m);return R}function l(g){if(g>=55296&&57343>=g)throw Error("Lone surrogate U+"+g.toString(16).toUpperCase()+" is not a scalar value")}function d(g,m){return M(g>>m&63|128)}function i(g){if(!(4294967168&g))return M(g);var m="";return 4294965248&g?4294901760&g?!(4292870144&g)&&(m=M(g>>18&7|240),m+=d(g,12),m+=d(g,6)):(l(g),m=M(g>>12&15|224),m+=d(g,6)):m=M(g>>6&31|192),m+=M(63&g|128)}function u(g){for(var m,_=h(g),B=_.length,R=-1,S="";++R<B;)m=_[R],S+=i(m);return S}function c(){if(x>=j)throw Error("Invalid byte index");var g=255&w[x];if(x++,(192&g)==128)return 63&g;throw Error("Invalid continuation byte")}function s(){var g,m,_,B,R;if(x>j)throw Error("Invalid byte index");if(x==j)return!1;if(g=255&w[x],x++,(128&g)==0)return g;if((224&g)==192){var m=c();if(R=(31&g)<<6|m,R>=128)return R;throw Error("Invalid continuation byte")}if((240&g)==224){if(m=c(),_=c(),R=(15&g)<<12|m<<6|_,R>=2048)return l(R),R;throw Error("Invalid continuation byte")}if((248&g)==240&&(m=c(),_=c(),B=c(),R=(15&g)<<18|m<<12|_<<6|B,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function n(g){w=h(g),j=w.length,x=0;for(var m,_=[];(m=s())!==!1;)_.push(m);return f(_)}var p=typeof e=="object"&&e,y=typeof t=="object"&&t&&t.exports==p&&t,v=typeof r=="object"&&r;(v.global===v||v.window===v)&&(o=v);var w,j,x,M=String.fromCharCode,I={version:"2.0.0",encode:u,decode:n};if(p&&!p.nodeType)if(y)y.exports=I;else{var k={},b=k.hasOwnProperty;for(var N in I)b.call(I,N)&&(p[N]=I[N])}else o.utf8=I})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(a,t){(function(e){var r=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,h=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,f=/(?:^|:|,)(?:\s*\[)+/g,l=/^\s+/,d=/\s+$/;t.exports=function(i){return typeof i=="string"&&i?(i=i.replace(l,"").replace(d,""),e.JSON&&JSON.parse?JSON.parse(i):r.test(i.replace(o,"@").replace(h,"]").replace(f,""))?new Function("return "+i)():void 0):null}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],33:[function(a,t,e){e.encode=function(r){var o="";for(var h in r)r.hasOwnProperty(h)&&(o.length&&(o+="&"),o+=encodeURIComponent(h)+"="+encodeURIComponent(r[h]));return o},e.decode=function(r){for(var o={},h=r.split("&"),f=0,l=h.length;l>f;f++){var d=h[f].split("=");o[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return o}},{}],34:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(o){var h=o,f=o.indexOf("["),l=o.indexOf("]");f!=-1&&l!=-1&&(o=o.substring(0,f)+o.substring(f,l).replace(/:/g,";")+o.substring(l,o.length));for(var d=e.exec(o||""),i={},u=14;u--;)i[r[u]]=d[u]||"";return f!=-1&&l!=-1&&(i.source=h,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i}},{}],35:[function(a,t){function e(h,f){return f?new o(h,f):new o(h)}var r=function(){return self}(),o=r.WebSocket||r.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function r(h){function f(l){if(!l)return!1;if(e.Buffer&&e.Buffer.isBuffer(l)||e.ArrayBuffer&&l instanceof ArrayBuffer||e.Blob&&l instanceof Blob||e.File&&l instanceof File)return!0;if(o(l)){for(var d=0;d<l.length;d++)if(f(l[d]))return!0}else if(l&&typeof l=="object"){l.toJSON&&(l=l.toJSON());for(var i in l)if(Object.prototype.hasOwnProperty.call(l,i)&&f(l[i]))return!0}return!1}return f(h)}var o=a("isarray");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{isarray:37}],37:[function(a,t){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],38:[function(a,t){var e=a("global");try{t.exports="XMLHttpRequest"in e&&"withCredentials"in new e.XMLHttpRequest}catch{t.exports=!1}},{global:39}],39:[function(a,t){t.exports=function(){return this}()},{}],40:[function(a,t){var e=[].indexOf;t.exports=function(r,o){if(e)return r.indexOf(o);for(var h=0;h<r.length;++h)if(r[h]===o)return h;return-1}},{}],41:[function(a,t,e){var r=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var h=[];for(var f in o)r.call(o,f)&&h.push(f);return h},e.values=function(o){var h=[];for(var f in o)r.call(o,f)&&h.push(o[f]);return h},e.merge=function(o,h){for(var f in h)r.call(h,f)&&(o[f]=h[f]);return o},e.length=function(o){return e.keys(o).length},e.isEmpty=function(o){return e.length(o)==0}},{}],42:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(o){for(var h=e.exec(o||""),f={},l=14;l--;)f[r[l]]=h[l]||"";return f}},{}],43:[function(a,t,e){(function(r){var o=a("isarray"),h=a("./is-buffer");e.deconstructPacket=function(f){function l(c){if(!c)return c;if(h(c)){var s={_placeholder:!0,num:d.length};return d.push(c),s}if(o(c)){for(var n=new Array(c.length),p=0;p<c.length;p++)n[p]=l(c[p]);return n}if(typeof c=="object"&&!(c instanceof Date)){var n={};for(var y in c)n[y]=l(c[y]);return n}return c}var d=[],i=f.data,u=f;return u.data=l(i),u.attachments=d.length,{packet:u,buffers:d}},e.reconstructPacket=function(f,l){function d(i){if(i&&i._placeholder){var u=l[i.num];return u}if(o(i)){for(var c=0;c<i.length;c++)i[c]=d(i[c]);return i}if(i&&typeof i=="object"){for(var s in i)i[s]=d(i[s]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,l){function d(c,s,n){if(!c)return c;if(r.Blob&&c instanceof Blob||r.File&&c instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[s]=this.result:u=this.result,--i||l(u)},p.readAsArrayBuffer(c)}else if(o(c))for(var y=0;y<c.length;y++)d(c[y],y,c);else if(c&&typeof c=="object"&&!h(c))for(var v in c)d(c[v],v,c)}var i=0,u=f;d(u),i||l(u)}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./is-buffer":45,isarray:46}],44:[function(a,t,e){function r(){}function o(y){var v="",w=!1;return v+=y.type,(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)&&(v+=y.attachments,v+="-"),y.nsp&&y.nsp!="/"&&(w=!0,v+=y.nsp),y.id!=null&&(w&&(v+=",",w=!1),v+=y.id),y.data!=null&&(w&&(v+=","),v+=c.stringify(y.data)),u("encoded %j as %s",y,v),v}function h(y,v){function w(j){var x=n.deconstructPacket(j),M=o(x.packet),I=x.buffers;I.unshift(M),v(I)}n.removeBlobs(y,w)}function f(){this.reconstructor=null}function l(y){var v={},w=0;if(v.type=Number(y.charAt(0)),e.types[v.type]==null)return i();if(e.BINARY_EVENT==v.type||e.BINARY_ACK==v.type){for(var j="";y.charAt(++w)!="-"&&(j+=y.charAt(w),w!=y.length););if(j!=Number(j)||y.charAt(w)!="-")throw new Error("Illegal attachments");v.attachments=Number(j)}if(y.charAt(w+1)=="/")for(v.nsp="";++w;){var x=y.charAt(w);if(x==","||(v.nsp+=x,w==y.length))break}else v.nsp="/";var M=y.charAt(w+1);if(M!==""&&Number(M)==M){for(v.id="";++w;){var x=y.charAt(w);if(x==null||Number(x)!=x){--w;break}if(v.id+=y.charAt(w),w==y.length)break}v.id=Number(v.id)}if(y.charAt(++w))try{v.data=c.parse(y.substr(w))}catch{return i()}return u("decoded %s as %j",y,v),v}function d(y){this.reconPack=y,this.buffers=[]}function i(){return{type:e.ERROR,data:"parser error"}}var u=a("debug")("socket.io-parser"),c=a("json3"),s=(a("isarray"),a("component-emitter")),n=a("./binary"),p=a("./is-buffer");e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","BINARY_EVENT","ACK","BINARY_ACK","ERROR"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=f,r.prototype.encode=function(y,v){if(u("encoding packet %j",y),e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)h(y,v);else{var w=o(y);v([w])}},s(f.prototype),f.prototype.add=function(y){var v;if(typeof y=="string")v=l(y),e.BINARY_EVENT==v.type||e.BINARY_ACK==v.type?(this.reconstructor=new d(v),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",v)):this.emit("decoded",v);else{if(!p(y)&&!y.base64)throw new Error("Unknown type: "+y);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");v=this.reconstructor.takeBinaryData(y),v&&(this.reconstructor=null,this.emit("decoded",v))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},d.prototype.takeBinaryData=function(y){if(this.buffers.push(y),this.buffers.length==this.reconPack.attachments){var v=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),v}return null},d.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":43,"./is-buffer":45,"component-emitter":9,debug:10,isarray:46,json3:47}],45:[function(a,t){(function(e){function r(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(r){function o(E){if(o[E]!==l)return o[E];var O;if(E=="bug-string-char-index")O=!1;else if(E=="json")O=o("json-stringify")&&o("json-parse");else{var T,P='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var C=u.stringify,U=typeof C=="function"&&c;if(U){(T=function(){return 1}).toJSON=T;try{U=C(0)==="0"&&C(new Number)==="0"&&C(new String)=='""'&&C(d)===l&&C(l)===l&&C()===l&&C(T)==="1"&&C([T])=="[1]"&&C([l])=="[null]"&&C(null)=="null"&&C([l,d,null])=="[null,null,null]"&&C({a:[T,!0,!1,null,`\0\b
|
|
8
|
+
\f\r `]})==P&&C(null,T)==="1"&&C([1,2],null,1)==`[
|
|
9
9
|
1,
|
|
10
10
|
2
|
|
11
|
-
]`&&
|
|
12
|
-
`+
|
|
13
|
-
`+
|
|
14
|
-
`+Se+"]":"["+ee.join(",")+"]":"[]"}else f(P||
|
|
15
|
-
`+
|
|
16
|
-
`+
|
|
17
|
-
`+Se+"}":"{"+ee.join(",")+"}":"{}";return D.pop(),
|
|
18
|
-
`,102:"\f",114:"\r"},q=function(){throw S=X=null,SyntaxError()},W=function(){for(var E,_,T,P,k,x=X,D=x.length;D>S;)switch(k=x.charCodeAt(S)){case 9:case 10:case 13:case 32:S++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=j?x.charAt(S):x[S],S++,E;case 34:for(E="@",S++;D>S;)if(k=x.charCodeAt(S),32>k)q();else if(k==92)switch(k=x.charCodeAt(++S)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=J[k],S++;break;case 117:for(_=++S,T=S+4;T>S;S++)k=x.charCodeAt(S),k>=48&&57>=k||k>=97&&102>=k||k>=65&&70>=k||q();E+=$("0x"+x.slice(_,S));break;default:q()}else{if(k==34)break;for(k=x.charCodeAt(S),_=S;k>=32&&k!=92&&k!=34;)k=x.charCodeAt(++S);E+=x.slice(_,S)}if(x.charCodeAt(S)==34)return S++,E;q();default:if(_=S,k==45&&(P=!0,k=x.charCodeAt(++S)),k>=48&&57>=k){for(k==48&&(k=x.charCodeAt(S+1),k>=48&&57>=k)&&q(),P=!1;D>S&&(k=x.charCodeAt(S),k>=48&&57>=k);S++);if(x.charCodeAt(S)==46){for(T=++S;D>T&&(k=x.charCodeAt(T),k>=48&&57>=k);T++);T==S&&q(),S=T}if(k=x.charCodeAt(S),k==101||k==69){for(k=x.charCodeAt(++S),(k==43||k==45)&&S++,T=S;D>T&&(k=x.charCodeAt(T),k>=48&&57>=k);T++);T==S&&q(),S=T}return+x.slice(_,S)}if(P&&q(),x.slice(S,S+4)=="true")return S+=4,!0;if(x.slice(S,S+5)=="false")return S+=5,!1;if(x.slice(S,S+4)=="null")return S+=4,null;q()}return"$"},oe=function(E){var _,T;if(E=="$"&&q(),typeof E=="string"){if((j?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(_=[];E=W(),E!="]";T||(T=!0))T&&(E==","?(E=W(),E=="]"&&q()):q()),E==","&&q(),_.push(oe(E));return _}if(E=="{"){for(_={};E=W(),E!="}";T||(T=!0))T&&(E==","?(E=W(),E=="}"&&q()):q()),(E==","||typeof E!="string"||(j?E.charAt(0):E[0])!="@"||W()!=":")&&q(),_[E.slice(1)]=oe(W());return _}q()}return E},Be=function(E,_,T){var P=De(E,_,T);P===l?delete E[_]:E[_]=P},De=function(E,_,T){var P,k=E[_];if(typeof k=="object"&&k)if(d.call(k)==v)for(P=k.length;P--;)Be(k,P,T);else f(k,function(x){Be(k,x,T)});return T.call(E,_,k)};u.parse=function(E,_){var T,P;return S=0,X=""+E,T=oe(W()),W()!="$"&&q(),S=X=null,_&&d.call(_)==s?De((P={},P[""]=T,P),"",_):T}}}})(this)},{}],48:[function(a,t){function e(r,o){var h=[];o=o||0;for(var f=o||0;f<r.length;f++)h[f-o]=r[f];return h}t.exports=e},{}]},{},[1])(1)}const Ge=Object.assign({"./v1_3_7.js":Object.freeze(Object.defineProperty({__proto__:null,default:$e},Symbol.toStringTag,{value:"Module"}))}),ze=/v\d+_\d+_\d+/;function Je(a){return typeof a=="function"}const ue=Object.entries(Ge).reduce((a,t)=>{var o;const e=t[1].default,r=(o=t[0].match(ze))==null?void 0:o[0];return Je(e)&&r&&(a[r]=e()),a},{}),Ne=a=>{if(a in ue)return ue[a];throw new Error(`Socket version ${a} not found`)},We={...ue,getSocketVersion:Ne,makeSocketVersion:(a,...t)=>Ne(a)(...t)};var Le=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Le||{}),_e=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(_e||{}),se=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(se||{}),Oe=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(Oe||{}),Ie=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(Ie||{}),Re=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(Re||{}),U=(a=>(a.ALL_DIALER_STATUS="AllDialersStatus",a.ALL_EXTENSION_STATUS="AllExtensionsStatus",a.ALL_USERS_STATUS="AllUsersStatus",a.CONNECT="connect",a.DISCONNECT="disconnect",a.CONNECT_ERROR_EVENT="connect_error",a.EXTENSION_EVENT="ExtensionEvent",a.KEEP_ALIVE="keepalive",a.KEEP_ALIVE_RESPONSE="keepaliveResponse",a.LOGIN_STATUS="loginStatus",a.LOGIN_SUCCESS="loginSuccess",a.QUEUE_EVENT="QueueEvent",a.ONLINE_STATUS_EVENT="onlineStatusEvent",a.DIALER_EVENT="DialerEvent",a.EXTENSIONS_UPDATED="ExtensionsUpdated",a.ALL_VOICEBOTS_STATUS="AllVoicebotsStatus",a.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED="subscribeToCallFailed",a.VOICEBOT_SUBSCRIBED_TO_CALL="subscribedToCall",a.VOICEBOT_INITIAL_CALL_HISTORY="initialCallHistory",a.VOICEBOT_UNSUBSCRIBED_FROM_CALL="unsubscribedFromCall",a.VOICEBOT_EVENT="VoicebotEvent",a))(U||{}),pe=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(pe||{}),Ue=(a=>(a.NORMAL_HANGUP="Normal hangup",a.USER_BUSY="User busy",a.CALL_REJECTED="Call Rejected",a.UNALLOCATED_NUMBER="Unallocated (unassigned) number",a.UNKNOWN="Unknown",a.NO_USER_RESPONDING="No user responding",a.USER_ALERTING="User alerting, no answer",a.ANSWERED_ELSEWHERE="Answered elsewhere",a))(Ue||{}),xe=(a=>(a.ANSWER="ANSWER",a.ABANDONED="ABANDONED",a.EXIT="EXIT",a.JOIN="JOIN",a))(xe||{});class ce{static mapExtensionEvent(t){var f,l;const e=t.reason;let r,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const h=this.mapExtensionData(t,t.data);return e===pe.HANGUP?r={...t,reason:e,data:{...h,currentCall:o?{...o,duration:o.callAnswered_UTC_CLIENT?Date.now()-o.callAnswered_UTC_CLIENT:0}:void 0,calls:(f=t.data.calls)==null?void 0:f.map(d=>{const i=this.mapExtensionCall(t,d);return{...i,duration:i.callAnswered_UTC_CLIENT?Date.now()-i.callAnswered_UTC_CLIENT:0}})}}:r={...t,data:{...h,currentCall:o,calls:(l=t.data.calls)==null?void 0:l.map(d=>this.mapExtensionCall(t,d))},reason:e},r}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var r;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(r=e.calls)==null?void 0:r.map(o=>this.mapExtensionCall(t,o))}})}}static mapExtensionData(t,e){return this.configureUTCForObject(e,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],t.servertime,t.servertimeoffset)}static mapExtensionCall(t,e){return this.configureUTCForObject(e,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],t.servertime,t.servertimeoffset)}static mapQueueCall(t,e){return this.configureUTCForObject(e,[{key:"JoinTimeStamp",format:"sec"},{key:"VHJoinTimeStamp",format:"sec"}],t.servertime,t.servertimeoffset)}static mapLoginStatusEvent(t){return{...t,queues:t.queues.map(e=>({...e,Calls:e.Calls.map(r=>this.mapQueueCall(t,r))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,r){t[e]=r}static configureUTCForObject(t,e,r,o){const h=(r-o*60)*1e3,f=Date.now()-h,l={};return e.forEach(d=>{const i=t[d.key],u=d.key;if(i!==0&&typeof i=="number"&&!isNaN(i)){let c=i;d.format==="ms"&&(c=Math.floor(c/1e3));const s=(c-o*60)*1e3;this.assignProperty(l,`${u}_UTC`,s),this.assignProperty(l,`${u}_UTC_CLIENT`,s+f)}else this.assignProperty(l,`${u}_UTC`,0),this.assignProperty(l,`${u}_UTC_CLIENT`,0)}),{...t,...l}}}var fe=(a=>(a.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",a.KEEP_ALIVE="keepalive",a.SUBSCRIBE_VOICEBOT_CALL_UPDATES="subscribeVoicebotCallUpdates",a.UNSUBSCRIBE_VOICEBOT_CALL_UPDATES="unsubscribeVoicebotCallUpdates",a))(fe||{});class He{constructor(t){K(this,"io");K(this,"ioFunction");K(this,"lastEventTimestamp",new Date().getTime());K(this,"doReconnect",!0);K(this,"connectionState","disconnected");K(this,"keepAliveInterval");K(this,"reconnectTimeout");K(this,"networkReconnectTimeout");K(this,"reconnectionTime",Ae.reconnectionDelay);K(this,"maxReconnectionDelay",120);K(this,"networkCleanup",[]);this.eventsSdkClass=t,this.reconnectionTime=t.options.reconnectionDelay,this.setupNetworkListeners()}setupNetworkListeners(){const t=()=>this.closeAllConnections(),e=()=>this.handleNetworkOnline();typeof window<"u"&&"addEventListener"in window&&typeof window.addEventListener=="function"?(window.addEventListener("offline",t),window.addEventListener("online",e),this.networkCleanup.push(()=>window.removeEventListener("offline",t),()=>window.removeEventListener("online",e))):typeof self<"u"&&"addEventListener"in self&&typeof self.addEventListener=="function"&&(self.addEventListener("offline",t),self.addEventListener("online",e),this.networkCleanup.push(()=>self.removeEventListener("offline",t),()=>self.removeEventListener("online",e)))}handleNetworkOnline(){this.networkReconnectTimeout&&clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=setTimeout(()=>{this.connectionState==="disconnected"&&this.doReconnect&&this.eventsSdkClass.connect(ne.NEXT)},500)}getSocketIoFunction(t){const e=t.split("v="),r="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=We.getSocketVersion(r)}initSocketConnection(){if(this.connectionState!=="disconnected")return;this.connectionState="connecting";const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,r=this.eventsSdkClass.server;try{const o=r?r.Domain:this.eventsSdkClass.URL,h=r?`${e}://${o}`:this.eventsSdkClass.URL,f={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:t},timeout:this.eventsSdkClass.options.timeout};if(this.ioFunction&&h)this.io=this.ioFunction(h,f),this.initSocketEvents(),this.eventsSdkClass.eventEmitterClass.emit(U.ONLINE_STATUS_EVENT,{attemptToConnect:h,connectionStatus:se.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url not defined")}catch(o){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&(clearInterval(this.keepAliveInterval),this.keepAliveInterval=void 0)}initKeepAlive(){this.clearKeepAliveInterval(),this.keepAliveInterval=setInterval(async()=>{new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.connectionState==="connected"&&this.eventsSdkClass.authClass.token&&(this.eventsSdkClass.emit(fe.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit())},this.eventsSdkClass.options.keepAliveTimeout)}async closeAllConnections(){if(this.clearKeepAliveInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.networkReconnectTimeout&&(clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=void 0),this.io){const t=this.io;this.io=void 0;try{await Promise.race([new Promise(e=>{t.on("disconnect",()=>e()),t.removeAllListeners(),t.close(),t.disconnect()}),new Promise(e=>setTimeout(e,1e3))])}catch{}}this.connectionState="disconnected",this.eventsSdkClass.loggerClass.stop(),re.clearSessionStorage()}initSocketEvents(){this.io&&(this.io.removeAllListeners(),this.io.on(U.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,U.LOGIN_SUCCESS)).on(U.QUEUE_EVENT,t=>this.onQueueEvent(t,U.QUEUE_EVENT)).on(U.EXTENSION_EVENT,t=>this.onExtensionEvent(t,U.EXTENSION_EVENT)).on(U.DIALER_EVENT,t=>this.onDialerEvent(t,U.DIALER_EVENT)).on(U.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,U.LOGIN_STATUS)).on(U.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,U.ALL_EXTENSION_STATUS)).on(U.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,U.ALL_DIALER_STATUS)).on(U.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(U.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,U.EXTENSIONS_UPDATED)).on(U.CONNECT,()=>this.onConnect()).on(U.DISCONNECT,t=>this.onDisconnect(t)).on(U.CONNECT_ERROR_EVENT,t=>this.onConnectError(t)))}updateEventTimestamp(){this.lastEventTimestamp=new Date().getTime()}onLoginSuccessEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapQueueEvent(t))}onExtensionEvent(t,e){this.updateEventTimestamp();const r=ce.mapExtensionEvent(t);r&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r))}onDialerEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){this.updateEventTimestamp();const r=ce.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onAllDialerStatus(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.closeAllConnections().then(()=>{this.doReconnect&&this.connectionState==="disconnected"&&this.scheduleReconnect()});return}}onExtensionsUpdatedEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connectionState="connected",this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.eventsSdkClass.eventEmitterClass.emit(U.ONLINE_STATUS_EVENT,{connectionStatus:se.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}scheduleReconnect(){!this.doReconnect||this.reconnectTimeout||(this.eventsSdkClass.eventEmitterClass.emit(U.ONLINE_STATUS_EVENT,{connectionStatus:se.TRYING_TO_CONNECT}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=void 0,this.reconnectionTime=Math.min(this.reconnectionTime*2,this.maxReconnectionDelay),this.reconnectionTime>this.maxReconnectionDelay&&(this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay),this.eventsSdkClass.connect(ne.NEXT)},this.reconnectionTime*1e3))}onDisconnect(t){if(this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkDisconnect([t]),!this.doReconnect){this.eventsSdkClass.eventEmitterClass.emit(U.ONLINE_STATUS_EVENT,{connectionStatus:se.DISCONNECTED});return}this.closeAllConnections(),this.scheduleReconnect()}onConnectError(t){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.doReconnect?this.scheduleReconnect():this.eventsSdkClass.eventEmitterClass.emit(U.ONLINE_STATUS_EVENT,{connectionStatus:se.DISCONNECTED})}async destroy(){this.doReconnect=!1,this.networkCleanup.forEach(t=>t()),await this.closeAllConnections()}}class Ye{constructor(t){K(this,"storageLogger");this.eventsSdkClass=t,this.eventsSdkClass=t}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let t;this.eventsSdkClass.options.loggerSocketConnection&&(t=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!t&&(t=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),t&&(this.storageLogger=new F({socket:t,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}async start(){this.storageLogger&&await this.storageLogger.start()}async stop(){this.storageLogger&&await this.storageLogger.stop()}log(t){if(this.eventsSdkClass.options.useLogger)if(this.storageLogger)switch(t.Level){case F.LevelEnum.INFO:this.storageLogger.log(t);break;case F.LevelEnum.DEBUG:this.storageLogger.debug(t);break;case F.LevelEnum.WARNING:this.storageLogger.warn(t);break;case F.LevelEnum.ERROR:this.storageLogger.error(t)}else t.Level===F.LevelEnum.INFO?console.log(t):t.Level===F.LevelEnum.ERROR&&console.error(t)}sdkConnectionSuccess(){const t={...this.eventsSdkClass.options,token:"CENSORED",password:"CENSORED"};this.log({Message:`Sdk connected to the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL}`,Body:JSON.stringify(t,this.eventsSdkClass.getCircularReplacer()),ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkDisconnect(t){this.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${t})`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkAttemptToConnect(t){this.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${t}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkAttemptToConnectError(t){this.log({Message:`${t}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}loginError(t,e,r,o){this.log({Message:`External login request error with the login type ${t} ${t===Q.TOKEN?r:o}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:e||400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}getSettingsError(t,e){this.log({Message:`Get settings error with token ${t}, error: ${e}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}refreshTokenError(t,e,r){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${r}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}keepAliveEmit(){this.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}keepAliveResponse(t){this.log({Message:`Keep alive response: ${JSON.stringify(t)}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}eventLog(t,e){const r={[te.FULL]:[],[te.BOOTSTRAP]:[U.LOGIN_STATUS,U.LOGIN_SUCCESS,U.ALL_EXTENSION_STATUS,U.ALL_DIALER_STATUS],[te.DEBUG_EXTENSIONS]:[U.ALL_EXTENSION_STATUS,U.EXTENSION_EVENT,U.EXTENSIONS_UPDATED],[te.DEBUG_DIALER]:[U.ALL_DIALER_STATUS,U.DIALER_EVENT],[te.DEBUG_QUEUE]:[U.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(r[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===te.FULL)&&this.log({Message:`Event name: ${t}`,Body:{...this.getStaticData(),...e},ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:F.LevelEnum.DEBUG,LogType:F.LogTypeEnum.INFO})}getStaticData(){return{SocketId:this.eventsSdkClass.socketIoClass&&this.eventsSdkClass.socketIoClass.io?this.eventsSdkClass.socketIoClass.io.id:""}}}class Qe{constructor(t){K(this,"listeners",{[U.ALL_EXTENSION_STATUS]:[],[U.ALL_DIALER_STATUS]:[],[U.ALL_USERS_STATUS]:[],[U.ALL_VOICEBOTS_STATUS]:[],[U.QUEUE_EVENT]:[],[U.EXTENSION_EVENT]:[],[U.DIALER_EVENT]:[],[U.LOGIN_SUCCESS]:[],[U.LOGIN_STATUS]:[],[U.KEEP_ALIVE_RESPONSE]:[],[U.ONLINE_STATUS_EVENT]:[],[U.EXTENSIONS_UPDATED]:[],[U.VOICEBOT_SUBSCRIBED_TO_CALL]:[],[U.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED]:[],[U.VOICEBOT_INITIAL_CALL_HISTORY]:[],[U.VOICEBOT_UNSUBSCRIBED_FROM_CALL]:[],[U.VOICEBOT_EVENT]:[]});K(this,"allListeners",[]);this.eventsSdkClass=t,this.eventsSdkClass=t}on(t,e){t==="*"?this.allListeners.push(e):this.listeners[t].push(e)}off(t,e){if(t==="*")this.allListeners=this.allListeners.filter(r=>r!==e);else{const o=this.listeners[t].filter(h=>h!==e);this.listeners={...this.listeners,[t]:o}}}emit(t,e){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[t].forEach(o=>o({name:t,data:e}));const r={name:t,data:e};this.allListeners.forEach(o=>o(r))}}class Ze{constructor(t){K(this,"options");K(this,"servers",[]);K(this,"URLList",[]);K(this,"server");K(this,"URL");K(this,"socket");K(this,"mainServer");K(this,"alreadyAttemptedOtherServers",[]);K(this,"authClass",new Xe(this));K(this,"socketIoClass");K(this,"loggerClass",new Ye(this));K(this,"eventEmitterClass",new Qe(this));K(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,r)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof r=="object"&&r!==null){if(t.has(r))return;t.add(r)}return r}}});this.options={...Ae,...t},this.socketIoClass=new He(this)}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===ne.MAIN&&this.findMainServer(),t===ne.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initKeepAlive()}async disconnect(){this.socketIoClass.doReconnect=!1,await this.socketIoClass.closeAllConnections(),await this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((t,e)=>e.Priority>t.Priority?e:t),this.server=this.mainServer):this.URLList.length&&(this.URL=this.URLList[0])}findNextServer(){if(this.servers.length&&this.server)if(this.server.Priority===this.mainServer.Priority){let t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0)),t.length&&(this.server=t.reduce((e,r)=>r.Priority>e.Priority?r:e),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0)),t.length&&(this.URL=t[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const t=await this.authClass.login();return t&&this.authClass.onLoginResponse(t),!0}getCurrentMonitorServer(){return this.server}}return z.CallStatusEnum=Le,z.CallTypeEnum=_e,z.ConnectionStatusEnum=se,z.DebugOption=te,z.DialerTypeEnum=Oe,z.DirectionEnum=Ie,z.DoNotCallMeStatusCodeEnum=Re,z.EventsEnum=U,z.ExtensionEventReasonEnum=pe,z.ExtensionHangupCauseEnum=Ue,z.LoginType=Q,z.QueueEventReasonEnum=xe,z.ServerListenerEventsEnum=fe,z.ServerParameter=ne,z.default=Ze,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),z}({},ws,StorageLogger);
|
|
11
|
+
]`&&C(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&C(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&C(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&C(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{U=!1}}O=U}if(E=="json-parse"){var D=u.parse;if(typeof D=="function")try{if(D("0")===0&&!D(!1)){T=D(P);var L=T.a.length==5&&T.a[0]===1;if(L){try{L=!D('" "')}catch{}if(L)try{L=D("01")!==1}catch{}if(L)try{L=D("1.")!==1}catch{}}}}catch{L=!1}O=L}}return o[E]=!!O}var h,f,l,d={}.toString,i=typeof JSON=="object"&&JSON,u=typeof e=="object"&&e&&!e.nodeType&&e;u&&i?(u.stringify=i.stringify,u.parse=i.parse):u=r.JSON=i||{};var c=new Date(-0xc782b5b800cec);try{c=c.getUTCFullYear()==-109252&&c.getUTCMonth()===0&&c.getUTCDate()===1&&c.getUTCHours()==10&&c.getUTCMinutes()==37&&c.getUTCSeconds()==6&&c.getUTCMilliseconds()==708}catch{}if(!o("json")){var s="[object Function]",n="[object Date]",p="[object Number]",y="[object String]",v="[object Array]",w="[object Boolean]",j=o("bug-string-char-index");if(!c)var x=Math.floor,M=[0,31,59,90,120,151,181,212,243,273,304,334],I=function(E,O){return M[O]+365*(E-1970)+x((E-1969+(O=+(O>1)))/4)-x((E-1901+O)/100)+x((E-1601+O)/400)};(h={}.hasOwnProperty)||(h=function(E){var O,T={};return(T.__proto__=null,T.__proto__={toString:1},T).toString!=d?h=function(P){var C=this.__proto__,U=P in(this.__proto__=null,this);return this.__proto__=C,U}:(O=T.constructor,h=function(P){var C=(this.constructor||O).prototype;return P in this&&!(P in C&&this[P]===C[P])}),T=null,h.call(this,E)});var k={boolean:1,number:1,string:1,undefined:1},b=function(E,O){var T=typeof E[O];return T=="object"?!!E[O]:!k[T]};if(f=function(E,O){var T,P,C,U=0;(T=function(){this.valueOf=0}).prototype.valueOf=0,P=new T;for(C in P)h.call(P,C)&&U++;return T=P=null,U?f=U==2?function(D,L){var V,G={},H=d.call(D)==s;for(V in D)H&&V=="prototype"||h.call(G,V)||!(G[V]=1)||!h.call(D,V)||L(V)}:function(D,L){var V,G,H=d.call(D)==s;for(V in D)H&&V=="prototype"||!h.call(D,V)||(G=V==="constructor")||L(V);(G||h.call(D,V="constructor"))&&L(V)}:(P=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],f=function(D,L){var V,G,H=d.call(D)==s,Y=!H&&typeof D.constructor!="function"&&b(D,"hasOwnProperty")?D.hasOwnProperty:h;for(V in D)H&&V=="prototype"||!Y.call(D,V)||L(V);for(G=P.length;V=P[--G];Y.call(D,V)&&L(V));}),f(E,O)},!o("json-stringify")){var N={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},g="000000",m=function(E,O){return(g+(O||0)).slice(-E)},_="\\u00",B=function(E){var O,T='"',P=0,C=E.length,U=C>10&&j;for(U&&(O=E.split(""));C>P;P++){var D=E.charCodeAt(P);switch(D){case 8:case 9:case 10:case 12:case 13:case 34:case 92:T+=N[D];break;default:if(32>D){T+=_+m(2,D.toString(16));break}T+=U?O[P]:j?E.charAt(P):E[P]}}return T+'"'},R=function(E,O,T,P,C,U,D){var L,V,G,H,Y,ie,de,ye,ve,ge,ee,me,le,ae,Se,Ce;try{L=O[E]}catch{}if(typeof L=="object"&&L)if(V=d.call(L),V!=n||h.call(L,"toJSON"))typeof L.toJSON=="function"&&(V!=p&&V!=y&&V!=v||h.call(L,"toJSON"))&&(L=L.toJSON(E));else if(L>-1/0&&1/0>L){if(I){for(Y=x(L/864e5),G=x(Y/365.2425)+1970-1;I(G+1,0)<=Y;G++);for(H=x((Y-I(G,0))/30.42);I(G,H+1)<=Y;H++);Y=1+Y-I(G,H),ie=(L%864e5+864e5)%864e5,de=x(ie/36e5)%24,ye=x(ie/6e4)%60,ve=x(ie/1e3)%60,ge=ie%1e3}else G=L.getUTCFullYear(),H=L.getUTCMonth(),Y=L.getUTCDate(),de=L.getUTCHours(),ye=L.getUTCMinutes(),ve=L.getUTCSeconds(),ge=L.getUTCMilliseconds();L=(0>=G||G>=1e4?(0>G?"-":"+")+m(6,0>G?-G:G):m(4,G))+"-"+m(2,H+1)+"-"+m(2,Y)+"T"+m(2,de)+":"+m(2,ye)+":"+m(2,ve)+"."+m(3,ge)+"Z"}else L=null;if(T&&(L=T.call(O,E,L)),L===null)return"null";if(V=d.call(L),V==w)return""+L;if(V==p)return L>-1/0&&1/0>L?""+L:"null";if(V==y)return B(""+L);if(typeof L=="object"){for(ae=D.length;ae--;)if(D[ae]===L)throw TypeError();if(D.push(L),ee=[],Se=U,U+=C,V==v){for(le=0,ae=L.length;ae>le;le++)me=R(le,L,T,P,C,U,D),ee.push(me===l?"null":me);Ce=ee.length?C?`[
|
|
12
|
+
`+U+ee.join(`,
|
|
13
|
+
`+U)+`
|
|
14
|
+
`+Se+"]":"["+ee.join(",")+"]":"[]"}else f(P||L,function(ke){var Pe=R(ke,L,T,P,C,U,D);Pe!==l&&ee.push(B(ke)+":"+(C?" ":"")+Pe)}),Ce=ee.length?C?`{
|
|
15
|
+
`+U+ee.join(`,
|
|
16
|
+
`+U)+`
|
|
17
|
+
`+Se+"}":"{"+ee.join(",")+"}":"{}";return D.pop(),Ce}};u.stringify=function(E,O,T){var P,C,U,D;if(typeof O=="function"||typeof O=="object"&&O){if((D=d.call(O))==s)C=O;else if(D==v){U={};for(var L,V=0,G=O.length;G>V;L=O[V++],D=d.call(L),(D==y||D==p)&&(U[L]=1));}}if(T)if((D=d.call(T))==p){if((T-=T%1)>0)for(P="",T>10&&(T=10);P.length<T;P+=" ");}else D==y&&(P=T.length<=10?T:T.slice(0,10));return R("",(L={},L[""]=E,L),C,U,P,"",[])}}if(!o("json-parse")){var S,X,$=String.fromCharCode,J={92:"\\",34:'"',47:"/",98:"\b",116:" ",110:`
|
|
18
|
+
`,102:"\f",114:"\r"},q=function(){throw S=X=null,SyntaxError()},W=function(){for(var E,O,T,P,C,U=X,D=U.length;D>S;)switch(C=U.charCodeAt(S)){case 9:case 10:case 13:case 32:S++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=j?U.charAt(S):U[S],S++,E;case 34:for(E="@",S++;D>S;)if(C=U.charCodeAt(S),32>C)q();else if(C==92)switch(C=U.charCodeAt(++S)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=J[C],S++;break;case 117:for(O=++S,T=S+4;T>S;S++)C=U.charCodeAt(S),C>=48&&57>=C||C>=97&&102>=C||C>=65&&70>=C||q();E+=$("0x"+U.slice(O,S));break;default:q()}else{if(C==34)break;for(C=U.charCodeAt(S),O=S;C>=32&&C!=92&&C!=34;)C=U.charCodeAt(++S);E+=U.slice(O,S)}if(U.charCodeAt(S)==34)return S++,E;q();default:if(O=S,C==45&&(P=!0,C=U.charCodeAt(++S)),C>=48&&57>=C){for(C==48&&(C=U.charCodeAt(S+1),C>=48&&57>=C)&&q(),P=!1;D>S&&(C=U.charCodeAt(S),C>=48&&57>=C);S++);if(U.charCodeAt(S)==46){for(T=++S;D>T&&(C=U.charCodeAt(T),C>=48&&57>=C);T++);T==S&&q(),S=T}if(C=U.charCodeAt(S),C==101||C==69){for(C=U.charCodeAt(++S),(C==43||C==45)&&S++,T=S;D>T&&(C=U.charCodeAt(T),C>=48&&57>=C);T++);T==S&&q(),S=T}return+U.slice(O,S)}if(P&&q(),U.slice(S,S+4)=="true")return S+=4,!0;if(U.slice(S,S+5)=="false")return S+=5,!1;if(U.slice(S,S+4)=="null")return S+=4,null;q()}return"$"},oe=function(E){var O,T;if(E=="$"&&q(),typeof E=="string"){if((j?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(O=[];E=W(),E!="]";T||(T=!0))T&&(E==","?(E=W(),E=="]"&&q()):q()),E==","&&q(),O.push(oe(E));return O}if(E=="{"){for(O={};E=W(),E!="}";T||(T=!0))T&&(E==","?(E=W(),E=="}"&&q()):q()),(E==","||typeof E!="string"||(j?E.charAt(0):E[0])!="@"||W()!=":")&&q(),O[E.slice(1)]=oe(W());return O}q()}return E},xe=function(E,O,T){var P=De(E,O,T);P===l?delete E[O]:E[O]=P},De=function(E,O,T){var P,C=E[O];if(typeof C=="object"&&C)if(d.call(C)==v)for(P=C.length;P--;)xe(C,P,T);else f(C,function(U){xe(C,U,T)});return T.call(E,O,C)};u.parse=function(E,O){var T,P;return S=0,X=""+E,T=oe(W()),W()!="$"&&q(),S=X=null,O&&d.call(O)==s?De((P={},P[""]=T,P),"",O):T}}}})(this)},{}],48:[function(a,t){function e(r,o){var h=[];o=o||0;for(var f=o||0;f<r.length;f++)h[f-o]=r[f];return h}t.exports=e},{}]},{},[1])(1)}const Ge=Object.assign({"./v1_3_7.js":Object.freeze(Object.defineProperty({__proto__:null,default:$e},Symbol.toStringTag,{value:"Module"}))}),ze=/v\d+_\d+_\d+/;function Je(a){return typeof a=="function"}const ue=Object.entries(Ge).reduce((a,t)=>{var o;const e=t[1].default,r=(o=t[0].match(ze))==null?void 0:o[0];return Je(e)&&r&&(a[r]=e()),a},{}),Ne=a=>{if(a in ue)return ue[a];throw new Error(`Socket version ${a} not found`)},We={...ue,getSocketVersion:Ne,makeSocketVersion:(a,...t)=>Ne(a)(...t)};var Le=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Le||{}),_e=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(_e||{}),se=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(se||{}),Oe=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(Oe||{}),Ie=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(Ie||{}),Re=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(Re||{}),A=(a=>(a.ALL_DIALER_STATUS="AllDialersStatus",a.ALL_EXTENSION_STATUS="AllExtensionsStatus",a.ALL_USERS_STATUS="AllUsersStatus",a.CONNECT="connect",a.DISCONNECT="disconnect",a.CONNECT_ERROR_EVENT="connect_error",a.EXTENSION_EVENT="ExtensionEvent",a.KEEP_ALIVE="keepalive",a.KEEP_ALIVE_RESPONSE="keepaliveResponse",a.LOGIN_STATUS="loginStatus",a.LOGIN_SUCCESS="loginSuccess",a.QUEUE_EVENT="QueueEvent",a.ONLINE_STATUS_EVENT="onlineStatusEvent",a.DIALER_EVENT="DialerEvent",a.EXTENSIONS_UPDATED="ExtensionsUpdated",a.ALL_VOICEBOTS_STATUS="AllVoicebotsStatus",a.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED="subscribeToCallFailed",a.VOICEBOT_SUBSCRIBED_TO_CALL="subscribedToCall",a.VOICEBOT_INITIAL_CALL_HISTORY="initialCallHistory",a.VOICEBOT_UNSUBSCRIBED_FROM_CALL="unsubscribedFromCall",a.VOICEBOT_EVENT="VoicebotEvent",a))(A||{}),pe=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(pe||{}),Be=(a=>(a.NORMAL_HANGUP="Normal hangup",a.USER_BUSY="User busy",a.CALL_REJECTED="Call Rejected",a.UNALLOCATED_NUMBER="Unallocated (unassigned) number",a.UNKNOWN="Unknown",a.NO_USER_RESPONDING="No user responding",a.USER_ALERTING="User alerting, no answer",a.ANSWERED_ELSEWHERE="Answered elsewhere",a))(Be||{}),Ue=(a=>(a.ANSWER="ANSWER",a.ABANDONED="ABANDONED",a.EXIT="EXIT",a.JOIN="JOIN",a))(Ue||{});class ce{static mapExtensionEvent(t){var f,l;const e=t.reason;let r,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const h=this.mapExtensionData(t,t.data);return e===pe.HANGUP?r={...t,reason:e,data:{...h,currentCall:o?{...o,duration:o.callAnswered_UTC_CLIENT?Date.now()-o.callAnswered_UTC_CLIENT:0}:void 0,calls:(f=t.data.calls)==null?void 0:f.map(d=>{const i=this.mapExtensionCall(t,d);return{...i,duration:i.callAnswered_UTC_CLIENT?Date.now()-i.callAnswered_UTC_CLIENT:0}})}}:r={...t,data:{...h,currentCall:o,calls:(l=t.data.calls)==null?void 0:l.map(d=>this.mapExtensionCall(t,d))},reason:e},r}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var r;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(r=e.calls)==null?void 0:r.map(o=>this.mapExtensionCall(t,o))}})}}static mapExtensionData(t,e){return this.configureUTCForObject(e,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],t.servertime,t.servertimeoffset)}static mapExtensionCall(t,e){return this.configureUTCForObject(e,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],t.servertime,t.servertimeoffset)}static mapQueueCall(t,e){return this.configureUTCForObject(e,[{key:"JoinTimeStamp",format:"sec"},{key:"VHJoinTimeStamp",format:"sec"}],t.servertime,t.servertimeoffset)}static mapLoginStatusEvent(t){return{...t,queues:t.queues.map(e=>({...e,Calls:e.Calls.map(r=>this.mapQueueCall(t,r))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,r){t[e]=r}static configureUTCForObject(t,e,r,o){const h=(r-o*60)*1e3,f=Date.now()-h,l={};return e.forEach(d=>{const i=t[d.key],u=d.key;if(i!==0&&typeof i=="number"&&!isNaN(i)){let c=i;d.format==="ms"&&(c=Math.floor(c/1e3));const s=(c-o*60)*1e3;this.assignProperty(l,`${u}_UTC`,s),this.assignProperty(l,`${u}_UTC_CLIENT`,s+f)}else this.assignProperty(l,`${u}_UTC`,0),this.assignProperty(l,`${u}_UTC_CLIENT`,0)}),{...t,...l}}}var fe=(a=>(a.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",a.KEEP_ALIVE="keepalive",a.SUBSCRIBE_VOICEBOT_CALL_UPDATES="subscribeVoicebotCallUpdates",a.UNSUBSCRIBE_VOICEBOT_CALL_UPDATES="unsubscribeVoicebotCallUpdates",a))(fe||{});class He{constructor(t){K(this,"io");K(this,"ioFunction");K(this,"lastEventTimestamp",new Date().getTime());K(this,"doReconnect",!0);K(this,"connectionState","disconnected");K(this,"keepAliveInterval");K(this,"reconnectTimeout");K(this,"networkReconnectTimeout");K(this,"reconnectionTime",Ae.reconnectionDelay);K(this,"maxReconnectionDelay",120);K(this,"networkCleanup",[]);this.eventsSdkClass=t,this.reconnectionTime=t.options.reconnectionDelay,this.setupNetworkListeners()}setupNetworkListeners(){const t=()=>this.closeAllConnections(),e=()=>this.handleNetworkOnline();typeof window<"u"&&"addEventListener"in window&&typeof window.addEventListener=="function"?(window.addEventListener("offline",t),window.addEventListener("online",e),this.networkCleanup.push(()=>window.removeEventListener("offline",t),()=>window.removeEventListener("online",e))):typeof self<"u"&&"addEventListener"in self&&typeof self.addEventListener=="function"&&(self.addEventListener("offline",t),self.addEventListener("online",e),this.networkCleanup.push(()=>self.removeEventListener("offline",t),()=>self.removeEventListener("online",e)))}handleNetworkOnline(){this.networkReconnectTimeout&&clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=setTimeout(()=>{this.connectionState==="disconnected"&&this.doReconnect&&this.eventsSdkClass.connect(ne.NEXT)},500)}getSocketIoFunction(t){const e=t.split("v="),r="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=We.getSocketVersion(r)}initSocketConnection(){if(this.connectionState!=="disconnected")return;this.connectionState="connecting";const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,r=this.eventsSdkClass.server;try{const o=r?r.Domain:this.eventsSdkClass.URL,h=r?`${e}://${o}`:this.eventsSdkClass.URL,f={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:t},timeout:this.eventsSdkClass.options.timeout};if(this.ioFunction&&h)this.io=this.ioFunction(h,f),this.initSocketEvents(),this.eventsSdkClass.eventEmitterClass.emit(A.ONLINE_STATUS_EVENT,{attemptToConnect:h,connectionStatus:se.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url not defined")}catch(o){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&(clearInterval(this.keepAliveInterval),this.keepAliveInterval=void 0)}initKeepAlive(){this.clearKeepAliveInterval(),this.keepAliveInterval=setInterval(async()=>{new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.connectionState==="connected"&&this.eventsSdkClass.authClass.token&&(this.eventsSdkClass.emit(fe.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit())},this.eventsSdkClass.options.keepAliveTimeout)}async closeAllConnections(){if(this.clearKeepAliveInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.networkReconnectTimeout&&(clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=void 0),this.io){const t=this.io;this.io=void 0;try{await Promise.race([new Promise(e=>{t.on("disconnect",()=>e()),t.removeAllListeners(),t.close(),t.disconnect()}),new Promise(e=>setTimeout(e,1e3))])}catch{}}this.connectionState="disconnected",this.eventsSdkClass.loggerClass.stop(),re.clearSessionStorage()}initSocketEvents(){this.io&&(this.io.removeAllListeners(),this.io.on(A.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,A.LOGIN_SUCCESS)).on(A.QUEUE_EVENT,t=>this.onQueueEvent(t,A.QUEUE_EVENT)).on(A.EXTENSION_EVENT,t=>this.onExtensionEvent(t,A.EXTENSION_EVENT)).on(A.DIALER_EVENT,t=>this.onDialerEvent(t,A.DIALER_EVENT)).on(A.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,A.LOGIN_STATUS)).on(A.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,A.ALL_EXTENSION_STATUS)).on(A.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,A.ALL_DIALER_STATUS)).on(A.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(A.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,A.EXTENSIONS_UPDATED)).on(A.CONNECT,()=>this.onConnect()).on(A.DISCONNECT,t=>this.onDisconnect(t)).on(A.CONNECT_ERROR_EVENT,t=>this.onConnectError(t)).on(A.ALL_VOICEBOTS_STATUS,t=>this.onAllVoicebotsStatus(t,A.ALL_VOICEBOTS_STATUS)).on(A.VOICEBOT_EVENT,t=>this.onVoicebotEvent(t,A.VOICEBOT_EVENT)).on(A.VOICEBOT_SUBSCRIBED_TO_CALL,t=>this.onVoicebotSubscribedToCall(t,A.VOICEBOT_SUBSCRIBED_TO_CALL)).on(A.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED,t=>this.onVoicebotSubscribeToCallFailed(t,A.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED)).on(A.VOICEBOT_INITIAL_CALL_HISTORY,t=>this.onVoicebotInitialCallHistory(t,A.VOICEBOT_INITIAL_CALL_HISTORY)).on(A.VOICEBOT_UNSUBSCRIBED_FROM_CALL,t=>this.onVoicebotUnsubscribedFromCall(t,A.VOICEBOT_UNSUBSCRIBED_FROM_CALL)))}updateEventTimestamp(){this.lastEventTimestamp=new Date().getTime()}onLoginSuccessEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapQueueEvent(t))}onExtensionEvent(t,e){this.updateEventTimestamp();const r=ce.mapExtensionEvent(t);r&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r))}onDialerEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onAllVoicebotsStatus(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotSubscribedToCall(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotSubscribeToCallFailed(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotInitialCallHistory(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotUnsubscribedFromCall(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){this.updateEventTimestamp();const r=ce.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onAllDialerStatus(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.closeAllConnections().then(()=>{this.doReconnect&&this.connectionState==="disconnected"&&this.scheduleReconnect()});return}}onExtensionsUpdatedEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connectionState="connected",this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.eventsSdkClass.eventEmitterClass.emit(A.ONLINE_STATUS_EVENT,{connectionStatus:se.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}scheduleReconnect(){!this.doReconnect||this.reconnectTimeout||(this.eventsSdkClass.eventEmitterClass.emit(A.ONLINE_STATUS_EVENT,{connectionStatus:se.TRYING_TO_CONNECT}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=void 0,this.reconnectionTime=Math.min(this.reconnectionTime*2,this.maxReconnectionDelay),this.reconnectionTime>this.maxReconnectionDelay&&(this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay),this.eventsSdkClass.connect(ne.NEXT)},this.reconnectionTime*1e3))}onDisconnect(t){if(this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkDisconnect([t]),!this.doReconnect){this.eventsSdkClass.eventEmitterClass.emit(A.ONLINE_STATUS_EVENT,{connectionStatus:se.DISCONNECTED});return}this.closeAllConnections(),this.scheduleReconnect()}onConnectError(t){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.doReconnect?this.scheduleReconnect():this.eventsSdkClass.eventEmitterClass.emit(A.ONLINE_STATUS_EVENT,{connectionStatus:se.DISCONNECTED})}async destroy(){this.doReconnect=!1,this.networkCleanup.forEach(t=>t()),await this.closeAllConnections()}}class Ye{constructor(t){K(this,"storageLogger");this.eventsSdkClass=t,this.eventsSdkClass=t}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let t;this.eventsSdkClass.options.loggerSocketConnection&&(t=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!t&&(t=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),t&&(this.storageLogger=new F({socket:t,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}async start(){this.storageLogger&&await this.storageLogger.start()}async stop(){this.storageLogger&&await this.storageLogger.stop()}log(t){if(this.eventsSdkClass.options.useLogger)if(this.storageLogger)switch(t.Level){case F.LevelEnum.INFO:this.storageLogger.log(t);break;case F.LevelEnum.DEBUG:this.storageLogger.debug(t);break;case F.LevelEnum.WARNING:this.storageLogger.warn(t);break;case F.LevelEnum.ERROR:this.storageLogger.error(t)}else t.Level===F.LevelEnum.INFO?console.log(t):t.Level===F.LevelEnum.ERROR&&console.error(t)}sdkConnectionSuccess(){const t={...this.eventsSdkClass.options,token:"CENSORED",password:"CENSORED"};this.log({Message:`Sdk connected to the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL}`,Body:JSON.stringify(t,this.eventsSdkClass.getCircularReplacer()),ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkDisconnect(t){this.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${t})`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkAttemptToConnect(t){this.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${t}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkAttemptToConnectError(t){this.log({Message:`${t}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}loginError(t,e,r,o){this.log({Message:`External login request error with the login type ${t} ${t===Q.TOKEN?r:o}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:e||400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}getSettingsError(t,e){this.log({Message:`Get settings error with token ${t}, error: ${e}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}refreshTokenError(t,e,r){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${r}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}keepAliveEmit(){this.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}keepAliveResponse(t){this.log({Message:`Keep alive response: ${JSON.stringify(t)}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}eventLog(t,e){const r={[te.FULL]:[],[te.BOOTSTRAP]:[A.LOGIN_STATUS,A.LOGIN_SUCCESS,A.ALL_EXTENSION_STATUS,A.ALL_DIALER_STATUS],[te.DEBUG_EXTENSIONS]:[A.ALL_EXTENSION_STATUS,A.EXTENSION_EVENT,A.EXTENSIONS_UPDATED],[te.DEBUG_DIALER]:[A.ALL_DIALER_STATUS,A.DIALER_EVENT],[te.DEBUG_QUEUE]:[A.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(r[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===te.FULL)&&this.log({Message:`Event name: ${t}`,Body:{...this.getStaticData(),...e},ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:F.LevelEnum.DEBUG,LogType:F.LogTypeEnum.INFO})}getStaticData(){return{SocketId:this.eventsSdkClass.socketIoClass&&this.eventsSdkClass.socketIoClass.io?this.eventsSdkClass.socketIoClass.io.id:""}}}class Qe{constructor(t){K(this,"listeners",{[A.ALL_EXTENSION_STATUS]:[],[A.ALL_DIALER_STATUS]:[],[A.ALL_USERS_STATUS]:[],[A.ALL_VOICEBOTS_STATUS]:[],[A.QUEUE_EVENT]:[],[A.EXTENSION_EVENT]:[],[A.DIALER_EVENT]:[],[A.LOGIN_SUCCESS]:[],[A.LOGIN_STATUS]:[],[A.KEEP_ALIVE_RESPONSE]:[],[A.ONLINE_STATUS_EVENT]:[],[A.EXTENSIONS_UPDATED]:[],[A.VOICEBOT_SUBSCRIBED_TO_CALL]:[],[A.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED]:[],[A.VOICEBOT_INITIAL_CALL_HISTORY]:[],[A.VOICEBOT_UNSUBSCRIBED_FROM_CALL]:[],[A.VOICEBOT_EVENT]:[]});K(this,"allListeners",[]);this.eventsSdkClass=t,this.eventsSdkClass=t}on(t,e){t==="*"?this.allListeners.push(e):this.listeners[t].push(e)}off(t,e){if(t==="*")this.allListeners=this.allListeners.filter(r=>r!==e);else{const o=this.listeners[t].filter(h=>h!==e);this.listeners={...this.listeners,[t]:o}}}emit(t,e){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[t].forEach(o=>o({name:t,data:e}));const r={name:t,data:e};this.allListeners.forEach(o=>o(r))}}class Ze{constructor(t){K(this,"options");K(this,"servers",[]);K(this,"URLList",[]);K(this,"server");K(this,"URL");K(this,"socket");K(this,"mainServer");K(this,"alreadyAttemptedOtherServers",[]);K(this,"authClass",new Xe(this));K(this,"socketIoClass");K(this,"loggerClass",new Ye(this));K(this,"eventEmitterClass",new Qe(this));K(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,r)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof r=="object"&&r!==null){if(t.has(r))return;t.add(r)}return r}}});this.options={...Ae,...t},this.socketIoClass=new He(this)}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===ne.MAIN&&this.findMainServer(),t===ne.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initKeepAlive()}async disconnect(){this.socketIoClass.doReconnect=!1,await this.socketIoClass.closeAllConnections(),await this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((t,e)=>e.Priority>t.Priority?e:t),this.server=this.mainServer):this.URLList.length&&(this.URL=this.URLList[0])}findNextServer(){if(this.servers.length&&this.server)if(this.server.Priority===this.mainServer.Priority){let t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0)),t.length&&(this.server=t.reduce((e,r)=>r.Priority>e.Priority?r:e),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0)),t.length&&(this.URL=t[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const t=await this.authClass.login();return t&&this.authClass.onLoginResponse(t),!0}getCurrentMonitorServer(){return this.server}}return z.CallStatusEnum=Le,z.CallTypeEnum=_e,z.ConnectionStatusEnum=se,z.DebugOption=te,z.DialerTypeEnum=Oe,z.DirectionEnum=Ie,z.DoNotCallMeStatusCodeEnum=Re,z.EventsEnum=A,z.ExtensionEventReasonEnum=pe,z.ExtensionHangupCauseEnum=Be,z.LoginType=Q,z.QueueEventReasonEnum=Ue,z.ServerListenerEventsEnum=fe,z.ServerParameter=ne,z.default=Ze,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),z}({},ws,StorageLogger);
|
|
19
19
|
//# sourceMappingURL=voicenter-events-sdk.iife.js.map
|