@novu/js 3.15.0 → 3.16.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,23 +1,23 @@
1
- "use strict";(()=>{var Uc=Object.create;var nr=Object.defineProperty,Dc=Object.defineProperties,Bc=Object.getOwnPropertyDescriptor,Mc=Object.getOwnPropertyDescriptors,qc=Object.getOwnPropertyNames,rr=Object.getOwnPropertySymbols,Wc=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty,Us=Object.prototype.propertyIsEnumerable;var Ds=i=>{throw TypeError(i)},Bs=Math.pow,xn=(i,e,t)=>e in i?nr(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,g=(i,e)=>{for(var t in e||(e={}))Nn.call(e,t)&&xn(i,t,e[t]);if(rr)for(var t of rr(e))Us.call(e,t)&&xn(i,t,e[t]);return i},C=(i,e)=>Dc(i,Mc(e));var O=(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 ui=(i,e)=>{var t={};for(var r in i)Nn.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&rr)for(var r of rr(i))e.indexOf(r)<0&&Us.call(i,r)&&(t[r]=i[r]);return t};var I=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),$c=(i,e)=>{for(var t in e)nr(i,t,{get:e[t],enumerable:!0})},Kc=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qc(e))!Nn.call(i,n)&&n!==t&&nr(i,n,{get:()=>e[n],enumerable:!(r=Bc(e,n))||r.enumerable});return i};var V=(i,e,t)=>(t=i!=null?Uc(Wc(i)):{},Kc(e||!i||!i.__esModule?nr(t,"default",{value:i,enumerable:!0}):t,i));var F=(i,e,t)=>xn(i,typeof e!="symbol"?e+"":e,t),An=(i,e,t)=>e.has(i)||Ds("Cannot "+t);var a=(i,e,t)=>(An(i,e,"read from private field"),t?t.call(i):e.get(i)),v=(i,e,t)=>e.has(i)?Ds("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(An(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Se=(i,e,t)=>(An(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=u=>{try{c(t.next(u))}catch(h){n(h)}},o=u=>{try{c(t.throw(u))}catch(h){n(h)}},c=u=>u.done?r(u.value):Promise.resolve(u.value).then(s,o);c((t=t.apply(i,e)).next())});var Wn=I((sm,Co)=>{"use strict";var Kt=1e3,zt=Kt*60,Vt=zt*60,xt=Vt*24,yl=xt*7,gl=xt*365.25;Co.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return vl(i);if(t==="number"&&isFinite(i))return e.long?Sl(i):bl(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function vl(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*gl;case"weeks":case"week":case"w":return t*yl;case"days":case"day":case"d":return t*xt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Vt;case"minutes":case"minute":case"mins":case"min":case"m":return t*zt;case"seconds":case"second":case"secs":case"sec":case"s":return t*Kt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function bl(i){var e=Math.abs(i);return e>=xt?Math.round(i/xt)+"d":e>=Vt?Math.round(i/Vt)+"h":e>=zt?Math.round(i/zt)+"m":e>=Kt?Math.round(i/Kt)+"s":i+"ms"}function Sl(i){var e=Math.abs(i);return e>=xt?qr(i,e,xt,"day"):e>=Vt?qr(i,e,Vt,"hour"):e>=zt?qr(i,e,zt,"minute"):e>=Kt?qr(i,e,Kt,"second"):i+" ms"}function qr(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var $n=I((om,xo)=>{"use strict";function _l(i){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Wn(),t.destroy=h,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let p=0;p<l.length;p++)f=(f<<5)-f+l.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,p=null,d,w;function y(...b){if(!y.enabled)return;let k=y,N=Number(new Date),_=N-(f||N);k.diff=_,k.prev=f,k.curr=N,f=N,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let E=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let te=b[E];R=$.call(k,te),b.splice(E,1),E--}return R}),t.formatArgs.call(k,b),(k.log||t.log).apply(k,b)}return y.namespace=l,y.useColors=t.useColors(),y.color=t.selectColor(l),y.extend=r,y.destroy=t.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==t.namespaces&&(d=t.namespaces,w=t.enabled(l)),w),set:b=>{p=b}}),typeof t.init=="function"&&t.init(y),y}function r(l,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+l);return p.log=this.log,p}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,p=(typeof l=="string"?l:"").split(/[\s,]+/),d=p.length;for(f=0;f<d;f++)p[f]&&(l=p[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(l))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}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}xo.exports=_l});var No=I((pe,Wr)=>{"use strict";pe.formatArgs=wl;pe.save=Cl;pe.load=xl;pe.useColors=El;pe.storage=Nl();pe.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`."))}})();pe.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 El(){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 wl(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Wr.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)}pe.log=console.debug||console.log||(()=>{});function Cl(i){try{i?pe.storage.setItem("debug",i):pe.storage.removeItem("debug")}catch(e){}}function xl(){let i;try{i=pe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Nl(){try{return localStorage}catch(i){}}Wr.exports=$n()(pe);var{formatters:Al}=Wr.exports;Al.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Kn=I((am,Ao)=>{"use strict";Ao.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 jn=I((cm,Ro)=>{"use strict";var kl=O("os"),ko=O("tty"),_e=Kn(),{env:Y}=process,pt;_e("no-color")||_e("no-colors")||_e("color=false")||_e("color=never")?pt=0:(_e("color")||_e("colors")||_e("color=true")||_e("color=always"))&&(pt=1);"FORCE_COLOR"in Y&&(Y.FORCE_COLOR==="true"?pt=1:Y.FORCE_COLOR==="false"?pt=0:pt=Y.FORCE_COLOR.length===0?1:Math.min(parseInt(Y.FORCE_COLOR,10),3));function zn(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Vn(i,e){if(pt===0)return 0;if(_e("color=16m")||_e("color=full")||_e("color=truecolor"))return 3;if(_e("color=256"))return 2;if(i&&!e&&pt===void 0)return 0;let t=pt||0;if(Y.TERM==="dumb")return t;if(process.platform==="win32"){let r=kl.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in Y)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in Y)||Y.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in Y)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Y.TEAMCITY_VERSION)?1:0;if(Y.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Y){let r=parseInt((Y.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Y.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Y.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Y.TERM)||"COLORTERM"in Y?1:t}function Rl(i){let e=Vn(i,i&&i.isTTY);return zn(e)}Ro.exports={supportsColor:Rl,stdout:zn(Vn(!0,ko.isatty(1))),stderr:zn(Vn(!0,ko.isatty(2)))}});var Oo=I((J,Kr)=>{"use strict";var Tl=O("tty"),$r=O("util");J.init=Dl;J.log=Fl;J.formatArgs=Il;J.save=Ll;J.load=Ul;J.useColors=Ol;J.destroy=$r.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=jn();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 Ol(){return"colors"in J.inspectOpts?!!J.inspectOpts.colors:Tl.isatty(process.stderr.fd)}function Il(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 Yc=Object.create;var an=Object.defineProperty,Jc=Object.defineProperties,Xc=Object.getOwnPropertyDescriptor,Qc=Object.getOwnPropertyDescriptors,Zc=Object.getOwnPropertyNames,on=Object.getOwnPropertySymbols,el=Object.getPrototypeOf,Tr=Object.prototype.hasOwnProperty,qs=Object.prototype.propertyIsEnumerable;var Ws=i=>{throw TypeError(i)},$s=Math.pow,Rr=(i,e,t)=>e in i?an(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,y=(i,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&Rr(i,t,e[t]);if(on)for(var t of on(e))qs.call(e,t)&&Rr(i,t,e[t]);return i},x=(i,e)=>Jc(i,Qc(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 ui=(i,e)=>{var t={};for(var n in i)Tr.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&on)for(var n of on(i))e.indexOf(n)<0&&qs.call(i,n)&&(t[n]=i[n]);return t};var O=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),tl=(i,e)=>{for(var t in e)an(i,t,{get:e[t],enumerable:!0})},il=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Zc(e))!Tr.call(i,r)&&r!==t&&an(i,r,{get:()=>e[r],enumerable:!(n=Xc(e,r))||n.enumerable});return i};var G=(i,e,t)=>(t=i!=null?Yc(el(i)):{},il(e||!i||!i.__esModule?an(t,"default",{value:i,enumerable:!0}):t,i));var F=(i,e,t)=>Rr(i,typeof e!="symbol"?e+"":e,t),Ir=(i,e,t)=>e.has(i)||Ws("Cannot "+t);var a=(i,e,t)=>(Ir(i,e,"read from private field"),t?t.call(i):e.get(i)),v=(i,e,t)=>e.has(i)?Ws("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,n)=>(Ir(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t),_e=(i,e,t)=>(Ir(i,e,"access private method"),t);var p=(i,e,t)=>new Promise((n,r)=>{var s=u=>{try{c(t.next(u))}catch(h){r(h)}},o=u=>{try{c(t.throw(u))}catch(h){r(h)}},c=u=>u.done?n(u.value):Promise.resolve(u.value).then(s,o);c((t=t.apply(i,e)).next())});var Gr=O((Bm,Do)=>{"use strict";var Kt=1e3,zt=Kt*60,Gt=zt*60,xt=Gt*24,Tl=xt*7,Il=xt*365.25;Do.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return Ol(i);if(t==="number"&&isFinite(i))return e.long?Fl(i):Pl(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function Ol(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]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Il;case"weeks":case"week":case"w":return t*Tl;case"days":case"day":case"d":return t*xt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Gt;case"minutes":case"minute":case"mins":case"min":case"m":return t*zt;case"seconds":case"second":case"secs":case"sec":case"s":return t*Kt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Pl(i){var e=Math.abs(i);return e>=xt?Math.round(i/xt)+"d":e>=Gt?Math.round(i/Gt)+"h":e>=zt?Math.round(i/zt)+"m":e>=Kt?Math.round(i/Kt)+"s":i+"ms"}function Fl(i){var e=Math.abs(i);return e>=xt?Gn(i,e,xt,"day"):e>=Gt?Gn(i,e,Gt,"hour"):e>=zt?Gn(i,e,zt,"minute"):e>=Kt?Gn(i,e,Kt,"second"):i+" ms"}function Gn(i,e,t,n){var r=e>=t*1.5;return Math.round(i/t)+" "+n+(r?"s":"")}});var Vr=O((Mm,Bo)=>{"use strict";function Ll(i){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=r,t.enabled=o,t.humanize=Gr(),t.destroy=h,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,d,C;function g(...b){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let E=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(T,P)=>{if(T==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let ie=b[E];T=$.call(R,ie),b.splice(E,1),E--}return T}),t.formatArgs.call(R,b),(R.log||t.log).apply(R,b)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=n,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(d!==t.namespaces&&(d=t.namespaces,C=t.enabled(l)),C),set:b=>{m=b}}),typeof t.init=="function"&&t.init(g),g}function n(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),d=m.length;for(f=0;f<d;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}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}Bo.exports=Ll});var Mo=O((pe,Vn)=>{"use strict";pe.formatArgs=Dl;pe.save=Bl;pe.load=Ml;pe.useColors=Ul;pe.storage=ql();pe.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`."))}})();pe.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 Ul(){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 Dl(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Vn.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,n=0;i[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(n=t))}),i.splice(n,0,e)}pe.log=console.debug||console.log||(()=>{});function Bl(i){try{i?pe.storage.setItem("debug",i):pe.storage.removeItem("debug")}catch(e){}}function Ml(){let i;try{i=pe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function ql(){try{return localStorage}catch(i){}}Vn.exports=Vr()(pe);var{formatters:Wl}=Vn.exports;Wl.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var jr=O((qm,qo)=>{"use strict";qo.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",n=e.indexOf(t+i),r=e.indexOf("--");return n!==-1&&(r===-1||n<r)}});var Jr=O((Wm,$o)=>{"use strict";var $l=I("os"),Wo=I("tty"),Ee=jr(),{env:J}=process,pt;Ee("no-color")||Ee("no-colors")||Ee("color=false")||Ee("color=never")?pt=0:(Ee("color")||Ee("colors")||Ee("color=true")||Ee("color=always"))&&(pt=1);"FORCE_COLOR"in J&&(J.FORCE_COLOR==="true"?pt=1:J.FORCE_COLOR==="false"?pt=0:pt=J.FORCE_COLOR.length===0?1:Math.min(parseInt(J.FORCE_COLOR,10),3));function Hr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Yr(i,e){if(pt===0)return 0;if(Ee("color=16m")||Ee("color=full")||Ee("color=truecolor"))return 3;if(Ee("color=256"))return 2;if(i&&!e&&pt===void 0)return 0;let t=pt||0;if(J.TERM==="dumb")return t;if(process.platform==="win32"){let n=$l.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in J)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n 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 n=parseInt((J.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(J.TERM_PROGRAM){case"iTerm.app":return n>=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 Kl(i){let e=Yr(i,i&&i.isTTY);return Hr(e)}$o.exports={supportsColor:Kl,stdout:Hr(Yr(!0,Wo.isatty(1))),stderr:Hr(Yr(!0,Wo.isatty(2)))}});var zo=O((X,Hn)=>{"use strict";var zl=I("tty"),jn=I("util");X.init=Xl;X.log=Hl;X.formatArgs=Vl;X.save=Yl;X.load=Jl;X.useColors=Gl;X.destroy=jn.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");X.colors=[6,2,3,4,5,1];try{let i=Jr();i&&(i.stderr||i).level>=2&&(X.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){}X.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),n=process.env[e];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),i[t]=n,i},{});function Gl(){return"colors"in X.inspectOpts?!!X.inspectOpts.colors:zl.isatty(process.stderr.fd)}function Vl(i){let{namespace:e,useColors:t}=this;if(t){let n=this.color,r="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${r};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
2
2
  `).join(`
3
- `+s),i.push(n+"m+"+Kr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Pl()+e+" "+i[0]}function Pl(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Fl(...i){return process.stderr.write($r.formatWithOptions(J.inspectOpts,...i)+`
4
- `)}function Ll(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Ul(){return process.env.DEBUG}function Dl(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]]}Kr.exports=$n()(J);var{formatters:To}=Kr.exports;To.o=function(i){return this.inspectOpts.colors=this.useColors,$r.inspect(i,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};To.O=function(i){return this.inspectOpts.colors=this.useColors,$r.inspect(i,this.inspectOpts)}});var jt=I((lm,Gn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Gn.exports=No():Gn.exports=Oo()});var Wo=I((gm,qo)=>{"use strict";var Gt=O("fs"),Mo=O("url"),ql=O("child_process").spawn;qo.exports=Jn;Jn.XMLHttpRequest=Jn;function Jn(i){"use strict";i=i||{};var e=this,t=O("http"),r=O("https"),n,s,o={},c=!1,u={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},h=Object.assign({},u),l=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],f=["TRACE","TRACK","CONNECT"],p=!1,d=!1,w=!1,y={};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 b=function(_){return c||_&&l.indexOf(_.toLowerCase())===-1},k=function(_){return _&&f.indexOf(_)===-1};this.open=function(_,E,M,R,P){if(this.abort(),d=!1,w=!1,!k(_))throw new Error("SecurityError: Request method not allowed");o={method:_,url:E.toString(),async:typeof M!="boolean"?!0:M,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(!b(_))return console.warn('Refused to set unsafe header "'+_+'"'),!1;if(p)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(p)throw new Error("INVALID_STATE_ERR: send has already been called");var E=!1,M=!1,R=Mo.parse(o.url),P;switch(R.protocol){case"https:":E=!0;case"http:":P=R.hostname;break;case"file:":M=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(M){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Gt.readFile(unescape(R.pathname),"utf8",function(be,Lt){be?e.handleError(be,be.errno||-1):(e.status=200,e.responseText=Lt,N(e.DONE))});else try{this.responseText=Gt.readFileSync(unescape(R.pathname),"utf8"),this.status=200,N(e.DONE)}catch(be){this.handleError(be,be.errno||-1)}return}var $=R.port||(E?443:80),te=R.pathname+(R.search?R.search:"");if(h.Host=P,E&&$===443||$===80||(h.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var We=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+We.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 vt=i.agent||!1,ce={host:P,port:$,path:te,method:o.method,headers:h,agent:vt};if(E&&(ce.pfx=i.pfx,ce.key=i.key,ce.passphrase=i.passphrase,ce.cert=i.cert,ce.ca=i.ca,ce.ciphers=i.ciphers,ce.rejectUnauthorized=i.rejectUnauthorized!==!1),d=!1,o.async){var rt=E?r.request:t.request;p=!0,e.dispatchEvent("readystatechange");var nt=function(be){if(s=be,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Lt=Mo.parse(o.url);P=Lt.hostname;var ot={hostname:Lt.hostname,port:Lt.port,path:Lt.path,method:s.statusCode===303?"GET":o.method,headers:h};E&&(ot.pfx=i.pfx,ot.key=i.key,ot.passphrase=i.passphrase,ot.cert=i.cert,ot.ca=i.ca,ot.ciphers=i.ciphers,ot.rejectUnauthorized=i.rejectUnauthorized!==!1),n=rt(ot,nt).on("error",st),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(ir){ir&&(e.responseText+=ir),p&&N(e.LOADING)}),s.on("end",function(){p&&(p=!1,N(e.DONE))}),s.on("error",function(ir){e.handleError(ir)})},st=function(be){e.handleError(be)};n=rt(ce,nt).on("error",st),i.autoUnref&&n.on("socket",be=>{be.unref()}),_&&n.write(_),n.end(),e.dispatchEvent("loadstart")}else{var xe=".node-xmlhttprequest-content-"+process.pid,Ne=".node-xmlhttprequest-sync-"+process.pid;Gt.writeFileSync(Ne,"","utf8");for(var $e="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"s":"")+".request;var options = "+JSON.stringify(ce)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+xe+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+Ne+"');});response.on('error', function(error) {fs.writeFileSync('"+xe+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});}).on('error', function(error) {fs.writeFileSync('"+xe+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});"+(_?"req.write('"+JSON.stringify(_).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Fc=ql(process.argv[0],["-e",$e]),Cf;Gt.existsSync(Ne););if(e.responseText=Gt.readFileSync(xe,"utf8"),Fc.stdin.end(),Gt.unlinkSync(xe),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var Lc=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(Lc,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({},u),this.responseText="",this.responseXML="",d=w=!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 y||(y[_]=[]),y[_].push(E)},this.removeEventListener=function(_,E){_ in y&&(y[_]=y[_].filter(function(M){return M!==E}))},this.dispatchEvent=function(_){if(typeof e["on"+_]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+_]()}):e["on"+_]()),_ in y)for(let E=0,M=y[_].length;E<M;E++)this.readyState===this.DONE?setImmediate(function(){y[_][E].call(e)}):y[_][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 Qe=I((Am,Go)=>{"use strict";var Vo=["nodebuffer","arraybuffer","fragments"],jo=typeof Blob!="undefined";jo&&Vo.push("blob");Go.exports={BINARY_TYPES:Vo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:jo,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var qi=I((km,Gr)=>{"use strict";var{EMPTY_BUFFER:zl}=Qe(),es=Buffer[Symbol.species];function Vl(i,e){if(i.length===0)return zl;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 es(t.buffer,t.byteOffset,r):t}function Ho(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function Yo(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function jl(i){return i.length===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.length)}function ts(i){if(ts.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=new es(i):ArrayBuffer.isView(i)?e=new es(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),ts.readOnly=!1),e}Gr.exports={concat:Vl,mask:Ho,toArrayBuffer:jl,toBuffer:ts,unmask:Yo};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=O("bufferutil");Gr.exports.mask=function(e,t,r,n,s){s<48?Ho(e,t,r,n,s):i.mask(e,t,r,n,s)},Gr.exports.unmask=function(e,t){e.length<32?Yo(e,t):i.unmask(e,t)}}catch(i){}});var Qo=I((Rm,Xo)=>{"use strict";var Jo=Symbol("kDone"),is=Symbol("kRun"),rs=class{constructor(e){this[Jo]=()=>{this.pending--,this[is]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[is]()}[is](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Jo])}}};Xo.exports=rs});var Jt=I((Tm,ia)=>{"use strict";var Wi=O("zlib"),Zo=qi(),Gl=Qo(),{kStatusCode:ea}=Qe(),Hl=Buffer[Symbol.species],Yl=Buffer.from([0,0,255,255]),Yr=Symbol("permessage-deflate"),Ze=Symbol("total-length"),Ht=Symbol("callback"),yt=Symbol("buffers"),Yt=Symbol("error"),Hr,ns=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Hr){let t=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Hr=new Gl(t)}}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[Ht];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){Hr.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Hr.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"?Wi.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Wi.createInflateRaw(C(g({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Yr]=this,this._inflate[Ze]=0,this._inflate[yt]=[],this._inflate.on("error",Xl),this._inflate.on("data",ta)}this._inflate[Ht]=r,this._inflate.write(e),t&&this._inflate.write(Yl),this._inflate.flush(()=>{let s=this._inflate[Yt];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Zo.concat(this._inflate[yt],this._inflate[Ze]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ze]=0,this._inflate[yt]=[],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"?Wi.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Wi.createDeflateRaw(C(g({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ze]=0,this._deflate[yt]=[],this._deflate.on("data",Jl)}this._deflate[Ht]=r,this._deflate.write(e),this._deflate.flush(Wi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Zo.concat(this._deflate[yt],this._deflate[Ze]);t&&(s=new Hl(s.buffer,s.byteOffset,s.length-4)),this._deflate[Ht]=null,this._deflate[Ze]=0,this._deflate[yt]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};ia.exports=ns;function Jl(i){this[yt].push(i),this[Ze]+=i.length}function ta(i){if(this[Ze]+=i.length,this[Yr]._maxPayload<1||this[Ze]<=this[Yr]._maxPayload){this[yt].push(i);return}this[Yt]=new RangeError("Max payload size exceeded"),this[Yt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Yt][ea]=1009,this.removeListener("data",ta),this.reset()}function Xl(i){if(this[Yr]._inflate=null,this[Yt]){this[Ht](this[Yt]);return}i[ea]=1007,this[Ht](i)}});var Xt=I((Im,Jr)=>{"use strict";var{isUtf8:ra}=O("buffer"),{hasBlob:Ql}=Qe(),Zl=[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 eu(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function ss(i){let e=i.length,t=0;for(;t<e;)if((i[t]&128)===0)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 tu(i){return Ql&&typeof i=="object"&&typeof i.arrayBuffer=="function"&&typeof i.type=="string"&&typeof i.stream=="function"&&(i[Symbol.toStringTag]==="Blob"||i[Symbol.toStringTag]==="File")}Jr.exports={isBlob:tu,isValidStatusCode:eu,isValidUTF8:ss,tokenChars:Zl};if(ra)Jr.exports.isValidUTF8=function(i){return i.length<24?ss(i):ra(i)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=O("utf-8-validate");Jr.exports.isValidUTF8=function(e){return e.length<32?ss(e):i(e)}}catch(i){}});var us=I((Pm,ua)=>{"use strict";var{Writable:iu}=O("stream"),na=Jt(),{BINARY_TYPES:ru,EMPTY_BUFFER:sa,kStatusCode:nu,kWebSocket:su}=Qe(),{concat:os,toArrayBuffer:ou,unmask:au}=qi(),{isValidStatusCode:cu,isValidUTF8:oa}=Xt(),Xr=Buffer[Symbol.species],Ee=0,aa=1,ca=2,la=3,as=4,cs=5,Qr=6,ls=class extends iu{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ru[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[su]=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=Ee}_write(e,t,r){if(this._opcode===8&&this._state==Ee)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 Xr(r.buffer,r.byteOffset+e,r.length-e),new Xr(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 Xr(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 Ee:this.getInfo(e);break;case aa:this.getPayloadLength16(e);break;case ca:this.getPayloadLength64(e);break;case la:this.getMask();break;case as:this.getData(e);break;case cs:case Qr: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)!==0){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[na.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=aa:this._payloadLength===127?this._state=ca: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=la:this._state=as}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=as}getData(e){let t=sa;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])!==0&&au(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=cs,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[na.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===Ee&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=Ee;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=os(r,t):this._binaryType==="arraybuffer"?n=ou(os(r,t)):this._binaryType==="blob"?n=new Blob(r):n=r,this._allowSynchronousEvents?(this.emit("message",n,!0),this._state=Ee):(this._state=Qr,setImmediate(()=>{this.emit("message",n,!0),this._state=Ee,this.startLoop(e)}))}else{let n=os(r,t);if(!this._skipUTF8Validation&&!oa(n)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===cs||this._allowSynchronousEvents?(this.emit("message",n,!1),this._state=Ee):(this._state=Qr,setImmediate(()=>{this.emit("message",n,!1),this._state=Ee,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,sa),this.end();else{let r=e.readUInt16BE(0);if(!cu(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let n=new Xr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!oa(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=Ee;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Ee):(this._state=Qr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Ee,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[nu]=n,o}};ua.exports=ls});var ds=I((Lm,da)=>{"use strict";var{Duplex:Fm}=O("stream"),{randomFillSync:lu}=O("crypto"),ha=Jt(),{EMPTY_BUFFER:uu,kWebSocket:hu,NOOP:fu}=Qe(),{isBlob:Qt,isValidStatusCode:du}=Xt(),{mask:fa,toBuffer:Nt}=qi(),we=Symbol("kByteLength"),pu=Buffer.alloc(4),Zr=8*1024,At,Zt=Zr,Pe=0,mu=1,yu=2,hs=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=Pe,this.onerror=fu,this[hu]=void 0}static frame(e,t){let r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||pu,t.generateMask?t.generateMask(r):(Zt===Zr&&(At===void 0&&(At=Buffer.alloc(Zr)),lu(At,0,Zr),Zt=0),r[0]=At[Zt++],r[1]=At[Zt++],r[2]=At[Zt++],r[3]=At[Zt++]),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[we]!==void 0?c=t[we]:(e=Buffer.from(e),c=e.length):(c=e.length,n=t.mask&&t.readOnly&&!o);let u=c;c>=65536?(s+=8,u=127):c>125&&(s+=2,u=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]=u,u===126?h.writeUInt16BE(c,2):u===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?(fa(e,r,h,s,c),[h]):(fa(e,r,e,0,c),[h,e])):[h,e]}close(e,t,r,n){let s;if(e===void 0)s=uu;else{if(typeof e!="number"||!du(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={[we]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Pe?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):Qt(e)?(n=e.size,s=!1):(e=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[we]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Qt(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==Pe?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):Qt(e)?(n=e.size,s=!1):(e=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[we]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Qt(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==Pe?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[ha.extensionName],s=t.binary?2:1,o=t.compress,c,u;typeof e=="string"?(c=Buffer.byteLength(e),u=!1):Qt(e)?(c=e.size,u=!1):(e=Nt(e),c=e.length,u=Nt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0);let h={[we]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:u,rsv1:o};Qt(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,this._compress,h,r]):this.getBlobData(e,this._compress,h,r):this._state!==Pe?this.enqueue([this.dispatch,e,this._compress,h,r]):this.dispatch(e,this._compress,h,r)}getBlobData(e,t,r,n){this._bufferedBytes+=r[we],this._state=yu,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(fs,this,c,n);return}this._bufferedBytes-=r[we];let o=Nt(s);t?this.dispatch(o,t,r,n):(this._state=Pe,this.sendFrame(i.frame(o,r),n),this.dequeue())}).catch(s=>{process.nextTick(gu,this,s,n)})}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[ha.extensionName];this._bufferedBytes+=r[we],this._state=mu,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");fs(this,u,n);return}this._bufferedBytes-=r[we],this._state=Pe,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;this._state===Pe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][we],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][we],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)}};da.exports=hs;function fs(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 gu(i,e,t){fs(i,e,t),i.onerror(e)}});var Ea=I((Um,_a)=>{"use strict";var{kForOnEventAttribute:$i,kListener:ps}=Qe(),pa=Symbol("kCode"),ma=Symbol("kData"),ya=Symbol("kError"),ga=Symbol("kMessage"),va=Symbol("kReason"),ei=Symbol("kTarget"),ba=Symbol("kType"),Sa=Symbol("kWasClean"),et=class{constructor(e){this[ei]=null,this[ba]=e}get target(){return this[ei]}get type(){return this[ba]}};Object.defineProperty(et.prototype,"target",{enumerable:!0});Object.defineProperty(et.prototype,"type",{enumerable:!0});var kt=class extends et{constructor(e,t={}){super(e),this[pa]=t.code===void 0?0:t.code,this[va]=t.reason===void 0?"":t.reason,this[Sa]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[pa]}get reason(){return this[va]}get wasClean(){return this[Sa]}};Object.defineProperty(kt.prototype,"code",{enumerable:!0});Object.defineProperty(kt.prototype,"reason",{enumerable:!0});Object.defineProperty(kt.prototype,"wasClean",{enumerable:!0});var ti=class extends et{constructor(e,t={}){super(e),this[ya]=t.error===void 0?null:t.error,this[ga]=t.message===void 0?"":t.message}get error(){return this[ya]}get message(){return this[ga]}};Object.defineProperty(ti.prototype,"error",{enumerable:!0});Object.defineProperty(ti.prototype,"message",{enumerable:!0});var Ki=class extends et{constructor(e,t={}){super(e),this[ma]=t.data===void 0?null:t.data}get data(){return this[ma]}};Object.defineProperty(Ki.prototype,"data",{enumerable:!0});var vu={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[$i]&&n[ps]===e&&!n[$i])return;let r;if(i==="message")r=function(s,o){let c=new Ki("message",{data:o?s:s.toString()});c[ei]=this,en(e,this,c)};else if(i==="close")r=function(s,o){let c=new kt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[ei]=this,en(e,this,c)};else if(i==="error")r=function(s){let o=new ti("error",{error:s,message:s.message});o[ei]=this,en(e,this,o)};else if(i==="open")r=function(){let s=new et("open");s[ei]=this,en(e,this,s)};else return;r[$i]=!!t[$i],r[ps]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[ps]===e&&!t[$i]){this.removeListener(i,t);break}}};_a.exports={CloseEvent:kt,ErrorEvent:ti,Event:et,EventTarget:vu,MessageEvent:Ki};function en(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var tn=I((Dm,wa)=>{"use strict";var{tokenChars:zi}=Xt();function Me(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function bu(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,u=-1,h=-1,l=-1,f=0;for(;f<i.length;f++)if(h=i.charCodeAt(f),o===void 0)if(l===-1&&zi[h]===1)u===-1&&(u=f);else if(f!==0&&(h===32||h===9))l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=i.slice(u,l);h===44?(Me(e,d,t),t=Object.create(null)):o=d,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(l===-1&&zi[h]===1)u===-1&&(u=f);else if(h===32||h===9)l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),Me(t,i.slice(u,l),!0),h===44&&(Me(e,o,t),t=Object.create(null),o=void 0),u=l=-1}else if(h===61&&u!==-1&&l===-1)c=i.slice(u,f),u=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(zi[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1?u=f:r||(r=!0),n=!1}else if(s)if(zi[h]===1)u===-1&&(u=f);else if(h===34&&u!==-1)s=!1,l=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(l===-1&&zi[h]===1)u===-1&&(u=f);else if(u!==-1&&(h===32||h===9))l===-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=i.slice(u,l);r&&(d=d.replace(/\\/g,""),r=!1),Me(t,c,d),h===44&&(Me(e,o,t),t=Object.create(null),o=void 0),c=void 0,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(u===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let p=i.slice(u,l);return o===void 0?Me(e,p,t):(c===void 0?Me(t,p,!0):r?Me(t,c,p.replace(/\\/g,"")):Me(t,c,p),Me(e,o,t)),e}function Su(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(", ")}wa.exports={format:Su,parse:bu}});var on=I((qm,La)=>{"use strict";var _u=O("events"),Eu=O("https"),wu=O("http"),Na=O("net"),Cu=O("tls"),{randomBytes:xu,createHash:Nu}=O("crypto"),{Duplex:Bm,Readable:Mm}=O("stream"),{URL:ms}=O("url"),gt=Jt(),Au=us(),ku=ds(),{isBlob:Ru}=Xt(),{BINARY_TYPES:Ca,CLOSE_TIMEOUT:Tu,EMPTY_BUFFER:rn,GUID:Ou,kForOnEventAttribute:ys,kListener:Iu,kStatusCode:Pu,kWebSocket:X,NOOP:Aa}=Qe(),{EventTarget:{addEventListener:Fu,removeEventListener:Lu}}=Ea(),{format:Uu,parse:Du}=tn(),{toBuffer:Bu}=qi(),ka=Symbol("kAborted"),gs=[8,13],tt=["CONNECTING","OPEN","CLOSING","CLOSED"],Mu=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,D=class i extends _u{constructor(e,t,r){super(),this._binaryType=Ca[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=rn,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]),Ra(this,e,t,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ca.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 Au({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new ku(e,this._extensions,r.generateMask);this._receiver=n,this._sender=s,this._socket=e,n[X]=this,s[X]=this,e[X]=this,n.on("conclude",$u),n.on("drain",Ku),n.on("error",zu),n.on("message",Vu),n.on("ping",ju),n.on("pong",Gu),s.onerror=Hu,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Ia),e.on("data",sn),e.on("end",Pa),e.on("error",Fa),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[gt.extensionName]&&this._extensions[gt.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){me(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())}),Oa(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){vs(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||rn,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){vs(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||rn,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){vs(this,e,r);return}let n=g({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[gt.extensionName]||(n.compress=!1),this._sender.send(e||rn,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING){me(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:tt.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:tt.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:tt.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:tt.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:tt.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:tt.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:tt.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:tt.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[ys])return e[Iu];return null},set(e){for(let t of this.listeners(i))if(t[ys]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[ys]:!0})}})});D.prototype.addEventListener=Fu;D.prototype.removeEventListener=Lu;La.exports=D;function Ra(i,e,t,r){let n=C(g({allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Tu,protocolVersion:gs[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,i._closeTimeout=n.closeTimeout,!gs.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${gs.join(", ")})`);let s;if(e instanceof ms)s=e;else try{s=new ms(e)}catch(y){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:",u;if(s.protocol!=="ws:"&&!o&&!c?u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?u="The URL's pathname is empty":s.hash&&(u="The URL contains a fragment identifier"),u){let y=new SyntaxError(u);if(i._redirects===0)throw y;nn(i,y);return}let h=o?443:80,l=xu(16).toString("base64"),f=o?Eu.request:wu.request,p=new Set,d;if(n.createConnection=n.createConnection||(o?Wu:qu),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":l,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(d=new gt(C(g({},n.perMessageDeflate),{isServer:!1,maxPayload:n.maxPayload})),n.headers["Sec-WebSocket-Extensions"]=Uu({[gt.extensionName]:d.offer()})),t.length){for(let y of t){if(typeof y!="string"||!Mu.test(y)||p.has(y))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(y)}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 y=n.path.split(":");n.socketPath=y[0],n.path=y[1]}let w;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let y=r&&r.headers;if(r=C(g({},r),{headers:{}}),y)for(let[b,k]of Object.entries(y))r.headers[b.toLowerCase()]=k}else if(i.listenerCount("redirect")===0){let y=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!y||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,y||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",()=>{me(i,w,"Opening handshake has timed out")}),w.on("error",y=>{w===null||w[ka]||(w=i._req=null,nn(i,y))}),w.on("response",y=>{let b=y.headers.location,k=y.statusCode;if(b&&n.followRedirects&&k>=300&&k<400){if(++i._redirects>n.maxRedirects){me(i,w,"Maximum redirects exceeded");return}w.abort();let N;try{N=new ms(b,e)}catch(_){let E=new SyntaxError(`Invalid URL: ${b}`);nn(i,E);return}Ra(i,N,t,r)}else i.emit("unexpected-response",w,y)||me(i,w,`Unexpected server response: ${y.statusCode}`)}),w.on("upgrade",(y,b,k)=>{if(i.emit("upgrade",y),i.readyState!==D.CONNECTING)return;w=i._req=null;let N=y.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){me(i,b,"Invalid Upgrade header");return}let _=Nu("sha1").update(l+Ou).digest("base64");if(y.headers["sec-websocket-accept"]!==_){me(i,b,"Invalid Sec-WebSocket-Accept header");return}let E=y.headers["sec-websocket-protocol"],M;if(E!==void 0?p.size?p.has(E)||(M="Server sent an invalid subprotocol"):M="Server sent a subprotocol but none was requested":p.size&&(M="Server sent no subprotocol"),M){me(i,b,M);return}E&&(i._protocol=E);let R=y.headers["sec-websocket-extensions"];if(R!==void 0){if(!d){me(i,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=Du(R)}catch(te){me(i,b,"Invalid Sec-WebSocket-Extensions header");return}let $=Object.keys(P);if($.length!==1||$[0]!==gt.extensionName){me(i,b,"Server indicated an extension that was not requested");return}try{d.accept(P[gt.extensionName])}catch(te){me(i,b,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[gt.extensionName]=d}i.setSocket(b,k,{allowSynchronousEvents:n.allowSynchronousEvents,generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),n.finishRequest?n.finishRequest(w,i):w.end()}function nn(i,e){i._readyState=D.CLOSING,i._errorEmitted=!0,i.emit("error",e),i.emitClose()}function qu(i){return i.path=i.socketPath,Na.connect(i)}function Wu(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Na.isIP(i.host)?"":i.host),Cu.connect(i)}function me(i,e,t){i._readyState=D.CLOSING;let r=new Error(t);Error.captureStackTrace(r,me),e.setHeader?(e[ka]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(nn,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function vs(i,e,t){if(e){let r=Ru(e)?e.size:Bu(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${tt[i.readyState]})`);process.nextTick(t,r)}}function $u(i,e){let t=this[X];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[X]!==void 0&&(t._socket.removeListener("data",sn),process.nextTick(Ta,t._socket),i===1005?t.close():t.close(i,e))}function Ku(){let i=this[X];i.isPaused||i._socket.resume()}function zu(i){let e=this[X];e._socket[X]!==void 0&&(e._socket.removeListener("data",sn),process.nextTick(Ta,e._socket),e.close(i[Pu])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i))}function xa(){this[X].emitClose()}function Vu(i,e){this[X].emit("message",i,e)}function ju(i){let e=this[X];e._autoPong&&e.pong(i,!this._isServer,Aa),e.emit("ping",i)}function Gu(i){this[X].emit("pong",i)}function Ta(i){i.resume()}function Hu(i){let e=this[X];e.readyState!==D.CLOSED&&(e.readyState===D.OPEN&&(e._readyState=D.CLOSING,Oa(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i)))}function Oa(i){i._closeTimer=setTimeout(i._socket.destroy.bind(i._socket),i._closeTimeout)}function Ia(){let i=this[X];if(this.removeListener("close",Ia),this.removeListener("data",sn),this.removeListener("end",Pa),i._readyState=D.CLOSING,!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);i._receiver.write(e)}i._receiver.end(),this[X]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",xa),i._receiver.on("finish",xa))}function sn(i){this[X]._receiver.write(i)||this.pause()}function Pa(){let i=this[X];i._readyState=D.CLOSING,i._receiver.end(),this.end()}function Fa(){let i=this[X];this.removeListener("error",Fa),this.on("error",Aa),i&&(i._readyState=D.CLOSING,this.destroy())}});var Ma=I((Km,Ba)=>{"use strict";var $m=on(),{Duplex:Yu}=O("stream");function Ua(i){i.emit("close")}function Ju(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Da(i){this.removeListener("error",Da),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Xu(i,e){let t=!0,r=new Yu(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(Ua,r);return}let o=!1;i.once("error",function(u){o=!0,s(u)}),i.once("close",function(){o||s(n),process.nextTick(Ua,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",Ju),r.on("error",Da),r}Ba.exports=Xu});var bs=I((Vm,qa)=>{"use strict";var{tokenChars:Qu}=Xt();function Zu(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&&Qu[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}qa.exports={parse:Zu}});var Ga=I((Gm,ja)=>{"use strict";var eh=O("events"),an=O("http"),{Duplex:jm}=O("stream"),{createHash:th}=O("crypto"),Wa=tn(),Rt=Jt(),ih=bs(),rh=on(),{CLOSE_TIMEOUT:nh,GUID:sh,kWebSocket:oh}=Qe(),ah=/^[+/0-9A-Za-z]{22}==$/,$a=0,Ka=1,Va=2,Ss=class extends eh{constructor(e,t){if(super(),e=g({allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:nh,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:rh},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=an.createServer((r,n)=>{let s=an.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=ch(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=$a}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===Va){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Vi,this);return}if(e&&this.once("close",e),this._state!==Ka)if(this._state=Ka,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(Vi,this):process.nextTick(Vi,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Vi(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",za);let s=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Tt(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Tt(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!ah.test(s)){Tt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){Tt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ji(t,400);return}let u=e.headers["sec-websocket-protocol"],h=new Set;if(u!==void 0)try{h=ih.parse(u)}catch(p){Tt(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&l!==void 0){let p=new Rt(C(g({},this.options.perMessageDeflate),{isServer:!0,maxPayload:this.options.maxPayload}));try{let d=Wa.parse(l);d[Rt.extensionName]&&(p.accept(d[Rt.extensionName]),f[Rt.extensionName]=p)}catch(d){Tt(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,(d,w,y,b)=>{if(!d)return ji(t,w||401,y,b);this.completeUpgrade(f,s,h,e,t,r,n)});return}if(!this.options.verifyClient(p))return ji(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[oh])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>$a)return ji(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${th("sha1").update(t+sh).digest("base64")}`],l=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}`),l._protocol=f)}if(e[Rt.extensionName]){let f=e[Rt.extensionName].params,p=Wa.format({[Rt.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${p}`),l._extensions=e}this.emit("headers",h,n),s.write(h.concat(`\r
3
+ `+s),i.push(r+"m+"+Hn.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=jl()+e+" "+i[0]}function jl(){return X.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Hl(...i){return process.stderr.write(jn.formatWithOptions(X.inspectOpts,...i)+`
4
+ `)}function Yl(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Jl(){return process.env.DEBUG}function Xl(i){i.inspectOpts={};let e=Object.keys(X.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=X.inspectOpts[e[t]]}Hn.exports=Vr()(X);var{formatters:Ko}=Hn.exports;Ko.o=function(i){return this.inspectOpts.colors=this.useColors,jn.inspect(i,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(" ")};Ko.O=function(i){return this.inspectOpts.colors=this.useColors,jn.inspect(i,this.inspectOpts)}});var Vt=O(($m,Xr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Xr.exports=Mo():Xr.exports=zo()});var ea=O((Jm,Zo)=>{"use strict";var jt=I("fs"),Qo=I("url"),eu=I("child_process").spawn;Zo.exports=es;es.XMLHttpRequest=es;function es(i){"use strict";i=i||{};var e=this,t=I("http"),n=I("https"),r,s,o={},c=!1,u={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},h=Object.assign({},u),l=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],f=["TRACE","TRACK","CONNECT"],m=!1,d=!1,C=!1,g={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var b=function(_){return c||_&&l.indexOf(_.toLowerCase())===-1},R=function(_){return _&&f.indexOf(_)===-1};this.open=function(_,E,M,T,P){if(this.abort(),d=!1,C=!1,!R(_))throw new Error("SecurityError: Request method not allowed");o={method:_,url:E.toString(),async:typeof M!="boolean"?!0:M,user:T||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(!b(_))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,M=!1,T=Qo.parse(o.url),P;switch(T.protocol){case"https:":E=!0;case"http:":P=T.hostname;break;case"file:":M=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(M){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)jt.readFile(unescape(T.pathname),"utf8",function(Se,Lt){Se?e.handleError(Se,Se.errno||-1):(e.status=200,e.responseText=Lt,N(e.DONE))});else try{this.responseText=jt.readFileSync(unescape(T.pathname),"utf8"),this.status=200,N(e.DONE)}catch(Se){this.handleError(Se,Se.errno||-1)}return}var $=T.port||(E?443:80),ie=T.pathname+(T.search?T.search:"");if(h.Host=P,E&&$===443||$===80||(h.Host+=":"+T.port),o.user){typeof o.password=="undefined"&&(o.password="");var $e=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+$e.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 vt=i.agent||!1,ue={host:P,port:$,path:ie,method:o.method,headers:h,agent:vt};if(E&&(ue.pfx=i.pfx,ue.key=i.key,ue.passphrase=i.passphrase,ue.cert=i.cert,ue.ca=i.ca,ue.ciphers=i.ciphers,ue.rejectUnauthorized=i.rejectUnauthorized!==!1),d=!1,o.async){var nt=E?n.request:t.request;m=!0,e.dispatchEvent("readystatechange");var rt=function(Se){if(s=Se,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Lt=Qo.parse(o.url);P=Lt.hostname;var ot={hostname:Lt.hostname,port:Lt.port,path:Lt.path,method:s.statusCode===303?"GET":o.method,headers:h};E&&(ot.pfx=i.pfx,ot.key=i.key,ot.passphrase=i.passphrase,ot.cert=i.cert,ot.ca=i.ca,ot.ciphers=i.ciphers,ot.rejectUnauthorized=i.rejectUnauthorized!==!1),r=nt(ot,rt).on("error",st),r.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(sn){sn&&(e.responseText+=sn),m&&N(e.LOADING)}),s.on("end",function(){m&&(m=!1,N(e.DONE))}),s.on("error",function(sn){e.handleError(sn)})},st=function(Se){e.handleError(Se)};r=nt(ue,rt).on("error",st),i.autoUnref&&r.on("socket",Se=>{Se.unref()}),_&&r.write(_),r.end(),e.dispatchEvent("loadstart")}else{var Ae=".node-xmlhttprequest-content-"+process.pid,Ne=".node-xmlhttprequest-sync-"+process.pid;jt.writeFileSync(Ne,"","utf8");for(var Ke="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"s":"")+".request;var options = "+JSON.stringify(ue)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+Ne+"');});response.on('error', function(error) {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});}).on('error', function(error) {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});"+(_?"req.write('"+JSON.stringify(_).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",jc=eu(process.argv[0],["-e",Ke]),Bf;jt.existsSync(Ne););if(e.responseText=jt.readFileSync(Ae,"utf8"),jc.stdin.end(),jt.unlinkSync(Ae),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var Hc=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(Hc,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(){r&&(r.abort(),r=null),h=Object.assign({},u),this.responseText="",this.responseXML="",d=C=!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 g||(g[_]=[]),g[_].push(E)},this.removeEventListener=function(_,E){_ in g&&(g[_]=g[_].filter(function(M){return M!==E}))},this.dispatchEvent=function(_){if(typeof e["on"+_]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+_]()}):e["on"+_]()),_ in g)for(let E=0,M=g[_].length;E<M;E++)this.readyState===this.DONE?setImmediate(function(){g[_][E].call(e)}):g[_][E].call(e)};var N=function(_){if(!(e.readyState===_||e.readyState===e.UNSENT&&C)&&(e.readyState=_,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let E;C?E="abort":d?E="error":E="load",e.dispatchEvent(E),e.dispatchEvent("loadend")}}}});var Ze=O((og,oa)=>{"use strict";var ra=["nodebuffer","arraybuffer","fragments"],sa=typeof Blob!="undefined";sa&&ra.push("blob");oa.exports={BINARY_TYPES:ra,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:sa,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var $i=O((ag,Qn)=>{"use strict";var{EMPTY_BUFFER:ru}=Ze(),rs=Buffer[Symbol.species];function su(i,e){if(i.length===0)return ru;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),n=0;for(let r=0;r<i.length;r++){let s=i[r];t.set(s,n),n+=s.length}return n<e?new rs(t.buffer,t.byteOffset,n):t}function aa(i,e,t,n,r){for(let s=0;s<r;s++)t[n+s]=i[s]^e[s&3]}function ca(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function ou(i){return i.length===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.length)}function ss(i){if(ss.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=new rs(i):ArrayBuffer.isView(i)?e=new rs(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),ss.readOnly=!1),e}Qn.exports={concat:su,mask:aa,toArrayBuffer:ou,toBuffer:ss,unmask:ca};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=I("bufferutil");Qn.exports.mask=function(e,t,n,r,s){s<48?aa(e,t,n,r,s):i.mask(e,t,n,r,s)},Qn.exports.unmask=function(e,t){e.length<32?ca(e,t):i.unmask(e,t)}}catch(i){}});var ha=O((cg,ua)=>{"use strict";var la=Symbol("kDone"),os=Symbol("kRun"),as=class{constructor(e){this[la]=()=>{this.pending--,this[os]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[os]()}[os](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[la])}}};ua.exports=as});var Jt=O((lg,ma)=>{"use strict";var Ki=I("zlib"),fa=$i(),au=ha(),{kStatusCode:da}=Ze(),cu=Buffer[Symbol.species],lu=Buffer.from([0,0,255,255]),er=Symbol("permessage-deflate"),et=Symbol("total-length"),Ht=Symbol("callback"),gt=Symbol("buffers"),Yt=Symbol("error"),Zn,cs=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Zn){let t=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Zn=new au(t)}}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[Ht];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,n=e.find(r=>!(t.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>r.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}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(n=>{let r=t[n];if(r.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(r=r[0],n==="client_max_window_bits"){if(r!==!0){let s=+r;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${r}`);r=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${r}`)}else if(n==="server_max_window_bits"){let s=+r;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${r}`);r=s}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${r}`)}else throw new Error(`Unknown parameter "${n}"`);t[n]=r})}),e}decompress(e,t,n){Zn.add(r=>{this._decompress(e,t,(s,o)=>{r(),n(s,o)})})}compress(e,t,n){Zn.add(r=>{this._compress(e,t,(s,o)=>{r(),n(s,o)})})}_decompress(e,t,n){let r=this._isServer?"client":"server";if(!this._inflate){let s=`${r}_max_window_bits`,o=typeof this.params[s]!="number"?Ki.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ki.createInflateRaw(x(y({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[er]=this,this._inflate[et]=0,this._inflate[gt]=[],this._inflate.on("error",hu),this._inflate.on("data",pa)}this._inflate[Ht]=n,this._inflate.write(e),t&&this._inflate.write(lu),this._inflate.flush(()=>{let s=this._inflate[Yt];if(s){this._inflate.close(),this._inflate=null,n(s);return}let o=fa.concat(this._inflate[gt],this._inflate[et]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[et]=0,this._inflate[gt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(e,t,n){let r=this._isServer?"server":"client";if(!this._deflate){let s=`${r}_max_window_bits`,o=typeof this.params[s]!="number"?Ki.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ki.createDeflateRaw(x(y({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[et]=0,this._deflate[gt]=[],this._deflate.on("data",uu)}this._deflate[Ht]=n,this._deflate.write(e),this._deflate.flush(Ki.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=fa.concat(this._deflate[gt],this._deflate[et]);t&&(s=new cu(s.buffer,s.byteOffset,s.length-4)),this._deflate[Ht]=null,this._deflate[et]=0,this._deflate[gt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),n(null,s)})}};ma.exports=cs;function uu(i){this[gt].push(i),this[et]+=i.length}function pa(i){if(this[et]+=i.length,this[er]._maxPayload<1||this[et]<=this[er]._maxPayload){this[gt].push(i);return}this[Yt]=new RangeError("Max payload size exceeded"),this[Yt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Yt][da]=1009,this.removeListener("data",pa),this.reset()}function hu(i){if(this[er]._inflate=null,this[Yt]){this[Ht](this[Yt]);return}i[da]=1007,this[Ht](i)}});var Xt=O((hg,tr)=>{"use strict";var{isUtf8:ga}=I("buffer"),{hasBlob:fu}=Ze(),du=[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 pu(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function ls(i){let e=i.length,t=0;for(;t<e;)if((i[t]&128)===0)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 mu(i){return fu&&typeof i=="object"&&typeof i.arrayBuffer=="function"&&typeof i.type=="string"&&typeof i.stream=="function"&&(i[Symbol.toStringTag]==="Blob"||i[Symbol.toStringTag]==="File")}tr.exports={isBlob:mu,isValidStatusCode:pu,isValidUTF8:ls,tokenChars:du};if(ga)tr.exports.isValidUTF8=function(i){return i.length<24?ls(i):ga(i)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=I("utf-8-validate");tr.exports.isValidUTF8=function(e){return e.length<32?ls(e):i(e)}}catch(i){}});var ps=O((fg,Ca)=>{"use strict";var{Writable:gu}=I("stream"),ya=Jt(),{BINARY_TYPES:yu,EMPTY_BUFFER:va,kStatusCode:vu,kWebSocket:bu}=Ze(),{concat:us,toArrayBuffer:Su,unmask:_u}=$i(),{isValidStatusCode:Eu,isValidUTF8:ba}=Xt(),ir=Buffer[Symbol.species],Ce=0,Sa=1,_a=2,Ea=3,hs=4,fs=5,nr=6,ds=class extends gu{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||yu[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[bu]=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=Ce}_write(e,t,n){if(this._opcode===8&&this._state==Ce)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new ir(n.buffer,n.byteOffset+e,n.length-e),new ir(n.buffer,n.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new ir(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case Ce:this.getInfo(e);break;case Sa:this.getPayloadLength16(e);break;case _a:this.getPayloadLength64(e);break;case Ea:this.getMask();break;case hs:this.getData(e);break;case fs:case nr: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)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(r);return}let n=(t[0]&64)===64;if(n&&!this._extensions[ya.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(r);return}if(n){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(r);return}this._payloadLength===126?this._state=Sa:this._payloadLength===127?this._state=_a: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),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(r);return}this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=Ea:this._state=hs}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=hs}getData(e){let t=va;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])!==0&&_u(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=fs,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[ya.extensionName].decompress(e,this._fin,(r,s)=>{if(r)return t(r);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===Ce&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=Ce;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=us(n,t):this._binaryType==="arraybuffer"?r=Su(us(n,t)):this._binaryType==="blob"?r=new Blob(n):r=n,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=Ce):(this._state=nr,setImmediate(()=>{this.emit("message",r,!0),this._state=Ce,this.startLoop(e)}))}else{let r=us(n,t);if(!this._skipUTF8Validation&&!ba(r)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===fs||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=Ce):(this._state=nr,setImmediate(()=>{this.emit("message",r,!1),this._state=Ce,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,va),this.end();else{let n=e.readUInt16BE(0);if(!Eu(n)){let s=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let r=new ir(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ba(r)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",n,r),this.end()}this._state=Ce;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Ce):(this._state=nr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Ce,this.startLoop(t)}))}createError(e,t,n,r,s){this._loop=!1,this._errored=!0;let o=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=s,o[vu]=r,o}};Ca.exports=ds});var ys=O((pg,Aa)=>{"use strict";var{Duplex:dg}=I("stream"),{randomFillSync:Cu}=I("crypto"),wa=Jt(),{EMPTY_BUFFER:wu,kWebSocket:xu,NOOP:Au}=Ze(),{isBlob:Qt,isValidStatusCode:Nu}=Xt(),{mask:xa,toBuffer:At}=$i(),we=Symbol("kByteLength"),ku=Buffer.alloc(4),rr=8*1024,Nt,Zt=rr,Fe=0,Ru=1,Tu=2,ms=class i{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Fe,this.onerror=Au,this[xu]=void 0}static frame(e,t){let n,r=!1,s=2,o=!1;t.mask&&(n=t.maskBuffer||ku,t.generateMask?t.generateMask(n):(Zt===rr&&(Nt===void 0&&(Nt=Buffer.alloc(rr)),Cu(Nt,0,rr),Zt=0),n[0]=Nt[Zt++],n[1]=Nt[Zt++],n[2]=Nt[Zt++],n[3]=Nt[Zt++]),o=(n[0]|n[1]|n[2]|n[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[we]!==void 0?c=t[we]:(e=Buffer.from(e),c=e.length):(c=e.length,r=t.mask&&t.readOnly&&!o);let u=c;c>=65536?(s+=8,u=127):c>125&&(s+=2,u=126);let h=Buffer.allocUnsafe(r?c+s:s);return h[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(h[0]|=64),h[1]=u,u===126?h.writeUInt16BE(c,2):u===127&&(h[2]=h[3]=0,h.writeUIntBE(c,4,6)),t.mask?(h[1]|=128,h[s-4]=n[0],h[s-3]=n[1],h[s-2]=n[2],h[s-1]=n[3],o?[h,e]:r?(xa(e,n,h,s,c),[h]):(xa(e,n,e,0,c),[h,e])):[h,e]}close(e,t,n,r){let s;if(e===void 0)s=wu;else{if(typeof e!="number"||!Nu(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={[we]:s.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Fe?this.enqueue([this.dispatch,s,!1,o,r]):this.sendFrame(i.frame(s,o),r)}ping(e,t,n){let r,s;if(typeof e=="string"?(r=Buffer.byteLength(e),s=!1):Qt(e)?(r=e.size,s=!1):(e=At(e),r=e.length,s=At.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[we]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Qt(e)?this._state!==Fe?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==Fe?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(i.frame(e,o),n)}pong(e,t,n){let r,s;if(typeof e=="string"?(r=Buffer.byteLength(e),s=!1):Qt(e)?(r=e.size,s=!1):(e=At(e),r=e.length,s=At.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[we]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Qt(e)?this._state!==Fe?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==Fe?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(i.frame(e,o),n)}send(e,t,n){let r=this._extensions[wa.extensionName],s=t.binary?2:1,o=t.compress,c,u;typeof e=="string"?(c=Buffer.byteLength(e),u=!1):Qt(e)?(c=e.size,u=!1):(e=At(e),c=e.length,u=At.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=r._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0);let h={[we]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:u,rsv1:o};Qt(e)?this._state!==Fe?this.enqueue([this.getBlobData,e,this._compress,h,n]):this.getBlobData(e,this._compress,h,n):this._state!==Fe?this.enqueue([this.dispatch,e,this._compress,h,n]):this.dispatch(e,this._compress,h,n)}getBlobData(e,t,n,r){this._bufferedBytes+=n[we],this._state=Tu,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(gs,this,c,r);return}this._bufferedBytes-=n[we];let o=At(s);t?this.dispatch(o,t,n,r):(this._state=Fe,this.sendFrame(i.frame(o,n),r),this.dequeue())}).catch(s=>{process.nextTick(Iu,this,s,r)})}dispatch(e,t,n,r){if(!t){this.sendFrame(i.frame(e,n),r);return}let s=this._extensions[wa.extensionName];this._bufferedBytes+=n[we],this._state=Ru,s.compress(e,n.fin,(o,c)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");gs(this,u,r);return}this._bufferedBytes-=n[we],this._state=Fe,n.readOnly=!1,this.sendFrame(i.frame(c,n),r),this.dequeue()})}dequeue(){for(;this._state===Fe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][we],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][we],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)}};Aa.exports=ms;function gs(i,e,t){typeof t=="function"&&t(e);for(let n=0;n<i._queue.length;n++){let r=i._queue[n],s=r[r.length-1];typeof s=="function"&&s(e)}}function Iu(i,e,t){gs(i,e,t),i.onerror(e)}});var La=O((mg,Fa)=>{"use strict";var{kForOnEventAttribute:zi,kListener:vs}=Ze(),Na=Symbol("kCode"),ka=Symbol("kData"),Ra=Symbol("kError"),Ta=Symbol("kMessage"),Ia=Symbol("kReason"),ei=Symbol("kTarget"),Oa=Symbol("kType"),Pa=Symbol("kWasClean"),tt=class{constructor(e){this[ei]=null,this[Oa]=e}get target(){return this[ei]}get type(){return this[Oa]}};Object.defineProperty(tt.prototype,"target",{enumerable:!0});Object.defineProperty(tt.prototype,"type",{enumerable:!0});var kt=class extends tt{constructor(e,t={}){super(e),this[Na]=t.code===void 0?0:t.code,this[Ia]=t.reason===void 0?"":t.reason,this[Pa]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Na]}get reason(){return this[Ia]}get wasClean(){return this[Pa]}};Object.defineProperty(kt.prototype,"code",{enumerable:!0});Object.defineProperty(kt.prototype,"reason",{enumerable:!0});Object.defineProperty(kt.prototype,"wasClean",{enumerable:!0});var ti=class extends tt{constructor(e,t={}){super(e),this[Ra]=t.error===void 0?null:t.error,this[Ta]=t.message===void 0?"":t.message}get error(){return this[Ra]}get message(){return this[Ta]}};Object.defineProperty(ti.prototype,"error",{enumerable:!0});Object.defineProperty(ti.prototype,"message",{enumerable:!0});var Gi=class extends tt{constructor(e,t={}){super(e),this[ka]=t.data===void 0?null:t.data}get data(){return this[ka]}};Object.defineProperty(Gi.prototype,"data",{enumerable:!0});var Ou={addEventListener(i,e,t={}){for(let r of this.listeners(i))if(!t[zi]&&r[vs]===e&&!r[zi])return;let n;if(i==="message")n=function(s,o){let c=new Gi("message",{data:o?s:s.toString()});c[ei]=this,sr(e,this,c)};else if(i==="close")n=function(s,o){let c=new kt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[ei]=this,sr(e,this,c)};else if(i==="error")n=function(s){let o=new ti("error",{error:s,message:s.message});o[ei]=this,sr(e,this,o)};else if(i==="open")n=function(){let s=new tt("open");s[ei]=this,sr(e,this,s)};else return;n[zi]=!!t[zi],n[vs]=e,t.once?this.once(i,n):this.on(i,n)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[vs]===e&&!t[zi]){this.removeListener(i,t);break}}};Fa.exports={CloseEvent:kt,ErrorEvent:ti,Event:tt,EventTarget:Ou,MessageEvent:Gi};function sr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var or=O((gg,Ua)=>{"use strict";var{tokenChars:Vi}=Xt();function qe(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Pu(i){let e=Object.create(null),t=Object.create(null),n=!1,r=!1,s=!1,o,c,u=-1,h=-1,l=-1,f=0;for(;f<i.length;f++)if(h=i.charCodeAt(f),o===void 0)if(l===-1&&Vi[h]===1)u===-1&&(u=f);else if(f!==0&&(h===32||h===9))l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=i.slice(u,l);h===44?(qe(e,d,t),t=Object.create(null)):o=d,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(l===-1&&Vi[h]===1)u===-1&&(u=f);else if(h===32||h===9)l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),qe(t,i.slice(u,l),!0),h===44&&(qe(e,o,t),t=Object.create(null),o=void 0),u=l=-1}else if(h===61&&u!==-1&&l===-1)c=i.slice(u,f),u=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(r){if(Vi[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1?u=f:n||(n=!0),r=!1}else if(s)if(Vi[h]===1)u===-1&&(u=f);else if(h===34&&u!==-1)s=!1,l=f;else if(h===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(h===34&&i.charCodeAt(f-1)===61)s=!0;else if(l===-1&&Vi[h]===1)u===-1&&(u=f);else if(u!==-1&&(h===32||h===9))l===-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=i.slice(u,l);n&&(d=d.replace(/\\/g,""),n=!1),qe(t,c,d),h===44&&(qe(e,o,t),t=Object.create(null),o=void 0),c=void 0,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(u===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let m=i.slice(u,l);return o===void 0?qe(e,m,t):(c===void 0?qe(t,m,!0):n?qe(t,c,m.replace(/\\/g,"")):qe(t,c,m),qe(e,o,t)),e}function Fu(i){return Object.keys(i).map(e=>{let t=i[e];return Array.isArray(t)||(t=[t]),t.map(n=>[e].concat(Object.keys(n).map(r=>{let s=n[r];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?r:`${r}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ua.exports={format:Fu,parse:Pu}});var ur=O((bg,Ha)=>{"use strict";var Lu=I("events"),Uu=I("https"),Du=I("http"),Ma=I("net"),Bu=I("tls"),{randomBytes:Mu,createHash:qu}=I("crypto"),{Duplex:yg,Readable:vg}=I("stream"),{URL:bs}=I("url"),yt=Jt(),Wu=ps(),$u=ys(),{isBlob:Ku}=Xt(),{BINARY_TYPES:Da,CLOSE_TIMEOUT:zu,EMPTY_BUFFER:ar,GUID:Gu,kForOnEventAttribute:Ss,kListener:Vu,kStatusCode:ju,kWebSocket:Q,NOOP:qa}=Ze(),{EventTarget:{addEventListener:Hu,removeEventListener:Yu}}=La(),{format:Ju,parse:Xu}=or(),{toBuffer:Qu}=$i(),Wa=Symbol("kAborted"),_s=[8,13],it=["CONNECTING","OPEN","CLOSING","CLOSED"],Zu=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,D=class i extends Lu{constructor(e,t,n){super(),this._binaryType=Da[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ar,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?(n=t,t=[]):t=[t]),$a(this,e,t,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Da.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,n){let r=new Wu({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),s=new $u(e,this._extensions,n.generateMask);this._receiver=r,this._sender=s,this._socket=e,r[Q]=this,s[Q]=this,e[Q]=this,r.on("conclude",ih),r.on("drain",nh),r.on("error",rh),r.on("message",sh),r.on("ping",oh),r.on("pong",ah),s.onerror=ch,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Ga),e.on("data",lr),e.on("end",Va),e.on("error",ja),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[yt.extensionName]&&this._extensions[yt.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){me(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,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),za(this)}}pause(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=t=void 0):typeof t=="function"&&(n=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Es(this,e,n);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||ar,t,n)}pong(e,t,n){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=t=void 0):typeof t=="function"&&(n=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Es(this,e,n);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||ar,t,n)}resume(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(n=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){Es(this,e,n);return}let r=y({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[yt.extensionName]||(r.compress=!1),this._sender.send(e||ar,r,n)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING){me(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:it.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:it.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:it.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:it.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:it.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:it.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:it.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:it.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[Ss])return e[Vu];return null},set(e){for(let t of this.listeners(i))if(t[Ss]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Ss]:!0})}})});D.prototype.addEventListener=Hu;D.prototype.removeEventListener=Yu;Ha.exports=D;function $a(i,e,t,n){let r=x(y({allowSynchronousEvents:!0,autoPong:!0,closeTimeout:zu,protocolVersion:_s[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},n),{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=r.autoPong,i._closeTimeout=r.closeTimeout,!_s.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${_s.join(", ")})`);let s;if(e instanceof bs)s=e;else try{s=new bs(e)}catch(g){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:",u;if(s.protocol!=="ws:"&&!o&&!c?u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?u="The URL's pathname is empty":s.hash&&(u="The URL contains a fragment identifier"),u){let g=new SyntaxError(u);if(i._redirects===0)throw g;cr(i,g);return}let h=o?443:80,l=Mu(16).toString("base64"),f=o?Uu.request:Du.request,m=new Set,d;if(r.createConnection=r.createConnection||(o?th:eh),r.defaultPort=r.defaultPort||h,r.port=s.port||h,r.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,r.headers=x(y({},r.headers),{"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),r.path=s.pathname+s.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(d=new yt(x(y({},r.perMessageDeflate),{isServer:!1,maxPayload:r.maxPayload})),r.headers["Sec-WebSocket-Extensions"]=Ju({[yt.extensionName]:d.offer()})),t.length){for(let g of t){if(typeof g!="string"||!Zu.test(g)||m.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(g)}r.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(s.username||s.password)&&(r.auth=`${s.username}:${s.password}`),c){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let C;if(r.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?r.socketPath:s.host;let g=n&&n.headers;if(n=x(y({},n),{headers:{}}),g)for(let[b,R]of Object.entries(g))n.headers[b.toLowerCase()]=R}else if(i.listenerCount("redirect")===0){let g=c?i._originalIpc?r.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!g||i._originalSecure&&!o)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),C=i._req=f(r),i._redirects&&i.emit("redirect",i.url,C)}else C=i._req=f(r);r.timeout&&C.on("timeout",()=>{me(i,C,"Opening handshake has timed out")}),C.on("error",g=>{C===null||C[Wa]||(C=i._req=null,cr(i,g))}),C.on("response",g=>{let b=g.headers.location,R=g.statusCode;if(b&&r.followRedirects&&R>=300&&R<400){if(++i._redirects>r.maxRedirects){me(i,C,"Maximum redirects exceeded");return}C.abort();let N;try{N=new bs(b,e)}catch(_){let E=new SyntaxError(`Invalid URL: ${b}`);cr(i,E);return}$a(i,N,t,n)}else i.emit("unexpected-response",C,g)||me(i,C,`Unexpected server response: ${g.statusCode}`)}),C.on("upgrade",(g,b,R)=>{if(i.emit("upgrade",g),i.readyState!==D.CONNECTING)return;C=i._req=null;let N=g.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){me(i,b,"Invalid Upgrade header");return}let _=qu("sha1").update(l+Gu).digest("base64");if(g.headers["sec-websocket-accept"]!==_){me(i,b,"Invalid Sec-WebSocket-Accept header");return}let E=g.headers["sec-websocket-protocol"],M;if(E!==void 0?m.size?m.has(E)||(M="Server sent an invalid subprotocol"):M="Server sent a subprotocol but none was requested":m.size&&(M="Server sent no subprotocol"),M){me(i,b,M);return}E&&(i._protocol=E);let T=g.headers["sec-websocket-extensions"];if(T!==void 0){if(!d){me(i,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=Xu(T)}catch(ie){me(i,b,"Invalid Sec-WebSocket-Extensions header");return}let $=Object.keys(P);if($.length!==1||$[0]!==yt.extensionName){me(i,b,"Server indicated an extension that was not requested");return}try{d.accept(P[yt.extensionName])}catch(ie){me(i,b,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[yt.extensionName]=d}i.setSocket(b,R,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(C,i):C.end()}function cr(i,e){i._readyState=D.CLOSING,i._errorEmitted=!0,i.emit("error",e),i.emitClose()}function eh(i){return i.path=i.socketPath,Ma.connect(i)}function th(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Ma.isIP(i.host)?"":i.host),Bu.connect(i)}function me(i,e,t){i._readyState=D.CLOSING;let n=new Error(t);Error.captureStackTrace(n,me),e.setHeader?(e[Wa]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(cr,i,n)):(e.destroy(n),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function Es(i,e,t){if(e){let n=Ku(e)?e.size:Qu(e).length;i._socket?i._sender._bufferedBytes+=n:i._bufferedAmount+=n}if(t){let n=new Error(`WebSocket is not open: readyState ${i.readyState} (${it[i.readyState]})`);process.nextTick(t,n)}}function ih(i,e){let t=this[Q];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[Q]!==void 0&&(t._socket.removeListener("data",lr),process.nextTick(Ka,t._socket),i===1005?t.close():t.close(i,e))}function nh(){let i=this[Q];i.isPaused||i._socket.resume()}function rh(i){let e=this[Q];e._socket[Q]!==void 0&&(e._socket.removeListener("data",lr),process.nextTick(Ka,e._socket),e.close(i[ju])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i))}function Ba(){this[Q].emitClose()}function sh(i,e){this[Q].emit("message",i,e)}function oh(i){let e=this[Q];e._autoPong&&e.pong(i,!this._isServer,qa),e.emit("ping",i)}function ah(i){this[Q].emit("pong",i)}function Ka(i){i.resume()}function ch(i){let e=this[Q];e.readyState!==D.CLOSED&&(e.readyState===D.OPEN&&(e._readyState=D.CLOSING,za(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",i)))}function za(i){i._closeTimer=setTimeout(i._socket.destroy.bind(i._socket),i._closeTimeout)}function Ga(){let i=this[Q];if(this.removeListener("close",Ga),this.removeListener("data",lr),this.removeListener("end",Va),i._readyState=D.CLOSING,!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);i._receiver.write(e)}i._receiver.end(),this[Q]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",Ba),i._receiver.on("finish",Ba))}function lr(i){this[Q]._receiver.write(i)||this.pause()}function Va(){let i=this[Q];i._readyState=D.CLOSING,i._receiver.end(),this.end()}function ja(){let i=this[Q];this.removeListener("error",ja),this.on("error",qa),i&&(i._readyState=D.CLOSING,this.destroy())}});var Qa=O((Eg,Xa)=>{"use strict";var _g=ur(),{Duplex:lh}=I("stream");function Ya(i){i.emit("close")}function uh(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ja(i){this.removeListener("error",Ja),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function hh(i,e){let t=!0,n=new lh(x(y({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let c=!o&&n._readableState.objectMode?s.toString():s;n.push(c)||i.pause()}),i.once("error",function(s){n.destroyed||(t=!1,n.destroy(s))}),i.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(r,s){if(i.readyState===i.CLOSED){s(r),process.nextTick(Ya,n);return}let o=!1;i.once("error",function(u){o=!0,s(u)}),i.once("close",function(){o||s(r),process.nextTick(Ya,n)}),t&&i.terminate()},n._final=function(r){if(i.readyState===i.CONNECTING){i.once("open",function(){n._final(r)});return}i._socket!==null&&(i._socket._writableState.finished?(r(),n._readableState.endEmitted&&n.destroy()):(i._socket.once("finish",function(){r()}),i.close()))},n._read=function(){i.isPaused&&i.resume()},n._write=function(r,s,o){if(i.readyState===i.CONNECTING){i.once("open",function(){n._write(r,s,o)});return}i.send(r,o)},n.on("end",uh),n.on("error",Ja),n}Xa.exports=hh});var Cs=O((wg,Za)=>{"use strict";var{tokenChars:fh}=Xt();function dh(i){let e=new Set,t=-1,n=-1,r=0;for(r;r<i.length;r++){let o=i.charCodeAt(r);if(n===-1&&fh[o]===1)t===-1&&(t=r);else if(r!==0&&(o===32||o===9))n===-1&&t!==-1&&(n=r);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${r}`);n===-1&&(n=r);let c=i.slice(t,n);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),t=n=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(t===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let s=i.slice(t,r);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}Za.exports={parse:dh}});var oc=O((Ag,sc)=>{"use strict";var ph=I("events"),hr=I("http"),{Duplex:xg}=I("stream"),{createHash:mh}=I("crypto"),ec=or(),Rt=Jt(),gh=Cs(),yh=ur(),{CLOSE_TIMEOUT:vh,GUID:bh,kWebSocket:Sh}=Ze(),_h=/^[+/0-9A-Za-z]{22}==$/,tc=0,ic=1,rc=2,ws=class extends ph{constructor(e,t){if(super(),e=y({allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:vh,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:yh},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=hr.createServer((n,r)=>{let s=hr.STATUS_CODES[426];r.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),r.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=Eh(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,s,o)=>{this.handleUpgrade(r,s,o,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=tc}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===rc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ji,this);return}if(e&&this.once("close",e),this._state!==ic)if(this._state=ic,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(ji,this):process.nextTick(ji,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ji(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,n,r){t.on("error",nc);let s=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Tt(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Tt(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!_h.test(s)){Tt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){Tt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Hi(t,400);return}let u=e.headers["sec-websocket-protocol"],h=new Set;if(u!==void 0)try{h=gh.parse(u)}catch(m){Tt(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&l!==void 0){let m=new Rt(x(y({},this.options.perMessageDeflate),{isServer:!0,maxPayload:this.options.maxPayload}));try{let d=ec.parse(l);d[Rt.extensionName]&&(m.accept(d[Rt.extensionName]),f[Rt.extensionName]=m)}catch(d){Tt(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,C,g,b)=>{if(!d)return Hi(t,C||401,g,b);this.completeUpgrade(f,s,h,e,t,n,r)});return}if(!this.options.verifyClient(m))return Hi(t,401)}this.completeUpgrade(f,s,h,e,t,n,r)}completeUpgrade(e,t,n,r,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[Sh])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>tc)return Hi(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mh("sha1").update(t+bh).digest("base64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(n.size){let f=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;f&&(h.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[Rt.extensionName]){let f=e[Rt.extensionName].params,m=ec.format({[Rt.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${m}`),l._extensions=e}this.emit("headers",h,r),s.write(h.concat(`\r
7
7
  `).join(`\r
8
- `)),s.removeListener("error",za),l.setSocket(s,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Vi,this)})),c(l,n)}};ja.exports=Ss;function ch(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 Vi(i){i._state=Va,i.emit("close")}function za(){this.destroy()}function ji(i,e,t,r){t=t||an.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} ${an.STATUS_CODES[e]}\r
9
- `+Object.keys(r).map(n=>`${n}: ${r[n]}`).join(`\r
8
+ `)),s.removeListener("error",nc),l.setSocket(s,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ji,this)})),c(l,r)}};sc.exports=ws;function Eh(i,e){for(let t of Object.keys(e))i.on(t,e[t]);return function(){for(let n of Object.keys(e))i.removeListener(n,e[n])}}function ji(i){i._state=rc,i.emit("close")}function nc(){this.destroy()}function Hi(i,e,t,n){t=t||hr.STATUS_CODES[e],n=y({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},n),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${hr.STATUS_CODES[e]}\r
9
+ `+Object.keys(n).map(r=>`${r}: ${n[r]}`).join(`\r
10
10
  `)+`\r
11
11
  \r
12
- `+t)}function Tt(i,e,t,r,n,s){if(i.listenerCount("wsClientError")){let o=new Error(n);Error.captureStackTrace(o,Tt),i.emit("wsClientError",o,t,e)}else ji(t,r,n,s)}});var Es=I((Ry,tc)=>{"use strict";function _h(i){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Wn(),t.destroy=h,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let p=0;p<l.length;p++)f=(f<<5)-f+l.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,p=null,d,w;function y(...b){if(!y.enabled)return;let k=y,N=Number(new Date),_=N-(f||N);k.diff=_,k.prev=f,k.curr=N,f=N,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let E=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let te=b[E];R=$.call(k,te),b.splice(E,1),E--}return R}),t.formatArgs.call(k,b),(k.log||t.log).apply(k,b)}return y.namespace=l,y.useColors=t.useColors(),y.color=t.selectColor(l),y.extend=r,y.destroy=t.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==t.namespaces&&(d=t.namespaces,w=t.enabled(l)),w),set:b=>{p=b}}),typeof t.init=="function"&&t.init(y),y}function r(l,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+l);return p.log=this.log,p}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,p=(typeof l=="string"?l:"").split(/[\s,]+/),d=p.length;for(f=0;f<d;f++)p[f]&&(l=p[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(l))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}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}tc.exports=_h});var ic=I((ye,hn)=>{"use strict";ye.formatArgs=wh;ye.save=Ch;ye.load=xh;ye.useColors=Eh;ye.storage=Nh();ye.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`."))}})();ye.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 Eh(){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 wh(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+hn.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)}ye.log=console.debug||console.log||(()=>{});function Ch(i){try{i?ye.storage.setItem("debug",i):ye.storage.removeItem("debug")}catch(e){}}function xh(){let i;try{i=ye.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Nh(){try{return localStorage}catch(i){}}hn.exports=Es()(ye);var{formatters:Ah}=hn.exports;Ah.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var nc=I((Q,dn)=>{"use strict";var kh=O("tty"),fn=O("util");Q.init=Lh;Q.log=Ih;Q.formatArgs=Th;Q.save=Ph;Q.load=Fh;Q.useColors=Rh;Q.destroy=fn.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Q.colors=[6,2,3,4,5,1];try{let i=jn();i&&(i.stderr||i).level>=2&&(Q.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){}Q.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 Rh(){return"colors"in Q.inspectOpts?!!Q.inspectOpts.colors:kh.isatty(process.stderr.fd)}function Th(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 Tt(i,e,t,n,r,s){if(i.listenerCount("wsClientError")){let o=new Error(r);Error.captureStackTrace(o,Tt),i.emit("wsClientError",o,t,e)}else Hi(t,n,r,s)}});var As=O((cy,pc)=>{"use strict";function Lh(i){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=r,t.enabled=o,t.humanize=Gr(),t.destroy=h,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,d,C;function g(...b){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let E=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(T,P)=>{if(T==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let ie=b[E];T=$.call(R,ie),b.splice(E,1),E--}return T}),t.formatArgs.call(R,b),(R.log||t.log).apply(R,b)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=n,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(d!==t.namespaces&&(d=t.namespaces,C=t.enabled(l)),C),set:b=>{m=b}}),typeof t.init=="function"&&t.init(g),g}function n(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),d=m.length;for(f=0;f<d;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}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}pc.exports=Lh});var mc=O((ge,mr)=>{"use strict";ge.formatArgs=Dh;ge.save=Bh;ge.load=Mh;ge.useColors=Uh;ge.storage=qh();ge.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`."))}})();ge.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 Uh(){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 Dh(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+mr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,n=0;i[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(n=t))}),i.splice(n,0,e)}ge.log=console.debug||console.log||(()=>{});function Bh(i){try{i?ge.storage.setItem("debug",i):ge.storage.removeItem("debug")}catch(e){}}function Mh(){let i;try{i=ge.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function qh(){try{return localStorage}catch(i){}}mr.exports=As()(ge);var{formatters:Wh}=mr.exports;Wh.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var yc=O((Z,yr)=>{"use strict";var $h=I("tty"),gr=I("util");Z.init=Yh;Z.log=Vh;Z.formatArgs=zh;Z.save=jh;Z.load=Hh;Z.useColors=Kh;Z.destroy=gr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Z.colors=[6,2,3,4,5,1];try{let i=Jr();i&&(i.stderr||i).level>=2&&(Z.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){}Z.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),n=process.env[e];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),i[t]=n,i},{});function Kh(){return"colors"in Z.inspectOpts?!!Z.inspectOpts.colors:$h.isatty(process.stderr.fd)}function zh(i){let{namespace:e,useColors:t}=this;if(t){let n=this.color,r="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${r};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
13
13
  `).join(`
14
- `+s),i.push(n+"m+"+dn.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Oh()+e+" "+i[0]}function Oh(){return Q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ih(...i){return process.stderr.write(fn.formatWithOptions(Q.inspectOpts,...i)+`
15
- `)}function Ph(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Fh(){return process.env.DEBUG}function Lh(i){i.inspectOpts={};let e=Object.keys(Q.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=Q.inspectOpts[e[t]]}dn.exports=Es()(Q);var{formatters:rc}=dn.exports;rc.o=function(i){return this.inspectOpts.colors=this.useColors,fn.inspect(i,this.inspectOpts).split(`
16
- `).map(e=>e.trim()).join(" ")};rc.O=function(i){return this.inspectOpts.colors=this.useColors,fn.inspect(i,this.inspectOpts)}});var Yi=I((Ty,ws)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?ws.exports=ic():ws.exports=nc()});var fc=I((Uy,hc)=>{"use strict";var ri=1e3,ni=ri*60,si=ni*60,Pt=si*24,qh=Pt*7,Wh=Pt*365.25;hc.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return $h(i);if(t==="number"&&isFinite(i))return e.long?zh(i):Kh(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function $h(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*Wh;case"weeks":case"week":case"w":return t*qh;case"days":case"day":case"d":return t*Pt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*si;case"minutes":case"minute":case"mins":case"min":case"m":return t*ni;case"seconds":case"second":case"secs":case"sec":case"s":return t*ri;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Kh(i){var e=Math.abs(i);return e>=Pt?Math.round(i/Pt)+"d":e>=si?Math.round(i/si)+"h":e>=ni?Math.round(i/ni)+"m":e>=ri?Math.round(i/ri)+"s":i+"ms"}function zh(i){var e=Math.abs(i);return e>=Pt?pn(i,e,Pt,"day"):e>=si?pn(i,e,si,"hour"):e>=ni?pn(i,e,ni,"minute"):e>=ri?pn(i,e,ri,"second"):i+" ms"}function pn(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var Ns=I((Dy,dc)=>{"use strict";function Vh(i){t.debug=t,t.default=t,t.coerce=u,t.disable=o,t.enable=n,t.enabled=c,t.humanize=fc(),t.destroy=h,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let p=0;p<l.length;p++)f=(f<<5)-f+l.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,p=null,d,w;function y(...b){if(!y.enabled)return;let k=y,N=Number(new Date),_=N-(f||N);k.diff=_,k.prev=f,k.curr=N,f=N,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let E=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let te=b[E];R=$.call(k,te),b.splice(E,1),E--}return R}),t.formatArgs.call(k,b),(k.log||t.log).apply(k,b)}return y.namespace=l,y.useColors=t.useColors(),y.color=t.selectColor(l),y.extend=r,y.destroy=t.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==t.namespaces&&(d=t.namespaces,w=t.enabled(l)),w),set:b=>{p=b}}),typeof t.init=="function"&&t.init(y),y}function r(l,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+l);return p.log=this.log,p}function n(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let p of f)p[0]==="-"?t.skips.push(p.slice(1)):t.names.push(p)}function s(l,f){let p=0,d=0,w=-1,y=0;for(;p<l.length;)if(d<f.length&&(f[d]===l[p]||f[d]==="*"))f[d]==="*"?(w=d,y=p,d++):(p++,d++);else if(w!==-1)d=w+1,y++,p=y;else return!1;for(;d<f.length&&f[d]==="*";)d++;return d===f.length}function o(){let l=[...t.names,...t.skips.map(f=>"-"+f)].join(",");return t.enable(""),l}function c(l){for(let f of t.skips)if(s(l,f))return!1;for(let f of t.names)if(s(l,f))return!0;return!1}function u(l){return l instanceof Error?l.stack||l.message:l}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}dc.exports=Vh});var pc=I((fe,mn)=>{"use strict";fe.formatArgs=Gh;fe.save=Hh;fe.load=Yh;fe.useColors=jh;fe.storage=Jh();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 jh(){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 Gh(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+mn.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 Hh(i){try{i?fe.storage.setItem("debug",i):fe.storage.removeItem("debug")}catch(e){}}function Yh(){let i;try{i=fe.storage.getItem("debug")||fe.storage.getItem("DEBUG")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Jh(){try{return localStorage}catch(i){}}mn.exports=Ns()(fe);var{formatters:Xh}=mn.exports;Xh.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var gc=I((By,yc)=>{"use strict";var Qh=O("os"),mc=O("tty"),Ce=Kn(),{env:Z}=process,yn;Ce("no-color")||Ce("no-colors")||Ce("color=false")||Ce("color=never")?yn=0:(Ce("color")||Ce("colors")||Ce("color=true")||Ce("color=always"))&&(yn=1);function Zh(){if("FORCE_COLOR"in Z)return Z.FORCE_COLOR==="true"?1:Z.FORCE_COLOR==="false"?0:Z.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Z.FORCE_COLOR,10),3)}function ef(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function tf(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let r=Zh();r!==void 0&&(yn=r);let n=t?yn:r;if(n===0)return 0;if(t){if(Ce("color=16m")||Ce("color=full")||Ce("color=truecolor"))return 3;if(Ce("color=256"))return 2}if(i&&!e&&n===void 0)return 0;let s=n||0;if(Z.TERM==="dumb")return s;if(process.platform==="win32"){let o=Qh.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in Z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in Z)||Z.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in Z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Z.TEAMCITY_VERSION)?1:0;if(Z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Z){let o=Number.parseInt((Z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Z.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Z.TERM)||"COLORTERM"in Z?1:s}function As(i,e={}){let t=tf(i,g({streamIsTTY:i&&i.isTTY},e));return ef(t)}yc.exports={supportsColor:As,stdout:As({isTTY:mc.isatty(1)}),stderr:As({isTTY:mc.isatty(2)})}});var bc=I((ee,vn)=>{"use strict";var rf=O("tty"),gn=O("util");ee.init=uf;ee.log=af;ee.formatArgs=sf;ee.save=cf;ee.load=lf;ee.useColors=nf;ee.destroy=gn.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");ee.colors=[6,2,3,4,5,1];try{let i=gc();i&&(i.stderr||i).level>=2&&(ee.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){}ee.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 nf(){return"colors"in ee.inspectOpts?!!ee.inspectOpts.colors:rf.isatty(process.stderr.fd)}function sf(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(`
14
+ `+s),i.push(r+"m+"+yr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Gh()+e+" "+i[0]}function Gh(){return Z.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Vh(...i){return process.stderr.write(gr.formatWithOptions(Z.inspectOpts,...i)+`
15
+ `)}function jh(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Hh(){return process.env.DEBUG}function Yh(i){i.inspectOpts={};let e=Object.keys(Z.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=Z.inspectOpts[e[t]]}yr.exports=As()(Z);var{formatters:gc}=yr.exports;gc.o=function(i){return this.inspectOpts.colors=this.useColors,gr.inspect(i,this.inspectOpts).split(`
16
+ `).map(e=>e.trim()).join(" ")};gc.O=function(i){return this.inspectOpts.colors=this.useColors,gr.inspect(i,this.inspectOpts)}});var Xi=O((ly,Ns)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ns.exports=mc():Ns.exports=yc()});var xc=O((my,wc)=>{"use strict";var ni=1e3,ri=ni*60,si=ri*60,Pt=si*24,ef=Pt*7,tf=Pt*365.25;wc.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return nf(i);if(t==="number"&&isFinite(i))return e.long?sf(i):rf(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function nf(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]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*tf;case"weeks":case"week":case"w":return t*ef;case"days":case"day":case"d":return t*Pt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*si;case"minutes":case"minute":case"mins":case"min":case"m":return t*ri;case"seconds":case"second":case"secs":case"sec":case"s":return t*ni;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function rf(i){var e=Math.abs(i);return e>=Pt?Math.round(i/Pt)+"d":e>=si?Math.round(i/si)+"h":e>=ri?Math.round(i/ri)+"m":e>=ni?Math.round(i/ni)+"s":i+"ms"}function sf(i){var e=Math.abs(i);return e>=Pt?vr(i,e,Pt,"day"):e>=si?vr(i,e,si,"hour"):e>=ri?vr(i,e,ri,"minute"):e>=ni?vr(i,e,ni,"second"):i+" ms"}function vr(i,e,t,n){var r=e>=t*1.5;return Math.round(i/t)+" "+n+(r?"s":"")}});var Ts=O((gy,Ac)=>{"use strict";function of(i){t.debug=t,t.default=t,t.coerce=u,t.disable=o,t.enable=r,t.enabled=c,t.humanize=xc(),t.destroy=h,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,d,C;function g(...b){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let E=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(T,P)=>{if(T==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let ie=b[E];T=$.call(R,ie),b.splice(E,1),E--}return T}),t.formatArgs.call(R,b),(R.log||t.log).apply(R,b)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=n,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(d!==t.namespaces&&(d=t.namespaces,C=t.enabled(l)),C),set:b=>{m=b}}),typeof t.init=="function"&&t.init(g),g}function n(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of f)m[0]==="-"?t.skips.push(m.slice(1)):t.names.push(m)}function s(l,f){let m=0,d=0,C=-1,g=0;for(;m<l.length;)if(d<f.length&&(f[d]===l[m]||f[d]==="*"))f[d]==="*"?(C=d,g=m,d++):(m++,d++);else if(C!==-1)d=C+1,g++,m=g;else return!1;for(;d<f.length&&f[d]==="*";)d++;return d===f.length}function o(){let l=[...t.names,...t.skips.map(f=>"-"+f)].join(",");return t.enable(""),l}function c(l){for(let f of t.skips)if(s(l,f))return!1;for(let f of t.names)if(s(l,f))return!0;return!1}function u(l){return l instanceof Error?l.stack||l.message:l}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}Ac.exports=of});var Nc=O((fe,br)=>{"use strict";fe.formatArgs=cf;fe.save=lf;fe.load=uf;fe.useColors=af;fe.storage=hf();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 af(){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 cf(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+br.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,n=0;i[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(n=t))}),i.splice(n,0,e)}fe.log=console.debug||console.log||(()=>{});function lf(i){try{i?fe.storage.setItem("debug",i):fe.storage.removeItem("debug")}catch(e){}}function uf(){let i;try{i=fe.storage.getItem("debug")||fe.storage.getItem("DEBUG")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function hf(){try{return localStorage}catch(i){}}br.exports=Ts()(fe);var{formatters:ff}=br.exports;ff.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Tc=O((yy,Rc)=>{"use strict";var df=I("os"),kc=I("tty"),xe=jr(),{env:ee}=process,Sr;xe("no-color")||xe("no-colors")||xe("color=false")||xe("color=never")?Sr=0:(xe("color")||xe("colors")||xe("color=true")||xe("color=always"))&&(Sr=1);function pf(){if("FORCE_COLOR"in ee)return ee.FORCE_COLOR==="true"?1:ee.FORCE_COLOR==="false"?0:ee.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(ee.FORCE_COLOR,10),3)}function mf(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function gf(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let n=pf();n!==void 0&&(Sr=n);let r=t?Sr:n;if(r===0)return 0;if(t){if(xe("color=16m")||xe("color=full")||xe("color=truecolor"))return 3;if(xe("color=256"))return 2}if(i&&!e&&r===void 0)return 0;let s=r||0;if(ee.TERM==="dumb")return s;if(process.platform==="win32"){let o=df.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in ee)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in ee)||ee.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ee.TEAMCITY_VERSION)?1:0;if(ee.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in ee){let o=Number.parseInt((ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ee.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ee.TERM)||"COLORTERM"in ee?1:s}function Is(i,e={}){let t=gf(i,y({streamIsTTY:i&&i.isTTY},e));return mf(t)}Rc.exports={supportsColor:Is,stdout:Is({isTTY:kc.isatty(1)}),stderr:Is({isTTY:kc.isatty(2)})}});var Oc=O((te,Er)=>{"use strict";var yf=I("tty"),_r=I("util");te.init=wf;te.log=_f;te.formatArgs=bf;te.save=Ef;te.load=Cf;te.useColors=vf;te.destroy=_r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");te.colors=[6,2,3,4,5,1];try{let i=Tc();i&&(i.stderr||i).level>=2&&(te.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){}te.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),n=process.env[e];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),i[t]=n,i},{});function vf(){return"colors"in te.inspectOpts?!!te.inspectOpts.colors:yf.isatty(process.stderr.fd)}function bf(i){let{namespace:e,useColors:t}=this;if(t){let n=this.color,r="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${r};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
17
17
  `).join(`
18
- `+s),i.push(n+"m+"+vn.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=of()+e+" "+i[0]}function of(){return ee.inspectOpts.hideDate?"":new Date().toISOString()+" "}function af(...i){return process.stderr.write(gn.formatWithOptions(ee.inspectOpts,...i)+`
19
- `)}function cf(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function lf(){return process.env.DEBUG}function uf(i){i.inspectOpts={};let e=Object.keys(ee.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=ee.inspectOpts[e[t]]}vn.exports=Ns()(ee);var{formatters:vc}=vn.exports;vc.o=function(i){return this.inspectOpts.colors=this.useColors,gn.inspect(i,this.inspectOpts).split(`
20
- `).map(e=>e.trim()).join(" ")};vc.O=function(i){return this.inspectOpts.colors=this.useColors,gn.inspect(i,this.inspectOpts)}});var Sc=I((qy,ks)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?ks.exports=pc():ks.exports=bc()});var zc=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,sr=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t="v1",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":zc,"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 m(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return m(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=Vc(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},u=yield fetch(o,c);if(!u.ok){let l=yield u.json();throw new Error(`${this.headers["Novu-Client-Version"]} error. Status: ${u.status}, Message: ${l.message}`)}if(u.status===204)return;let h=yield u.json();return n?h.data:h})}};function Vc(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var le="/inbox",oe=`${le}/notifications`;function jc(i,e){if(e!==void 0){if(Array.isArray(e)){if(e.length===0)return;for(let t of e)i.append("tags[]",t);return}if("or"in e){if(e.or.length===0)return;for(let t of e.or)i.append("tags[]",t);return}if("and"in e){if(e.and.length===0)return;e.and.forEach((t,r)=>{for(let n of t.or)i.append(`tags[${r}][]`,n)})}}}var T,or=class{constructor(e={}){this.isSessionInitialized=!1;v(this,T);S(this,T,new sr(e))}initializeSession(c){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let u=yield a(this,T).post(`${le}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,T).setAuthorizationToken(u.token),a(this,T).setKeylessHeader(u.applicationIdentifier),this.isSessionInitialized=!0,u})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:u,data:h,severity:l,createdGte:f,createdLte:p}){let d=new URLSearchParams(`limit=${r}`);if(e&&d.append("after",e),n&&d.append("offset",`${n}`),jc(d,o),s!==void 0&&d.append("read",`${s}`),t!==void 0&&d.append("archived",`${t}`),c!==void 0&&d.append("snoozed",`${c}`),u!==void 0&&d.append("seen",`${u}`),h!==void 0&&d.append("data",JSON.stringify(h)),l&&Array.isArray(l))for(let w of l)d.append("severity[]",w);else l&&d.append("severity",l);return f&&d.append("createdGte",`${f}`),p&&d.append("createdLte",`${p}`),a(this,T).get(oe,d,!1)}count({filters:e}){return a(this,T).get(`${oe}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,T).patch(`${oe}/${e}/read`)}unread(e){return a(this,T).patch(`${oe}/${e}/unread`)}archive(e){return a(this,T).patch(`${oe}/${e}/archive`)}unarchive(e){return a(this,T).patch(`${oe}/${e}/unarchive`)}snooze(e,t){return a(this,T).patch(`${oe}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,T).patch(`${oe}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,T).post(`${oe}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,T).post(`${oe}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,T).post(`${oe}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,T).delete(`${oe}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,T).post(`${oe}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,T).post(`${oe}/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,T).patch(`${oe}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,T).patch(`${oe}/${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,T).get(`${le}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,T).patch(`${le}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,T).patch(`${le}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,T).patch(`${le}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,T).get(`${le}/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,T).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,T).get(`${le}/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,T).get(`${le}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:r,topicName:n,preferences:s}){return a(this,T).post(`${le}/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,T).patch(`${le}/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:u,push:h}){return a(this,T).patch(`${le}/subscriptions/${e}/preferences/${t}`,{enabled:r,condition:n,email:s,sms:o,in_app:c,chat:u,push:h})}bulkUpdateSubscriptionPreferences(e){return a(this,T).patch(`${le}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,identifier:t}){return a(this,T).delete(`${le}/topics/${e}/subscriptions/${t}`)}};T=new WeakMap;function Ms(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 bt,ar=class{constructor(){v(this,bt);S(this,bt,Ms())}on(e,t){return a(this,bt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,bt).off(e,t)}emit(e,t){a(this,bt).emit(e,t)}};bt=new WeakMap;var x=class extends Error{constructor(e,t){super(e),this.originalError=t}};var cr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),lr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),ur=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),hr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),fr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),dr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),pr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ue(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)}}}),Ut=n=>m(null,[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}=Ue(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let u=yield e.completeAction({actionType:r,notificationId:o}),h=new U(u,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(u){return i.emit("notification.complete_action.resolved",{args:t,error:u}),{error:new x(`Failed to complete ${r} action on the notification`,u)}}}),Dt=n=>m(null,[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}=Ue(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let u=yield e.revertAction({actionType:r,notificationId:o}),h=new U(u,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(u){return i.emit("notification.revert_action.resolved",{args:t,error:u}),{error:new x("Failed to fetch notifications",u)}}}),Ue=(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},qs=s=>m(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(u=>new U(C(g({},u),{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)}}}),kn=o=>m(null,[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(l=>r.includes(l.id)):c).map(l=>new U(C(g({},l),{isSeen:!0,firstSeenAt:l.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data: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)}}}),Ws=s=>m(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(u=>new U(C(g({},u),{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)}}}),$s=s=>m(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(u=>new U(C(g({},u),{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)}}}),mr=r=>m(null,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=Ue(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)}}}),Ks=s=>m(null,[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 G,ae,U=class{constructor(e,t,r){v(this,G);v(this,ae);S(this,G,t),S(this,ae,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 cr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}unread(){return lr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}seen(){return ur({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}archive(){return hr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}unarchive(){return fr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}delete(){return mr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}snooze(e){return dr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this,snoozeUntil:e}})}unsnooze(){return pr({emitter:a(this,G),apiService:a(this,ae),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ut({emitter:a(this,G),apiService:a(this,ae),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ut({emitter:a(this,G),apiService:a(this,ae),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Dt({emitter:a(this,G),apiService:a(this,ae),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Dt({emitter:a(this,G),apiService:a(this,ae),args:{notification:this},actionType:"secondary"})}on(e,t){let r=a(this,G).on(e,t);return()=>{r()}}off(e,t){a(this,G).off(e,t)}};G=new WeakMap,ae=new WeakMap;var at,Bt,ue=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){v(this,at,[]);v(this,Bt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,at).forEach(c=>m(this,[c],function*({fn:s,resolve:o}){o(yield s())})),S(this,at,[])):r&&(this.onSessionError(r),S(this,Bt,r),a(this,at).forEach(({resolve:s})=>{s({error:new x("Failed to initialize session, please contact the support",r)})}),S(this,at,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Bt)?Promise.resolve({error:new x("Failed to initialize session, please contact the support",a(this,Bt))}):new Promise((t,r)=>{a(this,at).push({fn:e,resolve:t,reject:r})})})}};at=new WeakMap,Bt=new WeakMap;function zs({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var Vs=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Qf=["seen","unseen"],Zf=["read","unread"],js=30,yr=100,Gs=200,K=class extends Error{constructor(e){super(e),this.name="TagsFilterValidationError"}};function Hs(i,e){if(i.length>e)throw new K(`At most ${e} tags are allowed in a single OR-group`);for(let t of i)if(typeof t!="string")throw new K("Tags must be strings");return i}function Gc(i){let e=Object.keys(i),t=Object.prototype.hasOwnProperty.call(i,"or"),r=Object.prototype.hasOwnProperty.call(i,"and");if(t&&r)throw new K('Tags filter cannot have both "or" and "and"');if(t){if(e.length!==1)throw new K("Invalid tags filter object");let n=i.or;if(!Array.isArray(n))throw new K('"or" must be an array of strings');return n.length===0?[]:[Hs(n,yr)]}if(r){if(e.length!==1)throw new K("Invalid tags filter object");let n=i.and;if(!Array.isArray(n))throw new K('"and" must be an array');if(n.length===0)return[];if(n.length>js)throw new K(`At most ${js} tag groups are allowed`);let s=[],o=0;for(let c of n){if(typeof c!="object"||c===null||Array.isArray(c))throw new K('Each "and" entry must be an object { or: string[] }');if(Object.keys(c).length!==1||!Object.prototype.hasOwnProperty.call(c,"or"))throw new K('Each "and" entry must be { or: string[] }');let h=c.or;if(!Array.isArray(h))throw new K('"or" must be an array of strings');if(h.length===0)throw new K("Each tag group must be a non-empty array of strings");let l=Hs(h,yr);o+=l.length,s.push(l)}if(o>Gs)throw new K(`At most ${Gs} total tag values are allowed`);return s}throw new K('Tags filter object must have "or" or "and"')}function Hc(i){if(i===void 0)return[];if(i===null)throw new K("Tags must be an array or object");if(typeof i=="object"&&!Array.isArray(i))return Gc(i);if(!Array.isArray(i))throw new K("Tags must be an array or object");if(i.length===0)return[];if(Array.isArray(i[0]))throw new K("Nested tag arrays are not supported; use { and: [{ or: string[] }, ...] } for multiple OR-groups");let e=i;if(e.length>yr)throw new K(`At most ${yr} tags are allowed in a single OR-group`);for(let t of e)if(typeof t!="string")throw new K("Tags must be strings");return[e]}function Ys(i){if(i===void 0)return"";let e=Hc(i);if(e.length===0)return"";let t=Array.from(new Map(e.map(r=>{let n=Array.from(new Set(r)).sort((s,o)=>s.localeCompare(o));return[JSON.stringify(n),n]})).values()).sort((r,n)=>JSON.stringify(r).localeCompare(JSON.stringify(n)));return JSON.stringify(t)}var Rn=(i,e)=>{try{return Ys(i)===Ys(e)}catch(t){return!1}},Yc=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return Vs(t,r)},Tn=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},On=(i,e)=>Tn(i.data,e.data)&&Rn(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&Yc(i.severity,e.severity)&&i.createdGte===e.createdGte&&i.createdLte===e.createdLte;var Ae,ke=class{constructor(){v(this,Ae);S(this,Ae,new Map)}get(e){return a(this,Ae).get(e)}getValues(){return Array.from(a(this,Ae).values())}entries(){return Array.from(a(this,Ae).entries())}keys(){return Array.from(a(this,Ae).keys())}set(e,t){a(this,Ae).set(e,t)}remove(e){a(this,Ae).delete(e)}clear(){a(this,Ae).clear()}};Ae=new WeakMap;var Js=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f}).filter(([p,d])=>d!=null&&!(Array.isArray(d)&&d.length===0)).reduce((p,[d,w])=>(p[d]=w,p),{}),hi=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>JSON.stringify(Js({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})),Jc=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,createdGte:c,createdLte:u})=>JSON.stringify(Js({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,createdGte:c,createdLte:u})),St=i=>JSON.parse(i),Xc=["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"],Qc=["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"],Ke,di,q,fi=class{constructor({emitter:e,inboxService:t}){v(this,Ke);v(this,di);v(this,q);this.updateNotification=(e,t)=>{let r=a(this,q).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,q).set(e,C(g({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,q).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,q).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,q).keys().forEach(u=>{let h=a(this,q).get(u);if(h){let l=h.notifications.find(f=>f.id===n.notificationId);l&&c.push(l)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,q).keys().forEach(c=>{s.forEach(u=>{let h=!1;e?h=this.removeNotification(c,u):h=this.updateNotification(c,u),h&&o.add(Jc(St(c)))})}),o.forEach(c=>{let u=this.getAggregated(St(c));a(this,Ke).emit("notifications.list.updated",{data:u})})};S(this,Ke,e),S(this,di,t),Xc.forEach(r=>{a(this,Ke).on(r,this.handleNotificationEvent())}),Qc.forEach(r=>{a(this,Ke).on(r,this.handleNotificationEvent({remove:!0}))}),S(this,q,new ke)}getAggregated(e){return a(this,q).keys().filter(r=>{let n=St(r);return On(n,e)}).map(r=>a(this,q).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,q).get(hi(e))}has(e){return a(this,q).get(hi(e))!==void 0}set(e,t){a(this,q).set(hi(e),t)}unshift(e,t){let r=hi(e),n=a(this,q).get(r)||{hasMore:!1,filter:St(r),notifications:[]},s=zs({notification:g({},t),emitter:a(this,Ke),inboxService:a(this,di)});this.update(e,C(g({},n),{notifications:[s,...n.notifications]}))}update(e,t){this.set(e,t);let r=this.getAggregated(St(hi(e)));a(this,Ke).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,q).keys(),s=new Map;return n.forEach(o=>{let c=St(o);if(Rn(e,c.tags)&&Tn(r,c.data)){let u=a(this,q).get(o);if(!u)return;u.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,q).keys().forEach(r=>{On(St(r),e)&&a(this,q).remove(r)})}clearAll(){a(this,q).clear()}};Ke=new WeakMap,di=new WeakMap,q=new WeakMap;var pi,mi,yi,gi,ze=class{constructor(e,t,r,n,s){v(this,pi);v(this,mi);v(this,yi);v(this,gi);var o;S(this,pi,t),S(this,mi,r),S(this,yi,n),S(this,gi,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 m(this,null,function*(){var t;return gr({emitter:a(this,pi),apiService:a(this,mi),cache:a(this,yi),useCache:a(this,gi),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};pi=new WeakMap,mi=new WeakMap,yi=new WeakMap,gi=new WeakMap;var Xs=s=>m(null,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,u=o&&!c?t.getAll(n):void 0;return i.emit("subscriptions.list.pending",{args:n,data:u}),(!u||c)&&(u=(yield e.fetchSubscriptions(n.topicKey)).map(l=>new Ve(C(g({},l),{topicKey:n.topicKey}),i,e,t,o)),o&&(t.set(n,u),u=t.getAll(n))),i.emit("subscriptions.list.resolved",{args:n,data:u}),{data:u}}catch(o){return i.emit("subscriptions.list.resolved",{args:n,error:o}),{error:new x("Failed to fetch subscriptions",o)}}}),Qs=s=>m(null,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,u=o&&!c?t.get(n):void 0;if(i.emit("subscription.get.pending",{args:n,data:u}),!u||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};u=new Ve(C(g({},h),{topicKey:n.topicKey}),i,e,t,o),o&&(t.setOne(n,u),u=t.get(n))}return i.emit("subscription.get.resolved",{args:n,data:u}),{data:u}}catch(o){return i.emit("subscription.get.resolved",{args:n,error:o}),{error:new x("Failed to fetch subscription",o)}}}),Zs=s=>m(null,[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}),u=new Ve(C(g({},c),{topicKey:n.topicKey}),i,e,t,r);return i.emit("subscription.create.resolved",{args:n,data:u}),{data:u}}catch(c){return i.emit("subscription.create.resolved",{args:n,error:c}),{error:new x("Failed to create subscription",c)}}}),vr=s=>m(null,[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 u=yield e.updateSubscription({topicKey:c,identifier:o,name:n.name,preferences:n.preferences}),h=new Ve(C(g({},u),{topicKey:c}),i,e,t,r);return i.emit("subscription.update.resolved",{args:n,data:h}),{data:h}}catch(u){return i.emit("subscription.update.resolved",{args:n,error:u}),{error:new x("Failed to update subscription",u)}}}),gr=s=>m(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var c,u;let o="workflowId"in n?n.workflowId:(u=(c=n.preference)==null?void 0:c.workflow)==null?void 0:u.id;try{i.emit("subscription.preference.update.pending",{args:n,data:"preference"in n?new ze(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})),l=new ze(g({},h),i,e,t,r);return i.emit("subscription.preference.update.resolved",{args:n,data:l}),{data:l}}catch(h){return i.emit("subscription.preference.update.resolved",{args:n,error:h}),{error:new x("Failed to update subscription",h)}}}),eo=s=>m(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){try{let o=n.map(l=>"preference"in l?new ze(g(g({},l.preference),typeof l.value=="boolean"?{enabled:l.value}:{condition:l.value}),i,e,t,r):void 0).filter(l=>l!==void 0);i.emit("subscription.preferences.bulk_update.pending",{args:n,data:o});let c=n.map(l=>{var f,p,d,w,y,b;return g({subscriptionIdentifier:l.subscriptionId,workflowId:"workflowId"in l?l.workflowId:(b=(y=(p=(f=l.preference)==null?void 0:f.workflow)==null?void 0:p.id)!=null?y:(w=(d=l.preference)==null?void 0:d.workflow)==null?void 0:w.identifier)!=null?b:""},typeof l.value=="boolean"?{enabled:l.value,email:l.value,sms:l.value,in_app:l.value,chat:l.value,push:l.value}:{condition:l.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(l=>new ze(l,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)}}}),br=r=>m(null,[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 je,Ge,ct,lt,Mt,Ve=class{constructor(e,t,r,n,s){v(this,je);v(this,Ge);v(this,ct);v(this,lt);v(this,Mt,!1);var o;S(this,je,t),S(this,Ge,r),S(this,ct,n),S(this,lt,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 ze(g({},c),a(this,je),a(this,Ge),a(this,ct),a(this,lt)))}update(e){return m(this,null,function*(){return vr({emitter:a(this,je),apiService:a(this,Ge),cache:a(this,ct),useCache:a(this,lt),args:C(g({},e),{subscription:this})})})}updatePreference(e){return m(this,null,function*(){return a(this,Mt)?{error:new x("Cannot update a deleted subscription",new Error("Subscription is stale"))}:gr({emitter:a(this,je),apiService:a(this,Ge),cache:a(this,ct),useCache:a(this,lt),args:C(g({},e),{subscriptionId:this.identifier})})})}bulkUpdatePreferences(e){return m(this,null,function*(){return a(this,Mt)?{error:new x("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:eo({emitter:a(this,je),apiService:a(this,Ge),cache:a(this,ct),useCache:a(this,lt),args:e.map(t=>C(g({},t),{subscriptionId:this.identifier}))})})}delete(){return m(this,null,function*(){return a(this,Mt)?{error:new x("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:br({emitter:a(this,je),apiService:a(this,Ge),args:{subscription:this}})})}};je=new WeakMap,Ge=new WeakMap,ct=new WeakMap,lt=new WeakMap,Mt=new WeakMap;var _t=i=>`list:${i.topicKey}`,to=i=>i.split(":")[1],ut=i=>`item:${i.topicKey}:${i.identifier}`,ie,W,vi,z,bi,Sr=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:r}){v(this,ie);v(this,W);v(this,vi);v(this,z);v(this,bi);this.handleCreate=e=>{let t=_t({topicKey:e.topicKey}),r=a(this,W).get(t);if(r){let n=[...r,e];a(this,W).set(t,n),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,z).set(ut({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=_t({topicKey:e.topicKey}),r=a(this,W).get(t);if(r){let n=r.map(s=>s.id===e.id?e:s);a(this,W).set(t,n),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,z).set(ut({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,W).keys();for(let o of r){let c=a(this,W).get(o);if(!c)continue;let u=!1,h=c.map(l=>{let f=t.get(l.identifier);return f?(u=!0,this.createUpdatedSubscription(l,f)):l});u&&(a(this,W).set(o,h),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:to(o),subscriptions:h}}))}let n=a(this,z).keys();for(let o of n){let c=a(this,z).get(o);if(!c)continue;let u=t.get(c.identifier);if(u){let h=this.createUpdatedSubscription(c,u);a(this,z).set(o,h),a(this,ie).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 Ve({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:r},a(this,ie),a(this,bi),this,a(this,vi))};this.handleDelete=e=>{let t=_t({topicKey:e.topicKey}),r=a(this,W).get(t);if(r){let n=r.filter(s=>s.id!==e.id);a(this,W).set(t,n),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,z).remove(ut({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteByIdentifier=e=>{let t=a(this,W).keys();for(let n of t){let s=a(this,W).get(n);if(s){let o=s.find(c=>c.identifier===e);if(o){let c=s.filter(u=>u.identifier!==e);a(this,W).set(n,c),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:to(n),subscriptions:c}}),a(this,z).remove(ut({topicKey:o.topicKey,identifier:o.identifier}));return}}}let r=a(this,z).keys();for(let n of r){let s=a(this,z).get(n);if(s&&s.identifier===e){a(this,z).remove(n);return}}};S(this,ie,e),S(this,W,new ke),S(this,z,new ke),S(this,bi,t),S(this,vi,r),a(this,ie).on("subscription.create.resolved",({data:n})=>{n&&this.handleCreate(n)}),a(this,ie).on("subscription.update.resolved",({data:n})=>{n&&this.handleUpdate(n)}),a(this,ie).on("subscription.delete.resolved",({args:n})=>{"subscription"in n?this.handleDelete(n.subscription):"identifier"in n&&this.handleDeleteByIdentifier(n.identifier)}),a(this,ie).on("subscription.preference.update.pending",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,ie).on("subscription.preference.update.resolved",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,ie).on("subscription.preferences.bulk_update.resolved",({data:n})=>{n&&n.length>0&&this.handleBulkPreferenceUpdate(n)})}has(e){return a(this,W).get(_t(e))!==void 0}set(e,t){a(this,W).set(_t(e),t);for(let r of t)a(this,z).set(ut({topicKey:e.topicKey,identifier:r.identifier}),r)}setOne(e,t){a(this,z).set(ut(e),t)}getAll(e){return a(this,W).get(_t(e))}get(e){return a(this,z).get(ut(e))}invalidate(e){let t=_t({topicKey:e.topicKey}),r=a(this,W).get(t);if(r)for(let s of r)a(this,z).remove(ut({topicKey:e.topicKey,identifier:s.identifier}));a(this,W).remove(t);let n=a(this,z).keys();for(let s of n)s.startsWith(`item:${e.topicKey}:`)&&a(this,z).remove(s)}clearAll(){a(this,W).clear(),a(this,z).clear()}};ie=new WeakMap,W=new WeakMap,vi=new WeakMap,z=new WeakMap,bi=new WeakMap;var Si,_r=class extends ue{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,Si);this.cache=new fi({emitter:n,inboxService:r}),S(this,Si,t)}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=ui(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=g({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,Si),u=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:u}),!u){let h=yield this._inboxService.fetchNotifications(g({limit:t},r));u={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(l=>new U(l,this._emitter,this._inboxService))},c&&(this.cache.set(o,u),u=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:u}),{data:u}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new x("Failed to fetch notifications",c)}}}))})}count(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){let r=t&&"filters"in t?t.filters:[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 m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return cr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return lr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ur({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return hr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return fr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return dr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return pr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ut({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ut({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Dt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Dt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return qs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){return"notificationIds"in t?kn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):kn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Ws({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return $s({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Ks({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return m(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};Si=new WeakMap;var _i,Ei,wi,Ci,He=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){v(this,_i);v(this,Ei);v(this,wi);v(this,Ci);S(this,_i,t),S(this,Ei,r),S(this,wi,n),S(this,Ci,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return m(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return Er({emitter:a(this,_i),apiService:a(this,Ei),cache:a(this,wi),useCache:a(this,Ci),args:g({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:g(g({},this.weeklySchedule),e.weeklySchedule)})})})}};_i=new WeakMap,Ei=new WeakMap,wi=new WeakMap,Ci=new WeakMap;var xi,Ni,Ai,ki,Ri,De=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){v(this,xi);v(this,Ni);v(this,Ai);v(this,ki);v(this,Ri);S(this,xi,t),S(this,Ni,r),S(this,Ai,n),S(this,ki,s),S(this,Ri,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new He(g({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return wr({emitter:a(this,xi),apiService:a(this,Ni),cache:a(this,Ai),scheduleCache:a(this,ki),useCache:a(this,Ri),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};xi=new WeakMap,Ni=new WeakMap,Ai=new WeakMap,ki=new WeakMap,Ri=new WeakMap;var wr=o=>m(null,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var h;let{channels:c}=s,u="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 De(C(g({},s.preference),{channels:g(g({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let l;u?l=yield e.updateWorkflowPreferences({workflowId:u,channels:c}):(Zc({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),l=yield e.updateGlobalPreferences(c));let f=new De(l,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preference.update.resolved",{args:s,error:l}),{error:new x("Failed to update preference",l)}}}),io=o=>m(null,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){if(s.find(u=>"preference"in u&&u.preference.level==="global"))return{error:new x("Global preference is not supported in bulk update","")};try{let u=s.map(p=>"preference"in p?new De(C(g({},p.preference),{channels:g(g({},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:u});let h=s.map(p=>{var d,w,y,b;return g({workflowId:"workflowId"in p?p.workflowId:(b=(y=(d=p.preference.workflow)==null?void 0:d.id)!=null?y:(w=p.preference.workflow)==null?void 0:w.identifier)!=null?b:""},p.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(p=>new De(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(u){return i.emit("preferences.bulk_update.resolved",{args:s,error:u}),{error:new x("Failed to bulk update preferences",u)}}}),Zc=({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 u,h;if(c.level==="template"){let l=C(g({},c),{channels:Object.entries(c.channels).reduce((p,[d,w])=>{var b;let y=d;return p[y]=(b=s.channels[y])!=null?b:w,p},{})}),f="preference"in s?new De(l,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(h=(u=c.workflow)==null?void 0:u.id)!=null?h:"",channels:f.channels},data:f})}})},Er=s=>m(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:u,weeklySchedule:h}=n,l=new He({isEnabled:u,weeklySchedule:h},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:l});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:u,weeklySchedule:h}}),p=new He({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(u){return i.emit("preference.schedule.update.resolved",{args:n,error:u}),{error:new x("Failed to update preference",u)}}});var ht,Cr=class extends ue{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});v(this,ht);this.cache=t,S(this,ht,r)}get(){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){var t,r;try{let n=a(this,ht)?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 He({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,ht)}),a(this,ht)&&(this.cache.set(n),n=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:n}),{data:n}}catch(n){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Er({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ht),args:t}))})}};ht=new WeakMap;var el=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],tl=["preference.schedule.update.pending","preference.schedule.update.resolved"],il=({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),{}),In=({tags:i,severity:e})=>JSON.stringify(il({tags:i,severity:e})),ft,H,xr=class{constructor({emitterInstance:e}){v(this,ft);v(this,H);this.updatePreference=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>{var c,u;return((c=o.workflow)==null?void 0:c.id)===((u=t.workflow)==null?void 0:u.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,ft).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,ft).emit("preferences.list.updated",{data:(s=a(this,H).get(n))!=null?s:[]})})};S(this,ft,e);for(let t of el)a(this,ft).on(t,this.handlePreferenceEvent);for(let t of tl)a(this,ft).on(t,this.handleScheduleEvent);S(this,H,new ke)}has(e){return a(this,H).get(In(e))!==void 0}set(e,t){a(this,H).set(In(e),t)}getAll(e){if(this.has(e))return a(this,H).get(In(e))}clearAll(){a(this,H).clear()}};ft=new WeakMap,H=new WeakMap;var rl=["preference.schedule.update.pending","preference.schedule.update.resolved"],Pn=()=>"schedule",qt,de,Nr=class{constructor({emitterInstance:e}){v(this,qt);v(this,de);this.updateScheduleInCache=(e,t)=>a(this,de).get(e)?(a(this,de).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,de).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,de).get(n);!s||!o||t.add(n)}for(let n of t)a(this,qt).emit("preference.schedule.get.updated",{data:a(this,de).get(n)})};S(this,qt,e);for(let t of rl)a(this,qt).on(t,this.handleScheduleEvent);S(this,de,new ke)}has(){return a(this,de).get(Pn())!==void 0}set(e){a(this,de).set(Pn(),e)}getAll(){if(this.has())return a(this,de).get(Pn())}clearAll(){a(this,de).clear()}};qt=new WeakMap,de=new WeakMap;var Ye,Ar=class extends ue{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,Ye);this.cache=new xr({emitterInstance:this._emitter}),this.scheduleCache=new Nr({emitterInstance:this._emitter}),S(this,Ye,t),this.schedule=new Cr({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){var r;try{let n=a(this,Ye)?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 De(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Ye)})),a(this,Ye)&&(this.cache.set(t,n),n=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:n}),{data:n}}catch(n){throw this._emitter.emit("preferences.list.resolved",{args:t,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>wr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Ye),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>io({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Ye),args:t}))})}};Ye=new WeakMap;function ro(){return typeof window!="undefined"}var Et,Ti,re,kr=class{constructor(e,t,r){v(this,Et);v(this,Ti);v(this,re);S(this,Et,r),S(this,Ti,t),S(this,re,e)}get applicationIdentifier(){return a(this,re).applicationIdentifier}get subscriberId(){var e;return(e=a(this,re).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,re).context}get subscriberHash(){return a(this,re).subscriberHash}get contextHash(){return a(this,re).contextHash}get subscriber(){return a(this,re).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 m(this,null,function*(){var n,s,o,c,u,h;let t=((n=a(this,re).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,re).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&S(this,re,e);let{subscriber:l,subscriberHash:f,contextHash:p,applicationIdentifier:d,defaultSchedule:w,context:y}=a(this,re),b;ro()&&(b=Intl.DateTimeFormat().resolvedOptions().timeZone);let k=d;if(k)this.handleApplicationIdentifier("delete");else{let _=this.handleApplicationIdentifier("get");_&&(k=_)}a(this,Et).emit("session.initialize.pending",{args:a(this,re)});let N=yield a(this,Ti).initializeSession({applicationIdentifier:k,subscriberHash:f,contextHash:p,subscriber:C(g({},l),{subscriberId:(o=l==null?void 0:l.subscriberId)!=null?o:"",timezone:(c=l==null?void 0:l.timezone)!=null?c:b}),defaultSchedule:w,context:y});(u=N==null?void 0:N.applicationIdentifier)!=null&&u.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,Et).emit("session.initialize.resolved",{args:a(this,re),data:N})}catch(l){a(this,Et).emit("session.initialize.resolved",{args:a(this,re),error:l})}})}};Et=new WeakMap,Ti=new WeakMap,re=new WeakMap;function Fn(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 no({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}function so({topicKey:i,subscriberId:e,contextKey:t}){let r=`tk_${i}:si_${e}`;return t&&t.length>0?`${r}:ctx_${t}`:r}var dt,Ii,Pi,Oi=class extends ue{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n,subscriber:s,contextKey:o}){super({eventEmitterInstance:n,inboxServiceInstance:r});v(this,dt);v(this,Ii);v(this,Pi);this.cache=new Sr({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),S(this,dt,t),S(this,Ii,s),S(this,Pi,o)}list(t,r){return m(this,null,function*(){return this.callWithSession(()=>{var n;return Xs({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,dt)}),args:t})})})}get(t,r){return m(this,null,function*(){return this.callWithSession(()=>{var n,s;return Qs({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,dt)}),args:C(g({},t),{identifier:(s=t.identifier)!=null?s:so({topicKey:t.topicKey,subscriberId:a(this,Ii).subscriberId,contextKey:a(this,Pi)})})})})})}create(t){return m(this,null,function*(){return this.callWithSession(()=>Zs({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,dt),args:t}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>vr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,dt),args:t}))})}delete(t){return m(this,null,function*(){return this.callWithSession(()=>br({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};dt=new WeakMap,Ii=new WeakMap,Pi=new WeakMap;var Rr=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,nl=(function(){try{new Rr.Event("")}catch(i){return!0}return!1})(),sl=(function(){try{new Rr.EventTarget}catch(i){return!0}return!1})();nl&&(Rr.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})());sl&&(Rr.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(u){setTimeout(()=>{throw u})}c&&c.once&&n.delete(o)}return!0},i})());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
18
+ `+s),i.push(r+"m+"+Er.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Sf()+e+" "+i[0]}function Sf(){return te.inspectOpts.hideDate?"":new Date().toISOString()+" "}function _f(...i){return process.stderr.write(_r.formatWithOptions(te.inspectOpts,...i)+`
19
+ `)}function Ef(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Cf(){return process.env.DEBUG}function wf(i){i.inspectOpts={};let e=Object.keys(te.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=te.inspectOpts[e[t]]}Er.exports=Ts()(te);var{formatters:Ic}=Er.exports;Ic.o=function(i){return this.inspectOpts.colors=this.useColors,_r.inspect(i,this.inspectOpts).split(`
20
+ `).map(e=>e.trim()).join(" ")};Ic.O=function(i){return this.inspectOpts.colors=this.useColors,_r.inspect(i,this.inspectOpts)}});var Pc=O((by,Os)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Os.exports=Nc():Os.exports=Oc()});var nl=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,cn=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t="v1",apiUrl:n=this.DEFAULT_BACKEND_URL,headers:r={}}=e||{};this.apiVersion=t,this.apiUrl=`${n}/${t}`,this.headers=y({"Novu-API-Version":NOVU_API_VERSION,"Novu-Client-Version":nl,"Content-Type":"application/json"},r)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var n;let t=e||typeof window!="undefined"&&((n=window.localStorage)==null?void 0:n.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,n=!0){return p(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:n})})}post(e,t,n){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:n==null?void 0:n.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:n,unwrapEnvelope:r=!0}){let o=rl(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(n==null?void 0:n.method)||"GET",headers:y(y({},this.headers),(n==null?void 0:n.headers)||{}),body:n!=null&&n.body?JSON.stringify(n.body):void 0},u=yield fetch(o,c);if(!u.ok){let l=yield u.json();throw new Error(`${this.headers["Novu-Client-Version"]} error. Status: ${u.status}, Message: ${l.message}`)}if(u.status===204)return;let h=yield u.json();return r?h.data:h})}};function rl(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var ne="/inbox",ce=`${ne}/notifications`,sl=`${ne}/chat/oauth`,ln=`${ne}/channel-connections`,un=`${ne}/channel-endpoints`;function Ks(i){let e=new URLSearchParams;if(i.subscriberId&&e.append("subscriberId",i.subscriberId),i.integrationIdentifier&&e.append("integrationIdentifier",i.integrationIdentifier),i.connectionIdentifier&&e.append("connectionIdentifier",i.connectionIdentifier),i.channel&&e.append("channel",i.channel),i.providerId&&e.append("providerId",i.providerId),i.contextKeys!==void 0)if(i.contextKeys.length===0)e.append("contextKeys","");else for(let t of i.contextKeys)e.append("contextKeys",t);return i.limit&&e.append("limit",String(i.limit)),i.after&&e.append("after",i.after),i.before&&e.append("before",i.before),e.size?`?${e.toString()}`:""}function ol(i,e){if(e!==void 0){if(Array.isArray(e)){if(e.length===0)return;for(let t of e)i.append("tags[]",t);return}if("or"in e){if(e.or.length===0)return;for(let t of e.or)i.append("tags[]",t);return}if("and"in e){if(e.and.length===0)return;e.and.forEach((t,n)=>{for(let r of t.or)i.append(`tags[${n}][]`,r)})}}}var A,hn=class{constructor(e={}){this.isSessionInitialized=!1;v(this,A);S(this,A,new cn(e))}initializeSession(c){return p(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:n,subscriber:r,defaultSchedule:s,context:o}){let u=yield a(this,A).post(`${ne}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:n,subscriber:r,defaultSchedule:s,context:o});return a(this,A).setAuthorizationToken(u.token),a(this,A).setKeylessHeader(u.applicationIdentifier),this.isSessionInitialized=!0,u})}fetchNotifications({after:e,archived:t,limit:n=10,offset:r,read:s,tags:o,snoozed:c,seen:u,data:h,severity:l,createdGte:f,createdLte:m}){let d=new URLSearchParams(`limit=${n}`);if(e&&d.append("after",e),r&&d.append("offset",`${r}`),ol(d,o),s!==void 0&&d.append("read",`${s}`),t!==void 0&&d.append("archived",`${t}`),c!==void 0&&d.append("snoozed",`${c}`),u!==void 0&&d.append("seen",`${u}`),h!==void 0&&d.append("data",JSON.stringify(h)),l&&Array.isArray(l))for(let C of l)d.append("severity[]",C);else l&&d.append("severity",l);return f&&d.append("createdGte",`${f}`),m&&d.append("createdLte",`${m}`),a(this,A).get(ce,d,!1)}count({filters:e}){return a(this,A).get(`${ce}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,A).patch(`${ce}/${e}/read`)}unread(e){return a(this,A).patch(`${ce}/${e}/unread`)}archive(e){return a(this,A).patch(`${ce}/${e}/archive`)}unarchive(e){return a(this,A).patch(`${ce}/${e}/unarchive`)}snooze(e,t){return a(this,A).patch(`${ce}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,A).patch(`${ce}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,A).post(`${ce}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,A).post(`${ce}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,A).post(`${ce}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,A).delete(`${ce}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,A).post(`${ce}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:n}){return a(this,A).post(`${ce}/seen`,{notificationIds:e,tags:t,data:n?JSON.stringify(n):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ce}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ce}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:n}){let r=new URLSearchParams;if(e)for(let o of e)r.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)r.append("severity[]",o);else t&&r.append("severity",t);n&&r.append("criticality",n);let s=r.size?`?${r.toString()}`:"";return a(this,A).get(`${ne}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,A).patch(`${ne}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,A).patch(`${ne}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,A).patch(`${ne}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,A).get(`${ne}/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(`${ne}/topics/${e}/subscriptions`)}getSubscription(e,t,n,r){let s=new URLSearchParams;if(n!=null&&n.length)for(let c of n)s.append("workflowIds",c);if(r!=null&&r.length)for(let c of r)s.append("tags",c);let o=s.size?`?${s.toString()}`:"";return a(this,A).get(`${ne}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:n,topicName:r,preferences:s}){return a(this,A).post(`${ne}/topics/${n}/subscriptions`,y(y({identifier:e,name:t},r&&{topic:{name:r}}),s!==void 0&&{preferences:s}))}updateSubscription({topicKey:e,identifier:t,name:n,preferences:r}){return a(this,A).patch(`${ne}/topics/${e}/subscriptions/${t}`,y({name:n},r!==void 0&&{preferences:r}))}updateSubscriptionPreference({subscriptionIdentifier:e,workflowId:t,enabled:n,condition:r,email:s,sms:o,in_app:c,chat:u,push:h}){return a(this,A).patch(`${ne}/subscriptions/${e}/preferences/${t}`,{enabled:n,condition:r,email:s,sms:o,in_app:c,chat:u,push:h})}bulkUpdateSubscriptionPreferences(e){return a(this,A).patch(`${ne}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,identifier:t}){return a(this,A).delete(`${ne}/topics/${e}/subscriptions/${t}`)}generateChatOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:n,context:r,scope:s,userScope:o,mode:c,connectionMode:u}){return a(this,A).post(sl,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:n,context:r,scope:s,userScope:o,mode:c,connectionMode:u})}listChannelConnections(e={}){let t=Ks(e);return a(this,A).get(`${ln}${t}`,void 0,!1)}getChannelConnection(e){return a(this,A).get(`${ln}/${e}`)}createChannelConnection({identifier:e,integrationIdentifier:t,subscriberId:n,context:r,workspace:s,auth:o}){return a(this,A).post(ln,{identifier:e,integrationIdentifier:t,subscriberId:n,context:r,workspace:s,auth:o})}deleteChannelConnection(e){return a(this,A).delete(`${ln}/${e}`)}listChannelEndpoints(e={}){let t=Ks(e);return a(this,A).get(`${un}${t}`,void 0,!1)}getChannelEndpoint(e){return a(this,A).get(`${un}/${e}`)}createChannelEndpoint({identifier:e,integrationIdentifier:t,connectionIdentifier:n,subscriberId:r,context:s,type:o,endpoint:c}){return a(this,A).post(un,{identifier:e,integrationIdentifier:t,connectionIdentifier:n,subscriberId:r,context:s,type:o,endpoint:c})}deleteChannelEndpoint(e){return a(this,A).delete(`${un}/${e}`)}};A=new WeakMap;var w=class extends Error{constructor(e,t){super(e),this.originalError=t}};var at,Ut,j=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){v(this,at,[]);v(this,Ut);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:n,data:r})=>{r?(this.onSessionSuccess(r),a(this,at).forEach(c=>p(this,[c],function*({fn:s,resolve:o}){o(yield s())})),S(this,at,[])):n&&(this.onSessionError(n),S(this,Ut,n),a(this,at).forEach(({resolve:s})=>{s({error:new w("Failed to initialize session, please contact the support",n)})}),S(this,at,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return p(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Ut)?Promise.resolve({error:new w("Failed to initialize session, please contact the support",a(this,Ut))}):new Promise((t,n)=>{a(this,at).push({fn:e,resolve:t,reject:n})})})}};at=new WeakMap,Ut=new WeakMap;var zs=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{i.emit("channel-connection.oauth-url.pending",{args:t});let r=yield e.generateChatOAuthUrl(t);return i.emit("channel-connection.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return i.emit("channel-connection.oauth-url.resolved",{args:t,error:r}),{error:new w("Failed to generate chat OAuth URL",r)}}}),Gs=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{i.emit("channel-connections.list.pending",{args:t});let s=(yield e.listChannelConnections(t)).data;return i.emit("channel-connections.list.resolved",{args:t,data:s}),{data:s}}catch(r){return i.emit("channel-connections.list.resolved",{args:t,error:r}),{error:new w("Failed to list channel connections",r)}}}),Vs=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{i.emit("channel-connection.get.pending",{args:t});let r=yield e.getChannelConnection(t.identifier);return i.emit("channel-connection.get.resolved",{args:t,data:r}),{data:r}}catch(r){return i.emit("channel-connection.get.resolved",{args:t,error:r}),{error:new w("Failed to get channel connection",r)}}}),js=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{return i.emit("channel-connection.delete.pending",{args:t}),yield e.deleteChannelConnection(t.identifier),i.emit("channel-connection.delete.resolved",{args:t}),{data:void 0}}catch(r){return i.emit("channel-connection.delete.resolved",{args:t,error:r}),{error:new w("Failed to delete channel connection",r)}}});var hi=class extends j{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){super({inboxServiceInstance:e,eventEmitterInstance:t})}generateOAuthUrl(e){return p(this,null,function*(){return this.callWithSession(()=>zs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}list(){return p(this,arguments,function*(e={}){return this.callWithSession(()=>Gs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}get(e){return p(this,null,function*(){return this.callWithSession(()=>Vs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}delete(e){return p(this,null,function*(){return this.callWithSession(()=>js({emitter:this._emitter,apiService:this._inboxService,args:e}))})}};var Hs=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{i.emit("channel-endpoints.list.pending",{args:t});let s=(yield e.listChannelEndpoints(t)).data;return i.emit("channel-endpoints.list.resolved",{args:t,data:s}),{data:s}}catch(r){return i.emit("channel-endpoints.list.resolved",{args:t,error:r}),{error:new w("Failed to list channel endpoints",r)}}}),Ys=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{i.emit("channel-endpoint.get.pending",{args:t});let r=yield e.getChannelEndpoint(t.identifier);return i.emit("channel-endpoint.get.resolved",{args:t,data:r}),{data:r}}catch(r){return i.emit("channel-endpoint.get.resolved",{args:t,error:r}),{error:new w("Failed to get channel endpoint",r)}}}),Js=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{i.emit("channel-endpoint.create.pending",{args:t});let r=yield e.createChannelEndpoint(t);return i.emit("channel-endpoint.create.resolved",{args:t,data:r}),{data:r}}catch(r){return i.emit("channel-endpoint.create.resolved",{args:t,error:r}),{error:new w("Failed to create channel endpoint",r)}}}),Xs=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){try{return i.emit("channel-endpoint.delete.pending",{args:t}),yield e.deleteChannelEndpoint(t.identifier),i.emit("channel-endpoint.delete.resolved",{args:t}),{data:void 0}}catch(r){return i.emit("channel-endpoint.delete.resolved",{args:t,error:r}),{error:new w("Failed to delete channel endpoint",r)}}});var fi=class extends j{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){super({inboxServiceInstance:e,eventEmitterInstance:t})}list(){return p(this,arguments,function*(e={}){return this.callWithSession(()=>Hs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}get(e){return p(this,null,function*(){return this.callWithSession(()=>Ys({emitter:this._emitter,apiService:this._inboxService,args:e}))})}create(e){return p(this,null,function*(){return this.callWithSession(()=>Js({emitter:this._emitter,apiService:this._inboxService,args:e}))})}delete(e){return p(this,null,function*(){return this.callWithSession(()=>Xs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}};function Qs(i){return{all:i=i||new Map,on:function(e,t){var n=i.get(e);n?n.push(t):i.set(e,[t])},off:function(e,t){var n=i.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var n=i.get(e);n&&n.slice().map(function(r){r(t)}),(n=i.get("*"))&&n.slice().map(function(r){r(e,t)})}}}var bt,fn=class{constructor(){v(this,bt);S(this,bt,Qs())}on(e,t){return a(this,bt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,bt).off(e,t)}emit(e,t){a(this,bt).emit(e,t)}};bt=new WeakMap;var dn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(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(r),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)}}}),pn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(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(r),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)}}}),mn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(r),!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)}}}),gn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(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(r),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)}}}),yn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(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(r),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)}}}),vn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(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(r,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)}}}),bn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=De(t,{isSnoozed:!1,snoozedUntil:null},{emitter:i,apiService:e});try{i.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(r),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)}}}),Dt=r=>p(null,[r],function*({emitter:i,apiService:e,args:t,actionType:n}){let s=n==="primary"?{primaryAction:x(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:x(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=De(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let u=yield e.completeAction({actionType:n,notificationId:o}),h=new U(u,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(u){return i.emit("notification.complete_action.resolved",{args:t,error:u}),{error:new w(`Failed to complete ${n} action on the notification`,u)}}}),Bt=r=>p(null,[r],function*({emitter:i,apiService:e,args:t,actionType:n}){let s=n==="primary"?{primaryAction:x(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:x(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=De(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let u=yield e.revertAction({actionType:n,notificationId:o}),h=new U(u,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(u){return i.emit("notification.revert_action.resolved",{args:t,error:u}),{error:new w("Failed to fetch notifications",u)}}}),De=(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},Zs=s=>p(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:n,data:r}){try{let c=t.getUniqueNotifications({tags:n,data:r}).map(u=>new U(x(y({},u),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:n,data:r},data:c}),yield e.readAll({tags:n,data:r}),i.emit("notifications.read_all.resolved",{args:{tags:n,data:r},data:c}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:n,data:r},error:o}),{error:new w("Failed to read all notifications",o)}}}),Or=o=>p(null,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:n,tags:r,data:s}){try{let c=t.getUniqueNotifications({tags:r,data:s}),h=(n&&n.length>0?c.filter(l=>n.includes(l.id)):c).map(l=>new U(x(y({},l),{isSeen:!0,firstSeenAt:l.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:n,tags:r,data:s},data:h}),yield e.markAsSeen({notificationIds:n,tags:r,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:n,tags:r,data:s},data:h}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:n,tags:r,data:s},error:c}),{error:new w("Failed to mark all notifications as seen",c)}}}),eo=s=>p(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:n,data:r}){try{let c=t.getUniqueNotifications({tags:n,data:r}).map(u=>new U(x(y({},u),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all.pending",{args:{tags:n,data:r},data:c}),yield e.archiveAll({tags:n,data:r}),i.emit("notifications.archive_all.resolved",{args:{tags:n,data:r},data:c}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:n,data:r},error:o}),{error:new w("Failed to archive all notifications",o)}}}),to=s=>p(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:n,data:r}){try{let c=t.getUniqueNotifications({tags:n,data:r,read:!0}).map(u=>new U(x(y({},u),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:n,data:r},data:c}),yield e.archiveAllRead({tags:n,data:r}),i.emit("notifications.archive_all_read.resolved",{args:{tags:n,data:r},data:c}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:n,data:r},error:o}),{error:new w("Failed to archive all read notifications",o)}}}),Sn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let{notificationId:r}=De(t,{},{emitter:i,apiService:e});try{return i.emit("notification.delete.pending",{args:t}),yield e.delete(r),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)}}}),io=s=>p(null,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:n,data:r}){try{let o=t.getUniqueNotifications({tags:n,data:r});return i.emit("notifications.delete_all.pending",{args:{tags:n,data:r},data:o}),yield e.deleteAll({tags:n,data:r}),i.emit("notifications.delete_all.resolved",{args:{tags:n,data:r}}),{}}catch(o){return i.emit("notifications.delete_all.resolved",{args:{tags:n,data:r},error:o}),{error:new w("Failed to delete all notifications",o)}}});var H,le,U=class{constructor(e,t,n){v(this,H);v(this,le);S(this,H,t),S(this,le,n),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 dn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}unread(){return pn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}seen(){return mn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}archive(){return gn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}unarchive(){return yn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}delete(){return Sn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}snooze(e){return vn({emitter:a(this,H),apiService:a(this,le),args:{notification:this,snoozeUntil:e}})}unsnooze(){return bn({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Dt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Dt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Bt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Bt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"secondary"})}on(e,t){let n=a(this,H).on(e,t);return()=>{n()}}off(e,t){a(this,H).off(e,t)}};H=new WeakMap,le=new WeakMap;function no({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var ro=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,n)=>t===e[n]);var Id=["seen","unseen"],Od=["read","unread"],so=30,_n=100,oo=200,K=class extends Error{constructor(e){super(e),this.name="TagsFilterValidationError"}};function ao(i,e){if(i.length>e)throw new K(`At most ${e} tags are allowed in a single OR-group`);for(let t of i)if(typeof t!="string")throw new K("Tags must be strings");return i}function al(i){let e=Object.keys(i),t=Object.prototype.hasOwnProperty.call(i,"or"),n=Object.prototype.hasOwnProperty.call(i,"and");if(t&&n)throw new K('Tags filter cannot have both "or" and "and"');if(t){if(e.length!==1)throw new K("Invalid tags filter object");let r=i.or;if(!Array.isArray(r))throw new K('"or" must be an array of strings');return r.length===0?[]:[ao(r,_n)]}if(n){if(e.length!==1)throw new K("Invalid tags filter object");let r=i.and;if(!Array.isArray(r))throw new K('"and" must be an array');if(r.length===0)return[];if(r.length>so)throw new K(`At most ${so} tag groups are allowed`);let s=[],o=0;for(let c of r){if(typeof c!="object"||c===null||Array.isArray(c))throw new K('Each "and" entry must be an object { or: string[] }');if(Object.keys(c).length!==1||!Object.prototype.hasOwnProperty.call(c,"or"))throw new K('Each "and" entry must be { or: string[] }');let h=c.or;if(!Array.isArray(h))throw new K('"or" must be an array of strings');if(h.length===0)throw new K("Each tag group must be a non-empty array of strings");let l=ao(h,_n);o+=l.length,s.push(l)}if(o>oo)throw new K(`At most ${oo} total tag values are allowed`);return s}throw new K('Tags filter object must have "or" or "and"')}function cl(i){if(i===void 0)return[];if(i===null)throw new K("Tags must be an array or object");if(typeof i=="object"&&!Array.isArray(i))return al(i);if(!Array.isArray(i))throw new K("Tags must be an array or object");if(i.length===0)return[];if(Array.isArray(i[0]))throw new K("Nested tag arrays are not supported; use { and: [{ or: string[] }, ...] } for multiple OR-groups");let e=i;if(e.length>_n)throw new K(`At most ${_n} tags are allowed in a single OR-group`);for(let t of e)if(typeof t!="string")throw new K("Tags must be strings");return[e]}function co(i){if(i===void 0)return"";let e=cl(i);if(e.length===0)return"";let t=Array.from(new Map(e.map(n=>{let r=Array.from(new Set(n)).sort((s,o)=>s.localeCompare(o));return[JSON.stringify(r),r]})).values()).sort((n,r)=>JSON.stringify(n).localeCompare(JSON.stringify(r)));return JSON.stringify(t)}var Pr=(i,e)=>{try{return co(i)===co(e)}catch(t){return!1}},ll=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],n=Array.isArray(e)?e:e?[e]:[];return ro(t,n)},Fr=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},Lr=(i,e)=>Fr(i.data,e.data)&&Pr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&ll(i.severity,e.severity)&&i.createdGte===e.createdGte&&i.createdLte===e.createdLte;var ke,Re=class{constructor(){v(this,ke);S(this,ke,new Map)}get(e){return a(this,ke).get(e)}getValues(){return Array.from(a(this,ke).values())}entries(){return Array.from(a(this,ke).entries())}keys(){return Array.from(a(this,ke).keys())}set(e,t){a(this,ke).set(e,t)}remove(e){a(this,ke).delete(e)}clear(){a(this,ke).clear()}};ke=new WeakMap;var lo=({tags:i,data:e,read:t,archived:n,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>Object.entries({tags:i,data:e,read:t,archived:n,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f}).filter(([m,d])=>d!=null&&!(Array.isArray(d)&&d.length===0)).reduce((m,[d,C])=>(m[d]=C,m),{}),di=({tags:i,data:e,read:t,archived:n,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>JSON.stringify(lo({tags:i,data:e,read:t,archived:n,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})),ul=({tags:i,data:e,read:t,archived:n,snoozed:r,seen:s,severity:o,createdGte:c,createdLte:u})=>JSON.stringify(lo({tags:i,data:e,read:t,archived:n,snoozed:r,seen:s,severity:o,createdGte:c,createdLte:u})),St=i=>JSON.parse(i),hl=["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"],fl=["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"],ze,mi,q,pi=class{constructor({emitter:e,inboxService:t}){v(this,ze);v(this,mi);v(this,q);this.updateNotification=(e,t)=>{let n=a(this,q).get(e);if(!n)return!1;let r=n.notifications.findIndex(o=>o.id===t.id);if(r===-1)return!1;let s=[...n.notifications];return s[r]=t,a(this,q).set(e,x(y({},n),{notifications:s})),!0};this.removeNotification=(e,t)=>{let n=a(this,q).get(e);if(!n)return!1;let r=n.notifications.findIndex(o=>o.id===t.id);if(r===-1)return!1;let s=[...n.notifications];return s.splice(r,1),a(this,q).set(e,x(y({},n),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:n,args:r}=t,s=[];if(n!=null)Array.isArray(n)&&n.every(c=>typeof c=="object"&&"id"in c)?s=n:typeof n=="object"&&"id"in n&&(s=[n]);else if(e&&r){if("notification"in r&&r.notification)s=[r.notification];else if("notificationId"in r&&r.notificationId){let c=[];a(this,q).keys().forEach(u=>{let h=a(this,q).get(u);if(h){let l=h.notifications.find(f=>f.id===r.notificationId);l&&c.push(l)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,q).keys().forEach(c=>{s.forEach(u=>{let h=!1;e?h=this.removeNotification(c,u):h=this.updateNotification(c,u),h&&o.add(ul(St(c)))})}),o.forEach(c=>{let u=this.getAggregated(St(c));a(this,ze).emit("notifications.list.updated",{data:u})})};S(this,ze,e),S(this,mi,t),hl.forEach(n=>{a(this,ze).on(n,this.handleNotificationEvent())}),fl.forEach(n=>{a(this,ze).on(n,this.handleNotificationEvent({remove:!0}))}),S(this,q,new Re)}getAggregated(e){return a(this,q).keys().filter(n=>{let r=St(n);return Lr(r,e)}).map(n=>a(this,q).get(n)).reduce((n,r)=>r?{hasMore:r.hasMore,filter:r.filter,notifications:[...n.notifications,...r.notifications]}:n,{hasMore:!1,filter:{},notifications:[]})}get(e){return a(this,q).get(di(e))}has(e){return a(this,q).get(di(e))!==void 0}set(e,t){a(this,q).set(di(e),t)}unshift(e,t){let n=di(e),r=a(this,q).get(n)||{hasMore:!1,filter:St(n),notifications:[]},s=no({notification:y({},t),emitter:a(this,ze),inboxService:a(this,mi)});this.update(e,x(y({},r),{notifications:[s,...r.notifications]}))}update(e,t){this.set(e,t);let n=this.getAggregated(St(di(e)));a(this,ze).emit("notifications.list.updated",{data:n})}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:n}){let r=a(this,q).keys(),s=new Map;return r.forEach(o=>{let c=St(o);if(Pr(e,c.tags)&&Fr(n,c.data)){let u=a(this,q).get(o);if(!u)return;u.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,q).keys().forEach(n=>{Lr(St(n),e)&&a(this,q).remove(n)})}clearAll(){a(this,q).clear()}};ze=new WeakMap,mi=new WeakMap,q=new WeakMap;var gi,yi,vi,bi,Ge=class{constructor(e,t,n,r,s){v(this,gi);v(this,yi);v(this,vi);v(this,bi);var o;S(this,gi,t),S(this,yi,n),S(this,vi,r),S(this,bi,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 En({emitter:a(this,gi),apiService:a(this,yi),cache:a(this,vi),useCache:a(this,bi),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};gi=new WeakMap,yi=new WeakMap,vi=new WeakMap,bi=new WeakMap;var uo=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,options:n,args:r}){try{let{useCache:o,refetch:c}=n,u=o&&!c?t.getAll(r):void 0;return i.emit("subscriptions.list.pending",{args:r,data:u}),(!u||c)&&(u=(yield e.fetchSubscriptions(r.topicKey)).map(l=>new Ve(x(y({},l),{topicKey:r.topicKey}),i,e,t,o)),o&&(t.set(r,u),u=t.getAll(r))),i.emit("subscriptions.list.resolved",{args:r,data:u}),{data:u}}catch(o){return i.emit("subscriptions.list.resolved",{args:r,error:o}),{error:new w("Failed to fetch subscriptions",o)}}}),ho=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,options:n,args:r}){try{let{useCache:o,refetch:c}=n,u=o&&!c?t.get(r):void 0;if(i.emit("subscription.get.pending",{args:r,data:u}),!u||c){let h=yield e.getSubscription(r.topicKey,r.identifier,r.workflowIds,r.tags);if(!h)return i.emit("subscription.get.resolved",{args:r,data:null}),{data:null};u=new Ve(x(y({},h),{topicKey:r.topicKey}),i,e,t,o),o&&(t.setOne(r,u),u=t.get(r))}return i.emit("subscription.get.resolved",{args:r,data:u}),{data:u}}catch(o){return i.emit("subscription.get.resolved",{args:r,error:o}),{error:new w("Failed to fetch subscription",o)}}}),fo=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:n,args:r}){var o;try{i.emit("subscription.create.pending",{args:r});let c=yield e.createSubscription({identifier:(o=r.identifier)!=null?o:"",name:r.name,topicKey:r.topicKey,topicName:r.topicName,preferences:r.preferences}),u=new Ve(x(y({},c),{topicKey:r.topicKey}),i,e,t,n);return i.emit("subscription.create.resolved",{args:r,data:u}),{data:u}}catch(c){return i.emit("subscription.create.resolved",{args:r,error:c}),{error:new w("Failed to create subscription",c)}}}),Cn=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:n,args:r}){let o="identifier"in r?r.identifier:r.subscription.identifier,c="topicKey"in r?r.topicKey:r.subscription.topicKey;try{i.emit("subscription.update.pending",{args:r});let u=yield e.updateSubscription({topicKey:c,identifier:o,name:r.name,preferences:r.preferences}),h=new Ve(x(y({},u),{topicKey:c}),i,e,t,n);return i.emit("subscription.update.resolved",{args:r,data:h}),{data:h}}catch(u){return i.emit("subscription.update.resolved",{args:r,error:u}),{error:new w("Failed to update subscription",u)}}}),En=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:n,args:r}){var c,u;let o="workflowId"in r?r.workflowId:(u=(c=r.preference)==null?void 0:c.workflow)==null?void 0:u.id;try{i.emit("subscription.preference.update.pending",{args:r,data:"preference"in r?new Ge(y(y({},r.preference),typeof r.value=="boolean"?{enabled:r.value}:{condition:r.value}),i,e,t,n):void 0});let h=yield e.updateSubscriptionPreference(y({subscriptionIdentifier:r.subscriptionId,workflowId:o},typeof r.value=="boolean"?{enabled:r.value,email:r.value,sms:r.value,in_app:r.value,chat:r.value,push:r.value}:{condition:r.value})),l=new Ge(y({},h),i,e,t,n);return i.emit("subscription.preference.update.resolved",{args:r,data:l}),{data:l}}catch(h){return i.emit("subscription.preference.update.resolved",{args:r,error:h}),{error:new w("Failed to update subscription",h)}}}),po=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:n,args:r}){try{let o=r.map(l=>"preference"in l?new Ge(y(y({},l.preference),typeof l.value=="boolean"?{enabled:l.value}:{condition:l.value}),i,e,t,n):void 0).filter(l=>l!==void 0);i.emit("subscription.preferences.bulk_update.pending",{args:r,data:o});let c=r.map(l=>{var f,m,d,C,g,b;return y({subscriptionIdentifier:l.subscriptionId,workflowId:"workflowId"in l?l.workflowId:(b=(g=(m=(f=l.preference)==null?void 0:f.workflow)==null?void 0:m.id)!=null?g:(C=(d=l.preference)==null?void 0:d.workflow)==null?void 0:C.identifier)!=null?b:""},typeof l.value=="boolean"?{enabled:l.value,email:l.value,sms:l.value,in_app:l.value,chat:l.value,push:l.value}:{condition:l.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(l=>new Ge(l,i,e,t,n));return i.emit("subscription.preferences.bulk_update.resolved",{args:r,data:h}),{data:h}}catch(o){return i.emit("subscription.preferences.bulk_update.resolved",{args:r,error:o}),{error:new w("Failed to bulk update subscription preferences",o)}}}),wn=n=>p(null,[n],function*({emitter:i,apiService:e,args:t}){let r="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:r}),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 je,He,ct,lt,Mt,Ve=class{constructor(e,t,n,r,s){v(this,je);v(this,He);v(this,ct);v(this,lt);v(this,Mt,!1);var o;S(this,je,t),S(this,He,n),S(this,ct,r),S(this,lt,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 Ge(y({},c),a(this,je),a(this,He),a(this,ct),a(this,lt)))}update(e){return p(this,null,function*(){return Cn({emitter:a(this,je),apiService:a(this,He),cache:a(this,ct),useCache:a(this,lt),args:x(y({},e),{subscription:this})})})}updatePreference(e){return p(this,null,function*(){return a(this,Mt)?{error:new w("Cannot update a deleted subscription",new Error("Subscription is stale"))}:En({emitter:a(this,je),apiService:a(this,He),cache:a(this,ct),useCache:a(this,lt),args:x(y({},e),{subscriptionId:this.identifier})})})}bulkUpdatePreferences(e){return p(this,null,function*(){return a(this,Mt)?{error:new w("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:po({emitter:a(this,je),apiService:a(this,He),cache:a(this,ct),useCache:a(this,lt),args:e.map(t=>x(y({},t),{subscriptionId:this.identifier}))})})}delete(){return p(this,null,function*(){return a(this,Mt)?{error:new w("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:wn({emitter:a(this,je),apiService:a(this,He),args:{subscription:this}})})}};je=new WeakMap,He=new WeakMap,ct=new WeakMap,lt=new WeakMap,Mt=new WeakMap;var _t=i=>`list:${i.topicKey}`,mo=i=>i.split(":")[1],ut=i=>`item:${i.topicKey}:${i.identifier}`,re,W,Si,z,_i,xn=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:n}){v(this,re);v(this,W);v(this,Si);v(this,z);v(this,_i);this.handleCreate=e=>{let t=_t({topicKey:e.topicKey}),n=a(this,W).get(t);if(n){let r=[...n,e];a(this,W).set(t,r),a(this,re).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).set(ut({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=_t({topicKey:e.topicKey}),n=a(this,W).get(t);if(n){let r=n.map(s=>s.id===e.id?e:s);a(this,W).set(t,r),a(this,re).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).set(ut({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 n=a(this,W).keys();for(let o of n){let c=a(this,W).get(o);if(!c)continue;let u=!1,h=c.map(l=>{let f=t.get(l.identifier);return f?(u=!0,this.createUpdatedSubscription(l,f)):l});u&&(a(this,W).set(o,h),a(this,re).emit("subscriptions.list.updated",{data:{topicKey:mo(o),subscriptions:h}}))}let r=a(this,z).keys();for(let o of r){let c=a(this,z).get(o);if(!c)continue;let u=t.get(c.identifier);if(u){let h=this.createUpdatedSubscription(c,u);a(this,z).set(o,h),a(this,re).emit("subscription.update.resolved",{args:{subscription:c},data:h})}}};this.createUpdatedSubscription=(e,t)=>{var r;let n=(r=e.preferences)==null?void 0:r.map(s=>{let o=t.find(c=>c.workflow.id===s.workflow.id);return o||s});return new Ve({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:n},a(this,re),a(this,_i),this,a(this,Si))};this.handleDelete=e=>{let t=_t({topicKey:e.topicKey}),n=a(this,W).get(t);if(n){let r=n.filter(s=>s.id!==e.id);a(this,W).set(t,r),a(this,re).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).remove(ut({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteByIdentifier=e=>{let t=a(this,W).keys();for(let r of t){let s=a(this,W).get(r);if(s){let o=s.find(c=>c.identifier===e);if(o){let c=s.filter(u=>u.identifier!==e);a(this,W).set(r,c),a(this,re).emit("subscriptions.list.updated",{data:{topicKey:mo(r),subscriptions:c}}),a(this,z).remove(ut({topicKey:o.topicKey,identifier:o.identifier}));return}}}let n=a(this,z).keys();for(let r of n){let s=a(this,z).get(r);if(s&&s.identifier===e){a(this,z).remove(r);return}}};S(this,re,e),S(this,W,new Re),S(this,z,new Re),S(this,_i,t),S(this,Si,n),a(this,re).on("subscription.create.resolved",({data:r})=>{r&&this.handleCreate(r)}),a(this,re).on("subscription.update.resolved",({data:r})=>{r&&this.handleUpdate(r)}),a(this,re).on("subscription.delete.resolved",({args:r})=>{"subscription"in r?this.handleDelete(r.subscription):"identifier"in r&&this.handleDeleteByIdentifier(r.identifier)}),a(this,re).on("subscription.preference.update.pending",({data:r})=>{r&&this.handlePreferenceUpdate(r)}),a(this,re).on("subscription.preference.update.resolved",({data:r})=>{r&&this.handlePreferenceUpdate(r)}),a(this,re).on("subscription.preferences.bulk_update.resolved",({data:r})=>{r&&r.length>0&&this.handleBulkPreferenceUpdate(r)})}has(e){return a(this,W).get(_t(e))!==void 0}set(e,t){a(this,W).set(_t(e),t);for(let n of t)a(this,z).set(ut({topicKey:e.topicKey,identifier:n.identifier}),n)}setOne(e,t){a(this,z).set(ut(e),t)}getAll(e){return a(this,W).get(_t(e))}get(e){return a(this,z).get(ut(e))}invalidate(e){let t=_t({topicKey:e.topicKey}),n=a(this,W).get(t);if(n)for(let s of n)a(this,z).remove(ut({topicKey:e.topicKey,identifier:s.identifier}));a(this,W).remove(t);let r=a(this,z).keys();for(let s of r)s.startsWith(`item:${e.topicKey}:`)&&a(this,z).remove(s)}clearAll(){a(this,W).clear(),a(this,z).clear()}};re=new WeakMap,W=new WeakMap,Si=new WeakMap,z=new WeakMap,_i=new WeakMap;var Ei,An=class extends j{constructor({useCache:t,inboxServiceInstance:n,eventEmitterInstance:r}){super({eventEmitterInstance:r,inboxServiceInstance:n});v(this,Ei);this.cache=new pi({emitter:r,inboxService:n}),S(this,Ei,t)}list(){return p(this,arguments,function*(r={}){var s=r,{limit:t=10}=s,n=ui(s,["limit"]);return this.callWithSession(()=>p(this,null,function*(){let o=y({limit:t},n);try{let c="useCache"in o?o.useCache:a(this,Ei),u=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:u}),!u){let h=yield this._inboxService.fetchNotifications(y({limit:t},n));u={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(l=>new U(l,this._emitter,this._inboxService))},c&&(this.cache.set(o,u),u=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:u}),{data:u}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new w("Failed to fetch notifications",c)}}}))})}count(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){let n=t&&"filters"in t?t.filters:[y({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let r=yield this._inboxService.count({filters:n}),s=t&&"filters"in t?{counts:r.data}:r.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(r){return this._emitter.emit("notifications.count.resolved",{args:t,error:r}),{error:new w("Failed to count notifications",r)}}}))})}read(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return dn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return pn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return mn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return gn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return yn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Sn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return vn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return bn({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Dt({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 Dt({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 Bt({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 Bt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return p(this,arguments,function*({tags:t,data:n}={}){return this.callWithSession(()=>p(this,null,function*(){return Zs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:n})}))})}seenAll(){return p(this,arguments,function*(t={}){return this.callWithSession(()=>p(this,null,function*(){return"notificationIds"in t?Or({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Or({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:n}={}){return this.callWithSession(()=>p(this,null,function*(){return eo({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:n})}))})}archiveAllRead(){return p(this,arguments,function*({tags:t,data:n}={}){return this.callWithSession(()=>p(this,null,function*(){return to({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:n})}))})}deleteAll(){return p(this,arguments,function*({tags:t,data:n}={}){return this.callWithSession(()=>p(this,null,function*(){return io({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:n})}))})}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()})}};Ei=new WeakMap;var Ci,wi,xi,Ai,Ye=class{constructor(e,{emitterInstance:t,inboxServiceInstance:n,cache:r,useCache:s}){v(this,Ci);v(this,wi);v(this,xi);v(this,Ai);S(this,Ci,t),S(this,wi,n),S(this,xi,r),S(this,Ai,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return p(this,null,function*(){var n;let t=!!e.weeklySchedule||!!this.weeklySchedule;return Nn({emitter:a(this,Ci),apiService:a(this,wi),cache:a(this,xi),useCache:a(this,Ai),args:y({isEnabled:(n=e.isEnabled)!=null?n:this.isEnabled},t&&{weeklySchedule:y(y({},this.weeklySchedule),e.weeklySchedule)})})})}};Ci=new WeakMap,wi=new WeakMap,xi=new WeakMap,Ai=new WeakMap;var Ni,ki,Ri,Ti,Ii,Be=class{constructor(e,{emitterInstance:t,inboxServiceInstance:n,cache:r,scheduleCache:s,useCache:o}){v(this,Ni);v(this,ki);v(this,Ri);v(this,Ti);v(this,Ii);S(this,Ni,t),S(this,ki,n),S(this,Ri,r),S(this,Ti,s),S(this,Ii,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Ye(y({},e.schedule),{emitterInstance:t,inboxServiceInstance:n,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var n;return kn({emitter:a(this,Ni),apiService:a(this,ki),cache:a(this,Ri),scheduleCache:a(this,Ti),useCache:a(this,Ii),args:{workflowId:(n=this.workflow)==null?void 0:n.id,channels:e||t,preference:this}})}};Ni=new WeakMap,ki=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,Ii=new WeakMap;var kn=o=>p(null,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:n,useCache:r,args:s}){var h;let{channels:c}=s,u="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 Be(x(y({},s.preference),{channels:y(y({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:n,useCache:r}):void 0});let l;u?l=yield e.updateWorkflowPreferences({workflowId:u,channels:c}):(dl({emitter:i,apiService:e,cache:t,scheduleCache:n,useCache:r,args:s}),l=yield e.updateGlobalPreferences(c));let f=new Be(l,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:n,useCache:r});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preference.update.resolved",{args:s,error:l}),{error:new w("Failed to update preference",l)}}}),go=o=>p(null,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:n,useCache:r,args:s}){if(s.find(u=>"preference"in u&&u.preference.level==="global"))return{error:new w("Global preference is not supported in bulk update","")};try{let u=s.map(m=>"preference"in m?new Be(x(y({},m.preference),{channels:y(y({},m.preference.channels),m.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:n,useCache:r}):void 0).filter(m=>m!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:u});let h=s.map(m=>{var d,C,g,b;return y({workflowId:"workflowId"in m?m.workflowId:(b=(g=(d=m.preference.workflow)==null?void 0:d.id)!=null?g:(C=m.preference.workflow)==null?void 0:C.identifier)!=null?b:""},m.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(m=>new Be(m,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:n,useCache:r}));return i.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(u){return i.emit("preferences.bulk_update.resolved",{args:s,error:u}),{error:new w("Failed to bulk update preferences",u)}}}),dl=({emitter:i,apiService:e,cache:t,scheduleCache:n,useCache:r,args:s})=>{let o=r?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var u,h;if(c.level==="template"){let l=x(y({},c),{channels:Object.entries(c.channels).reduce((m,[d,C])=>{var b;let g=d;return m[g]=(b=s.channels[g])!=null?b:C,m},{})}),f="preference"in s?new Be(l,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:n,useCache:r}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(h=(u=c.workflow)==null?void 0:u.id)!=null?h:"",channels:f.channels},data:f})}})},Nn=s=>p(null,[s],function*({emitter:i,apiService:e,cache:t,useCache:n,args:r}){var o,c;try{let{isEnabled:u,weeklySchedule:h}=r,l=new Ye({isEnabled:u,weeklySchedule:h},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:n});i.emit("preference.schedule.update.pending",{args:r,data:l});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:u,weeklySchedule:h}}),m=new Ye({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:n});return i.emit("preference.schedule.update.resolved",{args:r,data:m}),{data:m}}catch(u){return i.emit("preference.schedule.update.resolved",{args:r,error:u}),{error:new w("Failed to update preference",u)}}});var ht,Rn=class extends j{constructor({cache:t,useCache:n,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,ht);this.cache=t,S(this,ht,n)}get(){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){var t,n;try{let r=a(this,ht)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:r}),!r){let s=yield this._inboxService.fetchGlobalPreferences();r=new Ye({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(n=s==null?void 0:s.schedule)==null?void 0:n.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,ht)}),a(this,ht)&&(this.cache.set(r),r=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:r}),{data:r}}catch(r){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:r}),r}}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>Nn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ht),args:t}))})}};ht=new WeakMap;var pl=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],ml=["preference.schedule.update.pending","preference.schedule.update.resolved"],gl=({tags:i,severity:e})=>Object.entries({tags:i,severity:e}).reduce((t,[n,r])=>(r==null||Array.isArray(r)&&r.length===0||(t[n]=r),t),{}),Ur=({tags:i,severity:e})=>JSON.stringify(gl({tags:i,severity:e})),ft,Y,Tn=class{constructor({emitterInstance:e}){v(this,ft);v(this,Y);this.updatePreference=(e,t)=>{let n=a(this,Y).get(e);if(!n)return!1;let r=n.findIndex(o=>{var c,u;return((c=o.workflow)==null?void 0:c.id)===((u=t.workflow)==null?void 0:u.id)||o.level===t.level&&t.level==="global"});if(r===-1)return!1;let s=[...n];return s[r]=t,a(this,Y).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let n=a(this,Y).get(e);if(!n)return!1;let r=n.findIndex(o=>o.level==="global");if(r===-1)return!1;let s=[...n];return s[r].schedule=t,a(this,Y).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var r;if(!e)return;let t=a(this,Y).keys(),n=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,Y).get(s);!o||!c||n.add(s)}for(let s of n)a(this,ft).emit("preferences.list.updated",{data:(r=a(this,Y).get(s))!=null?r:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],n=new Set;a(this,Y).keys().forEach(r=>{t.forEach(s=>{let o=this.updatePreference(r,s),c=a(this,Y).get(r);!o||!c||n.add(r)})}),n.forEach(r=>{var s;a(this,ft).emit("preferences.list.updated",{data:(s=a(this,Y).get(r))!=null?s:[]})})};S(this,ft,e);for(let t of pl)a(this,ft).on(t,this.handlePreferenceEvent);for(let t of ml)a(this,ft).on(t,this.handleScheduleEvent);S(this,Y,new Re)}has(e){return a(this,Y).get(Ur(e))!==void 0}set(e,t){a(this,Y).set(Ur(e),t)}getAll(e){if(this.has(e))return a(this,Y).get(Ur(e))}clearAll(){a(this,Y).clear()}};ft=new WeakMap,Y=new WeakMap;var yl=["preference.schedule.update.pending","preference.schedule.update.resolved"],Dr=()=>"schedule",qt,de,In=class{constructor({emitterInstance:e}){v(this,qt);v(this,de);this.updateScheduleInCache=(e,t)=>a(this,de).get(e)?(a(this,de).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,n=a(this,de).keys();for(let r of n){let s=this.updateScheduleInCache(r,e),o=a(this,de).get(r);!s||!o||t.add(r)}for(let r of t)a(this,qt).emit("preference.schedule.get.updated",{data:a(this,de).get(r)})};S(this,qt,e);for(let t of yl)a(this,qt).on(t,this.handleScheduleEvent);S(this,de,new Re)}has(){return a(this,de).get(Dr())!==void 0}set(e){a(this,de).set(Dr(),e)}getAll(){if(this.has())return a(this,de).get(Dr())}clearAll(){a(this,de).clear()}};qt=new WeakMap,de=new WeakMap;var Je,On=class extends j{constructor({useCache:t,inboxServiceInstance:n,eventEmitterInstance:r}){super({eventEmitterInstance:r,inboxServiceInstance:n});v(this,Je);this.cache=new Tn({emitterInstance:this._emitter}),this.scheduleCache=new In({emitterInstance:this._emitter}),S(this,Je,t),this.schedule=new Rn({cache:this.scheduleCache,useCache:t,inboxServiceInstance:n,eventEmitterInstance:r})}list(){return p(this,arguments,function*(t={}){return this.callWithSession(()=>p(this,null,function*(){var n;try{let r=a(this,Je)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:r}),r||(r=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(n=t.criticality)!=null?n:"nonCritical"})).map(o=>new Be(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Je)})),a(this,Je)&&(this.cache.set(t,r),r=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:r}),{data:r}}catch(r){throw this._emitter.emit("preferences.list.resolved",{args:t,error:r}),r}}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>kn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Je),args:t}))})}bulkUpdate(t){return p(this,null,function*(){return this.callWithSession(()=>go({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Je),args:t}))})}};Je=new WeakMap;function yo(){return typeof window!="undefined"}var Et,Oi,se,Pn=class{constructor(e,t,n){v(this,Et);v(this,Oi);v(this,se);S(this,Et,n),S(this,Oi,t),S(this,se,e)}get applicationIdentifier(){return a(this,se).applicationIdentifier}get subscriberId(){var e;return(e=a(this,se).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,se).context}get subscriberHash(){return a(this,se).subscriberHash}get contextHash(){return a(this,se).contextHash}get subscriber(){return a(this,se).subscriber}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let n="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(n);case"store":return t&&window.localStorage.setItem(n,t),null;case"delete":return window.localStorage.removeItem(n),null;default:return null}}initialize(e){return p(this,null,function*(){var r,s,o,c,u,h;let t=((r=a(this,se).subscriber)==null?void 0:r.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),n=JSON.stringify(a(this,se).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&n))try{e&&S(this,se,e);let{subscriber:l,subscriberHash:f,contextHash:m,applicationIdentifier:d,defaultSchedule:C,context:g}=a(this,se),b;yo()&&(b=Intl.DateTimeFormat().resolvedOptions().timeZone);let R=d;if(R)this.handleApplicationIdentifier("delete");else{let _=this.handleApplicationIdentifier("get");_&&(R=_)}a(this,Et).emit("session.initialize.pending",{args:a(this,se)});let N=yield a(this,Oi).initializeSession({applicationIdentifier:R,subscriberHash:f,contextHash:m,subscriber:x(y({},l),{subscriberId:(o=l==null?void 0:l.subscriberId)!=null?o:"",timezone:(c=l==null?void 0:l.timezone)!=null?c:b}),defaultSchedule:C,context:g});(u=N==null?void 0:N.applicationIdentifier)!=null&&u.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,Et).emit("session.initialize.resolved",{args:a(this,se),data:N})}catch(l){a(this,Et).emit("session.initialize.resolved",{args:a(this,se),error:l})}})}};Et=new WeakMap,Oi=new WeakMap,se=new WeakMap;function Br(i){if(!i)return"";let e=[];for(let[t,n]of Object.entries(i))if(n){let r=typeof n=="string"?n:n.id;e.push(`${t}:${r}`)}return e.sort().join(",")}function vo({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}function bo({topicKey:i,subscriberId:e,contextKey:t}){let n=`tk_${i}:si_${e}`;return t&&t.length>0?`${n}:ctx_${t}`:n}var dt,Fi,Li,Pi=class extends j{constructor({useCache:t,inboxServiceInstance:n,eventEmitterInstance:r,subscriber:s,contextKey:o}){super({eventEmitterInstance:r,inboxServiceInstance:n});v(this,dt);v(this,Fi);v(this,Li);this.cache=new xn({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),S(this,dt,t),S(this,Fi,s),S(this,Li,o)}list(t,n){return p(this,null,function*(){return this.callWithSession(()=>{var r;return uo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},n),{useCache:(r=n==null?void 0:n.useCache)!=null?r:a(this,dt)}),args:t})})})}get(t,n){return p(this,null,function*(){return this.callWithSession(()=>{var r,s;return ho({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},n),{useCache:(r=n==null?void 0:n.useCache)!=null?r:a(this,dt)}),args:x(y({},t),{identifier:(s=t.identifier)!=null?s:bo({topicKey:t.topicKey,subscriberId:a(this,Fi).subscriberId,contextKey:a(this,Li)})})})})})}create(t){return p(this,null,function*(){return this.callWithSession(()=>fo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,dt),args:t}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>Cn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,dt),args:t}))})}delete(t){return p(this,null,function*(){return this.callWithSession(()=>wn({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};dt=new WeakMap,Fi=new WeakMap,Li=new WeakMap;var Fn=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,vl=(function(){try{new Fn.Event("")}catch(i){return!0}return!1})(),bl=(function(){try{new Fn.EventTarget}catch(i){return!0}return!1})();vl&&(Fn.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})());bl&&(Fn.EventTarget=(function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,n){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let r=this.__listeners,s=e.toString();r.has(s)||r.set(s,new Map);let o=r.get(s);o.has(t)||o.set(t,n)},i.prototype.removeEventListener=function(e,t,n){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let r=this.__listeners,s=e.toString();if(r.has(s)){let o=r.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,r=this.__listeners.get(t);if(r)for(var s of r.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(u){setTimeout(()=>{throw u})}c&&c.once&&r.delete(o)}return!0},i})());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
21
21
  PartySocket requires a global 'EventTarget' class to be available!
22
22
  You can polyfill this global by adding this to your code before any partysocket imports:
23
23
 
@@ -25,7 +25,7 @@
25
25
  import 'partysocket/event-target-polyfill';
26
26
  \`\`\`
27
27
  Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
28
- `);var co=class extends Event{constructor(e,t){super("error",t);F(this,"message");F(this,"error");this.message=e.message,this.error=e}},lo=class extends Event{constructor(e=1e3,t="",r){super("close",r);F(this,"code");F(this,"reason");F(this,"wasClean",!0);this.code=e,this.reason=t}},Ln={Event,ErrorEvent:co,CloseEvent:lo};function ol(i,e){if(!i)throw new Error(e)}function al(i){return new i.constructor(i.type,i)}function cl(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new lo(i.code||1999,i.reason||"unknown reason",i):"error"in i?new co(i.error,i):new Event(i.type,i)}var oo,ll=typeof process!="undefined"&&typeof((oo=process.versions)==null?void 0:oo.node)!="undefined"&&typeof document=="undefined",Tr=ll?cl:al,wt={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},ao=!1,Or=class Ct extends EventTarget{constructor(t,r,n={}){super();F(this,"_ws");F(this,"_retryCount",-1);F(this,"_uptimeTimeout");F(this,"_connectTimeout");F(this,"_shouldReconnect",!0);F(this,"_connectLock",!1);F(this,"_binaryType","blob");F(this,"_closeCalled",!1);F(this,"_messageQueue",[]);F(this,"_debugLogger",console.log.bind(console));F(this,"_url");F(this,"_protocols");F(this,"_options");F(this,"onclose",null);F(this,"onerror",null);F(this,"onmessage",null);F(this,"onopen",null);F(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=wt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),ol(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(Tr(t))});F(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Tr(t))});F(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(Tr(t)),this._connect()});F(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(Tr(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 Ct.CONNECTING}get OPEN(){return Ct.OPEN}get CLOSING(){return Ct.CLOSING}get CLOSED(){return Ct.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?Ct.CLOSED:Ct.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=wt.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=wt.reconnectionDelayGrowFactor,minReconnectionDelay:r=wt.minReconnectionDelay,maxReconnectionDelay:n=wt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*Bs(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=wt.maxRetries,connectionTimeout:r=wt.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"&&!ao&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
28
+ `);var Eo=class extends Event{constructor(e,t){super("error",t);F(this,"message");F(this,"error");this.message=e.message,this.error=e}},Co=class extends Event{constructor(e=1e3,t="",n){super("close",n);F(this,"code");F(this,"reason");F(this,"wasClean",!0);this.code=e,this.reason=t}},Mr={Event,ErrorEvent:Eo,CloseEvent:Co};function Sl(i,e){if(!i)throw new Error(e)}function _l(i){return new i.constructor(i.type,i)}function El(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Co(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Eo(i.error,i):new Event(i.type,i)}var So,Cl=typeof process!="undefined"&&typeof((So=process.versions)==null?void 0:So.node)!="undefined"&&typeof document=="undefined",Ln=Cl?El:_l,Ct={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},_o=!1,Un=class wt extends EventTarget{constructor(t,n,r={}){super();F(this,"_ws");F(this,"_retryCount",-1);F(this,"_uptimeTimeout");F(this,"_connectTimeout");F(this,"_shouldReconnect",!0);F(this,"_connectLock",!1);F(this,"_binaryType","blob");F(this,"_closeCalled",!1);F(this,"_messageQueue",[]);F(this,"_debugLogger",console.log.bind(console));F(this,"_url");F(this,"_protocols");F(this,"_options");F(this,"onclose",null);F(this,"onerror",null);F(this,"onmessage",null);F(this,"onopen",null);F(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:n=Ct.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),n),Sl(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(r=>{var s;return(s=this._ws)==null?void 0:s.send(r)}),this._messageQueue=[],this.onopen&&this.onopen(t),this.dispatchEvent(Ln(t))});F(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Ln(t))});F(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(Ln(t)),this._connect()});F(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(Ln(t))});this._url=t,this._protocols=n,this._options=r,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 wt.CONNECTING}get OPEN(){return wt.OPEN}get CLOSING(){return wt.CLOSING}get CLOSED(){return wt.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((n,r)=>(typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n),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?wt.CLOSED:wt.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,n){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,n)}reconnect(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{let{maxEnqueuedMessages:n=Ct.maxEnqueuedMessages}=this._options;this._messageQueue.length<n&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){let{reconnectionDelayGrowFactor:t=Ct.reconnectionDelayGrowFactor,minReconnectionDelay:n=Ct.minReconnectionDelay,maxReconnectionDelay:r=Ct.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=n*$s(t,this._retryCount-1),s>r&&(s=r)),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 n=t();if(!n)return Promise.resolve(null);if(typeof n=="string"||Array.isArray(n))return Promise.resolve(n);if(n.then)return n}throw Error("Invalid protocols")}_getNextUrl(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){let n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:t=Ct.maxRetries,connectionTimeout:n=Ct.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(([r,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket=="undefined"&&!_o&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
29
29
 
30
30
  For example, if you're using node.js, run \`npm install ws\`, and then in your code:
31
31
 
@@ -38,7 +38,7 @@ const partysocket = new PartySocket({
38
38
  WebSocket: WS
39
39
  });
40
40
 
41
- `),ao=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:n,protocols:s}),this._ws=s?new o(n,s):new o(n),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),r)}).catch(n=>{this._connectLock=!1,this._handleError(new Ln.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Ln.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,r){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,r),this._handleClose(new Ln.CloseEvent(t,r,this))}catch(n){}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var Li="wss://socket.novu.co",uo="notifications.notification_received",ho="notifications.unseen_count_changed",fo="notifications.unread_count_changed",ul=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:p,subscriber:d,subject:w,avatar:y,cta:b,tags:k,data:N,workflow:_,severity:E})=>{var We,vt,ce,rt,nt,st,xe,Ne;let M={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=(vt=(We=b.action)==null?void 0:We.buttons)==null?void 0:vt.find($e=>$e.type==="primary"),P=(rt=(ce=b.action)==null?void 0:ce.buttons)==null?void 0:rt.find($e=>$e.type==="secondary"),$=(st=(nt=b.action)==null?void 0:nt.result)==null?void 0:st.type,te=(xe=b.action)==null?void 0:xe.status;return C(g(g({id:i,transactionId:e,subject:w,body:t,to:M,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:y,primaryAction:R&&{label:R.content,isCompleted:$==="primary"&&te==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&te==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:k,redirect:(Ne=b.data)!=null&&Ne.url?{url:b.data.url,target:b.data.target}:void 0,data:N,workflow:_,severity:E})},Wt,Re,Te,$t,Fi,Pr,Fr,Lr,Ur,Be,po,Un,Dn,Ir=class extends ue{constructor({socketUrl:t,socketOptions:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});v(this,Be);v(this,Wt);v(this,Re);v(this,Te);v(this,$t);v(this,Fi);v(this,Pr,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,Re).emit(uo,{result:new U(ul(r.data.message),a(this,Re),this._inboxService)})}catch(r){console.log("error",r)}});v(this,Fr,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,Re).emit(ho,{result:r.data.unseenCount})}catch(r){}});v(this,Lr,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,Re).emit(fo,{result:r.data.counts})}catch(r){}});v(this,Ur,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,Pr).call(this,t);break;case"unseen_count_changed":a(this,Fr).call(this,t);break;case"unread_count_changed":a(this,Lr).call(this,t);break;default:}}catch(r){}});S(this,Re,s),S(this,$t,t!=null?t:Li),S(this,Fi,r)}onSessionSuccess({token:t}){S(this,Wt,t)}isSocketEvent(t){return t===uo||t===ho||t===fo}connect(){return m(this,null,function*(){return a(this,Wt)?Se(this,Be,Un).call(this):this.callWithSession(Se(this,Be,Un).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,Te)?Se(this,Be,Dn).call(this):this.callWithSession(Se(this,Be,Dn).bind(this))})}};Wt=new WeakMap,Re=new WeakMap,Te=new WeakMap,$t=new WeakMap,Fi=new WeakMap,Pr=new WeakMap,Fr=new WeakMap,Lr=new WeakMap,Ur=new WeakMap,Be=new WeakSet,po=function(){return m(this,null,function*(){if(a(this,Te))return;let t={socketUrl:a(this,$t)};a(this,Re).emit("socket.connect.pending",{args:t});let r=new URL(a(this,$t));r.searchParams.set("token",a(this,Wt)),S(this,Te,new Or(r.toString(),void 0,a(this,Fi))),a(this,Te).addEventListener("open",()=>{a(this,Re).emit("socket.connect.resolved",{args:t})}),a(this,Te).addEventListener("error",n=>{a(this,Re).emit("socket.connect.resolved",{args:t,error:n})}),a(this,Te).addEventListener("message",a(this,Ur))})},Un=function(){return m(this,null,function*(){try{return yield Se(this,Be,po).call(this),{}}catch(t){return{error:new x("Failed to initialize the PartySocket",t)}}})},Dn=function(){return m(this,null,function*(){var t;try{return(t=a(this,Te))==null||t.close(),S(this,Te,void 0),{}}catch(r){return{error:new x("Failed to disconnect from the PartySocket",r)}}})};var Oe=Object.create(null);Oe.open="0";Oe.close="1";Oe.ping="2";Oe.pong="3";Oe.message="4";Oe.upgrade="5";Oe.noop="6";var Ui=Object.create(null);Object.keys(Oe).forEach(i=>{Ui[Oe[i]]=i});var Di={type:"error",data:"parser error"};var Bi=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+mo(e,!0).toString("base64")):r(Oe[i]+(e||"")),mo=(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 yo(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(mo(i.data,!1));Bi(i,!0,t=>{Bn||(Bn=new TextEncoder),e(Bn.encode(t))})}var Mi=(i,e)=>{if(typeof i!="string")return{type:"message",data:go(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:go(r,e)}}return Ui[t]?i.length>1?{type:Ui[t],data:i.substring(1)}:{type:Ui[t]}:Di},go=(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 vo="",bo=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Bi(s,!1,c=>{r[o]=c,++n===t&&e(r.join(vo))})})},So=(i,e)=>{let t=i.split(vo),r=[];for(let n=0;n<t.length;n++){let s=Mi(t[n],e);if(r.push(s),s.type==="error")break}return r};function _o(){return new TransformStream({transform(i,e){yo(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 Mn;function Dr(i){return i.reduce((e,t)=>e+t.length,0)}function Br(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 Eo(i,e){Mn||(Mn=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(Dr(t)<1)break;let u=Br(t,1);s=(u[0]&128)===128,n=u[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(Dr(t)<2)break;let u=Br(t,2);n=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),r=3}else if(r===2){if(Dr(t)<8)break;let u=Br(t,8),h=new DataView(u.buffer,u.byteOffset,u.length),l=h.getUint32(0);if(l>Math.pow(2,21)-1){c.enqueue(Di);break}n=l*Math.pow(2,32)+h.getUint32(4),r=3}else{if(Dr(t)<n)break;let u=Br(t,n);c.enqueue(Mi(s?u:Mn.decode(u),e)),r=0}if(n===0||n>i){c.enqueue(Di);break}}}})}var qn=4;function L(i){if(i)return hl(i)}function hl(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 Ie=global;function Mr(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var fl=Ie.setTimeout,dl=Ie.clearTimeout;function Je(i,e){e.useNativeTimers?(i.setTimeoutFn=fl.bind(Ie),i.clearTimeoutFn=dl.bind(Ie)):(i.setTimeoutFn=Ie.setTimeout.bind(Ie),i.clearTimeoutFn=Ie.clearTimeout.bind(Ie))}var pl=1.33;function wo(i){return typeof i=="string"?ml(i):Math.ceil((i.byteLength||i.size)*pl)}function ml(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 Fo=V(jt(),1);function Io(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function Po(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 Bl=(0,Fo.default)("engine.io-client:transport"),Hn=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Xe=class extends L{constructor(e){super(),this.writable=!1,Je(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Hn(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):Bl("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Mi(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=Io(e);return t.length?"?"+t:""}};var zo=V(jt(),1);var Bo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Yn=64,Ml={},Lo=0,zr=0,Uo;function Do(i){let e="";do e=Bo[i%Yn]+e,i=Math.floor(i/Yn);while(i>0);return e}function Vr(){let i=Do(+new Date);return i!==Uo?(Lo=0,Uo=i):i+"."+Do(Lo++)}for(;zr<Yn;zr++)Ml[Bo[zr]]=zr;var Qn=V(Wo(),1),Zn=Qn.default||Qn;function $o(){return new Xn}function Wl(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 u=c[0].trim(),h=c[1].trim();switch(u){case"Expires":s.expires=new Date(h);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(h,10)),s.expires=l;break;default:}}return s}var Xn=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=Wl(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 he=(0,zo.default)("engine.io-client:polling");function $l(){}var Kl=(function(){return new Zn({xdomain:!1}).responseType!=null})(),jr=class extends Xe{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=Kl&&!t,this.opts.withCredentials&&(this.cookieJar=$o())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{he("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(he("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){he("pre-pause polling complete"),--r||t()})),this.writable||(he("we are currently writing - waiting to pause"),r++,this.once("drain",function(){he("pre-pause writing complete"),--r||t()}))}else t()}poll(){he("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){he("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)};So(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():he('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{he("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(he("transport open - closing"),e()):(he("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,bo(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]=Vr()),!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 mt(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(){he("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}},mt=class i extends L{constructor(e,t){super(),Je(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=Mr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Zn(t);try{he("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))},he("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=$l,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()}};mt.requestsCount=0;mt.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",Ko);else if(typeof addEventListener=="function"){let i="onpagehide"in Ie?"pagehide":"unload";addEventListener(i,Ko,!1)}}function Ko(){for(let i in mt.requests)mt.requests.hasOwnProperty(i)&&mt.requests[i].abort()}var lh=V(Ma(),1),uh=V(tn(),1),hh=V(Jt(),1),fh=V(us(),1),dh=V(ds(),1),ph=V(bs(),1),Ha=V(on(),1),mh=V(Ga(),1);var Ya=Ha.default;var Gi=Ya,cn=!1,Ja="nodebuffer",Ot=process.nextTick;var Qa=V(jt(),1);var yh=(0,Qa.default)("engine.io-client:websocket"),Xa=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",ln=class extends Xe{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=Xa?{}:Mr(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=cn&&!Xa?t?new Gi(e,t):new Gi(e):new Gi(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;Bi(r,this.supportsBinary,s=>{let o={};cn||(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{cn?this.ws.send(s):this.ws.send(s,o)}catch(c){yh("websocket closed before onclose event")}n&&Ot(()=>{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]=Vr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Gi}};var Za=V(jt(),1),Hi=(0,Za.default)("engine.io-client:webtransport"),un=class extends Xe{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Hi("transport closed gracefully"),this.onClose()}).catch(e=>{Hi("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Eo(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=_o();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:u})=>{if(c){Hi("session is closed");return}Hi("received chunk: %o",u),this.onPacket(u),s()}).catch(c=>{Hi("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&&Ot(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var _s={websocket:ln,webtransport:un,polling:jr};var gh=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,vh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ii(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=gh.exec(i||""),s={},o=14;for(;o--;)s[vh[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=bh(s,s.path),s.queryKey=Sh(s,s.query),s}function bh(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 Sh(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var ec=V(jt(),1);var B=(0,ec.default)("engine.io-client:socket"),It=class i extends L{constructor(e,t={}){super(),this.binaryType=Ja,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=ii(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=ii(t.host).host),Je(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=Po(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=qn,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 _s[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"),l(),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,l(),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 u(){o("socket closed")}function h(f){t&&f.name!==t.name&&(B('"%s" works - aborting "%s"',f.name,t.name),s())}let l=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",u),this.off("upgrading",h)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",u),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+=wo(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}};It.protocol=qn;var Ey=It.protocol;var oc=V(Yi(),1),sc=(0,oc.default)("socket.io-client:url");function ac(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)||(sc("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),sc("parse %s",i),r=ii(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 Ps={};$c(Ps,{Decoder:()=>Os,Encoder:()=>Ts,PacketType:()=>A,isPacketValid:()=>pf,protocol:()=>wc});var Uh=typeof ArrayBuffer=="function",Dh=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,cc=Object.prototype.toString,Bh=typeof Blob=="function"||typeof Blob!="undefined"&&cc.call(Blob)==="[object BlobConstructor]",Mh=typeof File=="function"||typeof File!="undefined"&&cc.call(File)==="[object FileConstructor]";function Xi(i){return Uh&&(i instanceof ArrayBuffer||Dh(i))||Bh&&i instanceof Blob||Mh&&i instanceof File}function Ji(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Ji(i[t]))return!0;return!1}if(Xi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ji(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Ji(i[t]))return!0;return!1}function lc(i){let e=[],t=i.data,r=i;return r.data=Cs(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Cs(i,e){if(!i)return i;if(Xi(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]=Cs(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]=Cs(i[r],e));return t}return i}function uc(i,e){return i.data=xs(i.data,e),delete i.attachments,i}function xs(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]=xs(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=xs(i[t],e));return i}var _c=V(Sc(),1),Rs=(0,_c.default)("socket.io-parser"),Ec=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],wc=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 Ts=class{constructor(e){this.replacer=e}encode(e){return Rs("encoding packet %j",e),(e.type===A.EVENT||e.type===A.ACK)&&Ji(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)),Rs("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=lc(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Os=class i extends L{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}: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 Is(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Xi(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");let c=Number(o);if(!Cc(c)||c<0)throw new Error("Illegal attachments");if(c>this.opts.maxAttachments)throw new Error("too many attachments");r.attachments=c}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 Rs("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case A.CONNECT:return bn(t);case A.DISCONNECT:return t===void 0;case A.CONNECT_ERROR:return typeof t=="string"||bn(t);case A.EVENT:case A.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Ec.indexOf(t[0])===-1);case A.ACK:case A.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Is=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=uc(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function hf(i){return typeof i=="string"}var Cc=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function ff(i){return i===void 0||Cc(i)}function bn(i){return Object.prototype.toString.call(i)==="[object Object]"}function df(i,e){switch(i){case A.CONNECT:return e===void 0||bn(e);case A.DISCONNECT:return e===void 0;case A.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Ec.indexOf(e[0])===-1);case A.ACK:return Array.isArray(e);case A.CONNECT_ERROR:return typeof e=="string"||bn(e);default:return!1}}function pf(i){return hf(i.nsp)&&ff(i.id)&&df(i.type,i.data)}function ge(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var xc=V(Yi(),1),j=(0,xc.default)("socket.io-client:socket"),mf=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),oi=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=[ge(e,"open",this.onopen.bind(this)),ge(e,"packet",this.onpacket.bind(this)),ge(e,"error",this.onerror.bind(this)),ge(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(mf.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++;j("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)?j("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&&(j("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));j("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&&(j("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(j("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(j("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){j("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,j("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(){j("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){j("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||[];j("emitting event %j",t),e.id!=null&&(j("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,j("sending ack %j",n),t.packet({type:A.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(j("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):j("bad ack %s",e.id)}onconnect(e,t){j("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(){j("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&&(j("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 Ft(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}Ft.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)==0?i-t:i+t}return Math.min(i,this.max)|0};Ft.prototype.reset=function(){this.attempts=0};Ft.prototype.setMin=function(i){this.ms=i};Ft.prototype.setMax=function(i){this.max=i};Ft.prototype.setJitter=function(i){this.jitter=i};var Nc=V(Yi(),1),ne=(0,Nc.default)("socket.io-client:manager"),ai=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,Je(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 Ft({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||Ps;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(ne("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;ne("opening %s",this.uri),this.engine=new It(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=ge(t,"open",function(){r.onopen(),e&&e()}),s=c=>{ne("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=ge(t,"error",s);if(this._timeout!==!1){let c=this._timeout;ne("connect attempt will timeout after %d",c);let u=this.setTimeoutFn(()=>{ne("connect attempt timed out after %d",c),n(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){ne("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ge(e,"ping",this.onping.bind(this)),ge(e,"data",this.ondata.bind(this)),ge(e,"error",this.onerror.bind(this)),ge(e,"close",this.onclose.bind(this)),ge(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){Ot(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){ne("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new oi(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){ne("socket %s is still active, skipping close",r);return}this._close()}_packet(e){ne("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(){ne("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){ne("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){ne("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)ne("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();ne("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(ne("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(ne("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(ne("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 kc=V(Yi(),1),Ac=(0,kc.default)("socket.io-client"),Qi={};function Zi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=ac(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,u;return c?(Ac("ignoring socket cache for %s",r),u=new ai(r,e)):(Qi[n]||(Ac("new io instance for %s",r),Qi[n]=new ai(r,e)),u=Qi[n]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(Zi,{Manager:ai,Socket:oi,io:Zi,connect:Zi});var yf="https://ws.novu.co",Rc="notifications.notification_received",Tc="notifications.unseen_count_changed",Oc="notifications.unread_count_changed",gf=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:p,subscriber:d,subject:w,avatar:y,cta:b,tags:k,data:N,workflow:_,severity:E})=>{var We,vt,ce,rt,nt,st,xe,Ne;let M={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=(vt=(We=b.action)==null?void 0:We.buttons)==null?void 0:vt.find($e=>$e.type==="primary"),P=(rt=(ce=b.action)==null?void 0:ce.buttons)==null?void 0:rt.find($e=>$e.type==="secondary"),$=(st=(nt=b.action)==null?void 0:nt.result)==null?void 0:st.type,te=(xe=b.action)==null?void 0:xe.status;return C(g(g({id:i,transactionId:e,subject:w,body:t,to:M,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:y,primaryAction:R&&{label:R.content,isCompleted:$==="primary"&&te==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&te==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:k,redirect:(Ne=b.data)!=null&&Ne.url?{url:b.data.url,target:b.data.target}:void 0,data:N,workflow:_,severity:E})},ci,Fe,ve,li,er,_n,En,wn,qe,Ic,Fs,Ls,Sn=class extends ue{constructor({socketUrl:t,socketOptions:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});v(this,qe);v(this,ci);v(this,Fe);v(this,ve);v(this,li);v(this,er);v(this,_n,({message:t})=>{a(this,Fe).emit(Rc,{result:new U(gf(t),a(this,Fe),this._inboxService)})});v(this,En,({unseenCount:t})=>{a(this,Fe).emit(Tc,{result:t})});v(this,wn,({counts:t})=>{a(this,Fe).emit(Oc,{result:t})});S(this,Fe,s),S(this,li,t!=null?t:yf),S(this,er,r)}onSessionSuccess({token:t}){S(this,ci,t)}isSocketEvent(t){return t===Rc||t===Tc||t===Oc}connect(){return m(this,null,function*(){return a(this,ci)?Se(this,qe,Fs).call(this):this.callWithSession(Se(this,qe,Fs).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,ve)?Se(this,qe,Ls).call(this):this.callWithSession(Se(this,qe,Ls).bind(this))})}};ci=new WeakMap,Fe=new WeakMap,ve=new WeakMap,li=new WeakMap,er=new WeakMap,_n=new WeakMap,En=new WeakMap,wn=new WeakMap,qe=new WeakSet,Ic=function(){return m(this,null,function*(){var r,n,s,o;if(a(this,ve))return;let t={socketUrl:a(this,li)};a(this,Fe).emit("socket.connect.pending",{args:t}),S(this,ve,Zi(a(this,li),g({reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,ci)}`}},(r=a(this,er))!=null?r:{}))),a(this,ve).on("connect",()=>{a(this,Fe).emit("socket.connect.resolved",{args:t})}),a(this,ve).on("connect_error",c=>{a(this,Fe).emit("socket.connect.resolved",{args:t,error:c})}),(n=a(this,ve))==null||n.on("notification_received",a(this,_n)),(s=a(this,ve))==null||s.on("unseen_count_changed",a(this,En)),(o=a(this,ve))==null||o.on("unread_count_changed",a(this,wn))})},Fs=function(){return m(this,null,function*(){try{return yield Se(this,qe,Ic).call(this),{}}catch(t){return{error:new x("Failed to initialize the socket",t)}}})},Ls=function(){return m(this,null,function*(){var t;try{return(t=a(this,ve))==null||t.disconnect(),S(this,ve,void 0),{}}catch(r){return{error:new x("Failed to disconnect from the socket",r)}}})};var vf=["wss://eu.socket.novu.co",Li,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],bf={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Li,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"},Sf={cloud:"partysocket","self-hosted":"socket.io"};function _f(i){return i?bf[i]||i:Li}function Ef(i){return!i||vf.includes(i)}function wf(i,e){return e?Sf[e]:Ef(i)?"partysocket":"socket.io"}function Pc({socketUrl:i,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:r}){let n=_f(i),u=e||{},{socketType:s}=u,o=ui(u,["socketType"]);switch(wf(n,s)){case"partysocket":return new Ir({socketUrl:n,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:r});case"socket.io":default:return new Sn({socketUrl:n,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:r})}}var Le,se,it,tr,Cn=class{constructor(e){v(this,Le);v(this,se);v(this,it);v(this,tr);var n,s,o;S(this,tr,e),S(this,it,new or({apiUrl:e.apiUrl||e.backendUrl})),S(this,Le,new ar);let t=no({subscriberId:e.subscriberId,subscriber:e.subscriber}),r=Fn(e.context);S(this,se,new kr({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,it),a(this,Le))),a(this,se).initialize(),this.notifications=new _r({useCache:(n=e.useCache)!=null?n:!0,inboxServiceInstance:a(this,it),eventEmitterInstance:a(this,Le)}),this.preferences=new Ar({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,it),eventEmitterInstance:a(this,Le)}),this.subscriptions=new Oi({subscriber:t,contextKey:r,useCache:(o=e.useCache)!=null?o:!0,inboxServiceInstance:a(this,it),eventEmitterInstance:a(this,Le)}),this.socket=Pc({socketUrl:e.socketUrl,socketOptions:e.socketOptions,eventEmitterInstance:a(this,Le),inboxServiceInstance:a(this,it)}),this.on=(c,u)=>{this.socket.isSocketEvent(c)&&this.socket.connect();let h=a(this,Le).on(c,u);return()=>{h()}},this.off=(c,u)=>{a(this,Le).off(c,u)}}get applicationIdentifier(){return a(this,se).applicationIdentifier}get subscriberId(){return a(this,se).subscriberId}get context(){return a(this,se).context}get options(){return a(this,tr)}get contextKey(){return Fn(a(this,se).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return m(this,null,function*(){yield a(this,se).initialize({applicationIdentifier:a(this,se).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,se).context,contextHash:a(this,se).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return m(this,null,function*(){let t=a(this,se).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,se).initialize({applicationIdentifier:a(this,se).applicationIdentifier||"",subscriberHash:a(this,se).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Le=new WeakMap,se=new WeakMap,it=new WeakMap,tr=new WeakMap;window.Novu=Cn;})();
41
+ `),_o=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:r,protocols:s}),this._ws=s?new o(r,s):new o(r),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),n)}).catch(r=>{this._connectLock=!1,this._handleError(new Mr.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Mr.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,n){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,n),this._handleClose(new Mr.CloseEvent(t,n,this))}catch(r){}}}_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 Di="wss://socket.novu.co",wo="notifications.notification_received",xo="notifications.unseen_count_changed",Ao="notifications.unread_count_changed",wl=({_id:i,transactionId:e,content:t,read:n,seen:r,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:m,subscriber:d,subject:C,avatar:g,cta:b,tags:R,data:N,workflow:_,severity:E})=>{var $e,vt,ue,nt,rt,st,Ae,Ne;let M={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},T=(vt=($e=b.action)==null?void 0:$e.buttons)==null?void 0:vt.find(Ke=>Ke.type==="primary"),P=(nt=(ue=b.action)==null?void 0:ue.buttons)==null?void 0:nt.find(Ke=>Ke.type==="secondary"),$=(st=(rt=b.action)==null?void 0:rt.result)==null?void 0:st.type,ie=(Ae=b.action)==null?void 0:Ae.status;return x(y(y({id:i,transactionId:e,subject:C,body:t,to:M,isRead:n,isSeen:r,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:g,primaryAction:T&&{label:T.content,isCompleted:$==="primary"&&ie==="done",redirect:T.url?{target:T.target,url:T.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&ie==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:m,tags:R,redirect:(Ne=b.data)!=null&&Ne.url?{url:b.data.url,target:b.data.target}:void 0,data:N,workflow:_,severity:E})},Wt,Te,Ie,$t,Ui,Bn,Mn,qn,Wn,Me,No,qr,Wr,Dn=class extends j{constructor({socketUrl:t,socketOptions:n,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,Me);v(this,Wt);v(this,Te);v(this,Ie);v(this,$t);v(this,Ui);v(this,Bn,t=>{try{let n=JSON.parse(t.data);n.event==="notification_received"&&a(this,Te).emit(wo,{result:new U(wl(n.data.message),a(this,Te),this._inboxService)})}catch(n){console.log("error",n)}});v(this,Mn,t=>{try{let n=JSON.parse(t.data);n.event==="unseen_count_changed"&&a(this,Te).emit(xo,{result:n.data.unseenCount})}catch(n){}});v(this,qn,t=>{try{let n=JSON.parse(t.data);n.event==="unread_count_changed"&&a(this,Te).emit(Ao,{result:n.data.counts})}catch(n){}});v(this,Wn,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,Bn).call(this,t);break;case"unseen_count_changed":a(this,Mn).call(this,t);break;case"unread_count_changed":a(this,qn).call(this,t);break;default:}}catch(n){}});S(this,Te,s),S(this,$t,t!=null?t:Di),S(this,Ui,n)}onSessionSuccess({token:t}){S(this,Wt,t)}isSocketEvent(t){return t===wo||t===xo||t===Ao}connect(){return p(this,null,function*(){return a(this,Wt)?_e(this,Me,qr).call(this):this.callWithSession(_e(this,Me,qr).bind(this))})}disconnect(){return p(this,null,function*(){return a(this,Ie)?_e(this,Me,Wr).call(this):this.callWithSession(_e(this,Me,Wr).bind(this))})}};Wt=new WeakMap,Te=new WeakMap,Ie=new WeakMap,$t=new WeakMap,Ui=new WeakMap,Bn=new WeakMap,Mn=new WeakMap,qn=new WeakMap,Wn=new WeakMap,Me=new WeakSet,No=function(){return p(this,null,function*(){if(a(this,Ie))return;let t={socketUrl:a(this,$t)};a(this,Te).emit("socket.connect.pending",{args:t});let n=new URL(a(this,$t));n.searchParams.set("token",a(this,Wt)),S(this,Ie,new Un(n.toString(),void 0,a(this,Ui))),a(this,Ie).addEventListener("open",()=>{a(this,Te).emit("socket.connect.resolved",{args:t})}),a(this,Ie).addEventListener("error",r=>{a(this,Te).emit("socket.connect.resolved",{args:t,error:r})}),a(this,Ie).addEventListener("message",a(this,Wn))})},qr=function(){return p(this,null,function*(){try{return yield _e(this,Me,No).call(this),{}}catch(t){return{error:new w("Failed to initialize the PartySocket",t)}}})},Wr=function(){return p(this,null,function*(){var t;try{return(t=a(this,Ie))==null||t.close(),S(this,Ie,void 0),{}}catch(n){return{error:new w("Failed to disconnect from the PartySocket",n)}}})};var Oe=Object.create(null);Oe.open="0";Oe.close="1";Oe.ping="2";Oe.pong="3";Oe.message="4";Oe.upgrade="5";Oe.noop="6";var Bi=Object.create(null);Object.keys(Oe).forEach(i=>{Bi[Oe[i]]=i});var Mi={type:"error",data:"parser error"};var qi=({type:i,data:e},t,n)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?n(t?e:"b"+ko(e,!0).toString("base64")):n(Oe[i]+(e||"")),ko=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),$r;function Ro(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(ko(i.data,!1));qi(i,!0,t=>{$r||($r=new TextEncoder),e($r.encode(t))})}var Wi=(i,e)=>{if(typeof i!="string")return{type:"message",data:To(i,e)};let t=i.charAt(0);if(t==="b"){let n=Buffer.from(i.substring(1),"base64");return{type:"message",data:To(n,e)}}return Bi[t]?i.length>1?{type:Bi[t],data:i.substring(1)}:{type:Bi[t]}:Mi},To=(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 Io="",Oo=(i,e)=>{let t=i.length,n=new Array(t),r=0;i.forEach((s,o)=>{qi(s,!1,c=>{n[o]=c,++r===t&&e(n.join(Io))})})},Po=(i,e)=>{let t=i.split(Io),n=[];for(let r=0;r<t.length;r++){let s=Wi(t[r],e);if(n.push(s),s.type==="error")break}return n};function Fo(){return new TransformStream({transform(i,e){Ro(i,t=>{let n=t.length,r;if(n<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,n);else if(n<65536){r=new Uint8Array(3);let s=new DataView(r.buffer);s.setUint8(0,126),s.setUint16(1,n)}else{r=new Uint8Array(9);let s=new DataView(r.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(n))}i.data&&typeof i.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}var Kr;function $n(i){return i.reduce((e,t)=>e+t.length,0)}function Kn(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),n=0;for(let r=0;r<e;r++)t[r]=i[0][n++],n===i[0].length&&(i.shift(),n=0);return i.length&&n<i[0].length&&(i[0]=i[0].slice(n)),t}function Lo(i,e){Kr||(Kr=new TextDecoder);let t=[],n=0,r=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(n===0){if($n(t)<1)break;let u=Kn(t,1);s=(u[0]&128)===128,r=u[0]&127,r<126?n=3:r===126?n=1:n=2}else if(n===1){if($n(t)<2)break;let u=Kn(t,2);r=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),n=3}else if(n===2){if($n(t)<8)break;let u=Kn(t,8),h=new DataView(u.buffer,u.byteOffset,u.length),l=h.getUint32(0);if(l>Math.pow(2,21)-1){c.enqueue(Mi);break}r=l*Math.pow(2,32)+h.getUint32(4),n=3}else{if($n(t)<r)break;let u=Kn(t,r);c.enqueue(Wi(s?u:Kr.decode(u),e)),n=0}if(r===0||r>i){c.enqueue(Mi);break}}}})}var zr=4;function L(i){if(i)return xl(i)}function xl(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 n,r=0;r<t.length;r++)if(n=t[r],n===e||n.fn===e){t.splice(r,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],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,r=t.length;n<r;++n)t[n].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 Pe=global;function zn(i,...e){return e.reduce((t,n)=>(i.hasOwnProperty(n)&&(t[n]=i[n]),t),{})}var Al=Pe.setTimeout,Nl=Pe.clearTimeout;function Xe(i,e){e.useNativeTimers?(i.setTimeoutFn=Al.bind(Pe),i.clearTimeoutFn=Nl.bind(Pe)):(i.setTimeoutFn=Pe.setTimeout.bind(Pe),i.clearTimeoutFn=Pe.clearTimeout.bind(Pe))}var kl=1.33;function Uo(i){return typeof i=="string"?Rl(i):Math.ceil((i.byteLength||i.size)*kl)}function Rl(i){let e=0,t=0;for(let n=0,r=i.length;n<r;n++)e=i.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}var jo=G(Vt(),1);function Go(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function Vo(i){let e={},t=i.split("&");for(let n=0,r=t.length;n<r;n++){let s=t[n].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var Ql=(0,jo.default)("engine.io-client:transport"),Qr=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}},Qe=class extends L{constructor(e){super(),this.writable=!1,Xe(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new Qr(e,t,n)),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):Ql("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Wi(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=Go(e);return t.length?"?"+t:""}};var na=G(Vt(),1);var Xo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Zr=64,Zl={},Ho=0,Yn=0,Yo;function Jo(i){let e="";do e=Xo[i%Zr]+e,i=Math.floor(i/Zr);while(i>0);return e}function Jn(){let i=Jo(+new Date);return i!==Yo?(Ho=0,Yo=i):i+"."+Jo(Ho++)}for(;Yn<Zr;Yn++)Zl[Xo[Yn]]=Yn;var is=G(ea(),1),ns=is.default||is;function ta(){return new ts}function tu(i){let e=i.split("; "),t=e[0].indexOf("=");if(t===-1)return;let n=e[0].substring(0,t).trim();if(!n.length)return;let r=e[0].substring(t+1).trim();r.charCodeAt(0)===34&&(r=r.slice(1,-1));let s={name:n,value:r};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let u=c[0].trim(),h=c[1].trim();switch(u){case"Expires":s.expires=new Date(h);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(h,10)),s.expires=l;break;default:}}return s}var ts=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(n=>{let r=tu(n);r&&this.cookies.set(r.name,r)})}addCookies(e){let t=[];this.cookies.forEach((n,r)=>{var s;((s=n.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(r):t.push(`${r}=${n.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var he=(0,na.default)("engine.io-client:polling");function iu(){}var nu=(function(){return new ns({xdomain:!1}).responseType!=null})(),Xn=class extends Qe{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let n=location.protocol==="https:",r=location.port;r||(r=n?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||r!==e.port}let t=e&&e.forceBase64;this.supportsBinary=nu&&!t,this.opts.withCredentials&&(this.cookieJar=ta())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{he("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(he("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){he("pre-pause polling complete"),--n||t()})),this.writable||(he("we are currently writing - waiting to pause"),n++,this.once("drain",function(){he("pre-pause writing complete"),--n||t()}))}else t()}poll(){he("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){he("polling got data %s",e);let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};Po(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():he('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{he("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(he("transport open - closing"),e()):(he("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Oo(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]=Jn()),!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 mt(this.uri(),e)}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(r,s)=>{this.onError("xhr post error",r,s)})}doPoll(){he("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}},mt=class i extends L{constructor(e,t){super(),Xe(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=zn(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let n=this.xhr=new ns(t);try{he("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&n.setRequestHeader(r,this.opts.extraHeaders[r])}}catch(r){}if(this.method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(r){}try{n.setRequestHeader("Accept","*/*")}catch(r){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var r;n.readyState===3&&((r=this.opts.cookieJar)===null||r===void 0||r.parseCookies(n)),n.readyState===4&&(n.status===200||n.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof n.status=="number"?n.status:0)},0))},he("xhr data %s",this.data),n.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},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=iu,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()}};mt.requestsCount=0;mt.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ia);else if(typeof addEventListener=="function"){let i="onpagehide"in Pe?"pagehide":"unload";addEventListener(i,ia,!1)}}function ia(){for(let i in mt.requests)mt.requests.hasOwnProperty(i)&&mt.requests[i].abort()}var Ch=G(Qa(),1),wh=G(or(),1),xh=G(Jt(),1),Ah=G(ps(),1),Nh=G(ys(),1),kh=G(Cs(),1),ac=G(ur(),1),Rh=G(oc(),1);var cc=ac.default;var Yi=cc,fr=!1,lc="nodebuffer",It=process.nextTick;var hc=G(Vt(),1);var Th=(0,hc.default)("engine.io-client:websocket"),uc=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",dr=class extends Qe{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,n=uc?{}:zn(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=fr&&!uc?t?new Yi(e,t):new Yi(e):new Yi(e,t,n)}catch(r){return this.emitReserved("error",r)}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 n=e[t],r=t===e.length-1;qi(n,this.supportsBinary,s=>{let o={};fr||(n.options&&(o.compress=n.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{fr?this.ws.send(s):this.ws.send(s,o)}catch(c){Th("websocket closed before onclose event")}r&&It(()=>{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]=Jn()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Yi}};var fc=G(Vt(),1),Ji=(0,fc.default)("engine.io-client:webtransport"),pr=class extends Qe{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Ji("transport closed gracefully"),this.onClose()}).catch(e=>{Ji("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Lo(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=Fo();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();let s=()=>{n.read().then(({done:c,value:u})=>{if(c){Ji("session is closed");return}Ji("received chunk: %o",u),this.onPacket(u),s()}).catch(c=>{Ji("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 n=e[t],r=t===e.length-1;this.writer.write(n).then(()=>{r&&It(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var xs={websocket:dr,webtransport:pr,polling:Xn};var Ih=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Oh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ii(i){let e=i,t=i.indexOf("["),n=i.indexOf("]");t!=-1&&n!=-1&&(i=i.substring(0,t)+i.substring(t,n).replace(/:/g,";")+i.substring(n,i.length));let r=Ih.exec(i||""),s={},o=14;for(;o--;)s[Oh[o]]=r[o]||"";return t!=-1&&n!=-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=Ph(s,s.path),s.queryKey=Fh(s,s.query),s}function Ph(i,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Fh(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,r,s){r&&(t[r]=s)}),t}var dc=G(Vt(),1);var B=(0,dc.default)("engine.io-client:socket"),Ot=class i extends L{constructor(e,t={}){super(),this.binaryType=lc,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=ii(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=ii(t.host).host),Xe(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=Vo(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=zr,t.transport=e,this.id&&(t.sid=this.id);let n=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",n),new xs[e](n)}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),n=!1;i.priorWebsocketSuccess=!1;let r=()=>{n||(B('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!n)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(()=>{n||this.readyState!=="closed"&&(B("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{B('probe transport "%s" failed',e);let m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function s(){n||(n=!0,l(),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 u(){o("socket closed")}function h(f){t&&f.name!==t.name&&(B('"%s" works - aborting "%s"',f.name,t.name),s())}let l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",c),this.off("close",u),this.off("upgrading",h)};t.once("open",r),t.once("error",o),t.once("close",c),this.once("close",u),this.once("upgrading",h),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||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 n=0;n<this.writeBuffer.length;n++){let r=this.writeBuffer[n].data;if(r&&(t+=Uo(r)),n>0&&t>this.maxPayload)return B("only send %d out of %d packets",n,this.writeBuffer.length),this.writeBuffer.slice(0,n);t+=2}return B("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if(typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let s={type:e,data:t,options:n};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),r&&this.once("flush",r),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()},n=()=>{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?n():e()}):this.upgrading?n():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=[],n=0,r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};Ot.protocol=zr;var ty=Ot.protocol;var bc=G(Xi(),1),vc=(0,bc.default)("socket.io-client:url");function Sc(i,e="",t){let n=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)||(vc("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),vc("parse %s",i),n=ii(i)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let s=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+s+":"+n.port+e,n.href=n.protocol+"://"+s+(t&&t.port===n.port?"":":"+n.port),n}var Ds={};tl(Ds,{Decoder:()=>Ls,Encoder:()=>Fs,PacketType:()=>k,isPacketValid:()=>kf,protocol:()=>Uc});var Jh=typeof ArrayBuffer=="function",Xh=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,_c=Object.prototype.toString,Qh=typeof Blob=="function"||typeof Blob!="undefined"&&_c.call(Blob)==="[object BlobConstructor]",Zh=typeof File=="function"||typeof File!="undefined"&&_c.call(File)==="[object FileConstructor]";function Zi(i){return Jh&&(i instanceof ArrayBuffer||Xh(i))||Qh&&i instanceof Blob||Zh&&i instanceof File}function Qi(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,n=i.length;t<n;t++)if(Qi(i[t]))return!0;return!1}if(Zi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Qi(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Qi(i[t]))return!0;return!1}function Ec(i){let e=[],t=i.data,n=i;return n.data=ks(t,e),n.attachments=e.length,{packet:n,buffers:e}}function ks(i,e){if(!i)return i;if(Zi(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 n=0;n<i.length;n++)t[n]=ks(i[n],e);return t}else if(typeof i=="object"&&!(i instanceof Date)){let t={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=ks(i[n],e));return t}return i}function Cc(i,e){return i.data=Rs(i.data,e),delete i.attachments,i}function Rs(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]=Rs(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=Rs(i[t],e));return i}var Fc=G(Pc(),1),Ps=(0,Fc.default)("socket.io-parser"),Lc=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Uc=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 Fs=class{constructor(e){this.replacer=e}encode(e){return Ps("encoding packet %j",e),(e.type===k.EVENT||e.type===k.ACK)&&Qi(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)),Ps("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Ec(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Ls=class i extends L{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}: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 n=t.type===k.BINARY_EVENT;n||t.type===k.BINARY_ACK?(t.type=n?k.EVENT:k.ACK,this.reconstructor=new Us(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Zi(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,n={type:Number(e.charAt(0))};if(k[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===k.BINARY_EVENT||n.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");let c=Number(o);if(!Dc(c)||c<0)throw new Error("Illegal attachments");if(c>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=c}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(s,t)}else n.nsp="/";let r=e.charAt(t+1);if(r!==""&&Number(r)==r){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}n.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(n.type,s))n.data=s;else throw new Error("invalid payload")}return Ps("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case k.CONNECT:return Cr(t);case k.DISCONNECT:return t===void 0;case k.CONNECT_ERROR:return typeof t=="string"||Cr(t);case k.EVENT:case k.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Lc.indexOf(t[0])===-1);case k.ACK:case k.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Us=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=Cc(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function xf(i){return typeof i=="string"}var Dc=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function Af(i){return i===void 0||Dc(i)}function Cr(i){return Object.prototype.toString.call(i)==="[object Object]"}function Nf(i,e){switch(i){case k.CONNECT:return e===void 0||Cr(e);case k.DISCONNECT:return e===void 0;case k.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Lc.indexOf(e[0])===-1);case k.ACK:return Array.isArray(e);case k.CONNECT_ERROR:return typeof e=="string"||Cr(e);default:return!1}}function kf(i){return xf(i.nsp)&&Af(i.id)&&Nf(i.type,i.data)}function ye(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Bc=G(Xi(),1),V=(0,Bc.default)("socket.io-client:socket"),Rf=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),oi=class extends L{constructor(e,t,n){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,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ye(e,"open",this.onopen.bind(this)),ye(e,"packet",this.onpacket.bind(this)),ye(e,"error",this.onerror.bind(this)),ye(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(Rf.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 n={type:k.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;V("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),n.id=o}let r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)?V("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n),this.flags={},this}_registerAckCallback(e,t){var n;let r=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(r===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&&(V("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));V("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))},r);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let n=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((r,s)=>{t.push((o,c)=>n?o?s(o):r(c):r(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...s)=>n!==this._queue[0]?void 0:(r!==null?n.tryCount>this._opts.retries&&(V("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(r)):(V("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...s)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(V("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){V("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,V("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(){V("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){V("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 n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){let t=e.data||[];V("emitting event %j",t),e.id!=null&&(V("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 n of t)n.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,n=!1;return function(...r){n||(n=!0,V("sending ack %j",r),t.packet({type:k.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(V("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):V("bad ack %s",e.id)}onconnect(e,t){V("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(){V("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&&(V("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 n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function Ft(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}Ft.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)==0?i-t:i+t}return Math.min(i,this.max)|0};Ft.prototype.reset=function(){this.attempts=0};Ft.prototype.setMin=function(i){this.ms=i};Ft.prototype.setMax=function(i){this.max=i};Ft.prototype.setJitter=function(i){this.jitter=i};var Mc=G(Xi(),1),oe=(0,Mc.default)("socket.io-client:manager"),ai=class extends L{constructor(e,t){var n;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,Xe(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((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new Ft({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let r=t.parser||Ds;this.encoder=new r.Encoder,this.decoder=new r.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(oe("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;oe("opening %s",this.uri),this.engine=new Ot(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let r=ye(t,"open",function(){n.onopen(),e&&e()}),s=c=>{oe("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=ye(t,"error",s);if(this._timeout!==!1){let c=this._timeout;oe("connect attempt will timeout after %d",c);let u=this.setTimeoutFn(()=>{oe("connect attempt timed out after %d",c),r(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){oe("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ye(e,"ping",this.onping.bind(this)),ye(e,"data",this.ondata.bind(this)),ye(e,"error",this.onerror.bind(this)),ye(e,"close",this.onclose.bind(this)),ye(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){It(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){oe("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new oi(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active){oe("socket %s is still active, skipping close",n);return}this._close()}_packet(e){oe("writing packet %j",e);let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){oe("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){oe("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){oe("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)oe("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();oe("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(oe("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(oe("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):(oe("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Wc=G(Xi(),1),qc=(0,Wc.default)("socket.io-client"),en={};function tn(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Sc(i,e.path||"/socket.io"),n=t.source,r=t.id,s=t.path,o=en[r]&&s in en[r].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,u;return c?(qc("ignoring socket cache for %s",n),u=new ai(n,e)):(en[r]||(qc("new io instance for %s",n),en[r]=new ai(n,e)),u=en[r]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(tn,{Manager:ai,Socket:oi,io:tn,connect:tn});var Tf="https://ws.novu.co",$c="notifications.notification_received",Kc="notifications.unseen_count_changed",zc="notifications.unread_count_changed",If=({_id:i,transactionId:e,content:t,read:n,seen:r,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:m,subscriber:d,subject:C,avatar:g,cta:b,tags:R,data:N,workflow:_,severity:E})=>{var $e,vt,ue,nt,rt,st,Ae,Ne;let M={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},T=(vt=($e=b.action)==null?void 0:$e.buttons)==null?void 0:vt.find(Ke=>Ke.type==="primary"),P=(nt=(ue=b.action)==null?void 0:ue.buttons)==null?void 0:nt.find(Ke=>Ke.type==="secondary"),$=(st=(rt=b.action)==null?void 0:rt.result)==null?void 0:st.type,ie=(Ae=b.action)==null?void 0:Ae.status;return x(y(y({id:i,transactionId:e,subject:C,body:t,to:M,isRead:n,isSeen:r,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:g,primaryAction:T&&{label:T.content,isCompleted:$==="primary"&&ie==="done",redirect:T.url?{target:T.target,url:T.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&ie==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:m,tags:R,redirect:(Ne=b.data)!=null&&Ne.url?{url:b.data.url,target:b.data.target}:void 0,data:N,workflow:_,severity:E})},ci,Le,ve,li,nn,xr,Ar,Nr,We,Gc,Bs,Ms,wr=class extends j{constructor({socketUrl:t,socketOptions:n,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,We);v(this,ci);v(this,Le);v(this,ve);v(this,li);v(this,nn);v(this,xr,({message:t})=>{a(this,Le).emit($c,{result:new U(If(t),a(this,Le),this._inboxService)})});v(this,Ar,({unseenCount:t})=>{a(this,Le).emit(Kc,{result:t})});v(this,Nr,({counts:t})=>{a(this,Le).emit(zc,{result:t})});S(this,Le,s),S(this,li,t!=null?t:Tf),S(this,nn,n)}onSessionSuccess({token:t}){S(this,ci,t)}isSocketEvent(t){return t===$c||t===Kc||t===zc}connect(){return p(this,null,function*(){return a(this,ci)?_e(this,We,Bs).call(this):this.callWithSession(_e(this,We,Bs).bind(this))})}disconnect(){return p(this,null,function*(){return a(this,ve)?_e(this,We,Ms).call(this):this.callWithSession(_e(this,We,Ms).bind(this))})}};ci=new WeakMap,Le=new WeakMap,ve=new WeakMap,li=new WeakMap,nn=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Nr=new WeakMap,We=new WeakSet,Gc=function(){return p(this,null,function*(){var n,r,s,o;if(a(this,ve))return;let t={socketUrl:a(this,li)};a(this,Le).emit("socket.connect.pending",{args:t}),S(this,ve,tn(a(this,li),y({reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,ci)}`}},(n=a(this,nn))!=null?n:{}))),a(this,ve).on("connect",()=>{a(this,Le).emit("socket.connect.resolved",{args:t})}),a(this,ve).on("connect_error",c=>{a(this,Le).emit("socket.connect.resolved",{args:t,error:c})}),(r=a(this,ve))==null||r.on("notification_received",a(this,xr)),(s=a(this,ve))==null||s.on("unseen_count_changed",a(this,Ar)),(o=a(this,ve))==null||o.on("unread_count_changed",a(this,Nr))})},Bs=function(){return p(this,null,function*(){try{return yield _e(this,We,Gc).call(this),{}}catch(t){return{error:new w("Failed to initialize the socket",t)}}})},Ms=function(){return p(this,null,function*(){var t;try{return(t=a(this,ve))==null||t.disconnect(),S(this,ve,void 0),{}}catch(n){return{error:new w("Failed to disconnect from the socket",n)}}})};var Of=["wss://eu.socket.novu.co",Di,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Pf={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Di,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"},Ff={cloud:"partysocket","self-hosted":"socket.io"};function Lf(i){return i?Pf[i]||i:Di}function Uf(i){return!i||Of.includes(i)}function Df(i,e){return e?Ff[e]:Uf(i)?"partysocket":"socket.io"}function Vc({socketUrl:i,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:n}){let r=Lf(i),u=e||{},{socketType:s}=u,o=ui(u,["socketType"]);switch(Df(r,s)){case"partysocket":return new Dn({socketUrl:r,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:n});case"socket.io":default:return new wr({socketUrl:r,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:n})}}var be,ae,Ue,rn,kr=class{constructor(e){v(this,be);v(this,ae);v(this,Ue);v(this,rn);var r,s,o;S(this,rn,e),S(this,Ue,new hn({apiUrl:e.apiUrl||e.backendUrl})),S(this,be,new fn);let t=vo({subscriberId:e.subscriberId,subscriber:e.subscriber}),n=Br(e.context);S(this,ae,new Pn({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Ue),a(this,be))),a(this,ae).initialize(),this.notifications=new An({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Ue),eventEmitterInstance:a(this,be)}),this.preferences=new On({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,Ue),eventEmitterInstance:a(this,be)}),this.subscriptions=new Pi({subscriber:t,contextKey:n,useCache:(o=e.useCache)!=null?o:!0,inboxServiceInstance:a(this,Ue),eventEmitterInstance:a(this,be)}),this.channelConnections=new hi({inboxServiceInstance:a(this,Ue),eventEmitterInstance:a(this,be)}),this.channelEndpoints=new fi({inboxServiceInstance:a(this,Ue),eventEmitterInstance:a(this,be)}),this.socket=Vc({socketUrl:e.socketUrl,socketOptions:e.socketOptions,eventEmitterInstance:a(this,be),inboxServiceInstance:a(this,Ue)}),this.on=(c,u)=>{this.socket.isSocketEvent(c)&&this.socket.connect();let h=a(this,be).on(c,u);return()=>{h()}},this.off=(c,u)=>{a(this,be).off(c,u)}}get applicationIdentifier(){return a(this,ae).applicationIdentifier}get subscriberId(){return a(this,ae).subscriberId}get context(){return a(this,ae).context}get options(){return a(this,rn)}get contextKey(){return Br(a(this,ae).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,ae).initialize({applicationIdentifier:a(this,ae).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,ae).context,contextHash:a(this,ae).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return p(this,null,function*(){let t=a(this,ae).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,ae).initialize({applicationIdentifier:a(this,ae).applicationIdentifier||"",subscriberHash:a(this,ae).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};be=new WeakMap,ae=new WeakMap,Ue=new WeakMap,rn=new WeakMap;window.Novu=kr;})();
42
42
  /*! Bundled license information:
43
43
 
44
44
  xmlhttprequest-ssl/lib/XMLHttpRequest.js: