@linzumi/cli 1.0.271 → 1.0.272

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -58,7 +58,7 @@ Install the CLI or run it with `npx`:
58
58
  ```bash
59
59
  npm install -g @linzumi/cli@latest
60
60
  npx -y @linzumi/cli@latest signup
61
- npx -y @linzumi/cli@1.0.271 --version
61
+ npx -y @linzumi/cli@1.0.272 --version
62
62
  linzumi --version
63
63
  ```
64
64
 
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
2
2
  const require = __linzumiBundleCreateRequire(import.meta.url);
3
3
  var VF=Object.create;var Zm=Object.defineProperty;var ZF=Object.getOwnPropertyDescriptor;var QF=Object.getOwnPropertyNames;var YF=Object.getPrototypeOf,XF=Object.prototype.hasOwnProperty;var He=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var q=(e,t)=>()=>(e&&(t=e(e=0)),t);var tt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),eD=(e,t)=>{for(var n in t)Zm(e,n,{get:t[n],enumerable:!0})},tD=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of QF(t))!XF.call(e,r)&&r!==n&&Zm(e,r,{get:()=>t[r],enumerable:!(i=ZF(t,r))||i.enumerable});return e};var oa=(e,t,n)=>(n=e!=null?VF(YF(e)):{},tD(t||!e||!e.__esModule?Zm(n,"default",{value:e,enumerable:!0}):n,e));var Qm=q(()=>{});function Nt(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function Iu(e){if(e!=null)return Nt(e)}function Ve(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}var nt=q(()=>{});function aa(e,t){if(e!==void 0)return t(Ve(e))}function St(e,t){if(e!==void 0)return Nt(t(Ve(e)))}function mn(e,t){if(e!==void 0)return t(Ve(e))}function Ke(e,t){return e!==void 0?Ve(e):t}var Me=q(()=>{Qm();nt()});var Ou=q(()=>{});function dn(e,t,n){return e.reduce(n,t)}var Et=q(()=>{Ou();nt()});function ri(e){if(e.RE_EXN_ID==="JsExn")return Nt(e._1)}var Ru,rD,Dr,Bue,Wue,ii=q(()=>{nt();Ru=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),rD=Ru("stack"),Dr=Ru("message"),Bue=Ru("name"),Wue=Ru("fileName")});var $u=q(()=>{});var ik=tt((Hue,rk)=>{var Ci=He("constants"),iD=process.cwd,Mu=null,oD=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Mu||(Mu=iD.call(process)),Mu};try{process.cwd()}catch{}typeof process.chdir=="function"&&(eh=process.chdir,process.chdir=function(e){Mu=null,eh.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,eh));var eh;rk.exports=aD;function aD(e){Ci.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=r(e.chmodSync),e.fchmodSync=r(e.fchmodSync),e.lchmodSync=r(e.lchmodSync),e.stat=s(e.stat),e.fstat=s(e.fstat),e.lstat=s(e.lstat),e.statSync=d(e.statSync),e.fstatSync=d(e.fstatSync),e.lstatSync=d(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,c,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,c,p,f){f&&process.nextTick(f)},e.lchownSync=function(){}),oD==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function c(p,f,h){var g=Date.now(),_=0;u(p,f,function y(b){if(b&&(b.code==="EACCES"||b.code==="EPERM"||b.code==="EBUSY")&&Date.now()-g<6e4){setTimeout(function(){e.stat(f,function(v,w){v&&v.code==="ENOENT"?u(p,f,y):h(b)})},_),_<100&&(_+=10);return}h&&h(b)})}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function c(p,f,h,g,_,y){var b;if(y&&typeof y=="function"){var v=0;b=function(w,A,C){if(w&&w.code==="EAGAIN"&&v<10)return v++,u.call(e,p,f,h,g,_,b);y.apply(this,arguments)}}return u.call(e,p,f,h,g,_,b)}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(c,p,f,h,g){for(var _=0;;)try{return u.call(e,c,p,f,h,g)}catch(y){if(y.code==="EAGAIN"&&_<10){_++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(c,p,f){u.open(c,Ci.O_WRONLY|Ci.O_SYMLINK,p,function(h,g){if(h){f&&f(h);return}u.fchmod(g,p,function(_){u.close(g,function(y){f&&f(_||y)})})})},u.lchmodSync=function(c,p){var f=u.openSync(c,Ci.O_WRONLY|Ci.O_SYMLINK,p),h=!0,g;try{g=u.fchmodSync(f,p),h=!1}finally{if(h)try{u.closeSync(f)}catch{}else u.closeSync(f)}return g}}function n(u){Ci.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(c,p,f,h){u.open(c,Ci.O_SYMLINK,function(g,_){if(g){h&&h(g);return}u.futimes(_,p,f,function(y){u.close(_,function(b){h&&h(y||b)})})})},u.lutimesSync=function(c,p,f){var h=u.openSync(c,Ci.O_SYMLINK),g,_=!0;try{g=u.futimesSync(h,p,f),_=!1}finally{if(_)try{u.closeSync(h)}catch{}else u.closeSync(h)}return g}):u.futimes&&(u.lutimes=function(c,p,f,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function i(u){return u&&function(c,p,f){return u.call(e,c,p,function(h){l(h)&&(h=null),f&&f.apply(this,arguments)})}}function r(u){return u&&function(c,p){try{return u.call(e,c,p)}catch(f){if(!l(f))throw f}}}function o(u){return u&&function(c,p,f,h){return u.call(e,c,p,f,function(g){l(g)&&(g=null),h&&h.apply(this,arguments)})}}function a(u){return u&&function(c,p,f){try{return u.call(e,c,p,f)}catch(h){if(!l(h))throw h}}}function s(u){return u&&function(c,p,f){typeof p=="function"&&(f=p,p=null);function h(g,_){_&&(_.uid<0&&(_.uid+=4294967296),_.gid<0&&(_.gid+=4294967296)),f&&f.apply(this,arguments)}return p?u.call(e,c,p,h):u.call(e,c,h)}}function d(u){return u&&function(c,p){var f=p?u.call(e,c,p):u.call(e,c);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function l(u){if(!u||u.code==="ENOSYS")return!0;var c=!process.getuid||process.getuid()!==0;return!!(c&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var sk=tt((Vue,ak)=>{var ok=He("stream").Stream;ak.exports=sD;function sD(e){return{ReadStream:t,WriteStream:n};function t(i,r){if(!(this instanceof t))return new t(i,r);ok.call(this);var o=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,r=r||{};for(var a=Object.keys(r),s=0,d=a.length;s<d;s++){var l=a[s];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,c){if(u){o.emit("error",u),o.readable=!1;return}o.fd=c,o.emit("open",c),o._read()})}function n(i,r){if(!(this instanceof n))return new n(i,r);ok.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var o=Object.keys(r),a=0,s=o.length;a<s;a++){var d=o[a];this[d]=r[d]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var lk=tt((Zue,dk)=>{"use strict";dk.exports=lD;var dD=Object.getPrototypeOf||function(e){return e.__proto__};function lD(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:dD(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var ih=tt((Que,rh)=>{var wt=He("fs"),uD=ik(),cD=sk(),fD=lk(),ju=He("util"),Yt,Nu;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Yt=Symbol.for("graceful-fs.queue"),Nu=Symbol.for("graceful-fs.previous")):(Yt="___graceful-fs.queue",Nu="___graceful-fs.previous");function pD(){}function fk(e,t){Object.defineProperty(e,Yt,{get:function(){return t}})}var ao=pD;ju.debuglog?ao=ju.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ao=function(){var e=ju.format.apply(ju,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)});wt[Yt]||(uk=global[Yt]||[],fk(wt,uk),wt.close=(function(e){function t(n,i){return e.call(wt,n,function(r){r||ck(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(t,Nu,{value:e}),t})(wt.close),wt.closeSync=(function(e){function t(n){e.apply(wt,arguments),ck()}return Object.defineProperty(t,Nu,{value:e}),t})(wt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ao(wt[Yt]),He("assert").equal(wt[Yt].length,0)}));var uk;global[Yt]||fk(global,wt[Yt]);rh.exports=th(fD(wt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!wt.__patched&&(rh.exports=th(wt),wt.__patched=!0);function th(e){uD(e),e.gracefulify=th,e.createReadStream=A,e.createWriteStream=C;var t=e.readFile;e.readFile=n;function n(T,E,P){return typeof E=="function"&&(P=E,E=null),R(T,E,P);function R(O,M,J,Z){return t(O,M,function(z){z&&(z.code==="EMFILE"||z.code==="ENFILE")?sa([R,[O,M,J],z,Z||Date.now(),Date.now()]):typeof J=="function"&&J.apply(this,arguments)})}}var i=e.writeFile;e.writeFile=r;function r(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return i(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return o(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(T,E,P,R){return typeof P=="function"&&(R=P,P=0),O(T,E,P,R);function O(M,J,Z,z,X){return s(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(T,E,P){typeof E=="function"&&(P=E,E=null);var R=u.test(process.version)?function(J,Z,z,X){return l(J,O(J,Z,z,X))}:function(J,Z,z,X){return l(J,Z,O(J,Z,z,X))};return R(T,E,P);function O(M,J,Z,z){return function(X,ee){X&&(X.code==="EMFILE"||X.code==="ENFILE")?sa([R,[M,J,Z],X,z||Date.now(),Date.now()]):(ee&&ee.sort&&ee.sort(),typeof Z=="function"&&Z.call(this,X,ee))}}}if(process.version.substr(0,4)==="v0.8"){var p=cD(e);y=p.ReadStream,v=p.WriteStream}var f=e.ReadStream;f&&(y.prototype=Object.create(f.prototype),y.prototype.open=b);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(T){y=T},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(T){v=T},enumerable:!0,configurable:!0});var g=y;Object.defineProperty(e,"FileReadStream",{get:function(){return g},set:function(T){g=T},enumerable:!0,configurable:!0});var _=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(T){_=T},enumerable:!0,configurable:!0});function y(T,E){return this instanceof y?(f.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function b(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.autoClose&&T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P),T.read())})}function v(T,E){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function w(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P))})}function A(T,E){return new e.ReadStream(T,E)}function C(T,E){return new e.WriteStream(T,E)}var S=e.open;e.open=k;function k(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return S(M,J,Z,function(ee,B){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}return e}function sa(e){ao("ENQUEUE",e[0].name,e[1]),wt[Yt].push(e),nh()}var qu;function ck(){for(var e=Date.now(),t=0;t<wt[Yt].length;++t)wt[Yt][t].length>2&&(wt[Yt][t][3]=e,wt[Yt][t][4]=e);nh()}function nh(){if(clearTimeout(qu),qu=void 0,wt[Yt].length!==0){var e=wt[Yt].shift(),t=e[0],n=e[1],i=e[2],r=e[3],o=e[4];if(r===void 0)ao("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-r>=6e4){ao("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,i)}else{var s=Date.now()-o,d=Math.max(o-r,1),l=Math.min(d*1.2,100);s>=l?(ao("RETRY",t.name,n),t.apply(null,n.concat([r]))):wt[Yt].push(e)}qu===void 0&&(qu=setTimeout(nh,0))}}});var mk=tt((Yue,pk)=>{function Vn(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}pk.exports=Vn;Vn.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Vn.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Vn.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var i=this,r=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},n);return this._options.unref&&r.unref(),!0};Vn.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Vn.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Vn.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Vn.prototype.start=Vn.prototype.try;Vn.prototype.errors=function(){return this._errors};Vn.prototype.attempts=function(){return this._attempts};Vn.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,i=0;i<this._errors.length;i++){var r=this._errors[i],o=r.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=r,n=a)}return t}});var hk=tt(so=>{var mD=mk();so.operation=function(e){var t=so.timeouts(e);return new mD(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};so.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],r=0;r<t.retries;r++)i.push(this.createTimeout(r,t));return e&&e.forever&&!i.length&&i.push(this.createTimeout(r,t)),i.sort(function(o,a){return o-a}),i};so.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return i=Math.min(i,t.maxTimeout),i};so.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var i in e)typeof e[i]=="function"&&n.push(i)}for(var r=0;r<n.length;r++){var o=n[r],a=e[o];e[o]=function(d){var l=so.operation(t),u=Array.prototype.slice.call(arguments,1),c=u.pop();u.push(function(p){l.retry(p)||(p&&(arguments[0]=l.mainError()),c.apply(this,arguments))}),l.attempt(function(){d.apply(e,u)})}.bind(e,a),e[o].options=t}}});var yk=tt((ece,gk)=>{gk.exports=hk()});var _k=tt((tce,Fu)=>{Fu.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Fu.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Fu.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var kk=tt((nce,ua)=>{var ft=global.process,lo=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};lo(ft)?(bk=He("assert"),da=_k(),vk=/^win/i.test(ft.platform),Zs=He("events"),typeof Zs!="function"&&(Zs=Zs.EventEmitter),ft.__signal_exit_emitter__?zt=ft.__signal_exit_emitter__:(zt=ft.__signal_exit_emitter__=new Zs,zt.count=0,zt.emitted={}),zt.infinite||(zt.setMaxListeners(1/0),zt.infinite=!0),ua.exports=function(e,t){if(!lo(global.process))return function(){};bk.equal(typeof e,"function","a callback must be provided for exit handler"),la===!1&&oh();var n="exit";t&&t.alwaysLast&&(n="afterexit");var i=function(){zt.removeListener(n,e),zt.listeners("exit").length===0&&zt.listeners("afterexit").length===0&&Du()};return zt.on(n,e),i},Du=function(){!la||!lo(global.process)||(la=!1,da.forEach(function(t){try{ft.removeListener(t,Lu[t])}catch{}}),ft.emit=Uu,ft.reallyExit=ah,zt.count-=1)},ua.exports.unload=Du,uo=function(t,n,i){zt.emitted[t]||(zt.emitted[t]=!0,zt.emit(t,n,i))},Lu={},da.forEach(function(e){Lu[e]=function(){if(lo(global.process)){var n=ft.listeners(e);n.length===zt.count&&(Du(),uo("exit",null,e),uo("afterexit",null,e),vk&&e==="SIGHUP"&&(e="SIGINT"),ft.kill(ft.pid,e))}}}),ua.exports.signals=function(){return da},la=!1,oh=function(){la||!lo(global.process)||(la=!0,zt.count+=1,da=da.filter(function(t){try{return ft.on(t,Lu[t]),!0}catch{return!1}}),ft.emit=wk,ft.reallyExit=Sk)},ua.exports.load=oh,ah=ft.reallyExit,Sk=function(t){lo(global.process)&&(ft.exitCode=t||0,uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),ah.call(ft,ft.exitCode))},Uu=ft.emit,wk=function(t,n){if(t==="exit"&&lo(global.process)){n!==void 0&&(ft.exitCode=n);var i=Uu.apply(this,arguments);return uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),i}else return Uu.apply(this,arguments)}):ua.exports=function(){return function(){}};var bk,da,vk,Zs,zt,Du,uo,Lu,la,oh,ah,Sk,Uu,wk});var Ek=tt((rce,Qs)=>{"use strict";var hD=He("path"),lh=ih(),gD=yk(),yD=kk(),oi={};function ca(e,t){return t.lockfilePath||`${e}.lock`}function uh(e,t,n){if(!t.realpath)return n(null,hD.resolve(e));t.fs.realpath(e,n)}function sh(e,t,n){t.fs.mkdir(ca(e,t),i=>{if(!i)return n();if(i.code!=="EEXIST")return n(i);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(ca(e,t),(r,o)=>{if(r)return r.code==="ENOENT"?sh(e,{...t,stale:0},n):n(r);if(!Tk(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));Ck(e,t,a=>{if(a)return n(a);sh(e,{...t,stale:0},n)})})})}function Tk(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Ck(e,t,n){t.fs.rmdir(ca(e,t),i=>{if(i&&i.code!=="ENOENT")return n(i);n()})}function dh(e,t){let n=oi[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let i=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(ca(e,t),i,i,r=>{if(!n.released){if(n.lastUpdate<=Date.now()-t.stale&&n.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(n.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return xk(e,n,o)}if(r)return r.code==="ENOENT"?xk(e,n,Object.assign(r,{code:"ECOMPROMISED"})):(n.updateError=r,n.updateDelay=1e3,dh(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,dh(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function xk(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),oi[e]===t&&delete oi[e],t.options.onCompromised(n)}function _D(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:lh,onCompromised:i=>{throw i},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),uh(e,t,(i,r)=>{if(i)return n(i);let o=gD.operation(t.retries);o.attempt(()=>{sh(r,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=oi[r]={options:t,lastUpdate:Date.now()};dh(r,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Ak(r,{...t,realpath:!1},d)})})})})}function Ak(e,t,n){t={fs:lh,realpath:!0,...t},uh(e,t,(i,r)=>{if(i)return n(i);let o=oi[r];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete oi[r],Ck(r,t,n)})}function bD(e,t,n){t={stale:1e4,realpath:!0,fs:lh,...t},t.stale=Math.max(t.stale||0,2e3),uh(e,t,(i,r)=>{if(i)return n(i);t.fs.stat(ca(r,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!Tk(a,t)))})}function vD(){return oi}yD(()=>{for(let e in oi){let t=oi[e].options;try{t.fs.rmdirSync(ca(e,t))}catch{}}});Qs.exports.lock=_D;Qs.exports.unlock=Ak;Qs.exports.check=bD;Qs.exports.getLocks=vD});var Ik=tt((ice,Pk)=>{"use strict";var SD=ih();function wD(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(i=>{n[i]=(...r)=>{let o=r.pop(),a;try{a=e[`${i}Sync`](...r)}catch(s){return o(s)}o(null,a)}}),n}function kD(e){return(...t)=>new Promise((n,i)=>{t.push((r,o)=>{r?i(r):n(o)}),e(...t)})}function xD(e){return(...t)=>{let n,i;if(t.push((r,o)=>{n=r,i=o}),e(...t),n)throw n;return i}}function TD(e){if(e={...e},e.fs=wD(e.fs||SD),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Pk.exports={toPromise:kD,toSync:xD,toSyncOptions:TD}});var Rk=tt((oce,Ai)=>{"use strict";var fa=Ek(),{toPromise:Gu,toSync:zu,toSyncOptions:ch}=Ik();async function Ok(e,t){let n=await Gu(fa.lock)(e,t);return Gu(n)}function CD(e,t){let n=zu(fa.lock)(e,ch(t));return zu(n)}function AD(e,t){return Gu(fa.unlock)(e,t)}function ED(e,t){return zu(fa.unlock)(e,ch(t))}function PD(e,t){return Gu(fa.check)(e,t)}function ID(e,t){return zu(fa.check)(e,ch(t))}Ai.exports=Ok;Ai.exports.lock=Ok;Ai.exports.unlock=AD;Ai.exports.lockSync=CD;Ai.exports.unlockSync=ED;Ai.exports.check=PD;Ai.exports.checkSync=ID});var $k=q(()=>{});var Mk=q(()=>{});var Ju=q(()=>{});var Jt=q(()=>{$k();Mk();Ju()});function $D(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function Kt(e){return $D(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function mh(e){let t=ph[e];if(t!==void 0){let n=t+1|0;return ph[e]=n,e+("/"+n)}return ph[e]=1,e}var ph,en=q(()=>{ph={}});import*as Nk from"node:child_process";function pa(e){let t=ri(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=Ve(t);return{code:Iu(n.code),message:Ke(Dr(n),"unknown error")}}function Fk(e,t,n,i){try{return{TAG:"Ok",_0:Nk.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:i})}}catch(r){let o=Kt(r);return{TAG:"Error",_0:pa(o)}}}var MD,Bt=q(()=>{ii();Me();$u();MD=oa(Rk(),1);Jt();nt();en()});function Lk(e){let t=Fk(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=Dk.exec(t._0);if(n!=null)return mn(n.slice(1)[0],i=>i)}function Uk(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}var Dk,Gk=q(()=>{Et();Bt();Me();Jt();Dk=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function qD(e,t){let n=Uk(e,t);switch(n.TAG){case"Match":return{TAG:"Ok",_0:n.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+n.pathVersion+" expected="+n.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+t}}}function zk(e,t){return qD(Lk(e),t)}var Jk=q(()=>{Me();Gk()});var Kk,hh=q(()=>{Jk();Kk=zk});var Wk,Bk=q(()=>{Wk={name:"@linzumi/cli",version:"1.0.271",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts"],scripts:{"test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts test/llmProxySessionCredential.test.ts test/runnerBridge.test.ts test/threadCodexWorkerIpc.test.ts -t '(?:^| )(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup|does not install an old mint after its credential is (replaced|stopped)|worker agent capability requires an exact true ready flag|starts an explicitly server-keyed OpenAI agent worker without local OpenAI credentials|applies the accepted OpenAI follow-up model on an existing worker|refuses explicit OpenAI worker creation with (passthrough|missing-token|blank-origin) binding|refuses a private agent turn without an owned relay before Codex|explicitly capable worker receives a private request through ordinary IPC|old worker receives no private agent source descriptor)$'",build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","test:actual-commander-parity":"pnpm --dir ../linzumi-cli-rescript build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/ActualCommanderParityConformance.res.mjs","bump-version":"node scripts/bump-cli-version.mjs","codex:history-table":"node scripts/codex_history_table.mjs",test:"npm run test:startup && node --import tsx --test ../linzumi-cli-rescript/src/parity/McpToolCallBoundaryTest.res.mjs && rescript build ../../kandan/server_v2/web/replay_harness && vitest run --config vitest.config.mjs",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","record:agent-fixtures":"tsx scripts/record-agent-replay-fixtures.ts","normalize:agent-fixture":"tsx scripts/normalize-agent-replay-fixture.ts","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","replay:agent-fixture":"tsx scripts/replay-agent-fixture.ts","replay:agent-backend":"tsx scripts/replay-agent-backend.ts","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check","replay:agent-backend-browser":"tsx scripts/replay-agent-backend-browser.ts","promote:gstack-claude-smoke-fixture":"tsx scripts/promote-gstack-claude-smoke-fixture.ts","diagnose:claude-probe":"tsx scripts/diagnose-claude-probe.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.199","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.153.2",blessed:"^0.1.81","proper-lockfile":"3.2.0",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var gh,Wu=q(()=>{"use strict";Bk();gh=Wk.dependencies["@openai/codex"]});async function Hk(e,t,n){let i;try{e(),i=!0}catch{i=!1}let r;try{await t(),r=!0}catch{r=!1}return i&&r?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function Vk(e,t){let n=e.quotaWindow,i=e.credits;if(n===void 0&&i===void 0)return{status:"unavailable",reason:"empty_response"};let r=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:r[0],windowMinutes:r[1],resetsAtMs:r[2],capturedAtMs:t,credits:i}}}var Zk=q(()=>{});var Qk,Yk,Xk=q(()=>{Zk();Qk=Hk,Yk=Vk});function Be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yh(e){let t=[["threadId",e.threadId],["turnId",e.turnId],["itemId",e.itemId],["processId",e.processId],["requestId",e.requestId]].filter(n=>n[1]!==void 0);return Object.fromEntries(t)}var Pt=q(()=>{"use strict"});var Hu=q(()=>{"use strict";Pt()});function rx(e){let t=Lr(e.rateLimits)??Lr(e.rate_limits)??Lr(e.limits)??e,n=[t,...Object.values(t).flatMap(_=>{let y=Lr(_);return y===void 0?[]:[y]})],i=n.reduce((_,y)=>{let b=De(y.usedPercent)??De(y.used_percent);return b===void 0?_:_===void 0?b:Math.max(_,b)},void 0),o=n.some(_=>De(_.remaining)===0||De(_.remainingRequests)===0||De(_.remaining_requests)===0||De(_.remainingTokens)===0||De(_.remaining_tokens)===0||De(_.retryAfterSeconds)!==void 0||De(_.retry_after_seconds)!==void 0)?"rejected":i!==void 0&&i>=80?"allowed_warning":"allowed",a=Lr(t.primary),s=De(a?.usedPercent),d=De(a?.windowDurationMins),l=De(a?.resetsAt),u=Lr(t.credits),c=nx(u?.hasCredits),p=nx(u?.unlimited),f=u?.balance,h=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof f=="string"?f:null},g=s===void 0&&d===void 0&&l===void 0?void 0:{...s===void 0?{}:{usedPercent:s},...d===void 0?{}:{windowMinutes:d},...l===void 0?{}:{resetsAtMs:l*1e3}};return{summary:UD(e)??"seen (no details)",status:o,utilizationPercent:i,...g===void 0?{}:{quotaWindow:g},...h===void 0?{}:{credits:h}}}function UD(e){let t=Lr(e.rateLimits)??Lr(e.rate_limits)??Lr(e.limits)??e,n=ex(t,void 0),i=Object.entries(t).flatMap(([o,a])=>{let s=Lr(a);return s===void 0?[]:[ex(s,o)]}),r=[n,...i].filter(o=>o!==void 0);return r.length===0?void 0:r.join(" | ")}function ex(e,t){let n=gr(e.limitName)??gr(e.limit_name)??gr(e.name)??gr(e.type)??t,i=gr(e.planType)??gr(e.plan_type)??gr(e.plan),r=De(e.remaining)??De(e.remainingRequests)??De(e.remaining_requests)??De(e.remainingTokens)??De(e.remaining_tokens),o=De(e.limit)??De(e.requestLimit)??De(e.request_limit)??De(e.limitRequests)??De(e.limit_requests)??De(e.tokenLimit)??De(e.token_limit)??De(e.limitTokens)??De(e.limit_tokens),a=gr(e.resetAt)??gr(e.reset_at)??gr(e.resetsAt)??gr(e.resets_at)??tx(e.resetsAt)??tx(e.resets_at)??Vu(e.resetAfterSeconds)??Vu(e.reset_after_seconds)??Vu(e.retryAfterSeconds)??Vu(e.retry_after_seconds),s=De(e.usedPercent)??De(e.used_percent),d=De(e.windowDurationMins)??De(e.window_duration_mins),l=[n,i].filter(f=>f!==void 0).join(" "),u=l===""?void 0:l,p=[r===void 0?void 0:o===void 0?`${r} remaining`:`${r}/${o} remaining`,s===void 0?void 0:`${s}% used`,d===void 0?void 0:`${d}m window`,a===void 0?void 0:`reset ${a}`].filter(f=>f!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Vu(e){let t=De(e);return t===void 0?void 0:`${t}s`}function tx(e){let t=De(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function Lr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function gr(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function nx(e){return typeof e=="boolean"?e:void 0}function De(e){if(typeof e=="number"&&Number.isSafeInteger(e))return e;if(typeof e!="string")return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t.toString()===e.trim()?t:void 0}var ix=q(()=>{"use strict";Hu();Pt()});var ai=tt((kce,sx)=>{"use strict";var ox=["nodebuffer","arraybuffer","fragments"],ax=typeof Blob<"u";ax&&ox.push("blob");sx.exports={BINARY_TYPES:ox,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ax,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ys=tt((xce,Zu)=>{"use strict";var{EMPTY_BUFFER:GD}=ai(),_h=Buffer[Symbol.species];function zD(e,t){if(e.length===0)return GD;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),i=0;for(let r=0;r<e.length;r++){let o=e[r];n.set(o,i),i+=o.length}return i<t?new _h(n.buffer,n.byteOffset,i):n}function dx(e,t,n,i,r){for(let o=0;o<r;o++)n[i+o]=e[o]^t[o&3]}function lx(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function JD(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function bh(e){if(bh.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new _h(e):ArrayBuffer.isView(e)?t=new _h(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),bh.readOnly=!1),t}Zu.exports={concat:zD,mask:dx,toArrayBuffer:JD,toBuffer:bh,unmask:lx};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=He("bufferutil");Zu.exports.mask=function(t,n,i,r,o){o<48?dx(t,n,i,r,o):e.mask(t,n,i,r,o)},Zu.exports.unmask=function(t,n){t.length<32?lx(t,n):e.unmask(t,n)}}catch{}});var fx=tt((Tce,cx)=>{"use strict";var ux=Symbol("kDone"),vh=Symbol("kRun"),Sh=class{constructor(t){this[ux]=()=>{this.pending--,this[vh]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[vh]()}[vh](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[ux])}}};cx.exports=Sh});var ed=tt((Cce,gx)=>{"use strict";var Xs=He("zlib"),px=Ys(),KD=fx(),{kStatusCode:mx}=ai(),BD=Buffer[Symbol.species],WD=Buffer.from([0,0,255,255]),Yu=Symbol("permessage-deflate"),si=Symbol("total-length"),ha=Symbol("callback"),Ei=Symbol("buffers"),ga=Symbol("error"),Qu,wh=class{constructor(t,n,i){if(this._maxPayload=i|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Qu){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Qu=new KD(r)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[ha];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,i=t.find(r=>!(n.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>r.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(i.server_no_context_takeover=!0),n.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(i.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?i.client_max_window_bits=n.clientMaxWindowBits:(i.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(i=>{let r=n[i];if(r.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(r=r[0],i==="client_max_window_bits"){if(r!==!0){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else if(i==="server_max_window_bits"){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else throw new Error(`Unknown parameter "${i}"`);n[i]=r})}),t}decompress(t,n,i){Qu.add(r=>{this._decompress(t,n,(o,a)=>{r(),i(o,a)})})}compress(t,n,i){Qu.add(r=>{this._compress(t,n,(o,a)=>{r(),i(o,a)})})}_decompress(t,n,i){let r=this._isServer?"client":"server";if(!this._inflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Xs.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=Xs.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Yu]=this,this._inflate[si]=0,this._inflate[Ei]=[],this._inflate.on("error",VD),this._inflate.on("data",hx)}this._inflate[ha]=i,this._inflate.write(t),n&&this._inflate.write(WD),this._inflate.flush(()=>{let o=this._inflate[ga];if(o){this._inflate.close(),this._inflate=null,i(o);return}let a=px.concat(this._inflate[Ei],this._inflate[si]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[si]=0,this._inflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,a)})}_compress(t,n,i){let r=this._isServer?"server":"client";if(!this._deflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Xs.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=Xs.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[si]=0,this._deflate[Ei]=[],this._deflate.on("data",HD)}this._deflate[ha]=i,this._deflate.write(t),this._deflate.flush(Xs.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=px.concat(this._deflate[Ei],this._deflate[si]);n&&(o=new BD(o.buffer,o.byteOffset,o.length-4)),this._deflate[ha]=null,this._deflate[si]=0,this._deflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,o)})}};gx.exports=wh;function HD(e){this[Ei].push(e),this[si]+=e.length}function hx(e){if(this[si]+=e.length,this[Yu]._maxPayload<1||this[si]<=this[Yu]._maxPayload){this[Ei].push(e);return}this[ga]=new RangeError("Max payload size exceeded"),this[ga].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ga][mx]=1009,this.removeListener("data",hx),this.reset()}function VD(e){if(this[Yu]._inflate=null,this[ga]){this[ha](this[ga]);return}e[mx]=1007,this[ha](e)}});var ya=tt((Ace,Xu)=>{"use strict";var{isUtf8:yx}=He("buffer"),{hasBlob:ZD}=ai(),QD=[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];function YD(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function kh(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function XD(e){return ZD&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Xu.exports={isBlob:XD,isValidStatusCode:YD,isValidUTF8:kh,tokenChars:QD};if(yx)Xu.exports.isValidUTF8=function(e){return e.length<24?kh(e):yx(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=He("utf-8-validate");Xu.exports.isValidUTF8=function(t){return t.length<32?kh(t):e(t)}}catch{}});var Eh=tt((Ece,xx)=>{"use strict";var{Writable:eL}=He("stream"),_x=ed(),{BINARY_TYPES:tL,EMPTY_BUFFER:bx,kStatusCode:nL,kWebSocket:rL}=ai(),{concat:xh,toArrayBuffer:iL,unmask:oL}=Ys(),{isValidStatusCode:aL,isValidUTF8:vx}=ya(),ec=Buffer[Symbol.species],Zn=0,Sx=1,wx=2,kx=3,Th=4,Ch=5,tc=6,Ah=class extends eL{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||tL[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[rL]=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=Zn}_write(t,n,i){if(this._opcode===8&&this._state==Zn)return i();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(i)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t),new ec(i.buffer,i.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let i=this._buffers[0],r=n.length-t;t>=i.length?n.set(this._buffers.shift(),r):(n.set(new Uint8Array(i.buffer,i.byteOffset,t),r),this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t)),t-=i.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case Zn:this.getInfo(t);break;case Sx:this.getPayloadLength16(t);break;case wx:this.getPayloadLength64(t);break;case kx:this.getMask();break;case Th:this.getData(t);break;case Ch:case tc:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(r);return}let i=(n[0]&64)===64;if(i&&!this._extensions[_x.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(r);return}if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(r);return}this._payloadLength===126?this._state=Sx:this._payloadLength===127?this._state=wx:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),i=n.readUInt32BE(0);if(i>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(r);return}this._payloadLength=i*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=kx:this._state=Th}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Th}getData(t){let n=bx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&oL(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=Ch,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[_x.extensionName].decompress(t,this._fin,(r,o)=>{if(r)return n(r);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(a);return}this._fragments.push(o)}this.dataMessage(n),this._state===Zn&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=Zn;return}let n=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=xh(i,n):this._binaryType==="arraybuffer"?r=iL(xh(i,n)):this._binaryType==="blob"?r=new Blob(i):r=i,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!0),this._state=Zn,this.startLoop(t)}))}else{let r=xh(i,n);if(!this._skipUTF8Validation&&!vx(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===Ch||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!1),this._state=Zn,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,bx),this.end();else{let i=t.readUInt16BE(0);if(!aL(i)){let o=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let r=new ec(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!vx(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",i,r),this.end()}this._state=Zn;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn,this.startLoop(n)}))}createError(t,n,i,r,o){this._loop=!1,this._errored=!0;let a=new t(i?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[nL]=r,a}};xx.exports=Ah});var Oh=tt((Ice,Ax)=>{"use strict";var{Duplex:Pce}=He("stream"),{randomFillSync:sL}=He("crypto"),Tx=ed(),{EMPTY_BUFFER:dL,kWebSocket:lL,NOOP:uL}=ai(),{isBlob:_a,isValidStatusCode:cL}=ya(),{mask:Cx,toBuffer:co}=Ys(),Qn=Symbol("kByteLength"),fL=Buffer.alloc(4),nc=8*1024,fo,ba=nc,yr=0,pL=1,mL=2,Ph=class e{constructor(t,n,i){this._extensions=n||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=yr,this.onerror=uL,this[lL]=void 0}static frame(t,n){let i,r=!1,o=2,a=!1;n.mask&&(i=n.maskBuffer||fL,n.generateMask?n.generateMask(i):(ba===nc&&(fo===void 0&&(fo=Buffer.alloc(nc)),sL(fo,0,nc),ba=0),i[0]=fo[ba++],i[1]=fo[ba++],i[2]=fo[ba++],i[3]=fo[ba++]),a=(i[0]|i[1]|i[2]|i[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[Qn]!==void 0?s=n[Qn]:(t=Buffer.from(t),s=t.length):(s=t.length,r=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(r?s+o:o);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(s,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),n.mask?(l[1]|=128,l[o-4]=i[0],l[o-3]=i[1],l[o-2]=i[2],l[o-1]=i[3],a?[l,t]:r?(Cx(t,i,l,o,s),[l]):(Cx(t,i,t,0,s),[l,t])):[l,t]}close(t,n,i,r){let o;if(t===void 0)o=dL;else{if(typeof t!="number"||!cL(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let s=Buffer.byteLength(n);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(t,0),typeof n=="string"?o.write(n,2):o.set(n,2)}}let a={[Qn]:o.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==yr?this.enqueue([this.dispatch,o,!1,a,r]):this.sendFrame(e.frame(o,a),r)}ping(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}pong(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}send(t,n,i){let r=this._extensions[Tx.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):_a(t)?(s=t.size,d=!1):(t=co(t),s=t.length,d=co.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=r._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[Qn]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,this._compress,l,i]):this.getBlobData(t,this._compress,l,i):this._state!==yr?this.enqueue([this.dispatch,t,this._compress,l,i]):this.dispatch(t,this._compress,l,i)}getBlobData(t,n,i,r){this._bufferedBytes+=i[Qn],this._state=mL,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(Ih,this,s,r);return}this._bufferedBytes-=i[Qn];let a=co(o);n?this.dispatch(a,n,i,r):(this._state=yr,this.sendFrame(e.frame(a,i),r),this.dequeue())}).catch(o=>{process.nextTick(hL,this,o,r)})}dispatch(t,n,i,r){if(!n){this.sendFrame(e.frame(t,i),r);return}let o=this._extensions[Tx.extensionName];this._bufferedBytes+=i[Qn],this._state=pL,o.compress(t,i.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Ih(this,d,r);return}this._bufferedBytes-=i[Qn],this._state=yr,i.readOnly=!1,this.sendFrame(e.frame(s,i),r),this.dequeue()})}dequeue(){for(;this._state===yr&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][Qn],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][Qn],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};Ax.exports=Ph;function Ih(e,t,n){typeof n=="function"&&n(t);for(let i=0;i<e._queue.length;i++){let r=e._queue[i],o=r[r.length-1];typeof o=="function"&&o(t)}}function hL(e,t,n){Ih(e,t,n),e.onerror(t)}});var qx=tt((Oce,jx)=>{"use strict";var{kForOnEventAttribute:td,kListener:Rh}=ai(),Ex=Symbol("kCode"),Px=Symbol("kData"),Ix=Symbol("kError"),Ox=Symbol("kMessage"),Rx=Symbol("kReason"),va=Symbol("kTarget"),$x=Symbol("kType"),Mx=Symbol("kWasClean"),di=class{constructor(t){this[va]=null,this[$x]=t}get target(){return this[va]}get type(){return this[$x]}};Object.defineProperty(di.prototype,"target",{enumerable:!0});Object.defineProperty(di.prototype,"type",{enumerable:!0});var po=class extends di{constructor(t,n={}){super(t),this[Ex]=n.code===void 0?0:n.code,this[Rx]=n.reason===void 0?"":n.reason,this[Mx]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[Ex]}get reason(){return this[Rx]}get wasClean(){return this[Mx]}};Object.defineProperty(po.prototype,"code",{enumerable:!0});Object.defineProperty(po.prototype,"reason",{enumerable:!0});Object.defineProperty(po.prototype,"wasClean",{enumerable:!0});var Sa=class extends di{constructor(t,n={}){super(t),this[Ix]=n.error===void 0?null:n.error,this[Ox]=n.message===void 0?"":n.message}get error(){return this[Ix]}get message(){return this[Ox]}};Object.defineProperty(Sa.prototype,"error",{enumerable:!0});Object.defineProperty(Sa.prototype,"message",{enumerable:!0});var nd=class extends di{constructor(t,n={}){super(t),this[Px]=n.data===void 0?null:n.data}get data(){return this[Px]}};Object.defineProperty(nd.prototype,"data",{enumerable:!0});var gL={addEventListener(e,t,n={}){for(let r of this.listeners(e))if(!n[td]&&r[Rh]===t&&!r[td])return;let i;if(e==="message")i=function(o,a){let s=new nd("message",{data:a?o:o.toString()});s[va]=this,rc(t,this,s)};else if(e==="close")i=function(o,a){let s=new po("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[va]=this,rc(t,this,s)};else if(e==="error")i=function(o){let a=new Sa("error",{error:o,message:o.message});a[va]=this,rc(t,this,a)};else if(e==="open")i=function(){let o=new di("open");o[va]=this,rc(t,this,o)};else return;i[td]=!!n[td],i[Rh]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[Rh]===t&&!n[td]){this.removeListener(e,n);break}}};jx.exports={CloseEvent:po,ErrorEvent:Sa,Event:di,EventTarget:gL,MessageEvent:nd};function rc(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var $h=tt((Rce,Nx)=>{"use strict";var{tokenChars:rd}=ya();function Ur(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function yL(e){let t=Object.create(null),n=Object.create(null),i=!1,r=!1,o=!1,a,s,d=-1,l=-1,u=-1,c=0;for(;c<e.length;c++)if(l=e.charCodeAt(c),a===void 0)if(u===-1&&rd[l]===1)d===-1&&(d=c);else if(c!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);l===44?(Ur(t,f,n),n=Object.create(null)):a=f,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&rd[l]===1)d===-1&&(d=c);else if(l===32||l===9)u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c),Ur(n,e.slice(d,u),!0),l===44&&(Ur(t,a,n),n=Object.create(null),a=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)s=e.slice(d,c),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(r){if(rd[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:i||(i=!0),r=!1}else if(o)if(rd[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===34&&e.charCodeAt(c-1)===61)o=!0;else if(u===-1&&rd[l]===1)d===-1&&(d=c);else if(d!==-1&&(l===32||l===9))u===-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);i&&(f=f.replace(/\\/g,""),i=!1),Ur(n,s,f),l===44&&(Ur(t,a,n),n=Object.create(null),a=void 0),s=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(d===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=c);let p=e.slice(d,u);return a===void 0?Ur(t,p,n):(s===void 0?Ur(n,p,!0):i?Ur(n,s,p.replace(/\\/g,"")):Ur(n,s,p),Ur(t,a,n)),t}function _L(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(i=>[t].concat(Object.keys(i).map(r=>{let o=i[r];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?r:`${r}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Nx.exports={format:_L,parse:yL}});var sc=tt((jce,Vx)=>{"use strict";var bL=He("events"),vL=He("https"),SL=He("http"),Lx=He("net"),wL=He("tls"),{randomBytes:kL,createHash:xL}=He("crypto"),{Duplex:$ce,Readable:Mce}=He("stream"),{URL:Mh}=He("url"),Pi=ed(),TL=Eh(),CL=Oh(),{isBlob:AL}=ya(),{BINARY_TYPES:Fx,EMPTY_BUFFER:ic,GUID:EL,kForOnEventAttribute:jh,kListener:PL,kStatusCode:IL,kWebSocket:Wt,NOOP:Ux}=ai(),{EventTarget:{addEventListener:OL,removeEventListener:RL}}=qx(),{format:$L,parse:ML}=$h(),{toBuffer:jL}=Ys(),qL=30*1e3,Gx=Symbol("kAborted"),qh=[8,13],li=["CONNECTING","OPEN","CLOSING","CLOSED"],NL=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pt=class e extends bL{constructor(t,n,i){super(),this._binaryType=Fx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ic,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(i=n,n=[]):n=[n]),zx(this,t,n,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){Fx.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}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(t,n,i){let r=new TL({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),o=new CL(t,this._extensions,i.generateMask);this._receiver=r,this._sender=o,this._socket=t,r[Wt]=this,o[Wt]=this,t[Wt]=this,r.on("conclude",LL),r.on("drain",UL),r.on("error",GL),r.on("message",zL),r.on("ping",JL),r.on("pong",KL),o.onerror=BL,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",Bx),t.on("data",ac),t.on("end",Wx),t.on("error",Hx),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Pi.extensionName]&&this._extensions[Pi.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Kx(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Nh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||ic,n,i)}pong(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Nh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||ic,n,i)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(i=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Nh(this,t,i);return}let r={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[Pi.extensionName]||(r.compress=!1),this._sender.send(t||ic,r,i)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(pt,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt.prototype,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt.prototype,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt.prototype,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});Object.defineProperty(pt.prototype,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(pt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(pt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[jh])return t[PL];return null},set(t){for(let n of this.listeners(e))if(n[jh]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[jh]:!0})}})});pt.prototype.addEventListener=OL;pt.prototype.removeEventListener=RL;Vx.exports=pt;function zx(e,t,n,i){let r={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:qh[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,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=r.autoPong,!qh.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${qh.join(", ")})`);let o;if(t instanceof Mh)o=t;else try{o=new Mh(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",d;if(o.protocol!=="ws:"&&!a&&!s?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?d="The URL's pathname is empty":o.hash&&(d="The URL contains a fragment identifier"),d){let g=new SyntaxError(d);if(e._redirects===0)throw g;oc(e,g);return}let l=a?443:80,u=kL(16).toString("base64"),c=a?vL.request:SL.request,p=new Set,f;if(r.createConnection=r.createConnection||(a?DL:FL),r.defaultPort=r.defaultPort||l,r.port=o.port||l,r.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},r.path=o.pathname+o.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(f=new Pi(r.perMessageDeflate!==!0?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=$L({[Pi.extensionName]:f.offer()})),n.length){for(let g of n){if(typeof g!="string"||!NL.test(g)||p.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(g)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(o.username||o.password)&&(r.auth=`${o.username}:${o.password}`),s){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let h;if(r.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?r.socketPath:o.host;let g=i&&i.headers;if(i={...i,headers:{}},g)for(let[_,y]of Object.entries(g))i.headers[_.toLowerCase()]=y}else if(e.listenerCount("redirect")===0){let g=s?e._originalIpc?r.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!g||e._originalSecure&&!a)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),h=e._req=c(r),e._redirects&&e.emit("redirect",e.url,h)}else h=e._req=c(r);r.timeout&&h.on("timeout",()=>{qn(e,h,"Opening handshake has timed out")}),h.on("error",g=>{h===null||h[Gx]||(h=e._req=null,oc(e,g))}),h.on("response",g=>{let _=g.headers.location,y=g.statusCode;if(_&&r.followRedirects&&y>=300&&y<400){if(++e._redirects>r.maxRedirects){qn(e,h,"Maximum redirects exceeded");return}h.abort();let b;try{b=new Mh(_,t)}catch{let w=new SyntaxError(`Invalid URL: ${_}`);oc(e,w);return}zx(e,b,n,i)}else e.emit("unexpected-response",h,g)||qn(e,h,`Unexpected server response: ${g.statusCode}`)}),h.on("upgrade",(g,_,y)=>{if(e.emit("upgrade",g),e.readyState!==pt.CONNECTING)return;h=e._req=null;let b=g.headers.upgrade;if(b===void 0||b.toLowerCase()!=="websocket"){qn(e,_,"Invalid Upgrade header");return}let v=xL("sha1").update(u+EL).digest("base64");if(g.headers["sec-websocket-accept"]!==v){qn(e,_,"Invalid Sec-WebSocket-Accept header");return}let w=g.headers["sec-websocket-protocol"],A;if(w!==void 0?p.size?p.has(w)||(A="Server sent an invalid subprotocol"):A="Server sent a subprotocol but none was requested":p.size&&(A="Server sent no subprotocol"),A){qn(e,_,A);return}w&&(e._protocol=w);let C=g.headers["sec-websocket-extensions"];if(C!==void 0){if(!f){qn(e,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let S;try{S=ML(C)}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(S);if(k.length!==1||k[0]!==Pi.extensionName){qn(e,_,"Server indicated an extension that was not requested");return}try{f.accept(S[Pi.extensionName])}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Pi.extensionName]=f}e.setSocket(_,y,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(h,e):h.end()}function oc(e,t){e._readyState=pt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function FL(e){return e.path=e.socketPath,Lx.connect(e)}function DL(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Lx.isIP(e.host)?"":e.host),wL.connect(e)}function qn(e,t,n){e._readyState=pt.CLOSING;let i=new Error(n);Error.captureStackTrace(i,qn),t.setHeader?(t[Gx]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(oc,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Nh(e,t,n){if(t){let i=AL(t)?t.size:jL(t).length;e._socket?e._sender._bufferedBytes+=i:e._bufferedAmount+=i}if(n){let i=new Error(`WebSocket is not open: readyState ${e.readyState} (${li[e.readyState]})`);process.nextTick(n,i)}}function LL(e,t){let n=this[Wt];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[Wt]!==void 0&&(n._socket.removeListener("data",ac),process.nextTick(Jx,n._socket),e===1005?n.close():n.close(e,t))}function UL(){let e=this[Wt];e.isPaused||e._socket.resume()}function GL(e){let t=this[Wt];t._socket[Wt]!==void 0&&(t._socket.removeListener("data",ac),process.nextTick(Jx,t._socket),t.close(e[IL])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function Dx(){this[Wt].emitClose()}function zL(e,t){this[Wt].emit("message",e,t)}function JL(e){let t=this[Wt];t._autoPong&&t.pong(e,!this._isServer,Ux),t.emit("ping",e)}function KL(e){this[Wt].emit("pong",e)}function Jx(e){e.resume()}function BL(e){let t=this[Wt];t.readyState!==pt.CLOSED&&(t.readyState===pt.OPEN&&(t._readyState=pt.CLOSING,Kx(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function Kx(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),qL)}function Bx(){let e=this[Wt];this.removeListener("close",Bx),this.removeListener("data",ac),this.removeListener("end",Wx),e._readyState=pt.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[Wt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Dx),e._receiver.on("finish",Dx))}function ac(e){this[Wt]._receiver.write(e)||this.pause()}function Wx(){let e=this[Wt];e._readyState=pt.CLOSING,e._receiver.end(),this.end()}function Hx(){let e=this[Wt];this.removeListener("error",Hx),this.on("error",Ux),e&&(e._readyState=pt.CLOSING,this.destroy())}});var Xx=tt((Nce,Yx)=>{"use strict";var qce=sc(),{Duplex:WL}=He("stream");function Zx(e){e.emit("close")}function HL(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Qx(e){this.removeListener("error",Qx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function VL(e,t){let n=!0,i=new WL({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&i._readableState.objectMode?o.toString():o;i.push(s)||e.pause()}),e.once("error",function(o){i.destroyed||(n=!1,i.destroy(o))}),e.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(r,o){if(e.readyState===e.CLOSED){o(r),process.nextTick(Zx,i);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(r),process.nextTick(Zx,i)}),n&&e.terminate()},i._final=function(r){if(e.readyState===e.CONNECTING){e.once("open",function(){i._final(r)});return}e._socket!==null&&(e._socket._writableState.finished?(r(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",function(){r()}),e.close()))},i._read=function(){e.isPaused&&e.resume()},i._write=function(r,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){i._write(r,o,a)});return}e.send(r,a)},i.on("end",HL),i.on("error",Qx),i}Yx.exports=VL});var t0=tt((Fce,e0)=>{"use strict";var{tokenChars:ZL}=ya();function QL(e){let t=new Set,n=-1,i=-1,r=0;for(r;r<e.length;r++){let a=e.charCodeAt(r);if(i===-1&&ZL[a]===1)n===-1&&(n=r);else if(r!==0&&(a===32||a===9))i===-1&&n!==-1&&(i=r);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${r}`);i===-1&&(i=r);let s=e.slice(n,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=i=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(n===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,r);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}e0.exports={parse:QL}});var d0=tt((Lce,s0)=>{"use strict";var YL=He("events"),dc=He("http"),{Duplex:Dce}=He("stream"),{createHash:XL}=He("crypto"),n0=$h(),mo=ed(),eU=t0(),tU=sc(),{GUID:nU,kWebSocket:rU}=ai(),iU=/^[+/0-9A-Za-z]{22}==$/,r0=0,i0=1,a0=2,Fh=class extends YL{constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:tU,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=dc.createServer((i,r)=>{let o=dc.STATUS_CODES[426];r.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),r.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=oU(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,o,a)=>{this.handleUpgrade(r,o,a,i)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=r0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===a0){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(id,this);return}if(t&&this.once("close",t),this._state!==i0)if(this._state=i0,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(id,this):process.nextTick(id,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{id(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,i,r){n.on("error",o0);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){ho(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){ho(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!iU.test(o)){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){od(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=eU.parse(d)}catch{ho(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&u!==void 0){let p=new mo(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=n0.parse(u);f[mo.extensionName]&&(p.accept(f[mo.extensionName]),c[mo.extensionName]=p)}catch{ho(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:t.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(f,h,g,_)=>{if(!f)return od(n,h||401,g,_);this.completeUpgrade(c,o,l,t,n,i,r)});return}if(!this.options.verifyClient(p))return od(n,401)}this.completeUpgrade(c,o,l,t,n,i,r)}completeUpgrade(t,n,i,r,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[rU])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>r0)return od(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${XL("sha1").update(n+nU).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(i.size){let c=this.options.handleProtocols?this.options.handleProtocols(i,r):i.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[mo.extensionName]){let c=t[mo.extensionName].params,p=n0.format({[mo.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,r),o.write(l.concat(`\r
4
+ GFS4: `),console.error(e)});wt[Yt]||(uk=global[Yt]||[],fk(wt,uk),wt.close=(function(e){function t(n,i){return e.call(wt,n,function(r){r||ck(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(t,Nu,{value:e}),t})(wt.close),wt.closeSync=(function(e){function t(n){e.apply(wt,arguments),ck()}return Object.defineProperty(t,Nu,{value:e}),t})(wt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ao(wt[Yt]),He("assert").equal(wt[Yt].length,0)}));var uk;global[Yt]||fk(global,wt[Yt]);rh.exports=th(fD(wt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!wt.__patched&&(rh.exports=th(wt),wt.__patched=!0);function th(e){uD(e),e.gracefulify=th,e.createReadStream=A,e.createWriteStream=C;var t=e.readFile;e.readFile=n;function n(T,E,P){return typeof E=="function"&&(P=E,E=null),R(T,E,P);function R(O,M,J,Z){return t(O,M,function(z){z&&(z.code==="EMFILE"||z.code==="ENFILE")?sa([R,[O,M,J],z,Z||Date.now(),Date.now()]):typeof J=="function"&&J.apply(this,arguments)})}}var i=e.writeFile;e.writeFile=r;function r(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return i(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return o(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(T,E,P,R){return typeof P=="function"&&(R=P,P=0),O(T,E,P,R);function O(M,J,Z,z,X){return s(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(T,E,P){typeof E=="function"&&(P=E,E=null);var R=u.test(process.version)?function(J,Z,z,X){return l(J,O(J,Z,z,X))}:function(J,Z,z,X){return l(J,Z,O(J,Z,z,X))};return R(T,E,P);function O(M,J,Z,z){return function(X,ee){X&&(X.code==="EMFILE"||X.code==="ENFILE")?sa([R,[M,J,Z],X,z||Date.now(),Date.now()]):(ee&&ee.sort&&ee.sort(),typeof Z=="function"&&Z.call(this,X,ee))}}}if(process.version.substr(0,4)==="v0.8"){var p=cD(e);y=p.ReadStream,v=p.WriteStream}var f=e.ReadStream;f&&(y.prototype=Object.create(f.prototype),y.prototype.open=b);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(T){y=T},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(T){v=T},enumerable:!0,configurable:!0});var g=y;Object.defineProperty(e,"FileReadStream",{get:function(){return g},set:function(T){g=T},enumerable:!0,configurable:!0});var _=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(T){_=T},enumerable:!0,configurable:!0});function y(T,E){return this instanceof y?(f.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function b(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.autoClose&&T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P),T.read())})}function v(T,E){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function w(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P))})}function A(T,E){return new e.ReadStream(T,E)}function C(T,E){return new e.WriteStream(T,E)}var S=e.open;e.open=k;function k(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return S(M,J,Z,function(ee,B){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}return e}function sa(e){ao("ENQUEUE",e[0].name,e[1]),wt[Yt].push(e),nh()}var qu;function ck(){for(var e=Date.now(),t=0;t<wt[Yt].length;++t)wt[Yt][t].length>2&&(wt[Yt][t][3]=e,wt[Yt][t][4]=e);nh()}function nh(){if(clearTimeout(qu),qu=void 0,wt[Yt].length!==0){var e=wt[Yt].shift(),t=e[0],n=e[1],i=e[2],r=e[3],o=e[4];if(r===void 0)ao("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-r>=6e4){ao("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,i)}else{var s=Date.now()-o,d=Math.max(o-r,1),l=Math.min(d*1.2,100);s>=l?(ao("RETRY",t.name,n),t.apply(null,n.concat([r]))):wt[Yt].push(e)}qu===void 0&&(qu=setTimeout(nh,0))}}});var mk=tt((Yue,pk)=>{function Vn(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}pk.exports=Vn;Vn.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Vn.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Vn.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var i=this,r=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},n);return this._options.unref&&r.unref(),!0};Vn.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Vn.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Vn.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Vn.prototype.start=Vn.prototype.try;Vn.prototype.errors=function(){return this._errors};Vn.prototype.attempts=function(){return this._attempts};Vn.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,i=0;i<this._errors.length;i++){var r=this._errors[i],o=r.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=r,n=a)}return t}});var hk=tt(so=>{var mD=mk();so.operation=function(e){var t=so.timeouts(e);return new mD(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};so.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],r=0;r<t.retries;r++)i.push(this.createTimeout(r,t));return e&&e.forever&&!i.length&&i.push(this.createTimeout(r,t)),i.sort(function(o,a){return o-a}),i};so.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return i=Math.min(i,t.maxTimeout),i};so.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var i in e)typeof e[i]=="function"&&n.push(i)}for(var r=0;r<n.length;r++){var o=n[r],a=e[o];e[o]=function(d){var l=so.operation(t),u=Array.prototype.slice.call(arguments,1),c=u.pop();u.push(function(p){l.retry(p)||(p&&(arguments[0]=l.mainError()),c.apply(this,arguments))}),l.attempt(function(){d.apply(e,u)})}.bind(e,a),e[o].options=t}}});var yk=tt((ece,gk)=>{gk.exports=hk()});var _k=tt((tce,Fu)=>{Fu.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Fu.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Fu.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var kk=tt((nce,ua)=>{var ft=global.process,lo=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};lo(ft)?(bk=He("assert"),da=_k(),vk=/^win/i.test(ft.platform),Zs=He("events"),typeof Zs!="function"&&(Zs=Zs.EventEmitter),ft.__signal_exit_emitter__?zt=ft.__signal_exit_emitter__:(zt=ft.__signal_exit_emitter__=new Zs,zt.count=0,zt.emitted={}),zt.infinite||(zt.setMaxListeners(1/0),zt.infinite=!0),ua.exports=function(e,t){if(!lo(global.process))return function(){};bk.equal(typeof e,"function","a callback must be provided for exit handler"),la===!1&&oh();var n="exit";t&&t.alwaysLast&&(n="afterexit");var i=function(){zt.removeListener(n,e),zt.listeners("exit").length===0&&zt.listeners("afterexit").length===0&&Du()};return zt.on(n,e),i},Du=function(){!la||!lo(global.process)||(la=!1,da.forEach(function(t){try{ft.removeListener(t,Lu[t])}catch{}}),ft.emit=Uu,ft.reallyExit=ah,zt.count-=1)},ua.exports.unload=Du,uo=function(t,n,i){zt.emitted[t]||(zt.emitted[t]=!0,zt.emit(t,n,i))},Lu={},da.forEach(function(e){Lu[e]=function(){if(lo(global.process)){var n=ft.listeners(e);n.length===zt.count&&(Du(),uo("exit",null,e),uo("afterexit",null,e),vk&&e==="SIGHUP"&&(e="SIGINT"),ft.kill(ft.pid,e))}}}),ua.exports.signals=function(){return da},la=!1,oh=function(){la||!lo(global.process)||(la=!0,zt.count+=1,da=da.filter(function(t){try{return ft.on(t,Lu[t]),!0}catch{return!1}}),ft.emit=wk,ft.reallyExit=Sk)},ua.exports.load=oh,ah=ft.reallyExit,Sk=function(t){lo(global.process)&&(ft.exitCode=t||0,uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),ah.call(ft,ft.exitCode))},Uu=ft.emit,wk=function(t,n){if(t==="exit"&&lo(global.process)){n!==void 0&&(ft.exitCode=n);var i=Uu.apply(this,arguments);return uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),i}else return Uu.apply(this,arguments)}):ua.exports=function(){return function(){}};var bk,da,vk,Zs,zt,Du,uo,Lu,la,oh,ah,Sk,Uu,wk});var Ek=tt((rce,Qs)=>{"use strict";var hD=He("path"),lh=ih(),gD=yk(),yD=kk(),oi={};function ca(e,t){return t.lockfilePath||`${e}.lock`}function uh(e,t,n){if(!t.realpath)return n(null,hD.resolve(e));t.fs.realpath(e,n)}function sh(e,t,n){t.fs.mkdir(ca(e,t),i=>{if(!i)return n();if(i.code!=="EEXIST")return n(i);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(ca(e,t),(r,o)=>{if(r)return r.code==="ENOENT"?sh(e,{...t,stale:0},n):n(r);if(!Tk(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));Ck(e,t,a=>{if(a)return n(a);sh(e,{...t,stale:0},n)})})})}function Tk(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Ck(e,t,n){t.fs.rmdir(ca(e,t),i=>{if(i&&i.code!=="ENOENT")return n(i);n()})}function dh(e,t){let n=oi[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let i=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(ca(e,t),i,i,r=>{if(!n.released){if(n.lastUpdate<=Date.now()-t.stale&&n.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(n.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return xk(e,n,o)}if(r)return r.code==="ENOENT"?xk(e,n,Object.assign(r,{code:"ECOMPROMISED"})):(n.updateError=r,n.updateDelay=1e3,dh(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,dh(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function xk(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),oi[e]===t&&delete oi[e],t.options.onCompromised(n)}function _D(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:lh,onCompromised:i=>{throw i},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),uh(e,t,(i,r)=>{if(i)return n(i);let o=gD.operation(t.retries);o.attempt(()=>{sh(r,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=oi[r]={options:t,lastUpdate:Date.now()};dh(r,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Ak(r,{...t,realpath:!1},d)})})})})}function Ak(e,t,n){t={fs:lh,realpath:!0,...t},uh(e,t,(i,r)=>{if(i)return n(i);let o=oi[r];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete oi[r],Ck(r,t,n)})}function bD(e,t,n){t={stale:1e4,realpath:!0,fs:lh,...t},t.stale=Math.max(t.stale||0,2e3),uh(e,t,(i,r)=>{if(i)return n(i);t.fs.stat(ca(r,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!Tk(a,t)))})}function vD(){return oi}yD(()=>{for(let e in oi){let t=oi[e].options;try{t.fs.rmdirSync(ca(e,t))}catch{}}});Qs.exports.lock=_D;Qs.exports.unlock=Ak;Qs.exports.check=bD;Qs.exports.getLocks=vD});var Ik=tt((ice,Pk)=>{"use strict";var SD=ih();function wD(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(i=>{n[i]=(...r)=>{let o=r.pop(),a;try{a=e[`${i}Sync`](...r)}catch(s){return o(s)}o(null,a)}}),n}function kD(e){return(...t)=>new Promise((n,i)=>{t.push((r,o)=>{r?i(r):n(o)}),e(...t)})}function xD(e){return(...t)=>{let n,i;if(t.push((r,o)=>{n=r,i=o}),e(...t),n)throw n;return i}}function TD(e){if(e={...e},e.fs=wD(e.fs||SD),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Pk.exports={toPromise:kD,toSync:xD,toSyncOptions:TD}});var Rk=tt((oce,Ai)=>{"use strict";var fa=Ek(),{toPromise:Gu,toSync:zu,toSyncOptions:ch}=Ik();async function Ok(e,t){let n=await Gu(fa.lock)(e,t);return Gu(n)}function CD(e,t){let n=zu(fa.lock)(e,ch(t));return zu(n)}function AD(e,t){return Gu(fa.unlock)(e,t)}function ED(e,t){return zu(fa.unlock)(e,ch(t))}function PD(e,t){return Gu(fa.check)(e,t)}function ID(e,t){return zu(fa.check)(e,ch(t))}Ai.exports=Ok;Ai.exports.lock=Ok;Ai.exports.unlock=AD;Ai.exports.lockSync=CD;Ai.exports.unlockSync=ED;Ai.exports.check=PD;Ai.exports.checkSync=ID});var $k=q(()=>{});var Mk=q(()=>{});var Ju=q(()=>{});var Jt=q(()=>{$k();Mk();Ju()});function $D(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function Kt(e){return $D(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function mh(e){let t=ph[e];if(t!==void 0){let n=t+1|0;return ph[e]=n,e+("/"+n)}return ph[e]=1,e}var ph,en=q(()=>{ph={}});import*as Nk from"node:child_process";function pa(e){let t=ri(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=Ve(t);return{code:Iu(n.code),message:Ke(Dr(n),"unknown error")}}function Fk(e,t,n,i){try{return{TAG:"Ok",_0:Nk.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:i})}}catch(r){let o=Kt(r);return{TAG:"Error",_0:pa(o)}}}var MD,Bt=q(()=>{ii();Me();$u();MD=oa(Rk(),1);Jt();nt();en()});function Lk(e){let t=Fk(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=Dk.exec(t._0);if(n!=null)return mn(n.slice(1)[0],i=>i)}function Uk(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}var Dk,Gk=q(()=>{Et();Bt();Me();Jt();Dk=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function qD(e,t){let n=Uk(e,t);switch(n.TAG){case"Match":return{TAG:"Ok",_0:n.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+n.pathVersion+" expected="+n.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+t}}}function zk(e,t){return qD(Lk(e),t)}var Jk=q(()=>{Me();Gk()});var Kk,hh=q(()=>{Jk();Kk=zk});var Wk,Bk=q(()=>{Wk={name:"@linzumi/cli",version:"1.0.272",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts"],scripts:{"test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts test/llmProxySessionCredential.test.ts test/runnerBridge.test.ts test/threadCodexWorkerIpc.test.ts -t '(?:^| )(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup|does not install an old mint after its credential is (replaced|stopped)|worker agent capability requires an exact true ready flag|starts an explicitly server-keyed OpenAI agent worker without local OpenAI credentials|applies the accepted OpenAI follow-up model on an existing worker|refuses explicit OpenAI worker creation with (passthrough|missing-token|blank-origin) binding|refuses a private agent turn without an owned relay before Codex|explicitly capable worker receives a private request through ordinary IPC|old worker receives no private agent source descriptor)$'",build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","test:actual-commander-parity":"pnpm --dir ../linzumi-cli-rescript build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/ActualCommanderParityConformance.res.mjs","bump-version":"node scripts/bump-cli-version.mjs","codex:history-table":"node scripts/codex_history_table.mjs",test:"npm run test:startup && node --import tsx --test ../linzumi-cli-rescript/src/parity/McpToolCallBoundaryTest.res.mjs && rescript build ../../kandan/server_v2/web/replay_harness && vitest run --config vitest.config.mjs",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","record:agent-fixtures":"tsx scripts/record-agent-replay-fixtures.ts","normalize:agent-fixture":"tsx scripts/normalize-agent-replay-fixture.ts","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","replay:agent-fixture":"tsx scripts/replay-agent-fixture.ts","replay:agent-backend":"tsx scripts/replay-agent-backend.ts","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check","replay:agent-backend-browser":"tsx scripts/replay-agent-backend-browser.ts","promote:gstack-claude-smoke-fixture":"tsx scripts/promote-gstack-claude-smoke-fixture.ts","diagnose:claude-probe":"tsx scripts/diagnose-claude-probe.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.199","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.153.2",blessed:"^0.1.81","proper-lockfile":"3.2.0",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var gh,Wu=q(()=>{"use strict";Bk();gh=Wk.dependencies["@openai/codex"]});async function Hk(e,t,n){let i;try{e(),i=!0}catch{i=!1}let r;try{await t(),r=!0}catch{r=!1}return i&&r?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function Vk(e,t){let n=e.quotaWindow,i=e.credits;if(n===void 0&&i===void 0)return{status:"unavailable",reason:"empty_response"};let r=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:r[0],windowMinutes:r[1],resetsAtMs:r[2],capturedAtMs:t,credits:i}}}var Zk=q(()=>{});var Qk,Yk,Xk=q(()=>{Zk();Qk=Hk,Yk=Vk});function Be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yh(e){let t=[["threadId",e.threadId],["turnId",e.turnId],["itemId",e.itemId],["processId",e.processId],["requestId",e.requestId]].filter(n=>n[1]!==void 0);return Object.fromEntries(t)}var Pt=q(()=>{"use strict"});var Hu=q(()=>{"use strict";Pt()});function rx(e){let t=Lr(e.rateLimits)??Lr(e.rate_limits)??Lr(e.limits)??e,n=[t,...Object.values(t).flatMap(_=>{let y=Lr(_);return y===void 0?[]:[y]})],i=n.reduce((_,y)=>{let b=De(y.usedPercent)??De(y.used_percent);return b===void 0?_:_===void 0?b:Math.max(_,b)},void 0),o=n.some(_=>De(_.remaining)===0||De(_.remainingRequests)===0||De(_.remaining_requests)===0||De(_.remainingTokens)===0||De(_.remaining_tokens)===0||De(_.retryAfterSeconds)!==void 0||De(_.retry_after_seconds)!==void 0)?"rejected":i!==void 0&&i>=80?"allowed_warning":"allowed",a=Lr(t.primary),s=De(a?.usedPercent),d=De(a?.windowDurationMins),l=De(a?.resetsAt),u=Lr(t.credits),c=nx(u?.hasCredits),p=nx(u?.unlimited),f=u?.balance,h=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof f=="string"?f:null},g=s===void 0&&d===void 0&&l===void 0?void 0:{...s===void 0?{}:{usedPercent:s},...d===void 0?{}:{windowMinutes:d},...l===void 0?{}:{resetsAtMs:l*1e3}};return{summary:UD(e)??"seen (no details)",status:o,utilizationPercent:i,...g===void 0?{}:{quotaWindow:g},...h===void 0?{}:{credits:h}}}function UD(e){let t=Lr(e.rateLimits)??Lr(e.rate_limits)??Lr(e.limits)??e,n=ex(t,void 0),i=Object.entries(t).flatMap(([o,a])=>{let s=Lr(a);return s===void 0?[]:[ex(s,o)]}),r=[n,...i].filter(o=>o!==void 0);return r.length===0?void 0:r.join(" | ")}function ex(e,t){let n=gr(e.limitName)??gr(e.limit_name)??gr(e.name)??gr(e.type)??t,i=gr(e.planType)??gr(e.plan_type)??gr(e.plan),r=De(e.remaining)??De(e.remainingRequests)??De(e.remaining_requests)??De(e.remainingTokens)??De(e.remaining_tokens),o=De(e.limit)??De(e.requestLimit)??De(e.request_limit)??De(e.limitRequests)??De(e.limit_requests)??De(e.tokenLimit)??De(e.token_limit)??De(e.limitTokens)??De(e.limit_tokens),a=gr(e.resetAt)??gr(e.reset_at)??gr(e.resetsAt)??gr(e.resets_at)??tx(e.resetsAt)??tx(e.resets_at)??Vu(e.resetAfterSeconds)??Vu(e.reset_after_seconds)??Vu(e.retryAfterSeconds)??Vu(e.retry_after_seconds),s=De(e.usedPercent)??De(e.used_percent),d=De(e.windowDurationMins)??De(e.window_duration_mins),l=[n,i].filter(f=>f!==void 0).join(" "),u=l===""?void 0:l,p=[r===void 0?void 0:o===void 0?`${r} remaining`:`${r}/${o} remaining`,s===void 0?void 0:`${s}% used`,d===void 0?void 0:`${d}m window`,a===void 0?void 0:`reset ${a}`].filter(f=>f!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Vu(e){let t=De(e);return t===void 0?void 0:`${t}s`}function tx(e){let t=De(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function Lr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function gr(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function nx(e){return typeof e=="boolean"?e:void 0}function De(e){if(typeof e=="number"&&Number.isSafeInteger(e))return e;if(typeof e!="string")return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t.toString()===e.trim()?t:void 0}var ix=q(()=>{"use strict";Hu();Pt()});var ai=tt((kce,sx)=>{"use strict";var ox=["nodebuffer","arraybuffer","fragments"],ax=typeof Blob<"u";ax&&ox.push("blob");sx.exports={BINARY_TYPES:ox,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ax,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ys=tt((xce,Zu)=>{"use strict";var{EMPTY_BUFFER:GD}=ai(),_h=Buffer[Symbol.species];function zD(e,t){if(e.length===0)return GD;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),i=0;for(let r=0;r<e.length;r++){let o=e[r];n.set(o,i),i+=o.length}return i<t?new _h(n.buffer,n.byteOffset,i):n}function dx(e,t,n,i,r){for(let o=0;o<r;o++)n[i+o]=e[o]^t[o&3]}function lx(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function JD(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function bh(e){if(bh.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new _h(e):ArrayBuffer.isView(e)?t=new _h(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),bh.readOnly=!1),t}Zu.exports={concat:zD,mask:dx,toArrayBuffer:JD,toBuffer:bh,unmask:lx};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=He("bufferutil");Zu.exports.mask=function(t,n,i,r,o){o<48?dx(t,n,i,r,o):e.mask(t,n,i,r,o)},Zu.exports.unmask=function(t,n){t.length<32?lx(t,n):e.unmask(t,n)}}catch{}});var fx=tt((Tce,cx)=>{"use strict";var ux=Symbol("kDone"),vh=Symbol("kRun"),Sh=class{constructor(t){this[ux]=()=>{this.pending--,this[vh]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[vh]()}[vh](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[ux])}}};cx.exports=Sh});var ed=tt((Cce,gx)=>{"use strict";var Xs=He("zlib"),px=Ys(),KD=fx(),{kStatusCode:mx}=ai(),BD=Buffer[Symbol.species],WD=Buffer.from([0,0,255,255]),Yu=Symbol("permessage-deflate"),si=Symbol("total-length"),ha=Symbol("callback"),Ei=Symbol("buffers"),ga=Symbol("error"),Qu,wh=class{constructor(t,n,i){if(this._maxPayload=i|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Qu){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Qu=new KD(r)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[ha];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,i=t.find(r=>!(n.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>r.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(i.server_no_context_takeover=!0),n.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(i.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?i.client_max_window_bits=n.clientMaxWindowBits:(i.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(i=>{let r=n[i];if(r.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(r=r[0],i==="client_max_window_bits"){if(r!==!0){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else if(i==="server_max_window_bits"){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else throw new Error(`Unknown parameter "${i}"`);n[i]=r})}),t}decompress(t,n,i){Qu.add(r=>{this._decompress(t,n,(o,a)=>{r(),i(o,a)})})}compress(t,n,i){Qu.add(r=>{this._compress(t,n,(o,a)=>{r(),i(o,a)})})}_decompress(t,n,i){let r=this._isServer?"client":"server";if(!this._inflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Xs.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=Xs.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Yu]=this,this._inflate[si]=0,this._inflate[Ei]=[],this._inflate.on("error",VD),this._inflate.on("data",hx)}this._inflate[ha]=i,this._inflate.write(t),n&&this._inflate.write(WD),this._inflate.flush(()=>{let o=this._inflate[ga];if(o){this._inflate.close(),this._inflate=null,i(o);return}let a=px.concat(this._inflate[Ei],this._inflate[si]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[si]=0,this._inflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,a)})}_compress(t,n,i){let r=this._isServer?"server":"client";if(!this._deflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Xs.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=Xs.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[si]=0,this._deflate[Ei]=[],this._deflate.on("data",HD)}this._deflate[ha]=i,this._deflate.write(t),this._deflate.flush(Xs.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=px.concat(this._deflate[Ei],this._deflate[si]);n&&(o=new BD(o.buffer,o.byteOffset,o.length-4)),this._deflate[ha]=null,this._deflate[si]=0,this._deflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,o)})}};gx.exports=wh;function HD(e){this[Ei].push(e),this[si]+=e.length}function hx(e){if(this[si]+=e.length,this[Yu]._maxPayload<1||this[si]<=this[Yu]._maxPayload){this[Ei].push(e);return}this[ga]=new RangeError("Max payload size exceeded"),this[ga].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ga][mx]=1009,this.removeListener("data",hx),this.reset()}function VD(e){if(this[Yu]._inflate=null,this[ga]){this[ha](this[ga]);return}e[mx]=1007,this[ha](e)}});var ya=tt((Ace,Xu)=>{"use strict";var{isUtf8:yx}=He("buffer"),{hasBlob:ZD}=ai(),QD=[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];function YD(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function kh(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function XD(e){return ZD&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Xu.exports={isBlob:XD,isValidStatusCode:YD,isValidUTF8:kh,tokenChars:QD};if(yx)Xu.exports.isValidUTF8=function(e){return e.length<24?kh(e):yx(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=He("utf-8-validate");Xu.exports.isValidUTF8=function(t){return t.length<32?kh(t):e(t)}}catch{}});var Eh=tt((Ece,xx)=>{"use strict";var{Writable:eL}=He("stream"),_x=ed(),{BINARY_TYPES:tL,EMPTY_BUFFER:bx,kStatusCode:nL,kWebSocket:rL}=ai(),{concat:xh,toArrayBuffer:iL,unmask:oL}=Ys(),{isValidStatusCode:aL,isValidUTF8:vx}=ya(),ec=Buffer[Symbol.species],Zn=0,Sx=1,wx=2,kx=3,Th=4,Ch=5,tc=6,Ah=class extends eL{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||tL[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[rL]=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=Zn}_write(t,n,i){if(this._opcode===8&&this._state==Zn)return i();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(i)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t),new ec(i.buffer,i.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let i=this._buffers[0],r=n.length-t;t>=i.length?n.set(this._buffers.shift(),r):(n.set(new Uint8Array(i.buffer,i.byteOffset,t),r),this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t)),t-=i.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case Zn:this.getInfo(t);break;case Sx:this.getPayloadLength16(t);break;case wx:this.getPayloadLength64(t);break;case kx:this.getMask();break;case Th:this.getData(t);break;case Ch:case tc:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(r);return}let i=(n[0]&64)===64;if(i&&!this._extensions[_x.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(r);return}if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(r);return}this._payloadLength===126?this._state=Sx:this._payloadLength===127?this._state=wx:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),i=n.readUInt32BE(0);if(i>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(r);return}this._payloadLength=i*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=kx:this._state=Th}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Th}getData(t){let n=bx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&oL(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=Ch,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[_x.extensionName].decompress(t,this._fin,(r,o)=>{if(r)return n(r);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(a);return}this._fragments.push(o)}this.dataMessage(n),this._state===Zn&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=Zn;return}let n=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=xh(i,n):this._binaryType==="arraybuffer"?r=iL(xh(i,n)):this._binaryType==="blob"?r=new Blob(i):r=i,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!0),this._state=Zn,this.startLoop(t)}))}else{let r=xh(i,n);if(!this._skipUTF8Validation&&!vx(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===Ch||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!1),this._state=Zn,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,bx),this.end();else{let i=t.readUInt16BE(0);if(!aL(i)){let o=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let r=new ec(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!vx(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",i,r),this.end()}this._state=Zn;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn,this.startLoop(n)}))}createError(t,n,i,r,o){this._loop=!1,this._errored=!0;let a=new t(i?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[nL]=r,a}};xx.exports=Ah});var Oh=tt((Ice,Ax)=>{"use strict";var{Duplex:Pce}=He("stream"),{randomFillSync:sL}=He("crypto"),Tx=ed(),{EMPTY_BUFFER:dL,kWebSocket:lL,NOOP:uL}=ai(),{isBlob:_a,isValidStatusCode:cL}=ya(),{mask:Cx,toBuffer:co}=Ys(),Qn=Symbol("kByteLength"),fL=Buffer.alloc(4),nc=8*1024,fo,ba=nc,yr=0,pL=1,mL=2,Ph=class e{constructor(t,n,i){this._extensions=n||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=yr,this.onerror=uL,this[lL]=void 0}static frame(t,n){let i,r=!1,o=2,a=!1;n.mask&&(i=n.maskBuffer||fL,n.generateMask?n.generateMask(i):(ba===nc&&(fo===void 0&&(fo=Buffer.alloc(nc)),sL(fo,0,nc),ba=0),i[0]=fo[ba++],i[1]=fo[ba++],i[2]=fo[ba++],i[3]=fo[ba++]),a=(i[0]|i[1]|i[2]|i[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[Qn]!==void 0?s=n[Qn]:(t=Buffer.from(t),s=t.length):(s=t.length,r=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(r?s+o:o);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(s,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),n.mask?(l[1]|=128,l[o-4]=i[0],l[o-3]=i[1],l[o-2]=i[2],l[o-1]=i[3],a?[l,t]:r?(Cx(t,i,l,o,s),[l]):(Cx(t,i,t,0,s),[l,t])):[l,t]}close(t,n,i,r){let o;if(t===void 0)o=dL;else{if(typeof t!="number"||!cL(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let s=Buffer.byteLength(n);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(t,0),typeof n=="string"?o.write(n,2):o.set(n,2)}}let a={[Qn]:o.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==yr?this.enqueue([this.dispatch,o,!1,a,r]):this.sendFrame(e.frame(o,a),r)}ping(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}pong(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}send(t,n,i){let r=this._extensions[Tx.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):_a(t)?(s=t.size,d=!1):(t=co(t),s=t.length,d=co.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=r._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[Qn]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,this._compress,l,i]):this.getBlobData(t,this._compress,l,i):this._state!==yr?this.enqueue([this.dispatch,t,this._compress,l,i]):this.dispatch(t,this._compress,l,i)}getBlobData(t,n,i,r){this._bufferedBytes+=i[Qn],this._state=mL,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(Ih,this,s,r);return}this._bufferedBytes-=i[Qn];let a=co(o);n?this.dispatch(a,n,i,r):(this._state=yr,this.sendFrame(e.frame(a,i),r),this.dequeue())}).catch(o=>{process.nextTick(hL,this,o,r)})}dispatch(t,n,i,r){if(!n){this.sendFrame(e.frame(t,i),r);return}let o=this._extensions[Tx.extensionName];this._bufferedBytes+=i[Qn],this._state=pL,o.compress(t,i.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Ih(this,d,r);return}this._bufferedBytes-=i[Qn],this._state=yr,i.readOnly=!1,this.sendFrame(e.frame(s,i),r),this.dequeue()})}dequeue(){for(;this._state===yr&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][Qn],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][Qn],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};Ax.exports=Ph;function Ih(e,t,n){typeof n=="function"&&n(t);for(let i=0;i<e._queue.length;i++){let r=e._queue[i],o=r[r.length-1];typeof o=="function"&&o(t)}}function hL(e,t,n){Ih(e,t,n),e.onerror(t)}});var qx=tt((Oce,jx)=>{"use strict";var{kForOnEventAttribute:td,kListener:Rh}=ai(),Ex=Symbol("kCode"),Px=Symbol("kData"),Ix=Symbol("kError"),Ox=Symbol("kMessage"),Rx=Symbol("kReason"),va=Symbol("kTarget"),$x=Symbol("kType"),Mx=Symbol("kWasClean"),di=class{constructor(t){this[va]=null,this[$x]=t}get target(){return this[va]}get type(){return this[$x]}};Object.defineProperty(di.prototype,"target",{enumerable:!0});Object.defineProperty(di.prototype,"type",{enumerable:!0});var po=class extends di{constructor(t,n={}){super(t),this[Ex]=n.code===void 0?0:n.code,this[Rx]=n.reason===void 0?"":n.reason,this[Mx]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[Ex]}get reason(){return this[Rx]}get wasClean(){return this[Mx]}};Object.defineProperty(po.prototype,"code",{enumerable:!0});Object.defineProperty(po.prototype,"reason",{enumerable:!0});Object.defineProperty(po.prototype,"wasClean",{enumerable:!0});var Sa=class extends di{constructor(t,n={}){super(t),this[Ix]=n.error===void 0?null:n.error,this[Ox]=n.message===void 0?"":n.message}get error(){return this[Ix]}get message(){return this[Ox]}};Object.defineProperty(Sa.prototype,"error",{enumerable:!0});Object.defineProperty(Sa.prototype,"message",{enumerable:!0});var nd=class extends di{constructor(t,n={}){super(t),this[Px]=n.data===void 0?null:n.data}get data(){return this[Px]}};Object.defineProperty(nd.prototype,"data",{enumerable:!0});var gL={addEventListener(e,t,n={}){for(let r of this.listeners(e))if(!n[td]&&r[Rh]===t&&!r[td])return;let i;if(e==="message")i=function(o,a){let s=new nd("message",{data:a?o:o.toString()});s[va]=this,rc(t,this,s)};else if(e==="close")i=function(o,a){let s=new po("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[va]=this,rc(t,this,s)};else if(e==="error")i=function(o){let a=new Sa("error",{error:o,message:o.message});a[va]=this,rc(t,this,a)};else if(e==="open")i=function(){let o=new di("open");o[va]=this,rc(t,this,o)};else return;i[td]=!!n[td],i[Rh]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[Rh]===t&&!n[td]){this.removeListener(e,n);break}}};jx.exports={CloseEvent:po,ErrorEvent:Sa,Event:di,EventTarget:gL,MessageEvent:nd};function rc(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var $h=tt((Rce,Nx)=>{"use strict";var{tokenChars:rd}=ya();function Ur(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function yL(e){let t=Object.create(null),n=Object.create(null),i=!1,r=!1,o=!1,a,s,d=-1,l=-1,u=-1,c=0;for(;c<e.length;c++)if(l=e.charCodeAt(c),a===void 0)if(u===-1&&rd[l]===1)d===-1&&(d=c);else if(c!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);l===44?(Ur(t,f,n),n=Object.create(null)):a=f,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&rd[l]===1)d===-1&&(d=c);else if(l===32||l===9)u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c),Ur(n,e.slice(d,u),!0),l===44&&(Ur(t,a,n),n=Object.create(null),a=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)s=e.slice(d,c),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(r){if(rd[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:i||(i=!0),r=!1}else if(o)if(rd[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===34&&e.charCodeAt(c-1)===61)o=!0;else if(u===-1&&rd[l]===1)d===-1&&(d=c);else if(d!==-1&&(l===32||l===9))u===-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);i&&(f=f.replace(/\\/g,""),i=!1),Ur(n,s,f),l===44&&(Ur(t,a,n),n=Object.create(null),a=void 0),s=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(d===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=c);let p=e.slice(d,u);return a===void 0?Ur(t,p,n):(s===void 0?Ur(n,p,!0):i?Ur(n,s,p.replace(/\\/g,"")):Ur(n,s,p),Ur(t,a,n)),t}function _L(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(i=>[t].concat(Object.keys(i).map(r=>{let o=i[r];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?r:`${r}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Nx.exports={format:_L,parse:yL}});var sc=tt((jce,Vx)=>{"use strict";var bL=He("events"),vL=He("https"),SL=He("http"),Lx=He("net"),wL=He("tls"),{randomBytes:kL,createHash:xL}=He("crypto"),{Duplex:$ce,Readable:Mce}=He("stream"),{URL:Mh}=He("url"),Pi=ed(),TL=Eh(),CL=Oh(),{isBlob:AL}=ya(),{BINARY_TYPES:Fx,EMPTY_BUFFER:ic,GUID:EL,kForOnEventAttribute:jh,kListener:PL,kStatusCode:IL,kWebSocket:Wt,NOOP:Ux}=ai(),{EventTarget:{addEventListener:OL,removeEventListener:RL}}=qx(),{format:$L,parse:ML}=$h(),{toBuffer:jL}=Ys(),qL=30*1e3,Gx=Symbol("kAborted"),qh=[8,13],li=["CONNECTING","OPEN","CLOSING","CLOSED"],NL=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pt=class e extends bL{constructor(t,n,i){super(),this._binaryType=Fx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ic,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(i=n,n=[]):n=[n]),zx(this,t,n,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){Fx.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}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(t,n,i){let r=new TL({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),o=new CL(t,this._extensions,i.generateMask);this._receiver=r,this._sender=o,this._socket=t,r[Wt]=this,o[Wt]=this,t[Wt]=this,r.on("conclude",LL),r.on("drain",UL),r.on("error",GL),r.on("message",zL),r.on("ping",JL),r.on("pong",KL),o.onerror=BL,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",Bx),t.on("data",ac),t.on("end",Wx),t.on("error",Hx),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Pi.extensionName]&&this._extensions[Pi.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Kx(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Nh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||ic,n,i)}pong(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Nh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||ic,n,i)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(i=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Nh(this,t,i);return}let r={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[Pi.extensionName]||(r.compress=!1),this._sender.send(t||ic,r,i)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(pt,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt.prototype,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt.prototype,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt.prototype,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});Object.defineProperty(pt.prototype,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(pt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(pt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[jh])return t[PL];return null},set(t){for(let n of this.listeners(e))if(n[jh]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[jh]:!0})}})});pt.prototype.addEventListener=OL;pt.prototype.removeEventListener=RL;Vx.exports=pt;function zx(e,t,n,i){let r={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:qh[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,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=r.autoPong,!qh.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${qh.join(", ")})`);let o;if(t instanceof Mh)o=t;else try{o=new Mh(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",d;if(o.protocol!=="ws:"&&!a&&!s?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?d="The URL's pathname is empty":o.hash&&(d="The URL contains a fragment identifier"),d){let g=new SyntaxError(d);if(e._redirects===0)throw g;oc(e,g);return}let l=a?443:80,u=kL(16).toString("base64"),c=a?vL.request:SL.request,p=new Set,f;if(r.createConnection=r.createConnection||(a?DL:FL),r.defaultPort=r.defaultPort||l,r.port=o.port||l,r.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},r.path=o.pathname+o.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(f=new Pi(r.perMessageDeflate!==!0?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=$L({[Pi.extensionName]:f.offer()})),n.length){for(let g of n){if(typeof g!="string"||!NL.test(g)||p.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(g)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(o.username||o.password)&&(r.auth=`${o.username}:${o.password}`),s){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let h;if(r.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?r.socketPath:o.host;let g=i&&i.headers;if(i={...i,headers:{}},g)for(let[_,y]of Object.entries(g))i.headers[_.toLowerCase()]=y}else if(e.listenerCount("redirect")===0){let g=s?e._originalIpc?r.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!g||e._originalSecure&&!a)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),h=e._req=c(r),e._redirects&&e.emit("redirect",e.url,h)}else h=e._req=c(r);r.timeout&&h.on("timeout",()=>{qn(e,h,"Opening handshake has timed out")}),h.on("error",g=>{h===null||h[Gx]||(h=e._req=null,oc(e,g))}),h.on("response",g=>{let _=g.headers.location,y=g.statusCode;if(_&&r.followRedirects&&y>=300&&y<400){if(++e._redirects>r.maxRedirects){qn(e,h,"Maximum redirects exceeded");return}h.abort();let b;try{b=new Mh(_,t)}catch{let w=new SyntaxError(`Invalid URL: ${_}`);oc(e,w);return}zx(e,b,n,i)}else e.emit("unexpected-response",h,g)||qn(e,h,`Unexpected server response: ${g.statusCode}`)}),h.on("upgrade",(g,_,y)=>{if(e.emit("upgrade",g),e.readyState!==pt.CONNECTING)return;h=e._req=null;let b=g.headers.upgrade;if(b===void 0||b.toLowerCase()!=="websocket"){qn(e,_,"Invalid Upgrade header");return}let v=xL("sha1").update(u+EL).digest("base64");if(g.headers["sec-websocket-accept"]!==v){qn(e,_,"Invalid Sec-WebSocket-Accept header");return}let w=g.headers["sec-websocket-protocol"],A;if(w!==void 0?p.size?p.has(w)||(A="Server sent an invalid subprotocol"):A="Server sent a subprotocol but none was requested":p.size&&(A="Server sent no subprotocol"),A){qn(e,_,A);return}w&&(e._protocol=w);let C=g.headers["sec-websocket-extensions"];if(C!==void 0){if(!f){qn(e,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let S;try{S=ML(C)}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(S);if(k.length!==1||k[0]!==Pi.extensionName){qn(e,_,"Server indicated an extension that was not requested");return}try{f.accept(S[Pi.extensionName])}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Pi.extensionName]=f}e.setSocket(_,y,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(h,e):h.end()}function oc(e,t){e._readyState=pt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function FL(e){return e.path=e.socketPath,Lx.connect(e)}function DL(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Lx.isIP(e.host)?"":e.host),wL.connect(e)}function qn(e,t,n){e._readyState=pt.CLOSING;let i=new Error(n);Error.captureStackTrace(i,qn),t.setHeader?(t[Gx]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(oc,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Nh(e,t,n){if(t){let i=AL(t)?t.size:jL(t).length;e._socket?e._sender._bufferedBytes+=i:e._bufferedAmount+=i}if(n){let i=new Error(`WebSocket is not open: readyState ${e.readyState} (${li[e.readyState]})`);process.nextTick(n,i)}}function LL(e,t){let n=this[Wt];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[Wt]!==void 0&&(n._socket.removeListener("data",ac),process.nextTick(Jx,n._socket),e===1005?n.close():n.close(e,t))}function UL(){let e=this[Wt];e.isPaused||e._socket.resume()}function GL(e){let t=this[Wt];t._socket[Wt]!==void 0&&(t._socket.removeListener("data",ac),process.nextTick(Jx,t._socket),t.close(e[IL])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function Dx(){this[Wt].emitClose()}function zL(e,t){this[Wt].emit("message",e,t)}function JL(e){let t=this[Wt];t._autoPong&&t.pong(e,!this._isServer,Ux),t.emit("ping",e)}function KL(e){this[Wt].emit("pong",e)}function Jx(e){e.resume()}function BL(e){let t=this[Wt];t.readyState!==pt.CLOSED&&(t.readyState===pt.OPEN&&(t._readyState=pt.CLOSING,Kx(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function Kx(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),qL)}function Bx(){let e=this[Wt];this.removeListener("close",Bx),this.removeListener("data",ac),this.removeListener("end",Wx),e._readyState=pt.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[Wt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Dx),e._receiver.on("finish",Dx))}function ac(e){this[Wt]._receiver.write(e)||this.pause()}function Wx(){let e=this[Wt];e._readyState=pt.CLOSING,e._receiver.end(),this.end()}function Hx(){let e=this[Wt];this.removeListener("error",Hx),this.on("error",Ux),e&&(e._readyState=pt.CLOSING,this.destroy())}});var Xx=tt((Nce,Yx)=>{"use strict";var qce=sc(),{Duplex:WL}=He("stream");function Zx(e){e.emit("close")}function HL(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Qx(e){this.removeListener("error",Qx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function VL(e,t){let n=!0,i=new WL({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&i._readableState.objectMode?o.toString():o;i.push(s)||e.pause()}),e.once("error",function(o){i.destroyed||(n=!1,i.destroy(o))}),e.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(r,o){if(e.readyState===e.CLOSED){o(r),process.nextTick(Zx,i);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(r),process.nextTick(Zx,i)}),n&&e.terminate()},i._final=function(r){if(e.readyState===e.CONNECTING){e.once("open",function(){i._final(r)});return}e._socket!==null&&(e._socket._writableState.finished?(r(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",function(){r()}),e.close()))},i._read=function(){e.isPaused&&e.resume()},i._write=function(r,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){i._write(r,o,a)});return}e.send(r,a)},i.on("end",HL),i.on("error",Qx),i}Yx.exports=VL});var t0=tt((Fce,e0)=>{"use strict";var{tokenChars:ZL}=ya();function QL(e){let t=new Set,n=-1,i=-1,r=0;for(r;r<e.length;r++){let a=e.charCodeAt(r);if(i===-1&&ZL[a]===1)n===-1&&(n=r);else if(r!==0&&(a===32||a===9))i===-1&&n!==-1&&(i=r);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${r}`);i===-1&&(i=r);let s=e.slice(n,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=i=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(n===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,r);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}e0.exports={parse:QL}});var d0=tt((Lce,s0)=>{"use strict";var YL=He("events"),dc=He("http"),{Duplex:Dce}=He("stream"),{createHash:XL}=He("crypto"),n0=$h(),mo=ed(),eU=t0(),tU=sc(),{GUID:nU,kWebSocket:rU}=ai(),iU=/^[+/0-9A-Za-z]{22}==$/,r0=0,i0=1,a0=2,Fh=class extends YL{constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:tU,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=dc.createServer((i,r)=>{let o=dc.STATUS_CODES[426];r.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),r.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=oU(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,o,a)=>{this.handleUpgrade(r,o,a,i)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=r0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===a0){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(id,this);return}if(t&&this.once("close",t),this._state!==i0)if(this._state=i0,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(id,this):process.nextTick(id,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{id(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,i,r){n.on("error",o0);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){ho(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){ho(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!iU.test(o)){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){od(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=eU.parse(d)}catch{ho(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&u!==void 0){let p=new mo(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=n0.parse(u);f[mo.extensionName]&&(p.accept(f[mo.extensionName]),c[mo.extensionName]=p)}catch{ho(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:t.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(f,h,g,_)=>{if(!f)return od(n,h||401,g,_);this.completeUpgrade(c,o,l,t,n,i,r)});return}if(!this.options.verifyClient(p))return od(n,401)}this.completeUpgrade(c,o,l,t,n,i,r)}completeUpgrade(t,n,i,r,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[rU])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>r0)return od(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${XL("sha1").update(n+nU).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(i.size){let c=this.options.handleProtocols?this.options.handleProtocols(i,r):i.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[mo.extensionName]){let c=t[mo.extensionName].params,p=n0.format({[mo.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,r),o.write(l.concat(`\r
5
5
  `).join(`\r
6
6
  `)),o.removeListener("error",o0),u.setSocket(o,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(id,this)})),s(u,r)}};s0.exports=Fh;function oU(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let i of Object.keys(t))e.removeListener(i,t[i])}}function id(e){e._state=a0,e.emit("close")}function o0(){this.destroy()}function od(e,t,n,i){n=n||dc.STATUS_CODES[t],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...i},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${dc.STATUS_CODES[t]}\r
7
7
  `+Object.keys(i).map(r=>`${r}: ${i[r]}`).join(`\r