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