matex-cli 1.2.107 → 1.2.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -290,7 +290,7 @@ Connection: close\r
|
|
|
290
290
|
Content-type: text/html\r
|
|
291
291
|
Content-Length: `+i+`\r
|
|
292
292
|
\r
|
|
293
|
-
`+n)}t.destroy()}var jp=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,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,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,1,1,1,1,1,1,1,1,1,1,1,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,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,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,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,1,1,1,1,1,1,1,1,1,1,1,1];function NMe(t){if(t+="",t.length<1)return!1;if(!jp[t.charCodeAt(0)])return W('invalid header, index 0, char "%s"',t.charCodeAt(0)),!0;if(t.length<2)return!1;if(!jp[t.charCodeAt(1)])return W('invalid header, index 1, char "%s"',t.charCodeAt(1)),!0;if(t.length<3)return!1;if(!jp[t.charCodeAt(2)])return W('invalid header, index 2, char "%s"',t.charCodeAt(2)),!0;if(t.length<4)return!1;if(!jp[t.charCodeAt(3)])return W('invalid header, index 3, char "%s"',t.charCodeAt(3)),!0;for(let e=4;e<t.length;++e)if(!jp[t.charCodeAt(e)])return W('invalid header, index "%i", char "%s"',e,t.charCodeAt(e)),!0;return!1}});var AK=f(bg=>{"use strict";Object.defineProperty(bg,"__esModule",{value:!0});bg.Polling=void 0;var LMe=is(),DK=require("zlib"),UMe=Sp(),HMe=Qe(),Sr=(0,HMe.default)("engine:polling"),$Me={gzip:DK.createGzip,deflate:DK.createDeflate},e5=class extends LMe.Transport{constructor(e){super(e),this.closeTimeout=30*1e3}get name(){return"polling"}onRequest(e){let r=e.res;e.res=null,e.getMethod()==="get"?this.onPollRequest(e,r):e.getMethod()==="post"?this.onDataRequest(e,r):(r.writeStatus("500 Internal Server Error"),r.end())}onPollRequest(e,r){if(this.req){Sr("request overlap"),this.onError("overlap from client"),r.writeStatus("500 Internal Server Error"),r.end();return}Sr("setting request"),this.req=e,this.res=r;let n=()=>{this.writable=!1,this.onError("poll connection closed prematurely")},i=()=>{this.req=this.res=null};e.cleanup=i,r.onAborted(n),this.writable=!0,this.emit("ready"),this.writable&&this.shouldClose&&(Sr("triggering empty send to append close packet"),this.send([{type:"noop"}]))}onDataRequest(e,r){if(this.dataReq){this.onError("data request overlap from client"),r.writeStatus("500 Internal Server Error"),r.end();return}let n=Number(e.headers["content-length"]);if(!n){this.onError("content-length header required"),r.writeStatus("411 Length Required").end();return}if(n>this.maxHttpBufferSize){this.onError("payload too large"),r.writeStatus("413 Payload Too Large").end();return}if(e.headers["content-type"]==="application/octet-stream"&&this.protocol===4)return this.onError("invalid content");this.dataReq=e,this.dataRes=r;let a,s=0,o={"Content-Type":"text/html"};this.headers(e,o);for(let u in o)r.writeHeader(u,String(o[u]));let c=u=>{this.onData(u.toString()),this.onDataRequestCleanup(),r.cork(()=>{r.end("ok")})};r.onAborted(()=>{this.onDataRequestCleanup(),this.onError("data request connection closed prematurely")}),r.onData((u,l)=>{let p=s+u.byteLength;if(p>n){this.onError("content-length mismatch"),r.close();return}if(!a){if(l){c(Buffer.from(u));return}a=Buffer.allocUnsafe(n)}if(Buffer.from(u).copy(a,s),l){if(p!=n){this.onError("content-length mismatch"),r.writeStatus("400 Content-Length Mismatch").end(),this.onDataRequestCleanup();return}c(a);return}s=p})}onDataRequestCleanup(){this.dataReq=this.dataRes=null}onData(e){Sr('received "%s"',e);let r=n=>{if(n.type==="close")return Sr("got xhr close packet"),this.onClose(),!1;this.onPacket(n)};this.protocol===3?this.parser.decodePayload(e,r):this.parser.decodePayload(e).forEach(r)}onClose(){this.writable&&this.send([{type:"noop"}]),super.onClose()}send(e){this.writable=!1,this.shouldClose&&(Sr("appending close packet to payload"),e.push({type:"close"}),this.shouldClose(),this.shouldClose=null);let r=n=>{let i=e.some(a=>a.options&&a.options.compress);this.write(n,{compress:i})};this.protocol===3?this.parser.encodePayload(e,this.supportsBinary,r):this.parser.encodePayload(e,r)}write(e,r){Sr('writing "%s"',e),this.doWrite(e,r,()=>{this.req.cleanup(),this.emit("drain")})}doWrite(e,r,n){let i=typeof e=="string",s={"Content-Type":i?"text/plain; charset=UTF-8":"application/octet-stream"},o=l=>{this.headers(this.req,s),this.res.cork(()=>{Object.keys(s).forEach(p=>{this.res.writeHeader(p,String(s[p]))}),this.res.end(l)}),n()};if(!this.httpCompression||!r.compress){o(e);return}if((i?Buffer.byteLength(e):e.length)<this.httpCompression.threshold){o(e);return}let u=UMe(this.req).encodings(["gzip","deflate"]);if(!u){o(e);return}this.compress(e,u,(l,p)=>{if(l){this.res.writeStatus("500 Internal Server Error"),this.res.end(),n(l);return}s["Content-Encoding"]=u,o(p)})}compress(e,r,n){Sr("compressing");let i=[],a=0;$Me[r](this.httpCompression).on("error",n).on("data",function(s){i.push(s),a+=s.length}).on("end",function(){n(null,Buffer.concat(i,a))}).end(e)}doClose(e){Sr("closing");let r,n=()=>{clearTimeout(r),e(),this.onClose()};this.writable?(Sr("transport writable - closing right away"),this.send([{type:"close"}]),n()):this.discarded?(Sr("transport discarded - closing right away"),n()):(Sr("transport not writable - buffering orderly close"),this.shouldClose=n,r=setTimeout(n,this.closeTimeout))}headers(e,r){r=r||{};let n=e.headers["user-agent"];return n&&(~n.indexOf(";MSIE")||~n.indexOf("Trident/"))&&(r["X-XSS-Protection"]="0"),r["cache-control"]="no-store",this.emit("headers",r,e),r}};bg.Polling=e5});var CK=f(yg=>{"use strict";Object.defineProperty(yg,"__esModule",{value:!0});yg.WebSocket=void 0;var zMe=is(),WMe=Qe(),OK=(0,WMe.default)("engine:ws"),t5=class extends zMe.Transport{constructor(e){super(e),this.writable=!1,this.perMessageDeflate=null}get name(){return"websocket"}get handlesUpgrades(){return!0}send(e){this.writable=!1;for(let r=0;r<e.length;r++){let n=e[r],i=r+1===e.length,a=s=>{let o=typeof s!="string",c=this.perMessageDeflate&&Buffer.byteLength(s)>this.perMessageDeflate.threshold;OK('writing "%s"',s),this.socket.send(s,o,c),i&&(this.emit("drain"),this.writable=!0,this.emit("ready"))};n.options&&typeof n.options.wsPreEncoded=="string"?a(n.options.wsPreEncoded):this.parser.encodePacket(n,this.supportsBinary,a)}}doClose(e){OK("closing"),e&&e(),this.socket.end()}};yg.WebSocket=t5});var TK=f(r5=>{"use strict";Object.defineProperty(r5,"__esModule",{value:!0});var VMe=AK(),GMe=CK();r5.default={polling:VMe.Polling,websocket:GMe.WebSocket}});var qK=f(_g=>{"use strict";Object.defineProperty(_g,"__esModule",{value:!0});_g.uServer=void 0;var KMe=Qe(),ls=ZS(),YMe=TK(),oa=(0,KMe.default)("engine:uws"),n5=class extends ls.BaseServer{init(){}cleanup(){}prepare(e,r){e.method=e.getMethod().toUpperCase(),e.url=e.getUrl();let n=new URLSearchParams(e.getQuery());e._query=Object.fromEntries(n.entries()),e.headers={},e.forEach((i,a)=>{e.headers[i]=a}),e.connection={remoteAddress:Buffer.from(r.getRemoteAddressAsText()).toString()},r.onAborted(()=>{oa("response has been aborted")})}createTransport(e,r){return new YMe.default[e](r)}attach(e,r={}){let n=this._computePath(r);e.any(n,this.handleRequest.bind(this)).ws(n,{compression:r.compression,idleTimeout:r.idleTimeout,maxBackpressure:r.maxBackpressure,maxPayloadLength:this.opts.maxHttpBufferSize,upgrade:this.handleUpgrade.bind(this),open:i=>{let a=i.getUserData().transport;a.socket=i,a.writable=!0,a.emit("ready")},message:(i,a,s)=>{i.getUserData().transport.onData(s?a:Buffer.from(a).toString())},close:(i,a,s)=>{i.getUserData().transport.onClose(a,s)}})}_applyMiddlewares(e,r,n){if(this.middlewares.length===0)return n();e.res=new i5(r),super._applyMiddlewares(e,e.res,i=>{e.res.writeHead(),n(i)})}handleRequest(e,r){oa('handling "%s" http request "%s"',r.getMethod(),r.getUrl()),this.prepare(r,e),r.res=e;let n=(i,a)=>{if(i!==void 0){this.emit("connection_error",{req:r,code:i,message:ls.Server.errorMessages[i],context:a}),this.abortRequest(r.res,i,a);return}if(r._query.sid)oa("setting new request for existing client"),this.clients[r._query.sid].transport.onRequest(r);else{let s=(o,c)=>this.abortRequest(e,o,c);this.handshake(r._query.transport,r,s)}};this._applyMiddlewares(r,e,i=>{i?n(ls.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(r,!1,n)})}handleUpgrade(e,r,n){oa("on upgrade"),this.prepare(r,e),r.res=e;let i=async(a,s)=>{if(a!==void 0){this.emit("connection_error",{req:r,code:a,message:ls.Server.errorMessages[a],context:s}),this.abortRequest(e,a,s);return}let o=r._query.sid,c;if(o){let u=this.clients[o];if(u){if(u.upgrading)return oa("transport has already been trying to upgrade"),e.close();if(u.upgraded)return oa("transport had already been upgraded"),e.close();oa("upgrading existing transport"),c=this.createTransport(r._query.transport,r),u._maybeUpgrade(c)}else return oa("upgrade attempt for closed client"),e.close()}else if(c=await this.handshake(r._query.transport,r,(u,l)=>this.abortRequest(e,u,l)),!c)return;r.res.writeStatus("101 Switching Protocols"),e.upgrade({transport:c},r.getHeader("sec-websocket-key"),r.getHeader("sec-websocket-protocol"),r.getHeader("sec-websocket-extensions"),n)};this._applyMiddlewares(r,e,a=>{a?i(ls.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(r,!0,i)})}abortRequest(e,r,n){let i=r===ls.Server.errors.FORBIDDEN?"403 Forbidden":"400 Bad Request",a=n&&n.message?n.message:ls.Server.errorMessages[r];e.writeStatus(i),e.writeHeader("Content-Type","application/json"),e.end(JSON.stringify({code:r,message:a}))}};_g.uServer=n5;var i5=class{constructor(e){this.res=e,this.statusWritten=!1,this.headers=[],this.isAborted=!1}set statusCode(e){e&&this.writeStatus(e===200?"200 OK":"204 No Content")}writeHead(e){this.statusCode=e}setHeader(e,r){Array.isArray(r)?r.forEach(n=>{this.writeHeader(e,n)}):this.writeHeader(e,r)}removeHeader(){}getHeader(){}writeStatus(e){if(!this.isAborted)return this.res.writeStatus(e),this.statusWritten=!0,this.writeBufferedHeaders(),this}writeHeader(e,r){this.isAborted||e!=="Content-Length"&&(this.statusWritten?this.res.writeHeader(e,r):this.headers.push([e,r]))}writeBufferedHeaders(){this.headers.forEach(([e,r])=>{this.res.writeHeader(e,r)})}end(e){this.isAborted||this.res.cork(()=>{this.statusWritten||this.writeBufferedHeaders(),this.res.end(e)})}onData(e){this.isAborted||this.res.onData(e)}onAborted(e){this.isAborted||this.res.onAborted(()=>{this.isAborted=!0,e()})}cork(e){this.isAborted||this.res.cork(e)}}});var FK=f(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.protocol=dt.Transport=dt.Socket=dt.uServer=dt.parser=dt.transports=dt.Server=void 0;dt.listen=tNe;dt.attach=RK;var XMe=require("http"),kK=ZS();Object.defineProperty(dt,"Server",{enumerable:!0,get:function(){return kK.Server}});var JMe=AS();dt.transports=JMe.default;var PK=Cp();dt.parser=PK;var QMe=qK();Object.defineProperty(dt,"uServer",{enumerable:!0,get:function(){return QMe.uServer}});var ZMe=CS();Object.defineProperty(dt,"Socket",{enumerable:!0,get:function(){return ZMe.Socket}});var eNe=is();Object.defineProperty(dt,"Transport",{enumerable:!0,get:function(){return eNe.Transport}});dt.protocol=PK.protocol;function tNe(t,e,r){typeof e=="function"&&(r=e,e={});let n=(0,XMe.createServer)(function(a,s){s.writeHead(501),s.end("Not Implemented")}),i=RK(n,e);return i.httpServer=n,n.listen(t,r),i}function RK(t,e){let r=new kK.Server(e);return r.attach(t,e),r}});var BK=f(IK=>{IK.Emitter=Ft;function Ft(t){if(t)return rNe(t)}function rNe(t){for(var e in Ft.prototype)t[e]=Ft.prototype[e];return t}Ft.prototype.on=Ft.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};Ft.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this};Ft.prototype.off=Ft.prototype.removeListener=Ft.prototype.removeAllListeners=Ft.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===e||n.fn===e){r.splice(i,1);break}return r.length===0&&delete this._callbacks["$"+t],this};Ft.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,i=r.length;n<i;++n)r[n].apply(this,e)}return this};Ft.prototype.emitReserved=Ft.prototype.emit;Ft.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Ft.prototype.hasListeners=function(t){return!!this.listeners(t).length}});var a5=f(Eg=>{"use strict";Object.defineProperty(Eg,"__esModule",{value:!0});Eg.isBinary=MK;Eg.hasBinary=wg;var nNe=typeof ArrayBuffer=="function",iNe=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,jK=Object.prototype.toString,aNe=typeof Blob=="function"||typeof Blob<"u"&&jK.call(Blob)==="[object BlobConstructor]",sNe=typeof File=="function"||typeof File<"u"&&jK.call(File)==="[object FileConstructor]";function MK(t){return nNe&&(t instanceof ArrayBuffer||iNe(t))||aNe&&t instanceof Blob||sNe&&t instanceof File}function wg(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(wg(t[r]))return!0;return!1}if(MK(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return wg(t.toJSON(),!0);for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&wg(t[r]))return!0;return!1}});var NK=f(Sg=>{"use strict";Object.defineProperty(Sg,"__esModule",{value:!0});Sg.deconstructPacket=cNe;Sg.reconstructPacket=uNe;var oNe=a5();function cNe(t){let e=[],r=t.data,n=t;return n.data=s5(r,e),n.attachments=e.length,{packet:n,buffers:e}}function s5(t,e){if(!t)return t;if((0,oNe.isBinary)(t)){let r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){let r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=s5(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){let r={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=s5(t[n],e));return r}return t}function uNe(t,e){return t.data=o5(t.data,e),delete t.attachments,t}function o5(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o5(t[r],e);else if(typeof t=="object")for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=o5(t[r],e));return t}});var Mp=f(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.Decoder=Vr.Encoder=Vr.PacketType=Vr.protocol=void 0;Vr.isPacketValid=xNe;var lNe=BK(),LK=NK(),UK=a5(),pNe=Qe(),c5=(0,pNe.default)("socket.io-parser"),HK=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];Vr.protocol=5;var ve;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(ve||(Vr.PacketType=ve={}));var u5=class{constructor(e){this.replacer=e}encode(e){return c5("encoding packet %j",e),(e.type===ve.EVENT||e.type===ve.ACK)&&(0,UK.hasBinary)(e)?this.encodeAsBinary({type:e.type===ve.EVENT?ve.BINARY_EVENT:ve.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===ve.BINARY_EVENT||e.type===ve.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),c5("encoded %j as %s",e,r),r}encodeAsBinary(e){let r=(0,LK.deconstructPacket)(e),n=this.encodeAsString(r.packet),i=r.buffers;return i.unshift(n),i}};Vr.Encoder=u5;var l5=class t extends lNe.Emitter{constructor(e){super(),this.reviver=e}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e);let n=r.type===ve.BINARY_EVENT;n||r.type===ve.BINARY_ACK?(r.type=n?ve.EVENT:ve.ACK,this.reconstructor=new p5(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if((0,UK.isBinary)(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0,n={type:Number(e.charAt(0))};if(ve[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===ve.BINARY_EVENT||n.type===ve.BINARY_ACK){let a=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);let s=e.substring(a,r);if(s!=Number(s)||e.charAt(r)!=="-")throw new Error("Illegal attachments");n.attachments=Number(s)}if(e.charAt(r+1)==="/"){let a=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(a,r)}else n.nsp="/";let i=e.charAt(r+1);if(i!==""&&Number(i)==i){let a=r+1;for(;++r;){let s=e.charAt(r);if(s==null||Number(s)!=s){--r;break}if(r===e.length)break}n.id=Number(e.substring(a,r+1))}if(e.charAt(++r)){let a=this.tryParse(e.substr(r));if(t.isPayloadValid(n.type,a))n.data=a;else throw new Error("invalid payload")}return c5("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case ve.CONNECT:return Dg(r);case ve.DISCONNECT:return r===void 0;case ve.CONNECT_ERROR:return typeof r=="string"||Dg(r);case ve.EVENT:case ve.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&HK.indexOf(r[0])===-1);case ve.ACK:case ve.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}};Vr.Decoder=l5;var p5=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let r=(0,LK.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function fNe(t){return typeof t=="string"}var dNe=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function hNe(t){return t===void 0||dNe(t)}function Dg(t){return Object.prototype.toString.call(t)==="[object Object]"}function mNe(t,e){switch(t){case ve.CONNECT:return e===void 0||Dg(e);case ve.DISCONNECT:return e===void 0;case ve.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&HK.indexOf(e[0])===-1);case ve.ACK:return Array.isArray(e);case ve.CONNECT_ERROR:return typeof e=="string"||Dg(e);default:return!1}}function xNe(t){return fNe(t.nsp)&&hNe(t.id)&&mNe(t.type,t.data)}});var $K=f(Lc=>{"use strict";var vNe=Lc&&Lc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Lc,"__esModule",{value:!0});Lc.Client=void 0;var Ag=Mp(),gNe=vNe(Qe()),Gr=(0,gNe.default)("socket.io:client"),f5=class{constructor(e,r){this.sockets=new Map,this.nsps=new Map,this.server=e,this.conn=r,this.encoder=e.encoder,this.decoder=new e._parser.Decoder,this.id=r.id,this.setup()}get request(){return this.conn.request}setup(){this.onclose=this.onclose.bind(this),this.ondata=this.ondata.bind(this),this.onerror=this.onerror.bind(this),this.ondecoded=this.ondecoded.bind(this),this.decoder.on("decoded",this.ondecoded),this.conn.on("data",this.ondata),this.conn.on("error",this.onerror),this.conn.on("close",this.onclose),this.connectTimeout=setTimeout(()=>{this.nsps.size===0?(Gr("no namespace joined yet, close the client"),this.close()):Gr("the client has already joined a namespace, nothing to do")},this.server._connectTimeout)}connect(e,r={}){if(this.server._nsps.has(e))return Gr("connecting to namespace %s",e),this.doConnect(e,r);this.server._checkNamespace(e,r,n=>{n?this.doConnect(e,r):(Gr("creation of namespace %s was denied",e),this._packet({type:Ag.PacketType.CONNECT_ERROR,nsp:e,data:{message:"Invalid namespace"}}))})}doConnect(e,r){let n=this.server.of(e);n._add(this,r,i=>{this.sockets.set(i.id,i),this.nsps.set(n.name,i),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)})}_disconnect(){for(let e of this.sockets.values())e.disconnect();this.sockets.clear(),this.close()}_remove(e){if(this.sockets.has(e.id)){let r=this.sockets.get(e.id).nsp.name;this.sockets.delete(e.id),this.nsps.delete(r)}else Gr("ignoring remove for %s",e.id)}close(){this.conn.readyState==="open"&&(Gr("forcing transport close"),this.conn.close(),this.onclose("forced server close"))}_packet(e,r={}){if(this.conn.readyState!=="open"){Gr("ignoring packet write %j",e);return}let n=r.preEncoded?e:this.encoder.encode(e);this.writeToEngine(n,r)}writeToEngine(e,r){if(r.volatile&&!this.conn.transport.writable){Gr("volatile packet is discarded since the transport is not currently writable");return}let n=Array.isArray(e)?e:[e];for(let i of n)this.conn.write(i,r)}ondata(e){try{this.decoder.add(e)}catch(r){Gr("invalid packet format"),this.onerror(r)}}ondecoded(e){let{namespace:r,authPayload:n}=this._parseNamespace(e),i=this.nsps.get(r);!i&&e.type===Ag.PacketType.CONNECT?this.connect(r,n):i&&e.type!==Ag.PacketType.CONNECT&&e.type!==Ag.PacketType.CONNECT_ERROR?process.nextTick(function(){i._onpacket(e)}):(Gr("invalid state (packet type: %s)",e.type),this.close())}_parseNamespace(e){if(this.conn.protocol!==3)return{namespace:e.nsp,authPayload:e.data};let r=new URL(e.nsp,"https://socket.io");return{namespace:r.pathname,authPayload:Object.fromEntries(r.searchParams.entries())}}onerror(e){for(let r of this.sockets.values())r._onerror(e);this.conn.close()}onclose(e,r){Gr("client close with reason %s",e),this.destroy();for(let n of this.sockets.values())n._onclose(e,r);this.sockets.clear(),this.decoder.destroy()}destroy(){this.conn.removeListener("data",this.ondata),this.conn.removeListener("error",this.onerror),this.conn.removeListener("close",this.onclose),this.decoder.removeListener("decoded",this.ondecoded),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)}};Lc.Client=f5});var Cg=f(Og=>{"use strict";Object.defineProperty(Og,"__esModule",{value:!0});Og.StrictEventEmitter=void 0;var bNe=require("events"),d5=class extends bNe.EventEmitter{on(e,r){return super.on(e,r)}once(e,r){return super.once(e,r)}emit(e,...r){return super.emit(e,...r)}emitReserved(e,...r){return super.emit(e,...r)}emitUntyped(e,...r){return super.emit(e,...r)}listeners(e){return super.listeners(e)}};Og.StrictEventEmitter=d5});var h5=f(Tg=>{"use strict";Object.defineProperty(Tg,"__esModule",{value:!0});Tg.RESERVED_EVENTS=void 0;Tg.RESERVED_EVENTS=new Set(["connect","connect_error","disconnect","disconnecting","newListener","removeListener"])});var m5=f(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.RemoteSocket=Uc.BroadcastOperator=void 0;var yNe=h5(),_Ne=Mp(),qg=class t{constructor(e,r=new Set,n=new Set,i={}){this.adapter=e,this.rooms=r,this.exceptRooms=n,this.flags=i}to(e){let r=new Set(this.rooms);return Array.isArray(e)?e.forEach(n=>r.add(n)):r.add(e),new t(this.adapter,r,this.exceptRooms,this.flags)}in(e){return this.to(e)}except(e){let r=new Set(this.exceptRooms);return Array.isArray(e)?e.forEach(n=>r.add(n)):r.add(e),new t(this.adapter,this.rooms,r,this.flags)}compress(e){let r=Object.assign({},this.flags,{compress:e});return new t(this.adapter,this.rooms,this.exceptRooms,r)}get volatile(){let e=Object.assign({},this.flags,{volatile:!0});return new t(this.adapter,this.rooms,this.exceptRooms,e)}get local(){let e=Object.assign({},this.flags,{local:!0});return new t(this.adapter,this.rooms,this.exceptRooms,e)}timeout(e){let r=Object.assign({},this.flags,{timeout:e});return new t(this.adapter,this.rooms,this.exceptRooms,r)}emit(e,...r){if(yNe.RESERVED_EVENTS.has(e))throw new Error(`"${String(e)}" is a reserved event name`);let n=[e,...r],i={type:_Ne.PacketType.EVENT,data:n};if(!(typeof n[n.length-1]=="function"))return this.adapter.broadcast(i,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags}),!0;let s=n.pop(),o=!1,c=[],u=setTimeout(()=>{o=!0,s.apply(this,[new Error("operation has timed out"),this.flags.expectSingleResponse?null:c])},this.flags.timeout),l=-1,p=0,d=0,x=()=>{!o&&l===p&&c.length===d&&(clearTimeout(u),s.apply(this,[null,this.flags.expectSingleResponse?c[0]:c]))};return this.adapter.broadcastWithAck(i,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags},h=>{d+=h,p++,x()},h=>{c.push(h),x()}),this.adapter.serverCount().then(h=>{l=h,x()}),!0}emitWithAck(e,...r){return new Promise((n,i)=>{r.push((a,s)=>a?(a.responses=s,i(a)):n(s)),this.emit(e,...r)})}allSockets(){if(!this.adapter)throw new Error("No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?");return this.adapter.sockets(this.rooms)}fetchSockets(){return this.adapter.fetchSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags}).then(e=>e.map(r=>r.server?r:new kg(this.adapter,r)))}socketsJoin(e){this.adapter.addSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags},Array.isArray(e)?e:[e])}socketsLeave(e){this.adapter.delSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags},Array.isArray(e)?e:[e])}disconnectSockets(e=!1){this.adapter.disconnectSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags},e)}};Uc.BroadcastOperator=qg;var kg=class{constructor(e,r){this.id=r.id,this.handshake=r.handshake,this.rooms=new Set(r.rooms),this.data=r.data,this.operator=new qg(e,new Set([this.id]),new Set,{expectSingleResponse:!0})}timeout(e){return this.operator.timeout(e)}emit(e,...r){return this.operator.emit(e,...r)}join(e){return this.operator.socketsJoin(e)}leave(e){return this.operator.socketsLeave(e)}disconnect(e=!1){return this.operator.disconnectSockets(e),this}};Uc.RemoteSocket=kg});var v5=f(Hc=>{"use strict";var VK=Hc&&Hc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Hc,"__esModule",{value:!0});Hc.Socket=void 0;var Dr=Mp(),wNe=VK(Qe()),ENe=Cg(),zK=VK(lS()),SNe=m5(),DNe=h5(),wt=(0,wNe.default)("socket.io:socket"),ANe=new Set(["transport error","transport close","forced close","ping timeout","server shutting down","forced server close"]);function WK(){}var x5=class extends ENe.StrictEventEmitter{constructor(e,r,n,i){super(),this.nsp=e,this.client=r,this.recovered=!1,this.data={},this.connected=!1,this.acks=new Map,this.fns=[],this.flags={},this.server=e.server,this.adapter=e.adapter,i?(this.id=i.sid,this.pid=i.pid,i.rooms.forEach(a=>this.join(a)),this.data=i.data,i.missedPackets.forEach(a=>{this.packet({type:Dr.PacketType.EVENT,data:a})}),this.recovered=!0):(r.conn.protocol===3?this.id=e.name!=="/"?e.name+"#"+r.id:r.id:this.id=zK.default.generateId(),this.server._opts.connectionStateRecovery&&(this.pid=zK.default.generateId())),this.handshake=this.buildHandshake(n),this.on("error",WK)}buildHandshake(e){var r,n,i,a;return{headers:((r=this.request)===null||r===void 0?void 0:r.headers)||{},time:new Date+"",address:this.conn.remoteAddress,xdomain:!!(!((n=this.request)===null||n===void 0)&&n.headers.origin),secure:!this.request||!!this.request.connection.encrypted,issued:+new Date,url:(i=this.request)===null||i===void 0?void 0:i.url,query:((a=this.request)===null||a===void 0?void 0:a._query)||{},auth:e}}emit(e,...r){if(DNe.RESERVED_EVENTS.has(e))throw new Error(`"${String(e)}" is a reserved event name`);let n=[e,...r],i={type:Dr.PacketType.EVENT,data:n};if(typeof n[n.length-1]=="function"){let s=this.nsp._ids++;wt("emitting packet with ack id %d",s),this.registerAckCallback(s,n.pop()),i.id=s}let a=Object.assign({},this.flags);return this.flags={},this.nsp.server.opts.connectionStateRecovery?this.adapter.broadcast(i,{rooms:new Set([this.id]),except:new Set,flags:a}):(this.notifyOutgoingListeners(i),this.packet(i,a)),!0}emitWithAck(e,...r){let n=this.flags.timeout!==void 0;return new Promise((i,a)=>{r.push((s,o)=>n?s?a(s):i(o):i(s)),this.emit(e,...r)})}registerAckCallback(e,r){let n=this.flags.timeout;if(n===void 0){this.acks.set(e,r);return}let i=setTimeout(()=>{wt("event with ack id %d has timed out after %d ms",e,n),this.acks.delete(e),r.call(this,new Error("operation has timed out"))},n);this.acks.set(e,(...a)=>{clearTimeout(i),r.apply(this,[null,...a])})}to(e){return this.newBroadcastOperator().to(e)}in(e){return this.newBroadcastOperator().in(e)}except(e){return this.newBroadcastOperator().except(e)}send(...e){return this.emit("message",...e),this}write(...e){return this.emit("message",...e),this}packet(e,r={}){e.nsp=this.nsp.name,r.compress=r.compress!==!1,this.client._packet(e,r)}join(e){return wt("join room %s",e),this.adapter.addAll(this.id,new Set(Array.isArray(e)?e:[e]))}leave(e){return wt("leave room %s",e),this.adapter.del(this.id,e)}leaveAll(){this.adapter.delAll(this.id)}_onconnect(){wt("socket connected - writing packet"),this.connected=!0,this.join(this.id),this.conn.protocol===3?this.packet({type:Dr.PacketType.CONNECT}):this.packet({type:Dr.PacketType.CONNECT,data:{sid:this.id,pid:this.pid}})}_onpacket(e){switch(wt("got packet %j",e),e.type){case Dr.PacketType.EVENT:this.onevent(e);break;case Dr.PacketType.BINARY_EVENT:this.onevent(e);break;case Dr.PacketType.ACK:this.onack(e);break;case Dr.PacketType.BINARY_ACK:this.onack(e);break;case Dr.PacketType.DISCONNECT:this.ondisconnect();break}}onevent(e){let r=e.data||[];if(wt("emitting event %j",r),e.id!=null&&(wt("attaching ack callback to event"),r.push(this.ack(e.id))),this._anyListeners&&this._anyListeners.length){let n=this._anyListeners.slice();for(let i of n)i.apply(this,r)}this.dispatch(r)}ack(e){let r=this,n=!1;return function(){if(n)return;let i=Array.prototype.slice.call(arguments);wt("sending ack %j",i),r.packet({id:e,type:Dr.PacketType.ACK,data:i}),n=!0}}onack(e){let r=this.acks.get(e.id);typeof r=="function"?(wt("calling ack %s with %j",e.id,e.data),r.apply(this,e.data),this.acks.delete(e.id)):wt("bad ack %s",e.id)}ondisconnect(){wt("got disconnect packet"),this._onclose("client namespace disconnect")}_onerror(e){this.emitReserved("error",e)}_onclose(e,r){if(!this.connected)return this;wt("closing socket - reason %s",e),this.emitReserved("disconnecting",e,r),this.server._opts.connectionStateRecovery&&ANe.has(e)&&(wt("connection state recovery is enabled for sid %s",this.id),this.adapter.persistSession({sid:this.id,pid:this.pid,rooms:[...this.rooms],data:this.data})),this._cleanup(),this.client._remove(this),this.connected=!1,this.emitReserved("disconnect",e,r)}_cleanup(){this.leaveAll(),this.nsp._remove(this),this.join=WK}_error(e){this.packet({type:Dr.PacketType.CONNECT_ERROR,data:e})}disconnect(e=!1){return this.connected?(e?this.client._disconnect():(this.packet({type:Dr.PacketType.DISCONNECT}),this._onclose("server namespace disconnect")),this):this}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}get broadcast(){return this.newBroadcastOperator()}get local(){return this.newBroadcastOperator().local}timeout(e){return this.flags.timeout=e,this}dispatch(e){wt("dispatching an event %j",e),this.run(e,r=>{process.nextTick(()=>{if(r)return this._onerror(r);this.connected?super.emitUntyped.apply(this,e):wt("ignore packet received after disconnection")})})}use(e){return this.fns.push(e),this}run(e,r){if(!this.fns.length)return r();let n=this.fns.slice(0);function i(a){n[a](e,s=>{if(s)return r(s);if(!n[a+1])return r();i(a+1)})}i(0)}get disconnected(){return!this.connected}get request(){return this.client.request}get conn(){return this.client.conn}get rooms(){return this.adapter.socketRooms(this.id)||new Set}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let r=this._anyOutgoingListeners.slice();for(let n of r)n.apply(this,e.data)}}newBroadcastOperator(){let e=Object.assign({},this.flags);return this.flags={},new SNe.BroadcastOperator(this.adapter,new Set,new Set([this.id]),e)}};Hc.Socket=x5});var b5=f(ii=>{"use strict";var ONe=ii&&ii.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ii,"__esModule",{value:!0});ii.Namespace=ii.RESERVED_EVENTS=void 0;var GK=v5(),CNe=Cg(),TNe=ONe(Qe()),ar=m5(),$c=(0,TNe.default)("socket.io:namespace");ii.RESERVED_EVENTS=new Set(["connect","connection","new_namespace"]);var g5=class extends CNe.StrictEventEmitter{constructor(e,r){super(),this.sockets=new Map,this._preConnectSockets=new Map,this._fns=[],this._ids=0,this.server=e,this.name=r,this._initAdapter()}_initAdapter(){this.adapter=new(this.server.adapter())(this),Promise.resolve(this.adapter.init()).catch(e=>{$c("error while initializing adapter: %s",e)})}use(e){return this._fns.push(e),this}run(e,r){if(!this._fns.length)return r();let n=this._fns.slice(0);function i(a){n[a](e,s=>{if(s)return r(s);if(!n[a+1])return r();i(a+1)})}i(0)}to(e){return new ar.BroadcastOperator(this.adapter).to(e)}in(e){return new ar.BroadcastOperator(this.adapter).in(e)}except(e){return new ar.BroadcastOperator(this.adapter).except(e)}async _add(e,r,n){var i;$c("adding socket to nsp %s",this.name);let a=await this._createSocket(e,r);if(this._preConnectSockets.set(a.id,a),!((i=this.server.opts.connectionStateRecovery)===null||i===void 0)&&i.skipMiddlewares&&a.recovered&&e.conn.readyState==="open")return this._doConnect(a,n);this.run(a,s=>{process.nextTick(()=>{if(e.conn.readyState!=="open"){$c("next called after client was closed - ignoring socket"),a._cleanup();return}if(s)return $c("middleware error, sending CONNECT_ERROR packet to the client"),a._cleanup(),e.conn.protocol===3?a._error(s.data||s.message):a._error({message:s.message,data:s.data});this._doConnect(a,n)})})}async _createSocket(e,r){let n=r.pid,i=r.offset;if(this.server.opts.connectionStateRecovery&&typeof n=="string"&&typeof i=="string"){let a;try{a=await this.adapter.restoreSession(n,i)}catch(s){$c("error while restoring session: %s",s)}if(a)return $c("connection state recovered for sid %s",a.sid),new GK.Socket(this,e,r,a)}return new GK.Socket(this,e,r)}_doConnect(e,r){this._preConnectSockets.delete(e.id),this.sockets.set(e.id,e),e._onconnect(),r&&r(e),this.emitReserved("connect",e),this.emitReserved("connection",e)}_remove(e){this.sockets.delete(e.id)||this._preConnectSockets.delete(e.id)}emit(e,...r){return new ar.BroadcastOperator(this.adapter).emit(e,...r)}send(...e){return this.emit("message",...e),this}write(...e){return this.emit("message",...e),this}serverSideEmit(e,...r){if(ii.RESERVED_EVENTS.has(e))throw new Error(`"${String(e)}" is a reserved event name`);return r.unshift(e),this.adapter.serverSideEmit(r),!0}serverSideEmitWithAck(e,...r){return new Promise((n,i)=>{r.push((a,s)=>a?(a.responses=s,i(a)):n(s)),this.serverSideEmit(e,...r)})}_onServerSideEmit(e){super.emitUntyped.apply(this,e)}allSockets(){return new ar.BroadcastOperator(this.adapter).allSockets()}compress(e){return new ar.BroadcastOperator(this.adapter).compress(e)}get volatile(){return new ar.BroadcastOperator(this.adapter).volatile}get local(){return new ar.BroadcastOperator(this.adapter).local}timeout(e){return new ar.BroadcastOperator(this.adapter).timeout(e)}fetchSockets(){return new ar.BroadcastOperator(this.adapter).fetchSockets()}socketsJoin(e){return new ar.BroadcastOperator(this.adapter).socketsJoin(e)}socketsLeave(e){return new ar.BroadcastOperator(this.adapter).socketsLeave(e)}disconnectSockets(e=!1){return new ar.BroadcastOperator(this.adapter).disconnectSockets(e)}};ii.Namespace=g5});var QK=f(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});Np.encode=y5;Np.decode=qNe;Np.yeast=kNe;var XK="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Pg=64,JK={},KK=0,ca=0,YK;function y5(t){let e="";do e=XK[t%Pg]+e,t=Math.floor(t/Pg);while(t>0);return e}function qNe(t){let e=0;for(ca=0;ca<t.length;ca++)e=e*Pg+JK[t.charAt(ca)];return e}function kNe(){let t=y5(+new Date);return t!==YK?(KK=0,YK=t):t+"."+y5(KK++)}for(;ca<Pg;ca++)JK[XK[ca]]=ca});var E5=f(zc=>{"use strict";var _5;Object.defineProperty(zc,"__esModule",{value:!0});zc.SessionAwareAdapter=zc.Adapter=void 0;var PNe=require("events"),RNe=QK(),Rg=XS(),FNe=typeof((_5=Rg==null?void 0:Rg.Sender)===null||_5===void 0?void 0:_5.frame)=="function",Fg=class extends PNe.EventEmitter{constructor(e){super(),this.nsp=e,this.rooms=new Map,this.sids=new Map,this.encoder=e.server.encoder}init(){}close(){}serverCount(){return Promise.resolve(1)}addAll(e,r){this.sids.has(e)||this.sids.set(e,new Set);for(let n of r)this.sids.get(e).add(n),this.rooms.has(n)||(this.rooms.set(n,new Set),this.emit("create-room",n)),this.rooms.get(n).has(e)||(this.rooms.get(n).add(e),this.emit("join-room",n,e))}del(e,r){this.sids.has(e)&&this.sids.get(e).delete(r),this._del(r,e)}_del(e,r){let n=this.rooms.get(e);n!=null&&(n.delete(r)&&this.emit("leave-room",e,r),n.size===0&&this.rooms.delete(e)&&this.emit("delete-room",e))}delAll(e){if(this.sids.has(e)){for(let r of this.sids.get(e))this._del(r,e);this.sids.delete(e)}}broadcast(e,r){let n=r.flags||{},i={preEncoded:!0,volatile:n.volatile,compress:n.compress};e.nsp=this.nsp.name;let a=this._encode(e,i);this.apply(r,s=>{typeof s.notifyOutgoingListeners=="function"&&s.notifyOutgoingListeners(e),s.client.writeToEngine(a,i)})}broadcastWithAck(e,r,n,i){let a=r.flags||{},s={preEncoded:!0,volatile:a.volatile,compress:a.compress};e.nsp=this.nsp.name,e.id=this.nsp._ids++;let o=this._encode(e,s),c=0;this.apply(r,u=>{c++,u.acks.set(e.id,i),typeof u.notifyOutgoingListeners=="function"&&u.notifyOutgoingListeners(e),u.client.writeToEngine(o,s)}),n(c)}_encode(e,r){let n=this.encoder.encode(e);if(FNe&&n.length===1&&typeof n[0]=="string"){let i=Buffer.from("4"+n[0]);r.wsPreEncodedFrame=Rg.Sender.frame(i,{readOnly:!1,mask:!1,rsv1:!1,opcode:1,fin:!0})}return n}sockets(e){let r=new Set;return this.apply({rooms:e},n=>{r.add(n.id)}),Promise.resolve(r)}socketRooms(e){return this.sids.get(e)}fetchSockets(e){let r=[];return this.apply(e,n=>{r.push(n)}),Promise.resolve(r)}addSockets(e,r){this.apply(e,n=>{n.join(r)})}delSockets(e,r){this.apply(e,n=>{r.forEach(i=>n.leave(i))})}disconnectSockets(e,r){this.apply(e,n=>{n.disconnect(r)})}apply(e,r){let n=e.rooms,i=this.computeExceptSids(e.except);if(n.size){let a=new Set;for(let s of n)if(this.rooms.has(s))for(let o of this.rooms.get(s)){if(a.has(o)||i.has(o))continue;let c=this.nsp.sockets.get(o);c&&(r(c),a.add(o))}}else for(let[a]of this.sids){if(i.has(a))continue;let s=this.nsp.sockets.get(a);s&&r(s)}}computeExceptSids(e){let r=new Set;if(e&&e.size>0)for(let n of e)this.rooms.has(n)&&this.rooms.get(n).forEach(i=>r.add(i));return r}serverSideEmit(e){console.warn("this adapter does not support the serverSideEmit() functionality")}persistSession(e){}restoreSession(e,r){return null}};zc.Adapter=Fg;var w5=class extends Fg{constructor(e){super(e),this.nsp=e,this.sessions=new Map,this.packets=[],this.maxDisconnectionDuration=e.server.opts.connectionStateRecovery.maxDisconnectionDuration,setInterval(()=>{let n=Date.now()-this.maxDisconnectionDuration;this.sessions.forEach((i,a)=>{i.disconnectedAt<n&&this.sessions.delete(a)});for(let i=this.packets.length-1;i>=0;i--)if(this.packets[i].emittedAt<n){this.packets.splice(0,i+1);break}},60*1e3).unref()}persistSession(e){e.disconnectedAt=Date.now(),this.sessions.set(e.pid,e)}restoreSession(e,r){let n=this.sessions.get(e);if(!n)return null;if(n.disconnectedAt+this.maxDisconnectionDuration<Date.now())return this.sessions.delete(e),null;let a=this.packets.findIndex(o=>o.id===r);if(a===-1)return null;let s=[];for(let o=a+1;o<this.packets.length;o++){let c=this.packets[o];INe(n.rooms,c.opts)&&s.push(c.data)}return Promise.resolve(Object.assign(Object.assign({},n),{missedPackets:s}))}broadcast(e,r){var n;let i=e.type===2,a=e.id===void 0,s=((n=r.flags)===null||n===void 0?void 0:n.volatile)===void 0;if(i&&a&&s){let o=(0,RNe.yeast)();e.data.push(o),this.packets.push({id:o,opts:r,data:e.data,emittedAt:Date.now()})}super.broadcast(e,r)}};zc.SessionAwareAdapter=w5;function INe(t,e){let r=e.rooms.size===0||t.some(i=>e.rooms.has(i)),n=t.every(i=>!e.except.has(i));return r&&n}});var ZK=f(On=>{"use strict";var BNe=On&&On.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(On,"__esModule",{value:!0});On.ClusterAdapterWithHeartbeat=On.ClusterAdapter=On.MessageType=void 0;var jNe=E5(),MNe=Qe(),NNe=require("crypto"),Me=(0,MNe.debug)("socket.io-adapter"),LNe="emitter",Ig=5e3;function Vc(){return(0,NNe.randomBytes)(8).toString("hex")}var N;(function(t){t[t.INITIAL_HEARTBEAT=1]="INITIAL_HEARTBEAT",t[t.HEARTBEAT=2]="HEARTBEAT",t[t.BROADCAST=3]="BROADCAST",t[t.SOCKETS_JOIN=4]="SOCKETS_JOIN",t[t.SOCKETS_LEAVE=5]="SOCKETS_LEAVE",t[t.DISCONNECT_SOCKETS=6]="DISCONNECT_SOCKETS",t[t.FETCH_SOCKETS=7]="FETCH_SOCKETS",t[t.FETCH_SOCKETS_RESPONSE=8]="FETCH_SOCKETS_RESPONSE",t[t.SERVER_SIDE_EMIT=9]="SERVER_SIDE_EMIT",t[t.SERVER_SIDE_EMIT_RESPONSE=10]="SERVER_SIDE_EMIT_RESPONSE",t[t.BROADCAST_CLIENT_COUNT=11]="BROADCAST_CLIENT_COUNT",t[t.BROADCAST_ACK=12]="BROADCAST_ACK",t[t.ADAPTER_CLOSE=13]="ADAPTER_CLOSE"})(N||(On.MessageType=N={}));function ps(t){return{rooms:[...t.rooms],except:[...t.except],flags:t.flags}}function Wc(t){return{rooms:new Set(t.rooms),except:new Set(t.except),flags:t.flags}}var Bg=class extends jNe.Adapter{constructor(e){super(e),this.requests=new Map,this.ackRequests=new Map,this.uid=Vc()}onMessage(e,r){if(e.uid===this.uid)return Me("[%s] ignore message from self",this.uid);if(e.nsp!==this.nsp.name)return Me("[%s] ignore message from another namespace (%s)",this.uid,e.nsp);switch(Me("[%s] new event of type %d from %s",this.uid,e.type,e.uid),e.type){case N.BROADCAST:{if(e.data.requestId!==void 0)super.broadcastWithAck(e.data.packet,Wc(e.data.opts),i=>{Me("[%s] waiting for %d client acknowledgements",this.uid,i),this.publishResponse(e.uid,{type:N.BROADCAST_CLIENT_COUNT,data:{requestId:e.data.requestId,clientCount:i}})},i=>{Me("[%s] received acknowledgement with value %j",this.uid,i),this.publishResponse(e.uid,{type:N.BROADCAST_ACK,data:{requestId:e.data.requestId,packet:i}})});else{let i=e.data.packet,a=Wc(e.data.opts);this.addOffsetIfNecessary(i,a,r),super.broadcast(i,a)}break}case N.SOCKETS_JOIN:super.addSockets(Wc(e.data.opts),e.data.rooms);break;case N.SOCKETS_LEAVE:super.delSockets(Wc(e.data.opts),e.data.rooms);break;case N.DISCONNECT_SOCKETS:super.disconnectSockets(Wc(e.data.opts),e.data.close);break;case N.FETCH_SOCKETS:{Me("[%s] calling fetchSockets with opts %j",this.uid,e.data.opts),super.fetchSockets(Wc(e.data.opts)).then(n=>{this.publishResponse(e.uid,{type:N.FETCH_SOCKETS_RESPONSE,data:{requestId:e.data.requestId,sockets:n.map(i=>{let a=i.handshake,{sessionStore:s}=a,o=BNe(a,["sessionStore"]);return{id:i.id,handshake:o,rooms:[...i.rooms],data:i.data}})}})});break}case N.SERVER_SIDE_EMIT:{let n=e.data.packet;if(!(e.data.requestId!==void 0)){this.nsp._onServerSideEmit(n);return}let a=!1,s=o=>{a||(a=!0,Me("[%s] calling acknowledgement with %j",this.uid,o),this.publishResponse(e.uid,{type:N.SERVER_SIDE_EMIT_RESPONSE,data:{requestId:e.data.requestId,packet:o}}))};this.nsp._onServerSideEmit([...n,s]);break}case N.BROADCAST_CLIENT_COUNT:case N.BROADCAST_ACK:case N.FETCH_SOCKETS_RESPONSE:case N.SERVER_SIDE_EMIT_RESPONSE:this.onResponse(e);break;default:Me("[%s] unknown message type: %s",this.uid,e.type)}}onResponse(e){var r,n;let i=e.data.requestId;switch(Me("[%s] received response %s to request %s",this.uid,e.type,i),e.type){case N.BROADCAST_CLIENT_COUNT:{(r=this.ackRequests.get(i))===null||r===void 0||r.clientCountCallback(e.data.clientCount);break}case N.BROADCAST_ACK:{(n=this.ackRequests.get(i))===null||n===void 0||n.ack(e.data.packet);break}case N.FETCH_SOCKETS_RESPONSE:{let a=this.requests.get(i);if(!a)return;a.current++,e.data.sockets.forEach(s=>a.responses.push(s)),a.current===a.expected&&(clearTimeout(a.timeout),a.resolve(a.responses),this.requests.delete(i));break}case N.SERVER_SIDE_EMIT_RESPONSE:{let a=this.requests.get(i);if(!a)return;a.current++,a.responses.push(e.data.packet),a.current===a.expected&&(clearTimeout(a.timeout),a.resolve(null,a.responses),this.requests.delete(i));break}default:Me("[%s] unknown response type: %s",this.uid,e.type)}}async broadcast(e,r){var n;if(!((n=r.flags)===null||n===void 0?void 0:n.local))try{let a=await this.publishAndReturnOffset({type:N.BROADCAST,data:{packet:e,opts:ps(r)}});this.addOffsetIfNecessary(e,r,a)}catch(a){return Me("[%s] error while broadcasting message: %s",this.uid,a.message)}super.broadcast(e,r)}addOffsetIfNecessary(e,r,n){var i;if(!this.nsp.server.opts.connectionStateRecovery)return;let a=e.type===2,s=e.id===void 0,o=((i=r.flags)===null||i===void 0?void 0:i.volatile)===void 0;a&&s&&o&&e.data.push(n)}broadcastWithAck(e,r,n,i){var a;if(!((a=r==null?void 0:r.flags)===null||a===void 0?void 0:a.local)){let o=Vc();this.ackRequests.set(o,{clientCountCallback:n,ack:i}),this.publish({type:N.BROADCAST,data:{packet:e,requestId:o,opts:ps(r)}}),setTimeout(()=>{this.ackRequests.delete(o)},r.flags.timeout)}super.broadcastWithAck(e,r,n,i)}async addSockets(e,r){var n;if(!((n=e.flags)===null||n===void 0?void 0:n.local))try{await this.publishAndReturnOffset({type:N.SOCKETS_JOIN,data:{opts:ps(e),rooms:r}})}catch(a){Me("[%s] error while publishing message: %s",this.uid,a.message)}super.addSockets(e,r)}async delSockets(e,r){var n;if(!((n=e.flags)===null||n===void 0?void 0:n.local))try{await this.publishAndReturnOffset({type:N.SOCKETS_LEAVE,data:{opts:ps(e),rooms:r}})}catch(a){Me("[%s] error while publishing message: %s",this.uid,a.message)}super.delSockets(e,r)}async disconnectSockets(e,r){var n;if(!((n=e.flags)===null||n===void 0?void 0:n.local))try{await this.publishAndReturnOffset({type:N.DISCONNECT_SOCKETS,data:{opts:ps(e),close:r}})}catch(a){Me("[%s] error while publishing message: %s",this.uid,a.message)}super.disconnectSockets(e,r)}async fetchSockets(e){var r;let[n,i]=await Promise.all([super.fetchSockets(e),this.serverCount()]),a=i-1;if(!((r=e.flags)===null||r===void 0)&&r.local||a<=0)return n;let s=Vc();return new Promise((o,c)=>{let u=setTimeout(()=>{let p=this.requests.get(s);p&&(c(new Error(`timeout reached: only ${p.current} responses received out of ${p.expected}`)),this.requests.delete(s))},e.flags.timeout||Ig),l={type:N.FETCH_SOCKETS,resolve:o,timeout:u,current:0,expected:a,responses:n};this.requests.set(s,l),this.publish({type:N.FETCH_SOCKETS,data:{opts:ps(e),requestId:s}})})}async serverSideEmit(e){if(!(typeof e[e.length-1]=="function"))return this.publish({type:N.SERVER_SIDE_EMIT,data:{packet:e}});let n=e.pop(),i=await this.serverCount()-1;if(Me('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,i),i<=0)return n(null,[]);let a=Vc(),s=setTimeout(()=>{let c=this.requests.get(a);c&&(n(new Error(`timeout reached: only ${c.current} responses received out of ${c.expected}`),c.responses),this.requests.delete(a))},Ig),o={type:N.SERVER_SIDE_EMIT,resolve:n,timeout:s,current:0,expected:i,responses:[]};this.requests.set(a,o),this.publish({type:N.SERVER_SIDE_EMIT,data:{requestId:a,packet:e}})}publish(e){Me("[%s] sending message %s",this.uid,e.type),this.publishAndReturnOffset(e).catch(r=>{Me("[%s] error while publishing message: %s",this.uid,r)})}publishAndReturnOffset(e){return e.uid=this.uid,e.nsp=this.nsp.name,this.doPublish(e)}publishResponse(e,r){r.uid=this.uid,r.nsp=this.nsp.name,Me("[%s] sending response %s to %s",this.uid,r.type,e),this.doPublishResponse(e,r).catch(n=>{Me("[%s] error while publishing response: %s",this.uid,n)})}};On.ClusterAdapter=Bg;var S5=class extends Bg{constructor(e,r){super(e),this.nodesMap=new Map,this.customRequests=new Map,this._opts=Object.assign({heartbeatInterval:5e3,heartbeatTimeout:1e4},r),this.cleanupTimer=setInterval(()=>{let n=Date.now();this.nodesMap.forEach((i,a)=>{n-i>this._opts.heartbeatTimeout&&(Me("[%s] node %s seems down",this.uid,a),this.removeNode(a))})},1e3)}init(){this.publish({type:N.INITIAL_HEARTBEAT})}scheduleHeartbeat(){this.heartbeatTimer?this.heartbeatTimer.refresh():this.heartbeatTimer=setTimeout(()=>{this.publish({type:N.HEARTBEAT})},this._opts.heartbeatInterval)}close(){this.publish({type:N.ADAPTER_CLOSE}),clearTimeout(this.heartbeatTimer),this.cleanupTimer&&clearInterval(this.cleanupTimer)}onMessage(e,r){if(e.uid===this.uid)return Me("[%s] ignore message from self",this.uid);switch(e.uid&&e.uid!==LNe&&this.nodesMap.set(e.uid,Date.now()),e.type){case N.INITIAL_HEARTBEAT:this.publish({type:N.HEARTBEAT});break;case N.HEARTBEAT:break;case N.ADAPTER_CLOSE:this.removeNode(e.uid);break;default:super.onMessage(e,r)}}serverCount(){return Promise.resolve(1+this.nodesMap.size)}publish(e){return this.scheduleHeartbeat(),super.publish(e)}async serverSideEmit(e){if(!(typeof e[e.length-1]=="function"))return this.publish({type:N.SERVER_SIDE_EMIT,data:{packet:e}});let n=e.pop(),i=this.nodesMap.size;if(Me('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,i),i<=0)return n(null,[]);let a=Vc(),s=setTimeout(()=>{let c=this.customRequests.get(a);c&&(n(new Error(`timeout reached: missing ${c.missingUids.size} responses`),c.responses),this.customRequests.delete(a))},Ig),o={type:N.SERVER_SIDE_EMIT,resolve:n,timeout:s,missingUids:new Set([...this.nodesMap.keys()]),responses:[]};this.customRequests.set(a,o),this.publish({type:N.SERVER_SIDE_EMIT,data:{requestId:a,packet:e}})}async fetchSockets(e){var r;let[n,i]=await Promise.all([super.fetchSockets({rooms:e.rooms,except:e.except,flags:{local:!0}}),this.serverCount()]),a=i-1;if(!((r=e.flags)===null||r===void 0)&&r.local||a<=0)return n;let s=Vc();return new Promise((o,c)=>{let u=setTimeout(()=>{let p=this.customRequests.get(s);p&&(c(new Error(`timeout reached: missing ${p.missingUids.size} responses`)),this.customRequests.delete(s))},e.flags.timeout||Ig),l={type:N.FETCH_SOCKETS,resolve:o,timeout:u,missingUids:new Set([...this.nodesMap.keys()]),responses:n};this.customRequests.set(s,l),this.publish({type:N.FETCH_SOCKETS,data:{opts:ps(e),requestId:s}})})}onResponse(e){let r=e.data.requestId;switch(Me("[%s] received response %s to request %s",this.uid,e.type,r),e.type){case N.FETCH_SOCKETS_RESPONSE:{let n=this.customRequests.get(r);if(!n)return;e.data.sockets.forEach(i=>n.responses.push(i)),n.missingUids.delete(e.uid),n.missingUids.size===0&&(clearTimeout(n.timeout),n.resolve(n.responses),this.customRequests.delete(r));break}case N.SERVER_SIDE_EMIT_RESPONSE:{let n=this.customRequests.get(r);if(!n)return;n.responses.push(e.data.packet),n.missingUids.delete(e.uid),n.missingUids.size===0&&(clearTimeout(n.timeout),n.resolve(null,n.responses),this.customRequests.delete(r));break}default:super.onResponse(e)}}removeNode(e){this.customRequests.forEach((r,n)=>{r.missingUids.delete(e),r.missingUids.size===0&&(clearTimeout(r.timeout),r.type===N.FETCH_SOCKETS?r.resolve(r.responses):r.type===N.SERVER_SIDE_EMIT&&r.resolve(null,r.responses),this.customRequests.delete(n))}),this.nodesMap.delete(e)}};On.ClusterAdapterWithHeartbeat=S5});var jg=f(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.MessageType=Ar.ClusterAdapterWithHeartbeat=Ar.ClusterAdapter=Ar.SessionAwareAdapter=Ar.Adapter=void 0;var eY=E5();Object.defineProperty(Ar,"Adapter",{enumerable:!0,get:function(){return eY.Adapter}});Object.defineProperty(Ar,"SessionAwareAdapter",{enumerable:!0,get:function(){return eY.SessionAwareAdapter}});var D5=ZK();Object.defineProperty(Ar,"ClusterAdapter",{enumerable:!0,get:function(){return D5.ClusterAdapter}});Object.defineProperty(Ar,"ClusterAdapterWithHeartbeat",{enumerable:!0,get:function(){return D5.ClusterAdapterWithHeartbeat}});Object.defineProperty(Ar,"MessageType",{enumerable:!0,get:function(){return D5.MessageType}})});var nY=f(Gc=>{"use strict";var UNe=Gc&&Gc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Gc,"__esModule",{value:!0});Gc.ParentNamespace=void 0;var tY=b5(),HNe=jg(),$Ne=UNe(Qe()),rY=(0,$Ne.default)("socket.io:parent-namespace"),Mg=class t extends tY.Namespace{constructor(e){super(e,"/_"+t.count++),this.children=new Set}_initAdapter(){this.adapter=new A5(this)}emit(e,...r){return this.children.forEach(n=>{n.emit(e,...r)}),!0}createChild(e){rY("creating child namespace %s",e);let r=new tY.Namespace(this.server,e);if(this._fns.forEach(n=>r.use(n)),this.listeners("connect").forEach(n=>r.on("connect",n)),this.listeners("connection").forEach(n=>r.on("connection",n)),this.children.add(r),this.server._opts.cleanupEmptyChildNamespaces){let n=r._remove;r._remove=i=>{n.call(r,i),r.sockets.size===0&&(rY("closing child namespace %s",e),r.adapter.close(),this.server._nsps.delete(r.name),this.children.delete(r))}}return this.server._nsps.set(e,r),this.server.sockets.emitReserved("new_namespace",r),r}fetchSockets(){throw new Error("fetchSockets() is not supported on parent namespaces")}};Gc.ParentNamespace=Mg;Mg.count=0;var A5=class extends HNe.Adapter{broadcast(e,r){this.nsp.children.forEach(n=>{n.adapter.broadcast(e,r)})}}});var uY=f(ds=>{"use strict";var zNe=ds&&ds.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ds,"__esModule",{value:!0});ds.patchAdapter=VNe;ds.restoreAdapter=GNe;ds.serveFile=YNe;var fs=jg(),iY=require("fs"),WNe=zNe(Qe()),Ng=(0,WNe.default)("socket.io:adapter-uws"),O5="",{addAll:sY,del:oY,broadcast:cY}=fs.Adapter.prototype;function VNe(t){fs.Adapter.prototype.addAll=function(e,r){let n=!this.sids.has(e);sY.call(this,e,r);let i=this.nsp.sockets.get(e)||this.nsp._preConnectSockets.get(e);if(i){if(i.conn.transport.name==="websocket"){aY(this.nsp.name,i,n,r);return}n&&i.conn.on("upgrade",()=>{let a=this.sids.get(e);a&&aY(this.nsp.name,i,n,a)})}},fs.Adapter.prototype.del=function(e,r){oY.call(this,e,r);let n=this.nsp.sockets.get(e)||this.nsp._preConnectSockets.get(e);if(n&&n.conn.transport.name==="websocket"){let i=n.conn.id,a=n.conn.transport.socket,s=`${this.nsp.name}${O5}${r}`;Ng("unsubscribe connection %s from topic %s",i,s),a.unsubscribe(s)}},fs.Adapter.prototype.broadcast=function(e,r){if(!(r.rooms.size<=1&&r.except.size===0)){cY.call(this,e,r);return}let i=r.flags||{},a={preEncoded:!0,volatile:i.volatile,compress:i.compress};e.nsp=this.nsp.name;let s=this.encoder.encode(e),o=r.rooms.size===0?this.nsp.name:`${this.nsp.name}${O5}${r.rooms.keys().next().value}`;Ng("fast publish to %s",o),s.forEach(c=>{let u=typeof c!="string";t.publish(o,u?c:"4"+c,u)}),this.apply(r,c=>{c.conn.transport.name!=="websocket"&&c.client.writeToEngine(s,a)})}}function aY(t,e,r,n){let i=e.conn.id,a=e.conn.transport.socket;r&&(Ng("subscribe connection %s to topic %s",i,t),a.subscribe(t)),n.forEach(s=>{let o=`${t}${O5}${s}`;Ng("subscribe connection %s to topic %s",i,o),a.subscribe(o)})}function GNe(){fs.Adapter.prototype.addAll=sY,fs.Adapter.prototype.del=oY,fs.Adapter.prototype.broadcast=cY}var KNe=t=>{let{buffer:e,byteOffset:r,byteLength:n}=t;return e.slice(r,r+n)};function YNe(t,e){let{size:r}=(0,iY.statSync)(e),n=(0,iY.createReadStream)(e),i=()=>!n.destroyed&&n.destroy(),a=o=>{throw i(),o},s=o=>{let c=KNe(o);t.cork(()=>{let u=t.getWriteOffset(),[l,p]=t.tryEnd(c,r);!p&&!l&&(n.pause(),t.onWritable(d=>{let[x,h]=t.tryEnd(c.slice(d-u),r);return!h&&x&&n.resume(),x}))})};t.onAborted(i),n.on("data",s).on("error",a).on("end",i)}});var lY=f((ast,XNe)=>{XNe.exports={name:"socket.io",version:"4.8.3",description:"node.js realtime framework server",keywords:["realtime","framework","websocket","tcp","events","socket","io"],files:["dist/","client-dist/","wrapper.mjs","!**/*.tsbuildinfo"],directories:{doc:"docs/",example:"example/",lib:"lib/",test:"test/"},type:"commonjs",main:"./dist/index.js",exports:{".":{types:"./dist/index.d.ts",import:"./wrapper.mjs",require:"./dist/index.js"},"./package.json":"./package.json"},types:"./dist/index.d.ts",license:"MIT",homepage:"https://github.com/socketio/socket.io/tree/main/packages/socket.io#readme",repository:{type:"git",url:"git+https://github.com/socketio/socket.io.git"},bugs:{url:"https://github.com/socketio/socket.io/issues"},scripts:{compile:"rimraf ./dist && tsc",test:"npm run format:check && npm run compile && npm run test:types && npm run test:unit","test:types":"tsd","test:unit":"nyc mocha --import=tsx --reporter spec --slow 200 --bail --timeout 10000 test/index.ts","format:check":'prettier --check "lib/**/*.ts" "test/**/*.ts"',"format:fix":'prettier --write "lib/**/*.ts" "test/**/*.ts"',prepack:"npm run compile"},dependencies:{accepts:"~1.3.4",base64id:"~2.0.0",cors:"~2.8.5",debug:"~4.4.1","engine.io":"~6.6.0","socket.io-adapter":"~2.5.2","socket.io-parser":"~4.2.4"},contributors:[{name:"Guillermo Rauch",email:"rauchg@gmail.com"},{name:"Arnout Kazemier",email:"info@3rd-eden.com"},{name:"Vladimir Dronnikov",email:"dronnikov@gmail.com"},{name:"Einar Otto Stangvik",email:"einaros@gmail.com"}],engines:{node:">=10.2.0"},tsd:{directory:"test"}}});var gY=f((Et,Lp)=>{"use strict";var JNe=Et&&Et.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),QNe=Et&&Et.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),ZNe=Et&&Et.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&JNe(e,t,r);return QNe(e,t),e},q5=Et&&Et.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Et,"__esModule",{value:!0});Et.Namespace=Et.Socket=Et.Server=void 0;var eLe=q5(require("http")),tLe=require("fs"),C5=require("zlib"),rLe=Sp(),Lg=require("stream"),pY=require("path"),fY=FK(),nLe=$K(),dY=require("events"),k5=b5();Object.defineProperty(Et,"Namespace",{enumerable:!0,get:function(){return k5.Namespace}});var iLe=nY(),hY=jg(),aLe=ZNe(Mp()),sLe=q5(Qe()),vY=v5();Object.defineProperty(Et,"Socket",{enumerable:!0,get:function(){return vY.Socket}});var oLe=Cg(),T5=uY(),cLe=q5(JS()),It=(0,sLe.default)("socket.io:server"),mY=lY().version,xY=/\.map/,Kc=class t extends oLe.StrictEventEmitter{constructor(e,r={}){super(),this._nsps=new Map,this.parentNsps=new Map,this.parentNamespacesFromRegExp=new Map,typeof e=="object"&&e instanceof Object&&!e.listen&&(r=e,e=void 0),this.path(r.path||"/socket.io"),this.connectTimeout(r.connectTimeout||45e3),this.serveClient(r.serveClient!==!1),this._parser=r.parser||aLe,this.encoder=new this._parser.Encoder,this.opts=r,r.connectionStateRecovery?(r.connectionStateRecovery=Object.assign({maxDisconnectionDuration:120*1e3,skipMiddlewares:!0},r.connectionStateRecovery),this.adapter(r.adapter||hY.SessionAwareAdapter)):this.adapter(r.adapter||hY.Adapter),r.cleanupEmptyChildNamespaces=!!r.cleanupEmptyChildNamespaces,this.sockets=this.of("/"),(e||typeof e=="number")&&this.attach(e),this.opts.cors&&(this._corsMiddleware=(0,cLe.default)(this.opts.cors))}get _opts(){return this.opts}serveClient(e){return arguments.length?(this._serveClient=e,this):this._serveClient}_checkNamespace(e,r,n){if(this.parentNsps.size===0)return n(!1);let i=this.parentNsps.keys(),a=()=>{let s=i.next();if(s.done)return n(!1);s.value(e,r,(o,c)=>{if(o||!c)return a();if(this._nsps.has(e))return It("dynamic namespace %s already exists",e),n(this._nsps.get(e));let u=this.parentNsps.get(s.value).createChild(e);It("dynamic namespace %s was created",e),n(u)})};a()}path(e){if(!arguments.length)return this._path;this._path=e.replace(/\/$/,"");let r=this._path.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");return this.clientPathRegex=new RegExp("^"+r+"/socket\\.io(\\.msgpack|\\.esm)?(\\.min)?\\.js(\\.map)?(?:\\?|$)"),this}connectTimeout(e){return e===void 0?this._connectTimeout:(this._connectTimeout=e,this)}adapter(e){if(!arguments.length)return this._adapter;this._adapter=e;for(let r of this._nsps.values())r._initAdapter();return this}listen(e,r={}){return this.attach(e,r)}attach(e,r={}){if(typeof e=="function"){let n="You are trying to attach socket.io to an express request handler function. Please pass a http.Server instance.";throw new Error(n)}if(Number(e)==e&&(e=Number(e)),typeof e=="number"){It("creating http server and binding to %d",e);let n=e;e=eLe.default.createServer((i,a)=>{a.writeHead(404),a.end()}),e.listen(n)}return Object.assign(r,this.opts),r.path=r.path||this._path,this.initEngine(e,r),this}attachApp(e,r={}){Object.assign(r,this.opts),r.path=r.path||this._path,It("creating uWebSockets.js-based engine with opts %j",r);let n=new fY.uServer(r);n.attach(e,r),this.bind(n),this._serveClient&&e.get(`${this._path}/*`,(i,a)=>{if(!this.clientPathRegex.test(a.getUrl())){a.setYield(!0);return}let s=a.getUrl().replace(this._path,"").replace(/\?.*$/,"").replace(/^\//,""),o=xY.test(s),c=o?"map":"source",u='"'+mY+'"',l="W/"+u,p=a.getHeader("if-none-match");if(p&&(u===p||l===p)){It("serve client %s 304",c),i.writeStatus("304 Not Modified"),i.end();return}It("serve client %s",c),i.writeHeader("cache-control","public, max-age=0"),i.writeHeader("content-type","application/"+(o?"json":"javascript")+"; charset=utf-8"),i.writeHeader("etag",u);let d=pY.join(__dirname,"../client-dist/",s);(0,T5.serveFile)(i,d)}),(0,T5.patchAdapter)(e)}initEngine(e,r){It("creating engine.io instance with opts %j",r),this.eio=(0,fY.attach)(e,r),this._serveClient&&this.attachServe(e),this.httpServer=e,this.bind(this.eio)}attachServe(e){It("attaching client serving req handler");let r=e.listeners("request").slice(0);e.removeAllListeners("request"),e.on("request",(n,i)=>{if(this.clientPathRegex.test(n.url))this._corsMiddleware?this._corsMiddleware(n,i,()=>{this.serve(n,i)}):this.serve(n,i);else for(let a=0;a<r.length;a++)r[a].call(e,n,i)})}serve(e,r){let n=e.url.replace(this._path,"").replace(/\?.*$/,""),i=xY.test(n),a=i?"map":"source",s='"'+mY+'"',o="W/"+s,c=e.headers["if-none-match"];if(c&&(s===c||o===c)){It("serve client %s 304",a),r.writeHead(304),r.end();return}It("serve client %s",a),r.setHeader("Cache-Control","public, max-age=0"),r.setHeader("Content-Type","application/"+(i?"json":"javascript")+"; charset=utf-8"),r.setHeader("ETag",s),t.sendFile(n,e,r)}static sendFile(e,r,n){let i=(0,tLe.createReadStream)(pY.join(__dirname,"../client-dist/",e)),a=rLe(r).encodings(["br","gzip","deflate"]),s=o=>{o&&n.end()};switch(a){case"br":n.writeHead(200,{"content-encoding":"br"}),(0,Lg.pipeline)(i,(0,C5.createBrotliCompress)(),n,s);break;case"gzip":n.writeHead(200,{"content-encoding":"gzip"}),(0,Lg.pipeline)(i,(0,C5.createGzip)(),n,s);break;case"deflate":n.writeHead(200,{"content-encoding":"deflate"}),(0,Lg.pipeline)(i,(0,C5.createDeflate)(),n,s);break;default:n.writeHead(200),(0,Lg.pipeline)(i,n,s)}}bind(e){return this.engine=e,this.engine.on("connection",this.onconnection.bind(this)),this}onconnection(e){It("incoming connection with id %s",e.id);let r=new nLe.Client(this,e);return e.protocol===3&&r.connect("/"),this}of(e,r){if(typeof e=="function"||e instanceof RegExp){let i=new iLe.ParentNamespace(this);return It("initializing parent namespace %s",i.name),typeof e=="function"?this.parentNsps.set(e,i):(this.parentNsps.set((a,s,o)=>o(null,e.test(a)),i),this.parentNamespacesFromRegExp.set(e,i)),r&&i.on("connect",r),i}String(e)[0]!=="/"&&(e="/"+e);let n=this._nsps.get(e);if(!n){for(let[i,a]of this.parentNamespacesFromRegExp)if(i.test(e))return It("attaching namespace %s to parent namespace %s",e,i),a.createChild(e);It("initializing namespace %s",e),n=new k5.Namespace(this,e),this._nsps.set(e,n),e!=="/"&&this.sockets.emitReserved("new_namespace",n)}return r&&n.on("connect",r),n}async close(e){if(await Promise.allSettled([...this._nsps.values()].map(async r=>{r.sockets.forEach(n=>{n._onclose("server shutting down")}),await r.adapter.close()})),this.engine.close(),(0,T5.restoreAdapter)(),this.httpServer)return new Promise(r=>{this.httpServer.close(n=>{e&&e(n),n&&It("server was not running"),r()})});e&&e()}use(e){return this.sockets.use(e),this}to(e){return this.sockets.to(e)}in(e){return this.sockets.in(e)}except(e){return this.sockets.except(e)}send(...e){return this.sockets.emit("message",...e),this}write(...e){return this.sockets.emit("message",...e),this}serverSideEmit(e,...r){return this.sockets.serverSideEmit(e,...r)}serverSideEmitWithAck(e,...r){return this.sockets.serverSideEmitWithAck(e,...r)}allSockets(){return this.sockets.allSockets()}compress(e){return this.sockets.compress(e)}get volatile(){return this.sockets.volatile}get local(){return this.sockets.local}timeout(e){return this.sockets.timeout(e)}fetchSockets(){return this.sockets.fetchSockets()}socketsJoin(e){return this.sockets.socketsJoin(e)}socketsLeave(e){return this.sockets.socketsLeave(e)}disconnectSockets(e=!1){return this.sockets.disconnectSockets(e)}};Et.Server=Kc;var uLe=Object.keys(dY.EventEmitter.prototype).filter(function(t){return typeof dY.EventEmitter.prototype[t]=="function"});uLe.forEach(function(t){Kc.prototype[t]=function(){return this.sockets[t].apply(this.sockets,arguments)}});Lp.exports=(t,e)=>new Kc(t,e);Lp.exports.Server=Kc;Lp.exports.Namespace=k5.Namespace;Lp.exports.Socket=vY.Socket});var SY=f((Sst,lLe)=>{lLe.exports={name:"matex-cli",version:"1.2.107",description:"MATEX CLI - The Agentic 'Bro-Swarm' for Engineering. Zero-Cost AI for Students and Pro-Grade Dev Power.",main:"dist/index.js",bin:{matex:"bin/matex"},scripts:{build:"rm -rf dist && esbuild src/index.ts --bundle --platform=node --target=node16 --outfile=dist/index.js --minify",dev:"tsc --watch",test:"jest",postinstall:`echo "
|
|
293
|
+
`+n)}t.destroy()}var jp=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,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,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,1,1,1,1,1,1,1,1,1,1,1,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,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,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,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,1,1,1,1,1,1,1,1,1,1,1,1];function NMe(t){if(t+="",t.length<1)return!1;if(!jp[t.charCodeAt(0)])return W('invalid header, index 0, char "%s"',t.charCodeAt(0)),!0;if(t.length<2)return!1;if(!jp[t.charCodeAt(1)])return W('invalid header, index 1, char "%s"',t.charCodeAt(1)),!0;if(t.length<3)return!1;if(!jp[t.charCodeAt(2)])return W('invalid header, index 2, char "%s"',t.charCodeAt(2)),!0;if(t.length<4)return!1;if(!jp[t.charCodeAt(3)])return W('invalid header, index 3, char "%s"',t.charCodeAt(3)),!0;for(let e=4;e<t.length;++e)if(!jp[t.charCodeAt(e)])return W('invalid header, index "%i", char "%s"',e,t.charCodeAt(e)),!0;return!1}});var AK=f(bg=>{"use strict";Object.defineProperty(bg,"__esModule",{value:!0});bg.Polling=void 0;var LMe=is(),DK=require("zlib"),UMe=Sp(),HMe=Qe(),Sr=(0,HMe.default)("engine:polling"),$Me={gzip:DK.createGzip,deflate:DK.createDeflate},e5=class extends LMe.Transport{constructor(e){super(e),this.closeTimeout=30*1e3}get name(){return"polling"}onRequest(e){let r=e.res;e.res=null,e.getMethod()==="get"?this.onPollRequest(e,r):e.getMethod()==="post"?this.onDataRequest(e,r):(r.writeStatus("500 Internal Server Error"),r.end())}onPollRequest(e,r){if(this.req){Sr("request overlap"),this.onError("overlap from client"),r.writeStatus("500 Internal Server Error"),r.end();return}Sr("setting request"),this.req=e,this.res=r;let n=()=>{this.writable=!1,this.onError("poll connection closed prematurely")},i=()=>{this.req=this.res=null};e.cleanup=i,r.onAborted(n),this.writable=!0,this.emit("ready"),this.writable&&this.shouldClose&&(Sr("triggering empty send to append close packet"),this.send([{type:"noop"}]))}onDataRequest(e,r){if(this.dataReq){this.onError("data request overlap from client"),r.writeStatus("500 Internal Server Error"),r.end();return}let n=Number(e.headers["content-length"]);if(!n){this.onError("content-length header required"),r.writeStatus("411 Length Required").end();return}if(n>this.maxHttpBufferSize){this.onError("payload too large"),r.writeStatus("413 Payload Too Large").end();return}if(e.headers["content-type"]==="application/octet-stream"&&this.protocol===4)return this.onError("invalid content");this.dataReq=e,this.dataRes=r;let a,s=0,o={"Content-Type":"text/html"};this.headers(e,o);for(let u in o)r.writeHeader(u,String(o[u]));let c=u=>{this.onData(u.toString()),this.onDataRequestCleanup(),r.cork(()=>{r.end("ok")})};r.onAborted(()=>{this.onDataRequestCleanup(),this.onError("data request connection closed prematurely")}),r.onData((u,l)=>{let p=s+u.byteLength;if(p>n){this.onError("content-length mismatch"),r.close();return}if(!a){if(l){c(Buffer.from(u));return}a=Buffer.allocUnsafe(n)}if(Buffer.from(u).copy(a,s),l){if(p!=n){this.onError("content-length mismatch"),r.writeStatus("400 Content-Length Mismatch").end(),this.onDataRequestCleanup();return}c(a);return}s=p})}onDataRequestCleanup(){this.dataReq=this.dataRes=null}onData(e){Sr('received "%s"',e);let r=n=>{if(n.type==="close")return Sr("got xhr close packet"),this.onClose(),!1;this.onPacket(n)};this.protocol===3?this.parser.decodePayload(e,r):this.parser.decodePayload(e).forEach(r)}onClose(){this.writable&&this.send([{type:"noop"}]),super.onClose()}send(e){this.writable=!1,this.shouldClose&&(Sr("appending close packet to payload"),e.push({type:"close"}),this.shouldClose(),this.shouldClose=null);let r=n=>{let i=e.some(a=>a.options&&a.options.compress);this.write(n,{compress:i})};this.protocol===3?this.parser.encodePayload(e,this.supportsBinary,r):this.parser.encodePayload(e,r)}write(e,r){Sr('writing "%s"',e),this.doWrite(e,r,()=>{this.req.cleanup(),this.emit("drain")})}doWrite(e,r,n){let i=typeof e=="string",s={"Content-Type":i?"text/plain; charset=UTF-8":"application/octet-stream"},o=l=>{this.headers(this.req,s),this.res.cork(()=>{Object.keys(s).forEach(p=>{this.res.writeHeader(p,String(s[p]))}),this.res.end(l)}),n()};if(!this.httpCompression||!r.compress){o(e);return}if((i?Buffer.byteLength(e):e.length)<this.httpCompression.threshold){o(e);return}let u=UMe(this.req).encodings(["gzip","deflate"]);if(!u){o(e);return}this.compress(e,u,(l,p)=>{if(l){this.res.writeStatus("500 Internal Server Error"),this.res.end(),n(l);return}s["Content-Encoding"]=u,o(p)})}compress(e,r,n){Sr("compressing");let i=[],a=0;$Me[r](this.httpCompression).on("error",n).on("data",function(s){i.push(s),a+=s.length}).on("end",function(){n(null,Buffer.concat(i,a))}).end(e)}doClose(e){Sr("closing");let r,n=()=>{clearTimeout(r),e(),this.onClose()};this.writable?(Sr("transport writable - closing right away"),this.send([{type:"close"}]),n()):this.discarded?(Sr("transport discarded - closing right away"),n()):(Sr("transport not writable - buffering orderly close"),this.shouldClose=n,r=setTimeout(n,this.closeTimeout))}headers(e,r){r=r||{};let n=e.headers["user-agent"];return n&&(~n.indexOf(";MSIE")||~n.indexOf("Trident/"))&&(r["X-XSS-Protection"]="0"),r["cache-control"]="no-store",this.emit("headers",r,e),r}};bg.Polling=e5});var CK=f(yg=>{"use strict";Object.defineProperty(yg,"__esModule",{value:!0});yg.WebSocket=void 0;var zMe=is(),WMe=Qe(),OK=(0,WMe.default)("engine:ws"),t5=class extends zMe.Transport{constructor(e){super(e),this.writable=!1,this.perMessageDeflate=null}get name(){return"websocket"}get handlesUpgrades(){return!0}send(e){this.writable=!1;for(let r=0;r<e.length;r++){let n=e[r],i=r+1===e.length,a=s=>{let o=typeof s!="string",c=this.perMessageDeflate&&Buffer.byteLength(s)>this.perMessageDeflate.threshold;OK('writing "%s"',s),this.socket.send(s,o,c),i&&(this.emit("drain"),this.writable=!0,this.emit("ready"))};n.options&&typeof n.options.wsPreEncoded=="string"?a(n.options.wsPreEncoded):this.parser.encodePacket(n,this.supportsBinary,a)}}doClose(e){OK("closing"),e&&e(),this.socket.end()}};yg.WebSocket=t5});var TK=f(r5=>{"use strict";Object.defineProperty(r5,"__esModule",{value:!0});var VMe=AK(),GMe=CK();r5.default={polling:VMe.Polling,websocket:GMe.WebSocket}});var qK=f(_g=>{"use strict";Object.defineProperty(_g,"__esModule",{value:!0});_g.uServer=void 0;var KMe=Qe(),ls=ZS(),YMe=TK(),oa=(0,KMe.default)("engine:uws"),n5=class extends ls.BaseServer{init(){}cleanup(){}prepare(e,r){e.method=e.getMethod().toUpperCase(),e.url=e.getUrl();let n=new URLSearchParams(e.getQuery());e._query=Object.fromEntries(n.entries()),e.headers={},e.forEach((i,a)=>{e.headers[i]=a}),e.connection={remoteAddress:Buffer.from(r.getRemoteAddressAsText()).toString()},r.onAborted(()=>{oa("response has been aborted")})}createTransport(e,r){return new YMe.default[e](r)}attach(e,r={}){let n=this._computePath(r);e.any(n,this.handleRequest.bind(this)).ws(n,{compression:r.compression,idleTimeout:r.idleTimeout,maxBackpressure:r.maxBackpressure,maxPayloadLength:this.opts.maxHttpBufferSize,upgrade:this.handleUpgrade.bind(this),open:i=>{let a=i.getUserData().transport;a.socket=i,a.writable=!0,a.emit("ready")},message:(i,a,s)=>{i.getUserData().transport.onData(s?a:Buffer.from(a).toString())},close:(i,a,s)=>{i.getUserData().transport.onClose(a,s)}})}_applyMiddlewares(e,r,n){if(this.middlewares.length===0)return n();e.res=new i5(r),super._applyMiddlewares(e,e.res,i=>{e.res.writeHead(),n(i)})}handleRequest(e,r){oa('handling "%s" http request "%s"',r.getMethod(),r.getUrl()),this.prepare(r,e),r.res=e;let n=(i,a)=>{if(i!==void 0){this.emit("connection_error",{req:r,code:i,message:ls.Server.errorMessages[i],context:a}),this.abortRequest(r.res,i,a);return}if(r._query.sid)oa("setting new request for existing client"),this.clients[r._query.sid].transport.onRequest(r);else{let s=(o,c)=>this.abortRequest(e,o,c);this.handshake(r._query.transport,r,s)}};this._applyMiddlewares(r,e,i=>{i?n(ls.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(r,!1,n)})}handleUpgrade(e,r,n){oa("on upgrade"),this.prepare(r,e),r.res=e;let i=async(a,s)=>{if(a!==void 0){this.emit("connection_error",{req:r,code:a,message:ls.Server.errorMessages[a],context:s}),this.abortRequest(e,a,s);return}let o=r._query.sid,c;if(o){let u=this.clients[o];if(u){if(u.upgrading)return oa("transport has already been trying to upgrade"),e.close();if(u.upgraded)return oa("transport had already been upgraded"),e.close();oa("upgrading existing transport"),c=this.createTransport(r._query.transport,r),u._maybeUpgrade(c)}else return oa("upgrade attempt for closed client"),e.close()}else if(c=await this.handshake(r._query.transport,r,(u,l)=>this.abortRequest(e,u,l)),!c)return;r.res.writeStatus("101 Switching Protocols"),e.upgrade({transport:c},r.getHeader("sec-websocket-key"),r.getHeader("sec-websocket-protocol"),r.getHeader("sec-websocket-extensions"),n)};this._applyMiddlewares(r,e,a=>{a?i(ls.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(r,!0,i)})}abortRequest(e,r,n){let i=r===ls.Server.errors.FORBIDDEN?"403 Forbidden":"400 Bad Request",a=n&&n.message?n.message:ls.Server.errorMessages[r];e.writeStatus(i),e.writeHeader("Content-Type","application/json"),e.end(JSON.stringify({code:r,message:a}))}};_g.uServer=n5;var i5=class{constructor(e){this.res=e,this.statusWritten=!1,this.headers=[],this.isAborted=!1}set statusCode(e){e&&this.writeStatus(e===200?"200 OK":"204 No Content")}writeHead(e){this.statusCode=e}setHeader(e,r){Array.isArray(r)?r.forEach(n=>{this.writeHeader(e,n)}):this.writeHeader(e,r)}removeHeader(){}getHeader(){}writeStatus(e){if(!this.isAborted)return this.res.writeStatus(e),this.statusWritten=!0,this.writeBufferedHeaders(),this}writeHeader(e,r){this.isAborted||e!=="Content-Length"&&(this.statusWritten?this.res.writeHeader(e,r):this.headers.push([e,r]))}writeBufferedHeaders(){this.headers.forEach(([e,r])=>{this.res.writeHeader(e,r)})}end(e){this.isAborted||this.res.cork(()=>{this.statusWritten||this.writeBufferedHeaders(),this.res.end(e)})}onData(e){this.isAborted||this.res.onData(e)}onAborted(e){this.isAborted||this.res.onAborted(()=>{this.isAborted=!0,e()})}cork(e){this.isAborted||this.res.cork(e)}}});var FK=f(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.protocol=dt.Transport=dt.Socket=dt.uServer=dt.parser=dt.transports=dt.Server=void 0;dt.listen=tNe;dt.attach=RK;var XMe=require("http"),kK=ZS();Object.defineProperty(dt,"Server",{enumerable:!0,get:function(){return kK.Server}});var JMe=AS();dt.transports=JMe.default;var PK=Cp();dt.parser=PK;var QMe=qK();Object.defineProperty(dt,"uServer",{enumerable:!0,get:function(){return QMe.uServer}});var ZMe=CS();Object.defineProperty(dt,"Socket",{enumerable:!0,get:function(){return ZMe.Socket}});var eNe=is();Object.defineProperty(dt,"Transport",{enumerable:!0,get:function(){return eNe.Transport}});dt.protocol=PK.protocol;function tNe(t,e,r){typeof e=="function"&&(r=e,e={});let n=(0,XMe.createServer)(function(a,s){s.writeHead(501),s.end("Not Implemented")}),i=RK(n,e);return i.httpServer=n,n.listen(t,r),i}function RK(t,e){let r=new kK.Server(e);return r.attach(t,e),r}});var BK=f(IK=>{IK.Emitter=Ft;function Ft(t){if(t)return rNe(t)}function rNe(t){for(var e in Ft.prototype)t[e]=Ft.prototype[e];return t}Ft.prototype.on=Ft.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};Ft.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this};Ft.prototype.off=Ft.prototype.removeListener=Ft.prototype.removeAllListeners=Ft.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===e||n.fn===e){r.splice(i,1);break}return r.length===0&&delete this._callbacks["$"+t],this};Ft.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,i=r.length;n<i;++n)r[n].apply(this,e)}return this};Ft.prototype.emitReserved=Ft.prototype.emit;Ft.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Ft.prototype.hasListeners=function(t){return!!this.listeners(t).length}});var a5=f(Eg=>{"use strict";Object.defineProperty(Eg,"__esModule",{value:!0});Eg.isBinary=MK;Eg.hasBinary=wg;var nNe=typeof ArrayBuffer=="function",iNe=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,jK=Object.prototype.toString,aNe=typeof Blob=="function"||typeof Blob<"u"&&jK.call(Blob)==="[object BlobConstructor]",sNe=typeof File=="function"||typeof File<"u"&&jK.call(File)==="[object FileConstructor]";function MK(t){return nNe&&(t instanceof ArrayBuffer||iNe(t))||aNe&&t instanceof Blob||sNe&&t instanceof File}function wg(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(wg(t[r]))return!0;return!1}if(MK(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return wg(t.toJSON(),!0);for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&wg(t[r]))return!0;return!1}});var NK=f(Sg=>{"use strict";Object.defineProperty(Sg,"__esModule",{value:!0});Sg.deconstructPacket=cNe;Sg.reconstructPacket=uNe;var oNe=a5();function cNe(t){let e=[],r=t.data,n=t;return n.data=s5(r,e),n.attachments=e.length,{packet:n,buffers:e}}function s5(t,e){if(!t)return t;if((0,oNe.isBinary)(t)){let r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){let r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=s5(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){let r={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=s5(t[n],e));return r}return t}function uNe(t,e){return t.data=o5(t.data,e),delete t.attachments,t}function o5(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o5(t[r],e);else if(typeof t=="object")for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=o5(t[r],e));return t}});var Mp=f(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.Decoder=Vr.Encoder=Vr.PacketType=Vr.protocol=void 0;Vr.isPacketValid=xNe;var lNe=BK(),LK=NK(),UK=a5(),pNe=Qe(),c5=(0,pNe.default)("socket.io-parser"),HK=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];Vr.protocol=5;var ve;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(ve||(Vr.PacketType=ve={}));var u5=class{constructor(e){this.replacer=e}encode(e){return c5("encoding packet %j",e),(e.type===ve.EVENT||e.type===ve.ACK)&&(0,UK.hasBinary)(e)?this.encodeAsBinary({type:e.type===ve.EVENT?ve.BINARY_EVENT:ve.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===ve.BINARY_EVENT||e.type===ve.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),c5("encoded %j as %s",e,r),r}encodeAsBinary(e){let r=(0,LK.deconstructPacket)(e),n=this.encodeAsString(r.packet),i=r.buffers;return i.unshift(n),i}};Vr.Encoder=u5;var l5=class t extends lNe.Emitter{constructor(e){super(),this.reviver=e}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e);let n=r.type===ve.BINARY_EVENT;n||r.type===ve.BINARY_ACK?(r.type=n?ve.EVENT:ve.ACK,this.reconstructor=new p5(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if((0,UK.isBinary)(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0,n={type:Number(e.charAt(0))};if(ve[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===ve.BINARY_EVENT||n.type===ve.BINARY_ACK){let a=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);let s=e.substring(a,r);if(s!=Number(s)||e.charAt(r)!=="-")throw new Error("Illegal attachments");n.attachments=Number(s)}if(e.charAt(r+1)==="/"){let a=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(a,r)}else n.nsp="/";let i=e.charAt(r+1);if(i!==""&&Number(i)==i){let a=r+1;for(;++r;){let s=e.charAt(r);if(s==null||Number(s)!=s){--r;break}if(r===e.length)break}n.id=Number(e.substring(a,r+1))}if(e.charAt(++r)){let a=this.tryParse(e.substr(r));if(t.isPayloadValid(n.type,a))n.data=a;else throw new Error("invalid payload")}return c5("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case ve.CONNECT:return Dg(r);case ve.DISCONNECT:return r===void 0;case ve.CONNECT_ERROR:return typeof r=="string"||Dg(r);case ve.EVENT:case ve.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&HK.indexOf(r[0])===-1);case ve.ACK:case ve.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}};Vr.Decoder=l5;var p5=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let r=(0,LK.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function fNe(t){return typeof t=="string"}var dNe=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function hNe(t){return t===void 0||dNe(t)}function Dg(t){return Object.prototype.toString.call(t)==="[object Object]"}function mNe(t,e){switch(t){case ve.CONNECT:return e===void 0||Dg(e);case ve.DISCONNECT:return e===void 0;case ve.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&HK.indexOf(e[0])===-1);case ve.ACK:return Array.isArray(e);case ve.CONNECT_ERROR:return typeof e=="string"||Dg(e);default:return!1}}function xNe(t){return fNe(t.nsp)&&hNe(t.id)&&mNe(t.type,t.data)}});var $K=f(Lc=>{"use strict";var vNe=Lc&&Lc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Lc,"__esModule",{value:!0});Lc.Client=void 0;var Ag=Mp(),gNe=vNe(Qe()),Gr=(0,gNe.default)("socket.io:client"),f5=class{constructor(e,r){this.sockets=new Map,this.nsps=new Map,this.server=e,this.conn=r,this.encoder=e.encoder,this.decoder=new e._parser.Decoder,this.id=r.id,this.setup()}get request(){return this.conn.request}setup(){this.onclose=this.onclose.bind(this),this.ondata=this.ondata.bind(this),this.onerror=this.onerror.bind(this),this.ondecoded=this.ondecoded.bind(this),this.decoder.on("decoded",this.ondecoded),this.conn.on("data",this.ondata),this.conn.on("error",this.onerror),this.conn.on("close",this.onclose),this.connectTimeout=setTimeout(()=>{this.nsps.size===0?(Gr("no namespace joined yet, close the client"),this.close()):Gr("the client has already joined a namespace, nothing to do")},this.server._connectTimeout)}connect(e,r={}){if(this.server._nsps.has(e))return Gr("connecting to namespace %s",e),this.doConnect(e,r);this.server._checkNamespace(e,r,n=>{n?this.doConnect(e,r):(Gr("creation of namespace %s was denied",e),this._packet({type:Ag.PacketType.CONNECT_ERROR,nsp:e,data:{message:"Invalid namespace"}}))})}doConnect(e,r){let n=this.server.of(e);n._add(this,r,i=>{this.sockets.set(i.id,i),this.nsps.set(n.name,i),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)})}_disconnect(){for(let e of this.sockets.values())e.disconnect();this.sockets.clear(),this.close()}_remove(e){if(this.sockets.has(e.id)){let r=this.sockets.get(e.id).nsp.name;this.sockets.delete(e.id),this.nsps.delete(r)}else Gr("ignoring remove for %s",e.id)}close(){this.conn.readyState==="open"&&(Gr("forcing transport close"),this.conn.close(),this.onclose("forced server close"))}_packet(e,r={}){if(this.conn.readyState!=="open"){Gr("ignoring packet write %j",e);return}let n=r.preEncoded?e:this.encoder.encode(e);this.writeToEngine(n,r)}writeToEngine(e,r){if(r.volatile&&!this.conn.transport.writable){Gr("volatile packet is discarded since the transport is not currently writable");return}let n=Array.isArray(e)?e:[e];for(let i of n)this.conn.write(i,r)}ondata(e){try{this.decoder.add(e)}catch(r){Gr("invalid packet format"),this.onerror(r)}}ondecoded(e){let{namespace:r,authPayload:n}=this._parseNamespace(e),i=this.nsps.get(r);!i&&e.type===Ag.PacketType.CONNECT?this.connect(r,n):i&&e.type!==Ag.PacketType.CONNECT&&e.type!==Ag.PacketType.CONNECT_ERROR?process.nextTick(function(){i._onpacket(e)}):(Gr("invalid state (packet type: %s)",e.type),this.close())}_parseNamespace(e){if(this.conn.protocol!==3)return{namespace:e.nsp,authPayload:e.data};let r=new URL(e.nsp,"https://socket.io");return{namespace:r.pathname,authPayload:Object.fromEntries(r.searchParams.entries())}}onerror(e){for(let r of this.sockets.values())r._onerror(e);this.conn.close()}onclose(e,r){Gr("client close with reason %s",e),this.destroy();for(let n of this.sockets.values())n._onclose(e,r);this.sockets.clear(),this.decoder.destroy()}destroy(){this.conn.removeListener("data",this.ondata),this.conn.removeListener("error",this.onerror),this.conn.removeListener("close",this.onclose),this.decoder.removeListener("decoded",this.ondecoded),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)}};Lc.Client=f5});var Cg=f(Og=>{"use strict";Object.defineProperty(Og,"__esModule",{value:!0});Og.StrictEventEmitter=void 0;var bNe=require("events"),d5=class extends bNe.EventEmitter{on(e,r){return super.on(e,r)}once(e,r){return super.once(e,r)}emit(e,...r){return super.emit(e,...r)}emitReserved(e,...r){return super.emit(e,...r)}emitUntyped(e,...r){return super.emit(e,...r)}listeners(e){return super.listeners(e)}};Og.StrictEventEmitter=d5});var h5=f(Tg=>{"use strict";Object.defineProperty(Tg,"__esModule",{value:!0});Tg.RESERVED_EVENTS=void 0;Tg.RESERVED_EVENTS=new Set(["connect","connect_error","disconnect","disconnecting","newListener","removeListener"])});var m5=f(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.RemoteSocket=Uc.BroadcastOperator=void 0;var yNe=h5(),_Ne=Mp(),qg=class t{constructor(e,r=new Set,n=new Set,i={}){this.adapter=e,this.rooms=r,this.exceptRooms=n,this.flags=i}to(e){let r=new Set(this.rooms);return Array.isArray(e)?e.forEach(n=>r.add(n)):r.add(e),new t(this.adapter,r,this.exceptRooms,this.flags)}in(e){return this.to(e)}except(e){let r=new Set(this.exceptRooms);return Array.isArray(e)?e.forEach(n=>r.add(n)):r.add(e),new t(this.adapter,this.rooms,r,this.flags)}compress(e){let r=Object.assign({},this.flags,{compress:e});return new t(this.adapter,this.rooms,this.exceptRooms,r)}get volatile(){let e=Object.assign({},this.flags,{volatile:!0});return new t(this.adapter,this.rooms,this.exceptRooms,e)}get local(){let e=Object.assign({},this.flags,{local:!0});return new t(this.adapter,this.rooms,this.exceptRooms,e)}timeout(e){let r=Object.assign({},this.flags,{timeout:e});return new t(this.adapter,this.rooms,this.exceptRooms,r)}emit(e,...r){if(yNe.RESERVED_EVENTS.has(e))throw new Error(`"${String(e)}" is a reserved event name`);let n=[e,...r],i={type:_Ne.PacketType.EVENT,data:n};if(!(typeof n[n.length-1]=="function"))return this.adapter.broadcast(i,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags}),!0;let s=n.pop(),o=!1,c=[],u=setTimeout(()=>{o=!0,s.apply(this,[new Error("operation has timed out"),this.flags.expectSingleResponse?null:c])},this.flags.timeout),l=-1,p=0,d=0,x=()=>{!o&&l===p&&c.length===d&&(clearTimeout(u),s.apply(this,[null,this.flags.expectSingleResponse?c[0]:c]))};return this.adapter.broadcastWithAck(i,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags},h=>{d+=h,p++,x()},h=>{c.push(h),x()}),this.adapter.serverCount().then(h=>{l=h,x()}),!0}emitWithAck(e,...r){return new Promise((n,i)=>{r.push((a,s)=>a?(a.responses=s,i(a)):n(s)),this.emit(e,...r)})}allSockets(){if(!this.adapter)throw new Error("No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?");return this.adapter.sockets(this.rooms)}fetchSockets(){return this.adapter.fetchSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags}).then(e=>e.map(r=>r.server?r:new kg(this.adapter,r)))}socketsJoin(e){this.adapter.addSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags},Array.isArray(e)?e:[e])}socketsLeave(e){this.adapter.delSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags},Array.isArray(e)?e:[e])}disconnectSockets(e=!1){this.adapter.disconnectSockets({rooms:this.rooms,except:this.exceptRooms,flags:this.flags},e)}};Uc.BroadcastOperator=qg;var kg=class{constructor(e,r){this.id=r.id,this.handshake=r.handshake,this.rooms=new Set(r.rooms),this.data=r.data,this.operator=new qg(e,new Set([this.id]),new Set,{expectSingleResponse:!0})}timeout(e){return this.operator.timeout(e)}emit(e,...r){return this.operator.emit(e,...r)}join(e){return this.operator.socketsJoin(e)}leave(e){return this.operator.socketsLeave(e)}disconnect(e=!1){return this.operator.disconnectSockets(e),this}};Uc.RemoteSocket=kg});var v5=f(Hc=>{"use strict";var VK=Hc&&Hc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Hc,"__esModule",{value:!0});Hc.Socket=void 0;var Dr=Mp(),wNe=VK(Qe()),ENe=Cg(),zK=VK(lS()),SNe=m5(),DNe=h5(),wt=(0,wNe.default)("socket.io:socket"),ANe=new Set(["transport error","transport close","forced close","ping timeout","server shutting down","forced server close"]);function WK(){}var x5=class extends ENe.StrictEventEmitter{constructor(e,r,n,i){super(),this.nsp=e,this.client=r,this.recovered=!1,this.data={},this.connected=!1,this.acks=new Map,this.fns=[],this.flags={},this.server=e.server,this.adapter=e.adapter,i?(this.id=i.sid,this.pid=i.pid,i.rooms.forEach(a=>this.join(a)),this.data=i.data,i.missedPackets.forEach(a=>{this.packet({type:Dr.PacketType.EVENT,data:a})}),this.recovered=!0):(r.conn.protocol===3?this.id=e.name!=="/"?e.name+"#"+r.id:r.id:this.id=zK.default.generateId(),this.server._opts.connectionStateRecovery&&(this.pid=zK.default.generateId())),this.handshake=this.buildHandshake(n),this.on("error",WK)}buildHandshake(e){var r,n,i,a;return{headers:((r=this.request)===null||r===void 0?void 0:r.headers)||{},time:new Date+"",address:this.conn.remoteAddress,xdomain:!!(!((n=this.request)===null||n===void 0)&&n.headers.origin),secure:!this.request||!!this.request.connection.encrypted,issued:+new Date,url:(i=this.request)===null||i===void 0?void 0:i.url,query:((a=this.request)===null||a===void 0?void 0:a._query)||{},auth:e}}emit(e,...r){if(DNe.RESERVED_EVENTS.has(e))throw new Error(`"${String(e)}" is a reserved event name`);let n=[e,...r],i={type:Dr.PacketType.EVENT,data:n};if(typeof n[n.length-1]=="function"){let s=this.nsp._ids++;wt("emitting packet with ack id %d",s),this.registerAckCallback(s,n.pop()),i.id=s}let a=Object.assign({},this.flags);return this.flags={},this.nsp.server.opts.connectionStateRecovery?this.adapter.broadcast(i,{rooms:new Set([this.id]),except:new Set,flags:a}):(this.notifyOutgoingListeners(i),this.packet(i,a)),!0}emitWithAck(e,...r){let n=this.flags.timeout!==void 0;return new Promise((i,a)=>{r.push((s,o)=>n?s?a(s):i(o):i(s)),this.emit(e,...r)})}registerAckCallback(e,r){let n=this.flags.timeout;if(n===void 0){this.acks.set(e,r);return}let i=setTimeout(()=>{wt("event with ack id %d has timed out after %d ms",e,n),this.acks.delete(e),r.call(this,new Error("operation has timed out"))},n);this.acks.set(e,(...a)=>{clearTimeout(i),r.apply(this,[null,...a])})}to(e){return this.newBroadcastOperator().to(e)}in(e){return this.newBroadcastOperator().in(e)}except(e){return this.newBroadcastOperator().except(e)}send(...e){return this.emit("message",...e),this}write(...e){return this.emit("message",...e),this}packet(e,r={}){e.nsp=this.nsp.name,r.compress=r.compress!==!1,this.client._packet(e,r)}join(e){return wt("join room %s",e),this.adapter.addAll(this.id,new Set(Array.isArray(e)?e:[e]))}leave(e){return wt("leave room %s",e),this.adapter.del(this.id,e)}leaveAll(){this.adapter.delAll(this.id)}_onconnect(){wt("socket connected - writing packet"),this.connected=!0,this.join(this.id),this.conn.protocol===3?this.packet({type:Dr.PacketType.CONNECT}):this.packet({type:Dr.PacketType.CONNECT,data:{sid:this.id,pid:this.pid}})}_onpacket(e){switch(wt("got packet %j",e),e.type){case Dr.PacketType.EVENT:this.onevent(e);break;case Dr.PacketType.BINARY_EVENT:this.onevent(e);break;case Dr.PacketType.ACK:this.onack(e);break;case Dr.PacketType.BINARY_ACK:this.onack(e);break;case Dr.PacketType.DISCONNECT:this.ondisconnect();break}}onevent(e){let r=e.data||[];if(wt("emitting event %j",r),e.id!=null&&(wt("attaching ack callback to event"),r.push(this.ack(e.id))),this._anyListeners&&this._anyListeners.length){let n=this._anyListeners.slice();for(let i of n)i.apply(this,r)}this.dispatch(r)}ack(e){let r=this,n=!1;return function(){if(n)return;let i=Array.prototype.slice.call(arguments);wt("sending ack %j",i),r.packet({id:e,type:Dr.PacketType.ACK,data:i}),n=!0}}onack(e){let r=this.acks.get(e.id);typeof r=="function"?(wt("calling ack %s with %j",e.id,e.data),r.apply(this,e.data),this.acks.delete(e.id)):wt("bad ack %s",e.id)}ondisconnect(){wt("got disconnect packet"),this._onclose("client namespace disconnect")}_onerror(e){this.emitReserved("error",e)}_onclose(e,r){if(!this.connected)return this;wt("closing socket - reason %s",e),this.emitReserved("disconnecting",e,r),this.server._opts.connectionStateRecovery&&ANe.has(e)&&(wt("connection state recovery is enabled for sid %s",this.id),this.adapter.persistSession({sid:this.id,pid:this.pid,rooms:[...this.rooms],data:this.data})),this._cleanup(),this.client._remove(this),this.connected=!1,this.emitReserved("disconnect",e,r)}_cleanup(){this.leaveAll(),this.nsp._remove(this),this.join=WK}_error(e){this.packet({type:Dr.PacketType.CONNECT_ERROR,data:e})}disconnect(e=!1){return this.connected?(e?this.client._disconnect():(this.packet({type:Dr.PacketType.DISCONNECT}),this._onclose("server namespace disconnect")),this):this}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}get broadcast(){return this.newBroadcastOperator()}get local(){return this.newBroadcastOperator().local}timeout(e){return this.flags.timeout=e,this}dispatch(e){wt("dispatching an event %j",e),this.run(e,r=>{process.nextTick(()=>{if(r)return this._onerror(r);this.connected?super.emitUntyped.apply(this,e):wt("ignore packet received after disconnection")})})}use(e){return this.fns.push(e),this}run(e,r){if(!this.fns.length)return r();let n=this.fns.slice(0);function i(a){n[a](e,s=>{if(s)return r(s);if(!n[a+1])return r();i(a+1)})}i(0)}get disconnected(){return!this.connected}get request(){return this.client.request}get conn(){return this.client.conn}get rooms(){return this.adapter.socketRooms(this.id)||new Set}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let r=this._anyOutgoingListeners.slice();for(let n of r)n.apply(this,e.data)}}newBroadcastOperator(){let e=Object.assign({},this.flags);return this.flags={},new SNe.BroadcastOperator(this.adapter,new Set,new Set([this.id]),e)}};Hc.Socket=x5});var b5=f(ii=>{"use strict";var ONe=ii&&ii.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ii,"__esModule",{value:!0});ii.Namespace=ii.RESERVED_EVENTS=void 0;var GK=v5(),CNe=Cg(),TNe=ONe(Qe()),ar=m5(),$c=(0,TNe.default)("socket.io:namespace");ii.RESERVED_EVENTS=new Set(["connect","connection","new_namespace"]);var g5=class extends CNe.StrictEventEmitter{constructor(e,r){super(),this.sockets=new Map,this._preConnectSockets=new Map,this._fns=[],this._ids=0,this.server=e,this.name=r,this._initAdapter()}_initAdapter(){this.adapter=new(this.server.adapter())(this),Promise.resolve(this.adapter.init()).catch(e=>{$c("error while initializing adapter: %s",e)})}use(e){return this._fns.push(e),this}run(e,r){if(!this._fns.length)return r();let n=this._fns.slice(0);function i(a){n[a](e,s=>{if(s)return r(s);if(!n[a+1])return r();i(a+1)})}i(0)}to(e){return new ar.BroadcastOperator(this.adapter).to(e)}in(e){return new ar.BroadcastOperator(this.adapter).in(e)}except(e){return new ar.BroadcastOperator(this.adapter).except(e)}async _add(e,r,n){var i;$c("adding socket to nsp %s",this.name);let a=await this._createSocket(e,r);if(this._preConnectSockets.set(a.id,a),!((i=this.server.opts.connectionStateRecovery)===null||i===void 0)&&i.skipMiddlewares&&a.recovered&&e.conn.readyState==="open")return this._doConnect(a,n);this.run(a,s=>{process.nextTick(()=>{if(e.conn.readyState!=="open"){$c("next called after client was closed - ignoring socket"),a._cleanup();return}if(s)return $c("middleware error, sending CONNECT_ERROR packet to the client"),a._cleanup(),e.conn.protocol===3?a._error(s.data||s.message):a._error({message:s.message,data:s.data});this._doConnect(a,n)})})}async _createSocket(e,r){let n=r.pid,i=r.offset;if(this.server.opts.connectionStateRecovery&&typeof n=="string"&&typeof i=="string"){let a;try{a=await this.adapter.restoreSession(n,i)}catch(s){$c("error while restoring session: %s",s)}if(a)return $c("connection state recovered for sid %s",a.sid),new GK.Socket(this,e,r,a)}return new GK.Socket(this,e,r)}_doConnect(e,r){this._preConnectSockets.delete(e.id),this.sockets.set(e.id,e),e._onconnect(),r&&r(e),this.emitReserved("connect",e),this.emitReserved("connection",e)}_remove(e){this.sockets.delete(e.id)||this._preConnectSockets.delete(e.id)}emit(e,...r){return new ar.BroadcastOperator(this.adapter).emit(e,...r)}send(...e){return this.emit("message",...e),this}write(...e){return this.emit("message",...e),this}serverSideEmit(e,...r){if(ii.RESERVED_EVENTS.has(e))throw new Error(`"${String(e)}" is a reserved event name`);return r.unshift(e),this.adapter.serverSideEmit(r),!0}serverSideEmitWithAck(e,...r){return new Promise((n,i)=>{r.push((a,s)=>a?(a.responses=s,i(a)):n(s)),this.serverSideEmit(e,...r)})}_onServerSideEmit(e){super.emitUntyped.apply(this,e)}allSockets(){return new ar.BroadcastOperator(this.adapter).allSockets()}compress(e){return new ar.BroadcastOperator(this.adapter).compress(e)}get volatile(){return new ar.BroadcastOperator(this.adapter).volatile}get local(){return new ar.BroadcastOperator(this.adapter).local}timeout(e){return new ar.BroadcastOperator(this.adapter).timeout(e)}fetchSockets(){return new ar.BroadcastOperator(this.adapter).fetchSockets()}socketsJoin(e){return new ar.BroadcastOperator(this.adapter).socketsJoin(e)}socketsLeave(e){return new ar.BroadcastOperator(this.adapter).socketsLeave(e)}disconnectSockets(e=!1){return new ar.BroadcastOperator(this.adapter).disconnectSockets(e)}};ii.Namespace=g5});var QK=f(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});Np.encode=y5;Np.decode=qNe;Np.yeast=kNe;var XK="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Pg=64,JK={},KK=0,ca=0,YK;function y5(t){let e="";do e=XK[t%Pg]+e,t=Math.floor(t/Pg);while(t>0);return e}function qNe(t){let e=0;for(ca=0;ca<t.length;ca++)e=e*Pg+JK[t.charAt(ca)];return e}function kNe(){let t=y5(+new Date);return t!==YK?(KK=0,YK=t):t+"."+y5(KK++)}for(;ca<Pg;ca++)JK[XK[ca]]=ca});var E5=f(zc=>{"use strict";var _5;Object.defineProperty(zc,"__esModule",{value:!0});zc.SessionAwareAdapter=zc.Adapter=void 0;var PNe=require("events"),RNe=QK(),Rg=XS(),FNe=typeof((_5=Rg==null?void 0:Rg.Sender)===null||_5===void 0?void 0:_5.frame)=="function",Fg=class extends PNe.EventEmitter{constructor(e){super(),this.nsp=e,this.rooms=new Map,this.sids=new Map,this.encoder=e.server.encoder}init(){}close(){}serverCount(){return Promise.resolve(1)}addAll(e,r){this.sids.has(e)||this.sids.set(e,new Set);for(let n of r)this.sids.get(e).add(n),this.rooms.has(n)||(this.rooms.set(n,new Set),this.emit("create-room",n)),this.rooms.get(n).has(e)||(this.rooms.get(n).add(e),this.emit("join-room",n,e))}del(e,r){this.sids.has(e)&&this.sids.get(e).delete(r),this._del(r,e)}_del(e,r){let n=this.rooms.get(e);n!=null&&(n.delete(r)&&this.emit("leave-room",e,r),n.size===0&&this.rooms.delete(e)&&this.emit("delete-room",e))}delAll(e){if(this.sids.has(e)){for(let r of this.sids.get(e))this._del(r,e);this.sids.delete(e)}}broadcast(e,r){let n=r.flags||{},i={preEncoded:!0,volatile:n.volatile,compress:n.compress};e.nsp=this.nsp.name;let a=this._encode(e,i);this.apply(r,s=>{typeof s.notifyOutgoingListeners=="function"&&s.notifyOutgoingListeners(e),s.client.writeToEngine(a,i)})}broadcastWithAck(e,r,n,i){let a=r.flags||{},s={preEncoded:!0,volatile:a.volatile,compress:a.compress};e.nsp=this.nsp.name,e.id=this.nsp._ids++;let o=this._encode(e,s),c=0;this.apply(r,u=>{c++,u.acks.set(e.id,i),typeof u.notifyOutgoingListeners=="function"&&u.notifyOutgoingListeners(e),u.client.writeToEngine(o,s)}),n(c)}_encode(e,r){let n=this.encoder.encode(e);if(FNe&&n.length===1&&typeof n[0]=="string"){let i=Buffer.from("4"+n[0]);r.wsPreEncodedFrame=Rg.Sender.frame(i,{readOnly:!1,mask:!1,rsv1:!1,opcode:1,fin:!0})}return n}sockets(e){let r=new Set;return this.apply({rooms:e},n=>{r.add(n.id)}),Promise.resolve(r)}socketRooms(e){return this.sids.get(e)}fetchSockets(e){let r=[];return this.apply(e,n=>{r.push(n)}),Promise.resolve(r)}addSockets(e,r){this.apply(e,n=>{n.join(r)})}delSockets(e,r){this.apply(e,n=>{r.forEach(i=>n.leave(i))})}disconnectSockets(e,r){this.apply(e,n=>{n.disconnect(r)})}apply(e,r){let n=e.rooms,i=this.computeExceptSids(e.except);if(n.size){let a=new Set;for(let s of n)if(this.rooms.has(s))for(let o of this.rooms.get(s)){if(a.has(o)||i.has(o))continue;let c=this.nsp.sockets.get(o);c&&(r(c),a.add(o))}}else for(let[a]of this.sids){if(i.has(a))continue;let s=this.nsp.sockets.get(a);s&&r(s)}}computeExceptSids(e){let r=new Set;if(e&&e.size>0)for(let n of e)this.rooms.has(n)&&this.rooms.get(n).forEach(i=>r.add(i));return r}serverSideEmit(e){console.warn("this adapter does not support the serverSideEmit() functionality")}persistSession(e){}restoreSession(e,r){return null}};zc.Adapter=Fg;var w5=class extends Fg{constructor(e){super(e),this.nsp=e,this.sessions=new Map,this.packets=[],this.maxDisconnectionDuration=e.server.opts.connectionStateRecovery.maxDisconnectionDuration,setInterval(()=>{let n=Date.now()-this.maxDisconnectionDuration;this.sessions.forEach((i,a)=>{i.disconnectedAt<n&&this.sessions.delete(a)});for(let i=this.packets.length-1;i>=0;i--)if(this.packets[i].emittedAt<n){this.packets.splice(0,i+1);break}},60*1e3).unref()}persistSession(e){e.disconnectedAt=Date.now(),this.sessions.set(e.pid,e)}restoreSession(e,r){let n=this.sessions.get(e);if(!n)return null;if(n.disconnectedAt+this.maxDisconnectionDuration<Date.now())return this.sessions.delete(e),null;let a=this.packets.findIndex(o=>o.id===r);if(a===-1)return null;let s=[];for(let o=a+1;o<this.packets.length;o++){let c=this.packets[o];INe(n.rooms,c.opts)&&s.push(c.data)}return Promise.resolve(Object.assign(Object.assign({},n),{missedPackets:s}))}broadcast(e,r){var n;let i=e.type===2,a=e.id===void 0,s=((n=r.flags)===null||n===void 0?void 0:n.volatile)===void 0;if(i&&a&&s){let o=(0,RNe.yeast)();e.data.push(o),this.packets.push({id:o,opts:r,data:e.data,emittedAt:Date.now()})}super.broadcast(e,r)}};zc.SessionAwareAdapter=w5;function INe(t,e){let r=e.rooms.size===0||t.some(i=>e.rooms.has(i)),n=t.every(i=>!e.except.has(i));return r&&n}});var ZK=f(On=>{"use strict";var BNe=On&&On.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(On,"__esModule",{value:!0});On.ClusterAdapterWithHeartbeat=On.ClusterAdapter=On.MessageType=void 0;var jNe=E5(),MNe=Qe(),NNe=require("crypto"),Me=(0,MNe.debug)("socket.io-adapter"),LNe="emitter",Ig=5e3;function Vc(){return(0,NNe.randomBytes)(8).toString("hex")}var N;(function(t){t[t.INITIAL_HEARTBEAT=1]="INITIAL_HEARTBEAT",t[t.HEARTBEAT=2]="HEARTBEAT",t[t.BROADCAST=3]="BROADCAST",t[t.SOCKETS_JOIN=4]="SOCKETS_JOIN",t[t.SOCKETS_LEAVE=5]="SOCKETS_LEAVE",t[t.DISCONNECT_SOCKETS=6]="DISCONNECT_SOCKETS",t[t.FETCH_SOCKETS=7]="FETCH_SOCKETS",t[t.FETCH_SOCKETS_RESPONSE=8]="FETCH_SOCKETS_RESPONSE",t[t.SERVER_SIDE_EMIT=9]="SERVER_SIDE_EMIT",t[t.SERVER_SIDE_EMIT_RESPONSE=10]="SERVER_SIDE_EMIT_RESPONSE",t[t.BROADCAST_CLIENT_COUNT=11]="BROADCAST_CLIENT_COUNT",t[t.BROADCAST_ACK=12]="BROADCAST_ACK",t[t.ADAPTER_CLOSE=13]="ADAPTER_CLOSE"})(N||(On.MessageType=N={}));function ps(t){return{rooms:[...t.rooms],except:[...t.except],flags:t.flags}}function Wc(t){return{rooms:new Set(t.rooms),except:new Set(t.except),flags:t.flags}}var Bg=class extends jNe.Adapter{constructor(e){super(e),this.requests=new Map,this.ackRequests=new Map,this.uid=Vc()}onMessage(e,r){if(e.uid===this.uid)return Me("[%s] ignore message from self",this.uid);if(e.nsp!==this.nsp.name)return Me("[%s] ignore message from another namespace (%s)",this.uid,e.nsp);switch(Me("[%s] new event of type %d from %s",this.uid,e.type,e.uid),e.type){case N.BROADCAST:{if(e.data.requestId!==void 0)super.broadcastWithAck(e.data.packet,Wc(e.data.opts),i=>{Me("[%s] waiting for %d client acknowledgements",this.uid,i),this.publishResponse(e.uid,{type:N.BROADCAST_CLIENT_COUNT,data:{requestId:e.data.requestId,clientCount:i}})},i=>{Me("[%s] received acknowledgement with value %j",this.uid,i),this.publishResponse(e.uid,{type:N.BROADCAST_ACK,data:{requestId:e.data.requestId,packet:i}})});else{let i=e.data.packet,a=Wc(e.data.opts);this.addOffsetIfNecessary(i,a,r),super.broadcast(i,a)}break}case N.SOCKETS_JOIN:super.addSockets(Wc(e.data.opts),e.data.rooms);break;case N.SOCKETS_LEAVE:super.delSockets(Wc(e.data.opts),e.data.rooms);break;case N.DISCONNECT_SOCKETS:super.disconnectSockets(Wc(e.data.opts),e.data.close);break;case N.FETCH_SOCKETS:{Me("[%s] calling fetchSockets with opts %j",this.uid,e.data.opts),super.fetchSockets(Wc(e.data.opts)).then(n=>{this.publishResponse(e.uid,{type:N.FETCH_SOCKETS_RESPONSE,data:{requestId:e.data.requestId,sockets:n.map(i=>{let a=i.handshake,{sessionStore:s}=a,o=BNe(a,["sessionStore"]);return{id:i.id,handshake:o,rooms:[...i.rooms],data:i.data}})}})});break}case N.SERVER_SIDE_EMIT:{let n=e.data.packet;if(!(e.data.requestId!==void 0)){this.nsp._onServerSideEmit(n);return}let a=!1,s=o=>{a||(a=!0,Me("[%s] calling acknowledgement with %j",this.uid,o),this.publishResponse(e.uid,{type:N.SERVER_SIDE_EMIT_RESPONSE,data:{requestId:e.data.requestId,packet:o}}))};this.nsp._onServerSideEmit([...n,s]);break}case N.BROADCAST_CLIENT_COUNT:case N.BROADCAST_ACK:case N.FETCH_SOCKETS_RESPONSE:case N.SERVER_SIDE_EMIT_RESPONSE:this.onResponse(e);break;default:Me("[%s] unknown message type: %s",this.uid,e.type)}}onResponse(e){var r,n;let i=e.data.requestId;switch(Me("[%s] received response %s to request %s",this.uid,e.type,i),e.type){case N.BROADCAST_CLIENT_COUNT:{(r=this.ackRequests.get(i))===null||r===void 0||r.clientCountCallback(e.data.clientCount);break}case N.BROADCAST_ACK:{(n=this.ackRequests.get(i))===null||n===void 0||n.ack(e.data.packet);break}case N.FETCH_SOCKETS_RESPONSE:{let a=this.requests.get(i);if(!a)return;a.current++,e.data.sockets.forEach(s=>a.responses.push(s)),a.current===a.expected&&(clearTimeout(a.timeout),a.resolve(a.responses),this.requests.delete(i));break}case N.SERVER_SIDE_EMIT_RESPONSE:{let a=this.requests.get(i);if(!a)return;a.current++,a.responses.push(e.data.packet),a.current===a.expected&&(clearTimeout(a.timeout),a.resolve(null,a.responses),this.requests.delete(i));break}default:Me("[%s] unknown response type: %s",this.uid,e.type)}}async broadcast(e,r){var n;if(!((n=r.flags)===null||n===void 0?void 0:n.local))try{let a=await this.publishAndReturnOffset({type:N.BROADCAST,data:{packet:e,opts:ps(r)}});this.addOffsetIfNecessary(e,r,a)}catch(a){return Me("[%s] error while broadcasting message: %s",this.uid,a.message)}super.broadcast(e,r)}addOffsetIfNecessary(e,r,n){var i;if(!this.nsp.server.opts.connectionStateRecovery)return;let a=e.type===2,s=e.id===void 0,o=((i=r.flags)===null||i===void 0?void 0:i.volatile)===void 0;a&&s&&o&&e.data.push(n)}broadcastWithAck(e,r,n,i){var a;if(!((a=r==null?void 0:r.flags)===null||a===void 0?void 0:a.local)){let o=Vc();this.ackRequests.set(o,{clientCountCallback:n,ack:i}),this.publish({type:N.BROADCAST,data:{packet:e,requestId:o,opts:ps(r)}}),setTimeout(()=>{this.ackRequests.delete(o)},r.flags.timeout)}super.broadcastWithAck(e,r,n,i)}async addSockets(e,r){var n;if(!((n=e.flags)===null||n===void 0?void 0:n.local))try{await this.publishAndReturnOffset({type:N.SOCKETS_JOIN,data:{opts:ps(e),rooms:r}})}catch(a){Me("[%s] error while publishing message: %s",this.uid,a.message)}super.addSockets(e,r)}async delSockets(e,r){var n;if(!((n=e.flags)===null||n===void 0?void 0:n.local))try{await this.publishAndReturnOffset({type:N.SOCKETS_LEAVE,data:{opts:ps(e),rooms:r}})}catch(a){Me("[%s] error while publishing message: %s",this.uid,a.message)}super.delSockets(e,r)}async disconnectSockets(e,r){var n;if(!((n=e.flags)===null||n===void 0?void 0:n.local))try{await this.publishAndReturnOffset({type:N.DISCONNECT_SOCKETS,data:{opts:ps(e),close:r}})}catch(a){Me("[%s] error while publishing message: %s",this.uid,a.message)}super.disconnectSockets(e,r)}async fetchSockets(e){var r;let[n,i]=await Promise.all([super.fetchSockets(e),this.serverCount()]),a=i-1;if(!((r=e.flags)===null||r===void 0)&&r.local||a<=0)return n;let s=Vc();return new Promise((o,c)=>{let u=setTimeout(()=>{let p=this.requests.get(s);p&&(c(new Error(`timeout reached: only ${p.current} responses received out of ${p.expected}`)),this.requests.delete(s))},e.flags.timeout||Ig),l={type:N.FETCH_SOCKETS,resolve:o,timeout:u,current:0,expected:a,responses:n};this.requests.set(s,l),this.publish({type:N.FETCH_SOCKETS,data:{opts:ps(e),requestId:s}})})}async serverSideEmit(e){if(!(typeof e[e.length-1]=="function"))return this.publish({type:N.SERVER_SIDE_EMIT,data:{packet:e}});let n=e.pop(),i=await this.serverCount()-1;if(Me('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,i),i<=0)return n(null,[]);let a=Vc(),s=setTimeout(()=>{let c=this.requests.get(a);c&&(n(new Error(`timeout reached: only ${c.current} responses received out of ${c.expected}`),c.responses),this.requests.delete(a))},Ig),o={type:N.SERVER_SIDE_EMIT,resolve:n,timeout:s,current:0,expected:i,responses:[]};this.requests.set(a,o),this.publish({type:N.SERVER_SIDE_EMIT,data:{requestId:a,packet:e}})}publish(e){Me("[%s] sending message %s",this.uid,e.type),this.publishAndReturnOffset(e).catch(r=>{Me("[%s] error while publishing message: %s",this.uid,r)})}publishAndReturnOffset(e){return e.uid=this.uid,e.nsp=this.nsp.name,this.doPublish(e)}publishResponse(e,r){r.uid=this.uid,r.nsp=this.nsp.name,Me("[%s] sending response %s to %s",this.uid,r.type,e),this.doPublishResponse(e,r).catch(n=>{Me("[%s] error while publishing response: %s",this.uid,n)})}};On.ClusterAdapter=Bg;var S5=class extends Bg{constructor(e,r){super(e),this.nodesMap=new Map,this.customRequests=new Map,this._opts=Object.assign({heartbeatInterval:5e3,heartbeatTimeout:1e4},r),this.cleanupTimer=setInterval(()=>{let n=Date.now();this.nodesMap.forEach((i,a)=>{n-i>this._opts.heartbeatTimeout&&(Me("[%s] node %s seems down",this.uid,a),this.removeNode(a))})},1e3)}init(){this.publish({type:N.INITIAL_HEARTBEAT})}scheduleHeartbeat(){this.heartbeatTimer?this.heartbeatTimer.refresh():this.heartbeatTimer=setTimeout(()=>{this.publish({type:N.HEARTBEAT})},this._opts.heartbeatInterval)}close(){this.publish({type:N.ADAPTER_CLOSE}),clearTimeout(this.heartbeatTimer),this.cleanupTimer&&clearInterval(this.cleanupTimer)}onMessage(e,r){if(e.uid===this.uid)return Me("[%s] ignore message from self",this.uid);switch(e.uid&&e.uid!==LNe&&this.nodesMap.set(e.uid,Date.now()),e.type){case N.INITIAL_HEARTBEAT:this.publish({type:N.HEARTBEAT});break;case N.HEARTBEAT:break;case N.ADAPTER_CLOSE:this.removeNode(e.uid);break;default:super.onMessage(e,r)}}serverCount(){return Promise.resolve(1+this.nodesMap.size)}publish(e){return this.scheduleHeartbeat(),super.publish(e)}async serverSideEmit(e){if(!(typeof e[e.length-1]=="function"))return this.publish({type:N.SERVER_SIDE_EMIT,data:{packet:e}});let n=e.pop(),i=this.nodesMap.size;if(Me('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,i),i<=0)return n(null,[]);let a=Vc(),s=setTimeout(()=>{let c=this.customRequests.get(a);c&&(n(new Error(`timeout reached: missing ${c.missingUids.size} responses`),c.responses),this.customRequests.delete(a))},Ig),o={type:N.SERVER_SIDE_EMIT,resolve:n,timeout:s,missingUids:new Set([...this.nodesMap.keys()]),responses:[]};this.customRequests.set(a,o),this.publish({type:N.SERVER_SIDE_EMIT,data:{requestId:a,packet:e}})}async fetchSockets(e){var r;let[n,i]=await Promise.all([super.fetchSockets({rooms:e.rooms,except:e.except,flags:{local:!0}}),this.serverCount()]),a=i-1;if(!((r=e.flags)===null||r===void 0)&&r.local||a<=0)return n;let s=Vc();return new Promise((o,c)=>{let u=setTimeout(()=>{let p=this.customRequests.get(s);p&&(c(new Error(`timeout reached: missing ${p.missingUids.size} responses`)),this.customRequests.delete(s))},e.flags.timeout||Ig),l={type:N.FETCH_SOCKETS,resolve:o,timeout:u,missingUids:new Set([...this.nodesMap.keys()]),responses:n};this.customRequests.set(s,l),this.publish({type:N.FETCH_SOCKETS,data:{opts:ps(e),requestId:s}})})}onResponse(e){let r=e.data.requestId;switch(Me("[%s] received response %s to request %s",this.uid,e.type,r),e.type){case N.FETCH_SOCKETS_RESPONSE:{let n=this.customRequests.get(r);if(!n)return;e.data.sockets.forEach(i=>n.responses.push(i)),n.missingUids.delete(e.uid),n.missingUids.size===0&&(clearTimeout(n.timeout),n.resolve(n.responses),this.customRequests.delete(r));break}case N.SERVER_SIDE_EMIT_RESPONSE:{let n=this.customRequests.get(r);if(!n)return;n.responses.push(e.data.packet),n.missingUids.delete(e.uid),n.missingUids.size===0&&(clearTimeout(n.timeout),n.resolve(null,n.responses),this.customRequests.delete(r));break}default:super.onResponse(e)}}removeNode(e){this.customRequests.forEach((r,n)=>{r.missingUids.delete(e),r.missingUids.size===0&&(clearTimeout(r.timeout),r.type===N.FETCH_SOCKETS?r.resolve(r.responses):r.type===N.SERVER_SIDE_EMIT&&r.resolve(null,r.responses),this.customRequests.delete(n))}),this.nodesMap.delete(e)}};On.ClusterAdapterWithHeartbeat=S5});var jg=f(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.MessageType=Ar.ClusterAdapterWithHeartbeat=Ar.ClusterAdapter=Ar.SessionAwareAdapter=Ar.Adapter=void 0;var eY=E5();Object.defineProperty(Ar,"Adapter",{enumerable:!0,get:function(){return eY.Adapter}});Object.defineProperty(Ar,"SessionAwareAdapter",{enumerable:!0,get:function(){return eY.SessionAwareAdapter}});var D5=ZK();Object.defineProperty(Ar,"ClusterAdapter",{enumerable:!0,get:function(){return D5.ClusterAdapter}});Object.defineProperty(Ar,"ClusterAdapterWithHeartbeat",{enumerable:!0,get:function(){return D5.ClusterAdapterWithHeartbeat}});Object.defineProperty(Ar,"MessageType",{enumerable:!0,get:function(){return D5.MessageType}})});var nY=f(Gc=>{"use strict";var UNe=Gc&&Gc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Gc,"__esModule",{value:!0});Gc.ParentNamespace=void 0;var tY=b5(),HNe=jg(),$Ne=UNe(Qe()),rY=(0,$Ne.default)("socket.io:parent-namespace"),Mg=class t extends tY.Namespace{constructor(e){super(e,"/_"+t.count++),this.children=new Set}_initAdapter(){this.adapter=new A5(this)}emit(e,...r){return this.children.forEach(n=>{n.emit(e,...r)}),!0}createChild(e){rY("creating child namespace %s",e);let r=new tY.Namespace(this.server,e);if(this._fns.forEach(n=>r.use(n)),this.listeners("connect").forEach(n=>r.on("connect",n)),this.listeners("connection").forEach(n=>r.on("connection",n)),this.children.add(r),this.server._opts.cleanupEmptyChildNamespaces){let n=r._remove;r._remove=i=>{n.call(r,i),r.sockets.size===0&&(rY("closing child namespace %s",e),r.adapter.close(),this.server._nsps.delete(r.name),this.children.delete(r))}}return this.server._nsps.set(e,r),this.server.sockets.emitReserved("new_namespace",r),r}fetchSockets(){throw new Error("fetchSockets() is not supported on parent namespaces")}};Gc.ParentNamespace=Mg;Mg.count=0;var A5=class extends HNe.Adapter{broadcast(e,r){this.nsp.children.forEach(n=>{n.adapter.broadcast(e,r)})}}});var uY=f(ds=>{"use strict";var zNe=ds&&ds.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ds,"__esModule",{value:!0});ds.patchAdapter=VNe;ds.restoreAdapter=GNe;ds.serveFile=YNe;var fs=jg(),iY=require("fs"),WNe=zNe(Qe()),Ng=(0,WNe.default)("socket.io:adapter-uws"),O5="",{addAll:sY,del:oY,broadcast:cY}=fs.Adapter.prototype;function VNe(t){fs.Adapter.prototype.addAll=function(e,r){let n=!this.sids.has(e);sY.call(this,e,r);let i=this.nsp.sockets.get(e)||this.nsp._preConnectSockets.get(e);if(i){if(i.conn.transport.name==="websocket"){aY(this.nsp.name,i,n,r);return}n&&i.conn.on("upgrade",()=>{let a=this.sids.get(e);a&&aY(this.nsp.name,i,n,a)})}},fs.Adapter.prototype.del=function(e,r){oY.call(this,e,r);let n=this.nsp.sockets.get(e)||this.nsp._preConnectSockets.get(e);if(n&&n.conn.transport.name==="websocket"){let i=n.conn.id,a=n.conn.transport.socket,s=`${this.nsp.name}${O5}${r}`;Ng("unsubscribe connection %s from topic %s",i,s),a.unsubscribe(s)}},fs.Adapter.prototype.broadcast=function(e,r){if(!(r.rooms.size<=1&&r.except.size===0)){cY.call(this,e,r);return}let i=r.flags||{},a={preEncoded:!0,volatile:i.volatile,compress:i.compress};e.nsp=this.nsp.name;let s=this.encoder.encode(e),o=r.rooms.size===0?this.nsp.name:`${this.nsp.name}${O5}${r.rooms.keys().next().value}`;Ng("fast publish to %s",o),s.forEach(c=>{let u=typeof c!="string";t.publish(o,u?c:"4"+c,u)}),this.apply(r,c=>{c.conn.transport.name!=="websocket"&&c.client.writeToEngine(s,a)})}}function aY(t,e,r,n){let i=e.conn.id,a=e.conn.transport.socket;r&&(Ng("subscribe connection %s to topic %s",i,t),a.subscribe(t)),n.forEach(s=>{let o=`${t}${O5}${s}`;Ng("subscribe connection %s to topic %s",i,o),a.subscribe(o)})}function GNe(){fs.Adapter.prototype.addAll=sY,fs.Adapter.prototype.del=oY,fs.Adapter.prototype.broadcast=cY}var KNe=t=>{let{buffer:e,byteOffset:r,byteLength:n}=t;return e.slice(r,r+n)};function YNe(t,e){let{size:r}=(0,iY.statSync)(e),n=(0,iY.createReadStream)(e),i=()=>!n.destroyed&&n.destroy(),a=o=>{throw i(),o},s=o=>{let c=KNe(o);t.cork(()=>{let u=t.getWriteOffset(),[l,p]=t.tryEnd(c,r);!p&&!l&&(n.pause(),t.onWritable(d=>{let[x,h]=t.tryEnd(c.slice(d-u),r);return!h&&x&&n.resume(),x}))})};t.onAborted(i),n.on("data",s).on("error",a).on("end",i)}});var lY=f((ast,XNe)=>{XNe.exports={name:"socket.io",version:"4.8.3",description:"node.js realtime framework server",keywords:["realtime","framework","websocket","tcp","events","socket","io"],files:["dist/","client-dist/","wrapper.mjs","!**/*.tsbuildinfo"],directories:{doc:"docs/",example:"example/",lib:"lib/",test:"test/"},type:"commonjs",main:"./dist/index.js",exports:{".":{types:"./dist/index.d.ts",import:"./wrapper.mjs",require:"./dist/index.js"},"./package.json":"./package.json"},types:"./dist/index.d.ts",license:"MIT",homepage:"https://github.com/socketio/socket.io/tree/main/packages/socket.io#readme",repository:{type:"git",url:"git+https://github.com/socketio/socket.io.git"},bugs:{url:"https://github.com/socketio/socket.io/issues"},scripts:{compile:"rimraf ./dist && tsc",test:"npm run format:check && npm run compile && npm run test:types && npm run test:unit","test:types":"tsd","test:unit":"nyc mocha --import=tsx --reporter spec --slow 200 --bail --timeout 10000 test/index.ts","format:check":'prettier --check "lib/**/*.ts" "test/**/*.ts"',"format:fix":'prettier --write "lib/**/*.ts" "test/**/*.ts"',prepack:"npm run compile"},dependencies:{accepts:"~1.3.4",base64id:"~2.0.0",cors:"~2.8.5",debug:"~4.4.1","engine.io":"~6.6.0","socket.io-adapter":"~2.5.2","socket.io-parser":"~4.2.4"},contributors:[{name:"Guillermo Rauch",email:"rauchg@gmail.com"},{name:"Arnout Kazemier",email:"info@3rd-eden.com"},{name:"Vladimir Dronnikov",email:"dronnikov@gmail.com"},{name:"Einar Otto Stangvik",email:"einaros@gmail.com"}],engines:{node:">=10.2.0"},tsd:{directory:"test"}}});var gY=f((Et,Lp)=>{"use strict";var JNe=Et&&Et.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),QNe=Et&&Et.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),ZNe=Et&&Et.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&JNe(e,t,r);return QNe(e,t),e},q5=Et&&Et.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Et,"__esModule",{value:!0});Et.Namespace=Et.Socket=Et.Server=void 0;var eLe=q5(require("http")),tLe=require("fs"),C5=require("zlib"),rLe=Sp(),Lg=require("stream"),pY=require("path"),fY=FK(),nLe=$K(),dY=require("events"),k5=b5();Object.defineProperty(Et,"Namespace",{enumerable:!0,get:function(){return k5.Namespace}});var iLe=nY(),hY=jg(),aLe=ZNe(Mp()),sLe=q5(Qe()),vY=v5();Object.defineProperty(Et,"Socket",{enumerable:!0,get:function(){return vY.Socket}});var oLe=Cg(),T5=uY(),cLe=q5(JS()),It=(0,sLe.default)("socket.io:server"),mY=lY().version,xY=/\.map/,Kc=class t extends oLe.StrictEventEmitter{constructor(e,r={}){super(),this._nsps=new Map,this.parentNsps=new Map,this.parentNamespacesFromRegExp=new Map,typeof e=="object"&&e instanceof Object&&!e.listen&&(r=e,e=void 0),this.path(r.path||"/socket.io"),this.connectTimeout(r.connectTimeout||45e3),this.serveClient(r.serveClient!==!1),this._parser=r.parser||aLe,this.encoder=new this._parser.Encoder,this.opts=r,r.connectionStateRecovery?(r.connectionStateRecovery=Object.assign({maxDisconnectionDuration:120*1e3,skipMiddlewares:!0},r.connectionStateRecovery),this.adapter(r.adapter||hY.SessionAwareAdapter)):this.adapter(r.adapter||hY.Adapter),r.cleanupEmptyChildNamespaces=!!r.cleanupEmptyChildNamespaces,this.sockets=this.of("/"),(e||typeof e=="number")&&this.attach(e),this.opts.cors&&(this._corsMiddleware=(0,cLe.default)(this.opts.cors))}get _opts(){return this.opts}serveClient(e){return arguments.length?(this._serveClient=e,this):this._serveClient}_checkNamespace(e,r,n){if(this.parentNsps.size===0)return n(!1);let i=this.parentNsps.keys(),a=()=>{let s=i.next();if(s.done)return n(!1);s.value(e,r,(o,c)=>{if(o||!c)return a();if(this._nsps.has(e))return It("dynamic namespace %s already exists",e),n(this._nsps.get(e));let u=this.parentNsps.get(s.value).createChild(e);It("dynamic namespace %s was created",e),n(u)})};a()}path(e){if(!arguments.length)return this._path;this._path=e.replace(/\/$/,"");let r=this._path.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");return this.clientPathRegex=new RegExp("^"+r+"/socket\\.io(\\.msgpack|\\.esm)?(\\.min)?\\.js(\\.map)?(?:\\?|$)"),this}connectTimeout(e){return e===void 0?this._connectTimeout:(this._connectTimeout=e,this)}adapter(e){if(!arguments.length)return this._adapter;this._adapter=e;for(let r of this._nsps.values())r._initAdapter();return this}listen(e,r={}){return this.attach(e,r)}attach(e,r={}){if(typeof e=="function"){let n="You are trying to attach socket.io to an express request handler function. Please pass a http.Server instance.";throw new Error(n)}if(Number(e)==e&&(e=Number(e)),typeof e=="number"){It("creating http server and binding to %d",e);let n=e;e=eLe.default.createServer((i,a)=>{a.writeHead(404),a.end()}),e.listen(n)}return Object.assign(r,this.opts),r.path=r.path||this._path,this.initEngine(e,r),this}attachApp(e,r={}){Object.assign(r,this.opts),r.path=r.path||this._path,It("creating uWebSockets.js-based engine with opts %j",r);let n=new fY.uServer(r);n.attach(e,r),this.bind(n),this._serveClient&&e.get(`${this._path}/*`,(i,a)=>{if(!this.clientPathRegex.test(a.getUrl())){a.setYield(!0);return}let s=a.getUrl().replace(this._path,"").replace(/\?.*$/,"").replace(/^\//,""),o=xY.test(s),c=o?"map":"source",u='"'+mY+'"',l="W/"+u,p=a.getHeader("if-none-match");if(p&&(u===p||l===p)){It("serve client %s 304",c),i.writeStatus("304 Not Modified"),i.end();return}It("serve client %s",c),i.writeHeader("cache-control","public, max-age=0"),i.writeHeader("content-type","application/"+(o?"json":"javascript")+"; charset=utf-8"),i.writeHeader("etag",u);let d=pY.join(__dirname,"../client-dist/",s);(0,T5.serveFile)(i,d)}),(0,T5.patchAdapter)(e)}initEngine(e,r){It("creating engine.io instance with opts %j",r),this.eio=(0,fY.attach)(e,r),this._serveClient&&this.attachServe(e),this.httpServer=e,this.bind(this.eio)}attachServe(e){It("attaching client serving req handler");let r=e.listeners("request").slice(0);e.removeAllListeners("request"),e.on("request",(n,i)=>{if(this.clientPathRegex.test(n.url))this._corsMiddleware?this._corsMiddleware(n,i,()=>{this.serve(n,i)}):this.serve(n,i);else for(let a=0;a<r.length;a++)r[a].call(e,n,i)})}serve(e,r){let n=e.url.replace(this._path,"").replace(/\?.*$/,""),i=xY.test(n),a=i?"map":"source",s='"'+mY+'"',o="W/"+s,c=e.headers["if-none-match"];if(c&&(s===c||o===c)){It("serve client %s 304",a),r.writeHead(304),r.end();return}It("serve client %s",a),r.setHeader("Cache-Control","public, max-age=0"),r.setHeader("Content-Type","application/"+(i?"json":"javascript")+"; charset=utf-8"),r.setHeader("ETag",s),t.sendFile(n,e,r)}static sendFile(e,r,n){let i=(0,tLe.createReadStream)(pY.join(__dirname,"../client-dist/",e)),a=rLe(r).encodings(["br","gzip","deflate"]),s=o=>{o&&n.end()};switch(a){case"br":n.writeHead(200,{"content-encoding":"br"}),(0,Lg.pipeline)(i,(0,C5.createBrotliCompress)(),n,s);break;case"gzip":n.writeHead(200,{"content-encoding":"gzip"}),(0,Lg.pipeline)(i,(0,C5.createGzip)(),n,s);break;case"deflate":n.writeHead(200,{"content-encoding":"deflate"}),(0,Lg.pipeline)(i,(0,C5.createDeflate)(),n,s);break;default:n.writeHead(200),(0,Lg.pipeline)(i,n,s)}}bind(e){return this.engine=e,this.engine.on("connection",this.onconnection.bind(this)),this}onconnection(e){It("incoming connection with id %s",e.id);let r=new nLe.Client(this,e);return e.protocol===3&&r.connect("/"),this}of(e,r){if(typeof e=="function"||e instanceof RegExp){let i=new iLe.ParentNamespace(this);return It("initializing parent namespace %s",i.name),typeof e=="function"?this.parentNsps.set(e,i):(this.parentNsps.set((a,s,o)=>o(null,e.test(a)),i),this.parentNamespacesFromRegExp.set(e,i)),r&&i.on("connect",r),i}String(e)[0]!=="/"&&(e="/"+e);let n=this._nsps.get(e);if(!n){for(let[i,a]of this.parentNamespacesFromRegExp)if(i.test(e))return It("attaching namespace %s to parent namespace %s",e,i),a.createChild(e);It("initializing namespace %s",e),n=new k5.Namespace(this,e),this._nsps.set(e,n),e!=="/"&&this.sockets.emitReserved("new_namespace",n)}return r&&n.on("connect",r),n}async close(e){if(await Promise.allSettled([...this._nsps.values()].map(async r=>{r.sockets.forEach(n=>{n._onclose("server shutting down")}),await r.adapter.close()})),this.engine.close(),(0,T5.restoreAdapter)(),this.httpServer)return new Promise(r=>{this.httpServer.close(n=>{e&&e(n),n&&It("server was not running"),r()})});e&&e()}use(e){return this.sockets.use(e),this}to(e){return this.sockets.to(e)}in(e){return this.sockets.in(e)}except(e){return this.sockets.except(e)}send(...e){return this.sockets.emit("message",...e),this}write(...e){return this.sockets.emit("message",...e),this}serverSideEmit(e,...r){return this.sockets.serverSideEmit(e,...r)}serverSideEmitWithAck(e,...r){return this.sockets.serverSideEmitWithAck(e,...r)}allSockets(){return this.sockets.allSockets()}compress(e){return this.sockets.compress(e)}get volatile(){return this.sockets.volatile}get local(){return this.sockets.local}timeout(e){return this.sockets.timeout(e)}fetchSockets(){return this.sockets.fetchSockets()}socketsJoin(e){return this.sockets.socketsJoin(e)}socketsLeave(e){return this.sockets.socketsLeave(e)}disconnectSockets(e=!1){return this.sockets.disconnectSockets(e)}};Et.Server=Kc;var uLe=Object.keys(dY.EventEmitter.prototype).filter(function(t){return typeof dY.EventEmitter.prototype[t]=="function"});uLe.forEach(function(t){Kc.prototype[t]=function(){return this.sockets[t].apply(this.sockets,arguments)}});Lp.exports=(t,e)=>new Kc(t,e);Lp.exports.Server=Kc;Lp.exports.Namespace=k5.Namespace;Lp.exports.Socket=vY.Socket});var SY=f((Sst,lLe)=>{lLe.exports={name:"matex-cli",version:"1.2.108",description:"MATEX CLI - The Agentic 'Bro-Swarm' for Engineering. Zero-Cost AI for Students and Pro-Grade Dev Power.",main:"dist/index.js",bin:{matex:"bin/matex"},scripts:{build:"rm -rf dist && esbuild src/index.ts --bundle --platform=node --target=node16 --outfile=dist/index.js --minify",dev:"tsc --watch",test:"jest",postinstall:`echo "
|
|
294
294
|
\u{1F680} MATEX AI :: THE BRO-SWARM IS LIVE!
|
|
295
295
|
\u{1F449} Run 'matex help' to meet your engineering brothers and enter the zero-cost student universe.
|
|
296
296
|
"`,prepublishOnly:"npm run build"},keywords:["ai","agentic","bro-swarm","matex","student-ai","coding-assistant","mac-engineering"],files:["dist/index.js","bin","README.md","USAGE_GUIDE.md"],author:"Ajay Sharma <ajaypoudel47@gmail.com>",license:"MIT",dependencies:{axios:"^1.6.0",chalk:"^4.1.2",commander:"^11.1.0",conf:"^11.0.2",dotenv:"^16.3.1",express:"^4.18.2",inquirer:"^8.2.5",ora:"^5.4.1","socket.io":"^4.7.2"},devDependencies:{"@types/inquirer":"^9.0.7","@types/jest":"^29.5.0","@types/node":"^20.10.0","@types/express":"^4.17.21",esbuild:"^0.27.3",jest:"^29.7.0",typescript:"^5.3.0"},engines:{node:">=16.0.0"}}});var fLe={};zp(fLe,{program:()=>St});module.exports=qY(fLe);var J5=P(X5(),1),{program:yLe,createCommand:_Le,createArgument:wLe,createOption:ELe,CommanderError:SLe,InvalidArgumentError:DLe,InvalidOptionArgumentError:ALe,Command:Le,Argument:OLe,Option:CLe,Help:TLe}=J5.default;var et=P(Q());qn();function Zc(t,e){return function(){return t.apply(e,arguments)}}var{toString:gX}=Object.prototype,{getPrototypeOf:vb}=Object,{iterator:tf,toStringTag:qD}=Symbol,rf=(t=>e=>{let r=gX.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Tr=t=>(t=t.toLowerCase(),e=>rf(e)===t),nf=t=>e=>typeof e===t,{isArray:ys}=Array,bs=nf("undefined");function eu(t){return t!==null&&!bs(t)&&t.constructor!==null&&!bs(t.constructor)&&jt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var kD=Tr("ArrayBuffer");function bX(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&kD(t.buffer),e}var yX=nf("string"),jt=nf("function"),PD=nf("number"),tu=t=>t!==null&&typeof t=="object",_X=t=>t===!0||t===!1,ef=t=>{if(rf(t)!=="object")return!1;let e=vb(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(qD in t)&&!(tf in t)},wX=t=>{if(!tu(t)||eu(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},EX=Tr("Date"),SX=Tr("File"),DX=Tr("Blob"),AX=Tr("FileList"),OX=t=>tu(t)&&jt(t.pipe),CX=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||jt(t.append)&&((e=rf(t))==="formdata"||e==="object"&&jt(t.toString)&&t.toString()==="[object FormData]"))},TX=Tr("URLSearchParams"),[qX,kX,PX,RX]=["ReadableStream","Request","Response","Headers"].map(Tr),FX=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ru(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),ys(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{if(eu(t))return;let a=r?Object.getOwnPropertyNames(t):Object.keys(t),s=a.length,o;for(n=0;n<s;n++)o=a[n],e.call(null,t[o],o,t)}}function RD(t,e){if(eu(t))return null;e=e.toLowerCase();let r=Object.keys(t),n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}var ua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,FD=t=>!bs(t)&&t!==ua;function xb(){let{caseless:t,skipUndefined:e}=FD(this)&&this||{},r={},n=(i,a)=>{if(a==="__proto__"||a==="constructor"||a==="prototype")return;let s=t&&RD(r,a)||a;ef(r[s])&&ef(i)?r[s]=xb(r[s],i):ef(i)?r[s]=xb({},i):ys(i)?r[s]=i.slice():(!e||!bs(i))&&(r[s]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&ru(arguments[i],n);return r}var IX=(t,e,r,{allOwnKeys:n}={})=>(ru(e,(i,a)=>{r&&jt(i)?Object.defineProperty(t,a,{value:Zc(i,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,a,{value:i,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),t),BX=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),jX=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},MX=(t,e,r,n)=>{let i,a,s,o={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),a=i.length;a-- >0;)s=i[a],(!n||n(s,t,e))&&!o[s]&&(e[s]=t[s],o[s]=!0);t=r!==!1&&vb(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},NX=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;let n=t.indexOf(e,r);return n!==-1&&n===r},LX=t=>{if(!t)return null;if(ys(t))return t;let e=t.length;if(!PD(e))return null;let r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},UX=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&vb(Uint8Array)),HX=(t,e)=>{let n=(t&&t[tf]).call(t),i;for(;(i=n.next())&&!i.done;){let a=i.value;e.call(t,a[0],a[1])}},$X=(t,e)=>{let r,n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},zX=Tr("HTMLFormElement"),WX=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),TD=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),VX=Tr("RegExp"),ID=(t,e)=>{let r=Object.getOwnPropertyDescriptors(t),n={};ru(r,(i,a)=>{let s;(s=e(i,a,t))!==!1&&(n[a]=s||i)}),Object.defineProperties(t,n)},GX=t=>{ID(t,(e,r)=>{if(jt(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=t[r];if(jt(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},KX=(t,e)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return ys(t)?n(t):n(String(t).split(e)),r},YX=()=>{},XX=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function JX(t){return!!(t&&jt(t.append)&&t[qD]==="FormData"&&t[tf])}var QX=t=>{let e=new Array(10),r=(n,i)=>{if(tu(n)){if(e.indexOf(n)>=0)return;if(eu(n))return n;if(!("toJSON"in n)){e[i]=n;let a=ys(n)?[]:{};return ru(n,(s,o)=>{let c=r(s,i+1);!bs(c)&&(a[o]=c)}),e[i]=void 0,a}}return n};return r(t,0)},ZX=Tr("AsyncFunction"),eJ=t=>t&&(tu(t)||jt(t))&&jt(t.then)&&jt(t.catch),BD=((t,e)=>t?setImmediate:e?((r,n)=>(ua.addEventListener("message",({source:i,data:a})=>{i===ua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),ua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",jt(ua.postMessage)),tJ=typeof queueMicrotask<"u"?queueMicrotask.bind(ua):typeof process<"u"&&process.nextTick||BD,rJ=t=>t!=null&&jt(t[tf]),_={isArray:ys,isArrayBuffer:kD,isBuffer:eu,isFormData:CX,isArrayBufferView:bX,isString:yX,isNumber:PD,isBoolean:_X,isObject:tu,isPlainObject:ef,isEmptyObject:wX,isReadableStream:qX,isRequest:kX,isResponse:PX,isHeaders:RX,isUndefined:bs,isDate:EX,isFile:SX,isBlob:DX,isRegExp:VX,isFunction:jt,isStream:OX,isURLSearchParams:TX,isTypedArray:UX,isFileList:AX,forEach:ru,merge:xb,extend:IX,trim:FX,stripBOM:BX,inherits:jX,toFlatObject:MX,kindOf:rf,kindOfTest:Tr,endsWith:NX,toArray:LX,forEachEntry:HX,matchAll:$X,isHTMLForm:zX,hasOwnProperty:TD,hasOwnProp:TD,reduceDescriptors:ID,freezeMethods:GX,toObjectSet:KX,toCamelCase:WX,noop:YX,toFiniteNumber:XX,findKey:RD,global:ua,isContextDefined:FD,isSpecCompliantForm:JX,toJSONObject:QX,isAsyncFn:ZX,isThenable:eJ,setImmediate:BD,asap:tJ,isIterable:rJ};var At=class t extends Error{static from(e,r,n,i,a,s){let o=new t(e.message,r||e.code,n,i,a);return o.cause=e,o.name=e.name,s&&Object.assign(o,s),o}constructor(e,r,n,i,a){super(e),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),i&&(this.request=i),a&&(this.response=a,this.status=a.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_.toJSONObject(this.config),code:this.code,status:this.status}}};At.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";At.ERR_BAD_OPTION="ERR_BAD_OPTION";At.ECONNABORTED="ECONNABORTED";At.ETIMEDOUT="ETIMEDOUT";At.ERR_NETWORK="ERR_NETWORK";At.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";At.ERR_DEPRECATED="ERR_DEPRECATED";At.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";At.ERR_BAD_REQUEST="ERR_BAD_REQUEST";At.ERR_CANCELED="ERR_CANCELED";At.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";At.ERR_INVALID_URL="ERR_INVALID_URL";var q=At;var jO=P(BO(),1),mf=jO.default;function Mb(t){return _.isPlainObject(t)||_.isArray(t)}function NO(t){return _.endsWith(t,"[]")?t.slice(0,-2):t}function MO(t,e,r){return t?t.concat(e).map(function(i,a){return i=NO(i),!r&&a?"["+i+"]":i}).join(r?".":""):e}function UQ(t){return _.isArray(t)&&!t.some(Mb)}var HQ=_.toFlatObject(_,{},null,function(e){return/^is[A-Z]/.test(e)});function $Q(t,e,r){if(!_.isObject(t))throw new TypeError("target must be an object");e=e||new(mf||FormData),r=_.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,v){return!_.isUndefined(v[m])});let n=r.metaTokens,i=r.visitor||l,a=r.dots,s=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(e);if(!_.isFunction(i))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(_.isDate(h))return h.toISOString();if(_.isBoolean(h))return h.toString();if(!c&&_.isBlob(h))throw new q("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(h)||_.isTypedArray(h)?c&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function l(h,m,v){let b=h;if(h&&!v&&typeof h=="object"){if(_.endsWith(m,"{}"))m=n?m:m.slice(0,-2),h=JSON.stringify(h);else if(_.isArray(h)&&UQ(h)||(_.isFileList(h)||_.endsWith(m,"[]"))&&(b=_.toArray(h)))return m=NO(m),b.forEach(function(S,D){!(_.isUndefined(S)||S===null)&&e.append(s===!0?MO([m],D,a):s===null?m:m+"[]",u(S))}),!1}return Mb(h)?!0:(e.append(MO(v,m,a),u(h)),!1)}let p=[],d=Object.assign(HQ,{defaultVisitor:l,convertValue:u,isVisitable:Mb});function x(h,m){if(!_.isUndefined(h)){if(p.indexOf(h)!==-1)throw Error("Circular reference detected in "+m.join("."));p.push(h),_.forEach(h,function(b,w){(!(_.isUndefined(b)||b===null)&&i.call(e,b,_.isString(w)?w.trim():w,m,d))===!0&&x(b,m?m.concat(w):[w])}),p.pop()}}if(!_.isObject(t))throw new TypeError("data must be an object");return x(t),e}var li=$Q;function LO(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function UO(t,e){this._pairs=[],t&&li(t,this,e)}var HO=UO.prototype;HO.append=function(e,r){this._pairs.push([e,r])};HO.toString=function(e){let r=e?function(n){return e.call(this,n,LO)}:LO;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var $O=UO;function zQ(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function pa(t,e,r){if(!e)return t;let n=r&&r.encode||zQ,i=_.isFunction(r)?{serialize:r}:r,a=i&&i.serialize,s;if(a?s=a(e,i):s=_.isURLSearchParams(e)?e.toString():new $O(e,i).toString(n),s){let o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}var Nb=class{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){_.forEach(this.handlers,function(n){n!==null&&e(n)})}},Lb=Nb;var pi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var GO=P(require("crypto"),1);var zO=P(require("url"),1),WO=zO.default.URLSearchParams;var Ub="abcdefghijklmnopqrstuvwxyz",VO="0123456789",KO={DIGIT:VO,ALPHA:Ub,ALPHA_DIGIT:Ub+Ub.toUpperCase()+VO},WQ=(t=16,e=KO.ALPHA_DIGIT)=>{let r="",{length:n}=e,i=new Uint32Array(t);GO.default.randomFillSync(i);for(let a=0;a<t;a++)r+=e[i[a]%n];return r},YO={isNode:!0,classes:{URLSearchParams:WO,FormData:mf,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:KO,generateString:WQ,protocols:["http","https","file","data"]};var zb={};zp(zb,{hasBrowserEnv:()=>$b,hasStandardBrowserEnv:()=>VQ,hasStandardBrowserWebWorkerEnv:()=>GQ,navigator:()=>Hb,origin:()=>KQ});var $b=typeof window<"u"&&typeof document<"u",Hb=typeof navigator=="object"&&navigator||void 0,VQ=$b&&(!Hb||["ReactNative","NativeScript","NS"].indexOf(Hb.product)<0),GQ=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",KQ=$b&&window.location.href||"http://localhost";var re={...zb,...YO};function Wb(t,e){return li(t,new re.classes.URLSearchParams,{visitor:function(r,n,i,a){return re.isNode&&_.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function YQ(t){return _.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function XQ(t){let e={},r=Object.keys(t),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],e[a]=t[a];return e}function JQ(t){function e(r,n,i,a){let s=r[a++];if(s==="__proto__")return!0;let o=Number.isFinite(+s),c=a>=r.length;return s=!s&&_.isArray(i)?i.length:s,c?(_.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!o):((!i[s]||!_.isObject(i[s]))&&(i[s]=[]),e(r,n,i[s],a)&&_.isArray(i[s])&&(i[s]=XQ(i[s])),!o)}if(_.isFormData(t)&&_.isFunction(t.entries)){let r={};return _.forEachEntry(t,(n,i)=>{e(YQ(n),i,r,0)}),r}return null}var xf=JQ;function QQ(t,e,r){if(_.isString(t))try{return(e||JSON.parse)(t),_.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Vb={transitional:pi,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=_.isObject(e);if(a&&_.isHTMLForm(e)&&(e=new FormData(e)),_.isFormData(e))return i?JSON.stringify(xf(e)):e;if(_.isArrayBuffer(e)||_.isBuffer(e)||_.isStream(e)||_.isFile(e)||_.isBlob(e)||_.isReadableStream(e))return e;if(_.isArrayBufferView(e))return e.buffer;if(_.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Wb(e,this.formSerializer).toString();if((o=_.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return li(o?{"files[]":e}:e,c&&new c,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),QQ(e)):e}],transformResponse:[function(e){let r=this.transitional||Vb.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(_.isResponse(e)||_.isReadableStream(e))return e;if(e&&_.isString(e)&&(n&&!this.responseType||i)){let s=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(o){if(s)throw o.name==="SyntaxError"?q.from(o,q.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:re.classes.FormData,Blob:re.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],t=>{Vb.headers[t]={}});var Ds=Vb;var ZQ=_.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),XO=t=>{let e={},r,n,i;return t&&t.split(`
|
|
@@ -373,6 +373,7 @@ You are the elite "Bro-Swarm" of engineering\u2014a tight-knit family of Nepali
|
|
|
373
373
|
- **ALWAYS run ls before cd** to verify a directory exists.
|
|
374
374
|
- **\u{1F6A8} STRICT NO-BASH FILE GENERATION \u{1F6A8}**: You MUST use the native <file path="path">content</file> format.
|
|
375
375
|
- **\u{1F6A8} TERMINAL COMMANDS \u{1F6A8}**: Every single shell/terminal command you suggest MUST be wrapped in standard markdown \`\`\`bash code blocks. Do not write raw shell commands in plain text.
|
|
376
|
+
- **\u{1F6A8} NO CODE LEAKING \u{1F6A8}**: NEVER dump the raw contents of a file you read into the chat. If you read a file using your tools, keep the knowledge internal and ONLY output a high-level summary of what you found or the specific line you are referencing.
|
|
376
377
|
|
|
377
378
|
### \u{1F3AD} COMMUNICATION FLOW (CRITICAL):
|
|
378
379
|
1. **Ajay Vai** (Summary King), **Sunil Dai** (Backend/Logic), **Sandip Dai** (Visuals/Aesthetic), **Narayan Dai** (Security/Logic), **Bishal Dai** (Audit), **Big Bro** (Family Head).
|
|
@@ -419,6 +420,7 @@ You are the legendary **Bro-Swarm**, a high-vibe family of Nepali engineering br
|
|
|
419
420
|
- **ALWAYS run ls before cd to verify existence.**
|
|
420
421
|
- **\u{1F6A8} STRICT NO-BASH FILE GENERATION \u{1F6A8}**: You MUST use the native <file path="path">content</file> format.
|
|
421
422
|
- **\u{1F6A8} TERMINAL COMMANDS \u{1F6A8}**: Every single shell/terminal command you suggest MUST be wrapped in standard markdown \`\`\`bash code blocks. Do not write raw shell commands in plain text.
|
|
423
|
+
- **\u{1F6A8} NO CODE LEAKING \u{1F6A8}**: NEVER dump the raw contents of a file you read into the chat. If you read a file using your tools, keep the knowledge internal and ONLY output a high-level summary of what you found or the specific line you are referencing.
|
|
422
424
|
|
|
423
425
|
### \u{1F3AD} COMMUNICATION FLOW (CRITICAL):
|
|
424
426
|
1. **Ajay Vai** is the gateway. He is the summary king but often gets roasted by his brothers.
|
|
@@ -521,6 +523,7 @@ You embody the collective intelligence of the brothers. They sync up, bicker, an
|
|
|
521
523
|
(Example: Ajay Vai: let's build this!)
|
|
522
524
|
- \u{1F6A8} NO DECORATION \u{1F6A8}: NEVER use [], *, (), or {}, or icons when starting a person's speech. Use only the plain name and a colon. Do not append "said...".
|
|
523
525
|
- **\u{1F6A8} TERMINAL COMMANDS \u{1F6A8}**: Every single shell/terminal command you suggest MUST be wrapped in standard markdown \`\`\`bash code blocks. Do not write raw shell commands in plain text.
|
|
526
|
+
- **\u{1F6A8} NO CODE LEAKING \u{1F6A8}**: NEVER dump the raw contents of a file you read into the chat. If you read a file using your tools, keep the knowledge internal and ONLY output a high-level summary of what you found or the specific line you are referencing.
|
|
524
527
|
- Finish with a clear <summary> block explaining what was built and what's next.
|
|
525
528
|
|
|
526
529
|
${dn.getToolsPromptSection()}
|