qumra-cli 1.1.59 → 1.1.60
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/build/cli.cjs +1 -1
- package/build/cli.cjs.map +1 -1
- package/package.json +2 -2
package/build/cli.cjs
CHANGED
|
@@ -374,7 +374,7 @@ const XH=y,ez=qH,tz=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),nz=e=>"nu
|
|
|
374
374
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
375
375
|
* MIT Licensed
|
|
376
376
|
*/
|
|
377
|
-
parse:function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");for(var n={},i=t||{},r=e.split(CK),s=i.decode||AK,o=0;o<r.length;o++){var a=r[o],c=a.indexOf("=");if(!(c<0)){var l=a.substr(0,c).trim(),u=a.substr(++c,a.length).trim();'"'==u[0]&&(u=u.slice(1,-1)),null==n[l]&&(n[l]=RK(u,s))}}return n},serialize:function(e,t,n){var i=n||{},r=i.encode||DK;if("function"!=typeof r)throw new TypeError("option encode is invalid");if(!OK.test(e))throw new TypeError("argument name is invalid");var s=r(t);if(s&&!OK.test(s))throw new TypeError("argument val is invalid");var o=e+"="+s;if(null!=i.maxAge){var a=i.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(a)}if(i.domain){if(!OK.test(i.domain))throw new TypeError("option domain is invalid");o+="; Domain="+i.domain}if(i.path){if(!OK.test(i.path))throw new TypeError("option path is invalid");o+="; Path="+i.path}if(i.expires){if("function"!=typeof i.expires.toUTCString)throw new TypeError("option expires is invalid");o+="; Expires="+i.expires.toUTCString()}i.httpOnly&&(o+="; HttpOnly");i.secure&&(o+="; Secure");if(i.sameSite){switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}},AK=decodeURIComponent,DK=encodeURIComponent,CK=/; */,OK=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function RK(e,t){try{return t(e)}catch(t){return e}}var LK,IK,NK,PK,jK,FK,BK={exports:{}},MK={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}},UK={exports:{}},qK={exports:{}};function $K(){if(NK)return qK.exports;NK=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:QF;return"function"==typeof e.addon?qK.exports=e.addon.bind(e):qK.exports=function(){if(IK)return LK;IK=1;var e=s,t=o,n=a,i="function"==typeof __webpack_require__?__non_webpack_require__:QF,r=process.config&&process.config.variables||{},c=!!process.env.PREBUILDS_ONLY,l=process.versions.modules,u=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",p=process.env.npm_config_arch||n.arch(),h=process.env.npm_config_platform||n.platform(),d=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),f=process.env.ARM_VERSION||("arm64"===p?"8":r.arm_version)||"",m=(process.versions.uv||"").split(".")[0];function g(e){return i(g.resolve(e))}function y(t){try{return e.readdirSync(t)}catch(e){return[]}}function v(e,n){var i=y(e).filter(n);return i[0]&&t.join(e,i[0])}function b(e){return/\.node$/.test(e)}function _(e){var t=e.split("-");if(2===t.length){var n=t[0],i=t[1].split("+");if(n&&i.length&&i.every(Boolean))return{name:e,platform:n,architectures:i}}}function w(e,t){return function(n){return null!=n&&n.platform===e&&n.architectures.includes(t)}}function x(e,t){return e.architectures.length-t.architectures.length}function E(e){var t=e.split("."),n={file:e,specificity:0};if("node"===t.pop()){for(var i=0;i<t.length;i++){var r=t[i];if("node"===r||"electron"===r||"node-webkit"===r)n.runtime=r;else if("napi"===r)n.napi=!0;else if("abi"===r.slice(0,3))n.abi=r.slice(3);else if("uv"===r.slice(0,2))n.uv=r.slice(2);else if("armv"===r.slice(0,4))n.armv=r.slice(4);else{if("glibc"!==r&&"musl"!==r)continue;n.libc=r}n.specificity++}return n}}function S(e,t){return function(n){return!(null==n||n.runtime&&n.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(n)||n.abi&&n.abi!==t&&!n.napi||n.uv&&n.uv!==m||n.armv&&n.armv!==f||n.libc&&n.libc!==d)}}function k(e){return function(t,n){return t.runtime!==n.runtime?t.runtime===e?-1:1:t.abi!==n.abi?t.abi?-1:1:t.specificity!==n.specificity?t.specificity>n.specificity?-1:1:0}}return LK=g,g.resolve=g.path=function(e){e=t.resolve(e||".");try{var n=i(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[n+"_PREBUILD"]&&(e=process.env[n+"_PREBUILD"])}catch(e){}if(!c){var r=v(t.join(e,"build/Release"),b);if(r)return r;var s=v(t.join(e,"build/Debug"),b);if(s)return s}var o=T(e);if(o)return o;var a=T(t.dirname(process.execPath));if(a)return a;var g=["platform="+h,"arch="+p,"runtime="+u,"abi="+l,"uv="+m,f?"armv="+f:"","libc="+d,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+g+"\n loaded from: "+e+"\n");function T(e){var n=y(t.join(e,"prebuilds")).map(_).filter(w(h,p)).sort(x)[0];if(n){var i=t.join(e,"prebuilds",n.name),r=y(i).map(E).filter(S(u,l)).sort(k(u))[0];return r?t.join(i,r.file):void 0}}},g.parseTags=E,g.matchTags=S,g.compareTags=k,g.parseTuple=_,g.matchTuple=w,g.compareTuples=x,LK}(),qK.exports}const{EMPTY_BUFFER:HK}=MK,zK=Buffer[Symbol.species];function WK(e,t,n,i,r){for(let s=0;s<r;s++)n[i+s]=e[s]^t[3&s]}function GK(e,t){for(let n=0;n<e.length;n++)e[n]^=t[3&n]}if(BK.exports={concat:function(e,t){if(0===e.length)return HK;if(1===e.length)return e[0];const n=Buffer.allocUnsafe(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];n.set(r,i),i+=r.length}return i<t?new zK(n.buffer,n.byteOffset,i):n},mask:WK,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let n;return t instanceof ArrayBuffer?n=new zK(t):ArrayBuffer.isView(t)?n=new zK(t.buffer,t.byteOffset,t.byteLength):(n=Buffer.from(t),e.readOnly=!1),n},unmask:GK},!process.env.WS_NO_BUFFER_UTIL)try{const e=function(){if(FK)return UK.exports;FK=1;try{UK.exports=$K()(__dirname)}catch(e){UK.exports=(jK||(jK=1,PK={mask:(e,t,n,i,r)=>{for(var s=0;s<r;s++)n[i+s]=e[s]^t[3&s]},unmask:(e,t)=>{const n=e.length;for(var i=0;i<n;i++)e[i]^=t[3&i]}}),PK)}return UK.exports}();BK.exports.mask=function(t,n,i,r,s){s<48?WK(t,n,i,r,s):e.mask(t,n,i,r,s)},BK.exports.unmask=function(t,n){t.length<32?GK(t,n):e.unmask(t,n)}}catch(m4){}var VK=BK.exports;const KK=Symbol("kDone"),YK=Symbol("kRun");const ZK=k,QK=VK,JK=class{constructor(e){this[KK]=()=>{this.pending--,this[YK]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[YK]()}[YK](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[KK])}}},{kStatusCode:XK}=MK,eY=Buffer[Symbol.species],tY=Buffer.from([0,0,255,255]),nY=Symbol("permessage-deflate"),iY=Symbol("total-length"),rY=Symbol("callback"),sY=Symbol("buffers"),oY=Symbol("error");let aY;var cY=class{constructor(e,t,n){if(this._maxPayload=0|n,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!aY){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;aY=new JK(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[rY];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,n=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(n.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?n.client_max_window_bits=t.clientMaxWindowBits:!0!==n.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete n.client_max_window_bits,n}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let n=e[t];if(n.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(n=n[0],"client_max_window_bits"===t){if(!0!==n){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}else if("server_max_window_bits"===t){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==n)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}e[t]=n}))})),e}decompress(e,t,n){aY.add((i=>{this._decompress(e,t,((e,t)=>{i(),n(e,t)}))}))}compress(e,t,n){aY.add((i=>{this._compress(e,t,((e,t)=>{i(),n(e,t)}))}))}_decompress(e,t,n){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?ZK.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=ZK.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[nY]=this,this._inflate[iY]=0,this._inflate[sY]=[],this._inflate.on("error",pY),this._inflate.on("data",uY)}this._inflate[rY]=n,this._inflate.write(e),t&&this._inflate.write(tY),this._inflate.flush((()=>{const e=this._inflate[oY];if(e)return this._inflate.close(),this._inflate=null,void n(e);const r=QK.concat(this._inflate[sY],this._inflate[iY]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[iY]=0,this._inflate[sY]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,r)}))}_compress(e,t,n){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?ZK.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=ZK.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[iY]=0,this._deflate[sY]=[],this._deflate.on("data",lY)}this._deflate[rY]=n,this._deflate.write(e),this._deflate.flush(ZK.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=QK.concat(this._deflate[sY],this._deflate[iY]);t&&(e=new eY(e.buffer,e.byteOffset,e.length-4)),this._deflate[rY]=null,this._deflate[iY]=0,this._deflate[sY]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,e)}))}};function lY(e){this[sY].push(e),this[iY]+=e.length}function uY(e){this[iY]+=e.length,this[nY]._maxPayload<1||this[iY]<=this[nY]._maxPayload?this[sY].push(e):(this[oY]=new RangeError("Max payload size exceeded"),this[oY].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[oY][XK]=1009,this.removeListener("data",uY),this.reset())}function pY(e){this[nY]._inflate=null,e[XK]=1007,this[rY](e)}var hY,dY,fY,mY={exports:{}},gY={exports:{}};const{isUtf8:yY}=v;function vY(e){const t=e.length;let n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}if(mY.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:vY,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},yY)mY.exports.isValidUTF8=function(e){return e.length<24?vY(e):yY(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=function(){if(fY)return gY.exports;fY=1;try{gY.exports=$K()(__dirname)}catch(e){gY.exports=(dY||(dY=1,hY=function(e){const t=e.length;let n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}),hY)}return gY.exports}();mY.exports.isValidUTF8=function(t){return t.length<32?vY(t):e(t)}}catch(m4){}var bY=mY.exports;const{Writable:_Y}=h,wY=cY,{BINARY_TYPES:xY,EMPTY_BUFFER:EY,kStatusCode:SY,kWebSocket:kY}=MK,{concat:TY,toArrayBuffer:AY,unmask:DY}=VK,{isValidStatusCode:CY,isValidUTF8:OY}=bY,RY=Buffer[Symbol.species];var LY=class extends _Y{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||xY[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[kY]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(8===this._opcode&&0==this._state)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new RY(t.buffer,t.byteOffset+e,t.length-e),new RY(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const n=this._buffers[0],i=t.length-e;e>=n.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),i),this._buffers[0]=new RY(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const n=!(64&~t[0]);if(!n||this._extensions[wY.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=n}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=EY;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&DY(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[wY.extensionName].decompress(e,this._fin,((e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(n)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let i;i="nodebuffer"===this._binaryType?TY(n,t):"arraybuffer"===this._binaryType?AY(TY(n,t)):n,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",i,!0),this._state=0,this.startLoop(e)})))}else{const i=TY(n,t);if(!this._skipUTF8Validation&&!OY(i)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",i,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,EY),this.end();else{const n=e.readUInt16BE(0);if(!CY(n)){const e=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const i=new RY(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!OY(i)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",n,i),this.end()}this._state=0}}createError(e,t,n,i,r){this._loop=!1,this._errored=!0;const s=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(s,this.createError),s.code=r,s[SY]=i,s}};const{randomFillSync:IY}=w,NY=cY,{EMPTY_BUFFER:PY}=MK,{isValidStatusCode:jY}=bY,{mask:FY,toBuffer:BY}=VK,MY=Symbol("kByteLength"),UY=Buffer.alloc(4),qY=8192;let $Y,HY=qY;var zY=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let n,i,r=!1,s=2,o=!1;t.mask&&(n=t.maskBuffer||UY,t.generateMask?t.generateMask(n):(HY===qY&&(void 0===$Y&&($Y=Buffer.alloc(qY)),IY($Y,0,qY),HY=0),n[0]=$Y[HY++],n[1]=$Y[HY++],n[2]=$Y[HY++],n[3]=$Y[HY++]),o=!(n[0]|n[1]|n[2]|n[3]),s=6),"string"==typeof e?i=t.mask&&!o||void 0===t[MY]?(e=Buffer.from(e)).length:t[MY]:(i=e.length,r=t.mask&&t.readOnly&&!o);let a=i;i>=65536?(s+=8,a=127):i>125&&(s+=2,a=126);const c=Buffer.allocUnsafe(r?i+s:s);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=a,126===a?c.writeUInt16BE(i,2):127===a&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),t.mask?(c[1]|=128,c[s-4]=n[0],c[s-3]=n[1],c[s-2]=n[2],c[s-1]=n[3],o?[c,e]:r?(FY(e,n,c,s,i),[c]):(FY(e,n,e,0,i),[c,e])):[c,e]}close(t,n,i,r){let s;if(void 0===t)s=PY;else{if("number"!=typeof t||!jY(t))throw new TypeError("First argument must be a valid error code number");if(void 0!==n&&n.length){const e=Buffer.byteLength(n);if(e>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+e),s.writeUInt16BE(t,0),"string"==typeof n?s.write(n,2):s.set(n,2)}else s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0)}const o={[MY]:s.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,r]):this.sendFrame(e.frame(s,o),r)}ping(t,n,i){let r,s;if("string"==typeof t?(r=Buffer.byteLength(t),s=!1):(r=(t=BY(t)).length,s=BY.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[MY]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,t,!1,o,i]):this.sendFrame(e.frame(t,o),i)}pong(t,n,i){let r,s;if("string"==typeof t?(r=Buffer.byteLength(t),s=!1):(r=(t=BY(t)).length,s=BY.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[MY]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,t,!1,o,i]):this.sendFrame(e.frame(t,o),i)}send(t,n,i){const r=this._extensions[NY.extensionName];let s,o,a=n.binary?2:1,c=n.compress;if("string"==typeof t?(s=Buffer.byteLength(t),o=!1):(s=(t=BY(t)).length,o=BY.readOnly),this._firstFragment?(this._firstFragment=!1,c&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(c=s>=r._threshold),this._compress=c):(c=!1,a=0),n.fin&&(this._firstFragment=!0),r){const e={[MY]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:o,rsv1:c};this._deflating?this.enqueue([this.dispatch,t,this._compress,e,i]):this.dispatch(t,this._compress,e,i)}else this.sendFrame(e.frame(t,{[MY]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:o,rsv1:!1}),i)}dispatch(t,n,i,r){if(!n)return void this.sendFrame(e.frame(t,i),r);const s=this._extensions[NY.extensionName];this._bufferedBytes+=i[MY],this._deflating=!0,s.compress(t,i.fin,((t,n)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t<this._queue.length;t++){const n=this._queue[t],i=n[n.length-1];"function"==typeof i&&i(e)}}else this._bufferedBytes-=i[MY],this._deflating=!1,i.readOnly=!1,this.sendFrame(e.frame(n,i),r),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][MY],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][MY],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};const{kForOnEventAttribute:WY,kListener:GY}=MK,VY=Symbol("kCode"),KY=Symbol("kData"),YY=Symbol("kError"),ZY=Symbol("kMessage"),QY=Symbol("kReason"),JY=Symbol("kTarget"),XY=Symbol("kType"),eZ=Symbol("kWasClean");class tZ{constructor(e){this[JY]=null,this[XY]=e}get target(){return this[JY]}get type(){return this[XY]}}Object.defineProperty(tZ.prototype,"target",{enumerable:!0}),Object.defineProperty(tZ.prototype,"type",{enumerable:!0});class nZ extends tZ{constructor(e,t={}){super(e),this[VY]=void 0===t.code?0:t.code,this[QY]=void 0===t.reason?"":t.reason,this[eZ]=void 0!==t.wasClean&&t.wasClean}get code(){return this[VY]}get reason(){return this[QY]}get wasClean(){return this[eZ]}}Object.defineProperty(nZ.prototype,"code",{enumerable:!0}),Object.defineProperty(nZ.prototype,"reason",{enumerable:!0}),Object.defineProperty(nZ.prototype,"wasClean",{enumerable:!0});class iZ extends tZ{constructor(e,t={}){super(e),this[YY]=void 0===t.error?null:t.error,this[ZY]=void 0===t.message?"":t.message}get error(){return this[YY]}get message(){return this[ZY]}}Object.defineProperty(iZ.prototype,"error",{enumerable:!0}),Object.defineProperty(iZ.prototype,"message",{enumerable:!0});class rZ extends tZ{constructor(e,t={}){super(e),this[KY]=void 0===t.data?null:t.data}get data(){return this[KY]}}Object.defineProperty(rZ.prototype,"data",{enumerable:!0});const sZ={addEventListener(e,t,n={}){for(const i of this.listeners(e))if(!n[WY]&&i[GY]===t&&!i[WY])return;let i;if("message"===e)i=function(e,n){const i=new rZ("message",{data:n?e:e.toString()});i[JY]=this,aZ(t,this,i)};else if("close"===e)i=function(e,n){const i=new nZ("close",{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});i[JY]=this,aZ(t,this,i)};else if("error"===e)i=function(e){const n=new iZ("error",{error:e,message:e.message});n[JY]=this,aZ(t,this,n)};else{if("open"!==e)return;i=function(){const e=new tZ("open");e[JY]=this,aZ(t,this,e)}}i[WY]=!!n[WY],i[GY]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(const n of this.listeners(e))if(n[GY]===t&&!n[WY]){this.removeListener(e,n);break}}};var oZ={CloseEvent:nZ,ErrorEvent:iZ,Event:tZ,EventTarget:sZ,MessageEvent:rZ};function aZ(e,t,n){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}const{tokenChars:cZ}=bY;function lZ(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}var uZ={format:function(e){return Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>[t].concat(Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let n,i,r=Object.create(null),s=!1,o=!1,a=!1,c=-1,l=-1,u=-1,p=0;for(;p<e.length;p++)if(l=e.charCodeAt(p),void 0===n)if(-1===u&&1===cZ[l])-1===c&&(c=p);else if(0===p||32!==l&&9!==l){if(59!==l&&44!==l)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===u&&(u=p);const i=e.slice(c,u);44===l?(lZ(t,i,r),r=Object.create(null)):n=i,c=u=-1}}else-1===u&&-1!==c&&(u=p);else if(void 0===i)if(-1===u&&1===cZ[l])-1===c&&(c=p);else if(32===l||9===l)-1===u&&-1!==c&&(u=p);else if(59===l||44===l){if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===u&&(u=p),lZ(r,e.slice(c,u),!0),44===l&&(lZ(t,n,r),r=Object.create(null),n=void 0),c=u=-1}else{if(61!==l||-1===c||-1!==u)throw new SyntaxError(`Unexpected character at index ${p}`);i=e.slice(c,p),c=u=-1}else if(o){if(1!==cZ[l])throw new SyntaxError(`Unexpected character at index ${p}`);-1===c?c=p:s||(s=!0),o=!1}else if(a)if(1===cZ[l])-1===c&&(c=p);else if(34===l&&-1!==c)a=!1,u=p;else{if(92!==l)throw new SyntaxError(`Unexpected character at index ${p}`);o=!0}else if(34===l&&61===e.charCodeAt(p-1))a=!0;else if(-1===u&&1===cZ[l])-1===c&&(c=p);else if(-1===c||32!==l&&9!==l){if(59!==l&&44!==l)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===u&&(u=p);let o=e.slice(c,u);s&&(o=o.replace(/\\/g,""),s=!1),lZ(r,i,o),44===l&&(lZ(t,n,r),r=Object.create(null),n=void 0),i=void 0,c=u=-1}}else-1===u&&(u=p);if(-1===c||a||32===l||9===l)throw new SyntaxError("Unexpected end of input");-1===u&&(u=p);const h=e.slice(c,u);return void 0===n?lZ(t,h,r):(void 0===i?lZ(r,h,!0):lZ(r,i,s?h.replace(/\\/g,""):h),lZ(t,n,r)),t}};const pZ=p,hZ=E,dZ=x,fZ=R,mZ=P,{randomBytes:gZ,createHash:yZ}=w,{URL:vZ}=S,bZ=cY,_Z=LY,wZ=zY,{BINARY_TYPES:xZ,EMPTY_BUFFER:EZ,GUID:SZ,kForOnEventAttribute:kZ,kListener:TZ,kStatusCode:AZ,kWebSocket:DZ,NOOP:CZ}=MK,{EventTarget:{addEventListener:OZ,removeEventListener:RZ}}=oZ,{format:LZ,parse:IZ}=uZ,{toBuffer:NZ}=VK,PZ=Symbol("kAborted"),jZ=[8,13],FZ=["CONNECTING","OPEN","CLOSING","CLOSED"],BZ=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;let MZ=class e extends pZ{constructor(t,n,i){super(),this._binaryType=xZ[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=EZ,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==t?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===n?n=[]:Array.isArray(n)||("object"==typeof n&&null!==n?(i=n,n=[]):n=[n]),qZ(this,t,n,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){xZ.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,i){const r=new _Z({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation});this._sender=new wZ(t,this._extensions,i.generateMask),this._receiver=r,this._socket=t,r[DZ]=this,t[DZ]=this,r.on("conclude",VZ),r.on("drain",KZ),r.on("error",YZ),r.on("message",QZ),r.on("ping",JZ),r.on("pong",XZ),t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",tQ),t.on("data",nQ),t.on("end",iQ),t.on("error",rQ),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=e.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[bZ.extensionName]&&this._extensions[bZ.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED)if(this.readyState!==e.CONNECTING)this.readyState!==e.CLOSING?(this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";WZ(this,this._req,e)}}pause(){this.readyState!==e.CONNECTING&&this.readyState!==e.CLOSED&&(this._paused=!0,this._socket.pause())}ping(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof t?(i=t,t=n=void 0):"function"==typeof n&&(i=n,n=void 0),"number"==typeof t&&(t=t.toString()),this.readyState===e.OPEN?(void 0===n&&(n=!this._isServer),this._sender.ping(t||EZ,n,i)):GZ(this,t,i)}pong(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof t?(i=t,t=n=void 0):"function"==typeof n&&(i=n,n=void 0),"number"==typeof t&&(t=t.toString()),this.readyState===e.OPEN?(void 0===n&&(n=!this._isServer),this._sender.pong(t||EZ,n,i)):GZ(this,t,i)}resume(){this.readyState!==e.CONNECTING&&this.readyState!==e.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof n&&(i=n,n={}),"number"==typeof t&&(t=t.toString()),this.readyState!==e.OPEN)return void GZ(this,t,i);const r={binary:"string"!=typeof t,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[bZ.extensionName]||(r.compress=!1),this._sender.send(t||EZ,r,i)}terminate(){if(this.readyState!==e.CLOSED)if(this.readyState!==e.CONNECTING)this._socket&&(this._readyState=e.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";WZ(this,this._req,e)}}};Object.defineProperty(MZ,"CONNECTING",{enumerable:!0,value:FZ.indexOf("CONNECTING")}),Object.defineProperty(MZ.prototype,"CONNECTING",{enumerable:!0,value:FZ.indexOf("CONNECTING")}),Object.defineProperty(MZ,"OPEN",{enumerable:!0,value:FZ.indexOf("OPEN")}),Object.defineProperty(MZ.prototype,"OPEN",{enumerable:!0,value:FZ.indexOf("OPEN")}),Object.defineProperty(MZ,"CLOSING",{enumerable:!0,value:FZ.indexOf("CLOSING")}),Object.defineProperty(MZ.prototype,"CLOSING",{enumerable:!0,value:FZ.indexOf("CLOSING")}),Object.defineProperty(MZ,"CLOSED",{enumerable:!0,value:FZ.indexOf("CLOSED")}),Object.defineProperty(MZ.prototype,"CLOSED",{enumerable:!0,value:FZ.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(MZ.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(MZ.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[kZ])return t[TZ];return null},set(t){for(const t of this.listeners(e))if(t[kZ]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[kZ]:!0})}})})),MZ.prototype.addEventListener=OZ,MZ.prototype.removeEventListener=RZ;var UZ=MZ;function qZ(e,t,n,i){const r={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:jZ[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=r.autoPong,!jZ.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${jZ.join(", ")})`);let s;if(t instanceof vZ)s=t;else try{s=new vZ(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),e._url=s.href;const o="wss:"===s.protocol,a="ws+unix:"===s.protocol;let c;if("ws:"===s.protocol||o||a?a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void $Z(e,t)}const l=o?443:80,u=gZ(16).toString("base64"),p=o?hZ.request:dZ.request,h=new Set;let d,f;if(r.createConnection=r.createConnection||(o?zZ:HZ),r.defaultPort=r.defaultPort||l,r.port=s.port||l,r.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},r.path=s.pathname+s.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(d=new bZ(!0!==r.perMessageDeflate?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=LZ({[bZ.extensionName]:d.offer()})),n.length){for(const e of n){if("string"!=typeof e||!BZ.test(e)||h.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");h.add(e)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(s.username||s.password)&&(r.auth=`${s.username}:${s.password}`),a){const e=r.path.split(":");r.socketPath=e[0],r.path=e[1]}if(r.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=o,e._originalHostOrSocketPath=a?r.socketPath:s.host;const t=i&&i.headers;if(i={...i,headers:{}},t)for(const[e,n]of Object.entries(t))i.headers[e.toLowerCase()]=n}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&r.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!o)&&(delete r.headers.authorization,delete r.headers.cookie,t||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),f=e._req=p(r),e._redirects&&e.emit("redirect",e.url,f)}else f=e._req=p(r);r.timeout&&f.on("timeout",(()=>{WZ(e,f,"Opening handshake has timed out")})),f.on("error",(t=>{null===f||f[PZ]||(f=e._req=null,$Z(e,t))})),f.on("response",(s=>{const o=s.headers.location,a=s.statusCode;if(o&&r.followRedirects&&a>=300&&a<400){if(++e._redirects>r.maxRedirects)return void WZ(e,f,"Maximum redirects exceeded");let s;f.abort();try{s=new vZ(o,t)}catch(t){const n=new SyntaxError(`Invalid URL: ${o}`);return void $Z(e,n)}qZ(e,s,n,i)}else e.emit("unexpected-response",f,s)||WZ(e,f,`Unexpected server response: ${s.statusCode}`)})),f.on("upgrade",((t,n,i)=>{if(e.emit("upgrade",t),e.readyState!==MZ.CONNECTING)return;f=e._req=null;const s=t.headers.upgrade;if(void 0===s||"websocket"!==s.toLowerCase())return void WZ(e,n,"Invalid Upgrade header");const o=yZ("sha1").update(u+SZ).digest("base64");if(t.headers["sec-websocket-accept"]!==o)return void WZ(e,n,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?h.size?h.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":h.size&&(c="Server sent no subprotocol"),c)return void WZ(e,n,c);a&&(e._protocol=a);const l=t.headers["sec-websocket-extensions"];if(void 0!==l){if(!d){return void WZ(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=IZ(l)}catch(t){return void WZ(e,n,"Invalid Sec-WebSocket-Extensions header")}const i=Object.keys(t);if(1!==i.length||i[0]!==bZ.extensionName){return void WZ(e,n,"Server indicated an extension that was not requested")}try{d.accept(t[bZ.extensionName])}catch(t){return void WZ(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[bZ.extensionName]=d}e.setSocket(n,i,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})})),r.finishRequest?r.finishRequest(f,e):f.end()}function $Z(e,t){e._readyState=MZ.CLOSING,e.emit("error",t),e.emitClose()}function HZ(e){return e.path=e.socketPath,fZ.connect(e)}function zZ(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=fZ.isIP(e.host)?"":e.host),mZ.connect(e)}function WZ(e,t,n){e._readyState=MZ.CLOSING;const i=new Error(n);Error.captureStackTrace(i,WZ),t.setHeader?(t[PZ]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick($Z,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function GZ(e,t,n){if(t){const n=NZ(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${FZ[e.readyState]})`);process.nextTick(n,t)}}function VZ(e,t){const n=this[DZ];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,void 0!==n._socket[DZ]&&(n._socket.removeListener("data",nQ),process.nextTick(eQ,n._socket),1005===e?n.close():n.close(e,t))}function KZ(){const e=this[DZ];e.isPaused||e._socket.resume()}function YZ(e){const t=this[DZ];void 0!==t._socket[DZ]&&(t._socket.removeListener("data",nQ),process.nextTick(eQ,t._socket),t.close(e[AZ])),t.emit("error",e)}function ZZ(){this[DZ].emitClose()}function QZ(e,t){this[DZ].emit("message",e,t)}function JZ(e){const t=this[DZ];t._autoPong&&t.pong(e,!this._isServer,CZ),t.emit("ping",e)}function XZ(e){this[DZ].emit("pong",e)}function eQ(e){e.resume()}function tQ(){const e=this[DZ];let t;this.removeListener("close",tQ),this.removeListener("data",nQ),this.removeListener("end",iQ),e._readyState=MZ.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[DZ]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",ZZ),e._receiver.on("finish",ZZ))}function nQ(e){this[DZ]._receiver.write(e)||this.pause()}function iQ(){const e=this[DZ];e._readyState=MZ.CLOSING,e._receiver.end(),this.end()}function rQ(){const e=this[DZ];this.removeListener("error",rQ),this.on("error",CZ),e&&(e._readyState=MZ.CLOSING,this.destroy())}var sQ=z(UZ);const{Duplex:oQ}=h;function aQ(e){e.emit("close")}function cQ(){!this.destroyed&&this._writableState.finished&&this.destroy()}function lQ(e){this.removeListener("error",lQ),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var uQ=function(e,t){let n=!0;const i=new oQ({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,n){const r=!n&&i._readableState.objectMode?t.toString():t;i.push(r)||e.pause()})),e.once("error",(function(e){i.destroyed||(n=!1,i.destroy(e))})),e.once("close",(function(){i.destroyed||i.push(null)})),i._destroy=function(t,r){if(e.readyState===e.CLOSED)return r(t),void process.nextTick(aQ,i);let s=!1;e.once("error",(function(e){s=!0,r(e)})),e.once("close",(function(){s||r(t),process.nextTick(aQ,i)})),n&&e.terminate()},i._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){i._final(t)}))},i._read=function(){e.isPaused&&e.resume()},i._write=function(t,n,r){e.readyState!==e.CONNECTING?e.send(t,r):e.once("open",(function(){i._write(t,n,r)}))},i.on("end",cQ),i.on("error",lQ),i};const{tokenChars:pQ}=bY;var hQ={parse:function(e){const t=new Set;let n=-1,i=-1,r=0;for(;r<e.length;r++){const s=e.charCodeAt(r);if(-1===i&&1===pQ[s])-1===n&&(n=r);else if(0===r||32!==s&&9!==s){if(44!==s)throw new SyntaxError(`Unexpected character at index ${r}`);{if(-1===n)throw new SyntaxError(`Unexpected character at index ${r}`);-1===i&&(i=r);const s=e.slice(n,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=i=-1}}else-1===i&&-1!==n&&(i=r)}if(-1===n||-1!==i)throw new SyntaxError("Unexpected end of input");const s=e.slice(n,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}};const dQ=p,fQ=x,{createHash:mQ}=w,gQ=uZ,yQ=cY,vQ=hQ,bQ=UZ,{GUID:_Q,kWebSocket:wQ}=MK,xQ=/^[+/0-9A-Za-z]{22}==$/;var EQ=class extends dQ{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:bQ,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=fQ.createServer(((e,t)=>{const n=fQ.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),t.end(n)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const n of Object.keys(t))e.on(n,t[n]);return function(){for(const n of Object.keys(t))e.removeListener(n,t[n])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,n,i)=>{this.handleUpgrade(t,n,i,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(SQ,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(SQ,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{SQ(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,i){t.on("error",kQ);const r=e.headers["sec-websocket-key"],s=e.headers.upgrade,o=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void AQ(this,e,t,405,"Invalid HTTP method")}if(void 0===s||"websocket"!==s.toLowerCase()){return void AQ(this,e,t,400,"Invalid Upgrade header")}if(void 0===r||!xQ.test(r)){return void AQ(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==o&&13!==o){return void AQ(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void TQ(t,400);const a=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==a)try{c=vQ.parse(a)}catch(n){return void AQ(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const l=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&void 0!==l){const n=new yQ(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=gQ.parse(l);e[yQ.extensionName]&&(n.accept(e[yQ.extensionName]),u[yQ.extensionName]=n)}catch(n){return void AQ(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const s={origin:e.headers[""+(8===o?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(s,((s,o,a,l)=>{if(!s)return TQ(t,o||401,a,l);this.completeUpgrade(u,r,c,e,t,n,i)}));if(!this.options.verifyClient(s))return TQ(t,401)}this.completeUpgrade(u,r,c,e,t,n,i)}completeUpgrade(e,t,n,i,r,s,o){if(!r.readable||!r.writable)return r.destroy();if(r[wQ])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return TQ(r,503);const a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mQ("sha1").update(t+_Q).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(n.size){const e=this.options.handleProtocols?this.options.handleProtocols(n,i):n.values().next().value;e&&(a.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[yQ.extensionName]){const t=e[yQ.extensionName].params,n=gQ.format({[yQ.extensionName]:[t]});a.push(`Sec-WebSocket-Extensions: ${n}`),c._extensions=e}this.emit("headers",a,i),r.write(a.concat("\r\n").join("\r\n")),r.removeListener("error",kQ),c.setSocket(r,s,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(SQ,this)}))),o(c,i)}};function SQ(e){e._state=2,e.emit("close")}function kQ(){this.destroy()}function TQ(e,t,n,i){n=n||fQ.STATUS_CODES[t],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...i},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${fQ.STATUS_CODES[t]}\r\n`+Object.keys(i).map((e=>`${e}: ${i[e]}`)).join("\r\n")+"\r\n\r\n"+n)}function AQ(e,t,n,i,r){if(e.listenerCount("wsClientError")){const i=new Error(r);Error.captureStackTrace(i,AQ),e.emit("wsClientError",i,n,t)}else TQ(n,i,r)}const DQ=UZ;DQ.createWebSocketStream=uQ,DQ.Server=EQ,DQ.Receiver=LY,DQ.Sender=zY,DQ.WebSocket=DQ,DQ.WebSocketServer=DQ.Server;var CQ=DQ,OQ={exports:{}},RQ=Object.getOwnPropertySymbols,LQ=Object.prototype.hasOwnProperty,IQ=Object.prototype.propertyIsEnumerable;var NQ=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,i,r=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),s=1;s<arguments.length;s++){for(var o in n=Object(arguments[s]))LQ.call(n,o)&&(r[o]=n[o]);if(RQ){i=RQ(n);for(var a=0;a<i.length;a++)IQ.call(n,i[a])&&(r[i[a]]=n[i[a]])}}return r};!function(){var e=NQ,t=bq,n={origin:"*",methods:"GET,HEAD,PUT,PATCH,POST,DELETE",preflightContinue:!1,optionsSuccessStatus:204};function i(e){return"string"==typeof e||e instanceof String}function r(e,t){if(Array.isArray(t)){for(var n=0;n<t.length;++n)if(r(e,t[n]))return!0;return!1}return i(t)?e===t:t instanceof RegExp?t.test(e):!!t}function s(e,t){var n,s=t.headers.origin,o=[];return e.origin&&"*"!==e.origin?i(e.origin)?(o.push([{key:"Access-Control-Allow-Origin",value:e.origin}]),o.push([{key:"Vary",value:"Origin"}])):(n=r(s,e.origin),o.push([{key:"Access-Control-Allow-Origin",value:!!n&&s}]),o.push([{key:"Vary",value:"Origin"}])):o.push([{key:"Access-Control-Allow-Origin",value:"*"}]),o}function o(e){return!0===e.credentials?{key:"Access-Control-Allow-Credentials",value:"true"}:null}function a(e){var t=e.exposedHeaders;return t?(t.join&&(t=t.join(",")),t&&t.length?{key:"Access-Control-Expose-Headers",value:t}:null):null}function c(e,n){for(var i=0,r=e.length;i<r;i++){var s=e[i];s&&(Array.isArray(s)?c(s,n):"Vary"===s.key&&s.value?t(n,s.value):s.value&&n.setHeader(s.key,s.value))}}OQ.exports=function(t){var i=null;return i="function"==typeof t?t:function(e,n){n(null,t)},function(t,r,l){i(t,(function(i,u){if(i)l(i);else{var p=e({},n,u),h=null;p.origin&&"function"==typeof p.origin?h=p.origin:p.origin&&(h=function(e,t){t(null,p.origin)}),h?h(t.headers.origin,(function(e,n){e||!n?l(e):(p.origin=n,function(e,t,n,i){var r=[];"OPTIONS"===(t.method&&t.method.toUpperCase&&t.method.toUpperCase())?(r.push(s(e,t)),r.push(o(e)),r.push(function(e){var t=e.methods;return t.join&&(t=e.methods.join(",")),{key:"Access-Control-Allow-Methods",value:t}}(e)),r.push(function(e,t){var n=e.allowedHeaders||e.headers,i=[];return n?n.join&&(n=n.join(",")):(n=t.headers["access-control-request-headers"],i.push([{key:"Vary",value:"Access-Control-Request-Headers"}])),n&&n.length&&i.push([{key:"Access-Control-Allow-Headers",value:n}]),i}(e,t)),r.push(function(e){var t=("number"==typeof e.maxAge||e.maxAge)&&e.maxAge.toString();return t&&t.length?{key:"Access-Control-Max-Age",value:t}:null}(e)),r.push(a(e)),c(r,n),e.preflightContinue?i():(n.statusCode=e.optionsSuccessStatus,n.setHeader("Content-Length","0"),n.end())):(r.push(s(e,t)),r.push(o(e)),r.push(a(e)),c(r,n),i())}(p,t,r,l))})):l()}}))}}}();var PQ=OQ.exports;Object.defineProperty(yV,"__esModule",{value:!0}),yV.Server=yV.BaseServer=void 0;const jQ=L,FQ=S,BQ=bV,MQ=_V,UQ=p,qQ=wK,$Q=TK,HQ=CQ,zQ=pK,WQ=EV,GQ=(0,ch.default)("engine"),VQ=Symbol("responseHeaders");class KQ extends UQ.EventEmitter{constructor(e={}){super(),this.middlewares=[],this.clients={},this.clientsCount=0,this.opts=Object.assign({wsEngine:HQ.Server,pingTimeout:2e4,pingInterval:25e3,upgradeTimeout:1e4,maxHttpBufferSize:1e6,transports:["polling","websocket"],allowUpgrades:!0,httpCompression:{threshold:1024},cors:!1,allowEIO3:!1},e),e.cookie&&(this.opts.cookie=Object.assign({name:"io",path:"/",httpOnly:!1!==e.cookie.path,sameSite:"lax"},e.cookie)),this.opts.cors&&this.use(PQ(this.opts.cors)),e.perMessageDeflate&&(this.opts.perMessageDeflate=Object.assign({threshold:1024},e.perMessageDeflate)),this.init()}_computePath(e){let t=(e.path||"/engine.io").replace(/\/$/,"");return!1!==e.addTrailingSlash&&(t+="/"),t}upgrades(e){return this.opts.allowUpgrades&&MQ.default[e].upgradesTo||[]}verify(e,t,n){const i=e._query.transport;if(!~this.opts.transports.indexOf(i)||"webtransport"===i)return GQ('unknown transport "%s"',i),n(ZQ.errors.UNKNOWN_TRANSPORT,{transport:i});const r=function(e){if((e+="").length<1)return!1;if(!XQ[e.charCodeAt(0)])return GQ('invalid header, index 0, char "%s"',e.charCodeAt(0)),!0;if(e.length<2)return!1;if(!XQ[e.charCodeAt(1)])return GQ('invalid header, index 1, char "%s"',e.charCodeAt(1)),!0;if(e.length<3)return!1;if(!XQ[e.charCodeAt(2)])return GQ('invalid header, index 2, char "%s"',e.charCodeAt(2)),!0;if(e.length<4)return!1;if(!XQ[e.charCodeAt(3)])return GQ('invalid header, index 3, char "%s"',e.charCodeAt(3)),!0;for(let t=4;t<e.length;++t)if(!XQ[e.charCodeAt(t)])return GQ('invalid header, index "%i", char "%s"',t,e.charCodeAt(t)),!0;return!1}(e.headers.origin);if(r){const t=e.headers.origin;return e.headers.origin=null,GQ("origin header invalid"),n(ZQ.errors.BAD_REQUEST,{name:"INVALID_ORIGIN",origin:t})}const s=e._query.sid;if(!s)return"GET"!==e.method?n(ZQ.errors.BAD_HANDSHAKE_METHOD,{method:e.method}):"websocket"!==i||t?this.opts.allowRequest?this.opts.allowRequest(e,((e,t)=>{if(!t)return n(ZQ.errors.FORBIDDEN,{message:e});n()})):n():(GQ("invalid transport upgrade"),n(ZQ.errors.BAD_REQUEST,{name:"TRANSPORT_HANDSHAKE_ERROR"}));{if(!this.clients.hasOwnProperty(s))return GQ('unknown sid "%s"',s),n(ZQ.errors.UNKNOWN_SID,{sid:s});const e=this.clients[s].transport.name;if(!t&&e!==i)return GQ("bad request: unexpected transport without upgrade"),n(ZQ.errors.BAD_REQUEST,{name:"TRANSPORT_MISMATCH",transport:i,previousTransport:e})}n()}use(e){this.middlewares.push(e)}_applyMiddlewares(e,t,n){if(0===this.middlewares.length)return GQ("no middleware to apply, skipping"),n();const i=r=>{GQ("applying middleware n°%d",r+1),this.middlewares[r](e,t,(e=>{if(e)return n(e);r+1<this.middlewares.length?i(r+1):n()}))};i(0)}close(){GQ("closing all open clients");for(let e in this.clients)this.clients.hasOwnProperty(e)&&this.clients[e].close(!0);return this.cleanup(),this}generateId(e){return BQ.generateId()}async handshake(e,t,n){const i="4"===t._query.EIO?4:3;if(3===i&&!this.opts.allowEIO3)return GQ("unsupported protocol version"),this.emit("connection_error",{req:t,code:ZQ.errors.UNSUPPORTED_PROTOCOL_VERSION,message:ZQ.errorMessages[ZQ.errors.UNSUPPORTED_PROTOCOL_VERSION],context:{protocol:i}}),void n(ZQ.errors.UNSUPPORTED_PROTOCOL_VERSION);let r;try{r=await this.generateId(t)}catch(e){return GQ("error while generating an id"),this.emit("connection_error",{req:t,code:ZQ.errors.BAD_REQUEST,message:ZQ.errorMessages[ZQ.errors.BAD_REQUEST],context:{name:"ID_GENERATION_ERROR",error:e}}),void n(ZQ.errors.BAD_REQUEST)}GQ('handshaking client "%s"',r);try{var s=this.createTransport(e,t);"polling"===e?(s.maxHttpBufferSize=this.opts.maxHttpBufferSize,s.httpCompression=this.opts.httpCompression):"websocket"===e&&(s.perMessageDeflate=this.opts.perMessageDeflate)}catch(i){return GQ('error handshaking to transport "%s"',e),this.emit("connection_error",{req:t,code:ZQ.errors.BAD_REQUEST,message:ZQ.errorMessages[ZQ.errors.BAD_REQUEST],context:{name:"TRANSPORT_HANDSHAKE_ERROR",error:i}}),void n(ZQ.errors.BAD_REQUEST)}const o=new qQ.Socket(r,this,s,t,i);return s.on("headers",((e,t)=>{!t._query.sid&&(this.opts.cookie&&(e["Set-Cookie"]=[(0,$Q.serialize)(this.opts.cookie.name,r,this.opts.cookie)]),this.emit("initial_headers",e,t)),this.emit("headers",e,t)})),s.onRequest(t),this.clients[r]=o,this.clientsCount++,o.once("close",(()=>{delete this.clients[r],this.clientsCount--})),this.emit("connection",o),s}async onWebTransportSession(e){const t=setTimeout((()=>{GQ("the client failed to establish a bidirectional stream in the given period"),e.close()}),this.opts.upgradeTimeout),n=e.incomingBidirectionalStreams.getReader(),i=await n.read();if(i.done)return void GQ("session is closed");const r=i.value,s=(0,WQ.createPacketDecoderStream)(this.opts.maxHttpBufferSize,"nodebuffer"),o=r.readable.pipeThrough(s).getReader(),{value:a,done:c}=await o.read();if(c)return void GQ("stream is closed");if(clearTimeout(t),"open"!==a.type)return GQ("invalid WebTransport handshake"),e.close();if(void 0===a.data){const t=new zQ.WebTransport(e,r,o),n=BQ.generateId();GQ('handshaking client "%s" (WebTransport)',n);const i=new qQ.Socket(n,this,t,null,4);return this.clients[n]=i,this.clientsCount++,i.once("close",(()=>{delete this.clients[n],this.clientsCount--})),void this.emit("connection",i)}const l=function(e){try{const t=JSON.parse(e);if("string"==typeof t.sid)return t.sid}catch(e){}}(a.data);if(!l)return GQ("invalid WebTransport handshake"),e.close();const u=this.clients[l];if(u)if(u.upgrading)GQ("transport has already been trying to upgrade"),e.close();else if(u.upgraded)GQ("transport had already been upgraded"),e.close();else{GQ("upgrading existing transport");const t=new zQ.WebTransport(e,r,o);u.maybeUpgrade(t)}else GQ("upgrade attempt for closed client"),e.close()}}yV.BaseServer=KQ,KQ.errors={UNKNOWN_TRANSPORT:0,UNKNOWN_SID:1,BAD_HANDSHAKE_METHOD:2,BAD_REQUEST:3,FORBIDDEN:4,UNSUPPORTED_PROTOCOL_VERSION:5},KQ.errorMessages={0:"Transport unknown",1:"Session ID unknown",2:"Bad handshake method",3:"Bad request",4:"Forbidden",5:"Unsupported protocol version"};class YQ{constructor(e,t){this.req=e,this.socket=t,e[VQ]={}}setHeader(e,t){this.req[VQ][e]=t}getHeader(e){return this.req[VQ][e]}removeHeader(e){delete this.req[VQ][e]}write(){}writeHead(){}end(){this.socket.destroy()}}let ZQ=class e extends KQ{init(){~this.opts.transports.indexOf("websocket")&&(this.ws&&this.ws.close(),this.ws=new this.opts.wsEngine({noServer:!0,clientTracking:!1,perMessageDeflate:this.opts.perMessageDeflate,maxPayload:this.opts.maxHttpBufferSize}),"function"==typeof this.ws.on&&this.ws.on("headers",((e,t)=>{const n=t[VQ]||{};delete t[VQ];!t._query.sid&&this.emit("initial_headers",n,t),this.emit("headers",n,t),GQ("writing headers: %j",n),Object.keys(n).forEach((t=>{e.push(`${t}: ${n[t]}`)}))})))}cleanup(){this.ws&&(GQ("closing webSocketServer"),this.ws.close())}prepare(e){e._query||(e._query=~e.url.indexOf("?")?jQ.parse((0,FQ.parse)(e.url).query):{})}createTransport(e,t){return new MQ.default[e](t)}handleRequest(t,n){GQ('handling "%s" http request "%s"',t.method,t.url),this.prepare(t),t.res=n;const i=(i,r)=>{if(void 0!==i)return this.emit("connection_error",{req:t,code:i,message:e.errorMessages[i],context:r}),void QQ(n,i,r);if(t._query.sid)GQ("setting new request for existing client"),this.clients[t._query.sid].transport.onRequest(t);else{const e=(e,t)=>QQ(n,e,t);this.handshake(t._query.transport,t,e)}};this._applyMiddlewares(t,n,(n=>{n?i(e.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!1,i)}))}handleUpgrade(t,n,i){this.prepare(t);const r=new YQ(t,n),s=(s,o)=>{if(void 0!==s)return this.emit("connection_error",{req:t,code:s,message:e.errorMessages[s],context:o}),void JQ(n,s,o);const a=Buffer.from(i);i=null,r.writeHead(),this.ws.handleUpgrade(t,n,a,(e=>{this.onWebSocket(t,n,e)}))};this._applyMiddlewares(t,r,(n=>{n?s(e.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!0,s)}))}onWebSocket(e,t,n){if(n.on("error",r),void 0!==MQ.default[e._query.transport]&&!MQ.default[e._query.transport].prototype.handlesUpgrades)return GQ("transport doesnt handle upgraded requests"),void n.close();const i=e._query.sid;if(e.websocket=n,i){const t=this.clients[i];if(t)if(t.upgrading)GQ("transport has already been trying to upgrade"),n.close();else if(t.upgraded)GQ("transport had already been upgraded"),n.close();else{GQ("upgrading existing transport"),n.removeListener("error",r);const i=this.createTransport(e._query.transport,e);i.perMessageDeflate=this.opts.perMessageDeflate,t.maybeUpgrade(i)}else GQ("upgrade attempt for closed client"),n.close()}else{const n=(e,n)=>JQ(t,e,n);this.handshake(e._query.transport,e,n)}function r(){GQ("websocket error before upgrade")}}attach(e,t={}){const n=this._computePath(t),i=t.destroyUpgradeTimeout||1e3;function r(e){return n===e.url.slice(0,n.length)}const s=e.listeners("request").slice(0);e.removeAllListeners("request"),e.on("close",this.close.bind(this)),e.on("listening",this.init.bind(this)),e.on("request",((t,i)=>{if(r(t))GQ('intercepting request for path "%s"',n),this.handleRequest(t,i);else{let n=0;const r=s.length;for(;n<r;n++)s[n].call(e,t,i)}})),~this.opts.transports.indexOf("websocket")&&e.on("upgrade",((e,n,s)=>{r(e)?this.handleUpgrade(e,n,s):!1!==t.destroyUpgrade&&setTimeout((function(){if(n.writable&&n.bytesWritten<=0)return n.on("error",(e=>{GQ("error while destroying upgrade: %s",e.message)})),n.end()}),i)}))}};function QQ(e,t,n){const i=t===ZQ.errors.FORBIDDEN?403:400,r=n&&n.message?n.message:ZQ.errorMessages[t];e.writeHead(i,{"Content-Type":"application/json"}),e.end(JSON.stringify({code:t,message:r}))}function JQ(e,t,n={}){if(e.on("error",(()=>{GQ("ignoring error from closed connection")})),e.writable){const i=n.message||ZQ.errorMessages[t],r=Buffer.byteLength(i);e.write("HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-type: text/html\r\nContent-Length: "+r+"\r\n\r\n"+i)}e.destroy()}yV.Server=ZQ;const XQ=[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];var eJ={},tJ={},nJ={};Object.defineProperty(nJ,"__esModule",{value:!0}),nJ.Polling=void 0;const iJ=xV,rJ=k,sJ=$U,oJ=(0,ch.default)("engine:polling"),aJ={gzip:rJ.createGzip,deflate:rJ.createDeflate};let cJ=class extends iJ.Transport{constructor(e){super(e),this.closeTimeout=3e4}get name(){return"polling"}get supportsFraming(){return!1}onRequest(e){const t=e.res;e.res=null,"get"===e.getMethod()?this.onPollRequest(e,t):"post"===e.getMethod()?this.onDataRequest(e,t):(t.writeStatus("500 Internal Server Error"),t.end())}onPollRequest(e,t){if(this.req)return oJ("request overlap"),this.onError("overlap from client"),t.writeStatus("500 Internal Server Error"),void t.end();oJ("setting request"),this.req=e,this.res=t;e.cleanup=()=>{this.req=this.res=null},t.onAborted((()=>{this.writable=!1,this.onError("poll connection closed prematurely")})),this.writable=!0,this.emit("drain"),this.writable&&this.shouldClose&&(oJ("triggering empty send to append close packet"),this.send([{type:"noop"}]))}onDataRequest(e,t){if(this.dataReq)return this.onError("data request overlap from client"),t.writeStatus("500 Internal Server Error"),void t.end();const n=Number(e.headers["content-length"]);if(!n)return this.onError("content-length header required"),void t.writeStatus("411 Length Required").end();if(n>this.maxHttpBufferSize)return this.onError("payload too large"),void t.writeStatus("413 Payload Too Large").end();if("application/octet-stream"===e.headers["content-type"]&&4===this.protocol)return this.onError("invalid content");let i;this.dataReq=e,this.dataRes=t;let r=0;const s={"Content-Type":"text/html"};this.headers(e,s);for(let e in s)t.writeHeader(e,String(s[e]));const o=e=>{this.onData(e.toString()),this.onDataRequestCleanup(),t.cork((()=>{t.end("ok")}))};t.onAborted((()=>{this.onDataRequestCleanup(),this.onError("data request connection closed prematurely")})),t.onData(((e,s)=>{const a=r+e.byteLength;if(a>n)return this.onError("content-length mismatch"),void t.close();if(!i){if(s)return void o(Buffer.from(e));i=Buffer.allocUnsafe(n)}if(Buffer.from(e).copy(i,r),s)return a!=n?(this.onError("content-length mismatch"),t.writeStatus("400 Content-Length Mismatch").end(),void this.onDataRequestCleanup()):void o(i);r=a}))}onDataRequestCleanup(){this.dataReq=this.dataRes=null}onData(e){oJ('received "%s"',e);const t=e=>{if("close"===e.type)return oJ("got xhr close packet"),this.onClose(),!1;this.onPacket(e)};3===this.protocol?this.parser.decodePayload(e,t):this.parser.decodePayload(e).forEach(t)}onClose(){this.writable&&this.send([{type:"noop"}]),super.onClose()}send(e){this.writable=!1,this.shouldClose&&(oJ("appending close packet to payload"),e.push({type:"close"}),this.shouldClose(),this.shouldClose=null);const t=t=>{const n=e.some((e=>e.options&&e.options.compress));this.write(t,{compress:n})};3===this.protocol?this.parser.encodePayload(e,this.supportsBinary,t):this.parser.encodePayload(e,t)}write(e,t){oJ('writing "%s"',e),this.doWrite(e,t,(()=>{this.req.cleanup()}))}doWrite(e,t,n){const i="string"==typeof e,r={"Content-Type":i?"text/plain; charset=UTF-8":"application/octet-stream"},s=e=>{this.headers(this.req,r),this.res.cork((()=>{Object.keys(r).forEach((e=>{this.res.writeHeader(e,String(r[e]))})),this.res.end(e)})),n()};if(!this.httpCompression||!t.compress)return void s(e);if((i?Buffer.byteLength(e):e.length)<this.httpCompression.threshold)return void s(e);const o=sJ(this.req).encodings(["gzip","deflate"]);o?this.compress(e,o,((e,t)=>{if(e)return this.res.writeStatus("500 Internal Server Error"),this.res.end(),void n(e);r["Content-Encoding"]=o,s(t)})):s(e)}compress(e,t,n){oJ("compressing");const i=[];let r=0;aJ[t](this.httpCompression).on("error",n).on("data",(function(e){i.push(e),r+=e.length})).on("end",(function(){n(null,Buffer.concat(i,r))})).end(e)}doClose(e){let t;oJ("closing");const n=()=>{clearTimeout(t),e(),this.onClose()};this.writable?(oJ("transport writable - closing right away"),this.send([{type:"close"}]),n()):this.discarded?(oJ("transport discarded - closing right away"),n()):(oJ("transport not writable - buffering orderly close"),this.shouldClose=n,t=setTimeout(n,this.closeTimeout))}headers(e,t){t=t||{};const n=e.headers["user-agent"];return n&&(~n.indexOf(";MSIE")||~n.indexOf("Trident/"))&&(t["X-XSS-Protection"]="0"),t["cache-control"]="no-store",this.emit("headers",t,e),t}};nJ.Polling=cJ;var lJ={};Object.defineProperty(lJ,"__esModule",{value:!0}),lJ.WebSocket=void 0;const uJ=xV,pJ=(0,ch.default)("engine:ws");let hJ=class extends uJ.Transport{constructor(e){super(e),this.writable=!1,this.perMessageDeflate=null}get name(){return"websocket"}get handlesUpgrades(){return!0}get supportsFraming(){return!0}send(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t+1===e.length,r=e=>{const t="string"!=typeof e,n=this.perMessageDeflate&&Buffer.byteLength(e)>this.perMessageDeflate.threshold;pJ('writing "%s"',e),this.socket.send(e,t,n),i&&(this.writable=!0,this.emit("drain"))};n.options&&"string"==typeof n.options.wsPreEncoded?r(n.options.wsPreEncoded):this.parser.encodePacket(n,this.supportsBinary,r)}}doClose(e){pJ("closing"),e&&e(),this.socket.end()}};lJ.WebSocket=hJ,Object.defineProperty(tJ,"__esModule",{value:!0});const dJ=nJ,fJ=lJ;tJ.default={polling:dJ.Polling,websocket:fJ.WebSocket},Object.defineProperty(eJ,"__esModule",{value:!0}),eJ.uServer=void 0;const mJ=yV,gJ=tJ,yJ=(0,ch.default)("engine:uws");class vJ extends mJ.BaseServer{init(){}cleanup(){}prepare(e,t){e.method=e.getMethod().toUpperCase(),e.url=e.getUrl();const n=new URLSearchParams(e.getQuery());e._query=Object.fromEntries(n.entries()),e.headers={},e.forEach(((t,n)=>{e.headers[t]=n})),e.connection={remoteAddress:Buffer.from(t.getRemoteAddressAsText()).toString()},t.onAborted((()=>{yJ("response has been aborted")}))}createTransport(e,t){return new gJ.default[e](t)}attach(e,t={}){const n=this._computePath(t);e.any(n,this.handleRequest.bind(this)).ws(n,{compression:t.compression,idleTimeout:t.idleTimeout,maxBackpressure:t.maxBackpressure,maxPayloadLength:this.opts.maxHttpBufferSize,upgrade:this.handleUpgrade.bind(this),open:e=>{const t=e.getUserData().transport;t.socket=e,t.writable=!0,t.emit("drain")},message:(e,t,n)=>{e.getUserData().transport.onData(n?t:Buffer.from(t).toString())},close:(e,t,n)=>{e.getUserData().transport.onClose(t,n)}})}_applyMiddlewares(e,t,n){if(0===this.middlewares.length)return n();e.res=new bJ(t),super._applyMiddlewares(e,e.res,(t=>{e.res.writeHead(),n(t)}))}handleRequest(e,t){yJ('handling "%s" http request "%s"',t.getMethod(),t.getUrl()),this.prepare(t,e),t.res=e;const n=(n,i)=>{if(void 0!==n)return this.emit("connection_error",{req:t,code:n,message:mJ.Server.errorMessages[n],context:i}),void this.abortRequest(t.res,n,i);if(t._query.sid)yJ("setting new request for existing client"),this.clients[t._query.sid].transport.onRequest(t);else{const n=(t,n)=>this.abortRequest(e,t,n);this.handshake(t._query.transport,t,n)}};this._applyMiddlewares(t,e,(e=>{e?n(mJ.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!1,n)}))}handleUpgrade(e,t,n){yJ("on upgrade"),this.prepare(t,e),t.res=e;const i=async(i,r)=>{if(void 0!==i)return this.emit("connection_error",{req:t,code:i,message:mJ.Server.errorMessages[i],context:r}),void this.abortRequest(e,i,r);const s=t._query.sid;let o;if(s){const n=this.clients[s];n?n.upgrading?(yJ("transport has already been trying to upgrade"),e.close()):n.upgraded?(yJ("transport had already been upgraded"),e.close()):(yJ("upgrading existing transport"),o=this.createTransport(t._query.transport,t),n.maybeUpgrade(o)):(yJ("upgrade attempt for closed client"),e.close())}else if(o=await this.handshake(t._query.transport,t,((t,n)=>this.abortRequest(e,t,n))),!o)return;t.res.writeStatus("101 Switching Protocols"),e.upgrade({transport:o},t.getHeader("sec-websocket-key"),t.getHeader("sec-websocket-protocol"),t.getHeader("sec-websocket-extensions"),n)};this._applyMiddlewares(t,e,(e=>{e?i(mJ.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!0,i)}))}abortRequest(e,t,n){const i=t===mJ.Server.errors.FORBIDDEN?"403 Forbidden":"400 Bad Request",r=n&&n.message?n.message:mJ.Server.errorMessages[t];e.writeStatus(i),e.writeHeader("Content-Type","application/json"),e.end(JSON.stringify({code:t,message:r}))}}eJ.uServer=vJ;class bJ{constructor(e){this.res=e,this.statusWritten=!1,this.headers=[],this.isAborted=!1}set statusCode(e){e&&this.writeStatus(200===e?"200 OK":"204 No Content")}writeHead(e){this.statusCode=e}setHeader(e,t){Array.isArray(t)?t.forEach((t=>{this.writeHeader(e,t)})):this.writeHeader(e,t)}removeHeader(){}getHeader(){}writeStatus(e){if(!this.isAborted)return this.res.writeStatus(e),this.statusWritten=!0,this.writeBufferedHeaders(),this}writeHeader(e,t){this.isAborted||"Content-Length"!==e&&(this.statusWritten?this.res.writeHeader(e,t):this.headers.push([e,t]))}writeBufferedHeaders(){this.headers.forEach((([e,t])=>{this.res.writeHeader(e,t)}))}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)}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.protocol=e.Transport=e.Socket=e.uServer=e.parser=e.attach=e.listen=e.transports=e.Server=void 0;const t=x,n=yV;Object.defineProperty(e,"Server",{enumerable:!0,get:function(){return n.Server}});const i=_V;e.transports=i.default;const r=EV;e.parser=r;var s=eJ;Object.defineProperty(e,"uServer",{enumerable:!0,get:function(){return s.uServer}});var o=wK;Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return o.Socket}});var a=xV;function c(e,t){const i=new n.Server(t);return i.attach(e,t),i}Object.defineProperty(e,"Transport",{enumerable:!0,get:function(){return a.Transport}}),e.protocol=r.protocol,e.listen=function(e,n,i){"function"==typeof n&&(i=n,n={});const r=(0,t.createServer)((function(e,t){t.writeHead(501),t.end("Not Implemented")})),s=c(r,n);return s.httpServer=r,r.listen(e,i),s},e.attach=c}(gV);var _J={},wJ={};function xJ(e){if(e)return function(e){for(var t in xJ.prototype)e[t]=xJ.prototype[t];return e}(e)}xJ.prototype.on=xJ.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},xJ.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},xJ.prototype.off=xJ.prototype.removeListener=xJ.prototype.removeAllListeners=xJ.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<i.length;r++)if((n=i[r])===t||n.fn===t){i.splice(r,1);break}return 0===i.length&&delete this._callbacks["$"+e],this},xJ.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(n){i=0;for(var r=(n=n.slice(0)).length;i<r;++i)n[i].apply(this,t)}return this},xJ.prototype.emitReserved=xJ.prototype.emit,xJ.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},xJ.prototype.hasListeners=function(e){return!!this.listeners(e).length};var EJ=W(Object.freeze({__proto__:null,Emitter:xJ})),SJ={},kJ={};Object.defineProperty(kJ,"__esModule",{value:!0}),kJ.hasBinary=kJ.isBinary=void 0;const TJ="function"==typeof ArrayBuffer,AJ=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,DJ=Object.prototype.toString,CJ="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===DJ.call(Blob),OJ="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===DJ.call(File);function RJ(e){return TJ&&(e instanceof ArrayBuffer||AJ(e))||CJ&&e instanceof Blob||OJ&&e instanceof File}kJ.isBinary=RJ,kJ.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,i=t.length;n<i;n++)if(e(t[n]))return!0;return!1}if(RJ(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1},Object.defineProperty(SJ,"__esModule",{value:!0}),SJ.reconstructPacket=SJ.deconstructPacket=void 0;const LJ=kJ;function IJ(e,t){if(!e)return e;if((0,LJ.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let i=0;i<e.length;i++)n[i]=IJ(e[i],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=IJ(e[i],t));return n}return e}function NJ(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=NJ(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=NJ(e[n],t));return e}SJ.deconstructPacket=function(e){const t=[],n=e.data,i=e;return i.data=IJ(n,t),i.attachments=t.length,{packet:i,buffers:t}},SJ.reconstructPacket=function(e,t){return e.data=NJ(e.data,t),delete e.attachments,e},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Decoder=e.Encoder=e.PacketType=e.protocol=void 0;const t=EJ,n=SJ,i=kJ,r=(0,ch.default)("socket.io-parser"),s=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var o;e.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(o=e.PacketType||(e.PacketType={}));function a(e){return"[object Object]"===Object.prototype.toString.call(e)}e.Encoder=class{constructor(e){this.replacer=e}encode(e){return r("encoding packet %j",e),e.type!==o.EVENT&&e.type!==o.ACK||!(0,i.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===o.EVENT?o.BINARY_EVENT:o.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==o.BINARY_EVENT&&e.type!==o.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),r("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,n.deconstructPacket)(e),i=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(i),r}};class c extends t.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===o.BINARY_EVENT;n||t.type===o.BINARY_ACK?(t.type=n?o.EVENT:o.ACK,this.reconstructor=new l(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,i.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===o[n.type])throw new Error("unknown packet type "+n.type);if(n.type===o.BINARY_EVENT||n.type===o.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(i,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(r)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(i,t)}else n.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!c.isPayloadValid(n.type,i))throw new Error("invalid payload");n.data=i}return r("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case o.CONNECT:return a(t);case o.DISCONNECT:return void 0===t;case o.CONNECT_ERROR:return"string"==typeof t||a(t);case o.EVENT:case o.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===s.indexOf(t[0]));case o.ACK:case o.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}e.Decoder=c;class l{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,n.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}}(wJ),Object.defineProperty(_J,"__esModule",{value:!0}),_J.Client=void 0;const PJ=wJ,jJ=S,FJ=ch("socket.io:client");_J.Client=class{constructor(e,t){this.sockets=new Map,this.nsps=new Map,this.server=e,this.conn=t,this.encoder=e.encoder,this.decoder=new e._parser.Decoder,this.id=t.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((()=>{0===this.nsps.size?(FJ("no namespace joined yet, close the client"),this.close()):FJ("the client has already joined a namespace, nothing to do")}),this.server._connectTimeout)}connect(e,t={}){if(this.server._nsps.has(e))return FJ("connecting to namespace %s",e),this.doConnect(e,t);this.server._checkNamespace(e,t,(n=>{n?this.doConnect(e,t):(FJ("creation of namespace %s was denied",e),this._packet({type:PJ.PacketType.CONNECT_ERROR,nsp:e,data:{message:"Invalid namespace"}}))}))}doConnect(e,t){const n=this.server.of(e);n._add(this,t,(e=>{this.sockets.set(e.id,e),this.nsps.set(n.name,e),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)}))}_disconnect(){for(const e of this.sockets.values())e.disconnect();this.sockets.clear(),this.close()}_remove(e){if(this.sockets.has(e.id)){const t=this.sockets.get(e.id).nsp.name;this.sockets.delete(e.id),this.nsps.delete(t)}else FJ("ignoring remove for %s",e.id)}close(){"open"===this.conn.readyState&&(FJ("forcing transport close"),this.conn.close(),this.onclose("forced server close"))}_packet(e,t={}){if("open"!==this.conn.readyState)return void FJ("ignoring packet write %j",e);const n=t.preEncoded?e:this.encoder.encode(e);this.writeToEngine(n,t)}writeToEngine(e,t){if(t.volatile&&!this.conn.transport.writable)return void FJ("volatile packet is discarded since the transport is not currently writable");const n=Array.isArray(e)?e:[e];for(const e of n)this.conn.write(e,t)}ondata(e){try{this.decoder.add(e)}catch(e){FJ("invalid packet format"),this.onerror(e)}}ondecoded(e){let t,n;if(3===this.conn.protocol){const i=jJ.parse(e.nsp,!0);t=i.pathname,n=i.query}else t=e.nsp,n=e.data;const i=this.nsps.get(t);i||e.type!==PJ.PacketType.CONNECT?i&&e.type!==PJ.PacketType.CONNECT&&e.type!==PJ.PacketType.CONNECT_ERROR?process.nextTick((function(){i._onpacket(e)})):(FJ("invalid state (packet type: %s)",e.type),this.close()):this.connect(t,n)}onerror(e){for(const t of this.sockets.values())t._onerror(e);this.conn.close()}onclose(e,t){FJ("client close with reason %s",e),this.destroy();for(const n of this.sockets.values())n._onclose(e,t);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)}};var BJ={},MJ={},UJ={};Object.defineProperty(UJ,"__esModule",{value:!0}),UJ.StrictEventEmitter=void 0;const qJ=p;class $J extends qJ.EventEmitter{on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}emit(e,...t){return super.emit(e,...t)}emitReserved(e,...t){return super.emit(e,...t)}emitUntyped(e,...t){return super.emit(e,...t)}listeners(e){return super.listeners(e)}}UJ.StrictEventEmitter=$J;var HJ,zJ,WJ={};function GJ(){if(HJ)return WJ;HJ=1,Object.defineProperty(WJ,"__esModule",{value:!0}),WJ.RemoteSocket=WJ.BroadcastOperator=void 0;const e=VJ(),t=wJ;class n{constructor(e,t=new Set,n=new Set,i={}){this.adapter=e,this.rooms=t,this.exceptRooms=n,this.flags=i}to(e){const t=new Set(this.rooms);return Array.isArray(e)?e.forEach((e=>t.add(e))):t.add(e),new n(this.adapter,t,this.exceptRooms,this.flags)}in(e){return this.to(e)}except(e){const t=new Set(this.exceptRooms);return Array.isArray(e)?e.forEach((e=>t.add(e))):t.add(e),new n(this.adapter,this.rooms,t,this.flags)}compress(e){const t=Object.assign({},this.flags,{compress:e});return new n(this.adapter,this.rooms,this.exceptRooms,t)}get volatile(){const e=Object.assign({},this.flags,{volatile:!0});return new n(this.adapter,this.rooms,this.exceptRooms,e)}get local(){const e=Object.assign({},this.flags,{local:!0});return new n(this.adapter,this.rooms,this.exceptRooms,e)}timeout(e){const t=Object.assign({},this.flags,{timeout:e});return new n(this.adapter,this.rooms,this.exceptRooms,t)}emit(n,...i){if(e.RESERVED_EVENTS.has(n))throw new Error(`"${String(n)}" is a reserved event name`);const r=[n,...i],s={type:t.PacketType.EVENT,data:r};if(!("function"==typeof r[r.length-1]))return this.adapter.broadcast(s,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags}),!0;const o=r.pop();let a=!1,c=[];const l=setTimeout((()=>{a=!0,o.apply(this,[new Error("operation has timed out"),this.flags.expectSingleResponse?null:c])}),this.flags.timeout);let u=-1,p=0,h=0;const d=()=>{a||u!==p||c.length!==h||(clearTimeout(l),o.apply(this,[null,this.flags.expectSingleResponse?c[0]:c]))};return this.adapter.broadcastWithAck(s,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags},(e=>{h+=e,p++,d()}),(e=>{c.push(e),d()})),this.adapter.serverCount().then((e=>{u=e,d()})),!0}emitWithAck(e,...t){return new Promise(((n,i)=>{t.push(((e,t)=>e?(e.responses=t,i(e)):n(t))),this.emit(e,...t)}))}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((t=>t.map((t=>t instanceof e.Socket?t:new i(this.adapter,t)))))}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)}}WJ.BroadcastOperator=n;class i{constructor(e,t){this.id=t.id,this.handshake=t.handshake,this.rooms=new Set(t.rooms),this.data=t.data,this.operator=new n(e,new Set([this.id]),new Set,{expectSingleResponse:!0})}timeout(e){return this.operator.timeout(e)}emit(e,...t){return this.operator.emit(e,...t)}join(e){return this.operator.socketsJoin(e)}leave(e){return this.operator.socketsLeave(e)}disconnect(e=!1){return this.operator.disconnectSockets(e),this}}return WJ.RemoteSocket=i,WJ}function VJ(){return zJ||(zJ=1,function(e){var t=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Socket=e.RESERVED_EVENTS=void 0;const n=wJ,i=t(ch),r=UJ,s=t(bV),o=GJ(),a=(0,i.default)("socket.io:socket"),c=new Set(["transport error","transport close","forced close","ping timeout","server shutting down","forced server close"]);function l(){}e.RESERVED_EVENTS=new Set(["connect","connect_error","disconnect","disconnecting","newListener","removeListener"]);class u extends r.StrictEventEmitter{constructor(e,t,i,r){super(),this.nsp=e,this.client=t,this.recovered=!1,this.data={},this.connected=!1,this.acks=new Map,this.fns=[],this.flags={},this.server=e.server,this.adapter=this.nsp.adapter,r?(this.id=r.sid,this.pid=r.pid,r.rooms.forEach((e=>this.join(e))),this.data=r.data,r.missedPackets.forEach((e=>{this.packet({type:n.PacketType.EVENT,data:e})})),this.recovered=!0):(3===t.conn.protocol?this.id="/"!==e.name?e.name+"#"+t.id:t.id:this.id=s.default.generateId(),this.server._opts.connectionStateRecovery&&(this.pid=s.default.generateId())),this.handshake=this.buildHandshake(i),this.on("error",l)}buildHandshake(e){var t,n,i,r;return{headers:(null===(t=this.request)||void 0===t?void 0:t.headers)||{},time:new Date+"",address:this.conn.remoteAddress,xdomain:!!(null===(n=this.request)||void 0===n?void 0:n.headers.origin),secure:!this.request||!!this.request.connection.encrypted,issued:+new Date,url:null===(i=this.request)||void 0===i?void 0:i.url,query:(null===(r=this.request)||void 0===r?void 0:r._query)||{},auth:e}}emit(t,...i){if(e.RESERVED_EVENTS.has(t))throw new Error(`"${String(t)}" is a reserved event name`);const r=[t,...i],s={type:n.PacketType.EVENT,data:r};if("function"==typeof r[r.length-1]){const e=this.nsp._ids++;a("emitting packet with ack id %d",e),this.registerAckCallback(e,r.pop()),s.id=e}const o=Object.assign({},this.flags);return this.flags={},this.nsp.server.opts.connectionStateRecovery?this.adapter.broadcast(s,{rooms:new Set([this.id]),except:new Set,flags:o}):(this.notifyOutgoingListeners(s),this.packet(s,o)),!0}emitWithAck(e,...t){const n=void 0!==this.flags.timeout;return new Promise(((i,r)=>{t.push(((e,t)=>n?e?r(e):i(t):i(e))),this.emit(e,...t)}))}registerAckCallback(e,t){const n=this.flags.timeout;if(void 0===n)return void this.acks.set(e,t);const i=setTimeout((()=>{a("event with ack id %d has timed out after %d ms",e,n),this.acks.delete(e),t.call(this,new Error("operation has timed out"))}),n);this.acks.set(e,((...e)=>{clearTimeout(i),t.apply(this,[null,...e])}))}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,t={}){e.nsp=this.nsp.name,t.compress=!1!==t.compress,this.client._packet(e,t)}join(e){return a("join room %s",e),this.adapter.addAll(this.id,new Set(Array.isArray(e)?e:[e]))}leave(e){return a("leave room %s",e),this.adapter.del(this.id,e)}leaveAll(){this.adapter.delAll(this.id)}_onconnect(){a("socket connected - writing packet"),this.connected=!0,this.join(this.id),3===this.conn.protocol?this.packet({type:n.PacketType.CONNECT}):this.packet({type:n.PacketType.CONNECT,data:{sid:this.id,pid:this.pid}})}_onpacket(e){switch(a("got packet %j",e),e.type){case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(e);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(e);break;case n.PacketType.DISCONNECT:this.ondisconnect()}}onevent(e){const t=e.data||[];if(a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const n of e)n.apply(this,t)}this.dispatch(t)}ack(e){const t=this;let i=!1;return function(){if(i)return;const r=Array.prototype.slice.call(arguments);a("sending ack %j",r),t.packet({id:e,type:n.PacketType.ACK,data:r}),i=!0}}onack(e){const t=this.acks.get(e.id);"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),this.acks.delete(e.id)):a("bad ack %s",e.id)}ondisconnect(){a("got disconnect packet"),this._onclose("client namespace disconnect")}_onerror(e){this.emitReserved("error",e)}_onclose(e,t){if(!this.connected)return this;a("closing socket - reason %s",e),this.emitReserved("disconnecting",e,t),this.server._opts.connectionStateRecovery&&c.has(e)&&(a("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,t)}_cleanup(){this.leaveAll(),this.nsp._remove(this),this.join=l}_error(e){this.packet({type:n.PacketType.CONNECT_ERROR,data:e})}disconnect(e=!1){return this.connected?(e?this.client._disconnect():(this.packet({type:n.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){a("dispatching an event %j",e),this.run(e,(t=>{process.nextTick((()=>{if(t)return this._onerror(t);this.connected?super.emitUntyped.apply(this,e):a("ignore packet received after disconnection")}))}))}use(e){return this.fns.push(e),this}run(e,t){const n=this.fns.slice(0);if(!n.length)return t(null);!function i(r){n[r](e,(function(e){return e?t(e):n[r+1]?void i(r+1):t(null)}))}(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){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}newBroadcastOperator(){const e=Object.assign({},this.flags);return this.flags={},new o.BroadcastOperator(this.adapter,new Set,new Set([this.id]),e)}}e.Socket=u}(MJ)),MJ}!function(e){var t=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Namespace=e.RESERVED_EVENTS=void 0;const n=VJ(),i=UJ,r=t(ch),s=GJ(),o=(0,r.default)("socket.io:namespace");e.RESERVED_EVENTS=new Set(["connect","connection","new_namespace"]);class a extends i.StrictEventEmitter{constructor(e,t){super(),this.sockets=new Map,this._fns=[],this._ids=0,this.server=e,this.name=t,this._initAdapter()}_initAdapter(){this.adapter=new(this.server.adapter())(this)}use(e){return this._fns.push(e),this}run(e,t){const n=this._fns.slice(0);if(!n.length)return t(null);!function i(r){n[r](e,(function(e){return e?t(e):n[r+1]?void i(r+1):t(null)}))}(0)}to(e){return new s.BroadcastOperator(this.adapter).to(e)}in(e){return new s.BroadcastOperator(this.adapter).in(e)}except(e){return new s.BroadcastOperator(this.adapter).except(e)}async _add(e,t,n){var i;o("adding socket to nsp %s",this.name);const r=await this._createSocket(e,t);if((null===(i=this.server.opts.connectionStateRecovery)||void 0===i?void 0:i.skipMiddlewares)&&r.recovered&&"open"===e.conn.readyState)return this._doConnect(r,n);this.run(r,(t=>{process.nextTick((()=>"open"!==e.conn.readyState?(o("next called after client was closed - ignoring socket"),void r._cleanup()):t?(o("middleware error, sending CONNECT_ERROR packet to the client"),r._cleanup(),3===e.conn.protocol?r._error(t.data||t.message):r._error({message:t.message,data:t.data})):void this._doConnect(r,n)))}))}async _createSocket(e,t){const i=t.pid,r=t.offset;if(this.server.opts.connectionStateRecovery&&"string"==typeof i&&"string"==typeof r){let s;try{s=await this.adapter.restoreSession(i,r)}catch(e){o("error while restoring session: %s",e)}if(s)return o("connection state recovered for sid %s",s.sid),new n.Socket(this,e,t,s)}return new n.Socket(this,e,t)}_doConnect(e,t){this.sockets.set(e.id,e),e._onconnect(),t&&t(e),this.emitReserved("connect",e),this.emitReserved("connection",e)}_remove(e){this.sockets.has(e.id)?this.sockets.delete(e.id):o("ignoring remove for %s",e.id)}emit(e,...t){return new s.BroadcastOperator(this.adapter).emit(e,...t)}send(...e){return this.emit("message",...e),this}write(...e){return this.emit("message",...e),this}serverSideEmit(t,...n){if(e.RESERVED_EVENTS.has(t))throw new Error(`"${String(t)}" is a reserved event name`);return n.unshift(t),this.adapter.serverSideEmit(n),!0}serverSideEmitWithAck(e,...t){return new Promise(((n,i)=>{t.push(((e,t)=>e?(e.responses=t,i(e)):n(t))),this.serverSideEmit(e,...t)}))}_onServerSideEmit(e){super.emitUntyped.apply(this,e)}allSockets(){return new s.BroadcastOperator(this.adapter).allSockets()}compress(e){return new s.BroadcastOperator(this.adapter).compress(e)}get volatile(){return new s.BroadcastOperator(this.adapter).volatile}get local(){return new s.BroadcastOperator(this.adapter).local}timeout(e){return new s.BroadcastOperator(this.adapter).timeout(e)}fetchSockets(){return new s.BroadcastOperator(this.adapter).fetchSockets()}socketsJoin(e){return new s.BroadcastOperator(this.adapter).socketsJoin(e)}socketsLeave(e){return new s.BroadcastOperator(this.adapter).socketsLeave(e)}disconnectSockets(e=!1){return new s.BroadcastOperator(this.adapter).disconnectSockets(e)}}e.Namespace=a}(BJ);var KJ={},YJ={},ZJ={},QJ={};Object.defineProperty(QJ,"__esModule",{value:!0}),QJ.yeast=QJ.decode=QJ.encode=void 0;const JJ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),XJ=64,eX={};let tX,nX=0,iX=0;function rX(e){let t="";do{t=JJ[e%XJ]+t,e=Math.floor(e/XJ)}while(e>0);return t}for(QJ.encode=rX,QJ.decode=function(e){let t=0;for(iX=0;iX<e.length;iX++)t=t*XJ+eX[e.charAt(iX)];return t},QJ.yeast=function(){const e=rX(+new Date);return e!==tX?(nX=0,tX=e):e+"."+rX(nX++)};iX<XJ;iX++)eX[JJ[iX]]=iX;var sX;Object.defineProperty(ZJ,"__esModule",{value:!0}),ZJ.SessionAwareAdapter=ZJ.Adapter=void 0;const oX=p,aX=QJ,cX=CQ,lX="function"==typeof(null===(sX=null==cX?void 0:cX.Sender)||void 0===sX?void 0:sX.frame);class uX extends oX.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,t){this.sids.has(e)||this.sids.set(e,new Set);for(const n of t)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,t){this.sids.has(e)&&this.sids.get(e).delete(t),this._del(t,e)}_del(e,t){const n=this.rooms.get(e);if(null!=n){n.delete(t)&&this.emit("leave-room",e,t),0===n.size&&this.rooms.delete(e)&&this.emit("delete-room",e)}}delAll(e){if(this.sids.has(e)){for(const t of this.sids.get(e))this._del(t,e);this.sids.delete(e)}}broadcast(e,t){const n=t.flags||{},i={preEncoded:!0,volatile:n.volatile,compress:n.compress};e.nsp=this.nsp.name;const r=this._encode(e,i);this.apply(t,(t=>{"function"==typeof t.notifyOutgoingListeners&&t.notifyOutgoingListeners(e),t.client.writeToEngine(r,i)}))}broadcastWithAck(e,t,n,i){const r=t.flags||{},s={preEncoded:!0,volatile:r.volatile,compress:r.compress};e.nsp=this.nsp.name,e.id=this.nsp._ids++;const o=this._encode(e,s);let a=0;this.apply(t,(t=>{a++,t.acks.set(e.id,i),"function"==typeof t.notifyOutgoingListeners&&t.notifyOutgoingListeners(e),t.client.writeToEngine(o,s)})),n(a)}_encode(e,t){const n=this.encoder.encode(e);if(lX&&1===n.length&&"string"==typeof n[0]){const e=Buffer.from("4"+n[0]);t.wsPreEncodedFrame=cX.Sender.frame(e,{readOnly:!1,mask:!1,rsv1:!1,opcode:1,fin:!0})}return n}sockets(e){const t=new Set;return this.apply({rooms:e},(e=>{t.add(e.id)})),Promise.resolve(t)}socketRooms(e){return this.sids.get(e)}fetchSockets(e){const t=[];return this.apply(e,(e=>{t.push(e)})),Promise.resolve(t)}addSockets(e,t){this.apply(e,(e=>{e.join(t)}))}delSockets(e,t){this.apply(e,(e=>{t.forEach((t=>e.leave(t)))}))}disconnectSockets(e,t){this.apply(e,(e=>{e.disconnect(t)}))}apply(e,t){const n=e.rooms,i=this.computeExceptSids(e.except);if(n.size){const e=new Set;for(const r of n)if(this.rooms.has(r))for(const n of this.rooms.get(r)){if(e.has(n)||i.has(n))continue;const r=this.nsp.sockets.get(n);r&&(t(r),e.add(n))}}else for(const[e]of this.sids){if(i.has(e))continue;const n=this.nsp.sockets.get(e);n&&t(n)}}computeExceptSids(e){const t=new Set;if(e&&e.size>0)for(const n of e)this.rooms.has(n)&&this.rooms.get(n).forEach((e=>t.add(e)));return t}serverSideEmit(e){console.warn("this adapter does not support the serverSideEmit() functionality")}persistSession(e){}restoreSession(e,t){return null}}ZJ.Adapter=uX;function pX(e,t){const n=0===t.rooms.size||e.some((e=>t.rooms.has(e))),i=e.every((e=>!t.except.has(e)));return n&&i}ZJ.SessionAwareAdapter=class extends uX{constructor(e){super(e),this.nsp=e,this.sessions=new Map,this.packets=[],this.maxDisconnectionDuration=e.server.opts.connectionStateRecovery.maxDisconnectionDuration;const t=setInterval((()=>{const e=Date.now()-this.maxDisconnectionDuration;this.sessions.forEach(((t,n)=>{t.disconnectedAt<e&&this.sessions.delete(n)}));for(let t=this.packets.length-1;t>=0;t--){if(this.packets[t].emittedAt<e){this.packets.splice(0,t+1);break}}}),6e4);t.unref()}persistSession(e){e.disconnectedAt=Date.now(),this.sessions.set(e.pid,e)}restoreSession(e,t){const n=this.sessions.get(e);if(!n)return null;if(n.disconnectedAt+this.maxDisconnectionDuration<Date.now())return this.sessions.delete(e),null;const i=this.packets.findIndex((e=>e.id===t));if(-1===i)return null;const r=[];for(let e=i+1;e<this.packets.length;e++){const t=this.packets[e];pX(n.rooms,t.opts)&&r.push(t.data)}return Promise.resolve(Object.assign(Object.assign({},n),{missedPackets:r}))}broadcast(e,t){var n;const i=2===e.type,r=void 0===e.id,s=void 0===(null===(n=t.flags)||void 0===n?void 0:n.volatile);if(i&&r&&s){const n=(0,aX.yeast)();e.data.push(n),this.packets.push({id:n,opts:t,data:e.data,emittedAt:Date.now()})}super.broadcast(e,t)}};var hX={};!function(e){var t=H&&H.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.ClusterAdapterWithHeartbeat=e.ClusterAdapter=e.MessageType=void 0;const n=ZJ,i=w,r=(0,ch.debug)("socket.io-adapter"),s=5e3;function o(){return(0,i.randomBytes)(8).toString("hex")}var a;function c(e){return{rooms:[...e.rooms],except:[...e.except],flags:e.flags}}function l(e){return{rooms:new Set(e.rooms),except:new Set(e.except),flags:e.flags}}!function(e){e[e.INITIAL_HEARTBEAT=1]="INITIAL_HEARTBEAT",e[e.HEARTBEAT=2]="HEARTBEAT",e[e.BROADCAST=3]="BROADCAST",e[e.SOCKETS_JOIN=4]="SOCKETS_JOIN",e[e.SOCKETS_LEAVE=5]="SOCKETS_LEAVE",e[e.DISCONNECT_SOCKETS=6]="DISCONNECT_SOCKETS",e[e.FETCH_SOCKETS=7]="FETCH_SOCKETS",e[e.FETCH_SOCKETS_RESPONSE=8]="FETCH_SOCKETS_RESPONSE",e[e.SERVER_SIDE_EMIT=9]="SERVER_SIDE_EMIT",e[e.SERVER_SIDE_EMIT_RESPONSE=10]="SERVER_SIDE_EMIT_RESPONSE",e[e.BROADCAST_CLIENT_COUNT=11]="BROADCAST_CLIENT_COUNT",e[e.BROADCAST_ACK=12]="BROADCAST_ACK",e[e.ADAPTER_CLOSE=13]="ADAPTER_CLOSE"}(a=e.MessageType||(e.MessageType={}));class u extends n.Adapter{constructor(e){super(e),this.requests=new Map,this.ackRequests=new Map,this.uid=o()}onMessage(e,n){if(e.uid===this.uid)return r("[%s] ignore message from self",this.uid);switch(r("[%s] new event of type %d from %s",this.uid,e.type,e.uid),e.type){case a.BROADCAST:if(void 0!==e.data.requestId)super.broadcastWithAck(e.data.packet,l(e.data.opts),(t=>{r("[%s] waiting for %d client acknowledgements",this.uid,t),this.publishResponse(e.uid,{type:a.BROADCAST_CLIENT_COUNT,data:{requestId:e.data.requestId,clientCount:t}})}),(t=>{r("[%s] received acknowledgement with value %j",this.uid,t),this.publishResponse(e.uid,{type:a.BROADCAST_ACK,data:{requestId:e.data.requestId,packet:t}})}));else{const t=e.data.packet,i=l(e.data.opts);this.addOffsetIfNecessary(t,i,n),super.broadcast(t,i)}break;case a.SOCKETS_JOIN:super.addSockets(l(e.data.opts),e.data.rooms);break;case a.SOCKETS_LEAVE:super.delSockets(l(e.data.opts),e.data.rooms);break;case a.DISCONNECT_SOCKETS:super.disconnectSockets(l(e.data.opts),e.data.close);break;case a.FETCH_SOCKETS:r("[%s] calling fetchSockets with opts %j",this.uid,e.data.opts),super.fetchSockets(l(e.data.opts)).then((n=>{this.publishResponse(e.uid,{type:a.FETCH_SOCKETS_RESPONSE,data:{requestId:e.data.requestId,sockets:n.map((e=>{const n=e.handshake,i=t(n,["sessionStore"]);return{id:e.id,handshake:i,rooms:[...e.rooms],data:e.data}}))}})}));break;case a.SERVER_SIDE_EMIT:{const t=e.data.packet;if(!(void 0!==e.data.requestId))return void this.nsp._onServerSideEmit(t);let n=!1;const i=t=>{n||(n=!0,r("[%s] calling acknowledgement with %j",this.uid,t),this.publishResponse(e.uid,{type:a.SERVER_SIDE_EMIT_RESPONSE,data:{requestId:e.data.requestId,packet:t}}))};this.nsp._onServerSideEmit([...t,i]);break}case a.BROADCAST_CLIENT_COUNT:case a.BROADCAST_ACK:case a.FETCH_SOCKETS_RESPONSE:case a.SERVER_SIDE_EMIT_RESPONSE:this.onResponse(e);break;default:r("[%s] unknown message type: %s",this.uid,e.type)}}onResponse(e){var t,n;const i=e.data.requestId;switch(r("[%s] received response %s to request %s",this.uid,e.type,i),e.type){case a.BROADCAST_CLIENT_COUNT:null===(t=this.ackRequests.get(i))||void 0===t||t.clientCountCallback(e.data.clientCount);break;case a.BROADCAST_ACK:null===(n=this.ackRequests.get(i))||void 0===n||n.ack(e.data.packet);break;case a.FETCH_SOCKETS_RESPONSE:{const t=this.requests.get(i);if(!t)return;t.current++,e.data.sockets.forEach((e=>t.responses.push(e))),t.current===t.expected&&(clearTimeout(t.timeout),t.resolve(t.responses),this.requests.delete(i));break}case a.SERVER_SIDE_EMIT_RESPONSE:{const t=this.requests.get(i);if(!t)return;t.current++,t.responses.push(e.data.packet),t.current===t.expected&&(clearTimeout(t.timeout),t.resolve(null,t.responses),this.requests.delete(i));break}default:r("[%s] unknown response type: %s",this.uid,e.type)}}async broadcast(e,t){var n;if(!(null===(n=t.flags)||void 0===n?void 0:n.local))try{const n=await this.publishAndReturnOffset({type:a.BROADCAST,data:{packet:e,opts:c(t)}});this.addOffsetIfNecessary(e,t,n)}catch(e){return r("[%s] error while broadcasting message: %s",this.uid,e.message)}super.broadcast(e,t)}addOffsetIfNecessary(e,t,n){var i;if(!this.nsp.server.opts.connectionStateRecovery)return;const r=2===e.type,s=void 0===e.id,o=void 0===(null===(i=t.flags)||void 0===i?void 0:i.volatile);r&&s&&o&&e.data.push(n)}broadcastWithAck(e,t,n,i){var r;if(!(null===(r=null==t?void 0:t.flags)||void 0===r?void 0:r.local)){const r=o();this.ackRequests.set(r,{clientCountCallback:n,ack:i}),this.publish({type:a.BROADCAST,data:{packet:e,requestId:r,opts:c(t)}}),setTimeout((()=>{this.ackRequests.delete(r)}),t.flags.timeout)}super.broadcastWithAck(e,t,n,i)}async addSockets(e,t){var n;if(!(null===(n=e.flags)||void 0===n?void 0:n.local))try{await this.publishAndReturnOffset({type:a.SOCKETS_JOIN,data:{opts:c(e),rooms:t}})}catch(e){r("[%s] error while publishing message: %s",this.uid,e.message)}super.addSockets(e,t)}async delSockets(e,t){var n;if(!(null===(n=e.flags)||void 0===n?void 0:n.local))try{await this.publishAndReturnOffset({type:a.SOCKETS_LEAVE,data:{opts:c(e),rooms:t}})}catch(e){r("[%s] error while publishing message: %s",this.uid,e.message)}super.delSockets(e,t)}async disconnectSockets(e,t){var n;if(!(null===(n=e.flags)||void 0===n?void 0:n.local))try{await this.publishAndReturnOffset({type:a.DISCONNECT_SOCKETS,data:{opts:c(e),close:t}})}catch(e){r("[%s] error while publishing message: %s",this.uid,e.message)}super.disconnectSockets(e,t)}async fetchSockets(e){var t;const[n,i]=await Promise.all([super.fetchSockets(e),this.serverCount()]),r=i-1;if((null===(t=e.flags)||void 0===t?void 0:t.local)||r<=0)return n;const l=o();return new Promise(((t,i)=>{const o=setTimeout((()=>{const e=this.requests.get(l);e&&(i(new Error(`timeout reached: only ${e.current} responses received out of ${e.expected}`)),this.requests.delete(l))}),e.flags.timeout||s),u={type:a.FETCH_SOCKETS,resolve:t,timeout:o,current:0,expected:r,responses:n};this.requests.set(l,u),this.publish({type:a.FETCH_SOCKETS,data:{opts:c(e),requestId:l}})}))}async serverSideEmit(e){if(!("function"==typeof e[e.length-1]))return this.publish({type:a.SERVER_SIDE_EMIT,data:{packet:e}});const t=e.pop(),n=await this.serverCount()-1;if(r('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,n),n<=0)return t(null,[]);const i=o(),c=setTimeout((()=>{const e=this.requests.get(i);e&&(t(new Error(`timeout reached: only ${e.current} responses received out of ${e.expected}`),e.responses),this.requests.delete(i))}),s),l={type:a.SERVER_SIDE_EMIT,resolve:t,timeout:c,current:0,expected:n,responses:[]};this.requests.set(i,l),this.publish({type:a.SERVER_SIDE_EMIT,data:{requestId:i,packet:e}})}publish(e){this.publishAndReturnOffset(e).catch((e=>{r("[%s] error while publishing message: %s",this.uid,e)}))}publishAndReturnOffset(e){return e.uid=this.uid,e.nsp=this.nsp.name,this.doPublish(e)}publishResponse(e,t){t.uid=this.uid,t.nsp=this.nsp.name,this.doPublishResponse(e,t).catch((e=>{r("[%s] error while publishing response: %s",this.uid,e)}))}}e.ClusterAdapter=u;e.ClusterAdapterWithHeartbeat=class extends u{constructor(e,t){super(e),this.nodesMap=new Map,this.customRequests=new Map,this._opts=Object.assign({heartbeatInterval:5e3,heartbeatTimeout:1e4},t),this.cleanupTimer=setInterval((()=>{const e=Date.now();this.nodesMap.forEach(((t,n)=>{e-t>this._opts.heartbeatTimeout&&(r("[%s] node %s seems down",this.uid,n),this.removeNode(n))}))}),1e3)}init(){this.publish({type:a.INITIAL_HEARTBEAT})}scheduleHeartbeat(){this.heartbeatTimer?this.heartbeatTimer.refresh():this.heartbeatTimer=setTimeout((()=>{this.publish({type:a.HEARTBEAT})}),this._opts.heartbeatInterval)}close(){this.publish({type:a.ADAPTER_CLOSE}),clearTimeout(this.heartbeatTimer),this.cleanupTimer&&clearInterval(this.cleanupTimer)}onMessage(e,t){if(e.uid===this.uid)return r("[%s] ignore message from self",this.uid);switch(e.uid&&"emitter"!==e.uid&&this.nodesMap.set(e.uid,Date.now()),r("[%s] new event of type %d from %s",this.uid,e.type,e.uid),e.type){case a.INITIAL_HEARTBEAT:this.publish({type:a.HEARTBEAT});break;case a.HEARTBEAT:break;case a.ADAPTER_CLOSE:this.removeNode(e.uid);break;default:super.onMessage(e,t)}}serverCount(){return Promise.resolve(1+this.nodesMap.size)}publish(e){return this.scheduleHeartbeat(),super.publish(e)}async serverSideEmit(e){if(!("function"==typeof e[e.length-1]))return this.publish({type:a.SERVER_SIDE_EMIT,data:{packet:e}});const t=e.pop(),n=this.nodesMap.size;if(r('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,n),n<=0)return t(null,[]);const i=o(),c=setTimeout((()=>{const e=this.customRequests.get(i);e&&(t(new Error(`timeout reached: missing ${e.missingUids.size} responses`),e.responses),this.customRequests.delete(i))}),s),l={type:a.SERVER_SIDE_EMIT,resolve:t,timeout:c,missingUids:new Set([...this.nodesMap.keys()]),responses:[]};this.customRequests.set(i,l),this.publish({type:a.SERVER_SIDE_EMIT,data:{requestId:i,packet:e}})}async fetchSockets(e){var t;const[n,i]=await Promise.all([super.fetchSockets({rooms:e.rooms,except:e.except,flags:{local:!0}}),this.serverCount()]),r=i-1;if((null===(t=e.flags)||void 0===t?void 0:t.local)||r<=0)return n;const l=o();return new Promise(((t,i)=>{const r=setTimeout((()=>{const e=this.customRequests.get(l);e&&(i(new Error(`timeout reached: missing ${e.missingUids.size} responses`)),this.customRequests.delete(l))}),e.flags.timeout||s),o={type:a.FETCH_SOCKETS,resolve:t,timeout:r,missingUids:new Set([...this.nodesMap.keys()]),responses:n};this.customRequests.set(l,o),this.publish({type:a.FETCH_SOCKETS,data:{opts:c(e),requestId:l}})}))}onResponse(e){const t=e.data.requestId;switch(r("[%s] received response %s to request %s",this.uid,e.type,t),e.type){case a.FETCH_SOCKETS_RESPONSE:{const n=this.customRequests.get(t);if(!n)return;e.data.sockets.forEach((e=>n.responses.push(e))),n.missingUids.delete(e.uid),0===n.missingUids.size&&(clearTimeout(n.timeout),n.resolve(n.responses),this.customRequests.delete(t));break}case a.SERVER_SIDE_EMIT_RESPONSE:{const n=this.customRequests.get(t);if(!n)return;n.responses.push(e.data.packet),n.missingUids.delete(e.uid),0===n.missingUids.size&&(clearTimeout(n.timeout),n.resolve(null,n.responses),this.customRequests.delete(t));break}default:super.onResponse(e)}}removeNode(e){this.customRequests.forEach(((t,n)=>{t.missingUids.delete(e),0===t.missingUids.size&&(clearTimeout(t.timeout),t.type===a.FETCH_SOCKETS?t.resolve(t.responses):t.type===a.SERVER_SIDE_EMIT&&t.resolve(null,t.responses),this.customRequests.delete(n))})),this.nodesMap.delete(e)}}}(hX),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MessageType=e.ClusterAdapterWithHeartbeat=e.ClusterAdapter=e.SessionAwareAdapter=e.Adapter=void 0;var t=ZJ;Object.defineProperty(e,"Adapter",{enumerable:!0,get:function(){return t.Adapter}}),Object.defineProperty(e,"SessionAwareAdapter",{enumerable:!0,get:function(){return t.SessionAwareAdapter}});var n=hX;Object.defineProperty(e,"ClusterAdapter",{enumerable:!0,get:function(){return n.ClusterAdapter}}),Object.defineProperty(e,"ClusterAdapterWithHeartbeat",{enumerable:!0,get:function(){return n.ClusterAdapterWithHeartbeat}}),Object.defineProperty(e,"MessageType",{enumerable:!0,get:function(){return n.MessageType}})}(YJ);var dX=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(KJ,"__esModule",{value:!0}),KJ.ParentNamespace=void 0;const fX=BJ,mX=YJ,gX=(0,dX(ch).default)("socket.io:parent-namespace");class yX extends fX.Namespace{constructor(e){super(e,"/_"+yX.count++),this.children=new Set}_initAdapter(){this.adapter=new vX(this,this.children)}emit(e,...t){return this.children.forEach((n=>{n.emit(e,...t)})),!0}createChild(e){gX("creating child namespace %s",e);const t=new fX.Namespace(this.server,e);if(t._fns=this._fns.slice(0),this.listeners("connect").forEach((e=>t.on("connect",e))),this.listeners("connection").forEach((e=>t.on("connection",e))),this.children.add(t),this.server._opts.cleanupEmptyChildNamespaces){const n=t._remove;t._remove=i=>{n.call(t,i),0===t.sockets.size&&(gX("closing child namespace %s",e),t.adapter.close(),this.server._nsps.delete(t.name),this.children.delete(t))}}return this.server._nsps.set(e,t),this.server.sockets.emitReserved("new_namespace",t),t}fetchSockets(){throw new Error("fetchSockets() is not supported on parent namespaces")}}KJ.ParentNamespace=yX,yX.count=0;class vX extends mX.Adapter{constructor(e,t){super(e),this.children=t}broadcast(e,t){this.children.forEach((n=>{n.adapter.broadcast(e,t)}))}}var bX={},_X=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bX,"__esModule",{value:!0}),bX.serveFile=bX.restoreAdapter=bX.patchAdapter=void 0;const wX=YJ,xX=s,EX=(0,_X(ch).default)("socket.io:adapter-uws"),SX="",{addAll:kX,del:TX,broadcast:AX}=wX.Adapter.prototype;function DX(e,t,n,i){const r=t.conn.id,s=t.conn.transport.socket;n&&(EX("subscribe connection %s to topic %s",r,e),s.subscribe(e)),i.forEach((t=>{const n=`${e}${SX}${t}`;EX("subscribe connection %s to topic %s",r,n),s.subscribe(n)}))}bX.patchAdapter=function(e){wX.Adapter.prototype.addAll=function(e,t){const n=!this.sids.has(e);kX.call(this,e,t);const i=this.nsp.sockets.get(e);i&&("websocket"!==i.conn.transport.name?n&&i.conn.on("upgrade",(()=>{const t=this.sids.get(e);t&&DX(this.nsp.name,i,n,t)})):DX(this.nsp.name,i,n,t))},wX.Adapter.prototype.del=function(e,t){TX.call(this,e,t);const n=this.nsp.sockets.get(e);if(n&&"websocket"===n.conn.transport.name){const e=n.conn.id,i=n.conn.transport.socket,r=`${this.nsp.name}${SX}${t}`;EX("unsubscribe connection %s from topic %s",e,r),i.unsubscribe(r)}},wX.Adapter.prototype.broadcast=function(t,n){if(!(n.rooms.size<=1&&0===n.except.size))return void AX.call(this,t,n);const i=n.flags||{},r={preEncoded:!0,volatile:i.volatile,compress:i.compress};t.nsp=this.nsp.name;const s=this.encoder.encode(t),o=0===n.rooms.size?this.nsp.name:`${this.nsp.name}${SX}${n.rooms.keys().next().value}`;EX("fast publish to %s",o),s.forEach((t=>{const n="string"!=typeof t;e.publish(o,n?t:"4"+t,n)})),this.apply(n,(e=>{"websocket"!==e.conn.transport.name&&e.client.writeToEngine(s,r)}))}},bX.restoreAdapter=function(){wX.Adapter.prototype.addAll=kX,wX.Adapter.prototype.del=TX,wX.Adapter.prototype.broadcast=AX};bX.serveFile=function(e,t){const{size:n}=(0,xX.statSync)(t),i=(0,xX.createReadStream)(t),r=()=>!i.destroyed&&i.destroy();e.onAborted(r),i.on("data",(t=>{const r=(e=>{const{buffer:t,byteOffset:n,byteLength:i}=e;return t.slice(n,n+i)})(t),s=e.getWriteOffset(),[o,a]=e.tryEnd(r,n);a||o||(i.pause(),e.onWritable((t=>{const[o,a]=e.tryEnd(r.slice(t-s),n);return!a&&o&&i.resume(),o})))})).on("error",(e=>{throw r(),e})).on("end",r)};var CX="4.7.5";!function(e,t){var n=H&&H.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),i=H&&H.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=H&&H.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Namespace=t.Socket=t.Server=void 0;const c=x,l=s,u=k,d=$U,f=h,m=o,g=gV,y=_J,v=p,b=BJ;Object.defineProperty(t,"Namespace",{enumerable:!0,get:function(){return b.Namespace}});const _=KJ,w=YJ,E=r(wJ),S=a(ch),T=VJ();Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return T.Socket}});const A=UJ,D=bX,C=a(PQ),O=(0,S.default)("socket.io:server"),R=CX,L=/\.map/;class I extends A.StrictEventEmitter{constructor(e,t={}){super(),this._nsps=new Map,this.parentNsps=new Map,this.parentNamespacesFromRegExp=new Map,"object"==typeof e&&e instanceof Object&&!e.listen&&(t=e,e=void 0),this.path(t.path||"/socket.io"),this.connectTimeout(t.connectTimeout||45e3),this.serveClient(!1!==t.serveClient),this._parser=t.parser||E,this.encoder=new this._parser.Encoder,this.opts=t,t.connectionStateRecovery?(t.connectionStateRecovery=Object.assign({maxDisconnectionDuration:12e4,skipMiddlewares:!0},t.connectionStateRecovery),this.adapter(t.adapter||w.SessionAwareAdapter)):this.adapter(t.adapter||w.Adapter),t.cleanupEmptyChildNamespaces=!!t.cleanupEmptyChildNamespaces,this.sockets=this.of("/"),(e||"number"==typeof e)&&this.attach(e),this.opts.cors&&(this._corsMiddleware=(0,C.default)(this.opts.cors))}get _opts(){return this.opts}serveClient(e){return arguments.length?(this._serveClient=e,this):this._serveClient}_checkNamespace(e,t,n){if(0===this.parentNsps.size)return n(!1);const i=this.parentNsps.keys(),r=()=>{const s=i.next();if(s.done)return n(!1);s.value(e,t,((t,i)=>{if(t||!i)return r();if(this._nsps.has(e))return O("dynamic namespace %s already exists",e),n(this._nsps.get(e));const o=this.parentNsps.get(s.value).createChild(e);O("dynamic namespace %s was created",e),n(o)}))};r()}path(e){if(!arguments.length)return this._path;this._path=e.replace(/\/$/,"");const t=this._path.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");return this.clientPathRegex=new RegExp("^"+t+"/socket\\.io(\\.msgpack|\\.esm)?(\\.min)?\\.js(\\.map)?(?:\\?|$)"),this}connectTimeout(e){return void 0===e?this._connectTimeout:(this._connectTimeout=e,this)}adapter(e){if(!arguments.length)return this._adapter;this._adapter=e;for(const e of this._nsps.values())e._initAdapter();return this}listen(e,t={}){return this.attach(e,t)}attach(e,t={}){if("function"==typeof e){throw new Error("You are trying to attach socket.io to an express request handler function. Please pass a http.Server instance.")}if(Number(e)==e&&(e=Number(e)),"number"==typeof e){O("creating http server and binding to %d",e);const t=e;e=c.createServer(((e,t)=>{t.writeHead(404),t.end()})),e.listen(t)}return Object.assign(t,this.opts),t.path=t.path||this._path,this.initEngine(e,t),this}attachApp(e,t={}){Object.assign(t,this.opts),t.path=t.path||this._path,O("creating uWebSockets.js-based engine with opts %j",t);const n=new g.uServer(t);n.attach(e,t),this.bind(n),this._serveClient&&e.get(`${this._path}/*`,((e,t)=>{if(!this.clientPathRegex.test(t.getUrl()))return void t.setYield(!0);const n=t.getUrl().replace(this._path,"").replace(/\?.*$/,"").replace(/^\//,""),i=L.test(n),r=i?"map":"source",s='"'+R+'"',o="W/"+s,a=t.getHeader("if-none-match");if(a&&(s===a||o===a))return O("serve client %s 304",r),e.writeStatus("304 Not Modified"),void e.end();O("serve client %s",r),e.writeHeader("cache-control","public, max-age=0"),e.writeHeader("content-type","application/"+(i?"json":"javascript")+"; charset=utf-8"),e.writeHeader("etag",s);const c=m.join(__dirname,"../client-dist/",n);(0,D.serveFile)(e,c)})),(0,D.patchAdapter)(e)}initEngine(e,t){O("creating engine.io instance with opts %j",t),this.eio=(0,g.attach)(e,t),this._serveClient&&this.attachServe(e),this.httpServer=e,this.bind(this.eio)}attachServe(e){O("attaching client serving req handler");const t=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 r=0;r<t.length;r++)t[r].call(e,n,i)}))}serve(e,t){const n=e.url.replace(this._path,"").replace(/\?.*$/,""),i=L.test(n),r=i?"map":"source",s='"'+R+'"',o="W/"+s,a=e.headers["if-none-match"];if(a&&(s===a||o===a))return O("serve client %s 304",r),t.writeHead(304),void t.end();O("serve client %s",r),t.setHeader("Cache-Control","public, max-age=0"),t.setHeader("Content-Type","application/"+(i?"json":"javascript")+"; charset=utf-8"),t.setHeader("ETag",s),I.sendFile(n,e,t)}static sendFile(e,t,n){const i=(0,l.createReadStream)(m.join(__dirname,"../client-dist/",e)),r=e=>{e&&n.end()};switch(d(t).encodings(["br","gzip","deflate"])){case"br":n.writeHead(200,{"content-encoding":"br"}),(0,f.pipeline)(i,(0,u.createBrotliCompress)(),n,r);break;case"gzip":n.writeHead(200,{"content-encoding":"gzip"}),(0,f.pipeline)(i,(0,u.createGzip)(),n,r);break;case"deflate":n.writeHead(200,{"content-encoding":"deflate"}),(0,f.pipeline)(i,(0,u.createDeflate)(),n,r);break;default:n.writeHead(200),(0,f.pipeline)(i,n,r)}}bind(e){return this.engine=e,this.engine.on("connection",this.onconnection.bind(this)),this}onconnection(e){O("incoming connection with id %s",e.id);const t=new y.Client(this,e);return 3===e.protocol&&t.connect("/"),this}of(e,t){if("function"==typeof e||e instanceof RegExp){const n=new _.ParentNamespace(this);return O("initializing parent namespace %s",n.name),"function"==typeof e?this.parentNsps.set(e,n):(this.parentNsps.set(((t,n,i)=>i(null,e.test(t))),n),this.parentNamespacesFromRegExp.set(e,n)),t&&n.on("connect",t),n}"/"!==String(e)[0]&&(e="/"+e);let n=this._nsps.get(e);if(!n){for(const[t,n]of this.parentNamespacesFromRegExp)if(t.test(e))return O("attaching namespace %s to parent namespace %s",e,t),n.createChild(e);O("initializing namespace %s",e),n=new b.Namespace(this,e),this._nsps.set(e,n),"/"!==e&&this.sockets.emitReserved("new_namespace",n)}return t&&n.on("connect",t),n}close(e){this._nsps.forEach((e=>{e.sockets.forEach((e=>{e._onclose("server shutting down")})),e.adapter.close()})),this.engine.close(),(0,D.restoreAdapter)(),this.httpServer?this.httpServer.close(e):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,...t){return this.sockets.serverSideEmit(e,...t)}serverSideEmitWithAck(e,...t){return this.sockets.serverSideEmitWithAck(e,...t)}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)}}t.Server=I;const N=Object.keys(v.EventEmitter.prototype).filter((function(e){return"function"==typeof v.EventEmitter.prototype[e]}));N.forEach((function(e){I.prototype[e]=function(){return this.sockets[e].apply(this.sockets,arguments)}})),e.exports=(e,t)=>new I(e,t),e.exports.Server=I,e.exports.Namespace=b.Namespace,e.exports.Socket=T.Socket,VJ()}(mV,mV.exports);var OX=z(mV.exports);const{Server:RX,Namespace:LX,Socket:IX}=OX,NX=e=>new Promise(((t,n)=>{const i=a.platform();let r;if("win32"===i)r=`start ${e}`;else if("darwin"===i)r=`open ${e}`;else{if("linux"!==i)return n(new Error(`Unsupported platform: ${i}`));r=`xdg-open ${e}`}d.exec(r,(e=>{if(e)return n(new Error(`Failed to open URL on ${i}: ${e.message}`));t()}))}));class PX extends Error{constructor(e){super(`${e} is locked`)}}const jX={old:new Set,young:new Set};let FX;const BX=e=>new Promise(((t,n)=>{const i=F.createServer();i.unref(),i.on("error",n),i.listen(e,(()=>{const{port:e}=i.address();i.close((()=>{t(e)}))}))})),MX=async(e,t)=>{if(e.host||0===e.port)return BX(e);for(const n of t)try{await BX({port:e.port,host:n})}catch(e){if(!["EADDRNOTAVAIL","EINVAL"].includes(e.code))throw e}return e.port};async function UX(e){let t,n=new Set;if(e&&(e.port&&(t="number"==typeof e.port?[e.port]:e.port),e.exclude)){const t=e.exclude;if("function"!=typeof t[Symbol.iterator])throw new TypeError("The `exclude` option must be an iterable.");for(const e of t){if("number"!=typeof e)throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(e))throw new TypeError(`Number ${e} in the exclude option is not a safe integer and can't be used`)}n=new Set(t)}void 0===FX&&(FX=setTimeout((()=>{FX=void 0,jX.old=jX.young,jX.young=new Set}),15e3),FX.unref&&FX.unref());const i=(()=>{const e=B.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(const n of Object.values(e))for(const e of n)t.add(e.address);return t})();for(const r of function*(e){e&&(yield*e),yield 0}(t))try{if(n.has(r))continue;let t=await MX({...e,port:r},i);for(;jX.old.has(t)||jX.young.has(t);){if(0!==r)throw new PX(r);t=await MX({...e,port:r},i)}return jX.young.add(t),t}catch(e){if(!(["EADDRINUSE","EACCES"].includes(e.code)||e instanceof PX))throw e}throw new Error("No available ports found")}var qX=z((function(e,t="https://khalaf.qumra.cloud"){return e.toString().includes("localhost")&&(e=t),`https://api.qumra.cloud/templateEngine/v1/render?path=${encodeURIComponent(e)}`}));var $X=(e,t)=>{const{token:n,qvid:i,qaid:r,qdid:s}=e.cookies??{},o=e.cookies?.["qg-token"],a={"Content-Type":"application/json","User-Agent":e.headers["user-agent"]??"",Referer:e.headers.referer??"","X-Forwarded-For":e.headers["x-forwarded-for"]??e.connection.remoteAddress??"","Accept-Language":e.headers["accept-language"]??"","X-Device-Type":e.headers["x-device-type"]??"unknown","X-OS":e.headers["x-os"]??"unknown","X-Timezone":e.headers["x-timezone"]??"UTC"};return a["X-Subdomain"]=t,n&&(a.Authorization=n),i&&(a.qvid=i),r&&(a.qaid=r),s&&(a.qdid=s),o&&(a["qg-token"]=o),a},HX=z($X),zX={exports:{}},WX=Array.prototype,GX=Object.prototype,VX={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},KX=/[&"'<>\\]/g,YX=zX.exports={};function ZX(e,t){return GX.hasOwnProperty.call(e,t)}function QX(e){return VX[e]}function JX(e,t,n){var i,r,s;if(e instanceof Error&&(e=(r=e).name+": "+r.message),Object.setPrototypeOf?(i=new Error(e),Object.setPrototypeOf(i,JX.prototype)):(i=this,Object.defineProperty(i,"message",{enumerable:!1,writable:!0,value:e})),Object.defineProperty(i,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(i,this.constructor),r){var o=Object.getOwnPropertyDescriptor(r,"stack");(s=o&&(o.get||function(){return o.value}))||(s=function(){return r.stack})}else{var a=new Error(e).stack;s=function(){return a}}return Object.defineProperty(i,"stack",{get:function(){return s.call(i)}}),Object.defineProperty(i,"cause",{value:r}),i.lineno=t,i.colno=n,i.firstUpdate=!0,i.Update=function(e){var t="("+(e||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?t+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(t+=" [Line "+this.lineno+"]")),t+="\n ",this.firstUpdate&&(t+=" "),this.message=t+(this.message||""),this.firstUpdate=!1,this},i}function XX(e){return"[object Function]"===GX.toString.call(e)}function e0(e){return"[object Array]"===GX.toString.call(e)}function t0(e){return"[object String]"===GX.toString.call(e)}function n0(e){return"[object Object]"===GX.toString.call(e)}function i0(e){var t,n=(t=e)?"string"==typeof t?t.split("."):[t]:[];return function(e){for(var t=e,i=0;i<n.length;i++){var r=n[i];if(!ZX(t,r))return;t=t[r]}return t}}function r0(e){return Array.prototype.slice.call(e)}function s0(e,t,n){return Array.prototype.indexOf.call(e||[],t,n)}function o0(e){var t=[];for(var n in e)ZX(e,n)&&t.push(n);return t}YX.hasOwnProp=ZX,YX._prettifyError=function(e,t,n){if(n.Update||(n=new YX.TemplateError(n)),n.Update(e),!t){var i=n;(n=new Error(i.message)).name=i.name}return n},Object.setPrototypeOf?Object.setPrototypeOf(JX.prototype,Error.prototype):JX.prototype=Object.create(Error.prototype,{constructor:{value:JX}}),YX.TemplateError=JX,YX.escape=function(e){return e.replace(KX,QX)},YX.isFunction=XX,YX.isArray=e0,YX.isString=t0,YX.isObject=n0,YX.getAttrGetter=i0,YX.groupBy=function(e,t,n){for(var i={},r=XX(t)?t:i0(t),s=0;s<e.length;s++){var o=e[s],a=r(o,s);if(void 0===a&&!0===n)throw new TypeError('groupby: attribute "'+t+'" resolved to undefined');(i[a]||(i[a]=[])).push(o)}return i},YX.toArray=r0,YX.without=function(e){var t=[];if(!e)return t;for(var n=e.length,i=r0(arguments).slice(1),r=-1;++r<n;)-1===s0(i,e[r])&&t.push(e[r]);return t},YX.repeat=function(e,t){for(var n="",i=0;i<t;i++)n+=e;return n},YX.each=function(e,t,n){if(null!=e)if(WX.forEach&&e.forEach===WX.forEach)e.forEach(t,n);else if(e.length===+e.length)for(var i=0,r=e.length;i<r;i++)t.call(n,e[i],i,e)},YX.map=function(e,t){var n=[];if(null==e)return n;if(WX.map&&e.map===WX.map)return e.map(t);for(var i=0;i<e.length;i++)n[n.length]=t(e[i],i);return e.length===+e.length&&(n.length=e.length),n},YX.asyncIter=function(e,t,n){var i=-1;!function r(){++i<e.length?t(e[i],i,r,n):n()}()},YX.asyncFor=function(e,t,n){var i=o0(e||{}),r=i.length,s=-1;!function o(){s++;var a=i[s];s<r?t(a,e[a],s,r,o):n()}()},YX.indexOf=s0,YX.keys=o0,YX._entries=function(e){return o0(e).map((function(t){return[t,e[t]]}))},YX._values=function(e){return o0(e).map((function(t){return e[t]}))},YX._assign=YX.extend=function(e,t){return e=e||{},o0(t).forEach((function(n){e[n]=t[n]})),e},YX.inOperator=function(e,t){if(e0(t)||t0(t))return-1!==t.indexOf(e);if(n0(t))return e in t;throw new Error('Cannot use "in" operator to search for "'+e+'" in unexpected types.')};var a0,c0=zX.exports,l0="function"==typeof setImmediate,u0=p0;function p0(e){h0.length||(y0(),d0=!0),h0[h0.length]=e}var h0=[],d0=!1,f0=0,m0=1024;function g0(){for(;f0<h0.length;){var e=f0;if(f0+=1,h0[e].call(),f0>m0){for(var t=0,n=h0.length-f0;t<n;t++)h0[t]=h0[t+f0];h0.length-=f0,f0=0}}h0.length=0,f0=0,d0=!1}function y0(){var e=process.domain;e&&(a0||(a0=M),a0.active=process.domain=null),d0&&l0?setImmediate(g0):process.nextTick(g0),e&&(a0.active=process.domain=e)}p0.requestFlush=y0;var v0=u0,b0=[],_0=function(e){var t;t=b0.length?b0.pop():new w0;t.task=e,t.domain=process.domain,v0(t)};function w0(){this.task=null,this.domain=null}w0.prototype.call=function(){this.domain&&this.domain.enter();var e=!0;try{this.task.call(),e=!1,this.domain&&this.domain.exit()}finally{e&&v0.requestFlush(),this.task=null,this.domain=null,b0.push(this)}};var x0={exports:{}};!function(e){!function(t){var n=function(){var e=Array.prototype.slice.call(arguments);"function"==typeof e[0]&&e[0].apply(null,e.splice(1))},i=function(e){"function"==typeof setImmediate?setImmediate(e):"undefined"!=typeof process&&process.nextTick?process.nextTick(e):setTimeout(e,0)},r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=function(e,t,s){var o=s?i:n;if(t=t||function(){},!r(e)){var a=new Error("First argument to waterfall must be an array of functions");return t(a)}if(!e.length)return t();var c=function(e){return function(n){if(n)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),r=e.next();r?i.push(c(r)):i.push(t),o((function(){e.apply(null,i)}))}}};c(function(e){var t=function(n){var i=function(){return e.length&&e[n].apply(null,arguments),i.next()};return i.next=function(){return n<e.length-1?t(n+1):null},i};return t(0)}(e))()};e.exports?e.exports=s:t.waterfall=s}(H)}(x0);var E0=x0.exports,S0=c0,k0=" \n\t\r ",T0="()[]{}%*-+~/#,:|.<>=!",A0="string",D0="whitespace",C0="data",O0="block-start",R0="block-end",L0="variable-start",I0="variable-end",N0="comment",P0="left-paren",j0="right-paren",F0="left-bracket",B0="right-bracket",M0="left-curly",U0="right-curly",q0="operator",$0="comma",H0="colon",z0="tilde",W0="pipe",G0="float",V0="boolean",K0="none",Y0="symbol",Z0="regex";function Q0(e,t,n,i){return{type:e,value:t,lineno:n,colno:i}}var J0=function(){function e(e,t){this.str=e,this.index=0,this.len=e.length,this.lineno=0,this.colno=0,this.in_code=!1;var n=(t=t||{}).tags||{};this.tags={BLOCK_START:n.blockStart||"{%",BLOCK_END:n.blockEnd||"%}",VARIABLE_START:n.variableStart||"{{",VARIABLE_END:n.variableEnd||"}}",COMMENT_START:n.commentStart||"{#",COMMENT_END:n.commentEnd||"#}"},this.trimBlocks=!!t.trimBlocks,this.lstripBlocks=!!t.lstripBlocks}var t=e.prototype;return t.nextToken=function(){var e,t=this.lineno,n=this.colno;if(this.in_code){var i=this.current();if(this.isFinished())return null;if('"'===i||"'"===i)return Q0(A0,this._parseString(i),t,n);if(e=this._extract(k0))return Q0(D0,e,t,n);if((e=this._extractString(this.tags.BLOCK_END))||(e=this._extractString("-"+this.tags.BLOCK_END)))return this.in_code=!1,this.trimBlocks&&("\n"===(i=this.current())?this.forward():"\r"===i&&(this.forward(),"\n"===(i=this.current())?this.forward():this.back())),Q0(R0,e,t,n);if((e=this._extractString(this.tags.VARIABLE_END))||(e=this._extractString("-"+this.tags.VARIABLE_END)))return this.in_code=!1,Q0(I0,e,t,n);if("r"===i&&"/"===this.str.charAt(this.index+1)){this.forwardN(2);for(var r="";!this.isFinished();){if("/"===this.current()&&"\\"!==this.previous()){this.forward();break}r+=this.current(),this.forward()}for(var s=["g","i","m","y"],o="";!this.isFinished();){if(!(-1!==s.indexOf(this.current())))break;o+=this.current(),this.forward()}return Q0(Z0,{body:r,flags:o},t,n)}if(-1!==T0.indexOf(i)){this.forward();var a,c=["==","===","!=","!==","<=",">=","//","**"],l=i+this.current();switch(-1!==S0.indexOf(c,l)&&(this.forward(),i=l,-1!==S0.indexOf(c,l+this.current())&&(i=l+this.current(),this.forward())),i){case"(":a=P0;break;case")":a=j0;break;case"[":a=F0;break;case"]":a=B0;break;case"{":a=M0;break;case"}":a=U0;break;case",":a=$0;break;case":":a=H0;break;case"~":a=z0;break;case"|":a=W0;break;default:a=q0}return Q0(a,i,t,n)}if((e=this._extractUntil(k0+T0)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var u=this._extract("0123456789");return Q0(G0,e+"."+u,t,n)}return Q0("int",e,t,n)}if(e.match(/^(true|false)$/))return Q0(V0,e,t,n);if("none"===e)return Q0(K0,e,t,n);if("null"===e)return Q0(K0,e,t,n);if(e)return Q0(Y0,e,t,n);throw new Error("Unexpected value while parsing: "+e)}var p,h=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((e=this._extractString(this.tags.BLOCK_START+"-"))||(e=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,Q0(O0,e,t,n);if((e=this._extractString(this.tags.VARIABLE_START+"-"))||(e=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,Q0(L0,e,t,n);e="";var d=!1;for(this._matches(this.tags.COMMENT_START)&&(d=!0,e=this._extractString(this.tags.COMMENT_START));null!==(p=this._extractUntil(h));){if(e+=p,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!d){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=e.length){var f=e.slice(-this.colno);if(/^\s+$/.test(f)&&!(e=e.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!d)throw new Error("unexpected end of comment");e+=this._extractString(this.tags.COMMENT_END);break}e+=this.current(),this.forward()}if(null===p&&d)throw new Error("expected end of comment, got end of file");return Q0(d?N0:C0,e,t,n)},t._parseString=function(e){this.forward();for(var t="";!this.isFinished()&&this.current()!==e;){var n=this.current();if("\\"===n){switch(this.forward(),this.current()){case"n":t+="\n";break;case"t":t+="\t";break;case"r":t+="\r";break;default:t+=this.current()}this.forward()}else t+=n,this.forward()}return this.forward(),t},t._matches=function(e){return this.index+e.length>this.len?null:this.str.slice(this.index,this.index+e.length)===e},t._extractString=function(e){return this._matches(e)?(this.forwardN(e.length),e):null},t._extractUntil=function(e){return this._extractMatching(!0,e||"")},t._extract=function(e){return this._extractMatching(!1,e)},t._extractMatching=function(e,t){if(this.isFinished())return null;var n=t.indexOf(this.current());if(e&&-1===n||!e&&-1!==n){var i=this.current();this.forward();for(var r=t.indexOf(this.current());(e&&-1===r||!e&&-1!==r)&&!this.isFinished();)i+=this.current(),this.forward(),r=t.indexOf(this.current());return i}return""},t._extractRegex=function(e){var t=this.currentStr().match(e);return t?(this.forwardN(t[0].length),t):null},t.isFinished=function(){return this.index>=this.len},t.forwardN=function(e){for(var t=0;t<e;t++)this.forward()},t.forward=function(){this.index++,"\n"===this.previous()?(this.lineno++,this.colno=0):this.colno++},t.backN=function(e){for(var t=0;t<e;t++)this.back()},t.back=function(){if(this.index--,"\n"===this.current()){this.lineno--;var e=this.src.lastIndexOf("\n",this.index-1);this.colno=-1===e?this.index:this.index-e}else this.colno--},t.current=function(){return this.isFinished()?"":this.str.charAt(this.index)},t.currentStr=function(){return this.isFinished()?"":this.str.substr(this.index)},t.previous=function(){return this.str.charAt(this.index-1)},e}(),X0={lex:function(e,t){return new J0(e,t)},TOKEN_STRING:A0,TOKEN_WHITESPACE:D0,TOKEN_DATA:C0,TOKEN_BLOCK_START:O0,TOKEN_BLOCK_END:R0,TOKEN_VARIABLE_START:L0,TOKEN_VARIABLE_END:I0,TOKEN_COMMENT:N0,TOKEN_LEFT_PAREN:P0,TOKEN_RIGHT_PAREN:j0,TOKEN_LEFT_BRACKET:F0,TOKEN_RIGHT_BRACKET:B0,TOKEN_LEFT_CURLY:M0,TOKEN_RIGHT_CURLY:U0,TOKEN_OPERATOR:q0,TOKEN_COMMA:$0,TOKEN_COLON:H0,TOKEN_TILDE:z0,TOKEN_PIPE:W0,TOKEN_INT:"int",TOKEN_FLOAT:G0,TOKEN_BOOLEAN:V0,TOKEN_NONE:K0,TOKEN_SYMBOL:Y0,TOKEN_SPECIAL:"special",TOKEN_REGEX:Z0};function e1(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n1(i.key),i)}}function t1(e,t,n){return t&&e1(e.prototype,t),n&&e1(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n1(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r1(e,t)}function r1(e,t){return r1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r1(e,t)}var s1=p,o1=c0;function a1(e,t,n){n=n||{},o1.keys(n).forEach((function(t){n[t]=function(e,t){return"function"!=typeof e||"function"!=typeof t?t:function(){var n=this.parent;this.parent=e;var i=t.apply(this,arguments);return this.parent=n,i}}(e.prototype[t],n[t])}));var i=function(e){function n(){return e.apply(this,arguments)||this}return i1(n,e),t1(n,[{key:"typename",get:function(){return t}}]),n}(e);return o1._assign(i.prototype,n),i}var c1=function(){function e(){this.init.apply(this,arguments)}return e.prototype.init=function(){},e.extend=function(e,t){return"object"==typeof e&&(t=e,e="anonymous"),a1(this,e,t)},t1(e,[{key:"typename",get:function(){return this.constructor.name}}]),e}(),l1=function(e){function t(){var t,n;return(t=n=e.call(this)||this).init.apply(t,arguments),n}return i1(t,e),t.prototype.init=function(){},t.extend=function(e,t){return"object"==typeof e&&(t=e,e="anonymous"),a1(this,e,t)},t1(t,[{key:"typename",get:function(){return this.constructor.name}}]),t}(s1),u1={Obj:c1,EmitterObj:l1};function p1(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,d1(i.key),i)}}function h1(e,t,n){return t&&p1(e.prototype,t),n&&p1(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d1(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function f1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,m1(e,t)}function m1(e,t){return m1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m1(e,t)}function g1(e,t,n){e instanceof t&&n.push(e),e instanceof y1&&e.findAll(t,n)}var y1=function(e){function t(){return e.apply(this,arguments)||this}f1(t,e);var n=t.prototype;return n.init=function(e,t){for(var n=arguments,i=this,r=arguments.length,s=new Array(r>2?r-2:0),o=2;o<r;o++)s[o-2]=arguments[o];this.lineno=e,this.colno=t,this.fields.forEach((function(e,t){var r=n[t+2];void 0===r&&(r=null),i[e]=r}))},n.findAll=function(e,t){var n=this;return t=t||[],this instanceof b1?this.children.forEach((function(n){return g1(n,e,t)})):this.fields.forEach((function(i){return g1(n[i],e,t)})),t},n.iterFields=function(e){var t=this;this.fields.forEach((function(n){e(t[n],n)}))},t}(u1.Obj),v1=function(e){function t(){return e.apply(this,arguments)||this}return f1(t,e),h1(t,[{key:"typename",get:function(){return"Value"}},{key:"fields",get:function(){return["value"]}}]),t}(y1),b1=function(e){function t(){return e.apply(this,arguments)||this}f1(t,e);var n=t.prototype;return n.init=function(t,n,i){e.prototype.init.call(this,t,n,i||[])},n.addChild=function(e){this.children.push(e)},h1(t,[{key:"typename",get:function(){return"NodeList"}},{key:"fields",get:function(){return["children"]}}]),t}(y1),_1=b1.extend("Root"),w1=v1.extend("Literal"),x1=v1.extend("Symbol"),E1=b1.extend("Group"),S1=b1.extend("Array"),k1=y1.extend("Pair",{fields:["key","value"]}),T1=b1.extend("Dict"),A1=y1.extend("LookupVal",{fields:["target","val"]}),D1=y1.extend("If",{fields:["cond","body","else_"]}),C1=D1.extend("IfAsync"),O1=y1.extend("InlineIf",{fields:["cond","body","else_"]}),R1=y1.extend("For",{fields:["arr","name","body","else_"]}),L1=R1.extend("AsyncEach"),I1=R1.extend("AsyncAll"),N1=y1.extend("Macro",{fields:["name","args","body"]}),P1=N1.extend("Caller"),j1=y1.extend("Import",{fields:["template","target","withContext"]}),F1=function(e){function t(){return e.apply(this,arguments)||this}return f1(t,e),t.prototype.init=function(t,n,i,r,s){e.prototype.init.call(this,t,n,i,r||new b1,s)},h1(t,[{key:"typename",get:function(){return"FromImport"}},{key:"fields",get:function(){return["template","names","withContext"]}}]),t}(y1),B1=y1.extend("FunCall",{fields:["name","args"]}),M1=B1.extend("Filter"),U1=M1.extend("FilterAsync",{fields:["name","args","symbol"]}),q1=T1.extend("KeywordArgs"),$1=y1.extend("Block",{fields:["name","body"]}),H1=y1.extend("Super",{fields:["blockName","symbol"]}),z1=y1.extend("TemplateRef",{fields:["template"]}).extend("Extends"),W1=y1.extend("Include",{fields:["template","ignoreMissing"]}),G1=y1.extend("Set",{fields:["targets","value"]}),V1=y1.extend("Switch",{fields:["expr","cases","default"]}),K1=y1.extend("Case",{fields:["cond","body"]}),Y1=b1.extend("Output"),Z1=y1.extend("Capture",{fields:["body"]}),Q1=w1.extend("TemplateData"),J1=y1.extend("UnaryOp",{fields:["target"]}),X1=y1.extend("BinOp",{fields:["left","right"]}),e2=X1.extend("In"),t2=X1.extend("Is"),n2=X1.extend("Or"),i2=X1.extend("And"),r2=J1.extend("Not"),s2=X1.extend("Add"),o2=X1.extend("Concat"),a2=X1.extend("Sub"),c2=X1.extend("Mul"),l2=X1.extend("Div"),u2=X1.extend("FloorDiv"),p2=X1.extend("Mod"),h2=X1.extend("Pow"),d2=J1.extend("Neg"),f2=J1.extend("Pos"),m2=y1.extend("Compare",{fields:["expr","ops"]}),g2=y1.extend("CompareOperand",{fields:["expr","type"]}),y2=y1.extend("CallExtension",{init:function(e,t,n,i){this.parent(),this.extName=e.__name||e,this.prop=t,this.args=n||new b1,this.contentArgs=i||[],this.autoescape=e.autoescape},fields:["extName","prop","args","contentArgs"]}),v2=y2.extend("CallExtensionAsync");function b2(e,t,n){var i=e.split("\n");i.forEach((function(e,r){e&&(n&&r>0||!n)&&process.stdout.write(" ".repeat(t));var s=r===i.length-1?"":"\n";process.stdout.write(""+e+s)}))}var _2={Node:y1,Root:_1,NodeList:b1,Value:v1,Literal:w1,Symbol:x1,Group:E1,Array:S1,Pair:k1,Dict:T1,Output:Y1,Capture:Z1,TemplateData:Q1,If:D1,IfAsync:C1,InlineIf:O1,For:R1,AsyncEach:L1,AsyncAll:I1,Macro:N1,Caller:P1,Import:j1,FromImport:F1,FunCall:B1,Filter:M1,FilterAsync:U1,KeywordArgs:q1,Block:$1,Super:H1,Extends:z1,Include:W1,Set:G1,Switch:V1,Case:K1,LookupVal:A1,BinOp:X1,In:e2,Is:t2,Or:n2,And:i2,Not:r2,Add:s2,Concat:o2,Sub:a2,Mul:c2,Div:l2,FloorDiv:u2,Mod:p2,Pow:h2,Neg:d2,Pos:f2,Compare:m2,CompareOperand:g2,CallExtension:y2,CallExtensionAsync:v2,printNodes:function e(t,n){if(n=n||0,b2(t.typename+": ",n),t instanceof b1)b2("\n"),t.children.forEach((function(t){e(t,n+2)}));else if(t instanceof y2)b2(t.extName+"."+t.prop+"\n"),t.args&&e(t.args,n+2),t.contentArgs&&t.contentArgs.forEach((function(t){e(t,n+2)}));else{var i=[],r=null;t.iterFields((function(e,t){e instanceof y1?i.push([t,e]):(r=r||{})[t]=e})),r?b2(JSON.stringify(r,null,2)+"\n",null,!0):b2("\n"),i.forEach((function(t){var i=t[0],r=t[1];b2("["+i+"] =>",n+2),e(r,n+4)}))}}};function w2(e,t){return w2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},w2(e,t)}var x2=X0,E2=_2,S2=c0,k2=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,w2(t,n);var r=i.prototype;return r.init=function(e){this.tokens=e,this.peeked=null,this.breakOnBlocks=null,this.dropLeadingWhitespace=!1,this.extensions=[]},r.nextToken=function(e){var t;if(this.peeked){if(e||this.peeked.type!==x2.TOKEN_WHITESPACE)return t=this.peeked,this.peeked=null,t;this.peeked=null}if(t=this.tokens.nextToken(),!e)for(;t&&t.type===x2.TOKEN_WHITESPACE;)t=this.tokens.nextToken();return t},r.peekToken=function(){return this.peeked=this.peeked||this.nextToken(),this.peeked},r.pushToken=function(e){if(this.peeked)throw new Error("pushToken: can only push one token on between reads");this.peeked=e},r.error=function(e,t,n){if(void 0===t||void 0===n){var i=this.peekToken()||{};t=i.lineno,n=i.colno}return void 0!==t&&(t+=1),void 0!==n&&(n+=1),new S2.TemplateError(e,t,n)},r.fail=function(e,t,n){throw this.error(e,t,n)},r.skip=function(e){var t=this.nextToken();return!(!t||t.type!==e)||(this.pushToken(t),!1)},r.expect=function(e){var t=this.nextToken();return t.type!==e&&this.fail("expected "+e+", got "+t.type,t.lineno,t.colno),t},r.skipValue=function(e,t){var n=this.nextToken();return!(!n||n.type!==e||n.value!==t)||(this.pushToken(n),!1)},r.skipSymbol=function(e){return this.skipValue(x2.TOKEN_SYMBOL,e)},r.advanceAfterBlockEnd=function(e){var t;return e||((t=this.peekToken())||this.fail("unexpected end of file"),t.type!==x2.TOKEN_SYMBOL&&this.fail("advanceAfterBlockEnd: expected symbol token or explicit name to be passed"),e=this.nextToken().value),(t=this.nextToken())&&t.type===x2.TOKEN_BLOCK_END?"-"===t.value.charAt(0)&&(this.dropLeadingWhitespace=!0):this.fail("expected block end in "+e+" statement"),t},r.advanceAfterVariableEnd=function(){var e=this.nextToken();e&&e.type===x2.TOKEN_VARIABLE_END?this.dropLeadingWhitespace="-"===e.value.charAt(e.value.length-this.tokens.tags.VARIABLE_END.length-1):(this.pushToken(e),this.fail("expected variable end"))},r.parseFor=function(){var e,t,n=this.peekToken();if(this.skipSymbol("for")?(e=new E2.For(n.lineno,n.colno),t="endfor"):this.skipSymbol("asyncEach")?(e=new E2.AsyncEach(n.lineno,n.colno),t="endeach"):this.skipSymbol("asyncAll")?(e=new E2.AsyncAll(n.lineno,n.colno),t="endall"):this.fail("parseFor: expected for{Async}",n.lineno,n.colno),e.name=this.parsePrimary(),e.name instanceof E2.Symbol||this.fail("parseFor: variable name expected for loop"),this.peekToken().type===x2.TOKEN_COMMA){var i=e.name;for(e.name=new E2.Array(i.lineno,i.colno),e.name.addChild(i);this.skip(x2.TOKEN_COMMA);){var r=this.parsePrimary();e.name.addChild(r)}}return this.skipSymbol("in")||this.fail('parseFor: expected "in" keyword for loop',n.lineno,n.colno),e.arr=this.parseExpression(),this.advanceAfterBlockEnd(n.value),e.body=this.parseUntilBlocks(t,"else"),this.skipSymbol("else")&&(this.advanceAfterBlockEnd("else"),e.else_=this.parseUntilBlocks(t)),this.advanceAfterBlockEnd(),e},r.parseMacro=function(){var e=this.peekToken();this.skipSymbol("macro")||this.fail("expected macro");var t=this.parsePrimary(!0),n=this.parseSignature(),i=new E2.Macro(e.lineno,e.colno,t,n);return this.advanceAfterBlockEnd(e.value),i.body=this.parseUntilBlocks("endmacro"),this.advanceAfterBlockEnd(),i},r.parseCall=function(){var e=this.peekToken();this.skipSymbol("call")||this.fail("expected call");var t=this.parseSignature(!0)||new E2.NodeList,n=this.parsePrimary();this.advanceAfterBlockEnd(e.value);var i=this.parseUntilBlocks("endcall");this.advanceAfterBlockEnd();var r=new E2.Symbol(e.lineno,e.colno,"caller"),s=new E2.Caller(e.lineno,e.colno,r,t,i),o=n.args.children;return o[o.length-1]instanceof E2.KeywordArgs||o.push(new E2.KeywordArgs),o[o.length-1].addChild(new E2.Pair(e.lineno,e.colno,r,s)),new E2.Output(e.lineno,e.colno,[n])},r.parseWithContext=function(){var e=this.peekToken(),t=null;return this.skipSymbol("with")?t=!0:this.skipSymbol("without")&&(t=!1),null!==t&&(this.skipSymbol("context")||this.fail("parseFrom: expected context after with/without",e.lineno,e.colno)),t},r.parseImport=function(){var e=this.peekToken();this.skipSymbol("import")||this.fail("parseImport: expected import",e.lineno,e.colno);var t=this.parseExpression();this.skipSymbol("as")||this.fail('parseImport: expected "as" keyword',e.lineno,e.colno);var n=this.parseExpression(),i=this.parseWithContext(),r=new E2.Import(e.lineno,e.colno,t,n,i);return this.advanceAfterBlockEnd(e.value),r},r.parseFrom=function(){var e=this.peekToken();this.skipSymbol("from")||this.fail("parseFrom: expected from");var t=this.parseExpression();this.skipSymbol("import")||this.fail("parseFrom: expected import",e.lineno,e.colno);for(var n,i=new E2.NodeList;;){var r=this.peekToken();if(r.type===x2.TOKEN_BLOCK_END){i.children.length||this.fail("parseFrom: Expected at least one import name",e.lineno,e.colno),"-"===r.value.charAt(0)&&(this.dropLeadingWhitespace=!0),this.nextToken();break}i.children.length>0&&!this.skip(x2.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",e.lineno,e.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var o=this.parsePrimary();i.addChild(new E2.Pair(s.lineno,s.colno,s,o))}else i.addChild(s);n=this.parseWithContext()}return new E2.FromImport(e.lineno,e.colno,t,i,n)},r.parseBlock=function(){var e=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",e.lineno,e.colno);var t=new E2.Block(e.lineno,e.colno);t.name=this.parsePrimary(),t.name instanceof E2.Symbol||this.fail("parseBlock: variable name expected",e.lineno,e.colno),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(t.name.value);var n=this.peekToken();return n||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(n.value),t},r.parseExtends=function(){var e="extends",t=this.peekToken();this.skipSymbol(e)||this.fail("parseTemplateRef: expected "+e);var n=new E2.Extends(t.lineno,t.colno);return n.template=this.parseExpression(),this.advanceAfterBlockEnd(t.value),n},r.parseInclude=function(){var e="include",t=this.peekToken();this.skipSymbol(e)||this.fail("parseInclude: expected "+e);var n=new E2.Include(t.lineno,t.colno);return n.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(n.ignoreMissing=!0),this.advanceAfterBlockEnd(t.value),n},r.parseIf=function(){var e,t=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?e=new E2.If(t.lineno,t.colno):this.skipSymbol("ifAsync")?e=new E2.IfAsync(t.lineno,t.colno):this.fail("parseIf: expected if, elif, or elseif",t.lineno,t.colno),e.cond=this.parseExpression(),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("elif","elseif","else","endif");var n=this.peekToken();switch(n&&n.value){case"elseif":case"elif":e.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),e.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":e.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return e},r.parseSet=function(){var e=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",e.lineno,e.colno);for(var t,n=new E2.Set(e.lineno,e.colno,[]);(t=this.parsePrimary())&&(n.targets.push(t),this.skip(x2.TOKEN_COMMA)););return this.skipValue(x2.TOKEN_OPERATOR,"=")?(n.value=this.parseExpression(),this.advanceAfterBlockEnd(e.value)):this.skip(x2.TOKEN_BLOCK_END)?(n.body=new E2.Capture(e.lineno,e.colno,this.parseUntilBlocks("endset")),n.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",e.lineno,e.colno),n},r.parseSwitch=function(){var e="switch",t="endswitch",n="case",i="default",r=this.peekToken();this.skipSymbol(e)||this.skipSymbol(n)||this.skipSymbol(i)||this.fail('parseSwitch: expected "switch," "case" or "default"',r.lineno,r.colno);var s=this.parseExpression();this.advanceAfterBlockEnd(e),this.parseUntilBlocks(n,i,t);var o,a=this.peekToken(),c=[];do{this.skipSymbol(n);var l=this.parseExpression();this.advanceAfterBlockEnd(e);var u=this.parseUntilBlocks(n,i,t);c.push(new E2.Case(a.line,a.col,l,u)),a=this.peekToken()}while(a&&a.value===n);switch(a.value){case i:this.advanceAfterBlockEnd(),o=this.parseUntilBlocks(t),this.advanceAfterBlockEnd();break;case t:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new E2.Switch(r.lineno,r.colno,s,c,o)},r.parseStatement=function(){var e=this.peekToken();if(e.type!==x2.TOKEN_SYMBOL&&this.fail("tag name expected",e.lineno,e.colno),this.breakOnBlocks&&-1!==S2.indexOf(this.breakOnBlocks,e.value))return null;switch(e.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var t=0;t<this.extensions.length;t++){var n=this.extensions[t];if(-1!==S2.indexOf(n.tags||[],e.value))return n.parse(this,E2,x2)}this.fail("unknown block tag: "+e.value,e.lineno,e.colno)}},r.parseRaw=function(e){for(var t="end"+(e=e||"raw"),n=new RegExp("([\\s\\S]*?){%\\s*("+e+"|"+t+")\\s*(?=%})%}"),i=1,r="",s=null,o=this.advanceAfterBlockEnd();(s=this.tokens._extractRegex(n))&&i>0;){var a=s[0],c=s[1],l=s[2];l===e?i+=1:l===t&&(i-=1),0===i?(r+=c,this.tokens.backN(a.length-c.length)):r+=a}return new E2.Output(o.lineno,o.colno,[new E2.TemplateData(o.lineno,o.colno,r)])},r.parsePostfix=function(e){for(var t,n=this.peekToken();n;){if(n.type===x2.TOKEN_LEFT_PAREN)e=new E2.FunCall(n.lineno,n.colno,e,this.parseSignature());else if(n.type===x2.TOKEN_LEFT_BRACKET)(t=this.parseAggregate()).children.length>1&&this.fail("invalid index"),e=new E2.LookupVal(n.lineno,n.colno,e,t.children[0]);else{if(n.type!==x2.TOKEN_OPERATOR||"."!==n.value)break;this.nextToken();var i=this.nextToken();i.type!==x2.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+i.value,i.lineno,i.colno),t=new E2.Literal(i.lineno,i.colno,i.value),e=new E2.LookupVal(n.lineno,n.colno,e,t)}n=this.peekToken()}return e},r.parseExpression=function(){return this.parseInlineIf()},r.parseInlineIf=function(){var e=this.parseOr();if(this.skipSymbol("if")){var t=this.parseOr(),n=e;(e=new E2.InlineIf(e.lineno,e.colno)).body=n,e.cond=t,this.skipSymbol("else")?e.else_=this.parseOr():e.else_=null}return e},r.parseOr=function(){for(var e=this.parseAnd();this.skipSymbol("or");){var t=this.parseAnd();e=new E2.Or(e.lineno,e.colno,e,t)}return e},r.parseAnd=function(){for(var e=this.parseNot();this.skipSymbol("and");){var t=this.parseNot();e=new E2.And(e.lineno,e.colno,e,t)}return e},r.parseNot=function(){var e=this.peekToken();return this.skipSymbol("not")?new E2.Not(e.lineno,e.colno,this.parseNot()):this.parseIn()},r.parseIn=function(){for(var e=this.parseIs();;){var t=this.nextToken();if(!t)break;var n=t.type===x2.TOKEN_SYMBOL&&"not"===t.value;if(n||this.pushToken(t),!this.skipSymbol("in")){n&&this.pushToken(t);break}var i=this.parseIs();e=new E2.In(e.lineno,e.colno,e,i),n&&(e=new E2.Not(e.lineno,e.colno,e))}return e},r.parseIs=function(){var e=this.parseCompare();if(this.skipSymbol("is")){var t=this.skipSymbol("not"),n=this.parseCompare();e=new E2.Is(e.lineno,e.colno,e,n),t&&(e=new E2.Not(e.lineno,e.colno,e))}return e},r.parseCompare=function(){for(var e=["==","===","!=","!==","<",">","<=",">="],t=this.parseConcat(),n=[];;){var i=this.nextToken();if(!i)break;if(-1===e.indexOf(i.value)){this.pushToken(i);break}n.push(new E2.CompareOperand(i.lineno,i.colno,this.parseConcat(),i.value))}return n.length?new E2.Compare(n[0].lineno,n[0].colno,t,n):t},r.parseConcat=function(){for(var e=this.parseAdd();this.skipValue(x2.TOKEN_TILDE,"~");){var t=this.parseAdd();e=new E2.Concat(e.lineno,e.colno,e,t)}return e},r.parseAdd=function(){for(var e=this.parseSub();this.skipValue(x2.TOKEN_OPERATOR,"+");){var t=this.parseSub();e=new E2.Add(e.lineno,e.colno,e,t)}return e},r.parseSub=function(){for(var e=this.parseMul();this.skipValue(x2.TOKEN_OPERATOR,"-");){var t=this.parseMul();e=new E2.Sub(e.lineno,e.colno,e,t)}return e},r.parseMul=function(){for(var e=this.parseDiv();this.skipValue(x2.TOKEN_OPERATOR,"*");){var t=this.parseDiv();e=new E2.Mul(e.lineno,e.colno,e,t)}return e},r.parseDiv=function(){for(var e=this.parseFloorDiv();this.skipValue(x2.TOKEN_OPERATOR,"/");){var t=this.parseFloorDiv();e=new E2.Div(e.lineno,e.colno,e,t)}return e},r.parseFloorDiv=function(){for(var e=this.parseMod();this.skipValue(x2.TOKEN_OPERATOR,"//");){var t=this.parseMod();e=new E2.FloorDiv(e.lineno,e.colno,e,t)}return e},r.parseMod=function(){for(var e=this.parsePow();this.skipValue(x2.TOKEN_OPERATOR,"%");){var t=this.parsePow();e=new E2.Mod(e.lineno,e.colno,e,t)}return e},r.parsePow=function(){for(var e=this.parseUnary();this.skipValue(x2.TOKEN_OPERATOR,"**");){var t=this.parseUnary();e=new E2.Pow(e.lineno,e.colno,e,t)}return e},r.parseUnary=function(e){var t,n=this.peekToken();return t=this.skipValue(x2.TOKEN_OPERATOR,"-")?new E2.Neg(n.lineno,n.colno,this.parseUnary(!0)):this.skipValue(x2.TOKEN_OPERATOR,"+")?new E2.Pos(n.lineno,n.colno,this.parseUnary(!0)):this.parsePrimary(),e||(t=this.parseFilter(t)),t},r.parsePrimary=function(e){var t,n=this.nextToken(),i=null;if(n?n.type===x2.TOKEN_STRING?t=n.value:n.type===x2.TOKEN_INT?t=parseInt(n.value,10):n.type===x2.TOKEN_FLOAT?t=parseFloat(n.value):n.type===x2.TOKEN_BOOLEAN?"true"===n.value?t=!0:"false"===n.value?t=!1:this.fail("invalid boolean: "+n.value,n.lineno,n.colno):n.type===x2.TOKEN_NONE?t=null:n.type===x2.TOKEN_REGEX&&(t=new RegExp(n.value.body,n.value.flags)):this.fail("expected expression, got end of file"),void 0!==t?i=new E2.Literal(n.lineno,n.colno,t):n.type===x2.TOKEN_SYMBOL?i=new E2.Symbol(n.lineno,n.colno,n.value):(this.pushToken(n),i=this.parseAggregate()),e||(i=this.parsePostfix(i)),i)return i;throw this.error("unexpected token: "+n.value,n.lineno,n.colno)},r.parseFilterName=function(){for(var e=this.expect(x2.TOKEN_SYMBOL),t=e.value;this.skipValue(x2.TOKEN_OPERATOR,".");)t+="."+this.expect(x2.TOKEN_SYMBOL).value;return new E2.Symbol(e.lineno,e.colno,t)},r.parseFilterArgs=function(e){return this.peekToken().type===x2.TOKEN_LEFT_PAREN?this.parsePostfix(e).args.children:[]},r.parseFilter=function(e){for(;this.skip(x2.TOKEN_PIPE);){var t=this.parseFilterName();e=new E2.Filter(t.lineno,t.colno,t,new E2.NodeList(t.lineno,t.colno,[e].concat(this.parseFilterArgs(e))))}return e},r.parseFilterStatement=function(){var e=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var t=this.parseFilterName(),n=this.parseFilterArgs(t);this.advanceAfterBlockEnd(e.value);var i=new E2.Capture(t.lineno,t.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var r=new E2.Filter(t.lineno,t.colno,t,new E2.NodeList(t.lineno,t.colno,[i].concat(n)));return new E2.Output(t.lineno,t.colno,[r])},r.parseAggregate=function(){var e,t=this.nextToken();switch(t.type){case x2.TOKEN_LEFT_PAREN:e=new E2.Group(t.lineno,t.colno);break;case x2.TOKEN_LEFT_BRACKET:e=new E2.Array(t.lineno,t.colno);break;case x2.TOKEN_LEFT_CURLY:e=new E2.Dict(t.lineno,t.colno);break;default:return null}for(;;){var n=this.peekToken().type;if(n===x2.TOKEN_RIGHT_PAREN||n===x2.TOKEN_RIGHT_BRACKET||n===x2.TOKEN_RIGHT_CURLY){this.nextToken();break}if(e.children.length>0&&(this.skip(x2.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",t.lineno,t.colno)),e instanceof E2.Dict){var i=this.parsePrimary();this.skip(x2.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",t.lineno,t.colno);var r=this.parseExpression();e.addChild(new E2.Pair(i.lineno,i.colno,i,r))}else{var s=this.parseExpression();e.addChild(s)}}return e},r.parseSignature=function(e,t){var n=this.peekToken();if(!t&&n.type!==x2.TOKEN_LEFT_PAREN){if(e)return null;this.fail("expected arguments",n.lineno,n.colno)}n.type===x2.TOKEN_LEFT_PAREN&&(n=this.nextToken());for(var i=new E2.NodeList(n.lineno,n.colno),r=new E2.KeywordArgs(n.lineno,n.colno),s=!1;;){if(n=this.peekToken(),!t&&n.type===x2.TOKEN_RIGHT_PAREN){this.nextToken();break}if(t&&n.type===x2.TOKEN_BLOCK_END)break;if(s&&!this.skip(x2.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",n.lineno,n.colno);else{var o=this.parseExpression();this.skipValue(x2.TOKEN_OPERATOR,"=")?r.addChild(new E2.Pair(o.lineno,o.colno,o,this.parseExpression())):i.addChild(o)}s=!0}return r.children.length&&i.addChild(r),i},r.parseUntilBlocks=function(){for(var e=this.breakOnBlocks,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];this.breakOnBlocks=n;var r=this.parse();return this.breakOnBlocks=e,r},r.parseNodes=function(){for(var e,t=[];e=this.nextToken();)if(e.type===x2.TOKEN_DATA){var n=e.value,i=this.peekToken(),r=i&&i.value;this.dropLeadingWhitespace&&(n=n.replace(/^\s*/,""),this.dropLeadingWhitespace=!1),i&&(i.type===x2.TOKEN_BLOCK_START&&"-"===r.charAt(r.length-1)||i.type===x2.TOKEN_VARIABLE_START&&"-"===r.charAt(this.tokens.tags.VARIABLE_START.length)||i.type===x2.TOKEN_COMMENT&&"-"===r.charAt(this.tokens.tags.COMMENT_START.length))&&(n=n.replace(/\s*$/,"")),t.push(new E2.Output(e.lineno,e.colno,[new E2.TemplateData(e.lineno,e.colno,n)]))}else if(e.type===x2.TOKEN_BLOCK_START){this.dropLeadingWhitespace=!1;var s=this.parseStatement();if(!s)break;t.push(s)}else if(e.type===x2.TOKEN_VARIABLE_START){var o=this.parseExpression();this.dropLeadingWhitespace=!1,this.advanceAfterVariableEnd(),t.push(new E2.Output(e.lineno,e.colno,[o]))}else e.type===x2.TOKEN_COMMENT?this.dropLeadingWhitespace="-"===e.value.charAt(e.value.length-this.tokens.tags.COMMENT_END.length-1):this.fail("Unexpected token at top-level: "+e.type,e.lineno,e.colno);return t},r.parse=function(){return new E2.NodeList(0,0,this.parseNodes())},r.parseAsRoot=function(){return new E2.Root(0,0,this.parseNodes())},i}(u1.Obj),T2={parse:function(e,t,n){var i=new k2(x2.lex(e,n));return void 0!==t&&(i.extensions=t),i.parseAsRoot()},Parser:k2},A2=_2,D2=c0,C2=0;function O2(){return"hole_"+C2++}function R2(e,t){for(var n=null,i=0;i<e.length;i++){var r=t(e[i]);r!==e[i]&&(n||(n=e.slice()),n[i]=r)}return n||e}function L2(e,t,n){if(!(e instanceof A2.Node))return e;if(!n){var i=t(e);if(i&&i!==e)return i}if(e instanceof A2.NodeList){var r=R2(e.children,(function(e){return L2(e,t,n)}));r!==e.children&&(e=new A2[e.typename](e.lineno,e.colno,r))}else if(e instanceof A2.CallExtension){var s=L2(e.args,t,n),o=R2(e.contentArgs,(function(e){return L2(e,t,n)}));s===e.args&&o===e.contentArgs||(e=new A2[e.typename](e.extName,e.prop,s,o))}else{var a=e.fields.map((function(t){return e[t]})),c=R2(a,(function(e){return L2(e,t,n)}));c!==a&&(e=new A2[e.typename](e.lineno,e.colno),c.forEach((function(t,n){e[e.fields[n]]=t})))}return n&&t(e)||e}function I2(e,t){return L2(e,t,!0)}function N2(e,t,n){var i=[],r=I2(n?e[n]:e,(function(e){var n;return e instanceof A2.Block?e:((e instanceof A2.Filter&&-1!==D2.indexOf(t,e.name.value)||e instanceof A2.CallExtensionAsync)&&(n=new A2.Symbol(e.lineno,e.colno,O2()),i.push(new A2.FilterAsync(e.lineno,e.colno,e.name,e.args,n))),n)}));return n?e[n]=r:e=r,i.length?(i.push(e),new A2.NodeList(e.lineno,e.colno,i)):e}function P2(e,t){return function(e){return I2(e,(function(e){if(e instanceof A2.If||e instanceof A2.For){var t=!1;if(L2(e,(function(e){if(e instanceof A2.FilterAsync||e instanceof A2.IfAsync||e instanceof A2.AsyncEach||e instanceof A2.AsyncAll||e instanceof A2.CallExtensionAsync)return t=!0,e})),t){if(e instanceof A2.If)return new A2.IfAsync(e.lineno,e.colno,e.cond,e.body,e.else_);if(e instanceof A2.For&&!(e instanceof A2.AsyncAll))return new A2.AsyncEach(e.lineno,e.colno,e.arr,e.name,e.body,e.else_)}}}))}(function(e){return L2(e,(function(e){if(e instanceof A2.Block){var t=!1,n=O2();e.body=L2(e.body,(function(e){if(e instanceof A2.FunCall&&"super"===e.name.value)return t=!0,new A2.Symbol(e.lineno,e.colno,n)})),t&&e.body.children.unshift(new A2.Super(0,0,e.name,new A2.Symbol(0,0,n)))}}))}(function(e,t){return I2(e,(function(e){return e instanceof A2.Output?N2(e,t):e instanceof A2.Set?N2(e,t,"value"):e instanceof A2.For?N2(e,t,"arr"):e instanceof A2.If?N2(e,t,"cond"):e instanceof A2.CallExtension?N2(e,t,"args"):void 0}))}(e,t)))}var j2={transform:function(e,t){return P2(e,t||[])}},F2=c0,B2=Array.from,M2="function"==typeof Symbol&&Symbol.iterator&&"function"==typeof B2,U2=function(){function e(e,t){this.variables=Object.create(null),this.parent=e,this.topLevel=!1,this.isolateWrites=t}var t=e.prototype;return t.set=function(e,t,n){var i=e.split("."),r=this.variables,s=this;if(n&&(s=this.resolve(i[0],!0)))s.set(e,t);else{for(var o=0;o<i.length-1;o++){var a=i[o];r[a]||(r[a]={}),r=r[a]}r[i[i.length-1]]=t}},t.get=function(e){var t=this.variables[e];return void 0!==t?t:null},t.lookup=function(e){var t=this.parent,n=this.variables[e];return void 0!==n?n:t&&t.lookup(e)},t.resolve=function(e,t){var n=t&&this.isolateWrites?void 0:this.parent;return void 0!==this.variables[e]?this:n&&n.resolve(e)},t.push=function(t){return new e(this,t)},t.pop=function(){return this.parent},e}();function q2(e){return e&&Object.prototype.hasOwnProperty.call(e,"__keywords")}function $2(e){var t=e.length;return 0===t?0:q2(e[t-1])?t-1:t}function H2(e){if("string"!=typeof e)return e;this.val=e,this.length=e.length}H2.prototype=Object.create(String.prototype,{length:{writable:!0,configurable:!0,value:0}}),H2.prototype.valueOf=function(){return this.val},H2.prototype.toString=function(){return this.val};var z2={Frame:U2,makeMacro:function(e,t,n){return function(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];var o,a=$2(r),c=function(e){var t=e.length;if(t){var n=e[t-1];if(q2(n))return n}return{}}(r);if(a>e.length)o=r.slice(0,e.length),r.slice(o.length,a).forEach((function(e,n){n<t.length&&(c[t[n]]=e)})),o.push(c);else if(a<e.length){o=r.slice(0,a);for(var l=a;l<e.length;l++){var u=e[l];o.push(c[u]),delete c[u]}o.push(c)}else o=r;return n.apply(this,o)}},makeKeywordArgs:function(e){return e.__keywords=!0,e},numArgs:$2,suppressValue:function(e,t){return e=null!=e?e:"",!t||e instanceof H2||(e=F2.escape(e.toString())),e},ensureDefined:function(e,t,n){if(null==e)throw new F2.TemplateError("attempted to output null or undefined value",t+1,n+1);return e},memberLookup:function(e,t){if(null!=e)return"function"==typeof e[t]?function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return e[t].apply(e,i)}:e[t]},contextOrFrameLookup:function(e,t,n){var i=t.lookup(n);return void 0!==i?i:e.lookup(n)},callWrap:function(e,t,n,i){if(!e)throw new Error("Unable to call `"+t+"`, which is undefined or falsey");if("function"!=typeof e)throw new Error("Unable to call `"+t+"`, which is not a function");return e.apply(n,i)},handleError:function(e,t,n){return e.lineno?e:new F2.TemplateError(e,t,n)},isArray:F2.isArray,keys:F2.keys,SafeString:H2,copySafeness:function(e,t){return e instanceof H2?new H2(t):t.toString()},markSafe:function(e){var t=typeof e;return"string"===t?new H2(e):"function"!==t?e:function(t){var n=e.apply(this,arguments);return"string"==typeof n?new H2(n):n}},asyncEach:function(e,t,n,i){if(F2.isArray(e)){var r=e.length;F2.asyncIter(e,(function(e,i,s){switch(t){case 1:n(e,i,r,s);break;case 2:n(e[0],e[1],i,r,s);break;case 3:n(e[0],e[1],e[2],i,r,s);break;default:e.push(i,r,s),n.apply(this,e)}}),i)}else F2.asyncFor(e,(function(e,t,i,r,s){n(e,t,i,r,s)}),i)},asyncAll:function(e,t,n,i){var r,s,o=0;function a(e,t){o++,s[e]=t,o===r&&i(null,s.join(""))}if(F2.isArray(e))if(r=e.length,s=new Array(r),0===r)i(null,"");else for(var c=0;c<e.length;c++){var l=e[c];switch(t){case 1:n(l,c,r,a);break;case 2:n(l[0],l[1],c,r,a);break;case 3:n(l[0],l[1],l[2],c,r,a);break;default:l.push(c,r,a),n.apply(this,l)}}else{var u=F2.keys(e||{});if(r=u.length,s=new Array(r),0===r)i(null,"");else for(var p=0;p<u.length;p++){var h=u[p];n(h,e[h],p,r,a)}}},inOperator:F2.inOperator,fromIterator:function(e){return"object"!=typeof e||null===e||F2.isArray(e)?e:M2&&Symbol.iterator in e?B2(e):e}};function W2(e,t){return W2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},W2(e,t)}var G2=T2,V2=j2,K2=_2,Y2=c0.TemplateError,Z2=z2.Frame,Q2={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},J2=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,W2(t,n);var r=i.prototype;return r.init=function(e,t){this.templateName=e,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=t},r.fail=function(e,t,n){throw void 0!==t&&(t+=1),void 0!==n&&(n+=1),new Y2(e,t,n)},r._pushBuffer=function(){var e=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=e,this._emit("var "+this.buffer+' = "";'),e},r._popBuffer=function(){this.buffer=this.bufferStack.pop()},r._emit=function(e){this.codebuf.push(e)},r._emitLine=function(e){this._emit(e+"\n")},r._emitLines=function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach((function(t){return e._emitLine(t)}))},r._emitFuncBegin=function(e,t){this.buffer="output",this._scopeClosers="",this._emitLine("function "+t+"(env, context, frame, runtime, cb) {"),this._emitLine("var lineno = "+e.lineno+";"),this._emitLine("var colno = "+e.colno+";"),this._emitLine("var "+this.buffer+' = "";'),this._emitLine("try {")},r._emitFuncEnd=function(e){e||this._emitLine("cb(null, "+this.buffer+");"),this._closeScopeLevels(),this._emitLine("} catch (e) {"),this._emitLine(" cb(runtime.handleError(e, lineno, colno));"),this._emitLine("}"),this._emitLine("}"),this.buffer=null},r._addScopeLevel=function(){this._scopeClosers+="})"},r._closeScopeLevels=function(){this._emitLine(this._scopeClosers+";"),this._scopeClosers=""},r._withScopedSyntax=function(e){var t=this._scopeClosers;this._scopeClosers="",e.call(this),this._closeScopeLevels(),this._scopeClosers=t},r._makeCallback=function(e){var t=this._tmpid();return"function("+t+(e?","+e:"")+") {\nif("+t+") { cb("+t+"); return; }"},r._tmpid=function(){return this.lastId++,"t_"+this.lastId},r._templateName=function(){return null==this.templateName?"undefined":JSON.stringify(this.templateName)},r._compileChildren=function(e,t){var n=this;e.children.forEach((function(e){n.compile(e,t)}))},r._compileAggregate=function(e,t,n,i){var r=this;n&&this._emit(n),e.children.forEach((function(e,n){n>0&&r._emit(","),r.compile(e,t)})),i&&this._emit(i)},r._compileExpression=function(e,t){this.assertType(e,K2.Literal,K2.Symbol,K2.Group,K2.Array,K2.Dict,K2.FunCall,K2.Caller,K2.Filter,K2.LookupVal,K2.Compare,K2.InlineIf,K2.In,K2.Is,K2.And,K2.Or,K2.Not,K2.Add,K2.Concat,K2.Sub,K2.Mul,K2.Div,K2.FloorDiv,K2.Mod,K2.Pow,K2.Neg,K2.Pos,K2.Compare,K2.NodeList),this.compile(e,t)},r.assertType=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];n.some((function(t){return e instanceof t}))||this.fail("assertType: invalid type: "+e.typename,e.lineno,e.colno)},r.compileCallExtension=function(e,t,n){var i=this,r=e.args,s=e.contentArgs,o="boolean"!=typeof e.autoescape||e.autoescape;if(n||this._emit(this.buffer+" += runtime.suppressValue("),this._emit('env.getExtension("'+e.extName+'")["'+e.prop+'"]('),this._emit("context"),(r||s)&&this._emit(","),r&&(r instanceof K2.NodeList||this.fail("compileCallExtension: arguments must be a NodeList, use `parser.parseSignature`"),r.children.forEach((function(e,n){i._compileExpression(e,t),(n!==r.children.length-1||s.length)&&i._emit(",")}))),s.length&&s.forEach((function(e,n){if(n>0&&i._emit(","),e){i._emitLine("function(cb) {"),i._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var r=i._pushBuffer();i._withScopedSyntax((function(){i.compile(e,t),i._emitLine("cb(null, "+r+");")})),i._popBuffer(),i._emitLine("return "+r+";"),i._emitLine("}")}else i._emit("null")})),n){var a=this._tmpid();this._emitLine(", "+this._makeCallback(a)),this._emitLine(this.buffer+" += runtime.suppressValue("+a+", "+o+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+o+" && env.opts.autoescape);\n")},r.compileCallExtensionAsync=function(e,t){this.compileCallExtension(e,t,!0)},r.compileNodeList=function(e,t){this._compileChildren(e,t)},r.compileLiteral=function(e){if("string"==typeof e.value){var t=e.value.replace(/\\/g,"\\\\");t=(t=(t=(t=(t=t.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+t+'"')}else null===e.value?this._emit("null"):this._emit(e.value.toString())},r.compileSymbol=function(e,t){var n=e.value,i=t.lookup(n);i?this._emit(i):this._emit('runtime.contextOrFrameLookup(context, frame, "'+n+'")')},r.compileGroup=function(e,t){this._compileAggregate(e,t,"(",")")},r.compileArray=function(e,t){this._compileAggregate(e,t,"[","]")},r.compileDict=function(e,t){this._compileAggregate(e,t,"{","}")},r.compilePair=function(e,t){var n=e.key,i=e.value;n instanceof K2.Symbol?n=new K2.Literal(n.lineno,n.colno,n.value):n instanceof K2.Literal&&"string"==typeof n.value||this.fail("compilePair: Dict keys must be strings or names",n.lineno,n.colno),this.compile(n,t),this._emit(": "),this._compileExpression(i,t)},r.compileInlineIf=function(e,t){this._emit("("),this.compile(e.cond,t),this._emit("?"),this.compile(e.body,t),this._emit(":"),null!==e.else_?this.compile(e.else_,t):this._emit('""'),this._emit(")")},r.compileIn=function(e,t){this._emit("runtime.inOperator("),this.compile(e.left,t),this._emit(","),this.compile(e.right,t),this._emit(")")},r.compileIs=function(e,t){var n=e.right.name?e.right.name.value:e.right.value;this._emit('env.getTest("'+n+'").call(context, '),this.compile(e.left,t),e.right.args&&(this._emit(","),this.compile(e.right.args,t)),this._emit(") === true")},r._binOpEmitter=function(e,t,n){this.compile(e.left,t),this._emit(n),this.compile(e.right,t)},r.compileOr=function(e,t){return this._binOpEmitter(e,t," || ")},r.compileAnd=function(e,t){return this._binOpEmitter(e,t," && ")},r.compileAdd=function(e,t){return this._binOpEmitter(e,t," + ")},r.compileConcat=function(e,t){return this._binOpEmitter(e,t,' + "" + ')},r.compileSub=function(e,t){return this._binOpEmitter(e,t," - ")},r.compileMul=function(e,t){return this._binOpEmitter(e,t," * ")},r.compileDiv=function(e,t){return this._binOpEmitter(e,t," / ")},r.compileMod=function(e,t){return this._binOpEmitter(e,t," % ")},r.compileNot=function(e,t){this._emit("!"),this.compile(e.target,t)},r.compileFloorDiv=function(e,t){this._emit("Math.floor("),this.compile(e.left,t),this._emit(" / "),this.compile(e.right,t),this._emit(")")},r.compilePow=function(e,t){this._emit("Math.pow("),this.compile(e.left,t),this._emit(", "),this.compile(e.right,t),this._emit(")")},r.compileNeg=function(e,t){this._emit("-"),this.compile(e.target,t)},r.compilePos=function(e,t){this._emit("+"),this.compile(e.target,t)},r.compileCompare=function(e,t){var n=this;this.compile(e.expr,t),e.ops.forEach((function(e){n._emit(" "+Q2[e.type]+" "),n.compile(e.expr,t)}))},r.compileLookupVal=function(e,t){this._emit("runtime.memberLookup(("),this._compileExpression(e.target,t),this._emit("),"),this._compileExpression(e.val,t),this._emit(")")},r._getNodeName=function(e){switch(e.typename){case"Symbol":return e.value;case"FunCall":return"the return value of ("+this._getNodeName(e.name)+")";case"LookupVal":return this._getNodeName(e.target)+'["'+this._getNodeName(e.val)+'"]';case"Literal":return e.value.toString();default:return"--expression--"}},r.compileFunCall=function(e,t){this._emit("(lineno = "+e.lineno+", colno = "+e.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(e.name,t),this._emit(', "'+this._getNodeName(e.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(e.args,t,"[","])"),this._emit(")")},r.compileFilter=function(e,t){var n=e.name;this.assertType(n,K2.Symbol),this._emit('env.getFilter("'+n.value+'").call(context, '),this._compileAggregate(e.args,t),this._emit(")")},r.compileFilterAsync=function(e,t){var n=e.name,i=e.symbol.value;this.assertType(n,K2.Symbol),t.set(i,i),this._emit('env.getFilter("'+n.value+'").call(context, '),this._compileAggregate(e.args,t),this._emitLine(", "+this._makeCallback(i)),this._addScopeLevel()},r.compileKeywordArgs=function(e,t){this._emit("runtime.makeKeywordArgs("),this.compileDict(e,t),this._emit(")")},r.compileSet=function(e,t){var n=this,i=[];e.targets.forEach((function(e){var r=e.value,s=t.lookup(r);null==s&&(s=n._tmpid(),n._emitLine("var "+s+";")),i.push(s)})),e.value?(this._emit(i.join(" = ")+" = "),this._compileExpression(e.value,t),this._emitLine(";")):(this._emit(i.join(" = ")+" = "),this.compile(e.body,t),this._emitLine(";")),e.targets.forEach((function(e,t){var r=i[t],s=e.value;n._emitLine('frame.set("'+s+'", '+r+", true);"),n._emitLine("if(frame.topLevel) {"),n._emitLine('context.setVariable("'+s+'", '+r+");"),n._emitLine("}"),"_"!==s.charAt(0)&&(n._emitLine("if(frame.topLevel) {"),n._emitLine('context.addExport("'+s+'", '+r+");"),n._emitLine("}"))}))},r.compileSwitch=function(e,t){var n=this;this._emit("switch ("),this.compile(e.expr,t),this._emit(") {"),e.cases.forEach((function(e,i){n._emit("case "),n.compile(e.cond,t),n._emit(": "),n.compile(e.body,t),e.body.children.length&&n._emitLine("break;")})),e.default&&(this._emit("default:"),this.compile(e.default,t)),this._emit("}")},r.compileIf=function(e,t,n){var i=this;this._emit("if("),this._compileExpression(e.cond,t),this._emitLine(") {"),this._withScopedSyntax((function(){i.compile(e.body,t),n&&i._emit("cb()")})),e.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){i.compile(e.else_,t),n&&i._emit("cb()")}))):n&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},r.compileIfAsync=function(e,t){this._emit("(function(cb) {"),this.compileIf(e,t,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},r._emitLoopBindings=function(e,t,n,i){var r=this;[{name:"index",val:n+" + 1"},{name:"index0",val:n},{name:"revindex",val:i+" - "+n},{name:"revindex0",val:i+" - "+n+" - 1"},{name:"first",val:n+" === 0"},{name:"last",val:n+" === "+i+" - 1"},{name:"length",val:i}].forEach((function(e){r._emitLine('frame.set("loop.'+e.name+'", '+e.val+");")}))},r.compileFor=function(e,t){var n=this,i=this._tmpid(),r=this._tmpid(),s=this._tmpid();if(t=t.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = "),this._compileExpression(e.arr,t),this._emitLine(";"),this._emit("if("+s+") {"),this._emitLine(s+" = runtime.fromIterator("+s+");"),e.name instanceof K2.Array){this._emitLine("var "+i+";"),this._emitLine("if(runtime.isArray("+s+")) {"),this._emitLine("var "+r+" = "+s+".length;"),this._emitLine("for("+i+"=0; "+i+" < "+s+".length; "+i+"++) {"),e.name.children.forEach((function(r,o){var a=n._tmpid();n._emitLine("var "+a+" = "+s+"["+i+"]["+o+"];"),n._emitLine('frame.set("'+r+'", '+s+"["+i+"]["+o+"]);"),t.set(e.name.children[o].value,a)})),this._emitLoopBindings(e,s,i,r),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}"),this._emitLine("} else {");var o=e.name.children,a=o[0],c=o[1],l=this._tmpid(),u=this._tmpid();t.set(a.value,l),t.set(c.value,u),this._emitLine(i+" = -1;"),this._emitLine("var "+r+" = runtime.keys("+s+").length;"),this._emitLine("for(var "+l+" in "+s+") {"),this._emitLine(i+"++;"),this._emitLine("var "+u+" = "+s+"["+l+"];"),this._emitLine('frame.set("'+a.value+'", '+l+");"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLoopBindings(e,s,i,r),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}"),this._emitLine("}")}else{var p=this._tmpid();t.set(e.name.value,p),this._emitLine("var "+r+" = "+s+".length;"),this._emitLine("for(var "+i+"=0; "+i+" < "+s+".length; "+i+"++) {"),this._emitLine("var "+p+" = "+s+"["+i+"];"),this._emitLine('frame.set("'+e.name.value+'", '+p+");"),this._emitLoopBindings(e,s,i,r),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}")}this._emitLine("}"),e.else_&&(this._emitLine("if (!"+r+") {"),this.compile(e.else_,t),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r._compileAsyncLoop=function(e,t,n){var i=this,r=this._tmpid(),s=this._tmpid(),o=this._tmpid(),a=n?"asyncAll":"asyncEach";if(t=t.push(),this._emitLine("frame = frame.push();"),this._emit("var "+o+" = runtime.fromIterator("),this._compileExpression(e.arr,t),this._emitLine(");"),e.name instanceof K2.Array){var c=e.name.children.length;this._emit("runtime."+a+"("+o+", "+c+", function("),e.name.children.forEach((function(e){i._emit(e.value+",")})),this._emit(r+","+s+",next) {"),e.name.children.forEach((function(e){var n=e.value;t.set(n,n),i._emitLine('frame.set("'+n+'", '+n+");")}))}else{var l=e.name.value;this._emitLine("runtime."+a+"("+o+", 1, function("+l+", "+r+", "+s+",next) {"),this._emitLine('frame.set("'+l+'", '+l+");"),t.set(l,l)}this._emitLoopBindings(e,o,r,s),this._withScopedSyntax((function(){var s;n&&(s=i._pushBuffer()),i.compile(e.body,t),i._emitLine("next("+r+(s?","+s:"")+");"),n&&i._popBuffer()}));var u=this._tmpid();this._emitLine("}, "+this._makeCallback(u)),this._addScopeLevel(),n&&this._emitLine(this.buffer+" += "+u+";"),e.else_&&(this._emitLine("if (!"+o+".length) {"),this.compile(e.else_,t),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r.compileAsyncEach=function(e,t){this._compileAsyncLoop(e,t)},r.compileAsyncAll=function(e,t){this._compileAsyncLoop(e,t,!0)},r._compileMacro=function(e,t){var n=this,i=[],r=null,s="macro_"+this._tmpid(),o=void 0!==t;e.args.children.forEach((function(t,s){s===e.args.children.length-1&&t instanceof K2.Dict?r=t:(n.assertType(t,K2.Symbol),i.push(t))}));var a,c=[].concat(i.map((function(e){return"l_"+e.value})),["kwargs"]),l=i.map((function(e){return'"'+e.value+'"'})),u=(r&&r.children||[]).map((function(e){return'"'+e.key.value+'"'}));a=o?t.push(!0):new Z2,this._emitLines("var "+s+" = runtime.makeMacro(","["+l.join(", ")+"], ","["+u.join(", ")+"], ","function ("+c.join(", ")+") {","var callerFrame = frame;","frame = "+(o?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),i.forEach((function(e){n._emitLine('frame.set("'+e.value+'", l_'+e.value+");"),a.set(e.value,"l_"+e.value)})),r&&r.children.forEach((function(e){var t=e.key.value;n._emit('frame.set("'+t+'", '),n._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+t+'")'),n._emit(' ? kwargs["'+t+'"] : '),n._compileExpression(e.value,a),n._emit(");")}));var p=this._pushBuffer();return this._withScopedSyntax((function(){n.compile(e.body,a)})),this._emitLine("frame = "+(o?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+p+");"),this._emitLine("});"),this._popBuffer(),s},r.compileMacro=function(e,t){var n=this._compileMacro(e),i=e.name.value;t.set(i,n),t.parent?this._emitLine('frame.set("'+i+'", '+n+");"):("_"!==e.name.value.charAt(0)&&this._emitLine('context.addExport("'+i+'");'),this._emitLine('context.setVariable("'+i+'", '+n+");"))},r.compileCaller=function(e,t){this._emit("(function (){");var n=this._compileMacro(e,t);this._emit("return "+n+";})()")},r._compileGetTemplate=function(e,t,n,i){var r=this._tmpid(),s=this._templateName(),o=this._makeCallback(r),a=n?"true":"false",c=i?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(e.template,t),this._emitLine(", "+a+", "+s+", "+c+", "+o),r},r.compileImport=function(e,t){var n=e.target.value,i=this._compileGetTemplate(e,t,!1,!1);this._addScopeLevel(),this._emitLine(i+".getExported("+(e.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(i)),this._addScopeLevel(),t.set(n,i),t.parent?this._emitLine('frame.set("'+n+'", '+i+");"):this._emitLine('context.setVariable("'+n+'", '+i+");")},r.compileFromImport=function(e,t){var n=this,i=this._compileGetTemplate(e,t,!1,!1);this._addScopeLevel(),this._emitLine(i+".getExported("+(e.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(i)),this._addScopeLevel(),e.names.children.forEach((function(e){var r,s,o=n._tmpid();e instanceof K2.Pair?(r=e.key.value,s=e.value.value):s=r=e.value,n._emitLine("if(Object.prototype.hasOwnProperty.call("+i+', "'+r+'")) {'),n._emitLine("var "+o+" = "+i+"."+r+";"),n._emitLine("} else {"),n._emitLine("cb(new Error(\"cannot import '"+r+"'\")); return;"),n._emitLine("}"),t.set(s,o),t.parent?n._emitLine('frame.set("'+s+'", '+o+");"):n._emitLine('context.setVariable("'+s+'", '+o+");")}))},r.compileBlock=function(e){var t=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+e.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(t)),this._emitLine(this.buffer+" += "+t+";"),this._addScopeLevel()},r.compileSuper=function(e,t){var n=e.blockName.value,i=e.symbol.value,r=this._makeCallback(i);this._emitLine('context.getSuper(env, "'+n+'", b_'+n+", frame, runtime, "+r),this._emitLine(i+" = runtime.markSafe("+i+");"),this._addScopeLevel(),t.set(i,i)},r.compileExtends=function(e,t){var n=this._tmpid(),i=this._compileGetTemplate(e,t,!0,!1);this._emitLine("parentTemplate = "+i),this._emitLine("for(var "+n+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+n+", parentTemplate.blocks["+n+"]);"),this._emitLine("}"),this._addScopeLevel()},r.compileInclude=function(e,t){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var n=this._compileGetTemplate(e,t,!1,e.ignoreMissing);this._emitLine("callback(null,"+n+");});"),this._emitLine("});");var i=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(i)),this._emitLine("callback(null,"+i+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},r.compileTemplateData=function(e,t){this.compileLiteral(e,t)},r.compileCapture=function(e,t){var n=this,i=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=i},r.compileOutput=function(e,t){var n=this;e.children.forEach((function(i){i instanceof K2.TemplateData?i.value&&(n._emit(n.buffer+" += "),n.compileLiteral(i,t),n._emitLine(";")):(n._emit(n.buffer+" += runtime.suppressValue("),n.throwOnUndefined&&n._emit("runtime.ensureDefined("),n.compile(i,t),n.throwOnUndefined&&n._emit(","+e.lineno+","+e.colno+")"),n._emit(", env.opts.autoescape);\n"))}))},r.compileRoot=function(e,t){var n=this;t&&this.fail("compileRoot: root node can't have frame"),t=new Z2,this._emitFuncBegin(e,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(e,t),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var i=[],r=e.findAll(K2.Block);r.forEach((function(e,t){var r=e.name.value;if(-1!==i.indexOf(r))throw new Error('Block "'+r+'" defined more than once.');i.push(r),n._emitFuncBegin(e,"b_"+r);var s=new Z2;n._emitLine("var frame = frame.push(true);"),n.compile(e.body,s),n._emitFuncEnd()})),this._emitLine("return {"),r.forEach((function(e,t){var i="b_"+e.name.value;n._emitLine(i+": "+i+",")})),this._emitLine("root: root\n};")},r.compile=function(e,t){var n=this["compile"+e.typename];n?n.call(this,e,t):this.fail("compile: Cannot compile node: "+e.typename,e.lineno,e.colno)},r.getCode=function(){return this.codebuf.join("")},i}(u1.Obj),X2={compile:function(e,t,n,i,r){void 0===r&&(r={});var s=new J2(i,r.throwOnUndefined),o=(n||[]).map((function(e){return e.preprocess})).filter((function(e){return!!e})),a=o.reduce((function(e,t){return t(e)}),e);return s.compile(V2.transform(G2.parse(a,n,r),t,i)),s.getCode()},Compiler:J2},e3={exports:{}},t3=c0,n3=z2,i3=e3.exports={};function r3(e,t){return null==e||!1===e?t:e}function s3(e){return e!=e}function o3(e){var t=(e=r3(e,"")).toLowerCase();return n3.copySafeness(e,t.charAt(0).toUpperCase()+t.slice(1))}function a3(e){if(t3.isString(e))return e.split("");if(t3.isObject(e))return t3._entries(e||{}).map((function(e){return{key:e[0],value:e[1]}}));if(t3.isArray(e))return e;throw new t3.TemplateError("list filter: type not iterable")}function c3(e){return function(t,n,i){void 0===n&&(n="truthy");var r=this,s=r.env.getTest(n);return t3.toArray(t).filter((function(t){return s.call(r,t,i)===e}))}}function l3(e){return n3.copySafeness(e,e.replace(/^\s*|\s*$/g,""))}i3.abs=Math.abs,i3.batch=function(e,t,n){var i,r=[],s=[];for(i=0;i<e.length;i++)i%t==0&&s.length&&(r.push(s),s=[]),s.push(e[i]);if(s.length){if(n)for(i=s.length;i<t;i++)s.push(n);r.push(s)}return r},i3.capitalize=o3,i3.center=function(e,t){if(t=t||80,(e=r3(e,"")).length>=t)return e;var n=t-e.length,i=t3.repeat(" ",n/2-n%2),r=t3.repeat(" ",n/2);return n3.copySafeness(e,i+e+r)},i3.default=function(e,t,n){return n?e||t:void 0!==e?e:t},i3.dictsort=function(e,t,n){if(!t3.isObject(e))throw new t3.TemplateError("dictsort filter: val must be an object");var i,r=[];for(var s in e)r.push([s,e[s]]);if(void 0===n||"key"===n)i=0;else{if("value"!==n)throw new t3.TemplateError("dictsort filter: You can only sort by either key or value");i=1}return r.sort((function(e,n){var r=e[i],s=n[i];return t||(t3.isString(r)&&(r=r.toUpperCase()),t3.isString(s)&&(s=s.toUpperCase())),r>s?1:r===s?0:-1})),r},i3.dump=function(e,t){return JSON.stringify(e,null,t)},i3.escape=function(e){return e instanceof n3.SafeString?e:(e=null==e?"":e,n3.markSafe(t3.escape(e.toString())))},i3.safe=function(e){return e instanceof n3.SafeString?e:(e=null==e?"":e,n3.markSafe(e.toString()))},i3.first=function(e){return e[0]},i3.forceescape=function(e){return e=null==e?"":e,n3.markSafe(t3.escape(e.toString()))},i3.groupby=function(e,t){return t3.groupBy(e,t,this.env.opts.throwOnUndefined)},i3.indent=function(e,t,n){if(""===(e=r3(e,"")))return"";t=t||4;var i=e.split("\n"),r=t3.repeat(" ",t),s=i.map((function(e,t){return 0!==t||n?""+r+e:e})).join("\n");return n3.copySafeness(e,s)},i3.join=function(e,t,n){return t=t||"",n&&(e=t3.map(e,(function(e){return e[n]}))),e.join(t)},i3.last=function(e){return e[e.length-1]},i3.length=function(e){var t=r3(e,"");return void 0!==t?"function"==typeof Map&&t instanceof Map||"function"==typeof Set&&t instanceof Set?t.size:!t3.isObject(t)||t instanceof n3.SafeString?t.length:t3.keys(t).length:0},i3.list=a3,i3.lower=function(e){return(e=r3(e,"")).toLowerCase()},i3.nl2br=function(e){return null==e?"":n3.copySafeness(e,e.replace(/\r\n|\n/g,"<br />\n"))},i3.random=function(e){return e[Math.floor(Math.random()*e.length)]},i3.reject=c3(!1),i3.rejectattr=function(e,t){return e.filter((function(e){return!e[t]}))},i3.select=c3(!0),i3.selectattr=function(e,t){return e.filter((function(e){return!!e[t]}))},i3.replace=function(e,t,n,i){var r=e;if(t instanceof RegExp)return e.replace(t,n);void 0===i&&(i=-1);var s="";if("number"==typeof t)t=""+t;else if("string"!=typeof t)return e;if("number"==typeof e&&(e=""+e),"string"!=typeof e&&!(e instanceof n3.SafeString))return e;if(""===t)return s=n+e.split("").join(n)+n,n3.copySafeness(e,s);var o=e.indexOf(t);if(0===i||-1===o)return e;for(var a=0,c=0;o>-1&&(-1===i||c<i);)s+=e.substring(a,o)+n,a=o+t.length,c++,o=e.indexOf(t,a);return a<e.length&&(s+=e.substring(a)),n3.copySafeness(r,s)},i3.reverse=function(e){var t;return(t=t3.isString(e)?a3(e):t3.map(e,(function(e){return e}))).reverse(),t3.isString(e)?n3.copySafeness(e,t.join("")):t},i3.round=function(e,t,n){t=t||0;var i=Math.pow(10,t);return("ceil"===n?Math.ceil:"floor"===n?Math.floor:Math.round)(e*i)/i},i3.slice=function(e,t,n){for(var i=Math.floor(e.length/t),r=e.length%t,s=[],o=0,a=0;a<t;a++){var c=o+a*i;a<r&&o++;var l=o+(a+1)*i,u=e.slice(c,l);n&&a>=r&&u.push(n),s.push(u)}return s},i3.sum=function(e,t,n){return void 0===n&&(n=0),t&&(e=t3.map(e,(function(e){return e[t]}))),n+e.reduce((function(e,t){return e+t}),0)},i3.sort=n3.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(e,t,n,i){var r=this,s=t3.map(e,(function(e){return e})),o=t3.getAttrGetter(i);return s.sort((function(e,s){var a=i?o(e):e,c=i?o(s):s;if(r.env.opts.throwOnUndefined&&i&&(void 0===a||void 0===c))throw new TypeError('sort: attribute "'+i+'" resolved to undefined');return!n&&t3.isString(a)&&t3.isString(c)&&(a=a.toLowerCase(),c=c.toLowerCase()),a<c?t?1:-1:a>c?t?-1:1:0})),s})),i3.string=function(e){return n3.copySafeness(e,e)},i3.striptags=function(e,t){var n=l3((e=r3(e,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|<!--[\s\S]*?-->/gi,"")),i="";return i=t?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),n3.copySafeness(e,i)},i3.title=function(e){var t=(e=r3(e,"")).split(" ").map((function(e){return o3(e)}));return n3.copySafeness(e,t.join(" "))},i3.trim=l3,i3.truncate=function(e,t,n,i){var r=e;if(t=t||255,(e=r3(e,"")).length<=t)return e;if(n)e=e.substring(0,t);else{var s=e.lastIndexOf(" ",t);-1===s&&(s=t),e=e.substring(0,s)}return e+=null!=i?i:"...",n3.copySafeness(r,e)},i3.upper=function(e){return(e=r3(e,"")).toUpperCase()},i3.urlencode=function(e){var t=encodeURIComponent;return t3.isString(e)?t(e):(t3.isArray(e)?e:t3._entries(e)).map((function(e){var n=e[0],i=e[1];return t(n)+"="+t(i)})).join("&")};var u3=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,p3=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,h3=/^https?:\/\/.*$/,d3=/^www\./,f3=/\.(?:org|net|com)(?:\:|\/|$)/;i3.urlize=function(e,t,n){s3(t)&&(t=1/0);var i=!0===n?' rel="nofollow"':"";return e.split(/(\s+)/).filter((function(e){return e&&e.length})).map((function(e){var n=e.match(u3),r=n?n[1]:e,s=r.substr(0,t);return h3.test(r)?'<a href="'+r+'"'+i+">"+s+"</a>":d3.test(r)?'<a href="http://'+r+'"'+i+">"+s+"</a>":p3.test(r)?'<a href="mailto:'+r+'">'+r+"</a>":f3.test(r)?'<a href="http://'+r+'"'+i+">"+s+"</a>":e})).join("")},i3.wordcount=function(e){var t=(e=r3(e,""))?e.match(/\w+/g):null;return t?t.length:null},i3.float=function(e,t){var n=parseFloat(e);return s3(n)?t:n};var m3=n3.makeMacro(["value","default","base"],[],(function(e,t,n){void 0===n&&(n=10);var i=parseInt(e,n);return s3(i)?t:i}));i3.int=m3,i3.d=i3.default,i3.e=i3.escape;var g3=e3.exports;function y3(e,t){return y3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y3(e,t)}var v3=o,b3=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,y3(t,n);var r=i.prototype;return r.resolve=function(e,t){return v3.resolve(v3.dirname(e),t)},r.isRelative=function(e){return 0===e.indexOf("./")||0===e.indexOf("../")},i}(u1.EmitterObj);function _3(e,t){return _3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_3(e,t)}var w3=function(e){var t,n;function i(t){var n;return(n=e.call(this)||this).precompiled=t||{},n}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,_3(t,n),i.prototype.getSource=function(e){return this.precompiled[e]?{src:{type:"code",obj:this.precompiled[e]},path:e}:null},i}(b3);function x3(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,E3(e,t)}function E3(e,t){return E3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E3(e,t)}var S3,k3=s,T3=o,A3=b3,D3={PrecompiledLoader:w3}.PrecompiledLoader,C3=function(e){function t(t,n){var i;if(i=e.call(this)||this,"boolean"==typeof n&&console.log("[nunjucks] Warning: you passed a boolean as the second argument to FileSystemLoader, but it now takes an options object. See http://mozilla.github.io/nunjucks/api.html#filesystemloader"),n=n||{},i.pathsToNames={},i.noCache=!!n.noCache,t?(t=Array.isArray(t)?t:[t],i.searchPaths=t.map(T3.normalize)):i.searchPaths=["."],n.watch){try{S3=Qq}catch(e){throw new Error("watch requires chokidar to be installed")}var r=i.searchPaths.filter(k3.existsSync),s=S3.watch(r);s.on("all",(function(e,t){t=T3.resolve(t),"change"===e&&t in i.pathsToNames&&i.emit("update",i.pathsToNames[t],t)})),s.on("error",(function(e){console.log("Watcher error: "+e)}))}return i}return x3(t,e),t.prototype.getSource=function(e){for(var t=null,n=this.searchPaths,i=0;i<n.length;i++){var r=T3.resolve(n[i]),s=T3.resolve(n[i],e);if(0===s.indexOf(r)&&k3.existsSync(s)){t=s;break}}if(!t)return null;this.pathsToNames[t]=e;var o={src:k3.readFileSync(t,"utf-8"),path:t,noCache:this.noCache};return this.emit("load",e,o),o},t}(A3),O3=function(e){function t(t){var n;if(t=t||{},(n=e.call(this)||this).pathsToNames={},n.noCache=!!t.noCache,t.watch){try{S3=Qq}catch(e){throw new Error("watch requires chokidar to be installed")}n.watcher=S3.watch(),n.watcher.on("change",(function(e){n.emit("update",n.pathsToNames[e],e)})),n.watcher.on("error",(function(e){console.log("Watcher error: "+e)})),n.on("load",(function(e,t){n.watcher.add(t.path)}))}return n}return x3(t,e),t.prototype.getSource=function(e){if(/^\.?\.?(\/|\\)/.test(e))return null;if(/^[A-Z]:/.test(e))return null;var t;try{t=require.resolve(e)}catch(e){return null}this.pathsToNames[t]=e;var n={src:k3.readFileSync(t,"utf-8"),path:t,noCache:this.noCache};return this.emit("load",e,n),n},t}(A3),R3={FileSystemLoader:C3,PrecompiledLoader:D3,NodeResolveLoader:O3},L3={};!function(e){var t=z2.SafeString;e.callable=function(e){return"function"==typeof e},e.defined=function(e){return void 0!==e},e.divisibleby=function(e,t){return e%t==0},e.escaped=function(e){return e instanceof t},e.equalto=function(e,t){return e===t},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(e){return e%2==0},e.falsy=function(e){return!e},e.ge=function(e,t){return e>=t},e.greaterthan=function(e,t){return e>t},e.gt=e.greaterthan,e.le=function(e,t){return e<=t},e.lessthan=function(e,t){return e<t},e.lt=e.lessthan,e.lower=function(e){return e.toLowerCase()===e},e.ne=function(e,t){return e!==t},e.null=function(e){return null===e},e.number=function(e){return"number"==typeof e},e.odd=function(e){return e%2==1},e.string=function(e){return"string"==typeof e},e.truthy=function(e){return!!e},e.undefined=function(e){return void 0===e},e.upper=function(e){return e.toUpperCase()===e},e.iterable=function(e){return"undefined"!=typeof Symbol?!!e[Symbol.iterator]:Array.isArray(e)||"string"==typeof e},e.mapping=function(e){var t=null!=e&&"object"==typeof e&&!Array.isArray(e);return Set?t&&!(e instanceof Set):t}}(L3);var I3=function(){return{range:function(e,t,n){void 0===t?(t=e,e=0,n=1):n||(n=1);var i=[];if(n>0)for(var r=e;r<t;r+=n)i.push(r);else for(var s=e;s>t;s+=n)i.push(s);return i},cycler:function(){return function(e){var t=-1;return{current:null,reset:function(){t=-1,this.current=null},next:function(){return++t>=e.length&&(t=0),this.current=e[t],this.current}}}(Array.prototype.slice.call(arguments))},joiner:function(e){return function(e){e=e||",";var t=!0;return function(){var n=t?"":e;return t=!1,n}}(e)}}},N3=o;function P3(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,j3(e,t)}function j3(e,t){return j3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},j3(e,t)}var F3=_0,B3=E0,M3=c0,U3=X2,q3=g3,$3=R3.FileSystemLoader,H3=R3.WebLoader,z3=R3.PrecompiledLoader,W3=L3,G3=I3,V3=u1.Obj,K3=z2,Y3=K3.handleError,Z3=K3.Frame,Q3=function(e,t){function n(e,t){if(this.name=e,this.path=e,this.defaultEngine=t.defaultEngine,this.ext=N3.extname(e),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return n.prototype.render=function(t,n){e.render(this.name,t,n)},t.set("view",n),t.set("nunjucksEnv",e),e};function J3(e,t,n){F3((function(){e(t,n)}))}var X3={type:"code",obj:{root:function(e,t,n,i,r){try{r(null,"")}catch(e){r(Y3(e,null,null))}}}},e4=function(e){function t(){return e.apply(this,arguments)||this}P3(t,e);var n=t.prototype;return n.init=function(e,t){var n=this;t=this.opts=t||{},this.opts.dev=!!t.dev,this.opts.autoescape=null==t.autoescape||t.autoescape,this.opts.throwOnUndefined=!!t.throwOnUndefined,this.opts.trimBlocks=!!t.trimBlocks,this.opts.lstripBlocks=!!t.lstripBlocks,this.loaders=[],e?this.loaders=M3.isArray(e)?e:[e]:$3?this.loaders=[new $3("views")]:H3&&(this.loaders=[new H3("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new z3(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=G3(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],M3._entries(q3).forEach((function(e){var t=e[0],i=e[1];return n.addFilter(t,i)})),M3._entries(W3).forEach((function(e){var t=e[0],i=e[1];return n.addTest(t,i)}))},n._initLoaders=function(){var e=this;this.loaders.forEach((function(t){t.cache={},"function"==typeof t.on&&(t.on("update",(function(n,i){t.cache[n]=null,e.emit("update",n,i,t)})),t.on("load",(function(n,i){e.emit("load",n,i,t)})))}))},n.invalidateCache=function(){this.loaders.forEach((function(e){e.cache={}}))},n.addExtension=function(e,t){return t.__name=e,this.extensions[e]=t,this.extensionsList.push(t),this},n.removeExtension=function(e){var t=this.getExtension(e);t&&(this.extensionsList=M3.without(this.extensionsList,t),delete this.extensions[e])},n.getExtension=function(e){return this.extensions[e]},n.hasExtension=function(e){return!!this.extensions[e]},n.addGlobal=function(e,t){return this.globals[e]=t,this},n.getGlobal=function(e){if(void 0===this.globals[e])throw new Error("global not found: "+e);return this.globals[e]},n.addFilter=function(e,t,n){var i=t;return n&&this.asyncFilters.push(e),this.filters[e]=i,this},n.getFilter=function(e){if(!this.filters[e])throw new Error("filter not found: "+e);return this.filters[e]},n.addTest=function(e,t){return this.tests[e]=t,this},n.getTest=function(e){if(!this.tests[e])throw new Error("test not found: "+e);return this.tests[e]},n.resolveTemplate=function(e,t,n){return!(!e.isRelative||!t)&&e.isRelative(n)&&e.resolve?e.resolve(t,n):n},n.getTemplate=function(e,t,n,i,r){var s,o=this,a=this,c=null;if(e&&e.raw&&(e=e.raw),M3.isFunction(n)&&(r=n,n=null,t=t||!1),M3.isFunction(t)&&(r=t,t=!1),e instanceof n4)c=e;else{if("string"!=typeof e)throw new Error("template names must be a string: "+e);for(var l=0;l<this.loaders.length;l++){var u=this.loaders[l];if(c=u.cache[this.resolveTemplate(u,n,e)])break}}if(c)return t&&c.compile(),r?void r(null,c):c;return M3.asyncIter(this.loaders,(function(t,i,r,s){function o(e,n){e?s(e):n?(n.loader=t,s(null,n)):r()}e=a.resolveTemplate(t,n,e),t.async?t.getSource(e,o):o(null,t.getSource(e))}),(function(n,a){if(a||n||i||(n=new Error("template not found: "+e)),n){if(r)return void r(n);throw n}var c;a?(c=new n4(a.src,o,a.path,t),a.noCache||(a.loader.cache[e]=c)):c=new n4(X3,o,"",t),r?r(null,c):s=c})),s},n.express=function(e){return Q3(this,e)},n.render=function(e,t,n){M3.isFunction(t)&&(n=t,t=null);var i=null;return this.getTemplate(e,(function(e,r){if(e&&n)J3(n,e);else{if(e)throw e;i=r.render(t,n)}})),i},n.renderString=function(e,t,n,i){return M3.isFunction(n)&&(i=n,n={}),new n4(e,this,(n=n||{}).path).render(t,i)},n.waterfall=function(e,t,n){return B3(e,t,n)},t}(u1.EmitterObj),t4=function(e){function t(){return e.apply(this,arguments)||this}P3(t,e);var n=t.prototype;return n.init=function(e,t,n){var i=this;this.env=n||new e4,this.ctx=M3.extend({},e),this.blocks={},this.exported=[],M3.keys(t).forEach((function(e){i.addBlock(e,t[e])}))},n.lookup=function(e){return e in this.env.globals&&!(e in this.ctx)?this.env.globals[e]:this.ctx[e]},n.setVariable=function(e,t){this.ctx[e]=t},n.getVariables=function(){return this.ctx},n.addBlock=function(e,t){return this.blocks[e]=this.blocks[e]||[],this.blocks[e].push(t),this},n.getBlock=function(e){if(!this.blocks[e])throw new Error('unknown block "'+e+'"');return this.blocks[e][0]},n.getSuper=function(e,t,n,i,r,s){var o=M3.indexOf(this.blocks[t]||[],n),a=this.blocks[t][o+1];if(-1===o||!a)throw new Error('no super block available for "'+t+'"');a(e,this,i,r,s)},n.addExport=function(e){this.exported.push(e)},n.getExported=function(){var e=this,t={};return this.exported.forEach((function(n){t[n]=e.ctx[n]})),t},t}(V3),n4=function(e){function t(){return e.apply(this,arguments)||this}P3(t,e);var n=t.prototype;return n.init=function(e,t,n,i){if(this.env=t||new e4,M3.isObject(e))switch(e.type){case"code":this.tmplProps=e.obj;break;case"string":this.tmplStr=e.obj;break;default:throw new Error("Unexpected template object type "+e.type+"; expected 'code', or 'string'")}else{if(!M3.isString(e))throw new Error("src must be a string or an object describing the source");this.tmplStr=e}if(this.path=n,i)try{this._compile()}catch(e){throw M3._prettifyError(this.path,this.env.opts.dev,e)}else this.compiled=!1},n.render=function(e,t,n){var i=this;"function"==typeof e?(n=e,e={}):"function"==typeof t&&(n=t,t=null);var r=!t;try{this.compile()}catch(e){var s=M3._prettifyError(this.path,this.env.opts.dev,e);if(n)return J3(n,s);throw s}var o=new t4(e||{},this.blocks,this.env),a=t?t.push(!0):new Z3;a.topLevel=!0;var c=null,l=!1;return this.rootRenderFunc(this.env,o,a,K3,(function(e,t){if(!l||!n||void 0===t)if(e&&(e=M3._prettifyError(i.path,i.env.opts.dev,e),l=!0),n)r?J3(n,e,t):n(e,t);else{if(e)throw e;c=t}})),c},n.getExported=function(e,t,n){"function"==typeof e&&(n=e,e={}),"function"==typeof t&&(n=t,t=null);try{this.compile()}catch(e){if(n)return n(e);throw e}var i=t?t.push():new Z3;i.topLevel=!0;var r=new t4(e||{},this.blocks,this.env);this.rootRenderFunc(this.env,r,i,K3,(function(e){e?n(e,null):n(null,r.getExported())}))},n.compile=function(){this.compiled||this._compile()},n._compile=function(){var e;if(this.tmplProps)e=this.tmplProps;else{var t=U3.compile(this.tmplStr,this.env.asyncFilters,this.env.extensionsList,this.path,this.env.opts);e=new Function(t)()}this.blocks=this._getBlocks(e),this.rootRenderFunc=e.root,this.compiled=!0},n._getBlocks=function(e){var t={};return M3.keys(e).forEach((function(n){"b_"===n.slice(0,2)&&(t[n.slice(2)]=e[n])})),t},t}(V3),i4={Environment:e4,Template:n4};var r4=function(e,t){var n="";t=t||{};for(var i=0;i<e.length;i++){var r=JSON.stringify(e[i].name);n+="(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["+r+"] = (function() {\n"+e[i].template+"\n})();\n",t.asFunction&&(n+="return function(ctx, cb) { return nunjucks.render("+r+", ctx, cb); }\n"),n+="})();\n"}return n},s4=s,o4=o,a4=c0._prettifyError,c4=X2,l4=i4.Environment,u4=r4;function p4(e,t){return!!Array.isArray(t)&&t.some((function(t){return e.match(t)}))}function h4(e,t){(t=t||{}).isString=!0;var n=t.env||new l4([]),i=t.wrapper||u4;if(!t.name)throw new Error('the "name" option is required when compiling a string');return i([d4(e,t.name,n)],t)}function d4(e,t,n){var i,r=(n=n||new l4([])).asyncFilters,s=n.extensionsList;t=t.replace(/\\/g,"/");try{i=c4.compile(e,r,s,t,n.opts)}catch(e){throw a4(t,!1,e)}return{name:t,template:i}}var f4={precompile:function(e,t){var n=(t=t||{}).env||new l4([]),i=t.wrapper||u4;if(t.isString)return h4(e,t);var r=s4.existsSync(e)&&s4.statSync(e),s=[],o=[];if(r.isFile())s.push(d4(s4.readFileSync(e,"utf-8"),t.name||e,n));else if(r.isDirectory()){!function n(i){s4.readdirSync(i).forEach((function(r){var s=o4.join(i,r),a=s.substr(o4.join(e,"/").length),c=s4.statSync(s);c&&c.isDirectory()?p4(a+="/",t.exclude)||n(s):p4(a,t.include)&&o.push(s)}))}(e);for(var a=0;a<o.length;a++){var c=o[a].replace(o4.join(e,"/"),"");try{s.push(d4(s4.readFileSync(o[a],"utf-8"),c,n))}catch(e){if(!t.force)throw e;console.error(e)}}}return i(s,t)},precompileString:h4};var m4,g4=function(){var e,t,n=this.runtime,i=this.lib,r=this.compiler.Compiler,s=this.parser.Parser,o=this.nodes,a=this.lexer,c=n.contextOrFrameLookup,l=n.memberLookup;function u(e){return{index:e.index,lineno:e.lineno,colno:e.colno}}if(r&&(e=r.prototype.assertType),s&&(t=s.prototype.parseAggregate),n.contextOrFrameLookup=function(e,t,n){var i=c.apply(this,arguments);if(void 0!==i)return i;switch(n){case"True":return!0;case"False":return!1;case"None":return null;default:return}},"SLIM"!==process.env.BUILD_TYPE&&o&&r&&s){var p=o.Node.extend("Slice",{fields:["start","stop","step"],init:function(e,t,n,i,r){n=n||new o.Literal(e,t,null),i=i||new o.Literal(e,t,null),r=r||new o.Literal(e,t,1),this.parent(e,t,n,i,r)}});r.prototype.assertType=function(t){t instanceof p||e.apply(this,arguments)},r.prototype.compileSlice=function(e,t){this._emit("("),this._compileExpression(e.start,t),this._emit("),("),this._compileExpression(e.stop,t),this._emit("),("),this._compileExpression(e.step,t),this._emit(")")},s.prototype.parseAggregate=function(){var e=this,n=u(this.tokens);n.colno--,n.index--;try{return t.apply(this)}catch(t){var r=u(this.tokens),s=function(){return i._assign(e.tokens,r),t};i._assign(this.tokens,n),this.peeked=!1;var c=this.peekToken();if(c.type!==a.TOKEN_LEFT_BRACKET)throw s();this.nextToken();for(var l=new p(c.lineno,c.colno),h=!1,d=0;d<=l.fields.length&&!this.skip(a.TOKEN_RIGHT_BRACKET);d++){if(d===l.fields.length){if(!h)break;this.fail("parseSlice: too many slice components",c.lineno,c.colno)}this.skip(a.TOKEN_COLON)?h=!0:(l[l.fields[d]]=this.parseExpression(),h=this.skip(a.TOKEN_COLON)||h)}if(!h)throw s();return new o.Array(c.lineno,c.colno,[l])}}}function h(e,t,i,r){e=e||[],null===t&&(t=r<0?e.length-1:0),null===i?i=r<0?-1:e.length:i<0&&(i+=e.length),t<0&&(t+=e.length);for(var s=[],o=t;!(o<0||o>e.length)&&!(r>0&&o>=i)&&!(r<0&&o<=i);o+=r)s.push(n.memberLookup(e,o));return s}function d(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var f={pop:function(e){if(void 0===e)return this.pop();if(e>=this.length||e<0)throw new Error("KeyError");return this.splice(e,1)},append:function(e){return this.push(e)},remove:function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return this.splice(t,1);throw new Error("ValueError")},count:function(e){for(var t=0,n=0;n<this.length;n++)this[n]===e&&t++;return t},index:function(e){var t;if(-1===(t=this.indexOf(e)))throw new Error("ValueError");return t},find:function(e){return this.indexOf(e)},insert:function(e,t){return this.splice(e,0,t)}},m={items:function(){return i._entries(this)},values:function(){return i._values(this)},keys:function(){return i.keys(this)},get:function(e,t){var n=this[e];return void 0===n&&(n=t),n},has_key:function(e){return d(this,e)},pop:function(e,t){var n=this[e];if(void 0===n&&void 0!==t)n=t;else{if(void 0===n)throw new Error("KeyError");delete this[e]}return n},popitem:function(){var e=i.keys(this);if(!e.length)throw new Error("KeyError");var t=e[0],n=this[t];return delete this[t],[t,n]},setdefault:function(e,t){return void 0===t&&(t=null),e in this||(this[e]=t),this[e]},update:function(e){return i._assign(this,e),null}};return m.iteritems=m.items,m.itervalues=m.values,m.iterkeys=m.keys,n.memberLookup=function(e,t,n){return 4===arguments.length?h.apply(this,arguments):(e=e||{},i.isArray(e)&&d(f,t)?f[t].bind(e):i.isObject(e)&&d(m,t)?m[t].bind(e):l.apply(this,arguments))},function(){n.contextOrFrameLookup=c,n.memberLookup=l,r&&(r.prototype.assertType=e),s&&(s.prototype.parseAggregate=t)}},y4=c0,v4=i4.Environment,b4=i4.Template,_4=R3,w4=f4,x4=X2,E4=T2,S4=X0,k4=z2,T4=_2,A4=g4;function D4(e,t){var n;return t=t||{},y4.isObject(e)&&(t=e,e=null),_4.FileSystemLoader?n=new _4.FileSystemLoader(e,{watch:t.watch,noCache:t.noCache}):_4.WebLoader&&(n=new _4.WebLoader(e,{useCache:t.web&&t.web.useCache,async:t.web&&t.web.async})),m4=new v4(n,t),t&&t.express&&m4.express(t.express),m4}var C4={Environment:v4,Template:b4,Loader:b3,FileSystemLoader:_4.FileSystemLoader,NodeResolveLoader:_4.NodeResolveLoader,PrecompiledLoader:_4.PrecompiledLoader,WebLoader:_4.WebLoader,compiler:x4,parser:E4,lexer:S4,runtime:k4,lib:y4,nodes:T4,installJinjaCompat:A4,configure:D4,reset:function(){m4=void 0},compile:function(e,t,n,i){return m4||D4(),new b4(e,t,n,i)},render:function(e,t,n){return m4||D4(),m4.render(e,t,n)},renderString:function(e,t,n){return m4||D4(),m4.renderString(e,t,n)},precompile:w4?w4.precompile:void 0,precompileString:w4?w4.precompileString:void 0};const O4=C4,R4=o;O4.configure(R4.join(__dirname,"../views"),{autoescape:!0});const L4=R4.join(__dirname,"../views","notfound.njk");console.log("🚀 ~ TEMPLATE_PATH:",L4);var I4=function(e,t){return new Promise(((n,i)=>e.headersSent?n():O4.render(L4,{title:"qumra"},((n,r)=>{if(n)return console.error("🚀 ~ Error rendering template:",n),e.headersSent||t(n),i(n);e.status(404).send(r)}))))};const N4=I4;var P4=async(e,t,n,i,r)=>{const s=await fetch(e,{headers:t});if(!s.ok)return console.error("🚀 ~ Response error:",s.status),N4(i,r);return await s.json()},j4=z(P4);const F4=I4;var B4=async(e,t,n)=>{const i=await fetch("https://api.qumra.cloud/templateEngine/v1/customer",{headers:e});if(!i.ok)return console.error("🚀 ~ Response error:",i.status),F4(t,n);return await i.json()},M4=z(B4);const U4=process.cwd(),q4=o.join(U4,"src","views");const $4=new Oe;$4.name("theme").description("dev, list"),$4.command("create").description("Run development server with Webpack and BrowserSync").action(vf),$4.command("check").description("Run development server with Webpack and BrowserSync").action((async function(){const e=Vi("Checking files...").start();try{const t=await WR(q4,"views"),n=Object.keys(t);await GR(n,e)}catch(t){e.fail("Failed to retrieve files"),console.error(Et.red(`Failed to retrieve files - Error: ${t.message}`))}})),$4.command("dev").description("Run development server with Webpack and BrowserSync").action((async()=>{await yf();const{data:e}=await af.get("/apps"),t=e?.apps?.map((e=>({name:e.subdomain,value:e._id}))),n=await _l.prompt({type:"list",name:"app",message:"Choose the theme you want to use",choices:t});var i=e?.apps?.find((e=>e._id===n.app));const r=Zq(),s=await UX({port:3e3}),a=new x.Server(r),c=new RX(a),l=Vi("Start Server").start(),u=process.cwd(),p=o.join(u,"src");o.join(u,"src","assets");const h=o.join(u,"dist");d.exec("npx webpack --config webpack.config.js --mode development --stats errors-warnings",(async e=>{e&&console.log(e,"errrrrr");try{await I.access(p),await I.access(h)}catch{console.error("Error: Required directories do not exist."),process.exit(1)}r.use(Zq.static(h)),r.get("/api/auth",((e,t)=>{const{redirect_url:n,token:i}=e.query;if(console.log("🚀 ~ app.get ~ req.query:",e.query),!n||!i)return t.status(400).send("Missing redirect_url or token");t.cookie("token",i,{httpOnly:!1,secure:"production"===process.env.NODE_ENV,expires:new Date(9999,0,1)}),t.redirect(n)})),r.get("/api/auth/logout",((e,t)=>{t.clearCookie("token",{httpOnly:!0,secure:"production"===process.env.NODE_ENV}),t.redirect("/")})),r.use((async(e,t,n)=>{const r=`${i.url}${e.originalUrl}`;console.log("🚀 ~ app.use ~ choiseApp:",i),console.log("🚀 ~ app.use ~ fullUrl:",r);const s=qX(r),o=HX(e,i.subdomain),a=await j4(s,o,r,t,n),{customer:c,cart:l}=await M4(o,t,n);t.locals.render=a,t.locals.customer=c??{},t.locals.cart=l??{},n()})),r.get("*",j(r,{viewsDirectory:p,watch:!0},"development","theme")),Vi("REloading");const t=Vi("Connected"),n=Vi("Budilding");c.on("connection",(e=>{t.stop(),t.start();const i=Qq.watch([p,o.join(u,"tailwind.config.js")]);i.on("change",(()=>{i.close(),t.stop(),n.start(),d.exec(`cd ${u} && npx webpack --config webpack.config.js --mode development --stats errors-warnings`,(t=>{if(t)return console.log(t),void n.fail(Et.red("Build failed"));n.succeed(Et.blue("Rebuilt successfully")),e.emit("reload")}))})),e.on("disconnect",(()=>{i.close()}))})),c.on("disconnect",(()=>{console.log(Et.blue("Disconnected")),t.stop(),reloadSpinner.stop()})),a.listen(s,(()=>{l.succeed("Server Started"),console.log(`Server running at http://localhost:${s}`),NX(`http://localhost:${s}`)}))}))})),$4.command("list").description("List available themes").action((async()=>{const e=Vi("Fetching Data...").start();try{const{data:t}=await af.get("/themes");e.stop();const n=t?.themes?.map((e=>({name:e.title,value:e._id}))),i=await _l.prompt({type:"list",name:"selectedThemeId",message:"Choose the theme you want to use:",choices:n}),r=t?.themes.find((e=>e._id===i.selectedThemeId));console.log("🚀 ~ getThemes ~ selectedTheme:",r)}catch(t){e.stop(),console.error("Failed to fetch data:",t)}}));const H4=process.cwd(),z4=o.join(H4,"src");const W4=new Oe;W4.name("widget").description("dev"),W4.command("dev").description("Run development server with Webpack and BrowserSync").action((async()=>{await yf();const{data:e}=await af.get("/apps"),t=e?.apps?.map((e=>({name:e.subdomain,value:e._id}))),n=await _l.prompt({type:"list",name:"app",message:"Choose the theme you want to use",choices:t});var i=e?.apps?.find((e=>e._id===n.app));const r=Zq(),s=3e3,a=new x.Server(r),c=new RX(a),l=Vi("Start Server").start(),u=process.cwd(),p=o.join(u,"src");o.join(u,"src","assets");const h=o.join(u,"dist");console.log("🚀 ~ initializeServer ~ distPath:",h),d.exec("npx webpack --config webpack.config.js --mode development --stats errors-warnings",(async e=>{e&&console.log(e,"errrrrr");try{await I.access(p),await I.access(h)}catch{console.error("Error: Required directories do not exist."),process.exit(1)}r.use(Zq.static(h)),r.get("/api/auth",((e,t)=>{const{redirect_url:n,token:i}=e.query;if(console.log("🚀 ~ app.get ~ req.query:",e.query),!n||!i)return t.status(400).send("Missing redirect_url or token");t.cookie("token",i,{httpOnly:!1,secure:"production"===process.env.NODE_ENV,expires:new Date(9999,0,1)}),t.redirect(n)})),r.get("/api/auth/logout",((e,t)=>{t.clearCookie("token",{httpOnly:!0,secure:"production"===process.env.NODE_ENV}),t.redirect("/")})),r.get("*",j(r,{viewsDirectory:p,secretKey:i.secretKey,watch:!0},"development","widget")),Vi("REloading");const t=Vi("Connected"),n=Vi("Budilding");c.on("connection",(e=>{t.stop(),t.start();const i=Qq.watch([p,o.join(u,"tailwind.config.js")]);i.on("change",(()=>{i.close(),t.stop(),n.start(),d.exec(`cd ${u} && npx webpack --config webpack.config.js --mode development --stats errors-warnings`,(t=>{if(t)return console.log(t),void n.fail(Et.red("Build failed"));n.succeed(Et.blue("Rebuilt successfully")),e.emit("reload")}))})),e.on("disconnect",(()=>{i.close()}))})),c.on("disconnect",(()=>{console.log(Et.blue("Disconnected")),t.stop(),reloadSpinner.stop()})),a.listen(s,(()=>{l.succeed("Server Started"),console.log("Server running at http://localhost:3000"),NX("http://localhost:3000")}))}))})),W4.command("check").description("Run development server with Webpack and BrowserSync").action((async function(){const e=Vi("Checking files...").start();try{const e=await WR(z4),t=Object.keys(e);console.log("🚀 ~ checkFiles ~ files:",t)}catch(t){e.fail("Failed to retrieve files"),console.error(Et.red(`Failed to retrieve files - Error: ${t.message}`))}}));const G4=Object.create(null);G4.open="0",G4.close="1",G4.ping="2",G4.pong="3",G4.message="4",G4.upgrade="5",G4.noop="6";const V4=Object.create(null);Object.keys(G4).forEach((e=>{V4[G4[e]]=e}));const K4={type:"error",data:"parser error"},Y4=({type:e,data:t},n,i)=>t instanceof ArrayBuffer||ArrayBuffer.isView(t)?i(n?t:"b"+Z4(t,!0).toString("base64")):i(G4[e]+(t||"")),Z4=(e,t)=>Buffer.isBuffer(e)||e instanceof Uint8Array&&!t?e:e instanceof ArrayBuffer?Buffer.from(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength);let Q4;const J4=(e,t)=>{if("string"!=typeof e)return{type:"message",data:X4(e,t)};const n=e.charAt(0);if("b"===n){const n=Buffer.from(e.substring(1),"base64");return{type:"message",data:X4(n,t)}}return V4[n]?e.length>1?{type:V4[n],data:e.substring(1)}:{type:V4[n]}:K4},X4=(e,t)=>"arraybuffer"===t?e instanceof ArrayBuffer?e:Buffer.isBuffer(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e.buffer:Buffer.isBuffer(e)?e:Buffer.from(e),e5=String.fromCharCode(30);function t5(){return new TransformStream({transform(e,t){!function(e,t){if(e.data instanceof ArrayBuffer||ArrayBuffer.isView(e.data))return t(Z4(e.data,!1));Y4(e,!0,(e=>{Q4||(Q4=new TextEncoder),t(Q4.encode(e))}))}(e,(n=>{const i=n.length;let r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,i)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(i))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}})}let n5;function i5(e){return e.reduce(((e,t)=>e+t.length),0)}function r5(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let i=0;for(let r=0;r<t;r++)n[r]=e[0][i++],i===e[0].length&&(e.shift(),i=0);return e.length&&i<e[0].length&&(e[0]=e[0].slice(i)),n}const s5=global;function o5(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const a5=s5.setTimeout,c5=s5.clearTimeout;function l5(e,t){t.useNativeTimers?(e.setTimeoutFn=a5.bind(s5),e.clearTimeoutFn=c5.bind(s5)):(e.setTimeoutFn=s5.setTimeout.bind(s5),e.clearTimeoutFn=s5.clearTimeout.bind(s5))}class u5 extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class p5 extends xJ{constructor(e){super(),this.writable=!1,l5(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new u5(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=J4(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}const h5="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),d5=64,f5={};let m5,g5=0,y5=0;function v5(e){let t="";do{t=h5[e%d5]+t,e=Math.floor(e/d5)}while(e>0);return t}function b5(){const e=v5(+new Date);return e!==m5?(g5=0,m5=e):e+"."+v5(g5++)}for(;y5<d5;y5++)f5[h5[y5]]=y5;
|
|
377
|
+
parse:function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");for(var n={},i=t||{},r=e.split(CK),s=i.decode||AK,o=0;o<r.length;o++){var a=r[o],c=a.indexOf("=");if(!(c<0)){var l=a.substr(0,c).trim(),u=a.substr(++c,a.length).trim();'"'==u[0]&&(u=u.slice(1,-1)),null==n[l]&&(n[l]=RK(u,s))}}return n},serialize:function(e,t,n){var i=n||{},r=i.encode||DK;if("function"!=typeof r)throw new TypeError("option encode is invalid");if(!OK.test(e))throw new TypeError("argument name is invalid");var s=r(t);if(s&&!OK.test(s))throw new TypeError("argument val is invalid");var o=e+"="+s;if(null!=i.maxAge){var a=i.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(a)}if(i.domain){if(!OK.test(i.domain))throw new TypeError("option domain is invalid");o+="; Domain="+i.domain}if(i.path){if(!OK.test(i.path))throw new TypeError("option path is invalid");o+="; Path="+i.path}if(i.expires){if("function"!=typeof i.expires.toUTCString)throw new TypeError("option expires is invalid");o+="; Expires="+i.expires.toUTCString()}i.httpOnly&&(o+="; HttpOnly");i.secure&&(o+="; Secure");if(i.sameSite){switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}},AK=decodeURIComponent,DK=encodeURIComponent,CK=/; */,OK=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function RK(e,t){try{return t(e)}catch(t){return e}}var LK,IK,NK,PK,jK,FK,BK={exports:{}},MK={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}},UK={exports:{}},qK={exports:{}};function $K(){if(NK)return qK.exports;NK=1;const e="function"==typeof __webpack_require__?__non_webpack_require__:QF;return"function"==typeof e.addon?qK.exports=e.addon.bind(e):qK.exports=function(){if(IK)return LK;IK=1;var e=s,t=o,n=a,i="function"==typeof __webpack_require__?__non_webpack_require__:QF,r=process.config&&process.config.variables||{},c=!!process.env.PREBUILDS_ONLY,l=process.versions.modules,u=process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",p=process.env.npm_config_arch||n.arch(),h=process.env.npm_config_platform||n.platform(),d=process.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(h)?"musl":"glibc"),f=process.env.ARM_VERSION||("arm64"===p?"8":r.arm_version)||"",m=(process.versions.uv||"").split(".")[0];function g(e){return i(g.resolve(e))}function y(t){try{return e.readdirSync(t)}catch(e){return[]}}function v(e,n){var i=y(e).filter(n);return i[0]&&t.join(e,i[0])}function b(e){return/\.node$/.test(e)}function _(e){var t=e.split("-");if(2===t.length){var n=t[0],i=t[1].split("+");if(n&&i.length&&i.every(Boolean))return{name:e,platform:n,architectures:i}}}function w(e,t){return function(n){return null!=n&&n.platform===e&&n.architectures.includes(t)}}function x(e,t){return e.architectures.length-t.architectures.length}function E(e){var t=e.split("."),n={file:e,specificity:0};if("node"===t.pop()){for(var i=0;i<t.length;i++){var r=t[i];if("node"===r||"electron"===r||"node-webkit"===r)n.runtime=r;else if("napi"===r)n.napi=!0;else if("abi"===r.slice(0,3))n.abi=r.slice(3);else if("uv"===r.slice(0,2))n.uv=r.slice(2);else if("armv"===r.slice(0,4))n.armv=r.slice(4);else{if("glibc"!==r&&"musl"!==r)continue;n.libc=r}n.specificity++}return n}}function S(e,t){return function(n){return!(null==n||n.runtime&&n.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(n)||n.abi&&n.abi!==t&&!n.napi||n.uv&&n.uv!==m||n.armv&&n.armv!==f||n.libc&&n.libc!==d)}}function k(e){return function(t,n){return t.runtime!==n.runtime?t.runtime===e?-1:1:t.abi!==n.abi?t.abi?-1:1:t.specificity!==n.specificity?t.specificity>n.specificity?-1:1:0}}return LK=g,g.resolve=g.path=function(e){e=t.resolve(e||".");try{var n=i(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[n+"_PREBUILD"]&&(e=process.env[n+"_PREBUILD"])}catch(e){}if(!c){var r=v(t.join(e,"build/Release"),b);if(r)return r;var s=v(t.join(e,"build/Debug"),b);if(s)return s}var o=T(e);if(o)return o;var a=T(t.dirname(process.execPath));if(a)return a;var g=["platform="+h,"arch="+p,"runtime="+u,"abi="+l,"uv="+m,f?"armv="+f:"","libc="+d,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+g+"\n loaded from: "+e+"\n");function T(e){var n=y(t.join(e,"prebuilds")).map(_).filter(w(h,p)).sort(x)[0];if(n){var i=t.join(e,"prebuilds",n.name),r=y(i).map(E).filter(S(u,l)).sort(k(u))[0];return r?t.join(i,r.file):void 0}}},g.parseTags=E,g.matchTags=S,g.compareTags=k,g.parseTuple=_,g.matchTuple=w,g.compareTuples=x,LK}(),qK.exports}const{EMPTY_BUFFER:HK}=MK,zK=Buffer[Symbol.species];function WK(e,t,n,i,r){for(let s=0;s<r;s++)n[i+s]=e[s]^t[3&s]}function GK(e,t){for(let n=0;n<e.length;n++)e[n]^=t[3&n]}if(BK.exports={concat:function(e,t){if(0===e.length)return HK;if(1===e.length)return e[0];const n=Buffer.allocUnsafe(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];n.set(r,i),i+=r.length}return i<t?new zK(n.buffer,n.byteOffset,i):n},mask:WK,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let n;return t instanceof ArrayBuffer?n=new zK(t):ArrayBuffer.isView(t)?n=new zK(t.buffer,t.byteOffset,t.byteLength):(n=Buffer.from(t),e.readOnly=!1),n},unmask:GK},!process.env.WS_NO_BUFFER_UTIL)try{const e=function(){if(FK)return UK.exports;FK=1;try{UK.exports=$K()(__dirname)}catch(e){UK.exports=(jK||(jK=1,PK={mask:(e,t,n,i,r)=>{for(var s=0;s<r;s++)n[i+s]=e[s]^t[3&s]},unmask:(e,t)=>{const n=e.length;for(var i=0;i<n;i++)e[i]^=t[3&i]}}),PK)}return UK.exports}();BK.exports.mask=function(t,n,i,r,s){s<48?WK(t,n,i,r,s):e.mask(t,n,i,r,s)},BK.exports.unmask=function(t,n){t.length<32?GK(t,n):e.unmask(t,n)}}catch(m4){}var VK=BK.exports;const KK=Symbol("kDone"),YK=Symbol("kRun");const ZK=k,QK=VK,JK=class{constructor(e){this[KK]=()=>{this.pending--,this[YK]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[YK]()}[YK](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[KK])}}},{kStatusCode:XK}=MK,eY=Buffer[Symbol.species],tY=Buffer.from([0,0,255,255]),nY=Symbol("permessage-deflate"),iY=Symbol("total-length"),rY=Symbol("callback"),sY=Symbol("buffers"),oY=Symbol("error");let aY;var cY=class{constructor(e,t,n){if(this._maxPayload=0|n,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!aY){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;aY=new JK(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[rY];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,n=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(n.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?n.client_max_window_bits=t.clientMaxWindowBits:!0!==n.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete n.client_max_window_bits,n}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let n=e[t];if(n.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(n=n[0],"client_max_window_bits"===t){if(!0!==n){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}else if("server_max_window_bits"===t){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==n)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}e[t]=n}))})),e}decompress(e,t,n){aY.add((i=>{this._decompress(e,t,((e,t)=>{i(),n(e,t)}))}))}compress(e,t,n){aY.add((i=>{this._compress(e,t,((e,t)=>{i(),n(e,t)}))}))}_decompress(e,t,n){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?ZK.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=ZK.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[nY]=this,this._inflate[iY]=0,this._inflate[sY]=[],this._inflate.on("error",pY),this._inflate.on("data",uY)}this._inflate[rY]=n,this._inflate.write(e),t&&this._inflate.write(tY),this._inflate.flush((()=>{const e=this._inflate[oY];if(e)return this._inflate.close(),this._inflate=null,void n(e);const r=QK.concat(this._inflate[sY],this._inflate[iY]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[iY]=0,this._inflate[sY]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,r)}))}_compress(e,t,n){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?ZK.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=ZK.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[iY]=0,this._deflate[sY]=[],this._deflate.on("data",lY)}this._deflate[rY]=n,this._deflate.write(e),this._deflate.flush(ZK.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=QK.concat(this._deflate[sY],this._deflate[iY]);t&&(e=new eY(e.buffer,e.byteOffset,e.length-4)),this._deflate[rY]=null,this._deflate[iY]=0,this._deflate[sY]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,e)}))}};function lY(e){this[sY].push(e),this[iY]+=e.length}function uY(e){this[iY]+=e.length,this[nY]._maxPayload<1||this[iY]<=this[nY]._maxPayload?this[sY].push(e):(this[oY]=new RangeError("Max payload size exceeded"),this[oY].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[oY][XK]=1009,this.removeListener("data",uY),this.reset())}function pY(e){this[nY]._inflate=null,e[XK]=1007,this[rY](e)}var hY,dY,fY,mY={exports:{}},gY={exports:{}};const{isUtf8:yY}=v;function vY(e){const t=e.length;let n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}if(mY.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:vY,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},yY)mY.exports.isValidUTF8=function(e){return e.length<24?vY(e):yY(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const e=function(){if(fY)return gY.exports;fY=1;try{gY.exports=$K()(__dirname)}catch(e){gY.exports=(dY||(dY=1,hY=function(e){const t=e.length;let n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}),hY)}return gY.exports}();mY.exports.isValidUTF8=function(t){return t.length<32?vY(t):e(t)}}catch(m4){}var bY=mY.exports;const{Writable:_Y}=h,wY=cY,{BINARY_TYPES:xY,EMPTY_BUFFER:EY,kStatusCode:SY,kWebSocket:kY}=MK,{concat:TY,toArrayBuffer:AY,unmask:DY}=VK,{isValidStatusCode:CY,isValidUTF8:OY}=bY,RY=Buffer[Symbol.species];var LY=class extends _Y{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||xY[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[kY]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(8===this._opcode&&0==this._state)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new RY(t.buffer,t.byteOffset+e,t.length-e),new RY(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const n=this._buffers[0],i=t.length-e;e>=n.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),i),this._buffers[0]=new RY(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const n=!(64&~t[0]);if(!n||this._extensions[wY.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=n}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=EY;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&DY(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[wY.extensionName].decompress(e,this._fin,((e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(n)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let i;i="nodebuffer"===this._binaryType?TY(n,t):"arraybuffer"===this._binaryType?AY(TY(n,t)):n,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",i,!0),this._state=0,this.startLoop(e)})))}else{const i=TY(n,t);if(!this._skipUTF8Validation&&!OY(i)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",i,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,EY),this.end();else{const n=e.readUInt16BE(0);if(!CY(n)){const e=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const i=new RY(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!OY(i)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",n,i),this.end()}this._state=0}}createError(e,t,n,i,r){this._loop=!1,this._errored=!0;const s=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(s,this.createError),s.code=r,s[SY]=i,s}};const{randomFillSync:IY}=w,NY=cY,{EMPTY_BUFFER:PY}=MK,{isValidStatusCode:jY}=bY,{mask:FY,toBuffer:BY}=VK,MY=Symbol("kByteLength"),UY=Buffer.alloc(4),qY=8192;let $Y,HY=qY;var zY=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let n,i,r=!1,s=2,o=!1;t.mask&&(n=t.maskBuffer||UY,t.generateMask?t.generateMask(n):(HY===qY&&(void 0===$Y&&($Y=Buffer.alloc(qY)),IY($Y,0,qY),HY=0),n[0]=$Y[HY++],n[1]=$Y[HY++],n[2]=$Y[HY++],n[3]=$Y[HY++]),o=!(n[0]|n[1]|n[2]|n[3]),s=6),"string"==typeof e?i=t.mask&&!o||void 0===t[MY]?(e=Buffer.from(e)).length:t[MY]:(i=e.length,r=t.mask&&t.readOnly&&!o);let a=i;i>=65536?(s+=8,a=127):i>125&&(s+=2,a=126);const c=Buffer.allocUnsafe(r?i+s:s);return c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=a,126===a?c.writeUInt16BE(i,2):127===a&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),t.mask?(c[1]|=128,c[s-4]=n[0],c[s-3]=n[1],c[s-2]=n[2],c[s-1]=n[3],o?[c,e]:r?(FY(e,n,c,s,i),[c]):(FY(e,n,e,0,i),[c,e])):[c,e]}close(t,n,i,r){let s;if(void 0===t)s=PY;else{if("number"!=typeof t||!jY(t))throw new TypeError("First argument must be a valid error code number");if(void 0!==n&&n.length){const e=Buffer.byteLength(n);if(e>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+e),s.writeUInt16BE(t,0),"string"==typeof n?s.write(n,2):s.set(n,2)}else s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0)}const o={[MY]:s.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,r]):this.sendFrame(e.frame(s,o),r)}ping(t,n,i){let r,s;if("string"==typeof t?(r=Buffer.byteLength(t),s=!1):(r=(t=BY(t)).length,s=BY.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[MY]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,t,!1,o,i]):this.sendFrame(e.frame(t,o),i)}pong(t,n,i){let r,s;if("string"==typeof t?(r=Buffer.byteLength(t),s=!1):(r=(t=BY(t)).length,s=BY.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[MY]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,t,!1,o,i]):this.sendFrame(e.frame(t,o),i)}send(t,n,i){const r=this._extensions[NY.extensionName];let s,o,a=n.binary?2:1,c=n.compress;if("string"==typeof t?(s=Buffer.byteLength(t),o=!1):(s=(t=BY(t)).length,o=BY.readOnly),this._firstFragment?(this._firstFragment=!1,c&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(c=s>=r._threshold),this._compress=c):(c=!1,a=0),n.fin&&(this._firstFragment=!0),r){const e={[MY]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:o,rsv1:c};this._deflating?this.enqueue([this.dispatch,t,this._compress,e,i]):this.dispatch(t,this._compress,e,i)}else this.sendFrame(e.frame(t,{[MY]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:o,rsv1:!1}),i)}dispatch(t,n,i,r){if(!n)return void this.sendFrame(e.frame(t,i),r);const s=this._extensions[NY.extensionName];this._bufferedBytes+=i[MY],this._deflating=!0,s.compress(t,i.fin,((t,n)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t<this._queue.length;t++){const n=this._queue[t],i=n[n.length-1];"function"==typeof i&&i(e)}}else this._bufferedBytes-=i[MY],this._deflating=!1,i.readOnly=!1,this.sendFrame(e.frame(n,i),r),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][MY],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][MY],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};const{kForOnEventAttribute:WY,kListener:GY}=MK,VY=Symbol("kCode"),KY=Symbol("kData"),YY=Symbol("kError"),ZY=Symbol("kMessage"),QY=Symbol("kReason"),JY=Symbol("kTarget"),XY=Symbol("kType"),eZ=Symbol("kWasClean");class tZ{constructor(e){this[JY]=null,this[XY]=e}get target(){return this[JY]}get type(){return this[XY]}}Object.defineProperty(tZ.prototype,"target",{enumerable:!0}),Object.defineProperty(tZ.prototype,"type",{enumerable:!0});class nZ extends tZ{constructor(e,t={}){super(e),this[VY]=void 0===t.code?0:t.code,this[QY]=void 0===t.reason?"":t.reason,this[eZ]=void 0!==t.wasClean&&t.wasClean}get code(){return this[VY]}get reason(){return this[QY]}get wasClean(){return this[eZ]}}Object.defineProperty(nZ.prototype,"code",{enumerable:!0}),Object.defineProperty(nZ.prototype,"reason",{enumerable:!0}),Object.defineProperty(nZ.prototype,"wasClean",{enumerable:!0});class iZ extends tZ{constructor(e,t={}){super(e),this[YY]=void 0===t.error?null:t.error,this[ZY]=void 0===t.message?"":t.message}get error(){return this[YY]}get message(){return this[ZY]}}Object.defineProperty(iZ.prototype,"error",{enumerable:!0}),Object.defineProperty(iZ.prototype,"message",{enumerable:!0});class rZ extends tZ{constructor(e,t={}){super(e),this[KY]=void 0===t.data?null:t.data}get data(){return this[KY]}}Object.defineProperty(rZ.prototype,"data",{enumerable:!0});const sZ={addEventListener(e,t,n={}){for(const i of this.listeners(e))if(!n[WY]&&i[GY]===t&&!i[WY])return;let i;if("message"===e)i=function(e,n){const i=new rZ("message",{data:n?e:e.toString()});i[JY]=this,aZ(t,this,i)};else if("close"===e)i=function(e,n){const i=new nZ("close",{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});i[JY]=this,aZ(t,this,i)};else if("error"===e)i=function(e){const n=new iZ("error",{error:e,message:e.message});n[JY]=this,aZ(t,this,n)};else{if("open"!==e)return;i=function(){const e=new tZ("open");e[JY]=this,aZ(t,this,e)}}i[WY]=!!n[WY],i[GY]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(const n of this.listeners(e))if(n[GY]===t&&!n[WY]){this.removeListener(e,n);break}}};var oZ={CloseEvent:nZ,ErrorEvent:iZ,Event:tZ,EventTarget:sZ,MessageEvent:rZ};function aZ(e,t,n){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}const{tokenChars:cZ}=bY;function lZ(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}var uZ={format:function(e){return Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>[t].concat(Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let n,i,r=Object.create(null),s=!1,o=!1,a=!1,c=-1,l=-1,u=-1,p=0;for(;p<e.length;p++)if(l=e.charCodeAt(p),void 0===n)if(-1===u&&1===cZ[l])-1===c&&(c=p);else if(0===p||32!==l&&9!==l){if(59!==l&&44!==l)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===u&&(u=p);const i=e.slice(c,u);44===l?(lZ(t,i,r),r=Object.create(null)):n=i,c=u=-1}}else-1===u&&-1!==c&&(u=p);else if(void 0===i)if(-1===u&&1===cZ[l])-1===c&&(c=p);else if(32===l||9===l)-1===u&&-1!==c&&(u=p);else if(59===l||44===l){if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===u&&(u=p),lZ(r,e.slice(c,u),!0),44===l&&(lZ(t,n,r),r=Object.create(null),n=void 0),c=u=-1}else{if(61!==l||-1===c||-1!==u)throw new SyntaxError(`Unexpected character at index ${p}`);i=e.slice(c,p),c=u=-1}else if(o){if(1!==cZ[l])throw new SyntaxError(`Unexpected character at index ${p}`);-1===c?c=p:s||(s=!0),o=!1}else if(a)if(1===cZ[l])-1===c&&(c=p);else if(34===l&&-1!==c)a=!1,u=p;else{if(92!==l)throw new SyntaxError(`Unexpected character at index ${p}`);o=!0}else if(34===l&&61===e.charCodeAt(p-1))a=!0;else if(-1===u&&1===cZ[l])-1===c&&(c=p);else if(-1===c||32!==l&&9!==l){if(59!==l&&44!==l)throw new SyntaxError(`Unexpected character at index ${p}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${p}`);-1===u&&(u=p);let o=e.slice(c,u);s&&(o=o.replace(/\\/g,""),s=!1),lZ(r,i,o),44===l&&(lZ(t,n,r),r=Object.create(null),n=void 0),i=void 0,c=u=-1}}else-1===u&&(u=p);if(-1===c||a||32===l||9===l)throw new SyntaxError("Unexpected end of input");-1===u&&(u=p);const h=e.slice(c,u);return void 0===n?lZ(t,h,r):(void 0===i?lZ(r,h,!0):lZ(r,i,s?h.replace(/\\/g,""):h),lZ(t,n,r)),t}};const pZ=p,hZ=E,dZ=x,fZ=R,mZ=P,{randomBytes:gZ,createHash:yZ}=w,{URL:vZ}=S,bZ=cY,_Z=LY,wZ=zY,{BINARY_TYPES:xZ,EMPTY_BUFFER:EZ,GUID:SZ,kForOnEventAttribute:kZ,kListener:TZ,kStatusCode:AZ,kWebSocket:DZ,NOOP:CZ}=MK,{EventTarget:{addEventListener:OZ,removeEventListener:RZ}}=oZ,{format:LZ,parse:IZ}=uZ,{toBuffer:NZ}=VK,PZ=Symbol("kAborted"),jZ=[8,13],FZ=["CONNECTING","OPEN","CLOSING","CLOSED"],BZ=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;let MZ=class e extends pZ{constructor(t,n,i){super(),this._binaryType=xZ[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=EZ,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==t?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===n?n=[]:Array.isArray(n)||("object"==typeof n&&null!==n?(i=n,n=[]):n=[n]),qZ(this,t,n,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){xZ.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,i){const r=new _Z({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation});this._sender=new wZ(t,this._extensions,i.generateMask),this._receiver=r,this._socket=t,r[DZ]=this,t[DZ]=this,r.on("conclude",VZ),r.on("drain",KZ),r.on("error",YZ),r.on("message",QZ),r.on("ping",JZ),r.on("pong",XZ),t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",tQ),t.on("data",nQ),t.on("end",iQ),t.on("error",rQ),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=e.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[bZ.extensionName]&&this._extensions[bZ.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED)if(this.readyState!==e.CONNECTING)this.readyState!==e.CLOSING?(this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";WZ(this,this._req,e)}}pause(){this.readyState!==e.CONNECTING&&this.readyState!==e.CLOSED&&(this._paused=!0,this._socket.pause())}ping(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof t?(i=t,t=n=void 0):"function"==typeof n&&(i=n,n=void 0),"number"==typeof t&&(t=t.toString()),this.readyState===e.OPEN?(void 0===n&&(n=!this._isServer),this._sender.ping(t||EZ,n,i)):GZ(this,t,i)}pong(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof t?(i=t,t=n=void 0):"function"==typeof n&&(i=n,n=void 0),"number"==typeof t&&(t=t.toString()),this.readyState===e.OPEN?(void 0===n&&(n=!this._isServer),this._sender.pong(t||EZ,n,i)):GZ(this,t,i)}resume(){this.readyState!==e.CONNECTING&&this.readyState!==e.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof n&&(i=n,n={}),"number"==typeof t&&(t=t.toString()),this.readyState!==e.OPEN)return void GZ(this,t,i);const r={binary:"string"!=typeof t,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[bZ.extensionName]||(r.compress=!1),this._sender.send(t||EZ,r,i)}terminate(){if(this.readyState!==e.CLOSED)if(this.readyState!==e.CONNECTING)this._socket&&(this._readyState=e.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";WZ(this,this._req,e)}}};Object.defineProperty(MZ,"CONNECTING",{enumerable:!0,value:FZ.indexOf("CONNECTING")}),Object.defineProperty(MZ.prototype,"CONNECTING",{enumerable:!0,value:FZ.indexOf("CONNECTING")}),Object.defineProperty(MZ,"OPEN",{enumerable:!0,value:FZ.indexOf("OPEN")}),Object.defineProperty(MZ.prototype,"OPEN",{enumerable:!0,value:FZ.indexOf("OPEN")}),Object.defineProperty(MZ,"CLOSING",{enumerable:!0,value:FZ.indexOf("CLOSING")}),Object.defineProperty(MZ.prototype,"CLOSING",{enumerable:!0,value:FZ.indexOf("CLOSING")}),Object.defineProperty(MZ,"CLOSED",{enumerable:!0,value:FZ.indexOf("CLOSED")}),Object.defineProperty(MZ.prototype,"CLOSED",{enumerable:!0,value:FZ.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(MZ.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(MZ.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[kZ])return t[TZ];return null},set(t){for(const t of this.listeners(e))if(t[kZ]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[kZ]:!0})}})})),MZ.prototype.addEventListener=OZ,MZ.prototype.removeEventListener=RZ;var UZ=MZ;function qZ(e,t,n,i){const r={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:jZ[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=r.autoPong,!jZ.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${jZ.join(", ")})`);let s;if(t instanceof vZ)s=t;else try{s=new vZ(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),e._url=s.href;const o="wss:"===s.protocol,a="ws+unix:"===s.protocol;let c;if("ws:"===s.protocol||o||a?a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',c){const t=new SyntaxError(c);if(0===e._redirects)throw t;return void $Z(e,t)}const l=o?443:80,u=gZ(16).toString("base64"),p=o?hZ.request:dZ.request,h=new Set;let d,f;if(r.createConnection=r.createConnection||(o?zZ:HZ),r.defaultPort=r.defaultPort||l,r.port=s.port||l,r.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},r.path=s.pathname+s.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(d=new bZ(!0!==r.perMessageDeflate?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=LZ({[bZ.extensionName]:d.offer()})),n.length){for(const e of n){if("string"!=typeof e||!BZ.test(e)||h.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");h.add(e)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(s.username||s.password)&&(r.auth=`${s.username}:${s.password}`),a){const e=r.path.split(":");r.socketPath=e[0],r.path=e[1]}if(r.followRedirects){if(0===e._redirects){e._originalIpc=a,e._originalSecure=o,e._originalHostOrSocketPath=a?r.socketPath:s.host;const t=i&&i.headers;if(i={...i,headers:{}},t)for(const[e,n]of Object.entries(t))i.headers[e.toLowerCase()]=n}else if(0===e.listenerCount("redirect")){const t=a?!!e._originalIpc&&r.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!o)&&(delete r.headers.authorization,delete r.headers.cookie,t||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),f=e._req=p(r),e._redirects&&e.emit("redirect",e.url,f)}else f=e._req=p(r);r.timeout&&f.on("timeout",(()=>{WZ(e,f,"Opening handshake has timed out")})),f.on("error",(t=>{null===f||f[PZ]||(f=e._req=null,$Z(e,t))})),f.on("response",(s=>{const o=s.headers.location,a=s.statusCode;if(o&&r.followRedirects&&a>=300&&a<400){if(++e._redirects>r.maxRedirects)return void WZ(e,f,"Maximum redirects exceeded");let s;f.abort();try{s=new vZ(o,t)}catch(t){const n=new SyntaxError(`Invalid URL: ${o}`);return void $Z(e,n)}qZ(e,s,n,i)}else e.emit("unexpected-response",f,s)||WZ(e,f,`Unexpected server response: ${s.statusCode}`)})),f.on("upgrade",((t,n,i)=>{if(e.emit("upgrade",t),e.readyState!==MZ.CONNECTING)return;f=e._req=null;const s=t.headers.upgrade;if(void 0===s||"websocket"!==s.toLowerCase())return void WZ(e,n,"Invalid Upgrade header");const o=yZ("sha1").update(u+SZ).digest("base64");if(t.headers["sec-websocket-accept"]!==o)return void WZ(e,n,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?h.size?h.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":h.size&&(c="Server sent no subprotocol"),c)return void WZ(e,n,c);a&&(e._protocol=a);const l=t.headers["sec-websocket-extensions"];if(void 0!==l){if(!d){return void WZ(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=IZ(l)}catch(t){return void WZ(e,n,"Invalid Sec-WebSocket-Extensions header")}const i=Object.keys(t);if(1!==i.length||i[0]!==bZ.extensionName){return void WZ(e,n,"Server indicated an extension that was not requested")}try{d.accept(t[bZ.extensionName])}catch(t){return void WZ(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[bZ.extensionName]=d}e.setSocket(n,i,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})})),r.finishRequest?r.finishRequest(f,e):f.end()}function $Z(e,t){e._readyState=MZ.CLOSING,e.emit("error",t),e.emitClose()}function HZ(e){return e.path=e.socketPath,fZ.connect(e)}function zZ(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=fZ.isIP(e.host)?"":e.host),mZ.connect(e)}function WZ(e,t,n){e._readyState=MZ.CLOSING;const i=new Error(n);Error.captureStackTrace(i,WZ),t.setHeader?(t[PZ]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick($Z,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function GZ(e,t,n){if(t){const n=NZ(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${FZ[e.readyState]})`);process.nextTick(n,t)}}function VZ(e,t){const n=this[DZ];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,void 0!==n._socket[DZ]&&(n._socket.removeListener("data",nQ),process.nextTick(eQ,n._socket),1005===e?n.close():n.close(e,t))}function KZ(){const e=this[DZ];e.isPaused||e._socket.resume()}function YZ(e){const t=this[DZ];void 0!==t._socket[DZ]&&(t._socket.removeListener("data",nQ),process.nextTick(eQ,t._socket),t.close(e[AZ])),t.emit("error",e)}function ZZ(){this[DZ].emitClose()}function QZ(e,t){this[DZ].emit("message",e,t)}function JZ(e){const t=this[DZ];t._autoPong&&t.pong(e,!this._isServer,CZ),t.emit("ping",e)}function XZ(e){this[DZ].emit("pong",e)}function eQ(e){e.resume()}function tQ(){const e=this[DZ];let t;this.removeListener("close",tQ),this.removeListener("data",nQ),this.removeListener("end",iQ),e._readyState=MZ.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[DZ]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",ZZ),e._receiver.on("finish",ZZ))}function nQ(e){this[DZ]._receiver.write(e)||this.pause()}function iQ(){const e=this[DZ];e._readyState=MZ.CLOSING,e._receiver.end(),this.end()}function rQ(){const e=this[DZ];this.removeListener("error",rQ),this.on("error",CZ),e&&(e._readyState=MZ.CLOSING,this.destroy())}var sQ=z(UZ);const{Duplex:oQ}=h;function aQ(e){e.emit("close")}function cQ(){!this.destroyed&&this._writableState.finished&&this.destroy()}function lQ(e){this.removeListener("error",lQ),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var uQ=function(e,t){let n=!0;const i=new oQ({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,n){const r=!n&&i._readableState.objectMode?t.toString():t;i.push(r)||e.pause()})),e.once("error",(function(e){i.destroyed||(n=!1,i.destroy(e))})),e.once("close",(function(){i.destroyed||i.push(null)})),i._destroy=function(t,r){if(e.readyState===e.CLOSED)return r(t),void process.nextTick(aQ,i);let s=!1;e.once("error",(function(e){s=!0,r(e)})),e.once("close",(function(){s||r(t),process.nextTick(aQ,i)})),n&&e.terminate()},i._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){i._final(t)}))},i._read=function(){e.isPaused&&e.resume()},i._write=function(t,n,r){e.readyState!==e.CONNECTING?e.send(t,r):e.once("open",(function(){i._write(t,n,r)}))},i.on("end",cQ),i.on("error",lQ),i};const{tokenChars:pQ}=bY;var hQ={parse:function(e){const t=new Set;let n=-1,i=-1,r=0;for(;r<e.length;r++){const s=e.charCodeAt(r);if(-1===i&&1===pQ[s])-1===n&&(n=r);else if(0===r||32!==s&&9!==s){if(44!==s)throw new SyntaxError(`Unexpected character at index ${r}`);{if(-1===n)throw new SyntaxError(`Unexpected character at index ${r}`);-1===i&&(i=r);const s=e.slice(n,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=i=-1}}else-1===i&&-1!==n&&(i=r)}if(-1===n||-1!==i)throw new SyntaxError("Unexpected end of input");const s=e.slice(n,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}};const dQ=p,fQ=x,{createHash:mQ}=w,gQ=uZ,yQ=cY,vQ=hQ,bQ=UZ,{GUID:_Q,kWebSocket:wQ}=MK,xQ=/^[+/0-9A-Za-z]{22}==$/;var EQ=class extends dQ{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:bQ,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=fQ.createServer(((e,t)=>{const n=fQ.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),t.end(n)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const n of Object.keys(t))e.on(n,t[n]);return function(){for(const n of Object.keys(t))e.removeListener(n,t[n])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,n,i)=>{this.handleUpgrade(t,n,i,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(SQ,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(SQ,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{SQ(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,i){t.on("error",kQ);const r=e.headers["sec-websocket-key"],s=e.headers.upgrade,o=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void AQ(this,e,t,405,"Invalid HTTP method")}if(void 0===s||"websocket"!==s.toLowerCase()){return void AQ(this,e,t,400,"Invalid Upgrade header")}if(void 0===r||!xQ.test(r)){return void AQ(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==o&&13!==o){return void AQ(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void TQ(t,400);const a=e.headers["sec-websocket-protocol"];let c=new Set;if(void 0!==a)try{c=vQ.parse(a)}catch(n){return void AQ(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const l=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&void 0!==l){const n=new yQ(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=gQ.parse(l);e[yQ.extensionName]&&(n.accept(e[yQ.extensionName]),u[yQ.extensionName]=n)}catch(n){return void AQ(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const s={origin:e.headers[""+(8===o?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(s,((s,o,a,l)=>{if(!s)return TQ(t,o||401,a,l);this.completeUpgrade(u,r,c,e,t,n,i)}));if(!this.options.verifyClient(s))return TQ(t,401)}this.completeUpgrade(u,r,c,e,t,n,i)}completeUpgrade(e,t,n,i,r,s,o){if(!r.readable||!r.writable)return r.destroy();if(r[wQ])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return TQ(r,503);const a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mQ("sha1").update(t+_Q).digest("base64")}`],c=new this.options.WebSocket(null,void 0,this.options);if(n.size){const e=this.options.handleProtocols?this.options.handleProtocols(n,i):n.values().next().value;e&&(a.push(`Sec-WebSocket-Protocol: ${e}`),c._protocol=e)}if(e[yQ.extensionName]){const t=e[yQ.extensionName].params,n=gQ.format({[yQ.extensionName]:[t]});a.push(`Sec-WebSocket-Extensions: ${n}`),c._extensions=e}this.emit("headers",a,i),r.write(a.concat("\r\n").join("\r\n")),r.removeListener("error",kQ),c.setSocket(r,s,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(c),c.on("close",(()=>{this.clients.delete(c),this._shouldEmitClose&&!this.clients.size&&process.nextTick(SQ,this)}))),o(c,i)}};function SQ(e){e._state=2,e.emit("close")}function kQ(){this.destroy()}function TQ(e,t,n,i){n=n||fQ.STATUS_CODES[t],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...i},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${fQ.STATUS_CODES[t]}\r\n`+Object.keys(i).map((e=>`${e}: ${i[e]}`)).join("\r\n")+"\r\n\r\n"+n)}function AQ(e,t,n,i,r){if(e.listenerCount("wsClientError")){const i=new Error(r);Error.captureStackTrace(i,AQ),e.emit("wsClientError",i,n,t)}else TQ(n,i,r)}const DQ=UZ;DQ.createWebSocketStream=uQ,DQ.Server=EQ,DQ.Receiver=LY,DQ.Sender=zY,DQ.WebSocket=DQ,DQ.WebSocketServer=DQ.Server;var CQ=DQ,OQ={exports:{}},RQ=Object.getOwnPropertySymbols,LQ=Object.prototype.hasOwnProperty,IQ=Object.prototype.propertyIsEnumerable;var NQ=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,i,r=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),s=1;s<arguments.length;s++){for(var o in n=Object(arguments[s]))LQ.call(n,o)&&(r[o]=n[o]);if(RQ){i=RQ(n);for(var a=0;a<i.length;a++)IQ.call(n,i[a])&&(r[i[a]]=n[i[a]])}}return r};!function(){var e=NQ,t=bq,n={origin:"*",methods:"GET,HEAD,PUT,PATCH,POST,DELETE",preflightContinue:!1,optionsSuccessStatus:204};function i(e){return"string"==typeof e||e instanceof String}function r(e,t){if(Array.isArray(t)){for(var n=0;n<t.length;++n)if(r(e,t[n]))return!0;return!1}return i(t)?e===t:t instanceof RegExp?t.test(e):!!t}function s(e,t){var n,s=t.headers.origin,o=[];return e.origin&&"*"!==e.origin?i(e.origin)?(o.push([{key:"Access-Control-Allow-Origin",value:e.origin}]),o.push([{key:"Vary",value:"Origin"}])):(n=r(s,e.origin),o.push([{key:"Access-Control-Allow-Origin",value:!!n&&s}]),o.push([{key:"Vary",value:"Origin"}])):o.push([{key:"Access-Control-Allow-Origin",value:"*"}]),o}function o(e){return!0===e.credentials?{key:"Access-Control-Allow-Credentials",value:"true"}:null}function a(e){var t=e.exposedHeaders;return t?(t.join&&(t=t.join(",")),t&&t.length?{key:"Access-Control-Expose-Headers",value:t}:null):null}function c(e,n){for(var i=0,r=e.length;i<r;i++){var s=e[i];s&&(Array.isArray(s)?c(s,n):"Vary"===s.key&&s.value?t(n,s.value):s.value&&n.setHeader(s.key,s.value))}}OQ.exports=function(t){var i=null;return i="function"==typeof t?t:function(e,n){n(null,t)},function(t,r,l){i(t,(function(i,u){if(i)l(i);else{var p=e({},n,u),h=null;p.origin&&"function"==typeof p.origin?h=p.origin:p.origin&&(h=function(e,t){t(null,p.origin)}),h?h(t.headers.origin,(function(e,n){e||!n?l(e):(p.origin=n,function(e,t,n,i){var r=[];"OPTIONS"===(t.method&&t.method.toUpperCase&&t.method.toUpperCase())?(r.push(s(e,t)),r.push(o(e)),r.push(function(e){var t=e.methods;return t.join&&(t=e.methods.join(",")),{key:"Access-Control-Allow-Methods",value:t}}(e)),r.push(function(e,t){var n=e.allowedHeaders||e.headers,i=[];return n?n.join&&(n=n.join(",")):(n=t.headers["access-control-request-headers"],i.push([{key:"Vary",value:"Access-Control-Request-Headers"}])),n&&n.length&&i.push([{key:"Access-Control-Allow-Headers",value:n}]),i}(e,t)),r.push(function(e){var t=("number"==typeof e.maxAge||e.maxAge)&&e.maxAge.toString();return t&&t.length?{key:"Access-Control-Max-Age",value:t}:null}(e)),r.push(a(e)),c(r,n),e.preflightContinue?i():(n.statusCode=e.optionsSuccessStatus,n.setHeader("Content-Length","0"),n.end())):(r.push(s(e,t)),r.push(o(e)),r.push(a(e)),c(r,n),i())}(p,t,r,l))})):l()}}))}}}();var PQ=OQ.exports;Object.defineProperty(yV,"__esModule",{value:!0}),yV.Server=yV.BaseServer=void 0;const jQ=L,FQ=S,BQ=bV,MQ=_V,UQ=p,qQ=wK,$Q=TK,HQ=CQ,zQ=pK,WQ=EV,GQ=(0,ch.default)("engine"),VQ=Symbol("responseHeaders");class KQ extends UQ.EventEmitter{constructor(e={}){super(),this.middlewares=[],this.clients={},this.clientsCount=0,this.opts=Object.assign({wsEngine:HQ.Server,pingTimeout:2e4,pingInterval:25e3,upgradeTimeout:1e4,maxHttpBufferSize:1e6,transports:["polling","websocket"],allowUpgrades:!0,httpCompression:{threshold:1024},cors:!1,allowEIO3:!1},e),e.cookie&&(this.opts.cookie=Object.assign({name:"io",path:"/",httpOnly:!1!==e.cookie.path,sameSite:"lax"},e.cookie)),this.opts.cors&&this.use(PQ(this.opts.cors)),e.perMessageDeflate&&(this.opts.perMessageDeflate=Object.assign({threshold:1024},e.perMessageDeflate)),this.init()}_computePath(e){let t=(e.path||"/engine.io").replace(/\/$/,"");return!1!==e.addTrailingSlash&&(t+="/"),t}upgrades(e){return this.opts.allowUpgrades&&MQ.default[e].upgradesTo||[]}verify(e,t,n){const i=e._query.transport;if(!~this.opts.transports.indexOf(i)||"webtransport"===i)return GQ('unknown transport "%s"',i),n(ZQ.errors.UNKNOWN_TRANSPORT,{transport:i});const r=function(e){if((e+="").length<1)return!1;if(!XQ[e.charCodeAt(0)])return GQ('invalid header, index 0, char "%s"',e.charCodeAt(0)),!0;if(e.length<2)return!1;if(!XQ[e.charCodeAt(1)])return GQ('invalid header, index 1, char "%s"',e.charCodeAt(1)),!0;if(e.length<3)return!1;if(!XQ[e.charCodeAt(2)])return GQ('invalid header, index 2, char "%s"',e.charCodeAt(2)),!0;if(e.length<4)return!1;if(!XQ[e.charCodeAt(3)])return GQ('invalid header, index 3, char "%s"',e.charCodeAt(3)),!0;for(let t=4;t<e.length;++t)if(!XQ[e.charCodeAt(t)])return GQ('invalid header, index "%i", char "%s"',t,e.charCodeAt(t)),!0;return!1}(e.headers.origin);if(r){const t=e.headers.origin;return e.headers.origin=null,GQ("origin header invalid"),n(ZQ.errors.BAD_REQUEST,{name:"INVALID_ORIGIN",origin:t})}const s=e._query.sid;if(!s)return"GET"!==e.method?n(ZQ.errors.BAD_HANDSHAKE_METHOD,{method:e.method}):"websocket"!==i||t?this.opts.allowRequest?this.opts.allowRequest(e,((e,t)=>{if(!t)return n(ZQ.errors.FORBIDDEN,{message:e});n()})):n():(GQ("invalid transport upgrade"),n(ZQ.errors.BAD_REQUEST,{name:"TRANSPORT_HANDSHAKE_ERROR"}));{if(!this.clients.hasOwnProperty(s))return GQ('unknown sid "%s"',s),n(ZQ.errors.UNKNOWN_SID,{sid:s});const e=this.clients[s].transport.name;if(!t&&e!==i)return GQ("bad request: unexpected transport without upgrade"),n(ZQ.errors.BAD_REQUEST,{name:"TRANSPORT_MISMATCH",transport:i,previousTransport:e})}n()}use(e){this.middlewares.push(e)}_applyMiddlewares(e,t,n){if(0===this.middlewares.length)return GQ("no middleware to apply, skipping"),n();const i=r=>{GQ("applying middleware n°%d",r+1),this.middlewares[r](e,t,(e=>{if(e)return n(e);r+1<this.middlewares.length?i(r+1):n()}))};i(0)}close(){GQ("closing all open clients");for(let e in this.clients)this.clients.hasOwnProperty(e)&&this.clients[e].close(!0);return this.cleanup(),this}generateId(e){return BQ.generateId()}async handshake(e,t,n){const i="4"===t._query.EIO?4:3;if(3===i&&!this.opts.allowEIO3)return GQ("unsupported protocol version"),this.emit("connection_error",{req:t,code:ZQ.errors.UNSUPPORTED_PROTOCOL_VERSION,message:ZQ.errorMessages[ZQ.errors.UNSUPPORTED_PROTOCOL_VERSION],context:{protocol:i}}),void n(ZQ.errors.UNSUPPORTED_PROTOCOL_VERSION);let r;try{r=await this.generateId(t)}catch(e){return GQ("error while generating an id"),this.emit("connection_error",{req:t,code:ZQ.errors.BAD_REQUEST,message:ZQ.errorMessages[ZQ.errors.BAD_REQUEST],context:{name:"ID_GENERATION_ERROR",error:e}}),void n(ZQ.errors.BAD_REQUEST)}GQ('handshaking client "%s"',r);try{var s=this.createTransport(e,t);"polling"===e?(s.maxHttpBufferSize=this.opts.maxHttpBufferSize,s.httpCompression=this.opts.httpCompression):"websocket"===e&&(s.perMessageDeflate=this.opts.perMessageDeflate)}catch(i){return GQ('error handshaking to transport "%s"',e),this.emit("connection_error",{req:t,code:ZQ.errors.BAD_REQUEST,message:ZQ.errorMessages[ZQ.errors.BAD_REQUEST],context:{name:"TRANSPORT_HANDSHAKE_ERROR",error:i}}),void n(ZQ.errors.BAD_REQUEST)}const o=new qQ.Socket(r,this,s,t,i);return s.on("headers",((e,t)=>{!t._query.sid&&(this.opts.cookie&&(e["Set-Cookie"]=[(0,$Q.serialize)(this.opts.cookie.name,r,this.opts.cookie)]),this.emit("initial_headers",e,t)),this.emit("headers",e,t)})),s.onRequest(t),this.clients[r]=o,this.clientsCount++,o.once("close",(()=>{delete this.clients[r],this.clientsCount--})),this.emit("connection",o),s}async onWebTransportSession(e){const t=setTimeout((()=>{GQ("the client failed to establish a bidirectional stream in the given period"),e.close()}),this.opts.upgradeTimeout),n=e.incomingBidirectionalStreams.getReader(),i=await n.read();if(i.done)return void GQ("session is closed");const r=i.value,s=(0,WQ.createPacketDecoderStream)(this.opts.maxHttpBufferSize,"nodebuffer"),o=r.readable.pipeThrough(s).getReader(),{value:a,done:c}=await o.read();if(c)return void GQ("stream is closed");if(clearTimeout(t),"open"!==a.type)return GQ("invalid WebTransport handshake"),e.close();if(void 0===a.data){const t=new zQ.WebTransport(e,r,o),n=BQ.generateId();GQ('handshaking client "%s" (WebTransport)',n);const i=new qQ.Socket(n,this,t,null,4);return this.clients[n]=i,this.clientsCount++,i.once("close",(()=>{delete this.clients[n],this.clientsCount--})),void this.emit("connection",i)}const l=function(e){try{const t=JSON.parse(e);if("string"==typeof t.sid)return t.sid}catch(e){}}(a.data);if(!l)return GQ("invalid WebTransport handshake"),e.close();const u=this.clients[l];if(u)if(u.upgrading)GQ("transport has already been trying to upgrade"),e.close();else if(u.upgraded)GQ("transport had already been upgraded"),e.close();else{GQ("upgrading existing transport");const t=new zQ.WebTransport(e,r,o);u.maybeUpgrade(t)}else GQ("upgrade attempt for closed client"),e.close()}}yV.BaseServer=KQ,KQ.errors={UNKNOWN_TRANSPORT:0,UNKNOWN_SID:1,BAD_HANDSHAKE_METHOD:2,BAD_REQUEST:3,FORBIDDEN:4,UNSUPPORTED_PROTOCOL_VERSION:5},KQ.errorMessages={0:"Transport unknown",1:"Session ID unknown",2:"Bad handshake method",3:"Bad request",4:"Forbidden",5:"Unsupported protocol version"};class YQ{constructor(e,t){this.req=e,this.socket=t,e[VQ]={}}setHeader(e,t){this.req[VQ][e]=t}getHeader(e){return this.req[VQ][e]}removeHeader(e){delete this.req[VQ][e]}write(){}writeHead(){}end(){this.socket.destroy()}}let ZQ=class e extends KQ{init(){~this.opts.transports.indexOf("websocket")&&(this.ws&&this.ws.close(),this.ws=new this.opts.wsEngine({noServer:!0,clientTracking:!1,perMessageDeflate:this.opts.perMessageDeflate,maxPayload:this.opts.maxHttpBufferSize}),"function"==typeof this.ws.on&&this.ws.on("headers",((e,t)=>{const n=t[VQ]||{};delete t[VQ];!t._query.sid&&this.emit("initial_headers",n,t),this.emit("headers",n,t),GQ("writing headers: %j",n),Object.keys(n).forEach((t=>{e.push(`${t}: ${n[t]}`)}))})))}cleanup(){this.ws&&(GQ("closing webSocketServer"),this.ws.close())}prepare(e){e._query||(e._query=~e.url.indexOf("?")?jQ.parse((0,FQ.parse)(e.url).query):{})}createTransport(e,t){return new MQ.default[e](t)}handleRequest(t,n){GQ('handling "%s" http request "%s"',t.method,t.url),this.prepare(t),t.res=n;const i=(i,r)=>{if(void 0!==i)return this.emit("connection_error",{req:t,code:i,message:e.errorMessages[i],context:r}),void QQ(n,i,r);if(t._query.sid)GQ("setting new request for existing client"),this.clients[t._query.sid].transport.onRequest(t);else{const e=(e,t)=>QQ(n,e,t);this.handshake(t._query.transport,t,e)}};this._applyMiddlewares(t,n,(n=>{n?i(e.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!1,i)}))}handleUpgrade(t,n,i){this.prepare(t);const r=new YQ(t,n),s=(s,o)=>{if(void 0!==s)return this.emit("connection_error",{req:t,code:s,message:e.errorMessages[s],context:o}),void JQ(n,s,o);const a=Buffer.from(i);i=null,r.writeHead(),this.ws.handleUpgrade(t,n,a,(e=>{this.onWebSocket(t,n,e)}))};this._applyMiddlewares(t,r,(n=>{n?s(e.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!0,s)}))}onWebSocket(e,t,n){if(n.on("error",r),void 0!==MQ.default[e._query.transport]&&!MQ.default[e._query.transport].prototype.handlesUpgrades)return GQ("transport doesnt handle upgraded requests"),void n.close();const i=e._query.sid;if(e.websocket=n,i){const t=this.clients[i];if(t)if(t.upgrading)GQ("transport has already been trying to upgrade"),n.close();else if(t.upgraded)GQ("transport had already been upgraded"),n.close();else{GQ("upgrading existing transport"),n.removeListener("error",r);const i=this.createTransport(e._query.transport,e);i.perMessageDeflate=this.opts.perMessageDeflate,t.maybeUpgrade(i)}else GQ("upgrade attempt for closed client"),n.close()}else{const n=(e,n)=>JQ(t,e,n);this.handshake(e._query.transport,e,n)}function r(){GQ("websocket error before upgrade")}}attach(e,t={}){const n=this._computePath(t),i=t.destroyUpgradeTimeout||1e3;function r(e){return n===e.url.slice(0,n.length)}const s=e.listeners("request").slice(0);e.removeAllListeners("request"),e.on("close",this.close.bind(this)),e.on("listening",this.init.bind(this)),e.on("request",((t,i)=>{if(r(t))GQ('intercepting request for path "%s"',n),this.handleRequest(t,i);else{let n=0;const r=s.length;for(;n<r;n++)s[n].call(e,t,i)}})),~this.opts.transports.indexOf("websocket")&&e.on("upgrade",((e,n,s)=>{r(e)?this.handleUpgrade(e,n,s):!1!==t.destroyUpgrade&&setTimeout((function(){if(n.writable&&n.bytesWritten<=0)return n.on("error",(e=>{GQ("error while destroying upgrade: %s",e.message)})),n.end()}),i)}))}};function QQ(e,t,n){const i=t===ZQ.errors.FORBIDDEN?403:400,r=n&&n.message?n.message:ZQ.errorMessages[t];e.writeHead(i,{"Content-Type":"application/json"}),e.end(JSON.stringify({code:t,message:r}))}function JQ(e,t,n={}){if(e.on("error",(()=>{GQ("ignoring error from closed connection")})),e.writable){const i=n.message||ZQ.errorMessages[t],r=Buffer.byteLength(i);e.write("HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-type: text/html\r\nContent-Length: "+r+"\r\n\r\n"+i)}e.destroy()}yV.Server=ZQ;const XQ=[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];var eJ={},tJ={},nJ={};Object.defineProperty(nJ,"__esModule",{value:!0}),nJ.Polling=void 0;const iJ=xV,rJ=k,sJ=$U,oJ=(0,ch.default)("engine:polling"),aJ={gzip:rJ.createGzip,deflate:rJ.createDeflate};let cJ=class extends iJ.Transport{constructor(e){super(e),this.closeTimeout=3e4}get name(){return"polling"}get supportsFraming(){return!1}onRequest(e){const t=e.res;e.res=null,"get"===e.getMethod()?this.onPollRequest(e,t):"post"===e.getMethod()?this.onDataRequest(e,t):(t.writeStatus("500 Internal Server Error"),t.end())}onPollRequest(e,t){if(this.req)return oJ("request overlap"),this.onError("overlap from client"),t.writeStatus("500 Internal Server Error"),void t.end();oJ("setting request"),this.req=e,this.res=t;e.cleanup=()=>{this.req=this.res=null},t.onAborted((()=>{this.writable=!1,this.onError("poll connection closed prematurely")})),this.writable=!0,this.emit("drain"),this.writable&&this.shouldClose&&(oJ("triggering empty send to append close packet"),this.send([{type:"noop"}]))}onDataRequest(e,t){if(this.dataReq)return this.onError("data request overlap from client"),t.writeStatus("500 Internal Server Error"),void t.end();const n=Number(e.headers["content-length"]);if(!n)return this.onError("content-length header required"),void t.writeStatus("411 Length Required").end();if(n>this.maxHttpBufferSize)return this.onError("payload too large"),void t.writeStatus("413 Payload Too Large").end();if("application/octet-stream"===e.headers["content-type"]&&4===this.protocol)return this.onError("invalid content");let i;this.dataReq=e,this.dataRes=t;let r=0;const s={"Content-Type":"text/html"};this.headers(e,s);for(let e in s)t.writeHeader(e,String(s[e]));const o=e=>{this.onData(e.toString()),this.onDataRequestCleanup(),t.cork((()=>{t.end("ok")}))};t.onAborted((()=>{this.onDataRequestCleanup(),this.onError("data request connection closed prematurely")})),t.onData(((e,s)=>{const a=r+e.byteLength;if(a>n)return this.onError("content-length mismatch"),void t.close();if(!i){if(s)return void o(Buffer.from(e));i=Buffer.allocUnsafe(n)}if(Buffer.from(e).copy(i,r),s)return a!=n?(this.onError("content-length mismatch"),t.writeStatus("400 Content-Length Mismatch").end(),void this.onDataRequestCleanup()):void o(i);r=a}))}onDataRequestCleanup(){this.dataReq=this.dataRes=null}onData(e){oJ('received "%s"',e);const t=e=>{if("close"===e.type)return oJ("got xhr close packet"),this.onClose(),!1;this.onPacket(e)};3===this.protocol?this.parser.decodePayload(e,t):this.parser.decodePayload(e).forEach(t)}onClose(){this.writable&&this.send([{type:"noop"}]),super.onClose()}send(e){this.writable=!1,this.shouldClose&&(oJ("appending close packet to payload"),e.push({type:"close"}),this.shouldClose(),this.shouldClose=null);const t=t=>{const n=e.some((e=>e.options&&e.options.compress));this.write(t,{compress:n})};3===this.protocol?this.parser.encodePayload(e,this.supportsBinary,t):this.parser.encodePayload(e,t)}write(e,t){oJ('writing "%s"',e),this.doWrite(e,t,(()=>{this.req.cleanup()}))}doWrite(e,t,n){const i="string"==typeof e,r={"Content-Type":i?"text/plain; charset=UTF-8":"application/octet-stream"},s=e=>{this.headers(this.req,r),this.res.cork((()=>{Object.keys(r).forEach((e=>{this.res.writeHeader(e,String(r[e]))})),this.res.end(e)})),n()};if(!this.httpCompression||!t.compress)return void s(e);if((i?Buffer.byteLength(e):e.length)<this.httpCompression.threshold)return void s(e);const o=sJ(this.req).encodings(["gzip","deflate"]);o?this.compress(e,o,((e,t)=>{if(e)return this.res.writeStatus("500 Internal Server Error"),this.res.end(),void n(e);r["Content-Encoding"]=o,s(t)})):s(e)}compress(e,t,n){oJ("compressing");const i=[];let r=0;aJ[t](this.httpCompression).on("error",n).on("data",(function(e){i.push(e),r+=e.length})).on("end",(function(){n(null,Buffer.concat(i,r))})).end(e)}doClose(e){let t;oJ("closing");const n=()=>{clearTimeout(t),e(),this.onClose()};this.writable?(oJ("transport writable - closing right away"),this.send([{type:"close"}]),n()):this.discarded?(oJ("transport discarded - closing right away"),n()):(oJ("transport not writable - buffering orderly close"),this.shouldClose=n,t=setTimeout(n,this.closeTimeout))}headers(e,t){t=t||{};const n=e.headers["user-agent"];return n&&(~n.indexOf(";MSIE")||~n.indexOf("Trident/"))&&(t["X-XSS-Protection"]="0"),t["cache-control"]="no-store",this.emit("headers",t,e),t}};nJ.Polling=cJ;var lJ={};Object.defineProperty(lJ,"__esModule",{value:!0}),lJ.WebSocket=void 0;const uJ=xV,pJ=(0,ch.default)("engine:ws");let hJ=class extends uJ.Transport{constructor(e){super(e),this.writable=!1,this.perMessageDeflate=null}get name(){return"websocket"}get handlesUpgrades(){return!0}get supportsFraming(){return!0}send(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t+1===e.length,r=e=>{const t="string"!=typeof e,n=this.perMessageDeflate&&Buffer.byteLength(e)>this.perMessageDeflate.threshold;pJ('writing "%s"',e),this.socket.send(e,t,n),i&&(this.writable=!0,this.emit("drain"))};n.options&&"string"==typeof n.options.wsPreEncoded?r(n.options.wsPreEncoded):this.parser.encodePacket(n,this.supportsBinary,r)}}doClose(e){pJ("closing"),e&&e(),this.socket.end()}};lJ.WebSocket=hJ,Object.defineProperty(tJ,"__esModule",{value:!0});const dJ=nJ,fJ=lJ;tJ.default={polling:dJ.Polling,websocket:fJ.WebSocket},Object.defineProperty(eJ,"__esModule",{value:!0}),eJ.uServer=void 0;const mJ=yV,gJ=tJ,yJ=(0,ch.default)("engine:uws");class vJ extends mJ.BaseServer{init(){}cleanup(){}prepare(e,t){e.method=e.getMethod().toUpperCase(),e.url=e.getUrl();const n=new URLSearchParams(e.getQuery());e._query=Object.fromEntries(n.entries()),e.headers={},e.forEach(((t,n)=>{e.headers[t]=n})),e.connection={remoteAddress:Buffer.from(t.getRemoteAddressAsText()).toString()},t.onAborted((()=>{yJ("response has been aborted")}))}createTransport(e,t){return new gJ.default[e](t)}attach(e,t={}){const n=this._computePath(t);e.any(n,this.handleRequest.bind(this)).ws(n,{compression:t.compression,idleTimeout:t.idleTimeout,maxBackpressure:t.maxBackpressure,maxPayloadLength:this.opts.maxHttpBufferSize,upgrade:this.handleUpgrade.bind(this),open:e=>{const t=e.getUserData().transport;t.socket=e,t.writable=!0,t.emit("drain")},message:(e,t,n)=>{e.getUserData().transport.onData(n?t:Buffer.from(t).toString())},close:(e,t,n)=>{e.getUserData().transport.onClose(t,n)}})}_applyMiddlewares(e,t,n){if(0===this.middlewares.length)return n();e.res=new bJ(t),super._applyMiddlewares(e,e.res,(t=>{e.res.writeHead(),n(t)}))}handleRequest(e,t){yJ('handling "%s" http request "%s"',t.getMethod(),t.getUrl()),this.prepare(t,e),t.res=e;const n=(n,i)=>{if(void 0!==n)return this.emit("connection_error",{req:t,code:n,message:mJ.Server.errorMessages[n],context:i}),void this.abortRequest(t.res,n,i);if(t._query.sid)yJ("setting new request for existing client"),this.clients[t._query.sid].transport.onRequest(t);else{const n=(t,n)=>this.abortRequest(e,t,n);this.handshake(t._query.transport,t,n)}};this._applyMiddlewares(t,e,(e=>{e?n(mJ.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!1,n)}))}handleUpgrade(e,t,n){yJ("on upgrade"),this.prepare(t,e),t.res=e;const i=async(i,r)=>{if(void 0!==i)return this.emit("connection_error",{req:t,code:i,message:mJ.Server.errorMessages[i],context:r}),void this.abortRequest(e,i,r);const s=t._query.sid;let o;if(s){const n=this.clients[s];n?n.upgrading?(yJ("transport has already been trying to upgrade"),e.close()):n.upgraded?(yJ("transport had already been upgraded"),e.close()):(yJ("upgrading existing transport"),o=this.createTransport(t._query.transport,t),n.maybeUpgrade(o)):(yJ("upgrade attempt for closed client"),e.close())}else if(o=await this.handshake(t._query.transport,t,((t,n)=>this.abortRequest(e,t,n))),!o)return;t.res.writeStatus("101 Switching Protocols"),e.upgrade({transport:o},t.getHeader("sec-websocket-key"),t.getHeader("sec-websocket-protocol"),t.getHeader("sec-websocket-extensions"),n)};this._applyMiddlewares(t,e,(e=>{e?i(mJ.Server.errors.BAD_REQUEST,{name:"MIDDLEWARE_FAILURE"}):this.verify(t,!0,i)}))}abortRequest(e,t,n){const i=t===mJ.Server.errors.FORBIDDEN?"403 Forbidden":"400 Bad Request",r=n&&n.message?n.message:mJ.Server.errorMessages[t];e.writeStatus(i),e.writeHeader("Content-Type","application/json"),e.end(JSON.stringify({code:t,message:r}))}}eJ.uServer=vJ;class bJ{constructor(e){this.res=e,this.statusWritten=!1,this.headers=[],this.isAborted=!1}set statusCode(e){e&&this.writeStatus(200===e?"200 OK":"204 No Content")}writeHead(e){this.statusCode=e}setHeader(e,t){Array.isArray(t)?t.forEach((t=>{this.writeHeader(e,t)})):this.writeHeader(e,t)}removeHeader(){}getHeader(){}writeStatus(e){if(!this.isAborted)return this.res.writeStatus(e),this.statusWritten=!0,this.writeBufferedHeaders(),this}writeHeader(e,t){this.isAborted||"Content-Length"!==e&&(this.statusWritten?this.res.writeHeader(e,t):this.headers.push([e,t]))}writeBufferedHeaders(){this.headers.forEach((([e,t])=>{this.res.writeHeader(e,t)}))}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)}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.protocol=e.Transport=e.Socket=e.uServer=e.parser=e.attach=e.listen=e.transports=e.Server=void 0;const t=x,n=yV;Object.defineProperty(e,"Server",{enumerable:!0,get:function(){return n.Server}});const i=_V;e.transports=i.default;const r=EV;e.parser=r;var s=eJ;Object.defineProperty(e,"uServer",{enumerable:!0,get:function(){return s.uServer}});var o=wK;Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return o.Socket}});var a=xV;function c(e,t){const i=new n.Server(t);return i.attach(e,t),i}Object.defineProperty(e,"Transport",{enumerable:!0,get:function(){return a.Transport}}),e.protocol=r.protocol,e.listen=function(e,n,i){"function"==typeof n&&(i=n,n={});const r=(0,t.createServer)((function(e,t){t.writeHead(501),t.end("Not Implemented")})),s=c(r,n);return s.httpServer=r,r.listen(e,i),s},e.attach=c}(gV);var _J={},wJ={};function xJ(e){if(e)return function(e){for(var t in xJ.prototype)e[t]=xJ.prototype[t];return e}(e)}xJ.prototype.on=xJ.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},xJ.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},xJ.prototype.off=xJ.prototype.removeListener=xJ.prototype.removeAllListeners=xJ.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<i.length;r++)if((n=i[r])===t||n.fn===t){i.splice(r,1);break}return 0===i.length&&delete this._callbacks["$"+e],this},xJ.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(n){i=0;for(var r=(n=n.slice(0)).length;i<r;++i)n[i].apply(this,t)}return this},xJ.prototype.emitReserved=xJ.prototype.emit,xJ.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},xJ.prototype.hasListeners=function(e){return!!this.listeners(e).length};var EJ=W(Object.freeze({__proto__:null,Emitter:xJ})),SJ={},kJ={};Object.defineProperty(kJ,"__esModule",{value:!0}),kJ.hasBinary=kJ.isBinary=void 0;const TJ="function"==typeof ArrayBuffer,AJ=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,DJ=Object.prototype.toString,CJ="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===DJ.call(Blob),OJ="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===DJ.call(File);function RJ(e){return TJ&&(e instanceof ArrayBuffer||AJ(e))||CJ&&e instanceof Blob||OJ&&e instanceof File}kJ.isBinary=RJ,kJ.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,i=t.length;n<i;n++)if(e(t[n]))return!0;return!1}if(RJ(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1},Object.defineProperty(SJ,"__esModule",{value:!0}),SJ.reconstructPacket=SJ.deconstructPacket=void 0;const LJ=kJ;function IJ(e,t){if(!e)return e;if((0,LJ.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let i=0;i<e.length;i++)n[i]=IJ(e[i],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=IJ(e[i],t));return n}return e}function NJ(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=NJ(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=NJ(e[n],t));return e}SJ.deconstructPacket=function(e){const t=[],n=e.data,i=e;return i.data=IJ(n,t),i.attachments=t.length,{packet:i,buffers:t}},SJ.reconstructPacket=function(e,t){return e.data=NJ(e.data,t),delete e.attachments,e},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Decoder=e.Encoder=e.PacketType=e.protocol=void 0;const t=EJ,n=SJ,i=kJ,r=(0,ch.default)("socket.io-parser"),s=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var o;e.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(o=e.PacketType||(e.PacketType={}));function a(e){return"[object Object]"===Object.prototype.toString.call(e)}e.Encoder=class{constructor(e){this.replacer=e}encode(e){return r("encoding packet %j",e),e.type!==o.EVENT&&e.type!==o.ACK||!(0,i.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===o.EVENT?o.BINARY_EVENT:o.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==o.BINARY_EVENT&&e.type!==o.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),r("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,n.deconstructPacket)(e),i=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(i),r}};class c extends t.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===o.BINARY_EVENT;n||t.type===o.BINARY_ACK?(t.type=n?o.EVENT:o.ACK,this.reconstructor=new l(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,i.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===o[n.type])throw new Error("unknown packet type "+n.type);if(n.type===o.BINARY_EVENT||n.type===o.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(i,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(r)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(i,t)}else n.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!c.isPayloadValid(n.type,i))throw new Error("invalid payload");n.data=i}return r("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case o.CONNECT:return a(t);case o.DISCONNECT:return void 0===t;case o.CONNECT_ERROR:return"string"==typeof t||a(t);case o.EVENT:case o.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===s.indexOf(t[0]));case o.ACK:case o.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}e.Decoder=c;class l{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,n.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}}(wJ),Object.defineProperty(_J,"__esModule",{value:!0}),_J.Client=void 0;const PJ=wJ,jJ=S,FJ=ch("socket.io:client");_J.Client=class{constructor(e,t){this.sockets=new Map,this.nsps=new Map,this.server=e,this.conn=t,this.encoder=e.encoder,this.decoder=new e._parser.Decoder,this.id=t.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((()=>{0===this.nsps.size?(FJ("no namespace joined yet, close the client"),this.close()):FJ("the client has already joined a namespace, nothing to do")}),this.server._connectTimeout)}connect(e,t={}){if(this.server._nsps.has(e))return FJ("connecting to namespace %s",e),this.doConnect(e,t);this.server._checkNamespace(e,t,(n=>{n?this.doConnect(e,t):(FJ("creation of namespace %s was denied",e),this._packet({type:PJ.PacketType.CONNECT_ERROR,nsp:e,data:{message:"Invalid namespace"}}))}))}doConnect(e,t){const n=this.server.of(e);n._add(this,t,(e=>{this.sockets.set(e.id,e),this.nsps.set(n.name,e),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)}))}_disconnect(){for(const e of this.sockets.values())e.disconnect();this.sockets.clear(),this.close()}_remove(e){if(this.sockets.has(e.id)){const t=this.sockets.get(e.id).nsp.name;this.sockets.delete(e.id),this.nsps.delete(t)}else FJ("ignoring remove for %s",e.id)}close(){"open"===this.conn.readyState&&(FJ("forcing transport close"),this.conn.close(),this.onclose("forced server close"))}_packet(e,t={}){if("open"!==this.conn.readyState)return void FJ("ignoring packet write %j",e);const n=t.preEncoded?e:this.encoder.encode(e);this.writeToEngine(n,t)}writeToEngine(e,t){if(t.volatile&&!this.conn.transport.writable)return void FJ("volatile packet is discarded since the transport is not currently writable");const n=Array.isArray(e)?e:[e];for(const e of n)this.conn.write(e,t)}ondata(e){try{this.decoder.add(e)}catch(e){FJ("invalid packet format"),this.onerror(e)}}ondecoded(e){let t,n;if(3===this.conn.protocol){const i=jJ.parse(e.nsp,!0);t=i.pathname,n=i.query}else t=e.nsp,n=e.data;const i=this.nsps.get(t);i||e.type!==PJ.PacketType.CONNECT?i&&e.type!==PJ.PacketType.CONNECT&&e.type!==PJ.PacketType.CONNECT_ERROR?process.nextTick((function(){i._onpacket(e)})):(FJ("invalid state (packet type: %s)",e.type),this.close()):this.connect(t,n)}onerror(e){for(const t of this.sockets.values())t._onerror(e);this.conn.close()}onclose(e,t){FJ("client close with reason %s",e),this.destroy();for(const n of this.sockets.values())n._onclose(e,t);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)}};var BJ={},MJ={},UJ={};Object.defineProperty(UJ,"__esModule",{value:!0}),UJ.StrictEventEmitter=void 0;const qJ=p;class $J extends qJ.EventEmitter{on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}emit(e,...t){return super.emit(e,...t)}emitReserved(e,...t){return super.emit(e,...t)}emitUntyped(e,...t){return super.emit(e,...t)}listeners(e){return super.listeners(e)}}UJ.StrictEventEmitter=$J;var HJ,zJ,WJ={};function GJ(){if(HJ)return WJ;HJ=1,Object.defineProperty(WJ,"__esModule",{value:!0}),WJ.RemoteSocket=WJ.BroadcastOperator=void 0;const e=VJ(),t=wJ;class n{constructor(e,t=new Set,n=new Set,i={}){this.adapter=e,this.rooms=t,this.exceptRooms=n,this.flags=i}to(e){const t=new Set(this.rooms);return Array.isArray(e)?e.forEach((e=>t.add(e))):t.add(e),new n(this.adapter,t,this.exceptRooms,this.flags)}in(e){return this.to(e)}except(e){const t=new Set(this.exceptRooms);return Array.isArray(e)?e.forEach((e=>t.add(e))):t.add(e),new n(this.adapter,this.rooms,t,this.flags)}compress(e){const t=Object.assign({},this.flags,{compress:e});return new n(this.adapter,this.rooms,this.exceptRooms,t)}get volatile(){const e=Object.assign({},this.flags,{volatile:!0});return new n(this.adapter,this.rooms,this.exceptRooms,e)}get local(){const e=Object.assign({},this.flags,{local:!0});return new n(this.adapter,this.rooms,this.exceptRooms,e)}timeout(e){const t=Object.assign({},this.flags,{timeout:e});return new n(this.adapter,this.rooms,this.exceptRooms,t)}emit(n,...i){if(e.RESERVED_EVENTS.has(n))throw new Error(`"${String(n)}" is a reserved event name`);const r=[n,...i],s={type:t.PacketType.EVENT,data:r};if(!("function"==typeof r[r.length-1]))return this.adapter.broadcast(s,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags}),!0;const o=r.pop();let a=!1,c=[];const l=setTimeout((()=>{a=!0,o.apply(this,[new Error("operation has timed out"),this.flags.expectSingleResponse?null:c])}),this.flags.timeout);let u=-1,p=0,h=0;const d=()=>{a||u!==p||c.length!==h||(clearTimeout(l),o.apply(this,[null,this.flags.expectSingleResponse?c[0]:c]))};return this.adapter.broadcastWithAck(s,{rooms:this.rooms,except:this.exceptRooms,flags:this.flags},(e=>{h+=e,p++,d()}),(e=>{c.push(e),d()})),this.adapter.serverCount().then((e=>{u=e,d()})),!0}emitWithAck(e,...t){return new Promise(((n,i)=>{t.push(((e,t)=>e?(e.responses=t,i(e)):n(t))),this.emit(e,...t)}))}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((t=>t.map((t=>t instanceof e.Socket?t:new i(this.adapter,t)))))}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)}}WJ.BroadcastOperator=n;class i{constructor(e,t){this.id=t.id,this.handshake=t.handshake,this.rooms=new Set(t.rooms),this.data=t.data,this.operator=new n(e,new Set([this.id]),new Set,{expectSingleResponse:!0})}timeout(e){return this.operator.timeout(e)}emit(e,...t){return this.operator.emit(e,...t)}join(e){return this.operator.socketsJoin(e)}leave(e){return this.operator.socketsLeave(e)}disconnect(e=!1){return this.operator.disconnectSockets(e),this}}return WJ.RemoteSocket=i,WJ}function VJ(){return zJ||(zJ=1,function(e){var t=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Socket=e.RESERVED_EVENTS=void 0;const n=wJ,i=t(ch),r=UJ,s=t(bV),o=GJ(),a=(0,i.default)("socket.io:socket"),c=new Set(["transport error","transport close","forced close","ping timeout","server shutting down","forced server close"]);function l(){}e.RESERVED_EVENTS=new Set(["connect","connect_error","disconnect","disconnecting","newListener","removeListener"]);class u extends r.StrictEventEmitter{constructor(e,t,i,r){super(),this.nsp=e,this.client=t,this.recovered=!1,this.data={},this.connected=!1,this.acks=new Map,this.fns=[],this.flags={},this.server=e.server,this.adapter=this.nsp.adapter,r?(this.id=r.sid,this.pid=r.pid,r.rooms.forEach((e=>this.join(e))),this.data=r.data,r.missedPackets.forEach((e=>{this.packet({type:n.PacketType.EVENT,data:e})})),this.recovered=!0):(3===t.conn.protocol?this.id="/"!==e.name?e.name+"#"+t.id:t.id:this.id=s.default.generateId(),this.server._opts.connectionStateRecovery&&(this.pid=s.default.generateId())),this.handshake=this.buildHandshake(i),this.on("error",l)}buildHandshake(e){var t,n,i,r;return{headers:(null===(t=this.request)||void 0===t?void 0:t.headers)||{},time:new Date+"",address:this.conn.remoteAddress,xdomain:!!(null===(n=this.request)||void 0===n?void 0:n.headers.origin),secure:!this.request||!!this.request.connection.encrypted,issued:+new Date,url:null===(i=this.request)||void 0===i?void 0:i.url,query:(null===(r=this.request)||void 0===r?void 0:r._query)||{},auth:e}}emit(t,...i){if(e.RESERVED_EVENTS.has(t))throw new Error(`"${String(t)}" is a reserved event name`);const r=[t,...i],s={type:n.PacketType.EVENT,data:r};if("function"==typeof r[r.length-1]){const e=this.nsp._ids++;a("emitting packet with ack id %d",e),this.registerAckCallback(e,r.pop()),s.id=e}const o=Object.assign({},this.flags);return this.flags={},this.nsp.server.opts.connectionStateRecovery?this.adapter.broadcast(s,{rooms:new Set([this.id]),except:new Set,flags:o}):(this.notifyOutgoingListeners(s),this.packet(s,o)),!0}emitWithAck(e,...t){const n=void 0!==this.flags.timeout;return new Promise(((i,r)=>{t.push(((e,t)=>n?e?r(e):i(t):i(e))),this.emit(e,...t)}))}registerAckCallback(e,t){const n=this.flags.timeout;if(void 0===n)return void this.acks.set(e,t);const i=setTimeout((()=>{a("event with ack id %d has timed out after %d ms",e,n),this.acks.delete(e),t.call(this,new Error("operation has timed out"))}),n);this.acks.set(e,((...e)=>{clearTimeout(i),t.apply(this,[null,...e])}))}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,t={}){e.nsp=this.nsp.name,t.compress=!1!==t.compress,this.client._packet(e,t)}join(e){return a("join room %s",e),this.adapter.addAll(this.id,new Set(Array.isArray(e)?e:[e]))}leave(e){return a("leave room %s",e),this.adapter.del(this.id,e)}leaveAll(){this.adapter.delAll(this.id)}_onconnect(){a("socket connected - writing packet"),this.connected=!0,this.join(this.id),3===this.conn.protocol?this.packet({type:n.PacketType.CONNECT}):this.packet({type:n.PacketType.CONNECT,data:{sid:this.id,pid:this.pid}})}_onpacket(e){switch(a("got packet %j",e),e.type){case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(e);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(e);break;case n.PacketType.DISCONNECT:this.ondisconnect()}}onevent(e){const t=e.data||[];if(a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const n of e)n.apply(this,t)}this.dispatch(t)}ack(e){const t=this;let i=!1;return function(){if(i)return;const r=Array.prototype.slice.call(arguments);a("sending ack %j",r),t.packet({id:e,type:n.PacketType.ACK,data:r}),i=!0}}onack(e){const t=this.acks.get(e.id);"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),this.acks.delete(e.id)):a("bad ack %s",e.id)}ondisconnect(){a("got disconnect packet"),this._onclose("client namespace disconnect")}_onerror(e){this.emitReserved("error",e)}_onclose(e,t){if(!this.connected)return this;a("closing socket - reason %s",e),this.emitReserved("disconnecting",e,t),this.server._opts.connectionStateRecovery&&c.has(e)&&(a("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,t)}_cleanup(){this.leaveAll(),this.nsp._remove(this),this.join=l}_error(e){this.packet({type:n.PacketType.CONNECT_ERROR,data:e})}disconnect(e=!1){return this.connected?(e?this.client._disconnect():(this.packet({type:n.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){a("dispatching an event %j",e),this.run(e,(t=>{process.nextTick((()=>{if(t)return this._onerror(t);this.connected?super.emitUntyped.apply(this,e):a("ignore packet received after disconnection")}))}))}use(e){return this.fns.push(e),this}run(e,t){const n=this.fns.slice(0);if(!n.length)return t(null);!function i(r){n[r](e,(function(e){return e?t(e):n[r+1]?void i(r+1):t(null)}))}(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){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}newBroadcastOperator(){const e=Object.assign({},this.flags);return this.flags={},new o.BroadcastOperator(this.adapter,new Set,new Set([this.id]),e)}}e.Socket=u}(MJ)),MJ}!function(e){var t=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Namespace=e.RESERVED_EVENTS=void 0;const n=VJ(),i=UJ,r=t(ch),s=GJ(),o=(0,r.default)("socket.io:namespace");e.RESERVED_EVENTS=new Set(["connect","connection","new_namespace"]);class a extends i.StrictEventEmitter{constructor(e,t){super(),this.sockets=new Map,this._fns=[],this._ids=0,this.server=e,this.name=t,this._initAdapter()}_initAdapter(){this.adapter=new(this.server.adapter())(this)}use(e){return this._fns.push(e),this}run(e,t){const n=this._fns.slice(0);if(!n.length)return t(null);!function i(r){n[r](e,(function(e){return e?t(e):n[r+1]?void i(r+1):t(null)}))}(0)}to(e){return new s.BroadcastOperator(this.adapter).to(e)}in(e){return new s.BroadcastOperator(this.adapter).in(e)}except(e){return new s.BroadcastOperator(this.adapter).except(e)}async _add(e,t,n){var i;o("adding socket to nsp %s",this.name);const r=await this._createSocket(e,t);if((null===(i=this.server.opts.connectionStateRecovery)||void 0===i?void 0:i.skipMiddlewares)&&r.recovered&&"open"===e.conn.readyState)return this._doConnect(r,n);this.run(r,(t=>{process.nextTick((()=>"open"!==e.conn.readyState?(o("next called after client was closed - ignoring socket"),void r._cleanup()):t?(o("middleware error, sending CONNECT_ERROR packet to the client"),r._cleanup(),3===e.conn.protocol?r._error(t.data||t.message):r._error({message:t.message,data:t.data})):void this._doConnect(r,n)))}))}async _createSocket(e,t){const i=t.pid,r=t.offset;if(this.server.opts.connectionStateRecovery&&"string"==typeof i&&"string"==typeof r){let s;try{s=await this.adapter.restoreSession(i,r)}catch(e){o("error while restoring session: %s",e)}if(s)return o("connection state recovered for sid %s",s.sid),new n.Socket(this,e,t,s)}return new n.Socket(this,e,t)}_doConnect(e,t){this.sockets.set(e.id,e),e._onconnect(),t&&t(e),this.emitReserved("connect",e),this.emitReserved("connection",e)}_remove(e){this.sockets.has(e.id)?this.sockets.delete(e.id):o("ignoring remove for %s",e.id)}emit(e,...t){return new s.BroadcastOperator(this.adapter).emit(e,...t)}send(...e){return this.emit("message",...e),this}write(...e){return this.emit("message",...e),this}serverSideEmit(t,...n){if(e.RESERVED_EVENTS.has(t))throw new Error(`"${String(t)}" is a reserved event name`);return n.unshift(t),this.adapter.serverSideEmit(n),!0}serverSideEmitWithAck(e,...t){return new Promise(((n,i)=>{t.push(((e,t)=>e?(e.responses=t,i(e)):n(t))),this.serverSideEmit(e,...t)}))}_onServerSideEmit(e){super.emitUntyped.apply(this,e)}allSockets(){return new s.BroadcastOperator(this.adapter).allSockets()}compress(e){return new s.BroadcastOperator(this.adapter).compress(e)}get volatile(){return new s.BroadcastOperator(this.adapter).volatile}get local(){return new s.BroadcastOperator(this.adapter).local}timeout(e){return new s.BroadcastOperator(this.adapter).timeout(e)}fetchSockets(){return new s.BroadcastOperator(this.adapter).fetchSockets()}socketsJoin(e){return new s.BroadcastOperator(this.adapter).socketsJoin(e)}socketsLeave(e){return new s.BroadcastOperator(this.adapter).socketsLeave(e)}disconnectSockets(e=!1){return new s.BroadcastOperator(this.adapter).disconnectSockets(e)}}e.Namespace=a}(BJ);var KJ={},YJ={},ZJ={},QJ={};Object.defineProperty(QJ,"__esModule",{value:!0}),QJ.yeast=QJ.decode=QJ.encode=void 0;const JJ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),XJ=64,eX={};let tX,nX=0,iX=0;function rX(e){let t="";do{t=JJ[e%XJ]+t,e=Math.floor(e/XJ)}while(e>0);return t}for(QJ.encode=rX,QJ.decode=function(e){let t=0;for(iX=0;iX<e.length;iX++)t=t*XJ+eX[e.charAt(iX)];return t},QJ.yeast=function(){const e=rX(+new Date);return e!==tX?(nX=0,tX=e):e+"."+rX(nX++)};iX<XJ;iX++)eX[JJ[iX]]=iX;var sX;Object.defineProperty(ZJ,"__esModule",{value:!0}),ZJ.SessionAwareAdapter=ZJ.Adapter=void 0;const oX=p,aX=QJ,cX=CQ,lX="function"==typeof(null===(sX=null==cX?void 0:cX.Sender)||void 0===sX?void 0:sX.frame);class uX extends oX.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,t){this.sids.has(e)||this.sids.set(e,new Set);for(const n of t)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,t){this.sids.has(e)&&this.sids.get(e).delete(t),this._del(t,e)}_del(e,t){const n=this.rooms.get(e);if(null!=n){n.delete(t)&&this.emit("leave-room",e,t),0===n.size&&this.rooms.delete(e)&&this.emit("delete-room",e)}}delAll(e){if(this.sids.has(e)){for(const t of this.sids.get(e))this._del(t,e);this.sids.delete(e)}}broadcast(e,t){const n=t.flags||{},i={preEncoded:!0,volatile:n.volatile,compress:n.compress};e.nsp=this.nsp.name;const r=this._encode(e,i);this.apply(t,(t=>{"function"==typeof t.notifyOutgoingListeners&&t.notifyOutgoingListeners(e),t.client.writeToEngine(r,i)}))}broadcastWithAck(e,t,n,i){const r=t.flags||{},s={preEncoded:!0,volatile:r.volatile,compress:r.compress};e.nsp=this.nsp.name,e.id=this.nsp._ids++;const o=this._encode(e,s);let a=0;this.apply(t,(t=>{a++,t.acks.set(e.id,i),"function"==typeof t.notifyOutgoingListeners&&t.notifyOutgoingListeners(e),t.client.writeToEngine(o,s)})),n(a)}_encode(e,t){const n=this.encoder.encode(e);if(lX&&1===n.length&&"string"==typeof n[0]){const e=Buffer.from("4"+n[0]);t.wsPreEncodedFrame=cX.Sender.frame(e,{readOnly:!1,mask:!1,rsv1:!1,opcode:1,fin:!0})}return n}sockets(e){const t=new Set;return this.apply({rooms:e},(e=>{t.add(e.id)})),Promise.resolve(t)}socketRooms(e){return this.sids.get(e)}fetchSockets(e){const t=[];return this.apply(e,(e=>{t.push(e)})),Promise.resolve(t)}addSockets(e,t){this.apply(e,(e=>{e.join(t)}))}delSockets(e,t){this.apply(e,(e=>{t.forEach((t=>e.leave(t)))}))}disconnectSockets(e,t){this.apply(e,(e=>{e.disconnect(t)}))}apply(e,t){const n=e.rooms,i=this.computeExceptSids(e.except);if(n.size){const e=new Set;for(const r of n)if(this.rooms.has(r))for(const n of this.rooms.get(r)){if(e.has(n)||i.has(n))continue;const r=this.nsp.sockets.get(n);r&&(t(r),e.add(n))}}else for(const[e]of this.sids){if(i.has(e))continue;const n=this.nsp.sockets.get(e);n&&t(n)}}computeExceptSids(e){const t=new Set;if(e&&e.size>0)for(const n of e)this.rooms.has(n)&&this.rooms.get(n).forEach((e=>t.add(e)));return t}serverSideEmit(e){console.warn("this adapter does not support the serverSideEmit() functionality")}persistSession(e){}restoreSession(e,t){return null}}ZJ.Adapter=uX;function pX(e,t){const n=0===t.rooms.size||e.some((e=>t.rooms.has(e))),i=e.every((e=>!t.except.has(e)));return n&&i}ZJ.SessionAwareAdapter=class extends uX{constructor(e){super(e),this.nsp=e,this.sessions=new Map,this.packets=[],this.maxDisconnectionDuration=e.server.opts.connectionStateRecovery.maxDisconnectionDuration;const t=setInterval((()=>{const e=Date.now()-this.maxDisconnectionDuration;this.sessions.forEach(((t,n)=>{t.disconnectedAt<e&&this.sessions.delete(n)}));for(let t=this.packets.length-1;t>=0;t--){if(this.packets[t].emittedAt<e){this.packets.splice(0,t+1);break}}}),6e4);t.unref()}persistSession(e){e.disconnectedAt=Date.now(),this.sessions.set(e.pid,e)}restoreSession(e,t){const n=this.sessions.get(e);if(!n)return null;if(n.disconnectedAt+this.maxDisconnectionDuration<Date.now())return this.sessions.delete(e),null;const i=this.packets.findIndex((e=>e.id===t));if(-1===i)return null;const r=[];for(let e=i+1;e<this.packets.length;e++){const t=this.packets[e];pX(n.rooms,t.opts)&&r.push(t.data)}return Promise.resolve(Object.assign(Object.assign({},n),{missedPackets:r}))}broadcast(e,t){var n;const i=2===e.type,r=void 0===e.id,s=void 0===(null===(n=t.flags)||void 0===n?void 0:n.volatile);if(i&&r&&s){const n=(0,aX.yeast)();e.data.push(n),this.packets.push({id:n,opts:t,data:e.data,emittedAt:Date.now()})}super.broadcast(e,t)}};var hX={};!function(e){var t=H&&H.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.ClusterAdapterWithHeartbeat=e.ClusterAdapter=e.MessageType=void 0;const n=ZJ,i=w,r=(0,ch.debug)("socket.io-adapter"),s=5e3;function o(){return(0,i.randomBytes)(8).toString("hex")}var a;function c(e){return{rooms:[...e.rooms],except:[...e.except],flags:e.flags}}function l(e){return{rooms:new Set(e.rooms),except:new Set(e.except),flags:e.flags}}!function(e){e[e.INITIAL_HEARTBEAT=1]="INITIAL_HEARTBEAT",e[e.HEARTBEAT=2]="HEARTBEAT",e[e.BROADCAST=3]="BROADCAST",e[e.SOCKETS_JOIN=4]="SOCKETS_JOIN",e[e.SOCKETS_LEAVE=5]="SOCKETS_LEAVE",e[e.DISCONNECT_SOCKETS=6]="DISCONNECT_SOCKETS",e[e.FETCH_SOCKETS=7]="FETCH_SOCKETS",e[e.FETCH_SOCKETS_RESPONSE=8]="FETCH_SOCKETS_RESPONSE",e[e.SERVER_SIDE_EMIT=9]="SERVER_SIDE_EMIT",e[e.SERVER_SIDE_EMIT_RESPONSE=10]="SERVER_SIDE_EMIT_RESPONSE",e[e.BROADCAST_CLIENT_COUNT=11]="BROADCAST_CLIENT_COUNT",e[e.BROADCAST_ACK=12]="BROADCAST_ACK",e[e.ADAPTER_CLOSE=13]="ADAPTER_CLOSE"}(a=e.MessageType||(e.MessageType={}));class u extends n.Adapter{constructor(e){super(e),this.requests=new Map,this.ackRequests=new Map,this.uid=o()}onMessage(e,n){if(e.uid===this.uid)return r("[%s] ignore message from self",this.uid);switch(r("[%s] new event of type %d from %s",this.uid,e.type,e.uid),e.type){case a.BROADCAST:if(void 0!==e.data.requestId)super.broadcastWithAck(e.data.packet,l(e.data.opts),(t=>{r("[%s] waiting for %d client acknowledgements",this.uid,t),this.publishResponse(e.uid,{type:a.BROADCAST_CLIENT_COUNT,data:{requestId:e.data.requestId,clientCount:t}})}),(t=>{r("[%s] received acknowledgement with value %j",this.uid,t),this.publishResponse(e.uid,{type:a.BROADCAST_ACK,data:{requestId:e.data.requestId,packet:t}})}));else{const t=e.data.packet,i=l(e.data.opts);this.addOffsetIfNecessary(t,i,n),super.broadcast(t,i)}break;case a.SOCKETS_JOIN:super.addSockets(l(e.data.opts),e.data.rooms);break;case a.SOCKETS_LEAVE:super.delSockets(l(e.data.opts),e.data.rooms);break;case a.DISCONNECT_SOCKETS:super.disconnectSockets(l(e.data.opts),e.data.close);break;case a.FETCH_SOCKETS:r("[%s] calling fetchSockets with opts %j",this.uid,e.data.opts),super.fetchSockets(l(e.data.opts)).then((n=>{this.publishResponse(e.uid,{type:a.FETCH_SOCKETS_RESPONSE,data:{requestId:e.data.requestId,sockets:n.map((e=>{const n=e.handshake,i=t(n,["sessionStore"]);return{id:e.id,handshake:i,rooms:[...e.rooms],data:e.data}}))}})}));break;case a.SERVER_SIDE_EMIT:{const t=e.data.packet;if(!(void 0!==e.data.requestId))return void this.nsp._onServerSideEmit(t);let n=!1;const i=t=>{n||(n=!0,r("[%s] calling acknowledgement with %j",this.uid,t),this.publishResponse(e.uid,{type:a.SERVER_SIDE_EMIT_RESPONSE,data:{requestId:e.data.requestId,packet:t}}))};this.nsp._onServerSideEmit([...t,i]);break}case a.BROADCAST_CLIENT_COUNT:case a.BROADCAST_ACK:case a.FETCH_SOCKETS_RESPONSE:case a.SERVER_SIDE_EMIT_RESPONSE:this.onResponse(e);break;default:r("[%s] unknown message type: %s",this.uid,e.type)}}onResponse(e){var t,n;const i=e.data.requestId;switch(r("[%s] received response %s to request %s",this.uid,e.type,i),e.type){case a.BROADCAST_CLIENT_COUNT:null===(t=this.ackRequests.get(i))||void 0===t||t.clientCountCallback(e.data.clientCount);break;case a.BROADCAST_ACK:null===(n=this.ackRequests.get(i))||void 0===n||n.ack(e.data.packet);break;case a.FETCH_SOCKETS_RESPONSE:{const t=this.requests.get(i);if(!t)return;t.current++,e.data.sockets.forEach((e=>t.responses.push(e))),t.current===t.expected&&(clearTimeout(t.timeout),t.resolve(t.responses),this.requests.delete(i));break}case a.SERVER_SIDE_EMIT_RESPONSE:{const t=this.requests.get(i);if(!t)return;t.current++,t.responses.push(e.data.packet),t.current===t.expected&&(clearTimeout(t.timeout),t.resolve(null,t.responses),this.requests.delete(i));break}default:r("[%s] unknown response type: %s",this.uid,e.type)}}async broadcast(e,t){var n;if(!(null===(n=t.flags)||void 0===n?void 0:n.local))try{const n=await this.publishAndReturnOffset({type:a.BROADCAST,data:{packet:e,opts:c(t)}});this.addOffsetIfNecessary(e,t,n)}catch(e){return r("[%s] error while broadcasting message: %s",this.uid,e.message)}super.broadcast(e,t)}addOffsetIfNecessary(e,t,n){var i;if(!this.nsp.server.opts.connectionStateRecovery)return;const r=2===e.type,s=void 0===e.id,o=void 0===(null===(i=t.flags)||void 0===i?void 0:i.volatile);r&&s&&o&&e.data.push(n)}broadcastWithAck(e,t,n,i){var r;if(!(null===(r=null==t?void 0:t.flags)||void 0===r?void 0:r.local)){const r=o();this.ackRequests.set(r,{clientCountCallback:n,ack:i}),this.publish({type:a.BROADCAST,data:{packet:e,requestId:r,opts:c(t)}}),setTimeout((()=>{this.ackRequests.delete(r)}),t.flags.timeout)}super.broadcastWithAck(e,t,n,i)}async addSockets(e,t){var n;if(!(null===(n=e.flags)||void 0===n?void 0:n.local))try{await this.publishAndReturnOffset({type:a.SOCKETS_JOIN,data:{opts:c(e),rooms:t}})}catch(e){r("[%s] error while publishing message: %s",this.uid,e.message)}super.addSockets(e,t)}async delSockets(e,t){var n;if(!(null===(n=e.flags)||void 0===n?void 0:n.local))try{await this.publishAndReturnOffset({type:a.SOCKETS_LEAVE,data:{opts:c(e),rooms:t}})}catch(e){r("[%s] error while publishing message: %s",this.uid,e.message)}super.delSockets(e,t)}async disconnectSockets(e,t){var n;if(!(null===(n=e.flags)||void 0===n?void 0:n.local))try{await this.publishAndReturnOffset({type:a.DISCONNECT_SOCKETS,data:{opts:c(e),close:t}})}catch(e){r("[%s] error while publishing message: %s",this.uid,e.message)}super.disconnectSockets(e,t)}async fetchSockets(e){var t;const[n,i]=await Promise.all([super.fetchSockets(e),this.serverCount()]),r=i-1;if((null===(t=e.flags)||void 0===t?void 0:t.local)||r<=0)return n;const l=o();return new Promise(((t,i)=>{const o=setTimeout((()=>{const e=this.requests.get(l);e&&(i(new Error(`timeout reached: only ${e.current} responses received out of ${e.expected}`)),this.requests.delete(l))}),e.flags.timeout||s),u={type:a.FETCH_SOCKETS,resolve:t,timeout:o,current:0,expected:r,responses:n};this.requests.set(l,u),this.publish({type:a.FETCH_SOCKETS,data:{opts:c(e),requestId:l}})}))}async serverSideEmit(e){if(!("function"==typeof e[e.length-1]))return this.publish({type:a.SERVER_SIDE_EMIT,data:{packet:e}});const t=e.pop(),n=await this.serverCount()-1;if(r('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,n),n<=0)return t(null,[]);const i=o(),c=setTimeout((()=>{const e=this.requests.get(i);e&&(t(new Error(`timeout reached: only ${e.current} responses received out of ${e.expected}`),e.responses),this.requests.delete(i))}),s),l={type:a.SERVER_SIDE_EMIT,resolve:t,timeout:c,current:0,expected:n,responses:[]};this.requests.set(i,l),this.publish({type:a.SERVER_SIDE_EMIT,data:{requestId:i,packet:e}})}publish(e){this.publishAndReturnOffset(e).catch((e=>{r("[%s] error while publishing message: %s",this.uid,e)}))}publishAndReturnOffset(e){return e.uid=this.uid,e.nsp=this.nsp.name,this.doPublish(e)}publishResponse(e,t){t.uid=this.uid,t.nsp=this.nsp.name,this.doPublishResponse(e,t).catch((e=>{r("[%s] error while publishing response: %s",this.uid,e)}))}}e.ClusterAdapter=u;e.ClusterAdapterWithHeartbeat=class extends u{constructor(e,t){super(e),this.nodesMap=new Map,this.customRequests=new Map,this._opts=Object.assign({heartbeatInterval:5e3,heartbeatTimeout:1e4},t),this.cleanupTimer=setInterval((()=>{const e=Date.now();this.nodesMap.forEach(((t,n)=>{e-t>this._opts.heartbeatTimeout&&(r("[%s] node %s seems down",this.uid,n),this.removeNode(n))}))}),1e3)}init(){this.publish({type:a.INITIAL_HEARTBEAT})}scheduleHeartbeat(){this.heartbeatTimer?this.heartbeatTimer.refresh():this.heartbeatTimer=setTimeout((()=>{this.publish({type:a.HEARTBEAT})}),this._opts.heartbeatInterval)}close(){this.publish({type:a.ADAPTER_CLOSE}),clearTimeout(this.heartbeatTimer),this.cleanupTimer&&clearInterval(this.cleanupTimer)}onMessage(e,t){if(e.uid===this.uid)return r("[%s] ignore message from self",this.uid);switch(e.uid&&"emitter"!==e.uid&&this.nodesMap.set(e.uid,Date.now()),r("[%s] new event of type %d from %s",this.uid,e.type,e.uid),e.type){case a.INITIAL_HEARTBEAT:this.publish({type:a.HEARTBEAT});break;case a.HEARTBEAT:break;case a.ADAPTER_CLOSE:this.removeNode(e.uid);break;default:super.onMessage(e,t)}}serverCount(){return Promise.resolve(1+this.nodesMap.size)}publish(e){return this.scheduleHeartbeat(),super.publish(e)}async serverSideEmit(e){if(!("function"==typeof e[e.length-1]))return this.publish({type:a.SERVER_SIDE_EMIT,data:{packet:e}});const t=e.pop(),n=this.nodesMap.size;if(r('[%s] waiting for %d responses to "serverSideEmit" request',this.uid,n),n<=0)return t(null,[]);const i=o(),c=setTimeout((()=>{const e=this.customRequests.get(i);e&&(t(new Error(`timeout reached: missing ${e.missingUids.size} responses`),e.responses),this.customRequests.delete(i))}),s),l={type:a.SERVER_SIDE_EMIT,resolve:t,timeout:c,missingUids:new Set([...this.nodesMap.keys()]),responses:[]};this.customRequests.set(i,l),this.publish({type:a.SERVER_SIDE_EMIT,data:{requestId:i,packet:e}})}async fetchSockets(e){var t;const[n,i]=await Promise.all([super.fetchSockets({rooms:e.rooms,except:e.except,flags:{local:!0}}),this.serverCount()]),r=i-1;if((null===(t=e.flags)||void 0===t?void 0:t.local)||r<=0)return n;const l=o();return new Promise(((t,i)=>{const r=setTimeout((()=>{const e=this.customRequests.get(l);e&&(i(new Error(`timeout reached: missing ${e.missingUids.size} responses`)),this.customRequests.delete(l))}),e.flags.timeout||s),o={type:a.FETCH_SOCKETS,resolve:t,timeout:r,missingUids:new Set([...this.nodesMap.keys()]),responses:n};this.customRequests.set(l,o),this.publish({type:a.FETCH_SOCKETS,data:{opts:c(e),requestId:l}})}))}onResponse(e){const t=e.data.requestId;switch(r("[%s] received response %s to request %s",this.uid,e.type,t),e.type){case a.FETCH_SOCKETS_RESPONSE:{const n=this.customRequests.get(t);if(!n)return;e.data.sockets.forEach((e=>n.responses.push(e))),n.missingUids.delete(e.uid),0===n.missingUids.size&&(clearTimeout(n.timeout),n.resolve(n.responses),this.customRequests.delete(t));break}case a.SERVER_SIDE_EMIT_RESPONSE:{const n=this.customRequests.get(t);if(!n)return;n.responses.push(e.data.packet),n.missingUids.delete(e.uid),0===n.missingUids.size&&(clearTimeout(n.timeout),n.resolve(null,n.responses),this.customRequests.delete(t));break}default:super.onResponse(e)}}removeNode(e){this.customRequests.forEach(((t,n)=>{t.missingUids.delete(e),0===t.missingUids.size&&(clearTimeout(t.timeout),t.type===a.FETCH_SOCKETS?t.resolve(t.responses):t.type===a.SERVER_SIDE_EMIT&&t.resolve(null,t.responses),this.customRequests.delete(n))})),this.nodesMap.delete(e)}}}(hX),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MessageType=e.ClusterAdapterWithHeartbeat=e.ClusterAdapter=e.SessionAwareAdapter=e.Adapter=void 0;var t=ZJ;Object.defineProperty(e,"Adapter",{enumerable:!0,get:function(){return t.Adapter}}),Object.defineProperty(e,"SessionAwareAdapter",{enumerable:!0,get:function(){return t.SessionAwareAdapter}});var n=hX;Object.defineProperty(e,"ClusterAdapter",{enumerable:!0,get:function(){return n.ClusterAdapter}}),Object.defineProperty(e,"ClusterAdapterWithHeartbeat",{enumerable:!0,get:function(){return n.ClusterAdapterWithHeartbeat}}),Object.defineProperty(e,"MessageType",{enumerable:!0,get:function(){return n.MessageType}})}(YJ);var dX=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(KJ,"__esModule",{value:!0}),KJ.ParentNamespace=void 0;const fX=BJ,mX=YJ,gX=(0,dX(ch).default)("socket.io:parent-namespace");class yX extends fX.Namespace{constructor(e){super(e,"/_"+yX.count++),this.children=new Set}_initAdapter(){this.adapter=new vX(this,this.children)}emit(e,...t){return this.children.forEach((n=>{n.emit(e,...t)})),!0}createChild(e){gX("creating child namespace %s",e);const t=new fX.Namespace(this.server,e);if(t._fns=this._fns.slice(0),this.listeners("connect").forEach((e=>t.on("connect",e))),this.listeners("connection").forEach((e=>t.on("connection",e))),this.children.add(t),this.server._opts.cleanupEmptyChildNamespaces){const n=t._remove;t._remove=i=>{n.call(t,i),0===t.sockets.size&&(gX("closing child namespace %s",e),t.adapter.close(),this.server._nsps.delete(t.name),this.children.delete(t))}}return this.server._nsps.set(e,t),this.server.sockets.emitReserved("new_namespace",t),t}fetchSockets(){throw new Error("fetchSockets() is not supported on parent namespaces")}}KJ.ParentNamespace=yX,yX.count=0;class vX extends mX.Adapter{constructor(e,t){super(e),this.children=t}broadcast(e,t){this.children.forEach((n=>{n.adapter.broadcast(e,t)}))}}var bX={},_X=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bX,"__esModule",{value:!0}),bX.serveFile=bX.restoreAdapter=bX.patchAdapter=void 0;const wX=YJ,xX=s,EX=(0,_X(ch).default)("socket.io:adapter-uws"),SX="",{addAll:kX,del:TX,broadcast:AX}=wX.Adapter.prototype;function DX(e,t,n,i){const r=t.conn.id,s=t.conn.transport.socket;n&&(EX("subscribe connection %s to topic %s",r,e),s.subscribe(e)),i.forEach((t=>{const n=`${e}${SX}${t}`;EX("subscribe connection %s to topic %s",r,n),s.subscribe(n)}))}bX.patchAdapter=function(e){wX.Adapter.prototype.addAll=function(e,t){const n=!this.sids.has(e);kX.call(this,e,t);const i=this.nsp.sockets.get(e);i&&("websocket"!==i.conn.transport.name?n&&i.conn.on("upgrade",(()=>{const t=this.sids.get(e);t&&DX(this.nsp.name,i,n,t)})):DX(this.nsp.name,i,n,t))},wX.Adapter.prototype.del=function(e,t){TX.call(this,e,t);const n=this.nsp.sockets.get(e);if(n&&"websocket"===n.conn.transport.name){const e=n.conn.id,i=n.conn.transport.socket,r=`${this.nsp.name}${SX}${t}`;EX("unsubscribe connection %s from topic %s",e,r),i.unsubscribe(r)}},wX.Adapter.prototype.broadcast=function(t,n){if(!(n.rooms.size<=1&&0===n.except.size))return void AX.call(this,t,n);const i=n.flags||{},r={preEncoded:!0,volatile:i.volatile,compress:i.compress};t.nsp=this.nsp.name;const s=this.encoder.encode(t),o=0===n.rooms.size?this.nsp.name:`${this.nsp.name}${SX}${n.rooms.keys().next().value}`;EX("fast publish to %s",o),s.forEach((t=>{const n="string"!=typeof t;e.publish(o,n?t:"4"+t,n)})),this.apply(n,(e=>{"websocket"!==e.conn.transport.name&&e.client.writeToEngine(s,r)}))}},bX.restoreAdapter=function(){wX.Adapter.prototype.addAll=kX,wX.Adapter.prototype.del=TX,wX.Adapter.prototype.broadcast=AX};bX.serveFile=function(e,t){const{size:n}=(0,xX.statSync)(t),i=(0,xX.createReadStream)(t),r=()=>!i.destroyed&&i.destroy();e.onAborted(r),i.on("data",(t=>{const r=(e=>{const{buffer:t,byteOffset:n,byteLength:i}=e;return t.slice(n,n+i)})(t),s=e.getWriteOffset(),[o,a]=e.tryEnd(r,n);a||o||(i.pause(),e.onWritable((t=>{const[o,a]=e.tryEnd(r.slice(t-s),n);return!a&&o&&i.resume(),o})))})).on("error",(e=>{throw r(),e})).on("end",r)};var CX="4.7.5";!function(e,t){var n=H&&H.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),i=H&&H.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=H&&H.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=H&&H.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Namespace=t.Socket=t.Server=void 0;const c=x,l=s,u=k,d=$U,f=h,m=o,g=gV,y=_J,v=p,b=BJ;Object.defineProperty(t,"Namespace",{enumerable:!0,get:function(){return b.Namespace}});const _=KJ,w=YJ,E=r(wJ),S=a(ch),T=VJ();Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return T.Socket}});const A=UJ,D=bX,C=a(PQ),O=(0,S.default)("socket.io:server"),R=CX,L=/\.map/;class I extends A.StrictEventEmitter{constructor(e,t={}){super(),this._nsps=new Map,this.parentNsps=new Map,this.parentNamespacesFromRegExp=new Map,"object"==typeof e&&e instanceof Object&&!e.listen&&(t=e,e=void 0),this.path(t.path||"/socket.io"),this.connectTimeout(t.connectTimeout||45e3),this.serveClient(!1!==t.serveClient),this._parser=t.parser||E,this.encoder=new this._parser.Encoder,this.opts=t,t.connectionStateRecovery?(t.connectionStateRecovery=Object.assign({maxDisconnectionDuration:12e4,skipMiddlewares:!0},t.connectionStateRecovery),this.adapter(t.adapter||w.SessionAwareAdapter)):this.adapter(t.adapter||w.Adapter),t.cleanupEmptyChildNamespaces=!!t.cleanupEmptyChildNamespaces,this.sockets=this.of("/"),(e||"number"==typeof e)&&this.attach(e),this.opts.cors&&(this._corsMiddleware=(0,C.default)(this.opts.cors))}get _opts(){return this.opts}serveClient(e){return arguments.length?(this._serveClient=e,this):this._serveClient}_checkNamespace(e,t,n){if(0===this.parentNsps.size)return n(!1);const i=this.parentNsps.keys(),r=()=>{const s=i.next();if(s.done)return n(!1);s.value(e,t,((t,i)=>{if(t||!i)return r();if(this._nsps.has(e))return O("dynamic namespace %s already exists",e),n(this._nsps.get(e));const o=this.parentNsps.get(s.value).createChild(e);O("dynamic namespace %s was created",e),n(o)}))};r()}path(e){if(!arguments.length)return this._path;this._path=e.replace(/\/$/,"");const t=this._path.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");return this.clientPathRegex=new RegExp("^"+t+"/socket\\.io(\\.msgpack|\\.esm)?(\\.min)?\\.js(\\.map)?(?:\\?|$)"),this}connectTimeout(e){return void 0===e?this._connectTimeout:(this._connectTimeout=e,this)}adapter(e){if(!arguments.length)return this._adapter;this._adapter=e;for(const e of this._nsps.values())e._initAdapter();return this}listen(e,t={}){return this.attach(e,t)}attach(e,t={}){if("function"==typeof e){throw new Error("You are trying to attach socket.io to an express request handler function. Please pass a http.Server instance.")}if(Number(e)==e&&(e=Number(e)),"number"==typeof e){O("creating http server and binding to %d",e);const t=e;e=c.createServer(((e,t)=>{t.writeHead(404),t.end()})),e.listen(t)}return Object.assign(t,this.opts),t.path=t.path||this._path,this.initEngine(e,t),this}attachApp(e,t={}){Object.assign(t,this.opts),t.path=t.path||this._path,O("creating uWebSockets.js-based engine with opts %j",t);const n=new g.uServer(t);n.attach(e,t),this.bind(n),this._serveClient&&e.get(`${this._path}/*`,((e,t)=>{if(!this.clientPathRegex.test(t.getUrl()))return void t.setYield(!0);const n=t.getUrl().replace(this._path,"").replace(/\?.*$/,"").replace(/^\//,""),i=L.test(n),r=i?"map":"source",s='"'+R+'"',o="W/"+s,a=t.getHeader("if-none-match");if(a&&(s===a||o===a))return O("serve client %s 304",r),e.writeStatus("304 Not Modified"),void e.end();O("serve client %s",r),e.writeHeader("cache-control","public, max-age=0"),e.writeHeader("content-type","application/"+(i?"json":"javascript")+"; charset=utf-8"),e.writeHeader("etag",s);const c=m.join(__dirname,"../client-dist/",n);(0,D.serveFile)(e,c)})),(0,D.patchAdapter)(e)}initEngine(e,t){O("creating engine.io instance with opts %j",t),this.eio=(0,g.attach)(e,t),this._serveClient&&this.attachServe(e),this.httpServer=e,this.bind(this.eio)}attachServe(e){O("attaching client serving req handler");const t=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 r=0;r<t.length;r++)t[r].call(e,n,i)}))}serve(e,t){const n=e.url.replace(this._path,"").replace(/\?.*$/,""),i=L.test(n),r=i?"map":"source",s='"'+R+'"',o="W/"+s,a=e.headers["if-none-match"];if(a&&(s===a||o===a))return O("serve client %s 304",r),t.writeHead(304),void t.end();O("serve client %s",r),t.setHeader("Cache-Control","public, max-age=0"),t.setHeader("Content-Type","application/"+(i?"json":"javascript")+"; charset=utf-8"),t.setHeader("ETag",s),I.sendFile(n,e,t)}static sendFile(e,t,n){const i=(0,l.createReadStream)(m.join(__dirname,"../client-dist/",e)),r=e=>{e&&n.end()};switch(d(t).encodings(["br","gzip","deflate"])){case"br":n.writeHead(200,{"content-encoding":"br"}),(0,f.pipeline)(i,(0,u.createBrotliCompress)(),n,r);break;case"gzip":n.writeHead(200,{"content-encoding":"gzip"}),(0,f.pipeline)(i,(0,u.createGzip)(),n,r);break;case"deflate":n.writeHead(200,{"content-encoding":"deflate"}),(0,f.pipeline)(i,(0,u.createDeflate)(),n,r);break;default:n.writeHead(200),(0,f.pipeline)(i,n,r)}}bind(e){return this.engine=e,this.engine.on("connection",this.onconnection.bind(this)),this}onconnection(e){O("incoming connection with id %s",e.id);const t=new y.Client(this,e);return 3===e.protocol&&t.connect("/"),this}of(e,t){if("function"==typeof e||e instanceof RegExp){const n=new _.ParentNamespace(this);return O("initializing parent namespace %s",n.name),"function"==typeof e?this.parentNsps.set(e,n):(this.parentNsps.set(((t,n,i)=>i(null,e.test(t))),n),this.parentNamespacesFromRegExp.set(e,n)),t&&n.on("connect",t),n}"/"!==String(e)[0]&&(e="/"+e);let n=this._nsps.get(e);if(!n){for(const[t,n]of this.parentNamespacesFromRegExp)if(t.test(e))return O("attaching namespace %s to parent namespace %s",e,t),n.createChild(e);O("initializing namespace %s",e),n=new b.Namespace(this,e),this._nsps.set(e,n),"/"!==e&&this.sockets.emitReserved("new_namespace",n)}return t&&n.on("connect",t),n}close(e){this._nsps.forEach((e=>{e.sockets.forEach((e=>{e._onclose("server shutting down")})),e.adapter.close()})),this.engine.close(),(0,D.restoreAdapter)(),this.httpServer?this.httpServer.close(e):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,...t){return this.sockets.serverSideEmit(e,...t)}serverSideEmitWithAck(e,...t){return this.sockets.serverSideEmitWithAck(e,...t)}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)}}t.Server=I;const N=Object.keys(v.EventEmitter.prototype).filter((function(e){return"function"==typeof v.EventEmitter.prototype[e]}));N.forEach((function(e){I.prototype[e]=function(){return this.sockets[e].apply(this.sockets,arguments)}})),e.exports=(e,t)=>new I(e,t),e.exports.Server=I,e.exports.Namespace=b.Namespace,e.exports.Socket=T.Socket,VJ()}(mV,mV.exports);var OX=z(mV.exports);const{Server:RX,Namespace:LX,Socket:IX}=OX,NX=e=>new Promise(((t,n)=>{const i=a.platform();let r;if("win32"===i)r=`start ${e}`;else if("darwin"===i)r=`open ${e}`;else{if("linux"!==i)return n(new Error(`Unsupported platform: ${i}`));r=`xdg-open ${e}`}d.exec(r,(e=>{if(e)return n(new Error(`Failed to open URL on ${i}: ${e.message}`));t()}))}));class PX extends Error{constructor(e){super(`${e} is locked`)}}const jX={old:new Set,young:new Set};let FX;const BX=e=>new Promise(((t,n)=>{const i=F.createServer();i.unref(),i.on("error",n),i.listen(e,(()=>{const{port:e}=i.address();i.close((()=>{t(e)}))}))})),MX=async(e,t)=>{if(e.host||0===e.port)return BX(e);for(const n of t)try{await BX({port:e.port,host:n})}catch(e){if(!["EADDRNOTAVAIL","EINVAL"].includes(e.code))throw e}return e.port};async function UX(e){let t,n=new Set;if(e&&(e.port&&(t="number"==typeof e.port?[e.port]:e.port),e.exclude)){const t=e.exclude;if("function"!=typeof t[Symbol.iterator])throw new TypeError("The `exclude` option must be an iterable.");for(const e of t){if("number"!=typeof e)throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(e))throw new TypeError(`Number ${e} in the exclude option is not a safe integer and can't be used`)}n=new Set(t)}void 0===FX&&(FX=setTimeout((()=>{FX=void 0,jX.old=jX.young,jX.young=new Set}),15e3),FX.unref&&FX.unref());const i=(()=>{const e=B.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(const n of Object.values(e))for(const e of n)t.add(e.address);return t})();for(const r of function*(e){e&&(yield*e),yield 0}(t))try{if(n.has(r))continue;let t=await MX({...e,port:r},i);for(;jX.old.has(t)||jX.young.has(t);){if(0!==r)throw new PX(r);t=await MX({...e,port:r},i)}return jX.young.add(t),t}catch(e){if(!(["EADDRINUSE","EACCES"].includes(e.code)||e instanceof PX))throw e}throw new Error("No available ports found")}var qX=z((function(e,t="https://khalaf.qumra.cloud"){return e.toString().includes("localhost")&&(e=t),`https://api.qumra.cloud/templateEngine/v1/render?path=${encodeURIComponent(e)}`}));var $X=(e,t)=>{console.log("🚀 ~ buildHeaders ~ req.cookies:",e.cookies);const{token:n,qvid:i,qaid:r,qdid:s}=e.cookies??{},o=e.cookies?.["qg-token"],a={"Content-Type":"application/json","User-Agent":e.headers["user-agent"]??"",Referer:e.headers.referer??"","X-Forwarded-For":e.headers["x-forwarded-for"]??e.connection.remoteAddress??"","Accept-Language":e.headers["accept-language"]??"","X-Device-Type":e.headers["x-device-type"]??"unknown","X-OS":e.headers["x-os"]??"unknown","X-Timezone":e.headers["x-timezone"]??"UTC"};return a["X-Subdomain"]=t,n&&(a.Authorization=n),i&&(a.qvid=i),r&&(a.qaid=r),s&&(a.qdid=s),o&&(a["qg-token"]=o),a},HX=z($X),zX={exports:{}},WX=Array.prototype,GX=Object.prototype,VX={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},KX=/[&"'<>\\]/g,YX=zX.exports={};function ZX(e,t){return GX.hasOwnProperty.call(e,t)}function QX(e){return VX[e]}function JX(e,t,n){var i,r,s;if(e instanceof Error&&(e=(r=e).name+": "+r.message),Object.setPrototypeOf?(i=new Error(e),Object.setPrototypeOf(i,JX.prototype)):(i=this,Object.defineProperty(i,"message",{enumerable:!1,writable:!0,value:e})),Object.defineProperty(i,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(i,this.constructor),r){var o=Object.getOwnPropertyDescriptor(r,"stack");(s=o&&(o.get||function(){return o.value}))||(s=function(){return r.stack})}else{var a=new Error(e).stack;s=function(){return a}}return Object.defineProperty(i,"stack",{get:function(){return s.call(i)}}),Object.defineProperty(i,"cause",{value:r}),i.lineno=t,i.colno=n,i.firstUpdate=!0,i.Update=function(e){var t="("+(e||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?t+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(t+=" [Line "+this.lineno+"]")),t+="\n ",this.firstUpdate&&(t+=" "),this.message=t+(this.message||""),this.firstUpdate=!1,this},i}function XX(e){return"[object Function]"===GX.toString.call(e)}function e0(e){return"[object Array]"===GX.toString.call(e)}function t0(e){return"[object String]"===GX.toString.call(e)}function n0(e){return"[object Object]"===GX.toString.call(e)}function i0(e){var t,n=(t=e)?"string"==typeof t?t.split("."):[t]:[];return function(e){for(var t=e,i=0;i<n.length;i++){var r=n[i];if(!ZX(t,r))return;t=t[r]}return t}}function r0(e){return Array.prototype.slice.call(e)}function s0(e,t,n){return Array.prototype.indexOf.call(e||[],t,n)}function o0(e){var t=[];for(var n in e)ZX(e,n)&&t.push(n);return t}YX.hasOwnProp=ZX,YX._prettifyError=function(e,t,n){if(n.Update||(n=new YX.TemplateError(n)),n.Update(e),!t){var i=n;(n=new Error(i.message)).name=i.name}return n},Object.setPrototypeOf?Object.setPrototypeOf(JX.prototype,Error.prototype):JX.prototype=Object.create(Error.prototype,{constructor:{value:JX}}),YX.TemplateError=JX,YX.escape=function(e){return e.replace(KX,QX)},YX.isFunction=XX,YX.isArray=e0,YX.isString=t0,YX.isObject=n0,YX.getAttrGetter=i0,YX.groupBy=function(e,t,n){for(var i={},r=XX(t)?t:i0(t),s=0;s<e.length;s++){var o=e[s],a=r(o,s);if(void 0===a&&!0===n)throw new TypeError('groupby: attribute "'+t+'" resolved to undefined');(i[a]||(i[a]=[])).push(o)}return i},YX.toArray=r0,YX.without=function(e){var t=[];if(!e)return t;for(var n=e.length,i=r0(arguments).slice(1),r=-1;++r<n;)-1===s0(i,e[r])&&t.push(e[r]);return t},YX.repeat=function(e,t){for(var n="",i=0;i<t;i++)n+=e;return n},YX.each=function(e,t,n){if(null!=e)if(WX.forEach&&e.forEach===WX.forEach)e.forEach(t,n);else if(e.length===+e.length)for(var i=0,r=e.length;i<r;i++)t.call(n,e[i],i,e)},YX.map=function(e,t){var n=[];if(null==e)return n;if(WX.map&&e.map===WX.map)return e.map(t);for(var i=0;i<e.length;i++)n[n.length]=t(e[i],i);return e.length===+e.length&&(n.length=e.length),n},YX.asyncIter=function(e,t,n){var i=-1;!function r(){++i<e.length?t(e[i],i,r,n):n()}()},YX.asyncFor=function(e,t,n){var i=o0(e||{}),r=i.length,s=-1;!function o(){s++;var a=i[s];s<r?t(a,e[a],s,r,o):n()}()},YX.indexOf=s0,YX.keys=o0,YX._entries=function(e){return o0(e).map((function(t){return[t,e[t]]}))},YX._values=function(e){return o0(e).map((function(t){return e[t]}))},YX._assign=YX.extend=function(e,t){return e=e||{},o0(t).forEach((function(n){e[n]=t[n]})),e},YX.inOperator=function(e,t){if(e0(t)||t0(t))return-1!==t.indexOf(e);if(n0(t))return e in t;throw new Error('Cannot use "in" operator to search for "'+e+'" in unexpected types.')};var a0,c0=zX.exports,l0="function"==typeof setImmediate,u0=p0;function p0(e){h0.length||(y0(),d0=!0),h0[h0.length]=e}var h0=[],d0=!1,f0=0,m0=1024;function g0(){for(;f0<h0.length;){var e=f0;if(f0+=1,h0[e].call(),f0>m0){for(var t=0,n=h0.length-f0;t<n;t++)h0[t]=h0[t+f0];h0.length-=f0,f0=0}}h0.length=0,f0=0,d0=!1}function y0(){var e=process.domain;e&&(a0||(a0=M),a0.active=process.domain=null),d0&&l0?setImmediate(g0):process.nextTick(g0),e&&(a0.active=process.domain=e)}p0.requestFlush=y0;var v0=u0,b0=[],_0=function(e){var t;t=b0.length?b0.pop():new w0;t.task=e,t.domain=process.domain,v0(t)};function w0(){this.task=null,this.domain=null}w0.prototype.call=function(){this.domain&&this.domain.enter();var e=!0;try{this.task.call(),e=!1,this.domain&&this.domain.exit()}finally{e&&v0.requestFlush(),this.task=null,this.domain=null,b0.push(this)}};var x0={exports:{}};!function(e){!function(t){var n=function(){var e=Array.prototype.slice.call(arguments);"function"==typeof e[0]&&e[0].apply(null,e.splice(1))},i=function(e){"function"==typeof setImmediate?setImmediate(e):"undefined"!=typeof process&&process.nextTick?process.nextTick(e):setTimeout(e,0)},r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=function(e,t,s){var o=s?i:n;if(t=t||function(){},!r(e)){var a=new Error("First argument to waterfall must be an array of functions");return t(a)}if(!e.length)return t();var c=function(e){return function(n){if(n)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),r=e.next();r?i.push(c(r)):i.push(t),o((function(){e.apply(null,i)}))}}};c(function(e){var t=function(n){var i=function(){return e.length&&e[n].apply(null,arguments),i.next()};return i.next=function(){return n<e.length-1?t(n+1):null},i};return t(0)}(e))()};e.exports?e.exports=s:t.waterfall=s}(H)}(x0);var E0=x0.exports,S0=c0,k0=" \n\t\r ",T0="()[]{}%*-+~/#,:|.<>=!",A0="string",D0="whitespace",C0="data",O0="block-start",R0="block-end",L0="variable-start",I0="variable-end",N0="comment",P0="left-paren",j0="right-paren",F0="left-bracket",B0="right-bracket",M0="left-curly",U0="right-curly",q0="operator",$0="comma",H0="colon",z0="tilde",W0="pipe",G0="float",V0="boolean",K0="none",Y0="symbol",Z0="regex";function Q0(e,t,n,i){return{type:e,value:t,lineno:n,colno:i}}var J0=function(){function e(e,t){this.str=e,this.index=0,this.len=e.length,this.lineno=0,this.colno=0,this.in_code=!1;var n=(t=t||{}).tags||{};this.tags={BLOCK_START:n.blockStart||"{%",BLOCK_END:n.blockEnd||"%}",VARIABLE_START:n.variableStart||"{{",VARIABLE_END:n.variableEnd||"}}",COMMENT_START:n.commentStart||"{#",COMMENT_END:n.commentEnd||"#}"},this.trimBlocks=!!t.trimBlocks,this.lstripBlocks=!!t.lstripBlocks}var t=e.prototype;return t.nextToken=function(){var e,t=this.lineno,n=this.colno;if(this.in_code){var i=this.current();if(this.isFinished())return null;if('"'===i||"'"===i)return Q0(A0,this._parseString(i),t,n);if(e=this._extract(k0))return Q0(D0,e,t,n);if((e=this._extractString(this.tags.BLOCK_END))||(e=this._extractString("-"+this.tags.BLOCK_END)))return this.in_code=!1,this.trimBlocks&&("\n"===(i=this.current())?this.forward():"\r"===i&&(this.forward(),"\n"===(i=this.current())?this.forward():this.back())),Q0(R0,e,t,n);if((e=this._extractString(this.tags.VARIABLE_END))||(e=this._extractString("-"+this.tags.VARIABLE_END)))return this.in_code=!1,Q0(I0,e,t,n);if("r"===i&&"/"===this.str.charAt(this.index+1)){this.forwardN(2);for(var r="";!this.isFinished();){if("/"===this.current()&&"\\"!==this.previous()){this.forward();break}r+=this.current(),this.forward()}for(var s=["g","i","m","y"],o="";!this.isFinished();){if(!(-1!==s.indexOf(this.current())))break;o+=this.current(),this.forward()}return Q0(Z0,{body:r,flags:o},t,n)}if(-1!==T0.indexOf(i)){this.forward();var a,c=["==","===","!=","!==","<=",">=","//","**"],l=i+this.current();switch(-1!==S0.indexOf(c,l)&&(this.forward(),i=l,-1!==S0.indexOf(c,l+this.current())&&(i=l+this.current(),this.forward())),i){case"(":a=P0;break;case")":a=j0;break;case"[":a=F0;break;case"]":a=B0;break;case"{":a=M0;break;case"}":a=U0;break;case",":a=$0;break;case":":a=H0;break;case"~":a=z0;break;case"|":a=W0;break;default:a=q0}return Q0(a,i,t,n)}if((e=this._extractUntil(k0+T0)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var u=this._extract("0123456789");return Q0(G0,e+"."+u,t,n)}return Q0("int",e,t,n)}if(e.match(/^(true|false)$/))return Q0(V0,e,t,n);if("none"===e)return Q0(K0,e,t,n);if("null"===e)return Q0(K0,e,t,n);if(e)return Q0(Y0,e,t,n);throw new Error("Unexpected value while parsing: "+e)}var p,h=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((e=this._extractString(this.tags.BLOCK_START+"-"))||(e=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,Q0(O0,e,t,n);if((e=this._extractString(this.tags.VARIABLE_START+"-"))||(e=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,Q0(L0,e,t,n);e="";var d=!1;for(this._matches(this.tags.COMMENT_START)&&(d=!0,e=this._extractString(this.tags.COMMENT_START));null!==(p=this._extractUntil(h));){if(e+=p,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!d){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=e.length){var f=e.slice(-this.colno);if(/^\s+$/.test(f)&&!(e=e.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!d)throw new Error("unexpected end of comment");e+=this._extractString(this.tags.COMMENT_END);break}e+=this.current(),this.forward()}if(null===p&&d)throw new Error("expected end of comment, got end of file");return Q0(d?N0:C0,e,t,n)},t._parseString=function(e){this.forward();for(var t="";!this.isFinished()&&this.current()!==e;){var n=this.current();if("\\"===n){switch(this.forward(),this.current()){case"n":t+="\n";break;case"t":t+="\t";break;case"r":t+="\r";break;default:t+=this.current()}this.forward()}else t+=n,this.forward()}return this.forward(),t},t._matches=function(e){return this.index+e.length>this.len?null:this.str.slice(this.index,this.index+e.length)===e},t._extractString=function(e){return this._matches(e)?(this.forwardN(e.length),e):null},t._extractUntil=function(e){return this._extractMatching(!0,e||"")},t._extract=function(e){return this._extractMatching(!1,e)},t._extractMatching=function(e,t){if(this.isFinished())return null;var n=t.indexOf(this.current());if(e&&-1===n||!e&&-1!==n){var i=this.current();this.forward();for(var r=t.indexOf(this.current());(e&&-1===r||!e&&-1!==r)&&!this.isFinished();)i+=this.current(),this.forward(),r=t.indexOf(this.current());return i}return""},t._extractRegex=function(e){var t=this.currentStr().match(e);return t?(this.forwardN(t[0].length),t):null},t.isFinished=function(){return this.index>=this.len},t.forwardN=function(e){for(var t=0;t<e;t++)this.forward()},t.forward=function(){this.index++,"\n"===this.previous()?(this.lineno++,this.colno=0):this.colno++},t.backN=function(e){for(var t=0;t<e;t++)this.back()},t.back=function(){if(this.index--,"\n"===this.current()){this.lineno--;var e=this.src.lastIndexOf("\n",this.index-1);this.colno=-1===e?this.index:this.index-e}else this.colno--},t.current=function(){return this.isFinished()?"":this.str.charAt(this.index)},t.currentStr=function(){return this.isFinished()?"":this.str.substr(this.index)},t.previous=function(){return this.str.charAt(this.index-1)},e}(),X0={lex:function(e,t){return new J0(e,t)},TOKEN_STRING:A0,TOKEN_WHITESPACE:D0,TOKEN_DATA:C0,TOKEN_BLOCK_START:O0,TOKEN_BLOCK_END:R0,TOKEN_VARIABLE_START:L0,TOKEN_VARIABLE_END:I0,TOKEN_COMMENT:N0,TOKEN_LEFT_PAREN:P0,TOKEN_RIGHT_PAREN:j0,TOKEN_LEFT_BRACKET:F0,TOKEN_RIGHT_BRACKET:B0,TOKEN_LEFT_CURLY:M0,TOKEN_RIGHT_CURLY:U0,TOKEN_OPERATOR:q0,TOKEN_COMMA:$0,TOKEN_COLON:H0,TOKEN_TILDE:z0,TOKEN_PIPE:W0,TOKEN_INT:"int",TOKEN_FLOAT:G0,TOKEN_BOOLEAN:V0,TOKEN_NONE:K0,TOKEN_SYMBOL:Y0,TOKEN_SPECIAL:"special",TOKEN_REGEX:Z0};function e1(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n1(i.key),i)}}function t1(e,t,n){return t&&e1(e.prototype,t),n&&e1(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n1(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r1(e,t)}function r1(e,t){return r1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r1(e,t)}var s1=p,o1=c0;function a1(e,t,n){n=n||{},o1.keys(n).forEach((function(t){n[t]=function(e,t){return"function"!=typeof e||"function"!=typeof t?t:function(){var n=this.parent;this.parent=e;var i=t.apply(this,arguments);return this.parent=n,i}}(e.prototype[t],n[t])}));var i=function(e){function n(){return e.apply(this,arguments)||this}return i1(n,e),t1(n,[{key:"typename",get:function(){return t}}]),n}(e);return o1._assign(i.prototype,n),i}var c1=function(){function e(){this.init.apply(this,arguments)}return e.prototype.init=function(){},e.extend=function(e,t){return"object"==typeof e&&(t=e,e="anonymous"),a1(this,e,t)},t1(e,[{key:"typename",get:function(){return this.constructor.name}}]),e}(),l1=function(e){function t(){var t,n;return(t=n=e.call(this)||this).init.apply(t,arguments),n}return i1(t,e),t.prototype.init=function(){},t.extend=function(e,t){return"object"==typeof e&&(t=e,e="anonymous"),a1(this,e,t)},t1(t,[{key:"typename",get:function(){return this.constructor.name}}]),t}(s1),u1={Obj:c1,EmitterObj:l1};function p1(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,d1(i.key),i)}}function h1(e,t,n){return t&&p1(e.prototype,t),n&&p1(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d1(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function f1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,m1(e,t)}function m1(e,t){return m1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m1(e,t)}function g1(e,t,n){e instanceof t&&n.push(e),e instanceof y1&&e.findAll(t,n)}var y1=function(e){function t(){return e.apply(this,arguments)||this}f1(t,e);var n=t.prototype;return n.init=function(e,t){for(var n=arguments,i=this,r=arguments.length,s=new Array(r>2?r-2:0),o=2;o<r;o++)s[o-2]=arguments[o];this.lineno=e,this.colno=t,this.fields.forEach((function(e,t){var r=n[t+2];void 0===r&&(r=null),i[e]=r}))},n.findAll=function(e,t){var n=this;return t=t||[],this instanceof b1?this.children.forEach((function(n){return g1(n,e,t)})):this.fields.forEach((function(i){return g1(n[i],e,t)})),t},n.iterFields=function(e){var t=this;this.fields.forEach((function(n){e(t[n],n)}))},t}(u1.Obj),v1=function(e){function t(){return e.apply(this,arguments)||this}return f1(t,e),h1(t,[{key:"typename",get:function(){return"Value"}},{key:"fields",get:function(){return["value"]}}]),t}(y1),b1=function(e){function t(){return e.apply(this,arguments)||this}f1(t,e);var n=t.prototype;return n.init=function(t,n,i){e.prototype.init.call(this,t,n,i||[])},n.addChild=function(e){this.children.push(e)},h1(t,[{key:"typename",get:function(){return"NodeList"}},{key:"fields",get:function(){return["children"]}}]),t}(y1),_1=b1.extend("Root"),w1=v1.extend("Literal"),x1=v1.extend("Symbol"),E1=b1.extend("Group"),S1=b1.extend("Array"),k1=y1.extend("Pair",{fields:["key","value"]}),T1=b1.extend("Dict"),A1=y1.extend("LookupVal",{fields:["target","val"]}),D1=y1.extend("If",{fields:["cond","body","else_"]}),C1=D1.extend("IfAsync"),O1=y1.extend("InlineIf",{fields:["cond","body","else_"]}),R1=y1.extend("For",{fields:["arr","name","body","else_"]}),L1=R1.extend("AsyncEach"),I1=R1.extend("AsyncAll"),N1=y1.extend("Macro",{fields:["name","args","body"]}),P1=N1.extend("Caller"),j1=y1.extend("Import",{fields:["template","target","withContext"]}),F1=function(e){function t(){return e.apply(this,arguments)||this}return f1(t,e),t.prototype.init=function(t,n,i,r,s){e.prototype.init.call(this,t,n,i,r||new b1,s)},h1(t,[{key:"typename",get:function(){return"FromImport"}},{key:"fields",get:function(){return["template","names","withContext"]}}]),t}(y1),B1=y1.extend("FunCall",{fields:["name","args"]}),M1=B1.extend("Filter"),U1=M1.extend("FilterAsync",{fields:["name","args","symbol"]}),q1=T1.extend("KeywordArgs"),$1=y1.extend("Block",{fields:["name","body"]}),H1=y1.extend("Super",{fields:["blockName","symbol"]}),z1=y1.extend("TemplateRef",{fields:["template"]}).extend("Extends"),W1=y1.extend("Include",{fields:["template","ignoreMissing"]}),G1=y1.extend("Set",{fields:["targets","value"]}),V1=y1.extend("Switch",{fields:["expr","cases","default"]}),K1=y1.extend("Case",{fields:["cond","body"]}),Y1=b1.extend("Output"),Z1=y1.extend("Capture",{fields:["body"]}),Q1=w1.extend("TemplateData"),J1=y1.extend("UnaryOp",{fields:["target"]}),X1=y1.extend("BinOp",{fields:["left","right"]}),e2=X1.extend("In"),t2=X1.extend("Is"),n2=X1.extend("Or"),i2=X1.extend("And"),r2=J1.extend("Not"),s2=X1.extend("Add"),o2=X1.extend("Concat"),a2=X1.extend("Sub"),c2=X1.extend("Mul"),l2=X1.extend("Div"),u2=X1.extend("FloorDiv"),p2=X1.extend("Mod"),h2=X1.extend("Pow"),d2=J1.extend("Neg"),f2=J1.extend("Pos"),m2=y1.extend("Compare",{fields:["expr","ops"]}),g2=y1.extend("CompareOperand",{fields:["expr","type"]}),y2=y1.extend("CallExtension",{init:function(e,t,n,i){this.parent(),this.extName=e.__name||e,this.prop=t,this.args=n||new b1,this.contentArgs=i||[],this.autoescape=e.autoescape},fields:["extName","prop","args","contentArgs"]}),v2=y2.extend("CallExtensionAsync");function b2(e,t,n){var i=e.split("\n");i.forEach((function(e,r){e&&(n&&r>0||!n)&&process.stdout.write(" ".repeat(t));var s=r===i.length-1?"":"\n";process.stdout.write(""+e+s)}))}var _2={Node:y1,Root:_1,NodeList:b1,Value:v1,Literal:w1,Symbol:x1,Group:E1,Array:S1,Pair:k1,Dict:T1,Output:Y1,Capture:Z1,TemplateData:Q1,If:D1,IfAsync:C1,InlineIf:O1,For:R1,AsyncEach:L1,AsyncAll:I1,Macro:N1,Caller:P1,Import:j1,FromImport:F1,FunCall:B1,Filter:M1,FilterAsync:U1,KeywordArgs:q1,Block:$1,Super:H1,Extends:z1,Include:W1,Set:G1,Switch:V1,Case:K1,LookupVal:A1,BinOp:X1,In:e2,Is:t2,Or:n2,And:i2,Not:r2,Add:s2,Concat:o2,Sub:a2,Mul:c2,Div:l2,FloorDiv:u2,Mod:p2,Pow:h2,Neg:d2,Pos:f2,Compare:m2,CompareOperand:g2,CallExtension:y2,CallExtensionAsync:v2,printNodes:function e(t,n){if(n=n||0,b2(t.typename+": ",n),t instanceof b1)b2("\n"),t.children.forEach((function(t){e(t,n+2)}));else if(t instanceof y2)b2(t.extName+"."+t.prop+"\n"),t.args&&e(t.args,n+2),t.contentArgs&&t.contentArgs.forEach((function(t){e(t,n+2)}));else{var i=[],r=null;t.iterFields((function(e,t){e instanceof y1?i.push([t,e]):(r=r||{})[t]=e})),r?b2(JSON.stringify(r,null,2)+"\n",null,!0):b2("\n"),i.forEach((function(t){var i=t[0],r=t[1];b2("["+i+"] =>",n+2),e(r,n+4)}))}}};function w2(e,t){return w2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},w2(e,t)}var x2=X0,E2=_2,S2=c0,k2=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,w2(t,n);var r=i.prototype;return r.init=function(e){this.tokens=e,this.peeked=null,this.breakOnBlocks=null,this.dropLeadingWhitespace=!1,this.extensions=[]},r.nextToken=function(e){var t;if(this.peeked){if(e||this.peeked.type!==x2.TOKEN_WHITESPACE)return t=this.peeked,this.peeked=null,t;this.peeked=null}if(t=this.tokens.nextToken(),!e)for(;t&&t.type===x2.TOKEN_WHITESPACE;)t=this.tokens.nextToken();return t},r.peekToken=function(){return this.peeked=this.peeked||this.nextToken(),this.peeked},r.pushToken=function(e){if(this.peeked)throw new Error("pushToken: can only push one token on between reads");this.peeked=e},r.error=function(e,t,n){if(void 0===t||void 0===n){var i=this.peekToken()||{};t=i.lineno,n=i.colno}return void 0!==t&&(t+=1),void 0!==n&&(n+=1),new S2.TemplateError(e,t,n)},r.fail=function(e,t,n){throw this.error(e,t,n)},r.skip=function(e){var t=this.nextToken();return!(!t||t.type!==e)||(this.pushToken(t),!1)},r.expect=function(e){var t=this.nextToken();return t.type!==e&&this.fail("expected "+e+", got "+t.type,t.lineno,t.colno),t},r.skipValue=function(e,t){var n=this.nextToken();return!(!n||n.type!==e||n.value!==t)||(this.pushToken(n),!1)},r.skipSymbol=function(e){return this.skipValue(x2.TOKEN_SYMBOL,e)},r.advanceAfterBlockEnd=function(e){var t;return e||((t=this.peekToken())||this.fail("unexpected end of file"),t.type!==x2.TOKEN_SYMBOL&&this.fail("advanceAfterBlockEnd: expected symbol token or explicit name to be passed"),e=this.nextToken().value),(t=this.nextToken())&&t.type===x2.TOKEN_BLOCK_END?"-"===t.value.charAt(0)&&(this.dropLeadingWhitespace=!0):this.fail("expected block end in "+e+" statement"),t},r.advanceAfterVariableEnd=function(){var e=this.nextToken();e&&e.type===x2.TOKEN_VARIABLE_END?this.dropLeadingWhitespace="-"===e.value.charAt(e.value.length-this.tokens.tags.VARIABLE_END.length-1):(this.pushToken(e),this.fail("expected variable end"))},r.parseFor=function(){var e,t,n=this.peekToken();if(this.skipSymbol("for")?(e=new E2.For(n.lineno,n.colno),t="endfor"):this.skipSymbol("asyncEach")?(e=new E2.AsyncEach(n.lineno,n.colno),t="endeach"):this.skipSymbol("asyncAll")?(e=new E2.AsyncAll(n.lineno,n.colno),t="endall"):this.fail("parseFor: expected for{Async}",n.lineno,n.colno),e.name=this.parsePrimary(),e.name instanceof E2.Symbol||this.fail("parseFor: variable name expected for loop"),this.peekToken().type===x2.TOKEN_COMMA){var i=e.name;for(e.name=new E2.Array(i.lineno,i.colno),e.name.addChild(i);this.skip(x2.TOKEN_COMMA);){var r=this.parsePrimary();e.name.addChild(r)}}return this.skipSymbol("in")||this.fail('parseFor: expected "in" keyword for loop',n.lineno,n.colno),e.arr=this.parseExpression(),this.advanceAfterBlockEnd(n.value),e.body=this.parseUntilBlocks(t,"else"),this.skipSymbol("else")&&(this.advanceAfterBlockEnd("else"),e.else_=this.parseUntilBlocks(t)),this.advanceAfterBlockEnd(),e},r.parseMacro=function(){var e=this.peekToken();this.skipSymbol("macro")||this.fail("expected macro");var t=this.parsePrimary(!0),n=this.parseSignature(),i=new E2.Macro(e.lineno,e.colno,t,n);return this.advanceAfterBlockEnd(e.value),i.body=this.parseUntilBlocks("endmacro"),this.advanceAfterBlockEnd(),i},r.parseCall=function(){var e=this.peekToken();this.skipSymbol("call")||this.fail("expected call");var t=this.parseSignature(!0)||new E2.NodeList,n=this.parsePrimary();this.advanceAfterBlockEnd(e.value);var i=this.parseUntilBlocks("endcall");this.advanceAfterBlockEnd();var r=new E2.Symbol(e.lineno,e.colno,"caller"),s=new E2.Caller(e.lineno,e.colno,r,t,i),o=n.args.children;return o[o.length-1]instanceof E2.KeywordArgs||o.push(new E2.KeywordArgs),o[o.length-1].addChild(new E2.Pair(e.lineno,e.colno,r,s)),new E2.Output(e.lineno,e.colno,[n])},r.parseWithContext=function(){var e=this.peekToken(),t=null;return this.skipSymbol("with")?t=!0:this.skipSymbol("without")&&(t=!1),null!==t&&(this.skipSymbol("context")||this.fail("parseFrom: expected context after with/without",e.lineno,e.colno)),t},r.parseImport=function(){var e=this.peekToken();this.skipSymbol("import")||this.fail("parseImport: expected import",e.lineno,e.colno);var t=this.parseExpression();this.skipSymbol("as")||this.fail('parseImport: expected "as" keyword',e.lineno,e.colno);var n=this.parseExpression(),i=this.parseWithContext(),r=new E2.Import(e.lineno,e.colno,t,n,i);return this.advanceAfterBlockEnd(e.value),r},r.parseFrom=function(){var e=this.peekToken();this.skipSymbol("from")||this.fail("parseFrom: expected from");var t=this.parseExpression();this.skipSymbol("import")||this.fail("parseFrom: expected import",e.lineno,e.colno);for(var n,i=new E2.NodeList;;){var r=this.peekToken();if(r.type===x2.TOKEN_BLOCK_END){i.children.length||this.fail("parseFrom: Expected at least one import name",e.lineno,e.colno),"-"===r.value.charAt(0)&&(this.dropLeadingWhitespace=!0),this.nextToken();break}i.children.length>0&&!this.skip(x2.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",e.lineno,e.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var o=this.parsePrimary();i.addChild(new E2.Pair(s.lineno,s.colno,s,o))}else i.addChild(s);n=this.parseWithContext()}return new E2.FromImport(e.lineno,e.colno,t,i,n)},r.parseBlock=function(){var e=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",e.lineno,e.colno);var t=new E2.Block(e.lineno,e.colno);t.name=this.parsePrimary(),t.name instanceof E2.Symbol||this.fail("parseBlock: variable name expected",e.lineno,e.colno),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(t.name.value);var n=this.peekToken();return n||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(n.value),t},r.parseExtends=function(){var e="extends",t=this.peekToken();this.skipSymbol(e)||this.fail("parseTemplateRef: expected "+e);var n=new E2.Extends(t.lineno,t.colno);return n.template=this.parseExpression(),this.advanceAfterBlockEnd(t.value),n},r.parseInclude=function(){var e="include",t=this.peekToken();this.skipSymbol(e)||this.fail("parseInclude: expected "+e);var n=new E2.Include(t.lineno,t.colno);return n.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(n.ignoreMissing=!0),this.advanceAfterBlockEnd(t.value),n},r.parseIf=function(){var e,t=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?e=new E2.If(t.lineno,t.colno):this.skipSymbol("ifAsync")?e=new E2.IfAsync(t.lineno,t.colno):this.fail("parseIf: expected if, elif, or elseif",t.lineno,t.colno),e.cond=this.parseExpression(),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("elif","elseif","else","endif");var n=this.peekToken();switch(n&&n.value){case"elseif":case"elif":e.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),e.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":e.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return e},r.parseSet=function(){var e=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",e.lineno,e.colno);for(var t,n=new E2.Set(e.lineno,e.colno,[]);(t=this.parsePrimary())&&(n.targets.push(t),this.skip(x2.TOKEN_COMMA)););return this.skipValue(x2.TOKEN_OPERATOR,"=")?(n.value=this.parseExpression(),this.advanceAfterBlockEnd(e.value)):this.skip(x2.TOKEN_BLOCK_END)?(n.body=new E2.Capture(e.lineno,e.colno,this.parseUntilBlocks("endset")),n.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",e.lineno,e.colno),n},r.parseSwitch=function(){var e="switch",t="endswitch",n="case",i="default",r=this.peekToken();this.skipSymbol(e)||this.skipSymbol(n)||this.skipSymbol(i)||this.fail('parseSwitch: expected "switch," "case" or "default"',r.lineno,r.colno);var s=this.parseExpression();this.advanceAfterBlockEnd(e),this.parseUntilBlocks(n,i,t);var o,a=this.peekToken(),c=[];do{this.skipSymbol(n);var l=this.parseExpression();this.advanceAfterBlockEnd(e);var u=this.parseUntilBlocks(n,i,t);c.push(new E2.Case(a.line,a.col,l,u)),a=this.peekToken()}while(a&&a.value===n);switch(a.value){case i:this.advanceAfterBlockEnd(),o=this.parseUntilBlocks(t),this.advanceAfterBlockEnd();break;case t:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new E2.Switch(r.lineno,r.colno,s,c,o)},r.parseStatement=function(){var e=this.peekToken();if(e.type!==x2.TOKEN_SYMBOL&&this.fail("tag name expected",e.lineno,e.colno),this.breakOnBlocks&&-1!==S2.indexOf(this.breakOnBlocks,e.value))return null;switch(e.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var t=0;t<this.extensions.length;t++){var n=this.extensions[t];if(-1!==S2.indexOf(n.tags||[],e.value))return n.parse(this,E2,x2)}this.fail("unknown block tag: "+e.value,e.lineno,e.colno)}},r.parseRaw=function(e){for(var t="end"+(e=e||"raw"),n=new RegExp("([\\s\\S]*?){%\\s*("+e+"|"+t+")\\s*(?=%})%}"),i=1,r="",s=null,o=this.advanceAfterBlockEnd();(s=this.tokens._extractRegex(n))&&i>0;){var a=s[0],c=s[1],l=s[2];l===e?i+=1:l===t&&(i-=1),0===i?(r+=c,this.tokens.backN(a.length-c.length)):r+=a}return new E2.Output(o.lineno,o.colno,[new E2.TemplateData(o.lineno,o.colno,r)])},r.parsePostfix=function(e){for(var t,n=this.peekToken();n;){if(n.type===x2.TOKEN_LEFT_PAREN)e=new E2.FunCall(n.lineno,n.colno,e,this.parseSignature());else if(n.type===x2.TOKEN_LEFT_BRACKET)(t=this.parseAggregate()).children.length>1&&this.fail("invalid index"),e=new E2.LookupVal(n.lineno,n.colno,e,t.children[0]);else{if(n.type!==x2.TOKEN_OPERATOR||"."!==n.value)break;this.nextToken();var i=this.nextToken();i.type!==x2.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+i.value,i.lineno,i.colno),t=new E2.Literal(i.lineno,i.colno,i.value),e=new E2.LookupVal(n.lineno,n.colno,e,t)}n=this.peekToken()}return e},r.parseExpression=function(){return this.parseInlineIf()},r.parseInlineIf=function(){var e=this.parseOr();if(this.skipSymbol("if")){var t=this.parseOr(),n=e;(e=new E2.InlineIf(e.lineno,e.colno)).body=n,e.cond=t,this.skipSymbol("else")?e.else_=this.parseOr():e.else_=null}return e},r.parseOr=function(){for(var e=this.parseAnd();this.skipSymbol("or");){var t=this.parseAnd();e=new E2.Or(e.lineno,e.colno,e,t)}return e},r.parseAnd=function(){for(var e=this.parseNot();this.skipSymbol("and");){var t=this.parseNot();e=new E2.And(e.lineno,e.colno,e,t)}return e},r.parseNot=function(){var e=this.peekToken();return this.skipSymbol("not")?new E2.Not(e.lineno,e.colno,this.parseNot()):this.parseIn()},r.parseIn=function(){for(var e=this.parseIs();;){var t=this.nextToken();if(!t)break;var n=t.type===x2.TOKEN_SYMBOL&&"not"===t.value;if(n||this.pushToken(t),!this.skipSymbol("in")){n&&this.pushToken(t);break}var i=this.parseIs();e=new E2.In(e.lineno,e.colno,e,i),n&&(e=new E2.Not(e.lineno,e.colno,e))}return e},r.parseIs=function(){var e=this.parseCompare();if(this.skipSymbol("is")){var t=this.skipSymbol("not"),n=this.parseCompare();e=new E2.Is(e.lineno,e.colno,e,n),t&&(e=new E2.Not(e.lineno,e.colno,e))}return e},r.parseCompare=function(){for(var e=["==","===","!=","!==","<",">","<=",">="],t=this.parseConcat(),n=[];;){var i=this.nextToken();if(!i)break;if(-1===e.indexOf(i.value)){this.pushToken(i);break}n.push(new E2.CompareOperand(i.lineno,i.colno,this.parseConcat(),i.value))}return n.length?new E2.Compare(n[0].lineno,n[0].colno,t,n):t},r.parseConcat=function(){for(var e=this.parseAdd();this.skipValue(x2.TOKEN_TILDE,"~");){var t=this.parseAdd();e=new E2.Concat(e.lineno,e.colno,e,t)}return e},r.parseAdd=function(){for(var e=this.parseSub();this.skipValue(x2.TOKEN_OPERATOR,"+");){var t=this.parseSub();e=new E2.Add(e.lineno,e.colno,e,t)}return e},r.parseSub=function(){for(var e=this.parseMul();this.skipValue(x2.TOKEN_OPERATOR,"-");){var t=this.parseMul();e=new E2.Sub(e.lineno,e.colno,e,t)}return e},r.parseMul=function(){for(var e=this.parseDiv();this.skipValue(x2.TOKEN_OPERATOR,"*");){var t=this.parseDiv();e=new E2.Mul(e.lineno,e.colno,e,t)}return e},r.parseDiv=function(){for(var e=this.parseFloorDiv();this.skipValue(x2.TOKEN_OPERATOR,"/");){var t=this.parseFloorDiv();e=new E2.Div(e.lineno,e.colno,e,t)}return e},r.parseFloorDiv=function(){for(var e=this.parseMod();this.skipValue(x2.TOKEN_OPERATOR,"//");){var t=this.parseMod();e=new E2.FloorDiv(e.lineno,e.colno,e,t)}return e},r.parseMod=function(){for(var e=this.parsePow();this.skipValue(x2.TOKEN_OPERATOR,"%");){var t=this.parsePow();e=new E2.Mod(e.lineno,e.colno,e,t)}return e},r.parsePow=function(){for(var e=this.parseUnary();this.skipValue(x2.TOKEN_OPERATOR,"**");){var t=this.parseUnary();e=new E2.Pow(e.lineno,e.colno,e,t)}return e},r.parseUnary=function(e){var t,n=this.peekToken();return t=this.skipValue(x2.TOKEN_OPERATOR,"-")?new E2.Neg(n.lineno,n.colno,this.parseUnary(!0)):this.skipValue(x2.TOKEN_OPERATOR,"+")?new E2.Pos(n.lineno,n.colno,this.parseUnary(!0)):this.parsePrimary(),e||(t=this.parseFilter(t)),t},r.parsePrimary=function(e){var t,n=this.nextToken(),i=null;if(n?n.type===x2.TOKEN_STRING?t=n.value:n.type===x2.TOKEN_INT?t=parseInt(n.value,10):n.type===x2.TOKEN_FLOAT?t=parseFloat(n.value):n.type===x2.TOKEN_BOOLEAN?"true"===n.value?t=!0:"false"===n.value?t=!1:this.fail("invalid boolean: "+n.value,n.lineno,n.colno):n.type===x2.TOKEN_NONE?t=null:n.type===x2.TOKEN_REGEX&&(t=new RegExp(n.value.body,n.value.flags)):this.fail("expected expression, got end of file"),void 0!==t?i=new E2.Literal(n.lineno,n.colno,t):n.type===x2.TOKEN_SYMBOL?i=new E2.Symbol(n.lineno,n.colno,n.value):(this.pushToken(n),i=this.parseAggregate()),e||(i=this.parsePostfix(i)),i)return i;throw this.error("unexpected token: "+n.value,n.lineno,n.colno)},r.parseFilterName=function(){for(var e=this.expect(x2.TOKEN_SYMBOL),t=e.value;this.skipValue(x2.TOKEN_OPERATOR,".");)t+="."+this.expect(x2.TOKEN_SYMBOL).value;return new E2.Symbol(e.lineno,e.colno,t)},r.parseFilterArgs=function(e){return this.peekToken().type===x2.TOKEN_LEFT_PAREN?this.parsePostfix(e).args.children:[]},r.parseFilter=function(e){for(;this.skip(x2.TOKEN_PIPE);){var t=this.parseFilterName();e=new E2.Filter(t.lineno,t.colno,t,new E2.NodeList(t.lineno,t.colno,[e].concat(this.parseFilterArgs(e))))}return e},r.parseFilterStatement=function(){var e=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var t=this.parseFilterName(),n=this.parseFilterArgs(t);this.advanceAfterBlockEnd(e.value);var i=new E2.Capture(t.lineno,t.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var r=new E2.Filter(t.lineno,t.colno,t,new E2.NodeList(t.lineno,t.colno,[i].concat(n)));return new E2.Output(t.lineno,t.colno,[r])},r.parseAggregate=function(){var e,t=this.nextToken();switch(t.type){case x2.TOKEN_LEFT_PAREN:e=new E2.Group(t.lineno,t.colno);break;case x2.TOKEN_LEFT_BRACKET:e=new E2.Array(t.lineno,t.colno);break;case x2.TOKEN_LEFT_CURLY:e=new E2.Dict(t.lineno,t.colno);break;default:return null}for(;;){var n=this.peekToken().type;if(n===x2.TOKEN_RIGHT_PAREN||n===x2.TOKEN_RIGHT_BRACKET||n===x2.TOKEN_RIGHT_CURLY){this.nextToken();break}if(e.children.length>0&&(this.skip(x2.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",t.lineno,t.colno)),e instanceof E2.Dict){var i=this.parsePrimary();this.skip(x2.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",t.lineno,t.colno);var r=this.parseExpression();e.addChild(new E2.Pair(i.lineno,i.colno,i,r))}else{var s=this.parseExpression();e.addChild(s)}}return e},r.parseSignature=function(e,t){var n=this.peekToken();if(!t&&n.type!==x2.TOKEN_LEFT_PAREN){if(e)return null;this.fail("expected arguments",n.lineno,n.colno)}n.type===x2.TOKEN_LEFT_PAREN&&(n=this.nextToken());for(var i=new E2.NodeList(n.lineno,n.colno),r=new E2.KeywordArgs(n.lineno,n.colno),s=!1;;){if(n=this.peekToken(),!t&&n.type===x2.TOKEN_RIGHT_PAREN){this.nextToken();break}if(t&&n.type===x2.TOKEN_BLOCK_END)break;if(s&&!this.skip(x2.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",n.lineno,n.colno);else{var o=this.parseExpression();this.skipValue(x2.TOKEN_OPERATOR,"=")?r.addChild(new E2.Pair(o.lineno,o.colno,o,this.parseExpression())):i.addChild(o)}s=!0}return r.children.length&&i.addChild(r),i},r.parseUntilBlocks=function(){for(var e=this.breakOnBlocks,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];this.breakOnBlocks=n;var r=this.parse();return this.breakOnBlocks=e,r},r.parseNodes=function(){for(var e,t=[];e=this.nextToken();)if(e.type===x2.TOKEN_DATA){var n=e.value,i=this.peekToken(),r=i&&i.value;this.dropLeadingWhitespace&&(n=n.replace(/^\s*/,""),this.dropLeadingWhitespace=!1),i&&(i.type===x2.TOKEN_BLOCK_START&&"-"===r.charAt(r.length-1)||i.type===x2.TOKEN_VARIABLE_START&&"-"===r.charAt(this.tokens.tags.VARIABLE_START.length)||i.type===x2.TOKEN_COMMENT&&"-"===r.charAt(this.tokens.tags.COMMENT_START.length))&&(n=n.replace(/\s*$/,"")),t.push(new E2.Output(e.lineno,e.colno,[new E2.TemplateData(e.lineno,e.colno,n)]))}else if(e.type===x2.TOKEN_BLOCK_START){this.dropLeadingWhitespace=!1;var s=this.parseStatement();if(!s)break;t.push(s)}else if(e.type===x2.TOKEN_VARIABLE_START){var o=this.parseExpression();this.dropLeadingWhitespace=!1,this.advanceAfterVariableEnd(),t.push(new E2.Output(e.lineno,e.colno,[o]))}else e.type===x2.TOKEN_COMMENT?this.dropLeadingWhitespace="-"===e.value.charAt(e.value.length-this.tokens.tags.COMMENT_END.length-1):this.fail("Unexpected token at top-level: "+e.type,e.lineno,e.colno);return t},r.parse=function(){return new E2.NodeList(0,0,this.parseNodes())},r.parseAsRoot=function(){return new E2.Root(0,0,this.parseNodes())},i}(u1.Obj),T2={parse:function(e,t,n){var i=new k2(x2.lex(e,n));return void 0!==t&&(i.extensions=t),i.parseAsRoot()},Parser:k2},A2=_2,D2=c0,C2=0;function O2(){return"hole_"+C2++}function R2(e,t){for(var n=null,i=0;i<e.length;i++){var r=t(e[i]);r!==e[i]&&(n||(n=e.slice()),n[i]=r)}return n||e}function L2(e,t,n){if(!(e instanceof A2.Node))return e;if(!n){var i=t(e);if(i&&i!==e)return i}if(e instanceof A2.NodeList){var r=R2(e.children,(function(e){return L2(e,t,n)}));r!==e.children&&(e=new A2[e.typename](e.lineno,e.colno,r))}else if(e instanceof A2.CallExtension){var s=L2(e.args,t,n),o=R2(e.contentArgs,(function(e){return L2(e,t,n)}));s===e.args&&o===e.contentArgs||(e=new A2[e.typename](e.extName,e.prop,s,o))}else{var a=e.fields.map((function(t){return e[t]})),c=R2(a,(function(e){return L2(e,t,n)}));c!==a&&(e=new A2[e.typename](e.lineno,e.colno),c.forEach((function(t,n){e[e.fields[n]]=t})))}return n&&t(e)||e}function I2(e,t){return L2(e,t,!0)}function N2(e,t,n){var i=[],r=I2(n?e[n]:e,(function(e){var n;return e instanceof A2.Block?e:((e instanceof A2.Filter&&-1!==D2.indexOf(t,e.name.value)||e instanceof A2.CallExtensionAsync)&&(n=new A2.Symbol(e.lineno,e.colno,O2()),i.push(new A2.FilterAsync(e.lineno,e.colno,e.name,e.args,n))),n)}));return n?e[n]=r:e=r,i.length?(i.push(e),new A2.NodeList(e.lineno,e.colno,i)):e}function P2(e,t){return function(e){return I2(e,(function(e){if(e instanceof A2.If||e instanceof A2.For){var t=!1;if(L2(e,(function(e){if(e instanceof A2.FilterAsync||e instanceof A2.IfAsync||e instanceof A2.AsyncEach||e instanceof A2.AsyncAll||e instanceof A2.CallExtensionAsync)return t=!0,e})),t){if(e instanceof A2.If)return new A2.IfAsync(e.lineno,e.colno,e.cond,e.body,e.else_);if(e instanceof A2.For&&!(e instanceof A2.AsyncAll))return new A2.AsyncEach(e.lineno,e.colno,e.arr,e.name,e.body,e.else_)}}}))}(function(e){return L2(e,(function(e){if(e instanceof A2.Block){var t=!1,n=O2();e.body=L2(e.body,(function(e){if(e instanceof A2.FunCall&&"super"===e.name.value)return t=!0,new A2.Symbol(e.lineno,e.colno,n)})),t&&e.body.children.unshift(new A2.Super(0,0,e.name,new A2.Symbol(0,0,n)))}}))}(function(e,t){return I2(e,(function(e){return e instanceof A2.Output?N2(e,t):e instanceof A2.Set?N2(e,t,"value"):e instanceof A2.For?N2(e,t,"arr"):e instanceof A2.If?N2(e,t,"cond"):e instanceof A2.CallExtension?N2(e,t,"args"):void 0}))}(e,t)))}var j2={transform:function(e,t){return P2(e,t||[])}},F2=c0,B2=Array.from,M2="function"==typeof Symbol&&Symbol.iterator&&"function"==typeof B2,U2=function(){function e(e,t){this.variables=Object.create(null),this.parent=e,this.topLevel=!1,this.isolateWrites=t}var t=e.prototype;return t.set=function(e,t,n){var i=e.split("."),r=this.variables,s=this;if(n&&(s=this.resolve(i[0],!0)))s.set(e,t);else{for(var o=0;o<i.length-1;o++){var a=i[o];r[a]||(r[a]={}),r=r[a]}r[i[i.length-1]]=t}},t.get=function(e){var t=this.variables[e];return void 0!==t?t:null},t.lookup=function(e){var t=this.parent,n=this.variables[e];return void 0!==n?n:t&&t.lookup(e)},t.resolve=function(e,t){var n=t&&this.isolateWrites?void 0:this.parent;return void 0!==this.variables[e]?this:n&&n.resolve(e)},t.push=function(t){return new e(this,t)},t.pop=function(){return this.parent},e}();function q2(e){return e&&Object.prototype.hasOwnProperty.call(e,"__keywords")}function $2(e){var t=e.length;return 0===t?0:q2(e[t-1])?t-1:t}function H2(e){if("string"!=typeof e)return e;this.val=e,this.length=e.length}H2.prototype=Object.create(String.prototype,{length:{writable:!0,configurable:!0,value:0}}),H2.prototype.valueOf=function(){return this.val},H2.prototype.toString=function(){return this.val};var z2={Frame:U2,makeMacro:function(e,t,n){return function(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];var o,a=$2(r),c=function(e){var t=e.length;if(t){var n=e[t-1];if(q2(n))return n}return{}}(r);if(a>e.length)o=r.slice(0,e.length),r.slice(o.length,a).forEach((function(e,n){n<t.length&&(c[t[n]]=e)})),o.push(c);else if(a<e.length){o=r.slice(0,a);for(var l=a;l<e.length;l++){var u=e[l];o.push(c[u]),delete c[u]}o.push(c)}else o=r;return n.apply(this,o)}},makeKeywordArgs:function(e){return e.__keywords=!0,e},numArgs:$2,suppressValue:function(e,t){return e=null!=e?e:"",!t||e instanceof H2||(e=F2.escape(e.toString())),e},ensureDefined:function(e,t,n){if(null==e)throw new F2.TemplateError("attempted to output null or undefined value",t+1,n+1);return e},memberLookup:function(e,t){if(null!=e)return"function"==typeof e[t]?function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return e[t].apply(e,i)}:e[t]},contextOrFrameLookup:function(e,t,n){var i=t.lookup(n);return void 0!==i?i:e.lookup(n)},callWrap:function(e,t,n,i){if(!e)throw new Error("Unable to call `"+t+"`, which is undefined or falsey");if("function"!=typeof e)throw new Error("Unable to call `"+t+"`, which is not a function");return e.apply(n,i)},handleError:function(e,t,n){return e.lineno?e:new F2.TemplateError(e,t,n)},isArray:F2.isArray,keys:F2.keys,SafeString:H2,copySafeness:function(e,t){return e instanceof H2?new H2(t):t.toString()},markSafe:function(e){var t=typeof e;return"string"===t?new H2(e):"function"!==t?e:function(t){var n=e.apply(this,arguments);return"string"==typeof n?new H2(n):n}},asyncEach:function(e,t,n,i){if(F2.isArray(e)){var r=e.length;F2.asyncIter(e,(function(e,i,s){switch(t){case 1:n(e,i,r,s);break;case 2:n(e[0],e[1],i,r,s);break;case 3:n(e[0],e[1],e[2],i,r,s);break;default:e.push(i,r,s),n.apply(this,e)}}),i)}else F2.asyncFor(e,(function(e,t,i,r,s){n(e,t,i,r,s)}),i)},asyncAll:function(e,t,n,i){var r,s,o=0;function a(e,t){o++,s[e]=t,o===r&&i(null,s.join(""))}if(F2.isArray(e))if(r=e.length,s=new Array(r),0===r)i(null,"");else for(var c=0;c<e.length;c++){var l=e[c];switch(t){case 1:n(l,c,r,a);break;case 2:n(l[0],l[1],c,r,a);break;case 3:n(l[0],l[1],l[2],c,r,a);break;default:l.push(c,r,a),n.apply(this,l)}}else{var u=F2.keys(e||{});if(r=u.length,s=new Array(r),0===r)i(null,"");else for(var p=0;p<u.length;p++){var h=u[p];n(h,e[h],p,r,a)}}},inOperator:F2.inOperator,fromIterator:function(e){return"object"!=typeof e||null===e||F2.isArray(e)?e:M2&&Symbol.iterator in e?B2(e):e}};function W2(e,t){return W2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},W2(e,t)}var G2=T2,V2=j2,K2=_2,Y2=c0.TemplateError,Z2=z2.Frame,Q2={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},J2=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,W2(t,n);var r=i.prototype;return r.init=function(e,t){this.templateName=e,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=t},r.fail=function(e,t,n){throw void 0!==t&&(t+=1),void 0!==n&&(n+=1),new Y2(e,t,n)},r._pushBuffer=function(){var e=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=e,this._emit("var "+this.buffer+' = "";'),e},r._popBuffer=function(){this.buffer=this.bufferStack.pop()},r._emit=function(e){this.codebuf.push(e)},r._emitLine=function(e){this._emit(e+"\n")},r._emitLines=function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach((function(t){return e._emitLine(t)}))},r._emitFuncBegin=function(e,t){this.buffer="output",this._scopeClosers="",this._emitLine("function "+t+"(env, context, frame, runtime, cb) {"),this._emitLine("var lineno = "+e.lineno+";"),this._emitLine("var colno = "+e.colno+";"),this._emitLine("var "+this.buffer+' = "";'),this._emitLine("try {")},r._emitFuncEnd=function(e){e||this._emitLine("cb(null, "+this.buffer+");"),this._closeScopeLevels(),this._emitLine("} catch (e) {"),this._emitLine(" cb(runtime.handleError(e, lineno, colno));"),this._emitLine("}"),this._emitLine("}"),this.buffer=null},r._addScopeLevel=function(){this._scopeClosers+="})"},r._closeScopeLevels=function(){this._emitLine(this._scopeClosers+";"),this._scopeClosers=""},r._withScopedSyntax=function(e){var t=this._scopeClosers;this._scopeClosers="",e.call(this),this._closeScopeLevels(),this._scopeClosers=t},r._makeCallback=function(e){var t=this._tmpid();return"function("+t+(e?","+e:"")+") {\nif("+t+") { cb("+t+"); return; }"},r._tmpid=function(){return this.lastId++,"t_"+this.lastId},r._templateName=function(){return null==this.templateName?"undefined":JSON.stringify(this.templateName)},r._compileChildren=function(e,t){var n=this;e.children.forEach((function(e){n.compile(e,t)}))},r._compileAggregate=function(e,t,n,i){var r=this;n&&this._emit(n),e.children.forEach((function(e,n){n>0&&r._emit(","),r.compile(e,t)})),i&&this._emit(i)},r._compileExpression=function(e,t){this.assertType(e,K2.Literal,K2.Symbol,K2.Group,K2.Array,K2.Dict,K2.FunCall,K2.Caller,K2.Filter,K2.LookupVal,K2.Compare,K2.InlineIf,K2.In,K2.Is,K2.And,K2.Or,K2.Not,K2.Add,K2.Concat,K2.Sub,K2.Mul,K2.Div,K2.FloorDiv,K2.Mod,K2.Pow,K2.Neg,K2.Pos,K2.Compare,K2.NodeList),this.compile(e,t)},r.assertType=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];n.some((function(t){return e instanceof t}))||this.fail("assertType: invalid type: "+e.typename,e.lineno,e.colno)},r.compileCallExtension=function(e,t,n){var i=this,r=e.args,s=e.contentArgs,o="boolean"!=typeof e.autoescape||e.autoescape;if(n||this._emit(this.buffer+" += runtime.suppressValue("),this._emit('env.getExtension("'+e.extName+'")["'+e.prop+'"]('),this._emit("context"),(r||s)&&this._emit(","),r&&(r instanceof K2.NodeList||this.fail("compileCallExtension: arguments must be a NodeList, use `parser.parseSignature`"),r.children.forEach((function(e,n){i._compileExpression(e,t),(n!==r.children.length-1||s.length)&&i._emit(",")}))),s.length&&s.forEach((function(e,n){if(n>0&&i._emit(","),e){i._emitLine("function(cb) {"),i._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var r=i._pushBuffer();i._withScopedSyntax((function(){i.compile(e,t),i._emitLine("cb(null, "+r+");")})),i._popBuffer(),i._emitLine("return "+r+";"),i._emitLine("}")}else i._emit("null")})),n){var a=this._tmpid();this._emitLine(", "+this._makeCallback(a)),this._emitLine(this.buffer+" += runtime.suppressValue("+a+", "+o+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+o+" && env.opts.autoescape);\n")},r.compileCallExtensionAsync=function(e,t){this.compileCallExtension(e,t,!0)},r.compileNodeList=function(e,t){this._compileChildren(e,t)},r.compileLiteral=function(e){if("string"==typeof e.value){var t=e.value.replace(/\\/g,"\\\\");t=(t=(t=(t=(t=t.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+t+'"')}else null===e.value?this._emit("null"):this._emit(e.value.toString())},r.compileSymbol=function(e,t){var n=e.value,i=t.lookup(n);i?this._emit(i):this._emit('runtime.contextOrFrameLookup(context, frame, "'+n+'")')},r.compileGroup=function(e,t){this._compileAggregate(e,t,"(",")")},r.compileArray=function(e,t){this._compileAggregate(e,t,"[","]")},r.compileDict=function(e,t){this._compileAggregate(e,t,"{","}")},r.compilePair=function(e,t){var n=e.key,i=e.value;n instanceof K2.Symbol?n=new K2.Literal(n.lineno,n.colno,n.value):n instanceof K2.Literal&&"string"==typeof n.value||this.fail("compilePair: Dict keys must be strings or names",n.lineno,n.colno),this.compile(n,t),this._emit(": "),this._compileExpression(i,t)},r.compileInlineIf=function(e,t){this._emit("("),this.compile(e.cond,t),this._emit("?"),this.compile(e.body,t),this._emit(":"),null!==e.else_?this.compile(e.else_,t):this._emit('""'),this._emit(")")},r.compileIn=function(e,t){this._emit("runtime.inOperator("),this.compile(e.left,t),this._emit(","),this.compile(e.right,t),this._emit(")")},r.compileIs=function(e,t){var n=e.right.name?e.right.name.value:e.right.value;this._emit('env.getTest("'+n+'").call(context, '),this.compile(e.left,t),e.right.args&&(this._emit(","),this.compile(e.right.args,t)),this._emit(") === true")},r._binOpEmitter=function(e,t,n){this.compile(e.left,t),this._emit(n),this.compile(e.right,t)},r.compileOr=function(e,t){return this._binOpEmitter(e,t," || ")},r.compileAnd=function(e,t){return this._binOpEmitter(e,t," && ")},r.compileAdd=function(e,t){return this._binOpEmitter(e,t," + ")},r.compileConcat=function(e,t){return this._binOpEmitter(e,t,' + "" + ')},r.compileSub=function(e,t){return this._binOpEmitter(e,t," - ")},r.compileMul=function(e,t){return this._binOpEmitter(e,t," * ")},r.compileDiv=function(e,t){return this._binOpEmitter(e,t," / ")},r.compileMod=function(e,t){return this._binOpEmitter(e,t," % ")},r.compileNot=function(e,t){this._emit("!"),this.compile(e.target,t)},r.compileFloorDiv=function(e,t){this._emit("Math.floor("),this.compile(e.left,t),this._emit(" / "),this.compile(e.right,t),this._emit(")")},r.compilePow=function(e,t){this._emit("Math.pow("),this.compile(e.left,t),this._emit(", "),this.compile(e.right,t),this._emit(")")},r.compileNeg=function(e,t){this._emit("-"),this.compile(e.target,t)},r.compilePos=function(e,t){this._emit("+"),this.compile(e.target,t)},r.compileCompare=function(e,t){var n=this;this.compile(e.expr,t),e.ops.forEach((function(e){n._emit(" "+Q2[e.type]+" "),n.compile(e.expr,t)}))},r.compileLookupVal=function(e,t){this._emit("runtime.memberLookup(("),this._compileExpression(e.target,t),this._emit("),"),this._compileExpression(e.val,t),this._emit(")")},r._getNodeName=function(e){switch(e.typename){case"Symbol":return e.value;case"FunCall":return"the return value of ("+this._getNodeName(e.name)+")";case"LookupVal":return this._getNodeName(e.target)+'["'+this._getNodeName(e.val)+'"]';case"Literal":return e.value.toString();default:return"--expression--"}},r.compileFunCall=function(e,t){this._emit("(lineno = "+e.lineno+", colno = "+e.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(e.name,t),this._emit(', "'+this._getNodeName(e.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(e.args,t,"[","])"),this._emit(")")},r.compileFilter=function(e,t){var n=e.name;this.assertType(n,K2.Symbol),this._emit('env.getFilter("'+n.value+'").call(context, '),this._compileAggregate(e.args,t),this._emit(")")},r.compileFilterAsync=function(e,t){var n=e.name,i=e.symbol.value;this.assertType(n,K2.Symbol),t.set(i,i),this._emit('env.getFilter("'+n.value+'").call(context, '),this._compileAggregate(e.args,t),this._emitLine(", "+this._makeCallback(i)),this._addScopeLevel()},r.compileKeywordArgs=function(e,t){this._emit("runtime.makeKeywordArgs("),this.compileDict(e,t),this._emit(")")},r.compileSet=function(e,t){var n=this,i=[];e.targets.forEach((function(e){var r=e.value,s=t.lookup(r);null==s&&(s=n._tmpid(),n._emitLine("var "+s+";")),i.push(s)})),e.value?(this._emit(i.join(" = ")+" = "),this._compileExpression(e.value,t),this._emitLine(";")):(this._emit(i.join(" = ")+" = "),this.compile(e.body,t),this._emitLine(";")),e.targets.forEach((function(e,t){var r=i[t],s=e.value;n._emitLine('frame.set("'+s+'", '+r+", true);"),n._emitLine("if(frame.topLevel) {"),n._emitLine('context.setVariable("'+s+'", '+r+");"),n._emitLine("}"),"_"!==s.charAt(0)&&(n._emitLine("if(frame.topLevel) {"),n._emitLine('context.addExport("'+s+'", '+r+");"),n._emitLine("}"))}))},r.compileSwitch=function(e,t){var n=this;this._emit("switch ("),this.compile(e.expr,t),this._emit(") {"),e.cases.forEach((function(e,i){n._emit("case "),n.compile(e.cond,t),n._emit(": "),n.compile(e.body,t),e.body.children.length&&n._emitLine("break;")})),e.default&&(this._emit("default:"),this.compile(e.default,t)),this._emit("}")},r.compileIf=function(e,t,n){var i=this;this._emit("if("),this._compileExpression(e.cond,t),this._emitLine(") {"),this._withScopedSyntax((function(){i.compile(e.body,t),n&&i._emit("cb()")})),e.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){i.compile(e.else_,t),n&&i._emit("cb()")}))):n&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},r.compileIfAsync=function(e,t){this._emit("(function(cb) {"),this.compileIf(e,t,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},r._emitLoopBindings=function(e,t,n,i){var r=this;[{name:"index",val:n+" + 1"},{name:"index0",val:n},{name:"revindex",val:i+" - "+n},{name:"revindex0",val:i+" - "+n+" - 1"},{name:"first",val:n+" === 0"},{name:"last",val:n+" === "+i+" - 1"},{name:"length",val:i}].forEach((function(e){r._emitLine('frame.set("loop.'+e.name+'", '+e.val+");")}))},r.compileFor=function(e,t){var n=this,i=this._tmpid(),r=this._tmpid(),s=this._tmpid();if(t=t.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = "),this._compileExpression(e.arr,t),this._emitLine(";"),this._emit("if("+s+") {"),this._emitLine(s+" = runtime.fromIterator("+s+");"),e.name instanceof K2.Array){this._emitLine("var "+i+";"),this._emitLine("if(runtime.isArray("+s+")) {"),this._emitLine("var "+r+" = "+s+".length;"),this._emitLine("for("+i+"=0; "+i+" < "+s+".length; "+i+"++) {"),e.name.children.forEach((function(r,o){var a=n._tmpid();n._emitLine("var "+a+" = "+s+"["+i+"]["+o+"];"),n._emitLine('frame.set("'+r+'", '+s+"["+i+"]["+o+"]);"),t.set(e.name.children[o].value,a)})),this._emitLoopBindings(e,s,i,r),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}"),this._emitLine("} else {");var o=e.name.children,a=o[0],c=o[1],l=this._tmpid(),u=this._tmpid();t.set(a.value,l),t.set(c.value,u),this._emitLine(i+" = -1;"),this._emitLine("var "+r+" = runtime.keys("+s+").length;"),this._emitLine("for(var "+l+" in "+s+") {"),this._emitLine(i+"++;"),this._emitLine("var "+u+" = "+s+"["+l+"];"),this._emitLine('frame.set("'+a.value+'", '+l+");"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLoopBindings(e,s,i,r),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}"),this._emitLine("}")}else{var p=this._tmpid();t.set(e.name.value,p),this._emitLine("var "+r+" = "+s+".length;"),this._emitLine("for(var "+i+"=0; "+i+" < "+s+".length; "+i+"++) {"),this._emitLine("var "+p+" = "+s+"["+i+"];"),this._emitLine('frame.set("'+e.name.value+'", '+p+");"),this._emitLoopBindings(e,s,i,r),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("}")}this._emitLine("}"),e.else_&&(this._emitLine("if (!"+r+") {"),this.compile(e.else_,t),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r._compileAsyncLoop=function(e,t,n){var i=this,r=this._tmpid(),s=this._tmpid(),o=this._tmpid(),a=n?"asyncAll":"asyncEach";if(t=t.push(),this._emitLine("frame = frame.push();"),this._emit("var "+o+" = runtime.fromIterator("),this._compileExpression(e.arr,t),this._emitLine(");"),e.name instanceof K2.Array){var c=e.name.children.length;this._emit("runtime."+a+"("+o+", "+c+", function("),e.name.children.forEach((function(e){i._emit(e.value+",")})),this._emit(r+","+s+",next) {"),e.name.children.forEach((function(e){var n=e.value;t.set(n,n),i._emitLine('frame.set("'+n+'", '+n+");")}))}else{var l=e.name.value;this._emitLine("runtime."+a+"("+o+", 1, function("+l+", "+r+", "+s+",next) {"),this._emitLine('frame.set("'+l+'", '+l+");"),t.set(l,l)}this._emitLoopBindings(e,o,r,s),this._withScopedSyntax((function(){var s;n&&(s=i._pushBuffer()),i.compile(e.body,t),i._emitLine("next("+r+(s?","+s:"")+");"),n&&i._popBuffer()}));var u=this._tmpid();this._emitLine("}, "+this._makeCallback(u)),this._addScopeLevel(),n&&this._emitLine(this.buffer+" += "+u+";"),e.else_&&(this._emitLine("if (!"+o+".length) {"),this.compile(e.else_,t),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r.compileAsyncEach=function(e,t){this._compileAsyncLoop(e,t)},r.compileAsyncAll=function(e,t){this._compileAsyncLoop(e,t,!0)},r._compileMacro=function(e,t){var n=this,i=[],r=null,s="macro_"+this._tmpid(),o=void 0!==t;e.args.children.forEach((function(t,s){s===e.args.children.length-1&&t instanceof K2.Dict?r=t:(n.assertType(t,K2.Symbol),i.push(t))}));var a,c=[].concat(i.map((function(e){return"l_"+e.value})),["kwargs"]),l=i.map((function(e){return'"'+e.value+'"'})),u=(r&&r.children||[]).map((function(e){return'"'+e.key.value+'"'}));a=o?t.push(!0):new Z2,this._emitLines("var "+s+" = runtime.makeMacro(","["+l.join(", ")+"], ","["+u.join(", ")+"], ","function ("+c.join(", ")+") {","var callerFrame = frame;","frame = "+(o?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),i.forEach((function(e){n._emitLine('frame.set("'+e.value+'", l_'+e.value+");"),a.set(e.value,"l_"+e.value)})),r&&r.children.forEach((function(e){var t=e.key.value;n._emit('frame.set("'+t+'", '),n._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+t+'")'),n._emit(' ? kwargs["'+t+'"] : '),n._compileExpression(e.value,a),n._emit(");")}));var p=this._pushBuffer();return this._withScopedSyntax((function(){n.compile(e.body,a)})),this._emitLine("frame = "+(o?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+p+");"),this._emitLine("});"),this._popBuffer(),s},r.compileMacro=function(e,t){var n=this._compileMacro(e),i=e.name.value;t.set(i,n),t.parent?this._emitLine('frame.set("'+i+'", '+n+");"):("_"!==e.name.value.charAt(0)&&this._emitLine('context.addExport("'+i+'");'),this._emitLine('context.setVariable("'+i+'", '+n+");"))},r.compileCaller=function(e,t){this._emit("(function (){");var n=this._compileMacro(e,t);this._emit("return "+n+";})()")},r._compileGetTemplate=function(e,t,n,i){var r=this._tmpid(),s=this._templateName(),o=this._makeCallback(r),a=n?"true":"false",c=i?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(e.template,t),this._emitLine(", "+a+", "+s+", "+c+", "+o),r},r.compileImport=function(e,t){var n=e.target.value,i=this._compileGetTemplate(e,t,!1,!1);this._addScopeLevel(),this._emitLine(i+".getExported("+(e.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(i)),this._addScopeLevel(),t.set(n,i),t.parent?this._emitLine('frame.set("'+n+'", '+i+");"):this._emitLine('context.setVariable("'+n+'", '+i+");")},r.compileFromImport=function(e,t){var n=this,i=this._compileGetTemplate(e,t,!1,!1);this._addScopeLevel(),this._emitLine(i+".getExported("+(e.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(i)),this._addScopeLevel(),e.names.children.forEach((function(e){var r,s,o=n._tmpid();e instanceof K2.Pair?(r=e.key.value,s=e.value.value):s=r=e.value,n._emitLine("if(Object.prototype.hasOwnProperty.call("+i+', "'+r+'")) {'),n._emitLine("var "+o+" = "+i+"."+r+";"),n._emitLine("} else {"),n._emitLine("cb(new Error(\"cannot import '"+r+"'\")); return;"),n._emitLine("}"),t.set(s,o),t.parent?n._emitLine('frame.set("'+s+'", '+o+");"):n._emitLine('context.setVariable("'+s+'", '+o+");")}))},r.compileBlock=function(e){var t=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+e.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(t)),this._emitLine(this.buffer+" += "+t+";"),this._addScopeLevel()},r.compileSuper=function(e,t){var n=e.blockName.value,i=e.symbol.value,r=this._makeCallback(i);this._emitLine('context.getSuper(env, "'+n+'", b_'+n+", frame, runtime, "+r),this._emitLine(i+" = runtime.markSafe("+i+");"),this._addScopeLevel(),t.set(i,i)},r.compileExtends=function(e,t){var n=this._tmpid(),i=this._compileGetTemplate(e,t,!0,!1);this._emitLine("parentTemplate = "+i),this._emitLine("for(var "+n+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+n+", parentTemplate.blocks["+n+"]);"),this._emitLine("}"),this._addScopeLevel()},r.compileInclude=function(e,t){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var n=this._compileGetTemplate(e,t,!1,e.ignoreMissing);this._emitLine("callback(null,"+n+");});"),this._emitLine("});");var i=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(i)),this._emitLine("callback(null,"+i+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},r.compileTemplateData=function(e,t){this.compileLiteral(e,t)},r.compileCapture=function(e,t){var n=this,i=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){n.compile(e.body,t)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=i},r.compileOutput=function(e,t){var n=this;e.children.forEach((function(i){i instanceof K2.TemplateData?i.value&&(n._emit(n.buffer+" += "),n.compileLiteral(i,t),n._emitLine(";")):(n._emit(n.buffer+" += runtime.suppressValue("),n.throwOnUndefined&&n._emit("runtime.ensureDefined("),n.compile(i,t),n.throwOnUndefined&&n._emit(","+e.lineno+","+e.colno+")"),n._emit(", env.opts.autoescape);\n"))}))},r.compileRoot=function(e,t){var n=this;t&&this.fail("compileRoot: root node can't have frame"),t=new Z2,this._emitFuncBegin(e,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(e,t),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var i=[],r=e.findAll(K2.Block);r.forEach((function(e,t){var r=e.name.value;if(-1!==i.indexOf(r))throw new Error('Block "'+r+'" defined more than once.');i.push(r),n._emitFuncBegin(e,"b_"+r);var s=new Z2;n._emitLine("var frame = frame.push(true);"),n.compile(e.body,s),n._emitFuncEnd()})),this._emitLine("return {"),r.forEach((function(e,t){var i="b_"+e.name.value;n._emitLine(i+": "+i+",")})),this._emitLine("root: root\n};")},r.compile=function(e,t){var n=this["compile"+e.typename];n?n.call(this,e,t):this.fail("compile: Cannot compile node: "+e.typename,e.lineno,e.colno)},r.getCode=function(){return this.codebuf.join("")},i}(u1.Obj),X2={compile:function(e,t,n,i,r){void 0===r&&(r={});var s=new J2(i,r.throwOnUndefined),o=(n||[]).map((function(e){return e.preprocess})).filter((function(e){return!!e})),a=o.reduce((function(e,t){return t(e)}),e);return s.compile(V2.transform(G2.parse(a,n,r),t,i)),s.getCode()},Compiler:J2},e3={exports:{}},t3=c0,n3=z2,i3=e3.exports={};function r3(e,t){return null==e||!1===e?t:e}function s3(e){return e!=e}function o3(e){var t=(e=r3(e,"")).toLowerCase();return n3.copySafeness(e,t.charAt(0).toUpperCase()+t.slice(1))}function a3(e){if(t3.isString(e))return e.split("");if(t3.isObject(e))return t3._entries(e||{}).map((function(e){return{key:e[0],value:e[1]}}));if(t3.isArray(e))return e;throw new t3.TemplateError("list filter: type not iterable")}function c3(e){return function(t,n,i){void 0===n&&(n="truthy");var r=this,s=r.env.getTest(n);return t3.toArray(t).filter((function(t){return s.call(r,t,i)===e}))}}function l3(e){return n3.copySafeness(e,e.replace(/^\s*|\s*$/g,""))}i3.abs=Math.abs,i3.batch=function(e,t,n){var i,r=[],s=[];for(i=0;i<e.length;i++)i%t==0&&s.length&&(r.push(s),s=[]),s.push(e[i]);if(s.length){if(n)for(i=s.length;i<t;i++)s.push(n);r.push(s)}return r},i3.capitalize=o3,i3.center=function(e,t){if(t=t||80,(e=r3(e,"")).length>=t)return e;var n=t-e.length,i=t3.repeat(" ",n/2-n%2),r=t3.repeat(" ",n/2);return n3.copySafeness(e,i+e+r)},i3.default=function(e,t,n){return n?e||t:void 0!==e?e:t},i3.dictsort=function(e,t,n){if(!t3.isObject(e))throw new t3.TemplateError("dictsort filter: val must be an object");var i,r=[];for(var s in e)r.push([s,e[s]]);if(void 0===n||"key"===n)i=0;else{if("value"!==n)throw new t3.TemplateError("dictsort filter: You can only sort by either key or value");i=1}return r.sort((function(e,n){var r=e[i],s=n[i];return t||(t3.isString(r)&&(r=r.toUpperCase()),t3.isString(s)&&(s=s.toUpperCase())),r>s?1:r===s?0:-1})),r},i3.dump=function(e,t){return JSON.stringify(e,null,t)},i3.escape=function(e){return e instanceof n3.SafeString?e:(e=null==e?"":e,n3.markSafe(t3.escape(e.toString())))},i3.safe=function(e){return e instanceof n3.SafeString?e:(e=null==e?"":e,n3.markSafe(e.toString()))},i3.first=function(e){return e[0]},i3.forceescape=function(e){return e=null==e?"":e,n3.markSafe(t3.escape(e.toString()))},i3.groupby=function(e,t){return t3.groupBy(e,t,this.env.opts.throwOnUndefined)},i3.indent=function(e,t,n){if(""===(e=r3(e,"")))return"";t=t||4;var i=e.split("\n"),r=t3.repeat(" ",t),s=i.map((function(e,t){return 0!==t||n?""+r+e:e})).join("\n");return n3.copySafeness(e,s)},i3.join=function(e,t,n){return t=t||"",n&&(e=t3.map(e,(function(e){return e[n]}))),e.join(t)},i3.last=function(e){return e[e.length-1]},i3.length=function(e){var t=r3(e,"");return void 0!==t?"function"==typeof Map&&t instanceof Map||"function"==typeof Set&&t instanceof Set?t.size:!t3.isObject(t)||t instanceof n3.SafeString?t.length:t3.keys(t).length:0},i3.list=a3,i3.lower=function(e){return(e=r3(e,"")).toLowerCase()},i3.nl2br=function(e){return null==e?"":n3.copySafeness(e,e.replace(/\r\n|\n/g,"<br />\n"))},i3.random=function(e){return e[Math.floor(Math.random()*e.length)]},i3.reject=c3(!1),i3.rejectattr=function(e,t){return e.filter((function(e){return!e[t]}))},i3.select=c3(!0),i3.selectattr=function(e,t){return e.filter((function(e){return!!e[t]}))},i3.replace=function(e,t,n,i){var r=e;if(t instanceof RegExp)return e.replace(t,n);void 0===i&&(i=-1);var s="";if("number"==typeof t)t=""+t;else if("string"!=typeof t)return e;if("number"==typeof e&&(e=""+e),"string"!=typeof e&&!(e instanceof n3.SafeString))return e;if(""===t)return s=n+e.split("").join(n)+n,n3.copySafeness(e,s);var o=e.indexOf(t);if(0===i||-1===o)return e;for(var a=0,c=0;o>-1&&(-1===i||c<i);)s+=e.substring(a,o)+n,a=o+t.length,c++,o=e.indexOf(t,a);return a<e.length&&(s+=e.substring(a)),n3.copySafeness(r,s)},i3.reverse=function(e){var t;return(t=t3.isString(e)?a3(e):t3.map(e,(function(e){return e}))).reverse(),t3.isString(e)?n3.copySafeness(e,t.join("")):t},i3.round=function(e,t,n){t=t||0;var i=Math.pow(10,t);return("ceil"===n?Math.ceil:"floor"===n?Math.floor:Math.round)(e*i)/i},i3.slice=function(e,t,n){for(var i=Math.floor(e.length/t),r=e.length%t,s=[],o=0,a=0;a<t;a++){var c=o+a*i;a<r&&o++;var l=o+(a+1)*i,u=e.slice(c,l);n&&a>=r&&u.push(n),s.push(u)}return s},i3.sum=function(e,t,n){return void 0===n&&(n=0),t&&(e=t3.map(e,(function(e){return e[t]}))),n+e.reduce((function(e,t){return e+t}),0)},i3.sort=n3.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(e,t,n,i){var r=this,s=t3.map(e,(function(e){return e})),o=t3.getAttrGetter(i);return s.sort((function(e,s){var a=i?o(e):e,c=i?o(s):s;if(r.env.opts.throwOnUndefined&&i&&(void 0===a||void 0===c))throw new TypeError('sort: attribute "'+i+'" resolved to undefined');return!n&&t3.isString(a)&&t3.isString(c)&&(a=a.toLowerCase(),c=c.toLowerCase()),a<c?t?1:-1:a>c?t?-1:1:0})),s})),i3.string=function(e){return n3.copySafeness(e,e)},i3.striptags=function(e,t){var n=l3((e=r3(e,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|<!--[\s\S]*?-->/gi,"")),i="";return i=t?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),n3.copySafeness(e,i)},i3.title=function(e){var t=(e=r3(e,"")).split(" ").map((function(e){return o3(e)}));return n3.copySafeness(e,t.join(" "))},i3.trim=l3,i3.truncate=function(e,t,n,i){var r=e;if(t=t||255,(e=r3(e,"")).length<=t)return e;if(n)e=e.substring(0,t);else{var s=e.lastIndexOf(" ",t);-1===s&&(s=t),e=e.substring(0,s)}return e+=null!=i?i:"...",n3.copySafeness(r,e)},i3.upper=function(e){return(e=r3(e,"")).toUpperCase()},i3.urlencode=function(e){var t=encodeURIComponent;return t3.isString(e)?t(e):(t3.isArray(e)?e:t3._entries(e)).map((function(e){var n=e[0],i=e[1];return t(n)+"="+t(i)})).join("&")};var u3=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,p3=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,h3=/^https?:\/\/.*$/,d3=/^www\./,f3=/\.(?:org|net|com)(?:\:|\/|$)/;i3.urlize=function(e,t,n){s3(t)&&(t=1/0);var i=!0===n?' rel="nofollow"':"";return e.split(/(\s+)/).filter((function(e){return e&&e.length})).map((function(e){var n=e.match(u3),r=n?n[1]:e,s=r.substr(0,t);return h3.test(r)?'<a href="'+r+'"'+i+">"+s+"</a>":d3.test(r)?'<a href="http://'+r+'"'+i+">"+s+"</a>":p3.test(r)?'<a href="mailto:'+r+'">'+r+"</a>":f3.test(r)?'<a href="http://'+r+'"'+i+">"+s+"</a>":e})).join("")},i3.wordcount=function(e){var t=(e=r3(e,""))?e.match(/\w+/g):null;return t?t.length:null},i3.float=function(e,t){var n=parseFloat(e);return s3(n)?t:n};var m3=n3.makeMacro(["value","default","base"],[],(function(e,t,n){void 0===n&&(n=10);var i=parseInt(e,n);return s3(i)?t:i}));i3.int=m3,i3.d=i3.default,i3.e=i3.escape;var g3=e3.exports;function y3(e,t){return y3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y3(e,t)}var v3=o,b3=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,y3(t,n);var r=i.prototype;return r.resolve=function(e,t){return v3.resolve(v3.dirname(e),t)},r.isRelative=function(e){return 0===e.indexOf("./")||0===e.indexOf("../")},i}(u1.EmitterObj);function _3(e,t){return _3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_3(e,t)}var w3=function(e){var t,n;function i(t){var n;return(n=e.call(this)||this).precompiled=t||{},n}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,_3(t,n),i.prototype.getSource=function(e){return this.precompiled[e]?{src:{type:"code",obj:this.precompiled[e]},path:e}:null},i}(b3);function x3(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,E3(e,t)}function E3(e,t){return E3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E3(e,t)}var S3,k3=s,T3=o,A3=b3,D3={PrecompiledLoader:w3}.PrecompiledLoader,C3=function(e){function t(t,n){var i;if(i=e.call(this)||this,"boolean"==typeof n&&console.log("[nunjucks] Warning: you passed a boolean as the second argument to FileSystemLoader, but it now takes an options object. See http://mozilla.github.io/nunjucks/api.html#filesystemloader"),n=n||{},i.pathsToNames={},i.noCache=!!n.noCache,t?(t=Array.isArray(t)?t:[t],i.searchPaths=t.map(T3.normalize)):i.searchPaths=["."],n.watch){try{S3=Qq}catch(e){throw new Error("watch requires chokidar to be installed")}var r=i.searchPaths.filter(k3.existsSync),s=S3.watch(r);s.on("all",(function(e,t){t=T3.resolve(t),"change"===e&&t in i.pathsToNames&&i.emit("update",i.pathsToNames[t],t)})),s.on("error",(function(e){console.log("Watcher error: "+e)}))}return i}return x3(t,e),t.prototype.getSource=function(e){for(var t=null,n=this.searchPaths,i=0;i<n.length;i++){var r=T3.resolve(n[i]),s=T3.resolve(n[i],e);if(0===s.indexOf(r)&&k3.existsSync(s)){t=s;break}}if(!t)return null;this.pathsToNames[t]=e;var o={src:k3.readFileSync(t,"utf-8"),path:t,noCache:this.noCache};return this.emit("load",e,o),o},t}(A3),O3=function(e){function t(t){var n;if(t=t||{},(n=e.call(this)||this).pathsToNames={},n.noCache=!!t.noCache,t.watch){try{S3=Qq}catch(e){throw new Error("watch requires chokidar to be installed")}n.watcher=S3.watch(),n.watcher.on("change",(function(e){n.emit("update",n.pathsToNames[e],e)})),n.watcher.on("error",(function(e){console.log("Watcher error: "+e)})),n.on("load",(function(e,t){n.watcher.add(t.path)}))}return n}return x3(t,e),t.prototype.getSource=function(e){if(/^\.?\.?(\/|\\)/.test(e))return null;if(/^[A-Z]:/.test(e))return null;var t;try{t=require.resolve(e)}catch(e){return null}this.pathsToNames[t]=e;var n={src:k3.readFileSync(t,"utf-8"),path:t,noCache:this.noCache};return this.emit("load",e,n),n},t}(A3),R3={FileSystemLoader:C3,PrecompiledLoader:D3,NodeResolveLoader:O3},L3={};!function(e){var t=z2.SafeString;e.callable=function(e){return"function"==typeof e},e.defined=function(e){return void 0!==e},e.divisibleby=function(e,t){return e%t==0},e.escaped=function(e){return e instanceof t},e.equalto=function(e,t){return e===t},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(e){return e%2==0},e.falsy=function(e){return!e},e.ge=function(e,t){return e>=t},e.greaterthan=function(e,t){return e>t},e.gt=e.greaterthan,e.le=function(e,t){return e<=t},e.lessthan=function(e,t){return e<t},e.lt=e.lessthan,e.lower=function(e){return e.toLowerCase()===e},e.ne=function(e,t){return e!==t},e.null=function(e){return null===e},e.number=function(e){return"number"==typeof e},e.odd=function(e){return e%2==1},e.string=function(e){return"string"==typeof e},e.truthy=function(e){return!!e},e.undefined=function(e){return void 0===e},e.upper=function(e){return e.toUpperCase()===e},e.iterable=function(e){return"undefined"!=typeof Symbol?!!e[Symbol.iterator]:Array.isArray(e)||"string"==typeof e},e.mapping=function(e){var t=null!=e&&"object"==typeof e&&!Array.isArray(e);return Set?t&&!(e instanceof Set):t}}(L3);var I3=function(){return{range:function(e,t,n){void 0===t?(t=e,e=0,n=1):n||(n=1);var i=[];if(n>0)for(var r=e;r<t;r+=n)i.push(r);else for(var s=e;s>t;s+=n)i.push(s);return i},cycler:function(){return function(e){var t=-1;return{current:null,reset:function(){t=-1,this.current=null},next:function(){return++t>=e.length&&(t=0),this.current=e[t],this.current}}}(Array.prototype.slice.call(arguments))},joiner:function(e){return function(e){e=e||",";var t=!0;return function(){var n=t?"":e;return t=!1,n}}(e)}}},N3=o;function P3(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,j3(e,t)}function j3(e,t){return j3=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},j3(e,t)}var F3=_0,B3=E0,M3=c0,U3=X2,q3=g3,$3=R3.FileSystemLoader,H3=R3.WebLoader,z3=R3.PrecompiledLoader,W3=L3,G3=I3,V3=u1.Obj,K3=z2,Y3=K3.handleError,Z3=K3.Frame,Q3=function(e,t){function n(e,t){if(this.name=e,this.path=e,this.defaultEngine=t.defaultEngine,this.ext=N3.extname(e),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return n.prototype.render=function(t,n){e.render(this.name,t,n)},t.set("view",n),t.set("nunjucksEnv",e),e};function J3(e,t,n){F3((function(){e(t,n)}))}var X3={type:"code",obj:{root:function(e,t,n,i,r){try{r(null,"")}catch(e){r(Y3(e,null,null))}}}},e4=function(e){function t(){return e.apply(this,arguments)||this}P3(t,e);var n=t.prototype;return n.init=function(e,t){var n=this;t=this.opts=t||{},this.opts.dev=!!t.dev,this.opts.autoescape=null==t.autoescape||t.autoescape,this.opts.throwOnUndefined=!!t.throwOnUndefined,this.opts.trimBlocks=!!t.trimBlocks,this.opts.lstripBlocks=!!t.lstripBlocks,this.loaders=[],e?this.loaders=M3.isArray(e)?e:[e]:$3?this.loaders=[new $3("views")]:H3&&(this.loaders=[new H3("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new z3(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=G3(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],M3._entries(q3).forEach((function(e){var t=e[0],i=e[1];return n.addFilter(t,i)})),M3._entries(W3).forEach((function(e){var t=e[0],i=e[1];return n.addTest(t,i)}))},n._initLoaders=function(){var e=this;this.loaders.forEach((function(t){t.cache={},"function"==typeof t.on&&(t.on("update",(function(n,i){t.cache[n]=null,e.emit("update",n,i,t)})),t.on("load",(function(n,i){e.emit("load",n,i,t)})))}))},n.invalidateCache=function(){this.loaders.forEach((function(e){e.cache={}}))},n.addExtension=function(e,t){return t.__name=e,this.extensions[e]=t,this.extensionsList.push(t),this},n.removeExtension=function(e){var t=this.getExtension(e);t&&(this.extensionsList=M3.without(this.extensionsList,t),delete this.extensions[e])},n.getExtension=function(e){return this.extensions[e]},n.hasExtension=function(e){return!!this.extensions[e]},n.addGlobal=function(e,t){return this.globals[e]=t,this},n.getGlobal=function(e){if(void 0===this.globals[e])throw new Error("global not found: "+e);return this.globals[e]},n.addFilter=function(e,t,n){var i=t;return n&&this.asyncFilters.push(e),this.filters[e]=i,this},n.getFilter=function(e){if(!this.filters[e])throw new Error("filter not found: "+e);return this.filters[e]},n.addTest=function(e,t){return this.tests[e]=t,this},n.getTest=function(e){if(!this.tests[e])throw new Error("test not found: "+e);return this.tests[e]},n.resolveTemplate=function(e,t,n){return!(!e.isRelative||!t)&&e.isRelative(n)&&e.resolve?e.resolve(t,n):n},n.getTemplate=function(e,t,n,i,r){var s,o=this,a=this,c=null;if(e&&e.raw&&(e=e.raw),M3.isFunction(n)&&(r=n,n=null,t=t||!1),M3.isFunction(t)&&(r=t,t=!1),e instanceof n4)c=e;else{if("string"!=typeof e)throw new Error("template names must be a string: "+e);for(var l=0;l<this.loaders.length;l++){var u=this.loaders[l];if(c=u.cache[this.resolveTemplate(u,n,e)])break}}if(c)return t&&c.compile(),r?void r(null,c):c;return M3.asyncIter(this.loaders,(function(t,i,r,s){function o(e,n){e?s(e):n?(n.loader=t,s(null,n)):r()}e=a.resolveTemplate(t,n,e),t.async?t.getSource(e,o):o(null,t.getSource(e))}),(function(n,a){if(a||n||i||(n=new Error("template not found: "+e)),n){if(r)return void r(n);throw n}var c;a?(c=new n4(a.src,o,a.path,t),a.noCache||(a.loader.cache[e]=c)):c=new n4(X3,o,"",t),r?r(null,c):s=c})),s},n.express=function(e){return Q3(this,e)},n.render=function(e,t,n){M3.isFunction(t)&&(n=t,t=null);var i=null;return this.getTemplate(e,(function(e,r){if(e&&n)J3(n,e);else{if(e)throw e;i=r.render(t,n)}})),i},n.renderString=function(e,t,n,i){return M3.isFunction(n)&&(i=n,n={}),new n4(e,this,(n=n||{}).path).render(t,i)},n.waterfall=function(e,t,n){return B3(e,t,n)},t}(u1.EmitterObj),t4=function(e){function t(){return e.apply(this,arguments)||this}P3(t,e);var n=t.prototype;return n.init=function(e,t,n){var i=this;this.env=n||new e4,this.ctx=M3.extend({},e),this.blocks={},this.exported=[],M3.keys(t).forEach((function(e){i.addBlock(e,t[e])}))},n.lookup=function(e){return e in this.env.globals&&!(e in this.ctx)?this.env.globals[e]:this.ctx[e]},n.setVariable=function(e,t){this.ctx[e]=t},n.getVariables=function(){return this.ctx},n.addBlock=function(e,t){return this.blocks[e]=this.blocks[e]||[],this.blocks[e].push(t),this},n.getBlock=function(e){if(!this.blocks[e])throw new Error('unknown block "'+e+'"');return this.blocks[e][0]},n.getSuper=function(e,t,n,i,r,s){var o=M3.indexOf(this.blocks[t]||[],n),a=this.blocks[t][o+1];if(-1===o||!a)throw new Error('no super block available for "'+t+'"');a(e,this,i,r,s)},n.addExport=function(e){this.exported.push(e)},n.getExported=function(){var e=this,t={};return this.exported.forEach((function(n){t[n]=e.ctx[n]})),t},t}(V3),n4=function(e){function t(){return e.apply(this,arguments)||this}P3(t,e);var n=t.prototype;return n.init=function(e,t,n,i){if(this.env=t||new e4,M3.isObject(e))switch(e.type){case"code":this.tmplProps=e.obj;break;case"string":this.tmplStr=e.obj;break;default:throw new Error("Unexpected template object type "+e.type+"; expected 'code', or 'string'")}else{if(!M3.isString(e))throw new Error("src must be a string or an object describing the source");this.tmplStr=e}if(this.path=n,i)try{this._compile()}catch(e){throw M3._prettifyError(this.path,this.env.opts.dev,e)}else this.compiled=!1},n.render=function(e,t,n){var i=this;"function"==typeof e?(n=e,e={}):"function"==typeof t&&(n=t,t=null);var r=!t;try{this.compile()}catch(e){var s=M3._prettifyError(this.path,this.env.opts.dev,e);if(n)return J3(n,s);throw s}var o=new t4(e||{},this.blocks,this.env),a=t?t.push(!0):new Z3;a.topLevel=!0;var c=null,l=!1;return this.rootRenderFunc(this.env,o,a,K3,(function(e,t){if(!l||!n||void 0===t)if(e&&(e=M3._prettifyError(i.path,i.env.opts.dev,e),l=!0),n)r?J3(n,e,t):n(e,t);else{if(e)throw e;c=t}})),c},n.getExported=function(e,t,n){"function"==typeof e&&(n=e,e={}),"function"==typeof t&&(n=t,t=null);try{this.compile()}catch(e){if(n)return n(e);throw e}var i=t?t.push():new Z3;i.topLevel=!0;var r=new t4(e||{},this.blocks,this.env);this.rootRenderFunc(this.env,r,i,K3,(function(e){e?n(e,null):n(null,r.getExported())}))},n.compile=function(){this.compiled||this._compile()},n._compile=function(){var e;if(this.tmplProps)e=this.tmplProps;else{var t=U3.compile(this.tmplStr,this.env.asyncFilters,this.env.extensionsList,this.path,this.env.opts);e=new Function(t)()}this.blocks=this._getBlocks(e),this.rootRenderFunc=e.root,this.compiled=!0},n._getBlocks=function(e){var t={};return M3.keys(e).forEach((function(n){"b_"===n.slice(0,2)&&(t[n.slice(2)]=e[n])})),t},t}(V3),i4={Environment:e4,Template:n4};var r4=function(e,t){var n="";t=t||{};for(var i=0;i<e.length;i++){var r=JSON.stringify(e[i].name);n+="(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["+r+"] = (function() {\n"+e[i].template+"\n})();\n",t.asFunction&&(n+="return function(ctx, cb) { return nunjucks.render("+r+", ctx, cb); }\n"),n+="})();\n"}return n},s4=s,o4=o,a4=c0._prettifyError,c4=X2,l4=i4.Environment,u4=r4;function p4(e,t){return!!Array.isArray(t)&&t.some((function(t){return e.match(t)}))}function h4(e,t){(t=t||{}).isString=!0;var n=t.env||new l4([]),i=t.wrapper||u4;if(!t.name)throw new Error('the "name" option is required when compiling a string');return i([d4(e,t.name,n)],t)}function d4(e,t,n){var i,r=(n=n||new l4([])).asyncFilters,s=n.extensionsList;t=t.replace(/\\/g,"/");try{i=c4.compile(e,r,s,t,n.opts)}catch(e){throw a4(t,!1,e)}return{name:t,template:i}}var f4={precompile:function(e,t){var n=(t=t||{}).env||new l4([]),i=t.wrapper||u4;if(t.isString)return h4(e,t);var r=s4.existsSync(e)&&s4.statSync(e),s=[],o=[];if(r.isFile())s.push(d4(s4.readFileSync(e,"utf-8"),t.name||e,n));else if(r.isDirectory()){!function n(i){s4.readdirSync(i).forEach((function(r){var s=o4.join(i,r),a=s.substr(o4.join(e,"/").length),c=s4.statSync(s);c&&c.isDirectory()?p4(a+="/",t.exclude)||n(s):p4(a,t.include)&&o.push(s)}))}(e);for(var a=0;a<o.length;a++){var c=o[a].replace(o4.join(e,"/"),"");try{s.push(d4(s4.readFileSync(o[a],"utf-8"),c,n))}catch(e){if(!t.force)throw e;console.error(e)}}}return i(s,t)},precompileString:h4};var m4,g4=function(){var e,t,n=this.runtime,i=this.lib,r=this.compiler.Compiler,s=this.parser.Parser,o=this.nodes,a=this.lexer,c=n.contextOrFrameLookup,l=n.memberLookup;function u(e){return{index:e.index,lineno:e.lineno,colno:e.colno}}if(r&&(e=r.prototype.assertType),s&&(t=s.prototype.parseAggregate),n.contextOrFrameLookup=function(e,t,n){var i=c.apply(this,arguments);if(void 0!==i)return i;switch(n){case"True":return!0;case"False":return!1;case"None":return null;default:return}},"SLIM"!==process.env.BUILD_TYPE&&o&&r&&s){var p=o.Node.extend("Slice",{fields:["start","stop","step"],init:function(e,t,n,i,r){n=n||new o.Literal(e,t,null),i=i||new o.Literal(e,t,null),r=r||new o.Literal(e,t,1),this.parent(e,t,n,i,r)}});r.prototype.assertType=function(t){t instanceof p||e.apply(this,arguments)},r.prototype.compileSlice=function(e,t){this._emit("("),this._compileExpression(e.start,t),this._emit("),("),this._compileExpression(e.stop,t),this._emit("),("),this._compileExpression(e.step,t),this._emit(")")},s.prototype.parseAggregate=function(){var e=this,n=u(this.tokens);n.colno--,n.index--;try{return t.apply(this)}catch(t){var r=u(this.tokens),s=function(){return i._assign(e.tokens,r),t};i._assign(this.tokens,n),this.peeked=!1;var c=this.peekToken();if(c.type!==a.TOKEN_LEFT_BRACKET)throw s();this.nextToken();for(var l=new p(c.lineno,c.colno),h=!1,d=0;d<=l.fields.length&&!this.skip(a.TOKEN_RIGHT_BRACKET);d++){if(d===l.fields.length){if(!h)break;this.fail("parseSlice: too many slice components",c.lineno,c.colno)}this.skip(a.TOKEN_COLON)?h=!0:(l[l.fields[d]]=this.parseExpression(),h=this.skip(a.TOKEN_COLON)||h)}if(!h)throw s();return new o.Array(c.lineno,c.colno,[l])}}}function h(e,t,i,r){e=e||[],null===t&&(t=r<0?e.length-1:0),null===i?i=r<0?-1:e.length:i<0&&(i+=e.length),t<0&&(t+=e.length);for(var s=[],o=t;!(o<0||o>e.length)&&!(r>0&&o>=i)&&!(r<0&&o<=i);o+=r)s.push(n.memberLookup(e,o));return s}function d(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var f={pop:function(e){if(void 0===e)return this.pop();if(e>=this.length||e<0)throw new Error("KeyError");return this.splice(e,1)},append:function(e){return this.push(e)},remove:function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return this.splice(t,1);throw new Error("ValueError")},count:function(e){for(var t=0,n=0;n<this.length;n++)this[n]===e&&t++;return t},index:function(e){var t;if(-1===(t=this.indexOf(e)))throw new Error("ValueError");return t},find:function(e){return this.indexOf(e)},insert:function(e,t){return this.splice(e,0,t)}},m={items:function(){return i._entries(this)},values:function(){return i._values(this)},keys:function(){return i.keys(this)},get:function(e,t){var n=this[e];return void 0===n&&(n=t),n},has_key:function(e){return d(this,e)},pop:function(e,t){var n=this[e];if(void 0===n&&void 0!==t)n=t;else{if(void 0===n)throw new Error("KeyError");delete this[e]}return n},popitem:function(){var e=i.keys(this);if(!e.length)throw new Error("KeyError");var t=e[0],n=this[t];return delete this[t],[t,n]},setdefault:function(e,t){return void 0===t&&(t=null),e in this||(this[e]=t),this[e]},update:function(e){return i._assign(this,e),null}};return m.iteritems=m.items,m.itervalues=m.values,m.iterkeys=m.keys,n.memberLookup=function(e,t,n){return 4===arguments.length?h.apply(this,arguments):(e=e||{},i.isArray(e)&&d(f,t)?f[t].bind(e):i.isObject(e)&&d(m,t)?m[t].bind(e):l.apply(this,arguments))},function(){n.contextOrFrameLookup=c,n.memberLookup=l,r&&(r.prototype.assertType=e),s&&(s.prototype.parseAggregate=t)}},y4=c0,v4=i4.Environment,b4=i4.Template,_4=R3,w4=f4,x4=X2,E4=T2,S4=X0,k4=z2,T4=_2,A4=g4;function D4(e,t){var n;return t=t||{},y4.isObject(e)&&(t=e,e=null),_4.FileSystemLoader?n=new _4.FileSystemLoader(e,{watch:t.watch,noCache:t.noCache}):_4.WebLoader&&(n=new _4.WebLoader(e,{useCache:t.web&&t.web.useCache,async:t.web&&t.web.async})),m4=new v4(n,t),t&&t.express&&m4.express(t.express),m4}var C4={Environment:v4,Template:b4,Loader:b3,FileSystemLoader:_4.FileSystemLoader,NodeResolveLoader:_4.NodeResolveLoader,PrecompiledLoader:_4.PrecompiledLoader,WebLoader:_4.WebLoader,compiler:x4,parser:E4,lexer:S4,runtime:k4,lib:y4,nodes:T4,installJinjaCompat:A4,configure:D4,reset:function(){m4=void 0},compile:function(e,t,n,i){return m4||D4(),new b4(e,t,n,i)},render:function(e,t,n){return m4||D4(),m4.render(e,t,n)},renderString:function(e,t,n){return m4||D4(),m4.renderString(e,t,n)},precompile:w4?w4.precompile:void 0,precompileString:w4?w4.precompileString:void 0};const O4=C4,R4=o;O4.configure(R4.join(__dirname,"../views"),{autoescape:!0});const L4=R4.join(__dirname,"../views","notfound.njk");console.log("🚀 ~ TEMPLATE_PATH:",L4);var I4=function(e,t){return new Promise(((n,i)=>e.headersSent?n():O4.render(L4,{title:"qumra"},((n,r)=>{if(n)return console.error("🚀 ~ Error rendering template:",n),e.headersSent||t(n),i(n);e.status(404).send(r)}))))};const N4=I4;var P4=async(e,t,n,i,r)=>{const s=await fetch(e,{headers:t});if(!s.ok)return console.error("🚀 ~ Response error:",s.status),N4(i,r);return await s.json()},j4=z(P4);const F4=I4;var B4=async(e,t,n)=>{const i=await fetch("https://api.qumra.cloud/templateEngine/v1/customer",{headers:e});if(!i.ok)return console.error("🚀 ~ Response error:",i.status),F4(t,n);return await i.json()},M4=z(B4);const U4=process.cwd(),q4=o.join(U4,"src","views");const $4=new Oe;$4.name("theme").description("dev, list"),$4.command("create").description("Run development server with Webpack and BrowserSync").action(vf),$4.command("check").description("Run development server with Webpack and BrowserSync").action((async function(){const e=Vi("Checking files...").start();try{const t=await WR(q4,"views"),n=Object.keys(t);await GR(n,e)}catch(t){e.fail("Failed to retrieve files"),console.error(Et.red(`Failed to retrieve files - Error: ${t.message}`))}})),$4.command("dev").description("Run development server with Webpack and BrowserSync").action((async()=>{await yf();const{data:e}=await af.get("/apps"),t=e?.apps?.map((e=>({name:e.subdomain,value:e._id}))),n=await _l.prompt({type:"list",name:"app",message:"Choose the theme you want to use",choices:t});var i=e?.apps?.find((e=>e._id===n.app));const r=Zq(),s=await UX({port:3e3}),a=new x.Server(r),c=new RX(a),l=Vi("Start Server").start(),u=process.cwd(),p=o.join(u,"src");o.join(u,"src","assets");const h=o.join(u,"dist");d.exec("npx webpack --config webpack.config.js --mode development --stats errors-warnings",(async e=>{e&&console.log(e,"errrrrr");try{await I.access(p),await I.access(h)}catch{console.error("Error: Required directories do not exist."),process.exit(1)}r.use(Zq.static(h)),r.get("/api/auth",((e,t)=>{const{redirect_url:n,token:i}=e.query;if(console.log("🚀 ~ app.get ~ req.query:",e.query),!n||!i)return t.status(400).send("Missing redirect_url or token");t.cookie("token",i,{httpOnly:!1,secure:"production"===process.env.NODE_ENV,expires:new Date(9999,0,1)}),t.redirect(n)})),r.get("/api/auth/logout",((e,t)=>{t.clearCookie("token",{httpOnly:!0,secure:"production"===process.env.NODE_ENV}),t.redirect("/")})),r.use((async(e,t,n)=>{const r=`${i.url}${e.originalUrl}`;console.log("🚀 ~ app.use ~ choiseApp:",i),console.log("🚀 ~ app.use ~ fullUrl:",r);const s=qX(r),o=HX(e,i.subdomain),a=await j4(s,o,r,t,n),{customer:c,cart:l}=await M4(o,t,n);t.locals.render=a,t.locals.customer=c??{},t.locals.cart=l??{},n()})),r.get("*",j(r,{viewsDirectory:p,watch:!0},"development","theme")),Vi("REloading");const t=Vi("Connected"),n=Vi("Budilding");c.on("connection",(e=>{t.stop(),t.start();const i=Qq.watch([p,o.join(u,"tailwind.config.js")]);i.on("change",(()=>{i.close(),t.stop(),n.start(),d.exec(`cd ${u} && npx webpack --config webpack.config.js --mode development --stats errors-warnings`,(t=>{if(t)return console.log(t),void n.fail(Et.red("Build failed"));n.succeed(Et.blue("Rebuilt successfully")),e.emit("reload")}))})),e.on("disconnect",(()=>{i.close()}))})),c.on("disconnect",(()=>{console.log(Et.blue("Disconnected")),t.stop(),reloadSpinner.stop()})),a.listen(s,(()=>{l.succeed("Server Started"),console.log(`Server running at http://localhost:${s}`),NX(`http://localhost:${s}`)}))}))})),$4.command("list").description("List available themes").action((async()=>{const e=Vi("Fetching Data...").start();try{const{data:t}=await af.get("/themes");e.stop();const n=t?.themes?.map((e=>({name:e.title,value:e._id}))),i=await _l.prompt({type:"list",name:"selectedThemeId",message:"Choose the theme you want to use:",choices:n}),r=t?.themes.find((e=>e._id===i.selectedThemeId));console.log("🚀 ~ getThemes ~ selectedTheme:",r)}catch(t){e.stop(),console.error("Failed to fetch data:",t)}}));const H4=process.cwd(),z4=o.join(H4,"src");const W4=new Oe;W4.name("widget").description("dev"),W4.command("dev").description("Run development server with Webpack and BrowserSync").action((async()=>{await yf();const{data:e}=await af.get("/apps"),t=e?.apps?.map((e=>({name:e.subdomain,value:e._id}))),n=await _l.prompt({type:"list",name:"app",message:"Choose the theme you want to use",choices:t});var i=e?.apps?.find((e=>e._id===n.app));const r=Zq(),s=3e3,a=new x.Server(r),c=new RX(a),l=Vi("Start Server").start(),u=process.cwd(),p=o.join(u,"src");o.join(u,"src","assets");const h=o.join(u,"dist");console.log("🚀 ~ initializeServer ~ distPath:",h),d.exec("npx webpack --config webpack.config.js --mode development --stats errors-warnings",(async e=>{e&&console.log(e,"errrrrr");try{await I.access(p),await I.access(h)}catch{console.error("Error: Required directories do not exist."),process.exit(1)}r.use(Zq.static(h)),r.get("/api/auth",((e,t)=>{const{redirect_url:n,token:i}=e.query;if(console.log("🚀 ~ app.get ~ req.query:",e.query),!n||!i)return t.status(400).send("Missing redirect_url or token");t.cookie("token",i,{httpOnly:!1,secure:"production"===process.env.NODE_ENV,expires:new Date(9999,0,1)}),t.redirect(n)})),r.get("/api/auth/logout",((e,t)=>{t.clearCookie("token",{httpOnly:!0,secure:"production"===process.env.NODE_ENV}),t.redirect("/")})),r.get("*",j(r,{viewsDirectory:p,secretKey:i.secretKey,watch:!0},"development","widget")),Vi("REloading");const t=Vi("Connected"),n=Vi("Budilding");c.on("connection",(e=>{t.stop(),t.start();const i=Qq.watch([p,o.join(u,"tailwind.config.js")]);i.on("change",(()=>{i.close(),t.stop(),n.start(),d.exec(`cd ${u} && npx webpack --config webpack.config.js --mode development --stats errors-warnings`,(t=>{if(t)return console.log(t),void n.fail(Et.red("Build failed"));n.succeed(Et.blue("Rebuilt successfully")),e.emit("reload")}))})),e.on("disconnect",(()=>{i.close()}))})),c.on("disconnect",(()=>{console.log(Et.blue("Disconnected")),t.stop(),reloadSpinner.stop()})),a.listen(s,(()=>{l.succeed("Server Started"),console.log("Server running at http://localhost:3000"),NX("http://localhost:3000")}))}))})),W4.command("check").description("Run development server with Webpack and BrowserSync").action((async function(){const e=Vi("Checking files...").start();try{const e=await WR(z4),t=Object.keys(e);console.log("🚀 ~ checkFiles ~ files:",t)}catch(t){e.fail("Failed to retrieve files"),console.error(Et.red(`Failed to retrieve files - Error: ${t.message}`))}}));const G4=Object.create(null);G4.open="0",G4.close="1",G4.ping="2",G4.pong="3",G4.message="4",G4.upgrade="5",G4.noop="6";const V4=Object.create(null);Object.keys(G4).forEach((e=>{V4[G4[e]]=e}));const K4={type:"error",data:"parser error"},Y4=({type:e,data:t},n,i)=>t instanceof ArrayBuffer||ArrayBuffer.isView(t)?i(n?t:"b"+Z4(t,!0).toString("base64")):i(G4[e]+(t||"")),Z4=(e,t)=>Buffer.isBuffer(e)||e instanceof Uint8Array&&!t?e:e instanceof ArrayBuffer?Buffer.from(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength);let Q4;const J4=(e,t)=>{if("string"!=typeof e)return{type:"message",data:X4(e,t)};const n=e.charAt(0);if("b"===n){const n=Buffer.from(e.substring(1),"base64");return{type:"message",data:X4(n,t)}}return V4[n]?e.length>1?{type:V4[n],data:e.substring(1)}:{type:V4[n]}:K4},X4=(e,t)=>"arraybuffer"===t?e instanceof ArrayBuffer?e:Buffer.isBuffer(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e.buffer:Buffer.isBuffer(e)?e:Buffer.from(e),e5=String.fromCharCode(30);function t5(){return new TransformStream({transform(e,t){!function(e,t){if(e.data instanceof ArrayBuffer||ArrayBuffer.isView(e.data))return t(Z4(e.data,!1));Y4(e,!0,(e=>{Q4||(Q4=new TextEncoder),t(Q4.encode(e))}))}(e,(n=>{const i=n.length;let r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,i)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(i))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}})}let n5;function i5(e){return e.reduce(((e,t)=>e+t.length),0)}function r5(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let i=0;for(let r=0;r<t;r++)n[r]=e[0][i++],i===e[0].length&&(e.shift(),i=0);return e.length&&i<e[0].length&&(e[0]=e[0].slice(i)),n}const s5=global;function o5(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const a5=s5.setTimeout,c5=s5.clearTimeout;function l5(e,t){t.useNativeTimers?(e.setTimeoutFn=a5.bind(s5),e.clearTimeoutFn=c5.bind(s5)):(e.setTimeoutFn=s5.setTimeout.bind(s5),e.clearTimeoutFn=s5.clearTimeout.bind(s5))}class u5 extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class p5 extends xJ{constructor(e){super(),this.writable=!1,l5(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new u5(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=J4(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}const h5="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),d5=64,f5={};let m5,g5=0,y5=0;function v5(e){let t="";do{t=h5[e%d5]+t,e=Math.floor(e/d5)}while(e>0);return t}function b5(){const e=v5(+new Date);return e!==m5?(g5=0,m5=e):e+"."+v5(g5++)}for(;y5<d5;y5++)f5[h5[y5]]=y5;
|
|
378
378
|
/**
|
|
379
379
|
* Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.
|
|
380
380
|
*
|