@appthen/cli 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -84,4 +84,4 @@ var pp=function(e){for(var t=arguments.length,s=0;++s<t;)e=hp(e,arguments[s]);re
|
|
|
84
84
|
* @author Dan DeFelippi <dan@driverdan.com>
|
|
85
85
|
* @contributor David Ellis <d.f.ellis@ieee.org>
|
|
86
86
|
* @license MIT
|
|
87
|
-
*/var cm=N.default.spawn,um=lm;function lm(e){e=e||{};var t,s,r=this,n=R.default,i=U.default,a={},o=!1,c={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},c),l=["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"],p=["TRACE","TRACK","CONNECT"],h=!1,d=!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,s,r,n){if(this.abort(),d=!1,f=!1,!function(e){return e&&-1===p.indexOf(e)}(e))throw new Error("SecurityError: Request method not allowed");a={method:e,url:t.toString(),async:"boolean"!=typeof s||s,user:r||null,password:n||null},y(this.OPENED)},this.setDisableHeaderCheck=function(e){o=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 o||e&&-1===l.indexOf(e.toLowerCase())}(e))return console.warn('Refused to set unsafe header "'+e+'"'),!1;if(h)throw new Error("INVALID_STATE_ERR: send flag is true");return u[e]=t,!0},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&s.headers[e.toLowerCase()]&&!d?s.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||d)return"";var e="";for(var t in s.headers)"set-cookie"!==t&&"set-cookie2"!==t&&(e+=t+": "+s.headers[t]+"\r\n");return e.substr(0,e.length-2)},this.getRequestHeader=function(e){return"string"==typeof e&&u[e]?u[e]:""},this.send=function(o){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(h)throw new Error("INVALID_STATE_ERR: send has already been called");var c,l=!1,p=!1,f=q.default.parse(a.url);switch(f.protocol){case"https:":l=!0;case"http:":c=f.hostname;break;case"file:":p=!0;break;case void 0:case"":c="localhost";break;default:throw new Error("Protocol not supported.")}if(p){if("GET"!==a.method)throw new Error("XMLHttpRequest: Only GET method is supported");if(a.async)O.default.readFile(unescape(f.pathname),"utf8",(function(e,t){e?r.handleError(e,e.errno||-1):(r.status=200,r.responseText=t,y(r.DONE))}));else try{this.responseText=O.default.readFileSync(unescape(f.pathname),"utf8"),this.status=200,y(r.DONE)}catch(e){this.handleError(e,e.errno||-1)}}else{var m=f.port||(l?443:80),g=f.pathname+(f.search?f.search:"");if(u.Host=c,l&&443===m||80===m||(u.Host+=":"+f.port),a.user){void 0===a.password&&(a.password="");var x=new Buffer(a.user+":"+a.password);u.Authorization="Basic "+x.toString("base64")}"GET"===a.method||"HEAD"===a.method?o=null:o?(u["Content-Length"]=Buffer.isBuffer(o)?o.length:Buffer.byteLength(o),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):"POST"===a.method&&(u["Content-Length"]=0);var v=e.agent||!1,b={host:c,port:m,path:g,method:a.method,headers:u,agent:v};if(l&&(b.pfx=e.pfx,b.key=e.key,b.passphrase=e.passphrase,b.cert=e.cert,b.ca=e.ca,b.ciphers=e.ciphers,b.rejectUnauthorized=!1!==e.rejectUnauthorized),d=!1,a.async){var E=l?i.request:n.request;h=!0,r.dispatchEvent("readystatechange");var C=function(n){if(302===(s=n).statusCode||303===s.statusCode||307===s.statusCode){a.url=s.headers.location;var i=q.default.parse(a.url);c=i.hostname;var o={hostname:i.hostname,port:i.port,path:i.path,method:303===s.statusCode?"GET":a.method,headers:u};return l&&(o.pfx=e.pfx,o.key=e.key,o.passphrase=e.passphrase,o.cert=e.cert,o.ca=e.ca,o.ciphers=e.ciphers,o.rejectUnauthorized=!1!==e.rejectUnauthorized),void(t=E(o,C).on("error",A)).end()}s&&s.setEncoding&&s.setEncoding("utf8"),y(r.HEADERS_RECEIVED),r.status=s.statusCode,s.on("data",(function(e){e&&(r.responseText+=e),h&&y(r.LOADING)})),s.on("end",(function(){h&&(h=!1,y(r.DONE))})),s.on("error",(function(e){r.handleError(e)}))},A=function(e){r.handleError(e)};t=E(b,C).on("error",A),e.autoUnref&&t.on("socket",(e=>{e.unref()})),o&&t.write(o),t.end(),r.dispatchEvent("loadstart")}else{var w=".node-xmlhttprequest-content-"+process.pid,D=".node-xmlhttprequest-sync-"+process.pid;O.default.writeFileSync(D,"","utf8");for(var T="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(l?"s":"")+".request;var options = "+JSON.stringify(b)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+w+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+D+"');});response.on('error', function(error) {fs.writeFileSync('"+w+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+D+"');});}).on('error', function(error) {fs.writeFileSync('"+w+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+D+"');});"+(o?"req.write('"+JSON.stringify(o).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",S=cm(process.argv[0],["-e",T]);O.default.existsSync(D););if(r.responseText=O.default.readFileSync(w,"utf8"),S.stdin.end(),O.default.unlinkSync(w),r.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var P=r.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");r.handleError(P,503)}else r.status=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),r.responseText=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),y(r.DONE)}}},this.handleError=function(e,t){this.status=t||0,this.statusText=e,this.responseText=e.stack,d=!0,y(this.DONE)},this.abort=function(){t&&(t.abort(),t=null),u=Object.assign({},c),this.responseText="",this.responseXML="",d=f=!0,this.readyState===this.UNSENT||this.readyState===this.OPENED&&!h||this.readyState===this.DONE||(h=!1,y(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 r["on"+e]&&(this.readyState===this.DONE?setImmediate((function(){r["on"+e]()})):r["on"+e]()),e in m)for(let t=0,s=m[e].length;t<s;t++)this.readyState===this.DONE?setImmediate((function(){m[e][t].call(r)})):m[e][t].call(r)};var y=function(e){if(!(r.readyState===e||r.readyState===r.UNSENT&&f)&&(r.readyState=e,(a.async||r.readyState<r.OPENED||r.readyState===r.DONE)&&r.dispatchEvent("readystatechange"),r.readyState===r.DONE)){let e;e=f?"abort":d?"error":"load",r.dispatchEvent(e),r.dispatchEvent("loadend")}}}lm.XMLHttpRequest=lm;const pm=um||Object.freeze({__proto__:null,default:um,__moduleExports:um});class hm{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("; "),s=t[0].indexOf("=");if(-1===s)return;const r=t[0].substring(0,s).trim();if(!r.length)return;let n=t[0].substring(s+1).trim();34===n.charCodeAt(0)&&(n=n.slice(1,-1));const i={name:r,value:n};for(let e=1;e<t.length;e++){const s=t[e].split("=");if(2!==s.length)continue;const r=s[0].trim(),n=s[1].trim();switch(r){case"Expires":i.expires=new Date(n);break;case"Max-Age":const e=new Date;e.setUTCSeconds(e.getUTCSeconds()+parseInt(n,10)),i.expires=e}}return i}(e);t&&this.cookies.set(t.name,t)}))}addCookies(e){const t=[];this.cookies.forEach(((e,s)=>{var r;(null===(r=e.expires)||void 0===r?void 0:r.getTime())<Date.now()?this.cookies.delete(s):t.push(`${s}=${e.value}`)})),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}}function dm(){}const fm=null!=new pm({xdomain:!1}).responseType;class mm extends Gf{constructor(e,t){super(),Yf(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=Jf(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const s=this.xhr=new pm(t);try{s.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&s.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{s.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),s.onreadystatechange=()=>{var e;3===s.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(s)),4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof s.status?s.status:0)}),0))},s.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=mm.requestsCount++,mm.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=dm,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete mm.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(mm.requestsCount=0,mm.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",ym);else if("function"==typeof addEventListener){addEventListener("onpagehide"in Wf?"pagehide":"unload",ym,!1)}function ym(){for(let e in mm.requests)mm.requests.hasOwnProperty(e)&&mm.requests[e].abort()}var gm={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}},xm="function"==typeof __webpack_require__?__non_webpack_require__:he,vm=process.config&&process.config.variables||{},bm=!!process.env.PREBUILDS_ONLY,Em=process.versions.modules,Cm=!(!process.versions||!process.versions.electron)||!!process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",Am=process.env.npm_config_arch||S.default.arch(),wm=process.env.npm_config_platform||S.default.platform(),Dm=process.env.LIBC||(function(e){return"linux"===e&&O.default.existsSync("/etc/alpine-release")}(wm)?"musl":"glibc"),Tm=process.env.ARM_VERSION||("arm64"===Am?"8":vm.arm_version)||"",Sm=(process.versions.uv||"").split(".")[0],Pm=km;function km(e){return xm(km.resolve(e))}function _m(e){try{return O.default.readdirSync(e)}catch(e){return[]}}function Nm(e,t){var s=_m(e).filter(t);return s[0]&&k.default.join(e,s[0])}function Im(e){return/\.node$/.test(e)}function Fm(e){var t=e.split("-");if(2===t.length){var s=t[0],r=t[1].split("+");if(s&&r.length&&r.every(Boolean))return{name:e,platform:s,architectures:r}}}function Om(e,t){return function(s){return null!=s&&(s.platform===e&&s.architectures.includes(t))}}function Lm(e,t){return e.architectures.length-t.architectures.length}function Bm(e){var t=e.split("."),s={file:e,specificity:0};if("node"===t.pop()){for(var r=0;r<t.length;r++){var n=t[r];if("node"===n||"electron"===n||"node-webkit"===n)s.runtime=n;else if("napi"===n)s.napi=!0;else if("abi"===n.slice(0,3))s.abi=n.slice(3);else if("uv"===n.slice(0,2))s.uv=n.slice(2);else if("armv"===n.slice(0,4))s.armv=n.slice(4);else{if("glibc"!==n&&"musl"!==n)continue;s.libc=n}s.specificity++}return s}}function jm(e,t){return function(s){return null!=s&&(!(s.runtime&&s.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(s))&&(!(s.abi&&s.abi!==t&&!s.napi)&&((!s.uv||s.uv===Sm)&&((!s.armv||s.armv===Tm)&&(!s.libc||s.libc===Dm)))))}}function Mm(e){return function(t,s){return t.runtime!==s.runtime?t.runtime===e?-1:1:t.abi!==s.abi?t.abi?-1:1:t.specificity!==s.specificity?t.specificity>s.specificity?-1:1:0}}km.resolve=km.path=function(e){e=k.default.resolve(e||".");try{var t=xm(k.default.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"])}catch(e){}if(!bm){var s=Nm(k.default.join(e,"build/Release"),Im);if(s)return s;var r=Nm(k.default.join(e,"build/Debug"),Im);if(r)return r}var n=o(e);if(n)return n;var i=o(k.default.dirname(process.execPath));if(i)return i;var a=["platform="+wm,"arch="+Am,"runtime="+Cm,"abi="+Em,"uv="+Sm,Tm?"armv="+Tm:"","libc="+Dm,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+a+"\n loaded from: "+e+"\n");function o(e){var t=_m(k.default.join(e,"prebuilds")).map(Fm).filter(Om(wm,Am)).sort(Lm)[0];if(t){var s=k.default.join(e,"prebuilds",t.name),r=_m(s).map(Bm).filter(jm(Cm,Em)).sort(Mm(Cm))[0];return r?k.default.join(s,r.file):void 0}}},km.parseTags=Bm,km.matchTags=jm,km.compareTags=Mm,km.parseTuple=Fm,km.matchTuple=Om,km.compareTuples=Lm;var Rm=le((function(e){const t="function"==typeof __webpack_require__?__non_webpack_require__:he;"function"==typeof t.addon?e.exports=t.addon.bind(t):e.exports=Pm}));var Um={mask:(e,t,s,r,n)=>{for(var i=0;i<n;i++)s[r+i]=e[i]^t[3&i]},unmask:(e,t)=>{const s=e.length;for(var r=0;r<s;r++)e[r]^=t[3&r]}},qm=le((function(e){try{e.exports=Rm(__dirname)}catch(t){e.exports=Um}})),$m=le((function(e){const{EMPTY_BUFFER:t}=gm,s=Buffer[Symbol.species];function r(e,t,s,r,n){for(let i=0;i<n;i++)s[r+i]=e[i]^t[3&i]}function n(e,t){for(let s=0;s<e.length;s++)e[s]^=t[3&s]}if(e.exports={concat:function(e,r){if(0===e.length)return t;if(1===e.length)return e[0];const n=Buffer.allocUnsafe(r);let i=0;for(let t=0;t<e.length;t++){const s=e[t];n.set(s,i),i+=s.length}return i<r?new s(n.buffer,n.byteOffset,i):n},mask:r,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let r;return t instanceof ArrayBuffer?r=new s(t):ArrayBuffer.isView(t)?r=new s(t.buffer,t.byteOffset,t.byteLength):(r=Buffer.from(t),e.readOnly=!1),r},unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{const t=qm;e.exports.mask=function(e,s,n,i,a){a<48?r(e,s,n,i,a):t.mask(e,s,n,i,a)},e.exports.unmask=function(e,s){e.length<32?n(e,s):t.unmask(e,s)}}catch(e){}}));$m.concat,$m.mask,$m.toArrayBuffer,$m.toBuffer,$m.unmask;const zm=Symbol("kDone"),Hm=Symbol("kRun");var Vm=class{constructor(e){this[zm]=()=>{this.pending--,this[Hm]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Hm]()}[Hm](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[zm])}}};const{kStatusCode:Gm}=gm,Wm=Buffer[Symbol.species],Jm=Buffer.from([0,0,255,255]),Xm=Symbol("permessage-deflate"),Km=Symbol("total-length"),Ym=Symbol("callback"),Zm=Symbol("buffers"),Qm=Symbol("error");let ey;var ty=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!ey){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;ey=new Vm(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[Ym];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){ey.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){ey.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?V.default.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=V.default.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[Xm]=this,this._inflate[Km]=0,this._inflate[Zm]=[],this._inflate.on("error",ny),this._inflate.on("data",ry)}this._inflate[Ym]=s,this._inflate.write(e),t&&this._inflate.write(Jm),this._inflate.flush((()=>{const e=this._inflate[Qm];if(e)return this._inflate.close(),this._inflate=null,void s(e);const n=$m.concat(this._inflate[Zm],this._inflate[Km]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Km]=0,this._inflate[Zm]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,n)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?V.default.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=V.default.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[Km]=0,this._deflate[Zm]=[],this._deflate.on("data",sy)}this._deflate[Ym]=s,this._deflate.write(e),this._deflate.flush(V.default.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=$m.concat(this._deflate[Zm],this._deflate[Km]);t&&(e=new Wm(e.buffer,e.byteOffset,e.length-4)),this._deflate[Ym]=null,this._deflate[Km]=0,this._deflate[Zm]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function sy(e){this[Zm].push(e),this[Km]+=e.length}function ry(e){this[Km]+=e.length,this[Xm]._maxPayload<1||this[Km]<=this[Xm]._maxPayload?this[Zm].push(e):(this[Qm]=new RangeError("Max payload size exceeded"),this[Qm].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Qm][Gm]=1009,this.removeListener("data",ry),this.reset())}function ny(e){this[Xm]._inflate=null,e[Gm]=1007,this[Ym](e)}var iy=function(e){const t=e.length;let s=0;for(;s<t;)if(128&e[s])if(192==(224&e[s])){if(s+1===t||128!=(192&e[s+1])||192==(254&e[s]))return!1;s+=2}else if(224==(240&e[s])){if(s+2>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0},ay=le((function(e){try{e.exports=Rm(__dirname)}catch(t){e.exports=iy}})),oy=le((function(e){const{isUtf8:t}=ee.default;function s(e){const t=e.length;let s=0;for(;s<t;)if(128&e[s])if(192==(224&e[s])){if(s+1===t||128!=(192&e[s+1])||192==(254&e[s]))return!1;s+=2}else if(224==(240&e[s])){if(s+2>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0}if(e.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:s,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},t)e.exports.isValidUTF8=function(e){return e.length<24?s(e):t(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=ay;e.exports.isValidUTF8=function(e){return e.length<32?s(e):t(e)}}catch(e){}}));oy.isValidStatusCode,oy.isValidUTF8,oy.tokenChars;const{Writable:cy}=$.default,{BINARY_TYPES:uy,EMPTY_BUFFER:ly,kStatusCode:py,kWebSocket:hy}=gm,{concat:dy,toArrayBuffer:fy,unmask:my}=$m,{isValidStatusCode:yy,isValidUTF8:gy}=oy,xy=Buffer[Symbol.species];var vy=class extends cy{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||uy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[hy]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new xy(t.buffer,t.byteOffset+e,t.length-e),new xy(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new xy(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const s=!(64&~t[0]);if(!s||this._extensions[ty.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=s}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ly;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&my(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[ty.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?dy(s,t):"arraybuffer"===this._binaryType?fy(dy(s,t)):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)})))}else{const r=dy(s,t);if(!this._skipUTF8Validation&&!gy(r)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,ly),this.end();else{const s=e.readUInt16BE(0);if(!yy(s)){const e=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const r=new xy(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!gy(r)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0}}createError(e,t,s,r,n){this._loop=!1,this._errored=!0;const i=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=n,i[py]=r,i}};const{randomFillSync:by}=M.default,{EMPTY_BUFFER:Ey}=gm,{isValidStatusCode:Cy}=oy,{mask:Ay,toBuffer:wy}=$m,Dy=Symbol("kByteLength"),Ty=Buffer.alloc(4),Sy=8192;let Py,ky=Sy;class _y{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let s,r,n=!1,i=2,a=!1;t.mask&&(s=t.maskBuffer||Ty,t.generateMask?t.generateMask(s):(ky===Sy&&(void 0===Py&&(Py=Buffer.alloc(Sy)),by(Py,0,Sy),ky=0),s[0]=Py[ky++],s[1]=Py[ky++],s[2]=Py[ky++],s[3]=Py[ky++]),a=!(s[0]|s[1]|s[2]|s[3]),i=6),"string"==typeof e?r=t.mask&&!a||void 0===t[Dy]?(e=Buffer.from(e)).length:t[Dy]:(r=e.length,n=t.mask&&t.readOnly&&!a);let o=r;r>=65536?(i+=8,o=127):r>125&&(i+=2,o=126);const c=Buffer.allocUnsafe(n?r+i:i);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=o,126===o?c.writeUInt16BE(r,2):127===o&&(c[2]=c[3]=0,c.writeUIntBE(r,4,6)),t.mask?(c[1]|=128,c[i-4]=s[0],c[i-3]=s[1],c[i-2]=s[2],c[i-1]=s[3],a?[c,e]:n?(Ay(e,s,c,i,r),[c]):(Ay(e,s,e,0,r),[c,e])):[c,e]}close(e,t,s,r){let n;if(void 0===e)n=Ey;else{if("number"!=typeof e||!Cy(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+s),n.writeUInt16BE(e,0),"string"==typeof t?n.write(t,2):n.set(t,2)}else n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0)}const i={[Dy]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,i,r]):this.sendFrame(_y.frame(n,i),r)}ping(e,t,s){let r,n;if("string"==typeof e?(r=Buffer.byteLength(e),n=!1):(r=(e=wy(e)).length,n=wy.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[Dy]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,i,s]):this.sendFrame(_y.frame(e,i),s)}pong(e,t,s){let r,n;if("string"==typeof e?(r=Buffer.byteLength(e),n=!1):(r=(e=wy(e)).length,n=wy.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[Dy]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,i,s]):this.sendFrame(_y.frame(e,i),s)}send(e,t,s){const r=this._extensions[ty.extensionName];let n,i,a=t.binary?2:1,o=t.compress;if("string"==typeof e?(n=Buffer.byteLength(e),i=!1):(n=(e=wy(e)).length,i=wy.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=n>=r._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0),r){const r={[Dy]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:i,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,r,s]):this.dispatch(e,this._compress,r,s)}else this.sendFrame(_y.frame(e,{[Dy]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:i,rsv1:!1}),s)}dispatch(e,t,s,r){if(!t)return void this.sendFrame(_y.frame(e,s),r);const n=this._extensions[ty.extensionName];this._bufferedBytes+=s[Dy],this._deflating=!0,n.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t],r=s[s.length-1];"function"==typeof r&&r(e)}}else this._bufferedBytes-=s[Dy],this._deflating=!1,s.readOnly=!1,this.sendFrame(_y.frame(t,s),r),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][Dy],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Dy],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Ny=_y;const{kForOnEventAttribute:Iy,kListener:Fy}=gm,Oy=Symbol("kCode"),Ly=Symbol("kData"),By=Symbol("kError"),jy=Symbol("kMessage"),My=Symbol("kReason"),Ry=Symbol("kTarget"),Uy=Symbol("kType"),qy=Symbol("kWasClean");class $y{constructor(e){this[Ry]=null,this[Uy]=e}get target(){return this[Ry]}get type(){return this[Uy]}}Object.defineProperty($y.prototype,"target",{enumerable:!0}),Object.defineProperty($y.prototype,"type",{enumerable:!0});class zy extends $y{constructor(e,t={}){super(e),this[Oy]=void 0===t.code?0:t.code,this[My]=void 0===t.reason?"":t.reason,this[qy]=void 0!==t.wasClean&&t.wasClean}get code(){return this[Oy]}get reason(){return this[My]}get wasClean(){return this[qy]}}Object.defineProperty(zy.prototype,"code",{enumerable:!0}),Object.defineProperty(zy.prototype,"reason",{enumerable:!0}),Object.defineProperty(zy.prototype,"wasClean",{enumerable:!0});class Hy extends $y{constructor(e,t={}){super(e),this[By]=void 0===t.error?null:t.error,this[jy]=void 0===t.message?"":t.message}get error(){return this[By]}get message(){return this[jy]}}Object.defineProperty(Hy.prototype,"error",{enumerable:!0}),Object.defineProperty(Hy.prototype,"message",{enumerable:!0});class Vy extends $y{constructor(e,t={}){super(e),this[Ly]=void 0===t.data?null:t.data}get data(){return this[Ly]}}Object.defineProperty(Vy.prototype,"data",{enumerable:!0});const Gy={addEventListener(e,t,s={}){for(const r of this.listeners(e))if(!s[Iy]&&r[Fy]===t&&!r[Iy])return;let r;if("message"===e)r=function(e,s){const r=new Vy("message",{data:s?e:e.toString()});r[Ry]=this,Jy(t,this,r)};else if("close"===e)r=function(e,s){const r=new zy("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[Ry]=this,Jy(t,this,r)};else if("error"===e)r=function(e){const s=new Hy("error",{error:e,message:e.message});s[Ry]=this,Jy(t,this,s)};else{if("open"!==e)return;r=function(){const e=new $y("open");e[Ry]=this,Jy(t,this,e)}}r[Iy]=!!s[Iy],r[Fy]=t,s.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(const s of this.listeners(e))if(s[Fy]===t&&!s[Iy]){this.removeListener(e,s);break}}};var Wy={CloseEvent:zy,ErrorEvent:Hy,Event:$y,EventTarget:Gy,MessageEvent:Vy};function Jy(e,t,s){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,s):e.call(t,s)}const{tokenChars:Xy}=oy;function Ky(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}var Yy={format:function(e){return Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,n=Object.create(null),i=!1,a=!1,o=!1,c=-1,u=-1,l=-1,p=0;for(;p<e.length;p++)if(u=e.charCodeAt(p),void 0===s)if(-1===l&&1===Xy[u])-1===c&&(c=p);else if(0===p||32!==u&&9!==u){if(59!==u&&44!==u)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===l&&(l=p);const r=e.slice(c,l);44===u?(Ky(t,r,n),n=Object.create(null)):s=r,c=l=-1}}else-1===l&&-1!==c&&(l=p);else if(void 0===r)if(-1===l&&1===Xy[u])-1===c&&(c=p);else if(32===u||9===u)-1===l&&-1!==c&&(l=p);else if(59===u||44===u){if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===l&&(l=p),Ky(n,e.slice(c,l),!0),44===u&&(Ky(t,s,n),n=Object.create(null),s=void 0),c=l=-1}else{if(61!==u||-1===c||-1!==l)throw new SyntaxError(`Unexpected character at index ${p}`);r=e.slice(c,p),c=l=-1}else if(a){if(1!==Xy[u])throw new SyntaxError(`Unexpected character at index ${p}`);-1===c?c=p:i||(i=!0),a=!1}else if(o)if(1===Xy[u])-1===c&&(c=p);else if(34===u&&-1!==c)o=!1,l=p;else{if(92!==u)throw new SyntaxError(`Unexpected character at index ${p}`);a=!0}else if(34===u&&61===e.charCodeAt(p-1))o=!0;else if(-1===l&&1===Xy[u])-1===c&&(c=p);else if(-1===c||32!==u&&9!==u){if(59!==u&&44!==u)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===l&&(l=p);let a=e.slice(c,l);i&&(a=a.replace(/\\/g,""),i=!1),Ky(n,r,a),44===u&&(Ky(t,s,n),n=Object.create(null),s=void 0),r=void 0,c=l=-1}}else-1===l&&(l=p);if(-1===c||o||32===u||9===u)throw new SyntaxError("Unexpected end of input");-1===l&&(l=p);const h=e.slice(c,l);return void 0===s?Ky(t,h,n):(void 0===r?Ky(n,h,!0):Ky(n,r,i?h.replace(/\\/g,""):h),Ky(t,s,n)),t}};const{randomBytes:Zy,createHash:Qy}=M.default,{URL:eg}=q.default,{BINARY_TYPES:tg,EMPTY_BUFFER:sg,GUID:rg,kForOnEventAttribute:ng,kListener:ig,kStatusCode:ag,kWebSocket:og,NOOP:cg}=gm,{EventTarget:{addEventListener:ug,removeEventListener:lg}}=Wy,{format:pg,parse:hg}=Yy,{toBuffer:dg}=$m,fg=Symbol("kAborted"),mg=[8,13],yg=["CONNECTING","OPEN","CLOSING","CLOSED"],gg=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class xg extends Z.default{constructor(e,t,s){super(),this._binaryType=tg[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=sg,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=xg.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(s=t,t=[]):t=[t]),bg(this,e,t,s)):(this._autoPong=s.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){tg.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){const r=new vy({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new Ny(e,this._extensions,s.generateMask),this._receiver=r,this._socket=e,r[og]=this,e[og]=this,r.on("conclude",Tg),r.on("drain",Sg),r.on("error",Pg),r.on("message",_g),r.on("ping",Ng),r.on("pong",Ig),e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Og),e.on("data",Lg),e.on("end",Bg),e.on("error",jg),this._readyState=xg.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=xg.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[ty.extensionName]&&this._extensions[ty.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=xg.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==xg.CLOSED)if(this.readyState!==xg.CONNECTING)this.readyState!==xg.CLOSING?(this._readyState=xg.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";wg(this,this._req,e)}}pause(){this.readyState!==xg.CONNECTING&&this.readyState!==xg.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===xg.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===xg.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||sg,t,s)):Dg(this,e,s)}pong(e,t,s){if(this.readyState===xg.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===xg.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||sg,t,s)):Dg(this,e,s)}resume(){this.readyState!==xg.CONNECTING&&this.readyState!==xg.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===xg.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==xg.OPEN)return void Dg(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[ty.extensionName]||(r.compress=!1),this._sender.send(e||sg,r,s)}terminate(){if(this.readyState!==xg.CLOSED)if(this.readyState!==xg.CONNECTING)this._socket&&(this._readyState=xg.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";wg(this,this._req,e)}}}Object.defineProperty(xg,"CONNECTING",{enumerable:!0,value:yg.indexOf("CONNECTING")}),Object.defineProperty(xg.prototype,"CONNECTING",{enumerable:!0,value:yg.indexOf("CONNECTING")}),Object.defineProperty(xg,"OPEN",{enumerable:!0,value:yg.indexOf("OPEN")}),Object.defineProperty(xg.prototype,"OPEN",{enumerable:!0,value:yg.indexOf("OPEN")}),Object.defineProperty(xg,"CLOSING",{enumerable:!0,value:yg.indexOf("CLOSING")}),Object.defineProperty(xg.prototype,"CLOSING",{enumerable:!0,value:yg.indexOf("CLOSING")}),Object.defineProperty(xg,"CLOSED",{enumerable:!0,value:yg.indexOf("CLOSED")}),Object.defineProperty(xg.prototype,"CLOSED",{enumerable:!0,value:yg.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(xg.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(xg.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[ng])return t[ig];return null},set(t){for(const t of this.listeners(e))if(t[ng]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[ng]:!0})}})})),xg.prototype.addEventListener=ug,xg.prototype.removeEventListener=lg;var vg=xg;function bg(e,t,s,r){const n={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:mg[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=n.autoPong,!mg.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${mg.join(", ")})`);let i;if(t instanceof eg)i=t;else try{i=new eg(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===i.protocol?i.protocol="ws:":"https:"===i.protocol&&(i.protocol="wss:"),e._url=i.href;const a="wss:"===i.protocol,o="ws+unix:"===i.protocol;let c;if("ws:"===i.protocol||a||o?o&&!i.pathname?c="The URL's pathname is empty":i.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void Eg(e,t)}const u=a?443:80,l=Zy(16).toString("base64"),p=a?U.default.request:R.default.request,h=new Set;let d,f;if(n.createConnection=n.createConnection||(a?Ag:Cg),n.defaultPort=n.defaultPort||u,n.port=i.port||u,n.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,n.headers={...n.headers,"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},n.path=i.pathname+i.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(d=new ty(!0!==n.perMessageDeflate?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=pg({[ty.extensionName]:d.offer()})),s.length){for(const e of s){if("string"!=typeof e||!gg.test(e)||h.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");h.add(e)}n.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(i.username||i.password)&&(n.auth=`${i.username}:${i.password}`),o){const e=n.path.split(":");n.socketPath=e[0],n.path=e[1]}if(n.followRedirects){if(0===e._redirects){e._originalIpc=o,e._originalSecure=a,e._originalHostOrSocketPath=o?n.socketPath:i.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=o?!!e._originalIpc&&n.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&i.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!a)&&(delete n.headers.authorization,delete n.headers.cookie,t||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),f=e._req=p(n),e._redirects&&e.emit("redirect",e.url,f)}else f=e._req=p(n);n.timeout&&f.on("timeout",(()=>{wg(e,f,"Opening handshake has timed out")})),f.on("error",(t=>{null===f||f[fg]||(f=e._req=null,Eg(e,t))})),f.on("response",(i=>{const a=i.headers.location,o=i.statusCode;if(a&&n.followRedirects&&o>=300&&o<400){if(++e._redirects>n.maxRedirects)return void wg(e,f,"Maximum redirects exceeded");let i;f.abort();try{i=new eg(a,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${a}`);return void Eg(e,s)}bg(e,i,s,r)}else e.emit("unexpected-response",f,i)||wg(e,f,`Unexpected server response: ${i.statusCode}`)})),f.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==xg.CONNECTING)return;f=e._req=null;const i=t.headers.upgrade;if(void 0===i||"websocket"!==i.toLowerCase())return void wg(e,s,"Invalid Upgrade header");const a=Qy("sha1").update(l+rg).digest("base64");if(t.headers["sec-websocket-accept"]!==a)return void wg(e,s,"Invalid Sec-WebSocket-Accept header");const o=t.headers["sec-websocket-protocol"];let c;if(void 0!==o?h.size?h.has(o)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":h.size&&(c="Server sent no subprotocol"),c)return void wg(e,s,c);o&&(e._protocol=o);const u=t.headers["sec-websocket-extensions"];if(void 0!==u){if(!d){return void wg(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=hg(u)}catch(t){return void wg(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==ty.extensionName){return void wg(e,s,"Server indicated an extension that was not requested")}try{d.accept(t[ty.extensionName])}catch(t){return void wg(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[ty.extensionName]=d}e.setSocket(s,r,{allowSynchronousEvents:n.allowSynchronousEvents,generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})})),n.finishRequest?n.finishRequest(f,e):f.end()}function Eg(e,t){e._readyState=xg.CLOSING,e.emit("error",t),e.emitClose()}function Cg(e){return e.path=e.socketPath,J.default.connect(e)}function Ag(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=J.default.isIP(e.host)?"":e.host),Q.default.connect(e)}function wg(e,t,s){e._readyState=xg.CLOSING;const r=new Error(s);Error.captureStackTrace(r,wg),t.setHeader?(t[fg]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Eg,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Dg(e,t,s){if(t){const s=dg(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${yg[e.readyState]})`);process.nextTick(s,t)}}function Tg(e,t){const s=this[og];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[og]&&(s._socket.removeListener("data",Lg),process.nextTick(Fg,s._socket),1005===e?s.close():s.close(e,t))}function Sg(){const e=this[og];e.isPaused||e._socket.resume()}function Pg(e){const t=this[og];void 0!==t._socket[og]&&(t._socket.removeListener("data",Lg),process.nextTick(Fg,t._socket),t.close(e[ag])),t.emit("error",e)}function kg(){this[og].emitClose()}function _g(e,t){this[og].emit("message",e,t)}function Ng(e){const t=this[og];t._autoPong&&t.pong(e,!this._isServer,cg),t.emit("ping",e)}function Ig(e){this[og].emit("pong",e)}function Fg(e){e.resume()}function Og(){const e=this[og];let t;this.removeListener("close",Og),this.removeListener("data",Lg),this.removeListener("end",Bg),e._readyState=xg.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[og]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",kg),e._receiver.on("finish",kg))}function Lg(e){this[og]._receiver.write(e)||this.pause()}function Bg(){const e=this[og];e._readyState=xg.CLOSING,e._receiver.end(),this.end()}function jg(){const e=this[og];this.removeListener("error",jg),this.on("error",cg),e&&(e._readyState=xg.CLOSING,this.destroy())}const{Duplex:Mg}=$.default;function Rg(e){e.emit("close")}function Ug(){!this.destroyed&&this._writableState.finished&&this.destroy()}function qg(e){this.removeListener("error",qg),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var $g=function(e,t){let s=!0;const r=new Mg({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const n=!s&&r._readableState.objectMode?t.toString():t;r.push(n)||e.pause()})),e.once("error",(function(e){r.destroyed||(s=!1,r.destroy(e))})),e.once("close",(function(){r.destroyed||r.push(null)})),r._destroy=function(t,n){if(e.readyState===e.CLOSED)return n(t),void process.nextTick(Rg,r);let i=!1;e.once("error",(function(e){i=!0,n(e)})),e.once("close",(function(){i||n(t),process.nextTick(Rg,r)})),s&&e.terminate()},r._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){r._final(t)}))},r._read=function(){e.isPaused&&e.resume()},r._write=function(t,s,n){e.readyState!==e.CONNECTING?e.send(t,n):e.once("open",(function(){r._write(t,s,n)}))},r.on("end",Ug),r.on("error",qg),r};const{tokenChars:zg}=oy;var Hg={parse:function(e){const t=new Set;let s=-1,r=-1,n=0;for(;n<e.length;n++){const i=e.charCodeAt(n);if(-1===r&&1===zg[i])-1===s&&(s=n);else if(0===n||32!==i&&9!==i){if(44!==i)throw new SyntaxError(`Unexpected character at index ${n}`);{if(-1===s)throw new SyntaxError(`Unexpected character at index ${n}`);-1===r&&(r=n);const i=e.slice(s,r);if(t.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);t.add(i),s=r=-1}}else-1===r&&-1!==s&&(r=n)}if(-1===s||-1!==r)throw new SyntaxError("Unexpected end of input");const i=e.slice(s,n);if(t.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return t.add(i),t}};const{createHash:Vg}=M.default,{GUID:Gg,kWebSocket:Wg}=gm,Jg=/^[+/0-9A-Za-z]{22}==$/;class Xg extends Z.default{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:vg,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=R.default.createServer(((e,t)=>{const s=R.default.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(Yg,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(Yg,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{Yg(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",Zg);const n=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void ex(this,e,t,405,"Invalid HTTP method")}if(void 0===i||"websocket"!==i.toLowerCase()){return void ex(this,e,t,400,"Invalid Upgrade header")}if(void 0===n||!Jg.test(n)){return void ex(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==a&&13!==a){return void ex(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void Qg(t,400);const o=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==o)try{c=Hg.parse(o)}catch(s){return void ex(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const u=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&void 0!==u){const s=new ty(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=Yy.parse(u);e[ty.extensionName]&&(s.accept(e[ty.extensionName]),l[ty.extensionName]=s)}catch(s){return void ex(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const i={origin:e.headers[""+(8===a?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(i,((i,a,o,u)=>{if(!i)return Qg(t,a||401,o,u);this.completeUpgrade(l,n,c,e,t,s,r)}));if(!this.options.verifyClient(i))return Qg(t,401)}this.completeUpgrade(l,n,c,e,t,s,r)}completeUpgrade(e,t,s,r,n,i,a){if(!n.readable||!n.writable)return n.destroy();if(n[Wg])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return Qg(n,503);const o=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Vg("sha1").update(t+Gg).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(o.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[ty.extensionName]){const t=e[ty.extensionName].params,s=Yy.format({[ty.extensionName]:[t]});o.push(`Sec-WebSocket-Extensions: ${s}`),c._extensions=e}this.emit("headers",o,r),n.write(o.concat("\r\n").join("\r\n")),n.removeListener("error",Zg),c.setSocket(n,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Yg,this)}))),a(c,r)}}var Kg=Xg;function Yg(e){e._state=2,e.emit("close")}function Zg(){this.destroy()}function Qg(e,t,s,r){s=s||R.default.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${R.default.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function ex(e,t,s,r,n){if(e.listenerCount("wsClientError")){const r=new Error(n);Error.captureStackTrace(r,ex),e.emit("wsClientError",r,s,t)}else Qg(s,r,n)}vg.createWebSocketStream=$g,vg.Server=Kg,vg.Receiver=vy,vg.Sender=Ny,vg.WebSocket=vg,vg.WebSocketServer=vg.Server;const tx=vg,sx=process.nextTick,rx="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const nx={websocket:class extends Qf{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,s=rx?{}:Jf(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=new tx(e,t,s)}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 s=e[t],r=t===e.length-1;Bf(s,this.supportsBinary,(e=>{const t={};if(s.options&&(t.compress=s.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){}r&&sx((()=>{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]=om()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!tx}},webtransport:class extends Qf{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){zf||(zf=new TextDecoder);const s=[];let r=0,n=-1,i=!1;return new TransformStream({transform(a,o){for(s.push(a);;){if(0===r){if(Hf(s)<1)break;const e=Vf(s,1);i=!(128&~e[0]),n=127&e[0],r=n<126?3:126===n?1:2}else if(1===r){if(Hf(s)<2)break;const e=Vf(s,2);n=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(Hf(s)<8)break;const e=Vf(s,8),t=new DataView(e.buffer,e.byteOffset,e.length),i=t.getUint32(0);if(i>Math.pow(2,21)-1){o.enqueue(Lf);break}n=i*Math.pow(2,32)+t.getUint32(4),r=3}else{if(Hf(s)<n)break;const e=Vf(s,n);o.enqueue(Rf(i?e:zf.decode(e),t)),r=0}if(0===n||n>e){o.enqueue(Lf);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=$f();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const n=()=>{s.read().then((({done:e,value:t})=>{e||(this.onPacket(t),n())})).catch((e=>{}))};n();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this.writer.write(i).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this.writer.write(s).then((()=>{r&&sx((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends Qf{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let s=location.port;s||(s=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||s!==e.port}const t=e&&e.forceBase64;this.supportsBinary=fm&&!t,this.opts.withCredentials&&(this.cookieJar=new hm)}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 s=e.split(qf),r=[];for(let e=0;e<s.length;e++){const n=Rf(s[e],t);if(r.push(n),"error"===n.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const s=e.length,r=new Array(s);let n=0;e.forEach(((e,i)=>{Bf(e,!1,(e=>{r[i]=e,++n===s&&t(r.join(qf))}))}))})(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]=om()),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 mm(this.uri(),e)}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.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}}},ix=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ax=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ox(e){if(e.length>2e3)throw"URI too long";const t=e,s=e.indexOf("["),r=e.indexOf("]");-1!=s&&-1!=r&&(e=e.substring(0,s)+e.substring(s,r).replace(/:/g,";")+e.substring(r,e.length));let n=ix.exec(e||""),i={},a=14;for(;a--;)i[ax[a]]=n[a]||"";return-1!=s&&-1!=r&&(i.source=t,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=function(e,t){const s=/\/{2,9}/g,r=t.replace(s,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,i.path),i.queryKey=function(e,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(s[t]=r)})),s}(0,i.query),i}class cx extends Gf{constructor(e,t={}){super(),this.binaryType="nodebuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=ox(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=ox(t.host).host),Yf(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={},s=e.split("&");for(let e=0,r=s.length;e<r;e++){let r=s[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[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 s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new nx[e](s)}open(){let e;if(this.opts.rememberUpgrade&&cx.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}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",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),s=!1;cx.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!s)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;cx.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function n(){s||(s=!0,u(),t.close(),t=null)}const i=e=>{const s=new Error("probe error: "+e);s.transport=t.name,n(),this.emitReserved("upgradeError",s)};function a(){i("transport closed")}function o(){i("socket closed")}function c(e){t&&e.name!==t.name&&n()}const u=()=>{t.removeListener("open",r),t.removeListener("error",i),t.removeListener("close",a),this.off("close",o),this.off("upgrading",c)};t.once("open",r),t.once("error",i),t.once("close",a),this.once("close",o),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{s||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",cx.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 s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,s=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(r++,s+=4);return s}(t):Math.ceil(1.33*(t.byteLength||t.size))),s>0&&e>this.maxPayload)return this.writeBuffer.slice(0,s);e+=2}var t;return this.writeBuffer}write(e,t,s){return this.sendPacket("message",e,t,s),this}send(e,t,s){return this.sendPacket("message",e,t,s),this}sendPacket(e,t,s,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof s&&(r=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const n={type:e,data:t,options:s};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{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?s():e()})):this.upgrading?s():e()),this}onError(e){cx.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}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 s=0;const r=e.length;for(;s<r;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}cx.protocol=4;const ux="function"==typeof ArrayBuffer,lx=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,px=Object.prototype.toString,hx="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===px.call(Blob),dx="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===px.call(File);function fx(e){return ux&&(e instanceof ArrayBuffer||lx(e))||hx&&e instanceof Blob||dx&&e instanceof File}function mx(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,s=e.length;t<s;t++)if(mx(e[t]))return!0;return!1}if(fx(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return mx(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&mx(e[t]))return!0;return!1}function yx(e){const t=[],s=e.data,r=e;return r.data=gx(s,t),r.attachments=t.length,{packet:r,buffers:t}}function gx(e,t){if(!e)return e;if(fx(e)){const s={_placeholder:!0,num:t.length};return t.push(e),s}if(Array.isArray(e)){const s=new Array(e.length);for(let r=0;r<e.length;r++)s[r]=gx(e[r],t);return s}if("object"==typeof e&&!(e instanceof Date)){const s={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=gx(e[r],t));return s}return e}function xx(e,t){return e.data=vx(e.data,t),delete e.attachments,e}function vx(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 s=0;s<e.length;s++)e[s]=vx(e[s],t);else if("object"==typeof e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(e[s]=vx(e[s],t));return e}const bx=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ex;!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"}(Ex||(Ex={}));function Cx(e){return"[object Object]"===Object.prototype.toString.call(e)}class Ax extends Gf{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 s=t.type===Ex.BINARY_EVENT;s||t.type===Ex.BINARY_ACK?(t.type=s?Ex.EVENT:Ex.ACK,this.reconstructor=new wx(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!fx(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 s={type:Number(e.charAt(0))};if(void 0===Ex[s.type])throw new Error("unknown packet type "+s.type);if(s.type===Ex.BINARY_EVENT||s.type===Ex.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const n=e.substring(r,t);if(n!=Number(n)||"-"!==e.charAt(t))throw new Error("Illegal attachments");s.attachments=Number(n)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}s.nsp=e.substring(r,t)}else s.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const s=e.charAt(t);if(null==s||Number(s)!=s){--t;break}if(t===e.length)break}s.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!Ax.isPayloadValid(s.type,r))throw new Error("invalid payload");s.data=r}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Ex.CONNECT:return Cx(t);case Ex.DISCONNECT:return void 0===t;case Ex.CONNECT_ERROR:return"string"==typeof t||Cx(t);case Ex.EVENT:case Ex.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===bx.indexOf(t[0]));case Ex.ACK:case Ex.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class wx{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=xx(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Dx=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Ex},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Ex.EVENT&&e.type!==Ex.ACK||!mx(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Ex.EVENT?Ex.BINARY_EVENT:Ex.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Ex.BINARY_EVENT&&e.type!==Ex.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=yx(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}},Decoder:Ax});function Tx(e,t,s){return e.on(t,s),function(){e.off(t,s)}}const Sx=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Px extends Gf{constructor(e,t,s){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,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Tx(e,"open",this.onopen.bind(this)),Tx(e,"packet",this.onpacket.bind(this)),Tx(e,"error",this.onerror.bind(this)),Tx(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(Sx.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 s={type:Ex.EVENT,data:t,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),s.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var s;const r=null!==(s=this.flags.timeout)&&void 0!==s?s:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const n=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r),i=(...e)=>{this.io.clearTimeoutFn(n),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise(((s,r)=>{const n=(e,t)=>e?r(e):s(t);n.withError=!0,t.push(n),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(s!==this._queue[0])return;return null!==e?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),s.pending=!1,this._drainQueue()})),this._queue.push(s),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:Ex.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 Ex.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 Ex.EVENT:case Ex.BINARY_EVENT:this.onevent(e);break;case Ex.ACK:case Ex.BINARY_ACK:this.onack(e);break;case Ex.DISCONNECT:this.ondisconnect();break;case Ex.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 s of t)s.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 s=!1;return function(...r){s||(s=!0,t.packet({type:Ex.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ex.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 s=0;s<t.length;s++)if(e===t[s])return t.splice(s,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 s=0;s<t.length;s++)if(e===t[s])return t.splice(s,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 s of t)s.apply(this,e.data)}}}function kx(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}kx.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+s:e-s}return 0|Math.min(e,this.max)},kx.prototype.reset=function(){this.attempts=0},kx.prototype.setMin=function(e){this.ms=e},kx.prototype.setMax=function(e){this.max=e},kx.prototype.setJitter=function(e){this.jitter=e};class _x extends Gf{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,Yf(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!==(s=t.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new kx({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Dx;this.encoder=new r.Encoder,this.decoder=new r.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 cx(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Tx(t,"open",(function(){s.onopen(),e&&e()})),n=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=Tx(t,"error",n);if(!1!==this._timeout){const e=this._timeout,s=this.setTimeoutFn((()=>{r(),n(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}return this.subs.push(r),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(Tx(e,"ping",this.onping.bind(this)),Tx(e,"data",this.ondata.bind(this)),Tx(e,"error",this.onerror.bind(this)),Tx(e,"close",this.onclose.bind(this)),Tx(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){sx((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new Px(this,e,t),this.nsps[e]=s),s}_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 s=0;s<t.length;s++)this.engine.write(t[s],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 s=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&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Nx={};function Ix(e,t){"object"==typeof e&&(t=e,e=void 0);const s=function(e,t="",s){let r=e;s=s||"undefined"!=typeof location&&location,null==e&&(e=s.protocol+"//"+s.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?s.protocol+e:s.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==s?s.protocol+"//"+e:"https://"+e),r=ox(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const n=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+t,r.href=r.protocol+"://"+n+(s&&s.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=s.source,n=s.id,i=s.path,a=Nx[n]&&i in Nx[n].nsps;let o;return t.forceNew||t["force new connection"]||!1===t.multiplex||a?o=new _x(r,t):(Nx[n]||(Nx[n]=new _x(r,t)),o=Nx[n]),s.query&&!t.query&&(t.query=s.queryKey),o.socket(s.path,t)}Object.assign(Ix,{Manager:_x,Socket:Px,io:Ix,connect:Ix});var Fx="wss://editor.appthen.com",Ox=process.env.IsDev,Lx=function(){function e(e){this.connectState="connecting",this.connectStateText="连接中...",this.roomId="",this.account="",this.config=e}return e.prototype.joinRoom=function(e){var t,s=e.roomId,r=e.account;this.roomId=s,this.account=r,null===(t=this.socket)||void 0===t||t.emit("join",{room:s,account:r})},e.prototype.leaveRoom=function(){var e;null===(e=this.socket)||void 0===e||e.emit("leave",{room:this.roomId,account:this.account})},e.prototype.sendMessage=function(e){var t;null===(t=this.socket)||void 0===t||t.emit("message",{room:this.roomId,message:e})},e.prototype.connect=function(){var e=this,t=this.config,s=t.onconnect,r=t.onreconnect,n=t.onmsg;console.log("connect socket.io",Fx);var i=Ix(Fx,{transports:["websocket"]});this.onConnectChange("connecting"),i.on("opend",(function(t){e.onConnectChange("connect")})),i.on("message",(function(e){Ox&&console.log("socket.io message event",e),null==n||n(e)})),i.on("connect",(function(){Ox&&console.log("socket.io connect event"),s()})),i.on("disconnect",(function(){Ox&&console.log("socket.io disconnect event"),e.onConnectChange("disconnect")})),i.on("connect_error",(function(t){Ox&&console.log("socket.io connect_error event",t),e.onConnectChange("connect_error")})),i.on("connect_timeout",(function(){Ox&&console.log("socket.io connect_timeout event"),e.onConnectChange("connect_timeout")})),i.on("reconnect",(function(){Ox&&console.log("socket.io reconnect event"),null==r||r(),e.onConnectChange("reconnect")})),i.on("reconnect_attempt",(function(){Ox&&console.log("socket.io reconnect_attempt event"),e.onConnectChange("reconnect_attempt")})),i.on("reconnecting",(function(){Ox&&console.log("socket.io reconnecting event"),e.onConnectChange("reconnecting")})),i.on("reconnect_error",(function(){Ox&&console.log("socket.io reconnect_error event"),e.onConnectChange("reconnect_error")})),i.on("reconnect_failed",(function(){Ox&&console.log("socket.io reconnect_failed event"),e.onConnectChange("reconnect_failed")})),this.socket=i},e.prototype.onConnectChange=function(e){var t=this;switch(this.connectState=e,e){case"connecting":case"reconnecting":this.connectStateText="连接中...";break;case"connect":case"reconnect":this.connectStateText="连接成功",setTimeout((function(){t.connectStateText=""}),1500);break;case"disconnect":this.connectStateText="未连接";break;case"connect_error":case"reconnect_error":case"reconnect_failed":this.connectStateText="请检查网络";break;case"connect_timeout":this.connectStateText="连接超时"}},e}();exports.create=function(e){return ne(this,void 0,void 0,(function(){var t,s,r,n,i,a,o,c,u;return ie(this,(function(l){switch(l.label){case 0:s=(t=e||{}).template,r=void 0===s?"vite":s,n=t.folder,i=void 0===n?"appthen-assets-starter":n,console.log("template: ",r),l.label=1;case 1:return l.trys.push([1,6,,7]),[4,ja("/material/templates",{},{method:"GET"})];case 2:return a=l.sent(),o=a.data,c=o.find((function(e){return e.name===r})),c?[4,If(c,c.url,i)]:[3,4];case 3:return l.sent(),[3,5];case 4:console.log("[ERROR] ","template not found"),l.label=5;case 5:return[3,7];case 6:throw u=l.sent(),console.log("[e] ",u),u;case 7:return[2,1]}}))}))},exports.fuck=function(){},exports.getPureValue=Ud,exports.initSolution=function(e,t){return ne(this,void 0,void 0,(function(){var s,r,n,i,a,o,c,u,l,p,h,d,f;return ie(this,(function(m){switch(m.label){case 0:return m.trys.push([0,11,,12]),s=process.cwd(),r=e[0]||"hello",n=_.resolve(s,r),"."===r&&(r=_.basename(s),n=s),i=function(e){return e.replace(/hello-world/g,Mh(r)).replace(/HelloWorld/g,Rh(r)).replace(/Hello World/g,jh(r))},[4,Hd(n)];case 1:m.sent(),a=[{file:".editorconfig",content:"root = true\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\nquote_type = single\n\n[*.md]\ntrim_trailing_whitespace = false\n"},{file:".eslintignore",content:"# 忽略目录\nnode_modules/\nbuild/\ndist/\ntest-cases/\ntest/\ntests/\noutput/\nes/\nlib/\ncoverage/\n\n# 忽略文件\n**/*.min.js\n**/*-min.js\n**/*.bundle.js\n"},{file:".eslintrc.js",content:"module.exports = {\n extends: 'eslint-config-ali/typescript/react',\n rules: {\n 'max-len': ['error', { code: 200 }],\n 'comma-dangle': 0,\n },\n};\n"},{file:".gitignore",content:"# project custom\nbuild\nes\nlib\ndist\noutput\npackage-lock.json\ndeploy-space/packages\ndeploy-space/.env\ngenerated\n\n# IDE\n.vscode\n.idea\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\nlib\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# TypeScript v1 declaration files\ntypings/\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variables file\n.env\n.env.test\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n\n# next.js build output\n.next\n\n# nuxt.js build output\n.nuxt\n\n# vuepress build output\n.vuepress/dist\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# mac config files\n.DS_Store\n\n# codealike\ncodealike.json\n.node\n"},{file:".prettierignore",content:"/test-cases/"},{file:".prettierrc",content:'{\n "tabWidth": 2,\n "singleQuote": true,\n "trailingComma": "es5"\n}\n'},{file:"CHANGELOG.md",content:""},{file:"CONTRIBUTING.md",content:"# 欢迎共建\n\n# 注意\n\n- 注意解决 eslint 问题\n- 注意代码格式化 -- 建议安装 prettier 插件\n- 发布前注意要跑通 demo 和所有的单测\n\n## 本地调试运行 Demo\n\n```sh\n> npm run demo\n```\n\n## 本地跑单测\n\n```sh\n> npm test\n```\n"},{file:"README.md",content:"# 低代码出码自定义方案之 Hello World\n\n## 直接执行\n\n```sh\n> npx ali-lowcode-solution-hello-world demo-schema.json\n```\n\n## 本地调试运行 Demo\n\n```sh\n> npm run demo\n```\n"},{file:"demo-schema.json",content:'{\n "version": "1.0.0",\n "componentsMap": [\n {\n "componentName": "Button",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Button"\n },\n {\n "componentName": "Button.Group",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Button",\n "subName": "Group"\n },\n {\n "componentName": "Input",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Input"\n },\n {\n "componentName": "Form",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Form"\n },\n {\n "componentName": "Form.Item",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Form",\n "subName": "Item"\n },\n {\n "componentName": "NumberPicker",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "NumberPicker"\n },\n {\n "componentName": "Select",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Select"\n }\n ],\n "componentsTree": [\n {\n "componentName": "Page",\n "id": "node$1",\n "meta": {\n "title": "测试",\n "router": "/"\n },\n "props": {\n "ref": "outterView",\n "autoLoading": true\n },\n "fileName": "test",\n "state": {\n "text": "outter"\n },\n "lifeCycles": {\n "componentDidMount": {\n "type": "IPublicTypeJSExpression",\n "value": "function() { console.log(\'componentDidMount\'); }"\n }\n },\n "methodsModule": {\n "type": "JSModule",\n "source": "export function helloWorld() {\\n console.log(\'Hello world!\');\\n}\\n"\n },\n "dataSource": {\n "list": [\n {\n "id": "urlParams",\n "type": "urlParams"\n },\n\n {\n "id": "user",\n "type": "fetch",\n "options": {\n "method": "GET",\n "uri": "https://shs.xxx.com/mock/1458/demo/user",\n "isSync": true\n },\n "dataHandler": {\n "type": "IPublicTypeJSExpression",\n "value": "function (response) {\\nif (!response.data.success){\\n throw new Error(response.data.message);\\n }\\n return response.data.data;\\n}"\n }\n },\n\n {\n "id": "orders",\n "type": "fetch",\n "options": {\n "method": "GET",\n "uri": "https://shs.xxx.com/mock/1458/demo/orders",\n "isSync": true\n },\n "dataHandler": {\n "type": "IPublicTypeJSExpression",\n "value": "function (response) {\\nif (!response.data.success){\\n throw new Error(response.data.message);\\n }\\n return response.data.data.result;\\n}"\n }\n }\n ],\n "dataHandler": {\n "type": "IPublicTypeJSExpression",\n "value": "function (dataMap) {\\n console.info(\\"All datasources loaded:\\", dataMap);\\n}"\n }\n },\n "children": [\n {\n "componentName": "Form",\n "id": "node$2",\n "props": {\n "labelCol": {\n "type": "IPublicTypeJSExpression",\n "value": "this.state.colNum"\n },\n "style": {},\n "ref": "testForm"\n },\n "children": [\n {\n "componentName": "Form.Item",\n "id": "node$3",\n "props": {\n "label": "姓名:",\n "name": "name",\n "initValue": "李雷"\n },\n "children": [\n {\n "componentName": "Input",\n "id": "node$4",\n "props": {\n "placeholder": "请输入",\n "size": "medium",\n "style": {\n "width": 320\n }\n }\n }\n ]\n },\n {\n "componentName": "Form.Item",\n "id": "node$5",\n "props": {\n "label": "年龄:",\n "name": "age",\n "initValue": "22"\n },\n "children": [\n {\n "componentName": "NumberPicker",\n "id": "node$6",\n "props": {\n "size": "medium",\n "type": "normal"\n }\n }\n ]\n },\n {\n "componentName": "Form.Item",\n "id": "node$7",\n "props": {\n "label": "职业:",\n "name": "profession"\n },\n "children": [\n {\n "componentName": "Select",\n "id": "node$8",\n "props": {\n "dataSource": [\n {\n "label": "教师",\n "value": "t"\n },\n {\n "label": "医生",\n "value": "d"\n },\n {\n "label": "歌手",\n "value": "s"\n }\n ]\n }\n }\n ]\n },\n {\n "componentName": "Div",\n "id": "node$9",\n "props": {\n "style": {\n "textAlign": "center"\n }\n },\n "children": [\n {\n "componentName": "Button.Group",\n "id": "node$a",\n "props": {},\n "children": [\n {\n "componentName": "Button",\n "id": "node$b",\n "condition": {\n "type": "IPublicTypeJSExpression",\n "value": "this.index >= 1"\n },\n "loop": ["a", "b", "c"],\n "props": {\n "type": "primary",\n "style": {\n "margin": "0 5px 0 5px"\n }\n },\n "children": [\n {\n "type": "IPublicTypeJSExpression",\n "value": "this.item"\n }\n ]\n }\n ]\n }\n ]\n }\n ]\n }\n ]\n }\n ],\n "constants": {\n "ENV": "prod",\n "DOMAIN": "xxx.xxx.com"\n },\n "css": "body {font-size: 12px;} .table { width: 100px;}",\n "config": {\n "sdkVersion": "1.0.3",\n "historyMode": "hash",\n "targetRootID": "J_Container",\n "layout": {\n "componentName": "BasicLayout",\n "props": {\n "logo": "...",\n "name": "测试网站"\n }\n },\n "theme": {\n "package": "@alife/theme-fusion",\n "version": "^0.1.0",\n "primary": "#ff9966"\n }\n },\n "meta": {\n "name": "demo应用",\n "git_group": "appGroup",\n "project_name": "app_demo",\n "description": "这是一个测试应用",\n "spma": "spa23d",\n "creator": "月飞"\n }\n}\n'},{file:"jest.config.js",content:"module.exports = {\n preset: 'ts-jest',\n testEnvironment: 'node',\n testPathIgnorePatterns: ['/node_modules/', '/test-cases/', '/static-files/', '/lib/'],\n};\n"},{file:"package.json",content:'{\n "name": "ali-lowcode-solution-hello-world",\n "version": "1.0.0",\n "description": "AlLowCode Code Generate Solution - Hello World",\n "files": [\n "src",\n "lib",\n "tests",\n "jest.config.js",\n ".editorconfig",\n ".eslintignore",\n ".eslintrc.js",\n ".gitignore",\n ".prettierignore",\n ".prettierrc",\n "CHANGELOG.md",\n "CONTRIBUTING.md",\n "demo-schema.json",\n "package.json",\n "README.md",\n "tsconfig.json"\n ],\n "main": "lib/index.js",\n "scripts": {\n "start": "jest --watch",\n "build": "npm run clean && concurrently \'npm run build:ts\' \'npm run lint\'",\n "build:ts": "tsc",\n "check:type": "tsc -p . --noEmit",\n "clean": "rm -rf build dist lib generated",\n "dev": "build-scripts start",\n "lint": "eslint --ext .tsx,.ts,.js,.jsx src",\n "lintfix": "eslint --fix --color --ext .tsx,.ts,.js,.jsx src",\n "lint-staged": "lint-staged",\n "prepublishOnly": "npm run build",\n "postpublish": "git push origin master --tags",\n "test": "jest",\n "test:watch": "jest --watch",\n "test:update-snapshots": "cross-env UPDATE_EXPECTED=true npx jest",\n "demo": "npm run build && npx @alilc/lowcode-code-generator --solution . --output generated demo-schema.json"\n },\n "repository": {\n "type": "git",\n "url": "git@github.com:your-name/ali-lowcode-solution-hello-world.git"\n },\n "author": "",\n "license": "ISC",\n "publishConfig": {\n "registry": "https://registry.npm.xxx.com"\n },\n "dependencies": {\n "@alilc/lowcode-code-generator": "^1.0.0-beta.16",\n "@alilc/lowcode-types": "^1.0.0-beta.21",\n "tslib": "^2.3.0"\n },\n "devDependencies": {\n "@types/async": "^3.2.3",\n "@types/jest": "^26.0.17",\n "@typescript-eslint/eslint-plugin": "^4.28.4",\n "@typescript-eslint/parser": "^4.28.4",\n "async": "^3.2.0",\n "babel-runtime": "^6.26.0",\n "concurrently": "^5.2.0",\n "cross-env": "^7.0.0",\n "debug": "^4.1.1",\n "eslint": "^7.31.0",\n "eslint-config-ali": "^12.1.0",\n "eslint-plugin-import": "^2.23.4",\n "eslint-plugin-react": "^7.24.0",\n "eslint-plugin-react-hooks": "^4.2.0",\n "glob": "^7.2.0",\n "husky": "4.2.5",\n "jest": "^26.6.3",\n "json5": "^2.2.0",\n "lint-staged": "10.1.x",\n "lodash": "^4.17.21",\n "md5": "^2.2.1",\n "prettier": "^2.3.2",\n "ts-jest": "^26.4.4",\n "ts-node": "^9.0.0",\n "typescript": "4.x"\n }\n}\n'},{file:"tsconfig.json",content:'{\n "compilerOptions": {\n "esModuleInterop": true,\n "declaration": true,\n "experimentalDecorators": true,\n "forceConsistentCasingInFileNames": true,\n "importHelpers": true,\n "incremental": false,\n "jsx": "react",\n "moduleResolution": "node",\n "resolveJsonModule": true,\n "skipLibCheck": true,\n "sourceMap": true,\n "strict": true,\n "stripInternal": true,\n "outDir": "./lib",\n "declarationDir": "./lib",\n "rootDirs": ["./src"],\n "target": "es6",\n "module": "commonjs",\n "lib": ["esnext"],\n "types": ["jest", "node"],\n "noUnusedLocals": false,\n "noUnusedParameters": false\n },\n "include": ["src/**/*", "typings/**/*"]\n}\n'},{file:"src/index.ts",content:"import CodeGen from '@alilc/lowcode-code-generator';\n\nimport examplePlugin from './plugins/example';\n\nexport default function createHelloWorldProjectBuilder() {\n return CodeGen.createProjectBuilder({\n template: CodeGen.solutionParts.icejs.template,\n plugins: {\n components: [\n CodeGen.plugins.react.reactCommonDeps(),\n CodeGen.plugins.common.esmodule({ fileType: 'jsx' }),\n CodeGen.plugins.react.containerClass(),\n CodeGen.plugins.react.containerInjectContext(),\n CodeGen.plugins.react.containerInjectUtils(),\n CodeGen.plugins.react.containerInjectDataSourceEngine(),\n CodeGen.plugins.react.containerInjectI18n(),\n CodeGen.plugins.react.containerInitState(),\n CodeGen.plugins.react.containerLifeCycle(),\n CodeGen.plugins.react.containerMethod(),\n examplePlugin(),\n CodeGen.plugins.react.jsx({\n nodeTypeMapping: {\n Div: 'div',\n Component: 'div',\n Page: 'div',\n Block: 'div',\n },\n }),\n CodeGen.plugins.style.css(),\n ],\n pages: [\n CodeGen.plugins.react.reactCommonDeps(),\n CodeGen.plugins.common.esmodule({ fileType: 'jsx' }),\n CodeGen.plugins.react.containerClass(),\n CodeGen.plugins.react.containerInjectContext(),\n CodeGen.plugins.react.containerInjectUtils(),\n CodeGen.plugins.react.containerInjectDataSourceEngine(),\n CodeGen.plugins.react.containerInjectI18n(),\n CodeGen.plugins.react.containerInitState(),\n CodeGen.plugins.react.containerLifeCycle(),\n CodeGen.plugins.react.containerMethod(),\n examplePlugin(),\n CodeGen.plugins.react.jsx({\n nodeTypeMapping: {\n Div: 'div',\n Component: 'div',\n Page: 'div',\n Block: 'div',\n },\n }),\n CodeGen.plugins.style.css(),\n ],\n router: [\n CodeGen.plugins.common.esmodule(),\n CodeGen.solutionParts.icejs.plugins.router(),\n ],\n entry: [CodeGen.solutionParts.icejs.plugins.entry()],\n constants: [CodeGen.plugins.project.constants()],\n utils: [\n CodeGen.plugins.common.esmodule(),\n CodeGen.plugins.project.utils('react'),\n ],\n i18n: [CodeGen.plugins.project.i18n()],\n globalStyle: [CodeGen.solutionParts.icejs.plugins.globalStyle()],\n htmlEntry: [CodeGen.solutionParts.icejs.plugins.entryHtml()],\n packageJSON: [CodeGen.solutionParts.icejs.plugins.packageJSON()],\n },\n postProcessors: [CodeGen.postprocessor.prettier()],\n });\n}\n"},{file:"src/plugins/example.ts",content:"import {\n ICodeStruct,\n BuilderComponentPlugin,\n BuilderComponentPluginFactory,\n FileType,\n ChunkType,\n IContainerInfo,\n COMMON_CHUNK_NAME,\n CLASS_DEFINE_CHUNK_NAME,\n DEFAULT_LINK_AFTER,\n} from '@alilc/lowcode-code-generator';\n\nexport interface PluginConfig {\n fileType: string;\n}\n\nconst pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (\n config?\n) => {\n const cfg: PluginConfig = {\n fileType: FileType.JSX,\n ...config,\n };\n\n const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {\n const next: ICodeStruct = {\n ...pre,\n };\n\n const ir = next.ir as IContainerInfo & {\n methodsModule?: {\n type?: 'JSModule';\n source?: string;\n };\n };\n\n if (ir.methodsModule?.type !== 'JSModule' || !ir.methodsModule?.source) {\n return next;\n }\n\n // 创建 methods.jsx\n next.chunks.push({\n type: ChunkType.STRING,\n subModule: 'methods',\n fileType: cfg.fileType,\n name: COMMON_CHUNK_NAME.CustomContent,\n content: ir.methodsModule.source,\n linkAfter: [],\n });\n\n // 引入对应的模块\n next.chunks.push({\n type: ChunkType.STRING,\n fileType: cfg.fileType,\n name: COMMON_CHUNK_NAME.InternalDepsImport,\n content: \"import __$$methodsModule from './methods';\",\n linkAfter: [...DEFAULT_LINK_AFTER[COMMON_CHUNK_NAME.InternalDepsImport]],\n });\n\n // 将导出的东东都放到 class 上实例方法部分\n next.chunks.push({\n type: ChunkType.STRING,\n fileType: cfg.fileType,\n name: CLASS_DEFINE_CHUNK_NAME.ConstructorContent,\n content: 'Object.assign(this, __$$methodsModule);',\n linkAfter: [\n ...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.ConstructorContent],\n ],\n });\n\n return next;\n };\n\n return plugin;\n};\n\nexport default pluginFactory;\n"},{file:"tests/basic.test.ts",content:"test('basic functions should be ok', () => {\n // 这里放一些单元测试\n expect(0).toBe(0);\n});\n"}],m.label=2;case 2:m.trys.push([2,8,9,10]),o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],r=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(a),c=o.next(),m.label=3;case 3:return c.done?[3,7]:(u=c.value,t.verbose&&console.log("%s",it.gray("creating file ".concat(u.file))),l=_.join(n,u.file),[4,Hd(_.dirname(l))]);case 4:return m.sent(),[4,K.writeFile(l,i(u.content),{encoding:"utf-8"})];case 5:m.sent(),m.label=6;case 6:return c=o.next(),[3,3];case 7:return[3,10];case 8:return p=m.sent(),d={error:p},[3,10];case 9:try{c&&!c.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}return[7];case 10:return t.quiet||console.log("%s",it.green("solution ".concat(r," created successfully"))),[2,0];case 11:return h=m.sent(),console.log(it.red(at(h)||"Unexpected error: ".concat(h))),"object"==typeof h&&(null==h?void 0:h.stack)&&t.verbose&&console.log(it.gray(h.stack)),[2,1];case 12:return[2]}}))}))},exports.releaseMaterial=function(e){return ne(this,void 0,void 0,(function(){var t,s,r,n,i,a,o,c,u,l,p,h,d,f,m,y,g,x,v,b,E,C;return ie(this,(function(A){switch(A.label){case 0:return(t=e.auth)&&Ba(t),s=process.cwd(),r="build/lowcode",n=k.default.resolve(process.cwd(),r),(i=F.existsSync(n))||(n=k.default.resolve(process.cwd(),"dist")),[4,function(e){return Promise.resolve().then((function(){return D(require(e))}))}(k.default.resolve(process.cwd(),"package.json"))];case 1:return a=A.sent(),o=a.name,c=a.version,i&&(console.log("lceViewJS: ",k.default.resolve(process.cwd(),r,"view.js")),p=F.readFileSync(k.default.resolve(process.cwd(),r,"view.js"),"utf-8"),u=zd(p),h=F.readFileSync(k.default.resolve(process.cwd(),r,"meta.js"),"utf-8"),l=zd(h)),console.log("Uploading material..."),[4,ct(n+"/")];case 2:d=A.sent(),f=[],m=0,A.label=3;case 3:return m<d.length?(y=d[m],(g=F.readFileSync(y.path+"/"+y.fileName,"utf-8"))&&0!==g.trim().length?[3,4]:(console.log("File is empty Do not Upload: ",y.path+"/"+y.fileName),[3,6])):[3,7];case 4:return x="".concat(o,"/").concat(c,"/")+(y.path.split("".concat(s,"/").concat(r,"/"))[1]||"")+y.fileName,[4,$d(y,{t:1,route:"material",path:x})];case 5:v=A.sent(),f.push(v),A.label=6;case 6:return m++,[3,3];case 7:return console.log("Npm Name: ",o),console.log("Npm Version: ",c),i?(b=f.find((function(e){return e.key.includes("".concat(c,"/view.js"))})),E=f.find((function(e){return e.key.includes("".concat(c,"/view.css"))})),C=f.find((function(e){return e.key.includes("".concat(c,"/meta.js"))})),console.log("Npm Export Name: ",u),console.log("Npm Js Url: ",null==b?void 0:b.url),console.log("Npm Css Url: ",null==E?void 0:E.url),console.log("Meta Export Name: ",l),console.log("Meta Url: ",null==C?void 0:C.url)):f.length>0&&f.forEach((function(e){console.log("File Name: ",e.key),console.log("File Url: ",e.url)})),[2,1]}}))}))},exports.run=Md,exports.startWatching=function(e){return ne(this,void 0,void 0,(function(){var t,s,r,n,i,a,o,c;return ie(this,(function(u){return t=e.id,s=e.auth,r=e.account,s&&Ba(e.auth),n="PROJECT_ROOM_"+t,i=ae((La||"").split("##"),2),a=i[0],o=i[1],c=new Lx({token:a,client:o,onconnect:function(){console.log("[Service] Editor connected!"),c.joinRoom({roomId:n,account:r})},onmsg:function(t){var s=t||{};s.action;var n=s.message;if(n){n.updatedFileState;var i=n.userId,a=n.current;String(i)===r&&a&&Md(0,re(re({},e),{clear:!!a.clear}))}}}),c.connect(),[2,1]}))}))};
|
|
87
|
+
*/var cm=N.default.spawn,um=lm;function lm(e){e=e||{};var t,s,r=this,n=R.default,i=U.default,a={},o=!1,c={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},c),l=["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"],p=["TRACE","TRACK","CONNECT"],h=!1,d=!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,s,r,n){if(this.abort(),d=!1,f=!1,!function(e){return e&&-1===p.indexOf(e)}(e))throw new Error("SecurityError: Request method not allowed");a={method:e,url:t.toString(),async:"boolean"!=typeof s||s,user:r||null,password:n||null},y(this.OPENED)},this.setDisableHeaderCheck=function(e){o=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 o||e&&-1===l.indexOf(e.toLowerCase())}(e))return console.warn('Refused to set unsafe header "'+e+'"'),!1;if(h)throw new Error("INVALID_STATE_ERR: send flag is true");return u[e]=t,!0},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&s.headers[e.toLowerCase()]&&!d?s.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||d)return"";var e="";for(var t in s.headers)"set-cookie"!==t&&"set-cookie2"!==t&&(e+=t+": "+s.headers[t]+"\r\n");return e.substr(0,e.length-2)},this.getRequestHeader=function(e){return"string"==typeof e&&u[e]?u[e]:""},this.send=function(o){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(h)throw new Error("INVALID_STATE_ERR: send has already been called");var c,l=!1,p=!1,f=q.default.parse(a.url);switch(f.protocol){case"https:":l=!0;case"http:":c=f.hostname;break;case"file:":p=!0;break;case void 0:case"":c="localhost";break;default:throw new Error("Protocol not supported.")}if(p){if("GET"!==a.method)throw new Error("XMLHttpRequest: Only GET method is supported");if(a.async)O.default.readFile(unescape(f.pathname),"utf8",(function(e,t){e?r.handleError(e,e.errno||-1):(r.status=200,r.responseText=t,y(r.DONE))}));else try{this.responseText=O.default.readFileSync(unescape(f.pathname),"utf8"),this.status=200,y(r.DONE)}catch(e){this.handleError(e,e.errno||-1)}}else{var m=f.port||(l?443:80),g=f.pathname+(f.search?f.search:"");if(u.Host=c,l&&443===m||80===m||(u.Host+=":"+f.port),a.user){void 0===a.password&&(a.password="");var x=new Buffer(a.user+":"+a.password);u.Authorization="Basic "+x.toString("base64")}"GET"===a.method||"HEAD"===a.method?o=null:o?(u["Content-Length"]=Buffer.isBuffer(o)?o.length:Buffer.byteLength(o),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):"POST"===a.method&&(u["Content-Length"]=0);var v=e.agent||!1,b={host:c,port:m,path:g,method:a.method,headers:u,agent:v};if(l&&(b.pfx=e.pfx,b.key=e.key,b.passphrase=e.passphrase,b.cert=e.cert,b.ca=e.ca,b.ciphers=e.ciphers,b.rejectUnauthorized=!1!==e.rejectUnauthorized),d=!1,a.async){var E=l?i.request:n.request;h=!0,r.dispatchEvent("readystatechange");var C=function(n){if(302===(s=n).statusCode||303===s.statusCode||307===s.statusCode){a.url=s.headers.location;var i=q.default.parse(a.url);c=i.hostname;var o={hostname:i.hostname,port:i.port,path:i.path,method:303===s.statusCode?"GET":a.method,headers:u};return l&&(o.pfx=e.pfx,o.key=e.key,o.passphrase=e.passphrase,o.cert=e.cert,o.ca=e.ca,o.ciphers=e.ciphers,o.rejectUnauthorized=!1!==e.rejectUnauthorized),void(t=E(o,C).on("error",A)).end()}s&&s.setEncoding&&s.setEncoding("utf8"),y(r.HEADERS_RECEIVED),r.status=s.statusCode,s.on("data",(function(e){e&&(r.responseText+=e),h&&y(r.LOADING)})),s.on("end",(function(){h&&(h=!1,y(r.DONE))})),s.on("error",(function(e){r.handleError(e)}))},A=function(e){r.handleError(e)};t=E(b,C).on("error",A),e.autoUnref&&t.on("socket",(e=>{e.unref()})),o&&t.write(o),t.end(),r.dispatchEvent("loadstart")}else{var w=".node-xmlhttprequest-content-"+process.pid,D=".node-xmlhttprequest-sync-"+process.pid;O.default.writeFileSync(D,"","utf8");for(var T="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(l?"s":"")+".request;var options = "+JSON.stringify(b)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+w+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+D+"');});response.on('error', function(error) {fs.writeFileSync('"+w+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+D+"');});}).on('error', function(error) {fs.writeFileSync('"+w+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+D+"');});"+(o?"req.write('"+JSON.stringify(o).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",S=cm(process.argv[0],["-e",T]);O.default.existsSync(D););if(r.responseText=O.default.readFileSync(w,"utf8"),S.stdin.end(),O.default.unlinkSync(w),r.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var P=r.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");r.handleError(P,503)}else r.status=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),r.responseText=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),y(r.DONE)}}},this.handleError=function(e,t){this.status=t||0,this.statusText=e,this.responseText=e.stack,d=!0,y(this.DONE)},this.abort=function(){t&&(t.abort(),t=null),u=Object.assign({},c),this.responseText="",this.responseXML="",d=f=!0,this.readyState===this.UNSENT||this.readyState===this.OPENED&&!h||this.readyState===this.DONE||(h=!1,y(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 r["on"+e]&&(this.readyState===this.DONE?setImmediate((function(){r["on"+e]()})):r["on"+e]()),e in m)for(let t=0,s=m[e].length;t<s;t++)this.readyState===this.DONE?setImmediate((function(){m[e][t].call(r)})):m[e][t].call(r)};var y=function(e){if(!(r.readyState===e||r.readyState===r.UNSENT&&f)&&(r.readyState=e,(a.async||r.readyState<r.OPENED||r.readyState===r.DONE)&&r.dispatchEvent("readystatechange"),r.readyState===r.DONE)){let e;e=f?"abort":d?"error":"load",r.dispatchEvent(e),r.dispatchEvent("loadend")}}}lm.XMLHttpRequest=lm;const pm=um||Object.freeze({__proto__:null,default:um,__moduleExports:um});class hm{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("; "),s=t[0].indexOf("=");if(-1===s)return;const r=t[0].substring(0,s).trim();if(!r.length)return;let n=t[0].substring(s+1).trim();34===n.charCodeAt(0)&&(n=n.slice(1,-1));const i={name:r,value:n};for(let e=1;e<t.length;e++){const s=t[e].split("=");if(2!==s.length)continue;const r=s[0].trim(),n=s[1].trim();switch(r){case"Expires":i.expires=new Date(n);break;case"Max-Age":const e=new Date;e.setUTCSeconds(e.getUTCSeconds()+parseInt(n,10)),i.expires=e}}return i}(e);t&&this.cookies.set(t.name,t)}))}addCookies(e){const t=[];this.cookies.forEach(((e,s)=>{var r;(null===(r=e.expires)||void 0===r?void 0:r.getTime())<Date.now()?this.cookies.delete(s):t.push(`${s}=${e.value}`)})),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}}function dm(){}const fm=null!=new pm({xdomain:!1}).responseType;class mm extends Gf{constructor(e,t){super(),Yf(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=Jf(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const s=this.xhr=new pm(t);try{s.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&s.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{s.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),s.onreadystatechange=()=>{var e;3===s.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(s)),4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof s.status?s.status:0)}),0))},s.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=mm.requestsCount++,mm.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=dm,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete mm.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(mm.requestsCount=0,mm.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",ym);else if("function"==typeof addEventListener){addEventListener("onpagehide"in Wf?"pagehide":"unload",ym,!1)}function ym(){for(let e in mm.requests)mm.requests.hasOwnProperty(e)&&mm.requests[e].abort()}var gm={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}},xm="function"==typeof __webpack_require__?__non_webpack_require__:he,vm=process.config&&process.config.variables||{},bm=!!process.env.PREBUILDS_ONLY,Em=process.versions.modules,Cm=!(!process.versions||!process.versions.electron)||!!process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",Am=process.env.npm_config_arch||S.default.arch(),wm=process.env.npm_config_platform||S.default.platform(),Dm=process.env.LIBC||(function(e){return"linux"===e&&O.default.existsSync("/etc/alpine-release")}(wm)?"musl":"glibc"),Tm=process.env.ARM_VERSION||("arm64"===Am?"8":vm.arm_version)||"",Sm=(process.versions.uv||"").split(".")[0],Pm=km;function km(e){return xm(km.resolve(e))}function _m(e){try{return O.default.readdirSync(e)}catch(e){return[]}}function Nm(e,t){var s=_m(e).filter(t);return s[0]&&k.default.join(e,s[0])}function Im(e){return/\.node$/.test(e)}function Fm(e){var t=e.split("-");if(2===t.length){var s=t[0],r=t[1].split("+");if(s&&r.length&&r.every(Boolean))return{name:e,platform:s,architectures:r}}}function Om(e,t){return function(s){return null!=s&&(s.platform===e&&s.architectures.includes(t))}}function Lm(e,t){return e.architectures.length-t.architectures.length}function Bm(e){var t=e.split("."),s={file:e,specificity:0};if("node"===t.pop()){for(var r=0;r<t.length;r++){var n=t[r];if("node"===n||"electron"===n||"node-webkit"===n)s.runtime=n;else if("napi"===n)s.napi=!0;else if("abi"===n.slice(0,3))s.abi=n.slice(3);else if("uv"===n.slice(0,2))s.uv=n.slice(2);else if("armv"===n.slice(0,4))s.armv=n.slice(4);else{if("glibc"!==n&&"musl"!==n)continue;s.libc=n}s.specificity++}return s}}function jm(e,t){return function(s){return null!=s&&(!(s.runtime&&s.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(s))&&(!(s.abi&&s.abi!==t&&!s.napi)&&((!s.uv||s.uv===Sm)&&((!s.armv||s.armv===Tm)&&(!s.libc||s.libc===Dm)))))}}function Mm(e){return function(t,s){return t.runtime!==s.runtime?t.runtime===e?-1:1:t.abi!==s.abi?t.abi?-1:1:t.specificity!==s.specificity?t.specificity>s.specificity?-1:1:0}}km.resolve=km.path=function(e){e=k.default.resolve(e||".");try{var t=xm(k.default.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"])}catch(e){}if(!bm){var s=Nm(k.default.join(e,"build/Release"),Im);if(s)return s;var r=Nm(k.default.join(e,"build/Debug"),Im);if(r)return r}var n=o(e);if(n)return n;var i=o(k.default.dirname(process.execPath));if(i)return i;var a=["platform="+wm,"arch="+Am,"runtime="+Cm,"abi="+Em,"uv="+Sm,Tm?"armv="+Tm:"","libc="+Dm,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+a+"\n loaded from: "+e+"\n");function o(e){var t=_m(k.default.join(e,"prebuilds")).map(Fm).filter(Om(wm,Am)).sort(Lm)[0];if(t){var s=k.default.join(e,"prebuilds",t.name),r=_m(s).map(Bm).filter(jm(Cm,Em)).sort(Mm(Cm))[0];return r?k.default.join(s,r.file):void 0}}},km.parseTags=Bm,km.matchTags=jm,km.compareTags=Mm,km.parseTuple=Fm,km.matchTuple=Om,km.compareTuples=Lm;var Rm=le((function(e){const t="function"==typeof __webpack_require__?__non_webpack_require__:he;"function"==typeof t.addon?e.exports=t.addon.bind(t):e.exports=Pm}));var Um={mask:(e,t,s,r,n)=>{for(var i=0;i<n;i++)s[r+i]=e[i]^t[3&i]},unmask:(e,t)=>{const s=e.length;for(var r=0;r<s;r++)e[r]^=t[3&r]}},qm=le((function(e){try{e.exports=Rm(__dirname)}catch(t){e.exports=Um}})),$m=le((function(e){const{EMPTY_BUFFER:t}=gm,s=Buffer[Symbol.species];function r(e,t,s,r,n){for(let i=0;i<n;i++)s[r+i]=e[i]^t[3&i]}function n(e,t){for(let s=0;s<e.length;s++)e[s]^=t[3&s]}if(e.exports={concat:function(e,r){if(0===e.length)return t;if(1===e.length)return e[0];const n=Buffer.allocUnsafe(r);let i=0;for(let t=0;t<e.length;t++){const s=e[t];n.set(s,i),i+=s.length}return i<r?new s(n.buffer,n.byteOffset,i):n},mask:r,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let r;return t instanceof ArrayBuffer?r=new s(t):ArrayBuffer.isView(t)?r=new s(t.buffer,t.byteOffset,t.byteLength):(r=Buffer.from(t),e.readOnly=!1),r},unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{const t=qm;e.exports.mask=function(e,s,n,i,a){a<48?r(e,s,n,i,a):t.mask(e,s,n,i,a)},e.exports.unmask=function(e,s){e.length<32?n(e,s):t.unmask(e,s)}}catch(e){}}));$m.concat,$m.mask,$m.toArrayBuffer,$m.toBuffer,$m.unmask;const zm=Symbol("kDone"),Hm=Symbol("kRun");var Vm=class{constructor(e){this[zm]=()=>{this.pending--,this[Hm]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Hm]()}[Hm](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[zm])}}};const{kStatusCode:Gm}=gm,Wm=Buffer[Symbol.species],Jm=Buffer.from([0,0,255,255]),Xm=Symbol("permessage-deflate"),Km=Symbol("total-length"),Ym=Symbol("callback"),Zm=Symbol("buffers"),Qm=Symbol("error");let ey;var ty=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!ey){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;ey=new Vm(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[Ym];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){ey.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){ey.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?V.default.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=V.default.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[Xm]=this,this._inflate[Km]=0,this._inflate[Zm]=[],this._inflate.on("error",ny),this._inflate.on("data",ry)}this._inflate[Ym]=s,this._inflate.write(e),t&&this._inflate.write(Jm),this._inflate.flush((()=>{const e=this._inflate[Qm];if(e)return this._inflate.close(),this._inflate=null,void s(e);const n=$m.concat(this._inflate[Zm],this._inflate[Km]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Km]=0,this._inflate[Zm]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,n)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?V.default.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=V.default.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[Km]=0,this._deflate[Zm]=[],this._deflate.on("data",sy)}this._deflate[Ym]=s,this._deflate.write(e),this._deflate.flush(V.default.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=$m.concat(this._deflate[Zm],this._deflate[Km]);t&&(e=new Wm(e.buffer,e.byteOffset,e.length-4)),this._deflate[Ym]=null,this._deflate[Km]=0,this._deflate[Zm]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function sy(e){this[Zm].push(e),this[Km]+=e.length}function ry(e){this[Km]+=e.length,this[Xm]._maxPayload<1||this[Km]<=this[Xm]._maxPayload?this[Zm].push(e):(this[Qm]=new RangeError("Max payload size exceeded"),this[Qm].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Qm][Gm]=1009,this.removeListener("data",ry),this.reset())}function ny(e){this[Xm]._inflate=null,e[Gm]=1007,this[Ym](e)}var iy=function(e){const t=e.length;let s=0;for(;s<t;)if(128&e[s])if(192==(224&e[s])){if(s+1===t||128!=(192&e[s+1])||192==(254&e[s]))return!1;s+=2}else if(224==(240&e[s])){if(s+2>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0},ay=le((function(e){try{e.exports=Rm(__dirname)}catch(t){e.exports=iy}})),oy=le((function(e){const{isUtf8:t}=ee.default;function s(e){const t=e.length;let s=0;for(;s<t;)if(128&e[s])if(192==(224&e[s])){if(s+1===t||128!=(192&e[s+1])||192==(254&e[s]))return!1;s+=2}else if(224==(240&e[s])){if(s+2>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}else s++;return!0}if(e.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:s,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},t)e.exports.isValidUTF8=function(e){return e.length<24?s(e):t(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=ay;e.exports.isValidUTF8=function(e){return e.length<32?s(e):t(e)}}catch(e){}}));oy.isValidStatusCode,oy.isValidUTF8,oy.tokenChars;const{Writable:cy}=$.default,{BINARY_TYPES:uy,EMPTY_BUFFER:ly,kStatusCode:py,kWebSocket:hy}=gm,{concat:dy,toArrayBuffer:fy,unmask:my}=$m,{isValidStatusCode:yy,isValidUTF8:gy}=oy,xy=Buffer[Symbol.species];var vy=class extends cy{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||uy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[hy]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new xy(t.buffer,t.byteOffset+e,t.length-e),new xy(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new xy(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const s=!(64&~t[0]);if(!s||this._extensions[ty.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=s}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(s){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ly;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&my(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[ty.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?dy(s,t):"arraybuffer"===this._binaryType?fy(dy(s,t)):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)})))}else{const r=dy(s,t);if(!this._skipUTF8Validation&&!gy(r)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,ly),this.end();else{const s=e.readUInt16BE(0);if(!yy(s)){const e=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const r=new xy(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!gy(r)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0}}createError(e,t,s,r,n){this._loop=!1,this._errored=!0;const i=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=n,i[py]=r,i}};const{randomFillSync:by}=M.default,{EMPTY_BUFFER:Ey}=gm,{isValidStatusCode:Cy}=oy,{mask:Ay,toBuffer:wy}=$m,Dy=Symbol("kByteLength"),Ty=Buffer.alloc(4),Sy=8192;let Py,ky=Sy;class _y{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let s,r,n=!1,i=2,a=!1;t.mask&&(s=t.maskBuffer||Ty,t.generateMask?t.generateMask(s):(ky===Sy&&(void 0===Py&&(Py=Buffer.alloc(Sy)),by(Py,0,Sy),ky=0),s[0]=Py[ky++],s[1]=Py[ky++],s[2]=Py[ky++],s[3]=Py[ky++]),a=!(s[0]|s[1]|s[2]|s[3]),i=6),"string"==typeof e?r=t.mask&&!a||void 0===t[Dy]?(e=Buffer.from(e)).length:t[Dy]:(r=e.length,n=t.mask&&t.readOnly&&!a);let o=r;r>=65536?(i+=8,o=127):r>125&&(i+=2,o=126);const c=Buffer.allocUnsafe(n?r+i:i);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=o,126===o?c.writeUInt16BE(r,2):127===o&&(c[2]=c[3]=0,c.writeUIntBE(r,4,6)),t.mask?(c[1]|=128,c[i-4]=s[0],c[i-3]=s[1],c[i-2]=s[2],c[i-1]=s[3],a?[c,e]:n?(Ay(e,s,c,i,r),[c]):(Ay(e,s,e,0,r),[c,e])):[c,e]}close(e,t,s,r){let n;if(void 0===e)n=Ey;else{if("number"!=typeof e||!Cy(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+s),n.writeUInt16BE(e,0),"string"==typeof t?n.write(t,2):n.set(t,2)}else n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0)}const i={[Dy]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,i,r]):this.sendFrame(_y.frame(n,i),r)}ping(e,t,s){let r,n;if("string"==typeof e?(r=Buffer.byteLength(e),n=!1):(r=(e=wy(e)).length,n=wy.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[Dy]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,i,s]):this.sendFrame(_y.frame(e,i),s)}pong(e,t,s){let r,n;if("string"==typeof e?(r=Buffer.byteLength(e),n=!1):(r=(e=wy(e)).length,n=wy.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[Dy]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,i,s]):this.sendFrame(_y.frame(e,i),s)}send(e,t,s){const r=this._extensions[ty.extensionName];let n,i,a=t.binary?2:1,o=t.compress;if("string"==typeof e?(n=Buffer.byteLength(e),i=!1):(n=(e=wy(e)).length,i=wy.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=n>=r._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0),r){const r={[Dy]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:i,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,r,s]):this.dispatch(e,this._compress,r,s)}else this.sendFrame(_y.frame(e,{[Dy]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:i,rsv1:!1}),s)}dispatch(e,t,s,r){if(!t)return void this.sendFrame(_y.frame(e,s),r);const n=this._extensions[ty.extensionName];this._bufferedBytes+=s[Dy],this._deflating=!0,n.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t],r=s[s.length-1];"function"==typeof r&&r(e)}}else this._bufferedBytes-=s[Dy],this._deflating=!1,s.readOnly=!1,this.sendFrame(_y.frame(t,s),r),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][Dy],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Dy],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Ny=_y;const{kForOnEventAttribute:Iy,kListener:Fy}=gm,Oy=Symbol("kCode"),Ly=Symbol("kData"),By=Symbol("kError"),jy=Symbol("kMessage"),My=Symbol("kReason"),Ry=Symbol("kTarget"),Uy=Symbol("kType"),qy=Symbol("kWasClean");class $y{constructor(e){this[Ry]=null,this[Uy]=e}get target(){return this[Ry]}get type(){return this[Uy]}}Object.defineProperty($y.prototype,"target",{enumerable:!0}),Object.defineProperty($y.prototype,"type",{enumerable:!0});class zy extends $y{constructor(e,t={}){super(e),this[Oy]=void 0===t.code?0:t.code,this[My]=void 0===t.reason?"":t.reason,this[qy]=void 0!==t.wasClean&&t.wasClean}get code(){return this[Oy]}get reason(){return this[My]}get wasClean(){return this[qy]}}Object.defineProperty(zy.prototype,"code",{enumerable:!0}),Object.defineProperty(zy.prototype,"reason",{enumerable:!0}),Object.defineProperty(zy.prototype,"wasClean",{enumerable:!0});class Hy extends $y{constructor(e,t={}){super(e),this[By]=void 0===t.error?null:t.error,this[jy]=void 0===t.message?"":t.message}get error(){return this[By]}get message(){return this[jy]}}Object.defineProperty(Hy.prototype,"error",{enumerable:!0}),Object.defineProperty(Hy.prototype,"message",{enumerable:!0});class Vy extends $y{constructor(e,t={}){super(e),this[Ly]=void 0===t.data?null:t.data}get data(){return this[Ly]}}Object.defineProperty(Vy.prototype,"data",{enumerable:!0});const Gy={addEventListener(e,t,s={}){for(const r of this.listeners(e))if(!s[Iy]&&r[Fy]===t&&!r[Iy])return;let r;if("message"===e)r=function(e,s){const r=new Vy("message",{data:s?e:e.toString()});r[Ry]=this,Jy(t,this,r)};else if("close"===e)r=function(e,s){const r=new zy("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[Ry]=this,Jy(t,this,r)};else if("error"===e)r=function(e){const s=new Hy("error",{error:e,message:e.message});s[Ry]=this,Jy(t,this,s)};else{if("open"!==e)return;r=function(){const e=new $y("open");e[Ry]=this,Jy(t,this,e)}}r[Iy]=!!s[Iy],r[Fy]=t,s.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(const s of this.listeners(e))if(s[Fy]===t&&!s[Iy]){this.removeListener(e,s);break}}};var Wy={CloseEvent:zy,ErrorEvent:Hy,Event:$y,EventTarget:Gy,MessageEvent:Vy};function Jy(e,t,s){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,s):e.call(t,s)}const{tokenChars:Xy}=oy;function Ky(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}var Yy={format:function(e){return Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,n=Object.create(null),i=!1,a=!1,o=!1,c=-1,u=-1,l=-1,p=0;for(;p<e.length;p++)if(u=e.charCodeAt(p),void 0===s)if(-1===l&&1===Xy[u])-1===c&&(c=p);else if(0===p||32!==u&&9!==u){if(59!==u&&44!==u)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===l&&(l=p);const r=e.slice(c,l);44===u?(Ky(t,r,n),n=Object.create(null)):s=r,c=l=-1}}else-1===l&&-1!==c&&(l=p);else if(void 0===r)if(-1===l&&1===Xy[u])-1===c&&(c=p);else if(32===u||9===u)-1===l&&-1!==c&&(l=p);else if(59===u||44===u){if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===l&&(l=p),Ky(n,e.slice(c,l),!0),44===u&&(Ky(t,s,n),n=Object.create(null),s=void 0),c=l=-1}else{if(61!==u||-1===c||-1!==l)throw new SyntaxError(`Unexpected character at index ${p}`);r=e.slice(c,p),c=l=-1}else if(a){if(1!==Xy[u])throw new SyntaxError(`Unexpected character at index ${p}`);-1===c?c=p:i||(i=!0),a=!1}else if(o)if(1===Xy[u])-1===c&&(c=p);else if(34===u&&-1!==c)o=!1,l=p;else{if(92!==u)throw new SyntaxError(`Unexpected character at index ${p}`);a=!0}else if(34===u&&61===e.charCodeAt(p-1))o=!0;else if(-1===l&&1===Xy[u])-1===c&&(c=p);else if(-1===c||32!==u&&9!==u){if(59!==u&&44!==u)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===l&&(l=p);let a=e.slice(c,l);i&&(a=a.replace(/\\/g,""),i=!1),Ky(n,r,a),44===u&&(Ky(t,s,n),n=Object.create(null),s=void 0),r=void 0,c=l=-1}}else-1===l&&(l=p);if(-1===c||o||32===u||9===u)throw new SyntaxError("Unexpected end of input");-1===l&&(l=p);const h=e.slice(c,l);return void 0===s?Ky(t,h,n):(void 0===r?Ky(n,h,!0):Ky(n,r,i?h.replace(/\\/g,""):h),Ky(t,s,n)),t}};const{randomBytes:Zy,createHash:Qy}=M.default,{URL:eg}=q.default,{BINARY_TYPES:tg,EMPTY_BUFFER:sg,GUID:rg,kForOnEventAttribute:ng,kListener:ig,kStatusCode:ag,kWebSocket:og,NOOP:cg}=gm,{EventTarget:{addEventListener:ug,removeEventListener:lg}}=Wy,{format:pg,parse:hg}=Yy,{toBuffer:dg}=$m,fg=Symbol("kAborted"),mg=[8,13],yg=["CONNECTING","OPEN","CLOSING","CLOSED"],gg=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class xg extends Z.default{constructor(e,t,s){super(),this._binaryType=tg[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=sg,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=xg.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(s=t,t=[]):t=[t]),bg(this,e,t,s)):(this._autoPong=s.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){tg.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){const r=new vy({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new Ny(e,this._extensions,s.generateMask),this._receiver=r,this._socket=e,r[og]=this,e[og]=this,r.on("conclude",Tg),r.on("drain",Sg),r.on("error",Pg),r.on("message",_g),r.on("ping",Ng),r.on("pong",Ig),e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Og),e.on("data",Lg),e.on("end",Bg),e.on("error",jg),this._readyState=xg.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=xg.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[ty.extensionName]&&this._extensions[ty.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=xg.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==xg.CLOSED)if(this.readyState!==xg.CONNECTING)this.readyState!==xg.CLOSING?(this._readyState=xg.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";wg(this,this._req,e)}}pause(){this.readyState!==xg.CONNECTING&&this.readyState!==xg.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===xg.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===xg.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||sg,t,s)):Dg(this,e,s)}pong(e,t,s){if(this.readyState===xg.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===xg.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||sg,t,s)):Dg(this,e,s)}resume(){this.readyState!==xg.CONNECTING&&this.readyState!==xg.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===xg.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==xg.OPEN)return void Dg(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[ty.extensionName]||(r.compress=!1),this._sender.send(e||sg,r,s)}terminate(){if(this.readyState!==xg.CLOSED)if(this.readyState!==xg.CONNECTING)this._socket&&(this._readyState=xg.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";wg(this,this._req,e)}}}Object.defineProperty(xg,"CONNECTING",{enumerable:!0,value:yg.indexOf("CONNECTING")}),Object.defineProperty(xg.prototype,"CONNECTING",{enumerable:!0,value:yg.indexOf("CONNECTING")}),Object.defineProperty(xg,"OPEN",{enumerable:!0,value:yg.indexOf("OPEN")}),Object.defineProperty(xg.prototype,"OPEN",{enumerable:!0,value:yg.indexOf("OPEN")}),Object.defineProperty(xg,"CLOSING",{enumerable:!0,value:yg.indexOf("CLOSING")}),Object.defineProperty(xg.prototype,"CLOSING",{enumerable:!0,value:yg.indexOf("CLOSING")}),Object.defineProperty(xg,"CLOSED",{enumerable:!0,value:yg.indexOf("CLOSED")}),Object.defineProperty(xg.prototype,"CLOSED",{enumerable:!0,value:yg.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(xg.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(xg.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[ng])return t[ig];return null},set(t){for(const t of this.listeners(e))if(t[ng]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[ng]:!0})}})})),xg.prototype.addEventListener=ug,xg.prototype.removeEventListener=lg;var vg=xg;function bg(e,t,s,r){const n={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:mg[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=n.autoPong,!mg.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${mg.join(", ")})`);let i;if(t instanceof eg)i=t;else try{i=new eg(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===i.protocol?i.protocol="ws:":"https:"===i.protocol&&(i.protocol="wss:"),e._url=i.href;const a="wss:"===i.protocol,o="ws+unix:"===i.protocol;let c;if("ws:"===i.protocol||a||o?o&&!i.pathname?c="The URL's pathname is empty":i.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void Eg(e,t)}const u=a?443:80,l=Zy(16).toString("base64"),p=a?U.default.request:R.default.request,h=new Set;let d,f;if(n.createConnection=n.createConnection||(a?Ag:Cg),n.defaultPort=n.defaultPort||u,n.port=i.port||u,n.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,n.headers={...n.headers,"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},n.path=i.pathname+i.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(d=new ty(!0!==n.perMessageDeflate?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=pg({[ty.extensionName]:d.offer()})),s.length){for(const e of s){if("string"!=typeof e||!gg.test(e)||h.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");h.add(e)}n.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(i.username||i.password)&&(n.auth=`${i.username}:${i.password}`),o){const e=n.path.split(":");n.socketPath=e[0],n.path=e[1]}if(n.followRedirects){if(0===e._redirects){e._originalIpc=o,e._originalSecure=a,e._originalHostOrSocketPath=o?n.socketPath:i.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=o?!!e._originalIpc&&n.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&i.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!a)&&(delete n.headers.authorization,delete n.headers.cookie,t||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),f=e._req=p(n),e._redirects&&e.emit("redirect",e.url,f)}else f=e._req=p(n);n.timeout&&f.on("timeout",(()=>{wg(e,f,"Opening handshake has timed out")})),f.on("error",(t=>{null===f||f[fg]||(f=e._req=null,Eg(e,t))})),f.on("response",(i=>{const a=i.headers.location,o=i.statusCode;if(a&&n.followRedirects&&o>=300&&o<400){if(++e._redirects>n.maxRedirects)return void wg(e,f,"Maximum redirects exceeded");let i;f.abort();try{i=new eg(a,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${a}`);return void Eg(e,s)}bg(e,i,s,r)}else e.emit("unexpected-response",f,i)||wg(e,f,`Unexpected server response: ${i.statusCode}`)})),f.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==xg.CONNECTING)return;f=e._req=null;const i=t.headers.upgrade;if(void 0===i||"websocket"!==i.toLowerCase())return void wg(e,s,"Invalid Upgrade header");const a=Qy("sha1").update(l+rg).digest("base64");if(t.headers["sec-websocket-accept"]!==a)return void wg(e,s,"Invalid Sec-WebSocket-Accept header");const o=t.headers["sec-websocket-protocol"];let c;if(void 0!==o?h.size?h.has(o)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":h.size&&(c="Server sent no subprotocol"),c)return void wg(e,s,c);o&&(e._protocol=o);const u=t.headers["sec-websocket-extensions"];if(void 0!==u){if(!d){return void wg(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=hg(u)}catch(t){return void wg(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==ty.extensionName){return void wg(e,s,"Server indicated an extension that was not requested")}try{d.accept(t[ty.extensionName])}catch(t){return void wg(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[ty.extensionName]=d}e.setSocket(s,r,{allowSynchronousEvents:n.allowSynchronousEvents,generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})})),n.finishRequest?n.finishRequest(f,e):f.end()}function Eg(e,t){e._readyState=xg.CLOSING,e.emit("error",t),e.emitClose()}function Cg(e){return e.path=e.socketPath,J.default.connect(e)}function Ag(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=J.default.isIP(e.host)?"":e.host),Q.default.connect(e)}function wg(e,t,s){e._readyState=xg.CLOSING;const r=new Error(s);Error.captureStackTrace(r,wg),t.setHeader?(t[fg]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Eg,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Dg(e,t,s){if(t){const s=dg(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${yg[e.readyState]})`);process.nextTick(s,t)}}function Tg(e,t){const s=this[og];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[og]&&(s._socket.removeListener("data",Lg),process.nextTick(Fg,s._socket),1005===e?s.close():s.close(e,t))}function Sg(){const e=this[og];e.isPaused||e._socket.resume()}function Pg(e){const t=this[og];void 0!==t._socket[og]&&(t._socket.removeListener("data",Lg),process.nextTick(Fg,t._socket),t.close(e[ag])),t.emit("error",e)}function kg(){this[og].emitClose()}function _g(e,t){this[og].emit("message",e,t)}function Ng(e){const t=this[og];t._autoPong&&t.pong(e,!this._isServer,cg),t.emit("ping",e)}function Ig(e){this[og].emit("pong",e)}function Fg(e){e.resume()}function Og(){const e=this[og];let t;this.removeListener("close",Og),this.removeListener("data",Lg),this.removeListener("end",Bg),e._readyState=xg.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[og]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",kg),e._receiver.on("finish",kg))}function Lg(e){this[og]._receiver.write(e)||this.pause()}function Bg(){const e=this[og];e._readyState=xg.CLOSING,e._receiver.end(),this.end()}function jg(){const e=this[og];this.removeListener("error",jg),this.on("error",cg),e&&(e._readyState=xg.CLOSING,this.destroy())}const{Duplex:Mg}=$.default;function Rg(e){e.emit("close")}function Ug(){!this.destroyed&&this._writableState.finished&&this.destroy()}function qg(e){this.removeListener("error",qg),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var $g=function(e,t){let s=!0;const r=new Mg({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const n=!s&&r._readableState.objectMode?t.toString():t;r.push(n)||e.pause()})),e.once("error",(function(e){r.destroyed||(s=!1,r.destroy(e))})),e.once("close",(function(){r.destroyed||r.push(null)})),r._destroy=function(t,n){if(e.readyState===e.CLOSED)return n(t),void process.nextTick(Rg,r);let i=!1;e.once("error",(function(e){i=!0,n(e)})),e.once("close",(function(){i||n(t),process.nextTick(Rg,r)})),s&&e.terminate()},r._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){r._final(t)}))},r._read=function(){e.isPaused&&e.resume()},r._write=function(t,s,n){e.readyState!==e.CONNECTING?e.send(t,n):e.once("open",(function(){r._write(t,s,n)}))},r.on("end",Ug),r.on("error",qg),r};const{tokenChars:zg}=oy;var Hg={parse:function(e){const t=new Set;let s=-1,r=-1,n=0;for(;n<e.length;n++){const i=e.charCodeAt(n);if(-1===r&&1===zg[i])-1===s&&(s=n);else if(0===n||32!==i&&9!==i){if(44!==i)throw new SyntaxError(`Unexpected character at index ${n}`);{if(-1===s)throw new SyntaxError(`Unexpected character at index ${n}`);-1===r&&(r=n);const i=e.slice(s,r);if(t.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);t.add(i),s=r=-1}}else-1===r&&-1!==s&&(r=n)}if(-1===s||-1!==r)throw new SyntaxError("Unexpected end of input");const i=e.slice(s,n);if(t.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return t.add(i),t}};const{createHash:Vg}=M.default,{GUID:Gg,kWebSocket:Wg}=gm,Jg=/^[+/0-9A-Za-z]{22}==$/;class Xg extends Z.default{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:vg,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=R.default.createServer(((e,t)=>{const s=R.default.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(Yg,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(Yg,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{Yg(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",Zg);const n=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void ex(this,e,t,405,"Invalid HTTP method")}if(void 0===i||"websocket"!==i.toLowerCase()){return void ex(this,e,t,400,"Invalid Upgrade header")}if(void 0===n||!Jg.test(n)){return void ex(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==a&&13!==a){return void ex(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void Qg(t,400);const o=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==o)try{c=Hg.parse(o)}catch(s){return void ex(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const u=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&void 0!==u){const s=new ty(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=Yy.parse(u);e[ty.extensionName]&&(s.accept(e[ty.extensionName]),l[ty.extensionName]=s)}catch(s){return void ex(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const i={origin:e.headers[""+(8===a?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(i,((i,a,o,u)=>{if(!i)return Qg(t,a||401,o,u);this.completeUpgrade(l,n,c,e,t,s,r)}));if(!this.options.verifyClient(i))return Qg(t,401)}this.completeUpgrade(l,n,c,e,t,s,r)}completeUpgrade(e,t,s,r,n,i,a){if(!n.readable||!n.writable)return n.destroy();if(n[Wg])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return Qg(n,503);const o=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Vg("sha1").update(t+Gg).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(o.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[ty.extensionName]){const t=e[ty.extensionName].params,s=Yy.format({[ty.extensionName]:[t]});o.push(`Sec-WebSocket-Extensions: ${s}`),c._extensions=e}this.emit("headers",o,r),n.write(o.concat("\r\n").join("\r\n")),n.removeListener("error",Zg),c.setSocket(n,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Yg,this)}))),a(c,r)}}var Kg=Xg;function Yg(e){e._state=2,e.emit("close")}function Zg(){this.destroy()}function Qg(e,t,s,r){s=s||R.default.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${R.default.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function ex(e,t,s,r,n){if(e.listenerCount("wsClientError")){const r=new Error(n);Error.captureStackTrace(r,ex),e.emit("wsClientError",r,s,t)}else Qg(s,r,n)}vg.createWebSocketStream=$g,vg.Server=Kg,vg.Receiver=vy,vg.Sender=Ny,vg.WebSocket=vg,vg.WebSocketServer=vg.Server;const tx=vg,sx=process.nextTick,rx="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const nx={websocket:class extends Qf{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,s=rx?{}:Jf(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=new tx(e,t,s)}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 s=e[t],r=t===e.length-1;Bf(s,this.supportsBinary,(e=>{const t={};if(s.options&&(t.compress=s.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){}r&&sx((()=>{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]=om()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!tx}},webtransport:class extends Qf{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){zf||(zf=new TextDecoder);const s=[];let r=0,n=-1,i=!1;return new TransformStream({transform(a,o){for(s.push(a);;){if(0===r){if(Hf(s)<1)break;const e=Vf(s,1);i=!(128&~e[0]),n=127&e[0],r=n<126?3:126===n?1:2}else if(1===r){if(Hf(s)<2)break;const e=Vf(s,2);n=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(Hf(s)<8)break;const e=Vf(s,8),t=new DataView(e.buffer,e.byteOffset,e.length),i=t.getUint32(0);if(i>Math.pow(2,21)-1){o.enqueue(Lf);break}n=i*Math.pow(2,32)+t.getUint32(4),r=3}else{if(Hf(s)<n)break;const e=Vf(s,n);o.enqueue(Rf(i?e:zf.decode(e),t)),r=0}if(0===n||n>e){o.enqueue(Lf);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=$f();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const n=()=>{s.read().then((({done:e,value:t})=>{e||(this.onPacket(t),n())})).catch((e=>{}))};n();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this.writer.write(i).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this.writer.write(s).then((()=>{r&&sx((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends Qf{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let s=location.port;s||(s=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||s!==e.port}const t=e&&e.forceBase64;this.supportsBinary=fm&&!t,this.opts.withCredentials&&(this.cookieJar=new hm)}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 s=e.split(qf),r=[];for(let e=0;e<s.length;e++){const n=Rf(s[e],t);if(r.push(n),"error"===n.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const s=e.length,r=new Array(s);let n=0;e.forEach(((e,i)=>{Bf(e,!1,(e=>{r[i]=e,++n===s&&t(r.join(qf))}))}))})(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]=om()),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 mm(this.uri(),e)}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.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}}},ix=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ax=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ox(e){if(e.length>2e3)throw"URI too long";const t=e,s=e.indexOf("["),r=e.indexOf("]");-1!=s&&-1!=r&&(e=e.substring(0,s)+e.substring(s,r).replace(/:/g,";")+e.substring(r,e.length));let n=ix.exec(e||""),i={},a=14;for(;a--;)i[ax[a]]=n[a]||"";return-1!=s&&-1!=r&&(i.source=t,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=function(e,t){const s=/\/{2,9}/g,r=t.replace(s,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,i.path),i.queryKey=function(e,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(s[t]=r)})),s}(0,i.query),i}class cx extends Gf{constructor(e,t={}){super(),this.binaryType="nodebuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=ox(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=ox(t.host).host),Yf(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={},s=e.split("&");for(let e=0,r=s.length;e<r;e++){let r=s[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[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 s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new nx[e](s)}open(){let e;if(this.opts.rememberUpgrade&&cx.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}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",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),s=!1;cx.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!s)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;cx.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function n(){s||(s=!0,u(),t.close(),t=null)}const i=e=>{const s=new Error("probe error: "+e);s.transport=t.name,n(),this.emitReserved("upgradeError",s)};function a(){i("transport closed")}function o(){i("socket closed")}function c(e){t&&e.name!==t.name&&n()}const u=()=>{t.removeListener("open",r),t.removeListener("error",i),t.removeListener("close",a),this.off("close",o),this.off("upgrading",c)};t.once("open",r),t.once("error",i),t.once("close",a),this.once("close",o),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{s||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",cx.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 s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,s=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(r++,s+=4);return s}(t):Math.ceil(1.33*(t.byteLength||t.size))),s>0&&e>this.maxPayload)return this.writeBuffer.slice(0,s);e+=2}var t;return this.writeBuffer}write(e,t,s){return this.sendPacket("message",e,t,s),this}send(e,t,s){return this.sendPacket("message",e,t,s),this}sendPacket(e,t,s,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof s&&(r=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const n={type:e,data:t,options:s};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{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?s():e()})):this.upgrading?s():e()),this}onError(e){cx.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}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 s=0;const r=e.length;for(;s<r;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}cx.protocol=4;const ux="function"==typeof ArrayBuffer,lx=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,px=Object.prototype.toString,hx="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===px.call(Blob),dx="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===px.call(File);function fx(e){return ux&&(e instanceof ArrayBuffer||lx(e))||hx&&e instanceof Blob||dx&&e instanceof File}function mx(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,s=e.length;t<s;t++)if(mx(e[t]))return!0;return!1}if(fx(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return mx(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&mx(e[t]))return!0;return!1}function yx(e){const t=[],s=e.data,r=e;return r.data=gx(s,t),r.attachments=t.length,{packet:r,buffers:t}}function gx(e,t){if(!e)return e;if(fx(e)){const s={_placeholder:!0,num:t.length};return t.push(e),s}if(Array.isArray(e)){const s=new Array(e.length);for(let r=0;r<e.length;r++)s[r]=gx(e[r],t);return s}if("object"==typeof e&&!(e instanceof Date)){const s={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=gx(e[r],t));return s}return e}function xx(e,t){return e.data=vx(e.data,t),delete e.attachments,e}function vx(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 s=0;s<e.length;s++)e[s]=vx(e[s],t);else if("object"==typeof e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(e[s]=vx(e[s],t));return e}const bx=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ex;!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"}(Ex||(Ex={}));function Cx(e){return"[object Object]"===Object.prototype.toString.call(e)}class Ax extends Gf{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 s=t.type===Ex.BINARY_EVENT;s||t.type===Ex.BINARY_ACK?(t.type=s?Ex.EVENT:Ex.ACK,this.reconstructor=new wx(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!fx(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 s={type:Number(e.charAt(0))};if(void 0===Ex[s.type])throw new Error("unknown packet type "+s.type);if(s.type===Ex.BINARY_EVENT||s.type===Ex.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const n=e.substring(r,t);if(n!=Number(n)||"-"!==e.charAt(t))throw new Error("Illegal attachments");s.attachments=Number(n)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}s.nsp=e.substring(r,t)}else s.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const s=e.charAt(t);if(null==s||Number(s)!=s){--t;break}if(t===e.length)break}s.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!Ax.isPayloadValid(s.type,r))throw new Error("invalid payload");s.data=r}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Ex.CONNECT:return Cx(t);case Ex.DISCONNECT:return void 0===t;case Ex.CONNECT_ERROR:return"string"==typeof t||Cx(t);case Ex.EVENT:case Ex.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===bx.indexOf(t[0]));case Ex.ACK:case Ex.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class wx{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=xx(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Dx=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Ex},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Ex.EVENT&&e.type!==Ex.ACK||!mx(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Ex.EVENT?Ex.BINARY_EVENT:Ex.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Ex.BINARY_EVENT&&e.type!==Ex.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=yx(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}},Decoder:Ax});function Tx(e,t,s){return e.on(t,s),function(){e.off(t,s)}}const Sx=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Px extends Gf{constructor(e,t,s){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,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Tx(e,"open",this.onopen.bind(this)),Tx(e,"packet",this.onpacket.bind(this)),Tx(e,"error",this.onerror.bind(this)),Tx(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(Sx.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 s={type:Ex.EVENT,data:t,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),s.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var s;const r=null!==(s=this.flags.timeout)&&void 0!==s?s:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const n=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r),i=(...e)=>{this.io.clearTimeoutFn(n),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise(((s,r)=>{const n=(e,t)=>e?r(e):s(t);n.withError=!0,t.push(n),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(s!==this._queue[0])return;return null!==e?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),s.pending=!1,this._drainQueue()})),this._queue.push(s),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:Ex.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 Ex.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 Ex.EVENT:case Ex.BINARY_EVENT:this.onevent(e);break;case Ex.ACK:case Ex.BINARY_ACK:this.onack(e);break;case Ex.DISCONNECT:this.ondisconnect();break;case Ex.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 s of t)s.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 s=!1;return function(...r){s||(s=!0,t.packet({type:Ex.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ex.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 s=0;s<t.length;s++)if(e===t[s])return t.splice(s,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 s=0;s<t.length;s++)if(e===t[s])return t.splice(s,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 s of t)s.apply(this,e.data)}}}function kx(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}kx.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+s:e-s}return 0|Math.min(e,this.max)},kx.prototype.reset=function(){this.attempts=0},kx.prototype.setMin=function(e){this.ms=e},kx.prototype.setMax=function(e){this.max=e},kx.prototype.setJitter=function(e){this.jitter=e};class _x extends Gf{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,Yf(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!==(s=t.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new kx({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Dx;this.encoder=new r.Encoder,this.decoder=new r.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 cx(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Tx(t,"open",(function(){s.onopen(),e&&e()})),n=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},i=Tx(t,"error",n);if(!1!==this._timeout){const e=this._timeout,s=this.setTimeoutFn((()=>{r(),n(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}return this.subs.push(r),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(Tx(e,"ping",this.onping.bind(this)),Tx(e,"data",this.ondata.bind(this)),Tx(e,"error",this.onerror.bind(this)),Tx(e,"close",this.onclose.bind(this)),Tx(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){sx((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new Px(this,e,t),this.nsps[e]=s),s}_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 s=0;s<t.length;s++)this.engine.write(t[s],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 s=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&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Nx={};function Ix(e,t){"object"==typeof e&&(t=e,e=void 0);const s=function(e,t="",s){let r=e;s=s||"undefined"!=typeof location&&location,null==e&&(e=s.protocol+"//"+s.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?s.protocol+e:s.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==s?s.protocol+"//"+e:"https://"+e),r=ox(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const n=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+t,r.href=r.protocol+"://"+n+(s&&s.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=s.source,n=s.id,i=s.path,a=Nx[n]&&i in Nx[n].nsps;let o;return t.forceNew||t["force new connection"]||!1===t.multiplex||a?o=new _x(r,t):(Nx[n]||(Nx[n]=new _x(r,t)),o=Nx[n]),s.query&&!t.query&&(t.query=s.queryKey),o.socket(s.path,t)}Object.assign(Ix,{Manager:_x,Socket:Px,io:Ix,connect:Ix});var Fx="wss://editor.appthen.com",Ox=process.env.IsDev,Lx=function(){function e(e){this.connectState="connecting",this.connectStateText="连接中...",this.roomId="",this.account="",this.config=e}return e.prototype.joinRoom=function(e){var t,s=e.roomId,r=e.account;this.roomId=s,this.account=r,null===(t=this.socket)||void 0===t||t.emit("join",{room:s,account:r})},e.prototype.leaveRoom=function(){var e;null===(e=this.socket)||void 0===e||e.emit("leave",{room:this.roomId,account:this.account})},e.prototype.sendMessage=function(e){var t;null===(t=this.socket)||void 0===t||t.emit("message",{room:this.roomId,message:e})},e.prototype.connect=function(){var e=this,t=this.config,s=t.onconnect,r=t.onreconnect,n=t.onmsg;console.log("connect socket.io",Fx);var i=Ix(Fx,{transports:["websocket"]});this.onConnectChange("connecting"),i.on("opend",(function(t){e.onConnectChange("connect")})),i.on("message",(function(e){Ox&&console.log("socket.io message event",e),null==n||n(e)})),i.on("connect",(function(){Ox&&console.log("socket.io connect event"),s()})),i.on("disconnect",(function(){Ox&&console.log("socket.io disconnect event"),e.onConnectChange("disconnect")})),i.on("connect_error",(function(t){Ox&&console.log("socket.io connect_error event",t),e.onConnectChange("connect_error")})),i.on("connect_timeout",(function(){Ox&&console.log("socket.io connect_timeout event"),e.onConnectChange("connect_timeout")})),i.on("reconnect",(function(){Ox&&console.log("socket.io reconnect event"),null==r||r(),e.onConnectChange("reconnect")})),i.on("reconnect_attempt",(function(){Ox&&console.log("socket.io reconnect_attempt event"),e.onConnectChange("reconnect_attempt")})),i.on("reconnecting",(function(){Ox&&console.log("socket.io reconnecting event"),e.onConnectChange("reconnecting")})),i.on("reconnect_error",(function(){Ox&&console.log("socket.io reconnect_error event"),e.onConnectChange("reconnect_error")})),i.on("reconnect_failed",(function(){Ox&&console.log("socket.io reconnect_failed event"),e.onConnectChange("reconnect_failed")})),this.socket=i},e.prototype.onConnectChange=function(e){var t=this;switch(this.connectState=e,e){case"connecting":case"reconnecting":this.connectStateText="连接中...";break;case"connect":case"reconnect":this.connectStateText="连接成功",setTimeout((function(){t.connectStateText=""}),1500);break;case"disconnect":this.connectStateText="未连接";break;case"connect_error":case"reconnect_error":case"reconnect_failed":this.connectStateText="请检查网络";break;case"connect_timeout":this.connectStateText="连接超时"}},e}(),Bx=require("child_process").exec;exports.create=function(e){return ne(this,void 0,void 0,(function(){var t,s,r,n,i,a,o,c,u;return ie(this,(function(l){switch(l.label){case 0:s=(t=e||{}).template,r=void 0===s?"vite":s,n=t.folder,i=void 0===n?"appthen-assets-starter":n,console.log("template: ",r),l.label=1;case 1:return l.trys.push([1,6,,7]),[4,ja("/material/templates",{},{method:"GET"})];case 2:return a=l.sent(),o=a.data,c=o.find((function(e){return e.name===r})),c?[4,If(c,c.url,i)]:[3,4];case 3:return l.sent(),[3,5];case 4:console.log("[ERROR] ","template not found"),l.label=5;case 5:return[3,7];case 6:throw u=l.sent(),console.log("[e] ",u),u;case 7:return[2,1]}}))}))},exports.fuck=function(){},exports.getPureValue=Ud,exports.initSolution=function(e,t){return ne(this,void 0,void 0,(function(){var s,r,n,i,a,o,c,u,l,p,h,d,f;return ie(this,(function(m){switch(m.label){case 0:return m.trys.push([0,11,,12]),s=process.cwd(),r=e[0]||"hello",n=_.resolve(s,r),"."===r&&(r=_.basename(s),n=s),i=function(e){return e.replace(/hello-world/g,Mh(r)).replace(/HelloWorld/g,Rh(r)).replace(/Hello World/g,jh(r))},[4,Hd(n)];case 1:m.sent(),a=[{file:".editorconfig",content:"root = true\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\nquote_type = single\n\n[*.md]\ntrim_trailing_whitespace = false\n"},{file:".eslintignore",content:"# 忽略目录\nnode_modules/\nbuild/\ndist/\ntest-cases/\ntest/\ntests/\noutput/\nes/\nlib/\ncoverage/\n\n# 忽略文件\n**/*.min.js\n**/*-min.js\n**/*.bundle.js\n"},{file:".eslintrc.js",content:"module.exports = {\n extends: 'eslint-config-ali/typescript/react',\n rules: {\n 'max-len': ['error', { code: 200 }],\n 'comma-dangle': 0,\n },\n};\n"},{file:".gitignore",content:"# project custom\nbuild\nes\nlib\ndist\noutput\npackage-lock.json\ndeploy-space/packages\ndeploy-space/.env\ngenerated\n\n# IDE\n.vscode\n.idea\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\nlib\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# TypeScript v1 declaration files\ntypings/\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variables file\n.env\n.env.test\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n\n# next.js build output\n.next\n\n# nuxt.js build output\n.nuxt\n\n# vuepress build output\n.vuepress/dist\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# mac config files\n.DS_Store\n\n# codealike\ncodealike.json\n.node\n"},{file:".prettierignore",content:"/test-cases/"},{file:".prettierrc",content:'{\n "tabWidth": 2,\n "singleQuote": true,\n "trailingComma": "es5"\n}\n'},{file:"CHANGELOG.md",content:""},{file:"CONTRIBUTING.md",content:"# 欢迎共建\n\n# 注意\n\n- 注意解决 eslint 问题\n- 注意代码格式化 -- 建议安装 prettier 插件\n- 发布前注意要跑通 demo 和所有的单测\n\n## 本地调试运行 Demo\n\n```sh\n> npm run demo\n```\n\n## 本地跑单测\n\n```sh\n> npm test\n```\n"},{file:"README.md",content:"# 低代码出码自定义方案之 Hello World\n\n## 直接执行\n\n```sh\n> npx ali-lowcode-solution-hello-world demo-schema.json\n```\n\n## 本地调试运行 Demo\n\n```sh\n> npm run demo\n```\n"},{file:"demo-schema.json",content:'{\n "version": "1.0.0",\n "componentsMap": [\n {\n "componentName": "Button",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Button"\n },\n {\n "componentName": "Button.Group",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Button",\n "subName": "Group"\n },\n {\n "componentName": "Input",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Input"\n },\n {\n "componentName": "Form",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Form"\n },\n {\n "componentName": "Form.Item",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Form",\n "subName": "Item"\n },\n {\n "componentName": "NumberPicker",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "NumberPicker"\n },\n {\n "componentName": "Select",\n "package": "@alifd/next",\n "version": "1.19.18",\n "destructuring": true,\n "exportName": "Select"\n }\n ],\n "componentsTree": [\n {\n "componentName": "Page",\n "id": "node$1",\n "meta": {\n "title": "测试",\n "router": "/"\n },\n "props": {\n "ref": "outterView",\n "autoLoading": true\n },\n "fileName": "test",\n "state": {\n "text": "outter"\n },\n "lifeCycles": {\n "componentDidMount": {\n "type": "IPublicTypeJSExpression",\n "value": "function() { console.log(\'componentDidMount\'); }"\n }\n },\n "methodsModule": {\n "type": "JSModule",\n "source": "export function helloWorld() {\\n console.log(\'Hello world!\');\\n}\\n"\n },\n "dataSource": {\n "list": [\n {\n "id": "urlParams",\n "type": "urlParams"\n },\n\n {\n "id": "user",\n "type": "fetch",\n "options": {\n "method": "GET",\n "uri": "https://shs.xxx.com/mock/1458/demo/user",\n "isSync": true\n },\n "dataHandler": {\n "type": "IPublicTypeJSExpression",\n "value": "function (response) {\\nif (!response.data.success){\\n throw new Error(response.data.message);\\n }\\n return response.data.data;\\n}"\n }\n },\n\n {\n "id": "orders",\n "type": "fetch",\n "options": {\n "method": "GET",\n "uri": "https://shs.xxx.com/mock/1458/demo/orders",\n "isSync": true\n },\n "dataHandler": {\n "type": "IPublicTypeJSExpression",\n "value": "function (response) {\\nif (!response.data.success){\\n throw new Error(response.data.message);\\n }\\n return response.data.data.result;\\n}"\n }\n }\n ],\n "dataHandler": {\n "type": "IPublicTypeJSExpression",\n "value": "function (dataMap) {\\n console.info(\\"All datasources loaded:\\", dataMap);\\n}"\n }\n },\n "children": [\n {\n "componentName": "Form",\n "id": "node$2",\n "props": {\n "labelCol": {\n "type": "IPublicTypeJSExpression",\n "value": "this.state.colNum"\n },\n "style": {},\n "ref": "testForm"\n },\n "children": [\n {\n "componentName": "Form.Item",\n "id": "node$3",\n "props": {\n "label": "姓名:",\n "name": "name",\n "initValue": "李雷"\n },\n "children": [\n {\n "componentName": "Input",\n "id": "node$4",\n "props": {\n "placeholder": "请输入",\n "size": "medium",\n "style": {\n "width": 320\n }\n }\n }\n ]\n },\n {\n "componentName": "Form.Item",\n "id": "node$5",\n "props": {\n "label": "年龄:",\n "name": "age",\n "initValue": "22"\n },\n "children": [\n {\n "componentName": "NumberPicker",\n "id": "node$6",\n "props": {\n "size": "medium",\n "type": "normal"\n }\n }\n ]\n },\n {\n "componentName": "Form.Item",\n "id": "node$7",\n "props": {\n "label": "职业:",\n "name": "profession"\n },\n "children": [\n {\n "componentName": "Select",\n "id": "node$8",\n "props": {\n "dataSource": [\n {\n "label": "教师",\n "value": "t"\n },\n {\n "label": "医生",\n "value": "d"\n },\n {\n "label": "歌手",\n "value": "s"\n }\n ]\n }\n }\n ]\n },\n {\n "componentName": "Div",\n "id": "node$9",\n "props": {\n "style": {\n "textAlign": "center"\n }\n },\n "children": [\n {\n "componentName": "Button.Group",\n "id": "node$a",\n "props": {},\n "children": [\n {\n "componentName": "Button",\n "id": "node$b",\n "condition": {\n "type": "IPublicTypeJSExpression",\n "value": "this.index >= 1"\n },\n "loop": ["a", "b", "c"],\n "props": {\n "type": "primary",\n "style": {\n "margin": "0 5px 0 5px"\n }\n },\n "children": [\n {\n "type": "IPublicTypeJSExpression",\n "value": "this.item"\n }\n ]\n }\n ]\n }\n ]\n }\n ]\n }\n ]\n }\n ],\n "constants": {\n "ENV": "prod",\n "DOMAIN": "xxx.xxx.com"\n },\n "css": "body {font-size: 12px;} .table { width: 100px;}",\n "config": {\n "sdkVersion": "1.0.3",\n "historyMode": "hash",\n "targetRootID": "J_Container",\n "layout": {\n "componentName": "BasicLayout",\n "props": {\n "logo": "...",\n "name": "测试网站"\n }\n },\n "theme": {\n "package": "@alife/theme-fusion",\n "version": "^0.1.0",\n "primary": "#ff9966"\n }\n },\n "meta": {\n "name": "demo应用",\n "git_group": "appGroup",\n "project_name": "app_demo",\n "description": "这是一个测试应用",\n "spma": "spa23d",\n "creator": "月飞"\n }\n}\n'},{file:"jest.config.js",content:"module.exports = {\n preset: 'ts-jest',\n testEnvironment: 'node',\n testPathIgnorePatterns: ['/node_modules/', '/test-cases/', '/static-files/', '/lib/'],\n};\n"},{file:"package.json",content:'{\n "name": "ali-lowcode-solution-hello-world",\n "version": "1.0.0",\n "description": "AlLowCode Code Generate Solution - Hello World",\n "files": [\n "src",\n "lib",\n "tests",\n "jest.config.js",\n ".editorconfig",\n ".eslintignore",\n ".eslintrc.js",\n ".gitignore",\n ".prettierignore",\n ".prettierrc",\n "CHANGELOG.md",\n "CONTRIBUTING.md",\n "demo-schema.json",\n "package.json",\n "README.md",\n "tsconfig.json"\n ],\n "main": "lib/index.js",\n "scripts": {\n "start": "jest --watch",\n "build": "npm run clean && concurrently \'npm run build:ts\' \'npm run lint\'",\n "build:ts": "tsc",\n "check:type": "tsc -p . --noEmit",\n "clean": "rm -rf build dist lib generated",\n "dev": "build-scripts start",\n "lint": "eslint --ext .tsx,.ts,.js,.jsx src",\n "lintfix": "eslint --fix --color --ext .tsx,.ts,.js,.jsx src",\n "lint-staged": "lint-staged",\n "prepublishOnly": "npm run build",\n "postpublish": "git push origin master --tags",\n "test": "jest",\n "test:watch": "jest --watch",\n "test:update-snapshots": "cross-env UPDATE_EXPECTED=true npx jest",\n "demo": "npm run build && npx @alilc/lowcode-code-generator --solution . --output generated demo-schema.json"\n },\n "repository": {\n "type": "git",\n "url": "git@github.com:your-name/ali-lowcode-solution-hello-world.git"\n },\n "author": "",\n "license": "ISC",\n "publishConfig": {\n "registry": "https://registry.npm.xxx.com"\n },\n "dependencies": {\n "@alilc/lowcode-code-generator": "^1.0.0-beta.16",\n "@alilc/lowcode-types": "^1.0.0-beta.21",\n "tslib": "^2.3.0"\n },\n "devDependencies": {\n "@types/async": "^3.2.3",\n "@types/jest": "^26.0.17",\n "@typescript-eslint/eslint-plugin": "^4.28.4",\n "@typescript-eslint/parser": "^4.28.4",\n "async": "^3.2.0",\n "babel-runtime": "^6.26.0",\n "concurrently": "^5.2.0",\n "cross-env": "^7.0.0",\n "debug": "^4.1.1",\n "eslint": "^7.31.0",\n "eslint-config-ali": "^12.1.0",\n "eslint-plugin-import": "^2.23.4",\n "eslint-plugin-react": "^7.24.0",\n "eslint-plugin-react-hooks": "^4.2.0",\n "glob": "^7.2.0",\n "husky": "4.2.5",\n "jest": "^26.6.3",\n "json5": "^2.2.0",\n "lint-staged": "10.1.x",\n "lodash": "^4.17.21",\n "md5": "^2.2.1",\n "prettier": "^2.3.2",\n "ts-jest": "^26.4.4",\n "ts-node": "^9.0.0",\n "typescript": "4.x"\n }\n}\n'},{file:"tsconfig.json",content:'{\n "compilerOptions": {\n "esModuleInterop": true,\n "declaration": true,\n "experimentalDecorators": true,\n "forceConsistentCasingInFileNames": true,\n "importHelpers": true,\n "incremental": false,\n "jsx": "react",\n "moduleResolution": "node",\n "resolveJsonModule": true,\n "skipLibCheck": true,\n "sourceMap": true,\n "strict": true,\n "stripInternal": true,\n "outDir": "./lib",\n "declarationDir": "./lib",\n "rootDirs": ["./src"],\n "target": "es6",\n "module": "commonjs",\n "lib": ["esnext"],\n "types": ["jest", "node"],\n "noUnusedLocals": false,\n "noUnusedParameters": false\n },\n "include": ["src/**/*", "typings/**/*"]\n}\n'},{file:"src/index.ts",content:"import CodeGen from '@alilc/lowcode-code-generator';\n\nimport examplePlugin from './plugins/example';\n\nexport default function createHelloWorldProjectBuilder() {\n return CodeGen.createProjectBuilder({\n template: CodeGen.solutionParts.icejs.template,\n plugins: {\n components: [\n CodeGen.plugins.react.reactCommonDeps(),\n CodeGen.plugins.common.esmodule({ fileType: 'jsx' }),\n CodeGen.plugins.react.containerClass(),\n CodeGen.plugins.react.containerInjectContext(),\n CodeGen.plugins.react.containerInjectUtils(),\n CodeGen.plugins.react.containerInjectDataSourceEngine(),\n CodeGen.plugins.react.containerInjectI18n(),\n CodeGen.plugins.react.containerInitState(),\n CodeGen.plugins.react.containerLifeCycle(),\n CodeGen.plugins.react.containerMethod(),\n examplePlugin(),\n CodeGen.plugins.react.jsx({\n nodeTypeMapping: {\n Div: 'div',\n Component: 'div',\n Page: 'div',\n Block: 'div',\n },\n }),\n CodeGen.plugins.style.css(),\n ],\n pages: [\n CodeGen.plugins.react.reactCommonDeps(),\n CodeGen.plugins.common.esmodule({ fileType: 'jsx' }),\n CodeGen.plugins.react.containerClass(),\n CodeGen.plugins.react.containerInjectContext(),\n CodeGen.plugins.react.containerInjectUtils(),\n CodeGen.plugins.react.containerInjectDataSourceEngine(),\n CodeGen.plugins.react.containerInjectI18n(),\n CodeGen.plugins.react.containerInitState(),\n CodeGen.plugins.react.containerLifeCycle(),\n CodeGen.plugins.react.containerMethod(),\n examplePlugin(),\n CodeGen.plugins.react.jsx({\n nodeTypeMapping: {\n Div: 'div',\n Component: 'div',\n Page: 'div',\n Block: 'div',\n },\n }),\n CodeGen.plugins.style.css(),\n ],\n router: [\n CodeGen.plugins.common.esmodule(),\n CodeGen.solutionParts.icejs.plugins.router(),\n ],\n entry: [CodeGen.solutionParts.icejs.plugins.entry()],\n constants: [CodeGen.plugins.project.constants()],\n utils: [\n CodeGen.plugins.common.esmodule(),\n CodeGen.plugins.project.utils('react'),\n ],\n i18n: [CodeGen.plugins.project.i18n()],\n globalStyle: [CodeGen.solutionParts.icejs.plugins.globalStyle()],\n htmlEntry: [CodeGen.solutionParts.icejs.plugins.entryHtml()],\n packageJSON: [CodeGen.solutionParts.icejs.plugins.packageJSON()],\n },\n postProcessors: [CodeGen.postprocessor.prettier()],\n });\n}\n"},{file:"src/plugins/example.ts",content:"import {\n ICodeStruct,\n BuilderComponentPlugin,\n BuilderComponentPluginFactory,\n FileType,\n ChunkType,\n IContainerInfo,\n COMMON_CHUNK_NAME,\n CLASS_DEFINE_CHUNK_NAME,\n DEFAULT_LINK_AFTER,\n} from '@alilc/lowcode-code-generator';\n\nexport interface PluginConfig {\n fileType: string;\n}\n\nconst pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (\n config?\n) => {\n const cfg: PluginConfig = {\n fileType: FileType.JSX,\n ...config,\n };\n\n const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {\n const next: ICodeStruct = {\n ...pre,\n };\n\n const ir = next.ir as IContainerInfo & {\n methodsModule?: {\n type?: 'JSModule';\n source?: string;\n };\n };\n\n if (ir.methodsModule?.type !== 'JSModule' || !ir.methodsModule?.source) {\n return next;\n }\n\n // 创建 methods.jsx\n next.chunks.push({\n type: ChunkType.STRING,\n subModule: 'methods',\n fileType: cfg.fileType,\n name: COMMON_CHUNK_NAME.CustomContent,\n content: ir.methodsModule.source,\n linkAfter: [],\n });\n\n // 引入对应的模块\n next.chunks.push({\n type: ChunkType.STRING,\n fileType: cfg.fileType,\n name: COMMON_CHUNK_NAME.InternalDepsImport,\n content: \"import __$$methodsModule from './methods';\",\n linkAfter: [...DEFAULT_LINK_AFTER[COMMON_CHUNK_NAME.InternalDepsImport]],\n });\n\n // 将导出的东东都放到 class 上实例方法部分\n next.chunks.push({\n type: ChunkType.STRING,\n fileType: cfg.fileType,\n name: CLASS_DEFINE_CHUNK_NAME.ConstructorContent,\n content: 'Object.assign(this, __$$methodsModule);',\n linkAfter: [\n ...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.ConstructorContent],\n ],\n });\n\n return next;\n };\n\n return plugin;\n};\n\nexport default pluginFactory;\n"},{file:"tests/basic.test.ts",content:"test('basic functions should be ok', () => {\n // 这里放一些单元测试\n expect(0).toBe(0);\n});\n"}],m.label=2;case 2:m.trys.push([2,8,9,10]),o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],r=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(a),c=o.next(),m.label=3;case 3:return c.done?[3,7]:(u=c.value,t.verbose&&console.log("%s",it.gray("creating file ".concat(u.file))),l=_.join(n,u.file),[4,Hd(_.dirname(l))]);case 4:return m.sent(),[4,K.writeFile(l,i(u.content),{encoding:"utf-8"})];case 5:m.sent(),m.label=6;case 6:return c=o.next(),[3,3];case 7:return[3,10];case 8:return p=m.sent(),d={error:p},[3,10];case 9:try{c&&!c.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}return[7];case 10:return t.quiet||console.log("%s",it.green("solution ".concat(r," created successfully"))),[2,0];case 11:return h=m.sent(),console.log(it.red(at(h)||"Unexpected error: ".concat(h))),"object"==typeof h&&(null==h?void 0:h.stack)&&t.verbose&&console.log(it.gray(h.stack)),[2,1];case 12:return[2]}}))}))},exports.releaseMaterial=function(e){return ne(this,void 0,void 0,(function(){var t,s,r,n,i,a,o,c,u,l,p,h,d,f,m,y,g,x,v,b,E,C;return ie(this,(function(A){switch(A.label){case 0:return(t=e.auth)&&Ba(t),s=process.cwd(),r="build/lowcode",n=k.default.resolve(process.cwd(),r),(i=F.existsSync(n))||(n=k.default.resolve(process.cwd(),"dist")),[4,function(e){return Promise.resolve().then((function(){return D(require(e))}))}(k.default.resolve(process.cwd(),"package.json"))];case 1:return a=A.sent(),o=a.name,c=a.version,i&&(console.log("lceViewJS: ",k.default.resolve(process.cwd(),r,"view.js")),p=F.readFileSync(k.default.resolve(process.cwd(),r,"view.js"),"utf-8"),u=zd(p),h=F.readFileSync(k.default.resolve(process.cwd(),r,"meta.js"),"utf-8"),l=zd(h)),console.log("Uploading material..."),[4,ct(n+"/")];case 2:d=A.sent(),f=[],m=0,A.label=3;case 3:return m<d.length?(y=d[m],(g=F.readFileSync(y.path+"/"+y.fileName,"utf-8"))&&0!==g.trim().length?[3,4]:(console.log("File is empty Do not Upload: ",y.path+"/"+y.fileName),[3,6])):[3,7];case 4:return x="".concat(o,"/").concat(c,"/")+(y.path.split("".concat(s,"/").concat(r,"/"))[1]||"")+y.fileName,[4,$d(y,{t:1,route:"material",path:x})];case 5:v=A.sent(),f.push(v),A.label=6;case 6:return m++,[3,3];case 7:return console.log("Npm Name: ",o),console.log("Npm Version: ",c),i?(b=f.find((function(e){return e.key.includes("".concat(c,"/view.js"))})),E=f.find((function(e){return e.key.includes("".concat(c,"/view.css"))})),C=f.find((function(e){return e.key.includes("".concat(c,"/meta.js"))})),console.log("Npm Export Name: ",u),console.log("Npm Js Url: ",null==b?void 0:b.url),console.log("Npm Css Url: ",null==E?void 0:E.url),console.log("Meta Export Name: ",l),console.log("Meta Url: ",null==C?void 0:C.url)):f.length>0&&f.forEach((function(e){console.log("File Name: ",e.key),console.log("File Url: ",e.url)})),[2,1]}}))}))},exports.run=Md,exports.startWatching=function(e){return ne(this,void 0,void 0,(function(){var t,s,r,n,i,a,o,c;return ie(this,(function(u){return t=e.id,s=e.auth,r=e.account,s&&Ba(e.auth),n="PROJECT_ROOM_"+t,i=ae((La||"").split("##"),2),a=i[0],o=i[1],c=new Lx({token:a,client:o,onconnect:function(){console.log("[Service] Editor connected!"),c.joinRoom({roomId:n,account:r})},onmsg:function(t){var s=t||{};s.action;var n=s.message;if(n){n.updatedFileState;var i=n.userId,a=n.current,o=n.cwd;String(i)===r&&(a&&Md(0,re(re({},e),{clear:!!a.clear})),o&&Bx(o,{shell:"/bin/bash"},(function(e,t,s){e&&console.error("执行出错: ".concat(e)),console.log("exec: ",e,t,s),c.sendMessage({action:"cwd",message:{stdout:t,stderr:s,error:e}})})))}}}),c.connect(),[2,1]}))}))};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appthen/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Appthen Cli Tool",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
"@babel/types": "^7.24.0",
|
|
53
53
|
"@liangshen/youdao": "^1.0.3",
|
|
54
54
|
"@mengti/code-generator": "^1.0.7",
|
|
55
|
+
"@types/socket.io-client": "^3.0.0",
|
|
56
|
+
"@weapp-core/logger": "^1.0.1",
|
|
55
57
|
"adm-zip": "^0.5.12",
|
|
56
58
|
"axios": "^0.27.2",
|
|
57
59
|
"bufferutil": "^4.0.8",
|
|
@@ -60,6 +62,7 @@
|
|
|
60
62
|
"change-case": "^3.1.0",
|
|
61
63
|
"commander": "^6.1.0",
|
|
62
64
|
"cssjson": "^2.1.3",
|
|
65
|
+
"execa": "9.3.1",
|
|
63
66
|
"flat-cache": "3.0.4",
|
|
64
67
|
"form-data": "^4.0.0",
|
|
65
68
|
"fp-ts": "^2.11.9",
|
|
@@ -68,6 +71,7 @@
|
|
|
68
71
|
"nanoid": "3.3.4",
|
|
69
72
|
"nanomatch": "^1.2.13",
|
|
70
73
|
"original-fs": "^1.2.0",
|
|
74
|
+
"pathe": "^1.1.2",
|
|
71
75
|
"qiniu": "^7.10.0",
|
|
72
76
|
"react": "^18.2.0",
|
|
73
77
|
"short-uuid": "^4.2.2",
|