@novu/js 3.13.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/novu.min.js CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";(()=>{var tc=Object.create;var Vi=Object.defineProperty,ic=Object.defineProperties,rc=Object.getOwnPropertyDescriptor,nc=Object.getOwnPropertyDescriptors,sc=Object.getOwnPropertyNames,zi=Object.getOwnPropertySymbols,oc=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable;var ms=i=>{throw TypeError(i)},ys=Math.pow,nn=(i,e,t)=>e in i?Vi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,y=(i,e)=>{for(var t in e||(e={}))sn.call(e,t)&&nn(i,t,e[t]);if(zi)for(var t of zi(e))ps.call(e,t)&&nn(i,t,e[t]);return i},C=(i,e)=>ic(i,nc(e));var I=(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 on=(i,e)=>{var t={};for(var r in i)sn.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&zi)for(var r of zi(i))e.indexOf(r)<0&&ps.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),ac=(i,e)=>{for(var t in e)Vi(i,t,{get:e[t],enumerable:!0})},cc=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sc(e))!sn.call(i,n)&&n!==t&&Vi(i,n,{get:()=>e[n],enumerable:!(r=rc(e,n))||r.enumerable});return i};var te=(i,e,t)=>(t=i!=null?tc(oc(i)):{},cc(e||!i||!i.__esModule?Vi(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>nn(i,typeof e!="symbol"?e+"":e,t),an=(i,e,t)=>e.has(i)||ms("Cannot "+t);var a=(i,e,t)=>(an(i,e,"read from private field"),t?t.call(i):e.get(i)),g=(i,e,t)=>e.has(i)?ms("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),v=(i,e,t,r)=>(an(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ye=(i,e,t)=>(an(i,e,"access private method"),t);var d=(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 En=F(($d,Xs)=>{"use strict";var Bt=1e3,Mt=Bt*60,qt=Mt*60,St=qt*24,Oc=St*7,Pc=St*365.25;Xs.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return Lc(i);if(t==="number"&&isFinite(i))return e.long?Uc(i):Fc(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function Lc(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*Pc;case"weeks":case"week":case"w":return t*Oc;case"days":case"day":case"d":return t*St;case"hours":case"hour":case"hrs":case"hr":case"h":return t*qt;case"minutes":case"minute":case"mins":case"min":case"m":return t*Mt;case"seconds":case"second":case"secs":case"sec":case"s":return t*Bt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Fc(i){var e=Math.abs(i);return e>=St?Math.round(i/St)+"d":e>=qt?Math.round(i/qt)+"h":e>=Mt?Math.round(i/Mt)+"m":e>=Bt?Math.round(i/Bt)+"s":i+"ms"}function Uc(i){var e=Math.abs(i);return e>=St?Nr(i,e,St,"day"):e>=qt?Nr(i,e,qt,"hour"):e>=Mt?Nr(i,e,Mt,"minute"):e>=Bt?Nr(i,e,Bt,"second"):i+" ms"}function Nr(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var wn=F((Kd,Qs)=>{"use strict";function Dc(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=En(),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 p=0;p<h.length;p++)f=(f<<5)-f+h.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,p=null,m,x;function b(...S){if(!b.enabled)return;let T=b,N=Number(new Date),_=N-(f||N);T.diff=_,T.prev=f,T.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let E=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let z=t.formatters[P];if(typeof z=="function"){let ne=S[E];R=z.call(T,ne),S.splice(E,1),E--}return R}),t.formatArgs.call(T,S),(T.log||t.log).apply(T,S)}return b.namespace=h,b.useColors=t.useColors(),b.color=t.selectColor(h),b.extend=r,b.destroy=t.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(m!==t.namespaces&&(m=t.namespaces,x=t.enabled(h)),x),set:S=>{p=S}}),typeof t.init=="function"&&t.init(b),b}function r(h,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+h);return p.log=this.log,p}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,p=(typeof h=="string"?h:"").split(/[\s,]+/),m=p.length;for(f=0;f<m;f++)p[f]&&(h=p[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,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(h))return!1;for(f=0,p=t.names.length;f<p;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}Qs.exports=Dc});var Zs=F((he,Ar)=>{"use strict";he.formatArgs=Mc;he.save=qc;he.load=Wc;he.useColors=Bc;he.storage=$c();he.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`."))}})();he.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 Bc(){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 Mc(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Ar.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)}he.log=console.debug||console.log||(()=>{});function qc(i){try{i?he.storage.setItem("debug",i):he.storage.removeItem("debug")}catch(e){}}function Wc(){let i;try{i=he.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function $c(){try{return localStorage}catch(i){}}Ar.exports=wn()(he);var{formatters:Kc}=Ar.exports;Kc.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var to=F((zd,eo)=>{"use strict";eo.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 Nn=F((Vd,ro)=>{"use strict";var zc=I("os"),io=I("tty"),ge=to(),{env:j}=process,lt;ge("no-color")||ge("no-colors")||ge("color=false")||ge("color=never")?lt=0:(ge("color")||ge("colors")||ge("color=true")||ge("color=always"))&&(lt=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?lt=1:j.FORCE_COLOR==="false"?lt=0:lt=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function xn(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Cn(i,e){if(lt===0)return 0;if(ge("color=16m")||ge("color=full")||ge("color=truecolor"))return 3;if(ge("color=256"))return 2;if(i&&!e&&lt===void 0)return 0;let t=lt||0;if(j.TERM==="dumb")return t;if(process.platform==="win32"){let r=zc.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 Vc(i){let e=Cn(i,i&&i.isTTY);return xn(e)}ro.exports={supportsColor:Vc,stdout:xn(Cn(!0,io.isatty(1))),stderr:xn(Cn(!0,io.isatty(2)))}});var so=F((G,Rr)=>{"use strict";var Hc=I("tty"),kr=I("util");G.init=Zc;G.log=Jc;G.formatArgs=Gc;G.save=Xc;G.load=Qc;G.useColors=jc;G.destroy=kr.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=Nn();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 jc(){return"colors"in G.inspectOpts?!!G.inspectOpts.colors:Hc.isatty(process.stderr.fd)}function Gc(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 ic=Object.create;var Gi=Object.defineProperty,rc=Object.defineProperties,nc=Object.getOwnPropertyDescriptor,sc=Object.getOwnPropertyDescriptors,oc=Object.getOwnPropertyNames,Hi=Object.getOwnPropertySymbols,ac=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty,ys=Object.prototype.propertyIsEnumerable;var gs=i=>{throw TypeError(i)},vs=Math.pow,on=(i,e,t)=>e in i?Gi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,g=(i,e)=>{for(var t in e||(e={}))an.call(e,t)&&on(i,t,e[t]);if(Hi)for(var t of Hi(e))ys.call(e,t)&&on(i,t,e[t]);return i},C=(i,e)=>rc(i,sc(e));var I=(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 cn=(i,e)=>{var t={};for(var r in i)an.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&Hi)for(var r of Hi(i))e.indexOf(r)<0&&ys.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),cc=(i,e)=>{for(var t in e)Gi(i,t,{get:e[t],enumerable:!0})},lc=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of oc(e))!an.call(i,n)&&n!==t&&Gi(i,n,{get:()=>e[n],enumerable:!(r=nc(e,n))||r.enumerable});return i};var te=(i,e,t)=>(t=i!=null?ic(ac(i)):{},lc(e||!i||!i.__esModule?Gi(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>on(i,typeof e!="symbol"?e+"":e,t),ln=(i,e,t)=>e.has(i)||gs("Cannot "+t);var a=(i,e,t)=>(ln(i,e,"read from private field"),t?t.call(i):e.get(i)),y=(i,e,t)=>e.has(i)?gs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),v=(i,e,t,r)=>(ln(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ye=(i,e,t)=>(ln(i,e,"access private method"),t);var p=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{c(t.next(l))}catch(h){n(h)}},o=l=>{try{c(t.throw(l))}catch(h){n(h)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);c((t=t.apply(i,e)).next())});var xn=F((zd,Qs)=>{"use strict";var Bt=1e3,Mt=Bt*60,qt=Mt*60,St=qt*24,Lc=St*7,Fc=St*365.25;Qs.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return Uc(i);if(t==="number"&&isFinite(i))return e.long?Bc(i):Dc(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function Uc(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*Fc;case"weeks":case"week":case"w":return t*Lc;case"days":case"day":case"d":return t*St;case"hours":case"hour":case"hrs":case"hr":case"h":return t*qt;case"minutes":case"minute":case"mins":case"min":case"m":return t*Mt;case"seconds":case"second":case"secs":case"sec":case"s":return t*Bt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Dc(i){var e=Math.abs(i);return e>=St?Math.round(i/St)+"d":e>=qt?Math.round(i/qt)+"h":e>=Mt?Math.round(i/Mt)+"m":e>=Bt?Math.round(i/Bt)+"s":i+"ms"}function Bc(i){var e=Math.abs(i);return e>=St?Ar(i,e,St,"day"):e>=qt?Ar(i,e,qt,"hour"):e>=Mt?Ar(i,e,Mt,"minute"):e>=Bt?Ar(i,e,Bt,"second"):i+" ms"}function Ar(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var Cn=F((Vd,Zs)=>{"use strict";function Mc(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=xn(),t.destroy=h,Object.keys(i).forEach(u=>{t[u]=i[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let f=0;for(let m=0;m<u.length;m++)f=(f<<5)-f+u.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(u){let f,m=null,d,w;function b(...S){if(!b.enabled)return;let T=b,N=Number(new Date),_=N-(f||N);T.diff=_,T.prev=f,T.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let E=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let z=t.formatters[P];if(typeof z=="function"){let ne=S[E];R=z.call(T,ne),S.splice(E,1),E--}return R}),t.formatArgs.call(T,S),(T.log||t.log).apply(T,S)}return b.namespace=u,b.useColors=t.useColors(),b.color=t.selectColor(u),b.extend=r,b.destroy=t.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(d!==t.namespaces&&(d=t.namespaces,w=t.enabled(u)),w),set:S=>{m=S}}),typeof t.init=="function"&&t.init(b),b}function r(u,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+u);return m.log=this.log,m}function n(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let f,m=(typeof u=="string"?u:"").split(/[\s,]+/),d=m.length;for(f=0;f<d;f++)m[f]&&(u=m[f].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(u))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function h(){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}Zs.exports=Mc});var eo=F((ue,Rr)=>{"use strict";ue.formatArgs=Wc;ue.save=$c;ue.load=Kc;ue.useColors=qc;ue.storage=zc();ue.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`."))}})();ue.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 qc(){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 Wc(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Rr.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)}ue.log=console.debug||console.log||(()=>{});function $c(i){try{i?ue.storage.setItem("debug",i):ue.storage.removeItem("debug")}catch(e){}}function Kc(){let i;try{i=ue.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function zc(){try{return localStorage}catch(i){}}Rr.exports=Cn()(ue);var{formatters:Vc}=Rr.exports;Vc.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var io=F((Hd,to)=>{"use strict";to.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 An=F((Gd,no)=>{"use strict";var Hc=I("os"),ro=I("tty"),ge=io(),{env:G}=process,lt;ge("no-color")||ge("no-colors")||ge("color=false")||ge("color=never")?lt=0:(ge("color")||ge("colors")||ge("color=true")||ge("color=always"))&&(lt=1);"FORCE_COLOR"in G&&(G.FORCE_COLOR==="true"?lt=1:G.FORCE_COLOR==="false"?lt=0:lt=G.FORCE_COLOR.length===0?1:Math.min(parseInt(G.FORCE_COLOR,10),3));function Nn(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function kn(i,e){if(lt===0)return 0;if(ge("color=16m")||ge("color=full")||ge("color=truecolor"))return 3;if(ge("color=256"))return 2;if(i&&!e&&lt===void 0)return 0;let t=lt||0;if(G.TERM==="dumb")return t;if(process.platform==="win32"){let r=Hc.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in G)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in G)||G.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in G)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(G.TEAMCITY_VERSION)?1:0;if(G.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in G){let r=parseInt((G.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(G.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(G.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(G.TERM)||"COLORTERM"in G?1:t}function Gc(i){let e=kn(i,i&&i.isTTY);return Nn(e)}no.exports={supportsColor:Gc,stdout:Nn(kn(!0,ro.isatty(1))),stderr:Nn(kn(!0,ro.isatty(2)))}});var oo=F((j,Ir)=>{"use strict";var jc=I("tty"),Tr=I("util");j.init=tl;j.log=Qc;j.formatArgs=Jc;j.save=Zc;j.load=el;j.useColors=Yc;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=An();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 Yc(){return"colors"in j.inspectOpts?!!j.inspectOpts.colors:jc.isatty(process.stderr.fd)}function Jc(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+"+Rr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Yc()+e+" "+i[0]}function Yc(){return G.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Jc(...i){return process.stderr.write(kr.formatWithOptions(G.inspectOpts,...i)+`
4
- `)}function Xc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Qc(){return process.env.DEBUG}function Zc(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]]}Rr.exports=wn()(G);var{formatters:no}=Rr.exports;no.o=function(i){return this.inspectOpts.colors=this.useColors,kr.inspect(i,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};no.O=function(i){return this.inspectOpts.colors=this.useColors,kr.inspect(i,this.inspectOpts)}});var _t=F((Hd,An)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?An.exports=Zs():An.exports=so()});var yo=F((ep,mo)=>{"use strict";var Wt=I("fs"),po=I("url"),il=I("child_process").spawn;mo.exports=Tn;Tn.XMLHttpRequest=Tn;function Tn(i){"use strict";i=i||{};var e=this,t=I("http"),r=I("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"],p=!1,m=!1,x=!1,b={};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 S=function(_){return c||_&&h.indexOf(_.toLowerCase())===-1},T=function(_){return _&&f.indexOf(_)===-1};this.open=function(_,E,W,R,P){if(this.abort(),m=!1,x=!1,!T(_))throw new Error("SecurityError: Request method not allowed");o={method:_,url:E.toString(),async:typeof W!="boolean"?!0:W,user:R||null,password:P||null},N(this.OPENED)},this.setDisableHeaderCheck=function(_){c=_},this.setRequestHeader=function(_,E){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!S(_))return console.warn('Refused to set unsafe header "'+_+'"'),!1;if(p)throw new Error("INVALID_STATE_ERR: send flag is true");return u[_]=E,!0},this.getResponseHeader=function(_){return typeof _=="string"&&this.readyState>this.OPENED&&s.headers[_.toLowerCase()]&&!m?s.headers[_.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||m)return"";var _="";for(var E in s.headers)E!=="set-cookie"&&E!=="set-cookie2"&&(_+=E+": "+s.headers[E]+`\r
6
- `);return _.substr(0,_.length-2)},this.getRequestHeader=function(_){return typeof _=="string"&&u[_]?u[_]:""},this.send=function(_){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,W=!1,R=po.parse(o.url),P;switch(R.protocol){case"https:":E=!0;case"http:":P=R.hostname;break;case"file:":W=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(W){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Wt.readFile(unescape(R.pathname),"utf8",function(me,Tt){me?e.handleError(me,me.errno||-1):(e.status=200,e.responseText=Tt,N(e.DONE))});else try{this.responseText=Wt.readFileSync(unescape(R.pathname),"utf8"),this.status=200,N(e.DONE)}catch(me){this.handleError(me,me.errno||-1)}return}var z=R.port||(E?443:80),ne=R.pathname+(R.search?R.search:"");if(u.Host=P,E&&z===443||z===80||(u.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var Ue=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Ue.toString("base64")}o.method==="GET"||o.method==="HEAD"?_=null:_?(u["Content-Length"]=Buffer.isBuffer(_)?_.length:Buffer.byteLength(_),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var dt=i.agent||!1,se={host:P,port:z,path:ne,method:o.method,headers:u,agent:dt};if(E&&(se.pfx=i.pfx,se.key=i.key,se.passphrase=i.passphrase,se.cert=i.cert,se.ca=i.ca,se.ciphers=i.ciphers,se.rejectUnauthorized=i.rejectUnauthorized!==!1),m=!1,o.async){var Qe=E?r.request:t.request;p=!0,e.dispatchEvent("readystatechange");var Ze=function(me){if(s=me,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Tt=po.parse(o.url);P=Tt.hostname;var tt={hostname:Tt.hostname,port:Tt.port,path:Tt.path,method:s.statusCode===303?"GET":o.method,headers:u};E&&(tt.pfx=i.pfx,tt.key=i.key,tt.passphrase=i.passphrase,tt.cert=i.cert,tt.ca=i.ca,tt.ciphers=i.ciphers,tt.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Qe(tt,Ze).on("error",et),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(Ki){Ki&&(e.responseText+=Ki),p&&N(e.LOADING)}),s.on("end",function(){p&&(p=!1,N(e.DONE))}),s.on("error",function(Ki){e.handleError(Ki)})},et=function(me){e.handleError(me)};n=Qe(se,Ze).on("error",et),i.autoUnref&&n.on("socket",me=>{me.unref()}),_&&n.write(_),n.end(),e.dispatchEvent("loadstart")}else{var Se=".node-xmlhttprequest-content-"+process.pid,_e=".node-xmlhttprequest-sync-"+process.pid;Wt.writeFileSync(_e,"","utf8");for(var De="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"s":"")+".request;var options = "+JSON.stringify(se)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+Se+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+_e+"');});response.on('error', function(error) {fs.writeFileSync('"+Se+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+_e+"');});}).on('error', function(error) {fs.writeFileSync('"+Se+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+_e+"');});"+(_?"req.write('"+JSON.stringify(_).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Za=il(process.argv[0],["-e",De]),ou;Wt.existsSync(_e););if(e.responseText=Wt.readFileSync(Se,"utf8"),Za.stdin.end(),Wt.unlinkSync(Se),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var ec=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(ec,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),N(e.DONE)}},this.handleError=function(_,E){this.status=E||0,this.statusText=_,this.responseText=_.stack,m=!0,N(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),u=Object.assign({},l),this.responseText="",this.responseXML="",m=x=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||p)&&this.readyState!==this.DONE&&(p=!1,N(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(_,E){_ in b||(b[_]=[]),b[_].push(E)},this.removeEventListener=function(_,E){_ in b&&(b[_]=b[_].filter(function(W){return W!==E}))},this.dispatchEvent=function(_){if(typeof e["on"+_]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+_]()}):e["on"+_]()),_ in b)for(let E=0,W=b[_].length;E<W;E++)this.readyState===this.DONE?setImmediate(function(){b[_][E].call(e)}):b[_][E].call(e)};var N=function(_){if(!(e.readyState===_||e.readyState===e.UNSENT&&x)&&(e.readyState=_,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let E;x?E="abort":m?E="error":E="load",e.dispatchEvent(E),e.dispatchEvent("loadend")}}}});var wo=F((hp,Eo)=>{"use strict";var{Duplex:ol}=I("stream");function So(i){i.emit("close")}function al(){!this.destroyed&&this._writableState.finished&&this.destroy()}function _o(i){this.removeListener("error",_o),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function cl(i,e){let t=!0,r=new ol(C(y({},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(So,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(So,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",al),r.on("error",_o),r}Eo.exports=cl});var je=F((fp,No)=>{"use strict";var xo=["nodebuffer","arraybuffer","fragments"],Co=typeof Blob!="undefined";Co&&xo.push("blob");No.exports={BINARY_TYPES:xo,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Co,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ni=F((dp,Pr)=>{"use strict";var{EMPTY_BUFFER:ll}=je(),Ln=Buffer[Symbol.species];function hl(i,e){if(i.length===0)return ll;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?new Ln(t.buffer,t.byteOffset,r):t}function Ao(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function ko(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function ul(i){return i.length===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.length)}function Fn(i){if(Fn.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=new Ln(i):ArrayBuffer.isView(i)?e=new Ln(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),Fn.readOnly=!1),e}Pr.exports={concat:hl,mask:Ao,toArrayBuffer:ul,toBuffer:Fn,unmask:ko};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=I("bufferutil");Pr.exports.mask=function(e,t,r,n,s){s<48?Ao(e,t,r,n,s):i.mask(e,t,r,n,s)},Pr.exports.unmask=function(e,t){e.length<32?ko(e,t):i.unmask(e,t)}}catch(i){}});var Io=F((pp,To)=>{"use strict";var Ro=Symbol("kDone"),Un=Symbol("kRun"),Dn=class{constructor(e){this[Ro]=()=>{this.pending--,this[Un]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Un]()}[Un](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ro])}}};To.exports=Dn});var Ri=F((mp,Fo)=>{"use strict";var Ai=I("zlib"),Oo=Ni(),fl=Io(),{kStatusCode:Po}=je(),dl=Buffer[Symbol.species],pl=Buffer.from([0,0,255,255]),Ur=Symbol("permessage-deflate"),Ge=Symbol("total-length"),ki=Symbol("callback"),ut=Symbol("buffers"),Fr=Symbol("error"),Lr,Bn=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,!Lr){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Lr=new fl(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[ki];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){Lr.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Lr.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"?Ai.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ai.createInflateRaw(C(y({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Ur]=this,this._inflate[Ge]=0,this._inflate[ut]=[],this._inflate.on("error",yl),this._inflate.on("data",Lo)}this._inflate[ki]=r,this._inflate.write(e),t&&this._inflate.write(pl),this._inflate.flush(()=>{let s=this._inflate[Fr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Oo.concat(this._inflate[ut],this._inflate[Ge]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ge]=0,this._inflate[ut]=[],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"?Ai.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ai.createDeflateRaw(C(y({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ge]=0,this._deflate[ut]=[],this._deflate.on("data",ml)}this._deflate[ki]=r,this._deflate.write(e),this._deflate.flush(Ai.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Oo.concat(this._deflate[ut],this._deflate[Ge]);t&&(s=new dl(s.buffer,s.byteOffset,s.length-4)),this._deflate[ki]=null,this._deflate[Ge]=0,this._deflate[ut]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};Fo.exports=Bn;function ml(i){this[ut].push(i),this[Ge]+=i.length}function Lo(i){if(this[Ge]+=i.length,this[Ur]._maxPayload<1||this[Ge]<=this[Ur]._maxPayload){this[ut].push(i);return}this[Fr]=new RangeError("Max payload size exceeded"),this[Fr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Fr][Po]=1009,this.removeListener("data",Lo),this.reset()}function yl(i){this[Ur]._inflate=null,i[Po]=1007,this[ki](i)}});var $t=F((gp,Dr)=>{"use strict";var{isUtf8:Uo}=I("buffer"),{hasBlob:gl}=je(),vl=[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 bl(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Mn(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}function Sl(i){return gl&&typeof i=="object"&&typeof i.arrayBuffer=="function"&&typeof i.type=="string"&&typeof i.stream=="function"&&(i[Symbol.toStringTag]==="Blob"||i[Symbol.toStringTag]==="File")}Dr.exports={isBlob:Sl,isValidStatusCode:bl,isValidUTF8:Mn,tokenChars:vl};if(Uo)Dr.exports.isValidUTF8=function(i){return i.length<24?Mn(i):Uo(i)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=I("utf-8-validate");Dr.exports.isValidUTF8=function(e){return e.length<32?Mn(e):i(e)}}catch(i){}});var zn=F((vp,Ko)=>{"use strict";var{Writable:_l}=I("stream"),Do=Ri(),{BINARY_TYPES:El,EMPTY_BUFFER:Bo,kStatusCode:wl,kWebSocket:xl}=je(),{concat:qn,toArrayBuffer:Cl,unmask:Nl}=Ni(),{isValidStatusCode:Al,isValidUTF8:Mo}=$t(),Br=Buffer[Symbol.species],ve=0,qo=1,Wo=2,$o=3,Wn=4,$n=5,Mr=6,Kn=class extends _l{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||El[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[xl]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ve}_write(e,t,r){if(this._opcode===8&&this._state==ve)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]=new Br(r.buffer,r.byteOffset+e,r.length-e),new Br(r.buffer,r.byteOffset,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]=new Br(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case ve:this.getInfo(e);break;case qo:this.getPayloadLength16(e);break;case Wo:this.getPayloadLength64(e);break;case $o:this.getMask();break;case Wn:this.getData(e);break;case $n:case Mr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){let n=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(n);return}let r=(t[0]&64)===64;if(r&&!this._extensions[Do.extensionName]){let n=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(n);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let n=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(n);return}if(!this._fragmented){let n=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(n);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let n=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(n);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let n=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(n);return}if(r){let n=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(n);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let n=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(n);return}}else{let n=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(n);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let n=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(n);return}}else if(this._masked){let n=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(n);return}this._payloadLength===126?this._state=qo:this._payloadLength===127?this._state=Wo:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){let n=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(n);return}this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=$o:this._state=Wn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Wn}getData(e){let t=Bo;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]&&Nl(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=$n,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[Do.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){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(o);return}this._fragments.push(s)}this.dataMessage(t),this._state===ve&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=ve;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let n;this._binaryType==="nodebuffer"?n=qn(r,t):this._binaryType==="arraybuffer"?n=Cl(qn(r,t)):this._binaryType==="blob"?n=new Blob(r):n=r,this._allowSynchronousEvents?(this.emit("message",n,!0),this._state=ve):(this._state=Mr,setImmediate(()=>{this.emit("message",n,!0),this._state=ve,this.startLoop(e)}))}else{let n=qn(r,t);if(!this._skipUTF8Validation&&!Mo(n)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===$n||this._allowSynchronousEvents?(this.emit("message",n,!1),this._state=ve):(this._state=Mr,setImmediate(()=>{this.emit("message",n,!1),this._state=ve,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Bo),this.end();else{let r=e.readUInt16BE(0);if(!Al(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let n=new Br(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Mo(n)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",r,n),this.end()}this._state=ve;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ve):(this._state=Mr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ve,this.startLoop(t)}))}createError(e,t,r,n,s){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=s,o[wl]=n,o}};Ko.exports=Kn});var jn=F((Sp,Ho)=>{"use strict";var{Duplex:bp}=I("stream"),{randomFillSync:kl}=I("crypto"),zo=Ri(),{EMPTY_BUFFER:Rl,kWebSocket:Tl,NOOP:Il}=je(),{isBlob:Kt,isValidStatusCode:Ol}=$t(),{mask:Vo,toBuffer:Et}=Ni(),be=Symbol("kByteLength"),Pl=Buffer.alloc(4),qr=8*1024,wt,zt=qr,ke=0,Ll=1,Fl=2,Vn=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._queue=[],this._state=ke,this.onerror=Il,this[Tl]=void 0}static frame(e,t){let r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||Pl,t.generateMask?t.generateMask(r):(zt===qr&&(wt===void 0&&(wt=Buffer.alloc(qr)),kl(wt,0,qr),zt=0),r[0]=wt[zt++],r[1]=wt[zt++],r[2]=wt[zt++],r[3]=wt[zt++]),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[be]!==void 0?c=t[be]:(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?(Vo(e,r,u,s,c),[u]):(Vo(e,r,e,0,c),[u,e])):[u,e]}close(e,t,r,n){let s;if(e===void 0)s=Rl;else{if(typeof e!="number"||!Ol(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={[be]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ke?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):Kt(e)?(n=e.size,s=!1):(e=Et(e),n=e.length,s=Et.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Kt(e)?this._state!==ke?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==ke?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):Kt(e)?(n=e.size,s=!1):(e=Et(e),n=e.length,s=Et.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Kt(e)?this._state!==ke?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==ke?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[zo.extensionName],s=t.binary?2:1,o=t.compress,c,l;typeof e=="string"?(c=Buffer.byteLength(e),l=!1):Kt(e)?(c=e.size,l=!1):(e=Et(e),c=e.length,l=Et.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);let u={[be]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};Kt(e)?this._state!==ke?this.enqueue([this.getBlobData,e,this._compress,u,r]):this.getBlobData(e,this._compress,u,r):this._state!==ke?this.enqueue([this.dispatch,e,this._compress,u,r]):this.dispatch(e,this._compress,u,r)}getBlobData(e,t,r,n){this._bufferedBytes+=r[be],this._state=Fl,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(Hn,this,c,n);return}this._bufferedBytes-=r[be];let o=Et(s);t?this.dispatch(o,t,r,n):(this._state=ke,this.sendFrame(i.frame(o,r),n),this.dequeue())}).catch(s=>{process.nextTick(Ul,this,s,n)})}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[zo.extensionName];this._bufferedBytes+=r[be],this._state=Ll,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Hn(this,l,n);return}this._bufferedBytes-=r[be],this._state=ke,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;this._state===ke&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][be],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][be],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)}};Ho.exports=Vn;function Hn(i,e,t){typeof t=="function"&&t(e);for(let r=0;r<i._queue.length;r++){let n=i._queue[r],s=n[n.length-1];typeof s=="function"&&s(e)}}function Ul(i,e,t){Hn(i,e,t),i.onerror(e)}});var ta=F((_p,ea)=>{"use strict";var{kForOnEventAttribute:Ti,kListener:Gn}=je(),jo=Symbol("kCode"),Go=Symbol("kData"),Yo=Symbol("kError"),Jo=Symbol("kMessage"),Xo=Symbol("kReason"),Vt=Symbol("kTarget"),Qo=Symbol("kType"),Zo=Symbol("kWasClean"),Ye=class{constructor(e){this[Vt]=null,this[Qo]=e}get target(){return this[Vt]}get type(){return this[Qo]}};Object.defineProperty(Ye.prototype,"target",{enumerable:!0});Object.defineProperty(Ye.prototype,"type",{enumerable:!0});var xt=class extends Ye{constructor(e,t={}){super(e),this[jo]=t.code===void 0?0:t.code,this[Xo]=t.reason===void 0?"":t.reason,this[Zo]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[jo]}get reason(){return this[Xo]}get wasClean(){return this[Zo]}};Object.defineProperty(xt.prototype,"code",{enumerable:!0});Object.defineProperty(xt.prototype,"reason",{enumerable:!0});Object.defineProperty(xt.prototype,"wasClean",{enumerable:!0});var Ht=class extends Ye{constructor(e,t={}){super(e),this[Yo]=t.error===void 0?null:t.error,this[Jo]=t.message===void 0?"":t.message}get error(){return this[Yo]}get message(){return this[Jo]}};Object.defineProperty(Ht.prototype,"error",{enumerable:!0});Object.defineProperty(Ht.prototype,"message",{enumerable:!0});var Ii=class extends Ye{constructor(e,t={}){super(e),this[Go]=t.data===void 0?null:t.data}get data(){return this[Go]}};Object.defineProperty(Ii.prototype,"data",{enumerable:!0});var Dl={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[Ti]&&n[Gn]===e&&!n[Ti])return;let r;if(i==="message")r=function(s,o){let c=new Ii("message",{data:o?s:s.toString()});c[Vt]=this,Wr(e,this,c)};else if(i==="close")r=function(s,o){let c=new xt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[Vt]=this,Wr(e,this,c)};else if(i==="error")r=function(s){let o=new Ht("error",{error:s,message:s.message});o[Vt]=this,Wr(e,this,o)};else if(i==="open")r=function(){let s=new Ye("open");s[Vt]=this,Wr(e,this,s)};else return;r[Ti]=!!t[Ti],r[Gn]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[Gn]===e&&!t[Ti]){this.removeListener(i,t);break}}};ea.exports={CloseEvent:xt,ErrorEvent:Ht,Event:Ye,EventTarget:Dl,MessageEvent:Ii};function Wr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var Yn=F((Ep,ia)=>{"use strict";var{tokenChars:Oi}=$t();function Le(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Bl(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&&Oi[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 m=i.slice(l,h);u===44?(Le(e,m,t),t=Object.create(null)):o=m,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(h===-1&&Oi[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),Le(t,i.slice(l,h),!0),u===44&&(Le(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(Oi[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(Oi[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&&Oi[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 m=i.slice(l,h);r&&(m=m.replace(/\\/g,""),r=!1),Le(t,c,m),u===44&&(Le(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 p=i.slice(l,h);return o===void 0?Le(e,p,t):(c===void 0?Le(t,p,!0):r?Le(t,c,p.replace(/\\/g,"")):Le(t,c,p),Le(e,o,t)),e}function Ml(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(", ")}ia.exports={format:Ml,parse:Bl}});var es=F((Cp,pa)=>{"use strict";var ql=I("events"),Wl=I("https"),$l=I("http"),sa=I("net"),Kl=I("tls"),{randomBytes:zl,createHash:Vl}=I("crypto"),{Duplex:wp,Readable:xp}=I("stream"),{URL:Jn}=I("url"),ft=Ri(),Hl=zn(),jl=jn(),{isBlob:Gl}=$t(),{BINARY_TYPES:ra,EMPTY_BUFFER:$r,GUID:Yl,kForOnEventAttribute:Xn,kListener:Jl,kStatusCode:Xl,kWebSocket:Y,NOOP:oa}=je(),{EventTarget:{addEventListener:Ql,removeEventListener:Zl}}=ta(),{format:eh,parse:th}=Yn(),{toBuffer:ih}=Ni(),rh=30*1e3,aa=Symbol("kAborted"),Qn=[8,13],Je=["CONNECTING","OPEN","CLOSING","CLOSED"],nh=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,D=class i extends ql{constructor(e,t,r){super(),this._binaryType=ra[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=$r,this._closeTimer=null,this._errorEmitted=!1,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]),ca(this,e,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){ra.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 Hl({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new jl(e,this._extensions,r.generateMask);this._receiver=n,this._sender=s,this._socket=e,n[Y]=this,s[Y]=this,e[Y]=this,n.on("conclude",ah),n.on("drain",ch),n.on("error",lh),n.on("message",hh),n.on("ping",uh),n.on("pong",fh),s.onerror=dh,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",ua),e.on("data",zr),e.on("end",fa),e.on("error",da),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[ft.extensionName]&&this._extensions[ft.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){ue(this,this._req,"WebSocket was closed before the connection was established");return}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())}),ha(this)}}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){Zn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||$r,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){Zn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||$r,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){Zn(this,e,r);return}let n=y({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[ft.extensionName]||(n.compress=!1),this._sender.send(e||$r,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING){ue(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:Je.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:Je.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:Je.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:Je.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:Je.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:Je.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:Je.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:Je.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(D.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(D.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Xn])return e[Jl];return null},set(e){for(let t of this.listeners(i))if(t[Xn]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Xn]:!0})}})});D.prototype.addEventListener=Ql;D.prototype.removeEventListener=Zl;pa.exports=D;function ca(i,e,t,r){let n=C(y({allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Qn[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(i._autoPong=n.autoPong,!Qn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Qn.join(", ")})`);let s;if(e instanceof Jn)s=e;else try{s=new Jn(e)}catch(b){throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),i._url=s.href;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:", "http:", "https", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let b=new SyntaxError(l);if(i._redirects===0)throw b;Kr(i,b);return}let u=o?443:80,h=zl(16).toString("base64"),f=o?Wl.request:$l.request,p=new Set,m;if(n.createConnection=n.createConnection||(o?oh:sh),n.defaultPort=n.defaultPort||u,n.port=s.port||u,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=C(y({},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&&(m=new ft(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=eh({[ft.extensionName]:m.offer()})),t.length){for(let b of t){if(typeof b!="string"||!nh.test(b)||p.has(b))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(b)}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 b=n.path.split(":");n.socketPath=b[0],n.path=b[1]}let x;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let b=r&&r.headers;if(r=C(y({},r),{headers:{}}),b)for(let[S,T]of Object.entries(b))r.headers[S.toLowerCase()]=T}else if(i.listenerCount("redirect")===0){let b=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!b||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,b||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),x=i._req=f(n),i._redirects&&i.emit("redirect",i.url,x)}else x=i._req=f(n);n.timeout&&x.on("timeout",()=>{ue(i,x,"Opening handshake has timed out")}),x.on("error",b=>{x===null||x[aa]||(x=i._req=null,Kr(i,b))}),x.on("response",b=>{let S=b.headers.location,T=b.statusCode;if(S&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){ue(i,x,"Maximum redirects exceeded");return}x.abort();let N;try{N=new Jn(S,e)}catch(_){let E=new SyntaxError(`Invalid URL: ${S}`);Kr(i,E);return}ca(i,N,t,r)}else i.emit("unexpected-response",x,b)||ue(i,x,`Unexpected server response: ${b.statusCode}`)}),x.on("upgrade",(b,S,T)=>{if(i.emit("upgrade",b),i.readyState!==D.CONNECTING)return;x=i._req=null;let N=b.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){ue(i,S,"Invalid Upgrade header");return}let _=Vl("sha1").update(h+Yl).digest("base64");if(b.headers["sec-websocket-accept"]!==_){ue(i,S,"Invalid Sec-WebSocket-Accept header");return}let E=b.headers["sec-websocket-protocol"],W;if(E!==void 0?p.size?p.has(E)||(W="Server sent an invalid subprotocol"):W="Server sent a subprotocol but none was requested":p.size&&(W="Server sent no subprotocol"),W){ue(i,S,W);return}E&&(i._protocol=E);let R=b.headers["sec-websocket-extensions"];if(R!==void 0){if(!m){ue(i,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=th(R)}catch(ne){ue(i,S,"Invalid Sec-WebSocket-Extensions header");return}let z=Object.keys(P);if(z.length!==1||z[0]!==ft.extensionName){ue(i,S,"Server indicated an extension that was not requested");return}try{m.accept(P[ft.extensionName])}catch(ne){ue(i,S,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[ft.extensionName]=m}i.setSocket(S,T,{allowSynchronousEvents:n.allowSynchronousEvents,generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),n.finishRequest?n.finishRequest(x,i):x.end()}function Kr(i,e){i._readyState=D.CLOSING,i._errorEmitted=!0,i.emit("error",e),i.emitClose()}function sh(i){return i.path=i.socketPath,sa.connect(i)}function oh(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=sa.isIP(i.host)?"":i.host),Kl.connect(i)}function ue(i,e,t){i._readyState=D.CLOSING;let r=new Error(t);Error.captureStackTrace(r,ue),e.setHeader?(e[aa]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Kr,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function Zn(i,e,t){if(e){let r=Gl(e)?e.size:ih(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Je[i.readyState]})`);process.nextTick(t,r)}}function ah(i,e){let t=this[Y];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[Y]!==void 0&&(t._socket.removeListener("data",zr),process.nextTick(la,t._socket),i===1005?t.close():t.close(i,e))}function ch(){let i=this[Y];i.isPaused||i._socket.resume()}function lh(i){let e=this[Y];e._socket[Y]!==void 0&&(e._socket.removeListener("data",zr),process.nextTick(la,e._socket),e.close(i[Xl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i))}function na(){this[Y].emitClose()}function hh(i,e){this[Y].emit("message",i,e)}function uh(i){let e=this[Y];e._autoPong&&e.pong(i,!this._isServer,oa),e.emit("ping",i)}function fh(i){this[Y].emit("pong",i)}function la(i){i.resume()}function dh(i){let e=this[Y];e.readyState!==D.CLOSED&&(e.readyState===D.OPEN&&(e._readyState=D.CLOSING,ha(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i)))}function ha(i){i._closeTimer=setTimeout(i._socket.destroy.bind(i._socket),rh)}function ua(){let i=this[Y];this.removeListener("close",ua),this.removeListener("data",zr),this.removeListener("end",fa),i._readyState=D.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[Y]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",na),i._receiver.on("finish",na))}function zr(i){this[Y]._receiver.write(i)||this.pause()}function fa(){let i=this[Y];i._readyState=D.CLOSING,i._receiver.end(),this.end()}function da(){let i=this[Y];this.removeListener("error",da),this.on("error",oa),i&&(i._readyState=D.CLOSING,this.destroy())}});var ya=F((Ap,ma)=>{"use strict";var{tokenChars:ph}=$t();function mh(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&&ph[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}ma.exports={parse:mh}});var wa=F((Rp,Ea)=>{"use strict";var yh=I("events"),Vr=I("http"),{Duplex:kp}=I("stream"),{createHash:gh}=I("crypto"),ga=Yn(),Ct=Ri(),vh=ya(),bh=es(),{GUID:Sh,kWebSocket:_h}=je(),Eh=/^[+/0-9A-Za-z]{22}==$/,va=0,ba=1,_a=2,ts=class extends yh{constructor(e,t){if(super(),e=y({allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:bh},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=Vr.createServer((r,n)=>{let s=Vr.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=wh(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=va}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===_a){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Pi,this);return}if(e&&this.once("close",e),this._state!==ba)if(this._state=ba,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(Pi,this):process.nextTick(Pi,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Pi(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",Sa);let s=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Nt(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Nt(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!Eh.test(s)){Nt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==8&&c!==13){Nt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Li(t,400);return}let l=e.headers["sec-websocket-protocol"],u=new Set;if(l!==void 0)try{u=vh.parse(l)}catch(p){Nt(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&h!==void 0){let p=new Ct(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=ga.parse(h);m[Ct.extensionName]&&(p.accept(m[Ct.extensionName]),f[Ct.extensionName]=p)}catch(m){Nt(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:e.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(m,x,b,S)=>{if(!m)return Li(t,x||401,b,S);this.completeUpgrade(f,s,u,e,t,r,n)});return}if(!this.options.verifyClient(p))return Li(t,401)}this.completeUpgrade(f,s,u,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[_h])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>va)return Li(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${gh("sha1").update(t+Sh).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);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[Ct.extensionName]){let f=e[Ct.extensionName].params,p=ga.format({[Ct.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${p}`),h._extensions=e}this.emit("headers",u,n),s.write(u.concat(`\r
3
+ `+s),i.push(n+"m+"+Ir.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Xc()+e+" "+i[0]}function Xc(){return j.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Qc(...i){return process.stderr.write(Tr.formatWithOptions(j.inspectOpts,...i)+`
4
+ `)}function Zc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function el(){return process.env.DEBUG}function tl(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=Cn()(j);var{formatters:so}=Ir.exports;so.o=function(i){return this.inspectOpts.colors=this.useColors,Tr.inspect(i,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(" ")};so.O=function(i){return this.inspectOpts.colors=this.useColors,Tr.inspect(i,this.inspectOpts)}});var _t=F((jd,Rn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Rn.exports=eo():Rn.exports=oo()});var go=F((ip,yo)=>{"use strict";var Wt=I("fs"),mo=I("url"),nl=I("child_process").spawn;yo.exports=On;On.XMLHttpRequest=On;function On(i){"use strict";i=i||{};var e=this,t=I("http"),r=I("https"),n,s,o={},c=!1,l={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},h=Object.assign({},l),u=["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"],m=!1,d=!1,w=!1,b={};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 S=function(_){return c||_&&u.indexOf(_.toLowerCase())===-1},T=function(_){return _&&f.indexOf(_)===-1};this.open=function(_,E,W,R,P){if(this.abort(),d=!1,w=!1,!T(_))throw new Error("SecurityError: Request method not allowed");o={method:_,url:E.toString(),async:typeof W!="boolean"?!0:W,user:R||null,password:P||null},N(this.OPENED)},this.setDisableHeaderCheck=function(_){c=_},this.setRequestHeader=function(_,E){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!S(_))return console.warn('Refused to set unsafe header "'+_+'"'),!1;if(m)throw new Error("INVALID_STATE_ERR: send flag is true");return h[_]=E,!0},this.getResponseHeader=function(_){return typeof _=="string"&&this.readyState>this.OPENED&&s.headers[_.toLowerCase()]&&!d?s.headers[_.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||d)return"";var _="";for(var E in s.headers)E!=="set-cookie"&&E!=="set-cookie2"&&(_+=E+": "+s.headers[E]+`\r
6
+ `);return _.substr(0,_.length-2)},this.getRequestHeader=function(_){return typeof _=="string"&&h[_]?h[_]:""},this.send=function(_){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(m)throw new Error("INVALID_STATE_ERR: send has already been called");var E=!1,W=!1,R=mo.parse(o.url),P;switch(R.protocol){case"https:":E=!0;case"http:":P=R.hostname;break;case"file:":W=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(W){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Wt.readFile(unescape(R.pathname),"utf8",function(me,Tt){me?e.handleError(me,me.errno||-1):(e.status=200,e.responseText=Tt,N(e.DONE))});else try{this.responseText=Wt.readFileSync(unescape(R.pathname),"utf8"),this.status=200,N(e.DONE)}catch(me){this.handleError(me,me.errno||-1)}return}var z=R.port||(E?443:80),ne=R.pathname+(R.search?R.search:"");if(h.Host=P,E&&z===443||z===80||(h.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var Ue=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+Ue.toString("base64")}o.method==="GET"||o.method==="HEAD"?_=null:_?(h["Content-Length"]=Buffer.isBuffer(_)?_.length:Buffer.byteLength(_),h["Content-Type"]||(h["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(h["Content-Length"]=0);var dt=i.agent||!1,se={host:P,port:z,path:ne,method:o.method,headers:h,agent:dt};if(E&&(se.pfx=i.pfx,se.key=i.key,se.passphrase=i.passphrase,se.cert=i.cert,se.ca=i.ca,se.ciphers=i.ciphers,se.rejectUnauthorized=i.rejectUnauthorized!==!1),d=!1,o.async){var Qe=E?r.request:t.request;m=!0,e.dispatchEvent("readystatechange");var Ze=function(me){if(s=me,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Tt=mo.parse(o.url);P=Tt.hostname;var tt={hostname:Tt.hostname,port:Tt.port,path:Tt.path,method:s.statusCode===303?"GET":o.method,headers:h};E&&(tt.pfx=i.pfx,tt.key=i.key,tt.passphrase=i.passphrase,tt.cert=i.cert,tt.ca=i.ca,tt.ciphers=i.ciphers,tt.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Qe(tt,Ze).on("error",et),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(Vi){Vi&&(e.responseText+=Vi),m&&N(e.LOADING)}),s.on("end",function(){m&&(m=!1,N(e.DONE))}),s.on("error",function(Vi){e.handleError(Vi)})},et=function(me){e.handleError(me)};n=Qe(se,Ze).on("error",et),i.autoUnref&&n.on("socket",me=>{me.unref()}),_&&n.write(_),n.end(),e.dispatchEvent("loadstart")}else{var Se=".node-xmlhttprequest-content-"+process.pid,_e=".node-xmlhttprequest-sync-"+process.pid;Wt.writeFileSync(_e,"","utf8");for(var De="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"s":"")+".request;var options = "+JSON.stringify(se)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+Se+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+_e+"');});response.on('error', function(error) {fs.writeFileSync('"+Se+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+_e+"');});}).on('error', function(error) {fs.writeFileSync('"+Se+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+_e+"');});"+(_?"req.write('"+JSON.stringify(_).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",ec=nl(process.argv[0],["-e",De]),ch;Wt.existsSync(_e););if(e.responseText=Wt.readFileSync(Se,"utf8"),ec.stdin.end(),Wt.unlinkSync(Se),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var tc=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(tc,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),N(e.DONE)}},this.handleError=function(_,E){this.status=E||0,this.statusText=_,this.responseText=_.stack,d=!0,N(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),h=Object.assign({},l),this.responseText="",this.responseXML="",d=w=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||m)&&this.readyState!==this.DONE&&(m=!1,N(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(_,E){_ in b||(b[_]=[]),b[_].push(E)},this.removeEventListener=function(_,E){_ in b&&(b[_]=b[_].filter(function(W){return W!==E}))},this.dispatchEvent=function(_){if(typeof e["on"+_]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+_]()}):e["on"+_]()),_ in b)for(let E=0,W=b[_].length;E<W;E++)this.readyState===this.DONE?setImmediate(function(){b[_][E].call(e)}):b[_][E].call(e)};var N=function(_){if(!(e.readyState===_||e.readyState===e.UNSENT&&w)&&(e.readyState=_,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let E;w?E="abort":d?E="error":E="load",e.dispatchEvent(E),e.dispatchEvent("loadend")}}}});var xo=F((fp,wo)=>{"use strict";var{Duplex:cl}=I("stream");function _o(i){i.emit("close")}function ll(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Eo(i){this.removeListener("error",Eo),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function ul(i,e){let t=!0,r=new cl(C(g({},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(_o,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(_o,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",ll),r.on("error",Eo),r}wo.exports=ul});var Ge=F((pp,ko)=>{"use strict";var Co=["nodebuffer","arraybuffer","fragments"],No=typeof Blob!="undefined";No&&Co.push("blob");ko.exports={BINARY_TYPES:Co,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:No,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ki=F((mp,Fr)=>{"use strict";var{EMPTY_BUFFER:hl}=Ge(),Un=Buffer[Symbol.species];function fl(i,e){if(i.length===0)return hl;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?new Un(t.buffer,t.byteOffset,r):t}function Ao(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function Ro(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function dl(i){return i.length===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.length)}function Dn(i){if(Dn.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=new Un(i):ArrayBuffer.isView(i)?e=new Un(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),Dn.readOnly=!1),e}Fr.exports={concat:fl,mask:Ao,toArrayBuffer:dl,toBuffer:Dn,unmask:Ro};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=I("bufferutil");Fr.exports.mask=function(e,t,r,n,s){s<48?Ao(e,t,r,n,s):i.mask(e,t,r,n,s)},Fr.exports.unmask=function(e,t){e.length<32?Ro(e,t):i.unmask(e,t)}}catch(i){}});var Oo=F((yp,Io)=>{"use strict";var To=Symbol("kDone"),Bn=Symbol("kRun"),Mn=class{constructor(e){this[To]=()=>{this.pending--,this[Bn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Bn]()}[Bn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[To])}}};Io.exports=Mn});var Ti=F((gp,Uo)=>{"use strict";var Ai=I("zlib"),Po=ki(),pl=Oo(),{kStatusCode:Lo}=Ge(),ml=Buffer[Symbol.species],yl=Buffer.from([0,0,255,255]),Br=Symbol("permessage-deflate"),je=Symbol("total-length"),Ri=Symbol("callback"),ht=Symbol("buffers"),Dr=Symbol("error"),Ur,qn=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,!Ur){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ur=new pl(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[Ri];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){Ur.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Ur.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"?Ai.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ai.createInflateRaw(C(g({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Br]=this,this._inflate[je]=0,this._inflate[ht]=[],this._inflate.on("error",vl),this._inflate.on("data",Fo)}this._inflate[Ri]=r,this._inflate.write(e),t&&this._inflate.write(yl),this._inflate.flush(()=>{let s=this._inflate[Dr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Po.concat(this._inflate[ht],this._inflate[je]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[je]=0,this._inflate[ht]=[],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"?Ai.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ai.createDeflateRaw(C(g({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[je]=0,this._deflate[ht]=[],this._deflate.on("data",gl)}this._deflate[Ri]=r,this._deflate.write(e),this._deflate.flush(Ai.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Po.concat(this._deflate[ht],this._deflate[je]);t&&(s=new ml(s.buffer,s.byteOffset,s.length-4)),this._deflate[Ri]=null,this._deflate[je]=0,this._deflate[ht]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};Uo.exports=qn;function gl(i){this[ht].push(i),this[je]+=i.length}function Fo(i){if(this[je]+=i.length,this[Br]._maxPayload<1||this[je]<=this[Br]._maxPayload){this[ht].push(i);return}this[Dr]=new RangeError("Max payload size exceeded"),this[Dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dr][Lo]=1009,this.removeListener("data",Fo),this.reset()}function vl(i){this[Br]._inflate=null,i[Lo]=1007,this[Ri](i)}});var $t=F((bp,Mr)=>{"use strict";var{isUtf8:Do}=I("buffer"),{hasBlob:bl}=Ge(),Sl=[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 _l(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Wn(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}function El(i){return bl&&typeof i=="object"&&typeof i.arrayBuffer=="function"&&typeof i.type=="string"&&typeof i.stream=="function"&&(i[Symbol.toStringTag]==="Blob"||i[Symbol.toStringTag]==="File")}Mr.exports={isBlob:El,isValidStatusCode:_l,isValidUTF8:Wn,tokenChars:Sl};if(Do)Mr.exports.isValidUTF8=function(i){return i.length<24?Wn(i):Do(i)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=I("utf-8-validate");Mr.exports.isValidUTF8=function(e){return e.length<32?Wn(e):i(e)}}catch(i){}});var Hn=F((Sp,zo)=>{"use strict";var{Writable:wl}=I("stream"),Bo=Ti(),{BINARY_TYPES:xl,EMPTY_BUFFER:Mo,kStatusCode:Cl,kWebSocket:Nl}=Ge(),{concat:$n,toArrayBuffer:kl,unmask:Al}=ki(),{isValidStatusCode:Rl,isValidUTF8:qo}=$t(),qr=Buffer[Symbol.species],ve=0,Wo=1,$o=2,Ko=3,Kn=4,zn=5,Wr=6,Vn=class extends wl{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||xl[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Nl]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ve}_write(e,t,r){if(this._opcode===8&&this._state==ve)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]=new qr(r.buffer,r.byteOffset+e,r.length-e),new qr(r.buffer,r.byteOffset,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]=new qr(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case ve:this.getInfo(e);break;case Wo:this.getPayloadLength16(e);break;case $o:this.getPayloadLength64(e);break;case Ko:this.getMask();break;case Kn:this.getData(e);break;case zn:case Wr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){let n=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(n);return}let r=(t[0]&64)===64;if(r&&!this._extensions[Bo.extensionName]){let n=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(n);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let n=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(n);return}if(!this._fragmented){let n=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(n);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let n=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(n);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let n=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(n);return}if(r){let n=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(n);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let n=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(n);return}}else{let n=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(n);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let n=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(n);return}}else if(this._masked){let n=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(n);return}this._payloadLength===126?this._state=Wo:this._payloadLength===127?this._state=$o:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){let n=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(n);return}this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=Ko:this._state=Kn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Kn}getData(e){let t=Mo;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]&&Al(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=zn,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[Bo.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){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(o);return}this._fragments.push(s)}this.dataMessage(t),this._state===ve&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=ve;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let n;this._binaryType==="nodebuffer"?n=$n(r,t):this._binaryType==="arraybuffer"?n=kl($n(r,t)):this._binaryType==="blob"?n=new Blob(r):n=r,this._allowSynchronousEvents?(this.emit("message",n,!0),this._state=ve):(this._state=Wr,setImmediate(()=>{this.emit("message",n,!0),this._state=ve,this.startLoop(e)}))}else{let n=$n(r,t);if(!this._skipUTF8Validation&&!qo(n)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===zn||this._allowSynchronousEvents?(this.emit("message",n,!1),this._state=ve):(this._state=Wr,setImmediate(()=>{this.emit("message",n,!1),this._state=ve,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Mo),this.end();else{let r=e.readUInt16BE(0);if(!Rl(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let n=new qr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!qo(n)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",r,n),this.end()}this._state=ve;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ve):(this._state=Wr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ve,this.startLoop(t)}))}createError(e,t,r,n,s){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=s,o[Cl]=n,o}};zo.exports=Vn});var Yn=F((Ep,Go)=>{"use strict";var{Duplex:_p}=I("stream"),{randomFillSync:Tl}=I("crypto"),Vo=Ti(),{EMPTY_BUFFER:Il,kWebSocket:Ol,NOOP:Pl}=Ge(),{isBlob:Kt,isValidStatusCode:Ll}=$t(),{mask:Ho,toBuffer:Et}=ki(),be=Symbol("kByteLength"),Fl=Buffer.alloc(4),$r=8*1024,wt,zt=$r,Ae=0,Ul=1,Dl=2,Gn=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._queue=[],this._state=Ae,this.onerror=Pl,this[Ol]=void 0}static frame(e,t){let r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||Fl,t.generateMask?t.generateMask(r):(zt===$r&&(wt===void 0&&(wt=Buffer.alloc($r)),Tl(wt,0,$r),zt=0),r[0]=wt[zt++],r[1]=wt[zt++],r[2]=wt[zt++],r[3]=wt[zt++]),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[be]!==void 0?c=t[be]:(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 h=Buffer.allocUnsafe(n?c+s:s);return h[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(h[0]|=64),h[1]=l,l===126?h.writeUInt16BE(c,2):l===127&&(h[2]=h[3]=0,h.writeUIntBE(c,4,6)),t.mask?(h[1]|=128,h[s-4]=r[0],h[s-3]=r[1],h[s-2]=r[2],h[s-1]=r[3],o?[h,e]:n?(Ho(e,r,h,s,c),[h]):(Ho(e,r,e,0,c),[h,e])):[h,e]}close(e,t,r,n){let s;if(e===void 0)s=Il;else{if(typeof e!="number"||!Ll(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={[be]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ae?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):Kt(e)?(n=e.size,s=!1):(e=Et(e),n=e.length,s=Et.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Kt(e)?this._state!==Ae?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==Ae?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):Kt(e)?(n=e.size,s=!1):(e=Et(e),n=e.length,s=Et.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Kt(e)?this._state!==Ae?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==Ae?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[Vo.extensionName],s=t.binary?2:1,o=t.compress,c,l;typeof e=="string"?(c=Buffer.byteLength(e),l=!1):Kt(e)?(c=e.size,l=!1):(e=Et(e),c=e.length,l=Et.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);let h={[be]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};Kt(e)?this._state!==Ae?this.enqueue([this.getBlobData,e,this._compress,h,r]):this.getBlobData(e,this._compress,h,r):this._state!==Ae?this.enqueue([this.dispatch,e,this._compress,h,r]):this.dispatch(e,this._compress,h,r)}getBlobData(e,t,r,n){this._bufferedBytes+=r[be],this._state=Dl,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(jn,this,c,n);return}this._bufferedBytes-=r[be];let o=Et(s);t?this.dispatch(o,t,r,n):(this._state=Ae,this.sendFrame(i.frame(o,r),n),this.dequeue())}).catch(s=>{process.nextTick(Bl,this,s,n)})}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Vo.extensionName];this._bufferedBytes+=r[be],this._state=Ul,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");jn(this,l,n);return}this._bufferedBytes-=r[be],this._state=Ae,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;this._state===Ae&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][be],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][be],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)}};Go.exports=Gn;function jn(i,e,t){typeof t=="function"&&t(e);for(let r=0;r<i._queue.length;r++){let n=i._queue[r],s=n[n.length-1];typeof s=="function"&&s(e)}}function Bl(i,e,t){jn(i,e,t),i.onerror(e)}});var ia=F((wp,ta)=>{"use strict";var{kForOnEventAttribute:Ii,kListener:Jn}=Ge(),jo=Symbol("kCode"),Yo=Symbol("kData"),Jo=Symbol("kError"),Xo=Symbol("kMessage"),Qo=Symbol("kReason"),Vt=Symbol("kTarget"),Zo=Symbol("kType"),ea=Symbol("kWasClean"),Ye=class{constructor(e){this[Vt]=null,this[Zo]=e}get target(){return this[Vt]}get type(){return this[Zo]}};Object.defineProperty(Ye.prototype,"target",{enumerable:!0});Object.defineProperty(Ye.prototype,"type",{enumerable:!0});var xt=class extends Ye{constructor(e,t={}){super(e),this[jo]=t.code===void 0?0:t.code,this[Qo]=t.reason===void 0?"":t.reason,this[ea]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[jo]}get reason(){return this[Qo]}get wasClean(){return this[ea]}};Object.defineProperty(xt.prototype,"code",{enumerable:!0});Object.defineProperty(xt.prototype,"reason",{enumerable:!0});Object.defineProperty(xt.prototype,"wasClean",{enumerable:!0});var Ht=class extends Ye{constructor(e,t={}){super(e),this[Jo]=t.error===void 0?null:t.error,this[Xo]=t.message===void 0?"":t.message}get error(){return this[Jo]}get message(){return this[Xo]}};Object.defineProperty(Ht.prototype,"error",{enumerable:!0});Object.defineProperty(Ht.prototype,"message",{enumerable:!0});var Oi=class extends Ye{constructor(e,t={}){super(e),this[Yo]=t.data===void 0?null:t.data}get data(){return this[Yo]}};Object.defineProperty(Oi.prototype,"data",{enumerable:!0});var Ml={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[Ii]&&n[Jn]===e&&!n[Ii])return;let r;if(i==="message")r=function(s,o){let c=new Oi("message",{data:o?s:s.toString()});c[Vt]=this,Kr(e,this,c)};else if(i==="close")r=function(s,o){let c=new xt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[Vt]=this,Kr(e,this,c)};else if(i==="error")r=function(s){let o=new Ht("error",{error:s,message:s.message});o[Vt]=this,Kr(e,this,o)};else if(i==="open")r=function(){let s=new Ye("open");s[Vt]=this,Kr(e,this,s)};else return;r[Ii]=!!t[Ii],r[Jn]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[Jn]===e&&!t[Ii]){this.removeListener(i,t);break}}};ta.exports={CloseEvent:xt,ErrorEvent:Ht,Event:Ye,EventTarget:Ml,MessageEvent:Oi};function Kr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var Xn=F((xp,ra)=>{"use strict";var{tokenChars:Pi}=$t();function Le(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function ql(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,l=-1,h=-1,u=-1,f=0;for(;f<i.length;f++)if(h=i.charCodeAt(f),o===void 0)if(u===-1&&Pi[h]===1)l===-1&&(l=f);else if(f!==0&&(h===32||h===9))u===-1&&l!==-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let d=i.slice(l,u);h===44?(Le(e,d,t),t=Object.create(null)):o=d,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(u===-1&&Pi[h]===1)l===-1&&(l=f);else if(h===32||h===9)u===-1&&l!==-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f),Le(t,i.slice(l,u),!0),h===44&&(Le(e,o,t),t=Object.create(null),o=void 0),l=u=-1}else if(h===61&&l!==-1&&u===-1)c=i.slice(l,f),l=u=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(Pi[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(Pi[h]===1)l===-1&&(l=f);else if(h===34&&l!==-1)s=!1,u=f;else if(h===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(h===34&&i.charCodeAt(f-1)===61)s=!0;else if(u===-1&&Pi[h]===1)l===-1&&(l=f);else if(l!==-1&&(h===32||h===9))u===-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let d=i.slice(l,u);r&&(d=d.replace(/\\/g,""),r=!1),Le(t,c,d),h===44&&(Le(e,o,t),t=Object.create(null),o=void 0),c=void 0,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=f);let m=i.slice(l,u);return o===void 0?Le(e,m,t):(c===void 0?Le(t,m,!0):r?Le(t,c,m.replace(/\\/g,"")):Le(t,c,m),Le(e,o,t)),e}function Wl(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(", ")}ra.exports={format:Wl,parse:ql}});var is=F((kp,ma)=>{"use strict";var $l=I("events"),Kl=I("https"),zl=I("http"),oa=I("net"),Vl=I("tls"),{randomBytes:Hl,createHash:Gl}=I("crypto"),{Duplex:Cp,Readable:Np}=I("stream"),{URL:Qn}=I("url"),ft=Ti(),jl=Hn(),Yl=Yn(),{isBlob:Jl}=$t(),{BINARY_TYPES:na,EMPTY_BUFFER:zr,GUID:Xl,kForOnEventAttribute:Zn,kListener:Ql,kStatusCode:Zl,kWebSocket:Y,NOOP:aa}=Ge(),{EventTarget:{addEventListener:eu,removeEventListener:tu}}=ia(),{format:iu,parse:ru}=Xn(),{toBuffer:nu}=ki(),su=30*1e3,ca=Symbol("kAborted"),es=[8,13],Je=["CONNECTING","OPEN","CLOSING","CLOSED"],ou=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,D=class i extends $l{constructor(e,t,r){super(),this._binaryType=na[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=zr,this._closeTimer=null,this._errorEmitted=!1,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]),la(this,e,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){na.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 jl({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new Yl(e,this._extensions,r.generateMask);this._receiver=n,this._sender=s,this._socket=e,n[Y]=this,s[Y]=this,e[Y]=this,n.on("conclude",lu),n.on("drain",uu),n.on("error",hu),n.on("message",fu),n.on("ping",du),n.on("pong",pu),s.onerror=mu,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",fa),e.on("data",Hr),e.on("end",da),e.on("error",pa),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[ft.extensionName]&&this._extensions[ft.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){he(this,this._req,"WebSocket was closed before the connection was established");return}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())}),ha(this)}}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){ts(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||zr,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){ts(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||zr,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){ts(this,e,r);return}let n=g({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[ft.extensionName]||(n.compress=!1),this._sender.send(e||zr,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING){he(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:Je.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:Je.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:Je.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:Je.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:Je.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:Je.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:Je.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:Je.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(D.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(D.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Zn])return e[Ql];return null},set(e){for(let t of this.listeners(i))if(t[Zn]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Zn]:!0})}})});D.prototype.addEventListener=eu;D.prototype.removeEventListener=tu;ma.exports=D;function la(i,e,t,r){let n=C(g({allowSynchronousEvents:!0,autoPong:!0,protocolVersion:es[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(i._autoPong=n.autoPong,!es.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${es.join(", ")})`);let s;if(e instanceof Qn)s=e;else try{s=new Qn(e)}catch(b){throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),i._url=s.href;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:", "http:", "https", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let b=new SyntaxError(l);if(i._redirects===0)throw b;Vr(i,b);return}let h=o?443:80,u=Hl(16).toString("base64"),f=o?Kl.request:zl.request,m=new Set,d;if(n.createConnection=n.createConnection||(o?cu:au),n.defaultPort=n.defaultPort||h,n.port=s.port||h,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=C(g({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(d=new ft(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=iu({[ft.extensionName]:d.offer()})),t.length){for(let b of t){if(typeof b!="string"||!ou.test(b)||m.has(b))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(b)}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 b=n.path.split(":");n.socketPath=b[0],n.path=b[1]}let w;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let b=r&&r.headers;if(r=C(g({},r),{headers:{}}),b)for(let[S,T]of Object.entries(b))r.headers[S.toLowerCase()]=T}else if(i.listenerCount("redirect")===0){let b=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!b||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,b||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),w=i._req=f(n),i._redirects&&i.emit("redirect",i.url,w)}else w=i._req=f(n);n.timeout&&w.on("timeout",()=>{he(i,w,"Opening handshake has timed out")}),w.on("error",b=>{w===null||w[ca]||(w=i._req=null,Vr(i,b))}),w.on("response",b=>{let S=b.headers.location,T=b.statusCode;if(S&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){he(i,w,"Maximum redirects exceeded");return}w.abort();let N;try{N=new Qn(S,e)}catch(_){let E=new SyntaxError(`Invalid URL: ${S}`);Vr(i,E);return}la(i,N,t,r)}else i.emit("unexpected-response",w,b)||he(i,w,`Unexpected server response: ${b.statusCode}`)}),w.on("upgrade",(b,S,T)=>{if(i.emit("upgrade",b),i.readyState!==D.CONNECTING)return;w=i._req=null;let N=b.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){he(i,S,"Invalid Upgrade header");return}let _=Gl("sha1").update(u+Xl).digest("base64");if(b.headers["sec-websocket-accept"]!==_){he(i,S,"Invalid Sec-WebSocket-Accept header");return}let E=b.headers["sec-websocket-protocol"],W;if(E!==void 0?m.size?m.has(E)||(W="Server sent an invalid subprotocol"):W="Server sent a subprotocol but none was requested":m.size&&(W="Server sent no subprotocol"),W){he(i,S,W);return}E&&(i._protocol=E);let R=b.headers["sec-websocket-extensions"];if(R!==void 0){if(!d){he(i,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=ru(R)}catch(ne){he(i,S,"Invalid Sec-WebSocket-Extensions header");return}let z=Object.keys(P);if(z.length!==1||z[0]!==ft.extensionName){he(i,S,"Server indicated an extension that was not requested");return}try{d.accept(P[ft.extensionName])}catch(ne){he(i,S,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[ft.extensionName]=d}i.setSocket(S,T,{allowSynchronousEvents:n.allowSynchronousEvents,generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),n.finishRequest?n.finishRequest(w,i):w.end()}function Vr(i,e){i._readyState=D.CLOSING,i._errorEmitted=!0,i.emit("error",e),i.emitClose()}function au(i){return i.path=i.socketPath,oa.connect(i)}function cu(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=oa.isIP(i.host)?"":i.host),Vl.connect(i)}function he(i,e,t){i._readyState=D.CLOSING;let r=new Error(t);Error.captureStackTrace(r,he),e.setHeader?(e[ca]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Vr,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function ts(i,e,t){if(e){let r=Jl(e)?e.size:nu(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Je[i.readyState]})`);process.nextTick(t,r)}}function lu(i,e){let t=this[Y];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[Y]!==void 0&&(t._socket.removeListener("data",Hr),process.nextTick(ua,t._socket),i===1005?t.close():t.close(i,e))}function uu(){let i=this[Y];i.isPaused||i._socket.resume()}function hu(i){let e=this[Y];e._socket[Y]!==void 0&&(e._socket.removeListener("data",Hr),process.nextTick(ua,e._socket),e.close(i[Zl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i))}function sa(){this[Y].emitClose()}function fu(i,e){this[Y].emit("message",i,e)}function du(i){let e=this[Y];e._autoPong&&e.pong(i,!this._isServer,aa),e.emit("ping",i)}function pu(i){this[Y].emit("pong",i)}function ua(i){i.resume()}function mu(i){let e=this[Y];e.readyState!==D.CLOSED&&(e.readyState===D.OPEN&&(e._readyState=D.CLOSING,ha(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i)))}function ha(i){i._closeTimer=setTimeout(i._socket.destroy.bind(i._socket),su)}function fa(){let i=this[Y];this.removeListener("close",fa),this.removeListener("data",Hr),this.removeListener("end",da),i._readyState=D.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[Y]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",sa),i._receiver.on("finish",sa))}function Hr(i){this[Y]._receiver.write(i)||this.pause()}function da(){let i=this[Y];i._readyState=D.CLOSING,i._receiver.end(),this.end()}function pa(){let i=this[Y];this.removeListener("error",pa),this.on("error",aa),i&&(i._readyState=D.CLOSING,this.destroy())}});var ga=F((Rp,ya)=>{"use strict";var{tokenChars:yu}=$t();function gu(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&&yu[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}ya.exports={parse:gu}});var xa=F((Ip,wa)=>{"use strict";var vu=I("events"),Gr=I("http"),{Duplex:Tp}=I("stream"),{createHash:bu}=I("crypto"),va=Xn(),Ct=Ti(),Su=ga(),_u=is(),{GUID:Eu,kWebSocket:wu}=Ge(),xu=/^[+/0-9A-Za-z]{22}==$/,ba=0,Sa=1,Ea=2,rs=class extends vu{constructor(e,t){if(super(),e=g({allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:_u},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=Gr.createServer((r,n)=>{let s=Gr.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=Cu(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=ba}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===Ea){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Li,this);return}if(e&&this.once("close",e),this._state!==Sa)if(this._state=Sa,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(Li,this):process.nextTick(Li,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Li(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",_a);let s=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Nt(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Nt(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!xu.test(s)){Nt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==8&&c!==13){Nt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Fi(t,400);return}let l=e.headers["sec-websocket-protocol"],h=new Set;if(l!==void 0)try{h=Su.parse(l)}catch(m){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 m=new Ct(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=va.parse(u);d[Ct.extensionName]&&(m.accept(d[Ct.extensionName]),f[Ct.extensionName]=m)}catch(d){Nt(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:e.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(d,w,b,S)=>{if(!d)return Fi(t,w||401,b,S);this.completeUpgrade(f,s,h,e,t,r,n)});return}if(!this.options.verifyClient(m))return Fi(t,401)}this.completeUpgrade(f,s,h,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[wu])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ba)return Fi(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${bu("sha1").update(t+Eu).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(h.push(`Sec-WebSocket-Protocol: ${f}`),u._protocol=f)}if(e[Ct.extensionName]){let f=e[Ct.extensionName].params,m=va.format({[Ct.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${m}`),u._extensions=e}this.emit("headers",h,n),s.write(h.concat(`\r
7
7
  `).join(`\r
8
- `)),s.removeListener("error",Sa),h.setSocket(s,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,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(Pi,this)})),c(h,n)}};Ea.exports=ts;function wh(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 Pi(i){i._state=_a,i.emit("close")}function Sa(){this.destroy()}function Li(i,e,t,r){t=t||Vr.STATUS_CODES[e],r=y({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Vr.STATUS_CODES[e]}\r
8
+ `)),s.removeListener("error",_a),u.setSocket(s,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Li,this)})),c(u,n)}};wa.exports=rs;function Cu(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 Li(i){i._state=Ea,i.emit("close")}function _a(){this.destroy()}function Fi(i,e,t,r){t=t||Gr.STATUS_CODES[e],r=g({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Gr.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 Li(t,r,n)}});var rs=F((um,Ia)=>{"use strict";function Ph(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=En(),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 p=0;p<h.length;p++)f=(f<<5)-f+h.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,p=null,m,x;function b(...S){if(!b.enabled)return;let T=b,N=Number(new Date),_=N-(f||N);T.diff=_,T.prev=f,T.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let E=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let z=t.formatters[P];if(typeof z=="function"){let ne=S[E];R=z.call(T,ne),S.splice(E,1),E--}return R}),t.formatArgs.call(T,S),(T.log||t.log).apply(T,S)}return b.namespace=h,b.useColors=t.useColors(),b.color=t.selectColor(h),b.extend=r,b.destroy=t.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(m!==t.namespaces&&(m=t.namespaces,x=t.enabled(h)),x),set:S=>{p=S}}),typeof t.init=="function"&&t.init(b),b}function r(h,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+h);return p.log=this.log,p}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,p=(typeof h=="string"?h:"").split(/[\s,]+/),m=p.length;for(f=0;f<m;f++)p[f]&&(h=p[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,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(h))return!1;for(f=0,p=t.names.length;f<p;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}Ia.exports=Ph});var Oa=F((fe,Yr)=>{"use strict";fe.formatArgs=Fh;fe.save=Uh;fe.load=Dh;fe.useColors=Lh;fe.storage=Bh();fe.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`."))}})();fe.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 Lh(){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 Fh(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Yr.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)}fe.log=console.debug||console.log||(()=>{});function Uh(i){try{i?fe.storage.setItem("debug",i):fe.storage.removeItem("debug")}catch(e){}}function Dh(){let i;try{i=fe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Bh(){try{return localStorage}catch(i){}}Yr.exports=rs()(fe);var{formatters:Mh}=Yr.exports;Mh.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var La=F((J,Xr)=>{"use strict";var qh=I("tty"),Jr=I("util");J.init=jh;J.log=zh;J.formatArgs=$h;J.save=Vh;J.load=Hh;J.useColors=Wh;J.destroy=Jr.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=Nn();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 Wh(){return"colors"in J.inspectOpts?!!J.inspectOpts.colors:qh.isatty(process.stderr.fd)}function $h(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 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 Fi(t,r,n)}});var ss=F((dm,Oa)=>{"use strict";function Fu(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=xn(),t.destroy=h,Object.keys(i).forEach(u=>{t[u]=i[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let f=0;for(let m=0;m<u.length;m++)f=(f<<5)-f+u.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(u){let f,m=null,d,w;function b(...S){if(!b.enabled)return;let T=b,N=Number(new Date),_=N-(f||N);T.diff=_,T.prev=f,T.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let E=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let z=t.formatters[P];if(typeof z=="function"){let ne=S[E];R=z.call(T,ne),S.splice(E,1),E--}return R}),t.formatArgs.call(T,S),(T.log||t.log).apply(T,S)}return b.namespace=u,b.useColors=t.useColors(),b.color=t.selectColor(u),b.extend=r,b.destroy=t.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(d!==t.namespaces&&(d=t.namespaces,w=t.enabled(u)),w),set:S=>{m=S}}),typeof t.init=="function"&&t.init(b),b}function r(u,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+u);return m.log=this.log,m}function n(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let f,m=(typeof u=="string"?u:"").split(/[\s,]+/),d=m.length;for(f=0;f<d;f++)m[f]&&(u=m[f].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(u))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function h(){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}Oa.exports=Fu});var Pa=F((fe,Xr)=>{"use strict";fe.formatArgs=Du;fe.save=Bu;fe.load=Mu;fe.useColors=Uu;fe.storage=qu();fe.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`."))}})();fe.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 Uu(){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 Du(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Xr.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)}fe.log=console.debug||console.log||(()=>{});function Bu(i){try{i?fe.storage.setItem("debug",i):fe.storage.removeItem("debug")}catch(e){}}function Mu(){let i;try{i=fe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function qu(){try{return localStorage}catch(i){}}Xr.exports=ss()(fe);var{formatters:Wu}=Xr.exports;Wu.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Fa=F((J,Zr)=>{"use strict";var $u=I("tty"),Qr=I("util");J.init=Yu;J.log=Hu;J.formatArgs=zu;J.save=Gu;J.load=ju;J.useColors=Ku;J.destroy=Qr.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=An();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 Ku(){return"colors"in J.inspectOpts?!!J.inspectOpts.colors:$u.isatty(process.stderr.fd)}function zu(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+"+Xr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Kh()+e+" "+i[0]}function Kh(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function zh(...i){return process.stderr.write(Jr.formatWithOptions(J.inspectOpts,...i)+`
15
- `)}function Vh(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Hh(){return process.env.DEBUG}function jh(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]]}Xr.exports=rs()(J);var{formatters:Pa}=Xr.exports;Pa.o=function(i){return this.inspectOpts.colors=this.useColors,Jr.inspect(i,this.inspectOpts).split(`
16
- `).map(e=>e.trim()).join(" ")};Pa.O=function(i){return this.inspectOpts.colors=this.useColors,Jr.inspect(i,this.inspectOpts)}});var Di=F((fm,ns)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?ns.exports=Oa():ns.exports=La()});var lc="v1",gs=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,Hi=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=lc,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=gs,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=y({"Novu-API-Version":NOVU_API_VERSION,"Novu-Client-Version":gs,"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=y(y({},this.headers),e)}get(e,t,r=!0){return d(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return d(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=hc(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:y(y({},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["Novu-Client-Version"]} error. Status: ${l.status}, Message: ${h.message}`)}if(l.status===204)return;let u=yield l.json();return n?u.data:u})}};function hc(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var oe="/inbox",ie=`${oe}/notifications`,A,ji=class{constructor(e={}){this.isSessionInitialized=!1;g(this,A);v(this,A,new Hi(e))}initializeSession(c){return d(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let l=yield a(this,A).post(`${oe}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,A).setAuthorizationToken(l.token),a(this,A).setKeylessHeader(l.applicationIdentifier),this.isSessionInitialized=!0,l})}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 p of o)f.append("tags[]",p);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 p of h)f.append("severity[]",p);else h&&f.append("severity",h);return a(this,A).get(ie,f,!1)}count({filters:e}){return a(this,A).get(`${ie}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,A).patch(`${ie}/${e}/read`)}unread(e){return a(this,A).patch(`${ie}/${e}/unread`)}archive(e){return a(this,A).patch(`${ie}/${e}/archive`)}unarchive(e){return a(this,A).patch(`${ie}/${e}/unarchive`)}snooze(e,t){return a(this,A).patch(`${ie}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,A).patch(`${ie}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,A).post(`${ie}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,A).post(`${ie}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,A).post(`${ie}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,A).delete(`${ie}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,A).post(`${ie}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,A).post(`${ie}/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,A).patch(`${ie}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ie}/${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,A).get(`${oe}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,A).patch(`${oe}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,A).patch(`${oe}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,A).patch(`${oe}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,A).get(`${oe}/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,A).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,A).get(`${oe}/topics/${e}/subscriptions`)}getSubscription(e,t,r,n){let s=new URLSearchParams;if(r!=null&&r.length)for(let c of r)s.append("workflowIds",c);if(n!=null&&n.length)for(let c of n)s.append("tags",c);let o=s.size?`?${s.toString()}`:"";return a(this,A).get(`${oe}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:r,topicName:n,preferences:s}){return a(this,A).post(`${oe}/topics/${r}/subscriptions`,y(y({identifier:e,name:t},n&&{topic:{name:n}}),s!==void 0&&{preferences:s}))}updateSubscription({topicKey:e,identifier:t,name:r,preferences:n}){return a(this,A).patch(`${oe}/topics/${e}/subscriptions/${t}`,y({name:r},n!==void 0&&{preferences:n}))}updateSubscriptionPreference({subscriptionIdentifier:e,workflowId:t,enabled:r,condition:n,email:s,sms:o,in_app:c,chat:l,push:u}){return a(this,A).patch(`${oe}/subscriptions/${e}/preferences/${t}`,{enabled:r,condition:n,email:s,sms:o,in_app:c,chat:l,push:u})}bulkUpdateSubscriptionPreferences(e){return a(this,A).patch(`${oe}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,identifier:t}){return a(this,A).delete(`${oe}/topics/${e}/subscriptions/${t}`)}};A=new WeakMap;function vs(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 pt,Gi=class{constructor(){g(this,pt);v(this,pt,vs())}on(e,t){return a(this,pt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,pt).off(e,t)}emit(e,t){a(this,pt).emit(e,t)}};pt=new WeakMap;var w=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Yi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to read notification",o)}}}),Ji=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to unread notification",o)}}}),Xi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to mark notification as seen",o)}}}),Qi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to archive notification",o)}}}),Zi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to unarchive notification",o)}}}),er=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to snooze notification",o)}}}),tr=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 w("Failed to unsnooze notification",o)}}}),It=n=>d(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:C(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:C(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=Ie(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 w(`Failed to complete ${r} action on the notification`,l)}}}),Ot=n=>d(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:C(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:C(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=Ie(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 w("Failed to fetch notifications",l)}}}),Ie=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(y(y({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},bs=s=>d(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(C(y({},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 w("Failed to read all notifications",o)}}}),cn=o=>d(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(C(y({},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 w("Failed to mark all notifications as seen",c)}}}),Ss=s=>d(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(C(y({},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 w("Failed to archive all notifications",o)}}}),_s=s=>d(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(C(y({},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 w("Failed to archive all read notifications",o)}}}),ir=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=Ie(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 w("Failed to delete notification",s)}}}),Es=s=>d(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 w("Failed to delete all notifications",o)}}});var V,re,U=class{constructor(e,t,r){g(this,V);g(this,re);v(this,V,t),v(this,re,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 Yi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}unread(){return Ji({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}seen(){return Xi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}archive(){return Qi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}unarchive(){return Zi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}delete(){return ir({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}snooze(e){return er({emitter:a(this,V),apiService:a(this,re),args:{notification:this,snoozeUntil:e}})}unsnooze(){return tr({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return It({emitter:a(this,V),apiService:a(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return It({emitter:a(this,V),apiService:a(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ot({emitter:a(this,V),apiService:a(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ot({emitter:a(this,V),apiService:a(this,re),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,re=new WeakMap;var it,Pt,ae=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){g(this,it,[]);g(this,Pt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,it).forEach(c=>d(this,[c],function*({fn:s,resolve:o}){o(yield s())})),v(this,it,[])):r&&(this.onSessionError(r),v(this,Pt,r),a(this,it).forEach(({resolve:s})=>{s({error:new w("Failed to initialize session, please contact the support",r)})}),v(this,it,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return d(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Pt)?Promise.resolve({error:new w("Failed to initialize session, please contact the support",a(this,Pt))}):new Promise((t,r)=>{a(this,it).push({fn:e,resolve:t,reject:r})})})}};it=new WeakMap,Pt=new WeakMap;function ws({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var ln=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Lu=["seen","unseen"],Fu=["read","unread"],hn=(i,e)=>ln(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,uc=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return ln(t,r)},un=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},fn=(i,e)=>un(i.data,e.data)&&hn(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&uc(i.severity,e.severity);var Ee,we=class{constructor(){g(this,Ee);v(this,Ee,new Map)}get(e){return a(this,Ee).get(e)}getValues(){return Array.from(a(this,Ee).values())}entries(){return Array.from(a(this,Ee).entries())}keys(){return Array.from(a(this,Ee).keys())}set(e,t){a(this,Ee).set(e,t)}remove(e){a(this,Ee).delete(e)}clear(){a(this,Ee).clear()}};Ee=new WeakMap;var xs=({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,p])=>(h[f]=p,h),{}),Qt=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>JSON.stringify(xs({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})),fc=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(xs({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),mt=i=>JSON.parse(i),dc=["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"],pc=["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"],Be,ei,M,Zt=class{constructor({emitter:e,inboxService:t}){g(this,Be);g(this,ei);g(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,C(y({},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,C(y({},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(fc(mt(c)))})}),o.forEach(c=>{let l=this.getAggregated(mt(c));a(this,Be).emit("notifications.list.updated",{data:l})})};v(this,Be,e),v(this,ei,t),dc.forEach(r=>{a(this,Be).on(r,this.handleNotificationEvent())}),pc.forEach(r=>{a(this,Be).on(r,this.handleNotificationEvent({remove:!0}))}),v(this,M,new we)}getAggregated(e){return a(this,M).keys().filter(r=>{let n=mt(r);return fn(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:[]})}get(e){return a(this,M).get(Qt(e))}has(e){return a(this,M).get(Qt(e))!==void 0}set(e,t){a(this,M).set(Qt(e),t)}unshift(e,t){let r=Qt(e),n=a(this,M).get(r)||{hasMore:!1,filter:mt(r),notifications:[]},s=ws({notification:y({},t),emitter:a(this,Be),inboxService:a(this,ei)});this.update(e,C(y({},n),{notifications:[s,...n.notifications]}))}update(e,t){this.set(e,t);let r=this.getAggregated(mt(Qt(e)));a(this,Be).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=mt(o);if(hn(e,c.tags)&&un(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=>{fn(mt(r),e)&&a(this,M).remove(r)})}clearAll(){a(this,M).clear()}};Be=new WeakMap,ei=new WeakMap,M=new WeakMap;var ti,ii,ri,ni,Me=class{constructor(e,t,r,n,s){g(this,ti);g(this,ii);g(this,ri);g(this,ni);var o;v(this,ti,t),v(this,ii,r),v(this,ri,n),v(this,ni,s),this.enabled=e.enabled,this.condition=(o=e.condition)!=null?o:void 0,this.workflow=e.workflow,this.subscriptionId=e.subscriptionId}update(e){return d(this,null,function*(){var t;return rr({emitter:a(this,ti),apiService:a(this,ii),cache:a(this,ri),useCache:a(this,ni),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};ti=new WeakMap,ii=new WeakMap,ri=new WeakMap,ni=new WeakMap;var Cs=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.getAll(n):void 0;return i.emit("subscriptions.list.pending",{args:n,data:l}),(!l||c)&&(l=(yield e.fetchSubscriptions(n.topicKey)).map(h=>new qe(C(y({},h),{topicKey:n.topicKey}),i,e,t,o)),o&&(t.set(n,l),l=t.getAll(n))),i.emit("subscriptions.list.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscriptions.list.resolved",{args:n,error:o}),{error:new w("Failed to fetch subscriptions",o)}}}),Ns=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.get(n):void 0;if(i.emit("subscription.get.pending",{args:n,data:l}),!l||c){let u=yield e.getSubscription(n.topicKey,n.identifier,n.workflowIds,n.tags);if(!u)return i.emit("subscription.get.resolved",{args:n,data:null}),{data:null};l=new qe(C(y({},u),{topicKey:n.topicKey}),i,e,t,o),o&&(t.setOne(n,l),l=t.get(n))}return i.emit("subscription.get.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscription.get.resolved",{args:n,error:o}),{error:new w("Failed to fetch subscription",o)}}}),As=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o;try{i.emit("subscription.create.pending",{args:n});let c=yield e.createSubscription({identifier:(o=n.identifier)!=null?o:"",name:n.name,topicKey:n.topicKey,topicName:n.topicName,preferences:n.preferences}),l=new qe(C(y({},c),{topicKey:n.topicKey}),i,e,t,r);return i.emit("subscription.create.resolved",{args:n,data:l}),{data:l}}catch(c){return i.emit("subscription.create.resolved",{args:n,error:c}),{error:new w("Failed to create subscription",c)}}}),nr=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){let o="identifier"in n?n.identifier:n.subscription.identifier,c="topicKey"in n?n.topicKey:n.subscription.topicKey;try{i.emit("subscription.update.pending",{args:n});let l=yield e.updateSubscription({topicKey:c,identifier:o,name:n.name,preferences:n.preferences}),u=new qe(C(y({},l),{topicKey:c}),i,e,t,r);return i.emit("subscription.update.resolved",{args:n,data:u}),{data:u}}catch(l){return i.emit("subscription.update.resolved",{args:n,error:l}),{error:new w("Failed to update subscription",l)}}}),rr=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var c,l;let o="workflowId"in n?n.workflowId:(l=(c=n.preference)==null?void 0:c.workflow)==null?void 0:l.id;try{i.emit("subscription.preference.update.pending",{args:n,data:"preference"in n?new Me(y(y({},n.preference),typeof n.value=="boolean"?{enabled:n.value}:{condition:n.value}),i,e,t,r):void 0});let u=yield e.updateSubscriptionPreference(y({subscriptionIdentifier:n.subscriptionId,workflowId:o},typeof n.value=="boolean"?{enabled:n.value,email:n.value,sms:n.value,in_app:n.value,chat:n.value,push:n.value}:{condition:n.value})),h=new Me(y({},u),i,e,t,r);return i.emit("subscription.preference.update.resolved",{args:n,data:h}),{data:h}}catch(u){return i.emit("subscription.preference.update.resolved",{args:n,error:u}),{error:new w("Failed to update subscription",u)}}}),ks=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){try{let o=n.map(h=>"preference"in h?new Me(y(y({},h.preference),typeof h.value=="boolean"?{enabled:h.value}:{condition:h.value}),i,e,t,r):void 0).filter(h=>h!==void 0);i.emit("subscription.preferences.bulk_update.pending",{args:n,data:o});let c=n.map(h=>{var f,p,m,x,b,S;return y({subscriptionIdentifier:h.subscriptionId,workflowId:"workflowId"in h?h.workflowId:(S=(b=(p=(f=h.preference)==null?void 0:f.workflow)==null?void 0:p.id)!=null?b:(x=(m=h.preference)==null?void 0:m.workflow)==null?void 0:x.identifier)!=null?S:""},typeof h.value=="boolean"?{enabled:h.value,email:h.value,sms:h.value,in_app:h.value,chat:h.value,push:h.value}:{condition:h.value})}),u=(yield e.bulkUpdateSubscriptionPreferences(c)).map(h=>new Me(h,i,e,t,r));return i.emit("subscription.preferences.bulk_update.resolved",{args:n,data:u}),{data:u}}catch(o){return i.emit("subscription.preferences.bulk_update.resolved",{args:n,error:o}),{error:new w("Failed to bulk update subscription preferences",o)}}}),sr=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let n="identifier"in t?t.identifier:t.subscription.identifier,s="topicKey"in t?t.topicKey:t.subscription.topicKey;try{return i.emit("subscription.delete.pending",{args:t}),yield e.deleteSubscription({topicKey:s,identifier:n}),i.emit("subscription.delete.resolved",{args:t}),{data:void 0}}catch(o){return i.emit("subscription.delete.resolved",{args:t,error:o}),{error:new w("Failed to delete subscription",o)}}});var We,$e,rt,nt,Lt,qe=class{constructor(e,t,r,n,s){g(this,We);g(this,$e);g(this,rt);g(this,nt);g(this,Lt,!1);var o;v(this,We,t),v(this,$e,r),v(this,rt,n),v(this,nt,s),this.id=e.id,this.identifier=e.identifier,this.topicKey=e.topicKey,this.preferences=(o=e.preferences)==null?void 0:o.map(c=>new Me(y({},c),a(this,We),a(this,$e),a(this,rt),a(this,nt)))}update(e){return d(this,null,function*(){return nr({emitter:a(this,We),apiService:a(this,$e),cache:a(this,rt),useCache:a(this,nt),args:C(y({},e),{subscription:this})})})}updatePreference(e){return d(this,null,function*(){return a(this,Lt)?{error:new w("Cannot update a deleted subscription",new Error("Subscription is stale"))}:rr({emitter:a(this,We),apiService:a(this,$e),cache:a(this,rt),useCache:a(this,nt),args:C(y({},e),{subscriptionId:this.identifier})})})}bulkUpdatePreferences(e){return d(this,null,function*(){return a(this,Lt)?{error:new w("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:ks({emitter:a(this,We),apiService:a(this,$e),cache:a(this,rt),useCache:a(this,nt),args:e.map(t=>C(y({},t),{subscriptionId:this.identifier}))})})}delete(){return d(this,null,function*(){return a(this,Lt)?{error:new w("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:sr({emitter:a(this,We),apiService:a(this,$e),args:{subscription:this}})})}};We=new WeakMap,$e=new WeakMap,rt=new WeakMap,nt=new WeakMap,Lt=new WeakMap;var yt=i=>`list:${i.topicKey}`,Rs=i=>i.split(":")[1],st=i=>`item:${i.topicKey}:${i.identifier}`,X,q,si,$,oi,or=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:r}){g(this,X);g(this,q);g(this,si);g(this,$);g(this,oi);this.handleCreate=e=>{let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r){let n=[...r,e];a(this,q).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,$).set(st({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r){let n=r.map(s=>s.id===e.id?e:s);a(this,q).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,$).set(st({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handlePreferenceUpdate=e=>{this.updateSubscriptionPreferences([e])};this.handleBulkPreferenceUpdate=e=>{this.updateSubscriptionPreferences(e)};this.updateSubscriptionPreferences=e=>{var s;let t=new Map;for(let o of e){let c=(s=t.get(o.subscriptionId))!=null?s:[];c.push(o),t.set(o.subscriptionId,c)}let r=a(this,q).keys();for(let o of r){let c=a(this,q).get(o);if(!c)continue;let l=!1,u=c.map(h=>{let f=t.get(h.id);return f?(l=!0,this.createUpdatedSubscription(h,f)):h});l&&(a(this,q).set(o,u),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:Rs(o),subscriptions:u}}))}let n=a(this,$).keys();for(let o of n){let c=a(this,$).get(o);if(!c)continue;let l=t.get(c.id);if(l){let u=this.createUpdatedSubscription(c,l);a(this,$).set(o,u),a(this,X).emit("subscription.update.resolved",{args:{subscription:c},data:u})}}};this.createUpdatedSubscription=(e,t)=>{var n;let r=(n=e.preferences)==null?void 0:n.map(s=>{let o=t.find(c=>c.workflow.id===s.workflow.id);return o||s});return new qe({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:r},a(this,X),a(this,oi),this,a(this,si))};this.handleDelete=e=>{let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r){let n=r.filter(s=>s.id!==e.id);a(this,q).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,$).remove(st({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteByIdentifier=e=>{let t=a(this,q).keys();for(let n of t){let s=a(this,q).get(n);if(s){let o=s.find(c=>c.identifier===e);if(o){let c=s.filter(l=>l.identifier!==e);a(this,q).set(n,c),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:Rs(n),subscriptions:c}}),a(this,$).remove(st({topicKey:o.topicKey,identifier:o.identifier}));return}}}let r=a(this,$).keys();for(let n of r){let s=a(this,$).get(n);if(s&&s.identifier===e){a(this,$).remove(n);return}}};v(this,X,e),v(this,q,new we),v(this,$,new we),v(this,oi,t),v(this,si,r),a(this,X).on("subscription.create.resolved",({data:n})=>{n&&this.handleCreate(n)}),a(this,X).on("subscription.update.resolved",({data:n})=>{n&&this.handleUpdate(n)}),a(this,X).on("subscription.delete.resolved",({args:n})=>{"subscription"in n?this.handleDelete(n.subscription):"identifier"in n&&this.handleDeleteByIdentifier(n.identifier)}),a(this,X).on("subscription.preference.update.pending",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preference.update.resolved",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preferences.bulk_update.resolved",({data:n})=>{n&&n.length>0&&this.handleBulkPreferenceUpdate(n)})}has(e){return a(this,q).get(yt(e))!==void 0}set(e,t){a(this,q).set(yt(e),t);for(let r of t)a(this,$).set(st({topicKey:e.topicKey,identifier:r.identifier}),r)}setOne(e,t){a(this,$).set(st(e),t)}getAll(e){return a(this,q).get(yt(e))}get(e){return a(this,$).get(st(e))}invalidate(e){let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r)for(let s of r)a(this,$).remove(st({topicKey:e.topicKey,identifier:s.identifier}));a(this,q).remove(t);let n=a(this,$).keys();for(let s of n)s.startsWith(`item:${e.topicKey}:`)&&a(this,$).remove(s)}clearAll(){a(this,q).clear(),a(this,$).clear()}};X=new WeakMap,q=new WeakMap,si=new WeakMap,$=new WeakMap,oi=new WeakMap;var ai,ar=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,ai);this.cache=new Zt({emitter:n,inboxService:r}),v(this,ai,t)}list(){return d(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=on(s,["limit"]);return this.callWithSession(()=>d(this,null,function*(){let o=y({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,ai),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(y({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 w("Failed to fetch notifications",c)}}}))})}count(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){let r=t&&"filters"in t?t.filters:[y({},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 w("Failed to count notifications",n)}}}))})}read(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ji({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Qi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Zi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return ir({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return er({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return tr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return It({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return It({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ot({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ot({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return bs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){return"notificationIds"in t?cn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):cn({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 d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return Ss({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return _s({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return Es({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 d(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};ai=new WeakMap;var ci,li,hi,ui,Ke=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){g(this,ci);g(this,li);g(this,hi);g(this,ui);v(this,ci,t),v(this,li,r),v(this,hi,n),v(this,ui,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return d(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return cr({emitter:a(this,ci),apiService:a(this,li),cache:a(this,hi),useCache:a(this,ui),args:y({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:y(y({},this.weeklySchedule),e.weeklySchedule)})})})}};ci=new WeakMap,li=new WeakMap,hi=new WeakMap,ui=new WeakMap;var fi,di,pi,mi,yi,Oe=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){g(this,fi);g(this,di);g(this,pi);g(this,mi);g(this,yi);v(this,fi,t),v(this,di,r),v(this,pi,n),v(this,mi,s),v(this,yi,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Ke(y({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return lr({emitter:a(this,fi),apiService:a(this,di),cache:a(this,pi),scheduleCache:a(this,mi),useCache:a(this,yi),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};fi=new WeakMap,di=new WeakMap,pi=new WeakMap,mi=new WeakMap,yi=new WeakMap;var lr=o=>d(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 Oe(C(y({},s.preference),{channels:y(y({},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}):(mc({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),h=yield e.updateGlobalPreferences(c));let f=new Oe(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 w("Failed to update preference",h)}}}),Ts=o=>d(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 w("Global preference is not supported in bulk update","")};try{let l=s.map(p=>"preference"in p?new Oe(C(y({},p.preference),{channels:y(y({},p.preference.channels),p.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(p=>p!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let u=s.map(p=>{var m,x,b,S;return y({workflowId:"workflowId"in p?p.workflowId:(S=(b=(m=p.preference.workflow)==null?void 0:m.id)!=null?b:(x=p.preference.workflow)==null?void 0:x.identifier)!=null?S:""},p.channels)}),f=(yield e.bulkUpdatePreferences(u)).map(p=>new Oe(p,{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 w("Failed to bulk update preferences",l)}}}),mc=({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=C(y({},c),{channels:Object.entries(c.channels).reduce((p,[m,x])=>{var S;let b=m;return p[b]=(S=s.channels[b])!=null?S:x,p},{})}),f="preference"in s?new Oe(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})}})},cr=s=>d(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 Ke({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}}),p=new Ke({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:p}),{data:p}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new w("Failed to update preference",l)}}});var ot,hr=class extends ae{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});g(this,ot);this.cache=t,v(this,ot,r)}get(){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){var t,r;try{let n=a(this,ot)?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 Ke({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,ot)}),a(this,ot)&&(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 d(this,null,function*(){return this.callWithSession(()=>cr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ot),args:t}))})}};ot=new WeakMap;var yc=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],gc=["preference.schedule.update.pending","preference.schedule.update.resolved"],vc=({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),{}),dn=({tags:i,severity:e})=>JSON.stringify(vc({tags:i,severity:e})),at,H,ur=class{constructor({emitterInstance:e}){g(this,at);g(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,at).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,at).emit("preferences.list.updated",{data:(s=a(this,H).get(n))!=null?s:[]})})};v(this,at,e);for(let t of yc)a(this,at).on(t,this.handlePreferenceEvent);for(let t of gc)a(this,at).on(t,this.handleScheduleEvent);v(this,H,new we)}has(e){return a(this,H).get(dn(e))!==void 0}set(e,t){a(this,H).set(dn(e),t)}getAll(e){if(this.has(e))return a(this,H).get(dn(e))}clearAll(){a(this,H).clear()}};at=new WeakMap,H=new WeakMap;var bc=["preference.schedule.update.pending","preference.schedule.update.resolved"],pn=()=>"schedule",Ft,le,fr=class{constructor({emitterInstance:e}){g(this,Ft);g(this,le);this.updateScheduleInCache=(e,t)=>a(this,le).get(e)?(a(this,le).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,le).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,le).get(n);!s||!o||t.add(n)}for(let n of t)a(this,Ft).emit("preference.schedule.get.updated",{data:a(this,le).get(n)})};v(this,Ft,e);for(let t of bc)a(this,Ft).on(t,this.handleScheduleEvent);v(this,le,new we)}has(){return a(this,le).get(pn())!==void 0}set(e){a(this,le).set(pn(),e)}getAll(){if(this.has())return a(this,le).get(pn())}clearAll(){a(this,le).clear()}};Ft=new WeakMap,le=new WeakMap;var ze,dr=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,ze);this.cache=new ur({emitterInstance:this._emitter}),this.scheduleCache=new fr({emitterInstance:this._emitter}),v(this,ze,t),this.schedule=new hr({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){var r;try{let n=a(this,ze)?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 Oe(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,ze)})),a(this,ze)&&(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 d(this,null,function*(){return this.callWithSession(()=>lr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,ze),args:t}))})}bulkUpdate(t){return d(this,null,function*(){return this.callWithSession(()=>Ts({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,ze),args:t}))})}};ze=new WeakMap;function Is(){return typeof window!="undefined"}var gt,gi,Q,pr=class{constructor(e,t,r){g(this,gt);g(this,gi);g(this,Q);v(this,gt,r),v(this,gi,t),v(this,Q,e)}get applicationIdentifier(){return a(this,Q).applicationIdentifier}get subscriberId(){var e;return(e=a(this,Q).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,Q).context}get subscriberHash(){return a(this,Q).subscriberHash}get contextHash(){return a(this,Q).contextHash}get subscriber(){return a(this,Q).subscriber}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 d(this,null,function*(){var n,s,o,c,l,u;let t=((n=a(this,Q).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,Q).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&v(this,Q,e);let{subscriber:h,subscriberHash:f,contextHash:p,applicationIdentifier:m,defaultSchedule:x,context:b}=a(this,Q),S;Is()&&(S=Intl.DateTimeFormat().resolvedOptions().timeZone);let T=m;if(T)this.handleApplicationIdentifier("delete");else{let _=this.handleApplicationIdentifier("get");_&&(T=_)}a(this,gt).emit("session.initialize.pending",{args:a(this,Q)});let N=yield a(this,gi).initializeSession({applicationIdentifier:T,subscriberHash:f,contextHash:p,subscriber:C(y({},h),{subscriberId:(o=h==null?void 0:h.subscriberId)!=null?o:"",timezone:(c=h==null?void 0:h.timezone)!=null?c:S}),defaultSchedule:x,context:b});(l=N==null?void 0:N.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",N.applicationIdentifier),(u=N==null?void 0:N.applicationIdentifier)!=null&&u.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,gt).emit("session.initialize.resolved",{args:a(this,Q),data:N})}catch(h){a(this,gt).emit("session.initialize.resolved",{args:a(this,Q),error:h})}})}};gt=new WeakMap,gi=new WeakMap,Q=new WeakMap;function mn(i){if(!i)return"";let e=[];for(let[t,r]of Object.entries(i))if(r){let n=typeof r=="string"?r:r.id;e.push(`${t}:${n}`)}return e.sort().join(",")}function Os({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}function Ps({topicKey:i,subscriberId:e,contextKey:t}){let r=`tk_${i}:si_${e}`;return t&&t.length>0?`${r}:ctx_${t}`:r}var ct,bi,Si,vi=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n,subscriber:s,contextKey:o}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,ct);g(this,bi);g(this,Si);this.cache=new or({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),v(this,ct,t),v(this,bi,s),v(this,Si,o)}list(t,r){return d(this,null,function*(){return this.callWithSession(()=>{var n;return Cs({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:C(y({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,ct)}),args:t})})})}get(t,r){return d(this,null,function*(){return this.callWithSession(()=>{var n,s;return Ns({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:C(y({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,ct)}),args:C(y({},t),{identifier:(s=t.identifier)!=null?s:Ps({topicKey:t.topicKey,subscriberId:a(this,bi).subscriberId,contextKey:a(this,Si)})})})})})}create(t){return d(this,null,function*(){return this.callWithSession(()=>As({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ct),args:t}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>nr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ct),args:t}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>sr({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};ct=new WeakMap,bi=new WeakMap,Si=new WeakMap;var mr=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,Sc=function(){try{new mr.Event("")}catch(i){return!0}return!1}(),_c=function(){try{new mr.EventTarget}catch(i){return!0}return!1}();Sc&&(mr.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}());_c&&(mr.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(`
14
+ `+s),i.push(n+"m+"+Zr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Vu()+e+" "+i[0]}function Vu(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Hu(...i){return process.stderr.write(Qr.formatWithOptions(J.inspectOpts,...i)+`
15
+ `)}function Gu(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function ju(){return process.env.DEBUG}function Yu(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]]}Zr.exports=ss()(J);var{formatters:La}=Zr.exports;La.o=function(i){return this.inspectOpts.colors=this.useColors,Qr.inspect(i,this.inspectOpts).split(`
16
+ `).map(e=>e.trim()).join(" ")};La.O=function(i){return this.inspectOpts.colors=this.useColors,Qr.inspect(i,this.inspectOpts)}});var Bi=F((pm,os)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?os.exports=Pa():os.exports=Fa()});var uc="v1",hc=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,ji=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=uc,apiUrl:r=this.DEFAULT_BACKEND_URL,headers:n={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=g({"Novu-API-Version":NOVU_API_VERSION,"Novu-Client-Version":hc,"Content-Type":"application/json"},n)}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=g(g({},this.headers),e)}get(e,t,r=!0){return p(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return p(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=fc(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:g(g({},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 u=yield l.json();throw new Error(`${this.headers["Novu-Client-Version"]} error. Status: ${l.status}, Message: ${u.message}`)}if(l.status===204)return;let h=yield l.json();return n?h.data:h})}};function fc(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var oe="/inbox",ie=`${oe}/notifications`,k,Yi=class{constructor(e={}){this.isSessionInitialized=!1;y(this,k);v(this,k,new ji(e))}initializeSession(c){return p(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let l=yield a(this,k).post(`${oe}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,k).setAuthorizationToken(l.token),a(this,k).setKeylessHeader(l.applicationIdentifier),this.isSessionInitialized=!0,l})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:l,data:h,severity:u,createdGte:f,createdLte:m}){let d=new URLSearchParams(`limit=${r}`);if(e&&d.append("after",e),n&&d.append("offset",`${n}`),o)for(let w of o)d.append("tags[]",w);if(s!==void 0&&d.append("read",`${s}`),t!==void 0&&d.append("archived",`${t}`),c!==void 0&&d.append("snoozed",`${c}`),l!==void 0&&d.append("seen",`${l}`),h!==void 0&&d.append("data",JSON.stringify(h)),u&&Array.isArray(u))for(let w of u)d.append("severity[]",w);else u&&d.append("severity",u);return f&&d.append("createdGte",`${f}`),m&&d.append("createdLte",`${m}`),a(this,k).get(ie,d,!1)}count({filters:e}){return a(this,k).get(`${ie}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,k).patch(`${ie}/${e}/read`)}unread(e){return a(this,k).patch(`${ie}/${e}/unread`)}archive(e){return a(this,k).patch(`${ie}/${e}/archive`)}unarchive(e){return a(this,k).patch(`${ie}/${e}/unarchive`)}snooze(e,t){return a(this,k).patch(`${ie}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,k).patch(`${ie}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,k).post(`${ie}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,k).post(`${ie}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,k).post(`${ie}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,k).delete(`${ie}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,k).post(`${ie}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,k).post(`${ie}/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,k).patch(`${ie}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,k).patch(`${ie}/${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,k).get(`${oe}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,k).patch(`${oe}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,k).patch(`${oe}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,k).patch(`${oe}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,k).get(`${oe}/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,k).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,k).get(`${oe}/topics/${e}/subscriptions`)}getSubscription(e,t,r,n){let s=new URLSearchParams;if(r!=null&&r.length)for(let c of r)s.append("workflowIds",c);if(n!=null&&n.length)for(let c of n)s.append("tags",c);let o=s.size?`?${s.toString()}`:"";return a(this,k).get(`${oe}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:r,topicName:n,preferences:s}){return a(this,k).post(`${oe}/topics/${r}/subscriptions`,g(g({identifier:e,name:t},n&&{topic:{name:n}}),s!==void 0&&{preferences:s}))}updateSubscription({topicKey:e,identifier:t,name:r,preferences:n}){return a(this,k).patch(`${oe}/topics/${e}/subscriptions/${t}`,g({name:r},n!==void 0&&{preferences:n}))}updateSubscriptionPreference({subscriptionIdentifier:e,workflowId:t,enabled:r,condition:n,email:s,sms:o,in_app:c,chat:l,push:h}){return a(this,k).patch(`${oe}/subscriptions/${e}/preferences/${t}`,{enabled:r,condition:n,email:s,sms:o,in_app:c,chat:l,push:h})}bulkUpdateSubscriptionPreferences(e){return a(this,k).patch(`${oe}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,identifier:t}){return a(this,k).delete(`${oe}/topics/${e}/subscriptions/${t}`)}};k=new WeakMap;function bs(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 pt,Ji=class{constructor(){y(this,pt);v(this,pt,bs())}on(e,t){return a(this,pt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,pt).off(e,t)}emit(e,t){a(this,pt).emit(e,t)}};pt=new WeakMap;var x=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Xi=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to read notification",o)}}}),Qi=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to unread notification",o)}}}),Zi=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to mark notification as seen",o)}}}),er=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to archive notification",o)}}}),tr=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to unarchive notification",o)}}}),ir=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to snooze notification",o)}}}),rr=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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 x("Failed to unsnooze notification",o)}}}),It=n=>p(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:C(g({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:C(g({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=Ie(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}),h=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new x(`Failed to complete ${r} action on the notification`,l)}}}),Ot=n=>p(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:C(g({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:C(g({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=Ie(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}),h=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new x("Failed to fetch notifications",l)}}}),Ie=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(g(g({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},Ss=s=>p(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(C(g({},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 x("Failed to read all notifications",o)}}}),un=o=>p(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}),h=(r&&r.length>0?c.filter(u=>r.includes(u.id)):c).map(u=>new U(C(g({},u),{isSeen:!0,firstSeenAt:u.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:h}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:h}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:c}),{error:new x("Failed to mark all notifications as seen",c)}}}),_s=s=>p(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(C(g({},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 x("Failed to archive all notifications",o)}}}),Es=s=>p(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(C(g({},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 x("Failed to archive all read notifications",o)}}}),nr=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=Ie(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 x("Failed to delete notification",s)}}}),ws=s=>p(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 x("Failed to delete all notifications",o)}}});var V,re,U=class{constructor(e,t,r){y(this,V);y(this,re);v(this,V,t),v(this,re,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 Xi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}unread(){return Qi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}seen(){return Zi({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}archive(){return er({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}unarchive(){return tr({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}delete(){return nr({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}snooze(e){return ir({emitter:a(this,V),apiService:a(this,re),args:{notification:this,snoozeUntil:e}})}unsnooze(){return rr({emitter:a(this,V),apiService:a(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return It({emitter:a(this,V),apiService:a(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return It({emitter:a(this,V),apiService:a(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ot({emitter:a(this,V),apiService:a(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ot({emitter:a(this,V),apiService:a(this,re),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,re=new WeakMap;var it,Pt,ae=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){y(this,it,[]);y(this,Pt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,it).forEach(c=>p(this,[c],function*({fn:s,resolve:o}){o(yield s())})),v(this,it,[])):r&&(this.onSessionError(r),v(this,Pt,r),a(this,it).forEach(({resolve:s})=>{s({error:new x("Failed to initialize session, please contact the support",r)})}),v(this,it,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return p(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Pt)?Promise.resolve({error:new x("Failed to initialize session, please contact the support",a(this,Pt))}):new Promise((t,r)=>{a(this,it).push({fn:e,resolve:t,reject:r})})})}};it=new WeakMap,Pt=new WeakMap;function xs({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var hn=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Uh=["seen","unseen"],Dh=["read","unread"],fn=(i,e)=>hn(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,dc=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return hn(t,r)},dn=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},pn=(i,e)=>dn(i.data,e.data)&&fn(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&dc(i.severity,e.severity)&&i.createdGte===e.createdGte&&i.createdLte===e.createdLte;var Ee,we=class{constructor(){y(this,Ee);v(this,Ee,new Map)}get(e){return a(this,Ee).get(e)}getValues(){return Array.from(a(this,Ee).values())}entries(){return Array.from(a(this,Ee).entries())}keys(){return Array.from(a(this,Ee).keys())}set(e,t){a(this,Ee).set(e,t)}remove(e){a(this,Ee).delete(e)}clear(){a(this,Ee).clear()}};Ee=new WeakMap;var Cs=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h,createdGte:u,createdLte:f})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h,createdGte:u,createdLte:f}).filter(([m,d])=>d!=null&&!(Array.isArray(d)&&d.length===0)).reduce((m,[d,w])=>(m[d]=w,m),{}),Qt=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h,createdGte:u,createdLte:f})=>JSON.stringify(Cs({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h,createdGte:u,createdLte:f})),pc=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,createdGte:c,createdLte:l})=>JSON.stringify(Cs({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,createdGte:c,createdLte:l})),mt=i=>JSON.parse(i),mc=["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"],yc=["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"],Be,ei,M,Zt=class{constructor({emitter:e,inboxService:t}){y(this,Be);y(this,ei);y(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,C(g({},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,C(g({},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 h=a(this,M).get(l);if(h){let u=h.notifications.find(f=>f.id===n.notificationId);u&&c.push(u)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,M).keys().forEach(c=>{s.forEach(l=>{let h=!1;e?h=this.removeNotification(c,l):h=this.updateNotification(c,l),h&&o.add(pc(mt(c)))})}),o.forEach(c=>{let l=this.getAggregated(mt(c));a(this,Be).emit("notifications.list.updated",{data:l})})};v(this,Be,e),v(this,ei,t),mc.forEach(r=>{a(this,Be).on(r,this.handleNotificationEvent())}),yc.forEach(r=>{a(this,Be).on(r,this.handleNotificationEvent({remove:!0}))}),v(this,M,new we)}getAggregated(e){return a(this,M).keys().filter(r=>{let n=mt(r);return pn(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:[]})}get(e){return a(this,M).get(Qt(e))}has(e){return a(this,M).get(Qt(e))!==void 0}set(e,t){a(this,M).set(Qt(e),t)}unshift(e,t){let r=Qt(e),n=a(this,M).get(r)||{hasMore:!1,filter:mt(r),notifications:[]},s=xs({notification:g({},t),emitter:a(this,Be),inboxService:a(this,ei)});this.update(e,C(g({},n),{notifications:[s,...n.notifications]}))}update(e,t){this.set(e,t);let r=this.getAggregated(mt(Qt(e)));a(this,Be).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,createdGte:e.createdGte,createdLte:e.createdLte})}getUniqueNotifications({tags:e,read:t,data:r}){let n=a(this,M).keys(),s=new Map;return n.forEach(o=>{let c=mt(o);if(fn(e,c.tags)&&dn(r,c.data)){let l=a(this,M).get(o);if(!l)return;l.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,M).keys().forEach(r=>{pn(mt(r),e)&&a(this,M).remove(r)})}clearAll(){a(this,M).clear()}};Be=new WeakMap,ei=new WeakMap,M=new WeakMap;var ti,ii,ri,ni,Me=class{constructor(e,t,r,n,s){y(this,ti);y(this,ii);y(this,ri);y(this,ni);var o;v(this,ti,t),v(this,ii,r),v(this,ri,n),v(this,ni,s),this.enabled=e.enabled,this.condition=(o=e.condition)!=null?o:void 0,this.workflow=e.workflow,this.subscriptionId=e.subscriptionId}update(e){return p(this,null,function*(){var t;return sr({emitter:a(this,ti),apiService:a(this,ii),cache:a(this,ri),useCache:a(this,ni),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};ti=new WeakMap,ii=new WeakMap,ri=new WeakMap,ni=new WeakMap;var Ns=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.getAll(n):void 0;return i.emit("subscriptions.list.pending",{args:n,data:l}),(!l||c)&&(l=(yield e.fetchSubscriptions(n.topicKey)).map(u=>new qe(C(g({},u),{topicKey:n.topicKey}),i,e,t,o)),o&&(t.set(n,l),l=t.getAll(n))),i.emit("subscriptions.list.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscriptions.list.resolved",{args:n,error:o}),{error:new x("Failed to fetch subscriptions",o)}}}),ks=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.get(n):void 0;if(i.emit("subscription.get.pending",{args:n,data:l}),!l||c){let h=yield e.getSubscription(n.topicKey,n.identifier,n.workflowIds,n.tags);if(!h)return i.emit("subscription.get.resolved",{args:n,data:null}),{data:null};l=new qe(C(g({},h),{topicKey:n.topicKey}),i,e,t,o),o&&(t.setOne(n,l),l=t.get(n))}return i.emit("subscription.get.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscription.get.resolved",{args:n,error:o}),{error:new x("Failed to fetch subscription",o)}}}),As=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o;try{i.emit("subscription.create.pending",{args:n});let c=yield e.createSubscription({identifier:(o=n.identifier)!=null?o:"",name:n.name,topicKey:n.topicKey,topicName:n.topicName,preferences:n.preferences}),l=new qe(C(g({},c),{topicKey:n.topicKey}),i,e,t,r);return i.emit("subscription.create.resolved",{args:n,data:l}),{data:l}}catch(c){return i.emit("subscription.create.resolved",{args:n,error:c}),{error:new x("Failed to create subscription",c)}}}),or=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){let o="identifier"in n?n.identifier:n.subscription.identifier,c="topicKey"in n?n.topicKey:n.subscription.topicKey;try{i.emit("subscription.update.pending",{args:n});let l=yield e.updateSubscription({topicKey:c,identifier:o,name:n.name,preferences:n.preferences}),h=new qe(C(g({},l),{topicKey:c}),i,e,t,r);return i.emit("subscription.update.resolved",{args:n,data:h}),{data:h}}catch(l){return i.emit("subscription.update.resolved",{args:n,error:l}),{error:new x("Failed to update subscription",l)}}}),sr=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var c,l;let o="workflowId"in n?n.workflowId:(l=(c=n.preference)==null?void 0:c.workflow)==null?void 0:l.id;try{i.emit("subscription.preference.update.pending",{args:n,data:"preference"in n?new Me(g(g({},n.preference),typeof n.value=="boolean"?{enabled:n.value}:{condition:n.value}),i,e,t,r):void 0});let h=yield e.updateSubscriptionPreference(g({subscriptionIdentifier:n.subscriptionId,workflowId:o},typeof n.value=="boolean"?{enabled:n.value,email:n.value,sms:n.value,in_app:n.value,chat:n.value,push:n.value}:{condition:n.value})),u=new Me(g({},h),i,e,t,r);return i.emit("subscription.preference.update.resolved",{args:n,data:u}),{data:u}}catch(h){return i.emit("subscription.preference.update.resolved",{args:n,error:h}),{error:new x("Failed to update subscription",h)}}}),Rs=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){try{let o=n.map(u=>"preference"in u?new Me(g(g({},u.preference),typeof u.value=="boolean"?{enabled:u.value}:{condition:u.value}),i,e,t,r):void 0).filter(u=>u!==void 0);i.emit("subscription.preferences.bulk_update.pending",{args:n,data:o});let c=n.map(u=>{var f,m,d,w,b,S;return g({subscriptionIdentifier:u.subscriptionId,workflowId:"workflowId"in u?u.workflowId:(S=(b=(m=(f=u.preference)==null?void 0:f.workflow)==null?void 0:m.id)!=null?b:(w=(d=u.preference)==null?void 0:d.workflow)==null?void 0:w.identifier)!=null?S:""},typeof u.value=="boolean"?{enabled:u.value,email:u.value,sms:u.value,in_app:u.value,chat:u.value,push:u.value}:{condition:u.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(u=>new Me(u,i,e,t,r));return i.emit("subscription.preferences.bulk_update.resolved",{args:n,data:h}),{data:h}}catch(o){return i.emit("subscription.preferences.bulk_update.resolved",{args:n,error:o}),{error:new x("Failed to bulk update subscription preferences",o)}}}),ar=r=>p(void 0,[r],function*({emitter:i,apiService:e,args:t}){let n="identifier"in t?t.identifier:t.subscription.identifier,s="topicKey"in t?t.topicKey:t.subscription.topicKey;try{return i.emit("subscription.delete.pending",{args:t}),yield e.deleteSubscription({topicKey:s,identifier:n}),i.emit("subscription.delete.resolved",{args:t}),{data:void 0}}catch(o){return i.emit("subscription.delete.resolved",{args:t,error:o}),{error:new x("Failed to delete subscription",o)}}});var We,$e,rt,nt,Lt,qe=class{constructor(e,t,r,n,s){y(this,We);y(this,$e);y(this,rt);y(this,nt);y(this,Lt,!1);var o;v(this,We,t),v(this,$e,r),v(this,rt,n),v(this,nt,s),this.id=e.id,this.identifier=e.identifier,this.topicKey=e.topicKey,this.preferences=(o=e.preferences)==null?void 0:o.map(c=>new Me(g({},c),a(this,We),a(this,$e),a(this,rt),a(this,nt)))}update(e){return p(this,null,function*(){return or({emitter:a(this,We),apiService:a(this,$e),cache:a(this,rt),useCache:a(this,nt),args:C(g({},e),{subscription:this})})})}updatePreference(e){return p(this,null,function*(){return a(this,Lt)?{error:new x("Cannot update a deleted subscription",new Error("Subscription is stale"))}:sr({emitter:a(this,We),apiService:a(this,$e),cache:a(this,rt),useCache:a(this,nt),args:C(g({},e),{subscriptionId:this.identifier})})})}bulkUpdatePreferences(e){return p(this,null,function*(){return a(this,Lt)?{error:new x("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:Rs({emitter:a(this,We),apiService:a(this,$e),cache:a(this,rt),useCache:a(this,nt),args:e.map(t=>C(g({},t),{subscriptionId:this.identifier}))})})}delete(){return p(this,null,function*(){return a(this,Lt)?{error:new x("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:ar({emitter:a(this,We),apiService:a(this,$e),args:{subscription:this}})})}};We=new WeakMap,$e=new WeakMap,rt=new WeakMap,nt=new WeakMap,Lt=new WeakMap;var yt=i=>`list:${i.topicKey}`,Ts=i=>i.split(":")[1],st=i=>`item:${i.topicKey}:${i.identifier}`,X,q,si,$,oi,cr=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:r}){y(this,X);y(this,q);y(this,si);y(this,$);y(this,oi);this.handleCreate=e=>{let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r){let n=[...r,e];a(this,q).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,$).set(st({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r){let n=r.map(s=>s.id===e.id?e:s);a(this,q).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,$).set(st({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handlePreferenceUpdate=e=>{this.updateSubscriptionPreferences([e])};this.handleBulkPreferenceUpdate=e=>{this.updateSubscriptionPreferences(e)};this.updateSubscriptionPreferences=e=>{var s;let t=new Map;for(let o of e){let c=(s=t.get(o.subscriptionId))!=null?s:[];c.push(o),t.set(o.subscriptionId,c)}let r=a(this,q).keys();for(let o of r){let c=a(this,q).get(o);if(!c)continue;let l=!1,h=c.map(u=>{let f=t.get(u.identifier);return f?(l=!0,this.createUpdatedSubscription(u,f)):u});l&&(a(this,q).set(o,h),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:Ts(o),subscriptions:h}}))}let n=a(this,$).keys();for(let o of n){let c=a(this,$).get(o);if(!c)continue;let l=t.get(c.identifier);if(l){let h=this.createUpdatedSubscription(c,l);a(this,$).set(o,h),a(this,X).emit("subscription.update.resolved",{args:{subscription:c},data:h})}}};this.createUpdatedSubscription=(e,t)=>{var n;let r=(n=e.preferences)==null?void 0:n.map(s=>{let o=t.find(c=>c.workflow.id===s.workflow.id);return o||s});return new qe({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:r},a(this,X),a(this,oi),this,a(this,si))};this.handleDelete=e=>{let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r){let n=r.filter(s=>s.id!==e.id);a(this,q).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,$).remove(st({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteByIdentifier=e=>{let t=a(this,q).keys();for(let n of t){let s=a(this,q).get(n);if(s){let o=s.find(c=>c.identifier===e);if(o){let c=s.filter(l=>l.identifier!==e);a(this,q).set(n,c),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:Ts(n),subscriptions:c}}),a(this,$).remove(st({topicKey:o.topicKey,identifier:o.identifier}));return}}}let r=a(this,$).keys();for(let n of r){let s=a(this,$).get(n);if(s&&s.identifier===e){a(this,$).remove(n);return}}};v(this,X,e),v(this,q,new we),v(this,$,new we),v(this,oi,t),v(this,si,r),a(this,X).on("subscription.create.resolved",({data:n})=>{n&&this.handleCreate(n)}),a(this,X).on("subscription.update.resolved",({data:n})=>{n&&this.handleUpdate(n)}),a(this,X).on("subscription.delete.resolved",({args:n})=>{"subscription"in n?this.handleDelete(n.subscription):"identifier"in n&&this.handleDeleteByIdentifier(n.identifier)}),a(this,X).on("subscription.preference.update.pending",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preference.update.resolved",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preferences.bulk_update.resolved",({data:n})=>{n&&n.length>0&&this.handleBulkPreferenceUpdate(n)})}has(e){return a(this,q).get(yt(e))!==void 0}set(e,t){a(this,q).set(yt(e),t);for(let r of t)a(this,$).set(st({topicKey:e.topicKey,identifier:r.identifier}),r)}setOne(e,t){a(this,$).set(st(e),t)}getAll(e){return a(this,q).get(yt(e))}get(e){return a(this,$).get(st(e))}invalidate(e){let t=yt({topicKey:e.topicKey}),r=a(this,q).get(t);if(r)for(let s of r)a(this,$).remove(st({topicKey:e.topicKey,identifier:s.identifier}));a(this,q).remove(t);let n=a(this,$).keys();for(let s of n)s.startsWith(`item:${e.topicKey}:`)&&a(this,$).remove(s)}clearAll(){a(this,q).clear(),a(this,$).clear()}};X=new WeakMap,q=new WeakMap,si=new WeakMap,$=new WeakMap,oi=new WeakMap;var ai,lr=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,ai);this.cache=new Zt({emitter:n,inboxService:r}),v(this,ai,t)}list(){return p(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=cn(s,["limit"]);return this.callWithSession(()=>p(this,null,function*(){let o=g({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,ai),l=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let h=yield this._inboxService.fetchNotifications(g({limit:t},r));l={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(u=>new U(u,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 x("Failed to fetch notifications",c)}}}))})}count(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){let r=t&&"filters"in t?t.filters:[g({},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 x("Failed to count notifications",n)}}}))})}read(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Qi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Zi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return er({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return tr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return nr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return ir({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return rr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return It({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return It({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Ot({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Ot({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return p(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>p(this,null,function*(){return Ss({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return p(this,arguments,function*(t={}){return this.callWithSession(()=>p(this,null,function*(){return"notificationIds"in t?un({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):un({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 p(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>p(this,null,function*(){return _s({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return p(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>p(this,null,function*(){return Es({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return p(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>p(this,null,function*(){return ws({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 p(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};ai=new WeakMap;var ci,li,ui,hi,Ke=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){y(this,ci);y(this,li);y(this,ui);y(this,hi);v(this,ci,t),v(this,li,r),v(this,ui,n),v(this,hi,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return p(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return ur({emitter:a(this,ci),apiService:a(this,li),cache:a(this,ui),useCache:a(this,hi),args:g({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:g(g({},this.weeklySchedule),e.weeklySchedule)})})})}};ci=new WeakMap,li=new WeakMap,ui=new WeakMap,hi=new WeakMap;var fi,di,pi,mi,yi,Oe=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){y(this,fi);y(this,di);y(this,pi);y(this,mi);y(this,yi);v(this,fi,t),v(this,di,r),v(this,pi,n),v(this,mi,s),v(this,yi,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Ke(g({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return hr({emitter:a(this,fi),apiService:a(this,di),cache:a(this,pi),scheduleCache:a(this,mi),useCache:a(this,yi),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};fi=new WeakMap,di=new WeakMap,pi=new WeakMap,mi=new WeakMap,yi=new WeakMap;var hr=o=>p(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var h;let{channels:c}=s,l="workflowId"in s?s.workflowId:(h=s.preference.workflow)==null?void 0:h.id;try{i.emit("preference.update.pending",{args:s,data:"preference"in s?new Oe(C(g({},s.preference),{channels:g(g({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let u;l?u=yield e.updateWorkflowPreferences({workflowId:l,channels:c}):(gc({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),u=yield e.updateGlobalPreferences(c));let f=new Oe(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(u){return i.emit("preference.update.resolved",{args:s,error:u}),{error:new x("Failed to update preference",u)}}}),Is=o=>p(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 x("Global preference is not supported in bulk update","")};try{let l=s.map(m=>"preference"in m?new Oe(C(g({},m.preference),{channels:g(g({},m.preference.channels),m.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(m=>m!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let h=s.map(m=>{var d,w,b,S;return g({workflowId:"workflowId"in m?m.workflowId:(S=(b=(d=m.preference.workflow)==null?void 0:d.id)!=null?b:(w=m.preference.workflow)==null?void 0:w.identifier)!=null?S:""},m.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(m=>new Oe(m,{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 x("Failed to bulk update preferences",l)}}}),gc=({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,h;if(c.level==="template"){let u=C(g({},c),{channels:Object.entries(c.channels).reduce((m,[d,w])=>{var S;let b=d;return m[b]=(S=s.channels[b])!=null?S:w,m},{})}),f="preference"in s?new Oe(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(h=(l=c.workflow)==null?void 0:l.id)!=null?h:"",channels:f.channels},data:f})}})},ur=s=>p(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:l,weeklySchedule:h}=n,u=new Ke({isEnabled:l,weeklySchedule:h},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:u});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:l,weeklySchedule:h}}),m=new Ke({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:m}),{data:m}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new x("Failed to update preference",l)}}});var ot,fr=class extends ae{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});y(this,ot);this.cache=t,v(this,ot,r)}get(){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){var t,r;try{let n=a(this,ot)?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 Ke({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,ot)}),a(this,ot)&&(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 p(this,null,function*(){return this.callWithSession(()=>ur({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ot),args:t}))})}};ot=new WeakMap;var vc=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],bc=["preference.schedule.update.pending","preference.schedule.update.resolved"],Sc=({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),{}),mn=({tags:i,severity:e})=>JSON.stringify(Sc({tags:i,severity:e})),at,H,dr=class{constructor({emitterInstance:e}){y(this,at);y(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,at).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,at).emit("preferences.list.updated",{data:(s=a(this,H).get(n))!=null?s:[]})})};v(this,at,e);for(let t of vc)a(this,at).on(t,this.handlePreferenceEvent);for(let t of bc)a(this,at).on(t,this.handleScheduleEvent);v(this,H,new we)}has(e){return a(this,H).get(mn(e))!==void 0}set(e,t){a(this,H).set(mn(e),t)}getAll(e){if(this.has(e))return a(this,H).get(mn(e))}clearAll(){a(this,H).clear()}};at=new WeakMap,H=new WeakMap;var _c=["preference.schedule.update.pending","preference.schedule.update.resolved"],yn=()=>"schedule",Ft,le,pr=class{constructor({emitterInstance:e}){y(this,Ft);y(this,le);this.updateScheduleInCache=(e,t)=>a(this,le).get(e)?(a(this,le).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,le).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,le).get(n);!s||!o||t.add(n)}for(let n of t)a(this,Ft).emit("preference.schedule.get.updated",{data:a(this,le).get(n)})};v(this,Ft,e);for(let t of _c)a(this,Ft).on(t,this.handleScheduleEvent);v(this,le,new we)}has(){return a(this,le).get(yn())!==void 0}set(e){a(this,le).set(yn(),e)}getAll(){if(this.has())return a(this,le).get(yn())}clearAll(){a(this,le).clear()}};Ft=new WeakMap,le=new WeakMap;var ze,mr=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,ze);this.cache=new dr({emitterInstance:this._emitter}),this.scheduleCache=new pr({emitterInstance:this._emitter}),v(this,ze,t),this.schedule=new fr({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return p(this,arguments,function*(t={}){return this.callWithSession(()=>p(this,null,function*(){var r;try{let n=a(this,ze)?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 Oe(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,ze)})),a(this,ze)&&(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 p(this,null,function*(){return this.callWithSession(()=>hr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,ze),args:t}))})}bulkUpdate(t){return p(this,null,function*(){return this.callWithSession(()=>Is({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,ze),args:t}))})}};ze=new WeakMap;function Os(){return typeof window!="undefined"}var gt,gi,Q,yr=class{constructor(e,t,r){y(this,gt);y(this,gi);y(this,Q);v(this,gt,r),v(this,gi,t),v(this,Q,e)}get applicationIdentifier(){return a(this,Q).applicationIdentifier}get subscriberId(){var e;return(e=a(this,Q).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,Q).context}get subscriberHash(){return a(this,Q).subscriberHash}get contextHash(){return a(this,Q).contextHash}get subscriber(){return a(this,Q).subscriber}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 p(this,null,function*(){var n,s,o,c,l,h;let t=((n=a(this,Q).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,Q).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&v(this,Q,e);let{subscriber:u,subscriberHash:f,contextHash:m,applicationIdentifier:d,defaultSchedule:w,context:b}=a(this,Q),S;Os()&&(S=Intl.DateTimeFormat().resolvedOptions().timeZone);let T=d;if(T)this.handleApplicationIdentifier("delete");else{let _=this.handleApplicationIdentifier("get");_&&(T=_)}a(this,gt).emit("session.initialize.pending",{args:a(this,Q)});let N=yield a(this,gi).initializeSession({applicationIdentifier:T,subscriberHash:f,contextHash:m,subscriber:C(g({},u),{subscriberId:(o=u==null?void 0:u.subscriberId)!=null?o:"",timezone:(c=u==null?void 0:u.timezone)!=null?c:S}),defaultSchedule:w,context:b});(l=N==null?void 0:N.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",N.applicationIdentifier),(h=N==null?void 0:N.applicationIdentifier)!=null&&h.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,gt).emit("session.initialize.resolved",{args:a(this,Q),data:N})}catch(u){a(this,gt).emit("session.initialize.resolved",{args:a(this,Q),error:u})}})}};gt=new WeakMap,gi=new WeakMap,Q=new WeakMap;function gn(i){if(!i)return"";let e=[];for(let[t,r]of Object.entries(i))if(r){let n=typeof r=="string"?r:r.id;e.push(`${t}:${n}`)}return e.sort().join(",")}function Ps({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}function Ls({topicKey:i,subscriberId:e,contextKey:t}){let r=`tk_${i}:si_${e}`;return t&&t.length>0?`${r}:ctx_${t}`:r}var ct,bi,Si,vi=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n,subscriber:s,contextKey:o}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,ct);y(this,bi);y(this,Si);this.cache=new cr({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),v(this,ct,t),v(this,bi,s),v(this,Si,o)}list(t,r){return p(this,null,function*(){return this.callWithSession(()=>{var n;return Ns({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:C(g({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,ct)}),args:t})})})}get(t,r){return p(this,null,function*(){return this.callWithSession(()=>{var n,s;return ks({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:C(g({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,ct)}),args:C(g({},t),{identifier:(s=t.identifier)!=null?s:Ls({topicKey:t.topicKey,subscriberId:a(this,bi).subscriberId,contextKey:a(this,Si)})})})})})}create(t){return p(this,null,function*(){return this.callWithSession(()=>As({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ct),args:t}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>or({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ct),args:t}))})}delete(t){return p(this,null,function*(){return this.callWithSession(()=>ar({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};ct=new WeakMap,bi=new WeakMap,Si=new WeakMap;var gr=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,Ec=function(){try{new gr.Event("")}catch(i){return!0}return!1}(),wc=function(){try{new gr.EventTarget}catch(i){return!0}return!1}();Ec&&(gr.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}());wc&&(gr.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 Us=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},Ds=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}},yn={Event,ErrorEvent:Us,CloseEvent:Ds};function Ec(i,e){if(!i)throw new Error(e)}function wc(i){return new i.constructor(i.type,i)}function xc(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Ds(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Us(i.error,i):new Event(i.type,i)}var Ls,Cc=typeof process!="undefined"&&typeof((Ls=process.versions)==null?void 0:Ls.node)!="undefined"&&typeof document=="undefined",yr=Cc?xc:wc,vt={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},Fs=!1,gr=class bt 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=vt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),Ec(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(yr(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(yr(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(yr(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(yr(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 bt.CONNECTING}get OPEN(){return bt.OPEN}get CLOSING(){return bt.CLOSING}get CLOSED(){return bt.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?bt.CLOSED:bt.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=vt.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=vt.reconnectionDelayGrowFactor,minReconnectionDelay:r=vt.minReconnectionDelay,maxReconnectionDelay:n=vt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*ys(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=vt.maxRetries,connectionTimeout:r=vt.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"&&!Fs&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
24
+ `);var Ds=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},Bs=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}},vn={Event,ErrorEvent:Ds,CloseEvent:Bs};function xc(i,e){if(!i)throw new Error(e)}function Cc(i){return new i.constructor(i.type,i)}function Nc(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Bs(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Ds(i.error,i):new Event(i.type,i)}var Fs,kc=typeof process!="undefined"&&typeof((Fs=process.versions)==null?void 0:Fs.node)!="undefined"&&typeof document=="undefined",vr=kc?Nc:Cc,vt={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},Us=!1,br=class bt 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=vt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),xc(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(vr(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(vr(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(vr(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(vr(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 bt.CONNECTING}get OPEN(){return bt.OPEN}get CLOSING(){return bt.CLOSING}get CLOSED(){return bt.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?bt.CLOSED:bt.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=vt.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=vt.reconnectionDelayGrowFactor,minReconnectionDelay:r=vt.minReconnectionDelay,maxReconnectionDelay:n=vt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*vs(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=vt.maxRetries,connectionTimeout:r=vt.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"&&!Us&&(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
- `),Fs=!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 yn.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new yn.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 yn.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 _i="wss://socket.novu.co",Bs="notifications.notification_received",Ms="notifications.unseen_count_changed",qs="notifications.unread_count_changed",Nc=({_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:p,subscriber:m,subject:x,avatar:b,cta:S,tags:T,data:N,workflow:_,severity:E})=>{var Ue,dt,se,Qe,Ze,et,Se,_e;let W={id:m==null?void 0:m._id,subscriberId:m==null?void 0:m.subscriberId,firstName:m==null?void 0:m.firstName,lastName:m==null?void 0:m.lastName,avatar:m==null?void 0:m.avatar,locale:m==null?void 0:m.locale,data:m==null?void 0:m.data,timezone:m==null?void 0:m.timezone,email:m==null?void 0:m.email,phone:m==null?void 0:m.phone},R=(dt=(Ue=S.action)==null?void 0:Ue.buttons)==null?void 0:dt.find(De=>De.type==="primary"),P=(Qe=(se=S.action)==null?void 0:se.buttons)==null?void 0:Qe.find(De=>De.type==="secondary"),z=(et=(Ze=S.action)==null?void 0:Ze.result)==null?void 0:et.type,ne=(Se=S.action)==null?void 0:Se.status;return C(y(y({id:i,transactionId:e,subject:x,body:t,to:W,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:b,primaryAction:R&&{label:R.content,isCompleted:z==="primary"&&ne==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:z==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:T,redirect:(_e=S.data)!=null&&_e.url?{url:S.data.url,target:S.data.target}:void 0,data:N,workflow:_,severity:E})},Ut,xe,Ce,Dt,br,Sr,_r,Er,Pe,Ws,gn,vn,vr=class extends ae{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,Pe);g(this,Ut);g(this,xe);g(this,Ce);g(this,Dt);g(this,br,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,xe).emit(Bs,{result:new U(Nc(r.data.message),a(this,xe),this._inboxService)})}catch(r){console.log("error",r)}});g(this,Sr,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,xe).emit(Ms,{result:r.data.unseenCount})}catch(r){}});g(this,_r,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,xe).emit(qs,{result:r.data.counts})}catch(r){}});g(this,Er,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,br).call(this,t);break;case"unseen_count_changed":a(this,Sr).call(this,t);break;case"unread_count_changed":a(this,_r).call(this,t);break;default:}}catch(r){}});v(this,xe,n),v(this,Dt,t!=null?t:_i)}onSessionSuccess({token:t}){v(this,Ut,t)}isSocketEvent(t){return t===Bs||t===Ms||t===qs}connect(){return d(this,null,function*(){return a(this,Ut)?ye(this,Pe,gn).call(this):this.callWithSession(ye(this,Pe,gn).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,Ce)?ye(this,Pe,vn).call(this):this.callWithSession(ye(this,Pe,vn).bind(this))})}};Ut=new WeakMap,xe=new WeakMap,Ce=new WeakMap,Dt=new WeakMap,br=new WeakMap,Sr=new WeakMap,_r=new WeakMap,Er=new WeakMap,Pe=new WeakSet,Ws=function(){return d(this,null,function*(){if(a(this,Ce))return;let t={socketUrl:a(this,Dt)};a(this,xe).emit("socket.connect.pending",{args:t});let r=new URL(a(this,Dt));r.searchParams.set("token",a(this,Ut)),v(this,Ce,new gr(r.toString())),a(this,Ce).addEventListener("open",()=>{a(this,xe).emit("socket.connect.resolved",{args:t})}),a(this,Ce).addEventListener("error",n=>{a(this,xe).emit("socket.connect.resolved",{args:t,error:n})}),a(this,Ce).addEventListener("message",a(this,Er))})},gn=function(){return d(this,null,function*(){try{return yield ye(this,Pe,Ws).call(this),{}}catch(t){return{error:new w("Failed to initialize the PartySocket",t)}}})},vn=function(){return d(this,null,function*(){var t;try{return(t=a(this,Ce))==null||t.close(),v(this,Ce,void 0),{}}catch(r){return{error:new w("Failed to disconnect from the PartySocket",r)}}})};var Ne=Object.create(null);Ne.open="0";Ne.close="1";Ne.ping="2";Ne.pong="3";Ne.message="4";Ne.upgrade="5";Ne.noop="6";var Ei=Object.create(null);Object.keys(Ne).forEach(i=>{Ei[Ne[i]]=i});var wi={type:"error",data:"parser error"};var xi=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+$s(e,!0).toString("base64")):r(Ne[i]+(e||"")),$s=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),bn;function Ks(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e($s(i.data,!1));xi(i,!0,t=>{bn||(bn=new TextEncoder),e(bn.encode(t))})}var Ci=(i,e)=>{if(typeof i!="string")return{type:"message",data:zs(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:zs(r,e)}}return Ei[t]?i.length>1?{type:Ei[t],data:i.substring(1)}:{type:Ei[t]}:wi},zs=(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 Vs="",Hs=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{xi(s,!1,c=>{r[o]=c,++n===t&&e(r.join(Vs))})})},js=(i,e)=>{let t=i.split(Vs),r=[];for(let n=0;n<t.length;n++){let s=Ci(t[n],e);if(r.push(s),s.type==="error")break}return r};function Gs(){return new TransformStream({transform(i,e){Ks(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 Sn;function wr(i){return i.reduce((e,t)=>e+t.length,0)}function xr(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 Ys(i,e){Sn||(Sn=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(wr(t)<1)break;let l=xr(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(wr(t)<2)break;let l=xr(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(wr(t)<8)break;let l=xr(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),h=u.getUint32(0);if(h>Math.pow(2,21)-1){c.enqueue(wi);break}n=h*Math.pow(2,32)+u.getUint32(4),r=3}else{if(wr(t)<n)break;let l=xr(t,n);c.enqueue(Ci(s?l:Sn.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(wi);break}}}})}var _n=4;function L(i){if(i)return Ac(i)}function Ac(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 Ae=global;function Cr(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var kc=Ae.setTimeout,Rc=Ae.clearTimeout;function Ve(i,e){e.useNativeTimers?(i.setTimeoutFn=kc.bind(Ae),i.clearTimeoutFn=Rc.bind(Ae)):(i.setTimeoutFn=Ae.setTimeout.bind(Ae),i.clearTimeoutFn=Ae.clearTimeout.bind(Ae))}var Tc=1.33;function Js(i){return typeof i=="string"?Ic(i):Math.ceil((i.byteLength||i.size)*Tc)}function Ic(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 co=te(_t(),1);function oo(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ao(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 el=(0,co.default)("engine.io-client:transport"),kn=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},He=class extends L{constructor(e){super(),this.writable=!1,Ve(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new kn(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):el("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Ci(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=oo(e);return t.length?"?"+t:""}};var bo=te(_t(),1);var fo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Rn=64,tl={},lo=0,Tr=0,ho;function uo(i){let e="";do e=fo[i%Rn]+e,i=Math.floor(i/Rn);while(i>0);return e}function Ir(){let i=uo(+new Date);return i!==ho?(lo=0,ho=i):i+"."+uo(lo++)}for(;Tr<Rn;Tr++)tl[fo[Tr]]=Tr;var On=te(yo(),1),Pn=On.default||On;function go(){return new In}function rl(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 In=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=rl(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 ce=(0,bo.default)("engine.io-client:polling");function nl(){}var sl=function(){return new Pn({xdomain:!1}).responseType!=null}(),Or=class extends He{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=sl&&!t,this.opts.withCredentials&&(this.cookieJar=go())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{ce("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(ce("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){ce("pre-pause polling complete"),--r||t()})),this.writable||(ce("we are currently writing - waiting to pause"),r++,this.once("drain",function(){ce("pre-pause writing complete"),--r||t()}))}else t()}poll(){ce("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){ce("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)};js(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():ce('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{ce("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(ce("transport open - closing"),e()):(ce("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Hs(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]=Ir()),!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 ht(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(){ce("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}},ht=class i extends L{constructor(e,t){super(),Ve(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=Cr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Pn(t);try{ce("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))},ce("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=nl,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()}};ht.requestsCount=0;ht.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",vo);else if(typeof addEventListener=="function"){let i="onpagehide"in Ae?"pagehide":"unload";addEventListener(i,vo,!1)}}function vo(){for(let i in ht.requests)ht.requests.hasOwnProperty(i)&&ht.requests[i].abort()}var xh=te(wo(),1),Ch=te(zn(),1),Nh=te(jn(),1),xa=te(es(),1),Ah=te(wa(),1);var Ca=xa.default;var Fi=Ca,Hr=!1,Na="nodebuffer",At=process.nextTick;var ka=te(_t(),1);var kh=(0,ka.default)("engine.io-client:websocket"),Aa=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",jr=class extends He{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=Aa?{}:Cr(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&&!Aa?t?new Fi(e,t):new Fi(e):new Fi(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;xi(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){kh("websocket closed before onclose event")}n&&At(()=>{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]=Ir()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Fi}};var Ra=te(_t(),1),Ui=(0,Ra.default)("engine.io-client:webtransport"),Gr=class extends He{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Ui("transport closed gracefully"),this.onClose()}).catch(e=>{Ui("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Ys(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Gs();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){Ui("session is closed");return}Ui("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{Ui("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&&At(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var is={websocket:jr,webtransport:Gr,polling:Or};var Rh=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Th=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function jt(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=Rh.exec(i||""),s={},o=14;for(;o--;)s[Th[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=Ih(s,s.path),s.queryKey=Oh(s,s.query),s}function Ih(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 Oh(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var Ta=te(_t(),1);var B=(0,Ta.default)("engine.io-client:socket"),kt=class i extends L{constructor(e,t={}){super(),this.binaryType=Na,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=jt(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=jt(t.host).host),Ve(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=ao(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){B('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=_n,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 B("options: %j",r),new is[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){B("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){B("setting transport %s",e.name),this.transport&&(B("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){B('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(B('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(B('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",B('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(B("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{B('probe transport "%s" failed',e);let p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function s(){r||(r=!0,h(),t.close(),t=null)}let o=f=>{let p=new Error("probe error: "+f);p.transport=t.name,s(),B('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",p)};function c(){o("transport closed")}function l(){o("socket closed")}function u(f){t&&f.name!==t.name&&(B('"%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(B("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){B("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(B('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 B('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();B("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+=Js(n)),r>0&&t>this.maxPayload)return B("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return B("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"),B("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){B("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")&&(B('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}};kt.protocol=_n;var nm=kt.protocol;var Ua=te(Di(),1),Fa=(0,Ua.default)("socket.io-client:url");function Da(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)||(Fa("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Fa("parse %s",i),r=jt(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 us={};ac(us,{Decoder:()=>ls,Encoder:()=>cs,PacketType:()=>k,protocol:()=>Ka});var Gh=typeof ArrayBuffer=="function",Yh=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Ba=Object.prototype.toString,Jh=typeof Blob=="function"||typeof Blob!="undefined"&&Ba.call(Blob)==="[object BlobConstructor]",Xh=typeof File=="function"||typeof File!="undefined"&&Ba.call(File)==="[object FileConstructor]";function Mi(i){return Gh&&(i instanceof ArrayBuffer||Yh(i))||Jh&&i instanceof Blob||Xh&&i instanceof File}function Bi(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Bi(i[t]))return!0;return!1}if(Mi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Bi(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Bi(i[t]))return!0;return!1}function Ma(i){let e=[],t=i.data,r=i;return r.data=ss(t,e),r.attachments=e.length,{packet:r,buffers:e}}function ss(i,e){if(!i)return i;if(Mi(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]=ss(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]=ss(i[r],e));return t}return i}function qa(i,e){return i.data=os(i.data,e),delete i.attachments,i}function os(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]=os(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=os(i[t],e));return i}var $a=te(_t(),1),as=(0,$a.default)("socket.io-parser"),Qh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Ka=5,k;(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"})(k||(k={}));var cs=class{constructor(e){this.replacer=e}encode(e){return as("encoding packet %j",e),(e.type===k.EVENT||e.type===k.ACK)&&Bi(e)?this.encodeAsBinary({type:e.type===k.EVENT?k.BINARY_EVENT:k.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===k.BINARY_EVENT||e.type===k.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)),as("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Ma(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function Wa(i){return Object.prototype.toString.call(i)==="[object Object]"}var ls=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===k.BINARY_EVENT;r||t.type===k.BINARY_ACK?(t.type=r?k.EVENT:k.ACK,this.reconstructor=new hs(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Mi(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(k[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===k.BINARY_EVENT||r.type===k.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 as("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 k.CONNECT:return Wa(t);case k.DISCONNECT:return t===void 0;case k.CONNECT_ERROR:return typeof t=="string"||Wa(t);case k.EVENT:case k.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Qh.indexOf(t[0])===-1);case k.ACK:case k.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},hs=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=qa(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function de(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var za=te(Di(),1),K=(0,za.default)("socket.io-client:socket"),Zh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Gt=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=[de(e,"open",this.onopen.bind(this)),de(e,"packet",this.onpacket.bind(this)),de(e,"error",this.onerror.bind(this)),de(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(Zh.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:k.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;K("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)?K("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&&(K("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));K("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&&(K("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(K("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(K("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){K("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,K("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(){K("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:k.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){K("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 k.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 k.EVENT:case k.BINARY_EVENT:this.onevent(e);break;case k.ACK:case k.BINARY_ACK:this.onack(e);break;case k.DISCONNECT:this.ondisconnect();break;case k.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||[];K("emitting event %j",t),e.id!=null&&(K("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,K("sending ack %j",n),t.packet({type:k.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(K("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):K("bad ack %s",e.id)}onconnect(e,t){K("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(){K("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&&(K("performing disconnect (%s)",this.nsp),this.packet({type:k.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function Rt(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}Rt.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};Rt.prototype.reset=function(){this.attempts=0};Rt.prototype.setMin=function(i){this.ms=i};Rt.prototype.setMax=function(i){this.max=i};Rt.prototype.setJitter=function(i){this.jitter=i};var Va=te(Di(),1),Z=(0,Va.default)("socket.io-client:manager"),Yt=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,Ve(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Rt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||us;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(Z("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Z("opening %s",this.uri),this.engine=new kt(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=de(t,"open",function(){r.onopen(),e&&e()}),s=c=>{Z("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=de(t,"error",s);if(this._timeout!==!1){let c=this._timeout;Z("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{Z("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(){Z("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(de(e,"ping",this.onping.bind(this)),de(e,"data",this.ondata.bind(this)),de(e,"error",this.onerror.bind(this)),de(e,"close",this.onclose.bind(this)),de(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){At(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){Z("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Gt(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){Z("socket %s is still active, skipping close",r);return}this._close()}_packet(e){Z("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(){Z("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){Z("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){Z("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)Z("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();Z("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(Z("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(Z("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(Z("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 ja=te(Di(),1),Ha=(0,ja.default)("socket.io-client"),qi={};function Wi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Da(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=qi[n]&&s in qi[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Ha("ignoring socket cache for %s",r),l=new Yt(r,e)):(qi[n]||(Ha("new io instance for %s",r),qi[n]=new Yt(r,e)),l=qi[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(Wi,{Manager:Yt,Socket:Gt,io:Wi,connect:Wi});var eu="https://ws.novu.co",Ga="notifications.notification_received",Ya="notifications.unseen_count_changed",Ja="notifications.unread_count_changed",tu=({_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:p,subscriber:m,subject:x,avatar:b,cta:S,tags:T,data:N,workflow:_,severity:E})=>{var Ue,dt,se,Qe,Ze,et,Se,_e;let W={id:m==null?void 0:m._id,subscriberId:m==null?void 0:m.subscriberId,firstName:m==null?void 0:m.firstName,lastName:m==null?void 0:m.lastName,avatar:m==null?void 0:m.avatar,locale:m==null?void 0:m.locale,data:m==null?void 0:m.data,timezone:m==null?void 0:m.timezone,email:m==null?void 0:m.email,phone:m==null?void 0:m.phone},R=(dt=(Ue=S.action)==null?void 0:Ue.buttons)==null?void 0:dt.find(De=>De.type==="primary"),P=(Qe=(se=S.action)==null?void 0:se.buttons)==null?void 0:Qe.find(De=>De.type==="secondary"),z=(et=(Ze=S.action)==null?void 0:Ze.result)==null?void 0:et.type,ne=(Se=S.action)==null?void 0:Se.status;return C(y(y({id:i,transactionId:e,subject:x,body:t,to:W,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:b,primaryAction:R&&{label:R.content,isCompleted:z==="primary"&&ne==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:z==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:T,redirect:(_e=S.data)!=null&&_e.url?{url:S.data.url,target:S.data.target}:void 0,data:N,workflow:_,severity:E})},Jt,Re,pe,Xt,Zr,en,tn,Fe,Xa,fs,ds,Qr=class extends ae{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,Fe);g(this,Jt);g(this,Re);g(this,pe);g(this,Xt);g(this,Zr,({message:t})=>{a(this,Re).emit(Ga,{result:new U(tu(t),a(this,Re),this._inboxService)})});g(this,en,({unseenCount:t})=>{a(this,Re).emit(Ya,{result:t})});g(this,tn,({counts:t})=>{a(this,Re).emit(Ja,{result:t})});v(this,Re,n),v(this,Xt,t!=null?t:eu)}onSessionSuccess({token:t}){v(this,Jt,t)}isSocketEvent(t){return t===Ga||t===Ya||t===Ja}connect(){return d(this,null,function*(){return a(this,Jt)?ye(this,Fe,fs).call(this):this.callWithSession(ye(this,Fe,fs).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,pe)?ye(this,Fe,ds).call(this):this.callWithSession(ye(this,Fe,ds).bind(this))})}};Jt=new WeakMap,Re=new WeakMap,pe=new WeakMap,Xt=new WeakMap,Zr=new WeakMap,en=new WeakMap,tn=new WeakMap,Fe=new WeakSet,Xa=function(){return d(this,null,function*(){var r,n,s;if(a(this,pe))return;let t={socketUrl:a(this,Xt)};a(this,Re).emit("socket.connect.pending",{args:t}),v(this,pe,Wi(a(this,Xt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,Jt)}`}})),a(this,pe).on("connect",()=>{a(this,Re).emit("socket.connect.resolved",{args:t})}),a(this,pe).on("connect_error",o=>{a(this,Re).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,pe))==null||r.on("notification_received",a(this,Zr)),(n=a(this,pe))==null||n.on("unseen_count_changed",a(this,en)),(s=a(this,pe))==null||s.on("unread_count_changed",a(this,tn))})},fs=function(){return d(this,null,function*(){try{return yield ye(this,Fe,Xa).call(this),{}}catch(t){return{error:new w("Failed to initialize the socket",t)}}})},ds=function(){return d(this,null,function*(){var t;try{return(t=a(this,pe))==null||t.disconnect(),v(this,pe,void 0),{}}catch(r){return{error:new w("Failed to disconnect from the socket",r)}}})};var iu=["wss://eu.socket.novu.co",_i,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],ru={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":_i,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function nu(i){return i?ru[i]||i:_i}function su(i){return!i||iu.includes(i)}function Qa({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=nu(i);switch(su(r)?"partysocket":"socket.io"){case"partysocket":return new vr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new Qr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Te,ee,Xe,$i,rn=class{constructor(e){g(this,Te);g(this,ee);g(this,Xe);g(this,$i);var n,s,o;v(this,$i,e),v(this,Xe,new ji({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),v(this,Te,new Gi);let t=Os({subscriberId:e.subscriberId,subscriber:e.subscriber}),r=mn(e.context);v(this,ee,new pr({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Xe),a(this,Te))),a(this,ee).initialize(),this.notifications=new ar({useCache:(n=e.useCache)!=null?n:!0,inboxServiceInstance:a(this,Xe),eventEmitterInstance:a(this,Te)}),this.preferences=new dr({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,Xe),eventEmitterInstance:a(this,Te)}),this.subscriptions=new vi({subscriber:t,contextKey:r,useCache:(o=e.useCache)!=null?o:!0,inboxServiceInstance:a(this,Xe),eventEmitterInstance:a(this,Te)}),this.socket=Qa({socketUrl:e.socketUrl,eventEmitterInstance:a(this,Te),inboxServiceInstance:a(this,Xe)}),this.on=(c,l)=>{this.socket.isSocketEvent(c)&&this.socket.connect();let u=a(this,Te).on(c,l);return()=>{u()}},this.off=(c,l)=>{a(this,Te).off(c,l)}}get applicationIdentifier(){return a(this,ee).applicationIdentifier}get subscriberId(){return a(this,ee).subscriberId}get context(){return a(this,ee).context}get options(){return a(this,$i)}get contextKey(){return mn(a(this,ee).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return d(this,null,function*(){yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,ee).context,contextHash:a(this,ee).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return d(this,null,function*(){let t=a(this,ee).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:a(this,ee).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Te=new WeakMap,ee=new WeakMap,Xe=new WeakMap,$i=new WeakMap;window.Novu=rn;})();
37
+ `),Us=!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 vn.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new vn.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 vn.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 Ei="wss://socket.novu.co",Ms="notifications.notification_received",qs="notifications.unseen_count_changed",Ws="notifications.unread_count_changed",Ac=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:h,firstSeenDate:u,archivedAt:f,channel:m,subscriber:d,subject:w,avatar:b,cta:S,tags:T,data:N,workflow:_,severity:E})=>{var Ue,dt,se,Qe,Ze,et,Se,_e;let W={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},R=(dt=(Ue=S.action)==null?void 0:Ue.buttons)==null?void 0:dt.find(De=>De.type==="primary"),P=(Qe=(se=S.action)==null?void 0:se.buttons)==null?void 0:Qe.find(De=>De.type==="secondary"),z=(et=(Ze=S.action)==null?void 0:Ze.result)==null?void 0:et.type,ne=(Se=S.action)==null?void 0:Se.status;return C(g(g({id:i,transactionId:e,subject:w,body:t,to:W,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:h,firstSeenAt:u,archivedAt:f,avatar:b,primaryAction:R&&{label:R.content,isCompleted:z==="primary"&&ne==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:z==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:m,tags:T,redirect:(_e=S.data)!=null&&_e.url?{url:S.data.url,target:S.data.target}:void 0,data:N,workflow:_,severity:E})},Ut,xe,Ce,Dt,_i,_r,Er,wr,xr,Pe,$s,bn,Sn,Sr=class extends ae{constructor({socketUrl:t,socketOptions:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});y(this,Pe);y(this,Ut);y(this,xe);y(this,Ce);y(this,Dt);y(this,_i);y(this,_r,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,xe).emit(Ms,{result:new U(Ac(r.data.message),a(this,xe),this._inboxService)})}catch(r){console.log("error",r)}});y(this,Er,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,xe).emit(qs,{result:r.data.unseenCount})}catch(r){}});y(this,wr,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,xe).emit(Ws,{result:r.data.counts})}catch(r){}});y(this,xr,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,_r).call(this,t);break;case"unseen_count_changed":a(this,Er).call(this,t);break;case"unread_count_changed":a(this,wr).call(this,t);break;default:}}catch(r){}});v(this,xe,s),v(this,Dt,t!=null?t:Ei),v(this,_i,r)}onSessionSuccess({token:t}){v(this,Ut,t)}isSocketEvent(t){return t===Ms||t===qs||t===Ws}connect(){return p(this,null,function*(){return a(this,Ut)?ye(this,Pe,bn).call(this):this.callWithSession(ye(this,Pe,bn).bind(this))})}disconnect(){return p(this,null,function*(){return a(this,Ce)?ye(this,Pe,Sn).call(this):this.callWithSession(ye(this,Pe,Sn).bind(this))})}};Ut=new WeakMap,xe=new WeakMap,Ce=new WeakMap,Dt=new WeakMap,_i=new WeakMap,_r=new WeakMap,Er=new WeakMap,wr=new WeakMap,xr=new WeakMap,Pe=new WeakSet,$s=function(){return p(this,null,function*(){if(a(this,Ce))return;let t={socketUrl:a(this,Dt)};a(this,xe).emit("socket.connect.pending",{args:t});let r=new URL(a(this,Dt));r.searchParams.set("token",a(this,Ut)),v(this,Ce,new br(r.toString(),void 0,a(this,_i))),a(this,Ce).addEventListener("open",()=>{a(this,xe).emit("socket.connect.resolved",{args:t})}),a(this,Ce).addEventListener("error",n=>{a(this,xe).emit("socket.connect.resolved",{args:t,error:n})}),a(this,Ce).addEventListener("message",a(this,xr))})},bn=function(){return p(this,null,function*(){try{return yield ye(this,Pe,$s).call(this),{}}catch(t){return{error:new x("Failed to initialize the PartySocket",t)}}})},Sn=function(){return p(this,null,function*(){var t;try{return(t=a(this,Ce))==null||t.close(),v(this,Ce,void 0),{}}catch(r){return{error:new x("Failed to disconnect from the PartySocket",r)}}})};var Ne=Object.create(null);Ne.open="0";Ne.close="1";Ne.ping="2";Ne.pong="3";Ne.message="4";Ne.upgrade="5";Ne.noop="6";var wi=Object.create(null);Object.keys(Ne).forEach(i=>{wi[Ne[i]]=i});var xi={type:"error",data:"parser error"};var Ci=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Ks(e,!0).toString("base64")):r(Ne[i]+(e||"")),Ks=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),_n;function zs(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Ks(i.data,!1));Ci(i,!0,t=>{_n||(_n=new TextEncoder),e(_n.encode(t))})}var Ni=(i,e)=>{if(typeof i!="string")return{type:"message",data:Vs(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Vs(r,e)}}return wi[t]?i.length>1?{type:wi[t],data:i.substring(1)}:{type:wi[t]}:xi},Vs=(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 Hs="",Gs=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Ci(s,!1,c=>{r[o]=c,++n===t&&e(r.join(Hs))})})},js=(i,e)=>{let t=i.split(Hs),r=[];for(let n=0;n<t.length;n++){let s=Ni(t[n],e);if(r.push(s),s.type==="error")break}return r};function Ys(){return new TransformStream({transform(i,e){zs(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 En;function Cr(i){return i.reduce((e,t)=>e+t.length,0)}function Nr(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 Js(i,e){En||(En=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(Cr(t)<1)break;let l=Nr(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(Cr(t)<2)break;let l=Nr(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Cr(t)<8)break;let l=Nr(t,8),h=new DataView(l.buffer,l.byteOffset,l.length),u=h.getUint32(0);if(u>Math.pow(2,21)-1){c.enqueue(xi);break}n=u*Math.pow(2,32)+h.getUint32(4),r=3}else{if(Cr(t)<n)break;let l=Nr(t,n);c.enqueue(Ni(s?l:En.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(xi);break}}}})}var wn=4;function L(i){if(i)return Rc(i)}function Rc(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 ke=global;function kr(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var Tc=ke.setTimeout,Ic=ke.clearTimeout;function Ve(i,e){e.useNativeTimers?(i.setTimeoutFn=Tc.bind(ke),i.clearTimeoutFn=Ic.bind(ke)):(i.setTimeoutFn=ke.setTimeout.bind(ke),i.clearTimeoutFn=ke.clearTimeout.bind(ke))}var Oc=1.33;function Xs(i){return typeof i=="string"?Pc(i):Math.ceil((i.byteLength||i.size)*Oc)}function Pc(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 lo=te(_t(),1);function ao(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function co(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 il=(0,lo.default)("engine.io-client:transport"),Tn=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},He=class extends L{constructor(e){super(),this.writable=!1,Ve(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Tn(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):il("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Ni(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=ao(e);return t.length?"?"+t:""}};var So=te(_t(),1);var po="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),In=64,rl={},uo=0,Or=0,ho;function fo(i){let e="";do e=po[i%In]+e,i=Math.floor(i/In);while(i>0);return e}function Pr(){let i=fo(+new Date);return i!==ho?(uo=0,ho=i):i+"."+fo(uo++)}for(;Or<In;Or++)rl[po[Or]]=Or;var Ln=te(go(),1),Fn=Ln.default||Ln;function vo(){return new Pn}function sl(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(),h=c[1].trim();switch(l){case"Expires":s.expires=new Date(h);break;case"Max-Age":let u=new Date;u.setUTCSeconds(u.getUTCSeconds()+parseInt(h,10)),s.expires=u;break;default:}}return s}var Pn=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=sl(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 ce=(0,So.default)("engine.io-client:polling");function ol(){}var al=function(){return new Fn({xdomain:!1}).responseType!=null}(),Lr=class extends He{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=al&&!t,this.opts.withCredentials&&(this.cookieJar=vo())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{ce("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(ce("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){ce("pre-pause polling complete"),--r||t()})),this.writable||(ce("we are currently writing - waiting to pause"),r++,this.once("drain",function(){ce("pre-pause writing complete"),--r||t()}))}else t()}poll(){ce("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){ce("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)};js(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():ce('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{ce("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(ce("transport open - closing"),e()):(ce("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Gs(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]=Pr()),!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 ut(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(){ce("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}},ut=class i extends L{constructor(e,t){super(),Ve(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=kr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Fn(t);try{ce("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))},ce("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=ol,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()}};ut.requestsCount=0;ut.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",bo);else if(typeof addEventListener=="function"){let i="onpagehide"in ke?"pagehide":"unload";addEventListener(i,bo,!1)}}function bo(){for(let i in ut.requests)ut.requests.hasOwnProperty(i)&&ut.requests[i].abort()}var Nu=te(xo(),1),ku=te(Hn(),1),Au=te(Yn(),1),Ca=te(is(),1),Ru=te(xa(),1);var Na=Ca.default;var Ui=Na,jr=!1,ka="nodebuffer",kt=process.nextTick;var Ra=te(_t(),1);var Tu=(0,Ra.default)("engine.io-client:websocket"),Aa=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Yr=class extends He{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=Aa?{}:kr(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=jr&&!Aa?t?new Ui(e,t):new Ui(e):new Ui(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;Ci(r,this.supportsBinary,s=>{let o={};jr||(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{jr?this.ws.send(s):this.ws.send(s,o)}catch(c){Tu("websocket closed before onclose event")}n&&kt(()=>{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]=Pr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Ui}};var Ta=te(_t(),1),Di=(0,Ta.default)("engine.io-client:webtransport"),Jr=class extends He{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Di("transport closed gracefully"),this.onClose()}).catch(e=>{Di("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Js(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Ys();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){Di("session is closed");return}Di("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{Di("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&&kt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var ns={websocket:Yr,webtransport:Jr,polling:Lr};var Iu=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ou=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Gt(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=Iu.exec(i||""),s={},o=14;for(;o--;)s[Ou[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=Pu(s,s.path),s.queryKey=Lu(s,s.query),s}function Pu(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 Lu(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var Ia=te(_t(),1);var B=(0,Ia.default)("engine.io-client:socket"),At=class i extends L{constructor(e,t={}){super(),this.binaryType=ka,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Gt(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=Gt(t.host).host),Ve(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=co(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){B('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=wn,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 B("options: %j",r),new ns[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){B("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){B("setting transport %s",e.name),this.transport&&(B("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){B('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(B('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(B('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",B('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(B("changing transport and sending upgrade packet"),u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{B('probe transport "%s" failed',e);let m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function s(){r||(r=!0,u(),t.close(),t=null)}let o=f=>{let m=new Error("probe error: "+f);m.transport=t.name,s(),B('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",m)};function c(){o("transport closed")}function l(){o("socket closed")}function h(f){t&&f.name!==t.name&&(B('"%s" works - aborting "%s"',f.name,t.name),s())}let u=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",h)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",h),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(B("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){B("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(B('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 B('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();B("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+=Xs(n)),r>0&&t>this.maxPayload)return B("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return B("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"),B("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){B("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")&&(B('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}};At.protocol=wn;var om=At.protocol;var Da=te(Bi(),1),Ua=(0,Da.default)("socket.io-client:url");function Ba(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)||(Ua("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Ua("parse %s",i),r=Gt(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 ds={};cc(ds,{Decoder:()=>hs,Encoder:()=>us,PacketType:()=>A,protocol:()=>za});var Ju=typeof ArrayBuffer=="function",Xu=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Ma=Object.prototype.toString,Qu=typeof Blob=="function"||typeof Blob!="undefined"&&Ma.call(Blob)==="[object BlobConstructor]",Zu=typeof File=="function"||typeof File!="undefined"&&Ma.call(File)==="[object FileConstructor]";function qi(i){return Ju&&(i instanceof ArrayBuffer||Xu(i))||Qu&&i instanceof Blob||Zu&&i instanceof File}function Mi(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Mi(i[t]))return!0;return!1}if(qi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Mi(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Mi(i[t]))return!0;return!1}function qa(i){let e=[],t=i.data,r=i;return r.data=as(t,e),r.attachments=e.length,{packet:r,buffers:e}}function as(i,e){if(!i)return i;if(qi(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]=as(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]=as(i[r],e));return t}return i}function Wa(i,e){return i.data=cs(i.data,e),delete i.attachments,i}function cs(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]=cs(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=cs(i[t],e));return i}var Ka=te(_t(),1),ls=(0,Ka.default)("socket.io-parser"),eh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],za=5,A;(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"})(A||(A={}));var us=class{constructor(e){this.replacer=e}encode(e){return ls("encoding packet %j",e),(e.type===A.EVENT||e.type===A.ACK)&&Mi(e)?this.encodeAsBinary({type:e.type===A.EVENT?A.BINARY_EVENT:A.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===A.BINARY_EVENT||e.type===A.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)),ls("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=qa(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function $a(i){return Object.prototype.toString.call(i)==="[object Object]"}var hs=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===A.BINARY_EVENT;r||t.type===A.BINARY_ACK?(t.type=r?A.EVENT:A.ACK,this.reconstructor=new fs(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(qi(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(A[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===A.BINARY_EVENT||r.type===A.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 ls("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 A.CONNECT:return $a(t);case A.DISCONNECT:return t===void 0;case A.CONNECT_ERROR:return typeof t=="string"||$a(t);case A.EVENT:case A.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&eh.indexOf(t[0])===-1);case A.ACK:case A.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},fs=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=Wa(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function de(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Va=te(Bi(),1),K=(0,Va.default)("socket.io-client:socket"),th=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),jt=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=[de(e,"open",this.onopen.bind(this)),de(e,"packet",this.onpacket.bind(this)),de(e,"error",this.onerror.bind(this)),de(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(th.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:A.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;K("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)?K("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&&(K("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));K("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&&(K("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(K("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(K("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){K("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,K("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(){K("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:A.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){K("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 A.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 A.EVENT:case A.BINARY_EVENT:this.onevent(e);break;case A.ACK:case A.BINARY_ACK:this.onack(e);break;case A.DISCONNECT:this.ondisconnect();break;case A.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||[];K("emitting event %j",t),e.id!=null&&(K("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,K("sending ack %j",n),t.packet({type:A.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(K("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):K("bad ack %s",e.id)}onconnect(e,t){K("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(){K("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&&(K("performing disconnect (%s)",this.nsp),this.packet({type:A.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function Rt(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}Rt.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};Rt.prototype.reset=function(){this.attempts=0};Rt.prototype.setMin=function(i){this.ms=i};Rt.prototype.setMax=function(i){this.max=i};Rt.prototype.setJitter=function(i){this.jitter=i};var Ha=te(Bi(),1),Z=(0,Ha.default)("socket.io-client:manager"),Yt=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,Ve(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Rt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||ds;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(Z("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Z("opening %s",this.uri),this.engine=new At(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=de(t,"open",function(){r.onopen(),e&&e()}),s=c=>{Z("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=de(t,"error",s);if(this._timeout!==!1){let c=this._timeout;Z("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{Z("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(){Z("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(de(e,"ping",this.onping.bind(this)),de(e,"data",this.ondata.bind(this)),de(e,"error",this.onerror.bind(this)),de(e,"close",this.onclose.bind(this)),de(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){kt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){Z("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new jt(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){Z("socket %s is still active, skipping close",r);return}this._close()}_packet(e){Z("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(){Z("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){Z("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){Z("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)Z("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();Z("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(Z("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(Z("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(Z("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 ja=te(Bi(),1),Ga=(0,ja.default)("socket.io-client"),Wi={};function $i(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Ba(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=Wi[n]&&s in Wi[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Ga("ignoring socket cache for %s",r),l=new Yt(r,e)):(Wi[n]||(Ga("new io instance for %s",r),Wi[n]=new Yt(r,e)),l=Wi[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign($i,{Manager:Yt,Socket:jt,io:$i,connect:$i});var ih="https://ws.novu.co",Ya="notifications.notification_received",Ja="notifications.unseen_count_changed",Xa="notifications.unread_count_changed",rh=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:h,firstSeenDate:u,archivedAt:f,channel:m,subscriber:d,subject:w,avatar:b,cta:S,tags:T,data:N,workflow:_,severity:E})=>{var Ue,dt,se,Qe,Ze,et,Se,_e;let W={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},R=(dt=(Ue=S.action)==null?void 0:Ue.buttons)==null?void 0:dt.find(De=>De.type==="primary"),P=(Qe=(se=S.action)==null?void 0:se.buttons)==null?void 0:Qe.find(De=>De.type==="secondary"),z=(et=(Ze=S.action)==null?void 0:Ze.result)==null?void 0:et.type,ne=(Se=S.action)==null?void 0:Se.status;return C(g(g({id:i,transactionId:e,subject:w,body:t,to:W,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:h,firstSeenAt:u,archivedAt:f,avatar:b,primaryAction:R&&{label:R.content,isCompleted:z==="primary"&&ne==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:z==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:m,tags:T,redirect:(_e=S.data)!=null&&_e.url?{url:S.data.url,target:S.data.target}:void 0,data:N,workflow:_,severity:E})},Jt,Re,pe,Xt,Ki,tn,rn,nn,Fe,Qa,ps,ms,en=class extends ae{constructor({socketUrl:t,socketOptions:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});y(this,Fe);y(this,Jt);y(this,Re);y(this,pe);y(this,Xt);y(this,Ki);y(this,tn,({message:t})=>{a(this,Re).emit(Ya,{result:new U(rh(t),a(this,Re),this._inboxService)})});y(this,rn,({unseenCount:t})=>{a(this,Re).emit(Ja,{result:t})});y(this,nn,({counts:t})=>{a(this,Re).emit(Xa,{result:t})});v(this,Re,s),v(this,Xt,t!=null?t:ih),v(this,Ki,r)}onSessionSuccess({token:t}){v(this,Jt,t)}isSocketEvent(t){return t===Ya||t===Ja||t===Xa}connect(){return p(this,null,function*(){return a(this,Jt)?ye(this,Fe,ps).call(this):this.callWithSession(ye(this,Fe,ps).bind(this))})}disconnect(){return p(this,null,function*(){return a(this,pe)?ye(this,Fe,ms).call(this):this.callWithSession(ye(this,Fe,ms).bind(this))})}};Jt=new WeakMap,Re=new WeakMap,pe=new WeakMap,Xt=new WeakMap,Ki=new WeakMap,tn=new WeakMap,rn=new WeakMap,nn=new WeakMap,Fe=new WeakSet,Qa=function(){return p(this,null,function*(){var r,n,s,o;if(a(this,pe))return;let t={socketUrl:a(this,Xt)};a(this,Re).emit("socket.connect.pending",{args:t}),v(this,pe,$i(a(this,Xt),g({reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,Jt)}`}},(r=a(this,Ki))!=null?r:{}))),a(this,pe).on("connect",()=>{a(this,Re).emit("socket.connect.resolved",{args:t})}),a(this,pe).on("connect_error",c=>{a(this,Re).emit("socket.connect.resolved",{args:t,error:c})}),(n=a(this,pe))==null||n.on("notification_received",a(this,tn)),(s=a(this,pe))==null||s.on("unseen_count_changed",a(this,rn)),(o=a(this,pe))==null||o.on("unread_count_changed",a(this,nn))})},ps=function(){return p(this,null,function*(){try{return yield ye(this,Fe,Qa).call(this),{}}catch(t){return{error:new x("Failed to initialize the socket",t)}}})},ms=function(){return p(this,null,function*(){var t;try{return(t=a(this,pe))==null||t.disconnect(),v(this,pe,void 0),{}}catch(r){return{error:new x("Failed to disconnect from the socket",r)}}})};var nh=["wss://eu.socket.novu.co",Ei,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],sh={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Ei,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function oh(i){return i?sh[i]||i:Ei}function ah(i){return!i||nh.includes(i)}function Za({socketUrl:i,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:r}){let n=oh(i);switch(ah(n)?"partysocket":"socket.io"){case"partysocket":return new Sr({socketUrl:n,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:r});case"socket.io":default:return new en({socketUrl:n,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:r})}}var Te,ee,Xe,zi,sn=class{constructor(e){y(this,Te);y(this,ee);y(this,Xe);y(this,zi);var n,s,o;v(this,zi,e),v(this,Xe,new Yi({apiUrl:e.apiUrl||e.backendUrl})),v(this,Te,new Ji);let t=Ps({subscriberId:e.subscriberId,subscriber:e.subscriber}),r=gn(e.context);v(this,ee,new yr({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Xe),a(this,Te))),a(this,ee).initialize(),this.notifications=new lr({useCache:(n=e.useCache)!=null?n:!0,inboxServiceInstance:a(this,Xe),eventEmitterInstance:a(this,Te)}),this.preferences=new mr({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,Xe),eventEmitterInstance:a(this,Te)}),this.subscriptions=new vi({subscriber:t,contextKey:r,useCache:(o=e.useCache)!=null?o:!0,inboxServiceInstance:a(this,Xe),eventEmitterInstance:a(this,Te)}),this.socket=Za({socketUrl:e.socketUrl,socketOptions:e.socketOptions,eventEmitterInstance:a(this,Te),inboxServiceInstance:a(this,Xe)}),this.on=(c,l)=>{this.socket.isSocketEvent(c)&&this.socket.connect();let h=a(this,Te).on(c,l);return()=>{h()}},this.off=(c,l)=>{a(this,Te).off(c,l)}}get applicationIdentifier(){return a(this,ee).applicationIdentifier}get subscriberId(){return a(this,ee).subscriberId}get context(){return a(this,ee).context}get options(){return a(this,zi)}get contextKey(){return gn(a(this,ee).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return p(this,null,function*(){yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,ee).context,contextHash:a(this,ee).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return p(this,null,function*(){let t=a(this,ee).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:a(this,ee).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Te=new WeakMap,ee=new WeakMap,Xe=new WeakMap,zi=new WeakMap;window.Novu=sn;})();
38
38
  /*! Bundled license information:
39
39
 
40
40
  xmlhttprequest-ssl/lib/XMLHttpRequest.js: