@swyger/client-auth
Version:
Swyger Auth Client JS library is used for Swyger Server as consumer Rest API focused on authentication (register, login, forgot password...). Visit the master branch: https://github.com/coorise/swyger-js-client-auth.git
1 lines • 321 kB
JavaScript
var ba=Object.defineProperty,xa=Object.defineProperties;var Ea=Object.getOwnPropertyDescriptors;var ws=Object.getOwnPropertySymbols;var ka=Object.prototype.hasOwnProperty,_a=Object.prototype.propertyIsEnumerable;var Zn=(r,e,t)=>e in r?ba(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,V=(r,e)=>{for(var t in e||(e={}))ka.call(e,t)&&Zn(r,t,e[t]);if(ws)for(var t of ws(e))_a.call(e,t)&&Zn(r,t,e[t]);return r},we=(r,e)=>xa(r,Ea(e));var bs=(r,e,t)=>(Zn(r,typeof e!="symbol"?e+"":e,t),t),xs=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var Fe=(r,e,t)=>(xs(r,e,"read from private field"),t?t.call(r):e.get(r)),_t=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},tn=(r,e,t,n)=>(xs(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var k=(r,e,t)=>new Promise((n,s)=>{var i=c=>{try{a(t.next(c))}catch(u){s(u)}},o=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,o);a((t=t.apply(r,e)).next())});const qe=Object.create(null);qe.open="0";qe.close="1";qe.ping="2";qe.pong="3";qe.message="4";qe.upgrade="5";qe.noop="6";const hn=Object.create(null);Object.keys(qe).forEach(r=>{hn[qe[r]]=r});const Aa={type:"error",data:"parser error"},Sa=typeof Blob=="function"||typeof Blob!="undefined"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ta=typeof ArrayBuffer=="function",Oa=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,hi=({type:r,data:e},t,n)=>Sa&&e instanceof Blob?t?n(e):Es(e,n):Ta&&(e instanceof ArrayBuffer||Oa(e))?t?n(e):Es(new Blob([e]),n):n(qe[r]+(e||"")),Es=(r,e)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];e("b"+(n||""))},t.readAsDataURL(r)},ks="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ut=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(let r=0;r<ks.length;r++)Ut[ks.charCodeAt(r)]=r;const Pa=r=>{let e=r.length*.75,t=r.length,n,s=0,i,o,a,c;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);const u=new ArrayBuffer(e),l=new Uint8Array(u);for(n=0;n<t;n+=4)i=Ut[r.charCodeAt(n)],o=Ut[r.charCodeAt(n+1)],a=Ut[r.charCodeAt(n+2)],c=Ut[r.charCodeAt(n+3)],l[s++]=i<<2|o>>4,l[s++]=(o&15)<<4|a>>2,l[s++]=(a&3)<<6|c&63;return u},Ia=typeof ArrayBuffer=="function",di=(r,e)=>{if(typeof r!="string")return{type:"message",data:pi(r,e)};const t=r.charAt(0);return t==="b"?{type:"message",data:Ra(r.substring(1),e)}:hn[t]?r.length>1?{type:hn[t],data:r.substring(1)}:{type:hn[t]}:Aa},Ra=(r,e)=>{if(Ia){const t=Pa(r);return pi(t,e)}else return{base64:!0,data:r}},pi=(r,e)=>{switch(e){case"blob":return r instanceof ArrayBuffer?new Blob([r]):r;case"arraybuffer":default:return r}},yi=String.fromCharCode(30),Ca=(r,e)=>{const t=r.length,n=new Array(t);let s=0;r.forEach((i,o)=>{hi(i,!1,a=>{n[o]=a,++s===t&&e(n.join(yi))})})},Na=(r,e)=>{const t=r.split(yi),n=[];for(let s=0;s<t.length;s++){const i=di(t[s],e);if(n.push(i),i.type==="error")break}return n},mi=4;function de(r){if(r)return $a(r)}function $a(r){for(var e in de.prototype)r[e]=de.prototype[e];return r}de.prototype.on=de.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};de.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};de.prototype.off=de.prototype.removeListener=de.prototype.removeAllListeners=de.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,s=0;s<t.length;s++)if(n=t[s],n===e||n.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};de.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,s=t.length;n<s;++n)t[n].apply(this,e)}return this};de.prototype.emitReserved=de.prototype.emit;de.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};de.prototype.hasListeners=function(r){return!!this.listeners(r).length};const Le=(()=>typeof self!="undefined"?self:typeof window!="undefined"?window:Function("return this")())();function gi(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}const ja=Le.setTimeout,Ba=Le.clearTimeout;function $n(r,e){e.useNativeTimers?(r.setTimeoutFn=ja.bind(Le),r.clearTimeoutFn=Ba.bind(Le)):(r.setTimeoutFn=Le.setTimeout.bind(Le),r.clearTimeoutFn=Le.clearTimeout.bind(Le))}const La=1.33;function Da(r){return typeof r=="string"?Ua(r):Math.ceil((r.byteLength||r.size)*La)}function Ua(r){let e=0,t=0;for(let n=0,s=r.length;n<s;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}class Fa extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class vi extends de{constructor(e){super(),this.writable=!1,$n(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new Fa(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=di(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}}const wi="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),mr=64,Ma={};let _s=0,nn=0,As;function Ss(r){let e="";do e=wi[r%mr]+e,r=Math.floor(r/mr);while(r>0);return e}function bi(){const r=Ss(+new Date);return r!==As?(_s=0,As=r):r+"."+Ss(_s++)}for(;nn<mr;nn++)Ma[wi[nn]]=nn;function xi(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Ka(r){let e={},t=r.split("&");for(let n=0,s=t.length;n<s;n++){let i=t[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}let Ei=!1;try{Ei=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest}catch(r){}const Va=Ei;function ki(r){const e=r.xdomain;try{if(typeof XMLHttpRequest!="undefined"&&(!e||Va))return new XMLHttpRequest}catch(t){}if(!e)try{return new Le[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(t){}}function za(){}const Wa=function(){return new ki({xdomain:!1}).responseType!=null}();class Ha extends vi{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){const n=location.protocol==="https:";let s=location.port;s||(s=n?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||s!==e.port,this.xs=e.secure!==n}const t=e&&e.forceBase64;this.supportsBinary=Wa&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};Na(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Ca(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let n="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=bi()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port);const s=xi(e),i=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(i?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(s.length?"?"+s:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new Je(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}}class Je extends de{constructor(e,t){super(),$n(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.create()}create(){const e=gi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new ki(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&t.setRequestHeader(n,this.opts.extraHeaders[n])}}catch(n){}if(this.method==="POST")try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{t.setRequestHeader("Accept","*/*")}catch(n){}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{t.readyState===4&&(t.status===200||t.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t.status=="number"?t.status:0)},0))},t.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document!="undefined"&&(this.index=Je.requestsCount++,Je.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=za,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete Je.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}Je.requestsCount=0;Je.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",Ts);else if(typeof addEventListener=="function"){const r="onpagehide"in Le?"pagehide":"unload";addEventListener(r,Ts,!1)}}function Ts(){for(let r in Je.requests)Je.requests.hasOwnProperty(r)&&Je.requests[r].abort()}const _i=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),rn=Le.WebSocket||Le.MozWebSocket,Os=!0,Ja="arraybuffer",Ps=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class qa extends vi{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=Ps?{}:gi(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=Os&&!Ps?t?new rn(e,t):new rn(e):new rn(e,t,n)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType||Ja,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],s=t===e.length-1;hi(n,this.supportsBinary,i=>{const o={};try{Os&&this.ws.send(i)}catch(a){}s&&_i(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let n="";this.opts.port&&(t==="wss"&&Number(this.opts.port)!==443||t==="ws"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=bi()),this.supportsBinary||(e.b64=1);const s=xi(e),i=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(i?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(s.length?"?"+s:"")}check(){return!!rn}}const Ya={websocket:qa,polling:Ha},Ga=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Qa=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function gr(r){const e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let s=Ga.exec(r||""),i={},o=14;for(;o--;)i[Qa[o]]=s[o]||"";return t!=-1&&n!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Xa(i,i.path),i.queryKey=Za(i,i.query),i}function Xa(r,e){const t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Za(r,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,i){s&&(t[s]=i)}),t}class at extends de{constructor(e,t={}){super(),this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=gr(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=gr(t.host).host),$n(this,t),this.secure=t.secure!=null?t.secure:typeof location!="undefined"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=t.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.writeBuffer=[],this.prevBufferLen=0,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:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ka(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=mi,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new Ya[e](n)}open(){let e;if(this.opts.rememberUpgrade&&at.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}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",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),n=!1;at.priorWebsocketSuccess=!1;const s=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;at.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const y=new Error("probe error");y.transport=t.name,this.emitReserved("upgradeError",y)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}const o=f=>{const y=new Error("probe error: "+f);y.transport=t.name,i(),this.emitReserved("upgradeError",y)};function a(){o("transport closed")}function c(){o("socket closed")}function u(f){t&&f.name!==t.name&&i()}const l=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",u),t.open()}onOpen(){if(this.readyState="open",at.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");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);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&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&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const s=this.writeBuffer[n].data;if(s&&(t+=Da(s)),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}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,s){if(typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),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(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){at.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const s=e.length;for(;n<s;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}at.protocol=mi;function ec(r,e="",t){let n=r;t=t||typeof location!="undefined"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(typeof t!="undefined"?r=t.protocol+"//"+r:r="https://"+r),n=gr(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(t&&t.port===n.port?"":":"+n.port),n}const tc=typeof ArrayBuffer=="function",nc=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Ai=Object.prototype.toString,rc=typeof Blob=="function"||typeof Blob!="undefined"&&Ai.call(Blob)==="[object BlobConstructor]",sc=typeof File=="function"||typeof File!="undefined"&&Ai.call(File)==="[object FileConstructor]";function Dr(r){return tc&&(r instanceof ArrayBuffer||nc(r))||rc&&r instanceof Blob||sc&&r instanceof File}function dn(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if(dn(r[t]))return!0;return!1}if(Dr(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return dn(r.toJSON(),!0);for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&dn(r[t]))return!0;return!1}function ic(r){const e=[],t=r.data,n=r;return n.data=vr(t,e),n.attachments=e.length,{packet:n,buffers:e}}function vr(r,e){if(!r)return r;if(Dr(r)){const t={_placeholder:!0,num:e.length};return e.push(r),t}else if(Array.isArray(r)){const t=new Array(r.length);for(let n=0;n<r.length;n++)t[n]=vr(r[n],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){const t={};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=vr(r[n],e));return t}return r}function oc(r,e){return r.data=wr(r.data,e),delete r.attachments,r}function wr(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=wr(r[t],e);else if(typeof r=="object")for(const t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=wr(r[t],e));return r}const ac=5;var ee;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(ee||(ee={}));class cc{constructor(e){this.replacer=e}encode(e){return(e.type===ee.EVENT||e.type===ee.ACK)&&dn(e)?this.encodeAsBinary({type:e.type===ee.EVENT?ee.BINARY_EVENT:ee.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===ee.BINARY_EVENT||e.type===ee.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=ic(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}}class Ur extends de{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===ee.BINARY_EVENT;n||t.type===ee.BINARY_ACK?(t.type=n?ee.EVENT:ee.ACK,this.reconstructor=new uc(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Dr(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(ee[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===ee.BINARY_EVENT||n.type===ee.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(i,t)}else n.nsp="/";const s=e.charAt(t+1);if(s!==""&&Number(s)==s){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(Ur.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case ee.CONNECT:return typeof t=="object";case ee.DISCONNECT:return t===void 0;case ee.CONNECT_ERROR:return typeof t=="string"||typeof t=="object";case ee.EVENT:case ee.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="string"||typeof t[0]=="number");case ee.ACK:case ee.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class uc{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=oc(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const lc=Object.freeze(Object.defineProperty({__proto__:null,protocol:ac,get PacketType(){return ee},Encoder:cc,Decoder:Ur},Symbol.toStringTag,{value:"Module"}));function Ke(r,e,t){return r.on(e,t),function(){r.off(e,t)}}const fc=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Si extends de{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=[Ke(e,"open",this.onopen.bind(this)),Ke(e,"packet",this.onpacket.bind(this)),Ke(e,"error",this.onerror.bind(this)),Ke(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(fc.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 n={type:ee.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const o=this.ids++,a=t.pop();this._registerAckCallback(o,a),n.id=o}const s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...o])}}emitWithAck(e,...t){const n=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,i)=>{t.push((o,a)=>n?o?i(o):s(a):s(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>n!==this._queue[0]?void 0:(s!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(s)):(this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)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(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:ee.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)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case ee.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 ee.EVENT:case ee.BINARY_EVENT:this.onevent(e);break;case ee.ACK:case ee.BINARY_ACK:this.onack(e);break;case ee.DISCONNECT:this.ondisconnect();break;case ee.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const t=e.data||[];e.id!=null&&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&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...s){n||(n=!0,t.packet({type:ee.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}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:ee.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 Nt(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}Nt.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=(Math.floor(e*10)&1)==0?r-t:r+t}return Math.min(r,this.max)|0};Nt.prototype.reset=function(){this.attempts=0};Nt.prototype.setMin=function(r){this.ms=r};Nt.prototype.setMax=function(r){this.max=r};Nt.prototype.setJitter=function(r){this.jitter=r};class br extends de{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,$n(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new Nt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||lc;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new at(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const s=Ke(t,"open",function(){n.onopen(),e&&e()}),i=Ke(t,"error",o=>{n.cleanup(),n._readyState="closed",this.emitReserved("error",o),e?e(o):n.maybeReconnectOnOpen()});if(this._timeout!==!1){const o=this._timeout;o===0&&s();const a=this.setTimeoutFn(()=>{s(),t.close(),t.emit("error",new Error("timeout"))},o);this.opts.autoUnref&&a.unref(),this.subs.push(function(){clearTimeout(a)})}return this.subs.push(s),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Ke(e,"ping",this.onping.bind(this)),Ke(e,"data",this.ondata.bind(this)),Ke(e,"error",this.onerror.bind(this)),Ke(e,"close",this.onclose.bind(this)),Ke(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){_i(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Si(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Bt={};function pn(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};const t=ec(r,e.path||"/socket.io"),n=t.source,s=t.id,i=t.path,o=Bt[s]&&i in Bt[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new br(n,e):(Bt[s]||(Bt[s]=new br(n,e)),c=Bt[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(pn,{Manager:br,Socket:Si,io:pn,connect:pn});const hc={init:({API_KEY:r,HOST_SERVER:e,CURRENT:t,ENV:n,API_VERSION:s})=>{var a,c;let i={};const o=localStorage.getItem("accessToken");try{const u={Accept:"application/json","Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Key":r,"Access-Control-Allow-Methods":"POST, GET, OPTIONS, PUT, DELETE, HEAD,PATCH","Access-Control-Allow-Headers":"X-PINGOTHER, Origin, X-Requested-With, Content-Type, Accept","Access-Control-Max-Age":"1728000"};return o&&(u.Authorization="Bearer "+o),i.auth=pn(e.AUTH,{extraHeaders:u}),(a=i==null?void 0:i.auth)==null||a.on("connect",()=>{var f,y,p,d,h;n==="dev"&&console.log("Swyger Auth Client JS is connected with Swyger Server!!!");let l=JSON.parse(localStorage.getItem("userInfo")?localStorage.getItem("userInfo"):"{}");l.uid&&(f=i.auth)!=null&&f.id&&(n==="dev"&&console.log("The socket device id is: ",(y=i.auth)==null?void 0:y.id),(d=i==null?void 0:i.auth)==null||d.emit((s==null?void 0:s.AUTH)+"/user/join",{socketId:(p=i.auth)==null?void 0:p.id,currentUserId:l.uid}),(h=i==null?void 0:i.auth)==null||h.on((s==null?void 0:s.AUTH)+"/user/status",m=>{if(l.status!=="online"){let g;m.from===l.uid&&(g=m==null?void 0:m.value),g!=null&&g.status&&(n==="dev"&&console.log("user is online: ",g),l.status=g.status,localStorage.setItem("userInfo",JSON.stringify(l)))}}))}),(c=i==null?void 0:i.auth)==null||c.on("disconnect",l=>{n==="dev"&&console.log("The device is disconnected from Auth server!");let f=JSON.parse(localStorage.getItem("userInfo")?localStorage.getItem("userInfo"):"{}");f.uid&&f.status!=="offline"&&(f.status="offline",localStorage.setItem("userInfo",JSON.stringify(f)))}),i}catch(u){}}};function xr(r){this.message=r}xr.prototype=new Error,xr.prototype.name="InvalidCharacterError";var Is=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(r){var e=String(r).replace(/=+$/,"");if(e.length%4==1)throw new xr("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n,s=0,i=0,o="";n=e.charAt(i++);~n&&(t=s%4?64*t+n:n,s++%4)?o+=String.fromCharCode(255&t>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return o};function dc(r){var e=r.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Is(t).replace(/(.)/g,function(n,s){var i=s.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}(e)}catch(t){return Is(e)}}function _n(r){this.message=r}function pc(r,e){if(typeof r!="string")throw new _n("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(dc(r.split(".")[t]))}catch(n){throw new _n("Invalid token specified: "+n.message)}}_n.prototype=new Error,_n.prototype.name="InvalidTokenError";function Ti(r,e){return function(){return r.apply(e,arguments)}}const{toString:yc}=Object.prototype,{getPrototypeOf:Fr}=Object,jn=(r=>e=>{const t=yc.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ye=r=>(r=r.toLowerCase(),e=>jn(e)===r),Bn=r=>e=>typeof e===r,{isArray:$t}=Array,Ft=Bn("undefined");function mc(r){return r!==null&&!Ft(r)&&r.constructor!==null&&!Ft(r.constructor)&&De(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Oi=Ye("ArrayBuffer");function gc(r){let e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Oi(r.buffer),e}const vc=Bn("string"),De=Bn("function"),Pi=Bn("number"),Ln=r=>r!==null&&typeof r=="object",wc=r=>r===!0||r===!1,yn=r=>{if(jn(r)!=="object")return!1;const e=Fr(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},bc=Ye("Date"),xc=Ye("File"),Ec=Ye("Blob"),kc=Ye("FileList"),_c=r=>Ln(r)&&De(r.pipe),Ac=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||De(r.append)&&((e=jn(r))==="formdata"||e==="object"&&De(r.toString)&&r.toString()==="[object FormData]"))},Sc=Ye("URLSearchParams"),Tc=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qt(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r=="undefined")return;let n,s;if(typeof r!="object"&&(r=[r]),$t(r))for(n=0,s=r.length;n<s;n++)e.call(null,r[n],n,r);else{const i=t?Object.getOwnPropertyNames(r):Object.keys(r),o=i.length;let a;for(n=0;n<o;n++)a=i[n],e.call(null,r[a],a,r)}}function Ii(r,e){e=e.toLowerCase();const t=Object.keys(r);let n=t.length,s;for(;n-- >0;)if(s=t[n],e===s.toLowerCase())return s;return null}const Ri=(()=>typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global)(),Ci=r=>!Ft(r)&&r!==Ri;function Er(){const{caseless:r}=Ci(this)&&this||{},e={},t=(n,s)=>{const i=r&&Ii(e,s)||s;yn(e[i])&&yn(n)?e[i]=Er(e[i],n):yn(n)?e[i]=Er({},n):$t(n)?e[i]=n.slice():e[i]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&qt(arguments[n],t);return e}const Oc=(r,e,t,{allOwnKeys:n}={})=>(qt(e,(s,i)=>{t&&De(s)?r[i]=Ti(s,t):r[i]=s},{allOwnKeys:n}),r),Pc=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),Ic=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},Rc=(r,e,t,n)=>{let s,i,o;const a={};if(e=e||{},r==null)return e;do{for(s=Object.getOwnPropertyNames(r),i=s.length;i-- >0;)o=s[i],(!n||n(o,r,e))&&!a[o]&&(e[o]=r[o],a[o]=!0);r=t!==!1&&Fr(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Cc=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const n=r.indexOf(e,t);return n!==-1&&n===t},Nc=r=>{if(!r)return null;if($t(r))return r;let e=r.length;if(!Pi(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},$c=(r=>e=>r&&e instanceof r)(typeof Uint8Array!="undefined"&&Fr(Uint8Array)),jc=(r,e)=>{const n=(r&&r[Symbol.iterator]).call(r);let s;for(;(s=n.next())&&!s.done;){const i=s.value;e.call(r,i[0],i[1])}},Bc=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},Lc=Ye("HTMLFormElement"),Dc=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,s){return n.toUpperCase()+s}),Rs=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Uc=Ye("RegExp"),Ni=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};qt(t,(s,i)=>{e(s,i,r)!==!1&&(n[i]=s)}),Object.defineProperties(r,n)},Fc=r=>{Ni(r,(e,t)=>{if(De(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(!!De(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Mc=(r,e)=>{const t={},n=s=>{s.forEach(i=>{t[i]=!0})};return $t(r)?n(r):n(String(r).split(e)),t},Kc=()=>{},Vc=(r,e)=>(r=+r,Number.isFinite(r)?r:e),er="abcdefghijklmnopqrstuvwxyz",Cs="0123456789",$i={DIGIT:Cs,ALPHA:er,ALPHA_DIGIT:er+er.toUpperCase()+Cs},zc=(r=16,e=$i.ALPHA_DIGIT)=>{let t="";const{length:n}=e;for(;r--;)t+=e[Math.random()*n|0];return t};function Wc(r){return!!(r&&De(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const Hc=r=>{const e=new Array(10),t=(n,s)=>{if(Ln(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[s]=n;const i=$t(n)?[]:{};return qt(n,(o,a)=>{const c=t(o,s+1);!Ft(c)&&(i[a]=c)}),e[s]=void 0,i}}return n};return t(r,0)},Jc=Ye("AsyncFunction"),qc=r=>r&&(Ln(r)||De(r))&&De(r.then)&&De(r.catch),C={isArray:$t,isArrayBuffer:Oi,isBuffer:mc,isFormData:Ac,isArrayBufferView:gc,isString:vc,isNumber:Pi,isBoolean:wc,isObject:Ln,isPlainObject:yn,isUndefined:Ft,isDate:bc,isFile:xc,isBlob:Ec,isRegExp:Uc,isFunction:De,isStream:_c,isURLSearchParams:Sc,isTypedArray:$c,isFileList:kc,forEach:qt,merge:Er,extend:Oc,trim:Tc,stripBOM:Pc,inherits:Ic,toFlatObject:Rc,kindOf:jn,kindOfTest:Ye,endsWith:Cc,toArray:Nc,forEachEntry:jc,matchAll:Bc,isHTMLForm:Lc,hasOwnProperty:Rs,hasOwnProp:Rs,reduceDescriptors:Ni,freezeMethods:Fc,toObjectSet:Mc,toCamelCase:Dc,noop:Kc,toFiniteNumber:Vc,findKey:Ii,global:Ri,isContextDefined:Ci,ALPHABET:$i,generateString:zc,isSpecCompliantForm:Wc,toJSONObject:Hc,isAsyncFn:Jc,isThenable:qc};function re(r,e,t,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),s&&(this.response=s)}C.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:C.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const ji=re.prototype,Bi={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Bi[r]={value:r}});Object.defineProperties(re,Bi);Object.defineProperty(ji,"isAxiosError",{value:!0});re.from=(r,e,t,n,s,i)=>{const o=Object.create(ji);return C.toFlatObject(r,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),re.call(o,r.message,e,t,n,s),o.cause=r,o.name=r.name,i&&Object.assign(o,i),o};const Yc=null;function kr(r){return C.isPlainObject(r)||C.isArray(r)}function Li(r){return C.endsWith(r,"[]")?r.slice(0,-2):r}function Ns(r,e,t){return r?r.concat(e).map(function(s,i){return s=Li(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function Gc(r){return C.isArray(r)&&!r.some(kr)}const Qc=C.toFlatObject(C,{},null,function(e){return/^is[A-Z]/.test(e)});function Dn(r,e,t){if(!C.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=C.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,m){return!C.isUndefined(m[h])});const n=t.metaTokens,s=t.visitor||l,i=t.dots,o=t.indexes,c=(t.Blob||typeof Blob!="undefined"&&Blob)&&C.isSpecCompliantForm(e);if(!C.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(C.isDate(d))return d.toISOString();if(!c&&C.isBlob(d))throw new re("Blob is not supported. Use a Buffer instead.");return C.isArrayBuffer(d)||C.isTypedArray(d)?c&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,h,m){let g=d;if(d&&!m&&typeof d=="object"){if(C.endsWith(h,"{}"))h=n?h:h.slice(0,-2),d=JSON.stringify(d);else if(C.isArray(d)&&Gc(d)||(C.isFileList(d)||C.endsWith(h,"[]"))&&(g=C.toArray(d)))return h=Li(h),g.forEach(function(x,S){!(C.isUndefined(x)||x===null)&&e.append(o===!0?Ns([h],S,i):o===null?h:h+"[]",u(x))}),!1}return kr(d)?!0:(e.append(Ns(m,h,i),u(d)),!1)}const f=[],y=Object.assign(Qc,{defaultVisitor:l,convertValue:u,isVisitable:kr});function p(d,h){if(!C.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(d),C.forEach(d,function(g,w){(!(C.isUndefined(g)||g===null)&&s.call(e,g,C.isString(w)?w.trim():w,h,y))===!0&&p(g,h?h.concat(w):[w])}),f.pop()}}if(!C.isObject(r))throw new TypeError("data must be an object");return p(r),e}function $s(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Mr(r,e){this._pairs=[],r&&Dn(r,this,e)}const Di=Mr.prototype;Di.append=function(e,t){this._pairs.push([e,t])};Di.toString=function(e){const t=e?function(n){return e.call(this,n,$s)}:$s;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Xc(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").rep