qumra-cli 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -346,4 +346,4 @@ parse:function(e,t){if("string"!=typeof e)throw new TypeError("argument str must
346
346
  * @contributor David Ellis <d.f.ellis@ieee.org>
347
347
  * @license MIT
348
348
  */var dM=s,hM=P,fM=p.spawn,mM=gM;function gM(e){e=e||{};var t,n,i=this,r=C,s=j,o={},a=!1,c={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},l=Object.assign({},c),p=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],u=["TRACE","TRACK","CONNECT"],d=!1,h=!1,f=!1,m={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;this.open=function(e,t,n,i,r){if(this.abort(),h=!1,f=!1,!function(e){return e&&-1===u.indexOf(e)}(e))throw new Error("SecurityError: Request method not allowed");o={method:e,url:t.toString(),async:"boolean"!=typeof n||n,user:i||null,password:r||null},g(this.OPENED)},this.setDisableHeaderCheck=function(e){a=e},this.setRequestHeader=function(e,t){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!function(e){return a||e&&-1===p.indexOf(e.toLowerCase())}(e))return console.warn('Refused to set unsafe header "'+e+'"'),!1;if(d)throw new Error("INVALID_STATE_ERR: send flag is true");return l[e]=t,!0},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&n.headers[e.toLowerCase()]&&!h?n.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||h)return"";var e="";for(var t in n.headers)"set-cookie"!==t&&"set-cookie2"!==t&&(e+=t+": "+n.headers[t]+"\r\n");return e.substr(0,e.length-2)},this.getRequestHeader=function(e){return"string"==typeof e&&l[e]?l[e]:""},this.send=function(a){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(d)throw new Error("INVALID_STATE_ERR: send has already been called");var c,p=!1,u=!1,f=hM.parse(o.url);switch(f.protocol){case"https:":p=!0;case"http:":c=f.hostname;break;case"file:":u=!0;break;case void 0:case"":c="localhost";break;default:throw new Error("Protocol not supported.")}if(u){if("GET"!==o.method)throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)dM.readFile(unescape(f.pathname),"utf8",(function(e,t){e?i.handleError(e,e.errno||-1):(i.status=200,i.responseText=t,g(i.DONE))}));else try{this.responseText=dM.readFileSync(unescape(f.pathname),"utf8"),this.status=200,g(i.DONE)}catch(e){this.handleError(e,e.errno||-1)}}else{var m=f.port||(p?443:80),v=f.pathname+(f.search?f.search:"");if(l.Host=c,p&&443===m||80===m||(l.Host+=":"+f.port),o.user){void 0===o.password&&(o.password="");var y=new Buffer(o.user+":"+o.password);l.Authorization="Basic "+y.toString("base64")}"GET"===o.method||"HEAD"===o.method?a=null:a?(l["Content-Length"]=Buffer.isBuffer(a)?a.length:Buffer.byteLength(a),l["Content-Type"]||(l["Content-Type"]="text/plain;charset=UTF-8")):"POST"===o.method&&(l["Content-Length"]=0);var b=e.agent||!1,x={host:c,port:m,path:v,method:o.method,headers:l,agent:b};if(p&&(x.pfx=e.pfx,x.key=e.key,x.passphrase=e.passphrase,x.cert=e.cert,x.ca=e.ca,x.ciphers=e.ciphers,x.rejectUnauthorized=!1!==e.rejectUnauthorized),h=!1,o.async){var w=p?s.request:r.request;d=!0,i.dispatchEvent("readystatechange");var _=function(r){if(302===(n=r).statusCode||303===n.statusCode||307===n.statusCode){o.url=n.headers.location;var s=hM.parse(o.url);c=s.hostname;var a={hostname:s.hostname,port:s.port,path:s.path,method:303===n.statusCode?"GET":o.method,headers:l};return p&&(a.pfx=e.pfx,a.key=e.key,a.passphrase=e.passphrase,a.cert=e.cert,a.ca=e.ca,a.ciphers=e.ciphers,a.rejectUnauthorized=!1!==e.rejectUnauthorized),void(t=w(a,_).on("error",S)).end()}n&&n.setEncoding&&n.setEncoding("utf8"),g(i.HEADERS_RECEIVED),i.status=n.statusCode,n.on("data",(function(e){e&&(i.responseText+=e),d&&g(i.LOADING)})),n.on("end",(function(){d&&(d=!1,g(i.DONE))})),n.on("error",(function(e){i.handleError(e)}))},S=function(e){i.handleError(e)};t=w(x,_).on("error",S),e.autoUnref&&t.on("socket",(e=>{e.unref()})),a&&t.write(a),t.end(),i.dispatchEvent("loadstart")}else{var E=".node-xmlhttprequest-content-"+process.pid,k=".node-xmlhttprequest-sync-"+process.pid;dM.writeFileSync(k,"","utf8");for(var O="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(p?"s":"")+".request;var options = "+JSON.stringify(x)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+E+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+k+"');});response.on('error', function(error) {fs.writeFileSync('"+E+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+k+"');});}).on('error', function(error) {fs.writeFileSync('"+E+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+k+"');});"+(a?"req.write('"+JSON.stringify(a).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",T=fM(process.argv[0],["-e",O]);dM.existsSync(k););if(i.responseText=dM.readFileSync(E,"utf8"),T.stdin.end(),dM.unlinkSync(E),i.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var A=i.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");i.handleError(A,503)}else i.status=i.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),i.responseText=i.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),g(i.DONE)}}},this.handleError=function(e,t){this.status=t||0,this.statusText=e,this.responseText=e.stack,h=!0,g(this.DONE)},this.abort=function(){t&&(t.abort(),t=null),l=Object.assign({},c),this.responseText="",this.responseXML="",h=f=!0,this.readyState===this.UNSENT||this.readyState===this.OPENED&&!d||this.readyState===this.DONE||(d=!1,g(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(e,t){e in m||(m[e]=[]),m[e].push(t)},this.removeEventListener=function(e,t){e in m&&(m[e]=m[e].filter((function(e){return e!==t})))},this.dispatchEvent=function(e){if("function"==typeof i["on"+e]&&(this.readyState===this.DONE?setImmediate((function(){i["on"+e]()})):i["on"+e]()),e in m)for(let t=0,n=m[e].length;t<n;t++)this.readyState===this.DONE?setImmediate((function(){m[e][t].call(i)})):m[e][t].call(i)};var g=function(e){if(!(i.readyState===e||i.readyState===i.UNSENT&&f)&&(i.readyState=e,(o.async||i.readyState<i.OPENED||i.readyState===i.DONE)&&i.dispatchEvent("readystatechange"),i.readyState===i.DONE)){let e;e=f?"abort":h?"error":"load",i.dispatchEvent(e),i.dispatchEvent("loadend")}}}gM.XMLHttpRequest=gM;var vM=$(mM);const yM=vM||U({__proto__:null,default:vM},[mM]);class bM{constructor(){this.cookies=new Map}parseCookies(e){const t=e.getResponseHeader("set-cookie");t&&t.forEach((e=>{const t=function(e){const t=e.split("; "),n=t[0].indexOf("=");if(-1===n)return;const i=t[0].substring(0,n).trim();if(!i.length)return;let r=t[0].substring(n+1).trim();34===r.charCodeAt(0)&&(r=r.slice(1,-1));const s={name:i,value:r};for(let e=1;e<t.length;e++){const n=t[e].split("=");if(2!==n.length)continue;const i=n[0].trim(),r=n[1].trim();switch(i){case"Expires":s.expires=new Date(r);break;case"Max-Age":const e=new Date;e.setUTCSeconds(e.getUTCSeconds()+parseInt(r,10)),s.expires=e}}return s}(e);t&&this.cookies.set(t.name,t)}))}addCookies(e){const t=[];this.cookies.forEach(((e,n)=>{var i;(null===(i=e.expires)||void 0===i?void 0:i.getTime())<Date.now()?this.cookies.delete(n):t.push(`${n}=${e.value}`)})),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}}function xM(){}const wM=null!=new yM({xdomain:!1}).responseType;class _M extends _D{constructor(e,t){super(),tM(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=JB(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new yM(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)),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=_M.requestsCount++,_M.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=xM,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete _M.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()}}if(_M.requestsCount=0,_M.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",SM);else if("function"==typeof addEventListener){addEventListener("onpagehide"in QB?"pagehide":"unload",SM,!1)}function SM(){for(let e in _M.requests)_M.requests.hasOwnProperty(e)&&_M.requests[e].abort()}const EM=sI,kM=process.nextTick,OM="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const TM={websocket:class extends iM{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=OM?{}:JB(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=new EM(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],i=t===e.length-1;zB(n,this.supportsBinary,(e=>{const t={};if(n.options&&(t.compress=n.options.compress),this.opts.perMessageDeflate){("string"==typeof e?Buffer.byteLength(e):e.length)<this.opts.perMessageDeflate.threshold&&(t.compress=!1)}try{this.ws.send(e,t)}catch(e){}i&&kM((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(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]=uM()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!EM}},webtransport:class extends iM{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),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){KB||(KB=new TextDecoder);const n=[];let i=0,r=-1,s=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(0===i){if(YB(n)<1)break;const e=ZB(n,1);s=!(128&~e[0]),r=127&e[0],i=r<126?3:126===r?1:2}else if(1===i){if(YB(n)<2)break;const e=ZB(n,2);r=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),i=3}else if(2===i){if(YB(n)<8)break;const e=ZB(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(qB);break}r=s*Math.pow(2,32)+t.getUint32(4),i=3}else{if(YB(n)<r)break;const e=ZB(n,r);a.enqueue($B(s?e:KB.decode(e),t)),i=0}if(0===r||r>e){a.enqueue(qB);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),i=GB();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const r=()=>{n.read().then((({done:e,value:t})=>{e||(this.onPacket(t),r())})).catch((e=>{}))};r();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;this.writer.write(n).then((()=>{i&&kM((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends iM{constructor(e){if(super(e),this.polling=!1,"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}const t=e&&e.forceBase64;this.supportsBinary=wM&&!t,this.opts.withCredentials&&(this.cookieJar=new bM)}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(VB),i=[];for(let e=0;e<n.length;e++){const r=$B(n[e],t);if(i.push(r),"error"===r.type)break}return i})(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,i=new Array(n);let r=0;e.forEach(((e,s)=>{zB(e,!1,(e=>{i[s]=e,++r===n&&t(i.join(VB))}))}))})(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]=uM()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new _M(this.uri(),e)}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}}},AM=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,CM=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function RM(e){if(e.length>2e3)throw"URI too long";const t=e,n=e.indexOf("["),i=e.indexOf("]");-1!=n&&-1!=i&&(e=e.substring(0,n)+e.substring(n,i).replace(/:/g,";")+e.substring(i,e.length));let r=AM.exec(e||""),s={},o=14;for(;o--;)s[CM[o]]=r[o]||"";return-1!=n&&-1!=i&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){const n=/\/{2,9}/g,i=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||i.splice(0,1);"/"==t.slice(-1)&&i.splice(i.length-1,1);return i}(0,s.path),s.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,i){t&&(n[t]=i)})),n}(0,s.query),s}let jM=class e extends _D{constructor(e,t={}){super(),this.binaryType="nodebuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=RM(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=RM(t.host).host),tM(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=t.transports||["polling","websocket","webtransport"],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:!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,i=n.length;e<i;e++){let i=n[e].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(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"})},addEventListener("offline",this.offlineEventListener,!1))),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 TM[e](n)}open(){let t;if(this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(e){return this.transports.shift(),void this.open()}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)))}probe(t){let n=this.createTransport(t),i=!1;e.priorWebsocketSuccess=!1;const r=()=>{i||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(t=>{if(!i)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;e.priorWebsocketSuccess="websocket"===n.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(p(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=n.name,this.emitReserved("upgradeError",e)}})))};function s(){i||(i=!0,p(),n.close(),n=null)}const o=e=>{const t=new Error("probe error: "+e);t.transport=n.name,s(),this.emitReserved("upgradeError",t)};function a(){o("transport closed")}function c(){o("socket closed")}function l(e){n&&e.name!==n.name&&s()}const p=()=>{n.removeListener("open",r),n.removeListener("error",o),n.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};n.once("open",r),n.once("error",o),n.once("close",a),this.once("close",c),this.once("upgrading",l),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{i||n.open()}),200):n.open()}onOpen(){if(this.readyState="open",e.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":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)}}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(),"closed"!==this.readyState&&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,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 i=this.writeBuffer[n].data;if(i&&(e+="string"==typeof(t=i)?function(e){let t=0,n=0;for(let i=0,r=e.length;i<r;i++)t=e.charCodeAt(i),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(i++,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}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,i){if("function"==typeof t&&(i=t,t=void 0),"function"==typeof n&&(i=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const r={type:e,data:t,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),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(t){e.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(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 i=e.length;for(;n<i;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};jM.protocol=4,jM.protocol;const PM="function"==typeof ArrayBuffer,LM=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,NM=Object.prototype.toString,IM="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===NM.call(Blob),DM="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===NM.call(File);function BM(e){return PM&&(e instanceof ArrayBuffer||LM(e))||IM&&e instanceof Blob||DM&&e instanceof File}function MM(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(MM(e[t]))return!0;return!1}if(BM(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return MM(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&MM(e[t]))return!0;return!1}function FM(e){const t=[],n=e.data,i=e;return i.data=qM(n,t),i.attachments=t.length,{packet:i,buffers:t}}function qM(e,t){if(!e)return e;if(BM(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 i=0;i<e.length;i++)n[i]=qM(e[i],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=qM(e[i],t));return n}return e}function zM(e,t){return e.data=UM(e.data,t),delete e.attachments,e}function UM(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]=UM(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=UM(e[n],t));return e}const WM=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var $M;!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"}($M||($M={}));function HM(e){return"[object Object]"===Object.prototype.toString.call(e)}class VM extends _D{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===$M.BINARY_EVENT;n||t.type===$M.BINARY_ACK?(t.type=n?$M.EVENT:$M.ACK,this.reconstructor=new GM(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!BM(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===$M[n.type])throw new Error("unknown packet type "+n.type);if(n.type===$M.BINARY_EVENT||n.type===$M.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(i,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(r)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(i,t)}else n.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=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(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!VM.isPayloadValid(n.type,i))throw new Error("invalid payload");n.data=i}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case $M.CONNECT:return HM(t);case $M.DISCONNECT:return void 0===t;case $M.CONNECT_ERROR:return"string"==typeof t||HM(t);case $M.EVENT:case $M.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===WM.indexOf(t[0]));case $M.ACK:case $M.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class GM{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=zM(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var KM=Object.freeze({__proto__:null,Decoder:VM,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==$M.EVENT&&e.type!==$M.ACK||!MM(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===$M.EVENT?$M.BINARY_EVENT:$M.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==$M.BINARY_EVENT&&e.type!==$M.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=FM(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}},get PacketType(){return $M},protocol:5});function YM(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const ZM=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class QM extends _D{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=[YM(e,"open",this.onopen.bind(this)),YM(e,"packet",this.onpacket.bind(this)),YM(e,"error",this.onerror.bind(this)),YM(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){if(ZM.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:$M.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,i=t.pop();this._registerAckCallback(e,i),n.id=e}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const i=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===i)return void(this.acks[e]=t);const r=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"))}),i),s=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};s.withError=!0,this.acks[e]=s}emitWithAck(e,...t){return new Promise(((n,i)=>{const r=(e,t)=>e?i(e):n(t);r.withError=!0,t.push(r),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,...i)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...i)),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:$M.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 $M.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 $M.EVENT:case $M.BINARY_EVENT:this.onevent(e);break;case $M.ACK:case $M.BINARY_ACK:this.onack(e);break;case $M.DISCONNECT:this.ondisconnect();break;case $M.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(...i){n||(n=!0,t.packet({type:$M.ACK,id:e,data:i}))}}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:$M.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 JM(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}JM.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)},JM.prototype.reset=function(){this.attempts=0},JM.prototype.setMin=function(e){this.ms=e},JM.prototype.setMax=function(e){this.max=e},JM.prototype.setJitter=function(e){this.jitter=e};class XM extends _D{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,tM(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new JM({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||KM;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new jM(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=YM(t,"open",(function(){n.onopen(),e&&e()})),r=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=YM(t,"error",r);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn((()=>{i(),r(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(i),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(YM(e,"ping",this.onping.bind(this)),YM(e,"data",this.ondata.bind(this)),YM(e,"error",this.onerror.bind(this)),YM(e,"close",this.onclose.bind(this)),YM(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){kM((()=>{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 QM(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].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((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const eF={};function tF(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let i=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),i=RM(e)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const r=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+r+":"+i.port+t,i.href=i.protocol+"://"+r+(n&&n.port===i.port?"":":"+i.port),i}(e,(t=t||{}).path||"/socket.io"),i=n.source,r=n.id,s=n.path,o=eF[r]&&s in eF[r].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new XM(i,t):(eF[r]||(eF[r]=new XM(i,t)),a=eF[r]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}Object.assign(tF,{Manager:XM,Socket:QM,io:tF,connect:tF});const nF=async()=>{const e=l("Login Init...").start();try{console.log(`${Ie}/login`);const t=await fetch(`${Ie}/login`,{method:"POST"});if(!t.ok)throw new Error("Network response was not ok");const n=await t.json(),{room:i,sessionId:r}=n;e.succeed();const s=l("Wait User Auth").start();NB(`https://partner.qumra.cloud/cli/auth?sessionId=${r}`).then((()=>{const e=tF("https://api.qumra.cloud");e.on("connect",(()=>{e.emit("authRoom",i)})),e.on("login",(({data:t,token:n})=>{Be("user",t),Be("token",n),s.succeed("success"),e.disconnect()}))})).catch((e=>console.error("Failed to open URL:",e)))}catch(t){e.stop(),console.error("Failed to fetch data:",t)}};new Re("user").command("login").description("Run development server with Webpack and BrowserSync").action(nF);const iF=new Re;iF.version(Ne).description("CLI to create a new project"),iF.command("status").description("cli status").action((async()=>{const e=(e,t)=>e.split("\n").map((e=>{const n=Math.max(0,Math.floor((t-e.length)/2));return" ".repeat(n)+e})).join("\n"),t=100,n=m.textSync("Qumra Cloud CLI",{font:"Standard",horizontalLayout:"default",verticalLayout:"default",width:t,whitespaceBreak:!0}),i=m.textSync("Version 1.0.0",{font:"Standard",horizontalLayout:"default",verticalLayout:"default",width:t,whitespaceBreak:!0}),r=e(n,t),s=e(i,t),o=e("\n Welcome to Qumra Cloud CLI!\n \n At Qumra, we offer innovative cloud solutions to streamline your tech needs.\n Our tools are designed to make technology work for you with ease and efficiency.\n \n Learn more about our partners and how we collaborate to deliver the best:\n https://partners.qumra.cloud\n ",t);console.log(c.green(r)),console.log(c.green(s)),console.log(c.green(o))})),iF.command("create-new-app").description("Create a new project").action(We),iF.command("build").description("Build a project").action((()=>{const e=process.cwd(),t=a.join(e,"src","views"),n=a.join(e,"build"),i=a.join(n,"views.zip");console.log("🚀 ~ buildApp ~ projectPath:",e),s.existsSync(t)||(console.log(c.red('Error: The "views" folder does not exist.')),process.exit(1)),s.existsSync(n)||s.mkdirSync(n);const r=l('Compressing the "views" folder...').start(),o=s.createWriteStream(i),p=oy("zip",{zlib:{level:9}});o.on("close",(()=>{r.succeed(c.blue(`"views" folder compressed successfully into ${i}`))})),p.on("warning",(e=>{if("ENOENT"!==e.code)throw e;console.warn(e)})),p.on("error",(e=>{throw r.fail(c.red(`Failed to compress "views" folder: ${e.message}`)),e})),p.pipe(o),p.directory(t,!1),p.finalize()})),iF.command("publish").description("Publish your project").action((async function(){const e=function(){if(!s.existsSync(cb))throw new Error('File "qumra.config.json" not found!');const e=s.readFileSync(cb,"utf-8");try{return JSON.parse(e)}catch(e){throw new Error('Failed to parse "qumra.config.json". Invalid JSON format.')}}(),t=l("Checking files...").start();try{const n=await tb(ob),i=await tb(ab);nb(Object.keys(i),t).then((t=>{(async function(e,t){console.log("🚀 ~ uploadRequest ~ paths,config:",e,t);try{return(await Fe.post("/themes/uploadRequest",{paths:e,config:t})).data}catch(e){throw e}})(t.paths,e).then((e=>{(async function(e,t,n){const i=new eb;i.append("encryptionKey",e),i.append("paths",JSON.stringify(t));for(const[e,t]of Object.entries(n))console.log("🚀 ~ uploadTheme ~ filePath:",t),i.append("files",s.createReadStream(t),{filename:a.basename(t),filepath:e}),i.append("filePaths",e);const r=l(c.cyan("Uploading theme...")).start();try{const e=await ib.post("/theme/upload",i,{onUploadProgress:e=>{const t=Math.round(100*e.loaded/e.total);r.text=c.cyan(`Uploading theme... ${t}%`)}});return r.succeed(c.green("Upload successful!")),e.data}catch(e){throw r.fail(c.red("Upload failed.")),console.error("🚀 ~ uploadTheme ~ error:",e),e}})(e.encryptionKey,t.paths,i).then((t=>{(async function(e,t,n){const i=new eb;i.append("encryptionKey",e),i.append("paths",JSON.stringify(t));for(const[e,t]of Object.entries(n))i.append("files",s.createReadStream(t),{filename:a.basename(t),filepath:e}),i.append("filePaths",e);const r=l(c.cyan("Uploading theme...")).start();try{const e=await rb.post("/upload/assets",i,{onUploadProgress:e=>{const t=Math.round(100*e.loaded/e.total);r.text=c.cyan(`Uploading theme... ${t}%`)}});return r.succeed(c.green("Upload successful!")),e.data}catch(e){throw r.fail(c.red("Upload failed.")),console.error("🚀 ~ uploadAssets ~ error:",e),e}})(e.encryptionKey,Object.keys(n),n).then((e=>{console.log("🚀 ~ uploadAssets ~ uploadAssetsRes:",e)}))}))}))})).catch((e=>{}))}catch(e){console.error(`Failed to publish files - Error: ${e.message}`)}})),iF.command("login").description("developer login").action(nF),iF.addCommand(BB),iF.command("save").action((async()=>{const e=await Me("token");await Be("token",{test:"asdasdasd"}),console.log("🚀 ~ program.command ~ token:",e)})),iF.parse(process.argv);
349
- //# sourceMappingURL=index.js.map
349
+ //# sourceMappingURL=cli.js.map