@voicenter-team/events-sdk 0.0.104 → 0.0.105
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/dist/voicenter-events-sdk.cjs.js +10 -10
- package/dist/voicenter-events-sdk.cjs.js.map +1 -1
- package/dist/voicenter-events-sdk.es.js +113 -125
- package/dist/voicenter-events-sdk.es.js.map +1 -1
- package/dist/voicenter-events-sdk.iife.js +10 -10
- package/dist/voicenter-events-sdk.iife.js.map +1 -1
- package/dist/voicenter-events-sdk.umd.js +10 -10
- package/dist/voicenter-events-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(K,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("ws"),require("@voicenter-team/socketio-storage-logger")):typeof define=="function"&&define.amd?define(["exports","ws","@voicenter-team/socketio-storage-logger"],H):(K=typeof globalThis<"u"?globalThis:K||self,H(K.VoicenterEventsSDK={},K.ws,K.StorageLogger))})(this,function(K,H,F){"use strict";var et=Object.defineProperty;var tt=(K,H,F)=>H in K?et(K,H,{enumerable:!0,configurable:!0,writable:!0,value:F}):K[H]=F;var V=(K,H,F)=>(tt(K,typeof H!="symbol"?H+"":H,F),F);function je(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ee={exports:{}},we={exports:{}};(function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,s){return e<<s|e>>>32-s},rotr:function(e,s){return e<<32-s|e>>>s},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var s=0;s<e.length;s++)e[s]=t.endian(e[s]);return e},randomBytes:function(e){for(var s=[];e>0;e--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(e){for(var s=[],o=0,h=0;o<e.length;o++,h+=8)s[h>>>5]|=e[o]<<24-h%32;return s},wordsToBytes:function(e){for(var s=[],o=0;o<e.length*32;o+=8)s.push(e[o>>>5]>>>24-o%32&255);return s},bytesToHex:function(e){for(var s=[],o=0;o<e.length;o++)s.push((e[o]>>>4).toString(16)),s.push((e[o]&15).toString(16));return s.join("")},hexToBytes:function(e){for(var s=[],o=0;o<e.length;o+=2)s.push(parseInt(e.substr(o,2),16));return s},bytesToBase64:function(e){for(var s=[],o=0;o<e.length;o+=3)for(var h=e[o]<<16|e[o+1]<<8|e[o+2],f=0;f<4;f++)o*8+f*6<=e.length*8?s.push(a.charAt(h>>>6*(3-f)&63)):s.push("=");return s.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],o=0,h=0;o<e.length;h=++o%4)h!=0&&s.push((a.indexOf(e.charAt(o-1))&Math.pow(2,-2*h+8)-1)<<h*2|a.indexOf(e.charAt(o))>>>6-h*2);return s}};we.exports=t})();var Pe=we.exports,he={utf8:{stringToBytes:function(a){return he.bin.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(he.bin.bytesToString(a)))}},bin:{stringToBytes:function(a){for(var t=[],e=0;e<a.length;e++)t.push(a.charCodeAt(e)&255);return t},bytesToString:function(a){for(var t=[],e=0;e<a.length;e++)t.push(String.fromCharCode(a[e]));return t.join("")}}},Te=he;/*!
|
|
2
2
|
* Determine if an object is a Buffer
|
|
3
3
|
*
|
|
4
4
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
5
|
* @license MIT
|
|
6
|
-
*/var Fe=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=Pe,t=we.utf8,e=Fe,s=we.bin,o=function(h,f){h.constructor==String?f&&f.encoding==="binary"?h=s.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,r=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,g=o._hh,w=o._ii,n=0;n<l.length;n+=16){var P=i,U=u,q=c,_=r;i=p(i,u,c,r,l[n+0],7,-680876936),r=p(r,i,u,c,l[n+1],12,-389564586),c=p(c,r,i,u,l[n+2],17,606105819),u=p(u,c,r,i,l[n+3],22,-1044525330),i=p(i,u,c,r,l[n+4],7,-176418897),r=p(r,i,u,c,l[n+5],12,1200080426),c=p(c,r,i,u,l[n+6],17,-1473231341),u=p(u,c,r,i,l[n+7],22,-45705983),i=p(i,u,c,r,l[n+8],7,1770035416),r=p(r,i,u,c,l[n+9],12,-1958414417),c=p(c,r,i,u,l[n+10],17,-42063),u=p(u,c,r,i,l[n+11],22,-1990404162),i=p(i,u,c,r,l[n+12],7,1804603682),r=p(r,i,u,c,l[n+13],12,-40341101),c=p(c,r,i,u,l[n+14],17,-1502002290),u=p(u,c,r,i,l[n+15],22,1236535329),i=y(i,u,c,r,l[n+1],5,-165796510),r=y(r,i,u,c,l[n+6],9,-1069501632),c=y(c,r,i,u,l[n+11],14,643717713),u=y(u,c,r,i,l[n+0],20,-373897302),i=y(i,u,c,r,l[n+5],5,-701558691),r=y(r,i,u,c,l[n+10],9,38016083),c=y(c,r,i,u,l[n+15],14,-660478335),u=y(u,c,r,i,l[n+4],20,-405537848),i=y(i,u,c,r,l[n+9],5,568446438),r=y(r,i,u,c,l[n+14],9,-1019803690),c=y(c,r,i,u,l[n+3],14,-187363961),u=y(u,c,r,i,l[n+8],20,1163531501),i=y(i,u,c,r,l[n+13],5,-1444681467),r=y(r,i,u,c,l[n+2],9,-51403784),c=y(c,r,i,u,l[n+7],14,1735328473),u=y(u,c,r,i,l[n+12],20,-1926607734),i=g(i,u,c,r,l[n+5],4,-378558),r=g(r,i,u,c,l[n+8],11,-2022574463),c=g(c,r,i,u,l[n+11],16,1839030562),u=g(u,c,r,i,l[n+14],23,-35309556),i=g(i,u,c,r,l[n+1],4,-1530992060),r=g(r,i,u,c,l[n+4],11,1272893353),c=g(c,r,i,u,l[n+7],16,-155497632),u=g(u,c,r,i,l[n+10],23,-1094730640),i=g(i,u,c,r,l[n+13],4,681279174),r=g(r,i,u,c,l[n+0],11,-358537222),c=g(c,r,i,u,l[n+3],16,-722521979),u=g(u,c,r,i,l[n+6],23,76029189),i=g(i,u,c,r,l[n+9],4,-640364487),r=g(r,i,u,c,l[n+12],11,-421815835),c=g(c,r,i,u,l[n+15],16,530742520),u=g(u,c,r,i,l[n+2],23,-995338651),i=w(i,u,c,r,l[n+0],6,-198630844),r=w(r,i,u,c,l[n+7],10,1126891415),c=w(c,r,i,u,l[n+14],15,-1416354905),u=w(u,c,r,i,l[n+5],21,-57434055),i=w(i,u,c,r,l[n+12],6,1700485571),r=w(r,i,u,c,l[n+3],10,-1894986606),c=w(c,r,i,u,l[n+10],15,-1051523),u=w(u,c,r,i,l[n+1],21,-2054922799),i=w(i,u,c,r,l[n+8],6,1873313359),r=w(r,i,u,c,l[n+15],10,-30611744),c=w(c,r,i,u,l[n+6],15,-1560198380),u=w(u,c,r,i,l[n+13],21,1309151649),i=w(i,u,c,r,l[n+4],6,-145523070),r=w(r,i,u,c,l[n+11],10,-1120210379),c=w(c,r,i,u,l[n+2],15,718787259),u=w(u,c,r,i,l[n+9],21,-343485551),i=i+P>>>0,u=u+U>>>0,c=c+q>>>0,r=r+_>>>0}return a.endian([i,u,c,r])};o._ff=function(h,f,l,d,i,u,c){var r=h+(f&l|~f&d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._gg=function(h,f,l,d,i,u,c){var r=h+(f&d|l&~d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._hh=function(h,f,l,d,i,u,c){var r=h+(f^l^d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._ii=function(h,f,l,d,i,u,c){var r=h+(l^(f|~d))+(i>>>0)+c;return(r<<u|r>>>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?s.bytesToString(l):a.bytesToHex(l)}})();var qe=Ee.exports;const Ve=je(qe);var ee=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(ee||{}),te=(a=>(a.MAIN="main",a.NEXT="next",a))(te||{}),Z=(a=>(a.USER="User",a.TOKEN="Token",a))(Z||{});class se{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const s=await chrome.storage.session.get(t);if(s[t])return e?JSON.parse(s[t]):s[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const s=window.sessionStorage.getItem(t);if(s)return e?JSON.parse(s):s}}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 Ke{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=Ve(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||(se.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await se.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,s){let o,h,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,s),h=await this.getSettings(o.Data.AccessToken),f={...o.Data,...h}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,s),f={...o.Data.Socket}),await se.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,s)=>e.Priority>s.Priority?e:s)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,s)=>e.Priority>s.Priority?e:s)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,s)=>e.Priority>s.Priority?e:s)),!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(te.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(te.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Z.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Z.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,s=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 se.updateSessionStorageKey(this.storageKey,h)}},s)}async externalLogin(t,{password:e,token:s,email:o},h){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?h===Z.TOKEN?f=JSON.stringify({identityType:Z.TOKEN,token:s}):f=JSON.stringify({identityType:Z.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Z.TOKEN?(f=JSON.stringify({token:s}),t=`${t}/${Z.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Z.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,s,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(s){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,s),s}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Xe={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:1e4,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 Ge(){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=H,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,s){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 r=t[l][1][c];return o(r||c)},u,u.exports,a,t,e,s)}return e[l].exports}for(var h=typeof require=="function"&&require,f=0;f<s.length;f++)o(s[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function s(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var c,r=o(i),n=r.source,p=r.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(r.path)}var o=a("./url"),h=a("socket.io-parser"),f=a("./manager"),l=a("debug")("socket.io-client");t.exports=e=s;var d=e.managers={};e.protocol=h.protocol,e.connect=s,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(r,n){return this instanceof e?(r&&typeof r=="object"&&(n=r,r=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=r,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(r,n)}var s=(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 r in this.nsps)this.nsps[r].emit.apply(this.nsps[r],arguments)},e.prototype.updateSocketIds=function(){for(var r in this.nsps)this.nsps[r].id=this.engine.id},h(e.prototype),e.prototype.reconnection=function(r){return arguments.length?(this._reconnection=!!r,this):this._reconnection},e.prototype.reconnectionAttempts=function(r){return arguments.length?(this._reconnectionAttempts=r,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(r){return arguments.length?(this._reconnectionDelay=r,this.backoff&&this.backoff.setMin(r),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(r){return arguments.length?(this._randomizationFactor=r,this.backoff&&this.backoff.setJitter(r),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(r){return arguments.length?(this._reconnectionDelayMax=r,this.backoff&&this.backoff.setMax(r),this):this._reconnectionDelayMax},e.prototype.timeout=function(r){return arguments.length?(this._timeout=r,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(r){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=s(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var y=l(n,"open",function(){p.onopen(),r&&r()}),g=l(n,"error",function(U){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",U),r){var q=new Error("Connection error");q.data=U,r(q)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var w=this._timeout;i("connect attempt will timeout after %d",w);var P=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(P)}})}return this.subs.push(y),this.subs.push(g),this},e.prototype.onopen=function(){i("open"),this.cleanup(),this.readyState="open",this.emit("open");var r=this.engine;this.subs.push(l(r,"data",d(this,"ondata"))),this.subs.push(l(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(l(r,"error",d(this,"onerror"))),this.subs.push(l(r,"close",d(this,"onclose")))},e.prototype.ondata=function(r){this.decoder.add(r)},e.prototype.ondecoded=function(r){this.emit("packet",r)},e.prototype.onerror=function(r){i("error",r),this.emitAll("error",r)},e.prototype.socket=function(r){var n=this.nsps[r];if(!n){n=new o(this,r),this.nsps[r]=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(r){var n=u(this.connected,r);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(r){i("writing packet %j",r);var n=this;n.encoding?n.packetBuffer.push(r):(n.encoding=!0,this.encoder.encode(r,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 r=this.packetBuffer.shift();this.packet(r)}},e.prototype.cleanup=function(){for(var r;r=this.subs.shift();)r.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(r){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",r),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var r=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(){r.skipReconnect||(i("attempting reconnect"),r.emitAll("reconnect_attempt",r.backoff.attempts),r.emitAll("reconnecting",r.backoff.attempts),r.skipReconnect||r.open(function(y){y?(i("reconnect attempt error"),r.reconnecting=!1,r.reconnect(),r.emitAll("reconnect_error",y.data)):(i("reconnect success"),r.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var r=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",r)}},{"./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(s,o,h){return s.on(o,h),{destroy:function(){s.removeListener(o,h)}}}t.exports=e},{}],5:[function(a,t,e){function s(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=s;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},r=h.prototype.emit;h(s.prototype),s.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"))]}},s.prototype.open=s.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},s.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},s.prototype.emit=function(n){if(c.hasOwnProperty(n))return r.apply(this,arguments),this;var p=f(arguments),y=o.EVENT;u(p)&&(y=o.BINARY_EVENT);var g={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(),g.id=this.ids++),this.connected?this.packet(g):this.sendBuffer.push(g),this},s.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},s.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},s.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},s.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)}},s.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?r.apply(this,p):this.receiveBuffer.push(p)},s.prototype.ack=function(n){var p=this,y=!1;return function(){if(!y){y=!0;var g=f(arguments);i("sending ack %j",g);var w=u(g)?o.BINARY_ACK:o.ACK;p.packet({type:w,id:n,data:g})}}},s.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]},s.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},s.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)r.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},s.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},s.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)},s.prototype.close=s.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 s(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=s}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),h=Math.floor(o*this.jitter*s);s=1&Math.floor(10*o)?s+h:s-h}return 0|Math.min(s,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(s){this.ms=s},e.prototype.setMax=function(s){this.max=s},e.prototype.setJitter=function(s){this.jitter=s}},{}],8:[function(a,t){var e=[].slice;t.exports=function(s,o){if(typeof o=="string"&&(o=s[o]),typeof o!="function")throw new Error("bind() requires a function");var h=e.call(arguments,2);return function(){return o.apply(s,h.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?s(o):void 0}function s(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=s(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 s(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 s(n,p){if(!(this instanceof s))return new s(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=r.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"),r=a("parseqs");t.exports=s,s.priorWebsocketSuccess=!1,f(s.prototype),s.protocol=i.protocol,s.Socket=s,s.Transport=a("./transport"),s.transports=a("./transports"),s.parser=a("engine.io-parser"),s.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},s.prototype.open=function(){var p;if(this.rememberUpgrade&&s.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)},s.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")})},s.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),_.send([{type:"ping",data:"probe"}]),_.once("packet",function(v){if(!C)if(v.type=="pong"&&v.data=="probe"){if(l('probe transport "%s" pong',n),b.upgrading=!0,b.emit("upgrading",_),!_)return;s.priorWebsocketSuccess=_.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"),q(),b.setTransport(_),_.send([{type:"upgrade"}]),b.emit("upgrade",_),_=null,b.upgrading=!1,b.flush())})}else{l('probe transport "%s" failed',n);var m=new Error("probe error");m.transport=_.name,b.emit("upgradeError",m)}}))}function y(){C||(C=!0,q(),_.close(),_=null)}function g(A){var v=new Error("probe error: "+A);v.transport=_.name,y(),l('probe transport "%s" failed because of error: %s',n,A),b.emit("upgradeError",v)}function w(){g("transport closed")}function P(){g("socket closed")}function U(A){_&&A.name!=_.name&&(l('"%s" works - aborting "%s"',A.name,_.name),y())}function q(){_.removeListener("open",p),_.removeListener("error",g),_.removeListener("close",w),b.removeListener("close",P),b.removeListener("upgrading",U)}l('probing transport "%s"',n);var _=this.createTransport(n,{probe:1}),C=!1,b=this;s.priorWebsocketSuccess=!1,_.once("open",p),_.once("error",g),_.once("close",w),this.once("close",P),this.once("upgrading",U),_.open()},s.prototype.onOpen=function(){if(l("socket open"),this.readyState="open",s.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])}},s.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)},s.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))},s.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)},s.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)},s.prototype.ping=function(){this.sendPacket("ping")},s.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()},s.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"))},s.prototype.write=s.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},s.prototype.sendPacket=function(n,p,y){if(this.readyState!="closing"&&this.readyState!="closed"){var g={type:n,data:p};this.emit("packetCreate",g),this.writeBuffer.push(g),this.callbackBuffer.push(y),this.flush()}},s.prototype.close=function(){function n(){g.onClose("forced close"),l("socket closing - telling transport to close"),g.transport.close()}function p(){g.removeListener("upgrade",p),g.removeListener("upgradeError",p),n()}function y(){g.once("upgrade",p),g.once("upgradeError",p)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var g=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?y():n()}):this.upgrading?y():n()}return this},s.prototype.onError=function(n){l("socket error %j",n),s.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},s.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)}},s.prototype.filterUpgrades=function(n){for(var p=[],y=0,g=n.length;g>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 s=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=s.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(s){function o(i){var u,c=!1,r=!1,n=i.jsonp!==!1;if(s.location){var p=location.protocol=="https:",y=location.port;y||(y=p?443:80),c=i.hostname!=location.hostname||y!=i.port,r=i.secure!=p}if(i.xdomain=c,i.xscheme=r,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 s(){}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(r){c.onData(r)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){c.script&&(c.script.onerror=s)},!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 r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(c,r),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 r(){n(),c()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(q){p.onError("jsonp polling iframe removal error",q)}try{var U='<iframe src="javascript:0" name="'+p.iframeId+'">';y=document.createElement(U)}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,g=document.createElement("form"),w=document.createElement("textarea"),P=this.iframeId="eio_iframe_"+this.index;g.className="socketio",g.style.position="absolute",g.style.top="-1000px",g.style.left="-1000px",g.target=P,g.method="POST",g.setAttribute("accept-charset","utf-8"),w.name="d",g.appendChild(w),document.body.appendChild(g),this.form=g,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"&&r()}:this.iframe.onload=r}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function s(){}function o(r){if(d.call(this,r),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=r.hostname!=e.location.hostname||p!=r.port,this.xs=r.secure!=n}}function h(r){this.method=r.method||"GET",this.uri=r.uri,this.xd=!!r.xd,this.xs=!!r.xs,this.async=r.async!==!1,this.data=r.data!=null?r.data:null,this.agent=r.agent,this.isBinary=r.isBinary,this.supportsBinary=r.supportsBinary,this.enablesXDR=r.enablesXDR,this.pfx=r.pfx,this.key=r.key,this.passphrase=r.passphrase,this.cert=r.cert,this.ca=r.ca,this.ciphers=r.ciphers,this.rejectUnauthorized=r.rejectUnauthorized,this.create()}function f(){for(var r in h.requests)h.requests.hasOwnProperty(r)&&h.requests[r].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(r){return r=r||{},r.uri=this.uri(),r.xd=this.xd,r.xs=this.xs,r.agent=this.agent||!1,r.supportsBinary=this.supportsBinary,r.enablesXDR=this.enablesXDR,r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,new h(r)},o.prototype.doWrite=function(r,n){var p=typeof r!="string"&&r!==void 0,y=this.request({method:"POST",data:r,isBinary:p}),g=this;y.on("success",n),y.on("error",function(w){g.onError("xhr post error",w)}),this.sendXhr=y},o.prototype.doPoll=function(){c("xhr poll");var r=this.request(),n=this;r.on("data",function(p){n.onData(p)}),r.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=r},i(h.prototype),h.prototype.create=function(){var r={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized;var n=this.xhr=new l(r),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(r){this.emit("data",r),this.onSuccess()},h.prototype.onError=function(r){this.emit("error",r),this.cleanup(!0)},h.prototype.cleanup=function(r){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=s:this.xhr.onreadystatechange=s,r)try{this.xhr.abort()}catch{}e.document&&delete h.requests[this.index],this.xhr=null}},h.prototype.onLoad=function(){var r;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}r=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}r!=null&&this.onData(r)},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),s.call(this,i)}var s=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,s),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 r=0;this.polling&&(l("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){l("pre-pause polling complete"),--r||u()})),this.writable||(l("we are currently writing - waiting to pause"),r++,this.once("drain",function(){l("pre-pause writing complete"),--r||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(r){return u.readyState=="opening"&&u.onOpen(),r.type=="close"?(u.onClose(),!1):void u.onPacket(r)};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(r){c.doWrite(r,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",c="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+s.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),s.call(this,i)}var s=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,s),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(){s.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 r=0,n=i.length;n>r;r++)o.encodePacket(i[r],this.supportsBinary,function(p){try{c.ws.send(p)}catch{l("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){s.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(s){var o=s.xdomain,h=s.xscheme,f=s.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,s){var o=function(){};o.prototype=s.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function s(){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,r=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(c++,n==="%c"&&(r=c))}),d.splice(r,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=s,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 s(){return e.colors[u++%e.colors.length]}function o(c){function r(){}function n(){var y=n,g=+new Date,w=g-(i||g);y.diff=w,y.prev=i,y.curr=g,i=g,y.useColors==null&&(y.useColors=e.useColors()),y.color==null&&y.useColors&&(y.color=s());var P=Array.prototype.slice.call(arguments);P[0]=e.coerce(P[0]),typeof P[0]!="string"&&(P=["%o"].concat(P));var U=0;P[0]=P[0].replace(/%([a-z%])/g,function(_,C){if(_==="%%")return _;U++;var b=e.formatters[C];if(typeof b=="function"){var A=P[U];_=b.call(y,A),P.splice(U,1),U--}return _}),typeof e.formatArgs=="function"&&(P=e.formatArgs.apply(y,P));var q=n.log||e.log||console.log.bind(console);q.apply(y,P)}r.enabled=!1,n.enabled=!0;var p=e.enabled(c)?n:r;return p.namespace=c,p}function h(c){e.save(c);for(var r=(c||"").split(/[\s,]+/),n=r.length,p=0;n>p;p++)r[p]&&(c=r[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 r,n;for(r=0,n=e.skips.length;n>r;r++)if(e.skips[r].test(c))return!1;for(r=0,n=e.names.length;n>r;r++)if(e.names[r].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 r=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(c);if(r){var n=parseFloat(r[1]),p=(r[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 s(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,r,n){return r>c?void 0:1.5*r>c?Math.floor(c/r)+" "+n:Math.ceil(c/r)+" "+n+"s"}var f=1e3,l=60*f,d=60*l,i=24*d,u=365.25*i;t.exports=function(c,r){return r=r||{},typeof c=="string"?e(c):r.long?o(c):s(c)}},{}],25:[function(a,t,e){(function(s){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 v=C.data,m=new Uint8Array(v),L=new Uint8Array(1+v.byteLength);L[0]=P[C.type];for(var I=0;I<m.length;I++)L[I+1]=m[I];return A(L.buffer)}function f(C,b,A){if(!b)return e.encodeBase64Packet(C,A);var v=new FileReader;return v.onload=function(){C.data=v.result,e.encodePacket(C,b,!0,A)},v.readAsArrayBuffer(C.data)}function l(C,b,A){if(!b)return e.encodeBase64Packet(C,A);if(w)return f(C,b,A);var v=new Uint8Array(1);v[0]=P[C.type];var m=new _([v.buffer,C.data]);return A(m)}function d(C,b,A){for(var v=new Array(C.length),m=n(C.length,A),L=function(R,k,G){b(k,function($,J){v[R]=J,G($,v)})},I=0;I<C.length;I++)L(I,C[I],m)}var i=a("./keys"),u=a("has-binary"),c=a("arraybuffer.slice"),r=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),y=navigator.userAgent.match(/Android/i),g=/PhantomJS/i.test(navigator.userAgent),w=y||g;e.protocol=3;var P=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},U=i(P),q={type:"error",data:"parser error"},_=a("blob");e.encodePacket=function(C,b,A,v){typeof b=="function"&&(v=b,b=!1),typeof A=="function"&&(v=A,A=null);var m=C.data===void 0?void 0:C.data.buffer||C.data;if(s.ArrayBuffer&&m instanceof ArrayBuffer)return h(C,b,v);if(_&&m instanceof s.Blob)return l(C,b,v);if(m&&m.base64)return o(C,v);var L=P[C.type];return C.data!==void 0&&(L+=A?p.encode(String(C.data)):String(C.data)),v(""+L)},e.encodeBase64Packet=function(C,b){var A="b"+e.packets[C.type];if(_&&C.data instanceof _){var v=new FileReader;return v.onload=function(){var k=v.result.split(",")[1];b(A+k)},v.readAsDataURL(C.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(C.data))}catch{for(var L=new Uint8Array(C.data),I=new Array(L.length),R=0;R<L.length;R++)I[R]=L[R];m=String.fromCharCode.apply(null,I)}return A+=s.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 q}var m=C.charAt(0);return Number(m)==m&&U[m]?C.length>1?{type:U[m],data:C.substring(1)}:{type:U[m]}:q}var v=new Uint8Array(C),m=v[0],L=c(C,1);return _&&b==="blob"&&(L=new _([L])),{type:U[m],data:L}},e.decodeBase64Packet=function(C,b){var A=U[C.charAt(0)];if(!s.ArrayBuffer)return{type:A,data:{base64:!0,data:C.substr(1)}};var v=r.decode(C.substr(1));return b==="blob"&&_&&(v=new _([v])),{type:A,data:v}},e.encodePayload=function(C,b,A){function v(I){return I.length+":"+I}function m(I,R){e.encodePacket(I,L?b:!1,!0,function(k){R(null,v(k))})}typeof b=="function"&&(A=b,b=null);var L=u(C);return b&&L?_&&!w?e.encodePayloadAsBlob(C,A):e.encodePayloadAsArrayBuffer(C,A):C.length?void d(C,m,function(I,R){return A(R.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 v;if(C=="")return A(q,0,1);for(var m,L,I="",R=0,k=C.length;k>R;R++){var G=C.charAt(R);if(G!=":")I+=G;else{if(I==""||I!=(m=Number(I))||(L=C.substr(R+1,m),I!=L.length))return A(q,0,1);if(L.length){if(v=e.decodePacket(L,b,!0),q.type==v.type&&q.data==v.data)return A(q,0,1);var $=A(v,R+m,k);if($===!1)return}R+=m,I=""}}return I!=""?A(q,0,1):void 0},e.encodePayloadAsArrayBuffer=function(C,b){function A(v,m){e.encodePacket(v,!0,!0,function(L){return m(null,L)})}return C.length?void d(C,A,function(v,m){var L=m.reduce(function(k,G){var $;return $=typeof G=="string"?G.length:G.byteLength,k+$.toString().length+$+2},0),I=new Uint8Array(L),R=0;return m.forEach(function(k){var G=typeof k=="string",$=k;if(G){for(var J=new Uint8Array(k.length),V=0;V<k.length;V++)J[V]=k.charCodeAt(V);$=J.buffer}I[R++]=G?0:1;for(var W=$.byteLength.toString(),V=0;V<W.length;V++)I[R++]=parseInt(W[V]);I[R++]=255;for(var J=new Uint8Array($),V=0;V<J.length;V++)I[R++]=J[V]}),b(I.buffer)}):b(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(C,b){function A(v,m){e.encodePacket(v,!0,!0,function(L){var I=new Uint8Array(1);if(I[0]=1,typeof L=="string"){for(var R=new Uint8Array(L.length),k=0;k<L.length;k++)R[k]=L.charCodeAt(k);L=R.buffer,I[0]=0}for(var G=L instanceof ArrayBuffer?L.byteLength:L.size,$=G.toString(),J=new Uint8Array($.length+1),k=0;k<$.length;k++)J[k]=parseInt($[k]);if(J[$.length]=255,_){var V=new _([I.buffer,J.buffer,L]);m(null,V)}})}d(C,A,function(v,m){return b(new _(m))})},e.decodePayloadAsBinary=function(C,b,A){typeof b=="function"&&(A=b,b=null);for(var v=C,m=[],L=!1;v.byteLength>0;){for(var I=new Uint8Array(v),R=I[0]===0,k="",G=1;I[G]!=255;G++){if(k.length>310){L=!0;break}k+=I[G]}if(L)return A(q,0,1);v=c(v,2+k.length),k=parseInt(k);var $=c(v,0,k);if(R)try{$=String.fromCharCode.apply(null,new Uint8Array($))}catch{var J=new Uint8Array($);$="";for(var G=0;G<J.length;G++)$+=String.fromCharCode(J[G])}m.push($),v=c(v,k)}var V=m.length;m.forEach(function(W,oe){A(e.decodePacket(W,b,!0),oe,V)})}}).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 s=[],o=Object.prototype.hasOwnProperty;for(var h in e)o.call(e,h)&&s.push(h);return s}},{}],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||s,l.count=o,o===0?h():l}function s(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,s,o){var h=e.byteLength;if(s=s||0,o=o||h,e.slice)return e.slice(s,o);if(0>s&&(s+=h),0>o&&(o+=h),o>h&&(o=h),s>=h||s>=o||h===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),l=new Uint8Array(o-s),d=s,i=0;o>d;d++,i++)l[i]=f[d];return l.buffer}},{}],29:[function(a,t,e){(function(s){e.encode=function(o){var h,f=new Uint8Array(o),l=f.length,d="";for(h=0;l>h;h+=3)d+=s[f[h]>>2],d+=s[(3&f[h])<<4|f[h+1]>>4],d+=s[(15&f[h+1])<<2|f[h+2]>>6],d+=s[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,r=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=s.indexOf(o[h]),l=s.indexOf(o[h+1]),d=s.indexOf(o[h+2]),i=s.indexOf(o[h+3]),p[r++]=f<<2|l>>4,p[r++]=(15&l)<<4|d>>2,p[r++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function s(u){for(var c=0;c<u.length;c++){var r=u[c];if(r.buffer instanceof ArrayBuffer){var n=r.buffer;if(r.byteLength!==n.byteLength){var p=new Uint8Array(r.byteLength);p.set(new Uint8Array(n,r.byteOffset,r.byteLength)),n=p.buffer}u[c]=n}}}function o(u,c){c=c||{};var r=new f;s(u);for(var n=0;n<u.length;n++)r.append(u[n]);return c.type?r.getBlob(c.type):r.getBlob()}function h(u,c){return s(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(s){(function(o){function h(v){for(var m,L,I=[],R=0,k=v.length;k>R;)m=v.charCodeAt(R++),m>=55296&&56319>=m&&k>R?(L=v.charCodeAt(R++),(64512&L)==56320?I.push(((1023&m)<<10)+(1023&L)+65536):(I.push(m),R--)):I.push(m);return I}function f(v){for(var m,L=v.length,I=-1,R="";++I<L;)m=v[I],m>65535&&(m-=65536,R+=q(m>>>10&1023|55296),m=56320|1023&m),R+=q(m);return R}function l(v){if(v>=55296&&57343>=v)throw Error("Lone surrogate U+"+v.toString(16).toUpperCase()+" is not a scalar value")}function d(v,m){return q(v>>m&63|128)}function i(v){if(!(4294967168&v))return q(v);var m="";return 4294965248&v?4294901760&v?!(4292870144&v)&&(m=q(v>>18&7|240),m+=d(v,12),m+=d(v,6)):(l(v),m=q(v>>12&15|224),m+=d(v,6)):m=q(v>>6&31|192),m+=q(63&v|128)}function u(v){for(var m,L=h(v),I=L.length,R=-1,k="";++R<I;)m=L[R],k+=i(m);return k}function c(){if(U>=P)throw Error("Invalid byte index");var v=255&w[U];if(U++,(192&v)==128)return 63&v;throw Error("Invalid continuation byte")}function r(){var v,m,L,I,R;if(U>P)throw Error("Invalid byte index");if(U==P)return!1;if(v=255&w[U],U++,(128&v)==0)return v;if((224&v)==192){var m=c();if(R=(31&v)<<6|m,R>=128)return R;throw Error("Invalid continuation byte")}if((240&v)==224){if(m=c(),L=c(),R=(15&v)<<12|m<<6|L,R>=2048)return l(R),R;throw Error("Invalid continuation byte")}if((248&v)==240&&(m=c(),L=c(),I=c(),R=(15&v)<<18|m<<12|L<<6|I,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function n(v){w=h(v),P=w.length,U=0;for(var m,L=[];(m=r())!==!1;)L.push(m);return f(L)}var p=typeof e=="object"&&e,y=typeof t=="object"&&t&&t.exports==p&&t,g=typeof s=="object"&&s;(g.global===g||g.window===g)&&(o=g);var w,P,U,q=String.fromCharCode,_={version:"2.0.0",encode:u,decode:n};if(p&&!p.nodeType)if(y)y.exports=_;else{var C={},b=C.hasOwnProperty;for(var A in _)b.call(_,A)&&(p[A]=_[A])}else o.utf8=_})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(a,t){(function(e){var s=/^[\],:{}\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):s.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(s){var o="";for(var h in s)s.hasOwnProperty(h)&&(o.length&&(o+="&"),o+=encodeURIComponent(h)+"="+encodeURIComponent(s[h]));return o},e.decode=function(s){for(var o={},h=s.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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["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[s[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 s=function(){return self}(),o=s.WebSocket||s.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function s(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=s}).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(s,o){if(e)return s.indexOf(o);for(var h=0;h<s.length;++h)if(s[h]===o)return h;return-1}},{}],41:[function(a,t,e){var s=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var h=[];for(var f in o)s.call(o,f)&&h.push(f);return h},e.values=function(o){var h=[];for(var f in o)s.call(o,f)&&h.push(o[f]);return h},e.merge=function(o,h){for(var f in h)s.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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["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[s[l]]=h[l]||"";return f}},{}],43:[function(a,t,e){(function(s){var o=a("isarray"),h=a("./is-buffer");e.deconstructPacket=function(f){function l(c){if(!c)return c;if(h(c)){var r={_placeholder:!0,num:d.length};return d.push(c),r}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 r in i)i[r]=d(i[r]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,l){function d(c,r,n){if(!c)return c;if(s.Blob&&c instanceof Blob||s.File&&c instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[r]=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 g in c)d(c[g],g,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 s(){}function o(y){var g="",w=!1;return g+=y.type,(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)&&(g+=y.attachments,g+="-"),y.nsp&&y.nsp!="/"&&(w=!0,g+=y.nsp),y.id!=null&&(w&&(g+=",",w=!1),g+=y.id),y.data!=null&&(w&&(g+=","),g+=c.stringify(y.data)),u("encoded %j as %s",y,g),g}function h(y,g){function w(P){var U=n.deconstructPacket(P),q=o(U.packet),_=U.buffers;_.unshift(q),g(_)}n.removeBlobs(y,w)}function f(){this.reconstructor=null}function l(y){var g={},w=0;if(g.type=Number(y.charAt(0)),e.types[g.type]==null)return i();if(e.BINARY_EVENT==g.type||e.BINARY_ACK==g.type){for(var P="";y.charAt(++w)!="-"&&(P+=y.charAt(w),w!=y.length););if(P!=Number(P)||y.charAt(w)!="-")throw new Error("Illegal attachments");g.attachments=Number(P)}if(y.charAt(w+1)=="/")for(g.nsp="";++w;){var U=y.charAt(w);if(U==","||(g.nsp+=U,w==y.length))break}else g.nsp="/";var q=y.charAt(w+1);if(q!==""&&Number(q)==q){for(g.id="";++w;){var U=y.charAt(w);if(U==null||Number(U)!=U){--w;break}if(g.id+=y.charAt(w),w==y.length)break}g.id=Number(g.id)}if(y.charAt(++w))try{g.data=c.parse(y.substr(w))}catch{return i()}return u("decoded %s as %j",y,g),g}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"),r=(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=s,e.Decoder=f,s.prototype.encode=function(y,g){if(u("encoding packet %j",y),e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)h(y,g);else{var w=o(y);g([w])}},r(f.prototype),f.prototype.add=function(y){var g;if(typeof y=="string")g=l(y),e.BINARY_EVENT==g.type||e.BINARY_ACK==g.type?(this.reconstructor=new d(g),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",g)):this.emit("decoded",g);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");g=this.reconstructor.takeBinaryData(y),g&&(this.reconstructor=null,this.emit("decoded",g))}},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 g=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),g}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 s(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=s}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(s){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,D='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var S=u.stringify,x=typeof S=="function"&&c;if(x){(T=function(){return 1}).toJSON=T;try{x=S(0)==="0"&&S(new Number)==="0"&&S(new String)=='""'&&S(d)===l&&S(l)===l&&S()===l&&S(T)==="1"&&S([T])=="[1]"&&S([l])=="[null]"&&S(null)=="null"&&S([l,d,null])=="[null,null,null]"&&S({a:[T,!0,!1,null,`\0\b
|
|
8
|
-
\f\r `]})==D&&S(null,
|
|
6
|
+
*/var Fe=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=Pe,t=Te.utf8,e=Fe,s=Te.bin,o=function(h,f){h.constructor==String?f&&f.encoding==="binary"?h=s.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,r=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,T=o._ii,n=0;n<l.length;n+=16){var P=i,U=u,q=c,O=r;i=p(i,u,c,r,l[n+0],7,-680876936),r=p(r,i,u,c,l[n+1],12,-389564586),c=p(c,r,i,u,l[n+2],17,606105819),u=p(u,c,r,i,l[n+3],22,-1044525330),i=p(i,u,c,r,l[n+4],7,-176418897),r=p(r,i,u,c,l[n+5],12,1200080426),c=p(c,r,i,u,l[n+6],17,-1473231341),u=p(u,c,r,i,l[n+7],22,-45705983),i=p(i,u,c,r,l[n+8],7,1770035416),r=p(r,i,u,c,l[n+9],12,-1958414417),c=p(c,r,i,u,l[n+10],17,-42063),u=p(u,c,r,i,l[n+11],22,-1990404162),i=p(i,u,c,r,l[n+12],7,1804603682),r=p(r,i,u,c,l[n+13],12,-40341101),c=p(c,r,i,u,l[n+14],17,-1502002290),u=p(u,c,r,i,l[n+15],22,1236535329),i=y(i,u,c,r,l[n+1],5,-165796510),r=y(r,i,u,c,l[n+6],9,-1069501632),c=y(c,r,i,u,l[n+11],14,643717713),u=y(u,c,r,i,l[n+0],20,-373897302),i=y(i,u,c,r,l[n+5],5,-701558691),r=y(r,i,u,c,l[n+10],9,38016083),c=y(c,r,i,u,l[n+15],14,-660478335),u=y(u,c,r,i,l[n+4],20,-405537848),i=y(i,u,c,r,l[n+9],5,568446438),r=y(r,i,u,c,l[n+14],9,-1019803690),c=y(c,r,i,u,l[n+3],14,-187363961),u=y(u,c,r,i,l[n+8],20,1163531501),i=y(i,u,c,r,l[n+13],5,-1444681467),r=y(r,i,u,c,l[n+2],9,-51403784),c=y(c,r,i,u,l[n+7],14,1735328473),u=y(u,c,r,i,l[n+12],20,-1926607734),i=v(i,u,c,r,l[n+5],4,-378558),r=v(r,i,u,c,l[n+8],11,-2022574463),c=v(c,r,i,u,l[n+11],16,1839030562),u=v(u,c,r,i,l[n+14],23,-35309556),i=v(i,u,c,r,l[n+1],4,-1530992060),r=v(r,i,u,c,l[n+4],11,1272893353),c=v(c,r,i,u,l[n+7],16,-155497632),u=v(u,c,r,i,l[n+10],23,-1094730640),i=v(i,u,c,r,l[n+13],4,681279174),r=v(r,i,u,c,l[n+0],11,-358537222),c=v(c,r,i,u,l[n+3],16,-722521979),u=v(u,c,r,i,l[n+6],23,76029189),i=v(i,u,c,r,l[n+9],4,-640364487),r=v(r,i,u,c,l[n+12],11,-421815835),c=v(c,r,i,u,l[n+15],16,530742520),u=v(u,c,r,i,l[n+2],23,-995338651),i=T(i,u,c,r,l[n+0],6,-198630844),r=T(r,i,u,c,l[n+7],10,1126891415),c=T(c,r,i,u,l[n+14],15,-1416354905),u=T(u,c,r,i,l[n+5],21,-57434055),i=T(i,u,c,r,l[n+12],6,1700485571),r=T(r,i,u,c,l[n+3],10,-1894986606),c=T(c,r,i,u,l[n+10],15,-1051523),u=T(u,c,r,i,l[n+1],21,-2054922799),i=T(i,u,c,r,l[n+8],6,1873313359),r=T(r,i,u,c,l[n+15],10,-30611744),c=T(c,r,i,u,l[n+6],15,-1560198380),u=T(u,c,r,i,l[n+13],21,1309151649),i=T(i,u,c,r,l[n+4],6,-145523070),r=T(r,i,u,c,l[n+11],10,-1120210379),c=T(c,r,i,u,l[n+2],15,718787259),u=T(u,c,r,i,l[n+9],21,-343485551),i=i+P>>>0,u=u+U>>>0,c=c+q>>>0,r=r+O>>>0}return a.endian([i,u,c,r])};o._ff=function(h,f,l,d,i,u,c){var r=h+(f&l|~f&d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._gg=function(h,f,l,d,i,u,c){var r=h+(f&d|l&~d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._hh=function(h,f,l,d,i,u,c){var r=h+(f^l^d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._ii=function(h,f,l,d,i,u,c){var r=h+(l^(f|~d))+(i>>>0)+c;return(r<<u|r>>>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?s.bytesToString(l):a.bytesToHex(l)}})();var qe=Ee.exports;const Xe=je(qe);var ne=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(ne||{}),ee=(a=>(a.MAIN="main",a.NEXT="next",a))(ee||{}),Z=(a=>(a.USER="User",a.TOKEN="Token",a))(Z||{});class se{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const s=await chrome.storage.session.get(t);if(s[t])return e?JSON.parse(s[t]):s[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const s=window.sessionStorage.getItem(t);if(s)return e?JSON.parse(s):s}}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 Ve{constructor(t){V(this,"delay",1e3);V(this,"lastLoginTimestamp");V(this,"token");V(this,"refreshToken");V(this,"tokenExpiry");V(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=Xe(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||(se.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await se.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,s){let o,h,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,s),h=await this.getSettings(o.Data.AccessToken),f={...o.Data,...h}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,s),f={...o.Data.Socket}),await se.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,s)=>e.Priority>s.Priority?e:s)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,s)=>e.Priority>s.Priority?e:s)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,s)=>e.Priority>s.Priority?e:s)),!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(ee.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(ee.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Z.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Z.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,s=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 se.updateSessionStorageKey(this.storageKey,h)}},s)}async externalLogin(t,{password:e,token:s,email:o},h){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?h===Z.TOKEN?f=JSON.stringify({identityType:Z.TOKEN,token:s}):f=JSON.stringify({identityType:Z.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Z.TOKEN?(f=JSON.stringify({token:s}),t=`${t}/${Z.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Z.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,s,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(s){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,s),s}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Ke={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:1e4,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=H,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,s){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 r=t[l][1][c];return o(r||c)},u,u.exports,a,t,e,s)}return e[l].exports}for(var h=typeof require=="function"&&require,f=0;f<s.length;f++)o(s[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function s(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var c,r=o(i),n=r.source,p=r.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(r.path)}var o=a("./url"),h=a("socket.io-parser"),f=a("./manager"),l=a("debug")("socket.io-client");t.exports=e=s;var d=e.managers={};e.protocol=h.protocol,e.connect=s,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(r,n){return this instanceof e?(r&&typeof r=="object"&&(n=r,r=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=r,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(r,n)}var s=(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 r in this.nsps)this.nsps[r].emit.apply(this.nsps[r],arguments)},e.prototype.updateSocketIds=function(){for(var r in this.nsps)this.nsps[r].id=this.engine.id},h(e.prototype),e.prototype.reconnection=function(r){return arguments.length?(this._reconnection=!!r,this):this._reconnection},e.prototype.reconnectionAttempts=function(r){return arguments.length?(this._reconnectionAttempts=r,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(r){return arguments.length?(this._reconnectionDelay=r,this.backoff&&this.backoff.setMin(r),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(r){return arguments.length?(this._randomizationFactor=r,this.backoff&&this.backoff.setJitter(r),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(r){return arguments.length?(this._reconnectionDelayMax=r,this.backoff&&this.backoff.setMax(r),this):this._reconnectionDelayMax},e.prototype.timeout=function(r){return arguments.length?(this._timeout=r,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(r){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=s(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var y=l(n,"open",function(){p.onopen(),r&&r()}),v=l(n,"error",function(U){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",U),r){var q=new Error("Connection error");q.data=U,r(q)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var T=this._timeout;i("connect attempt will timeout after %d",T);var P=setTimeout(function(){i("connect attempt timed out after %d",T),y.destroy(),n.close(),n.emit("error","timeout"),p.emitAll("connect_timeout",T)},T);this.subs.push({destroy:function(){clearTimeout(P)}})}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 r=this.engine;this.subs.push(l(r,"data",d(this,"ondata"))),this.subs.push(l(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(l(r,"error",d(this,"onerror"))),this.subs.push(l(r,"close",d(this,"onclose")))},e.prototype.ondata=function(r){this.decoder.add(r)},e.prototype.ondecoded=function(r){this.emit("packet",r)},e.prototype.onerror=function(r){i("error",r),this.emitAll("error",r)},e.prototype.socket=function(r){var n=this.nsps[r];if(!n){n=new o(this,r),this.nsps[r]=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(r){var n=u(this.connected,r);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(r){i("writing packet %j",r);var n=this;n.encoding?n.packetBuffer.push(r):(n.encoding=!0,this.encoder.encode(r,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 r=this.packetBuffer.shift();this.packet(r)}},e.prototype.cleanup=function(){for(var r;r=this.subs.shift();)r.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(r){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",r),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var r=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(){r.skipReconnect||(i("attempting reconnect"),r.emitAll("reconnect_attempt",r.backoff.attempts),r.emitAll("reconnecting",r.backoff.attempts),r.skipReconnect||r.open(function(y){y?(i("reconnect attempt error"),r.reconnecting=!1,r.reconnect(),r.emitAll("reconnect_error",y.data)):(i("reconnect success"),r.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var r=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",r)}},{"./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(s,o,h){return s.on(o,h),{destroy:function(){s.removeListener(o,h)}}}t.exports=e},{}],5:[function(a,t,e){function s(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=s;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},r=h.prototype.emit;h(s.prototype),s.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"))]}},s.prototype.open=s.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},s.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},s.prototype.emit=function(n){if(c.hasOwnProperty(n))return r.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},s.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},s.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},s.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},s.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)}},s.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?r.apply(this,p):this.receiveBuffer.push(p)},s.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 T=u(v)?o.BINARY_ACK:o.ACK;p.packet({type:T,id:n,data:v})}}},s.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]},s.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},s.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)r.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},s.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},s.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)},s.prototype.close=s.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 s(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=s}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),h=Math.floor(o*this.jitter*s);s=1&Math.floor(10*o)?s+h:s-h}return 0|Math.min(s,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(s){this.ms=s},e.prototype.setMax=function(s){this.max=s},e.prototype.setJitter=function(s){this.jitter=s}},{}],8:[function(a,t){var e=[].slice;t.exports=function(s,o){if(typeof o=="string"&&(o=s[o]),typeof o!="function")throw new Error("bind() requires a function");var h=e.call(arguments,2);return function(){return o.apply(s,h.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?s(o):void 0}function s(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=s(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 s(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 s(n,p){if(!(this instanceof s))return new s(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=r.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"),r=a("parseqs");t.exports=s,s.priorWebsocketSuccess=!1,f(s.prototype),s.protocol=i.protocol,s.Socket=s,s.Transport=a("./transport"),s.transports=a("./transports"),s.parser=a("engine.io-parser"),s.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},s.prototype.open=function(){var p;if(this.rememberUpgrade&&s.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)},s.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")})},s.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;s.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"),q(),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,q(),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 T(){v("transport closed")}function P(){v("socket closed")}function U(A){O&&A.name!=O.name&&(l('"%s" works - aborting "%s"',A.name,O.name),y())}function q(){O.removeListener("open",p),O.removeListener("error",v),O.removeListener("close",T),b.removeListener("close",P),b.removeListener("upgrading",U)}l('probing transport "%s"',n);var O=this.createTransport(n,{probe:1}),C=!1,b=this;s.priorWebsocketSuccess=!1,O.once("open",p),O.once("error",v),O.once("close",T),this.once("close",P),this.once("upgrading",U),O.open()},s.prototype.onOpen=function(){if(l("socket open"),this.readyState="open",s.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])}},s.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)},s.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))},s.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)},s.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)},s.prototype.ping=function(){this.sendPacket("ping")},s.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()},s.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"))},s.prototype.write=s.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},s.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()}},s.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},s.prototype.onError=function(n){l("socket error %j",n),s.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},s.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)}},s.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 s=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=s.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(s){function o(i){var u,c=!1,r=!1,n=i.jsonp!==!1;if(s.location){var p=location.protocol=="https:",y=location.port;y||(y=p?443:80),c=i.hostname!=location.hostname||y!=i.port,r=i.secure!=p}if(i.xdomain=c,i.xscheme=r,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 s(){}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(r){c.onData(r)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){c.script&&(c.script.onerror=s)},!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 r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(c,r),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 r(){n(),c()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(q){p.onError("jsonp polling iframe removal error",q)}try{var U='<iframe src="javascript:0" name="'+p.iframeId+'">';y=document.createElement(U)}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"),T=document.createElement("textarea"),P=this.iframeId="eio_iframe_"+this.index;v.className="socketio",v.style.position="absolute",v.style.top="-1000px",v.style.left="-1000px",v.target=P,v.method="POST",v.setAttribute("accept-charset","utf-8"),T.name="d",v.appendChild(T),document.body.appendChild(v),this.form=v,this.area=T}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"&&r()}:this.iframe.onload=r}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function s(){}function o(r){if(d.call(this,r),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=r.hostname!=e.location.hostname||p!=r.port,this.xs=r.secure!=n}}function h(r){this.method=r.method||"GET",this.uri=r.uri,this.xd=!!r.xd,this.xs=!!r.xs,this.async=r.async!==!1,this.data=r.data!=null?r.data:null,this.agent=r.agent,this.isBinary=r.isBinary,this.supportsBinary=r.supportsBinary,this.enablesXDR=r.enablesXDR,this.pfx=r.pfx,this.key=r.key,this.passphrase=r.passphrase,this.cert=r.cert,this.ca=r.ca,this.ciphers=r.ciphers,this.rejectUnauthorized=r.rejectUnauthorized,this.create()}function f(){for(var r in h.requests)h.requests.hasOwnProperty(r)&&h.requests[r].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(r){return r=r||{},r.uri=this.uri(),r.xd=this.xd,r.xs=this.xs,r.agent=this.agent||!1,r.supportsBinary=this.supportsBinary,r.enablesXDR=this.enablesXDR,r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,new h(r)},o.prototype.doWrite=function(r,n){var p=typeof r!="string"&&r!==void 0,y=this.request({method:"POST",data:r,isBinary:p}),v=this;y.on("success",n),y.on("error",function(T){v.onError("xhr post error",T)}),this.sendXhr=y},o.prototype.doPoll=function(){c("xhr poll");var r=this.request(),n=this;r.on("data",function(p){n.onData(p)}),r.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=r},i(h.prototype),h.prototype.create=function(){var r={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized;var n=this.xhr=new l(r),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(r){this.emit("data",r),this.onSuccess()},h.prototype.onError=function(r){this.emit("error",r),this.cleanup(!0)},h.prototype.cleanup=function(r){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=s:this.xhr.onreadystatechange=s,r)try{this.xhr.abort()}catch{}e.document&&delete h.requests[this.index],this.xhr=null}},h.prototype.onLoad=function(){var r;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}r=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}r!=null&&this.onData(r)},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),s.call(this,i)}var s=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,s),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 r=0;this.polling&&(l("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){l("pre-pause polling complete"),--r||u()})),this.writable||(l("we are currently writing - waiting to pause"),r++,this.once("drain",function(){l("pre-pause writing complete"),--r||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(r){return u.readyState=="opening"&&u.onOpen(),r.type=="close"?(u.onClose(),!1):void u.onPacket(r)};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(r){c.doWrite(r,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",c="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+s.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),s.call(this,i)}var s=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,s),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(){s.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 r=0,n=i.length;n>r;r++)o.encodePacket(i[r],this.supportsBinary,function(p){try{c.ws.send(p)}catch{l("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){s.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(s){var o=s.xdomain,h=s.xscheme,f=s.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,s){var o=function(){};o.prototype=s.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function s(){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,r=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(c++,n==="%c"&&(r=c))}),d.splice(r,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=s,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 s(){return e.colors[u++%e.colors.length]}function o(c){function r(){}function n(){var y=n,v=+new Date,T=v-(i||v);y.diff=T,y.prev=i,y.curr=v,i=v,y.useColors==null&&(y.useColors=e.useColors()),y.color==null&&y.useColors&&(y.color=s());var P=Array.prototype.slice.call(arguments);P[0]=e.coerce(P[0]),typeof P[0]!="string"&&(P=["%o"].concat(P));var U=0;P[0]=P[0].replace(/%([a-z%])/g,function(O,C){if(O==="%%")return O;U++;var b=e.formatters[C];if(typeof b=="function"){var A=P[U];O=b.call(y,A),P.splice(U,1),U--}return O}),typeof e.formatArgs=="function"&&(P=e.formatArgs.apply(y,P));var q=n.log||e.log||console.log.bind(console);q.apply(y,P)}r.enabled=!1,n.enabled=!0;var p=e.enabled(c)?n:r;return p.namespace=c,p}function h(c){e.save(c);for(var r=(c||"").split(/[\s,]+/),n=r.length,p=0;n>p;p++)r[p]&&(c=r[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 r,n;for(r=0,n=e.skips.length;n>r;r++)if(e.skips[r].test(c))return!1;for(r=0,n=e.names.length;n>r;r++)if(e.names[r].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 r=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(c);if(r){var n=parseFloat(r[1]),p=(r[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 s(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,r,n){return r>c?void 0:1.5*r>c?Math.floor(c/r)+" "+n:Math.ceil(c/r)+" "+n+"s"}var f=1e3,l=60*f,d=60*l,i=24*d,u=365.25*i;t.exports=function(c,r){return r=r||{},typeof c=="string"?e(c):r.long?o(c):s(c)}},{}],25:[function(a,t,e){(function(s){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]=P[C.type];for(var I=0;I<m.length;I++)L[I+1]=m[I];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(T)return f(C,b,A);var g=new Uint8Array(1);g[0]=P[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(R,k,$){b(k,function(G,J){g[R]=J,$(G,g)})},I=0;I<C.length;I++)L(I,C[I],m)}var i=a("./keys"),u=a("has-binary"),c=a("arraybuffer.slice"),r=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),y=navigator.userAgent.match(/Android/i),v=/PhantomJS/i.test(navigator.userAgent),T=y||v;e.protocol=3;var P=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},U=i(P),q={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(s.ArrayBuffer&&m instanceof ArrayBuffer)return h(C,b,g);if(O&&m instanceof s.Blob)return l(C,b,g);if(m&&m.base64)return o(C,g);var L=P[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 k=g.result.split(",")[1];b(A+k)},g.readAsDataURL(C.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(C.data))}catch{for(var L=new Uint8Array(C.data),I=new Array(L.length),R=0;R<L.length;R++)I[R]=L[R];m=String.fromCharCode.apply(null,I)}return A+=s.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 q}var m=C.charAt(0);return Number(m)==m&&U[m]?C.length>1?{type:U[m],data:C.substring(1)}:{type:U[m]}:q}var g=new Uint8Array(C),m=g[0],L=c(C,1);return O&&b==="blob"&&(L=new O([L])),{type:U[m],data:L}},e.decodeBase64Packet=function(C,b){var A=U[C.charAt(0)];if(!s.ArrayBuffer)return{type:A,data:{base64:!0,data:C.substr(1)}};var g=r.decode(C.substr(1));return b==="blob"&&O&&(g=new O([g])),{type:A,data:g}},e.encodePayload=function(C,b,A){function g(I){return I.length+":"+I}function m(I,R){e.encodePacket(I,L?b:!1,!0,function(k){R(null,g(k))})}typeof b=="function"&&(A=b,b=null);var L=u(C);return b&&L?O&&!T?e.encodePayloadAsBlob(C,A):e.encodePayloadAsArrayBuffer(C,A):C.length?void d(C,m,function(I,R){return A(R.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(q,0,1);for(var m,L,I="",R=0,k=C.length;k>R;R++){var $=C.charAt(R);if($!=":")I+=$;else{if(I==""||I!=(m=Number(I))||(L=C.substr(R+1,m),I!=L.length))return A(q,0,1);if(L.length){if(g=e.decodePacket(L,b,!0),q.type==g.type&&q.data==g.data)return A(q,0,1);var G=A(g,R+m,k);if(G===!1)return}R+=m,I=""}}return I!=""?A(q,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(k,$){var G;return G=typeof $=="string"?$.length:$.byteLength,k+G.toString().length+G+2},0),I=new Uint8Array(L),R=0;return m.forEach(function(k){var $=typeof k=="string",G=k;if($){for(var J=new Uint8Array(k.length),X=0;X<k.length;X++)J[X]=k.charCodeAt(X);G=J.buffer}I[R++]=$?0:1;for(var W=G.byteLength.toString(),X=0;X<W.length;X++)I[R++]=parseInt(W[X]);I[R++]=255;for(var J=new Uint8Array(G),X=0;X<J.length;X++)I[R++]=J[X]}),b(I.buffer)}):b(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(C,b){function A(g,m){e.encodePacket(g,!0,!0,function(L){var I=new Uint8Array(1);if(I[0]=1,typeof L=="string"){for(var R=new Uint8Array(L.length),k=0;k<L.length;k++)R[k]=L.charCodeAt(k);L=R.buffer,I[0]=0}for(var $=L instanceof ArrayBuffer?L.byteLength:L.size,G=$.toString(),J=new Uint8Array(G.length+1),k=0;k<G.length;k++)J[k]=parseInt(G[k]);if(J[G.length]=255,O){var X=new O([I.buffer,J.buffer,L]);m(null,X)}})}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 I=new Uint8Array(g),R=I[0]===0,k="",$=1;I[$]!=255;$++){if(k.length>310){L=!0;break}k+=I[$]}if(L)return A(q,0,1);g=c(g,2+k.length),k=parseInt(k);var G=c(g,0,k);if(R)try{G=String.fromCharCode.apply(null,new Uint8Array(G))}catch{var J=new Uint8Array(G);G="";for(var $=0;$<J.length;$++)G+=String.fromCharCode(J[$])}m.push(G),g=c(g,k)}var X=m.length;m.forEach(function(W,oe){A(e.decodePacket(W,b,!0),oe,X)})}}).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 s=[],o=Object.prototype.hasOwnProperty;for(var h in e)o.call(e,h)&&s.push(h);return s}},{}],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||s,l.count=o,o===0?h():l}function s(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,s,o){var h=e.byteLength;if(s=s||0,o=o||h,e.slice)return e.slice(s,o);if(0>s&&(s+=h),0>o&&(o+=h),o>h&&(o=h),s>=h||s>=o||h===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),l=new Uint8Array(o-s),d=s,i=0;o>d;d++,i++)l[i]=f[d];return l.buffer}},{}],29:[function(a,t,e){(function(s){e.encode=function(o){var h,f=new Uint8Array(o),l=f.length,d="";for(h=0;l>h;h+=3)d+=s[f[h]>>2],d+=s[(3&f[h])<<4|f[h+1]>>4],d+=s[(15&f[h+1])<<2|f[h+2]>>6],d+=s[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,r=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=s.indexOf(o[h]),l=s.indexOf(o[h+1]),d=s.indexOf(o[h+2]),i=s.indexOf(o[h+3]),p[r++]=f<<2|l>>4,p[r++]=(15&l)<<4|d>>2,p[r++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function s(u){for(var c=0;c<u.length;c++){var r=u[c];if(r.buffer instanceof ArrayBuffer){var n=r.buffer;if(r.byteLength!==n.byteLength){var p=new Uint8Array(r.byteLength);p.set(new Uint8Array(n,r.byteOffset,r.byteLength)),n=p.buffer}u[c]=n}}}function o(u,c){c=c||{};var r=new f;s(u);for(var n=0;n<u.length;n++)r.append(u[n]);return c.type?r.getBlob(c.type):r.getBlob()}function h(u,c){return s(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(s){(function(o){function h(g){for(var m,L,I=[],R=0,k=g.length;k>R;)m=g.charCodeAt(R++),m>=55296&&56319>=m&&k>R?(L=g.charCodeAt(R++),(64512&L)==56320?I.push(((1023&m)<<10)+(1023&L)+65536):(I.push(m),R--)):I.push(m);return I}function f(g){for(var m,L=g.length,I=-1,R="";++I<L;)m=g[I],m>65535&&(m-=65536,R+=q(m>>>10&1023|55296),m=56320|1023&m),R+=q(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 q(g>>m&63|128)}function i(g){if(!(4294967168&g))return q(g);var m="";return 4294965248&g?4294901760&g?!(4292870144&g)&&(m=q(g>>18&7|240),m+=d(g,12),m+=d(g,6)):(l(g),m=q(g>>12&15|224),m+=d(g,6)):m=q(g>>6&31|192),m+=q(63&g|128)}function u(g){for(var m,L=h(g),I=L.length,R=-1,k="";++R<I;)m=L[R],k+=i(m);return k}function c(){if(U>=P)throw Error("Invalid byte index");var g=255&T[U];if(U++,(192&g)==128)return 63&g;throw Error("Invalid continuation byte")}function r(){var g,m,L,I,R;if(U>P)throw Error("Invalid byte index");if(U==P)return!1;if(g=255&T[U],U++,(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(),L=c(),R=(15&g)<<12|m<<6|L,R>=2048)return l(R),R;throw Error("Invalid continuation byte")}if((248&g)==240&&(m=c(),L=c(),I=c(),R=(15&g)<<18|m<<12|L<<6|I,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function n(g){T=h(g),P=T.length,U=0;for(var m,L=[];(m=r())!==!1;)L.push(m);return f(L)}var p=typeof e=="object"&&e,y=typeof t=="object"&&t&&t.exports==p&&t,v=typeof s=="object"&&s;(v.global===v||v.window===v)&&(o=v);var T,P,U,q=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 s=/^[\],:{}\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):s.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(s){var o="";for(var h in s)s.hasOwnProperty(h)&&(o.length&&(o+="&"),o+=encodeURIComponent(h)+"="+encodeURIComponent(s[h]));return o},e.decode=function(s){for(var o={},h=s.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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["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[s[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 s=function(){return self}(),o=s.WebSocket||s.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function s(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=s}).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(s,o){if(e)return s.indexOf(o);for(var h=0;h<s.length;++h)if(s[h]===o)return h;return-1}},{}],41:[function(a,t,e){var s=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var h=[];for(var f in o)s.call(o,f)&&h.push(f);return h},e.values=function(o){var h=[];for(var f in o)s.call(o,f)&&h.push(o[f]);return h},e.merge=function(o,h){for(var f in h)s.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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["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[s[l]]=h[l]||"";return f}},{}],43:[function(a,t,e){(function(s){var o=a("isarray"),h=a("./is-buffer");e.deconstructPacket=function(f){function l(c){if(!c)return c;if(h(c)){var r={_placeholder:!0,num:d.length};return d.push(c),r}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 r in i)i[r]=d(i[r]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,l){function d(c,r,n){if(!c)return c;if(s.Blob&&c instanceof Blob||s.File&&c instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[r]=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 s(){}function o(y){var v="",T=!1;return v+=y.type,(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)&&(v+=y.attachments,v+="-"),y.nsp&&y.nsp!="/"&&(T=!0,v+=y.nsp),y.id!=null&&(T&&(v+=",",T=!1),v+=y.id),y.data!=null&&(T&&(v+=","),v+=c.stringify(y.data)),u("encoded %j as %s",y,v),v}function h(y,v){function T(P){var U=n.deconstructPacket(P),q=o(U.packet),O=U.buffers;O.unshift(q),v(O)}n.removeBlobs(y,T)}function f(){this.reconstructor=null}function l(y){var v={},T=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 P="";y.charAt(++T)!="-"&&(P+=y.charAt(T),T!=y.length););if(P!=Number(P)||y.charAt(T)!="-")throw new Error("Illegal attachments");v.attachments=Number(P)}if(y.charAt(T+1)=="/")for(v.nsp="";++T;){var U=y.charAt(T);if(U==","||(v.nsp+=U,T==y.length))break}else v.nsp="/";var q=y.charAt(T+1);if(q!==""&&Number(q)==q){for(v.id="";++T;){var U=y.charAt(T);if(U==null||Number(U)!=U){--T;break}if(v.id+=y.charAt(T),T==y.length)break}v.id=Number(v.id)}if(y.charAt(++T))try{v.data=c.parse(y.substr(T))}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"),r=(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=s,e.Decoder=f,s.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 T=o(y);v([T])}},r(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 s(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=s}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(s){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 w,D='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var S=u.stringify,x=typeof S=="function"&&c;if(x){(w=function(){return 1}).toJSON=w;try{x=S(0)==="0"&&S(new Number)==="0"&&S(new String)=='""'&&S(d)===l&&S(l)===l&&S()===l&&S(w)==="1"&&S([w])=="[1]"&&S([l])=="[null]"&&S(null)=="null"&&S([l,d,null])=="[null,null,null]"&&S({a:[w,!0,!1,null,`\0\b
|
|
8
|
+
\f\r `]})==D&&S(null,w)==="1"&&S([1,2],null,1)==`[
|
|
9
9
|
1,
|
|
10
10
|
2
|
|
11
|
-
]`&&S(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&S(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&S(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&S(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{x=!1}}
|
|
12
|
-
`+x+
|
|
11
|
+
]`&&S(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&S(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&S(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&S(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{x=!1}}_=x}if(E=="json-parse"){var B=u.parse;if(typeof B=="function")try{if(B("0")===0&&!B(!1)){w=B(D);var N=w.a.length==5&&w.a[0]===1;if(N){try{N=!B('" "')}catch{}if(N)try{N=B("01")!==1}catch{}if(N)try{N=B("1.")!==1}catch{}}}}catch{N=!1}_=N}}return o[E]=!!_}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=s.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 r="[object Function]",n="[object Date]",p="[object Number]",y="[object String]",v="[object Array]",T="[object Boolean]",P=o("bug-string-char-index");if(!c)var U=Math.floor,q=[0,31,59,90,120,151,181,212,243,273,304,334],O=function(E,_){return q[_]+365*(E-1970)+U((E-1969+(_=+(_>1)))/4)-U((E-1901+_)/100)+U((E-1601+_)/400)};(h={}.hasOwnProperty)||(h=function(E){var _,w={};return(w.__proto__=null,w.__proto__={toString:1},w).toString!=d?h=function(D){var S=this.__proto__,x=D in(this.__proto__=null,this);return this.__proto__=S,x}:(_=w.constructor,h=function(D){var S=(this.constructor||_).prototype;return D in this&&!(D in S&&this[D]===S[D])}),w=null,h.call(this,E)});var C={boolean:1,number:1,string:1,undefined:1},b=function(E,_){var w=typeof E[_];return w=="object"?!!E[_]:!C[w]};if(f=function(E,_){var w,D,S,x=0;(w=function(){this.valueOf=0}).prototype.valueOf=0,D=new w;for(S in D)h.call(D,S)&&x++;return w=D=null,x?f=x==2?function(B,N){var M,z={},Y=d.call(B)==r;for(M in B)Y&&M=="prototype"||h.call(z,M)||!(z[M]=1)||!h.call(B,M)||N(M)}:function(B,N){var M,z,Y=d.call(B)==r;for(M in B)Y&&M=="prototype"||!h.call(B,M)||(z=M==="constructor")||N(M);(z||h.call(B,M="constructor"))&&N(M)}:(D=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],f=function(B,N){var M,z,Y=d.call(B)==r,Q=!Y&&typeof B.constructor!="function"&&b(B,"hasOwnProperty")?B.hasOwnProperty:h;for(M in B)Y&&M=="prototype"||!Q.call(B,M)||N(M);for(z=D.length;M=D[--z];Q.call(B,M)&&N(M));}),f(E,_)},!o("json-stringify")){var A={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},g="000000",m=function(E,_){return(g+(_||0)).slice(-E)},L="\\u00",I=function(E){var _,w='"',D=0,S=E.length,x=S>10&&P;for(x&&(_=E.split(""));S>D;D++){var B=E.charCodeAt(D);switch(B){case 8:case 9:case 10:case 12:case 13:case 34:case 92:w+=A[B];break;default:if(32>B){w+=L+m(2,B.toString(16));break}w+=x?_[D]:P?E.charAt(D):E[D]}}return w+'"'},R=function(E,_,w,D,S,x,B){var N,M,z,Y,Q,ie,de,ye,ve,ge,te,me,le,ae,ke,Se;try{N=_[E]}catch{}if(typeof N=="object"&&N)if(M=d.call(N),M!=n||h.call(N,"toJSON"))typeof N.toJSON=="function"&&(M!=p&&M!=y&&M!=v||h.call(N,"toJSON"))&&(N=N.toJSON(E));else if(N>-1/0&&1/0>N){if(O){for(Q=U(N/864e5),z=U(Q/365.2425)+1970-1;O(z+1,0)<=Q;z++);for(Y=U((Q-O(z,0))/30.42);O(z,Y+1)<=Q;Y++);Q=1+Q-O(z,Y),ie=(N%864e5+864e5)%864e5,de=U(ie/36e5)%24,ye=U(ie/6e4)%60,ve=U(ie/1e3)%60,ge=ie%1e3}else z=N.getUTCFullYear(),Y=N.getUTCMonth(),Q=N.getUTCDate(),de=N.getUTCHours(),ye=N.getUTCMinutes(),ve=N.getUTCSeconds(),ge=N.getUTCMilliseconds();N=(0>=z||z>=1e4?(0>z?"-":"+")+m(6,0>z?-z:z):m(4,z))+"-"+m(2,Y+1)+"-"+m(2,Q)+"T"+m(2,de)+":"+m(2,ye)+":"+m(2,ve)+"."+m(3,ge)+"Z"}else N=null;if(w&&(N=w.call(_,E,N)),N===null)return"null";if(M=d.call(N),M==T)return""+N;if(M==p)return N>-1/0&&1/0>N?""+N:"null";if(M==y)return I(""+N);if(typeof N=="object"){for(ae=B.length;ae--;)if(B[ae]===N)throw TypeError();if(B.push(N),te=[],ke=x,x+=S,M==v){for(le=0,ae=N.length;ae>le;le++)me=R(le,N,w,D,S,x,B),te.push(me===l?"null":me);Se=te.length?S?`[
|
|
12
|
+
`+x+te.join(`,
|
|
13
13
|
`+x)+`
|
|
14
|
-
`+ke+"]":"["+
|
|
15
|
-
`+x+
|
|
14
|
+
`+ke+"]":"["+te.join(",")+"]":"[]"}else f(D||N,function(Ce){var De=R(Ce,N,w,D,S,x,B);De!==l&&te.push(I(Ce)+":"+(S?" ":"")+De)}),Se=te.length?S?`{
|
|
15
|
+
`+x+te.join(`,
|
|
16
16
|
`+x)+`
|
|
17
|
-
`+ke+"}":"{"+
|
|
18
|
-
`,102:"\f",114:"\r"},V=function(){throw k=G=null,SyntaxError()},W=function(){for(var E,O,T,D,S,x=G,B=x.length;B>k;)switch(S=x.charCodeAt(k)){case 9:case 10:case 13:case 32:k++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=P?x.charAt(k):x[k],k++,E;case 34:for(E="@",k++;B>k;)if(S=x.charCodeAt(k),32>S)V();else if(S==92)switch(S=x.charCodeAt(++k)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=J[S],k++;break;case 117:for(O=++k,T=k+4;T>k;k++)S=x.charCodeAt(k),S>=48&&57>=S||S>=97&&102>=S||S>=65&&70>=S||V();E+=$("0x"+x.slice(O,k));break;default:V()}else{if(S==34)break;for(S=x.charCodeAt(k),O=k;S>=32&&S!=92&&S!=34;)S=x.charCodeAt(++k);E+=x.slice(O,k)}if(x.charCodeAt(k)==34)return k++,E;V();default:if(O=k,S==45&&(D=!0,S=x.charCodeAt(++k)),S>=48&&57>=S){for(S==48&&(S=x.charCodeAt(k+1),S>=48&&57>=S)&&V(),D=!1;B>k&&(S=x.charCodeAt(k),S>=48&&57>=S);k++);if(x.charCodeAt(k)==46){for(T=++k;B>T&&(S=x.charCodeAt(T),S>=48&&57>=S);T++);T==k&&V(),k=T}if(S=x.charCodeAt(k),S==101||S==69){for(S=x.charCodeAt(++k),(S==43||S==45)&&k++,T=k;B>T&&(S=x.charCodeAt(T),S>=48&&57>=S);T++);T==k&&V(),k=T}return+x.slice(O,k)}if(D&&V(),x.slice(k,k+4)=="true")return k+=4,!0;if(x.slice(k,k+5)=="false")return k+=5,!1;if(x.slice(k,k+4)=="null")return k+=4,null;V()}return"$"},oe=function(E){var O,T;if(E=="$"&&V(),typeof E=="string"){if((P?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(O=[];E=W(),E!="]";T||(T=!0))T&&(E==","?(E=W(),E=="]"&&V()):V()),E==","&&V(),O.push(oe(E));return O}if(E=="{"){for(O={};E=W(),E!="}";T||(T=!0))T&&(E==","?(E=W(),E=="}"&&V()):V()),(E==","||typeof E!="string"||(P?E.charAt(0):E[0])!="@"||W()!=":")&&V(),O[E.slice(1)]=oe(W());return O}V()}return E},Ue=function(E,O,T){var D=Be(E,O,T);D===l?delete E[O]:E[O]=D},Be=function(E,O,T){var D,S=E[O];if(typeof S=="object"&&S)if(d.call(S)==g)for(D=S.length;D--;)Ue(S,D,T);else f(S,function(x){Ue(S,x,T)});return T.call(E,O,S)};u.parse=function(E,O){var T,D;return k=0,G=""+E,T=oe(W()),W()!="$"&&V(),k=G=null,O&&d.call(O)==r?Be((D={},D[""]=T,D),"",O):T}}}})(this)},{}],48:[function(a,t){function e(s,o){var h=[];o=o||0;for(var f=o||0;f<s.length;f++)h[f-o]=s[f];return h}t.exports=e},{}]},{},[1])(1)}const $e=Object.assign({"./v1_3_7.js":Object.freeze(Object.defineProperty({__proto__:null,default:Ge},Symbol.toStringTag,{value:"Module"}))}),ze=/v\d+_\d+_\d+/;function Je(a){return typeof a=="function"}const ue=Object.entries($e).reduce((a,t)=>{var o;const e=t[1].default,s=(o=t[0].match(ze))==null?void 0:o[0];return Je(e)&&s&&(a[s]=e()),a},{}),Ae=a=>{if(a in ue)return ue[a];throw new Error(`Socket version ${a} not found`)},We={...ue,getSocketVersion:Ae,makeSocketVersion:(a,...t)=>Ae(a)(...t)};var Ne=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Ne||{}),Le=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(Le||{}),re=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(re||{}),Oe=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(Oe||{}),_e=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(_e||{}),Re=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(Re||{}),j=(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))(j||{}),pe=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(pe||{}),Ie=(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))(Ie||{}),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 s,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const h=this.mapExtensionData(t,t.data);return e===pe.HANGUP?s={...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}})}}:s={...t,data:{...h,currentCall:o,calls:(l=t.data.calls)==null?void 0:l.map(d=>this.mapExtensionCall(t,d))},reason:e},s}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var s;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(s=e.calls)==null?void 0:s.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(s=>this.mapQueueCall(t,s))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,s){t[e]=s}static configureUTCForObject(t,e,s,o){const h=(s-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 r=(c-o*60)*1e3;this.assignProperty(l,`${u}_UTC`,r),this.assignProperty(l,`${u}_UTC_CLIENT`,r+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))(fe||{});class He{constructor(t){K(this,"io");K(this,"ioFunction");K(this,"lastEventTimestamp",new Date().getTime());K(this,"doReconnect",!0);K(this,"keepAliveInterval");K(this,"keepReconnectInterval");K(this,"keepReconnectTimeout");K(this,"connected",!1);K(this,"reconnectionTime",20);this.eventsSdkClass=t,this.eventsSdkClass=t,typeof window<"u"&&(window.addEventListener("offline",()=>{this.closeAllConnections()}),window.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(te.NEXT)},5e3)})),typeof self<"u"&&typeof window>"u"&&typeof global>"u"&&(self.addEventListener("offline",()=>{this.closeAllConnections()}),self.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(te.NEXT)},5e3)}))}getSocketIoFunction(t){const e=t.split("v="),s="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=We.getSocketVersion(s)}initSocketConnection(){const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,s=this.eventsSdkClass.server;try{const o=s?s.Domain:this.eventsSdkClass.URL,h=s?`${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.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{attemptToConnect:h,connectionStatus:re.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url no defined")}catch(o){this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval)}initKeepAlive(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveInterval=setInterval(async()=>{if(new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.eventsSdkClass.authClass.token){this.eventsSdkClass.emit(fe.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit();return}},this.eventsSdkClass.options.keepAliveTimeout)}closeAllConnections(){var t;this.io&&(this.io.close(),(t=this.io)==null||t.disconnect(),this.io=void 0),this.eventsSdkClass.loggerClass.stop(),se.clearSessionStorage()}initSocketEvents(){this.io&&this.io.on(j.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,j.LOGIN_SUCCESS)).on(j.QUEUE_EVENT,t=>this.onQueueEvent(t,j.QUEUE_EVENT)).on(j.EXTENSION_EVENT,t=>this.onExtensionEvent(t,j.EXTENSION_EVENT)).on(j.DIALER_EVENT,t=>this.onDialerEvent(t,j.DIALER_EVENT)).on(j.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,j.LOGIN_STATUS)).on(j.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,j.ALL_EXTENSION_STATUS)).on(j.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,j.ALL_DIALER_STATUS)).on(j.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(j.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,j.EXTENSIONS_UPDATED)).on(j.CONNECT,()=>this.onConnect()).on(j.DISCONNECT,t=>this.onDisconnect(t)).on(j.CONNECT_ERROR_EVENT,t=>this.onConnectError(t))}onLoginSuccessEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapQueueEvent(t))}onExtensionEvent(t,e){const s=ce.mapExtensionEvent(t);s&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,s))}onDialerEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){const s=ce.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,s)}onAllDialerStatus(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.initSocketConnection();return}this.connected?this.lastEventTimestamp=new Date().getTime():this.initSocketConnection()}onExtensionsUpdatedEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connected=!0,this.keepReconnectInterval&&clearInterval(this.keepReconnectInterval),this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:re.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}onDisconnect(t){this.connected=!1,this.doReconnect&&(this.closeAllConnections(),this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?re.TRYING_TO_CONNECT:re.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkDisconnect([t]),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>120&&(this.reconnectionTime=20),this.eventsSdkClass.connect(te.NEXT)},this.reconnectionTime*1e3))}onConnectError(t){this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?re.TRYING_TO_CONNECT:re.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>60&&(this.reconnectionTime=20),this.eventsSdkClass.connect(te.NEXT)},this.reconnectionTime*1e3)}}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(console.log("IN SDK METHOD LOG 1",{data:t,useLogger:this.eventsSdkClass.options.useLogger}),this.eventsSdkClass.options.useLogger)if(console.log("IN SDK METHOD LOG 2",{storageLogger:this.storageLogger,LEVEL:t.Level}),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,s,o){this.log({Message:`External login request error with the login type ${t} ${t===Z.TOKEN?s: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,s){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${s}`,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 s={[ee.FULL]:[],[ee.BOOTSTRAP]:[j.LOGIN_STATUS,j.LOGIN_SUCCESS,j.ALL_EXTENSION_STATUS,j.ALL_DIALER_STATUS],[ee.DEBUG_EXTENSIONS]:[j.ALL_EXTENSION_STATUS,j.EXTENSION_EVENT,j.EXTENSIONS_UPDATED],[ee.DEBUG_DIALER]:[j.ALL_DIALER_STATUS,j.DIALER_EVENT],[ee.DEBUG_QUEUE]:[j.QUEUE_EVENT]};console.log("IN SDK METHOD EVENT LOG",{debugOptions:this.eventsSdkClass.options.debugOption}),this.eventsSdkClass.options.debugOption&&(console.log("IN SDK METHOD EVENT LOG 2",{includes:s[this.eventsSdkClass.options.debugOption].includes(t),isFull:this.eventsSdkClass.options.debugOption===ee.FULL,willLog:s[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===ee.FULL}),(s[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===ee.FULL)&&(console.log("IN SDK METHOD EVENT LOG 3","LOGGING EVENT"),this.log({Message:`Event name: ${t}`,Body:e,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:F.LevelEnum.DEBUG,LogType:F.LogTypeEnum.INFO})))}}class Qe{constructor(t){K(this,"listeners",{[j.ALL_EXTENSION_STATUS]:[],[j.ALL_DIALER_STATUS]:[],[j.ALL_USERS_STATUS]:[],[j.QUEUE_EVENT]:[],[j.EXTENSION_EVENT]:[],[j.DIALER_EVENT]:[],[j.LOGIN_SUCCESS]:[],[j.LOGIN_STATUS]:[],[j.KEEP_ALIVE_RESPONSE]:[],[j.ONLINE_STATUS_EVENT]:[],[j.EXTENSIONS_UPDATED]:[]});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(s=>s!==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 s={name:t,data:e};this.allListeners.forEach(o=>o(s))}}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 Ke(this));K(this,"socketIoClass",new He(this));K(this,"loggerClass",new Ye(this));K(this,"eventEmitterClass",new Qe(this));K(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,s)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof s=="object"&&s!==null){if(t.has(s))return;t.add(s)}return s}}});this.options={...Xe,...t}}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===te.MAIN&&this.findMainServer(),t===te.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initSocketEvents(),this.socketIoClass.initKeepAlive()}async disconnect(){this.socketIoClass.doReconnect=!1,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,s)=>s.Priority>e.Priority?s: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}}X.CallStatusEnum=Ne,X.CallTypeEnum=Le,X.ConnectionStatusEnum=re,X.DebugOption=ee,X.DialerTypeEnum=Oe,X.DirectionEnum=_e,X.DoNotCallMeStatusCodeEnum=Re,X.EventsEnum=j,X.ExtensionEventReasonEnum=pe,X.ExtensionHangupCauseEnum=Ie,X.LoginType=Z,X.QueueEventReasonEnum=xe,X.ServerListenerEventsEnum=fe,X.ServerParameter=te,X.default=Ze,Object.defineProperties(X,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
17
|
+
`+ke+"}":"{"+te.join(",")+"}":"{}";return B.pop(),Se}};u.stringify=function(E,_,w){var D,S,x,B;if(typeof _=="function"||typeof _=="object"&&_){if((B=d.call(_))==r)S=_;else if(B==v){x={};for(var N,M=0,z=_.length;z>M;N=_[M++],B=d.call(N),(B==y||B==p)&&(x[N]=1));}}if(w)if((B=d.call(w))==p){if((w-=w%1)>0)for(D="",w>10&&(w=10);D.length<w;D+=" ");}else B==y&&(D=w.length<=10?w:w.slice(0,10));return R("",(N={},N[""]=E,N),S,x,D,"",[])}}if(!o("json-parse")){var k,$,G=String.fromCharCode,J={92:"\\",34:'"',47:"/",98:"\b",116:" ",110:`
|
|
18
|
+
`,102:"\f",114:"\r"},X=function(){throw k=$=null,SyntaxError()},W=function(){for(var E,_,w,D,S,x=$,B=x.length;B>k;)switch(S=x.charCodeAt(k)){case 9:case 10:case 13:case 32:k++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=P?x.charAt(k):x[k],k++,E;case 34:for(E="@",k++;B>k;)if(S=x.charCodeAt(k),32>S)X();else if(S==92)switch(S=x.charCodeAt(++k)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=J[S],k++;break;case 117:for(_=++k,w=k+4;w>k;k++)S=x.charCodeAt(k),S>=48&&57>=S||S>=97&&102>=S||S>=65&&70>=S||X();E+=G("0x"+x.slice(_,k));break;default:X()}else{if(S==34)break;for(S=x.charCodeAt(k),_=k;S>=32&&S!=92&&S!=34;)S=x.charCodeAt(++k);E+=x.slice(_,k)}if(x.charCodeAt(k)==34)return k++,E;X();default:if(_=k,S==45&&(D=!0,S=x.charCodeAt(++k)),S>=48&&57>=S){for(S==48&&(S=x.charCodeAt(k+1),S>=48&&57>=S)&&X(),D=!1;B>k&&(S=x.charCodeAt(k),S>=48&&57>=S);k++);if(x.charCodeAt(k)==46){for(w=++k;B>w&&(S=x.charCodeAt(w),S>=48&&57>=S);w++);w==k&&X(),k=w}if(S=x.charCodeAt(k),S==101||S==69){for(S=x.charCodeAt(++k),(S==43||S==45)&&k++,w=k;B>w&&(S=x.charCodeAt(w),S>=48&&57>=S);w++);w==k&&X(),k=w}return+x.slice(_,k)}if(D&&X(),x.slice(k,k+4)=="true")return k+=4,!0;if(x.slice(k,k+5)=="false")return k+=5,!1;if(x.slice(k,k+4)=="null")return k+=4,null;X()}return"$"},oe=function(E){var _,w;if(E=="$"&&X(),typeof E=="string"){if((P?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(_=[];E=W(),E!="]";w||(w=!0))w&&(E==","?(E=W(),E=="]"&&X()):X()),E==","&&X(),_.push(oe(E));return _}if(E=="{"){for(_={};E=W(),E!="}";w||(w=!0))w&&(E==","?(E=W(),E=="}"&&X()):X()),(E==","||typeof E!="string"||(P?E.charAt(0):E[0])!="@"||W()!=":")&&X(),_[E.slice(1)]=oe(W());return _}X()}return E},Ue=function(E,_,w){var D=Be(E,_,w);D===l?delete E[_]:E[_]=D},Be=function(E,_,w){var D,S=E[_];if(typeof S=="object"&&S)if(d.call(S)==v)for(D=S.length;D--;)Ue(S,D,w);else f(S,function(x){Ue(S,x,w)});return w.call(E,_,S)};u.parse=function(E,_){var w,D;return k=0,$=""+E,w=oe(W()),W()!="$"&&X(),k=$=null,_&&d.call(_)==r?Be((D={},D[""]=w,D),"",_):w}}}})(this)},{}],48:[function(a,t){function e(s,o){var h=[];o=o||0;for(var f=o||0;f<s.length;f++)h[f-o]=s[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,s=(o=t[0].match(ze))==null?void 0:o[0];return Je(e)&&s&&(a[s]=e()),a},{}),Ae=a=>{if(a in ue)return ue[a];throw new Error(`Socket version ${a} not found`)},We={...ue,getSocketVersion:Ae,makeSocketVersion:(a,...t)=>Ae(a)(...t)};var Ne=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Ne||{}),Le=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(Le||{}),re=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(re||{}),_e=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(_e||{}),Oe=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(Oe||{}),Re=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(Re||{}),j=(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))(j||{}),pe=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(pe||{}),Ie=(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))(Ie||{}),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 s,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const h=this.mapExtensionData(t,t.data);return e===pe.HANGUP?s={...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}})}}:s={...t,data:{...h,currentCall:o,calls:(l=t.data.calls)==null?void 0:l.map(d=>this.mapExtensionCall(t,d))},reason:e},s}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var s;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(s=e.calls)==null?void 0:s.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(s=>this.mapQueueCall(t,s))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,s){t[e]=s}static configureUTCForObject(t,e,s,o){const h=(s-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 r=(c-o*60)*1e3;this.assignProperty(l,`${u}_UTC`,r),this.assignProperty(l,`${u}_UTC_CLIENT`,r+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))(fe||{});class He{constructor(t){V(this,"io");V(this,"ioFunction");V(this,"lastEventTimestamp",new Date().getTime());V(this,"doReconnect",!0);V(this,"keepAliveInterval");V(this,"keepReconnectInterval");V(this,"keepReconnectTimeout");V(this,"connected",!1);V(this,"reconnectionTime",20);this.eventsSdkClass=t,this.eventsSdkClass=t,typeof window<"u"&&(window.addEventListener("offline",()=>{this.closeAllConnections()}),window.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(ee.NEXT)},5e3)})),typeof self<"u"&&typeof window>"u"&&typeof global>"u"&&(self.addEventListener("offline",()=>{this.closeAllConnections()}),self.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(ee.NEXT)},5e3)}))}getSocketIoFunction(t){const e=t.split("v="),s="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=We.getSocketVersion(s)}initSocketConnection(){const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,s=this.eventsSdkClass.server;try{const o=s?s.Domain:this.eventsSdkClass.URL,h=s?`${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.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{attemptToConnect:h,connectionStatus:re.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url no defined")}catch(o){this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval)}initKeepAlive(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveInterval=setInterval(async()=>{if(new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.eventsSdkClass.authClass.token){this.eventsSdkClass.emit(fe.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit();return}},this.eventsSdkClass.options.keepAliveTimeout)}closeAllConnections(){var t;this.io&&(this.io.close(),(t=this.io)==null||t.disconnect(),this.io=void 0),this.eventsSdkClass.loggerClass.stop(),se.clearSessionStorage()}initSocketEvents(){this.io&&this.io.on(j.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,j.LOGIN_SUCCESS)).on(j.QUEUE_EVENT,t=>this.onQueueEvent(t,j.QUEUE_EVENT)).on(j.EXTENSION_EVENT,t=>this.onExtensionEvent(t,j.EXTENSION_EVENT)).on(j.DIALER_EVENT,t=>this.onDialerEvent(t,j.DIALER_EVENT)).on(j.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,j.LOGIN_STATUS)).on(j.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,j.ALL_EXTENSION_STATUS)).on(j.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,j.ALL_DIALER_STATUS)).on(j.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(j.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,j.EXTENSIONS_UPDATED)).on(j.CONNECT,()=>this.onConnect()).on(j.DISCONNECT,t=>this.onDisconnect(t)).on(j.CONNECT_ERROR_EVENT,t=>this.onConnectError(t))}onLoginSuccessEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapQueueEvent(t))}onExtensionEvent(t,e){const s=ce.mapExtensionEvent(t);s&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,s))}onDialerEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){const s=ce.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,s)}onAllDialerStatus(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.initSocketConnection();return}this.connected?this.lastEventTimestamp=new Date().getTime():this.initSocketConnection()}onExtensionsUpdatedEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connected=!0,this.keepReconnectInterval&&clearInterval(this.keepReconnectInterval),this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:re.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}onDisconnect(t){this.connected=!1,this.doReconnect&&(this.closeAllConnections(),this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?re.TRYING_TO_CONNECT:re.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkDisconnect([t]),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>120&&(this.reconnectionTime=20),this.eventsSdkClass.connect(ee.NEXT)},this.reconnectionTime*1e3))}onConnectError(t){this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?re.TRYING_TO_CONNECT:re.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>60&&(this.reconnectionTime=20),this.eventsSdkClass.connect(ee.NEXT)},this.reconnectionTime*1e3)}}class Ye{constructor(t){V(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,s,o){this.log({Message:`External login request error with the login type ${t} ${t===Z.TOKEN?s: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,s){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${s}`,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 s={[ne.FULL]:[],[ne.BOOTSTRAP]:[j.LOGIN_STATUS,j.LOGIN_SUCCESS,j.ALL_EXTENSION_STATUS,j.ALL_DIALER_STATUS],[ne.DEBUG_EXTENSIONS]:[j.ALL_EXTENSION_STATUS,j.EXTENSION_EVENT,j.EXTENSIONS_UPDATED],[ne.DEBUG_DIALER]:[j.ALL_DIALER_STATUS,j.DIALER_EVENT],[ne.DEBUG_QUEUE]:[j.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(s[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===ne.FULL)&&this.log({Message:`Event name: ${t}`,Body:e,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:F.LevelEnum.DEBUG,LogType:F.LogTypeEnum.INFO})}}class Qe{constructor(t){V(this,"listeners",{[j.ALL_EXTENSION_STATUS]:[],[j.ALL_DIALER_STATUS]:[],[j.ALL_USERS_STATUS]:[],[j.QUEUE_EVENT]:[],[j.EXTENSION_EVENT]:[],[j.DIALER_EVENT]:[],[j.LOGIN_SUCCESS]:[],[j.LOGIN_STATUS]:[],[j.KEEP_ALIVE_RESPONSE]:[],[j.ONLINE_STATUS_EVENT]:[],[j.EXTENSIONS_UPDATED]:[]});V(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(s=>s!==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 s={name:t,data:e};this.allListeners.forEach(o=>o(s))}}class Ze{constructor(t){V(this,"options");V(this,"servers",[]);V(this,"URLList",[]);V(this,"server");V(this,"URL");V(this,"socket");V(this,"mainServer");V(this,"alreadyAttemptedOtherServers",[]);V(this,"authClass",new Ve(this));V(this,"socketIoClass",new He(this));V(this,"loggerClass",new Ye(this));V(this,"eventEmitterClass",new Qe(this));V(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,s)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof s=="object"&&s!==null){if(t.has(s))return;t.add(s)}return s}}});this.options={...Ke,...t}}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===ee.MAIN&&this.findMainServer(),t===ee.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initSocketEvents(),this.socketIoClass.initKeepAlive()}async disconnect(){this.socketIoClass.doReconnect=!1,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,s)=>s.Priority>e.Priority?s: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}}K.CallStatusEnum=Ne,K.CallTypeEnum=Le,K.ConnectionStatusEnum=re,K.DebugOption=ne,K.DialerTypeEnum=_e,K.DirectionEnum=Oe,K.DoNotCallMeStatusCodeEnum=Re,K.EventsEnum=j,K.ExtensionEventReasonEnum=pe,K.ExtensionHangupCauseEnum=Ie,K.LoginType=Z,K.QueueEventReasonEnum=xe,K.ServerListenerEventsEnum=fe,K.ServerParameter=ee,K.default=Ze,Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
19
19
|
//# sourceMappingURL=voicenter-events-sdk.umd.js.map
|