@novu/js 3.9.3 → 3.10.1

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 Vo=Object.create;var ci=Object.defineProperty,Ho=Object.defineProperties,jo=Object.getOwnPropertyDescriptor,Go=Object.getOwnPropertyDescriptors,Ko=Object.getOwnPropertyNames,ai=Object.getOwnPropertySymbols,Yo=Object.getPrototypeOf,lr=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var gn=i=>{throw TypeError(i)},yn=Math.pow,cr=(i,e,t)=>e in i?ci(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_=(i,e)=>{for(var t in e||(e={}))lr.call(e,t)&&cr(i,t,e[t]);if(ai)for(var t of ai(e))mn.call(e,t)&&cr(i,t,e[t]);return i},k=(i,e)=>Ho(i,Go(e));var N=(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 hr=(i,e)=>{var t={};for(var r in i)lr.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&ai)for(var r of ai(i))e.indexOf(r)<0&&mn.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Jo=(i,e)=>{for(var t in e)ci(i,t,{get:e[t],enumerable:!0})},Xo=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ko(e))!lr.call(i,n)&&n!==t&&ci(i,n,{get:()=>e[n],enumerable:!(r=jo(e,n))||r.enumerable});return i};var Y=(i,e,t)=>(t=i!=null?Vo(Yo(i)):{},Xo(e||!i||!i.__esModule?ci(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>cr(i,typeof e!="symbol"?e+"":e,t),fr=(i,e,t)=>e.has(i)||gn("Cannot "+t);var c=(i,e,t)=>(fr(i,e,"read from private field"),t?t.call(i):e.get(i)),S=(i,e,t)=>e.has(i)?gn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),w=(i,e,t,r)=>(fr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),le=(i,e,t)=>(fr(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{a(t.next(l))}catch(u){n(u)}},o=l=>{try{a(t.throw(l))}catch(u){n(u)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);a((t=t.apply(i,e)).next())});var Cr=F((Af,$n)=>{"use strict";var vt=1e3,_t=vt*60,Et=_t*60,et=Et*24,Ea=et*7,Sa=et*365.25;$n.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return wa(i);if(t==="number"&&isFinite(i))return e.long?xa(i):ba(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function wa(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*Sa;case"weeks":case"week":case"w":return t*Ea;case"days":case"day":case"d":return t*et;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Et;case"minutes":case"minute":case"mins":case"min":case"m":return t*_t;case"seconds":case"second":case"secs":case"sec":case"s":return t*vt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function ba(i){var e=Math.abs(i);return e>=et?Math.round(i/et)+"d":e>=Et?Math.round(i/Et)+"h":e>=_t?Math.round(i/_t)+"m":e>=vt?Math.round(i/vt)+"s":i+"ms"}function xa(i){var e=Math.abs(i);return e>=et?Fi(i,e,et,"day"):e>=Et?Fi(i,e,Et,"hour"):e>=_t?Fi(i,e,_t,"minute"):e>=vt?Fi(i,e,vt,"second"):i+" ms"}function Fi(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var Nr=F((Rf,Vn)=>{"use strict";function Ca(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Cr(),t.destroy=u,Object.keys(i).forEach(f=>{t[f]=i[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let p=0;p<f.length;p++)h=(h<<5)-h+f.charCodeAt(p),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,p=null,d,b;function g(...v){if(!g.enabled)return;let R=g,T=Number(new Date),y=T-(h||T);R.diff=y,R.prev=h,R.curr=T,h=T,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let E=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(C,I)=>{if(C==="%%")return"%";E++;let M=t.formatters[I];if(typeof M=="function"){let te=v[E];C=M.call(R,te),v.splice(E,1),E--}return C}),t.formatArgs.call(R,v),(R.log||t.log).apply(R,v)}return g.namespace=f,g.useColors=t.useColors(),g.color=t.selectColor(f),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==t.namespaces&&(d=t.namespaces,b=t.enabled(f)),b),set:v=>{p=v}}),typeof t.init=="function"&&t.init(g),g}function r(f,h){let p=t(this.namespace+(typeof h=="undefined"?":":h)+f);return p.log=this.log,p}function n(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,p=(typeof f=="string"?f:"").split(/[\s,]+/),d=p.length;for(h=0;h<d;h++)p[h]&&(f=p[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,p;for(h=0,p=t.skips.length;h<p;h++)if(t.skips[h].test(f))return!1;for(h=0,p=t.names.length;h<p;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function l(f){return f instanceof Error?f.stack||f.message:f}function u(){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}Vn.exports=Ca});var Hn=F((re,Ui)=>{"use strict";re.formatArgs=ka;re.save=Aa;re.load=Ra;re.useColors=Na;re.storage=Ta();re.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`."))}})();re.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 Na(){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 ka(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Ui.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)}re.log=console.debug||console.log||(()=>{});function Aa(i){try{i?re.storage.setItem("debug",i):re.storage.removeItem("debug")}catch(e){}}function Ra(){let i;try{i=re.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ta(){try{return localStorage}catch(i){}}Ui.exports=Nr()(re);var{formatters:Oa}=Ui.exports;Oa.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Gn=F((Tf,jn)=>{"use strict";jn.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 Rr=F((Of,Yn)=>{"use strict";var Ia=N("os"),Kn=N("tty"),fe=Gn(),{env:V}=process,ze;fe("no-color")||fe("no-colors")||fe("color=false")||fe("color=never")?ze=0:(fe("color")||fe("colors")||fe("color=true")||fe("color=always"))&&(ze=1);"FORCE_COLOR"in V&&(V.FORCE_COLOR==="true"?ze=1:V.FORCE_COLOR==="false"?ze=0:ze=V.FORCE_COLOR.length===0?1:Math.min(parseInt(V.FORCE_COLOR,10),3));function kr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Ar(i,e){if(ze===0)return 0;if(fe("color=16m")||fe("color=full")||fe("color=truecolor"))return 3;if(fe("color=256"))return 2;if(i&&!e&&ze===void 0)return 0;let t=ze||0;if(V.TERM==="dumb")return t;if(process.platform==="win32"){let r=Ia.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 Pa(i){let e=Ar(i,i&&i.isTTY);return kr(e)}Yn.exports={supportsColor:Pa,stdout:kr(Ar(!0,Kn.isatty(1))),stderr:kr(Ar(!0,Kn.isatty(2)))}});var Xn=F((H,Bi)=>{"use strict";var La=N("tty"),Di=N("util");H.init=Wa;H.log=Ba;H.formatArgs=Ua;H.save=Ma;H.load=qa;H.useColors=Fa;H.destroy=Di.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=Rr();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 Fa(){return"colors"in H.inspectOpts?!!H.inspectOpts.colors:La.isatty(process.stderr.fd)}function Ua(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 sa=Object.create;var yi=Object.defineProperty,oa=Object.defineProperties,aa=Object.getOwnPropertyDescriptor,ca=Object.getOwnPropertyDescriptors,la=Object.getOwnPropertyNames,gi=Object.getOwnPropertySymbols,ha=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable;var Tn=i=>{throw TypeError(i)},On=Math.pow,Sr=(i,e,t)=>e in i?yi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E=(i,e)=>{for(var t in e||(e={}))wr.call(e,t)&&Sr(i,t,e[t]);if(gi)for(var t of gi(e))Rn.call(e,t)&&Sr(i,t,e[t]);return i},A=(i,e)=>oa(i,ca(e));var k=(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 br=(i,e)=>{var t={};for(var r in i)wr.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&gi)for(var r of gi(i))e.indexOf(r)<0&&Rn.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),fa=(i,e)=>{for(var t in e)yi(i,t,{get:e[t],enumerable:!0})},ua=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of la(e))!wr.call(i,n)&&n!==t&&yi(i,n,{get:()=>e[n],enumerable:!(r=aa(e,n))||r.enumerable});return i};var J=(i,e,t)=>(t=i!=null?sa(ha(i)):{},ua(e||!i||!i.__esModule?yi(t,"default",{value:i,enumerable:!0}):t,i));var I=(i,e,t)=>Sr(i,typeof e!="symbol"?e+"":e,t),xr=(i,e,t)=>e.has(i)||Tn("Cannot "+t);var a=(i,e,t)=>(xr(i,e,"read from private field"),t?t.call(i):e.get(i)),v=(i,e,t)=>e.has(i)?Tn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(xr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),he=(i,e,t)=>(xr(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{c(t.next(l))}catch(u){n(u)}},o=l=>{try{c(t.throw(l))}catch(u){n(u)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);c((t=t.apply(i,e)).next())});var Mr=F((au,ns)=>{"use strict";var wt=1e3,bt=wt*60,xt=bt*60,ot=xt*24,Da=ot*7,Ba=ot*365.25;ns.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return Ma(i);if(t==="number"&&isFinite(i))return e.long?Wa(i):qa(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function Ma(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*Ba;case"weeks":case"week":case"w":return t*Da;case"days":case"day":case"d":return t*ot;case"hours":case"hour":case"hrs":case"hr":case"h":return t*xt;case"minutes":case"minute":case"mins":case"min":case"m":return t*bt;case"seconds":case"second":case"secs":case"sec":case"s":return t*wt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function qa(i){var e=Math.abs(i);return e>=ot?Math.round(i/ot)+"d":e>=xt?Math.round(i/xt)+"h":e>=bt?Math.round(i/bt)+"m":e>=wt?Math.round(i/wt)+"s":i+"ms"}function Wa(i){var e=Math.abs(i);return e>=ot?Ki(i,e,ot,"day"):e>=xt?Ki(i,e,xt,"hour"):e>=bt?Ki(i,e,bt,"minute"):e>=wt?Ki(i,e,wt,"second"):i+" ms"}function Ki(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var qr=F((cu,ss)=>{"use strict";function za(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Mr(),t.destroy=u,Object.keys(i).forEach(h=>{t[h]=i[h]}),t.names=[],t.skips=[],t.formatters={};function e(h){let f=0;for(let d=0;d<h.length;d++)f=(f<<5)-f+h.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,d=null,p,b;function g(..._){if(!g.enabled)return;let T=g,O=Number(new Date),y=O-(f||O);T.diff=y,T.prev=f,T.curr=O,f=O,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let w=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(C,P)=>{if(C==="%%")return"%";w++;let q=t.formatters[P];if(typeof q=="function"){let ie=_[w];C=q.call(T,ie),_.splice(w,1),w--}return C}),t.formatArgs.call(T,_),(T.log||t.log).apply(T,_)}return g.namespace=h,g.useColors=t.useColors(),g.color=t.selectColor(h),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,b=t.enabled(h)),b),set:_=>{d=_}}),typeof t.init=="function"&&t.init(g),g}function r(h,f){let d=t(this.namespace+(typeof f=="undefined"?":":f)+h);return d.log=this.log,d}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,d=(typeof h=="string"?h:"").split(/[\s,]+/),p=d.length;for(f=0;f<p;f++)d[f]&&(h=d[f].replace(/\*/g,".*?"),h[0]==="-"?t.skips.push(new RegExp("^"+h.slice(1)+"$")):t.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),h}function o(h){if(h[h.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(h))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(h))return!0;return!1}function c(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function u(){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}ss.exports=za});var os=F((ne,Yi)=>{"use strict";ne.formatArgs=Va;ne.save=Ha;ne.load=ja;ne.useColors=$a;ne.storage=Ga();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 $a(){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 ":" ")+"+"+Yi.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 Ha(i){try{i?ne.storage.setItem("debug",i):ne.storage.removeItem("debug")}catch(e){}}function ja(){let i;try{i=ne.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ga(){try{return localStorage}catch(i){}}Yi.exports=qr()(ne);var{formatters:Ka}=Yi.exports;Ka.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var cs=F((lu,as)=>{"use strict";as.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 $r=F((hu,hs)=>{"use strict";var Ya=k("os"),ls=k("tty"),de=cs(),{env:j}=process,Ge;de("no-color")||de("no-colors")||de("color=false")||de("color=never")?Ge=0:(de("color")||de("colors")||de("color=true")||de("color=always"))&&(Ge=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?Ge=1:j.FORCE_COLOR==="false"?Ge=0:Ge=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function Wr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function zr(i,e){if(Ge===0)return 0;if(de("color=16m")||de("color=full")||de("color=truecolor"))return 3;if(de("color=256"))return 2;if(i&&!e&&Ge===void 0)return 0;let t=Ge||0;if(j.TERM==="dumb")return t;if(process.platform==="win32"){let r=Ya.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in j)||j.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let r=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:t}function Ja(i){let e=zr(i,i&&i.isTTY);return Wr(e)}hs.exports={supportsColor:Ja,stdout:Wr(zr(!0,ls.isatty(1))),stderr:Wr(zr(!0,ls.isatty(2)))}});var us=F((G,Xi)=>{"use strict";var Xa=k("tty"),Ji=k("util");G.init=nc;G.log=tc;G.formatArgs=Za;G.save=ic;G.load=rc;G.useColors=Qa;G.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`.");G.colors=[6,2,3,4,5,1];try{let i=$r();i&&(i.stderr||i).level>=2&&(G.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){}G.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 Qa(){return"colors"in G.inspectOpts?!!G.inspectOpts.colors:Xa.isatty(process.stderr.fd)}function Za(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+"+Bi.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Da()+e+" "+i[0]}function Da(){return H.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ba(...i){return process.stderr.write(Di.formatWithOptions(H.inspectOpts,...i)+`
4
- `)}function Ma(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function qa(){return process.env.DEBUG}function Wa(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]]}Bi.exports=Nr()(H);var{formatters:Jn}=Bi.exports;Jn.o=function(i){return this.inspectOpts.colors=this.useColors,Di.inspect(i,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};Jn.O=function(i){return this.inspectOpts.colors=this.useColors,Di.inspect(i,this.inspectOpts)}});var tt=F((If,Tr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Tr.exports=Hn():Tr.exports=Xn()});var as=F((qf,os)=>{"use strict";var St=N("fs"),ss=N("url"),Va=N("child_process").spawn;os.exports=Pr;Pr.XMLHttpRequest=Pr;function Pr(i){"use strict";i=i||{};var e=this,t=N("http"),r=N("https"),n,s,o={},a=!1,l={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},l),f=["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"],h=["TRACE","TRACK","CONNECT"],p=!1,d=!1,b=!1,g={};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 v=function(y){return a||y&&f.indexOf(y.toLowerCase())===-1},R=function(y){return y&&h.indexOf(y)===-1};this.open=function(y,E,z,C,I){if(this.abort(),d=!1,b=!1,!R(y))throw new Error("SecurityError: Request method not allowed");o={method:y,url:E.toString(),async:typeof z!="boolean"?!0:z,user:C||null,password:I||null},T(this.OPENED)},this.setDisableHeaderCheck=function(y){a=y},this.setRequestHeader=function(y,E){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!v(y))return console.warn('Refused to set unsafe header "'+y+'"'),!1;if(p)throw new Error("INVALID_STATE_ERR: send flag is true");return u[y]=E,!0},this.getResponseHeader=function(y){return typeof y=="string"&&this.readyState>this.OPENED&&s.headers[y.toLowerCase()]&&!d?s.headers[y.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||d)return"";var y="";for(var E in s.headers)E!=="set-cookie"&&E!=="set-cookie2"&&(y+=E+": "+s.headers[E]+`\r
6
- `);return y.substr(0,y.length-2)},this.getRequestHeader=function(y){return typeof y=="string"&&u[y]?u[y]:""},this.send=function(y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(p)throw new Error("INVALID_STATE_ERR: send has already been called");var E=!1,z=!1,C=ss.parse(o.url),I;switch(C.protocol){case"https:":E=!0;case"http:":I=C.hostname;break;case"file:":z=!0;break;case void 0:case"":I="localhost";break;default:throw new Error("Protocol not supported.")}if(z){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)St.readFile(unescape(C.pathname),"utf8",function(ce,ct){ce?e.handleError(ce,ce.errno||-1):(e.status=200,e.responseText=ct,T(e.DONE))});else try{this.responseText=St.readFileSync(unescape(C.pathname),"utf8"),this.status=200,T(e.DONE)}catch(ce){this.handleError(ce,ce.errno||-1)}return}var M=C.port||(E?443:80),te=C.pathname+(C.search?C.search:"");if(u.Host=I,E&&M===443||M===80||(u.Host+=":"+C.port),o.user){typeof o.password=="undefined"&&(o.password="");var Ke=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Ke.toString("base64")}o.method==="GET"||o.method==="HEAD"?y=null:y?(u["Content-Length"]=Buffer.isBuffer(y)?y.length:Buffer.byteLength(y),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var Ye=i.agent||!1,X={host:I,port:M,path:te,method:o.method,headers:u,agent:Ye};if(E&&(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),d=!1,o.async){var Ue=E?r.request:t.request;p=!0,e.dispatchEvent("readystatechange");var De=function(ce){if(s=ce,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var ct=ss.parse(o.url);I=ct.hostname;var Me={hostname:ct.hostname,port:ct.port,path:ct.path,method:s.statusCode===303?"GET":o.method,headers:u};E&&(Me.pfx=i.pfx,Me.key=i.key,Me.passphrase=i.passphrase,Me.cert=i.cert,Me.ca=i.ca,Me.ciphers=i.ciphers,Me.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Ue(Me,De).on("error",Be),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),T(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(oi){oi&&(e.responseText+=oi),p&&T(e.LOADING)}),s.on("end",function(){p&&(p=!1,T(e.DONE))}),s.on("error",function(oi){e.handleError(oi)})},Be=function(ce){e.handleError(ce)};n=Ue(X,De).on("error",Be),i.autoUnref&&n.on("socket",ce=>{ce.unref()}),y&&n.write(y),n.end(),e.dispatchEvent("loadstart")}else{var ue=".node-xmlhttprequest-content-"+process.pid,de=".node-xmlhttprequest-sync-"+process.pid;St.writeFileSync(de,"","utf8");for(var ke="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"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('"+ue+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+de+"');});response.on('error', function(error) {fs.writeFileSync('"+ue+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+de+"');});}).on('error', function(error) {fs.writeFileSync('"+ue+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+de+"');});"+(y?"req.write('"+JSON.stringify(y).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",zo=Va(process.argv[0],["-e",ke]),Ml;St.existsSync(de););if(e.responseText=St.readFileSync(ue,"utf8"),zo.stdin.end(),St.unlinkSync(ue),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var $o=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError($o,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(y,E){this.status=E||0,this.statusText=y,this.responseText=y.stack,d=!0,T(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),u=Object.assign({},l),this.responseText="",this.responseXML="",d=b=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||p)&&this.readyState!==this.DONE&&(p=!1,T(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(y,E){y in g||(g[y]=[]),g[y].push(E)},this.removeEventListener=function(y,E){y in g&&(g[y]=g[y].filter(function(z){return z!==E}))},this.dispatchEvent=function(y){if(typeof e["on"+y]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+y]()}):e["on"+y]()),y in g)for(let E=0,z=g[y].length;E<z;E++)this.readyState===this.DONE?setImmediate(function(){g[y][E].call(e)}):g[y][E].call(e)};var T=function(y){if(!(e.readyState===y||e.readyState===e.UNSENT&&b)&&(e.readyState=y,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let E;b?E="abort":d?E="error":E="load",e.dispatchEvent(E),e.dispatchEvent("loadend")}}}});var ps=F((Jf,ds)=>{"use strict";var{Duplex:Ka}=N("stream");function fs(i){i.emit("close")}function Ya(){!this.destroyed&&this._writableState.finished&&this.destroy()}function us(i){this.removeListener("error",us),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Ja(i,e){let t=!0,r=new Ka(k(_({},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(fs,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(fs,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",Ya),r.on("error",us),r}ds.exports=Ja});var Ve=F((Qf,ms)=>{"use strict";ms.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 zt=F((Zf,zi)=>{"use strict";var{EMPTY_BUFFER:Xa}=Ve();function Qa(i,e){if(i.length===0)return Xa;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 gs(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function ys(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Za(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Dr(i){if(Dr.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),Dr.readOnly=!1),e}zi.exports={concat:Qa,mask:gs,toArrayBuffer:Za,toBuffer:Dr,unmask:ys};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=N("bufferutil");zi.exports.mask=function(e,t,r,n,s){s<48?gs(e,t,r,n,s):i.mask(e,t,r,n,s)},zi.exports.unmask=function(e,t){e.length<32?ys(e,t):i.unmask(e,t)}}catch(i){}});var Es=F((eu,_s)=>{"use strict";var vs=Symbol("kDone"),Br=Symbol("kRun"),Mr=class{constructor(e){this[vs]=()=>{this.pending--,this[Br]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Br]()}[Br](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[vs])}}};_s.exports=Mr});var Ht=F((tu,xs)=>{"use strict";var $t=N("zlib"),Ss=zt(),ec=Es(),{kStatusCode:ws}=Ve(),tc=Buffer.from([0,0,255,255]),Hi=Symbol("permessage-deflate"),Ie=Symbol("total-length"),Vt=Symbol("callback"),He=Symbol("buffers"),Vi=Symbol("error"),$i,qr=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,!$i){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;$i=new ec(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[Vt];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){$i.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){$i.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"?$t.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=$t.createInflateRaw(k(_({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Hi]=this,this._inflate[Ie]=0,this._inflate[He]=[],this._inflate.on("error",rc),this._inflate.on("data",bs)}this._inflate[Vt]=r,this._inflate.write(e),t&&this._inflate.write(tc),this._inflate.flush(()=>{let s=this._inflate[Vi];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Ss.concat(this._inflate[He],this._inflate[Ie]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ie]=0,this._inflate[He]=[],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"?$t.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=$t.createDeflateRaw(k(_({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ie]=0,this._deflate[He]=[],this._deflate.on("data",ic)}this._deflate[Vt]=r,this._deflate.write(e),this._deflate.flush($t.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ss.concat(this._deflate[He],this._deflate[Ie]);t&&(s=s.slice(0,s.length-4)),this._deflate[Vt]=null,this._deflate[Ie]=0,this._deflate[He]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};xs.exports=qr;function ic(i){this[He].push(i),this[Ie]+=i.length}function bs(i){if(this[Ie]+=i.length,this[Hi]._maxPayload<1||this[Ie]<=this[Hi]._maxPayload){this[He].push(i);return}this[Vi]=new RangeError("Max payload size exceeded"),this[Vi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Vi][ws]=1009,this.removeListener("data",bs),this.reset()}function rc(i){this[Hi]._inflate=null,i[ws]=1007,this[Vt](i)}});var jt=F((ru,Wr)=>{"use strict";var nc=[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 sc(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Cs(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}Wr.exports={isValidStatusCode:sc,isValidUTF8:Cs,tokenChars:nc};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=N("utf-8-validate");Wr.exports.isValidUTF8=function(e){return e.length<150?Cs(e):i(e)}}catch(i){}});var Hr=F((nu,Is)=>{"use strict";var{Writable:oc}=N("stream"),Ns=Ht(),{BINARY_TYPES:ac,EMPTY_BUFFER:ks,kStatusCode:cc,kWebSocket:lc}=Ve(),{concat:zr,toArrayBuffer:hc,unmask:fc}=zt(),{isValidStatusCode:uc,isValidUTF8:As}=jt(),Gt=0,Rs=1,Ts=2,Os=3,$r=4,dc=5,Vr=class extends oc{constructor(e={}){super(),this._binaryType=e.binaryType||ac[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[lc]=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=Gt,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Gt)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 Gt:t=this.getInfo();break;case Rs:t=this.getPayloadLength16();break;case Ts:t=this.getPayloadLength64();break;case Os:this.getMask();break;case $r: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,q(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[Ns.extensionName])return this._loop=!1,q(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,q(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,q(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,q(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,q(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,q(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,q(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,q(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,q(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,q(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Rs;else if(this._payloadLength===127)this._state=Ts;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,q(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,q(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Os:this._state=$r}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=$r}getData(e){let t=ks;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]&&fc(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=dc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Ns.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(q(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=zr(t,e):this._binaryType==="arraybuffer"?r=hc(zr(t,e)):r=t,this.emit("message",r,!0)}else{let r=zr(t,e);if(!this._skipUTF8Validation&&!As(r))return this._loop=!1,q(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=Gt}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,ks),this.end();else{if(e.length===1)return q(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!uc(t))return q(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!As(r))return q(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=Gt}};Is.exports=Vr;function q(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,q),s.code=n,s[cc]=r,s}});var Gr=F((au,Fs)=>{"use strict";var su=N("net"),ou=N("tls"),{randomFillSync:pc}=N("crypto"),Ps=Ht(),{EMPTY_BUFFER:mc}=Ve(),{isValidStatusCode:gc}=jt(),{mask:Ls,toBuffer:wt}=zt(),_e=Symbol("kByteLength"),yc=Buffer.alloc(4),jr=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||yc,t.generateMask?t.generateMask(r):pc(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!t.mask||o)&&t[_e]!==void 0?a=t[_e]:(e=Buffer.from(e),a=e.length):(a=e.length,n=t.mask&&t.readOnly&&!o);let l=a;a>=65536?(s+=8,l=127):a>125&&(s+=2,l=126);let u=Buffer.allocUnsafe(n?a+s:s);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(a,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),t.mask?(u[1]|=128,u[s-4]=r[0],u[s-3]=r[1],u[s-2]=r[2],u[s-1]=r[3],o?[u,e]:n?(Ls(e,r,u,s,a),[u]):(Ls(e,r,e,0,a),[u,e])):[u,e]}close(e,t,r,n){let s;if(e===void 0)s=mc;else{if(typeof e!="number"||!gc(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={[_e]: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=wt(e),n=e.length,s=wt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[_e]: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=wt(e),n=e.length,s=wt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[_e]: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[Ps.extensionName],s=t.binary?2:1,o=t.compress,a,l;if(typeof e=="string"?(a=Buffer.byteLength(e),l=!1):(e=wt(e),a=e.length,l=wt.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 u={[_e]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,u,r]):this.dispatch(e,this._compress,u,r)}else this.sendFrame(i.frame(e,{[_e]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Ps.extensionName];this._bufferedBytes+=r[_e],this._deflating=!0,s.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let u=0;u<this._queue.length;u++){let f=this._queue[u],h=f[f.length-1];typeof h=="function"&&h(l)}return}this._bufferedBytes-=r[_e],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][_e],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][_e],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)}};Fs.exports=jr});var Vs=F((cu,$s)=>{"use strict";var{kForOnEventAttribute:Kt,kListener:Kr}=Ve(),Us=Symbol("kCode"),Ds=Symbol("kData"),Bs=Symbol("kError"),Ms=Symbol("kMessage"),qs=Symbol("kReason"),bt=Symbol("kTarget"),Ws=Symbol("kType"),zs=Symbol("kWasClean"),Pe=class{constructor(e){this[bt]=null,this[Ws]=e}get target(){return this[bt]}get type(){return this[Ws]}};Object.defineProperty(Pe.prototype,"target",{enumerable:!0});Object.defineProperty(Pe.prototype,"type",{enumerable:!0});var it=class extends Pe{constructor(e,t={}){super(e),this[Us]=t.code===void 0?0:t.code,this[qs]=t.reason===void 0?"":t.reason,this[zs]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Us]}get reason(){return this[qs]}get wasClean(){return this[zs]}};Object.defineProperty(it.prototype,"code",{enumerable:!0});Object.defineProperty(it.prototype,"reason",{enumerable:!0});Object.defineProperty(it.prototype,"wasClean",{enumerable:!0});var xt=class extends Pe{constructor(e,t={}){super(e),this[Bs]=t.error===void 0?null:t.error,this[Ms]=t.message===void 0?"":t.message}get error(){return this[Bs]}get message(){return this[Ms]}};Object.defineProperty(xt.prototype,"error",{enumerable:!0});Object.defineProperty(xt.prototype,"message",{enumerable:!0});var Yt=class extends Pe{constructor(e,t={}){super(e),this[Ds]=t.data===void 0?null:t.data}get data(){return this[Ds]}};Object.defineProperty(Yt.prototype,"data",{enumerable:!0});var vc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[Kt]&&n[Kr]===e&&!n[Kt])return;let r;if(i==="message")r=function(s,o){let a=new Yt("message",{data:o?s:s.toString()});a[bt]=this,ji(e,this,a)};else if(i==="close")r=function(s,o){let a=new it("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[bt]=this,ji(e,this,a)};else if(i==="error")r=function(s){let o=new xt("error",{error:s,message:s.message});o[bt]=this,ji(e,this,o)};else if(i==="open")r=function(){let s=new Pe("open");s[bt]=this,ji(e,this,s)};else return;r[Kt]=!!t[Kt],r[Kr]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[Kr]===e&&!t[Kt]){this.removeListener(i,t);break}}};$s.exports={CloseEvent:it,ErrorEvent:xt,Event:Pe,EventTarget:vc,MessageEvent:Yt};function ji(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var Yr=F((lu,Hs)=>{"use strict";var{tokenChars:Jt}=jt();function xe(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function _c(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,a,l=-1,u=-1,f=-1,h=0;for(;h<i.length;h++)if(u=i.charCodeAt(h),o===void 0)if(f===-1&&Jt[u]===1)l===-1&&(l=h);else if(h!==0&&(u===32||u===9))f===-1&&l!==-1&&(f=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h);let d=i.slice(l,f);u===44?(xe(e,d,t),t=Object.create(null)):o=d,l=f=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);else if(a===void 0)if(f===-1&&Jt[u]===1)l===-1&&(l=h);else if(u===32||u===9)f===-1&&l!==-1&&(f=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h),xe(t,i.slice(l,f),!0),u===44&&(xe(e,o,t),t=Object.create(null),o=void 0),l=f=-1}else if(u===61&&l!==-1&&f===-1)a=i.slice(l,h),l=f=-1;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(n){if(Jt[u]!==1)throw new SyntaxError(`Unexpected character at index ${h}`);l===-1?l=h:r||(r=!0),n=!1}else if(s)if(Jt[u]===1)l===-1&&(l=h);else if(u===34&&l!==-1)s=!1,f=h;else if(u===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(u===34&&i.charCodeAt(h-1)===61)s=!0;else if(f===-1&&Jt[u]===1)l===-1&&(l=h);else if(l!==-1&&(u===32||u===9))f===-1&&(f=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h);let d=i.slice(l,f);r&&(d=d.replace(/\\/g,""),r=!1),xe(t,a,d),u===44&&(xe(e,o,t),t=Object.create(null),o=void 0),a=void 0,l=f=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);if(l===-1||s||u===32||u===9)throw new SyntaxError("Unexpected end of input");f===-1&&(f=h);let p=i.slice(l,f);return o===void 0?xe(e,p,t):(a===void 0?xe(t,p,!0):r?xe(t,a,p.replace(/\\/g,"")):xe(t,a,p),xe(e,o,t)),e}function Ec(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(", ")}Hs.exports={format:Ec,parse:_c}});var en=F((fu,io)=>{"use strict";var Sc=N("events"),wc=N("https"),bc=N("http"),Ks=N("net"),xc=N("tls"),{randomBytes:Cc,createHash:Nc}=N("crypto"),{Readable:hu}=N("stream"),{URL:Jr}=N("url"),je=Ht(),kc=Hr(),Ac=Gr(),{BINARY_TYPES:js,EMPTY_BUFFER:Gi,GUID:Rc,kForOnEventAttribute:Xr,kListener:Tc,kStatusCode:Oc,kWebSocket:J,NOOP:Ys}=Ve(),{EventTarget:{addEventListener:Ic,removeEventListener:Pc}}=Vs(),{format:Lc,parse:Fc}=Yr(),{toBuffer:Uc}=zt(),Dc=30*1e3,Js=Symbol("kAborted"),Qr=[8,13],Le=["CONNECTING","OPEN","CLOSING","CLOSED"],Bc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,B=class i extends Sc{constructor(e,t,r){super(),this._binaryType=js[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Gi,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]),Xs(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){js.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 kc({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new Ac(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[J]=this,e[J]=this,n.on("conclude",Wc),n.on("drain",zc),n.on("error",$c),n.on("message",Vc),n.on("ping",Hc),n.on("pong",jc),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Zs),e.on("data",Yi),e.on("end",eo),e.on("error",to),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[je.extensionName]&&this._extensions[je.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 ne(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),Dc)}}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){Zr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Gi,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){Zr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Gi,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){Zr(this,e,r);return}let n=_({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[je.extensionName]||(n.compress=!1),this._sender.send(e||Gi,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return ne(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:Le.indexOf("CONNECTING")});Object.defineProperty(B.prototype,"CONNECTING",{enumerable:!0,value:Le.indexOf("CONNECTING")});Object.defineProperty(B,"OPEN",{enumerable:!0,value:Le.indexOf("OPEN")});Object.defineProperty(B.prototype,"OPEN",{enumerable:!0,value:Le.indexOf("OPEN")});Object.defineProperty(B,"CLOSING",{enumerable:!0,value:Le.indexOf("CLOSING")});Object.defineProperty(B.prototype,"CLOSING",{enumerable:!0,value:Le.indexOf("CLOSING")});Object.defineProperty(B,"CLOSED",{enumerable:!0,value:Le.indexOf("CLOSED")});Object.defineProperty(B.prototype,"CLOSED",{enumerable:!0,value:Le.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[Xr])return e[Tc];return null},set(e){for(let t of this.listeners(i))if(t[Xr]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Xr]:!0})}})});B.prototype.addEventListener=Ic;B.prototype.removeEventListener=Pc;io.exports=B;function Xs(i,e,t,r){let n=k(_({protocolVersion:Qr[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(!Qr.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Qr.join(", ")})`);let s;if(e instanceof Jr)s=e,i._url=e.href;else{try{s=new Jr(e)}catch(g){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",a=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let g=new SyntaxError(l);if(i._redirects===0)throw g;Ki(i,g);return}let u=o?443:80,f=Cc(16).toString("base64"),h=o?wc.request:bc.request,p=new Set,d;if(n.createConnection=o?qc:Mc,n.defaultPort=n.defaultPort||u,n.port=s.port||u,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=k(_({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":f,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(d=new je(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Lc({[je.extensionName]:d.offer()})),t.length){for(let g of t){if(typeof g!="string"||!Bc.test(g)||p.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(g)}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 g=n.path.split(":");n.socketPath=g[0],n.path=g[1]}let b;if(n.followRedirects){if(i._redirects===0){i._originalIpc=a,i._originalSecure=o,i._originalHostOrSocketPath=a?n.socketPath:s.host;let g=r&&r.headers;if(r=k(_({},r),{headers:{}}),g)for(let[v,R]of Object.entries(g))r.headers[v.toLowerCase()]=R}else if(i.listenerCount("redirect")===0){let g=a?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!g||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,g||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=h(n),i._redirects&&i.emit("redirect",i.url,b)}else b=i._req=h(n);n.timeout&&b.on("timeout",()=>{ne(i,b,"Opening handshake has timed out")}),b.on("error",g=>{b===null||b[Js]||(b=i._req=null,Ki(i,g))}),b.on("response",g=>{let v=g.headers.location,R=g.statusCode;if(v&&n.followRedirects&&R>=300&&R<400){if(++i._redirects>n.maxRedirects){ne(i,b,"Maximum redirects exceeded");return}b.abort();let T;try{T=new Jr(v,e)}catch(y){let E=new SyntaxError(`Invalid URL: ${v}`);Ki(i,E);return}Xs(i,T,t,r)}else i.emit("unexpected-response",b,g)||ne(i,b,`Unexpected server response: ${g.statusCode}`)}),b.on("upgrade",(g,v,R)=>{if(i.emit("upgrade",g),i.readyState!==B.CONNECTING)return;if(b=i._req=null,g.headers.upgrade.toLowerCase()!=="websocket"){ne(i,v,"Invalid Upgrade header");return}let T=Nc("sha1").update(f+Rc).digest("base64");if(g.headers["sec-websocket-accept"]!==T){ne(i,v,"Invalid Sec-WebSocket-Accept header");return}let y=g.headers["sec-websocket-protocol"],E;if(y!==void 0?p.size?p.has(y)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":p.size&&(E="Server sent no subprotocol"),E){ne(i,v,E);return}y&&(i._protocol=y);let z=g.headers["sec-websocket-extensions"];if(z!==void 0){if(!d){ne(i,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Fc(z)}catch(M){ne(i,v,"Invalid Sec-WebSocket-Extensions header");return}let I=Object.keys(C);if(I.length!==1||I[0]!==je.extensionName){ne(i,v,"Server indicated an extension that was not requested");return}try{d.accept(C[je.extensionName])}catch(M){ne(i,v,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[je.extensionName]=d}i.setSocket(v,R,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),b.end()}function Ki(i,e){i._readyState=B.CLOSING,i.emit("error",e),i.emitClose()}function Mc(i){return i.path=i.socketPath,Ks.connect(i)}function qc(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Ks.isIP(i.host)?"":i.host),xc.connect(i)}function ne(i,e,t){i._readyState=B.CLOSING;let r=new Error(t);Error.captureStackTrace(r,ne),e.setHeader?(e[Js]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Ki,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function Zr(i,e,t){if(e){let r=Uc(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Le[i.readyState]})`);t(r)}}function Wc(i,e){let t=this[J];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[J]!==void 0&&(t._socket.removeListener("data",Yi),process.nextTick(Qs,t._socket),i===1005?t.close():t.close(i,e))}function zc(){let i=this[J];i.isPaused||i._socket.resume()}function $c(i){let e=this[J];e._socket[J]!==void 0&&(e._socket.removeListener("data",Yi),process.nextTick(Qs,e._socket),e.close(i[Oc])),e.emit("error",i)}function Gs(){this[J].emitClose()}function Vc(i,e){this[J].emit("message",i,e)}function Hc(i){let e=this[J];e.pong(i,!e._isServer,Ys),e.emit("ping",i)}function jc(i){this[J].emit("pong",i)}function Qs(i){i.resume()}function Zs(){let i=this[J];this.removeListener("close",Zs),this.removeListener("data",Yi),this.removeListener("end",eo),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",Gs),i._receiver.on("finish",Gs))}function Yi(i){this[J]._receiver.write(i)||this.pause()}function eo(){let i=this[J];i._readyState=B.CLOSING,i._receiver.end(),this.end()}function to(){let i=this[J];this.removeListener("error",to),this.on("error",Ys),i&&(i._readyState=B.CLOSING,this.destroy())}});var no=F((du,ro)=>{"use strict";var{tokenChars:Gc}=jt();function Kc(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&&Gc[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}ro.exports={parse:Kc}});var fo=F((yu,ho)=>{"use strict";var Yc=N("events"),Ji=N("http"),pu=N("https"),mu=N("net"),gu=N("tls"),{createHash:Jc}=N("crypto"),so=Yr(),rt=Ht(),Xc=no(),Qc=en(),{GUID:Zc,kWebSocket:el}=Ve(),tl=/^[+/0-9A-Za-z]{22}==$/,oo=0,ao=1,lo=2,tn=class extends Yc{constructor(e,t){if(super(),e=_({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:Qc},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=Ji.createServer((r,n)=>{let s=Ji.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=il(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=oo}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===lo){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Xt,this);return}if(e&&this.once("close",e),this._state!==ao)if(this._state=ao,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(Xt,this):process.nextTick(Xt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Xt(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",co);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){nt(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){nt(this,e,t,400,"Invalid Upgrade header");return}if(!s||!tl.test(s)){nt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){nt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Qt(t,400);return}let a=e.headers["sec-websocket-protocol"],l=new Set;if(a!==void 0)try{l=Xc.parse(a)}catch(h){nt(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&u!==void 0){let h=new rt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let p=so.parse(u);p[rt.extensionName]&&(h.accept(p[rt.extensionName]),f[rt.extensionName]=h)}catch(p){nt(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let h={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(h,(p,d,b,g)=>{if(!p)return Qt(t,d||401,b,g);this.completeUpgrade(f,s,l,e,t,r,n)});return}if(!this.options.verifyClient(h))return Qt(t,401)}this.completeUpgrade(f,s,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,a){if(!s.readable||!s.writable)return s.destroy();if(s[el])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>oo)return Qt(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Jc("sha1").update(t+Zc).digest("base64")}`],f=new this.options.WebSocket(null);if(r.size){let h=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;h&&(u.push(`Sec-WebSocket-Protocol: ${h}`),f._protocol=h)}if(e[rt.extensionName]){let h=e[rt.extensionName].params,p=so.format({[rt.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${p}`),f._extensions=e}this.emit("headers",u,n),s.write(u.concat(`\r
3
+ `+s),i.push(n+"m+"+Xi.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=ec()+e+" "+i[0]}function ec(){return G.inspectOpts.hideDate?"":new Date().toISOString()+" "}function tc(...i){return process.stderr.write(Ji.formatWithOptions(G.inspectOpts,...i)+`
4
+ `)}function ic(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function rc(){return process.env.DEBUG}function nc(i){i.inspectOpts={};let e=Object.keys(G.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=G.inspectOpts[e[t]]}Xi.exports=qr()(G);var{formatters:fs}=Xi.exports;fs.o=function(i){return this.inspectOpts.colors=this.useColors,Ji.inspect(i,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(" ")};fs.O=function(i){return this.inspectOpts.colors=this.useColors,Ji.inspect(i,this.inspectOpts)}});var at=F((fu,Vr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Vr.exports=os():Vr.exports=us()});var ws=F((_u,Ss)=>{"use strict";var Ct=k("fs"),Es=k("url"),ac=k("child_process").spawn;Ss.exports=Gr;Gr.XMLHttpRequest=Gr;function Gr(i){"use strict";i=i||{};var e=this,t=k("http"),r=k("https"),n,s,o={},c=!1,l={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},l),h=["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"],d=!1,p=!1,b=!1,g={};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 _=function(y){return c||y&&h.indexOf(y.toLowerCase())===-1},T=function(y){return y&&f.indexOf(y)===-1};this.open=function(y,w,$,C,P){if(this.abort(),p=!1,b=!1,!T(y))throw new Error("SecurityError: Request method not allowed");o={method:y,url:w.toString(),async:typeof $!="boolean"?!0:$,user:C||null,password:P||null},O(this.OPENED)},this.setDisableHeaderCheck=function(y){c=y},this.setRequestHeader=function(y,w){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!_(y))return console.warn('Refused to set unsafe header "'+y+'"'),!1;if(d)throw new Error("INVALID_STATE_ERR: send flag is true");return u[y]=w,!0},this.getResponseHeader=function(y){return typeof y=="string"&&this.readyState>this.OPENED&&s.headers[y.toLowerCase()]&&!p?s.headers[y.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||p)return"";var y="";for(var w in s.headers)w!=="set-cookie"&&w!=="set-cookie2"&&(y+=w+": "+s.headers[w]+`\r
6
+ `);return y.substr(0,y.length-2)},this.getRequestHeader=function(y){return typeof y=="string"&&u[y]?u[y]:""},this.send=function(y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(d)throw new Error("INVALID_STATE_ERR: send has already been called");var w=!1,$=!1,C=Es.parse(o.url),P;switch(C.protocol){case"https:":w=!0;case"http:":P=C.hostname;break;case"file:":$=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if($){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Ct.readFile(unescape(C.pathname),"utf8",function(le,pt){le?e.handleError(le,le.errno||-1):(e.status=200,e.responseText=pt,O(e.DONE))});else try{this.responseText=Ct.readFileSync(unescape(C.pathname),"utf8"),this.status=200,O(e.DONE)}catch(le){this.handleError(le,le.errno||-1)}return}var q=C.port||(w?443:80),ie=C.pathname+(C.search?C.search:"");if(u.Host=P,w&&q===443||q===80||(u.Host+=":"+C.port),o.user){typeof o.password=="undefined"&&(o.password="");var Ze=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Ze.toString("base64")}o.method==="GET"||o.method==="HEAD"?y=null:y?(u["Content-Length"]=Buffer.isBuffer(y)?y.length:Buffer.byteLength(y),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var et=i.agent||!1,ee={host:P,port:q,path:ie,method:o.method,headers:u,agent:et};if(w&&(ee.pfx=i.pfx,ee.key=i.key,ee.passphrase=i.passphrase,ee.cert=i.cert,ee.ca=i.ca,ee.ciphers=i.ciphers,ee.rejectUnauthorized=i.rejectUnauthorized!==!1),p=!1,o.async){var Be=w?r.request:t.request;d=!0,e.dispatchEvent("readystatechange");var Me=function(le){if(s=le,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var pt=Es.parse(o.url);P=pt.hostname;var We={hostname:pt.hostname,port:pt.port,path:pt.path,method:s.statusCode===303?"GET":o.method,headers:u};w&&(We.pfx=i.pfx,We.key=i.key,We.passphrase=i.passphrase,We.cert=i.cert,We.ca=i.ca,We.ciphers=i.ciphers,We.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Be(We,Me).on("error",qe),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),O(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(mi){mi&&(e.responseText+=mi),d&&O(e.LOADING)}),s.on("end",function(){d&&(d=!1,O(e.DONE))}),s.on("error",function(mi){e.handleError(mi)})},qe=function(le){e.handleError(le)};n=Be(ee,Me).on("error",qe),i.autoUnref&&n.on("socket",le=>{le.unref()}),y&&n.write(y),n.end(),e.dispatchEvent("loadstart")}else{var pe=".node-xmlhttprequest-content-"+process.pid,me=".node-xmlhttprequest-sync-"+process.pid;Ct.writeFileSync(me,"","utf8");for(var Re="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(w?"s":"")+".request;var options = "+JSON.stringify(ee)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+pe+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+me+"');});response.on('error', function(error) {fs.writeFileSync('"+pe+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+me+"');});}).on('error', function(error) {fs.writeFileSync('"+pe+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+me+"');});"+(y?"req.write('"+JSON.stringify(y).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",ra=ac(process.argv[0],["-e",Re]),ih;Ct.existsSync(me););if(e.responseText=Ct.readFileSync(pe,"utf8"),ra.stdin.end(),Ct.unlinkSync(pe),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var na=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(na,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),O(e.DONE)}},this.handleError=function(y,w){this.status=w||0,this.statusText=y,this.responseText=y.stack,p=!0,O(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),u=Object.assign({},l),this.responseText="",this.responseXML="",p=b=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||d)&&this.readyState!==this.DONE&&(d=!1,O(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(y,w){y in g||(g[y]=[]),g[y].push(w)},this.removeEventListener=function(y,w){y in g&&(g[y]=g[y].filter(function($){return $!==w}))},this.dispatchEvent=function(y){if(typeof e["on"+y]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+y]()}):e["on"+y]()),y in g)for(let w=0,$=g[y].length;w<$;w++)this.readyState===this.DONE?setImmediate(function(){g[y][w].call(e)}):g[y][w].call(e)};var O=function(y){if(!(e.readyState===y||e.readyState===e.UNSENT&&b)&&(e.readyState=y,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let w;b?w="abort":p?w="error":w="load",e.dispatchEvent(w),e.dispatchEvent("loadend")}}}});var Rs=F((Ru,As)=>{"use strict";var{Duplex:fc}=k("stream");function Ns(i){i.emit("close")}function uc(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ks(i){this.removeListener("error",ks),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function dc(i,e){let t=!0,r=new fc(A(E({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let c=!o&&r._readableState.objectMode?s.toString():s;r.push(c)||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(Ns,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(Ns,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",uc),r.on("error",ks),r}As.exports=dc});var Ye=F((Ou,Ts)=>{"use strict";Ts.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 Xt=F((Iu,tr)=>{"use strict";var{EMPTY_BUFFER:pc}=Ye();function mc(i,e){if(i.length===0)return pc;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 Os(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function Is(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function gc(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Xr(i){if(Xr.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),Xr.readOnly=!1),e}tr.exports={concat:mc,mask:Os,toArrayBuffer:gc,toBuffer:Xr,unmask:Is};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=k("bufferutil");tr.exports.mask=function(e,t,r,n,s){s<48?Os(e,t,r,n,s):i.mask(e,t,r,n,s)},tr.exports.unmask=function(e,t){e.length<32?Is(e,t):i.unmask(e,t)}}catch(i){}});var Fs=F((Pu,Ls)=>{"use strict";var Ps=Symbol("kDone"),Qr=Symbol("kRun"),Zr=class{constructor(e){this[Ps]=()=>{this.pending--,this[Qr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Qr]()}[Qr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ps])}}};Ls.exports=Zr});var ei=F((Lu,Ms)=>{"use strict";var Qt=k("zlib"),Us=Xt(),yc=Fs(),{kStatusCode:Ds}=Ye(),vc=Buffer.from([0,0,255,255]),nr=Symbol("permessage-deflate"),Le=Symbol("total-length"),Zt=Symbol("callback"),Je=Symbol("buffers"),rr=Symbol("error"),ir,en=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,!ir){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ir=new yc(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){ir.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){ir.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"?Qt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Qt.createInflateRaw(A(E({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[nr]=this,this._inflate[Le]=0,this._inflate[Je]=[],this._inflate.on("error",Ec),this._inflate.on("data",Bs)}this._inflate[Zt]=r,this._inflate.write(e),t&&this._inflate.write(vc),this._inflate.flush(()=>{let s=this._inflate[rr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Us.concat(this._inflate[Je],this._inflate[Le]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Le]=0,this._inflate[Je]=[],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"?Qt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Qt.createDeflateRaw(A(E({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Le]=0,this._deflate[Je]=[],this._deflate.on("data",_c)}this._deflate[Zt]=r,this._deflate.write(e),this._deflate.flush(Qt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Us.concat(this._deflate[Je],this._deflate[Le]);t&&(s=s.slice(0,s.length-4)),this._deflate[Zt]=null,this._deflate[Le]=0,this._deflate[Je]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};Ms.exports=en;function _c(i){this[Je].push(i),this[Le]+=i.length}function Bs(i){if(this[Le]+=i.length,this[nr]._maxPayload<1||this[Le]<=this[nr]._maxPayload){this[Je].push(i);return}this[rr]=new RangeError("Max payload size exceeded"),this[rr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[rr][Ds]=1009,this.removeListener("data",Bs),this.reset()}function Ec(i){this[nr]._inflate=null,i[Ds]=1007,this[Zt](i)}});var ti=F((Uu,tn)=>{"use strict";var Sc=[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 wc(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function qs(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}tn.exports={isValidStatusCode:wc,isValidUTF8:qs,tokenChars:Sc};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=k("utf-8-validate");tn.exports.isValidUTF8=function(e){return e.length<150?qs(e):i(e)}}catch(i){}});var on=F((Du,Gs)=>{"use strict";var{Writable:bc}=k("stream"),Ws=ei(),{BINARY_TYPES:xc,EMPTY_BUFFER:zs,kStatusCode:Cc,kWebSocket:Nc}=Ye(),{concat:rn,toArrayBuffer:kc,unmask:Ac}=Xt(),{isValidStatusCode:Rc,isValidUTF8:$s}=ti(),ii=0,Vs=1,Hs=2,js=3,nn=4,Tc=5,sn=class extends bc{constructor(e={}){super(),this._binaryType=e.binaryType||xc[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Nc]=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=ii,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==ii)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 ii:t=this.getInfo();break;case Vs:t=this.getPayloadLength16();break;case Hs:t=this.getPayloadLength64();break;case js:this.getMask();break;case nn: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[Ws.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=Hs;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=js:this._state=nn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=nn}getData(e){let t=zs;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=Tc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Ws.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=rn(t,e):this._binaryType==="arraybuffer"?r=kc(rn(t,e)):r=t,this.emit("message",r,!0)}else{let r=rn(t,e);if(!this._skipUTF8Validation&&!$s(r))return this._loop=!1,W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=ii}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,zs),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&&!$s(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=ii}};Gs.exports=sn;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[Cc]=r,s}});var cn=F((qu,Js)=>{"use strict";var Bu=k("net"),Mu=k("tls"),{randomFillSync:Oc}=k("crypto"),Ks=ei(),{EMPTY_BUFFER:Ic}=Ye(),{isValidStatusCode:Pc}=ti(),{mask:Ys,toBuffer:Nt}=Xt(),Se=Symbol("kByteLength"),Lc=Buffer.alloc(4),an=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||Lc,t.generateMask?t.generateMask(r):Oc(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[Se]!==void 0?c=t[Se]:(e=Buffer.from(e),c=e.length):(c=e.length,n=t.mask&&t.readOnly&&!o);let l=c;c>=65536?(s+=8,l=127):c>125&&(s+=2,l=126);let u=Buffer.allocUnsafe(n?c+s:s);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(c,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(c,4,6)),t.mask?(u[1]|=128,u[s-4]=r[0],u[s-3]=r[1],u[s-2]=r[2],u[s-1]=r[3],o?[u,e]:n?(Ys(e,r,u,s,c),[u]):(Ys(e,r,e,0,c),[u,e])):[u,e]}close(e,t,r,n){let s;if(e===void 0)s=Ic;else{if(typeof e!="number"||!Pc(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 c=Buffer.byteLength(t);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let o={[Se]: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=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[Se]: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=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[Se]: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[Ks.extensionName],s=t.binary?2:1,o=t.compress,c,l;if(typeof e=="string"?(c=Buffer.byteLength(e),l=!1):(e=Nt(e),c=e.length,l=Nt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let u={[Se]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,u,r]):this.dispatch(e,this._compress,u,r)}else this.sendFrame(i.frame(e,{[Se]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Ks.extensionName];this._bufferedBytes+=r[Se],this._deflating=!0,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let u=0;u<this._queue.length;u++){let h=this._queue[u],f=h[h.length-1];typeof f=="function"&&f(l)}return}this._bufferedBytes-=r[Se],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Se],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Se],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)}};Js.exports=an});var so=F((Wu,no)=>{"use strict";var{kForOnEventAttribute:ri,kListener:ln}=Ye(),Xs=Symbol("kCode"),Qs=Symbol("kData"),Zs=Symbol("kError"),eo=Symbol("kMessage"),to=Symbol("kReason"),kt=Symbol("kTarget"),io=Symbol("kType"),ro=Symbol("kWasClean"),Fe=class{constructor(e){this[kt]=null,this[io]=e}get target(){return this[kt]}get type(){return this[io]}};Object.defineProperty(Fe.prototype,"target",{enumerable:!0});Object.defineProperty(Fe.prototype,"type",{enumerable:!0});var ct=class extends Fe{constructor(e,t={}){super(e),this[Xs]=t.code===void 0?0:t.code,this[to]=t.reason===void 0?"":t.reason,this[ro]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Xs]}get reason(){return this[to]}get wasClean(){return this[ro]}};Object.defineProperty(ct.prototype,"code",{enumerable:!0});Object.defineProperty(ct.prototype,"reason",{enumerable:!0});Object.defineProperty(ct.prototype,"wasClean",{enumerable:!0});var At=class extends Fe{constructor(e,t={}){super(e),this[Zs]=t.error===void 0?null:t.error,this[eo]=t.message===void 0?"":t.message}get error(){return this[Zs]}get message(){return this[eo]}};Object.defineProperty(At.prototype,"error",{enumerable:!0});Object.defineProperty(At.prototype,"message",{enumerable:!0});var ni=class extends Fe{constructor(e,t={}){super(e),this[Qs]=t.data===void 0?null:t.data}get data(){return this[Qs]}};Object.defineProperty(ni.prototype,"data",{enumerable:!0});var Fc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[ri]&&n[ln]===e&&!n[ri])return;let r;if(i==="message")r=function(s,o){let c=new ni("message",{data:o?s:s.toString()});c[kt]=this,sr(e,this,c)};else if(i==="close")r=function(s,o){let c=new ct("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[kt]=this,sr(e,this,c)};else if(i==="error")r=function(s){let o=new At("error",{error:s,message:s.message});o[kt]=this,sr(e,this,o)};else if(i==="open")r=function(){let s=new Fe("open");s[kt]=this,sr(e,this,s)};else return;r[ri]=!!t[ri],r[ln]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[ln]===e&&!t[ri]){this.removeListener(i,t);break}}};no.exports={CloseEvent:ct,ErrorEvent:At,Event:Fe,EventTarget:Fc,MessageEvent:ni};function sr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var hn=F((zu,oo)=>{"use strict";var{tokenChars:si}=ti();function Ne(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Uc(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,l=-1,u=-1,h=-1,f=0;for(;f<i.length;f++)if(u=i.charCodeAt(f),o===void 0)if(h===-1&&si[u]===1)l===-1&&(l=f);else if(f!==0&&(u===32||u===9))h===-1&&l!==-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f);let p=i.slice(l,h);u===44?(Ne(e,p,t),t=Object.create(null)):o=p,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(h===-1&&si[u]===1)l===-1&&(l=f);else if(u===32||u===9)h===-1&&l!==-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f),Ne(t,i.slice(l,h),!0),u===44&&(Ne(e,o,t),t=Object.create(null),o=void 0),l=h=-1}else if(u===61&&l!==-1&&h===-1)c=i.slice(l,f),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(si[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(si[u]===1)l===-1&&(l=f);else if(u===34&&l!==-1)s=!1,h=f;else if(u===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(u===34&&i.charCodeAt(f-1)===61)s=!0;else if(h===-1&&si[u]===1)l===-1&&(l=f);else if(l!==-1&&(u===32||u===9))h===-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f);let p=i.slice(l,h);r&&(p=p.replace(/\\/g,""),r=!1),Ne(t,c,p),u===44&&(Ne(e,o,t),t=Object.create(null),o=void 0),c=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||s||u===32||u===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=f);let d=i.slice(l,h);return o===void 0?Ne(e,d,t):(c===void 0?Ne(t,d,!0):r?Ne(t,c,d.replace(/\\/g,"")):Ne(t,c,d),Ne(e,o,t)),e}function Dc(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(", ")}oo.exports={format:Dc,parse:Uc}});var mn=F((Vu,vo)=>{"use strict";var Bc=k("events"),Mc=k("https"),qc=k("http"),lo=k("net"),Wc=k("tls"),{randomBytes:zc,createHash:$c}=k("crypto"),{Readable:$u}=k("stream"),{URL:fn}=k("url"),Xe=ei(),Vc=on(),Hc=cn(),{BINARY_TYPES:ao,EMPTY_BUFFER:or,GUID:jc,kForOnEventAttribute:un,kListener:Gc,kStatusCode:Kc,kWebSocket:Z,NOOP:ho}=Ye(),{EventTarget:{addEventListener:Yc,removeEventListener:Jc}}=so(),{format:Xc,parse:Qc}=hn(),{toBuffer:Zc}=Xt(),el=30*1e3,fo=Symbol("kAborted"),dn=[8,13],Ue=["CONNECTING","OPEN","CLOSING","CLOSED"],tl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,B=class i extends Bc{constructor(e,t,r){super(),this._binaryType=ao[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=or,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]),uo(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){ao.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 Hc(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[Z]=this,e[Z]=this,n.on("conclude",nl),n.on("drain",sl),n.on("error",ol),n.on("message",al),n.on("ping",cl),n.on("pong",ll),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",mo),e.on("data",cr),e.on("end",go),e.on("error",yo),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[Xe.extensionName]&&this._extensions[Xe.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),el)}}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){pn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||or,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){pn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||or,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){pn(this,e,r);return}let n=E({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Xe.extensionName]||(n.compress=!1),this._sender.send(e||or,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:Ue.indexOf("CONNECTING")});Object.defineProperty(B.prototype,"CONNECTING",{enumerable:!0,value:Ue.indexOf("CONNECTING")});Object.defineProperty(B,"OPEN",{enumerable:!0,value:Ue.indexOf("OPEN")});Object.defineProperty(B.prototype,"OPEN",{enumerable:!0,value:Ue.indexOf("OPEN")});Object.defineProperty(B,"CLOSING",{enumerable:!0,value:Ue.indexOf("CLOSING")});Object.defineProperty(B.prototype,"CLOSING",{enumerable:!0,value:Ue.indexOf("CLOSING")});Object.defineProperty(B,"CLOSED",{enumerable:!0,value:Ue.indexOf("CLOSED")});Object.defineProperty(B.prototype,"CLOSED",{enumerable:!0,value:Ue.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[un])return e[Gc];return null},set(e){for(let t of this.listeners(i))if(t[un]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[un]:!0})}})});B.prototype.addEventListener=Yc;B.prototype.removeEventListener=Jc;vo.exports=B;function uo(i,e,t,r){let n=A(E({protocolVersion:dn[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(!dn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${dn.join(", ")})`);let s;if(e instanceof fn)s=e,i._url=e.href;else{try{s=new fn(e)}catch(g){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let g=new SyntaxError(l);if(i._redirects===0)throw g;ar(i,g);return}let u=o?443:80,h=zc(16).toString("base64"),f=o?Mc.request:qc.request,d=new Set,p;if(n.createConnection=o?rl:il,n.defaultPort=n.defaultPort||u,n.port=s.port||u,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=A(E({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(p=new Xe(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Xc({[Xe.extensionName]:p.offer()})),t.length){for(let g of t){if(typeof g!="string"||!tl.test(g)||d.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(g)}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}`),c){let g=n.path.split(":");n.socketPath=g[0],n.path=g[1]}let b;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let g=r&&r.headers;if(r=A(E({},r),{headers:{}}),g)for(let[_,T]of Object.entries(g))r.headers[_.toLowerCase()]=T}else if(i.listenerCount("redirect")===0){let g=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!g||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,g||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",g=>{b===null||b[fo]||(b=i._req=null,ar(i,g))}),b.on("response",g=>{let _=g.headers.location,T=g.statusCode;if(_&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){se(i,b,"Maximum redirects exceeded");return}b.abort();let O;try{O=new fn(_,e)}catch(y){let w=new SyntaxError(`Invalid URL: ${_}`);ar(i,w);return}uo(i,O,t,r)}else i.emit("unexpected-response",b,g)||se(i,b,`Unexpected server response: ${g.statusCode}`)}),b.on("upgrade",(g,_,T)=>{if(i.emit("upgrade",g),i.readyState!==B.CONNECTING)return;if(b=i._req=null,g.headers.upgrade.toLowerCase()!=="websocket"){se(i,_,"Invalid Upgrade header");return}let O=$c("sha1").update(h+jc).digest("base64");if(g.headers["sec-websocket-accept"]!==O){se(i,_,"Invalid Sec-WebSocket-Accept header");return}let y=g.headers["sec-websocket-protocol"],w;if(y!==void 0?d.size?d.has(y)||(w="Server sent an invalid subprotocol"):w="Server sent a subprotocol but none was requested":d.size&&(w="Server sent no subprotocol"),w){se(i,_,w);return}y&&(i._protocol=y);let $=g.headers["sec-websocket-extensions"];if($!==void 0){if(!p){se(i,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Qc($)}catch(q){se(i,_,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(C);if(P.length!==1||P[0]!==Xe.extensionName){se(i,_,"Server indicated an extension that was not requested");return}try{p.accept(C[Xe.extensionName])}catch(q){se(i,_,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[Xe.extensionName]=p}i.setSocket(_,T,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),b.end()}function ar(i,e){i._readyState=B.CLOSING,i.emit("error",e),i.emitClose()}function il(i){return i.path=i.socketPath,lo.connect(i)}function rl(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=lo.isIP(i.host)?"":i.host),Wc.connect(i)}function se(i,e,t){i._readyState=B.CLOSING;let r=new Error(t);Error.captureStackTrace(r,se),e.setHeader?(e[fo]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(ar,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function pn(i,e,t){if(e){let r=Zc(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Ue[i.readyState]})`);t(r)}}function nl(i,e){let t=this[Z];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[Z]!==void 0&&(t._socket.removeListener("data",cr),process.nextTick(po,t._socket),i===1005?t.close():t.close(i,e))}function sl(){let i=this[Z];i.isPaused||i._socket.resume()}function ol(i){let e=this[Z];e._socket[Z]!==void 0&&(e._socket.removeListener("data",cr),process.nextTick(po,e._socket),e.close(i[Kc])),e.emit("error",i)}function co(){this[Z].emitClose()}function al(i,e){this[Z].emit("message",i,e)}function cl(i){let e=this[Z];e.pong(i,!e._isServer,ho),e.emit("ping",i)}function ll(i){this[Z].emit("pong",i)}function po(i){i.resume()}function mo(){let i=this[Z];this.removeListener("close",mo),this.removeListener("data",cr),this.removeListener("end",go),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[Z]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",co),i._receiver.on("finish",co))}function cr(i){this[Z]._receiver.write(i)||this.pause()}function go(){let i=this[Z];i._readyState=B.CLOSING,i._receiver.end(),this.end()}function yo(){let i=this[Z];this.removeListener("error",yo),this.on("error",ho),i&&(i._readyState=B.CLOSING,this.destroy())}});var Eo=F((ju,_o)=>{"use strict";var{tokenChars:hl}=ti();function fl(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&&hl[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 c=i.slice(t,r);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),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}_o.exports={parse:fl}});var ko=F((Ju,No)=>{"use strict";var ul=k("events"),lr=k("http"),Gu=k("https"),Ku=k("net"),Yu=k("tls"),{createHash:dl}=k("crypto"),So=hn(),lt=ei(),pl=Eo(),ml=mn(),{GUID:gl,kWebSocket:yl}=Ye(),vl=/^[+/0-9A-Za-z]{22}==$/,wo=0,bo=1,Co=2,gn=class extends ul{constructor(e,t){if(super(),e=E({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:ml},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=lr.createServer((r,n)=>{let s=lr.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=_l(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=wo}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===Co){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(oi,this);return}if(e&&this.once("close",e),this._state!==bo)if(this._state=bo,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(oi,this):process.nextTick(oi,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{oi(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",xo);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){ht(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){ht(this,e,t,400,"Invalid Upgrade header");return}if(!s||!vl.test(s)){ht(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){ht(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){ai(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=pl.parse(c)}catch(f){ht(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&u!==void 0){let f=new lt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=So.parse(u);d[lt.extensionName]&&(f.accept(d[lt.extensionName]),h[lt.extensionName]=f)}catch(d){ht(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,(d,p,b,g)=>{if(!d)return ai(t,p||401,b,g);this.completeUpgrade(h,s,l,e,t,r,n)});return}if(!this.options.verifyClient(f))return ai(t,401)}this.completeUpgrade(h,s,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[yl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>wo)return ai(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${dl("sha1").update(t+gl).digest("base64")}`],h=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(u.push(`Sec-WebSocket-Protocol: ${f}`),h._protocol=f)}if(e[lt.extensionName]){let f=e[lt.extensionName].params,d=So.format({[lt.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${d}`),h._extensions=e}this.emit("headers",u,n),s.write(u.concat(`\r
7
7
  `).join(`\r
8
- `)),s.removeListener("error",co),f.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Xt,this)})),a(f,n)}};ho.exports=tn;function il(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 Xt(i){i._state=lo,i.emit("close")}function co(){this.destroy()}function Qt(i,e,t,r){t=t||Ji.STATUS_CODES[e],r=_({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Ji.STATUS_CODES[e]}\r
8
+ `)),s.removeListener("error",xo),h.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(oi,this)})),c(h,n)}};No.exports=gn;function _l(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 oi(i){i._state=Co,i.emit("close")}function xo(){this.destroy()}function ai(i,e,t,r){t=t||lr.STATUS_CODES[e],r=E({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${lr.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 nt(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,nt),i.emit("wsClientError",s,t,e)}else Qt(t,r,n)}});var nn=F((Zu,Eo)=>{"use strict";function ul(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Cr(),t.destroy=u,Object.keys(i).forEach(f=>{t[f]=i[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let p=0;p<f.length;p++)h=(h<<5)-h+f.charCodeAt(p),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,p=null,d,b;function g(...v){if(!g.enabled)return;let R=g,T=Number(new Date),y=T-(h||T);R.diff=y,R.prev=h,R.curr=T,h=T,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let E=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(C,I)=>{if(C==="%%")return"%";E++;let M=t.formatters[I];if(typeof M=="function"){let te=v[E];C=M.call(R,te),v.splice(E,1),E--}return C}),t.formatArgs.call(R,v),(R.log||t.log).apply(R,v)}return g.namespace=f,g.useColors=t.useColors(),g.color=t.selectColor(f),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==t.namespaces&&(d=t.namespaces,b=t.enabled(f)),b),set:v=>{p=v}}),typeof t.init=="function"&&t.init(g),g}function r(f,h){let p=t(this.namespace+(typeof h=="undefined"?":":h)+f);return p.log=this.log,p}function n(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,p=(typeof f=="string"?f:"").split(/[\s,]+/),d=p.length;for(h=0;h<d;h++)p[h]&&(f=p[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,p;for(h=0,p=t.skips.length;h<p;h++)if(t.skips[h].test(f))return!1;for(h=0,p=t.names.length;h<p;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function l(f){return f instanceof Error?f.stack||f.message:f}function u(){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}Eo.exports=ul});var So=F((se,er)=>{"use strict";se.formatArgs=pl;se.save=ml;se.load=gl;se.useColors=dl;se.storage=yl();se.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`."))}})();se.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 dl(){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 pl(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+er.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)}se.log=console.debug||console.log||(()=>{});function ml(i){try{i?se.storage.setItem("debug",i):se.storage.removeItem("debug")}catch(e){}}function gl(){let i;try{i=se.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function yl(){try{return localStorage}catch(i){}}er.exports=nn()(se);var{formatters:vl}=er.exports;vl.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var bo=F((j,ir)=>{"use strict";var _l=N("tty"),tr=N("util");j.init=Nl;j.log=bl;j.formatArgs=Sl;j.save=xl;j.load=Cl;j.useColors=El;j.destroy=tr.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=Rr();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 El(){return"colors"in j.inspectOpts?!!j.inspectOpts.colors:_l.isatty(process.stderr.fd)}function Sl(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 ht(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,ht),i.emit("wsClientError",s,t,e)}else ai(t,r,n)}});var vn=F((Id,Fo)=>{"use strict";function Rl(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Mr(),t.destroy=u,Object.keys(i).forEach(h=>{t[h]=i[h]}),t.names=[],t.skips=[],t.formatters={};function e(h){let f=0;for(let d=0;d<h.length;d++)f=(f<<5)-f+h.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,d=null,p,b;function g(..._){if(!g.enabled)return;let T=g,O=Number(new Date),y=O-(f||O);T.diff=y,T.prev=f,T.curr=O,f=O,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let w=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(C,P)=>{if(C==="%%")return"%";w++;let q=t.formatters[P];if(typeof q=="function"){let ie=_[w];C=q.call(T,ie),_.splice(w,1),w--}return C}),t.formatArgs.call(T,_),(T.log||t.log).apply(T,_)}return g.namespace=h,g.useColors=t.useColors(),g.color=t.selectColor(h),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,b=t.enabled(h)),b),set:_=>{d=_}}),typeof t.init=="function"&&t.init(g),g}function r(h,f){let d=t(this.namespace+(typeof f=="undefined"?":":f)+h);return d.log=this.log,d}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,d=(typeof h=="string"?h:"").split(/[\s,]+/),p=d.length;for(f=0;f<p;f++)d[f]&&(h=d[f].replace(/\*/g,".*?"),h[0]==="-"?t.skips.push(new RegExp("^"+h.slice(1)+"$")):t.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),h}function o(h){if(h[h.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(h))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(h))return!0;return!1}function c(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function u(){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}Fo.exports=Rl});var Uo=F((oe,dr)=>{"use strict";oe.formatArgs=Ol;oe.save=Il;oe.load=Pl;oe.useColors=Tl;oe.storage=Ll();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 Tl(){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 Ol(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+dr.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 Il(i){try{i?oe.storage.setItem("debug",i):oe.storage.removeItem("debug")}catch(e){}}function Pl(){let i;try{i=oe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ll(){try{return localStorage}catch(i){}}dr.exports=vn()(oe);var{formatters:Fl}=dr.exports;Fl.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Bo=F((K,mr)=>{"use strict";var Ul=k("tty"),pr=k("util");K.init=$l;K.log=ql;K.formatArgs=Bl;K.save=Wl;K.load=zl;K.useColors=Dl;K.destroy=pr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");K.colors=[6,2,3,4,5,1];try{let i=$r();i&&(i.stderr||i).level>=2&&(K.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){}K.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 Dl(){return"colors"in K.inspectOpts?!!K.inspectOpts.colors:Ul.isatty(process.stderr.fd)}function Bl(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+"+ir.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=wl()+e+" "+i[0]}function wl(){return j.inspectOpts.hideDate?"":new Date().toISOString()+" "}function bl(...i){return process.stderr.write(tr.formatWithOptions(j.inspectOpts,...i)+`
15
- `)}function xl(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Cl(){return process.env.DEBUG}function Nl(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]]}ir.exports=nn()(j);var{formatters:wo}=ir.exports;wo.o=function(i){return this.inspectOpts.colors=this.useColors,tr.inspect(i,this.inspectOpts).split(`
16
- `).map(e=>e.trim()).join(" ")};wo.O=function(i){return this.inspectOpts.colors=this.useColors,tr.inspect(i,this.inspectOpts)}});var ti=F((ed,sn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?sn.exports=So():sn.exports=bo()});var Qo="v1",Zo=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,li=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=Qo,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=Zo,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=_({"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=_(_({},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=ea(this.apiUrl,e,t?`?${t.toString()}`:""),a={method:(r==null?void 0:r.method)||"GET",headers:_(_({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},l=yield fetch(o,a);if(!l.ok){let f=yield l.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${l.status}, Message: ${f.message}`)}if(l.status===204)return;let u=yield l.json();return n?u.data:u})}};function ea(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var lt="/inbox",Z=`${lt}/notifications`,P,hi=class{constructor(e={}){this.isSessionInitialized=!1;S(this,P);w(this,P,new li(e))}initializeSession(n){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,subscriber:r}){let s=yield c(this,P).post(`${lt}/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:l,data:u,severity:f}){let h=new URLSearchParams(`limit=${r}`);if(e&&h.append("after",e),n&&h.append("offset",`${n}`),o)for(let p of o)h.append("tags[]",p);if(s!==void 0&&h.append("read",`${s}`),t!==void 0&&h.append("archived",`${t}`),a!==void 0&&h.append("snoozed",`${a}`),l!==void 0&&h.append("seen",`${l}`),u!==void 0&&h.append("data",JSON.stringify(u)),f&&Array.isArray(f))for(let p of f)h.append("severity[]",p);else f&&h.append("severity",f);return c(this,P).get(Z,h,!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}/read-archive`,{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({tags:e,severity:t,criticality:r}){let n=new URLSearchParams;if(e)for(let o of e)n.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)n.append("severity[]",o);else t&&n.append("severity",t);r&&n.append("criticality",r);let s=n.size?`?${n.toString()}`:"";return c(this,P).get(`${lt}/preferences${s}`)}bulkUpdatePreferences(e){return c(this,P).patch(`${lt}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return c(this,P).patch(`${lt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return c(this,P).patch(`${lt}/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 vn(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 Je,fi=class{constructor(){S(this,Je);w(this,Je,vn())}on(e,t){return c(this,Je).on(e,t),()=>{this.off(e,t)}}off(e,t){c(this,Je).off(e,t)}emit(e,t){c(this,Je).emit(e,t)}};Je=new WeakMap;var A=class extends Error{constructor(e,t){super(e),this.originalError=t}};var ui=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to read notification",o)}}}),di=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to unread notification",o)}}}),pi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to mark notification as seen",o)}}}),mi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to archive notification",o)}}}),gi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to unarchive notification",o)}}}),yi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to snooze notification",o)}}}),vi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ae(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 A("Failed to unsnooze notification",o)}}}),ht=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:k(_({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:k(_({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:a}=Ae(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:a});let l=yield e.completeAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new A(`Failed to complete ${r} action on the notification`,l)}}}),ft=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:k(_({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:k(_({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:a}=Ae(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:a});let l=yield e.revertAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new A("Failed to fetch notifications",l)}}}),Ae=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(_(_({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},_n=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(l=>new U(k(_({},l),{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 A("Failed to read all notifications",o)}}}),ur=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}),u=(r&&r.length>0?a.filter(f=>r.includes(f.id)):a).map(f=>new U(k(_({},f),{isSeen:!0,firstSeenAt:f.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:u}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:u}),{}}catch(a){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:a}),{error:new A("Failed to mark all notifications as seen",a)}}}),En=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(l=>new U(k(_({},l),{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 A("Failed to archive all notifications",o)}}}),Sn=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(l=>new U(k(_({},l),{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 A("Failed to archive all read notifications",o)}}});var G,Q,U=class{constructor(e,t,r){S(this,G);S(this,Q);w(this,G,t),w(this,Q,r),this.id=e.id,this.transactionId=e.transactionId,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,this.severity=e.severity}read(){return ui({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}unread(){return di({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}seen(){return pi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}archive(){return mi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}unarchive(){return gi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}snooze(e){return yi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this,snoozeUntil:e}})}unsnooze(){return vi({emitter:c(this,G),apiService:c(this,Q),args:{notification:this}})}completePrimary(){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"})}completeSecondary(){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"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return ft({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 ft({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 qe,ut,Se=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){S(this,qe,[]);S(this,ut);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),c(this,qe).forEach(a=>m(this,[a],function*({fn:s,resolve:o}){o(yield s())})),w(this,qe,[])):r&&(this.onSessionError(r),w(this,ut,r),c(this,qe).forEach(({resolve:s})=>{s({error:new A("Failed to initialize session, please contact the support",r)})}),w(this,qe,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():c(this,ut)?Promise.resolve({error:new A("Failed to initialize session, please contact the support",c(this,ut))}):new Promise((t,r)=>{c(this,qe).push({fn:e,resolve:t,reject:r})})})}};qe=new WeakMap,ut=new WeakMap;var dr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var fh=["seen","unseen"],uh=["read","unread"],pr=(i,e)=>dr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,ta=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return dr(t,r)},mr=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},gr=(i,e)=>mr(i.data,e.data)&&pr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&ta(i.severity,e.severity);var pe,dt=class{constructor(){S(this,pe);w(this,pe,new Map)}get(e){return c(this,pe).get(e)}getValues(){return Array.from(c(this,pe).values())}entries(){return Array.from(c(this,pe).entries())}keys(){return Array.from(c(this,pe).keys())}set(e,t){c(this,pe).set(e,t)}remove(e){c(this,pe).delete(e)}clear(){c(this,pe).clear()}};pe=new WeakMap;var wn=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:a,offset:l,after:u})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:a,offset:l,after:u}).filter(([f,h])=>h!=null&&!(Array.isArray(h)&&h.length===0)).reduce((f,[h,p])=>(f[h]=p,f),{}),yr=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:a,offset:l,after:u})=>JSON.stringify(wn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:a,offset:l,after:u})),ia=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(wn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),pt=i=>JSON.parse(i),ra=["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"],na=["notification.archive.pending","notification.unarchive.pending","notification.snooze.pending","notification.unsnooze.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],We,$,Tt=class{constructor({emitter:e}){S(this,We);S(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,k(_({},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,k(_({},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(ia(pt(s)))})}),n.forEach(s=>{let o=this.getAggregated(pt(s));c(this,We).emit("notifications.list.updated",{data:o})})};w(this,We,e),ra.forEach(t=>{c(this,We).on(t,this.handleNotificationEvent())}),na.forEach(t=>{c(this,We).on(t,this.handleNotificationEvent({remove:!0}))}),w(this,$,new dt)}getAggregated(e){return c(this,$).keys().filter(r=>{let n=pt(r);return gr(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(yr(e))!==void 0}set(e,t){c(this,$).set(yr(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(pt(yr(e)));c(this,We).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,severity:e.severity})}getUniqueNotifications({tags:e,read:t,data:r}){let n=c(this,$).keys(),s=new Map;return n.forEach(o=>{let a=pt(o);if(pr(e,a.tags)&&mr(r,a.data)){let l=c(this,$).get(o);if(!l)return;l.notifications.filter(u=>typeof t=="undefined"||t===u.isRead).forEach(u=>{s.set(u.id,u)})}}),Array.from(s.values())}clear(e){c(this,$).keys().forEach(r=>{gr(pt(r),e)&&c(this,$).remove(r)})}clearAll(){c(this,$).clear()}};We=new WeakMap,$=new WeakMap;var Ot,_i=class extends Se{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});S(this,Ot);this.cache=new Tt({emitter:n}),w(this,Ot,t)}get inboxService(){return this._inboxService}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=hr(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=_({limit:t},r);try{let a="useCache"in o?o.useCache:c(this,Ot),l=a?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let u=yield this._inboxService.fetchNotifications(_({limit:t},r));l={hasMore:u.hasMore,filter:u.filter,notifications:u.data.map(f=>new U(f,this._emitter,this._inboxService))},a&&(this.cache.set(o,l),l=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:l}),{data:l}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new A("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:[_({},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 A("Failed to count notifications",n)}}}))})}read(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ui({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return di({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return pi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return vi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(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"})}))})}completeSecondary(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"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ft({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 ft({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 _n({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?ur({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):ur({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 En({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 Sn({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()})}};Ot=new WeakMap;var sa=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],oa=({tags:i,severity:e})=>Object.entries({tags:i,severity:e}).reduce((t,[r,n])=>(n==null||Array.isArray(n)&&n.length===0||(t[r]=n),t),{}),vr=({tags:i,severity:e})=>JSON.stringify(oa({tags:i,severity:e})),mt,ie,Ei=class{constructor({emitterInstance:e}){S(this,mt);S(this,ie);this.updatePreference=(e,t)=>{let r=c(this,ie).get(e);if(!r)return!1;let n=r.findIndex(o=>{var a,l;return((a=o.workflow)==null?void 0:a.id)===((l=t.workflow)==null?void 0:l.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,c(this,ie).set(e,s),!0};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;c(this,ie).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),a=c(this,ie).get(n);!o||!a||r.add(n)})}),r.forEach(n=>{var s;c(this,mt).emit("preferences.list.updated",{data:(s=c(this,ie).get(n))!=null?s:[]})})};w(this,mt,e),sa.forEach(t=>{c(this,mt).on(t,this.handlePreferenceEvent)}),w(this,ie,new dt)}has(e){return c(this,ie).get(vr(e))!==void 0}set(e,t){c(this,ie).set(vr(e),t)}getAll(e){if(this.has(e))return c(this,ie).get(vr(e))}clearAll(){c(this,ie).clear()}};mt=new WeakMap,ie=new WeakMap;var It,Pt,Lt,Ft,we=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){S(this,It);S(this,Pt);S(this,Lt);S(this,Ft);w(this,It,t),w(this,Pt,r),w(this,Lt,n),w(this,Ft,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 Si({emitter:c(this,It),apiService:c(this,Pt),cache:c(this,Lt),useCache:c(this,Ft),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};It=new WeakMap,Pt=new WeakMap,Lt=new WeakMap,Ft=new WeakMap;var Si=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var l;let{channels:o}=n,a="workflowId"in n?n.workflowId:(l=n.preference.workflow)==null?void 0:l.id;try{i.emit("preference.update.pending",{args:n,data:"preference"in n?new we(k(_({},n.preference),{channels:_(_({},n.preference.channels),o)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0});let u;a?u=yield e.updateWorkflowPreferences({workflowId:a,channels:o}):(aa({emitter:i,apiService:e,cache:t,useCache:r,args:n}),u=yield e.updateGlobalPreferences(o));let f=new we(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.update.resolved",{args:n,data:f}),{data:f}}catch(u){return i.emit("preference.update.resolved",{args:n,error:u}),{error:new A("Failed to update preference",u)}}}),bn=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 A("Global preference is not supported in bulk update","")};try{let a=n.map(h=>"preference"in h?new we(k(_({},h.preference),{channels:_(_({},h.preference.channels),h.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0).filter(h=>h!==void 0);i.emit("preferences.bulk_update.pending",{args:n,data:a});let l=n.map(h=>{var p,d,b,g;return _({workflowId:"workflowId"in h?h.workflowId:(g=(b=(p=h.preference.workflow)==null?void 0:p.id)!=null?b:(d=h.preference.workflow)==null?void 0:d.identifier)!=null?g:""},h.channels)}),f=(yield e.bulkUpdatePreferences(l)).map(h=>new we(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}));return i.emit("preferences.bulk_update.resolved",{args:n,data:f}),{data:f}}catch(a){return i.emit("preferences.bulk_update.resolved",{args:n,error:a}),{error:new A("Failed to bulk update preferences",a)}}}),aa=({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,l;if(o.level==="template"){let u=k(_({},o),{channels:Object.entries(o.channels).reduce((h,[p,d])=>{var g;let b=p;return h[b]=(g=n.channels[b])!=null?g:d,h},{})}),f="preference"in n?new we(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(l=(a=o.workflow)==null?void 0:a.id)!=null?l:"",channels:f.channels},data:f})}})};var Re,wi=class extends Se{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});S(this,Re);this.cache=new Ei({emitterInstance:this._emitter}),w(this,Re,t)}list(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){var r;try{let n=c(this,Re)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:n}),n||(n=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(r=t.criticality)!=null?r:"nonCritical"})).map(o=>new we(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:c(this,Re)})),c(this,Re)&&(this.cache.set(t,n),n=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:n}),{data:n}}catch(n){throw this._emitter.emit("preferences.list.resolved",{args:t,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Si({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:c(this,Re),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>bn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:c(this,Re),args:t}))})}};Re=new WeakMap;function xn(){return typeof window!="undefined"}var Xe,Ut,he,bi=class{constructor(e,t,r){S(this,Xe);S(this,Ut);S(this,he);w(this,Xe,r),w(this,Ut,t),w(this,he,e)}get applicationIdentifier(){return c(this,he).applicationIdentifier}get subscriberId(){var e;return(e=c(this,he).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,he).subscriber)==null?void 0:t.subscriberId)!==((r=e==null?void 0:e.subscriber)==null?void 0:r.subscriberId))try{e&&w(this,he,e);let{subscriber:l,subscriberHash:u,applicationIdentifier:f}=c(this,he),h;xn()&&(h=Intl.DateTimeFormat().resolvedOptions().timeZone);let p=f;if(p)this.handleApplicationIdentifier("delete");else{let b=this.handleApplicationIdentifier("get");b&&(p=b)}c(this,Xe).emit("session.initialize.pending",{args:c(this,he)});let d=yield c(this,Ut).initializeSession({applicationIdentifier:p,subscriberHash:u,subscriber:k(_({},l),{subscriberId:(n=l==null?void 0:l.subscriberId)!=null?n:"",timezone:(s=l==null?void 0:l.timezone)!=null?s:h})});(o=d==null?void 0:d.applicationIdentifier)!=null&&o.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",d.applicationIdentifier),(a=d==null?void 0:d.applicationIdentifier)!=null&&a.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),c(this,Xe).emit("session.initialize.resolved",{args:c(this,he),data:d})}catch(l){c(this,Xe).emit("session.initialize.resolved",{args:c(this,he),error:l})}})}};Xe=new WeakMap,Ut=new WeakMap,he=new WeakMap;function Cn({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}var xi=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,ca=function(){try{new xi.Event("")}catch(i){return!0}return!1}(),la=function(){try{new xi.EventTarget}catch(i){return!0}return!1}();ca&&(xi.Event=function(){function i(e,t){this.bubbles=!!t&&!!t.bubbles,this.cancelable=!!t&&!!t.cancelable,this.composed=!!t&&!!t.composed,this.type=e}return i}());la&&(xi.EventTarget=function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();n.has(s)||n.set(s,new Map);let o=n.get(s);o.has(t)||o.set(t,r)},i.prototype.removeEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();if(n.has(s)){let o=n.get(s);o.has(t)&&o.delete(t)}},i.prototype.dispatchEvent=function(e){if(!(e instanceof Event))throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.");let t=e.type,n=this.__listeners.get(t);if(n)for(var s of n.entries()){let o=s[0],a=s[1];try{typeof o=="function"?o.call(this,e):o&&typeof o.handleEvent=="function"&&o.handleEvent(e)}catch(l){setTimeout(()=>{throw l})}a&&a.once&&n.delete(o)}return!0},i}());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
14
+ `+s),i.push(n+"m+"+mr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Ml()+e+" "+i[0]}function Ml(){return K.inspectOpts.hideDate?"":new Date().toISOString()+" "}function ql(...i){return process.stderr.write(pr.formatWithOptions(K.inspectOpts,...i)+`
15
+ `)}function Wl(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function zl(){return process.env.DEBUG}function $l(i){i.inspectOpts={};let e=Object.keys(K.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=K.inspectOpts[e[t]]}mr.exports=vn()(K);var{formatters:Do}=mr.exports;Do.o=function(i){return this.inspectOpts.colors=this.useColors,pr.inspect(i,this.inspectOpts).split(`
16
+ `).map(e=>e.trim()).join(" ")};Do.O=function(i){return this.inspectOpts.colors=this.useColors,pr.inspect(i,this.inspectOpts)}});var hi=F((Pd,_n)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?_n.exports=Uo():_n.exports=Bo()});var da="v1",pa=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,vi=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=da,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=pa,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=E({"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=E(E({},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=ma(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:E(E({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},l=yield fetch(o,c);if(!l.ok){let h=yield l.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${l.status}, Message: ${h.message}`)}if(l.status===204)return;let u=yield l.json();return n?u.data:u})}};function ma(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var tt="/inbox",X=`${tt}/notifications`,R,_i=class{constructor(e={}){this.isSessionInitialized=!1;v(this,R);S(this,R,new vi(e))}initializeSession(s){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,subscriber:r,defaultSchedule:n}){let o=yield a(this,R).post(`${tt}/session`,{applicationIdentifier:e,subscriberHash:t,subscriber:r,defaultSchedule:n});return a(this,R).setAuthorizationToken(o.token),a(this,R).setKeylessHeader(o.applicationIdentifier),this.isSessionInitialized=!0,o})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:l,data:u,severity:h}){let f=new URLSearchParams(`limit=${r}`);if(e&&f.append("after",e),n&&f.append("offset",`${n}`),o)for(let d of o)f.append("tags[]",d);if(s!==void 0&&f.append("read",`${s}`),t!==void 0&&f.append("archived",`${t}`),c!==void 0&&f.append("snoozed",`${c}`),l!==void 0&&f.append("seen",`${l}`),u!==void 0&&f.append("data",JSON.stringify(u)),h&&Array.isArray(h))for(let d of h)f.append("severity[]",d);else h&&f.append("severity",h);return a(this,R).get(X,f,!1)}count({filters:e}){return a(this,R).get(`${X}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,R).patch(`${X}/${e}/read`)}unread(e){return a(this,R).patch(`${X}/${e}/unread`)}archive(e){return a(this,R).patch(`${X}/${e}/archive`)}unarchive(e){return a(this,R).patch(`${X}/${e}/unarchive`)}snooze(e,t){return a(this,R).patch(`${X}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,R).patch(`${X}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,R).post(`${X}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,R).post(`${X}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,R).post(`${X}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,R).delete(`${X}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,R).post(`${X}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,R).post(`${X}/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 a(this,R).patch(`${X}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,R).patch(`${X}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:r}){let n=new URLSearchParams;if(e)for(let o of e)n.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)n.append("severity[]",o);else t&&n.append("severity",t);r&&n.append("criticality",r);let s=n.size?`?${n.toString()}`:"";return a(this,R).get(`${tt}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,R).patch(`${tt}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,R).patch(`${tt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,R).patch(`${tt}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,R).get(`${tt}/preferences/global`)}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 a(this,R).post("/inbox/events",e)}};R=new WeakMap;function In(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 it,Ei=class{constructor(){v(this,it);S(this,it,In())}on(e,t){return a(this,it).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,it).off(e,t)}emit(e,t){a(this,it).emit(e,t)}};it=new WeakMap;var N=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Si=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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),c=new U(o,i,e);return i.emit("notification.read.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new N("Failed to read notification",o)}}}),wi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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),c=new U(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new N("Failed to unread notification",o)}}}),bi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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 N("Failed to mark notification as seen",o)}}}),xi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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),c=new U(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new N("Failed to archive notification",o)}}}),Ci=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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),c=new U(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new N("Failed to unarchive notification",o)}}}),Ni=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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),c=new U(o,i,e);return i.emit("notification.snooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.snooze.resolved",{args:t,error:o}),{error:new N("Failed to snooze notification",o)}}}),ki=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=be(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),c=new U(o,i,e);return i.emit("notification.unsnooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new N("Failed to unsnooze notification",o)}}}),mt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:A(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:A(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=be(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let l=yield e.completeAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new N(`Failed to complete ${r} action on the notification`,l)}}}),gt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:A(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:A(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=be(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let l=yield e.revertAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new N("Failed to fetch notifications",l)}}}),be=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(E(E({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},Pn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(A(E({},l),{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:c}),yield e.readAll({tags:r,data:n}),i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},error:o}),{error:new N("Failed to read all notifications",o)}}}),Cr=o=>m(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let c=t.getUniqueNotifications({tags:n,data:s}),u=(r&&r.length>0?c.filter(h=>r.includes(h.id)):c).map(h=>new U(A(E({},h),{isSeen:!0,firstSeenAt:h.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:u}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:u}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:c}),{error:new N("Failed to mark all notifications as seen",c)}}}),Ln=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(A(E({},l),{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:c}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new N("Failed to archive all notifications",o)}}}),Fn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(l=>new U(A(E({},l),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new N("Failed to archive all read notifications",o)}}}),Ai=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=be(t,{},{emitter:i,apiService:e});try{return i.emit("notification.delete.pending",{args:t}),yield e.delete(n),i.emit("notification.delete.resolved",{args:t}),{}}catch(s){return i.emit("notification.delete.resolved",{args:t,error:s}),{error:new N("Failed to delete notification",s)}}}),Un=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let o=t.getUniqueNotifications({tags:r,data:n});return i.emit("notifications.delete_all.pending",{args:{tags:r,data:n},data:o}),yield e.deleteAll({tags:r,data:n}),i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n}}),{}}catch(o){return i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n},error:o}),{error:new N("Failed to delete all notifications",o)}}});var V,Q,U=class{constructor(e,t,r){v(this,V);v(this,Q);S(this,V,t),S(this,Q,r),this.id=e.id,this.transactionId=e.transactionId,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,this.severity=e.severity}read(){return Si({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}unread(){return wi({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}seen(){return bi({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}archive(){return xi({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}unarchive(){return Ci({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}delete(){return Ai({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}snooze(e){return Ni({emitter:a(this,V),apiService:a(this,Q),args:{notification:this,snoozeUntil:e}})}unsnooze(){return ki({emitter:a(this,V),apiService:a(this,Q),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return mt({emitter:a(this,V),apiService:a(this,Q),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return mt({emitter:a(this,V),apiService:a(this,Q),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return gt({emitter:a(this,V),apiService:a(this,Q),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return gt({emitter:a(this,V),apiService:a(this,Q),args:{notification:this},actionType:"secondary"})}on(e,t){let r=a(this,V).on(e,t);return()=>{r()}}off(e,t){a(this,V).off(e,t)}};V=new WeakMap,Q=new WeakMap;var ze,yt,fe=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){v(this,ze,[]);v(this,yt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,ze).forEach(c=>m(this,[c],function*({fn:s,resolve:o}){o(yield s())})),S(this,ze,[])):r&&(this.onSessionError(r),S(this,yt,r),a(this,ze).forEach(({resolve:s})=>{s({error:new N("Failed to initialize session, please contact the support",r)})}),S(this,ze,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,yt)?Promise.resolve({error:new N("Failed to initialize session, please contact the support",a(this,yt))}):new Promise((t,r)=>{a(this,ze).push({fn:e,resolve:t,reject:r})})})}};ze=new WeakMap,yt=new WeakMap;var Nr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Ah=["seen","unseen"],Rh=["read","unread"],kr=(i,e)=>Nr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,ga=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return Nr(t,r)},Ar=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},Rr=(i,e)=>Ar(i.data,e.data)&&kr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&ga(i.severity,e.severity);var ge,$e=class{constructor(){v(this,ge);S(this,ge,new Map)}get(e){return a(this,ge).get(e)}getValues(){return Array.from(a(this,ge).values())}entries(){return Array.from(a(this,ge).entries())}keys(){return Array.from(a(this,ge).keys())}set(e,t){a(this,ge).set(e,t)}remove(e){a(this,ge).delete(e)}clear(){a(this,ge).clear()}};ge=new WeakMap;var Dn=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u}).filter(([h,f])=>f!=null&&!(Array.isArray(f)&&f.length===0)).reduce((h,[f,d])=>(h[f]=d,h),{}),Tr=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>JSON.stringify(Dn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})),ya=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(Dn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),vt=i=>JSON.parse(i),va=["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"],_a=["notification.archive.pending","notification.unarchive.pending","notification.snooze.pending","notification.unsnooze.pending","notification.delete.pending","notifications.archive_all.pending","notifications.archive_all_read.pending","notifications.delete_all.pending"],Ve,M,Lt=class{constructor({emitter:e}){v(this,Ve);v(this,M);this.updateNotification=(e,t)=>{let r=a(this,M).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,a(this,M).set(e,A(E({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,M).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),a(this,M).set(e,A(E({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:r,args:n}=t,s=[];if(r!=null)Array.isArray(r)&&r.every(c=>typeof c=="object"&&"id"in c)?s=r:typeof r=="object"&&"id"in r&&(s=[r]);else if(e&&n){if("notification"in n&&n.notification)s=[n.notification];else if("notificationId"in n&&n.notificationId){let c=[];a(this,M).keys().forEach(l=>{let u=a(this,M).get(l);if(u){let h=u.notifications.find(f=>f.id===n.notificationId);h&&c.push(h)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,M).keys().forEach(c=>{s.forEach(l=>{let u=!1;e?u=this.removeNotification(c,l):u=this.updateNotification(c,l),u&&o.add(ya(vt(c)))})}),o.forEach(c=>{let l=this.getAggregated(vt(c));a(this,Ve).emit("notifications.list.updated",{data:l})})};S(this,Ve,e),va.forEach(t=>{a(this,Ve).on(t,this.handleNotificationEvent())}),_a.forEach(t=>{a(this,Ve).on(t,this.handleNotificationEvent({remove:!0}))}),S(this,M,new $e)}getAggregated(e){return a(this,M).keys().filter(r=>{let n=vt(r);return Rr(n,e)}).map(r=>a(this,M).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 a(this,M).get(Tr(e))!==void 0}set(e,t){a(this,M).set(Tr(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(vt(Tr(e)));a(this,Ve).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,severity:e.severity})}getUniqueNotifications({tags:e,read:t,data:r}){let n=a(this,M).keys(),s=new Map;return n.forEach(o=>{let c=vt(o);if(kr(e,c.tags)&&Ar(r,c.data)){let l=a(this,M).get(o);if(!l)return;l.notifications.filter(u=>typeof t=="undefined"||t===u.isRead).forEach(u=>{s.set(u.id,u)})}}),Array.from(s.values())}clear(e){a(this,M).keys().forEach(r=>{Rr(vt(r),e)&&a(this,M).remove(r)})}clearAll(){a(this,M).clear()}};Ve=new WeakMap,M=new WeakMap;var Ft,Ri=class extends fe{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,Ft);this.cache=new Lt({emitter:n}),S(this,Ft,t)}get inboxService(){return this._inboxService}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=br(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=E({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,Ft),l=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let u=yield this._inboxService.fetchNotifications(E({limit:t},r));l={hasMore:u.hasMore,filter:u.filter,notifications:u.data.map(h=>new U(h,this._emitter,this._inboxService))},c&&(this.cache.set(o,l),l=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:l}),{data:l}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new N("Failed to fetch notifications",c)}}}))})}count(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){let r=t&&"filters"in t?t.filters:[E({},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 N("Failed to count notifications",n)}}}))})}read(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Si({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return wi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return bi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ci({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ai({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ni({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ki({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mt({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 mt({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 gt({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 gt({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 Pn({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?Cr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Cr({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 Ln({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 Fn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Un({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return m(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};Ft=new WeakMap;var Ut,Dt,Bt,Mt,Te=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){v(this,Ut);v(this,Dt);v(this,Bt);v(this,Mt);S(this,Ut,t),S(this,Dt,r),S(this,Bt,n),S(this,Mt,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return m(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return Ti({emitter:a(this,Ut),apiService:a(this,Dt),cache:a(this,Bt),useCache:a(this,Mt),args:E({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:E(E({},this.weeklySchedule),e.weeklySchedule)})})})}};Ut=new WeakMap,Dt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap;var qt,Wt,zt,$t,Vt,xe=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){v(this,qt);v(this,Wt);v(this,zt);v(this,$t);v(this,Vt);S(this,qt,t),S(this,Wt,r),S(this,zt,n),S(this,$t,s),S(this,Vt,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Te(E({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return Oi({emitter:a(this,qt),apiService:a(this,Wt),cache:a(this,zt),scheduleCache:a(this,$t),useCache:a(this,Vt),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};qt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,$t=new WeakMap,Vt=new WeakMap;var Oi=o=>m(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var u;let{channels:c}=s,l="workflowId"in s?s.workflowId:(u=s.preference.workflow)==null?void 0:u.id;try{i.emit("preference.update.pending",{args:s,data:"preference"in s?new xe(A(E({},s.preference),{channels:E(E({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let h;l?h=yield e.updateWorkflowPreferences({workflowId:l,channels:c}):(Ea({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),h=yield e.updateGlobalPreferences(c));let f=new xe(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(h){return i.emit("preference.update.resolved",{args:s,error:h}),{error:new N("Failed to update preference",h)}}}),Bn=o=>m(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){if(s.find(l=>"preference"in l&&l.preference.level==="global"))return{error:new N("Global preference is not supported in bulk update","")};try{let l=s.map(d=>"preference"in d?new xe(A(E({},d.preference),{channels:E(E({},d.preference.channels),d.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(d=>d!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let u=s.map(d=>{var p,b,g,_;return E({workflowId:"workflowId"in d?d.workflowId:(_=(g=(p=d.preference.workflow)==null?void 0:p.id)!=null?g:(b=d.preference.workflow)==null?void 0:b.identifier)!=null?_:""},d.channels)}),f=(yield e.bulkUpdatePreferences(u)).map(d=>new xe(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}));return i.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preferences.bulk_update.resolved",{args:s,error:l}),{error:new N("Failed to bulk update preferences",l)}}}),Ea=({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s})=>{let o=n?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var l,u;if(c.level==="template"){let h=A(E({},c),{channels:Object.entries(c.channels).reduce((d,[p,b])=>{var _;let g=p;return d[g]=(_=s.channels[g])!=null?_:b,d},{})}),f="preference"in s?new xe(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(u=(l=c.workflow)==null?void 0:l.id)!=null?u:"",channels:f.channels},data:f})}})},Ti=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:l,weeklySchedule:u}=n,h=new Te({isEnabled:l,weeklySchedule:u},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:h});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:l,weeklySchedule:u}}),d=new Te({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.schedule.update.resolved",{args:n,data:d}),{data:d}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new N("Failed to update preference",l)}}});var He,Ii=class extends fe{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});v(this,He);this.cache=t,S(this,He,r)}get(){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){var t,r;try{let n=a(this,He)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:n}),!n){let s=yield this._inboxService.fetchGlobalPreferences();n=new Te({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(r=s==null?void 0:s.schedule)==null?void 0:r.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,He)}),a(this,He)&&(this.cache.set(n),n=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:n}),{data:n}}catch(n){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Ti({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,He),args:t}))})}};He=new WeakMap;var Sa=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],wa=["preference.schedule.update.pending","preference.schedule.update.resolved"],ba=({tags:i,severity:e})=>Object.entries({tags:i,severity:e}).reduce((t,[r,n])=>(n==null||Array.isArray(n)&&n.length===0||(t[r]=n),t),{}),Or=({tags:i,severity:e})=>JSON.stringify(ba({tags:i,severity:e})),je,H,Pi=class{constructor({emitterInstance:e}){v(this,je);v(this,H);this.updatePreference=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>{var c,l;return((c=o.workflow)==null?void 0:c.id)===((l=t.workflow)==null?void 0:l.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,a(this,H).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>o.level==="global");if(n===-1)return!1;let s=[...r];return s[n].schedule=t,a(this,H).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var n;if(!e)return;let t=a(this,H).keys(),r=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,H).get(s);!o||!c||r.add(s)}for(let s of r)a(this,je).emit("preferences.list.updated",{data:(n=a(this,H).get(s))!=null?n:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;a(this,H).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),c=a(this,H).get(n);!o||!c||r.add(n)})}),r.forEach(n=>{var s;a(this,je).emit("preferences.list.updated",{data:(s=a(this,H).get(n))!=null?s:[]})})};S(this,je,e);for(let t of Sa)a(this,je).on(t,this.handlePreferenceEvent);for(let t of wa)a(this,je).on(t,this.handleScheduleEvent);S(this,H,new $e)}has(e){return a(this,H).get(Or(e))!==void 0}set(e,t){a(this,H).set(Or(e),t)}getAll(e){if(this.has(e))return a(this,H).get(Or(e))}clearAll(){a(this,H).clear()}};je=new WeakMap,H=new WeakMap;var xa=["preference.schedule.update.pending","preference.schedule.update.resolved"],Ir=()=>"schedule",_t,re,Li=class{constructor({emitterInstance:e}){v(this,_t);v(this,re);this.updateScheduleInCache=(e,t)=>a(this,re).get(e)?(a(this,re).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,re).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,re).get(n);!s||!o||t.add(n)}for(let n of t)a(this,_t).emit("preference.schedule.get.updated",{data:a(this,re).get(n)})};S(this,_t,e);for(let t of xa)a(this,_t).on(t,this.handleScheduleEvent);S(this,re,new $e)}has(){return a(this,re).get(Ir())!==void 0}set(e){a(this,re).set(Ir(),e)}getAll(){if(this.has())return a(this,re).get(Ir())}clearAll(){a(this,re).clear()}};_t=new WeakMap,re=new WeakMap;var Oe,Fi=class extends fe{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,Oe);this.cache=new Pi({emitterInstance:this._emitter}),this.scheduleCache=new Li({emitterInstance:this._emitter}),S(this,Oe,t),this.schedule=new Ii({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){var r;try{let n=a(this,Oe)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:n}),n||(n=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(r=t.criticality)!=null?r:"nonCritical"})).map(o=>new xe(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Oe)})),a(this,Oe)&&(this.cache.set(t,n),n=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:n}),{data:n}}catch(n){throw this._emitter.emit("preferences.list.resolved",{args:t,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Oi({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Oe),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>Bn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Oe),args:t}))})}};Oe=new WeakMap;function Mn(){return typeof window!="undefined"}var rt,Ht,ue,Ui=class{constructor(e,t,r){v(this,rt);v(this,Ht);v(this,ue);S(this,rt,r),S(this,Ht,t),S(this,ue,e)}get applicationIdentifier(){return a(this,ue).applicationIdentifier}get subscriberId(){var e;return(e=a(this,ue).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,c;if(((t=a(this,ue).subscriber)==null?void 0:t.subscriberId)!==((r=e==null?void 0:e.subscriber)==null?void 0:r.subscriberId))try{e&&S(this,ue,e);let{subscriber:l,subscriberHash:u,applicationIdentifier:h,defaultSchedule:f}=a(this,ue),d;Mn()&&(d=Intl.DateTimeFormat().resolvedOptions().timeZone);let p=h;if(p)this.handleApplicationIdentifier("delete");else{let g=this.handleApplicationIdentifier("get");g&&(p=g)}a(this,rt).emit("session.initialize.pending",{args:a(this,ue)});let b=yield a(this,Ht).initializeSession({applicationIdentifier:p,subscriberHash:u,subscriber:A(E({},l),{subscriberId:(n=l==null?void 0:l.subscriberId)!=null?n:"",timezone:(s=l==null?void 0:l.timezone)!=null?s:d}),defaultSchedule:f});(o=b==null?void 0:b.applicationIdentifier)!=null&&o.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",b.applicationIdentifier),(c=b==null?void 0:b.applicationIdentifier)!=null&&c.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,rt).emit("session.initialize.resolved",{args:a(this,ue),data:b})}catch(l){a(this,rt).emit("session.initialize.resolved",{args:a(this,ue),error:l})}})}};rt=new WeakMap,Ht=new WeakMap,ue=new WeakMap;function qn({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}var Di=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,Ca=function(){try{new Di.Event("")}catch(i){return!0}return!1}(),Na=function(){try{new Di.EventTarget}catch(i){return!0}return!1}();Ca&&(Di.Event=function(){function i(e,t){this.bubbles=!!t&&!!t.bubbles,this.cancelable=!!t&&!!t.cancelable,this.composed=!!t&&!!t.composed,this.type=e}return i}());Na&&(Di.EventTarget=function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();n.has(s)||n.set(s,new Map);let o=n.get(s);o.has(t)||o.set(t,r)},i.prototype.removeEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();if(n.has(s)){let o=n.get(s);o.has(t)&&o.delete(t)}},i.prototype.dispatchEvent=function(e){if(!(e instanceof Event))throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.");let t=e.type,n=this.__listeners.get(t);if(n)for(var s of n.entries()){let o=s[0],c=s[1];try{typeof o=="function"?o.call(this,e):o&&typeof o.handleEvent=="function"&&o.handleEvent(e)}catch(l){setTimeout(()=>{throw l})}c&&c.once&&n.delete(o)}return!0},i}());(!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 An=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},Rn=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}},_r={Event,ErrorEvent:An,CloseEvent:Rn};function ha(i,e){if(!i)throw new Error(e)}function fa(i){return new i.constructor(i.type,i)}function ua(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Rn(i.code||1999,i.reason||"unknown reason",i):"error"in i?new An(i.error,i):new Event(i.type,i)}var Nn,da=typeof process!="undefined"&&typeof((Nn=process.versions)==null?void 0:Nn.node)!="undefined"&&typeof document=="undefined",Ci=da?ua:fa,Qe={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},kn=!1,Ni=class Ze 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=Qe.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),ha(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(Ci(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Ci(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(Ci(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(Ci(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 Ze.CONNECTING}get OPEN(){return Ze.OPEN}get CLOSING(){return Ze.CLOSING}get CLOSED(){return Ze.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?Ze.CLOSED:Ze.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=Qe.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=Qe.reconnectionDelayGrowFactor,minReconnectionDelay:r=Qe.minReconnectionDelay,maxReconnectionDelay:n=Qe.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*yn(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=Qe.maxRetries,connectionTimeout:r=Qe.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"&&!kn&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
24
+ `);var $n=class extends Event{constructor(e,t){super("error",t);I(this,"message");I(this,"error");this.message=e.message,this.error=e}},Vn=class extends Event{constructor(e=1e3,t="",r){super("close",r);I(this,"code");I(this,"reason");I(this,"wasClean",!0);this.code=e,this.reason=t}},Pr={Event,ErrorEvent:$n,CloseEvent:Vn};function ka(i,e){if(!i)throw new Error(e)}function Aa(i){return new i.constructor(i.type,i)}function Ra(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Vn(i.code||1999,i.reason||"unknown reason",i):"error"in i?new $n(i.error,i):new Event(i.type,i)}var Wn,Ta=typeof process!="undefined"&&typeof((Wn=process.versions)==null?void 0:Wn.node)!="undefined"&&typeof document=="undefined",Bi=Ta?Ra:Aa,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},zn=!1,Mi=class st extends EventTarget{constructor(t,r,n={}){super();I(this,"_ws");I(this,"_retryCount",-1);I(this,"_uptimeTimeout");I(this,"_connectTimeout");I(this,"_shouldReconnect",!0);I(this,"_connectLock",!1);I(this,"_binaryType","blob");I(this,"_closeCalled",!1);I(this,"_messageQueue",[]);I(this,"_debugLogger",console.log.bind(console));I(this,"_url");I(this,"_protocols");I(this,"_options");I(this,"onclose",null);I(this,"onerror",null);I(this,"onmessage",null);I(this,"onopen",null);I(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=nt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),ka(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))});I(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Bi(t))});I(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()});I(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 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*On(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"&&!zn&&(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
- `),kn=!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 _r.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new _r.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 _r.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 Dt="wss://socket.novu.co",Tn="notifications.notification_received",On="notifications.unseen_count_changed",In="notifications.unread_count_changed",pa=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:a,createdAt:l,lastReadDate:u,firstSeenDate:f,archivedAt:h,channel:p,subscriber:d,subject:b,avatar:g,cta:v,tags:R,data:T,workflow:y,severity:E})=>{var Ke,Ye,X,Ue,De,Be,ue,de;let z={id:d==null?void 0:d._id,subscriberId:d==null?void 0:d.subscriberId,firstName:d==null?void 0:d.firstName,lastName:d==null?void 0:d.lastName,avatar:d==null?void 0:d.avatar,locale:d==null?void 0:d.locale,data:d==null?void 0:d.data,timezone:d==null?void 0:d.timezone,email:d==null?void 0:d.email,phone:d==null?void 0:d.phone},C=(Ye=(Ke=v.action)==null?void 0:Ke.buttons)==null?void 0:Ye.find(ke=>ke.type==="primary"),I=(Ue=(X=v.action)==null?void 0:X.buttons)==null?void 0:Ue.find(ke=>ke.type==="secondary"),M=(Be=(De=v.action)==null?void 0:De.result)==null?void 0:Be.type,te=(ue=v.action)==null?void 0:ue.status;return k(_(_({id:i,transactionId:e,subject:b,body:t,to:z,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},a&&{deliveredAt:a}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:f,archivedAt:h,avatar:g,primaryAction:C&&{label:C.content,isCompleted:M==="primary"&&te==="done",redirect:C.url?{target:C.target,url:C.url}:void 0},secondaryAction:I&&{label:I.content,isCompleted:M==="secondary"&&te==="done",redirect:I.url?{target:I.target,url:I.url}:void 0},channelType:p,tags:R,redirect:(de=v.data)!=null&&de.url?{url:v.data.url,target:v.data.target}:void 0,data:T,workflow:y,severity:E})},gt,me,ge,yt,Ai,Ri,Ti,Oi,be,Pn,Er,Sr,ki=class extends Se{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});S(this,be);S(this,gt);S(this,me);S(this,ge);S(this,yt);S(this,Ai,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&c(this,me).emit(Tn,{result:new U(pa(r.data.message),c(this,me),this._inboxService)})}catch(r){console.log("error",r)}});S(this,Ri,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&c(this,me).emit(On,{result:r.data.unseenCount})}catch(r){}});S(this,Ti,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&c(this,me).emit(In,{result:r.data.counts})}catch(r){}});S(this,Oi,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":c(this,Ai).call(this,t);break;case"unseen_count_changed":c(this,Ri).call(this,t);break;case"unread_count_changed":c(this,Ti).call(this,t);break;default:}}catch(r){}});w(this,me,n),w(this,yt,t!=null?t:Dt)}onSessionSuccess({token:t}){w(this,gt,t)}isSocketEvent(t){return t===Tn||t===On||t===In}connect(){return m(this,null,function*(){return c(this,gt)?le(this,be,Er).call(this):this.callWithSession(le(this,be,Er).bind(this))})}disconnect(){return m(this,null,function*(){return c(this,ge)?le(this,be,Sr).call(this):this.callWithSession(le(this,be,Sr).bind(this))})}};gt=new WeakMap,me=new WeakMap,ge=new WeakMap,yt=new WeakMap,Ai=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,Oi=new WeakMap,be=new WeakSet,Pn=function(){return m(this,null,function*(){if(c(this,ge))return;let t={socketUrl:c(this,yt)};c(this,me).emit("socket.connect.pending",{args:t});let r=new URL(c(this,yt));r.searchParams.set("token",c(this,gt)),w(this,ge,new Ni(r.toString())),c(this,ge).addEventListener("open",()=>{c(this,me).emit("socket.connect.resolved",{args:t})}),c(this,ge).addEventListener("error",n=>{c(this,me).emit("socket.connect.resolved",{args:t,error:n})}),c(this,ge).addEventListener("message",c(this,Oi))})},Er=function(){return m(this,null,function*(){try{return yield le(this,be,Pn).call(this),{}}catch(t){return{error:new A("Failed to initialize the PartySocket",t)}}})},Sr=function(){return m(this,null,function*(){var t;try{return(t=c(this,ge))==null||t.close(),w(this,ge,void 0),{}}catch(r){return{error:new A("Failed to disconnect from the PartySocket",r)}}})};var ye=Object.create(null);ye.open="0";ye.close="1";ye.ping="2";ye.pong="3";ye.message="4";ye.upgrade="5";ye.noop="6";var Bt=Object.create(null);Object.keys(ye).forEach(i=>{Bt[ye[i]]=i});var Mt={type:"error",data:"parser error"};var qt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Ln(e,!0).toString("base64")):r(ye[i]+(e||"")),Ln=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),wr;function Fn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Ln(i.data,!1));qt(i,!0,t=>{wr||(wr=new TextEncoder),e(wr.encode(t))})}var Wt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Un(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Un(r,e)}}return Bt[t]?i.length>1?{type:Bt[t],data:i.substring(1)}:{type:Bt[t]}:Mt},Un=(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 Dn="",Bn=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{qt(s,!1,a=>{r[o]=a,++n===t&&e(r.join(Dn))})})},Mn=(i,e)=>{let t=i.split(Dn),r=[];for(let n=0;n<t.length;n++){let s=Wt(t[n],e);if(r.push(s),s.type==="error")break}return r};function qn(){return new TransformStream({transform(i,e){Fn(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 br;function Ii(i){return i.reduce((e,t)=>e+t.length,0)}function Pi(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 Wn(i,e){br||(br=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(r===0){if(Ii(t)<1)break;let l=Pi(t,1);s=(l[0]&128)===128,n=l[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(Ii(t)<2)break;let l=Pi(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Ii(t)<8)break;let l=Pi(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),f=u.getUint32(0);if(f>Math.pow(2,21)-1){a.enqueue(Mt);break}n=f*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Ii(t)<n)break;let l=Pi(t,n);a.enqueue(Wt(s?l:br.decode(l),e)),r=0}if(n===0||n>i){a.enqueue(Mt);break}}}})}var xr=4;function L(i){if(i)return ma(i)}function ma(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 ve=global;function Li(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var ga=ve.setTimeout,ya=ve.clearTimeout;function Te(i,e){e.useNativeTimers?(i.setTimeoutFn=ga.bind(ve),i.clearTimeoutFn=ya.bind(ve)):(i.setTimeoutFn=ve.setTimeout.bind(ve),i.clearTimeoutFn=ve.clearTimeout.bind(ve))}var va=1.33;function zn(i){return typeof i=="string"?_a(i):Math.ceil((i.byteLength||i.size)*va)}function _a(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 es=Y(tt(),1);function Qn(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 za=(0,es.default)("engine.io-client:transport"),Or=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Oe=class extends L{constructor(e){super(),this.writable=!1,Te(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Or(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):za("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Wt(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=Qn(e);return t.length?"?"+t:""}};var hs=Y(tt(),1);var ns="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Ir=64,$a={},ts=0,Mi=0,is;function rs(i){let e="";do e=ns[i%Ir]+e,i=Math.floor(i/Ir);while(i>0);return e}function qi(){let i=rs(+new Date);return i!==is?(ts=0,is=i):i+"."+rs(ts++)}for(;Mi<Ir;Mi++)$a[ns[Mi]]=Mi;var Fr=Y(as(),1),Ur=Fr.default||Fr;function cs(){return new Lr}function Ha(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 l=a[0].trim(),u=a[1].trim();switch(l){case"Expires":s.expires=new Date(u);break;case"Max-Age":let f=new Date;f.setUTCSeconds(f.getUTCSeconds()+parseInt(u,10)),s.expires=f;break;default:}}return s}var Lr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=Ha(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,hs.default)("engine.io-client:polling");function ja(){}var Ga=function(){return new Ur({xdomain:!1}).responseType!=null}(),Wi=class extends Oe{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=Ga&&!t,this.opts.withCredentials&&(this.cookieJar=cs())}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)};Mn(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,Bn(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]=qi()),!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 $e(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}},$e=class i extends L{constructor(e,t){super(),Te(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=Li(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Ur(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=ja,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()}};$e.requestsCount=0;$e.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ls);else if(typeof addEventListener=="function"){let i="onpagehide"in ve?"pagehide":"unload";addEventListener(i,ls,!1)}}function ls(){for(let i in $e.requests)$e.requests.hasOwnProperty(i)&&$e.requests[i].abort()}var rl=Y(ps(),1),nl=Y(Hr(),1),sl=Y(Gr(),1),uo=Y(en(),1),ol=Y(fo(),1);var po=uo.default;var Zt=po,Xi=!1,mo="nodebuffer",st=process.nextTick;var yo=Y(tt(),1);var al=(0,yo.default)("engine.io-client:websocket"),go=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Qi=class extends Oe{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=go?{}:Li(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=Xi&&!go?t?new Zt(e,t):new Zt(e):new Zt(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;qt(r,this.supportsBinary,s=>{let o={};Xi||(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{Xi?this.ws.send(s):this.ws.send(s,o)}catch(a){al("websocket closed before onclose event")}n&&st(()=>{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]=qi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Zt}};var vo=Y(tt(),1),ei=(0,vo.default)("engine.io-client:webtransport"),Zi=class extends Oe{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{ei("transport closed gracefully"),this.onClose()}).catch(e=>{ei("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Wn(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=qn();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:a,value:l})=>{if(a){ei("session is closed");return}ei("received chunk: %o",l),this.onPacket(l),s()}).catch(a=>{ei("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&&st(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var rn={websocket:Qi,webtransport:Zi,polling:Wi};var cl=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ll=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ct(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=cl.exec(i||""),s={},o=14;for(;o--;)s[ll[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=hl(s,s.path),s.queryKey=fl(s,s.query),s}function hl(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 fl(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var _o=Y(tt(),1);var D=(0,_o.default)("engine.io-client:socket"),ot=class i extends L{constructor(e,t={}){super(),this.binaryType=mo,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Ct(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=Ct(t.host).host),Te(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=xr,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 rn[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",h=>{if(!r)if(h.type==="pong"&&h.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"),f(),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 p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function s(){r||(r=!0,f(),t.close(),t=null)}let o=h=>{let p=new Error("probe error: "+h);p.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,h),this.emitReserved("upgradeError",p)};function a(){o("transport closed")}function l(){o("socket closed")}function u(h){t&&h.name!==t.name&&(D('"%s" works - aborting "%s"',h.name,t.name),s())}let f=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",a),this.off("close",l),this.off("upgrading",u)};t.once("open",n),t.once("error",o),t.once("close",a),this.once("close",l),this.once("upgrading",u),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+=zn(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}};ot.protocol=xr;var ju=ot.protocol;var Co=Y(ti(),1),xo=(0,Co.default)("socket.io-client:url");function No(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)||(xo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),xo("parse %s",i),r=Ct(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 un={};Jo(un,{Decoder:()=>hn,Encoder:()=>ln,PacketType:()=>x,protocol:()=>Io});var kl=typeof ArrayBuffer=="function",Al=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,ko=Object.prototype.toString,Rl=typeof Blob=="function"||typeof Blob!="undefined"&&ko.call(Blob)==="[object BlobConstructor]",Tl=typeof File=="function"||typeof File!="undefined"&&ko.call(File)==="[object FileConstructor]";function ri(i){return kl&&(i instanceof ArrayBuffer||Al(i))||Rl&&i instanceof Blob||Tl&&i instanceof File}function ii(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(ii(i[t]))return!0;return!1}if(ri(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return ii(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&ii(i[t]))return!0;return!1}function Ao(i){let e=[],t=i.data,r=i;return r.data=on(t,e),r.attachments=e.length,{packet:r,buffers:e}}function on(i,e){if(!i)return i;if(ri(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]=on(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]=on(i[r],e));return t}return i}function Ro(i,e){return i.data=an(i.data,e),delete i.attachments,i}function an(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]=an(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=an(i[t],e));return i}var Oo=Y(tt(),1),cn=(0,Oo.default)("socket.io-parser"),Ol=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Io=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 ln=class{constructor(e){this.replacer=e}encode(e){return cn("encoding packet %j",e),(e.type===x.EVENT||e.type===x.ACK)&&ii(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)),cn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Ao(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function To(i){return Object.prototype.toString.call(i)==="[object Object]"}var hn=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 fn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ri(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 cn("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 To(t);case x.DISCONNECT:return t===void 0;case x.CONNECT_ERROR:return typeof t=="string"||To(t);case x.EVENT:case x.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Ol.indexOf(t[0])===-1);case x.ACK:case x.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},fn=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=Ro(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function oe(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Po=Y(ti(),1),W=(0,Po.default)("socket.io-client:socket"),Il=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Nt=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=[oe(e,"open",this.onopen.bind(this)),oe(e,"packet",this.onpacket.bind(this)),oe(e,"error",this.onerror.bind(this)),oe(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(Il.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++;W("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)?W("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&&(W("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));W("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&&(W("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(W("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(W("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){W("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,W("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(){W("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){W("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||[];W("emitting event %j",t),e.id!=null&&(W("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,W("sending ack %j",n),t.packet({type:x.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(W("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):W("bad ack %s",e.id)}onconnect(e,t){W("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(){W("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&&(W("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 at(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}at.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};at.prototype.reset=function(){this.attempts=0};at.prototype.setMin=function(i){this.ms=i};at.prototype.setMax=function(i){this.max=i};at.prototype.setJitter=function(i){this.jitter=i};var Lo=Y(ti(),1),K=(0,Lo.default)("socket.io-client:manager"),kt=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,Te(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 at({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||un;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 ot(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=oe(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=oe(t,"error",s);if(this._timeout!==!1){let a=this._timeout;K("connect attempt will timeout after %d",a);let l=this.setTimeoutFn(()=>{K("connect attempt timed out after %d",a),n(),s(new Error("timeout")),t.close()},a);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}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(oe(e,"ping",this.onping.bind(this)),oe(e,"data",this.ondata.bind(this)),oe(e,"error",this.onerror.bind(this)),oe(e,"close",this.onclose.bind(this)),oe(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){st(()=>{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 Nt(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 Uo=Y(ti(),1),Fo=(0,Uo.default)("socket.io-client"),ni={};function si(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=No(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=ni[n]&&s in ni[n].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return a?(Fo("ignoring socket cache for %s",r),l=new kt(r,e)):(ni[n]||(Fo("new io instance for %s",r),ni[n]=new kt(r,e)),l=ni[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(si,{Manager:kt,Socket:Nt,io:si,connect:si});var Pl="https://ws.novu.co",Do="notifications.notification_received",Bo="notifications.unseen_count_changed",Mo="notifications.unread_count_changed",Ll=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:a,createdAt:l,lastReadDate:u,firstSeenDate:f,archivedAt:h,channel:p,subscriber:d,subject:b,avatar:g,cta:v,tags:R,data:T,workflow:y,severity:E})=>{var Ke,Ye,X,Ue,De,Be,ue,de;let z={id:d==null?void 0:d._id,subscriberId:d==null?void 0:d.subscriberId,firstName:d==null?void 0:d.firstName,lastName:d==null?void 0:d.lastName,avatar:d==null?void 0:d.avatar,locale:d==null?void 0:d.locale,data:d==null?void 0:d.data,timezone:d==null?void 0:d.timezone,email:d==null?void 0:d.email,phone:d==null?void 0:d.phone},C=(Ye=(Ke=v.action)==null?void 0:Ke.buttons)==null?void 0:Ye.find(ke=>ke.type==="primary"),I=(Ue=(X=v.action)==null?void 0:X.buttons)==null?void 0:Ue.find(ke=>ke.type==="secondary"),M=(Be=(De=v.action)==null?void 0:De.result)==null?void 0:Be.type,te=(ue=v.action)==null?void 0:ue.status;return k(_(_({id:i,transactionId:e,subject:b,body:t,to:z,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},a&&{deliveredAt:a}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:f,archivedAt:h,avatar:g,primaryAction:C&&{label:C.content,isCompleted:M==="primary"&&te==="done",redirect:C.url?{target:C.target,url:C.url}:void 0},secondaryAction:I&&{label:I.content,isCompleted:M==="secondary"&&te==="done",redirect:I.url?{target:I.target,url:I.url}:void 0},channelType:p,tags:R,redirect:(de=v.data)!=null&&de.url?{url:v.data.url,target:v.data.target}:void 0,data:T,workflow:y,severity:E})},At,Ee,ae,Rt,nr,sr,or,Ce,qo,dn,pn,rr=class extends Se{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});S(this,Ce);S(this,At);S(this,Ee);S(this,ae);S(this,Rt);S(this,nr,({message:t})=>{c(this,Ee).emit(Do,{result:new U(Ll(t),c(this,Ee),this._inboxService)})});S(this,sr,({unseenCount:t})=>{c(this,Ee).emit(Bo,{result:t})});S(this,or,({counts:t})=>{c(this,Ee).emit(Mo,{result:t})});w(this,Ee,n),w(this,Rt,t!=null?t:Pl)}onSessionSuccess({token:t}){w(this,At,t)}isSocketEvent(t){return t===Do||t===Bo||t===Mo}connect(){return m(this,null,function*(){return c(this,At)?le(this,Ce,dn).call(this):this.callWithSession(le(this,Ce,dn).bind(this))})}disconnect(){return m(this,null,function*(){return c(this,ae)?le(this,Ce,pn).call(this):this.callWithSession(le(this,Ce,pn).bind(this))})}};At=new WeakMap,Ee=new WeakMap,ae=new WeakMap,Rt=new WeakMap,nr=new WeakMap,sr=new WeakMap,or=new WeakMap,Ce=new WeakSet,qo=function(){return m(this,null,function*(){var r,n,s;if(c(this,ae))return;let t={socketUrl:c(this,Rt)};c(this,Ee).emit("socket.connect.pending",{args:t}),w(this,ae,si(c(this,Rt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${c(this,At)}`}})),c(this,ae).on("connect",()=>{c(this,Ee).emit("socket.connect.resolved",{args:t})}),c(this,ae).on("connect_error",o=>{c(this,Ee).emit("socket.connect.resolved",{args:t,error:o})}),(r=c(this,ae))==null||r.on("notification_received",c(this,nr)),(n=c(this,ae))==null||n.on("unseen_count_changed",c(this,sr)),(s=c(this,ae))==null||s.on("unread_count_changed",c(this,or))})},dn=function(){return m(this,null,function*(){try{return yield le(this,Ce,qo).call(this),{}}catch(t){return{error:new A("Failed to initialize the socket",t)}}})},pn=function(){return m(this,null,function*(){var t;try{return(t=c(this,ae))==null||t.disconnect(),w(this,ae,void 0),{}}catch(r){return{error:new A("Failed to disconnect from the socket",r)}}})};var Fl=["wss://eu.socket.novu.co",Dt,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Ul={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Dt,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function Dl(i){return i?Ul[i]||i:Dt}function Bl(i){return!i||Fl.includes(i)}function Wo({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=Dl(i);switch(Bl(r)?"partysocket":"socket.io"){case"partysocket":return new ki({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new rr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Ne,Fe,Ge,ar=class{constructor(e){S(this,Ne);S(this,Fe);S(this,Ge);var t,r;w(this,Ge,new hi({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),w(this,Ne,new fi),w(this,Fe,new bi({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:Cn({subscriberId:e.subscriberId,subscriber:e.subscriber})},c(this,Ge),c(this,Ne))),c(this,Fe).initialize(),this.notifications=new _i({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:c(this,Ge),eventEmitterInstance:c(this,Ne)}),this.preferences=new wi({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:c(this,Ge),eventEmitterInstance:c(this,Ne)}),this.socket=Wo({socketUrl:e.socketUrl,eventEmitterInstance:c(this,Ne),inboxServiceInstance:c(this,Ge)}),this.on=(n,s)=>{this.socket.isSocketEvent(n)&&this.socket.connect();let o=c(this,Ne).on(n,s);return()=>{o()}},this.off=(n,s)=>{c(this,Ne).off(n,s)}}get applicationIdentifier(){return c(this,Fe).applicationIdentifier}get subscriberId(){return c(this,Fe).subscriberId}changeSubscriber(e){return m(this,null,function*(){yield c(this,Fe).initialize({applicationIdentifier:c(this,Fe).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber})})}};Ne=new WeakMap,Fe=new WeakMap,Ge=new WeakMap;window.Novu=ar;})();
37
+ `),zn=!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 Pr.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Pr.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 Pr.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 jt="wss://socket.novu.co",Hn="notifications.notification_received",jn="notifications.unseen_count_changed",Gn="notifications.unread_count_changed",Oa=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:u,firstSeenDate:h,archivedAt:f,channel:d,subscriber:p,subject:b,avatar:g,cta:_,tags:T,data:O,workflow:y,severity:w})=>{var Ze,et,ee,Be,Me,qe,pe,me;let $={id:p==null?void 0:p._id,subscriberId:p==null?void 0:p.subscriberId,firstName:p==null?void 0:p.firstName,lastName:p==null?void 0:p.lastName,avatar:p==null?void 0:p.avatar,locale:p==null?void 0:p.locale,data:p==null?void 0:p.data,timezone:p==null?void 0:p.timezone,email:p==null?void 0:p.email,phone:p==null?void 0:p.phone},C=(et=(Ze=_.action)==null?void 0:Ze.buttons)==null?void 0:et.find(Re=>Re.type==="primary"),P=(Be=(ee=_.action)==null?void 0:ee.buttons)==null?void 0:Be.find(Re=>Re.type==="secondary"),q=(qe=(Me=_.action)==null?void 0:Me.result)==null?void 0:qe.type,ie=(pe=_.action)==null?void 0:pe.status;return A(E(E({id:i,transactionId:e,subject:b,body:t,to:$,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:g,primaryAction:C&&{label:C.content,isCompleted:q==="primary"&&ie==="done",redirect:C.url?{target:C.target,url:C.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:q==="secondary"&&ie==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:d,tags:T,redirect:(me=_.data)!=null&&me.url?{url:_.data.url,target:_.data.target}:void 0,data:O,workflow:y,severity:w})},Et,ye,ve,St,Wi,zi,$i,Vi,Ce,Kn,Lr,Fr,qi=class extends fe{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,Ce);v(this,Et);v(this,ye);v(this,ve);v(this,St);v(this,Wi,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,ye).emit(Hn,{result:new U(Oa(r.data.message),a(this,ye),this._inboxService)})}catch(r){console.log("error",r)}});v(this,zi,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,ye).emit(jn,{result:r.data.unseenCount})}catch(r){}});v(this,$i,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,ye).emit(Gn,{result:r.data.counts})}catch(r){}});v(this,Vi,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,Wi).call(this,t);break;case"unseen_count_changed":a(this,zi).call(this,t);break;case"unread_count_changed":a(this,$i).call(this,t);break;default:}}catch(r){}});S(this,ye,n),S(this,St,t!=null?t:jt)}onSessionSuccess({token:t}){S(this,Et,t)}isSocketEvent(t){return t===Hn||t===jn||t===Gn}connect(){return m(this,null,function*(){return a(this,Et)?he(this,Ce,Lr).call(this):this.callWithSession(he(this,Ce,Lr).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,ve)?he(this,Ce,Fr).call(this):this.callWithSession(he(this,Ce,Fr).bind(this))})}};Et=new WeakMap,ye=new WeakMap,ve=new WeakMap,St=new WeakMap,Wi=new WeakMap,zi=new WeakMap,$i=new WeakMap,Vi=new WeakMap,Ce=new WeakSet,Kn=function(){return m(this,null,function*(){if(a(this,ve))return;let t={socketUrl:a(this,St)};a(this,ye).emit("socket.connect.pending",{args:t});let r=new URL(a(this,St));r.searchParams.set("token",a(this,Et)),S(this,ve,new Mi(r.toString())),a(this,ve).addEventListener("open",()=>{a(this,ye).emit("socket.connect.resolved",{args:t})}),a(this,ve).addEventListener("error",n=>{a(this,ye).emit("socket.connect.resolved",{args:t,error:n})}),a(this,ve).addEventListener("message",a(this,Vi))})},Lr=function(){return m(this,null,function*(){try{return yield he(this,Ce,Kn).call(this),{}}catch(t){return{error:new N("Failed to initialize the PartySocket",t)}}})},Fr=function(){return m(this,null,function*(){var t;try{return(t=a(this,ve))==null||t.close(),S(this,ve,void 0),{}}catch(r){return{error:new N("Failed to disconnect from the PartySocket",r)}}})};var _e=Object.create(null);_e.open="0";_e.close="1";_e.ping="2";_e.pong="3";_e.message="4";_e.upgrade="5";_e.noop="6";var Gt=Object.create(null);Object.keys(_e).forEach(i=>{Gt[_e[i]]=i});var Kt={type:"error",data:"parser error"};var Yt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Yn(e,!0).toString("base64")):r(_e[i]+(e||"")),Yn=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Ur;function Jn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Yn(i.data,!1));Yt(i,!0,t=>{Ur||(Ur=new TextEncoder),e(Ur.encode(t))})}var Jt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Xn(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Xn(r,e)}}return Gt[t]?i.length>1?{type:Gt[t],data:i.substring(1)}:{type:Gt[t]}:Kt},Xn=(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 Qn="",Zn=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Yt(s,!1,c=>{r[o]=c,++n===t&&e(r.join(Qn))})})},es=(i,e)=>{let t=i.split(Qn),r=[];for(let n=0;n<t.length;n++){let s=Jt(t[n],e);if(r.push(s),s.type==="error")break}return r};function ts(){return new TransformStream({transform(i,e){Jn(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 Dr;function Hi(i){return i.reduce((e,t)=>e+t.length,0)}function ji(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 is(i,e){Dr||(Dr=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(Hi(t)<1)break;let l=ji(t,1);s=(l[0]&128)===128,n=l[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(Hi(t)<2)break;let l=ji(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Hi(t)<8)break;let l=ji(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),h=u.getUint32(0);if(h>Math.pow(2,21)-1){c.enqueue(Kt);break}n=h*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Hi(t)<n)break;let l=ji(t,n);c.enqueue(Jt(s?l:Dr.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(Kt);break}}}})}var Br=4;function L(i){if(i)return Ia(i)}function Ia(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 Ee=global;function Gi(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var Pa=Ee.setTimeout,La=Ee.clearTimeout;function Ie(i,e){e.useNativeTimers?(i.setTimeoutFn=Pa.bind(Ee),i.clearTimeoutFn=La.bind(Ee)):(i.setTimeoutFn=Ee.setTimeout.bind(Ee),i.clearTimeoutFn=Ee.clearTimeout.bind(Ee))}var Fa=1.33;function rs(i){return typeof i=="string"?Ua(i):Math.ceil((i.byteLength||i.size)*Fa)}function Ua(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 ms=J(at(),1);function ds(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ps(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 sc=(0,ms.default)("engine.io-client:transport"),Hr=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Pe=class extends L{constructor(e){super(),this.writable=!1,Ie(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Hr(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):sc("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Jt(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=ds(e);return t.length?"?"+t:""}};var Cs=J(at(),1);var _s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),jr=64,oc={},gs=0,Qi=0,ys;function vs(i){let e="";do e=_s[i%jr]+e,i=Math.floor(i/jr);while(i>0);return e}function Zi(){let i=vs(+new Date);return i!==ys?(gs=0,ys=i):i+"."+vs(gs++)}for(;Qi<jr;Qi++)oc[_s[Qi]]=Qi;var Yr=J(ws(),1),Jr=Yr.default||Yr;function bs(){return new Kr}function cc(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 c=e[o].split("=");if(c.length!==2)continue;let l=c[0].trim(),u=c[1].trim();switch(l){case"Expires":s.expires=new Date(u);break;case"Max-Age":let h=new Date;h.setUTCSeconds(h.getUTCSeconds()+parseInt(u,10)),s.expires=h;break;default:}}return s}var Kr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=cc(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 te=(0,Cs.default)("engine.io-client:polling");function lc(){}var hc=function(){return new Jr({xdomain:!1}).responseType!=null}(),er=class extends Pe{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=hc&&!t,this.opts.withCredentials&&(this.cookieJar=bs())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{te("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(te("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){te("pre-pause polling complete"),--r||t()})),this.writable||(te("we are currently writing - waiting to pause"),r++,this.once("drain",function(){te("pre-pause writing complete"),--r||t()}))}else t()}poll(){te("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){te("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)};es(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():te('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{te("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(te("transport open - closing"),e()):(te("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Zn(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]=Zi()),!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 Ke(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(){te("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}},Ke=class i extends L{constructor(e,t){super(),Ie(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=Gi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Jr(t);try{te("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))},te("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=lc,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()}};Ke.requestsCount=0;Ke.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",xs);else if(typeof addEventListener=="function"){let i="onpagehide"in Ee?"pagehide":"unload";addEventListener(i,xs,!1)}}function xs(){for(let i in Ke.requests)Ke.requests.hasOwnProperty(i)&&Ke.requests[i].abort()}var El=J(Rs(),1),Sl=J(on(),1),wl=J(cn(),1),Ao=J(mn(),1),bl=J(ko(),1);var Ro=Ao.default;var ci=Ro,hr=!1,To="nodebuffer",ft=process.nextTick;var Io=J(at(),1);var xl=(0,Io.default)("engine.io-client:websocket"),Oo=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",fr=class extends Pe{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=Oo?{}:Gi(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=hr&&!Oo?t?new ci(e,t):new ci(e):new ci(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;Yt(r,this.supportsBinary,s=>{let o={};hr||(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{hr?this.ws.send(s):this.ws.send(s,o)}catch(c){xl("websocket closed before onclose event")}n&&ft(()=>{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]=Zi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!ci}};var Po=J(at(),1),li=(0,Po.default)("engine.io-client:webtransport"),ur=class extends Pe{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{li("transport closed gracefully"),this.onClose()}).catch(e=>{li("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=is(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=ts();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){li("session is closed");return}li("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{li("an error occurred while reading: %s",c)})};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&&ft(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var yn={websocket:fr,webtransport:ur,polling:er};var Cl=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Nl=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rt(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=Cl.exec(i||""),s={},o=14;for(;o--;)s[Nl[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=kl(s,s.path),s.queryKey=Al(s,s.query),s}function kl(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 Lo=J(at(),1);var D=(0,Lo.default)("engine.io-client:socket"),ut=class i extends L{constructor(e,t={}){super(),this.binaryType=To,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Rt(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=Rt(t.host).host),Ie(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=ps(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=Br,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 yn[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"),h(),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 d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function s(){r||(r=!0,h(),t.close(),t=null)}let o=f=>{let d=new Error("probe error: "+f);d.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",d)};function c(){o("transport closed")}function l(){o("socket closed")}function u(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let h=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",u)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",u),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+=rs(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}};ut.protocol=Br;var Cd=ut.protocol;var qo=J(hi(),1),Mo=(0,qo.default)("socket.io-client:url");function Wo(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)||(Mo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Mo("parse %s",i),r=Rt(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 Nn={};fa(Nn,{Decoder:()=>xn,Encoder:()=>bn,PacketType:()=>x,protocol:()=>Go});var Vl=typeof ArrayBuffer=="function",Hl=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,zo=Object.prototype.toString,jl=typeof Blob=="function"||typeof Blob!="undefined"&&zo.call(Blob)==="[object BlobConstructor]",Gl=typeof File=="function"||typeof File!="undefined"&&zo.call(File)==="[object FileConstructor]";function ui(i){return Vl&&(i instanceof ArrayBuffer||Hl(i))||jl&&i instanceof Blob||Gl&&i instanceof File}function fi(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(fi(i[t]))return!0;return!1}if(ui(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return fi(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&fi(i[t]))return!0;return!1}function $o(i){let e=[],t=i.data,r=i;return r.data=En(t,e),r.attachments=e.length,{packet:r,buffers:e}}function En(i,e){if(!i)return i;if(ui(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]=En(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]=En(i[r],e));return t}return i}function Vo(i,e){return i.data=Sn(i.data,e),delete i.attachments,i}function Sn(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]=Sn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=Sn(i[t],e));return i}var jo=J(at(),1),wn=(0,jo.default)("socket.io-parser"),Kl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Go=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 bn=class{constructor(e){this.replacer=e}encode(e){return wn("encoding packet %j",e),(e.type===x.EVENT||e.type===x.ACK)&&fi(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)),wn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=$o(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function Ho(i){return Object.prototype.toString.call(i)==="[object Object]"}var xn=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(ui(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 wn("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 Ho(t);case x.DISCONNECT:return t===void 0;case x.CONNECT_ERROR:return typeof t=="string"||Ho(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=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 Ko=J(hi(),1),z=(0,Ko.default)("socket.io-client:socket"),Yl=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Tt=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(Yl.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 c=t.pop();this._registerAckCallback(o,c),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,c)=>r?o?s(o):n(c):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 dt(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}dt.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};dt.prototype.reset=function(){this.attempts=0};dt.prototype.setMin=function(i){this.ms=i};dt.prototype.setMax=function(i){this.max=i};dt.prototype.setJitter=function(i){this.jitter=i};var Yo=J(hi(),1),Y=(0,Yo.default)("socket.io-client:manager"),Ot=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,Ie(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 dt({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||Nn;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(Y("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Y("opening %s",this.uri),this.engine=new ut(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=c=>{Y("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=ae(t,"error",s);if(this._timeout!==!1){let c=this._timeout;Y("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{Y("connect attempt timed out after %d",c),n(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){Y("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){ft(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){Y("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Tt(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){Y("socket %s is still active, skipping close",r);return}this._close()}_packet(e){Y("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(){Y("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){Y("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){Y("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)Y("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();Y("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(Y("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(Y("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(Y("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 Xo=J(hi(),1),Jo=(0,Xo.default)("socket.io-client"),di={};function pi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Wo(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=di[n]&&s in di[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Jo("ignoring socket cache for %s",r),l=new Ot(r,e)):(di[n]||(Jo("new io instance for %s",r),di[n]=new Ot(r,e)),l=di[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(pi,{Manager:Ot,Socket:Tt,io:pi,connect:pi});var Jl="https://ws.novu.co",Qo="notifications.notification_received",Zo="notifications.unseen_count_changed",ea="notifications.unread_count_changed",Xl=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:u,firstSeenDate:h,archivedAt:f,channel:d,subscriber:p,subject:b,avatar:g,cta:_,tags:T,data:O,workflow:y,severity:w})=>{var Ze,et,ee,Be,Me,qe,pe,me;let $={id:p==null?void 0:p._id,subscriberId:p==null?void 0:p.subscriberId,firstName:p==null?void 0:p.firstName,lastName:p==null?void 0:p.lastName,avatar:p==null?void 0:p.avatar,locale:p==null?void 0:p.locale,data:p==null?void 0:p.data,timezone:p==null?void 0:p.timezone,email:p==null?void 0:p.email,phone:p==null?void 0:p.phone},C=(et=(Ze=_.action)==null?void 0:Ze.buttons)==null?void 0:et.find(Re=>Re.type==="primary"),P=(Be=(ee=_.action)==null?void 0:ee.buttons)==null?void 0:Be.find(Re=>Re.type==="secondary"),q=(qe=(Me=_.action)==null?void 0:Me.result)==null?void 0:qe.type,ie=(pe=_.action)==null?void 0:pe.status;return A(E(E({id:i,transactionId:e,subject:b,body:t,to:$,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:g,primaryAction:C&&{label:C.content,isCompleted:q==="primary"&&ie==="done",redirect:C.url?{target:C.target,url:C.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:q==="secondary"&&ie==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:d,tags:T,redirect:(me=_.data)!=null&&me.url?{url:_.data.url,target:_.data.target}:void 0,data:O,workflow:y,severity:w})},It,we,ce,Pt,yr,vr,_r,ke,ta,kn,An,gr=class extends fe{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,ke);v(this,It);v(this,we);v(this,ce);v(this,Pt);v(this,yr,({message:t})=>{a(this,we).emit(Qo,{result:new U(Xl(t),a(this,we),this._inboxService)})});v(this,vr,({unseenCount:t})=>{a(this,we).emit(Zo,{result:t})});v(this,_r,({counts:t})=>{a(this,we).emit(ea,{result:t})});S(this,we,n),S(this,Pt,t!=null?t:Jl)}onSessionSuccess({token:t}){S(this,It,t)}isSocketEvent(t){return t===Qo||t===Zo||t===ea}connect(){return m(this,null,function*(){return a(this,It)?he(this,ke,kn).call(this):this.callWithSession(he(this,ke,kn).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,ce)?he(this,ke,An).call(this):this.callWithSession(he(this,ke,An).bind(this))})}};It=new WeakMap,we=new WeakMap,ce=new WeakMap,Pt=new WeakMap,yr=new WeakMap,vr=new WeakMap,_r=new WeakMap,ke=new WeakSet,ta=function(){return m(this,null,function*(){var r,n,s;if(a(this,ce))return;let t={socketUrl:a(this,Pt)};a(this,we).emit("socket.connect.pending",{args:t}),S(this,ce,pi(a(this,Pt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,It)}`}})),a(this,ce).on("connect",()=>{a(this,we).emit("socket.connect.resolved",{args:t})}),a(this,ce).on("connect_error",o=>{a(this,we).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,ce))==null||r.on("notification_received",a(this,yr)),(n=a(this,ce))==null||n.on("unseen_count_changed",a(this,vr)),(s=a(this,ce))==null||s.on("unread_count_changed",a(this,_r))})},kn=function(){return m(this,null,function*(){try{return yield he(this,ke,ta).call(this),{}}catch(t){return{error:new N("Failed to initialize the socket",t)}}})},An=function(){return m(this,null,function*(){var t;try{return(t=a(this,ce))==null||t.disconnect(),S(this,ce,void 0),{}}catch(r){return{error:new N("Failed to disconnect from the socket",r)}}})};var Ql=["wss://eu.socket.novu.co",jt,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Zl={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":jt,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function eh(i){return i?Zl[i]||i:jt}function th(i){return!i||Ql.includes(i)}function ia({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=eh(i);switch(th(r)?"partysocket":"socket.io"){case"partysocket":return new qi({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new gr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Ae,De,Qe,Er=class{constructor(e){v(this,Ae);v(this,De);v(this,Qe);var t,r;S(this,Qe,new _i({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),S(this,Ae,new Ei),S(this,De,new Ui({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:qn({subscriberId:e.subscriberId,subscriber:e.subscriber}),defaultSchedule:e.defaultSchedule},a(this,Qe),a(this,Ae))),a(this,De).initialize(),this.notifications=new Ri({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Ae)}),this.preferences=new Fi({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Ae)}),this.socket=ia({socketUrl:e.socketUrl,eventEmitterInstance:a(this,Ae),inboxServiceInstance:a(this,Qe)}),this.on=(n,s)=>{this.socket.isSocketEvent(n)&&this.socket.connect();let o=a(this,Ae).on(n,s);return()=>{o()}},this.off=(n,s)=>{a(this,Ae).off(n,s)}}get applicationIdentifier(){return a(this,De).applicationIdentifier}get subscriberId(){return a(this,De).subscriberId}changeSubscriber(e){return m(this,null,function*(){yield a(this,De).initialize({applicationIdentifier:a(this,De).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber})})}};Ae=new WeakMap,De=new WeakMap,Qe=new WeakMap;window.Novu=Er;})();
38
38
  /*! Bundled license information:
39
39
 
40
40
  xmlhttprequest-ssl/lib/XMLHttpRequest.js: