@novu/js 3.7.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/novu.min.js CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";(()=>{var $o=Object.create;var ai=Object.defineProperty,Vo=Object.defineProperties,Ho=Object.getOwnPropertyDescriptor,jo=Object.getOwnPropertyDescriptors,Go=Object.getOwnPropertyNames,oi=Object.getOwnPropertySymbols,Ko=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable;var dn=i=>{throw TypeError(i)},pn=Math.pow,or=(i,e,t)=>e in i?ai(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,v=(i,e)=>{for(var t in e||(e={}))ar.call(e,t)&&or(i,t,e[t]);if(oi)for(var t of oi(e))un.call(e,t)&&or(i,t,e[t]);return i},N=(i,e)=>Vo(i,jo(e));var C=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var cr=(i,e)=>{var t={};for(var r in i)ar.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&oi)for(var r of oi(i))e.indexOf(r)<0&&un.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Yo=(i,e)=>{for(var t in e)ai(i,t,{get:e[t],enumerable:!0})},Jo=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Go(e))!ar.call(i,n)&&n!==t&&ai(i,n,{get:()=>e[n],enumerable:!(r=Ho(e,n))||r.enumerable});return i};var Y=(i,e,t)=>(t=i!=null?$o(Ko(i)):{},Jo(e||!i||!i.__esModule?ai(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>or(i,typeof e!="symbol"?e+"":e,t),lr=(i,e,t)=>e.has(i)||dn("Cannot "+t);var c=(i,e,t)=>(lr(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?dn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(lr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),he=(i,e,t)=>(lr(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=h=>{try{a(t.next(h))}catch(d){n(d)}},o=h=>{try{a(t.throw(h))}catch(d){n(d)}},a=h=>h.done?r(h.value):Promise.resolve(h.value).then(s,o);a((t=t.apply(i,e)).next())});var _r=F((sf,In)=>{"use strict";var pt=1e3,mt=pt*60,gt=mt*60,Je=gt*24,fa=Je*7,ua=Je*365.25;In.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return da(i);if(t==="number"&&isFinite(i))return e.long?ma(i):pa(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function da(i){if(i=String(i),!(i.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return t*ua;case"weeks":case"week":case"w":return t*fa;case"days":case"day":case"d":return t*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return t*gt;case"minutes":case"minute":case"mins":case"min":case"m":return t*mt;case"seconds":case"second":case"secs":case"sec":case"s":return t*pt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function pa(i){var e=Math.abs(i);return e>=Je?Math.round(i/Je)+"d":e>=gt?Math.round(i/gt)+"h":e>=mt?Math.round(i/mt)+"m":e>=pt?Math.round(i/pt)+"s":i+"ms"}function ma(i){var e=Math.abs(i);return e>=Je?Ni(i,e,Je,"day"):e>=gt?Ni(i,e,gt,"hour"):e>=mt?Ni(i,e,mt,"minute"):e>=pt?Ni(i,e,pt,"second"):i+" ms"}function Ni(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var Er=F((of,Pn)=>{"use strict";function ga(i){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=n,t.enabled=o,t.humanize=_r(),t.destroy=d,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let u=0;u<l.length;u++)f=(f<<5)-f+l.charCodeAt(u),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,u=null,E,b;function p(...w){if(!p.enabled)return;let R=p,T=Number(new Date),g=T-(f||T);R.diff=g,R.prev=f,R.curr=T,f=T,w[0]=t.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let y=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(A,M)=>{if(A==="%%")return"%";y++;let q=t.formatters[M];if(typeof q=="function"){let te=w[y];A=q.call(R,te),w.splice(y,1),y--}return A}),t.formatArgs.call(R,w),(R.log||t.log).apply(R,w)}return p.namespace=l,p.useColors=t.useColors(),p.color=t.selectColor(l),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(E!==t.namespaces&&(E=t.namespaces,b=t.enabled(l)),b),set:w=>{u=w}}),typeof t.init=="function"&&t.init(p),p}function r(l,f){let u=t(this.namespace+(typeof f=="undefined"?":":f)+l);return u.log=this.log,u}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,u=(typeof l=="string"?l:"").split(/[\s,]+/),E=u.length;for(f=0;f<E;f++)u[f]&&(l=u[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(a),...t.skips.map(a).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,u;for(f=0,u=t.skips.length;f<u;f++)if(t.skips[f].test(l))return!1;for(f=0,u=t.names.length;f<u;f++)if(t.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Pn.exports=ga});var Ln=F((ne,ki)=>{"use strict";ne.formatArgs=va;ne.save=_a;ne.load=Ea;ne.useColors=ya;ne.storage=Sa();ne.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();ne.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ya(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let i;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(i=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(i[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function va(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+ki.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}ne.log=console.debug||console.log||(()=>{});function _a(i){try{i?ne.storage.setItem("debug",i):ne.storage.removeItem("debug")}catch(e){}}function Ea(){let i;try{i=ne.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Sa(){try{return localStorage}catch(i){}}ki.exports=Er()(ne);var{formatters:wa}=ki.exports;wa.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Un=F((af,Fn)=>{"use strict";Fn.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),n=e.indexOf("--");return r!==-1&&(n===-1||r<n)}});var br=F((cf,Bn)=>{"use strict";var ba=C("os"),Dn=C("tty"),ue=Un(),{env:V}=process,qe;ue("no-color")||ue("no-colors")||ue("color=false")||ue("color=never")?qe=0:(ue("color")||ue("colors")||ue("color=true")||ue("color=always"))&&(qe=1);"FORCE_COLOR"in V&&(V.FORCE_COLOR==="true"?qe=1:V.FORCE_COLOR==="false"?qe=0:qe=V.FORCE_COLOR.length===0?1:Math.min(parseInt(V.FORCE_COLOR,10),3));function Sr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function wr(i,e){if(qe===0)return 0;if(ue("color=16m")||ue("color=full")||ue("color=truecolor"))return 3;if(ue("color=256"))return 2;if(i&&!e&&qe===void 0)return 0;let t=qe||0;if(V.TERM==="dumb")return t;if(process.platform==="win32"){let r=ba.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in V)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in V)||V.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in V)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(V.TEAMCITY_VERSION)?1:0;if(V.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in V){let r=parseInt((V.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(V.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(V.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(V.TERM)||"COLORTERM"in V?1:t}function xa(i){let e=wr(i,i&&i.isTTY);return Sr(e)}Bn.exports={supportsColor:xa,stdout:Sr(wr(!0,Dn.isatty(1))),stderr:Sr(wr(!0,Dn.isatty(2)))}});var qn=F((H,Ri)=>{"use strict";var Ca=C("tty"),Ai=C("util");H.init=Ia;H.log=Ra;H.formatArgs=ka;H.save=Ta;H.load=Oa;H.useColors=Na;H.destroy=Ai.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");H.colors=[6,2,3,4,5,1];try{let i=br();i&&(i.stderr||i).level>=2&&(H.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}H.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function Na(){return"colors"in H.inspectOpts?!!H.inspectOpts.colors:Ca.isatty(process.stderr.fd)}function ka(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
1
+ "use strict";(()=>{var $o=Object.create;var ai=Object.defineProperty,Vo=Object.defineProperties,Ho=Object.getOwnPropertyDescriptor,jo=Object.getOwnPropertyDescriptors,Go=Object.getOwnPropertyNames,oi=Object.getOwnPropertySymbols,Ko=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable;var dn=i=>{throw TypeError(i)},pn=Math.pow,or=(i,e,t)=>e in i?ai(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,v=(i,e)=>{for(var t in e||(e={}))ar.call(e,t)&&or(i,t,e[t]);if(oi)for(var t of oi(e))un.call(e,t)&&or(i,t,e[t]);return i},N=(i,e)=>Vo(i,jo(e));var C=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var cr=(i,e)=>{var t={};for(var r in i)ar.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&oi)for(var r of oi(i))e.indexOf(r)<0&&un.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Yo=(i,e)=>{for(var t in e)ai(i,t,{get:e[t],enumerable:!0})},Jo=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Go(e))!ar.call(i,n)&&n!==t&&ai(i,n,{get:()=>e[n],enumerable:!(r=Ho(e,n))||r.enumerable});return i};var Y=(i,e,t)=>(t=i!=null?$o(Ko(i)):{},Jo(e||!i||!i.__esModule?ai(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>or(i,typeof e!="symbol"?e+"":e,t),lr=(i,e,t)=>e.has(i)||dn("Cannot "+t);var c=(i,e,t)=>(lr(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?dn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(lr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),he=(i,e,t)=>(lr(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=h=>{try{a(t.next(h))}catch(d){n(d)}},o=h=>{try{a(t.throw(h))}catch(d){n(d)}},a=h=>h.done?r(h.value):Promise.resolve(h.value).then(s,o);a((t=t.apply(i,e)).next())});var wr=F((bf,Wn)=>{"use strict";var gt=1e3,yt=gt*60,vt=yt*60,Qe=vt*24,ga=Qe*7,ya=Qe*365.25;Wn.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return va(i);if(t==="number"&&isFinite(i))return e.long?Ea(i):_a(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function va(i){if(i=String(i),!(i.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return t*ya;case"weeks":case"week":case"w":return t*ga;case"days":case"day":case"d":return t*Qe;case"hours":case"hour":case"hrs":case"hr":case"h":return t*vt;case"minutes":case"minute":case"mins":case"min":case"m":return t*yt;case"seconds":case"second":case"secs":case"sec":case"s":return t*gt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function _a(i){var e=Math.abs(i);return e>=Qe?Math.round(i/Qe)+"d":e>=vt?Math.round(i/vt)+"h":e>=yt?Math.round(i/yt)+"m":e>=gt?Math.round(i/gt)+"s":i+"ms"}function Ea(i){var e=Math.abs(i);return e>=Qe?Pi(i,e,Qe,"day"):e>=vt?Pi(i,e,vt,"hour"):e>=yt?Pi(i,e,yt,"minute"):e>=gt?Pi(i,e,gt,"second"):i+" ms"}function Pi(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var br=F((xf,zn)=>{"use strict";function Sa(i){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=n,t.enabled=o,t.humanize=wr(),t.destroy=d,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let u=0;u<l.length;u++)f=(f<<5)-f+l.charCodeAt(u),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,u=null,E,b;function p(...w){if(!p.enabled)return;let R=p,T=Number(new Date),g=T-(f||T);R.diff=g,R.prev=f,R.curr=T,f=T,w[0]=t.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let y=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(A,M)=>{if(A==="%%")return"%";y++;let q=t.formatters[M];if(typeof q=="function"){let te=w[y];A=q.call(R,te),w.splice(y,1),y--}return A}),t.formatArgs.call(R,w),(R.log||t.log).apply(R,w)}return p.namespace=l,p.useColors=t.useColors(),p.color=t.selectColor(l),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(E!==t.namespaces&&(E=t.namespaces,b=t.enabled(l)),b),set:w=>{u=w}}),typeof t.init=="function"&&t.init(p),p}function r(l,f){let u=t(this.namespace+(typeof f=="undefined"?":":f)+l);return u.log=this.log,u}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,u=(typeof l=="string"?l:"").split(/[\s,]+/),E=u.length;for(f=0;f<E;f++)u[f]&&(l=u[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(a),...t.skips.map(a).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,u;for(f=0,u=t.skips.length;f<u;f++)if(t.skips[f].test(l))return!1;for(f=0,u=t.names.length;f<u;f++)if(t.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}zn.exports=Sa});var $n=F((ne,Li)=>{"use strict";ne.formatArgs=ba;ne.save=xa;ne.load=Ca;ne.useColors=wa;ne.storage=Na();ne.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();ne.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function wa(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let i;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(i=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(i[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ba(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Li.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}ne.log=console.debug||console.log||(()=>{});function xa(i){try{i?ne.storage.setItem("debug",i):ne.storage.removeItem("debug")}catch(e){}}function Ca(){let i;try{i=ne.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Na(){try{return localStorage}catch(i){}}Li.exports=br()(ne);var{formatters:ka}=Li.exports;ka.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Hn=F((Cf,Vn)=>{"use strict";Vn.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),n=e.indexOf("--");return r!==-1&&(n===-1||r<n)}});var Nr=F((Nf,Gn)=>{"use strict";var Aa=C("os"),jn=C("tty"),ue=Hn(),{env:V}=process,qe;ue("no-color")||ue("no-colors")||ue("color=false")||ue("color=never")?qe=0:(ue("color")||ue("colors")||ue("color=true")||ue("color=always"))&&(qe=1);"FORCE_COLOR"in V&&(V.FORCE_COLOR==="true"?qe=1:V.FORCE_COLOR==="false"?qe=0:qe=V.FORCE_COLOR.length===0?1:Math.min(parseInt(V.FORCE_COLOR,10),3));function xr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Cr(i,e){if(qe===0)return 0;if(ue("color=16m")||ue("color=full")||ue("color=truecolor"))return 3;if(ue("color=256"))return 2;if(i&&!e&&qe===void 0)return 0;let t=qe||0;if(V.TERM==="dumb")return t;if(process.platform==="win32"){let r=Aa.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in V)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in V)||V.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in V)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(V.TEAMCITY_VERSION)?1:0;if(V.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in V){let r=parseInt((V.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(V.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(V.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(V.TERM)||"COLORTERM"in V?1:t}function Ra(i){let e=Cr(i,i&&i.isTTY);return xr(e)}Gn.exports={supportsColor:Ra,stdout:xr(Cr(!0,jn.isatty(1))),stderr:xr(Cr(!0,jn.isatty(2)))}});var Yn=F((H,Ui)=>{"use strict";var Ta=C("tty"),Fi=C("util");H.init=Da;H.log=La;H.formatArgs=Ia;H.save=Fa;H.load=Ua;H.useColors=Oa;H.destroy=Fi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");H.colors=[6,2,3,4,5,1];try{let i=Nr();i&&(i.stderr||i).level>=2&&(H.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}H.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function Oa(){return"colors"in H.inspectOpts?!!H.inspectOpts.colors:Ta.isatty(process.stderr.fd)}function Ia(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
2
2
  `).join(`
3
- `+s),i.push(n+"m+"+Ri.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Aa()+e+" "+i[0]}function Aa(){return H.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ra(...i){return process.stderr.write(Ai.formatWithOptions(H.inspectOpts,...i)+`
4
- `)}function Ta(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Oa(){return process.env.DEBUG}function Ia(i){i.inspectOpts={};let e=Object.keys(H.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=H.inspectOpts[e[t]]}Ri.exports=Er()(H);var{formatters:Mn}=Ri.exports;Mn.o=function(i){return this.inspectOpts.colors=this.useColors,Ai.inspect(i,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};Mn.O=function(i){return this.inspectOpts.colors=this.useColors,Ai.inspect(i,this.inspectOpts)}});var Xe=F((lf,xr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?xr.exports=Ln():xr.exports=qn()});var Jn=F((yf,Yn)=>{"use strict";var yt=C("fs"),Kn=C("url"),Fa=C("child_process").spawn;Yn.exports=kr;kr.XMLHttpRequest=kr;function kr(i){"use strict";i=i||{};var e=this,t=C("http"),r=C("https"),n,s,o={},a=!1,h={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},d=Object.assign({},h),l=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],f=["TRACE","TRACK","CONNECT"],u=!1,E=!1,b=!1,p={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var w=function(g){return a||g&&l.indexOf(g.toLowerCase())===-1},R=function(g){return g&&f.indexOf(g)===-1};this.open=function(g,y,I,A,M){if(this.abort(),E=!1,b=!1,!R(g))throw new Error("SecurityError: Request method not allowed");o={method:g,url:y.toString(),async:typeof I!="boolean"?!0:I,user:A||null,password:M||null},T(this.OPENED)},this.setDisableHeaderCheck=function(g){a=g},this.setRequestHeader=function(g,y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!w(g))return console.warn('Refused to set unsafe header "'+g+'"'),!1;if(u)throw new Error("INVALID_STATE_ERR: send flag is true");return d[g]=y,!0},this.getResponseHeader=function(g){return typeof g=="string"&&this.readyState>this.OPENED&&s.headers[g.toLowerCase()]&&!E?s.headers[g.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||E)return"";var g="";for(var y in s.headers)y!=="set-cookie"&&y!=="set-cookie2"&&(g+=y+": "+s.headers[y]+`\r
6
- `);return g.substr(0,g.length-2)},this.getRequestHeader=function(g){return typeof g=="string"&&d[g]?d[g]:""},this.send=function(g){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(u)throw new Error("INVALID_STATE_ERR: send has already been called");var y=!1,I=!1,A=Kn.parse(o.url),M;switch(A.protocol){case"https:":y=!0;case"http:":M=A.hostname;break;case"file:":I=!0;break;case void 0:case"":M="localhost";break;default:throw new Error("Protocol not supported.")}if(I){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)yt.readFile(unescape(A.pathname),"utf8",function(le,ot){le?e.handleError(le,le.errno||-1):(e.status=200,e.responseText=ot,T(e.DONE))});else try{this.responseText=yt.readFileSync(unescape(A.pathname),"utf8"),this.status=200,T(e.DONE)}catch(le){this.handleError(le,le.errno||-1)}return}var q=A.port||(y?443:80),te=A.pathname+(A.search?A.search:"");if(d.Host=M,y&&q===443||q===80||(d.Host+=":"+A.port),o.user){typeof o.password=="undefined"&&(o.password="");var je=new Buffer(o.user+":"+o.password);d.Authorization="Basic "+je.toString("base64")}o.method==="GET"||o.method==="HEAD"?g=null:g?(d["Content-Length"]=Buffer.isBuffer(g)?g.length:Buffer.byteLength(g),d["Content-Type"]||(d["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(d["Content-Length"]=0);var Ge=i.agent||!1,X={host:M,port:q,path:te,method:o.method,headers:d,agent:Ge};if(y&&(X.pfx=i.pfx,X.key=i.key,X.passphrase=i.passphrase,X.cert=i.cert,X.ca=i.ca,X.ciphers=i.ciphers,X.rejectUnauthorized=i.rejectUnauthorized!==!1),E=!1,o.async){var Le=y?r.request:t.request;u=!0,e.dispatchEvent("readystatechange");var Fe=function(le){if(s=le,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var ot=Kn.parse(o.url);M=ot.hostname;var De={hostname:ot.hostname,port:ot.port,path:ot.path,method:s.statusCode===303?"GET":o.method,headers:d};y&&(De.pfx=i.pfx,De.key=i.key,De.passphrase=i.passphrase,De.cert=i.cert,De.ca=i.ca,De.ciphers=i.ciphers,De.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Le(De,Fe).on("error",Ue),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),T(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(si){si&&(e.responseText+=si),u&&T(e.LOADING)}),s.on("end",function(){u&&(u=!1,T(e.DONE))}),s.on("error",function(si){e.handleError(si)})},Ue=function(le){e.handleError(le)};n=Le(X,Fe).on("error",Ue),i.autoUnref&&n.on("socket",le=>{le.unref()}),g&&n.write(g),n.end(),e.dispatchEvent("loadstart")}else{var ie=".node-xmlhttprequest-content-"+process.pid,At=".node-xmlhttprequest-sync-"+process.pid;yt.writeFileSync(At,"","utf8");for(var qo="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(y?"s":"")+".request;var options = "+JSON.stringify(X)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+ie+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+At+"');});response.on('error', function(error) {fs.writeFileSync('"+ie+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+At+"');});}).on('error', function(error) {fs.writeFileSync('"+ie+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+At+"');});"+(g?"req.write('"+JSON.stringify(g).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Wo=Fa(process.argv[0],["-e",qo]),Fl;yt.existsSync(At););if(e.responseText=yt.readFileSync(ie,"utf8"),Wo.stdin.end(),yt.unlinkSync(ie),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var zo=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(zo,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),T(e.DONE)}},this.handleError=function(g,y){this.status=y||0,this.statusText=g,this.responseText=g.stack,E=!0,T(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),d=Object.assign({},h),this.responseText="",this.responseXML="",E=b=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||u)&&this.readyState!==this.DONE&&(u=!1,T(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(g,y){g in p||(p[g]=[]),p[g].push(y)},this.removeEventListener=function(g,y){g in p&&(p[g]=p[g].filter(function(I){return I!==y}))},this.dispatchEvent=function(g){if(typeof e["on"+g]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+g]()}):e["on"+g]()),g in p)for(let y=0,I=p[g].length;y<I;y++)this.readyState===this.DONE?setImmediate(function(){p[g][y].call(e)}):p[g][y].call(e)};var T=function(g){if(!(e.readyState===g||e.readyState===e.UNSENT&&b)&&(e.readyState=g,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let y;b?y="abort":E?y="error":y="load",e.dispatchEvent(y),e.dispatchEvent("loadend")}}}});var rs=F((kf,is)=>{"use strict";var{Duplex:Ma}=C("stream");function es(i){i.emit("close")}function qa(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ts(i){this.removeListener("error",ts),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Wa(i,e){let t=!0,r=new Ma(N(v({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let a=!o&&r._readableState.objectMode?s.toString():s;r.push(a)||i.pause()}),i.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(n,s){if(i.readyState===i.CLOSED){s(n),process.nextTick(es,r);return}let o=!1;i.once("error",function(h){o=!0,s(h)}),i.once("close",function(){o||s(n),process.nextTick(es,r)}),t&&i.terminate()},r._final=function(n){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(n)});return}i._socket!==null&&(i._socket._writableState.finished?(n(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){n()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(n,s,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(n,s,o)});return}i.send(n,o)},r.on("end",qa),r.on("error",ts),r}is.exports=Wa});var ze=F((Rf,ns)=>{"use strict";ns.exports={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:()=>{}}});var qt=F((Tf,Pi)=>{"use strict";var{EMPTY_BUFFER:za}=ze();function $a(i,e){if(i.length===0)return za;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let n=0;n<i.length;n++){let s=i[n];t.set(s,r),r+=s.length}return r<e?t.slice(0,r):t}function ss(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function os(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Va(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Or(i){if(Or.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=Buffer.from(i):ArrayBuffer.isView(i)?e=Buffer.from(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),Or.readOnly=!1),e}Pi.exports={concat:$a,mask:ss,toArrayBuffer:Va,toBuffer:Or,unmask:os};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=C("bufferutil");Pi.exports.mask=function(e,t,r,n,s){s<48?ss(e,t,r,n,s):i.mask(e,t,r,n,s)},Pi.exports.unmask=function(e,t){e.length<32?os(e,t):i.unmask(e,t)}}catch(i){}});var ls=F((Of,cs)=>{"use strict";var as=Symbol("kDone"),Ir=Symbol("kRun"),Pr=class{constructor(e){this[as]=()=>{this.pending--,this[Ir]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ir]()}[Ir](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[as])}}};cs.exports=Pr});var $t=F((If,ds)=>{"use strict";var Wt=C("zlib"),hs=qt(),Ha=ls(),{kStatusCode:fs}=ze(),ja=Buffer.from([0,0,255,255]),Ui=Symbol("permessage-deflate"),Te=Symbol("total-length"),zt=Symbol("callback"),$e=Symbol("buffers"),Fi=Symbol("error"),Li,Lr=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Li){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Li=new Ha(n)}}static get extensionName(){return"permessage-deflate"}offer(){let 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:this._options.clientMaxWindowBits==null&&(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){let e=this._deflate[zt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(n=>!(t.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>n.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!n.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let n=t[r];if(n.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(n=n[0],r==="client_max_window_bits"){if(n!==!0){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else if(r==="server_max_window_bits"){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=n})}),e}decompress(e,t,r){Li.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Li.add(n=>{this._compress(e,t,(s,o)=>{n(),r(s,o)})})}_decompress(e,t,r){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Wt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Wt.createInflateRaw(N(v({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Ui]=this,this._inflate[Te]=0,this._inflate[$e]=[],this._inflate.on("error",Ka),this._inflate.on("data",us)}this._inflate[zt]=r,this._inflate.write(e),t&&this._inflate.write(ja),this._inflate.flush(()=>{let s=this._inflate[Fi];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=hs.concat(this._inflate[$e],this._inflate[Te]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Te]=0,this._inflate[$e]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Wt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Wt.createDeflateRaw(N(v({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Te]=0,this._deflate[$e]=[],this._deflate.on("data",Ga)}this._deflate[zt]=r,this._deflate.write(e),this._deflate.flush(Wt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=hs.concat(this._deflate[$e],this._deflate[Te]);t&&(s=s.slice(0,s.length-4)),this._deflate[zt]=null,this._deflate[Te]=0,this._deflate[$e]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};ds.exports=Lr;function Ga(i){this[$e].push(i),this[Te]+=i.length}function us(i){if(this[Te]+=i.length,this[Ui]._maxPayload<1||this[Te]<=this[Ui]._maxPayload){this[$e].push(i);return}this[Fi]=new RangeError("Max payload size exceeded"),this[Fi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Fi][fs]=1009,this.removeListener("data",us),this.reset()}function Ka(i){this[Ui]._inflate=null,i[fs]=1007,this[zt](i)}});var Vt=F((Lf,Fr)=>{"use strict";var Ya=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Ja(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function ps(i){let e=i.length,t=0;for(;t<e;)if(!(i[t]&128))t++;else if((i[t]&224)===192){if(t+1===e||(i[t+1]&192)!==128||(i[t]&254)===192)return!1;t+=2}else if((i[t]&240)===224){if(t+2>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||i[t]===224&&(i[t+1]&224)===128||i[t]===237&&(i[t+1]&224)===160)return!1;t+=3}else if((i[t]&248)===240){if(t+3>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||(i[t+3]&192)!==128||i[t]===240&&(i[t+1]&240)===128||i[t]===244&&i[t+1]>143||i[t]>244)return!1;t+=4}else return!1;return!0}Fr.exports={isValidStatusCode:Ja,isValidUTF8:ps,tokenChars:Ya};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=C("utf-8-validate");Fr.exports.isValidUTF8=function(e){return e.length<150?ps(e):i(e)}}catch(i){}});var Mr=F((Ff,Ss)=>{"use strict";var{Writable:Xa}=C("stream"),ms=$t(),{BINARY_TYPES:Qa,EMPTY_BUFFER:gs,kStatusCode:Za,kWebSocket:ec}=ze(),{concat:Ur,toArrayBuffer:tc,unmask:ic}=qt(),{isValidStatusCode:rc,isValidUTF8:ys}=Vt(),Ht=0,vs=1,_s=2,Es=3,Dr=4,nc=5,Br=class extends Xa{constructor(e={}){super(),this._binaryType=e.binaryType||Qa[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ec]=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._state=Ht,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Ht)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=r.slice(e),r.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case Ht:t=this.getInfo();break;case vs:t=this.getPayloadLength16();break;case _s:t=this.getPayloadLength64();break;case Es:this.getMask();break;case Dr:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,W(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[ms.extensionName])return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,W(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,W(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,W(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,W(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,W(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,W(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,W(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=vs;else if(this._payloadLength===127)this._state=_s;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,W(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Es:this._state=Dr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Dr}getData(e){let t=gs;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&ic(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=nc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[ms.extensionName].decompress(e,this._fin,(n,s)=>{if(n)return t(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=Ur(t,e):this._binaryType==="arraybuffer"?r=tc(Ur(t,e)):r=t,this.emit("message",r,!0)}else{let r=Ur(t,e);if(!this._skipUTF8Validation&&!ys(r))return this._loop=!1,W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=Ht}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,gs),this.end();else{if(e.length===1)return W(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!rc(t))return W(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!ys(r))return W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=Ht}};Ss.exports=Br;function W(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,W),s.code=n,s[Za]=r,s}});var Wr=F((Bf,xs)=>{"use strict";var Uf=C("net"),Df=C("tls"),{randomFillSync:sc}=C("crypto"),ws=$t(),{EMPTY_BUFFER:oc}=ze(),{isValidStatusCode:ac}=Vt(),{mask:bs,toBuffer:vt}=qt(),ge=Symbol("kByteLength"),cc=Buffer.alloc(4),qr=class i{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,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 r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||cc,t.generateMask?t.generateMask(r):sc(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!t.mask||o)&&t[ge]!==void 0?a=t[ge]:(e=Buffer.from(e),a=e.length):(a=e.length,n=t.mask&&t.readOnly&&!o);let h=a;a>=65536?(s+=8,h=127):a>125&&(s+=2,h=126);let d=Buffer.allocUnsafe(n?a+s:s);return d[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(d[0]|=64),d[1]=h,h===126?d.writeUInt16BE(a,2):h===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),t.mask?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=r[2],d[s-1]=r[3],o?[d,e]:n?(bs(e,r,d,s,a),[d]):(bs(e,r,e,0,a),[d,e])):[d,e]}close(e,t,r,n){let s;if(e===void 0)s=oc;else{if(typeof e!="number"||!ac(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let o={[ge]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,n]):this.sendFrame(i.frame(s,o),n)}ping(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=vt(e),n=e.length,s=vt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ge]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=vt(e),n=e.length,s=vt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ge]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[ws.extensionName],s=t.binary?2:1,o=t.compress,a,h;if(typeof e=="string"?(a=Buffer.byteLength(e),h=!1):(e=vt(e),a=e.length,h=vt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let d={[ge]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:h,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,d,r]):this.dispatch(e,this._compress,d,r)}else this.sendFrame(i.frame(e,{[ge]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:h,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[ws.extensionName];this._bufferedBytes+=r[ge],this._deflating=!0,s.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(h);for(let d=0;d<this._queue.length;d++){let l=this._queue[d],f=l[l.length-1];typeof f=="function"&&f(h)}return}this._bufferedBytes-=r[ge],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(a,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ge],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ge],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};xs.exports=qr});var Ps=F((Mf,Is)=>{"use strict";var{kForOnEventAttribute:jt,kListener:zr}=ze(),Cs=Symbol("kCode"),Ns=Symbol("kData"),ks=Symbol("kError"),As=Symbol("kMessage"),Rs=Symbol("kReason"),_t=Symbol("kTarget"),Ts=Symbol("kType"),Os=Symbol("kWasClean"),Oe=class{constructor(e){this[_t]=null,this[Ts]=e}get target(){return this[_t]}get type(){return this[Ts]}};Object.defineProperty(Oe.prototype,"target",{enumerable:!0});Object.defineProperty(Oe.prototype,"type",{enumerable:!0});var Qe=class extends Oe{constructor(e,t={}){super(e),this[Cs]=t.code===void 0?0:t.code,this[Rs]=t.reason===void 0?"":t.reason,this[Os]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Cs]}get reason(){return this[Rs]}get wasClean(){return this[Os]}};Object.defineProperty(Qe.prototype,"code",{enumerable:!0});Object.defineProperty(Qe.prototype,"reason",{enumerable:!0});Object.defineProperty(Qe.prototype,"wasClean",{enumerable:!0});var Et=class extends Oe{constructor(e,t={}){super(e),this[ks]=t.error===void 0?null:t.error,this[As]=t.message===void 0?"":t.message}get error(){return this[ks]}get message(){return this[As]}};Object.defineProperty(Et.prototype,"error",{enumerable:!0});Object.defineProperty(Et.prototype,"message",{enumerable:!0});var Gt=class extends Oe{constructor(e,t={}){super(e),this[Ns]=t.data===void 0?null:t.data}get data(){return this[Ns]}};Object.defineProperty(Gt.prototype,"data",{enumerable:!0});var lc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[jt]&&n[zr]===e&&!n[jt])return;let r;if(i==="message")r=function(s,o){let a=new Gt("message",{data:o?s:s.toString()});a[_t]=this,Di(e,this,a)};else if(i==="close")r=function(s,o){let a=new Qe("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[_t]=this,Di(e,this,a)};else if(i==="error")r=function(s){let o=new Et("error",{error:s,message:s.message});o[_t]=this,Di(e,this,o)};else if(i==="open")r=function(){let s=new Oe("open");s[_t]=this,Di(e,this,s)};else return;r[jt]=!!t[jt],r[zr]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[zr]===e&&!t[jt]){this.removeListener(i,t);break}}};Is.exports={CloseEvent:Qe,ErrorEvent:Et,Event:Oe,EventTarget:lc,MessageEvent:Gt};function Di(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var $r=F((qf,Ls)=>{"use strict";var{tokenChars:Kt}=Vt();function we(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function hc(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,a,h=-1,d=-1,l=-1,f=0;for(;f<i.length;f++)if(d=i.charCodeAt(f),o===void 0)if(l===-1&&Kt[d]===1)h===-1&&(h=f);else if(f!==0&&(d===32||d===9))l===-1&&h!==-1&&(l=f);else if(d===59||d===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let E=i.slice(h,l);d===44?(we(e,E,t),t=Object.create(null)):o=E,h=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)if(l===-1&&Kt[d]===1)h===-1&&(h=f);else if(d===32||d===9)l===-1&&h!==-1&&(l=f);else if(d===59||d===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),we(t,i.slice(h,l),!0),d===44&&(we(e,o,t),t=Object.create(null),o=void 0),h=l=-1}else if(d===61&&h!==-1&&l===-1)a=i.slice(h,f),h=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(Kt[d]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1?h=f:r||(r=!0),n=!1}else if(s)if(Kt[d]===1)h===-1&&(h=f);else if(d===34&&h!==-1)s=!1,l=f;else if(d===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(d===34&&i.charCodeAt(f-1)===61)s=!0;else if(l===-1&&Kt[d]===1)h===-1&&(h=f);else if(h!==-1&&(d===32||d===9))l===-1&&(l=f);else if(d===59||d===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let E=i.slice(h,l);r&&(E=E.replace(/\\/g,""),r=!1),we(t,a,E),d===44&&(we(e,o,t),t=Object.create(null),o=void 0),a=void 0,h=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(h===-1||s||d===32||d===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let u=i.slice(h,l);return o===void 0?we(e,u,t):(a===void 0?we(t,u,!0):r?we(t,a,u.replace(/\\/g,"")):we(t,a,u),we(e,o,t)),e}function fc(i){return Object.keys(i).map(e=>{let t=i[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(n=>{let s=r[n];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?n:`${n}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ls.exports={format:fc,parse:hc}});var Kr=F((zf,Hs)=>{"use strict";var uc=C("events"),dc=C("https"),pc=C("http"),Ds=C("net"),mc=C("tls"),{randomBytes:gc,createHash:yc}=C("crypto"),{Readable:Wf}=C("stream"),{URL:Vr}=C("url"),Ve=$t(),vc=Mr(),_c=Wr(),{BINARY_TYPES:Fs,EMPTY_BUFFER:Bi,GUID:Ec,kForOnEventAttribute:Hr,kListener:Sc,kStatusCode:wc,kWebSocket:J,NOOP:Bs}=ze(),{EventTarget:{addEventListener:bc,removeEventListener:xc}}=Ps(),{format:Cc,parse:Nc}=$r(),{toBuffer:kc}=qt(),Ac=30*1e3,Ms=Symbol("kAborted"),jr=[8,13],Ie=["CONNECTING","OPEN","CLOSING","CLOSED"],Rc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,B=class i extends uc{constructor(e,t,r){super(),this._binaryType=Fs[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bi,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=i.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),qs(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Fs.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let n=new vc({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new _c(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[J]=this,e[J]=this,n.on("conclude",Ic),n.on("drain",Pc),n.on("error",Lc),n.on("message",Fc),n.on("ping",Uc),n.on("pong",Dc),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",zs),e.on("data",qi),e.on("end",$s),e.on("error",Vs),this._readyState=i.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ve.extensionName]&&this._extensions[Ve.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return se(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===i.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=i.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),Ac)}}pause(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Gr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Bi,t,r)}pong(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Gr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Bi,t,r)}resume(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Gr(this,e,r);return}let n=v({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Ve.extensionName]||(n.compress=!1),this._sender.send(e||Bi,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return se(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(B,"CONNECTING",{enumerable:!0,value:Ie.indexOf("CONNECTING")});Object.defineProperty(B.prototype,"CONNECTING",{enumerable:!0,value:Ie.indexOf("CONNECTING")});Object.defineProperty(B,"OPEN",{enumerable:!0,value:Ie.indexOf("OPEN")});Object.defineProperty(B.prototype,"OPEN",{enumerable:!0,value:Ie.indexOf("OPEN")});Object.defineProperty(B,"CLOSING",{enumerable:!0,value:Ie.indexOf("CLOSING")});Object.defineProperty(B.prototype,"CLOSING",{enumerable:!0,value:Ie.indexOf("CLOSING")});Object.defineProperty(B,"CLOSED",{enumerable:!0,value:Ie.indexOf("CLOSED")});Object.defineProperty(B.prototype,"CLOSED",{enumerable:!0,value:Ie.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(B.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(B.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Hr])return e[Sc];return null},set(e){for(let t of this.listeners(i))if(t[Hr]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Hr]:!0})}})});B.prototype.addEventListener=bc;B.prototype.removeEventListener=xc;Hs.exports=B;function qs(i,e,t,r){let n=N(v({protocolVersion:jr[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(!jr.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${jr.join(", ")})`);let s;if(e instanceof Vr)s=e,i._url=e.href;else{try{s=new Vr(e)}catch(p){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",a=s.protocol==="ws+unix:",h;if(s.protocol!=="ws:"&&!o&&!a?h=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!s.pathname?h="The URL's pathname is empty":s.hash&&(h="The URL contains a fragment identifier"),h){let p=new SyntaxError(h);if(i._redirects===0)throw p;Mi(i,p);return}let d=o?443:80,l=gc(16).toString("base64"),f=o?dc.request:pc.request,u=new Set,E;if(n.createConnection=o?Oc:Tc,n.defaultPort=n.defaultPort||d,n.port=s.port||d,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=N(v({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(E=new Ve(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Cc({[Ve.extensionName]:E.offer()})),t.length){for(let p of t){if(typeof p!="string"||!Rc.test(p)||u.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");u.add(p)}n.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),a){let p=n.path.split(":");n.socketPath=p[0],n.path=p[1]}let b;if(n.followRedirects){if(i._redirects===0){i._originalIpc=a,i._originalSecure=o,i._originalHostOrSocketPath=a?n.socketPath:s.host;let p=r&&r.headers;if(r=N(v({},r),{headers:{}}),p)for(let[w,R]of Object.entries(p))r.headers[w.toLowerCase()]=R}else if(i.listenerCount("redirect")===0){let p=a?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!p||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,p||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),b=i._req=f(n),i._redirects&&i.emit("redirect",i.url,b)}else b=i._req=f(n);n.timeout&&b.on("timeout",()=>{se(i,b,"Opening handshake has timed out")}),b.on("error",p=>{b===null||b[Ms]||(b=i._req=null,Mi(i,p))}),b.on("response",p=>{let w=p.headers.location,R=p.statusCode;if(w&&n.followRedirects&&R>=300&&R<400){if(++i._redirects>n.maxRedirects){se(i,b,"Maximum redirects exceeded");return}b.abort();let T;try{T=new Vr(w,e)}catch(g){let y=new SyntaxError(`Invalid URL: ${w}`);Mi(i,y);return}qs(i,T,t,r)}else i.emit("unexpected-response",b,p)||se(i,b,`Unexpected server response: ${p.statusCode}`)}),b.on("upgrade",(p,w,R)=>{if(i.emit("upgrade",p),i.readyState!==B.CONNECTING)return;if(b=i._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){se(i,w,"Invalid Upgrade header");return}let T=yc("sha1").update(l+Ec).digest("base64");if(p.headers["sec-websocket-accept"]!==T){se(i,w,"Invalid Sec-WebSocket-Accept header");return}let g=p.headers["sec-websocket-protocol"],y;if(g!==void 0?u.size?u.has(g)||(y="Server sent an invalid subprotocol"):y="Server sent a subprotocol but none was requested":u.size&&(y="Server sent no subprotocol"),y){se(i,w,y);return}g&&(i._protocol=g);let I=p.headers["sec-websocket-extensions"];if(I!==void 0){if(!E){se(i,w,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let A;try{A=Nc(I)}catch(q){se(i,w,"Invalid Sec-WebSocket-Extensions header");return}let M=Object.keys(A);if(M.length!==1||M[0]!==Ve.extensionName){se(i,w,"Server indicated an extension that was not requested");return}try{E.accept(A[Ve.extensionName])}catch(q){se(i,w,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[Ve.extensionName]=E}i.setSocket(w,R,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),b.end()}function Mi(i,e){i._readyState=B.CLOSING,i.emit("error",e),i.emitClose()}function Tc(i){return i.path=i.socketPath,Ds.connect(i)}function Oc(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Ds.isIP(i.host)?"":i.host),mc.connect(i)}function se(i,e,t){i._readyState=B.CLOSING;let r=new Error(t);Error.captureStackTrace(r,se),e.setHeader?(e[Ms]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Mi,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function Gr(i,e,t){if(e){let r=kc(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Ie[i.readyState]})`);t(r)}}function Ic(i,e){let t=this[J];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[J]!==void 0&&(t._socket.removeListener("data",qi),process.nextTick(Ws,t._socket),i===1005?t.close():t.close(i,e))}function Pc(){let i=this[J];i.isPaused||i._socket.resume()}function Lc(i){let e=this[J];e._socket[J]!==void 0&&(e._socket.removeListener("data",qi),process.nextTick(Ws,e._socket),e.close(i[wc])),e.emit("error",i)}function Us(){this[J].emitClose()}function Fc(i,e){this[J].emit("message",i,e)}function Uc(i){let e=this[J];e.pong(i,!e._isServer,Bs),e.emit("ping",i)}function Dc(i){this[J].emit("pong",i)}function Ws(i){i.resume()}function zs(){let i=this[J];this.removeListener("close",zs),this.removeListener("data",qi),this.removeListener("end",$s),i._readyState=B.CLOSING;let e;!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&(e=i._socket.read())!==null&&i._receiver.write(e),i._receiver.end(),this[J]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",Us),i._receiver.on("finish",Us))}function qi(i){this[J]._receiver.write(i)||this.pause()}function $s(){let i=this[J];i._readyState=B.CLOSING,i._receiver.end(),this.end()}function Vs(){let i=this[J];this.removeListener("error",Vs),this.on("error",Bs),i&&(i._readyState=B.CLOSING,this.destroy())}});var Gs=F((Vf,js)=>{"use strict";var{tokenChars:Bc}=Vt();function Mc(i){let e=new Set,t=-1,r=-1,n=0;for(n;n<i.length;n++){let o=i.charCodeAt(n);if(r===-1&&Bc[o]===1)t===-1&&(t=n);else if(n!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=n);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${n}`);r===-1&&(r=n);let a=i.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${n}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=i.slice(t,n);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}js.exports={parse:Mc}});var eo=F((Kf,Zs)=>{"use strict";var qc=C("events"),Wi=C("http"),Hf=C("https"),jf=C("net"),Gf=C("tls"),{createHash:Wc}=C("crypto"),Ks=$r(),Ze=$t(),zc=Gs(),$c=Kr(),{GUID:Vc,kWebSocket:Hc}=ze(),jc=/^[+/0-9A-Za-z]{22}==$/,Ys=0,Js=1,Qs=2,Yr=class extends qc{constructor(e,t){if(super(),e=v({maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:$c},e),e.port==null&&!e.server&&!e.noServer||e.port!=null&&(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(e.port!=null?(this._server=Wi.createServer((r,n)=>{let s=Wi.STATUS_CODES[426];n.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),n.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=Gc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,s,o)=>{this.handleUpgrade(n,s,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Ys}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(this._state===Qs){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Yt,this);return}if(e&&this.once("close",e),this._state!==Js)if(this._state=Js,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(Yt,this):process.nextTick(Yt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Yt(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,n){t.on("error",Xs);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){et(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){et(this,e,t,400,"Invalid Upgrade header");return}if(!s||!jc.test(s)){et(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){et(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Jt(t,400);return}let a=e.headers["sec-websocket-protocol"],h=new Set;if(a!==void 0)try{h=zc.parse(a)}catch(f){et(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&d!==void 0){let f=new Ze(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=Ks.parse(d);u[Ze.extensionName]&&(f.accept(u[Ze.extensionName]),l[Ze.extensionName]=f)}catch(u){et(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(u,E,b,p)=>{if(!u)return Jt(t,E||401,b,p);this.completeUpgrade(l,s,h,e,t,r,n)});return}if(!this.options.verifyClient(f))return Jt(t,401)}this.completeUpgrade(l,s,h,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,a){if(!s.readable||!s.writable)return s.destroy();if(s[Hc])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ys)return Jt(s,503);let d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Wc("sha1").update(t+Vc).digest("base64")}`],l=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(d.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[Ze.extensionName]){let f=e[Ze.extensionName].params,u=Ks.format({[Ze.extensionName]:[f]});d.push(`Sec-WebSocket-Extensions: ${u}`),l._extensions=e}this.emit("headers",d,n),s.write(d.concat(`\r
3
+ `+s),i.push(n+"m+"+Ui.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Pa()+e+" "+i[0]}function Pa(){return H.inspectOpts.hideDate?"":new Date().toISOString()+" "}function La(...i){return process.stderr.write(Fi.formatWithOptions(H.inspectOpts,...i)+`
4
+ `)}function Fa(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Ua(){return process.env.DEBUG}function Da(i){i.inspectOpts={};let e=Object.keys(H.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=H.inspectOpts[e[t]]}Ui.exports=br()(H);var{formatters:Kn}=Ui.exports;Kn.o=function(i){return this.inspectOpts.colors=this.useColors,Fi.inspect(i,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(" ")};Kn.O=function(i){return this.inspectOpts.colors=this.useColors,Fi.inspect(i,this.inspectOpts)}});var Ze=F((kf,kr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?kr.exports=$n():kr.exports=Yn()});var ss=F((Ff,ns)=>{"use strict";var _t=C("fs"),rs=C("url"),qa=C("child_process").spawn;ns.exports=Tr;Tr.XMLHttpRequest=Tr;function Tr(i){"use strict";i=i||{};var e=this,t=C("http"),r=C("https"),n,s,o={},a=!1,h={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},d=Object.assign({},h),l=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],f=["TRACE","TRACK","CONNECT"],u=!1,E=!1,b=!1,p={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var w=function(g){return a||g&&l.indexOf(g.toLowerCase())===-1},R=function(g){return g&&f.indexOf(g)===-1};this.open=function(g,y,I,A,M){if(this.abort(),E=!1,b=!1,!R(g))throw new Error("SecurityError: Request method not allowed");o={method:g,url:y.toString(),async:typeof I!="boolean"?!0:I,user:A||null,password:M||null},T(this.OPENED)},this.setDisableHeaderCheck=function(g){a=g},this.setRequestHeader=function(g,y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!w(g))return console.warn('Refused to set unsafe header "'+g+'"'),!1;if(u)throw new Error("INVALID_STATE_ERR: send flag is true");return d[g]=y,!0},this.getResponseHeader=function(g){return typeof g=="string"&&this.readyState>this.OPENED&&s.headers[g.toLowerCase()]&&!E?s.headers[g.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||E)return"";var g="";for(var y in s.headers)y!=="set-cookie"&&y!=="set-cookie2"&&(g+=y+": "+s.headers[y]+`\r
6
+ `);return g.substr(0,g.length-2)},this.getRequestHeader=function(g){return typeof g=="string"&&d[g]?d[g]:""},this.send=function(g){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(u)throw new Error("INVALID_STATE_ERR: send has already been called");var y=!1,I=!1,A=rs.parse(o.url),M;switch(A.protocol){case"https:":y=!0;case"http:":M=A.hostname;break;case"file:":I=!0;break;case void 0:case"":M="localhost";break;default:throw new Error("Protocol not supported.")}if(I){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)_t.readFile(unescape(A.pathname),"utf8",function(le,ot){le?e.handleError(le,le.errno||-1):(e.status=200,e.responseText=ot,T(e.DONE))});else try{this.responseText=_t.readFileSync(unescape(A.pathname),"utf8"),this.status=200,T(e.DONE)}catch(le){this.handleError(le,le.errno||-1)}return}var q=A.port||(y?443:80),te=A.pathname+(A.search?A.search:"");if(d.Host=M,y&&q===443||q===80||(d.Host+=":"+A.port),o.user){typeof o.password=="undefined"&&(o.password="");var je=new Buffer(o.user+":"+o.password);d.Authorization="Basic "+je.toString("base64")}o.method==="GET"||o.method==="HEAD"?g=null:g?(d["Content-Length"]=Buffer.isBuffer(g)?g.length:Buffer.byteLength(g),d["Content-Type"]||(d["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(d["Content-Length"]=0);var Ge=i.agent||!1,X={host:M,port:q,path:te,method:o.method,headers:d,agent:Ge};if(y&&(X.pfx=i.pfx,X.key=i.key,X.passphrase=i.passphrase,X.cert=i.cert,X.ca=i.ca,X.ciphers=i.ciphers,X.rejectUnauthorized=i.rejectUnauthorized!==!1),E=!1,o.async){var Le=y?r.request:t.request;u=!0,e.dispatchEvent("readystatechange");var Fe=function(le){if(s=le,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var ot=rs.parse(o.url);M=ot.hostname;var De={hostname:ot.hostname,port:ot.port,path:ot.path,method:s.statusCode===303?"GET":o.method,headers:d};y&&(De.pfx=i.pfx,De.key=i.key,De.passphrase=i.passphrase,De.cert=i.cert,De.ca=i.ca,De.ciphers=i.ciphers,De.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Le(De,Fe).on("error",Ue),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),T(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(si){si&&(e.responseText+=si),u&&T(e.LOADING)}),s.on("end",function(){u&&(u=!1,T(e.DONE))}),s.on("error",function(si){e.handleError(si)})},Ue=function(le){e.handleError(le)};n=Le(X,Fe).on("error",Ue),i.autoUnref&&n.on("socket",le=>{le.unref()}),g&&n.write(g),n.end(),e.dispatchEvent("loadstart")}else{var ie=".node-xmlhttprequest-content-"+process.pid,At=".node-xmlhttprequest-sync-"+process.pid;_t.writeFileSync(At,"","utf8");for(var qo="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(y?"s":"")+".request;var options = "+JSON.stringify(X)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+ie+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+At+"');});response.on('error', function(error) {fs.writeFileSync('"+ie+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+At+"');});}).on('error', function(error) {fs.writeFileSync('"+ie+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+At+"');});"+(g?"req.write('"+JSON.stringify(g).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Wo=qa(process.argv[0],["-e",qo]),Fl;_t.existsSync(At););if(e.responseText=_t.readFileSync(ie,"utf8"),Wo.stdin.end(),_t.unlinkSync(ie),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var zo=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(zo,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),T(e.DONE)}},this.handleError=function(g,y){this.status=y||0,this.statusText=g,this.responseText=g.stack,E=!0,T(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),d=Object.assign({},h),this.responseText="",this.responseXML="",E=b=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||u)&&this.readyState!==this.DONE&&(u=!1,T(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(g,y){g in p||(p[g]=[]),p[g].push(y)},this.removeEventListener=function(g,y){g in p&&(p[g]=p[g].filter(function(I){return I!==y}))},this.dispatchEvent=function(g){if(typeof e["on"+g]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+g]()}):e["on"+g]()),g in p)for(let y=0,I=p[g].length;y<I;y++)this.readyState===this.DONE?setImmediate(function(){p[g][y].call(e)}):p[g][y].call(e)};var T=function(g){if(!(e.readyState===g||e.readyState===e.UNSENT&&b)&&(e.readyState=g,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let y;b?y="abort":E?y="error":y="load",e.dispatchEvent(y),e.dispatchEvent("loadend")}}}});var us=F((Hf,fs)=>{"use strict";var{Duplex:Va}=C("stream");function ls(i){i.emit("close")}function Ha(){!this.destroyed&&this._writableState.finished&&this.destroy()}function hs(i){this.removeListener("error",hs),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function ja(i,e){let t=!0,r=new Va(N(v({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let a=!o&&r._readableState.objectMode?s.toString():s;r.push(a)||i.pause()}),i.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(n,s){if(i.readyState===i.CLOSED){s(n),process.nextTick(ls,r);return}let o=!1;i.once("error",function(h){o=!0,s(h)}),i.once("close",function(){o||s(n),process.nextTick(ls,r)}),t&&i.terminate()},r._final=function(n){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(n)});return}i._socket!==null&&(i._socket._writableState.finished?(n(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){n()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(n,s,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(n,s,o)});return}i.send(n,o)},r.on("end",Ha),r.on("error",hs),r}fs.exports=ja});var ze=F((Gf,ds)=>{"use strict";ds.exports={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:()=>{}}});var Wt=F((Kf,qi)=>{"use strict";var{EMPTY_BUFFER:Ga}=ze();function Ka(i,e){if(i.length===0)return Ga;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let n=0;n<i.length;n++){let s=i[n];t.set(s,r),r+=s.length}return r<e?t.slice(0,r):t}function ps(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function ms(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Ya(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Lr(i){if(Lr.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=Buffer.from(i):ArrayBuffer.isView(i)?e=Buffer.from(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),Lr.readOnly=!1),e}qi.exports={concat:Ka,mask:ps,toArrayBuffer:Ya,toBuffer:Lr,unmask:ms};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=C("bufferutil");qi.exports.mask=function(e,t,r,n,s){s<48?ps(e,t,r,n,s):i.mask(e,t,r,n,s)},qi.exports.unmask=function(e,t){e.length<32?ms(e,t):i.unmask(e,t)}}catch(i){}});var vs=F((Yf,ys)=>{"use strict";var gs=Symbol("kDone"),Fr=Symbol("kRun"),Ur=class{constructor(e){this[gs]=()=>{this.pending--,this[Fr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Fr]()}[Fr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[gs])}}};ys.exports=Ur});var Vt=F((Jf,ws)=>{"use strict";var zt=C("zlib"),_s=Wt(),Ja=vs(),{kStatusCode:Es}=ze(),Xa=Buffer.from([0,0,255,255]),$i=Symbol("permessage-deflate"),Te=Symbol("total-length"),$t=Symbol("callback"),$e=Symbol("buffers"),zi=Symbol("error"),Wi,Dr=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Wi){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Wi=new Ja(n)}}static get extensionName(){return"permessage-deflate"}offer(){let 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:this._options.clientMaxWindowBits==null&&(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){let e=this._deflate[$t];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(n=>!(t.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>n.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!n.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let n=t[r];if(n.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(n=n[0],r==="client_max_window_bits"){if(n!==!0){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else if(r==="server_max_window_bits"){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=n})}),e}decompress(e,t,r){Wi.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Wi.add(n=>{this._compress(e,t,(s,o)=>{n(),r(s,o)})})}_decompress(e,t,r){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?zt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=zt.createInflateRaw(N(v({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[$i]=this,this._inflate[Te]=0,this._inflate[$e]=[],this._inflate.on("error",Za),this._inflate.on("data",Ss)}this._inflate[$t]=r,this._inflate.write(e),t&&this._inflate.write(Xa),this._inflate.flush(()=>{let s=this._inflate[zi];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=_s.concat(this._inflate[$e],this._inflate[Te]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Te]=0,this._inflate[$e]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?zt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=zt.createDeflateRaw(N(v({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Te]=0,this._deflate[$e]=[],this._deflate.on("data",Qa)}this._deflate[$t]=r,this._deflate.write(e),this._deflate.flush(zt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=_s.concat(this._deflate[$e],this._deflate[Te]);t&&(s=s.slice(0,s.length-4)),this._deflate[$t]=null,this._deflate[Te]=0,this._deflate[$e]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};ws.exports=Dr;function Qa(i){this[$e].push(i),this[Te]+=i.length}function Ss(i){if(this[Te]+=i.length,this[$i]._maxPayload<1||this[Te]<=this[$i]._maxPayload){this[$e].push(i);return}this[zi]=new RangeError("Max payload size exceeded"),this[zi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[zi][Es]=1009,this.removeListener("data",Ss),this.reset()}function Za(i){this[$i]._inflate=null,i[Es]=1007,this[$t](i)}});var Ht=F((Qf,Br)=>{"use strict";var ec=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function tc(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function bs(i){let e=i.length,t=0;for(;t<e;)if(!(i[t]&128))t++;else if((i[t]&224)===192){if(t+1===e||(i[t+1]&192)!==128||(i[t]&254)===192)return!1;t+=2}else if((i[t]&240)===224){if(t+2>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||i[t]===224&&(i[t+1]&224)===128||i[t]===237&&(i[t+1]&224)===160)return!1;t+=3}else if((i[t]&248)===240){if(t+3>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||(i[t+3]&192)!==128||i[t]===240&&(i[t+1]&240)===128||i[t]===244&&i[t+1]>143||i[t]>244)return!1;t+=4}else return!1;return!0}Br.exports={isValidStatusCode:tc,isValidUTF8:bs,tokenChars:ec};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=C("utf-8-validate");Br.exports.isValidUTF8=function(e){return e.length<150?bs(e):i(e)}}catch(i){}});var zr=F((Zf,Ts)=>{"use strict";var{Writable:ic}=C("stream"),xs=Vt(),{BINARY_TYPES:rc,EMPTY_BUFFER:Cs,kStatusCode:nc,kWebSocket:sc}=ze(),{concat:Mr,toArrayBuffer:oc,unmask:ac}=Wt(),{isValidStatusCode:cc,isValidUTF8:Ns}=Ht(),jt=0,ks=1,As=2,Rs=3,qr=4,lc=5,Wr=class extends ic{constructor(e={}){super(),this._binaryType=e.binaryType||rc[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[sc]=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._state=jt,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==jt)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=r.slice(e),r.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case jt:t=this.getInfo();break;case ks:t=this.getPayloadLength16();break;case As:t=this.getPayloadLength64();break;case Rs:this.getMask();break;case qr:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,W(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[xs.extensionName])return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,W(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,W(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,W(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,W(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,W(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,W(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,W(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=ks;else if(this._payloadLength===127)this._state=As;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,W(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Rs:this._state=qr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=qr}getData(e){let t=Cs;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&ac(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=lc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[xs.extensionName].decompress(e,this._fin,(n,s)=>{if(n)return t(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=Mr(t,e):this._binaryType==="arraybuffer"?r=oc(Mr(t,e)):r=t,this.emit("message",r,!0)}else{let r=Mr(t,e);if(!this._skipUTF8Validation&&!Ns(r))return this._loop=!1,W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=jt}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Cs),this.end();else{if(e.length===1)return W(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!cc(t))return W(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Ns(r))return W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=jt}};Ts.exports=Wr;function W(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,W),s.code=n,s[nc]=r,s}});var Vr=F((iu,Ps)=>{"use strict";var eu=C("net"),tu=C("tls"),{randomFillSync:hc}=C("crypto"),Os=Vt(),{EMPTY_BUFFER:fc}=ze(),{isValidStatusCode:uc}=Ht(),{mask:Is,toBuffer:Et}=Wt(),ve=Symbol("kByteLength"),dc=Buffer.alloc(4),$r=class i{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,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 r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||dc,t.generateMask?t.generateMask(r):hc(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!t.mask||o)&&t[ve]!==void 0?a=t[ve]:(e=Buffer.from(e),a=e.length):(a=e.length,n=t.mask&&t.readOnly&&!o);let h=a;a>=65536?(s+=8,h=127):a>125&&(s+=2,h=126);let d=Buffer.allocUnsafe(n?a+s:s);return d[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(d[0]|=64),d[1]=h,h===126?d.writeUInt16BE(a,2):h===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),t.mask?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=r[2],d[s-1]=r[3],o?[d,e]:n?(Is(e,r,d,s,a),[d]):(Is(e,r,e,0,a),[d,e])):[d,e]}close(e,t,r,n){let s;if(e===void 0)s=fc;else{if(typeof e!="number"||!uc(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let o={[ve]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,n]):this.sendFrame(i.frame(s,o),n)}ping(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Et(e),n=e.length,s=Et.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ve]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Et(e),n=e.length,s=Et.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ve]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[Os.extensionName],s=t.binary?2:1,o=t.compress,a,h;if(typeof e=="string"?(a=Buffer.byteLength(e),h=!1):(e=Et(e),a=e.length,h=Et.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let d={[ve]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:h,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,d,r]):this.dispatch(e,this._compress,d,r)}else this.sendFrame(i.frame(e,{[ve]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:h,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Os.extensionName];this._bufferedBytes+=r[ve],this._deflating=!0,s.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(h);for(let d=0;d<this._queue.length;d++){let l=this._queue[d],f=l[l.length-1];typeof f=="function"&&f(h)}return}this._bufferedBytes-=r[ve],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(a,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ve],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ve],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};Ps.exports=$r});var zs=F((ru,Ws)=>{"use strict";var{kForOnEventAttribute:Gt,kListener:Hr}=ze(),Ls=Symbol("kCode"),Fs=Symbol("kData"),Us=Symbol("kError"),Ds=Symbol("kMessage"),Bs=Symbol("kReason"),St=Symbol("kTarget"),Ms=Symbol("kType"),qs=Symbol("kWasClean"),Oe=class{constructor(e){this[St]=null,this[Ms]=e}get target(){return this[St]}get type(){return this[Ms]}};Object.defineProperty(Oe.prototype,"target",{enumerable:!0});Object.defineProperty(Oe.prototype,"type",{enumerable:!0});var et=class extends Oe{constructor(e,t={}){super(e),this[Ls]=t.code===void 0?0:t.code,this[Bs]=t.reason===void 0?"":t.reason,this[qs]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Ls]}get reason(){return this[Bs]}get wasClean(){return this[qs]}};Object.defineProperty(et.prototype,"code",{enumerable:!0});Object.defineProperty(et.prototype,"reason",{enumerable:!0});Object.defineProperty(et.prototype,"wasClean",{enumerable:!0});var wt=class extends Oe{constructor(e,t={}){super(e),this[Us]=t.error===void 0?null:t.error,this[Ds]=t.message===void 0?"":t.message}get error(){return this[Us]}get message(){return this[Ds]}};Object.defineProperty(wt.prototype,"error",{enumerable:!0});Object.defineProperty(wt.prototype,"message",{enumerable:!0});var Kt=class extends Oe{constructor(e,t={}){super(e),this[Fs]=t.data===void 0?null:t.data}get data(){return this[Fs]}};Object.defineProperty(Kt.prototype,"data",{enumerable:!0});var pc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[Gt]&&n[Hr]===e&&!n[Gt])return;let r;if(i==="message")r=function(s,o){let a=new Kt("message",{data:o?s:s.toString()});a[St]=this,Vi(e,this,a)};else if(i==="close")r=function(s,o){let a=new et("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[St]=this,Vi(e,this,a)};else if(i==="error")r=function(s){let o=new wt("error",{error:s,message:s.message});o[St]=this,Vi(e,this,o)};else if(i==="open")r=function(){let s=new Oe("open");s[St]=this,Vi(e,this,s)};else return;r[Gt]=!!t[Gt],r[Hr]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[Hr]===e&&!t[Gt]){this.removeListener(i,t);break}}};Ws.exports={CloseEvent:et,ErrorEvent:wt,Event:Oe,EventTarget:pc,MessageEvent:Kt};function Vi(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var jr=F((nu,$s)=>{"use strict";var{tokenChars:Yt}=Ht();function be(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function mc(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,a,h=-1,d=-1,l=-1,f=0;for(;f<i.length;f++)if(d=i.charCodeAt(f),o===void 0)if(l===-1&&Yt[d]===1)h===-1&&(h=f);else if(f!==0&&(d===32||d===9))l===-1&&h!==-1&&(l=f);else if(d===59||d===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let E=i.slice(h,l);d===44?(be(e,E,t),t=Object.create(null)):o=E,h=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)if(l===-1&&Yt[d]===1)h===-1&&(h=f);else if(d===32||d===9)l===-1&&h!==-1&&(l=f);else if(d===59||d===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),be(t,i.slice(h,l),!0),d===44&&(be(e,o,t),t=Object.create(null),o=void 0),h=l=-1}else if(d===61&&h!==-1&&l===-1)a=i.slice(h,f),h=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(Yt[d]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1?h=f:r||(r=!0),n=!1}else if(s)if(Yt[d]===1)h===-1&&(h=f);else if(d===34&&h!==-1)s=!1,l=f;else if(d===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(d===34&&i.charCodeAt(f-1)===61)s=!0;else if(l===-1&&Yt[d]===1)h===-1&&(h=f);else if(h!==-1&&(d===32||d===9))l===-1&&(l=f);else if(d===59||d===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let E=i.slice(h,l);r&&(E=E.replace(/\\/g,""),r=!1),be(t,a,E),d===44&&(be(e,o,t),t=Object.create(null),o=void 0),a=void 0,h=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(h===-1||s||d===32||d===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let u=i.slice(h,l);return o===void 0?be(e,u,t):(a===void 0?be(t,u,!0):r?be(t,a,u.replace(/\\/g,"")):be(t,a,u),be(e,o,t)),e}function gc(i){return Object.keys(i).map(e=>{let t=i[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(n=>{let s=r[n];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?n:`${n}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}$s.exports={format:gc,parse:mc}});var Xr=F((ou,eo)=>{"use strict";var yc=C("events"),vc=C("https"),_c=C("http"),js=C("net"),Ec=C("tls"),{randomBytes:Sc,createHash:wc}=C("crypto"),{Readable:su}=C("stream"),{URL:Gr}=C("url"),Ve=Vt(),bc=zr(),xc=Vr(),{BINARY_TYPES:Vs,EMPTY_BUFFER:Hi,GUID:Cc,kForOnEventAttribute:Kr,kListener:Nc,kStatusCode:kc,kWebSocket:J,NOOP:Gs}=ze(),{EventTarget:{addEventListener:Ac,removeEventListener:Rc}}=zs(),{format:Tc,parse:Oc}=jr(),{toBuffer:Ic}=Wt(),Pc=30*1e3,Ks=Symbol("kAborted"),Yr=[8,13],Ie=["CONNECTING","OPEN","CLOSING","CLOSED"],Lc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,B=class i extends yc{constructor(e,t,r){super(),this._binaryType=Vs[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Hi,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=i.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),Ys(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Vs.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let n=new bc({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new xc(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[J]=this,e[J]=this,n.on("conclude",Dc),n.on("drain",Bc),n.on("error",Mc),n.on("message",qc),n.on("ping",Wc),n.on("pong",zc),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Xs),e.on("data",Gi),e.on("end",Qs),e.on("error",Zs),this._readyState=i.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ve.extensionName]&&this._extensions[Ve.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return se(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===i.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=i.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),Pc)}}pause(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Jr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Hi,t,r)}pong(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Jr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Hi,t,r)}resume(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Jr(this,e,r);return}let n=v({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Ve.extensionName]||(n.compress=!1),this._sender.send(e||Hi,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return se(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(B,"CONNECTING",{enumerable:!0,value:Ie.indexOf("CONNECTING")});Object.defineProperty(B.prototype,"CONNECTING",{enumerable:!0,value:Ie.indexOf("CONNECTING")});Object.defineProperty(B,"OPEN",{enumerable:!0,value:Ie.indexOf("OPEN")});Object.defineProperty(B.prototype,"OPEN",{enumerable:!0,value:Ie.indexOf("OPEN")});Object.defineProperty(B,"CLOSING",{enumerable:!0,value:Ie.indexOf("CLOSING")});Object.defineProperty(B.prototype,"CLOSING",{enumerable:!0,value:Ie.indexOf("CLOSING")});Object.defineProperty(B,"CLOSED",{enumerable:!0,value:Ie.indexOf("CLOSED")});Object.defineProperty(B.prototype,"CLOSED",{enumerable:!0,value:Ie.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(B.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(B.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Kr])return e[Nc];return null},set(e){for(let t of this.listeners(i))if(t[Kr]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Kr]:!0})}})});B.prototype.addEventListener=Ac;B.prototype.removeEventListener=Rc;eo.exports=B;function Ys(i,e,t,r){let n=N(v({protocolVersion:Yr[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(!Yr.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Yr.join(", ")})`);let s;if(e instanceof Gr)s=e,i._url=e.href;else{try{s=new Gr(e)}catch(p){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",a=s.protocol==="ws+unix:",h;if(s.protocol!=="ws:"&&!o&&!a?h=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!s.pathname?h="The URL's pathname is empty":s.hash&&(h="The URL contains a fragment identifier"),h){let p=new SyntaxError(h);if(i._redirects===0)throw p;ji(i,p);return}let d=o?443:80,l=Sc(16).toString("base64"),f=o?vc.request:_c.request,u=new Set,E;if(n.createConnection=o?Uc:Fc,n.defaultPort=n.defaultPort||d,n.port=s.port||d,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=N(v({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(E=new Ve(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Tc({[Ve.extensionName]:E.offer()})),t.length){for(let p of t){if(typeof p!="string"||!Lc.test(p)||u.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");u.add(p)}n.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),a){let p=n.path.split(":");n.socketPath=p[0],n.path=p[1]}let b;if(n.followRedirects){if(i._redirects===0){i._originalIpc=a,i._originalSecure=o,i._originalHostOrSocketPath=a?n.socketPath:s.host;let p=r&&r.headers;if(r=N(v({},r),{headers:{}}),p)for(let[w,R]of Object.entries(p))r.headers[w.toLowerCase()]=R}else if(i.listenerCount("redirect")===0){let p=a?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!p||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,p||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),b=i._req=f(n),i._redirects&&i.emit("redirect",i.url,b)}else b=i._req=f(n);n.timeout&&b.on("timeout",()=>{se(i,b,"Opening handshake has timed out")}),b.on("error",p=>{b===null||b[Ks]||(b=i._req=null,ji(i,p))}),b.on("response",p=>{let w=p.headers.location,R=p.statusCode;if(w&&n.followRedirects&&R>=300&&R<400){if(++i._redirects>n.maxRedirects){se(i,b,"Maximum redirects exceeded");return}b.abort();let T;try{T=new Gr(w,e)}catch(g){let y=new SyntaxError(`Invalid URL: ${w}`);ji(i,y);return}Ys(i,T,t,r)}else i.emit("unexpected-response",b,p)||se(i,b,`Unexpected server response: ${p.statusCode}`)}),b.on("upgrade",(p,w,R)=>{if(i.emit("upgrade",p),i.readyState!==B.CONNECTING)return;if(b=i._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){se(i,w,"Invalid Upgrade header");return}let T=wc("sha1").update(l+Cc).digest("base64");if(p.headers["sec-websocket-accept"]!==T){se(i,w,"Invalid Sec-WebSocket-Accept header");return}let g=p.headers["sec-websocket-protocol"],y;if(g!==void 0?u.size?u.has(g)||(y="Server sent an invalid subprotocol"):y="Server sent a subprotocol but none was requested":u.size&&(y="Server sent no subprotocol"),y){se(i,w,y);return}g&&(i._protocol=g);let I=p.headers["sec-websocket-extensions"];if(I!==void 0){if(!E){se(i,w,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let A;try{A=Oc(I)}catch(q){se(i,w,"Invalid Sec-WebSocket-Extensions header");return}let M=Object.keys(A);if(M.length!==1||M[0]!==Ve.extensionName){se(i,w,"Server indicated an extension that was not requested");return}try{E.accept(A[Ve.extensionName])}catch(q){se(i,w,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[Ve.extensionName]=E}i.setSocket(w,R,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),b.end()}function ji(i,e){i._readyState=B.CLOSING,i.emit("error",e),i.emitClose()}function Fc(i){return i.path=i.socketPath,js.connect(i)}function Uc(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=js.isIP(i.host)?"":i.host),Ec.connect(i)}function se(i,e,t){i._readyState=B.CLOSING;let r=new Error(t);Error.captureStackTrace(r,se),e.setHeader?(e[Ks]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(ji,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function Jr(i,e,t){if(e){let r=Ic(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Ie[i.readyState]})`);t(r)}}function Dc(i,e){let t=this[J];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[J]!==void 0&&(t._socket.removeListener("data",Gi),process.nextTick(Js,t._socket),i===1005?t.close():t.close(i,e))}function Bc(){let i=this[J];i.isPaused||i._socket.resume()}function Mc(i){let e=this[J];e._socket[J]!==void 0&&(e._socket.removeListener("data",Gi),process.nextTick(Js,e._socket),e.close(i[kc])),e.emit("error",i)}function Hs(){this[J].emitClose()}function qc(i,e){this[J].emit("message",i,e)}function Wc(i){let e=this[J];e.pong(i,!e._isServer,Gs),e.emit("ping",i)}function zc(i){this[J].emit("pong",i)}function Js(i){i.resume()}function Xs(){let i=this[J];this.removeListener("close",Xs),this.removeListener("data",Gi),this.removeListener("end",Qs),i._readyState=B.CLOSING;let e;!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&(e=i._socket.read())!==null&&i._receiver.write(e),i._receiver.end(),this[J]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",Hs),i._receiver.on("finish",Hs))}function Gi(i){this[J]._receiver.write(i)||this.pause()}function Qs(){let i=this[J];i._readyState=B.CLOSING,i._receiver.end(),this.end()}function Zs(){let i=this[J];this.removeListener("error",Zs),this.on("error",Gs),i&&(i._readyState=B.CLOSING,this.destroy())}});var io=F((cu,to)=>{"use strict";var{tokenChars:$c}=Ht();function Vc(i){let e=new Set,t=-1,r=-1,n=0;for(n;n<i.length;n++){let o=i.charCodeAt(n);if(r===-1&&$c[o]===1)t===-1&&(t=n);else if(n!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=n);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${n}`);r===-1&&(r=n);let a=i.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${n}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=i.slice(t,n);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}to.exports={parse:Vc}});var lo=F((uu,co)=>{"use strict";var Hc=C("events"),Ki=C("http"),lu=C("https"),hu=C("net"),fu=C("tls"),{createHash:jc}=C("crypto"),ro=jr(),tt=Vt(),Gc=io(),Kc=Xr(),{GUID:Yc,kWebSocket:Jc}=ze(),Xc=/^[+/0-9A-Za-z]{22}==$/,no=0,so=1,ao=2,Qr=class extends Hc{constructor(e,t){if(super(),e=v({maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Kc},e),e.port==null&&!e.server&&!e.noServer||e.port!=null&&(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(e.port!=null?(this._server=Ki.createServer((r,n)=>{let s=Ki.STATUS_CODES[426];n.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),n.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=Qc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,s,o)=>{this.handleUpgrade(n,s,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=no}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(this._state===ao){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Jt,this);return}if(e&&this.once("close",e),this._state!==so)if(this._state=so,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(Jt,this):process.nextTick(Jt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Jt(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,n){t.on("error",oo);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){it(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){it(this,e,t,400,"Invalid Upgrade header");return}if(!s||!Xc.test(s)){it(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){it(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Xt(t,400);return}let a=e.headers["sec-websocket-protocol"],h=new Set;if(a!==void 0)try{h=Gc.parse(a)}catch(f){it(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&d!==void 0){let f=new tt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=ro.parse(d);u[tt.extensionName]&&(f.accept(u[tt.extensionName]),l[tt.extensionName]=f)}catch(u){it(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(u,E,b,p)=>{if(!u)return Xt(t,E||401,b,p);this.completeUpgrade(l,s,h,e,t,r,n)});return}if(!this.options.verifyClient(f))return Xt(t,401)}this.completeUpgrade(l,s,h,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,a){if(!s.readable||!s.writable)return s.destroy();if(s[Jc])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>no)return Xt(s,503);let d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${jc("sha1").update(t+Yc).digest("base64")}`],l=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(d.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[tt.extensionName]){let f=e[tt.extensionName].params,u=ro.format({[tt.extensionName]:[f]});d.push(`Sec-WebSocket-Extensions: ${u}`),l._extensions=e}this.emit("headers",d,n),s.write(d.concat(`\r
7
7
  `).join(`\r
8
- `)),s.removeListener("error",Xs),l.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Yt,this)})),a(l,n)}};Zs.exports=Yr;function Gc(i,e){for(let t of Object.keys(e))i.on(t,e[t]);return function(){for(let r of Object.keys(e))i.removeListener(r,e[r])}}function Yt(i){i._state=Qs,i.emit("close")}function Xs(){this.destroy()}function Jt(i,e,t,r){t=t||Wi.STATUS_CODES[e],r=v({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Wi.STATUS_CODES[e]}\r
8
+ `)),s.removeListener("error",oo),l.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Jt,this)})),a(l,n)}};co.exports=Qr;function Qc(i,e){for(let t of Object.keys(e))i.on(t,e[t]);return function(){for(let r of Object.keys(e))i.removeListener(r,e[r])}}function Jt(i){i._state=ao,i.emit("close")}function oo(){this.destroy()}function Xt(i,e,t,r){t=t||Ki.STATUS_CODES[e],r=v({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Ki.STATUS_CODES[e]}\r
9
9
  `+Object.keys(r).map(n=>`${n}: ${r[n]}`).join(`\r
10
10
  `)+`\r
11
11
  \r
12
- `+t)}function et(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,et),i.emit("wsClientError",s,t,e)}else Jt(t,r,n)}});var Xr=F((Tu,co)=>{"use strict";function rl(i){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=n,t.enabled=o,t.humanize=_r(),t.destroy=d,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let u=0;u<l.length;u++)f=(f<<5)-f+l.charCodeAt(u),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,u=null,E,b;function p(...w){if(!p.enabled)return;let R=p,T=Number(new Date),g=T-(f||T);R.diff=g,R.prev=f,R.curr=T,f=T,w[0]=t.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let y=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(A,M)=>{if(A==="%%")return"%";y++;let q=t.formatters[M];if(typeof q=="function"){let te=w[y];A=q.call(R,te),w.splice(y,1),y--}return A}),t.formatArgs.call(R,w),(R.log||t.log).apply(R,w)}return p.namespace=l,p.useColors=t.useColors(),p.color=t.selectColor(l),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(E!==t.namespaces&&(E=t.namespaces,b=t.enabled(l)),b),set:w=>{u=w}}),typeof t.init=="function"&&t.init(p),p}function r(l,f){let u=t(this.namespace+(typeof f=="undefined"?":":f)+l);return u.log=this.log,u}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,u=(typeof l=="string"?l:"").split(/[\s,]+/),E=u.length;for(f=0;f<E;f++)u[f]&&(l=u[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(a),...t.skips.map(a).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,u;for(f=0,u=t.skips.length;f<u;f++)if(t.skips[f].test(l))return!1;for(f=0,u=t.names.length;f<u;f++)if(t.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}co.exports=rl});var lo=F((oe,Hi)=>{"use strict";oe.formatArgs=sl;oe.save=ol;oe.load=al;oe.useColors=nl;oe.storage=cl();oe.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();oe.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function nl(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function sl(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Hi.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}oe.log=console.debug||console.log||(()=>{});function ol(i){try{i?oe.storage.setItem("debug",i):oe.storage.removeItem("debug")}catch(e){}}function al(){let i;try{i=oe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function cl(){try{return localStorage}catch(i){}}Hi.exports=Xr()(oe);var{formatters:ll}=Hi.exports;ll.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var fo=F((j,Gi)=>{"use strict";var hl=C("tty"),ji=C("util");j.init=yl;j.log=pl;j.formatArgs=ul;j.save=ml;j.load=gl;j.useColors=fl;j.destroy=ji.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");j.colors=[6,2,3,4,5,1];try{let i=br();i&&(i.stderr||i).level>=2&&(j.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}j.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function fl(){return"colors"in j.inspectOpts?!!j.inspectOpts.colors:hl.isatty(process.stderr.fd)}function ul(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
12
+ `+t)}function it(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,it),i.emit("wsClientError",s,t,e)}else Xt(t,r,n)}});var en=F((Ku,vo)=>{"use strict";function cl(i){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=n,t.enabled=o,t.humanize=wr(),t.destroy=d,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let u=0;u<l.length;u++)f=(f<<5)-f+l.charCodeAt(u),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,u=null,E,b;function p(...w){if(!p.enabled)return;let R=p,T=Number(new Date),g=T-(f||T);R.diff=g,R.prev=f,R.curr=T,f=T,w[0]=t.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let y=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(A,M)=>{if(A==="%%")return"%";y++;let q=t.formatters[M];if(typeof q=="function"){let te=w[y];A=q.call(R,te),w.splice(y,1),y--}return A}),t.formatArgs.call(R,w),(R.log||t.log).apply(R,w)}return p.namespace=l,p.useColors=t.useColors(),p.color=t.selectColor(l),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(E!==t.namespaces&&(E=t.namespaces,b=t.enabled(l)),b),set:w=>{u=w}}),typeof t.init=="function"&&t.init(p),p}function r(l,f){let u=t(this.namespace+(typeof f=="undefined"?":":f)+l);return u.log=this.log,u}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,u=(typeof l=="string"?l:"").split(/[\s,]+/),E=u.length;for(f=0;f<E;f++)u[f]&&(l=u[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(a),...t.skips.map(a).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,u;for(f=0,u=t.skips.length;f<u;f++)if(t.skips[f].test(l))return!1;for(f=0,u=t.names.length;f<u;f++)if(t.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}vo.exports=cl});var _o=F((oe,Qi)=>{"use strict";oe.formatArgs=hl;oe.save=fl;oe.load=ul;oe.useColors=ll;oe.storage=dl();oe.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();oe.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ll(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function hl(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Qi.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}oe.log=console.debug||console.log||(()=>{});function fl(i){try{i?oe.storage.setItem("debug",i):oe.storage.removeItem("debug")}catch(e){}}function ul(){let i;try{i=oe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function dl(){try{return localStorage}catch(i){}}Qi.exports=en()(oe);var{formatters:pl}=Qi.exports;pl.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var So=F((j,er)=>{"use strict";var ml=C("tty"),Zi=C("util");j.init=wl;j.log=_l;j.formatArgs=yl;j.save=El;j.load=Sl;j.useColors=gl;j.destroy=Zi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");j.colors=[6,2,3,4,5,1];try{let i=Nr();i&&(i.stderr||i).level>=2&&(j.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}j.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function gl(){return"colors"in j.inspectOpts?!!j.inspectOpts.colors:ml.isatty(process.stderr.fd)}function yl(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
13
13
  `).join(`
14
- `+s),i.push(n+"m+"+Gi.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=dl()+e+" "+i[0]}function dl(){return j.inspectOpts.hideDate?"":new Date().toISOString()+" "}function pl(...i){return process.stderr.write(ji.formatWithOptions(j.inspectOpts,...i)+`
15
- `)}function ml(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function gl(){return process.env.DEBUG}function yl(i){i.inspectOpts={};let e=Object.keys(j.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=j.inspectOpts[e[t]]}Gi.exports=Xr()(j);var{formatters:ho}=Gi.exports;ho.o=function(i){return this.inspectOpts.colors=this.useColors,ji.inspect(i,this.inspectOpts).split(`
16
- `).map(e=>e.trim()).join(" ")};ho.O=function(i){return this.inspectOpts.colors=this.useColors,ji.inspect(i,this.inspectOpts)}});var Zt=F((Ou,Qr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Qr.exports=lo():Qr.exports=fo()});var Xo="v1",Qo=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,ci=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=Xo,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=Qo,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=v({"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":n},s)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var r;let t=e||typeof window!="undefined"&&((r=window.localStorage)==null?void 0:r.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=v(v({},this.headers),e)}get(e,t,r=!0){return m(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return m(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=Zo(this.apiUrl,e,t?`?${t.toString()}`:""),a={method:(r==null?void 0:r.method)||"GET",headers:v(v({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},h=yield fetch(o,a);if(!h.ok){let l=yield h.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${h.status}, Message: ${l.message}`)}if(h.status===204)return;let d=yield h.json();return n?d.data:d})}};function Zo(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var at="/inbox",Z=`${at}/notifications`,P,li=class{constructor(e={}){this.isSessionInitialized=!1;_(this,P);S(this,P,new ci(e))}initializeSession(n){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,subscriber:r}){let s=yield c(this,P).post(`${at}/session`,{applicationIdentifier:e,subscriberHash:t,subscriber:r});return c(this,P).setAuthorizationToken(s.token),c(this,P).setKeylessHeader(s.applicationIdentifier),this.isSessionInitialized=!0,s})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:a,seen:h,data:d}){let l=new URLSearchParams(`limit=${r}`);return e&&l.append("after",e),n&&l.append("offset",`${n}`),o&&o.forEach(f=>l.append("tags[]",f)),s!==void 0&&l.append("read",`${s}`),t!==void 0&&l.append("archived",`${t}`),a!==void 0&&l.append("snoozed",`${a}`),h!==void 0&&l.append("seen",`${h}`),d!==void 0&&l.append("data",JSON.stringify(d)),c(this,P).get(Z,l,!1)}count({filters:e}){return c(this,P).get(`${Z}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return c(this,P).patch(`${Z}/${e}/read`)}unread(e){return c(this,P).patch(`${Z}/${e}/unread`)}archive(e){return c(this,P).patch(`${Z}/${e}/archive`)}unarchive(e){return c(this,P).patch(`${Z}/${e}/unarchive`)}snooze(e,t){return c(this,P).patch(`${Z}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return c(this,P).patch(`${Z}/${e}/unsnooze`)}readAll({tags:e,data:t}){return c(this,P).post(`${Z}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return c(this,P).post(`${Z}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return c(this,P).post(`${Z}/archive/read`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return c(this,P).post(`${Z}/seen`,{notificationIds:e,tags:t,data:r?JSON.stringify(r):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return c(this,P).patch(`${Z}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return c(this,P).patch(`${Z}/${t}/revert`,{actionType:e})}fetchPreferences(e){let t=new URLSearchParams;e&&e.forEach(n=>t.append("tags[]",n));let r=t.size?`?${t.toString()}`:"";return c(this,P).get(`${at}/preferences${r}`)}bulkUpdatePreferences(e){return c(this,P).patch(`${at}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return c(this,P).patch(`${at}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return c(this,P).patch(`${at}/preferences/${e}`,t)}triggerHelloWorldEvent(){let e={name:"hello-world",to:{subscriberId:"keyless-subscriber-id"},payload:{subject:"Novu Keyless Environment",body:"You're using a keyless demo environment. For full access to Novu features and cloud integration, obtain your API key.",primaryActionText:"Obtain API Key",primaryActionUrl:"https://go.novu.co/keyless",secondaryActionText:"Explore Documentation",secondaryActionUrl:"https://go.novu.co/keyless-docs"}};return c(this,P).post("/inbox/events",e)}};P=new WeakMap;function mn(i){return{all:i=i||new Map,on:function(e,t){var r=i.get(e);r?r.push(t):i.set(e,[t])},off:function(e,t){var r=i.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var r=i.get(e);r&&r.slice().map(function(n){n(t)}),(r=i.get("*"))&&r.slice().map(function(n){n(e,t)})}}}var Ke,hi=class{constructor(){_(this,Ke);S(this,Ke,mn())}on(e,t){return c(this,Ke).on(e,t),()=>{this.off(e,t)}}off(e,t){c(this,Ke).off(e,t)}emit(e,t){c(this,Ke).emit(e,t)}};Ke=new WeakMap;var k=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Be,ct,Ee=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,Be,[]);_(this,ct);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),c(this,Be).forEach(a=>m(this,[a],function*({fn:s,resolve:o}){o(yield s())})),S(this,Be,[])):r&&(this.onSessionError(r),S(this,ct,r),c(this,Be).forEach(({resolve:s})=>{s({error:new k("Failed to initialize session, please contact the support",r)})}),S(this,Be,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():c(this,ct)?Promise.resolve({error:new k("Failed to initialize session, please contact the support",c(this,ct))}):new Promise((t,r)=>{c(this,Be).push({fn:e,resolve:t,reject:r})})})}};Be=new WeakMap,ct=new WeakMap;var G,Q,U=class{constructor(e,t,r){_(this,G);_(this,Q);S(this,G,t),S(this,Q,r),this.id=e.id,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isSeen=e.isSeen,this.isArchived=e.isArchived,this.isSnoozed=e.isSnoozed,this.snoozedUntil=e.snoozedUntil,this.deliveredAt=e.deliveredAt,this.createdAt=e.createdAt,this.readAt=e.readAt,this.firstSeenAt=e.firstSeenAt,this.archivedAt=e.archivedAt,this.avatar=e.avatar,this.primaryAction=e.primaryAction,this.secondaryAction=e.secondaryAction,this.channelType=e.channelType,this.tags=e.tags,this.redirect=e.redirect,this.data=e.data,this.workflow=e.workflow}read(){return fi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}unread(){return ui({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}seen(){return di({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}archive(){return pi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}unarchive(){return mi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}snooze(e){return gi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this,snoozeUntil:e}})}unsnooze(){return yi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return lt({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return lt({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return ht({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return ht({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"secondary"})}on(e,t){let r=c(this,G).on(e,t);return()=>{r()}}off(e,t){c(this,G).off(e,t)}};G=new WeakMap,Q=new WeakMap;var fi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.read.pending",{args:t,data:s});let o=yield e.read(n),a=new U(o,i,e);return i.emit("notification.read.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new k("Failed to read notification",o)}}}),ui=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(n),a=new U(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new k("Failed to unread notification",o)}}}),di=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(n),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,i,e);return i.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return i.emit("notification.seen.resolved",{args:t,error:o}),{error:new k("Failed to mark notification as seen",o)}}}),pi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.archive.pending",{args:t,data:s});let o=yield e.archive(n),a=new U(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new k("Failed to archive notification",o)}}}),mi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(n),a=new U(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new k("Failed to unarchive notification",o)}}}),gi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:i,apiService:e});try{i.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(n,t.snoozeUntil),a=new U(o,i,e);return i.emit("notification.snooze.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.snooze.resolved",{args:t,error:o}),{error:new k("Failed to snooze notification",o)}}}),yi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isSnoozed:!1,snoozedUntil:null},{emitter:i,apiService:e});try{i.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(n),a=new U(o,i,e);return i.emit("notification.unsnooze.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new k("Failed to unsnooze notification",o)}}}),lt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:N(v({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:N(v({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:a}=Ne(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:a});let h=yield e.completeAction({actionType:r,notificationId:o}),d=new U(h,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:d}),{data:d}}catch(h){return i.emit("notification.complete_action.resolved",{args:t,error:h}),{error:new k(`Failed to complete ${r} action on the notification`,h)}}}),ht=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:N(v({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:N(v({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:a}=Ne(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:a});let h=yield e.revertAction({actionType:r,notificationId:o}),d=new U(h,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:d}),{data:d}}catch(h){return i.emit("notification.revert_action.resolved",{args:t,error:h}),{error:new k("Failed to fetch notifications",h)}}}),Ne=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(v(v({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},gn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let a=t.getUniqueNotifications({tags:r,data:n}).map(h=>new U(N(v({},h),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:r,data:n},data:a}),yield e.readAll({tags:r,data:n}),i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},data:a}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to read all notifications",o)}}}),hr=o=>m(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let a=t.getUniqueNotifications({tags:n,data:s}),d=(r&&r.length>0?a.filter(l=>r.includes(l.id)):a).map(l=>new U(N(v({},l),{isSeen:!0,firstSeenAt:l.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:d}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:d}),{}}catch(a){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:a}),{error:new k("Failed to mark all notifications as seen",a)}}}),yn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let a=t.getUniqueNotifications({tags:r,data:n}).map(h=>new U(N(v({},h),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all.pending",{args:{tags:r,data:n},data:a}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:a}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all notifications",o)}}}),vn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let a=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(h=>new U(N(v({},h),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:a}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:a}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all read notifications",o)}}});var _n=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var ah=["seen","unseen"],ch=["read","unread"],fr=(i,e)=>_n(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,ur=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},dr=(i,e)=>ur(i.data,e.data)&&fr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen;var de,ft=class{constructor(){_(this,de);S(this,de,new Map)}get(e){return c(this,de).get(e)}getValues(){return Array.from(c(this,de).values())}entries(){return Array.from(c(this,de).entries())}keys(){return Array.from(c(this,de).keys())}set(e,t){c(this,de).set(e,t)}remove(e){c(this,de).delete(e)}clear(){c(this,de).clear()}};de=new WeakMap;var En=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h}).filter(([d,l])=>l!=null&&!(Array.isArray(l)&&l.length===0)).reduce((d,[l,f])=>(d[l]=f,d),{}),pr=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h})=>JSON.stringify(En({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h})),ea=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s})=>JSON.stringify(En({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s})),ut=i=>JSON.parse(i),ta=["notification.read.pending","notification.read.resolved","notification.unread.pending","notification.unread.resolved","notification.complete_action.pending","notification.complete_action.resolved","notification.revert_action.pending","notification.revert_action.resolved","notifications.read_all.pending","notifications.read_all.resolved"],ia=["notification.archive.pending","notification.unarchive.pending","notification.snooze.pending","notification.unsnooze.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],Me,$,Rt=class{constructor({emitter:e}){_(this,Me);_(this,$);this.updateNotification=(e,t)=>{let r=c(this,$).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s[n]=t,c(this,$).set(e,N(v({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=c(this,$).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s.splice(n,1),c(this,$).set(e,N(v({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>({data:t})=>{if(!t)return;let r=Array.isArray(t)?t:[t],n=new Set;c(this,$).keys().forEach(s=>{r.forEach(o=>{let a=!1;e?a=this.removeNotification(s,o):a=this.updateNotification(s,o),a&&n.add(ea(ut(s)))})}),n.forEach(s=>{let o=this.getAggregated(ut(s));c(this,Me).emit("notifications.list.updated",{data:o})})};S(this,Me,e),ta.forEach(t=>{c(this,Me).on(t,this.handleNotificationEvent())}),ia.forEach(t=>{c(this,Me).on(t,this.handleNotificationEvent({remove:!0}))}),S(this,$,new ft)}getAggregated(e){return c(this,$).keys().filter(r=>{let n=ut(r);return dr(n,e)}).map(r=>c(this,$).get(r)).reduce((r,n)=>n?{hasMore:n.hasMore,filter:n.filter,notifications:[...r.notifications,...n.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}has(e){return c(this,$).get(pr(e))!==void 0}set(e,t){c(this,$).set(pr(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(ut(pr(e)));c(this,Me).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,data:e.data,read:e.read,snoozed:e.snoozed,archived:e.archived,seen:e.seen})}getUniqueNotifications({tags:e,read:t,data:r}){let n=c(this,$).keys(),s=new Map;return n.forEach(o=>{let a=ut(o);if(fr(e,a.tags)&&ur(r,a.data)){let h=c(this,$).get(o);if(!h)return;h.notifications.filter(d=>typeof t=="undefined"||t===d.isRead).forEach(d=>s.set(d.id,d))}}),Array.from(s.values())}clear(e){c(this,$).keys().forEach(r=>{dr(ut(r),e)&&c(this,$).remove(r)})}clearAll(){c(this,$).clear()}};Me=new WeakMap,$=new WeakMap;var Tt,vi=class extends Ee{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Tt);this.cache=new Rt({emitter:n}),S(this,Tt,t)}get inboxService(){return this._inboxService}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=cr(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=v({limit:t},r);try{let a="useCache"in o?o.useCache:c(this,Tt),h=a?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:h}),!h){let d=yield this._inboxService.fetchNotifications(v({limit:t},r));h={hasMore:d.hasMore,filter:d.filter,notifications:d.data.map(l=>new U(l,this._emitter,this._inboxService))},a&&(this.cache.set(o,h),h=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:h}),{data:h}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new k("Failed to fetch notifications",a)}}}))})}count(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){let r=t&&"filters"in t?t.filters:[v({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let n=yield this._inboxService.count({filters:r}),s=t&&"filters"in t?{counts:n.data}:n.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(n){return this._emitter.emit("notifications.count.resolved",{args:t,error:n}),{error:new k("Failed to count notifications",n)}}}))})}read(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return fi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ui({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return di({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return pi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return lt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return lt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ht({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ht({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return gn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){return"notificationIds"in t?hr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):hr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return yn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return vn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){return t?this.cache.clear(t!=null?t:{}):this.cache.clearAll()}triggerHelloWorldEvent(){return m(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};Tt=new WeakMap;var _i=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var h;let{channels:o}=n,a="workflowId"in n?n.workflowId:(h=n.preference.workflow)==null?void 0:h.id;try{i.emit("preference.update.pending",{args:n,data:"preference"in n?new Se(N(v({},n.preference),{channels:v(v({},n.preference.channels),o)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0});let d;a?d=yield e.updateWorkflowPreferences({workflowId:a,channels:o}):(ra({emitter:i,apiService:e,cache:t,useCache:r,args:n}),d=yield e.updateGlobalPreferences(o));let l=new Se(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.update.resolved",{args:n,data:l}),{data:l}}catch(d){return i.emit("preference.update.resolved",{args:n,error:d}),{error:new k("Failed to update preference",d)}}}),Sn=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){if(n.find(a=>"preference"in a&&a.preference.level==="global"))return{error:new k("Global preference is not supported in bulk update","")};try{let a=n.map(f=>"preference"in f?new Se(N(v({},f.preference),{channels:v(v({},f.preference.channels),f.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0).filter(f=>f!==void 0);i.emit("preferences.bulk_update.pending",{args:n,data:a});let h=n.map(f=>{var u,E,b,p;return v({workflowId:"workflowId"in f?f.workflowId:(p=(b=(u=f.preference.workflow)==null?void 0:u.id)!=null?b:(E=f.preference.workflow)==null?void 0:E.identifier)!=null?p:""},f.channels)}),l=(yield e.bulkUpdatePreferences(h)).map(f=>new Se(f,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}));return i.emit("preferences.bulk_update.resolved",{args:n,data:l}),{data:l}}catch(a){return i.emit("preferences.bulk_update.resolved",{args:n,error:a}),{error:new k("Failed to bulk update preferences",a)}}}),ra=({emitter:i,apiService:e,cache:t,useCache:r,args:n})=>{let s=r?t==null?void 0:t.getAll({}):void 0;s==null||s.forEach(o=>{var a,h;if(o.level==="template"){let d=N(v({},o),{channels:Object.entries(o.channels).reduce((f,[u,E])=>{var p;let b=u;return f[b]=(p=n.channels[b])!=null?p:E,f},{})}),l="preference"in n?new Se(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0;l&&i.emit("preference.update.pending",{args:{workflowId:(h=(a=o.workflow)==null?void 0:a.id)!=null?h:"",channels:l.channels},data:l})}})};var Ot,It,Pt,Lt,Se=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){_(this,Ot);_(this,It);_(this,Pt);_(this,Lt);S(this,Ot,t),S(this,It,r),S(this,Pt,n),S(this,Lt,s),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow}update({channels:e,channelPreferences:t}){var r;return _i({emitter:c(this,Ot),apiService:c(this,It),cache:c(this,Pt),useCache:c(this,Lt),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};Ot=new WeakMap,It=new WeakMap,Pt=new WeakMap,Lt=new WeakMap;var na=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],sa=({tags:i})=>Object.entries({tags:i}).reduce((e,[t,r])=>(r==null||Array.isArray(r)&&r.length===0||(e[t]=r),e),{}),mr=({tags:i})=>JSON.stringify(sa({tags:i})),dt,re,Ei=class{constructor({emitterInstance:e}){_(this,dt);_(this,re);this.updatePreference=(e,t)=>{let r=c(this,re).get(e);if(!r)return!1;let n=r.findIndex(o=>{var a,h;return((a=o.workflow)==null?void 0:a.id)===((h=t.workflow)==null?void 0:h.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,c(this,re).set(e,s),!0};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;c(this,re).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),a=c(this,re).get(n);!o||!a||r.add(n)})}),r.forEach(n=>{var s;c(this,dt).emit("preferences.list.updated",{data:(s=c(this,re).get(n))!=null?s:[]})})};S(this,dt,e),na.forEach(t=>{c(this,dt).on(t,this.handlePreferenceEvent)}),S(this,re,new ft)}has(e){return c(this,re).get(mr(e))!==void 0}set(e,t){c(this,re).set(mr(e),t)}getAll(e){if(this.has(e))return c(this,re).get(mr(e))}clearAll(){c(this,re).clear()}};dt=new WeakMap,re=new WeakMap;var ke,Si=class extends Ee{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,ke);this.cache=new Ei({emitterInstance:this._emitter}),S(this,ke,t)}list(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){try{let r=c(this,ke)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:r}),r||(r=(yield this._inboxService.fetchPreferences(t.tags)).map(s=>new Se(s,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:c(this,ke)})),c(this,ke)&&(this.cache.set(t,r),r=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:r}),{data:r}}catch(r){throw this._emitter.emit("preferences.list.resolved",{args:t,error:r}),r}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>_i({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:c(this,ke),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>Sn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:c(this,ke),args:t}))})}};ke=new WeakMap;function wn(){return typeof window!="undefined"}var Ye,Ft,fe,wi=class{constructor(e,t,r){_(this,Ye);_(this,Ft);_(this,fe);S(this,Ye,r),S(this,Ft,t),S(this,fe,e)}get applicationIdentifier(){return c(this,fe).applicationIdentifier}get subscriberId(){var e;return(e=c(this,fe).subscriber)==null?void 0:e.subscriberId}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let r="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(r);case"store":return t&&window.localStorage.setItem(r,t),null;case"delete":return window.localStorage.removeItem(r),null;default:return null}}initialize(e){return m(this,null,function*(){var t,r,n,s,o,a;if(((t=c(this,fe).subscriber)==null?void 0:t.subscriberId)!==((r=e==null?void 0:e.subscriber)==null?void 0:r.subscriberId))try{e&&S(this,fe,e);let{subscriber:h,subscriberHash:d,applicationIdentifier:l}=c(this,fe),f;wn()&&(f=Intl.DateTimeFormat().resolvedOptions().timeZone);let u=l;if(u)this.handleApplicationIdentifier("delete");else{let b=this.handleApplicationIdentifier("get");b&&(u=b)}c(this,Ye).emit("session.initialize.pending",{args:c(this,fe)});let E=yield c(this,Ft).initializeSession({applicationIdentifier:u,subscriberHash:d,subscriber:N(v({},h),{subscriberId:(n=h==null?void 0:h.subscriberId)!=null?n:"",timezone:(s=h==null?void 0:h.timezone)!=null?s:f})});(o=E==null?void 0:E.applicationIdentifier)!=null&&o.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",E.applicationIdentifier),(a=E==null?void 0:E.applicationIdentifier)!=null&&a.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),c(this,Ye).emit("session.initialize.resolved",{args:c(this,fe),data:E})}catch(h){c(this,Ye).emit("session.initialize.resolved",{args:c(this,fe),error:h})}})}};Ye=new WeakMap,Ft=new WeakMap,fe=new WeakMap;var pe=Object.create(null);pe.open="0";pe.close="1";pe.ping="2";pe.pong="3";pe.message="4";pe.upgrade="5";pe.noop="6";var Ut=Object.create(null);Object.keys(pe).forEach(i=>{Ut[pe[i]]=i});var Dt={type:"error",data:"parser error"};var Bt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+bn(e,!0).toString("base64")):r(pe[i]+(e||"")),bn=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),gr;function xn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(bn(i.data,!1));Bt(i,!0,t=>{gr||(gr=new TextEncoder),e(gr.encode(t))})}var Mt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Cn(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Cn(r,e)}}return Ut[t]?i.length>1?{type:Ut[t],data:i.substring(1)}:{type:Ut[t]}:Dt},Cn=(i,e)=>{switch(e){case"arraybuffer":return i instanceof ArrayBuffer?i:Buffer.isBuffer(i)?i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength):i.buffer;case"nodebuffer":default:return Buffer.isBuffer(i)?i:Buffer.from(i)}};var Nn="",kn=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Bt(s,!1,a=>{r[o]=a,++n===t&&e(r.join(Nn))})})},An=(i,e)=>{let t=i.split(Nn),r=[];for(let n=0;n<t.length;n++){let s=Mt(t[n],e);if(r.push(s),s.type==="error")break}return r};function Rn(){return new TransformStream({transform(i,e){xn(i,t=>{let r=t.length,n;if(r<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,r);else if(r<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(n[0]|=128),e.enqueue(n),e.enqueue(t)})}})}var yr;function bi(i){return i.reduce((e,t)=>e+t.length,0)}function xi(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let n=0;n<e;n++)t[n]=i[0][r++],r===i[0].length&&(i.shift(),r=0);return i.length&&r<i[0].length&&(i[0]=i[0].slice(r)),t}function Tn(i,e){yr||(yr=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(r===0){if(bi(t)<1)break;let h=xi(t,1);s=(h[0]&128)===128,n=h[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(bi(t)<2)break;let h=xi(t,2);n=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(bi(t)<8)break;let h=xi(t,8),d=new DataView(h.buffer,h.byteOffset,h.length),l=d.getUint32(0);if(l>Math.pow(2,21)-1){a.enqueue(Dt);break}n=l*Math.pow(2,32)+d.getUint32(4),r=3}else{if(bi(t)<n)break;let h=xi(t,n);a.enqueue(Mt(s?h:yr.decode(h),e)),r=0}if(n===0||n>i){a.enqueue(Dt);break}}}})}var vr=4;function L(i){if(i)return oa(i)}function oa(i){for(var e in L.prototype)i[e]=L.prototype[e];return i}L.prototype.on=L.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};L.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(i,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+i];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var r,n=0;n<t.length;n++)if(r=t[n],r===e||r.fn===e){t.splice(n,1);break}return t.length===0&&delete this._callbacks["$"+i],this};L.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+i],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,n=t.length;r<n;++r)t[r].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};L.prototype.hasListeners=function(i){return!!this.listeners(i).length};var me=global;function Ci(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var aa=me.setTimeout,ca=me.clearTimeout;function Ae(i,e){e.useNativeTimers?(i.setTimeoutFn=aa.bind(me),i.clearTimeoutFn=ca.bind(me)):(i.setTimeoutFn=me.setTimeout.bind(me),i.clearTimeoutFn=me.clearTimeout.bind(me))}var la=1.33;function On(i){return typeof i=="string"?ha(i):Math.ceil((i.byteLength||i.size)*la)}function ha(i){let e=0,t=0;for(let r=0,n=i.length;r<n;r++)e=i.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}var $n=Y(Xe(),1);function Wn(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function zn(i){let e={},t=i.split("&");for(let r=0,n=t.length;r<n;r++){let s=t[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var Pa=(0,$n.default)("engine.io-client:transport"),Cr=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Re=class extends L{constructor(e){super(),this.writable=!1,Ae(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Cr(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):Pa("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Mt(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(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Wn(e);return t.length?"?"+t:""}};var Zn=Y(Xe(),1);var Gn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Nr=64,La={},Vn=0,Ti=0,Hn;function jn(i){let e="";do e=Gn[i%Nr]+e,i=Math.floor(i/Nr);while(i>0);return e}function Oi(){let i=jn(+new Date);return i!==Hn?(Vn=0,Hn=i):i+"."+jn(Vn++)}for(;Ti<Nr;Ti++)La[Gn[Ti]]=Ti;var Rr=Y(Jn(),1),Tr=Rr.default||Rr;function Xn(){return new Ar}function Ua(i){let e=i.split("; "),t=e[0].indexOf("=");if(t===-1)return;let r=e[0].substring(0,t).trim();if(!r.length)return;let n=e[0].substring(t+1).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));let s={name:r,value:n};for(let o=1;o<e.length;o++){let a=e[o].split("=");if(a.length!==2)continue;let h=a[0].trim(),d=a[1].trim();switch(h){case"Expires":s.expires=new Date(d);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(d,10)),s.expires=l;break;default:}}return s}var Ar=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=Ua(r);n&&this.cookies.set(n.name,n)})}addCookies(e){let t=[];this.cookies.forEach((r,n)=>{var s;((s=r.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(n):t.push(`${n}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var ee=(0,Zn.default)("engine.io-client:polling");function Da(){}var Ba=function(){return new Tr({xdomain:!1}).responseType!=null}(),Ii=class extends Re{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",n=location.port;n||(n=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||n!==e.port}let t=e&&e.forceBase64;this.supportsBinary=Ba&&!t,this.opts.withCredentials&&(this.cookieJar=Xn())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{ee("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(ee("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){ee("pre-pause polling complete"),--r||t()})),this.writable||(ee("we are currently writing - waiting to pause"),r++,this.once("drain",function(){ee("pre-pause writing complete"),--r||t()}))}else t()}poll(){ee("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){ee("polling got data %s",e);let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};An(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():ee('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{ee("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(ee("transport open - closing"),e()):(ee("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,kn(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Oi()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new We(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(n,s)=>{this.onError("xhr post error",n,s)})}doPoll(){ee("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},We=class i extends L{constructor(e,t){super(),Ae(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;let t=Ci(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Tr(t);try{ee("xhr open %s: %s",this.method,this.uri),r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch(n){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{r.setRequestHeader("Accept","*/*")}catch(n){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var n;r.readyState===3&&((n=this.opts.cookieJar)===null||n===void 0||n.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},ee("xhr data %s",this.data),r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document!="undefined"&&(this.index=i.requestsCount++,i.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=Da,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete i.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};We.requestsCount=0;We.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",Qn);else if(typeof addEventListener=="function"){let i="onpagehide"in me?"pagehide":"unload";addEventListener(i,Qn,!1)}}function Qn(){for(let i in We.requests)We.requests.hasOwnProperty(i)&&We.requests[i].abort()}var Kc=Y(rs(),1),Yc=Y(Mr(),1),Jc=Y(Wr(),1),to=Y(Kr(),1),Xc=Y(eo(),1);var io=to.default;var Xt=io,zi=!1,ro="nodebuffer",tt=process.nextTick;var so=Y(Xe(),1);var Qc=(0,so.default)("engine.io-client:websocket"),no=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",$i=class extends Re{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,r=no?{}:Ci(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=zi&&!no?t?new Xt(e,t):new Xt(e):new Xt(e,t,r)}catch(n){return this.emitReserved("error",n)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],n=t===e.length-1;Bt(r,this.supportsBinary,s=>{let o={};zi||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{zi?this.ws.send(s):this.ws.send(s,o)}catch(a){Qc("websocket closed before onclose event")}n&&tt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Oi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Xt}};var oo=Y(Xe(),1),Qt=(0,oo.default)("engine.io-client:webtransport"),Vi=class extends Re{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Qt("transport closed gracefully"),this.onClose()}).catch(e=>{Qt("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Tn(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Rn();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:a,value:h})=>{if(a){Qt("session is closed");return}Qt("received chunk: %o",h),this.onPacket(h),s()}).catch(a=>{Qt("an error occurred while reading: %s",a)})};s();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],n=t===e.length-1;this.writer.write(r).then(()=>{n&&tt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Jr={websocket:$i,webtransport:Vi,polling:Ii};var Zc=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,el=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function St(i){let e=i,t=i.indexOf("["),r=i.indexOf("]");t!=-1&&r!=-1&&(i=i.substring(0,t)+i.substring(t,r).replace(/:/g,";")+i.substring(r,i.length));let n=Zc.exec(i||""),s={},o=14;for(;o--;)s[el[o]]=n[o]||"";return t!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=tl(s,s.path),s.queryKey=il(s,s.query),s}function tl(i,e){let t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function il(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var ao=Y(Xe(),1);var D=(0,ao.default)("engine.io-client:socket"),it=class i extends L{constructor(e,t={}){super(),this.binaryType=ro,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=St(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=St(t.host).host),Ae(this,t),this.secure=t.secure!=null?t.secure:typeof location!="undefined"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=t.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=zn(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){D('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=vr,t.transport=e,this.id&&(t.sid=this.id);let r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return D("options: %j",r),new Jr[e](r)}open(){let e;if(this.opts.rememberUpgrade&&i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){D("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){D("setting transport %s",e.name),this.transport&&(D("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){D('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(D('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(D('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",D('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(D("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{D('probe transport "%s" failed',e);let u=new Error("probe error");u.transport=t.name,this.emitReserved("upgradeError",u)}}))};function s(){r||(r=!0,l(),t.close(),t=null)}let o=f=>{let u=new Error("probe error: "+f);u.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",u)};function a(){o("transport closed")}function h(){o("socket closed")}function d(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let l=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",a),this.off("close",h),this.off("upgrading",d)};t.once("open",n),t.once("error",o),t.once("close",a),this.once("close",h),this.once("upgrading",d),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(D("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){D("starting upgrade probes");let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(D('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else D('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();D("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let n=this.writeBuffer[r].data;if(n&&(t+=On(n)),r>0&&t>this.maxPayload)return D("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return D("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if(typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:e,data:t,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this.onClose("forced close"),D("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){D("socket error %j",e),i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(D('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],r=0,n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};it.protocol=vr;var bu=it.protocol;var po=Y(Zt(),1),uo=(0,po.default)("socket.io-client:url");function mo(i,e="",t){let r=i;t=t||typeof location!="undefined"&&location,i==null&&(i=t.protocol+"//"+t.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=t.protocol+i:i=t.host+i),/^(https?|wss?):\/\//.test(i)||(uo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),uo("parse %s",i),r=St(i)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";let s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(t&&t.port===r.port?"":":"+r.port),r}var on={};Yo(on,{Decoder:()=>nn,Encoder:()=>rn,PacketType:()=>x,protocol:()=>So});var vl=typeof ArrayBuffer=="function",_l=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,go=Object.prototype.toString,El=typeof Blob=="function"||typeof Blob!="undefined"&&go.call(Blob)==="[object BlobConstructor]",Sl=typeof File=="function"||typeof File!="undefined"&&go.call(File)==="[object FileConstructor]";function ti(i){return vl&&(i instanceof ArrayBuffer||_l(i))||El&&i instanceof Blob||Sl&&i instanceof File}function ei(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(ei(i[t]))return!0;return!1}if(ti(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return ei(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&ei(i[t]))return!0;return!1}function yo(i){let e=[],t=i.data,r=i;return r.data=Zr(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Zr(i,e){if(!i)return i;if(ti(i)){let t={_placeholder:!0,num:e.length};return e.push(i),t}else if(Array.isArray(i)){let t=new Array(i.length);for(let r=0;r<i.length;r++)t[r]=Zr(i[r],e);return t}else if(typeof i=="object"&&!(i instanceof Date)){let t={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=Zr(i[r],e));return t}return i}function vo(i,e){return i.data=en(i.data,e),delete i.attachments,i}function en(i,e){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<e.length)return e[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let t=0;t<i.length;t++)i[t]=en(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=en(i[t],e));return i}var Eo=Y(Xe(),1),tn=(0,Eo.default)("socket.io-parser"),wl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],So=5,x;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(x||(x={}));var rn=class{constructor(e){this.replacer=e}encode(e){return tn("encoding packet %j",e),(e.type===x.EVENT||e.type===x.ACK)&&ei(e)?this.encodeAsBinary({type:e.type===x.EVENT?x.BINARY_EVENT:x.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===x.BINARY_EVENT||e.type===x.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),tn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=yo(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function _o(i){return Object.prototype.toString.call(i)==="[object Object]"}var nn=class i extends L{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let r=t.type===x.BINARY_EVENT;r||t.type===x.BINARY_ACK?(t.type=r?x.EVENT:x.ACK,this.reconstructor=new sn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ti(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,r={type:Number(e.charAt(0))};if(x[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===x.BINARY_EVENT||r.type===x.BINARY_ACK){let s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(s,t)}else r.nsp="/";let n=e.charAt(t+1);if(n!==""&&Number(n)==n){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return tn("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case x.CONNECT:return _o(t);case x.DISCONNECT:return t===void 0;case x.CONNECT_ERROR:return typeof t=="string"||_o(t);case x.EVENT:case x.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&wl.indexOf(t[0])===-1);case x.ACK:case x.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},sn=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=vo(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ae(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var wo=Y(Zt(),1),z=(0,wo.default)("socket.io-client:socket"),bl=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),wt=class extends L{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ae(e,"open",this.onopen.bind(this)),ae(e,"packet",this.onpacket.bind(this)),ae(e,"error",this.onerror.bind(this)),ae(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(bl.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let r={type:x.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;z("emitting packet with ack id %d",o);let a=t.pop();this._registerAckCallback(o,a),r.id=o}let n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)?z("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r),this.flags={},this}_registerAckCallback(e,t){var r;let n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(z("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));z("event with ack id %d has timed out after %d ms",e,n),t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((n,s)=>{t.push((o,a)=>r?o?s(o):n(a):n(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((n,...s)=>r!==this._queue[0]?void 0:(n!==null?r.tryCount>this._opts.retries&&(z("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(z("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(z("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){z("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,z("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){z("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:x.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){z("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case x.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case x.EVENT:case x.BINARY_EVENT:this.onevent(e);break;case x.ACK:case x.BINARY_ACK:this.onack(e);break;case x.DISCONNECT:this.ondisconnect();break;case x.CONNECT_ERROR:this.destroy();let r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){let t=e.data||[];z("emitting event %j",t),e.id!=null&&(z("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,r=!1;return function(...n){r||(r=!0,z("sending ack %j",n),t.packet({type:x.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(z("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):z("bad ack %s",e.id)}onconnect(e,t){z("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){z("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(z("performing disconnect (%s)",this.nsp),this.packet({type:x.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function rt(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}rt.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};rt.prototype.reset=function(){this.attempts=0};rt.prototype.setMin=function(i){this.ms=i};rt.prototype.setMax=function(i){this.max=i};rt.prototype.setJitter=function(i){this.jitter=i};var bo=Y(Zt(),1),K=(0,bo.default)("socket.io-client:manager"),bt=class extends L{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Ae(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new rt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||on;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(K("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;K("opening %s",this.uri),this.engine=new it(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=ae(t,"open",function(){r.onopen(),e&&e()}),s=a=>{K("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=ae(t,"error",s);if(this._timeout!==!1){let a=this._timeout;K("connect attempt will timeout after %d",a);let h=this.setTimeoutFn(()=>{K("connect attempt timed out after %d",a),n(),s(new Error("timeout")),t.close()},a);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){K("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ae(e,"ping",this.onping.bind(this)),ae(e,"data",this.ondata.bind(this)),ae(e,"error",this.onerror.bind(this)),ae(e,"close",this.onclose.bind(this)),ae(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){tt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){K("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new wt(this,e,t),this.nsps[e]=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nsps[r].active){K("socket %s is still active, skipping close",r);return}this._close()}_packet(e){K("writing packet %j",e);let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){K("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){K("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){K("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)K("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();K("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(K("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(K("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(K("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Co=Y(Zt(),1),xo=(0,Co.default)("socket.io-client"),ii={};function ri(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=mo(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=ii[n]&&s in ii[n].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,h;return a?(xo("ignoring socket cache for %s",r),h=new bt(r,e)):(ii[n]||(xo("new io instance for %s",r),ii[n]=new bt(r,e)),h=ii[n]),t.query&&!e.query&&(e.query=t.queryKey),h.socket(t.path,e)}Object.assign(ri,{Manager:bt,Socket:wt,io:ri,connect:ri});var xl="https://ws.novu.co",No="notifications.notification_received",ko="notifications.unseen_count_changed",Ao="notifications.unread_count_changed",Cl=({_id:i,content:e,read:t,seen:r,archived:n,snoozedUntil:s,deliveredAt:o,createdAt:a,lastReadDate:h,firstSeenDate:d,archivedAt:l,channel:f,subscriber:u,subject:E,avatar:b,cta:p,tags:w,data:R,workflow:T})=>{var q,te,je,Ge,X,Le,Fe,Ue;let g={id:u==null?void 0:u._id,subscriberId:u==null?void 0:u.subscriberId,firstName:u==null?void 0:u.firstName,lastName:u==null?void 0:u.lastName,avatar:u==null?void 0:u.avatar,locale:u==null?void 0:u.locale,data:u==null?void 0:u.data,timezone:u==null?void 0:u.timezone,email:u==null?void 0:u.email,phone:u==null?void 0:u.phone},y=(te=(q=p.action)==null?void 0:q.buttons)==null?void 0:te.find(ie=>ie.type==="primary"),I=(Ge=(je=p.action)==null?void 0:je.buttons)==null?void 0:Ge.find(ie=>ie.type==="secondary"),A=(Le=(X=p.action)==null?void 0:X.result)==null?void 0:Le.type,M=(Fe=p.action)==null?void 0:Fe.status;return N(v(v({id:i,subject:E,body:e,to:g,isRead:t,isSeen:r,isArchived:n,isSnoozed:!!s},o&&{deliveredAt:o}),s&&{snoozedUntil:s}),{createdAt:a,readAt:h,firstSeenAt:d,archivedAt:l,avatar:b,primaryAction:y&&{label:y.content,isCompleted:A==="primary"&&M==="done",redirect:y.url?{target:y.target,url:y.url}:void 0},secondaryAction:I&&{label:I.content,isCompleted:A==="secondary"&&M==="done",redirect:I.url?{target:I.target,url:I.url}:void 0},channelType:f,tags:w,redirect:(Ue=p.data)!=null&&Ue.url?{url:p.data.url,target:p.data.target}:void 0,data:R,workflow:T})},xt,ye,ce,Ct,Yi,Ji,Xi,be,Ro,an,cn,Ki=class extends Ee{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,be);_(this,xt);_(this,ye);_(this,ce);_(this,Ct);_(this,Yi,({message:t})=>{c(this,ye).emit(No,{result:new U(Cl(t),c(this,ye),this._inboxService)})});_(this,Ji,({unseenCount:t})=>{c(this,ye).emit(ko,{result:t})});_(this,Xi,({unreadCount:t})=>{c(this,ye).emit(Ao,{result:t})});S(this,ye,n),S(this,Ct,t!=null?t:xl)}onSessionSuccess({token:t}){S(this,xt,t)}isSocketEvent(t){return t===No||t===ko||t===Ao}connect(){return m(this,null,function*(){return c(this,xt)?he(this,be,an).call(this):this.callWithSession(he(this,be,an).bind(this))})}disconnect(){return m(this,null,function*(){return c(this,ce)?he(this,be,cn).call(this):this.callWithSession(he(this,be,cn).bind(this))})}};xt=new WeakMap,ye=new WeakMap,ce=new WeakMap,Ct=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,be=new WeakSet,Ro=function(){return m(this,null,function*(){var r,n,s;if(c(this,ce))return;let t={socketUrl:c(this,Ct)};c(this,ye).emit("socket.connect.pending",{args:t}),S(this,ce,ri(c(this,Ct),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${c(this,xt)}`}})),c(this,ce).on("connect",()=>{c(this,ye).emit("socket.connect.resolved",{args:t})}),c(this,ce).on("connect_error",o=>{c(this,ye).emit("socket.connect.resolved",{args:t,error:o})}),(r=c(this,ce))==null||r.on("notification_received",c(this,Yi)),(n=c(this,ce))==null||n.on("unseen_count_changed",c(this,Ji)),(s=c(this,ce))==null||s.on("unread_count_changed",c(this,Xi))})},an=function(){return m(this,null,function*(){try{return yield he(this,be,Ro).call(this),{}}catch(t){return{error:new k("Failed to initialize the socket",t)}}})},cn=function(){return m(this,null,function*(){var t;try{return(t=c(this,ce))==null||t.disconnect(),S(this,ce,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the socket",r)}}})};(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
14
+ `+s),i.push(n+"m+"+er.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=vl()+e+" "+i[0]}function vl(){return j.inspectOpts.hideDate?"":new Date().toISOString()+" "}function _l(...i){return process.stderr.write(Zi.formatWithOptions(j.inspectOpts,...i)+`
15
+ `)}function El(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Sl(){return process.env.DEBUG}function wl(i){i.inspectOpts={};let e=Object.keys(j.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=j.inspectOpts[e[t]]}er.exports=en()(j);var{formatters:Eo}=er.exports;Eo.o=function(i){return this.inspectOpts.colors=this.useColors,Zi.inspect(i,this.inspectOpts).split(`
16
+ `).map(e=>e.trim()).join(" ")};Eo.O=function(i){return this.inspectOpts.colors=this.useColors,Zi.inspect(i,this.inspectOpts)}});var ei=F((Yu,tn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?tn.exports=_o():tn.exports=So()});var Xo="v1",Qo=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,ci=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=Xo,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=Qo,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=v({"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":n},s)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var r;let t=e||typeof window!="undefined"&&((r=window.localStorage)==null?void 0:r.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=v(v({},this.headers),e)}get(e,t,r=!0){return m(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return m(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=Zo(this.apiUrl,e,t?`?${t.toString()}`:""),a={method:(r==null?void 0:r.method)||"GET",headers:v(v({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},h=yield fetch(o,a);if(!h.ok){let l=yield h.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${h.status}, Message: ${l.message}`)}if(h.status===204)return;let d=yield h.json();return n?d.data:d})}};function Zo(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var at="/inbox",Z=`${at}/notifications`,P,li=class{constructor(e={}){this.isSessionInitialized=!1;_(this,P);S(this,P,new ci(e))}initializeSession(n){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,subscriber:r}){let s=yield c(this,P).post(`${at}/session`,{applicationIdentifier:e,subscriberHash:t,subscriber:r});return c(this,P).setAuthorizationToken(s.token),c(this,P).setKeylessHeader(s.applicationIdentifier),this.isSessionInitialized=!0,s})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:a,seen:h,data:d}){let l=new URLSearchParams(`limit=${r}`);return e&&l.append("after",e),n&&l.append("offset",`${n}`),o&&o.forEach(f=>l.append("tags[]",f)),s!==void 0&&l.append("read",`${s}`),t!==void 0&&l.append("archived",`${t}`),a!==void 0&&l.append("snoozed",`${a}`),h!==void 0&&l.append("seen",`${h}`),d!==void 0&&l.append("data",JSON.stringify(d)),c(this,P).get(Z,l,!1)}count({filters:e}){return c(this,P).get(`${Z}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return c(this,P).patch(`${Z}/${e}/read`)}unread(e){return c(this,P).patch(`${Z}/${e}/unread`)}archive(e){return c(this,P).patch(`${Z}/${e}/archive`)}unarchive(e){return c(this,P).patch(`${Z}/${e}/unarchive`)}snooze(e,t){return c(this,P).patch(`${Z}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return c(this,P).patch(`${Z}/${e}/unsnooze`)}readAll({tags:e,data:t}){return c(this,P).post(`${Z}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return c(this,P).post(`${Z}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return c(this,P).post(`${Z}/archive/read`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return c(this,P).post(`${Z}/seen`,{notificationIds:e,tags:t,data:r?JSON.stringify(r):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return c(this,P).patch(`${Z}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return c(this,P).patch(`${Z}/${t}/revert`,{actionType:e})}fetchPreferences(e){let t=new URLSearchParams;e&&e.forEach(n=>t.append("tags[]",n));let r=t.size?`?${t.toString()}`:"";return c(this,P).get(`${at}/preferences${r}`)}bulkUpdatePreferences(e){return c(this,P).patch(`${at}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return c(this,P).patch(`${at}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return c(this,P).patch(`${at}/preferences/${e}`,t)}triggerHelloWorldEvent(){let e={name:"hello-world",to:{subscriberId:"keyless-subscriber-id"},payload:{subject:"Novu Keyless Environment",body:"You're using a keyless demo environment. For full access to Novu features and cloud integration, obtain your API key.",primaryActionText:"Obtain API Key",primaryActionUrl:"https://go.novu.co/keyless",secondaryActionText:"Explore Documentation",secondaryActionUrl:"https://go.novu.co/keyless-docs"}};return c(this,P).post("/inbox/events",e)}};P=new WeakMap;function mn(i){return{all:i=i||new Map,on:function(e,t){var r=i.get(e);r?r.push(t):i.set(e,[t])},off:function(e,t){var r=i.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var r=i.get(e);r&&r.slice().map(function(n){n(t)}),(r=i.get("*"))&&r.slice().map(function(n){n(e,t)})}}}var Ke,hi=class{constructor(){_(this,Ke);S(this,Ke,mn())}on(e,t){return c(this,Ke).on(e,t),()=>{this.off(e,t)}}off(e,t){c(this,Ke).off(e,t)}emit(e,t){c(this,Ke).emit(e,t)}};Ke=new WeakMap;var k=class extends Error{constructor(e,t){super(e),this.originalError=t}};var fi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.read.pending",{args:t,data:s});let o=yield e.read(n),a=new U(o,i,e);return i.emit("notification.read.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new k("Failed to read notification",o)}}}),ui=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(n),a=new U(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new k("Failed to unread notification",o)}}}),di=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(n),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,i,e);return i.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return i.emit("notification.seen.resolved",{args:t,error:o}),{error:new k("Failed to mark notification as seen",o)}}}),pi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.archive.pending",{args:t,data:s});let o=yield e.archive(n),a=new U(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new k("Failed to archive notification",o)}}}),mi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(n),a=new U(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new k("Failed to unarchive notification",o)}}}),gi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:i,apiService:e});try{i.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(n,t.snoozeUntil),a=new U(o,i,e);return i.emit("notification.snooze.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.snooze.resolved",{args:t,error:o}),{error:new k("Failed to snooze notification",o)}}}),yi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ne(t,{isSnoozed:!1,snoozedUntil:null},{emitter:i,apiService:e});try{i.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(n),a=new U(o,i,e);return i.emit("notification.unsnooze.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new k("Failed to unsnooze notification",o)}}}),ct=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:N(v({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:N(v({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:a}=Ne(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:a});let h=yield e.completeAction({actionType:r,notificationId:o}),d=new U(h,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:d}),{data:d}}catch(h){return i.emit("notification.complete_action.resolved",{args:t,error:h}),{error:new k(`Failed to complete ${r} action on the notification`,h)}}}),lt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:N(v({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:N(v({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:a}=Ne(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:a});let h=yield e.revertAction({actionType:r,notificationId:o}),d=new U(h,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:d}),{data:d}}catch(h){return i.emit("notification.revert_action.resolved",{args:t,error:h}),{error:new k("Failed to fetch notifications",h)}}}),Ne=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(v(v({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},gn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let a=t.getUniqueNotifications({tags:r,data:n}).map(h=>new U(N(v({},h),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:r,data:n},data:a}),yield e.readAll({tags:r,data:n}),i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},data:a}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to read all notifications",o)}}}),hr=o=>m(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let a=t.getUniqueNotifications({tags:n,data:s}),d=(r&&r.length>0?a.filter(l=>r.includes(l.id)):a).map(l=>new U(N(v({},l),{isSeen:!0,firstSeenAt:l.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:d}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:d}),{}}catch(a){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:a}),{error:new k("Failed to mark all notifications as seen",a)}}}),yn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let a=t.getUniqueNotifications({tags:r,data:n}).map(h=>new U(N(v({},h),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all.pending",{args:{tags:r,data:n},data:a}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:a}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all notifications",o)}}}),vn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let a=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(h=>new U(N(v({},h),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:a}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:a}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all read notifications",o)}}});var G,Q,U=class{constructor(e,t,r){_(this,G);_(this,Q);S(this,G,t),S(this,Q,r),this.id=e.id,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isSeen=e.isSeen,this.isArchived=e.isArchived,this.isSnoozed=e.isSnoozed,this.snoozedUntil=e.snoozedUntil,this.deliveredAt=e.deliveredAt,this.createdAt=e.createdAt,this.readAt=e.readAt,this.firstSeenAt=e.firstSeenAt,this.archivedAt=e.archivedAt,this.avatar=e.avatar,this.primaryAction=e.primaryAction,this.secondaryAction=e.secondaryAction,this.channelType=e.channelType,this.tags=e.tags,this.redirect=e.redirect,this.data=e.data,this.workflow=e.workflow}read(){return fi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}unread(){return ui({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}seen(){return di({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}archive(){return pi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}unarchive(){return mi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}snooze(e){return gi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this,snoozeUntil:e}})}unsnooze(){return yi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return ct({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return ct({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return lt({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return lt({emitter:c(this,G),apiService:c(this,Q),args:{notification:this},actionType:"secondary"})}on(e,t){let r=c(this,G).on(e,t);return()=>{r()}}off(e,t){c(this,G).off(e,t)}};G=new WeakMap,Q=new WeakMap;var Be,ht,Ee=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,Be,[]);_(this,ht);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),c(this,Be).forEach(a=>m(this,[a],function*({fn:s,resolve:o}){o(yield s())})),S(this,Be,[])):r&&(this.onSessionError(r),S(this,ht,r),c(this,Be).forEach(({resolve:s})=>{s({error:new k("Failed to initialize session, please contact the support",r)})}),S(this,Be,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():c(this,ht)?Promise.resolve({error:new k("Failed to initialize session, please contact the support",c(this,ht))}):new Promise((t,r)=>{c(this,Be).push({fn:e,resolve:t,reject:r})})})}};Be=new WeakMap,ht=new WeakMap;var _n=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var ah=["seen","unseen"],ch=["read","unread"],fr=(i,e)=>_n(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,ur=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},dr=(i,e)=>ur(i.data,e.data)&&fr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen;var de,ft=class{constructor(){_(this,de);S(this,de,new Map)}get(e){return c(this,de).get(e)}getValues(){return Array.from(c(this,de).values())}entries(){return Array.from(c(this,de).entries())}keys(){return Array.from(c(this,de).keys())}set(e,t){c(this,de).set(e,t)}remove(e){c(this,de).delete(e)}clear(){c(this,de).clear()}};de=new WeakMap;var En=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h}).filter(([d,l])=>l!=null&&!(Array.isArray(l)&&l.length===0)).reduce((d,[l,f])=>(d[l]=f,d),{}),pr=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h})=>JSON.stringify(En({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,limit:o,offset:a,after:h})),ea=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s})=>JSON.stringify(En({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s})),ut=i=>JSON.parse(i),ta=["notification.read.pending","notification.read.resolved","notification.unread.pending","notification.unread.resolved","notification.complete_action.pending","notification.complete_action.resolved","notification.revert_action.pending","notification.revert_action.resolved","notifications.read_all.pending","notifications.read_all.resolved"],ia=["notification.archive.pending","notification.unarchive.pending","notification.snooze.pending","notification.unsnooze.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],Me,$,Rt=class{constructor({emitter:e}){_(this,Me);_(this,$);this.updateNotification=(e,t)=>{let r=c(this,$).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s[n]=t,c(this,$).set(e,N(v({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=c(this,$).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s.splice(n,1),c(this,$).set(e,N(v({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>({data:t})=>{if(!t)return;let r=Array.isArray(t)?t:[t],n=new Set;c(this,$).keys().forEach(s=>{r.forEach(o=>{let a=!1;e?a=this.removeNotification(s,o):a=this.updateNotification(s,o),a&&n.add(ea(ut(s)))})}),n.forEach(s=>{let o=this.getAggregated(ut(s));c(this,Me).emit("notifications.list.updated",{data:o})})};S(this,Me,e),ta.forEach(t=>{c(this,Me).on(t,this.handleNotificationEvent())}),ia.forEach(t=>{c(this,Me).on(t,this.handleNotificationEvent({remove:!0}))}),S(this,$,new ft)}getAggregated(e){return c(this,$).keys().filter(r=>{let n=ut(r);return dr(n,e)}).map(r=>c(this,$).get(r)).reduce((r,n)=>n?{hasMore:n.hasMore,filter:n.filter,notifications:[...r.notifications,...n.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}has(e){return c(this,$).get(pr(e))!==void 0}set(e,t){c(this,$).set(pr(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(ut(pr(e)));c(this,Me).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,data:e.data,read:e.read,snoozed:e.snoozed,archived:e.archived,seen:e.seen})}getUniqueNotifications({tags:e,read:t,data:r}){let n=c(this,$).keys(),s=new Map;return n.forEach(o=>{let a=ut(o);if(fr(e,a.tags)&&ur(r,a.data)){let h=c(this,$).get(o);if(!h)return;h.notifications.filter(d=>typeof t=="undefined"||t===d.isRead).forEach(d=>s.set(d.id,d))}}),Array.from(s.values())}clear(e){c(this,$).keys().forEach(r=>{dr(ut(r),e)&&c(this,$).remove(r)})}clearAll(){c(this,$).clear()}};Me=new WeakMap,$=new WeakMap;var Tt,vi=class extends Ee{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Tt);this.cache=new Rt({emitter:n}),S(this,Tt,t)}get inboxService(){return this._inboxService}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=cr(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=v({limit:t},r);try{let a="useCache"in o?o.useCache:c(this,Tt),h=a?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:h}),!h){let d=yield this._inboxService.fetchNotifications(v({limit:t},r));h={hasMore:d.hasMore,filter:d.filter,notifications:d.data.map(l=>new U(l,this._emitter,this._inboxService))},a&&(this.cache.set(o,h),h=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:h}),{data:h}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new k("Failed to fetch notifications",a)}}}))})}count(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){let r=t&&"filters"in t?t.filters:[v({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let n=yield this._inboxService.count({filters:r}),s=t&&"filters"in t?{counts:n.data}:n.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(n){return this._emitter.emit("notifications.count.resolved",{args:t,error:n}),{error:new k("Failed to count notifications",n)}}}))})}read(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return fi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ui({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return di({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return pi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ct({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ct({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return lt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return lt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return gn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){return"notificationIds"in t?hr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):hr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return yn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return vn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){return t?this.cache.clear(t!=null?t:{}):this.cache.clearAll()}triggerHelloWorldEvent(){return m(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};Tt=new WeakMap;var ra=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],na=({tags:i})=>Object.entries({tags:i}).reduce((e,[t,r])=>(r==null||Array.isArray(r)&&r.length===0||(e[t]=r),e),{}),mr=({tags:i})=>JSON.stringify(na({tags:i})),dt,re,_i=class{constructor({emitterInstance:e}){_(this,dt);_(this,re);this.updatePreference=(e,t)=>{let r=c(this,re).get(e);if(!r)return!1;let n=r.findIndex(o=>{var a,h;return((a=o.workflow)==null?void 0:a.id)===((h=t.workflow)==null?void 0:h.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,c(this,re).set(e,s),!0};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;c(this,re).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),a=c(this,re).get(n);!o||!a||r.add(n)})}),r.forEach(n=>{var s;c(this,dt).emit("preferences.list.updated",{data:(s=c(this,re).get(n))!=null?s:[]})})};S(this,dt,e),ra.forEach(t=>{c(this,dt).on(t,this.handlePreferenceEvent)}),S(this,re,new ft)}has(e){return c(this,re).get(mr(e))!==void 0}set(e,t){c(this,re).set(mr(e),t)}getAll(e){if(this.has(e))return c(this,re).get(mr(e))}clearAll(){c(this,re).clear()}};dt=new WeakMap,re=new WeakMap;var Ot,It,Pt,Lt,Se=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){_(this,Ot);_(this,It);_(this,Pt);_(this,Lt);S(this,Ot,t),S(this,It,r),S(this,Pt,n),S(this,Lt,s),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow}update({channels:e,channelPreferences:t}){var r;return Ei({emitter:c(this,Ot),apiService:c(this,It),cache:c(this,Pt),useCache:c(this,Lt),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};Ot=new WeakMap,It=new WeakMap,Pt=new WeakMap,Lt=new WeakMap;var Ei=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var h;let{channels:o}=n,a="workflowId"in n?n.workflowId:(h=n.preference.workflow)==null?void 0:h.id;try{i.emit("preference.update.pending",{args:n,data:"preference"in n?new Se(N(v({},n.preference),{channels:v(v({},n.preference.channels),o)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0});let d;a?d=yield e.updateWorkflowPreferences({workflowId:a,channels:o}):(sa({emitter:i,apiService:e,cache:t,useCache:r,args:n}),d=yield e.updateGlobalPreferences(o));let l=new Se(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.update.resolved",{args:n,data:l}),{data:l}}catch(d){return i.emit("preference.update.resolved",{args:n,error:d}),{error:new k("Failed to update preference",d)}}}),Sn=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){if(n.find(a=>"preference"in a&&a.preference.level==="global"))return{error:new k("Global preference is not supported in bulk update","")};try{let a=n.map(f=>"preference"in f?new Se(N(v({},f.preference),{channels:v(v({},f.preference.channels),f.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0).filter(f=>f!==void 0);i.emit("preferences.bulk_update.pending",{args:n,data:a});let h=n.map(f=>{var u,E,b,p;return v({workflowId:"workflowId"in f?f.workflowId:(p=(b=(u=f.preference.workflow)==null?void 0:u.id)!=null?b:(E=f.preference.workflow)==null?void 0:E.identifier)!=null?p:""},f.channels)}),l=(yield e.bulkUpdatePreferences(h)).map(f=>new Se(f,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}));return i.emit("preferences.bulk_update.resolved",{args:n,data:l}),{data:l}}catch(a){return i.emit("preferences.bulk_update.resolved",{args:n,error:a}),{error:new k("Failed to bulk update preferences",a)}}}),sa=({emitter:i,apiService:e,cache:t,useCache:r,args:n})=>{let s=r?t==null?void 0:t.getAll({}):void 0;s==null||s.forEach(o=>{var a,h;if(o.level==="template"){let d=N(v({},o),{channels:Object.entries(o.channels).reduce((f,[u,E])=>{var p;let b=u;return f[b]=(p=n.channels[b])!=null?p:E,f},{})}),l="preference"in n?new Se(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0;l&&i.emit("preference.update.pending",{args:{workflowId:(h=(a=o.workflow)==null?void 0:a.id)!=null?h:"",channels:l.channels},data:l})}})};var ke,Si=class extends Ee{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,ke);this.cache=new _i({emitterInstance:this._emitter}),S(this,ke,t)}list(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){try{let r=c(this,ke)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:r}),r||(r=(yield this._inboxService.fetchPreferences(t.tags)).map(s=>new Se(s,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:c(this,ke)})),c(this,ke)&&(this.cache.set(t,r),r=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:r}),{data:r}}catch(r){throw this._emitter.emit("preferences.list.resolved",{args:t,error:r}),r}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Ei({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:c(this,ke),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>Sn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:c(this,ke),args:t}))})}};ke=new WeakMap;function wn(){return typeof window!="undefined"}var Ye,Ft,fe,wi=class{constructor(e,t,r){_(this,Ye);_(this,Ft);_(this,fe);S(this,Ye,r),S(this,Ft,t),S(this,fe,e)}get applicationIdentifier(){return c(this,fe).applicationIdentifier}get subscriberId(){var e;return(e=c(this,fe).subscriber)==null?void 0:e.subscriberId}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let r="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(r);case"store":return t&&window.localStorage.setItem(r,t),null;case"delete":return window.localStorage.removeItem(r),null;default:return null}}initialize(e){return m(this,null,function*(){var t,r,n,s,o,a;if(((t=c(this,fe).subscriber)==null?void 0:t.subscriberId)!==((r=e==null?void 0:e.subscriber)==null?void 0:r.subscriberId))try{e&&S(this,fe,e);let{subscriber:h,subscriberHash:d,applicationIdentifier:l}=c(this,fe),f;wn()&&(f=Intl.DateTimeFormat().resolvedOptions().timeZone);let u=l;if(u)this.handleApplicationIdentifier("delete");else{let b=this.handleApplicationIdentifier("get");b&&(u=b)}c(this,Ye).emit("session.initialize.pending",{args:c(this,fe)});let E=yield c(this,Ft).initializeSession({applicationIdentifier:u,subscriberHash:d,subscriber:N(v({},h),{subscriberId:(n=h==null?void 0:h.subscriberId)!=null?n:"",timezone:(s=h==null?void 0:h.timezone)!=null?s:f})});(o=E==null?void 0:E.applicationIdentifier)!=null&&o.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",E.applicationIdentifier),(a=E==null?void 0:E.applicationIdentifier)!=null&&a.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),c(this,Ye).emit("session.initialize.resolved",{args:c(this,fe),data:E})}catch(h){c(this,Ye).emit("session.initialize.resolved",{args:c(this,fe),error:h})}})}};Ye=new WeakMap,Ft=new WeakMap,fe=new WeakMap;function bn({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
17
17
  PartySocket requires a global 'EventTarget' class to be available!
18
18
  You can polyfill this global by adding this to your code before any partysocket imports:
19
19
 
@@ -21,7 +21,7 @@
21
21
  import 'partysocket/event-target-polyfill';
22
22
  \`\`\`
23
23
  Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
24
- `);var Io=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},Po=class extends Event{constructor(e=1e3,t="",r){super("close",r);O(this,"code");O(this,"reason");O(this,"wasClean",!0);this.code=e,this.reason=t}},ln={Event,ErrorEvent:Io,CloseEvent:Po};function Nl(i,e){if(!i)throw new Error(e)}function kl(i){return new i.constructor(i.type,i)}function Al(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Po(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Io(i.error,i):new Event(i.type,i)}var To,Rl=typeof process!="undefined"&&typeof((To=process.versions)==null?void 0:To.node)!="undefined"&&typeof document=="undefined",Qi=Rl?Al:kl,nt={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:Number.POSITIVE_INFINITY,maxEnqueuedMessages:Number.POSITIVE_INFINITY,startClosed:!1,debug:!1},Oo=!1,Zi=class st extends EventTarget{constructor(t,r,n={}){super();O(this,"_ws");O(this,"_retryCount",-1);O(this,"_uptimeTimeout");O(this,"_connectTimeout");O(this,"_shouldReconnect",!0);O(this,"_connectLock",!1);O(this,"_binaryType","blob");O(this,"_closeCalled",!1);O(this,"_messageQueue",[]);O(this,"_debugLogger",console.log.bind(console));O(this,"_url");O(this,"_protocols");O(this,"_options");O(this,"onclose",null);O(this,"onerror",null);O(this,"onmessage",null);O(this,"onopen",null);O(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=nt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),Nl(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(n=>{var s;return(s=this._ws)==null?void 0:s.send(n)}),this._messageQueue=[],this.onopen&&this.onopen(t),this.dispatchEvent(Qi(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Qi(t))});O(this,"_handleError",t=>{this._debug("error event",t.message),this._disconnect(void 0,t.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(t),this._debug("exec error listeners"),this.dispatchEvent(Qi(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(Qi(t))});this._url=t,this._protocols=r,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return st.CONNECTING}get OPEN(){return st.OPEN}get CLOSING(){return st.CLOSING}get CLOSED(){return st.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((r,n)=>(typeof n=="string"?r+=n.length:n instanceof Blob?r+=n.size:r+=n.byteLength,r),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?st.CLOSED:st.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,r){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,r)}reconnect(t,r){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,r),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{let{maxEnqueuedMessages:r=nt.maxEnqueuedMessages}=this._options;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){let{reconnectionDelayGrowFactor:t=nt.reconnectionDelayGrowFactor,minReconnectionDelay:r=nt.minReconnectionDelay,maxReconnectionDelay:n=nt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*pn(t,this._retryCount-1),s>n&&(s=n)),this._debug("next delay",s),s}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_getNextProtocols(t){if(!t)return Promise.resolve(null);if(typeof t=="string"||Array.isArray(t))return Promise.resolve(t);if(typeof t=="function"){let r=t();if(!r)return Promise.resolve(null);if(typeof r=="string"||Array.isArray(r))return Promise.resolve(r);if(r.then)return r}throw Error("Invalid protocols")}_getNextUrl(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){let r=t();if(typeof r=="string")return Promise.resolve(r);if(r.then)return r}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:t=nt.maxRetries,connectionTimeout:r=nt.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([n,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket=="undefined"&&!Oo&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
24
+ `);var Nn=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},kn=class extends Event{constructor(e=1e3,t="",r){super("close",r);O(this,"code");O(this,"reason");O(this,"wasClean",!0);this.code=e,this.reason=t}},gr={Event,ErrorEvent:Nn,CloseEvent:kn};function oa(i,e){if(!i)throw new Error(e)}function aa(i){return new i.constructor(i.type,i)}function ca(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new kn(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Nn(i.error,i):new Event(i.type,i)}var xn,la=typeof process!="undefined"&&typeof((xn=process.versions)==null?void 0:xn.node)!="undefined"&&typeof document=="undefined",bi=la?ca:aa,Je={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:Number.POSITIVE_INFINITY,maxEnqueuedMessages:Number.POSITIVE_INFINITY,startClosed:!1,debug:!1},Cn=!1,xi=class Xe extends EventTarget{constructor(t,r,n={}){super();O(this,"_ws");O(this,"_retryCount",-1);O(this,"_uptimeTimeout");O(this,"_connectTimeout");O(this,"_shouldReconnect",!0);O(this,"_connectLock",!1);O(this,"_binaryType","blob");O(this,"_closeCalled",!1);O(this,"_messageQueue",[]);O(this,"_debugLogger",console.log.bind(console));O(this,"_url");O(this,"_protocols");O(this,"_options");O(this,"onclose",null);O(this,"onerror",null);O(this,"onmessage",null);O(this,"onopen",null);O(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=Je.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),oa(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(n=>{var s;return(s=this._ws)==null?void 0:s.send(n)}),this._messageQueue=[],this.onopen&&this.onopen(t),this.dispatchEvent(bi(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(bi(t))});O(this,"_handleError",t=>{this._debug("error event",t.message),this._disconnect(void 0,t.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(t),this._debug("exec error listeners"),this.dispatchEvent(bi(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(bi(t))});this._url=t,this._protocols=r,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return Xe.CONNECTING}get OPEN(){return Xe.OPEN}get CLOSING(){return Xe.CLOSING}get CLOSED(){return Xe.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((r,n)=>(typeof n=="string"?r+=n.length:n instanceof Blob?r+=n.size:r+=n.byteLength,r),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?Xe.CLOSED:Xe.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,r){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,r)}reconnect(t,r){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,r),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{let{maxEnqueuedMessages:r=Je.maxEnqueuedMessages}=this._options;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){let{reconnectionDelayGrowFactor:t=Je.reconnectionDelayGrowFactor,minReconnectionDelay:r=Je.minReconnectionDelay,maxReconnectionDelay:n=Je.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*pn(t,this._retryCount-1),s>n&&(s=n)),this._debug("next delay",s),s}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_getNextProtocols(t){if(!t)return Promise.resolve(null);if(typeof t=="string"||Array.isArray(t))return Promise.resolve(t);if(typeof t=="function"){let r=t();if(!r)return Promise.resolve(null);if(typeof r=="string"||Array.isArray(r))return Promise.resolve(r);if(r.then)return r}throw Error("Invalid protocols")}_getNextUrl(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){let r=t();if(typeof r=="string")return Promise.resolve(r);if(r.then)return r}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:t=Je.maxRetries,connectionTimeout:r=Je.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([n,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket=="undefined"&&!Cn&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
25
25
 
26
26
  For example, if you're using node.js, run \`npm install ws\`, and then in your code:
27
27
 
@@ -34,7 +34,7 @@ const partysocket = new PartySocket({
34
34
  WebSocket: WS
35
35
  });
36
36
 
37
- `),Oo=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:n,protocols:s}),this._ws=s?new o(n,s):new o(n),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),r)}).catch(n=>{this._connectLock=!1,this._handleError(new ln.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new ln.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,r){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,r),this._handleClose(new ln.CloseEvent(t,r,this))}catch(n){}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var ni="wss://socket.novu.co",Lo="notifications.notification_received",Fo="notifications.unseen_count_changed",Uo="notifications.unread_count_changed",Tl=({_id:i,content:e,read:t,seen:r,archived:n,snoozedUntil:s,deliveredAt:o,createdAt:a,lastReadDate:h,firstSeenDate:d,archivedAt:l,channel:f,subscriber:u,subject:E,avatar:b,cta:p,tags:w,data:R,workflow:T})=>{var q,te,je,Ge,X,Le,Fe,Ue;let g={id:u==null?void 0:u._id,subscriberId:u==null?void 0:u.subscriberId,firstName:u==null?void 0:u.firstName,lastName:u==null?void 0:u.lastName,avatar:u==null?void 0:u.avatar,locale:u==null?void 0:u.locale,data:u==null?void 0:u.data,timezone:u==null?void 0:u.timezone,email:u==null?void 0:u.email,phone:u==null?void 0:u.phone},y=(te=(q=p.action)==null?void 0:q.buttons)==null?void 0:te.find(ie=>ie.type==="primary"),I=(Ge=(je=p.action)==null?void 0:je.buttons)==null?void 0:Ge.find(ie=>ie.type==="secondary"),A=(Le=(X=p.action)==null?void 0:X.result)==null?void 0:Le.type,M=(Fe=p.action)==null?void 0:Fe.status;return N(v(v({id:i,subject:E,body:e,to:g,isRead:t,isSeen:r,isArchived:n,isSnoozed:!!s},o&&{deliveredAt:o}),s&&{snoozedUntil:s}),{createdAt:a,readAt:h,firstSeenAt:d,archivedAt:l,avatar:b,primaryAction:y&&{label:y.content,isCompleted:A==="primary"&&M==="done",redirect:y.url?{target:y.target,url:y.url}:void 0},secondaryAction:I&&{label:I.content,isCompleted:A==="secondary"&&M==="done",redirect:I.url?{target:I.target,url:I.url}:void 0},channelType:f,tags:w,redirect:(Ue=p.data)!=null&&Ue.url?{url:p.data.url,target:p.data.target}:void 0,data:R,workflow:T})},Nt,ve,_e,kt,tr,ir,rr,nr,xe,Do,hn,fn,er=class extends Ee{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,xe);_(this,Nt);_(this,ve);_(this,_e);_(this,kt);_(this,tr,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&c(this,ve).emit(Lo,{result:new U(Tl(r.data.message),c(this,ve),this._inboxService)})}catch(r){console.log("error",r)}});_(this,ir,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&c(this,ve).emit(Fo,{result:r.data.unseenCount})}catch(r){}});_(this,rr,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&c(this,ve).emit(Uo,{result:r.data.unreadCount})}catch(r){}});_(this,nr,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":c(this,tr).call(this,t);break;case"unseen_count_changed":c(this,ir).call(this,t);break;case"unread_count_changed":c(this,rr).call(this,t);break;default:}}catch(r){}});S(this,ve,n),S(this,kt,t!=null?t:ni)}onSessionSuccess({token:t}){S(this,Nt,t)}isSocketEvent(t){return t===Lo||t===Fo||t===Uo}connect(){return m(this,null,function*(){return c(this,Nt)?he(this,xe,hn).call(this):this.callWithSession(he(this,xe,hn).bind(this))})}disconnect(){return m(this,null,function*(){return c(this,_e)?he(this,xe,fn).call(this):this.callWithSession(he(this,xe,fn).bind(this))})}};Nt=new WeakMap,ve=new WeakMap,_e=new WeakMap,kt=new WeakMap,tr=new WeakMap,ir=new WeakMap,rr=new WeakMap,nr=new WeakMap,xe=new WeakSet,Do=function(){return m(this,null,function*(){if(c(this,_e))return;let t={socketUrl:c(this,kt)};c(this,ve).emit("socket.connect.pending",{args:t});let r=new URL(c(this,kt));r.searchParams.set("token",c(this,Nt)),S(this,_e,new Zi(r.toString())),c(this,_e).addEventListener("open",()=>{c(this,ve).emit("socket.connect.resolved",{args:t})}),c(this,_e).addEventListener("error",n=>{c(this,ve).emit("socket.connect.resolved",{args:t,error:n})}),c(this,_e).addEventListener("message",c(this,nr))})},hn=function(){return m(this,null,function*(){try{return yield he(this,xe,Do).call(this),{}}catch(t){return{error:new k("Failed to initialize the PartySocket",t)}}})},fn=function(){return m(this,null,function*(){var t;try{return(t=c(this,_e))==null||t.close(),S(this,_e,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the PartySocket",r)}}})};var Ol=["wss://eu.socket.novu.co",ni,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Il={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":ni,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function Pl(i){return i?Il[i]||i:ni}function Ll(i){return!i||Ol.includes(i)}function Bo({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=Pl(i);switch(Ll(r)?"partysocket":"socket.io"){case"partysocket":return new er({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new Ki({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}function Mo({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}var Ce,Pe,He,sr=class{constructor(e){_(this,Ce);_(this,Pe);_(this,He);var t,r;S(this,He,new li({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),S(this,Ce,new hi),S(this,Pe,new wi({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:Mo({subscriberId:e.subscriberId,subscriber:e.subscriber})},c(this,He),c(this,Ce))),c(this,Pe).initialize(),this.notifications=new vi({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:c(this,He),eventEmitterInstance:c(this,Ce)}),this.preferences=new Si({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:c(this,He),eventEmitterInstance:c(this,Ce)}),this.socket=Bo({socketUrl:e.socketUrl,eventEmitterInstance:c(this,Ce),inboxServiceInstance:c(this,He)}),this.on=(n,s)=>{this.socket.isSocketEvent(n)&&this.socket.connect();let o=c(this,Ce).on(n,s);return()=>{o()}},this.off=(n,s)=>{c(this,Ce).off(n,s)}}get applicationIdentifier(){return c(this,Pe).applicationIdentifier}get subscriberId(){return c(this,Pe).subscriberId}changeSubscriber(e){return m(this,null,function*(){yield c(this,Pe).initialize({applicationIdentifier:c(this,Pe).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber})})}};Ce=new WeakMap,Pe=new WeakMap,He=new WeakMap;window.Novu=sr;})();
37
+ `),Cn=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:n,protocols:s}),this._ws=s?new o(n,s):new o(n),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),r)}).catch(n=>{this._connectLock=!1,this._handleError(new gr.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new gr.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,r){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,r),this._handleClose(new gr.CloseEvent(t,r,this))}catch(n){}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var Ut="wss://socket.novu.co",An="notifications.notification_received",Rn="notifications.unseen_count_changed",Tn="notifications.unread_count_changed",ha=({_id:i,content:e,read:t,seen:r,archived:n,snoozedUntil:s,deliveredAt:o,createdAt:a,lastReadDate:h,firstSeenDate:d,archivedAt:l,channel:f,subscriber:u,subject:E,avatar:b,cta:p,tags:w,data:R,workflow:T})=>{var q,te,je,Ge,X,Le,Fe,Ue;let g={id:u==null?void 0:u._id,subscriberId:u==null?void 0:u.subscriberId,firstName:u==null?void 0:u.firstName,lastName:u==null?void 0:u.lastName,avatar:u==null?void 0:u.avatar,locale:u==null?void 0:u.locale,data:u==null?void 0:u.data,timezone:u==null?void 0:u.timezone,email:u==null?void 0:u.email,phone:u==null?void 0:u.phone},y=(te=(q=p.action)==null?void 0:q.buttons)==null?void 0:te.find(ie=>ie.type==="primary"),I=(Ge=(je=p.action)==null?void 0:je.buttons)==null?void 0:Ge.find(ie=>ie.type==="secondary"),A=(Le=(X=p.action)==null?void 0:X.result)==null?void 0:Le.type,M=(Fe=p.action)==null?void 0:Fe.status;return N(v(v({id:i,subject:E,body:e,to:g,isRead:t,isSeen:r,isArchived:n,isSnoozed:!!s},o&&{deliveredAt:o}),s&&{snoozedUntil:s}),{createdAt:a,readAt:h,firstSeenAt:d,archivedAt:l,avatar:b,primaryAction:y&&{label:y.content,isCompleted:A==="primary"&&M==="done",redirect:y.url?{target:y.target,url:y.url}:void 0},secondaryAction:I&&{label:I.content,isCompleted:A==="secondary"&&M==="done",redirect:I.url?{target:I.target,url:I.url}:void 0},channelType:f,tags:w,redirect:(Ue=p.data)!=null&&Ue.url?{url:p.data.url,target:p.data.target}:void 0,data:R,workflow:T})},pt,pe,me,mt,Ni,ki,Ai,Ri,we,On,yr,vr,Ci=class extends Ee{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,we);_(this,pt);_(this,pe);_(this,me);_(this,mt);_(this,Ni,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&c(this,pe).emit(An,{result:new U(ha(r.data.message),c(this,pe),this._inboxService)})}catch(r){console.log("error",r)}});_(this,ki,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&c(this,pe).emit(Rn,{result:r.data.unseenCount})}catch(r){}});_(this,Ai,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&c(this,pe).emit(Tn,{result:r.data.unreadCount})}catch(r){}});_(this,Ri,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":c(this,Ni).call(this,t);break;case"unseen_count_changed":c(this,ki).call(this,t);break;case"unread_count_changed":c(this,Ai).call(this,t);break;default:}}catch(r){}});S(this,pe,n),S(this,mt,t!=null?t:Ut)}onSessionSuccess({token:t}){S(this,pt,t)}isSocketEvent(t){return t===An||t===Rn||t===Tn}connect(){return m(this,null,function*(){return c(this,pt)?he(this,we,yr).call(this):this.callWithSession(he(this,we,yr).bind(this))})}disconnect(){return m(this,null,function*(){return c(this,me)?he(this,we,vr).call(this):this.callWithSession(he(this,we,vr).bind(this))})}};pt=new WeakMap,pe=new WeakMap,me=new WeakMap,mt=new WeakMap,Ni=new WeakMap,ki=new WeakMap,Ai=new WeakMap,Ri=new WeakMap,we=new WeakSet,On=function(){return m(this,null,function*(){if(c(this,me))return;let t={socketUrl:c(this,mt)};c(this,pe).emit("socket.connect.pending",{args:t});let r=new URL(c(this,mt));r.searchParams.set("token",c(this,pt)),S(this,me,new xi(r.toString())),c(this,me).addEventListener("open",()=>{c(this,pe).emit("socket.connect.resolved",{args:t})}),c(this,me).addEventListener("error",n=>{c(this,pe).emit("socket.connect.resolved",{args:t,error:n})}),c(this,me).addEventListener("message",c(this,Ri))})},yr=function(){return m(this,null,function*(){try{return yield he(this,we,On).call(this),{}}catch(t){return{error:new k("Failed to initialize the PartySocket",t)}}})},vr=function(){return m(this,null,function*(){var t;try{return(t=c(this,me))==null||t.close(),S(this,me,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the PartySocket",r)}}})};var ge=Object.create(null);ge.open="0";ge.close="1";ge.ping="2";ge.pong="3";ge.message="4";ge.upgrade="5";ge.noop="6";var Dt=Object.create(null);Object.keys(ge).forEach(i=>{Dt[ge[i]]=i});var Bt={type:"error",data:"parser error"};var Mt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+In(e,!0).toString("base64")):r(ge[i]+(e||"")),In=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),_r;function Pn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(In(i.data,!1));Mt(i,!0,t=>{_r||(_r=new TextEncoder),e(_r.encode(t))})}var qt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Ln(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Ln(r,e)}}return Dt[t]?i.length>1?{type:Dt[t],data:i.substring(1)}:{type:Dt[t]}:Bt},Ln=(i,e)=>{switch(e){case"arraybuffer":return i instanceof ArrayBuffer?i:Buffer.isBuffer(i)?i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength):i.buffer;case"nodebuffer":default:return Buffer.isBuffer(i)?i:Buffer.from(i)}};var Fn="",Un=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Mt(s,!1,a=>{r[o]=a,++n===t&&e(r.join(Fn))})})},Dn=(i,e)=>{let t=i.split(Fn),r=[];for(let n=0;n<t.length;n++){let s=qt(t[n],e);if(r.push(s),s.type==="error")break}return r};function Bn(){return new TransformStream({transform(i,e){Pn(i,t=>{let r=t.length,n;if(r<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,r);else if(r<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(n[0]|=128),e.enqueue(n),e.enqueue(t)})}})}var Er;function Ti(i){return i.reduce((e,t)=>e+t.length,0)}function Oi(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let n=0;n<e;n++)t[n]=i[0][r++],r===i[0].length&&(i.shift(),r=0);return i.length&&r<i[0].length&&(i[0]=i[0].slice(r)),t}function Mn(i,e){Er||(Er=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(r===0){if(Ti(t)<1)break;let h=Oi(t,1);s=(h[0]&128)===128,n=h[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(Ti(t)<2)break;let h=Oi(t,2);n=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(Ti(t)<8)break;let h=Oi(t,8),d=new DataView(h.buffer,h.byteOffset,h.length),l=d.getUint32(0);if(l>Math.pow(2,21)-1){a.enqueue(Bt);break}n=l*Math.pow(2,32)+d.getUint32(4),r=3}else{if(Ti(t)<n)break;let h=Oi(t,n);a.enqueue(qt(s?h:Er.decode(h),e)),r=0}if(n===0||n>i){a.enqueue(Bt);break}}}})}var Sr=4;function L(i){if(i)return fa(i)}function fa(i){for(var e in L.prototype)i[e]=L.prototype[e];return i}L.prototype.on=L.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};L.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(i,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+i];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var r,n=0;n<t.length;n++)if(r=t[n],r===e||r.fn===e){t.splice(n,1);break}return t.length===0&&delete this._callbacks["$"+i],this};L.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+i],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,n=t.length;r<n;++r)t[r].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};L.prototype.hasListeners=function(i){return!!this.listeners(i).length};var ye=global;function Ii(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var ua=ye.setTimeout,da=ye.clearTimeout;function Ae(i,e){e.useNativeTimers?(i.setTimeoutFn=ua.bind(ye),i.clearTimeoutFn=da.bind(ye)):(i.setTimeoutFn=ye.setTimeout.bind(ye),i.clearTimeoutFn=ye.clearTimeout.bind(ye))}var pa=1.33;function qn(i){return typeof i=="string"?ma(i):Math.ceil((i.byteLength||i.size)*pa)}function ma(i){let e=0,t=0;for(let r=0,n=i.length;r<n;r++)e=i.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}var Qn=Y(Ze(),1);function Jn(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function Xn(i){let e={},t=i.split("&");for(let r=0,n=t.length;r<n;r++){let s=t[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var Ba=(0,Qn.default)("engine.io-client:transport"),Ar=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Re=class extends L{constructor(e){super(),this.writable=!1,Ae(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Ar(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):Ba("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=qt(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(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Jn(e);return t.length?"?"+t:""}};var cs=Y(Ze(),1);var is="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Rr=64,Ma={},Zn=0,Di=0,es;function ts(i){let e="";do e=is[i%Rr]+e,i=Math.floor(i/Rr);while(i>0);return e}function Bi(){let i=ts(+new Date);return i!==es?(Zn=0,es=i):i+"."+ts(Zn++)}for(;Di<Rr;Di++)Ma[is[Di]]=Di;var Ir=Y(ss(),1),Pr=Ir.default||Ir;function os(){return new Or}function Wa(i){let e=i.split("; "),t=e[0].indexOf("=");if(t===-1)return;let r=e[0].substring(0,t).trim();if(!r.length)return;let n=e[0].substring(t+1).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));let s={name:r,value:n};for(let o=1;o<e.length;o++){let a=e[o].split("=");if(a.length!==2)continue;let h=a[0].trim(),d=a[1].trim();switch(h){case"Expires":s.expires=new Date(d);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(d,10)),s.expires=l;break;default:}}return s}var Or=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=Wa(r);n&&this.cookies.set(n.name,n)})}addCookies(e){let t=[];this.cookies.forEach((r,n)=>{var s;((s=r.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(n):t.push(`${n}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var ee=(0,cs.default)("engine.io-client:polling");function za(){}var $a=function(){return new Pr({xdomain:!1}).responseType!=null}(),Mi=class extends Re{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",n=location.port;n||(n=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||n!==e.port}let t=e&&e.forceBase64;this.supportsBinary=$a&&!t,this.opts.withCredentials&&(this.cookieJar=os())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{ee("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(ee("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){ee("pre-pause polling complete"),--r||t()})),this.writable||(ee("we are currently writing - waiting to pause"),r++,this.once("drain",function(){ee("pre-pause writing complete"),--r||t()}))}else t()}poll(){ee("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){ee("polling got data %s",e);let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Dn(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():ee('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{ee("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(ee("transport open - closing"),e()):(ee("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Un(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Bi()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new We(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(n,s)=>{this.onError("xhr post error",n,s)})}doPoll(){ee("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},We=class i extends L{constructor(e,t){super(),Ae(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;let t=Ii(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Pr(t);try{ee("xhr open %s: %s",this.method,this.uri),r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch(n){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{r.setRequestHeader("Accept","*/*")}catch(n){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var n;r.readyState===3&&((n=this.opts.cookieJar)===null||n===void 0||n.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},ee("xhr data %s",this.data),r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document!="undefined"&&(this.index=i.requestsCount++,i.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=za,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete i.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};We.requestsCount=0;We.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",as);else if(typeof addEventListener=="function"){let i="onpagehide"in ye?"pagehide":"unload";addEventListener(i,as,!1)}}function as(){for(let i in We.requests)We.requests.hasOwnProperty(i)&&We.requests[i].abort()}var Zc=Y(us(),1),el=Y(zr(),1),tl=Y(Vr(),1),ho=Y(Xr(),1),il=Y(lo(),1);var fo=ho.default;var Qt=fo,Yi=!1,uo="nodebuffer",rt=process.nextTick;var mo=Y(Ze(),1);var rl=(0,mo.default)("engine.io-client:websocket"),po=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ji=class extends Re{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,r=po?{}:Ii(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=Yi&&!po?t?new Qt(e,t):new Qt(e):new Qt(e,t,r)}catch(n){return this.emitReserved("error",n)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],n=t===e.length-1;Mt(r,this.supportsBinary,s=>{let o={};Yi||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{Yi?this.ws.send(s):this.ws.send(s,o)}catch(a){rl("websocket closed before onclose event")}n&&rt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Bi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Qt}};var go=Y(Ze(),1),Zt=(0,go.default)("engine.io-client:webtransport"),Xi=class extends Re{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Zt("transport closed gracefully"),this.onClose()}).catch(e=>{Zt("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Mn(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Bn();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:a,value:h})=>{if(a){Zt("session is closed");return}Zt("received chunk: %o",h),this.onPacket(h),s()}).catch(a=>{Zt("an error occurred while reading: %s",a)})};s();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],n=t===e.length-1;this.writer.write(r).then(()=>{n&&rt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Zr={websocket:Ji,webtransport:Xi,polling:Mi};var nl=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,sl=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function bt(i){let e=i,t=i.indexOf("["),r=i.indexOf("]");t!=-1&&r!=-1&&(i=i.substring(0,t)+i.substring(t,r).replace(/:/g,";")+i.substring(r,i.length));let n=nl.exec(i||""),s={},o=14;for(;o--;)s[sl[o]]=n[o]||"";return t!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=ol(s,s.path),s.queryKey=al(s,s.query),s}function ol(i,e){let t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function al(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var yo=Y(Ze(),1);var D=(0,yo.default)("engine.io-client:socket"),nt=class i extends L{constructor(e,t={}){super(),this.binaryType=uo,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=bt(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=bt(t.host).host),Ae(this,t),this.secure=t.secure!=null?t.secure:typeof location!="undefined"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=t.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Xn(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){D('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Sr,t.transport=e,this.id&&(t.sid=this.id);let r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return D("options: %j",r),new Zr[e](r)}open(){let e;if(this.opts.rememberUpgrade&&i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){D("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){D("setting transport %s",e.name),this.transport&&(D("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){D('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(D('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(D('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",D('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(D("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{D('probe transport "%s" failed',e);let u=new Error("probe error");u.transport=t.name,this.emitReserved("upgradeError",u)}}))};function s(){r||(r=!0,l(),t.close(),t=null)}let o=f=>{let u=new Error("probe error: "+f);u.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",u)};function a(){o("transport closed")}function h(){o("socket closed")}function d(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let l=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",a),this.off("close",h),this.off("upgrading",d)};t.once("open",n),t.once("error",o),t.once("close",a),this.once("close",h),this.once("upgrading",d),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(D("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){D("starting upgrade probes");let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(D('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else D('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();D("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let n=this.writeBuffer[r].data;if(n&&(t+=qn(n)),r>0&&t>this.maxPayload)return D("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return D("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if(typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:e,data:t,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this.onClose("forced close"),D("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){D("socket error %j",e),i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(D('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],r=0,n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};nt.protocol=Sr;var Wu=nt.protocol;var bo=Y(ei(),1),wo=(0,bo.default)("socket.io-client:url");function xo(i,e="",t){let r=i;t=t||typeof location!="undefined"&&location,i==null&&(i=t.protocol+"//"+t.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=t.protocol+i:i=t.host+i),/^(https?|wss?):\/\//.test(i)||(wo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),wo("parse %s",i),r=bt(i)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";let s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(t&&t.port===r.port?"":":"+r.port),r}var ln={};Yo(ln,{Decoder:()=>an,Encoder:()=>on,PacketType:()=>x,protocol:()=>To});var bl=typeof ArrayBuffer=="function",xl=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Co=Object.prototype.toString,Cl=typeof Blob=="function"||typeof Blob!="undefined"&&Co.call(Blob)==="[object BlobConstructor]",Nl=typeof File=="function"||typeof File!="undefined"&&Co.call(File)==="[object FileConstructor]";function ii(i){return bl&&(i instanceof ArrayBuffer||xl(i))||Cl&&i instanceof Blob||Nl&&i instanceof File}function ti(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(ti(i[t]))return!0;return!1}if(ii(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return ti(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&ti(i[t]))return!0;return!1}function No(i){let e=[],t=i.data,r=i;return r.data=rn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function rn(i,e){if(!i)return i;if(ii(i)){let t={_placeholder:!0,num:e.length};return e.push(i),t}else if(Array.isArray(i)){let t=new Array(i.length);for(let r=0;r<i.length;r++)t[r]=rn(i[r],e);return t}else if(typeof i=="object"&&!(i instanceof Date)){let t={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=rn(i[r],e));return t}return i}function ko(i,e){return i.data=nn(i.data,e),delete i.attachments,i}function nn(i,e){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<e.length)return e[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let t=0;t<i.length;t++)i[t]=nn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=nn(i[t],e));return i}var Ro=Y(Ze(),1),sn=(0,Ro.default)("socket.io-parser"),kl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],To=5,x;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(x||(x={}));var on=class{constructor(e){this.replacer=e}encode(e){return sn("encoding packet %j",e),(e.type===x.EVENT||e.type===x.ACK)&&ti(e)?this.encodeAsBinary({type:e.type===x.EVENT?x.BINARY_EVENT:x.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===x.BINARY_EVENT||e.type===x.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),sn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=No(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function Ao(i){return Object.prototype.toString.call(i)==="[object Object]"}var an=class i extends L{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let r=t.type===x.BINARY_EVENT;r||t.type===x.BINARY_ACK?(t.type=r?x.EVENT:x.ACK,this.reconstructor=new cn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ii(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,r={type:Number(e.charAt(0))};if(x[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===x.BINARY_EVENT||r.type===x.BINARY_ACK){let s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(s,t)}else r.nsp="/";let n=e.charAt(t+1);if(n!==""&&Number(n)==n){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return sn("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case x.CONNECT:return Ao(t);case x.DISCONNECT:return t===void 0;case x.CONNECT_ERROR:return typeof t=="string"||Ao(t);case x.EVENT:case x.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&kl.indexOf(t[0])===-1);case x.ACK:case x.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},cn=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=ko(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ae(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Oo=Y(ei(),1),z=(0,Oo.default)("socket.io-client:socket"),Al=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),xt=class extends L{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ae(e,"open",this.onopen.bind(this)),ae(e,"packet",this.onpacket.bind(this)),ae(e,"error",this.onerror.bind(this)),ae(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Al.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let r={type:x.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;z("emitting packet with ack id %d",o);let a=t.pop();this._registerAckCallback(o,a),r.id=o}let n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)?z("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r),this.flags={},this}_registerAckCallback(e,t){var r;let n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(z("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));z("event with ack id %d has timed out after %d ms",e,n),t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((n,s)=>{t.push((o,a)=>r?o?s(o):n(a):n(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((n,...s)=>r!==this._queue[0]?void 0:(n!==null?r.tryCount>this._opts.retries&&(z("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(z("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(z("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){z("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,z("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){z("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:x.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){z("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case x.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case x.EVENT:case x.BINARY_EVENT:this.onevent(e);break;case x.ACK:case x.BINARY_ACK:this.onack(e);break;case x.DISCONNECT:this.ondisconnect();break;case x.CONNECT_ERROR:this.destroy();let r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){let t=e.data||[];z("emitting event %j",t),e.id!=null&&(z("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,r=!1;return function(...n){r||(r=!0,z("sending ack %j",n),t.packet({type:x.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(z("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):z("bad ack %s",e.id)}onconnect(e,t){z("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){z("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(z("performing disconnect (%s)",this.nsp),this.packet({type:x.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function st(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}st.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};st.prototype.reset=function(){this.attempts=0};st.prototype.setMin=function(i){this.ms=i};st.prototype.setMax=function(i){this.max=i};st.prototype.setJitter=function(i){this.jitter=i};var Io=Y(ei(),1),K=(0,Io.default)("socket.io-client:manager"),Ct=class extends L{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Ae(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new st({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||ln;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(K("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;K("opening %s",this.uri),this.engine=new nt(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=ae(t,"open",function(){r.onopen(),e&&e()}),s=a=>{K("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=ae(t,"error",s);if(this._timeout!==!1){let a=this._timeout;K("connect attempt will timeout after %d",a);let h=this.setTimeoutFn(()=>{K("connect attempt timed out after %d",a),n(),s(new Error("timeout")),t.close()},a);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){K("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ae(e,"ping",this.onping.bind(this)),ae(e,"data",this.ondata.bind(this)),ae(e,"error",this.onerror.bind(this)),ae(e,"close",this.onclose.bind(this)),ae(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){rt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){K("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new xt(this,e,t),this.nsps[e]=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nsps[r].active){K("socket %s is still active, skipping close",r);return}this._close()}_packet(e){K("writing packet %j",e);let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){K("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){K("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){K("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)K("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();K("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(K("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(K("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(K("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Lo=Y(ei(),1),Po=(0,Lo.default)("socket.io-client"),ri={};function ni(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=xo(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=ri[n]&&s in ri[n].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,h;return a?(Po("ignoring socket cache for %s",r),h=new Ct(r,e)):(ri[n]||(Po("new io instance for %s",r),ri[n]=new Ct(r,e)),h=ri[n]),t.query&&!e.query&&(e.query=t.queryKey),h.socket(t.path,e)}Object.assign(ni,{Manager:Ct,Socket:xt,io:ni,connect:ni});var Rl="https://ws.novu.co",Fo="notifications.notification_received",Uo="notifications.unseen_count_changed",Do="notifications.unread_count_changed",Tl=({_id:i,content:e,read:t,seen:r,archived:n,snoozedUntil:s,deliveredAt:o,createdAt:a,lastReadDate:h,firstSeenDate:d,archivedAt:l,channel:f,subscriber:u,subject:E,avatar:b,cta:p,tags:w,data:R,workflow:T})=>{var q,te,je,Ge,X,Le,Fe,Ue;let g={id:u==null?void 0:u._id,subscriberId:u==null?void 0:u.subscriberId,firstName:u==null?void 0:u.firstName,lastName:u==null?void 0:u.lastName,avatar:u==null?void 0:u.avatar,locale:u==null?void 0:u.locale,data:u==null?void 0:u.data,timezone:u==null?void 0:u.timezone,email:u==null?void 0:u.email,phone:u==null?void 0:u.phone},y=(te=(q=p.action)==null?void 0:q.buttons)==null?void 0:te.find(ie=>ie.type==="primary"),I=(Ge=(je=p.action)==null?void 0:je.buttons)==null?void 0:Ge.find(ie=>ie.type==="secondary"),A=(Le=(X=p.action)==null?void 0:X.result)==null?void 0:Le.type,M=(Fe=p.action)==null?void 0:Fe.status;return N(v(v({id:i,subject:E,body:e,to:g,isRead:t,isSeen:r,isArchived:n,isSnoozed:!!s},o&&{deliveredAt:o}),s&&{snoozedUntil:s}),{createdAt:a,readAt:h,firstSeenAt:d,archivedAt:l,avatar:b,primaryAction:y&&{label:y.content,isCompleted:A==="primary"&&M==="done",redirect:y.url?{target:y.target,url:y.url}:void 0},secondaryAction:I&&{label:I.content,isCompleted:A==="secondary"&&M==="done",redirect:I.url?{target:I.target,url:I.url}:void 0},channelType:f,tags:w,redirect:(Ue=p.data)!=null&&Ue.url?{url:p.data.url,target:p.data.target}:void 0,data:R,workflow:T})},Nt,_e,ce,kt,ir,rr,nr,xe,Bo,hn,fn,tr=class extends Ee{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,xe);_(this,Nt);_(this,_e);_(this,ce);_(this,kt);_(this,ir,({message:t})=>{c(this,_e).emit(Fo,{result:new U(Tl(t),c(this,_e),this._inboxService)})});_(this,rr,({unseenCount:t})=>{c(this,_e).emit(Uo,{result:t})});_(this,nr,({unreadCount:t})=>{c(this,_e).emit(Do,{result:t})});S(this,_e,n),S(this,kt,t!=null?t:Rl)}onSessionSuccess({token:t}){S(this,Nt,t)}isSocketEvent(t){return t===Fo||t===Uo||t===Do}connect(){return m(this,null,function*(){return c(this,Nt)?he(this,xe,hn).call(this):this.callWithSession(he(this,xe,hn).bind(this))})}disconnect(){return m(this,null,function*(){return c(this,ce)?he(this,xe,fn).call(this):this.callWithSession(he(this,xe,fn).bind(this))})}};Nt=new WeakMap,_e=new WeakMap,ce=new WeakMap,kt=new WeakMap,ir=new WeakMap,rr=new WeakMap,nr=new WeakMap,xe=new WeakSet,Bo=function(){return m(this,null,function*(){var r,n,s;if(c(this,ce))return;let t={socketUrl:c(this,kt)};c(this,_e).emit("socket.connect.pending",{args:t}),S(this,ce,ni(c(this,kt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${c(this,Nt)}`}})),c(this,ce).on("connect",()=>{c(this,_e).emit("socket.connect.resolved",{args:t})}),c(this,ce).on("connect_error",o=>{c(this,_e).emit("socket.connect.resolved",{args:t,error:o})}),(r=c(this,ce))==null||r.on("notification_received",c(this,ir)),(n=c(this,ce))==null||n.on("unseen_count_changed",c(this,rr)),(s=c(this,ce))==null||s.on("unread_count_changed",c(this,nr))})},hn=function(){return m(this,null,function*(){try{return yield he(this,xe,Bo).call(this),{}}catch(t){return{error:new k("Failed to initialize the socket",t)}}})},fn=function(){return m(this,null,function*(){var t;try{return(t=c(this,ce))==null||t.disconnect(),S(this,ce,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the socket",r)}}})};var Ol=["wss://eu.socket.novu.co",Ut,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Il={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Ut,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function Pl(i){return i?Il[i]||i:Ut}function Ll(i){return!i||Ol.includes(i)}function Mo({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=Pl(i);switch(Ll(r)?"partysocket":"socket.io"){case"partysocket":return new Ci({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new tr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Ce,Pe,He,sr=class{constructor(e){_(this,Ce);_(this,Pe);_(this,He);var t,r;S(this,He,new li({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),S(this,Ce,new hi),S(this,Pe,new wi({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:bn({subscriberId:e.subscriberId,subscriber:e.subscriber})},c(this,He),c(this,Ce))),c(this,Pe).initialize(),this.notifications=new vi({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:c(this,He),eventEmitterInstance:c(this,Ce)}),this.preferences=new Si({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:c(this,He),eventEmitterInstance:c(this,Ce)}),this.socket=Mo({socketUrl:e.socketUrl,eventEmitterInstance:c(this,Ce),inboxServiceInstance:c(this,He)}),this.on=(n,s)=>{this.socket.isSocketEvent(n)&&this.socket.connect();let o=c(this,Ce).on(n,s);return()=>{o()}},this.off=(n,s)=>{c(this,Ce).off(n,s)}}get applicationIdentifier(){return c(this,Pe).applicationIdentifier}get subscriberId(){return c(this,Pe).subscriberId}changeSubscriber(e){return m(this,null,function*(){yield c(this,Pe).initialize({applicationIdentifier:c(this,Pe).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber})})}};Ce=new WeakMap,Pe=new WeakMap,He=new WeakMap;window.Novu=sr;})();
38
38
  /*! Bundled license information:
39
39
 
40
40
  xmlhttprequest-ssl/lib/XMLHttpRequest.js: