UNPKG

ecentrix-voip

Version:

package ecentrix8 telephony agent, call center, telemarketing, omnichannel, collection system

2 lines 415 kB
/*! For license information please see evoip-sdk.module.js.LICENSE.txt */ (()=>{var e={9695:(e,t,n)=>{var r=n(6752);e.exports=function(e,t,n){var i,o=t,s={autoplay:!0,mirror:!1,muted:!1,audio:!1,disableContextMenu:!1};if(n)for(i in n)s[i]=n[i];return o?"audio"===o.tagName.toLowerCase()&&(s.audio=!0):o=document.createElement(s.audio?"audio":"video"),s.disableContextMenu&&(o.oncontextmenu=function(e){e.preventDefault()}),s.autoplay&&(o.autoplay="autoplay"),o.muted=!!s.muted,s.audio||["","moz","webkit","o","ms"].forEach((function(e){var t=e?e+"Transform":"transform";o.style[t]=s.mirror?"scaleX(-1)":"scaleX(1)"})),"safari"===r.browserDetails.browser&&o.setAttribute("playsinline",!0),o.srcObject=e,o}},5253:(e,t,n)=>{var r=n(8048).R;e.exports=r},8048:(e,t,n)=>{"use strict";n.d(t,{R:()=>at});var r={};n.r(r),n.d(r,{Decoder:()=>je,Encoder:()=>Me,PacketType:()=>Le,protocol:()=>De});var i=n(6540),o=n(5053),s=n.n(o);const a=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach((n=>n(t,e)))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},u=e=>e,l=e=>{const t=(e=>e?a(e):a)(e),n=e=>function(e,t=u){const n=i.useSyncExternalStore(e.subscribe,(()=>t(e.getState())),(()=>t(e.getInitialState())));return i.useDebugValue(n),n}(t,e);return Object.assign(n,t),n};var c,d=(c=function(e){return{count:0,setCount:function(t){return e({count:t})},increment:function(){return e((function(e){return{count:e.count+1}}))},decrement:function(){return e((function(e){return{count:e.count-1}}))},isLogin:!1,setLogin:function(t){return e({isLogin:t})},sessionID:null,setSessionID:function(t){return e({sessionID:t})},connectionID:null,setConnectionID:function(t){return e({connectionID:t})},dataLogin:null,setDataLogin:function(t){return e({dataLogin:t})},token:!1,setToken:function(t){return e({token:t})},chatDesign:null,setChatDesign:function(t){return e({chatDesign:t})},callSession:null,setCallSession:function(t){return e({callSession:t})},voipSession:null,setVoipSession:function(t){return e({voipSession:t})},responsePhone:"",setResponsePhone:function(t){return e({responsePhone:t})},holdCall:!1,setHoldCall:function(t){return e({holdCall:t})},muteCall:!1,setMuteCall:function(t){return e({muteCall:t})},showChat:!1,setShowChat:function(t){return e({showChat:t})},showAttachment:!1,setAttachment:function(t){return e({showAttachment:t})},showVideo:!1,setVideo:function(t){return e({showVideo:t})},showVoice:!1,setVoice:function(t){return e({showVoice:t})},getMessage:!1,setMessage:function(t){return e({getMessage:t})},getAudioList:!1,setAudioList:function(t){return e({getAudioList:t})},connection:!1,setConnection:function(t){return e({connection:t})},sipRegister:!1,setSipRegister:function(t){return e({sipRegister:t})},isIdle:!1,setIsIdle:function(t){return e({isIdle:t})},ecxSocket:!1,setEcxSocket:function(t){return e({ecxSocket:t})},ecxAgentId:null,setEcxAgentId:function(t){return e({ecxAgentId:t})},hours:0,minutes:0,seconds:0,resetTimer:function(){return e({hours:0,minutes:0,seconds:0})},incrementTime:function(){return e((function(e){var t=e.hours,n=e.minutes,r=e.seconds;return 59===r?(r=0,59===n?(n=0,t+=1):n+=1):r+=1,{hours:t,minutes:n,seconds:r}}))}}},c?l(c):l);function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{var n=document.getElementById("remoteVoice");if(!n)return void console.error("Element with id 'remoteVoice' not found.");n.pause(),n.loop=t,n.src=e,n.currentTime=0,setTimeout((function(){n.play().catch((function(e){console.error("Error during play:",e)}))}),100)}catch(e){console.log("playVoice >>>",e)}}function f(e){try{var t=document.querySelector("select#audioSource"),n=document.querySelector("select#audioOutput");t.innerHTML="",n.innerHTML="";var r=[t,n],i=r.map((function(e){return e.value}));r.forEach((function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}));for(var o=0;o!==e.length;++o){var s=e[o],a=document.createElement("option");a.value=s.deviceId,"audioinput"===s.kind?(a.text=s.label||"microphone ".concat(t.length+1),t.appendChild(a)):"audiooutput"===s.kind&&(a.text=s.label||"speaker ".concat(n.length+1),n.appendChild(a))}r.forEach((function(e,t){Array.prototype.slice.call(e.childNodes).some((function(e){return e.value===i[t]}))&&(e.value=i[t])}));try{var u=Array.from(t.options).map((function(e){return{value:e.value,label:e.text}}));d.getState().setAudioList(u),"function"==typeof ecxAudioList&&window.ecxAudioList(u)}catch(e){console.log(e)}}catch(e){console.log(e)}}function p(e){console.log("navigator.MediaDevices.getUserMedia error: ",e.message,e.name)}function _(e){var t=document.querySelector("remoteVoice");return window.stream=e,t.srcObject=e,navigator.mediaDevices.enumerateDevices()}function m(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";window.stream&&window.stream.getTracks().forEach((function(e){e.stop()}));var t={audio:{deviceId:e?{exact:e}:void 0}};navigator.mediaDevices.getUserMedia(t).then(_).then(f).catch(p)}var v=n(9695);function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,C(r.key),r)}}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(b=function(){return!!e})()}function T(e){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},T(e)}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function C(e){var t=function(e){if("object"!=g(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==g(t)?t:t+""}var E=function(e){function t(e,n,r){var i,o,a,u;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,n){return t=T(t),function(e,t){if(t&&("object"==g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,b()?Reflect.construct(t,n||[],T(e).constructor):t.apply(e,n))}(this,t,[e,n,r]),o=i,u=function(){d.getState().setLogin(!0)},(a=C(a="changeState"))in o?Object.defineProperty(o,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):o[a]=u,s().debug.disable("JsSIP:*"),i._localDetail,i._phone=null,i._session=null,i._uri="sip:"+e+"@"+r,i._ws="wss://"+r+":8189/asterisk/ws";var l=new(s().WebSocketInterface)(i._ws);return i._config={uri:i._uri+";transport=wss",contact_uri:i._uri+";transport=wss",password:n,ws_servers:i._ws,session_timers:!1,iceTransportPolicy:"all",rtcpMuxPolicy:"negotiate",rtcOfferConstraints:{offerToReceiveAudio:!0},mandatory:[{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},{DtlsSrtpKeyAgreement:!0}],realm:"ecentrix.net"},i._config.sockets=[l],i._phone=new(s().UA)(i._config),navigator.mediaDevices.enumerateDevices().then(f).catch(p),i.connect(),i.changeState(),i.state={message:d.getState().responsePhone},i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}(t,e),n=t,r=[{key:"componentDidMount",value:function(){console.log(">>> webphone componentDidMount <<< ")}},{key:"componentWillUnmount",value:function(){console.log(">>> webphone componentWillUnmount <<< ")}},{key:"connect",value:function(){var e=null;this._phone.on("connected",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("connected")})),this._phone.on("disconnected",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("disconnected")})),this._phone.on("registered",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("registered")})),this._phone.on("unregistered",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("unregistered")})),this._phone.on("registrationFailed",(function(e){"function"==typeof ecxPhoneState&&window.ecxPhoneState("registrationFailed",e)})),this._phone.on("newRTCSession",(function(t){var n=this;e=t.session,this._session&&this._session.terminate(),this._session=e,d.getState().setCallSession(this._session),this._session.isInProgress()&&"incoming"===this._session.direction&&(d.getState().setResponsePhone("ringing"),"function"==typeof ecxPhoneState&&window.ecxPhoneState("ringing")),this._session.isEstablished(),this._session.on("connecting",(function(e){var t;"function"==typeof ecxPhoneState&&window.ecxPhoneState("connecting with call_id ".concat(null===(t=e.request)||void 0===t?void 0:t.call_id)),d.getState().setResponsePhone("connecting")})),this._session.on("sdp",(function(e){})),this._session.on("icecandidate",(function(e){})),this._session.on("getusermediafailed",(function(e){console.log("session @getusermediafailed [error: %o]",e)})),this._session.on("peerconnection:createofferfailed",(function(e){console.log("session @peerconnection:createofferfailed [error: %o]",e)})),this._session.on("peerconnection:createanswerfailed",(function(e){console.log("session @peerconnection:createanswerfailed [error: %o]",e)})),this._session.on("peerconnection:setlocaldescriptionfailed",(function(e){console.log("session @peerconnection:setlocaldescriptionfailed [error: %o]",e)})),this._session.on("peerconnection:setremotedescriptionfailed",(function(e){console.log("session @peerconnection:setremotedescriptionfailed [error: %o]",e)})),this._session.on("ended",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("ended"),d.getState().setResponsePhone("ended"),setTimeout((function(){d.getState().setResponsePhone("ready"),"function"==typeof ecxPhoneState&&window.ecxPhoneState("ready")}),1e3),n._session=null,d.getState().setCallSession(null)})),this._session.on("failed",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("failed"),d.getState().setResponsePhone("failed"),n._session=null,d.getState().setCallSession(null)})),this._session.on("accepted",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("accepted"),n._session.isInProgress()&&(d.getState().setResponsePhone("ringing"),"function"==typeof ecxPhoneState&&window.ecxPhoneState("ringing")),n._session.isEstablished()&&(d.getState().setResponsePhone("establish"),"function"==typeof ecxPhoneState&&window.ecxPhoneState("establish")),n._session.isMuted().audio&&(d.getState().setResponsePhone("muted"),"function"==typeof ecxPhoneState&&window.ecxPhoneState("muted"))})),this._session.on("progress",(function(){"function"==typeof ecxPhoneState&&window.ecxPhoneState("progress"),d.getState().setResponsePhone("progress"),h("./voipSDK-v1.0/assets/ringtone.wav",!0)})),this._session.on("peerconnection",(function(e){"incoming"===n._session.direction&&(h("./voipSDK-v1.0/assets/ringtone.wav",!0),n._session.connection.addEventListener("addstream",(function(e){(0,v.attachMediaStream)(lStream,document.getElementById("localVoice"),{autoplay:!1,audio:!0})})))})),this._session.on("confirmed",(function(){var e;"function"==typeof ecxPhoneState&&window.ecxPhoneState("confirmed"),(e=document.getElementById("songs"))?(e.pause(),e.currentTime=0):console.error("Element with id 'songs' not found."),h("./voipSDK-v1.0/assets/answered.mp3",!1);try{n._session.connection.getReceivers().map((function(e){return e.track&&"audio"===e.track.kind&&e.track})).filter(Boolean);var t=n._session.connection.getReceivers().map((function(e){return e.track&&"audio"===e.track.kind&&e.track})),r=new MediaStream(t),i=document.getElementById("remoteVoice");i&&(i.srcObject=r,i.play().catch((function(e){return console.warn("Audio play failed:",e)}))),n._session.connection.addEventListener("track",(function(e){}))}catch(e){console.log(e)}})),this._session.on("addstream",(function(e){try{var t=n._session.connection.getLocalStreams();(0,v.attachMediaStream)(t,document.getElementById("localVoice"),{autoplay:!1,audio:!0}),e.stream&&(0,v.attachMediaStream)(e.stream,document.getElementById("remoteVoice"),{autoplay:!1,audio:!0})}catch(e){console.error(e)}}))})),this._phone.start(),d.getState().setVoipSession(this._phone)}}],r&&y(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(i.Component);class w extends Error{}function R(e,t){if("string"!=typeof e)throw new w("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,r=e.split(".")[n];if("string"!=typeof r)throw new w(`Invalid token specified: missing part #${n+1}`);let i;try{i=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}(r)}catch(e){throw new w(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new w(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}w.prototype.name="InvalidTokenError";const A=Object.create(null);A.open="0",A.close="1",A.ping="2",A.pong="3",A.message="4",A.upgrade="5",A.noop="6";const k=Object.create(null);Object.keys(A).forEach((e=>{k[A[e]]=e}));const O={type:"error",data:"parser error"},I="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),P="function"==typeof ArrayBuffer,x=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,N=({type:e,data:t},n,r)=>I&&t instanceof Blob?n?r(t):D(t,r):P&&(t instanceof ArrayBuffer||x(t))?n?r(t):D(new Blob([t]),r):r(A[e]+(t||"")),D=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function L(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let M;const U="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)U["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(e)]=e;const j="function"==typeof ArrayBuffer,q=(e,t)=>{if("string"!=typeof e)return{type:"message",data:H(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:F(e.substring(1),t)}:k[n]?e.length>1?{type:k[n],data:e.substring(1)}:{type:k[n]}:O},F=(e,t)=>{if(j){const n=(e=>{let t,n,r,i,o,s=.75*e.length,a=e.length,u=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),c=new Uint8Array(l);for(t=0;t<a;t+=4)n=U[e.charCodeAt(t)],r=U[e.charCodeAt(t+1)],i=U[e.charCodeAt(t+2)],o=U[e.charCodeAt(t+3)],c[u++]=n<<2|r>>4,c[u++]=(15&r)<<4|i>>2,c[u++]=(3&i)<<6|63&o;return l})(e);return H(n,t)}return{base64:!0,data:e}},H=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,B=String.fromCharCode(30);let G;function V(e){return e.reduce(((e,t)=>e+t.length),0)}function W(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function z(e){if(e)return function(e){for(var t in z.prototype)e[t]=z.prototype[t];return e}(e)}z.prototype.on=z.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},z.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},z.prototype.off=z.prototype.removeListener=z.prototype.removeAllListeners=z.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},z.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},z.prototype.emitReserved=z.prototype.emit,z.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},z.prototype.hasListeners=function(e){return!!this.listeners(e).length};const K="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),$="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Y(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const J=$.setTimeout,X=$.clearTimeout;function Q(e,t){t.useNativeTimers?(e.setTimeoutFn=J.bind($),e.clearTimeoutFn=X.bind($)):(e.setTimeoutFn=$.setTimeout.bind($),e.clearTimeoutFn=$.clearTimeout.bind($))}function Z(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class ee extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class te extends z{constructor(e){super(),this.writable=!1,Q(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new ee(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=q(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}class ne extends te{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(B),r=[];for(let e=0;e<n.length;e++){const i=q(n[e],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach(((e,o)=>{N(e,!1,(e=>{r[o]=e,++i===n&&t(r.join(B))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Z()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let re=!1;try{re="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const ie=re;function oe(){}class se extends ne{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}class ae extends z{constructor(e,t,n){super(),this.createRequest=e,Q(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var e;const t=Y(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn((()=>{this._onError("number"==typeof n.status?n.status:0)}),0))},n.send(this._data)}catch(e){return void this.setTimeoutFn((()=>{this._onError(e)}),0)}"undefined"!=typeof document&&(this._index=ae.requestsCount++,ae.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=oe,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ae.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}function ue(){for(let e in ae.requests)ae.requests.hasOwnProperty(e)&&ae.requests[e].abort()}ae.requestsCount=0,ae.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",ue):"function"==typeof addEventListener&&addEventListener("onpagehide"in $?"pagehide":"unload",ue,!1));const le=function(){const e=ce({xdomain:!1});return e&&null!==e.responseType}();function ce(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||ie))return new XMLHttpRequest}catch(e){}if(!t)try{return new($[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}const de="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class he extends te{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=de?{}:Y(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;N(n,this.supportsBinary,(e=>{try{this.doWrite(n,e)}catch(e){}r&&K((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Z()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const fe=$.WebSocket||$.MozWebSocket,pe={websocket:class extends he{createSocket(e,t,n){return de?new fe(e,t,n):t?new fe(e,t):new fe(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends te{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this._transport.ready.then((()=>{this._transport.createBidirectionalStream().then((e=>{const t=function(e,t){G||(G=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(V(n)<1)break;const e=W(n,1);o=!(128&~e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(V(n)<2)break;const e=W(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(V(n)<8)break;const e=W(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(O);break}i=o*Math.pow(2,32)+t.getUint32(4),r=3}else{if(V(n)<i)break;const e=W(n,i);a.enqueue(q(o?e:G.decode(e),t)),r=0}if(0===i||i>e){a.enqueue(O);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=new TransformStream({transform(e,t){!function(e,t){I&&e.data instanceof Blob?e.data.arrayBuffer().then(L).then(t):P&&(e.data instanceof ArrayBuffer||x(e.data))?t(L(e.data)):N(e,!1,(e=>{M||(M=new TextEncoder),t(M.encode(e))}))}(e,(n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)}))}});r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{n.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then((()=>this.onOpen()))}))}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this._writer.write(n).then((()=>{r&&K((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends se{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=le&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new ae(ce,this.uri(),e)}}},_e=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,me=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ve(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=_e.exec(e||""),o={},s=14;for(;s--;)o[me[s]]=i[s]||"";return-1!=n&&-1!=r&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,o.path),o.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(n[t]=r)})),n}(0,o.query),o}const ge="function"==typeof addEventListener&&"function"==typeof removeEventListener,ye=[];ge&&addEventListener("offline",(()=>{ye.forEach((e=>e()))}),!1);class be extends z{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=ve(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=ve(t.host).host);Q(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach((e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e})),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),ge&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ye.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);const e=this.opts.rememberUpgrade&&be.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",(e=>this._onClose("transport close",e)))}onOpen(){this.readyState="open",be.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn((()=>{this._onClose("ping timeout")}),e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let n=0;n<this.writeBuffer.length;n++){const r=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this._maxPayload)return this.writeBuffer.slice(0,n);e+=2}var t;return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,K((()=>{this._onClose("ping timeout")}),this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}_onError(e){if(be.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ge&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=ye.indexOf(this._offlineEventListener);-1!==e&&ye.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}be.protocol=4;class Te extends be{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;be.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;be.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{n||"closed"!==this.readyState&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){n||(n=!0,l(),t.close(),t=null)}const o=e=>{const n=new Error("probe error: "+e);n.transport=t.name,i(),this.emitReserved("upgradeError",n)};function s(){o("transport closed")}function a(){o("socket closed")}function u(e){t&&e.name!==t.name&&i()}const l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",u)};t.once("open",r),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",u),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}class Se extends Te{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map((e=>pe[e])).filter((e=>!!e))),super(e,n)}}const Ce="function"==typeof ArrayBuffer,Ee=Object.prototype.toString,we="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Ee.call(Blob),Re="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Ee.call(File);function Ae(e){return Ce&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||we&&e instanceof Blob||Re&&e instanceof File}function ke(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(ke(e[t]))return!0;return!1}if(Ae(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ke(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&ke(e[t]))return!0;return!1}function Oe(e){const t=[],n=e.data,r=e;return r.data=Ie(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Ie(e,t){if(!e)return e;if(Ae(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Ie(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Ie(e[r],t));return n}return e}function Pe(e,t){return e.data=xe(e.data,t),delete e.attachments,e}function xe(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=xe(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=xe(e[n],t));return e}const Ne=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],De=5;var Le;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Le||(Le={}));class Me{constructor(e){this.replacer=e}encode(e){return e.type!==Le.EVENT&&e.type!==Le.ACK||!ke(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Le.EVENT?Le.BINARY_EVENT:Le.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Le.BINARY_EVENT&&e.type!==Le.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Oe(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}function Ue(e){return"[object Object]"===Object.prototype.toString.call(e)}class je extends z{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===Le.BINARY_EVENT;n||t.type===Le.BINARY_ACK?(t.type=n?Le.EVENT:Le.ACK,this.reconstructor=new qe(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!Ae(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===Le[n.type])throw new Error("unknown packet type "+n.type);if(n.type===Le.BINARY_EVENT||n.type===Le.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!je.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Le.CONNECT:return Ue(t);case Le.DISCONNECT:return void 0===t;case Le.CONNECT_ERROR:return"string"==typeof t||Ue(t);case Le.EVENT:case Le.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Ne.indexOf(t[0]));case Le.ACK:case Le.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qe{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Pe(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Fe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const He=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Be extends z{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Fe(e,"open",this.onopen.bind(this)),Fe(e,"packet",this.onpacket.bind(this)),Fe(e,"error",this.onerror.bind(this)),Fe(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,r,i;if(He.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:Le.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),o.id=e}const s=null===(r=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===r?void 0:r.writable,a=this.connected&&!(null===(i=this.io.engine)||void 0===i?void 0:i._hasPingExpired());return this.flags.volatile&&!s||(a?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r),o=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,e)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise(((n,r)=>{const i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(n===this._queue[0])return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Le.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((e=>{if(!this.sendBuffer.some((t=>String(t.id)===e))){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}}))}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Le.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Le.EVENT:case Le.BINARY_EVENT:this.onevent(e);break;case Le.ACK:case Le.BINARY_ACK:this.onack(e);break;case Le.DISCONNECT:this.ondisconnect();break;case Le.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,t.packet({type:Le.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Le.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function Ge(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ge.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},Ge.prototype.reset=function(){this.attempts=0},Ge.prototype.setMin=function(e){this.ms=e},Ge.prototype.setMax=function(e){this.max=e},Ge.prototype.setJitter=function(e){this.jitter=e};class Ve extends z{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).pa